? backends/PalmOS/Src/midi
RCS file: /cvsroot/scummvm/scummvm/graphics/font.cpp,v
retrieving revision 1.4
diff -u -r1.4 font.cpp
|
|
|
20 | 20 | |
21 | 21 | #include "common/stdafx.h" |
22 | 22 | #include "graphics/font.h" |
| 23 | #include "gui/newgui.h" |
23 | 24 | |
24 | 25 | namespace Graphics { |
25 | 26 | |
… |
… |
|
36 | 37 | return desc.width[chr - desc.firstchar]; |
37 | 38 | } |
38 | 39 | |
39 | | void NewFont::drawChar(const Surface *dst, byte chr, int tx, int ty, uint32 color) const { |
| 40 | void NewFont::drawChar(const Surface *dst, byte chr, int tx, int ty, uint32 color, bool scale) const { |
40 | 41 | assert(dst != 0); |
| 42 | const int scaleFactor = scale ? g_gui.getScaleFactor() : 1; |
| 43 | tx *= scaleFactor; ty *= scaleFactor; |
| 44 | |
41 | 45 | byte *ptr = (byte *)dst->getBasePtr(tx, ty); |
42 | 46 | |
43 | 47 | assert(desc.bits != 0 && desc.maxwidth <= 16); |
… |
… |
|
54 | 58 | chr -= desc.firstchar; |
55 | 59 | const bitmap_t *tmp = desc.bits + (desc.offset ? desc.offset[chr] : (chr * desc.height)); |
56 | 60 | |
57 | | for (int y = 0; y < desc.height; y++, ptr += dst->pitch) { |
58 | | const bitmap_t buffer = *tmp++; |
| 61 | for (int y = 0; y < desc.height * scaleFactor; y++, ptr += dst->pitch) { |
| 62 | const bitmap_t *buffer = 0; |
| 63 | if(scaleFactor != 1) { |
| 64 | if(!(y % 2)) |
| 65 | buffer = tmp++; |
| 66 | else |
| 67 | buffer = tmp; |
| 68 | } else |
| 69 | buffer = tmp++; |
59 | 70 | bitmap_t mask = 0x8000; |
60 | 71 | if (ty + y < 0 || ty + y >= dst->h) |
61 | 72 | continue; |
62 | | |
63 | | for (int x = 0; x < w; x++, mask >>= 1) { |
| 73 | |
| 74 | for (int x = 0; x < w * scaleFactor; x++) { |
| 75 | if(scaleFactor != 1) { |
| 76 | if(!(x % 2) && x != 0) |
| 77 | mask >>= 1; |
| 78 | } else if(x != 0) { |
| 79 | mask >>= 1; |
| 80 | } |
| 81 | |
64 | 82 | if (tx + x < 0 || tx + x >= dst->w) |
65 | 83 | continue; |
66 | | if ((buffer & mask) != 0) { |
| 84 | if ((*buffer & mask) != 0) { |
67 | 85 | if (dst->bytesPerPixel == 1) |
68 | 86 | ptr[x] = color; |
69 | 87 | else if (dst->bytesPerPixel == 2) |
… |
… |
|
85 | 103 | return space; |
86 | 104 | } |
87 | 105 | |
88 | | void Font::drawString(const Surface *dst, const Common::String &s, int x, int y, int w, uint32 color, TextAlignment align, int deltax, bool useEllipsis) const { |
| 106 | void Font::drawString(const Surface *dst, const Common::String &s, int x, int y, int w, uint32 color, TextAlignment align, int deltax, bool useEllipsis, bool scale) const { |
89 | 107 | assert(dst != 0); |
90 | 108 | const int leftX = x, rightX = x + w; |
91 | 109 | uint i; |
92 | 110 | int width = getStringWidth(s); |
93 | 111 | Common::String str; |
94 | | |
| 112 | |
95 | 113 | if (useEllipsis && width > w) { |
96 | 114 | // String is too wide. So we shorten it "intellegently", by replacing |
97 | 115 | // parts of it by an ellipsis ("..."). There are three possibilities |
… |
… |
|
100 | 118 | // make this configurable, replacing the middle probably is a good |
101 | 119 | // compromise. |
102 | 120 | const int ellipsisWidth = getStringWidth("..."); |
103 | | |
| 121 | |
104 | 122 | // SLOW algorithm to remove enough of the middle. But it is good enough |
105 | 123 | // for now. |
106 | 124 | const int halfWidth = (w - ellipsisWidth) / 2; |
107 | 125 | int w2 = 0; |
108 | | |
| 126 | |
109 | 127 | for (i = 0; i < s.size(); ++i) { |
110 | 128 | int charWidth = getCharWidth(s[i]); |
111 | 129 | if (w2 + charWidth > halfWidth) |
… |
… |
|
116 | 134 | // At this point we know that the first 'i' chars are together 'w2' |
117 | 135 | // pixels wide. We took the first i-1, and add "..." to them. |
118 | 136 | str += "..."; |
119 | | |
| 137 | |
120 | 138 | // The original string is width wide. Of those we already skipped past |
121 | 139 | // w2 pixels, which means (width - w2) remain. |
122 | 140 | // The new str is (w2+ellipsisWidth) wide, so we can accomodate about |
… |
… |
|
150 | 168 | if (x+w > rightX) |
151 | 169 | break; |
152 | 170 | if (x >= leftX) |
153 | | drawChar(dst, str[i], x, y, color); |
| 171 | drawChar(dst, str[i], x, y, color, scale); |
154 | 172 | x += w; |
155 | 173 | } |
156 | 174 | } |
RCS file: /cvsroot/scummvm/scummvm/graphics/font.h,v
retrieving revision 1.3
diff -u -r1.3 font.h
|
|
|
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Instances of this class represent a distinct font, with a built-in renderer. |
38 | | * @todo Maybe move the high-level methods (drawString etc.) to a separate |
| 38 | * @todo Maybe move the high-level methods (drawString etc.) to a separate |
39 | 39 | * FontRenderer class? That way, we could have different variants... ? |
40 | 40 | * @todo Add more parameters to drawString, or additional similar methods, |
41 | 41 | * featuring abilities like |
… |
… |
|
52 | 52 | virtual int getMaxCharWidth() const = 0; |
53 | 53 | |
54 | 54 | virtual int getCharWidth(byte chr) const = 0; |
55 | | virtual void drawChar(const Surface *dst, byte chr, int x, int y, uint32 color) const = 0; |
| 55 | virtual void drawChar(const Surface *dst, byte chr, int x, int y, uint32 color, bool scale = false) const = 0; |
56 | 56 | |
57 | | void drawString(const Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlignment align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; |
| 57 | void drawString(const Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlignment align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true, bool scale = false) const; |
58 | 58 | int getStringWidth(const Common::String &str) const; |
59 | 59 | }; |
60 | 60 | |
… |
… |
|
65 | 65 | virtual int getMaxCharWidth() const { return 8; }; |
66 | 66 | |
67 | 67 | virtual int getCharWidth(byte chr) const; |
68 | | virtual void drawChar(const Surface *dst, byte chr, int x, int y, uint32 color) const; |
| 68 | virtual void drawChar(const Surface *dst, byte chr, int x, int y, uint32 color, bool scale) const; |
69 | 69 | }; |
70 | 70 | |
71 | 71 | extern const ScummFont g_scummfont; |
… |
… |
|
96 | 96 | |
97 | 97 | public: |
98 | 98 | NewFont(const FontDesc &d) : desc(d) {} |
99 | | |
| 99 | |
100 | 100 | virtual int getFontHeight() const { return desc.height; } |
101 | 101 | virtual int getMaxCharWidth() const { return desc.maxwidth; }; |
102 | 102 | |
103 | 103 | virtual int getCharWidth(byte chr) const; |
104 | | virtual void drawChar(const Surface *dst, byte chr, int x, int y, uint32 color) const; |
| 104 | virtual void drawChar(const Surface *dst, byte chr, int x, int y, uint32 color, bool scale) const; |
105 | 105 | }; |
106 | 106 | |
107 | 107 | extern const NewFont g_sysfont; |
RCS file: /cvsroot/scummvm/scummvm/graphics/scummfont.cpp,v
retrieving revision 1.4
diff -u -r1.4 scummfont.cpp
|
|
|
20 | 20 | |
21 | 21 | #include "stdafx.h" |
22 | 22 | #include "graphics/font.h" |
| 23 | #include "gui/newgui.h" |
23 | 24 | |
24 | 25 | namespace Graphics { |
25 | 26 | |
… |
… |
|
62 | 63 | } |
63 | 64 | |
64 | 65 | //void ScummFont::drawChar(byte chr, int xx, int yy, OverlayColor color) { |
65 | | void ScummFont::drawChar(const Surface *dst, byte chr, int tx, int ty, uint32 color) const { |
| 66 | void ScummFont::drawChar(const Surface *dst, byte chr, int tx, int ty, uint32 color, bool scale) const { |
66 | 67 | assert(dst != 0); |
| 68 | const int scaleFactor = scale ? g_gui.getScaleFactor() : 1; |
| 69 | tx *= scaleFactor; ty *= scaleFactor; |
| 70 | |
67 | 71 | byte *ptr = (byte *)dst->getBasePtr(tx, ty); |
68 | 72 | |
69 | 73 | const byte *tmp = guifont + 6 + guifont[4] + chr * 8; |
70 | 74 | uint buffer = 0; |
71 | 75 | uint mask = 0; |
72 | 76 | |
73 | | for (int y = 0; y < 8; y++) { |
| 77 | for (int y = 0; y < 8 * scaleFactor; y++) { |
74 | 78 | if (ty + y < 0 || ty + y >= dst->h) |
75 | 79 | continue; |
76 | | for (int x = 0; x < 8; x++) { |
| 80 | for (int x = 0; x < 8 * scaleFactor; x++) { |
| 81 | if(scaleFactor != 1 && !(x % 2)) |
| 82 | mask >>= 1; |
| 83 | else if(scaleFactor == 1) |
| 84 | mask >>= 1; |
| 85 | |
77 | 86 | if (tx + x < 0 || tx + x >= dst->w) |
78 | 87 | continue; |
79 | 88 | unsigned char c; |
80 | | mask >>= 1; |
| 89 | |
81 | 90 | if (mask == 0) { |
82 | | buffer = *tmp++; |
| 91 | if(scaleFactor != 1 && !(y % 2)) |
| 92 | buffer = *tmp++; |
| 93 | else if(scaleFactor == 1) |
| 94 | buffer = *tmp++; |
| 95 | |
83 | 96 | mask = 0x80; |
84 | 97 | } |
85 | 98 | c = ((buffer & mask) != 0); |
RCS file: /cvsroot/scummvm/scummvm/gui/console.cpp,v
retrieving revision 1.53
diff -u -r1.53 console.cpp
|
|
|
49 | 49 | * - a *lot* of others things, this code is in no way complete and heavily under progress |
50 | 50 | */ |
51 | 51 | ConsoleDialog::ConsoleDialog(float widthPercent, float heightPercent) |
52 | | : Dialog(0, 0, 1, 1), |
| 52 | : Dialog(0, 0, 1, 1), |
53 | 53 | _widthPercent(widthPercent), _heightPercent(heightPercent) { |
54 | | |
| 54 | |
55 | 55 | // Setup basic layout/dialog size |
56 | 56 | reflowLayout(); |
57 | 57 | |
… |
… |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | void ConsoleDialog::open() { |
| 114 | // disable scaling because the console is using non fixed positions |
| 115 | g_gui.enableScaling(false); |
| 116 | |
114 | 117 | // Initiate sliding the console down. We do a very simple trick to achieve |
115 | 118 | // this effect: we simply move the console dialog just above (outside) the |
116 | 119 | // visible screen area, then shift it down in handleTickle() over a |
117 | | // certain period of time. |
| 120 | // certain period of time. |
118 | 121 | _y = -_h; |
119 | 122 | _slideTime = g_system->getMillis(); |
120 | 123 | _slideMode = kDownSlideMode; |
… |
… |
|
165 | 168 | _caretTime = time + kCaretBlinkTime; |
166 | 169 | drawCaret(_caretVisible); |
167 | 170 | } |
168 | | |
| 171 | |
169 | 172 | // Perform the "slide animation". |
170 | 173 | if (_slideMode != kNoSlideMode) { |
171 | 174 | const float tmp = (float)(g_system->getMillis() - _slideTime) / kConsoleSlideDownDuration; |
… |
… |
|
174 | 177 | } else { |
175 | 178 | _y = (int)(_h * (tmp - 1.0)); |
176 | 179 | } |
177 | | |
| 180 | |
178 | 181 | if (_slideMode == kDownSlideMode && _y > 0) { |
179 | 182 | // End the slide |
180 | 183 | _slideMode = kNoSlideMode; |
… |
… |
|
195 | 198 | |
196 | 199 | void ConsoleDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) { |
197 | 200 | int i; |
198 | | |
| 201 | |
199 | 202 | if (_slideMode != kNoSlideMode) |
200 | 203 | return; |
201 | 204 | |
… |
… |
|
204 | 207 | case '\r': { |
205 | 208 | if (_caretVisible) |
206 | 209 | drawCaret(true); |
207 | | |
| 210 | |
208 | 211 | nextLine(); |
209 | 212 | |
210 | 213 | assert(_promptEndPos >= _promptStartPos); |
… |
… |
|
217 | 220 | // We have to allocate the string buffer with new, since VC++ sadly does not |
218 | 221 | // comply to the C++ standard, so we can't use a dynamic sized stack array. |
219 | 222 | char *str = new char[len + 1]; |
220 | | |
| 223 | |
221 | 224 | // Copy the user input to str |
222 | 225 | for (i = 0; i < len; i++) |
223 | 226 | str[i] = buffer(_promptStartPos + i); |
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.cpp,v
retrieving revision 1.46
diff -u -r1.46 dialog.cpp
|
|
|
29 | 29 | |
30 | 30 | /* |
31 | 31 | * TODO list |
32 | | * - add some sense of the window being "active" (i.e. in front) or not. If it |
| 32 | * - add some sense of the window being "active" (i.e. in front) or not. If it |
33 | 33 | * was inactive and just became active, reset certain vars (like who is focused). |
34 | 34 | * Maybe we should just add lostFocus and receivedFocus methods to Dialog, just |
35 | 35 | * like we have for class Widget? |
… |
… |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | void Dialog::drawDialog() { |
101 | | |
| 101 | |
102 | 102 | if (!isVisible()) |
103 | 103 | return; |
104 | 104 | |
… |
… |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | void Dialog::handleMouseDown(int x, int y, int button, int clickCount) { |
| 120 | x /= g_gui.getScaleFactor(); y /= g_gui.getScaleFactor(); |
| 121 | |
120 | 122 | Widget *w; |
| 123 | |
121 | 124 | w = findWidget(x, y); |
122 | | |
| 125 | |
123 | 126 | _dragWidget = w; |
124 | 127 | |
125 | 128 | // If the click occured inside a widget which is not the currently |
… |
… |
|
141 | 144 | } |
142 | 145 | |
143 | 146 | void Dialog::handleMouseUp(int x, int y, int button, int clickCount) { |
| 147 | x /= g_gui.getScaleFactor(); y /= g_gui.getScaleFactor(); |
| 148 | |
144 | 149 | Widget *w; |
145 | 150 | |
146 | 151 | if (_focusedWidget) { |
147 | 152 | //w = _focusedWidget; |
148 | | |
| 153 | |
149 | 154 | // Lose focus on mouseup unless the widget requested to retain the focus |
150 | 155 | if (! (_focusedWidget->getFlags() & WIDGET_RETAIN_FOCUS )) { |
151 | 156 | releaseFocus(); |
… |
… |
|
161 | 166 | } |
162 | 167 | |
163 | 168 | void Dialog::handleMouseWheel(int x, int y, int direction) { |
| 169 | x /= g_gui.getScaleFactor(); y /= g_gui.getScaleFactor(); |
| 170 | |
164 | 171 | Widget *w; |
165 | 172 | |
166 | 173 | // This may look a bit backwards, but I think it makes more sense for |
… |
… |
|
212 | 219 | } |
213 | 220 | |
214 | 221 | void Dialog::handleMouseMoved(int x, int y, int button) { |
| 222 | x /= g_gui.getScaleFactor(); y /= g_gui.getScaleFactor(); |
| 223 | |
215 | 224 | Widget *w; |
216 | | |
| 225 | |
217 | 226 | //if (!button) |
218 | 227 | // _dragWidget = 0; |
219 | | |
| 228 | |
220 | 229 | if (_focusedWidget && !_dragWidget) { |
221 | 230 | w = _focusedWidget; |
222 | 231 | int wx = w->getAbsX() - _x; |
223 | 232 | int wy = w->getAbsY() - _y; |
224 | | |
| 233 | |
225 | 234 | // We still send mouseEntered/Left messages to the focused item |
226 | 235 | // (but to no other items). |
227 | 236 | bool mouseInFocusedWidget = (x >= wx && x < wx + w->_w && y >= wy && y < wy + w->_h); |
… |
… |
|
237 | 246 | |
238 | 247 | w->handleMouseMoved(x - wx, y - wy, button); |
239 | 248 | } |
240 | | |
| 249 | |
241 | 250 | // While a "drag" is in process (i.e. mouse is moved while a button is pressed), |
242 | 251 | // only deal with the widget in which the click originated. |
243 | 252 | if (_dragWidget) |
… |
… |
|
251 | 260 | if (w) |
252 | 261 | w->handleMouseEntered(button); |
253 | 262 | _mouseWidget = w; |
254 | | } |
| 263 | } |
255 | 264 | |
256 | 265 | if (w && (w->getFlags() & WIDGET_TRACK_MOUSE)) { |
257 | 266 | w->handleMouseMoved(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button); |
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.cpp,v
retrieving revision 1.94
diff -u -r1.94 newgui.cpp
|
|
|
41 | 41 | * - allow multi line (l/c/r aligned) text via StaticTextWidget ? |
42 | 42 | * - add "close" widget to all dialogs (with a flag to turn it off) ? |
43 | 43 | * - make dialogs "moveable" ? |
44 | | * - come up with a new look & feel / theme for the GUI |
| 44 | * - come up with a new look & feel / theme for the GUI |
45 | 45 | * - ... |
46 | 46 | */ |
47 | 47 | |
… |
… |
|
54 | 54 | |
55 | 55 | |
56 | 56 | // Constructor |
57 | | NewGui::NewGui() : _needRedraw(false), |
| 57 | NewGui::NewGui() : _scaleEnable(true), _needRedraw(false), |
58 | 58 | _stateIsSaved(false), _cursorAnimateCounter(0), _cursorAnimateTimer(0) { |
59 | | |
| 59 | |
60 | 60 | _system = &OSystem::instance(); |
61 | 61 | |
62 | 62 | // Clear the cursor |
… |
… |
|
64 | 64 | |
65 | 65 | // Reset key repeat |
66 | 66 | _currentKeyDown.keycode = 0; |
| 67 | |
| 68 | // updates the scaling factor |
| 69 | updateScaleFactor(); |
67 | 70 | } |
68 | 71 | |
69 | 72 | void NewGui::updateColors() { |
… |
… |
|
75 | 78 | _textcolorhi = _system->RGBToColor(0, 255, 0); |
76 | 79 | } |
77 | 80 | |
| 81 | void NewGui::updateScaleFactor() { |
| 82 | if(!_scaleEnable) { |
| 83 | _scaleFactor = 1; |
| 84 | return; |
| 85 | } |
| 86 | |
| 87 | const int16 stdGuiWidth = 320; |
| 88 | const int16 stdGuiHeight = 200; |
| 89 | |
| 90 | _scaleFactor = _system->getWidth() / stdGuiWidth; |
| 91 | _scaleFactor = MIN(_scaleFactor, _system->getHeight() / stdGuiHeight); |
| 92 | } |
| 93 | |
78 | 94 | void NewGui::runLoop() { |
79 | 95 | Dialog *activeDialog = _dialogStack.top(); |
80 | 96 | bool didSaveState = false; |
81 | 97 | |
82 | 98 | if (activeDialog == 0) |
83 | 99 | return; |
84 | | |
| 100 | |
85 | 101 | // Setup some default GUI colors. Normally this will be done whenever an |
86 | 102 | // EVENT_SCREEN_CHANGED is received. However, not yet all backends support |
87 | 103 | // that event, so we also do it "manually" whenever a run loop is entered. |
88 | 104 | updateColors(); |
| 105 | updateScaleFactor(); |
89 | 106 | |
90 | 107 | if (!_stateIsSaved) { |
91 | 108 | saveState(); |
… |
… |
|
106 | 123 | } |
107 | 124 | |
108 | 125 | animateCursor(); |
109 | | _system->updateScreen(); |
| 126 | _system->updateScreen(); |
110 | 127 | |
111 | 128 | OSystem::Event event; |
112 | 129 | uint32 time = _system->getMillis(); |
… |
… |
|
131 | 148 | _currentKeyDown.keycode = 0; |
132 | 149 | break; |
133 | 150 | case OSystem::EVENT_MOUSEMOVE: |
134 | | activeDialog->handleMouseMoved(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, 0); |
| 151 | activeDialog->handleMouseMoved(event.mouse.x - (activeDialog->_x * _scaleFactor), event.mouse.y - (activeDialog->_y * _scaleFactor), 0); |
135 | 152 | break; |
136 | 153 | // We don't distinguish between mousebuttons (for now at least) |
137 | 154 | case OSystem::EVENT_LBUTTONDOWN: |
… |
… |
|
146 | 163 | _lastClick.count = 1; |
147 | 164 | } |
148 | 165 | _lastClick.time = time; |
149 | | activeDialog->handleMouseDown(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, 1, _lastClick.count); |
| 166 | activeDialog->handleMouseDown(event.mouse.x - (activeDialog->_x * _scaleFactor), event.mouse.y - (activeDialog->_y * _scaleFactor), 1, _lastClick.count); |
150 | 167 | break; |
151 | 168 | case OSystem::EVENT_LBUTTONUP: |
152 | 169 | case OSystem::EVENT_RBUTTONUP: |
153 | | activeDialog->handleMouseUp(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, 1, _lastClick.count); |
| 170 | activeDialog->handleMouseUp(event.mouse.x - (activeDialog->_x * _scaleFactor), event.mouse.y - (activeDialog->_y * _scaleFactor), 1, _lastClick.count); |
154 | 171 | break; |
155 | 172 | case OSystem::EVENT_WHEELUP: |
156 | | activeDialog->handleMouseWheel(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, -1); |
| 173 | activeDialog->handleMouseWheel(event.mouse.x - (activeDialog->_x * _scaleFactor), event.mouse.y - (activeDialog->_y * _scaleFactor), -1); |
157 | 174 | break; |
158 | 175 | case OSystem::EVENT_WHEELDOWN: |
159 | | activeDialog->handleMouseWheel(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, 1); |
| 176 | activeDialog->handleMouseWheel(event.mouse.x - (activeDialog->_x * _scaleFactor), event.mouse.y - (activeDialog->_y * _scaleFactor), 1); |
160 | 177 | break; |
161 | 178 | case OSystem::EVENT_QUIT: |
162 | 179 | _system->quit(); |
163 | 180 | return; |
164 | 181 | case OSystem::EVENT_SCREEN_CHANGED: |
165 | 182 | updateColors(); |
| 183 | updateScaleFactor(); |
166 | 184 | activeDialog->handleScreenChanged(); |
167 | 185 | break; |
168 | 186 | } |
… |
… |
|
180 | 198 | // Delay for a moment |
181 | 199 | _system->delayMillis(10); |
182 | 200 | } |
183 | | |
| 201 | |
184 | 202 | if (didSaveState) |
185 | 203 | restoreState(); |
186 | 204 | } |
… |
… |
|
212 | 230 | _lastClick.count = 0; |
213 | 231 | |
214 | 232 | _stateIsSaved = true; |
| 233 | _scaleEnable = true; |
215 | 234 | } |
216 | 235 | |
217 | 236 | void NewGui::restoreState() { |
… |
… |
|
224 | 243 | } |
225 | 244 | |
226 | 245 | _system->updateScreen(); |
227 | | |
| 246 | |
228 | 247 | _stateIsSaved = false; |
229 | 248 | } |
230 | 249 | |
… |
… |
|
270 | 289 | } |
271 | 290 | |
272 | 291 | void NewGui::hLine(int x, int y, int x2, OverlayColor color) { |
273 | | _screen.hLine(x, y, x2, color); |
| 292 | _screen.hLine(x * _scaleFactor, y * _scaleFactor, x2 * _scaleFactor, color); |
274 | 293 | } |
275 | 294 | |
276 | 295 | void NewGui::vLine(int x, int y, int y2, OverlayColor color) { |
277 | | _screen.vLine(x, y, y2, color); |
| 296 | _screen.vLine(x * _scaleFactor, y * _scaleFactor, y2 * _scaleFactor, color); |
278 | 297 | } |
279 | 298 | |
280 | 299 | void NewGui::blendRect(int x, int y, int w, int h, OverlayColor color, int level) { |
281 | 300 | #ifdef NEWGUI_256 |
282 | 301 | fillRect(x, y, w, h, color); |
283 | 302 | #else |
284 | | Common::Rect rect(x, y, x + w, y + h); |
| 303 | Common::Rect rect(x * _scaleFactor, y * _scaleFactor, (x + w) * _scaleFactor, (y + h) * _scaleFactor); |
285 | 304 | rect.clip(_screen.w, _screen.h); |
286 | | |
| 305 | |
287 | 306 | if (!rect.isValidRect()) |
288 | 307 | return; |
289 | 308 | |
… |
… |
|
311 | 330 | } |
312 | 331 | |
313 | 332 | void NewGui::fillRect(int x, int y, int w, int h, OverlayColor color) { |
314 | | _screen.fillRect(Common::Rect(x, y, x+w, y+h), color); |
| 333 | _screen.fillRect(Common::Rect(x * _scaleFactor, y * _scaleFactor, (x+w) * _scaleFactor, (y+h) * _scaleFactor), color); |
315 | 334 | } |
316 | 335 | |
317 | 336 | void NewGui::frameRect(int x, int y, int w, int h, OverlayColor color) { |
318 | | _screen.frameRect(Common::Rect(x, y, x+w, y+h), color); |
| 337 | _screen.frameRect(Common::Rect(x * _scaleFactor, y * _scaleFactor, (x+w) * _scaleFactor, (y+h) * _scaleFactor), color); |
319 | 338 | } |
320 | 339 | |
321 | 340 | void NewGui::addDirtyRect(int x, int y, int w, int h) { |
322 | | Common::Rect rect(x, y, x + w, y + h); |
| 341 | Common::Rect rect(x * _scaleFactor, y * _scaleFactor, (x + w) * _scaleFactor, (y + h) * _scaleFactor); |
323 | 342 | rect.clip(_screen.w, _screen.h); |
324 | | |
| 343 | |
325 | 344 | if (!rect.isValidRect()) |
326 | 345 | return; |
327 | 346 | |
… |
… |
|
335 | 354 | void NewGui::drawChar(byte chr, int xx, int yy, OverlayColor color, const Graphics::Font *font) { |
336 | 355 | if (font == 0) |
337 | 356 | font = &getFont(); |
338 | | font->drawChar(&_screen, chr, xx, yy, color); |
| 357 | font->drawChar(&_screen, chr, xx, yy, color, _scaleEnable); |
339 | 358 | } |
340 | 359 | |
341 | 360 | int NewGui::getStringWidth(const String &str) { |
… |
… |
|
347 | 366 | } |
348 | 367 | |
349 | 368 | void NewGui::drawString(const String &s, int x, int y, int w, OverlayColor color, TextAlignment align, int deltax, bool useEllipsis) { |
350 | | getFont().drawString(&_screen, s, x, y, w, color, align, deltax, useEllipsis); |
| 369 | getFont().drawString(&_screen, s, x, y, w, color, align, deltax, useEllipsis, _scaleEnable); |
351 | 370 | } |
352 | 371 | |
353 | 372 | // |
354 | 373 | // Draw an 8x8 bitmap at location (x,y) |
355 | 374 | // |
356 | 375 | void NewGui::drawBitmap(uint32 *bitmap, int tx, int ty, OverlayColor color, int h) { |
| 376 | tx *= _scaleFactor; ty *= _scaleFactor; |
| 377 | h *= _scaleFactor; |
357 | 378 | OverlayColor *ptr = getBasePtr(tx, ty); |
358 | 379 | |
359 | 380 | for (int y = 0; y < h; y++, ptr += _screenPitch) { |
360 | 381 | uint32 mask = 0xF0000000; |
361 | 382 | if (ty + y < 0 || ty + y >= _screen.h) |
362 | 383 | continue; |
363 | | for (int x = 0; x < 8; x++, mask >>= 4) { |
| 384 | for (int x = 0; x < 8 * _scaleFactor; x++) { |
| 385 | if(!(x % 2) && _scaleFactor != 1 && x != 0) |
| 386 | mask >>= 4; |
| 387 | else if(_scaleFactor == 1) |
| 388 | mask >>= 4; |
| 389 | |
364 | 390 | if (tx + x < 0 || tx + x >= _screen.w) |
365 | 391 | continue; |
366 | | if (bitmap[y] & mask) |
367 | | ptr[x] = color; |
| 392 | if (bitmap[y / _scaleFactor] & mask) |
| 393 | ptr[x] = color; |
368 | 394 | } |
369 | 395 | } |
370 | 396 | } |
… |
… |
|
374 | 400 | // We could plug in a different cursor here if we like to. |
375 | 401 | // |
376 | 402 | void NewGui::animateCursor() { |
377 | | int time = _system->getMillis(); |
| 403 | int time = _system->getMillis(); |
378 | 404 | if (time > _cursorAnimateTimer + kCursorAnimateDelay) { |
379 | 405 | const byte colors[4] = { 15, 15, 7, 8 }; |
380 | 406 | const byte color = colors[_cursorAnimateCounter]; |
381 | 407 | int i; |
382 | | |
| 408 | |
383 | 409 | for (i = 0; i < 15; i++) { |
384 | 410 | if ((i < 6) || (i > 8)) { |
385 | 411 | _cursor[16 * 7 + i] = color; |
386 | 412 | _cursor[16 * i + 7] = color; |
387 | 413 | } |
388 | 414 | } |
389 | | |
| 415 | |
390 | 416 | _system->setMouseCursor(_cursor, 16, 16, 7, 7); |
391 | 417 | |
392 | 418 | _cursorAnimateTimer = time; |
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.h,v
retrieving revision 1.49
diff -u -r1.49 newgui.h
|
|
|
52 | 52 | |
53 | 53 | /** |
54 | 54 | * GUI manager singleton. |
55 | | */ |
| 55 | */ |
56 | 56 | class NewGui : public Common::Singleton<NewGui> { |
57 | 57 | typedef Common::String String; |
58 | 58 | friend class Dialog; |
… |
… |
|
66 | 66 | |
67 | 67 | bool isActive() { return ! _dialogStack.empty(); } |
68 | 68 | |
| 69 | int getScaleFactor() { return _scaleFactor; } |
| 70 | void enableScaling(bool enable) { _scaleEnable = enable; updateScaleFactor(); } |
| 71 | |
69 | 72 | protected: |
70 | | OSystem *_system; |
71 | | Graphics::Surface _screen; |
| 73 | OSystem *_system; |
| 74 | Graphics::Surface _screen; |
72 | 75 | int _screenPitch; |
73 | | |
| 76 | |
| 77 | int _scaleFactor; |
| 78 | bool _scaleEnable; |
| 79 | |
74 | 80 | bool _needRedraw; |
75 | 81 | DialogStack _dialogStack; |
76 | | |
| 82 | |
77 | 83 | bool _stateIsSaved; |
78 | | |
| 84 | |
79 | 85 | // for continuous events (keyDown) |
80 | 86 | struct { |
81 | 87 | uint16 ascii; |
… |
… |
|
83 | 89 | int keycode; |
84 | 90 | } _currentKeyDown; |
85 | 91 | uint32 _keyRepeatTime; |
86 | | |
| 92 | |
87 | 93 | // position and time of last mouse click (used to detect double clicks) |
88 | 94 | struct { |
89 | 95 | int16 x, y; // Position of mouse when the click occured |
90 | 96 | uint32 time; // Time |
91 | 97 | int count; // How often was it already pressed? |
92 | 98 | } _lastClick; |
93 | | |
| 99 | |
94 | 100 | // mouse cursor state |
95 | 101 | bool _oldCursorMode; |
96 | | int _cursorAnimateCounter; |
97 | | int _cursorAnimateTimer; |
| 102 | int _cursorAnimateCounter; |
| 103 | int _cursorAnimateTimer; |
98 | 104 | byte _cursor[2048]; |
99 | 105 | |
100 | 106 | void saveState(); |
101 | 107 | void restoreState(); |
102 | | |
| 108 | |
103 | 109 | void openDialog(Dialog *dialog); |
104 | 110 | void closeTopDialog(); |
105 | | |
| 111 | |
106 | 112 | void loop(); |
107 | 113 | |
108 | 114 | void animateCursor(); |
109 | 115 | void updateColors(); |
| 116 | void updateScaleFactor(); |
110 | 117 | |
111 | 118 | OverlayColor *getBasePtr(int x, int y); |
112 | 119 | |
… |
… |
|
116 | 123 | OverlayColor _bgcolor; |
117 | 124 | OverlayColor _textcolor; |
118 | 125 | OverlayColor _textcolorhi; |
119 | | |
| 126 | |
120 | 127 | // Font |
121 | 128 | const Graphics::Font &getFont() const; |
122 | 129 | |