mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-03 15:41:41 +00:00
Create the gui object dynamically
svn-id: r11026
This commit is contained in:
parent
94edf540ef
commit
0435658b96
@ -538,7 +538,7 @@ void Logic::createSequenceSpeech(_movieTextObject *sequenceText[]) {
|
||||
|
||||
// if we want subtitles, or speech failed to load
|
||||
|
||||
if (gui._subtitles || !speechRunning) {
|
||||
if (gui->_subtitles || !speechRunning) {
|
||||
// open text resource & get the line
|
||||
text = FetchTextLine(res_man.open(text_res), local_text);
|
||||
// make the sprite
|
||||
|
@ -45,7 +45,7 @@ namespace Sword2 {
|
||||
// our fonts start on SPACE character (32)
|
||||
#define SIZE_OF_CHAR_SET (256 - 32)
|
||||
|
||||
Gui gui;
|
||||
Gui *gui;
|
||||
|
||||
enum {
|
||||
kAlignLeft,
|
||||
@ -775,11 +775,11 @@ public:
|
||||
registerWidget(_okButton);
|
||||
registerWidget(_cancelButton);
|
||||
|
||||
gui.readOptionSettings();
|
||||
gui->readOptionSettings();
|
||||
|
||||
_objectLabelsSwitch->setValue(gui._pointerTextSelected != 0);
|
||||
_subtitlesSwitch->setValue(gui._subtitles != 0);
|
||||
_reverseStereoSwitch->setValue(gui._stereoReversed != 0);
|
||||
_objectLabelsSwitch->setValue(gui->_pointerTextSelected != 0);
|
||||
_subtitlesSwitch->setValue(gui->_subtitles != 0);
|
||||
_reverseStereoSwitch->setValue(gui->_stereoReversed != 0);
|
||||
_musicSwitch->setValue(!g_sound->isMusicMute());
|
||||
_speechSwitch->setValue(!g_sound->isSpeechMute());
|
||||
_fxSwitch->setValue(!g_sound->isFxMute());
|
||||
@ -843,9 +843,9 @@ public:
|
||||
// is handled when the dialog is terminated.
|
||||
|
||||
if (widget == _reverseStereoSwitch) {
|
||||
if (result != gui._stereoReversed)
|
||||
if (result != gui->_stereoReversed)
|
||||
g_sound->reverseStereo();
|
||||
gui._stereoReversed = result;
|
||||
gui->_stereoReversed = result;
|
||||
} else if (widget == _musicSwitch) {
|
||||
g_sound->muteMusic(result);
|
||||
} else if (widget == _musicSlider) {
|
||||
@ -858,7 +858,7 @@ public:
|
||||
_fxSwitch->setValue(result != 0);
|
||||
} else if (widget == _gfxSlider) {
|
||||
_gfxPreview->setState(result);
|
||||
gui.updateGraphicsLevel(result);
|
||||
gui->updateGraphicsLevel(result);
|
||||
} else if (widget == _okButton) {
|
||||
// Apply the changes
|
||||
g_sound->muteMusic(!_musicSwitch->getValue());
|
||||
@ -868,17 +868,17 @@ public:
|
||||
g_sound->setSpeechVolume(_speechSlider->getValue());
|
||||
g_sound->setFxVolume(_fxSlider->getValue());
|
||||
|
||||
gui.updateGraphicsLevel(_gfxSlider->getValue());
|
||||
gui->updateGraphicsLevel(_gfxSlider->getValue());
|
||||
|
||||
gui._subtitles = _subtitlesSwitch->getValue();
|
||||
gui._pointerTextSelected = _objectLabelsSwitch->getValue();
|
||||
gui._stereoReversed = _reverseStereoSwitch->getValue();
|
||||
gui->_subtitles = _subtitlesSwitch->getValue();
|
||||
gui->_pointerTextSelected = _objectLabelsSwitch->getValue();
|
||||
gui->_stereoReversed = _reverseStereoSwitch->getValue();
|
||||
|
||||
gui.writeOptionSettings();
|
||||
gui->writeOptionSettings();
|
||||
setResult(1);
|
||||
} else if (widget == _cancelButton) {
|
||||
// Revert the changes
|
||||
gui.readOptionSettings();
|
||||
gui->readOptionSettings();
|
||||
setResult(0);
|
||||
}
|
||||
}
|
||||
@ -1074,13 +1074,13 @@ public:
|
||||
|
||||
void updateSlots() {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
Slot *slot = _slotButton[(gui._baseSlot + i) % 8];
|
||||
Slot *slot = _slotButton[(gui->_baseSlot + i) % 8];
|
||||
FontRendererGui *fr;
|
||||
uint8 description[SAVE_DESCRIPTION_LEN];
|
||||
|
||||
slot->setY(72 + i * 36);
|
||||
|
||||
if (gui._baseSlot + i == _selectedSlot) {
|
||||
if (gui->_baseSlot + i == _selectedSlot) {
|
||||
slot->setEditable(_mode == kSaveDialog);
|
||||
slot->setState(1);
|
||||
fr = _fr2;
|
||||
@ -1090,11 +1090,11 @@ public:
|
||||
fr = _fr1;
|
||||
}
|
||||
|
||||
if (GetSaveDescription(gui._baseSlot + i, description) == SR_OK) {
|
||||
slot->setText(fr, gui._baseSlot + i, (char *) description);
|
||||
if (GetSaveDescription(gui->_baseSlot + i, description) == SR_OK) {
|
||||
slot->setText(fr, gui->_baseSlot + i, (char *) description);
|
||||
slot->setClickable(true);
|
||||
} else {
|
||||
slot->setText(fr, gui._baseSlot + i, NULL);
|
||||
slot->setText(fr, gui->_baseSlot + i, NULL);
|
||||
slot->setClickable(_mode == kSaveDialog);
|
||||
}
|
||||
|
||||
@ -1107,29 +1107,29 @@ public:
|
||||
|
||||
virtual void onAction(Widget *widget, int result = 0) {
|
||||
if (widget == _zupButton) {
|
||||
if (gui._baseSlot > 0) {
|
||||
if (gui._baseSlot >= 8)
|
||||
gui._baseSlot -= 8;
|
||||
if (gui->_baseSlot > 0) {
|
||||
if (gui->_baseSlot >= 8)
|
||||
gui->_baseSlot -= 8;
|
||||
else
|
||||
gui._baseSlot = 0;
|
||||
gui->_baseSlot = 0;
|
||||
updateSlots();
|
||||
}
|
||||
} else if (widget == _upButton) {
|
||||
if (gui._baseSlot > 0) {
|
||||
gui._baseSlot--;
|
||||
if (gui->_baseSlot > 0) {
|
||||
gui->_baseSlot--;
|
||||
updateSlots();
|
||||
}
|
||||
} else if (widget == _downButton) {
|
||||
if (gui._baseSlot < 92) {
|
||||
gui._baseSlot++;
|
||||
if (gui->_baseSlot < 92) {
|
||||
gui->_baseSlot++;
|
||||
updateSlots();
|
||||
}
|
||||
} else if (widget == _zdownButton) {
|
||||
if (gui._baseSlot < 92) {
|
||||
if (gui._baseSlot <= 84)
|
||||
gui._baseSlot += 8;
|
||||
if (gui->_baseSlot < 92) {
|
||||
if (gui->_baseSlot <= 84)
|
||||
gui->_baseSlot += 8;
|
||||
else
|
||||
gui._baseSlot = 92;
|
||||
gui->_baseSlot = 92;
|
||||
updateSlots();
|
||||
}
|
||||
} else if (widget == _okButton) {
|
||||
@ -1187,7 +1187,7 @@ public:
|
||||
}
|
||||
} else {
|
||||
if (result == kSelectSlot)
|
||||
_selectedSlot = gui._baseSlot + (slot->getY() - 72) / 35;
|
||||
_selectedSlot = gui->_baseSlot + (slot->getY() - 72) / 35;
|
||||
else if (result == kDeselectSlot)
|
||||
_selectedSlot = -1;
|
||||
|
||||
@ -1215,7 +1215,7 @@ public:
|
||||
// but I doubt that will make any noticeable difference.
|
||||
|
||||
slot->paint();
|
||||
_fr2->drawText(_editBuffer, 130, 78 + (_selectedSlot - gui._baseSlot) * 36);
|
||||
_fr2->drawText(_editBuffer, 130, 78 + (_selectedSlot - gui->_baseSlot) * 36);
|
||||
}
|
||||
|
||||
virtual void paint() {
|
||||
@ -1392,9 +1392,9 @@ void Gui::writeOptionSettings(void) {
|
||||
ConfMan.set("speech_mute", g_sound->isSpeechMute());
|
||||
ConfMan.set("sfx_mute", g_sound->isFxMute());
|
||||
ConfMan.set("gfx_details", g_display->getRenderLevel());
|
||||
ConfMan.set("nosubtitles", !gui._subtitles);
|
||||
ConfMan.set("object_labels", gui._pointerTextSelected);
|
||||
ConfMan.set("reverse_stereo", gui._stereoReversed);
|
||||
ConfMan.set("nosubtitles", !_subtitles);
|
||||
ConfMan.set("object_labels", _pointerTextSelected);
|
||||
ConfMan.set("reverse_stereo", _stereoReversed);
|
||||
|
||||
ConfMan.flushToDisk();
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
void updateGraphicsLevel(int newLevel);
|
||||
};
|
||||
|
||||
extern Gui gui;
|
||||
extern Gui *gui;
|
||||
|
||||
} // End of namespace Sword2
|
||||
|
||||
|
@ -243,19 +243,19 @@ void System_menu_mouse(void) {
|
||||
// call the relevent screen
|
||||
switch (hit) {
|
||||
case 0:
|
||||
gui.optionControl();
|
||||
gui->optionControl();
|
||||
break;
|
||||
case 1:
|
||||
gui.quitControl();
|
||||
gui->quitControl();
|
||||
break;
|
||||
case 2:
|
||||
gui.saveControl();
|
||||
gui->saveControl();
|
||||
break;
|
||||
case 3:
|
||||
gui.restoreControl();
|
||||
gui->restoreControl();
|
||||
break;
|
||||
case 4:
|
||||
gui.restartControl();
|
||||
gui->restartControl();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -877,7 +877,7 @@ void CreatePointerText(uint32 textId, uint32 pointerRes) {
|
||||
int16 xOffset, yOffset;
|
||||
uint8 justification;
|
||||
|
||||
if (gui._pointerTextSelected) {
|
||||
if (gui->_pointerTextSelected) {
|
||||
if (textId) {
|
||||
// check what the pointer is, to set offsets
|
||||
// correctly for text position
|
||||
|
@ -959,7 +959,7 @@ int32 Logic::fnISpeak(int32 *params) {
|
||||
// for this line either, then just quit back to script right
|
||||
// now!
|
||||
|
||||
if (gui._subtitles == 0 && WantSpeechForLine(params[S_WAV]) == 0)
|
||||
if (gui->_subtitles == 0 && WantSpeechForLine(params[S_WAV]) == 0)
|
||||
return IR_CONT;
|
||||
|
||||
if (cycle_skip == 0) {
|
||||
@ -1191,7 +1191,7 @@ int32 Logic::fnISpeak(int32 *params) {
|
||||
}
|
||||
|
||||
// if we want subtitles, or speech failed to load
|
||||
if (gui._subtitles || speechRunning == 0) {
|
||||
if (gui->_subtitles || speechRunning == 0) {
|
||||
// then we're going to show the text
|
||||
textRunning = 1;
|
||||
|
||||
|
@ -137,6 +137,7 @@ Sword2Engine::Sword2Engine(GameDetector *detector, OSystem *syst)
|
||||
|
||||
g_sound = _sound = new Sound(_mixer);
|
||||
g_display = _display = new Display(640, 480);
|
||||
gui = new Gui();
|
||||
|
||||
_newgui = g_gui;
|
||||
_debugger = new Debugger(this);
|
||||
@ -159,6 +160,7 @@ Sword2Engine::~Sword2Engine() {
|
||||
delete _sound;
|
||||
delete _display;
|
||||
delete _debugger;
|
||||
delete gui;
|
||||
}
|
||||
|
||||
void Sword2Engine::errorString(const char *buf1, char *buf2) {
|
||||
@ -301,7 +303,7 @@ void Sword2Engine::go() {
|
||||
// via a window, thus time becomes a loop.
|
||||
|
||||
debug(5, "CALLING: readOptionSettings");
|
||||
gui.readOptionSettings();
|
||||
gui->readOptionSettings();
|
||||
|
||||
debug(5, "CALLING: InitialiseGame");
|
||||
if (InitialiseGame()) {
|
||||
@ -314,7 +316,7 @@ void Sword2Engine::go() {
|
||||
RestoreGame(_saveSlot);
|
||||
else { // show restore menu
|
||||
Set_mouse(NORMAL_MOUSE_ID);
|
||||
if (!gui.restoreControl())
|
||||
if (!gui->restoreControl())
|
||||
Start_game();
|
||||
}
|
||||
} else
|
||||
@ -517,8 +519,8 @@ void PauseGame(void) {
|
||||
// if level at max, turn down because palette-matching won't work
|
||||
// when dimmed
|
||||
|
||||
if (gui._currentGraphicsLevel == 3) {
|
||||
gui.updateGraphicsLevel(2);
|
||||
if (gui->_currentGraphicsLevel == 3) {
|
||||
gui->updateGraphicsLevel(2);
|
||||
graphics_level_fudged = 1;
|
||||
}
|
||||
|
||||
@ -545,7 +547,7 @@ void UnpauseGame(void) {
|
||||
|
||||
// If graphics level at max, turn up again
|
||||
if (graphics_level_fudged) {
|
||||
gui.updateGraphicsLevel(3);
|
||||
gui->updateGraphicsLevel(3);
|
||||
graphics_level_fudged = 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user