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 * Additional copyright for this file: 8 * Copyright (C) 1994-1998 Revolution Software Ltd. 9 * 10 * This program is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU General Public License 12 * as published by the Free Software Foundation; either version 2 13 * of the License, or (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 23 */ 24 25 #ifndef SWORD2_CONTROL_H 26 #define SWORD2_CONTROL_H 27 28 #include "sword2/defs.h" 29 #include "sword2/saveload.h" 30 31 #define MAX_WIDGETS 25 32 33 namespace Sword2 { 34 35 class Sword2Engine; 36 class FontRendererGui; 37 class Widget; 38 class Switch; 39 class Slider; 40 class Button; 41 class ScrollButton; 42 class Slot; 43 44 enum { 45 kSaveDialog, 46 kRestoreDialog 47 }; 48 49 /** 50 * Base class for all dialogs. 51 */ 52 53 class Dialog { 54 private: 55 int _numWidgets; 56 Widget *_widgets[MAX_WIDGETS]; 57 bool _finish; 58 int _result; 59 60 public: 61 Sword2Engine *_vm; 62 63 Dialog(Sword2Engine *vm); 64 virtual ~Dialog(); 65 66 void registerWidget(Widget *widget); 67 68 virtual void paint(); 69 virtual void setResult(int result); 70 71 virtual int runModal(); 72 73 virtual void onAction(Widget *widget, int result = 0) {} 74 }; 75 76 class OptionsDialog : public Dialog { 77 private: 78 FontRendererGui *_fr; 79 Widget *_panel; 80 Switch *_objectLabelsSwitch; 81 Switch *_subtitlesSwitch; 82 Switch *_reverseStereoSwitch; 83 Switch *_musicSwitch; 84 Switch *_speechSwitch; 85 Switch *_fxSwitch; 86 Slider *_musicSlider; 87 Slider *_speechSlider; 88 Slider *_fxSlider; 89 Slider *_gfxSlider; 90 Widget *_gfxPreview; 91 Button *_okButton; 92 Button *_cancelButton; 93 94 Audio::Mixer *_mixer; 95 96 public: 97 OptionsDialog(Sword2Engine *vm); 98 ~OptionsDialog(); 99 100 virtual void paint(); 101 virtual void onAction(Widget *widget, int result = 0); 102 }; 103 104 class SaveRestoreDialog : public Dialog { 105 private: 106 int _mode, _selectedSlot; 107 byte _editBuffer[SAVE_DESCRIPTION_LEN]; 108 int _editPos, _firstPos; 109 int _cursorTick; 110 111 FontRendererGui *_fr1; 112 FontRendererGui *_fr2; 113 Widget *_panel; 114 Slot *_slotButton[8]; 115 ScrollButton *_zupButton; 116 ScrollButton *_upButton; 117 ScrollButton *_downButton; 118 ScrollButton *_zdownButton; 119 Button *_okButton; 120 Button *_cancelButton; 121 122 public: 123 SaveRestoreDialog(Sword2Engine *vm, int mode); 124 ~SaveRestoreDialog(); 125 126 void updateSlots(); 127 void drawEditBuffer(Slot *slot); 128 129 virtual void onAction(Widget *widget, int result = 0); 130 virtual void paint(); 131 virtual void setResult(int result); 132 virtual int runModal(); 133 }; 134 135 /** 136 * A "mini" dialog is usually a yes/no question, but also used for the 137 * restart/restore dialog at the beginning of the game. 138 */ 139 140 class MiniDialog : public Dialog { 141 private: 142 uint32 _headerTextId; 143 uint32 _okTextId; 144 uint32 _cancelTextId; 145 FontRendererGui *_fr; 146 Widget *_panel; 147 Button *_okButton; 148 Button *_cancelButton; 149 150 public: 151 MiniDialog(Sword2Engine *vm, uint32 headerTextId, uint32 okTextId = TEXT_OK, uint32 cancelTextId = TEXT_CANCEL); 152 virtual ~MiniDialog(); 153 virtual void paint(); 154 virtual void onAction(Widget *widget, int result = 0); 155 }; 156 157 class StartDialog : public MiniDialog { 158 public: 159 StartDialog(Sword2Engine *vm); 160 virtual int runModal(); 161 }; 162 163 class RestartDialog : public MiniDialog { 164 public: 165 RestartDialog(Sword2Engine *vm); 166 virtual int runModal(); 167 }; 168 169 class QuitDialog : public MiniDialog { 170 public: 171 QuitDialog(Sword2Engine *vm); 172 virtual int runModal(); 173 }; 174 175 class SaveDialog : public SaveRestoreDialog { 176 public: SaveDialog(Sword2Engine * vm)177 SaveDialog(Sword2Engine *vm) : SaveRestoreDialog(vm, kSaveDialog) {} 178 }; 179 180 class RestoreDialog : public SaveRestoreDialog { 181 public: RestoreDialog(Sword2Engine * vm)182 RestoreDialog(Sword2Engine *vm) : SaveRestoreDialog(vm, kRestoreDialog) {} 183 }; 184 185 } // End of namespace Sword2 186 187 #endif 188