Ticket #7976: guistuff.patch

File guistuff.patch, 10.6 KB (added by SF/chuzwuzza, 22 years ago)

Gui additions patch file

  • gui.cpp

    RCS file: /cvsroot/scummvm/scummvm/gui.cpp,v
    retrieving revision 1.52
    diff -u -r1.52 gui.cpp
     
    5454        GUI_KEYTEXT = 7,
    5555        GUI_SCROLLTEXT = 8,
    5656        GUI_NEXTTEXT = 9,
    57         GUI_UPDOWNARROW = 10
     57        GUI_UPDOWNARROW = 10,
     58        GUI_CHECKBOX = 11
    5859};
    5960
    6061enum {
     
    7475        uint16 _w,_h;
    7576        uint16 _id;
    7677        byte _string_number;
     78        uint8 _hotkey;
    7779};
    7880
    7981enum {
     
    8385        KEYS_DIALOG,
    8486        OPTIONS_DIALOG,
    8587        ABOUT_DIALOG,
    86         LAUNCHER_DIALOG
     88        LAUNCHER_DIALOG,
     89        MISC_DIALOG
    8790};
    8891
    8992
     
    112115        0x00011000,
    113116};
    114117
     118static uint32 checked_img[IMG_SIZE] = {
     119        0x00000000,
     120        0x01000010,
     121        0x00100100,
     122        0x00011000,
     123        0x00011000,
     124        0x00100100,
     125        0x01000010,
     126        0x00000000,
     127};
    115128
    116129const GuiWidget launcher_dialog[] = {
    117130        {GUI_STAT, 0xFF, GWF_DEFAULT, 0, 0, 320, 200, 0, 0},
     
    162175};
    163176
    164177const GuiWidget about_dialog[] = {
    165         {GUI_STAT, 0xFF, GWF_DEFAULT, 30, 20, 260, 120, 0, 0},
     178        {GUI_STAT, 0xFF, GWF_DEFAULT, 30, 20, 260, 135, 0, 0},
    166179        {GUI_CUSTOMTEXT, 0x01, 0, 30 + 68, 20 + 10 + 15 + 5, 160, 15, 0, 9},    // Build
    167         {GUI_CUSTOMTEXT, 0x01, 0, 30 + 10, 20 + 10 + 15 + 5 + 15, 230, 15, 0, 10},      // ScummVM Url
     180        {GUI_CUSTOMTEXT, 0x01, 0, 30 + 10, 20 + 10 + 15 + 5 + 15, 240, 15, 0, 10},      // ScummVM Url
    168181        {GUI_CUSTOMTEXT, 0x01, 0, 30 + 75, 20 + 10 + 15 + 5 + 15 + 15 + 15, 150, 15, 0, 11},    // Lucasarts
     182        {GUI_CUSTOMTEXT, 0x01, 0, 30 + 110, 20 + 10 + 15 + 5 + 15 + 15 + 15 + 15, 40, 15, 0, 21}, // Except:
     183        {GUI_CUSTOMTEXT, 0x01, 0, 30 + 25, 20 + 100, 210, 15, 0, 22}, // Adventuresoft
    169184        {GUI_SCROLLTEXT, 0x01, 0, 30 + 95, 20 + 10, 100, 15, 0},
    170         {GUI_RESTEXT, 0x01, GWF_BUTTON, 30 + 113, 20 + 96, 54, 16, 40, 9},
     185        {GUI_RESTEXT, 0x01, GWF_BUTTON, 30 + 100, 20 + 112, 54, 16, 40, 9},
    171186        {0, 0, 0, 0, 0, 0, 0, 0, 0}
    172187};
    173188
    174189const GuiWidget options_dialog[] = {
    175         {GUI_STAT, 0xFF, GWF_DEFAULT, 50, 80, 210, 35, 0, 0},
    176         {GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 50 + 10, 80 + 10, 40, 15, 1, 5},     // Sound
    177         {GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 50 + 10 + 40 + 30, 80 + 10, 40, 15, 2, 6},   // Keys
    178         {GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 50 + 10 + 40 + 30 + 40 + 30, 80 + 10, 40, 15, 3, 7}, // About
     190        {GUI_STAT, 0xFF, GWF_DEFAULT, 50, 80, 210, 60, 0, 0},
     191        {GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 50 + 10, 80 + 10, 40, 15, 1, 5, 83}, // Sound
     192        {GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 50 + 10 + 40 + 30, 80 + 10, 40, 15, 2, 6, 75},       // Keys
     193        {GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 50 + 10 + 40 + 30 + 40 + 30, 80 + 10, 40, 15, 3, 7, 65},     // About
     194        {GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 50 + 10, 80 + 10 + 15 + 10, 40, 15, 4, 18, 77}, // Misc
     195        {0, 0, 0, 0, 0, 0, 0, 0, 0}
     196};
     197
     198const GuiWidget misc_dialog[] = {
     199        {GUI_STAT, 0xFF, GWF_DEFAULT, 50, 80, 210, 65, 0, 0},
     200        {GUI_CHECKBOX, 0x01, GWF_DEFAULT, 50 + 10, 80 + 6, 14, 14, 1, 0, 83}, // checkbox for subtitles
     201        {GUI_CUSTOMTEXT, 0x01, 0, 50 + 10 + 20, 80 + 10, 140, 15, 0, 19}, // "Show speech subtitles"
     202        {GUI_CHECKBOX, 0x01, GWF_DEFAULT, 50 + 10, 80 + 6 + 16, 14, 14, 5, 0, 65}, // checkbox for amiga pallete
     203        {GUI_CUSTOMTEXT, 0x01, 0, 50 + 10 + 20, 80 + 10 + 15, 140, 15, 0, 20}, // "Amiga pallete conversion"
     204        {GUI_RESTEXT, 0x01, GWF_BUTTON, 50 + 10 + 20, 80 + 10 + 15 + 20, 54, 16, 3, 9, 13}, // ok
     205        {GUI_RESTEXT, 0x01, GWF_BUTTON, 50 + 10 + 20 + 80, 80 + 10 + 15 + 20, 54, 16, 4, 7}, // cancel
    179206        {0, 0, 0, 0, 0, 0, 0, 0, 0}
    180207};
    181208
     
    190217        {GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 11, 20 + 25 + 25 + 11, 15, 15, 21, 3},  // Plus
    191218        {GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 33, 20 + 25 + 25 + 11, 15, 15, 22, 4},  // Minus
    192219        {GUI_VARTEXT, 0x01, GWF_BUTTON, 30 + 73, 20 + 25 + 25 + 11, 128, 15, 23, 2},    // SFX
    193         {GUI_RESTEXT, 0x01, GWF_BUTTON, 30 + (260 / 2) - 80, 20 + 25 + 25 + 11 + 25, 54, 16, 40, 9},    /* OK */
     220        {GUI_RESTEXT, 0x01, GWF_BUTTON, 30 + (260 / 2) - 80, 20 + 25 + 25 + 11 + 25, 54, 16, 40, 9, 13},        /* OK */
    194221        {GUI_RESTEXT, 0x01, GWF_BUTTON, 30 + (260 / 2), 20 + 25 + 25 + 11 + 25, 54, 16, 50, 7}, /* Cancel */
    195222        {0, 0, 0, 0, 0, 0, 0, 0, 0}
    196223};
     
    217244        {GUI_RESTEXT, 0x06, GWF_CLEARBG, 10, 94, 160, 10, 27, 0},
    218245        {GUI_RESTEXT, 0x06, GWF_CLEARBG, 10, 104, 160, 10, 28, 0},
    219246
    220         {GUI_RESTEXT, 0x01, GWF_BUTTON, 200, 20, 54, 16, 3, 4}, /* Save */
    221         {GUI_RESTEXT, 0x01, GWF_BUTTON, 200, 40, 54, 16, 4, 5}, /* Load */
    222         {GUI_RESTEXT, 0x01, GWF_BUTTON, 200, 60, 54, 16, 5, 6}, /* Play */
    223         {GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 200, 80, 54, 16, 9, 17},     /* Options */
    224         {GUI_RESTEXT, 0x01, GWF_BUTTON, 200, 100, 54, 16, 6, 8},        /* Quit */
     247        {GUI_RESTEXT, 0x01, GWF_BUTTON, 200, 20, 54, 16, 3, 4, 83},     /* Save */
     248        {GUI_RESTEXT, 0x01, GWF_BUTTON, 200, 40, 54, 16, 4, 5, 76},     /* Load */
     249        {GUI_RESTEXT, 0x01, GWF_BUTTON, 200, 60, 54, 16, 5, 6, 80},     /* Play */
     250        {GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 200, 80, 54, 16, 9, 17, 79}, /* Options */
     251        {GUI_RESTEXT, 0x01, GWF_BUTTON, 200, 100, 54, 16, 6, 8, 81},    /* Quit */
    225252
    226253        {GUI_RESTEXT, 0x02, GWF_BUTTON, 200, 60, 54, 16, 7, 7}, /* Cancel */
    227254
     
    408435        case GUI_IMAGE:
    409436                break;
    410437        case GUI_UPDOWNARROW:
     438        case GUI_CHECKBOX:
    411439                {
    412440                        uint32 *data;
    413441                        byte color = (_clickWidget && _clickWidget == w->_id) ? _textcolorhi : _textcolor;
    414442
    415                         if (w->_string_number == 0)
    416                                 data = up_arrow;
    417                         else
    418                                 data = down_arrow;
     443                        if (w->_type == GUI_UPDOWNARROW) {
     444                                if (w->_string_number == 0)
     445                                        data = up_arrow;
     446                                else
     447                                        data = down_arrow;
     448                                // if not an updownarrow, it must be a checkbox
     449                        } else {
     450                                data = checked_img;
     451                        }
    419452
    420453                        // Center the image
    421454                        x += w->_w/2 - IMG_SIZE/2;
     
    429462                        if (ptr == NULL)
    430463                                return;
    431464       
    432                         for (int y2 = 0; y2 < IMG_SIZE; y2++) {
    433                                 uint32 mask = 0xF0000000;
    434                                 for (int x2 = 0; x2 < IMG_SIZE; x2++) {
    435                                         if (data[y2] & mask)
    436                                                 ptr[x2] = color;
    437                                         mask >>= 4;
     465                        // If the checkbox is checked, or this is not a checkbox, draw the image
     466                        if ((getCheckboxChecked(w->_id) == true) || (w->_type != GUI_CHECKBOX)) {
     467                                for (int y2 = 0; y2 < IMG_SIZE; y2++) {
     468                                        uint32 mask = 0xF0000000;
     469                                        for (int x2 = 0; x2 < IMG_SIZE; x2++) {
     470                                                if (data[y2] & mask)
     471                                                        ptr[x2] = color;
     472                                                mask >>= 4;
     473                                        }
     474                                        ptr += 320;
    438475                                }
    439                                 ptr += 320;
    440476                        }
    441477                }
    442478                break;
     
    645681                _dialog = ABOUT_DIALOG;
    646682                draw(0, 100);
    647683                return;
     684        case 4:
     685                _widgets[0] = misc_dialog;
     686                _active = true;
     687                _cur_page = 0;
     688                _return_to = 0;
     689                _dialog = MISC_DIALOG;
     690                clearCheckboxes();
     691                setCheckbox(!(_s->_noSubtitles), 1);
     692                if (_s->_features & GF_AMIGA)
     693                        setCheckbox(true, 5);
     694                else
     695                        setCheckbox(false, 5);
     696                draw(0, 100);
     697                return;
     698        }
     699}
     700
     701void Gui::handleMiscDialogCommand(int cmd)
     702{
     703        switch (cmd) {
     704        case 1:
     705                if ((getCheckboxChecked(1)) == true)
     706                        setCheckbox(false, 1);
     707                else
     708                        setCheckbox(true, 1);
     709                draw(1, 1);
     710                return;
     711        case 5:
     712                if (getCheckboxChecked(5) == true)
     713                        setCheckbox(false, 5);
     714                else
     715                        setCheckbox(true, 5);
     716                draw(5, 5);
     717                return;
     718        case 3:
     719        case 4:
     720                // OK button - perform the actions of the checkboxes
     721                if (cmd == 3) {
     722                        // The opposite of the checkbox(1) is set because the internal variable is 'no subtitles' but
     723                        // a "Show subtitles" option makes more usability sense
     724                        _s->_noSubtitles = (!getCheckboxChecked(1));
     725
     726                        // Amiga pallete conversion checkbox
     727                        if (getCheckboxChecked(5))
     728                                        _s->_features = _s->_features | GF_AMIGA;
     729                        else
     730                                        _s->_features = _s->_features & ~GF_AMIGA;
     731                        _s->_fullRedraw = true;
     732                }
     733                close();
    648734        }
    649735}
    650736
     
    726812        case OPTIONS_DIALOG:
    727813                handleOptionsDialogCommand(cmd);
    728814                return;
     815        case MISC_DIALOG:
     816                handleMiscDialogCommand(cmd);
     817                return;
    729818        case KEYS_DIALOG:
    730819                handleKeysDialogCommand(cmd);
    731820                return;
     
    9321021        }
    9331022}
    9341023
     1024bool Gui::getCheckboxChecked(int id)
     1025{
     1026        return _cbox_checked[id];
     1027}
     1028
     1029void Gui::setCheckbox(bool state, int id)
     1030{
     1031        _cbox_checked[id] = state;
     1032}
     1033
     1034void Gui::clearCheckboxes()
     1035{
     1036        for (int id = 0; id <= 100; id++){
     1037                _cbox_checked[id] = false;
     1038        }
     1039}
     1040
    9351041void Gui::init(Scumm *s)
    9361042{
    9371043        /* Default GUI colors */
     
    9721078                if (_dialog != KEYS_DIALOG) {
    9731079                        if (_s->_lastKeyHit == 27)
    9741080                                close();
    975                         else
     1081                        else {
    9761082                                addLetter((unsigned char)_s->_lastKeyHit);
     1083                                checkHotKey(_s->_lastKeyHit);
     1084                        }
    9771085#ifdef _WIN32_WCE
    9781086                } else if (_s->_lastKeyHit > 1000) {    // GAPI
    9791087                        addLetter(_s->_lastKeyHit - 1000);
     
    10211129        }
    10221130
    10231131#endif
     1132}
     1133
     1134void Gui::checkHotKey(int keycode)
     1135{
     1136        byte page;
     1137        for (int i = 0; i < (int)(sizeof(_widgets) / sizeof(_widgets[0])); i++) {
     1138                const GuiWidget *w = _widgets[i];
     1139                if (w) {
     1140                        while (w->_type != GUI_NONE) {
     1141       
     1142                                // This rubbish is needed because the current page is 0 when really it should be 1
     1143                                if (_cur_page == 0)
     1144                                        page = 1;
     1145                                else
     1146                                        page = _cur_page;
     1147
     1148                                // Only check for widgets that are on the current GUI page (otherwise save dialog problems occur)
     1149                                if (w->_page == page) {
     1150                                        // Check the actual key pressed, and the uppercase version. For people who have caps lock on
     1151                                        if (keycode == w->_hotkey || (keycode - 32) == w->_hotkey)
     1152                                                handleCommand(w->_id);
     1153                                }
     1154                                w++;
     1155                        }
     1156                }
     1157        }
    10241158}
    10251159
    10261160void Gui::saveLoadDialog()
  • gui.h

    RCS file: /cvsroot/scummvm/scummvm/gui.h,v
    retrieving revision 1.23
    diff -u -r1.23 gui.h
     
    7070        // optiondialog specifics
    7171        int _gui_variables[100];
    7272
     73        // checkboxes
     74        bool _cbox_checked[100];
     75        const char *_cbox_cfg_key[100];
     76
    7377        // savedialog specifics
    7478        int _slotIndex;
    7579        int _editString;
     
    103107        void addLetter(byte letter);   
    104108        void queryMessage(const char *msg, const char *alts);
    105109        byte getDefaultColor(int color);
     110        bool getCheckboxChecked(int id);
     111        void setCheckbox(bool state, int id);
     112        void clearCheckboxes();
     113        void checkHotKey(int keycode);
    106114
    107115        char _gui_scroller[255];
    108116
     
    110118        void handleOptionsDialogCommand(int cmd);
    111119        void handleKeysDialogCommand(int cmd);
    112120        void handleLauncherDialogCommand(int cmd);
     121        void handleMiscDialogCommand(int cmd);
    113122};
    114123#endif
  • guimaps.h

    RCS file: /cvsroot/scummvm/scummvm/guimaps.h,v
    retrieving revision 1.3
    diff -u -r1.3 guimaps.h
     
    4545        "Save",                                                                                 //14
    4646        "Skip",                                                                                 //15
    4747        "Hide",                                                                                 //16
    48         "Options"                                                                               //17
     48        "Options",                                                                      //17
     49        "Misc",                                                                                 //18
     50        "Show speech subtitles",                //19
     51        "Amiga pallete conversion",     //20
     52        "Except:",                                                                      //21
     53        "Simon the Sorcerer (c) Adventuresoft" //22
    4954};
    5055
    5156static ResString string_map_table_v7[] = {