diff options
author | Torbjörn Andersson | 2005-02-20 15:38:48 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2005-02-20 15:38:48 +0000 |
commit | 807b33ec29797006dd13e4627102166344cc8901 (patch) | |
tree | 63cd1f4b64c644661c95069f3f0ac3442ef4513c /sword2/controls.h | |
parent | b1039bb59e76912528dcf1ad439e70f3f1485a50 (diff) | |
download | scummvm-rg350-807b33ec29797006dd13e4627102166344cc8901.tar.gz scummvm-rg350-807b33ec29797006dd13e4627102166344cc8901.tar.bz2 scummvm-rg350-807b33ec29797006dd13e4627102166344cc8901.zip |
More BS2 restructuring.
The various game settings are no longer stored in the Gui class. They are
stored in the class that use them.
Code that doesn't belong in the Gui class, e.g. the "restart" code, has
been moved out of it.
Afterwards, the Gui class had been reduced to nothing more than a handful
of trivial methods for invoking the in-game dialogs. So the entire Gui
class has been removed.
svn-id: r16827
Diffstat (limited to 'sword2/controls.h')
-rw-r--r-- | sword2/controls.h | 149 |
1 files changed, 134 insertions, 15 deletions
diff --git a/sword2/controls.h b/sword2/controls.h index 27cf07f9f5..9fa95a6b85 100644 --- a/sword2/controls.h +++ b/sword2/controls.h @@ -21,33 +21,152 @@ #ifndef _CONTROL_S #define _CONTROL_S +#include "sword2/defs.h" + +#define MAX_WIDGETS 25 + namespace Sword2 { class Sword2Engine; +class FontRendererGui; +class Widget; +class Switch; +class Slider; +class Button; +class ScrollButton; +class Slot; + +enum { + kSaveDialog, + kLoadDialog +}; + +/** + * Base class for all dialogs. + */ + +class Dialog { +private: + int _numWidgets; + Widget *_widgets[MAX_WIDGETS]; + bool _finish; + int _result; -class Gui { public: Sword2Engine *_vm; - int _baseSlot; - uint8 _currentGraphicsLevel; + Dialog(Sword2Engine *vm); + virtual ~Dialog(); + + void registerWidget(Widget *widget); + + virtual void paint(); + virtual void setResult(int result); + + virtual int runModal(); + + virtual void onAction(Widget *widget, int result = 0) {} +}; + +class OptionsDialog : public Dialog { +private: + FontRendererGui *_fr; + Widget *_panel; + Switch *_objectLabelsSwitch; + Switch *_subtitlesSwitch; + Switch *_reverseStereoSwitch; + Switch *_musicSwitch; + Switch *_speechSwitch; + Switch *_fxSwitch; + Slider *_musicSlider; + Slider *_speechSlider; + Slider *_fxSlider; + Slider *_gfxSlider; + Widget *_gfxPreview; + Button *_okButton; + Button *_cancelButton; + + SoundMixer *_mixer; + +public: + OptionsDialog(Sword2Engine *vm); + ~OptionsDialog(); + + virtual void paint(); + virtual void onAction(Widget *widget, int result = 0); +}; + +class SaveLoadDialog : public Dialog { +private: + int _mode, _selectedSlot; + byte _editBuffer[SAVE_DESCRIPTION_LEN]; + int _editPos, _firstPos; + int _cursorTick; + + FontRendererGui *_fr1; + FontRendererGui *_fr2; + Widget *_panel; + Slot *_slotButton[8]; + ScrollButton *_zupButton; + ScrollButton *_upButton; + ScrollButton *_downButton; + ScrollButton *_zdownButton; + Button *_okButton; + Button *_cancelButton; - bool _subtitles; - bool _pointerTextSelected; +public: + SaveLoadDialog(Sword2Engine *vm, int mode); + ~SaveLoadDialog(); - Gui(Sword2Engine *vm); + void updateSlots(); + void drawEditBuffer(Slot *slot); + + virtual void onAction(Widget *widget, int result = 0); + virtual void paint(); + virtual void setResult(int result); + virtual int runModal(); +}; - uint32 restoreControl(void); - void saveControl(void); - bool startControl(void); - void quitControl(void); - void restartControl(void); - void optionControl(void); - void readOptionSettings(void); - void writeOptionSettings(void); - void updateGraphicsLevel(int newLevel); +/** + * A "mini" dialog is usually a yes/no question, but also used for the + * restart/restore dialog at the beginning of the game. + */ + +class MiniDialog : public Dialog { +private: + uint32 _headerTextId; + uint32 _okTextId; + uint32 _cancelTextId; + FontRendererGui *_fr; + Widget *_panel; + Button *_okButton; + Button *_cancelButton; + +public: + MiniDialog(Sword2Engine *vm, uint32 headerTextId, uint32 okTextId = TEXT_OK, uint32 cancelTextId = TEXT_CANCEL); + virtual ~MiniDialog(); + virtual void paint(); + virtual void onAction(Widget *widget, int result = 0); }; +class StartDialog : public MiniDialog { +public: + StartDialog(Sword2Engine *vm); + virtual int runModal(); +}; + +class RestartDialog : public MiniDialog { +public: + RestartDialog(Sword2Engine *vm); + virtual int runModal(); +}; + +class QuitDialog : public MiniDialog { +public: + QuitDialog(Sword2Engine *vm); + virtual int runModal(); +}; + } // End of namespace Sword2 #endif |