ScummVM API documentation
controls.h
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 modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (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, see <http://www.gnu.org/licenses/>.
22  */
23 
24 #ifndef SWORD2_CONTROL_H
25 #define SWORD2_CONTROL_H
26 
27 #include "sword2/defs.h"
28 #include "sword2/saveload.h"
29 
30 #define MAX_WIDGETS 25
31 
32 namespace Sword2 {
33 
34 class Sword2Engine;
35 class FontRendererGui;
36 class Widget;
37 class Switch;
38 class Slider;
39 class Button;
40 class ScrollButton;
41 class Slot;
42 
43 enum {
44  kSaveDialog,
45  kRestoreDialog
46 };
47 
52 class Dialog {
53 private:
54  int _numWidgets;
55  Widget *_widgets[MAX_WIDGETS];
56  bool _finish;
57  int _result;
58 
59 public:
60  Sword2Engine *_vm;
61 
62  Dialog(Sword2Engine *vm);
63  virtual ~Dialog();
64 
65  void registerWidget(Widget *widget);
66 
67  virtual void paint();
68  virtual void setResult(int result);
69 
70  virtual int runModal();
71 
72  virtual void onAction(Widget *widget, int result = 0) {}
73 };
74 
75 class OptionsDialog : public Dialog {
76 private:
77  FontRendererGui *_fr;
78  Widget *_panel;
79  Switch *_objectLabelsSwitch;
80  Switch *_subtitlesSwitch;
81  Switch *_reverseStereoSwitch;
82  Switch *_musicSwitch;
83  Switch *_speechSwitch;
84  Switch *_fxSwitch;
85  Slider *_musicSlider;
86  Slider *_speechSlider;
87  Slider *_fxSlider;
88  Slider *_gfxSlider;
89  Widget *_gfxPreview;
90  Button *_okButton;
91  Button *_cancelButton;
92 
93  Audio::Mixer *_mixer;
94 
95 public:
97  ~OptionsDialog() override;
98 
99  void paint() override;
100  void onAction(Widget *widget, int result = 0) override;
101 };
102 
103 class SaveRestoreDialog : public Dialog {
104 private:
105  int _mode, _selectedSlot;
106  byte _editBuffer[SAVE_DESCRIPTION_LEN];
107  int _editPos, _firstPos;
108  int _cursorTick;
109 
110  FontRendererGui *_fr1;
111  FontRendererGui *_fr2;
112  Widget *_panel;
113  Slot *_slotButton[8];
114  ScrollButton *_zupButton;
115  ScrollButton *_upButton;
116  ScrollButton *_downButton;
117  ScrollButton *_zdownButton;
118  Button *_okButton;
119  Button *_cancelButton;
120 
121 public:
122  SaveRestoreDialog(Sword2Engine *vm, int mode);
123  ~SaveRestoreDialog() override;
124 
125  void updateSlots();
126  void drawEditBuffer(Slot *slot);
127 
128  void onAction(Widget *widget, int result = 0) override;
129  void paint() override;
130  void setResult(int result) override;
131  int runModal() override;
132 };
133 
139 class MiniDialog : public Dialog {
140 private:
141  uint32 _headerTextId;
142  uint32 _okTextId;
143  uint32 _cancelTextId;
144  FontRendererGui *_fr;
145  Widget *_panel;
146  Button *_okButton;
147  Button *_cancelButton;
148 
149 public:
150  MiniDialog(Sword2Engine *vm, uint32 headerTextId, uint32 okTextId = TEXT_OK, uint32 cancelTextId = TEXT_CANCEL);
151  ~MiniDialog() override;
152  void paint() override;
153  void onAction(Widget *widget, int result = 0) override;
154 };
155 
156 class StartDialog : public MiniDialog {
157 public:
159  int runModal() override;
160 };
161 
162 class RestartDialog : public MiniDialog {
163 public:
165  int runModal() override;
166 };
167 
168 class QuitDialog : public MiniDialog {
169 public:
171  int runModal() override;
172 };
173 
175 public:
176  SaveDialog(Sword2Engine *vm) : SaveRestoreDialog(vm, kSaveDialog) {}
177 };
178 
180 public:
181  RestoreDialog(Sword2Engine *vm) : SaveRestoreDialog(vm, kRestoreDialog) {}
182 };
183 
184 } // End of namespace Sword2
185 
186 #endif
Definition: animation.h:37
Definition: controls.h:75
Definition: controls.h:162
Definition: sword2.h:99
Definition: mixer.h:59
Definition: controls.h:103
Definition: controls.h:179
Definition: controls.h:52
Definition: controls.h:139
Definition: controls.h:174
Definition: controls.h:168
Definition: input.h:69
Definition: controls.h:156