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