o More widgets fot alternative constructors

o Cleanup of launcher dialog
o Implemented useWithPrefix keyword

svn-id: r21131
This commit is contained in:
Eugene Sandulenko 2006-03-07 19:02:42 +00:00
parent d7bc756edc
commit fc84c7fc1d
7 changed files with 54 additions and 40 deletions

View File

@ -45,6 +45,12 @@ Dialog::Dialog(int x, int y, int w, int h)
_drawingHints = THEME_HINT_FIRST_DRAW | THEME_HINT_SAVE_BACKGROUND;
}
Dialog::Dialog(String name)
: GuiObject(name),
_mouseWidget(0), _focusedWidget(0), _dragWidget(0), _visible(false), _drawingHints(0) {
_drawingHints = THEME_HINT_FIRST_DRAW | THEME_HINT_SAVE_BACKGROUND;
}
Dialog::~Dialog() {
delete _firstWidget;
_firstWidget = 0;

View File

@ -52,6 +52,7 @@ private:
public:
Dialog(int x, int y, int w, int h);
Dialog(Common::String name);
virtual ~Dialog();
virtual int runModal();

View File

@ -477,19 +477,6 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
#pragma mark -
#define BEGIN_BUTTONS(numButtons, hSpace, top) \
{ \
const int space = hSpace; \
const int width = (_w - 2 * hBorder - space * (numButtons - 1)) / numButtons; \
int x = hBorder; \
const int y = top;
#define ADD(name, cmd, hotkey) \
new ButtonWidget(this, x, y, width, buttonHeight, name, cmd, hotkey, ws); x += space + width
#define END_BUTTONS \
}
LauncherDialog::LauncherDialog(GameDetector &detector)
: Dialog(0, 0, 320, 200), _detector(detector) {
_drawingHints |= THEME_HINT_MAIN_DIALOG;
@ -497,22 +484,15 @@ LauncherDialog::LauncherDialog(GameDetector &detector)
const int screenW = g_system->getOverlayWidth();
const int screenH = g_system->getOverlayHeight();
const int hBorder = 10;
_w = screenW;
_h = screenH;
GUI::WidgetSize ws;
int buttonHeight;
int top;
if (screenW >= 400 && screenH >= 300) {
if (screenW >= 400 && screenH >= 300)
ws = GUI::kBigWidgetSize;
buttonHeight = kBigButtonHeight;
} else {
else
ws = GUI::kNormalWidgetSize;
buttonHeight = kButtonHeight;
}
// Show ScummVM version
new StaticTextWidget(this, "launcher_version", gScummVMFullVersion, kTextAlignCenter, ws);

View File

@ -73,18 +73,34 @@ enum {
OptionsDialog::OptionsDialog(const String &domain, int x, int y, int w, int h)
: Dialog(x, y, w, h),
_domain(domain),
_enableGraphicSettings(false),
_gfxPopUp(0), _renderModePopUp(0), _fullscreenCheckbox(0), _aspectCheckbox(0),
_enableAudioSettings(false),
_subCheckbox(0),
_enableMIDISettings(false),
_multiMidiCheckbox(0), _mt32Checkbox(0), _enableGSCheckbox(0),
_enableVolumeSettings(false),
_musicVolumeSlider(0), _musicVolumeLabel(0),
_sfxVolumeSlider(0), _sfxVolumeLabel(0),
_speechVolumeSlider(0), _speechVolumeLabel(0) {
: Dialog(x, y, w, h), _domain(domain) {
init();
}
OptionsDialog::OptionsDialog(const String &domain, String name)
: Dialog(name), _domain(domain) {
init();
}
void OptionsDialog::init() {
_enableGraphicSettings = false;
_gfxPopUp = 0;
_renderModePopUp = 0;
_fullscreenCheckbox = 0;
_aspectCheckbox = 0;
_enableAudioSettings = false;
_subCheckbox = 0;
_enableMIDISettings = false;
_multiMidiCheckbox = 0;
_mt32Checkbox = 0;
_enableGSCheckbox = 0;
_enableVolumeSettings = false;
_musicVolumeSlider = 0;
_musicVolumeLabel = 0;
_sfxVolumeSlider = 0;
_sfxVolumeLabel = 0;
_speechVolumeSlider = 0;
_speechVolumeLabel = 0;
}
void OptionsDialog::open() {

View File

@ -41,6 +41,9 @@ class OptionsDialog : public Dialog {
typedef Common::String String;
public:
OptionsDialog(const String &domain, int x, int y, int w, int h);
OptionsDialog(const String &domain, String name);
void init();
void open();
void close();

View File

@ -120,7 +120,7 @@ void Theme::processSingleLine(const String &section, const String name, const St
}
void Theme::processResSection(Common::ConfigFile &config, String name, bool skipDefs) {
void Theme::processResSection(Common::ConfigFile &config, String name, bool skipDefs, const String prefix) {
debug(3, "Reading section: [%s]", name.c_str());
const Common::ConfigFile::SectionKeyList &keys = config.getKeys(name);
@ -128,16 +128,16 @@ void Theme::processResSection(Common::ConfigFile &config, String name, bool skip
Common::ConfigFile::SectionKeyList::const_iterator iterk;
for (iterk = keys.begin(); iterk != keys.end(); ++iterk) {
if (iterk->key == "set_parent") {
setSpecialAlias("parent", iterk->value);
setSpecialAlias("parent", prefix + iterk->value);
continue;
}
if (iterk->key.hasPrefix("set_")) {
_evaluator->setAlias(name, iterk->key, iterk->value);
_evaluator->setAlias(name, iterk->key, prefix + iterk->value);
continue;
}
if (iterk->key.hasPrefix("def_")) {
if (!skipDefs)
_evaluator->setVariable(name, iterk->key, iterk->value);
_evaluator->setVariable(name, prefix + iterk->key, iterk->value);
continue;
}
if (iterk->key == "use") {
@ -148,7 +148,15 @@ void Theme::processResSection(Common::ConfigFile &config, String name, bool skip
processResSection(config, iterk->value, true);
continue;
}
processSingleLine(name, iterk->key, iterk->value);
if (iterk->key == "useWithPrefix") {
if (iterk->value == name)
error("Theme section [%s]: cannot use itself", name.c_str());
if (!config.hasSection(name))
error("Undefined use of section [%s]", name.c_str());
processResSection(config, iterk->value, true, iterk->value + "_");
continue;
}
processSingleLine(name, prefix + iterk->key, iterk->value);
}
}

View File

@ -169,7 +169,7 @@ public:
return kTextAlignCenter;
}
void processResSection(Common::ConfigFile &config, String name, bool skipDefs = false);
void processResSection(Common::ConfigFile &config, String name, bool skipDefs = false, const String prefix = "");
void processSingleLine(const String &section, const String name, const String str);
void setSpecialAlias(const String alias, const String &name);