diff -u --rec -N --exclude=CVS --exclude=.deps --exclude=*.o scummvm.old/graphics/font.cpp scummvm/graphics/font.cpp
old
|
new
|
|
37 | 37 | return desc.width[chr - desc.firstchar]; |
38 | 38 | } |
39 | 39 | |
40 | | 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 { |
41 | 41 | assert(dst != 0); |
42 | | const int scaleFactorWidth = g_gui.getScaleFactorWidth(), scaleFactorHeight = g_gui.getScaleFactorHeight(); |
| 42 | const int scaleFactorWidth = scale ? g_gui.getScaleFactorWidth() : 1, scaleFactorHeight = scale ? g_gui.getScaleFactorHeight() : 1; |
43 | 43 | tx *= scaleFactorWidth; ty *= scaleFactorHeight; |
44 | 44 | |
45 | 45 | byte *ptr = (byte *)dst->getBasePtr(tx, ty); |
… |
… |
|
102 | 102 | return space; |
103 | 103 | } |
104 | 104 | |
105 | | 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 { |
| 105 | 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 { |
106 | 106 | assert(dst != 0); |
107 | 107 | const int leftX = x, rightX = x + w; |
108 | 108 | uint i; |
… |
… |
|
167 | 167 | if (x+w > rightX) |
168 | 168 | break; |
169 | 169 | if (x >= leftX) |
170 | | drawChar(dst, str[i], x, y, color); |
| 170 | drawChar(dst, str[i], x, y, color, scale); |
171 | 171 | x += w; |
172 | 172 | } |
173 | 173 | } |
diff -u --rec -N --exclude=CVS --exclude=.deps --exclude=*.o scummvm.old/graphics/font.h scummvm/graphics/font.h
old
|
new
|
|
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; |
Binary files scummvm.old/graphics/libgraphics.a and scummvm/graphics/libgraphics.a differ
diff -u --rec -N --exclude=CVS --exclude=.deps --exclude=*.o scummvm.old/graphics/scummfont.cpp scummvm/graphics/scummfont.cpp
old
|
new
|
|
63 | 63 | } |
64 | 64 | |
65 | 65 | //void ScummFont::drawChar(byte chr, int xx, int yy, OverlayColor color) { |
66 | | 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 { |
67 | 67 | assert(dst != 0); |
68 | | const int scaleFactorWidth = g_gui.getScaleFactorWidth(), scaleFactorHeight = g_gui.getScaleFactorHeight(); |
| 68 | const int scaleFactorWidth = scale ? g_gui.getScaleFactorWidth() : 1, scaleFactorHeight = scale ? g_gui.getScaleFactorHeight() : 1; |
69 | 69 | tx *= scaleFactorWidth; ty *= scaleFactorHeight; |
70 | 70 | |
71 | 71 | byte *ptr = (byte *)dst->getBasePtr(tx, ty); |
diff -u --rec -N --exclude=CVS --exclude=.deps --exclude=*.o scummvm.old/gui/console.cpp scummvm/gui/console.cpp
old
|
new
|
|
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 | g_gui.enableScaling(false); |
| 115 | |
114 | 116 | // Initiate sliding the console down. We do a very simple trick to achieve |
115 | 117 | // this effect: we simply move the console dialog just above (outside) the |
116 | 118 | // visible screen area, then shift it down in handleTickle() over a |
117 | | // certain period of time. |
| 119 | // certain period of time. |
118 | 120 | _y = -_h; |
119 | 121 | _slideTime = g_system->getMillis(); |
120 | 122 | _slideMode = kDownSlideMode; |
… |
… |
|
165 | 167 | _caretTime = time + kCaretBlinkTime; |
166 | 168 | drawCaret(_caretVisible); |
167 | 169 | } |
168 | | |
| 170 | |
169 | 171 | // Perform the "slide animation". |
170 | 172 | if (_slideMode != kNoSlideMode) { |
171 | 173 | const float tmp = (float)(g_system->getMillis() - _slideTime) / kConsoleSlideDownDuration; |
… |
… |
|
174 | 176 | } else { |
175 | 177 | _y = (int)(_h * (tmp - 1.0)); |
176 | 178 | } |
177 | | |
| 179 | |
178 | 180 | if (_slideMode == kDownSlideMode && _y > 0) { |
179 | 181 | // End the slide |
180 | 182 | _slideMode = kNoSlideMode; |
… |
… |
|
195 | 197 | |
196 | 198 | void ConsoleDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) { |
197 | 199 | int i; |
198 | | |
| 200 | |
199 | 201 | if (_slideMode != kNoSlideMode) |
200 | 202 | return; |
201 | 203 | |
… |
… |
|
204 | 206 | case '\r': { |
205 | 207 | if (_caretVisible) |
206 | 208 | drawCaret(true); |
207 | | |
| 209 | |
208 | 210 | nextLine(); |
209 | 211 | |
210 | 212 | assert(_promptEndPos >= _promptStartPos); |
… |
… |
|
217 | 219 | // We have to allocate the string buffer with new, since VC++ sadly does not |
218 | 220 | // comply to the C++ standard, so we can't use a dynamic sized stack array. |
219 | 221 | char *str = new char[len + 1]; |
220 | | |
| 222 | |
221 | 223 | // Copy the user input to str |
222 | 224 | for (i = 0; i < len; i++) |
223 | 225 | str[i] = buffer(_promptStartPos + i); |
Binary files scummvm.old/gui/libgui.a and scummvm/gui/libgui.a differ
diff -u --rec -N --exclude=CVS --exclude=.deps --exclude=*.o scummvm.old/gui/newgui.cpp scummvm/gui/newgui.cpp
old
|
new
|
|
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(); |
… |
… |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | void NewGui::updateScaleFactor() { |
| 82 | if(!_scaleEnable) { |
| 83 | _scaleFactorWidth = _scaleFactorHeight = 1; |
| 84 | return; |
| 85 | } |
| 86 | |
82 | 87 | const int16 stdGuiWidth = 320; |
83 | 88 | const int16 stdGuiHeight = 200; |
84 | 89 | |
… |
… |
|
225 | 230 | _lastClick.count = 0; |
226 | 231 | |
227 | 232 | _stateIsSaved = true; |
| 233 | _scaleEnable = true; |
228 | 234 | } |
229 | 235 | |
230 | 236 | void NewGui::restoreState() { |
… |
… |
|
348 | 354 | void NewGui::drawChar(byte chr, int xx, int yy, OverlayColor color, const Graphics::Font *font) { |
349 | 355 | if (font == 0) |
350 | 356 | font = &getFont(); |
351 | | font->drawChar(&_screen, chr, xx, yy, color); |
| 357 | font->drawChar(&_screen, chr, xx, yy, color, _scaleEnable); |
352 | 358 | } |
353 | 359 | |
354 | 360 | int NewGui::getStringWidth(const String &str) { |
355 | | return getFont().getStringWidth(str) * _scaleFactorWidth; |
| 361 | int width = 0; |
| 362 | for (uint p = 0; p < str.size(); p++) |
| 363 | width += getCharWidth(str[p]); |
| 364 | return width; |
356 | 365 | } |
357 | 366 | |
358 | 367 | int NewGui::getCharWidth(byte c) { |
359 | | return getFont().getCharWidth(c) * _scaleFactorWidth; |
| 368 | return getFont().getCharWidth(c) * c != ' ' ? _scaleFactorWidth : 1; |
360 | 369 | } |
361 | 370 | |
362 | 371 | void NewGui::drawString(const String &s, int x, int y, int w, OverlayColor color, TextAlignment align, int deltax, bool useEllipsis) { |
363 | | getFont().drawString(&_screen, s, x, y, w, color, align, deltax, useEllipsis); |
| 372 | getFont().drawString(&_screen, s, x, y, w, color, align, deltax, useEllipsis, _scaleEnable); |
364 | 373 | } |
365 | 374 | |
366 | 375 | // |
diff -u --rec -N --exclude=CVS --exclude=.deps --exclude=*.o scummvm.old/gui/newgui.h scummvm/gui/newgui.h
old
|
new
|
|
68 | 68 | |
69 | 69 | int getScaleFactorWidth() { return _scaleFactorWidth; } |
70 | 70 | int getScaleFactorHeight() { return _scaleFactorHeight; } |
| 71 | void enableScaling(bool enable) { _scaleEnable = enable; updateScaleFactor(); } |
71 | 72 | |
72 | 73 | protected: |
73 | 74 | OSystem *_system; |
… |
… |
|
76 | 77 | |
77 | 78 | int _scaleFactorWidth; |
78 | 79 | int _scaleFactorHeight; |
| 80 | bool _scaleEnable; |
79 | 81 | |
80 | 82 | bool _needRedraw; |
81 | 83 | DialogStack _dialogStack; |