1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef KYRA_GUI_V1_H 24 #define KYRA_GUI_V1_H 25 26 #include "kyra/gui/gui.h" 27 28 namespace Kyra { 29 30 struct MenuItem { 31 bool enabled; 32 33 Common::String itemString; 34 uint16 itemId; 35 bool useItemString; 36 37 int16 x, y; 38 uint16 width, height; 39 40 uint8 textColor, highlightColor; 41 42 int16 titleX; 43 44 uint8 color1, color2; 45 uint8 bkgdColor; 46 47 Button::Callback callback; 48 49 int16 saveSlot; 50 51 const char *labelString; 52 uint16 labelId; 53 int16 labelX, labelY; 54 55 uint16 keyCode; 56 }; 57 58 struct Menu { 59 int16 x, y; 60 uint16 width, height; 61 62 uint8 bkgdColor; 63 uint8 color1, color2; 64 65 const char *menuNameString; 66 uint16 menuNameId; 67 68 uint8 textColor; 69 int16 titleX, titleY; 70 71 uint8 highlightedItem; 72 73 uint8 numberOfItems; 74 75 int16 scrollUpButtonX, scrollUpButtonY; 76 int16 scrollDownButtonX, scrollDownButtonY; 77 78 MenuItem item[7]; 79 }; 80 81 class TextDisplayer; 82 83 class GUI_v1 : public GUI { 84 public: 85 GUI_v1(KyraEngine_v1 *vm); ~GUI_v1()86 ~GUI_v1() override {} 87 88 // button specific 89 virtual Button *addButtonToList(Button *list, Button *newButton); 90 91 void processButton(Button *button) override = 0; 92 int processButtonList(Button *buttonList, uint16 inputFlags, int8 mouseWheel) override = 0; 93 94 virtual int redrawShadedButtonCallback(Button *button); 95 virtual int redrawButtonCallback(Button *button); 96 97 // menu specific 98 virtual void initMenuLayout(Menu &menu); 99 void initMenu(Menu &menu); 100 101 void processHighlights(Menu &menu); 102 103 // utilities for thumbnail creation 104 void createScreenThumbnail(Graphics::Surface &dst) override = 0; 105 106 protected: 107 TextDisplayer *_text; 108 109 Button *_menuButtonList; 110 bool _displayMenu; 111 bool _displaySubMenu; 112 bool _cancelSubMenu; 113 114 virtual void printMenuText(const Common::String &str, int x, int y, uint8 c0, uint8 c1, uint8 c2); 115 virtual int getMenuCenterStringX(const Common::String &str, int x1, int x2); 116 117 Button::Callback _redrawShadedButtonFunctor; 118 Button::Callback _redrawButtonFunctor; 119 120 virtual Button *getButtonListData() = 0; 121 virtual Button *getScrollUpButton() = 0; 122 virtual Button *getScrollDownButton() = 0; 123 124 virtual Button::Callback getScrollUpButtonHandler() const = 0; 125 virtual Button::Callback getScrollDownButtonHandler() const = 0; 126 127 virtual uint8 defaultColor1() const = 0; 128 virtual uint8 defaultColor2() const = 0; 129 130 virtual Common::String getMenuTitle(const Menu &menu) = 0; 131 virtual Common::String getMenuItemTitle(const MenuItem &menuItem) = 0; 132 virtual Common::String getMenuItemLabel(const MenuItem &menuItem) = 0; 133 134 void updateAllMenuButtons(); 135 void updateMenuButton(Button *button); 136 virtual void updateButton(Button *button); 137 138 void redrawText(const Menu &menu); 139 void redrawHighlight(const Menu &menu); 140 141 uint32 _lastScreenUpdate; 142 void checkTextfieldInput(); 143 }; 144 145 class Movie; 146 147 class MainMenu { 148 public: 149 MainMenu(KyraEngine_v1 *vm); ~MainMenu()150 virtual ~MainMenu() {} 151 152 struct Animation { AnimationAnimation153 Animation() : anim(0), startFrame(0), endFrame(0), delay(0) {} 154 155 Movie *anim; 156 int startFrame; 157 int endFrame; 158 int delay; 159 }; 160 161 struct StaticData { 162 const char *strings[5]; 163 164 uint8 menuTable[7]; 165 uint8 colorTable[4]; 166 167 Screen::FontId font; 168 uint8 altColor; 169 }; 170 171 void init(StaticData data, Animation anim); 172 int handle(int dim); 173 private: 174 KyraEngine_v1 *_vm; 175 Screen *_screen; 176 OSystem *_system; 177 178 StaticData _static; 179 struct AnimIntern { 180 int curFrame; 181 int direction; 182 }; 183 Animation _anim; 184 AnimIntern _animIntern; 185 186 uint32 _nextUpdate; 187 188 void updateAnimation(); 189 void draw(int select); 190 void drawBox(int x, int y, int w, int h, int fill); 191 bool getInput(); 192 193 void printString(const char *string, int x, int y, int col1, int col2, int flags, ...) GCC_PRINTF(2, 8); 194 }; 195 196 } // end of namesapce Kyra 197 198 #endif 199