Ticket #7976: guistuff.patch
File guistuff.patch, 10.6 KB (added by , 22 years ago) |
---|
-
gui.cpp
RCS file: /cvsroot/scummvm/scummvm/gui.cpp,v retrieving revision 1.52 diff -u -r1.52 gui.cpp
54 54 GUI_KEYTEXT = 7, 55 55 GUI_SCROLLTEXT = 8, 56 56 GUI_NEXTTEXT = 9, 57 GUI_UPDOWNARROW = 10 57 GUI_UPDOWNARROW = 10, 58 GUI_CHECKBOX = 11 58 59 }; 59 60 60 61 enum { … … 74 75 uint16 _w,_h; 75 76 uint16 _id; 76 77 byte _string_number; 78 uint8 _hotkey; 77 79 }; 78 80 79 81 enum { … … 83 85 KEYS_DIALOG, 84 86 OPTIONS_DIALOG, 85 87 ABOUT_DIALOG, 86 LAUNCHER_DIALOG 88 LAUNCHER_DIALOG, 89 MISC_DIALOG 87 90 }; 88 91 89 92 … … 112 115 0x00011000, 113 116 }; 114 117 118 static uint32 checked_img[IMG_SIZE] = { 119 0x00000000, 120 0x01000010, 121 0x00100100, 122 0x00011000, 123 0x00011000, 124 0x00100100, 125 0x01000010, 126 0x00000000, 127 }; 115 128 116 129 const GuiWidget launcher_dialog[] = { 117 130 {GUI_STAT, 0xFF, GWF_DEFAULT, 0, 0, 320, 200, 0, 0}, … … 162 175 }; 163 176 164 177 const GuiWidget about_dialog[] = { 165 {GUI_STAT, 0xFF, GWF_DEFAULT, 30, 20, 260, 1 20, 0, 0},178 {GUI_STAT, 0xFF, GWF_DEFAULT, 30, 20, 260, 135, 0, 0}, 166 179 {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, 2 30, 15, 0, 10}, // ScummVM Url180 {GUI_CUSTOMTEXT, 0x01, 0, 30 + 10, 20 + 10 + 15 + 5 + 15, 240, 15, 0, 10}, // ScummVM Url 168 181 {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 169 184 {GUI_SCROLLTEXT, 0x01, 0, 30 + 95, 20 + 10, 100, 15, 0}, 170 {GUI_RESTEXT, 0x01, GWF_BUTTON, 30 + 1 13, 20 + 96, 54, 16, 40, 9},185 {GUI_RESTEXT, 0x01, GWF_BUTTON, 30 + 100, 20 + 112, 54, 16, 40, 9}, 171 186 {0, 0, 0, 0, 0, 0, 0, 0, 0} 172 187 }; 173 188 174 189 const 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 198 const 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 179 206 {0, 0, 0, 0, 0, 0, 0, 0, 0} 180 207 }; 181 208 … … 190 217 {GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 11, 20 + 25 + 25 + 11, 15, 15, 21, 3}, // Plus 191 218 {GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 33, 20 + 25 + 25 + 11, 15, 15, 22, 4}, // Minus 192 219 {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 */ 194 221 {GUI_RESTEXT, 0x01, GWF_BUTTON, 30 + (260 / 2), 20 + 25 + 25 + 11 + 25, 54, 16, 50, 7}, /* Cancel */ 195 222 {0, 0, 0, 0, 0, 0, 0, 0, 0} 196 223 }; … … 217 244 {GUI_RESTEXT, 0x06, GWF_CLEARBG, 10, 94, 160, 10, 27, 0}, 218 245 {GUI_RESTEXT, 0x06, GWF_CLEARBG, 10, 104, 160, 10, 28, 0}, 219 246 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 */ 225 252 226 253 {GUI_RESTEXT, 0x02, GWF_BUTTON, 200, 60, 54, 16, 7, 7}, /* Cancel */ 227 254 … … 408 435 case GUI_IMAGE: 409 436 break; 410 437 case GUI_UPDOWNARROW: 438 case GUI_CHECKBOX: 411 439 { 412 440 uint32 *data; 413 441 byte color = (_clickWidget && _clickWidget == w->_id) ? _textcolorhi : _textcolor; 414 442 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 } 419 452 420 453 // Center the image 421 454 x += w->_w/2 - IMG_SIZE/2; … … 429 462 if (ptr == NULL) 430 463 return; 431 464 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; 438 475 } 439 ptr += 320;440 476 } 441 477 } 442 478 break; … … 645 681 _dialog = ABOUT_DIALOG; 646 682 draw(0, 100); 647 683 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 701 void 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(); 648 734 } 649 735 } 650 736 … … 726 812 case OPTIONS_DIALOG: 727 813 handleOptionsDialogCommand(cmd); 728 814 return; 815 case MISC_DIALOG: 816 handleMiscDialogCommand(cmd); 817 return; 729 818 case KEYS_DIALOG: 730 819 handleKeysDialogCommand(cmd); 731 820 return; … … 932 1021 } 933 1022 } 934 1023 1024 bool Gui::getCheckboxChecked(int id) 1025 { 1026 return _cbox_checked[id]; 1027 } 1028 1029 void Gui::setCheckbox(bool state, int id) 1030 { 1031 _cbox_checked[id] = state; 1032 } 1033 1034 void Gui::clearCheckboxes() 1035 { 1036 for (int id = 0; id <= 100; id++){ 1037 _cbox_checked[id] = false; 1038 } 1039 } 1040 935 1041 void Gui::init(Scumm *s) 936 1042 { 937 1043 /* Default GUI colors */ … … 972 1078 if (_dialog != KEYS_DIALOG) { 973 1079 if (_s->_lastKeyHit == 27) 974 1080 close(); 975 else 1081 else { 976 1082 addLetter((unsigned char)_s->_lastKeyHit); 1083 checkHotKey(_s->_lastKeyHit); 1084 } 977 1085 #ifdef _WIN32_WCE 978 1086 } else if (_s->_lastKeyHit > 1000) { // GAPI 979 1087 addLetter(_s->_lastKeyHit - 1000); … … 1021 1129 } 1022 1130 1023 1131 #endif 1132 } 1133 1134 void 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 } 1024 1158 } 1025 1159 1026 1160 void Gui::saveLoadDialog() -
gui.h
RCS file: /cvsroot/scummvm/scummvm/gui.h,v retrieving revision 1.23 diff -u -r1.23 gui.h
70 70 // optiondialog specifics 71 71 int _gui_variables[100]; 72 72 73 // checkboxes 74 bool _cbox_checked[100]; 75 const char *_cbox_cfg_key[100]; 76 73 77 // savedialog specifics 74 78 int _slotIndex; 75 79 int _editString; … … 103 107 void addLetter(byte letter); 104 108 void queryMessage(const char *msg, const char *alts); 105 109 byte getDefaultColor(int color); 110 bool getCheckboxChecked(int id); 111 void setCheckbox(bool state, int id); 112 void clearCheckboxes(); 113 void checkHotKey(int keycode); 106 114 107 115 char _gui_scroller[255]; 108 116 … … 110 118 void handleOptionsDialogCommand(int cmd); 111 119 void handleKeysDialogCommand(int cmd); 112 120 void handleLauncherDialogCommand(int cmd); 121 void handleMiscDialogCommand(int cmd); 113 122 }; 114 123 #endif -
guimaps.h
RCS file: /cvsroot/scummvm/scummvm/guimaps.h,v retrieving revision 1.3 diff -u -r1.3 guimaps.h
45 45 "Save", //14 46 46 "Skip", //15 47 47 "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 49 54 }; 50 55 51 56 static ResString string_map_table_v7[] = {