Ticket #8388: scaleableGUI-v5.patch

File scaleableGUI-v5.patch, 22.7 KB (added by lordhoto, 19 years ago)

patch against CVS (02.01.2005)

  • graphics/font.cpp

    ? backends/PalmOS/Src/midi
    RCS file: /cvsroot/scummvm/scummvm/graphics/font.cpp,v
    retrieving revision 1.4
    diff -u -r1.4 font.cpp
     
    2020
    2121#include "common/stdafx.h"
    2222#include "graphics/font.h"
     23#include "gui/newgui.h"
    2324
    2425namespace Graphics {
    2526
     
    3637        return desc.width[chr - desc.firstchar];
    3738}
    3839
    39 void NewFont::drawChar(const Surface *dst, byte chr, int tx, int ty, uint32 color) const {
     40void NewFont::drawChar(const Surface *dst, byte chr, int tx, int ty, uint32 color, bool scale) const {
    4041        assert(dst != 0);
     42        const int scaleFactor = scale ? g_gui.getScaleFactor() : 1;
     43        tx *= scaleFactor; ty *= scaleFactor;
     44
    4145        byte *ptr = (byte *)dst->getBasePtr(tx, ty);
    4246
    4347        assert(desc.bits != 0 && desc.maxwidth <= 16);
     
    5458        chr -= desc.firstchar;
    5559        const bitmap_t *tmp = desc.bits + (desc.offset ? desc.offset[chr] : (chr * desc.height));
    5660
    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++;
    5970                bitmap_t mask = 0x8000;
    6071                if (ty + y < 0 || ty + y >= dst->h)
    6172                        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
    6482                        if (tx + x < 0 || tx + x >= dst->w)
    6583                                continue;
    66                         if ((buffer & mask) != 0) {
     84                        if ((*buffer & mask) != 0) {
    6785                                if (dst->bytesPerPixel == 1)
    6886                                        ptr[x] = color;
    6987                                else if (dst->bytesPerPixel == 2)
     
    85103        return space;
    86104}
    87105
    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 {
     106void 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 {
    89107        assert(dst != 0);
    90108        const int leftX = x, rightX = x + w;
    91109        uint i;
    92110        int width = getStringWidth(s);
    93111        Common::String str;
    94        
     112
    95113        if (useEllipsis && width > w) {
    96114                // String is too wide. So we shorten it "intellegently", by replacing
    97115                // parts of it by an ellipsis ("..."). There are three possibilities
     
    100118                // make this configurable, replacing the middle probably is a good
    101119                // compromise.
    102120                const int ellipsisWidth = getStringWidth("...");
    103                
     121
    104122                // SLOW algorithm to remove enough of the middle. But it is good enough
    105123                // for now.
    106124                const int halfWidth = (w - ellipsisWidth) / 2;
    107125                int w2 = 0;
    108                
     126
    109127                for (i = 0; i < s.size(); ++i) {
    110128                        int charWidth = getCharWidth(s[i]);
    111129                        if (w2 + charWidth > halfWidth)
     
    116134                // At this point we know that the first 'i' chars are together 'w2'
    117135                // pixels wide. We took the first i-1, and add "..." to them.
    118136                str += "...";
    119                
     137
    120138                // The original string is width wide. Of those we already skipped past
    121139                // w2 pixels, which means (width - w2) remain.
    122140                // The new str is (w2+ellipsisWidth) wide, so we can accomodate about
     
    150168                if (x+w > rightX)
    151169                        break;
    152170                if (x >= leftX)
    153                         drawChar(dst, str[i], x, y, color);
     171                        drawChar(dst, str[i], x, y, color, scale);
    154172                x += w;
    155173        }
    156174}
  • graphics/font.h

    RCS file: /cvsroot/scummvm/scummvm/graphics/font.h,v
    retrieving revision 1.3
    diff -u -r1.3 font.h
     
    3535
    3636/**
    3737 * 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
    3939 *       FontRenderer class? That way, we could have different variants... ?
    4040 * @todo Add more parameters to drawString, or additional similar methods,
    4141 *       featuring abilities like
     
    5252        virtual int getMaxCharWidth() const = 0;
    5353
    5454        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;
    5656
    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;
    5858        int getStringWidth(const Common::String &str) const;
    5959};
    6060
     
    6565        virtual int getMaxCharWidth() const { return 8; };
    6666
    6767        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;
    6969};
    7070
    7171extern const ScummFont g_scummfont;
     
    9696
    9797public:
    9898        NewFont(const FontDesc &d) : desc(d) {}
    99        
     99
    100100        virtual int getFontHeight() const { return desc.height; }
    101101        virtual int getMaxCharWidth() const { return desc.maxwidth; };
    102102
    103103        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;
    105105};
    106106
    107107extern const NewFont g_sysfont;
  • graphics/scummfont.cpp

    RCS file: /cvsroot/scummvm/scummvm/graphics/scummfont.cpp,v
    retrieving revision 1.4
    diff -u -r1.4 scummfont.cpp
     
    2020
    2121#include "stdafx.h"
    2222#include "graphics/font.h"
     23#include "gui/newgui.h"
    2324
    2425namespace Graphics {
    2526
     
    6263}
    6364
    6465//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 {
     66void ScummFont::drawChar(const Surface *dst, byte chr, int tx, int ty, uint32 color, bool scale) const {
    6667        assert(dst != 0);
     68        const int scaleFactor = scale ? g_gui.getScaleFactor() : 1;
     69        tx *= scaleFactor; ty *= scaleFactor;
     70
    6771        byte *ptr = (byte *)dst->getBasePtr(tx, ty);
    6872
    6973        const byte *tmp = guifont + 6 + guifont[4] + chr * 8;
    7074        uint buffer = 0;
    7175        uint mask = 0;
    7276
    73         for (int y = 0; y < 8; y++) {
     77        for (int y = 0; y < 8 * scaleFactor; y++) {
    7478                if (ty + y < 0 || ty + y >= dst->h)
    7579                        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
    7786                        if (tx + x < 0 || tx + x >= dst->w)
    7887                                continue;
    7988                        unsigned char c;
    80                         mask >>= 1;
     89
    8190                        if (mask == 0) {
    82                                 buffer = *tmp++;
     91                                if(scaleFactor != 1 && !(y % 2))
     92                                        buffer = *tmp++;
     93                                else if(scaleFactor == 1)
     94                                        buffer = *tmp++;
     95
    8396                                mask = 0x80;
    8497                        }
    8598                        c = ((buffer & mask) != 0);
  • gui/console.cpp

    RCS file: /cvsroot/scummvm/scummvm/gui/console.cpp,v
    retrieving revision 1.53
    diff -u -r1.53 console.cpp
     
    4949 * - a *lot* of others things, this code is in no way complete and heavily under progress
    5050 */
    5151ConsoleDialog::ConsoleDialog(float widthPercent, float heightPercent)
    52         : Dialog(0, 0, 1, 1), 
     52        : Dialog(0, 0, 1, 1),
    5353        _widthPercent(widthPercent), _heightPercent(heightPercent) {
    54        
     54
    5555        // Setup basic layout/dialog size
    5656        reflowLayout();
    5757
     
    111111}
    112112
    113113void ConsoleDialog::open() {
     114        // disable scaling because the console is using non fixed positions
     115        g_gui.enableScaling(false);
     116
    114117        // Initiate sliding the console down. We do a very simple trick to achieve
    115118        // this effect: we simply move the console dialog just above (outside) the
    116119        // visible screen area, then shift it down in handleTickle() over a
    117         // certain period of time. 
     120        // certain period of time.
    118121        _y = -_h;
    119122        _slideTime = g_system->getMillis();
    120123        _slideMode = kDownSlideMode;
     
    165168                _caretTime = time + kCaretBlinkTime;
    166169                drawCaret(_caretVisible);
    167170        }
    168        
     171
    169172        // Perform the "slide animation".
    170173        if (_slideMode != kNoSlideMode) {
    171174                const float tmp = (float)(g_system->getMillis() - _slideTime) / kConsoleSlideDownDuration;
     
    174177                } else {
    175178                        _y = (int)(_h * (tmp - 1.0));
    176179                }
    177                
     180
    178181                if (_slideMode == kDownSlideMode && _y > 0) {
    179182                        // End the slide
    180183                        _slideMode = kNoSlideMode;
     
    195198
    196199void ConsoleDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) {
    197200        int i;
    198        
     201
    199202        if (_slideMode != kNoSlideMode)
    200203                return;
    201204
     
    204207        case '\r': {
    205208                if (_caretVisible)
    206209                        drawCaret(true);
    207                        
     210
    208211                nextLine();
    209212
    210213                assert(_promptEndPos >= _promptStartPos);
     
    217220                        // We have to allocate the string buffer with new, since VC++ sadly does not
    218221                        // comply to the C++ standard, so we can't use a dynamic sized stack array.
    219222                        char *str = new char[len + 1];
    220        
     223
    221224                        // Copy the user input to str
    222225                        for (i = 0; i < len; i++)
    223226                                str[i] = buffer(_promptStartPos + i);
  • gui/dialog.cpp

    RCS file: /cvsroot/scummvm/scummvm/gui/dialog.cpp,v
    retrieving revision 1.46
    diff -u -r1.46 dialog.cpp
     
    2929
    3030/*
    3131 * 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
    3333 *   was inactive and just became active, reset certain vars (like who is focused).
    3434 *   Maybe we should just add lostFocus and receivedFocus methods to Dialog, just
    3535 *   like we have for class Widget?
     
    9898}
    9999
    100100void Dialog::drawDialog() {
    101        
     101
    102102        if (!isVisible())
    103103                return;
    104104
     
    117117}
    118118
    119119void Dialog::handleMouseDown(int x, int y, int button, int clickCount) {
     120        x /= g_gui.getScaleFactor(); y /= g_gui.getScaleFactor();
     121
    120122        Widget *w;
     123
    121124        w = findWidget(x, y);
    122        
     125
    123126        _dragWidget = w;
    124127
    125128        // If the click occured inside a widget which is not the currently
     
    141144}
    142145
    143146void Dialog::handleMouseUp(int x, int y, int button, int clickCount) {
     147        x /= g_gui.getScaleFactor(); y /= g_gui.getScaleFactor();
     148
    144149        Widget *w;
    145150
    146151        if (_focusedWidget) {
    147152                //w = _focusedWidget;
    148                
     153
    149154                // Lose focus on mouseup unless the widget requested to retain the focus
    150155                if (! (_focusedWidget->getFlags() & WIDGET_RETAIN_FOCUS )) {
    151156                        releaseFocus();
     
    161166}
    162167
    163168void Dialog::handleMouseWheel(int x, int y, int direction) {
     169        x /= g_gui.getScaleFactor(); y /= g_gui.getScaleFactor();
     170
    164171        Widget *w;
    165172
    166173        // This may look a bit backwards, but I think it makes more sense for
     
    212219}
    213220
    214221void Dialog::handleMouseMoved(int x, int y, int button) {
     222        x /= g_gui.getScaleFactor(); y /= g_gui.getScaleFactor();
     223
    215224        Widget *w;
    216        
     225
    217226        //if (!button)
    218227        //      _dragWidget = 0;
    219        
     228
    220229        if (_focusedWidget && !_dragWidget) {
    221230                w = _focusedWidget;
    222231                int wx = w->getAbsX() - _x;
    223232                int wy = w->getAbsY() - _y;
    224                
     233
    225234                // We still send mouseEntered/Left messages to the focused item
    226235                // (but to no other items).
    227236                bool mouseInFocusedWidget = (x >= wx && x < wx + w->_w && y >= wy && y < wy + w->_h);
     
    237246
    238247                w->handleMouseMoved(x - wx, y - wy, button);
    239248        }
    240        
     249
    241250        // While a "drag" is in process (i.e. mouse is moved while a button is pressed),
    242251        // only deal with the widget in which the click originated.
    243252        if (_dragWidget)
     
    251260                if (w)
    252261                        w->handleMouseEntered(button);
    253262                _mouseWidget = w;
    254         } 
     263        }
    255264
    256265        if (w && (w->getFlags() & WIDGET_TRACK_MOUSE)) {
    257266                w->handleMouseMoved(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button);
  • gui/newgui.cpp

    RCS file: /cvsroot/scummvm/scummvm/gui/newgui.cpp,v
    retrieving revision 1.94
    diff -u -r1.94 newgui.cpp
     
    4141 * - allow multi line (l/c/r aligned) text via StaticTextWidget ?
    4242 * - add "close" widget to all dialogs (with a flag to turn it off) ?
    4343 * - 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
    4545 * - ...
    4646 */
    4747
     
    5454
    5555
    5656// Constructor
    57 NewGui::NewGui() : _needRedraw(false),
     57NewGui::NewGui() : _scaleEnable(true), _needRedraw(false),
    5858        _stateIsSaved(false), _cursorAnimateCounter(0), _cursorAnimateTimer(0) {
    59        
     59
    6060        _system = &OSystem::instance();
    6161
    6262        // Clear the cursor
     
    6464
    6565        // Reset key repeat
    6666        _currentKeyDown.keycode = 0;
     67
     68        // updates the scaling factor
     69        updateScaleFactor();
    6770}
    6871
    6972void NewGui::updateColors() {
     
    7578        _textcolorhi = _system->RGBToColor(0, 255, 0);
    7679}
    7780
     81void 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
    7894void NewGui::runLoop() {
    7995        Dialog *activeDialog = _dialogStack.top();
    8096        bool didSaveState = false;
    8197
    8298        if (activeDialog == 0)
    8399                return;
    84        
     100
    85101        // Setup some default GUI colors. Normally this will be done whenever an
    86102        // EVENT_SCREEN_CHANGED is received. However, not yet all backends support
    87103        // that event, so we also do it "manually" whenever a run loop is entered.
    88104        updateColors();
     105        updateScaleFactor();
    89106
    90107        if (!_stateIsSaved) {
    91108                saveState();
     
    106123                }
    107124
    108125                animateCursor();
    109                 _system->updateScreen();               
     126                _system->updateScreen();
    110127
    111128                OSystem::Event event;
    112129                uint32 time = _system->getMillis();
     
    131148                                        _currentKeyDown.keycode = 0;
    132149                                break;
    133150                        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);
    135152                                break;
    136153                        // We don't distinguish between mousebuttons (for now at least)
    137154                        case OSystem::EVENT_LBUTTONDOWN:
     
    146163                                        _lastClick.count = 1;
    147164                                }
    148165                                _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);
    150167                                break;
    151168                        case OSystem::EVENT_LBUTTONUP:
    152169                        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);
    154171                                break;
    155172                        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);
    157174                                break;
    158175                        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);
    160177                                break;
    161178                        case OSystem::EVENT_QUIT:
    162179                                _system->quit();
    163180                                return;
    164181                        case OSystem::EVENT_SCREEN_CHANGED:
    165182                                updateColors();
     183                                updateScaleFactor();
    166184                                activeDialog->handleScreenChanged();
    167185                                break;
    168186                        }
     
    180198                // Delay for a moment
    181199                _system->delayMillis(10);
    182200        }
    183        
     201
    184202        if (didSaveState)
    185203                restoreState();
    186204}
     
    212230        _lastClick.count = 0;
    213231
    214232        _stateIsSaved = true;
     233        _scaleEnable = true;
    215234}
    216235
    217236void NewGui::restoreState() {
     
    224243        }
    225244
    226245        _system->updateScreen();
    227        
     246
    228247        _stateIsSaved = false;
    229248}
    230249
     
    270289}
    271290
    272291void 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);
    274293}
    275294
    276295void 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);
    278297}
    279298
    280299void NewGui::blendRect(int x, int y, int w, int h, OverlayColor color, int level) {
    281300#ifdef NEWGUI_256
    282301        fillRect(x, y, w, h, color);
    283302#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);
    285304        rect.clip(_screen.w, _screen.h);
    286        
     305
    287306        if (!rect.isValidRect())
    288307                return;
    289308
     
    311330}
    312331
    313332void 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);
    315334}
    316335
    317336void 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);
    319338}
    320339
    321340void 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);
    323342        rect.clip(_screen.w, _screen.h);
    324        
     343
    325344        if (!rect.isValidRect())
    326345                return;
    327346
     
    335354void NewGui::drawChar(byte chr, int xx, int yy, OverlayColor color, const Graphics::Font *font) {
    336355        if (font == 0)
    337356                font = &getFont();
    338         font->drawChar(&_screen, chr, xx, yy, color);
     357        font->drawChar(&_screen, chr, xx, yy, color, _scaleEnable);
    339358}
    340359
    341360int NewGui::getStringWidth(const String &str) {
     
    347366}
    348367
    349368void 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);
    351370}
    352371
    353372//
    354373// Draw an 8x8 bitmap at location (x,y)
    355374//
    356375void NewGui::drawBitmap(uint32 *bitmap, int tx, int ty, OverlayColor color, int h) {
     376        tx *= _scaleFactor; ty *= _scaleFactor;
     377        h *= _scaleFactor;
    357378        OverlayColor *ptr = getBasePtr(tx, ty);
    358379
    359380        for (int y = 0; y < h; y++, ptr += _screenPitch) {
    360381                uint32 mask = 0xF0000000;
    361382                if (ty + y < 0 || ty + y >= _screen.h)
    362383                        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
    364390                        if (tx + x < 0 || tx + x >= _screen.w)
    365391                                continue;
    366                         if (bitmap[y] & mask)
    367                                 ptr[x] = color;
     392                        if (bitmap[y / _scaleFactor] & mask)
     393                                        ptr[x] = color;
    368394                }
    369395        }
    370396}
     
    374400// We could plug in a different cursor here if we like to.
    375401//
    376402void NewGui::animateCursor() {
    377         int time = _system->getMillis(); 
     403        int time = _system->getMillis();
    378404        if (time > _cursorAnimateTimer + kCursorAnimateDelay) {
    379405                const byte colors[4] = { 15, 15, 7, 8 };
    380406                const byte color = colors[_cursorAnimateCounter];
    381407                int i;
    382                
     408
    383409                for (i = 0; i < 15; i++) {
    384410                        if ((i < 6) || (i > 8)) {
    385411                                _cursor[16 * 7 + i] = color;
    386412                                _cursor[16 * i + 7] = color;
    387413                        }
    388414                }
    389        
     415
    390416                _system->setMouseCursor(_cursor, 16, 16, 7, 7);
    391417
    392418                _cursorAnimateTimer = time;
  • gui/newgui.h

    RCS file: /cvsroot/scummvm/scummvm/gui/newgui.h,v
    retrieving revision 1.49
    diff -u -r1.49 newgui.h
     
    5252
    5353/**
    5454 * GUI manager singleton.
    55  */ 
     55 */
    5656class NewGui : public Common::Singleton<NewGui> {
    5757        typedef Common::String String;
    5858        friend class Dialog;
     
    6666
    6767        bool isActive() { return ! _dialogStack.empty(); }
    6868
     69        int getScaleFactor() { return _scaleFactor; }
     70        void enableScaling(bool enable) { _scaleEnable = enable; updateScaleFactor(); }
     71
    6972protected:
    70         OSystem         *_system;
    71         Graphics::Surface               _screen;
     73        OSystem                 *_system;
     74        Graphics::Surface       _screen;
    7275        int                     _screenPitch;
    73        
     76
     77        int                     _scaleFactor;
     78        bool                    _scaleEnable;
     79
    7480        bool            _needRedraw;
    7581        DialogStack     _dialogStack;
    76        
     82
    7783        bool            _stateIsSaved;
    78        
     84
    7985        // for continuous events (keyDown)
    8086        struct {
    8187                uint16 ascii;
     
    8389                int keycode;
    8490        } _currentKeyDown;
    8591        uint32          _keyRepeatTime;
    86        
     92
    8793        // position and time of last mouse click (used to detect double clicks)
    8894        struct {
    8995                int16 x, y;     // Position of mouse when the click occured
    9096                uint32 time;    // Time
    9197                int count;      // How often was it already pressed?
    9298        } _lastClick;
    93        
     99
    94100        // mouse cursor state
    95101        bool            _oldCursorMode;
    96         int                     _cursorAnimateCounter;
    97         int                     _cursorAnimateTimer;
     102        int             _cursorAnimateCounter;
     103        int             _cursorAnimateTimer;
    98104        byte            _cursor[2048];
    99105
    100106        void saveState();
    101107        void restoreState();
    102        
     108
    103109        void openDialog(Dialog *dialog);
    104110        void closeTopDialog();
    105        
     111
    106112        void loop();
    107113
    108114        void animateCursor();
    109115        void updateColors();
     116        void updateScaleFactor();
    110117
    111118        OverlayColor *getBasePtr(int x, int y);
    112119
     
    116123        OverlayColor _bgcolor;
    117124        OverlayColor _textcolor;
    118125        OverlayColor _textcolorhi;
    119        
     126
    120127        // Font
    121128        const Graphics::Font &getFont() const;
    122129