mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-31 07:53:36 +00:00
More refactoring for gui code.
svn-id: r29355
This commit is contained in:
parent
288f47e034
commit
7c8bf86a45
@ -434,7 +434,8 @@ void Parallaction_ns::_c_finito(void *parm) {
|
||||
_gfx->updateScreen();
|
||||
waitUntilLeftClick();
|
||||
|
||||
guiSelectCharacter();
|
||||
selectCharacterForNewLocation();
|
||||
_engineFlags |= kEngineChangeLocation;
|
||||
}
|
||||
|
||||
// this code saves main character animation from being removed from the following code
|
||||
@ -547,7 +548,8 @@ void Parallaction_ns::_c_endIntro(void *parm) {
|
||||
waitUntilLeftClick();
|
||||
|
||||
_engineFlags &= ~kEngineBlockInput;
|
||||
guiSelectCharacter();
|
||||
selectCharacterForNewLocation();
|
||||
_engineFlags |= kEngineChangeLocation;
|
||||
} else {
|
||||
waitUntilLeftClick();
|
||||
}
|
||||
|
@ -100,11 +100,24 @@ static uint16 _pcKeys[][PASSWORD_LEN] = {
|
||||
{ 0, 2, 8, 5, 5, 1 } // donna
|
||||
};
|
||||
|
||||
static const char *_charStartLocation[] = {
|
||||
"test.dough",
|
||||
"test.dino",
|
||||
"test.donna"
|
||||
};
|
||||
|
||||
enum {
|
||||
NEW_GAME,
|
||||
LOAD_GAME
|
||||
};
|
||||
|
||||
enum {
|
||||
START_DEMO,
|
||||
START_INTRO,
|
||||
GAME_LOADED,
|
||||
SELECT_CHARACTER
|
||||
};
|
||||
|
||||
void Parallaction_ns::guiStart() {
|
||||
|
||||
_disk->selectArchive((getFeatures() & GF_LANG_MULT) ? "disk1" : "disk0");
|
||||
@ -116,18 +129,49 @@ void Parallaction_ns::guiStart() {
|
||||
_language = guiChooseLanguage();
|
||||
_disk->setLanguage(_language);
|
||||
|
||||
int event;
|
||||
|
||||
if (getFeatures() & GF_DEMO) {
|
||||
strcpy(_location._name, "fognedemo.dough");
|
||||
return;
|
||||
event = START_DEMO;
|
||||
} else {
|
||||
if (guiSelectGame() == NEW_GAME) {
|
||||
event = guiNewGame();
|
||||
} else {
|
||||
event = loadGame() ? GAME_LOADED : START_INTRO;
|
||||
}
|
||||
}
|
||||
|
||||
if (guiSelectGame() == NEW_GAME) {
|
||||
guiNewGame();
|
||||
switch (event) {
|
||||
case START_DEMO:
|
||||
strcpy(_location._name, "fognedemo.dough");
|
||||
break;
|
||||
|
||||
case START_INTRO:
|
||||
strcpy(_location._name, "fogne.dough");
|
||||
break;
|
||||
|
||||
case GAME_LOADED:
|
||||
// nothing to do here
|
||||
return;
|
||||
|
||||
case SELECT_CHARACTER:
|
||||
selectCharacterForNewLocation();
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void Parallaction_ns::selectCharacterForNewLocation() {
|
||||
int character = guiSelectCharacter();
|
||||
if (character == -1)
|
||||
error("invalid character selected from menu screen");
|
||||
|
||||
strcpy(_location._name, _charStartLocation[character]);
|
||||
}
|
||||
|
||||
|
||||
void Parallaction_ns::guiSplash() {
|
||||
|
||||
showSlide("intro");
|
||||
@ -140,7 +184,7 @@ void Parallaction_ns::guiSplash() {
|
||||
|
||||
}
|
||||
|
||||
void Parallaction_ns::guiNewGame() {
|
||||
int Parallaction_ns::guiNewGame() {
|
||||
|
||||
const char **v14 = introMsg3;
|
||||
|
||||
@ -167,13 +211,10 @@ void Parallaction_ns::guiNewGame() {
|
||||
showCursor(true);
|
||||
|
||||
if (_mouseButtons != kMouseRightUp) {
|
||||
strcpy(_location._name, "fogne.dough");
|
||||
return; // show intro
|
||||
return START_INTRO;
|
||||
}
|
||||
|
||||
guiSelectCharacter();
|
||||
|
||||
return; // start game
|
||||
return SELECT_CHARACTER;
|
||||
}
|
||||
|
||||
uint16 Parallaction_ns::guiChooseLanguage() {
|
||||
@ -226,8 +267,8 @@ uint16 Parallaction_ns::guiChooseLanguage() {
|
||||
}
|
||||
}
|
||||
|
||||
g_system->delayMillis(30);
|
||||
_gfx->updateScreen();
|
||||
g_system->delayMillis(30);
|
||||
|
||||
} while (true);
|
||||
|
||||
@ -266,23 +307,11 @@ uint16 Parallaction_ns::guiSelectGame() {
|
||||
|
||||
}
|
||||
|
||||
g_system->delayMillis(30);
|
||||
_gfx->updateScreen();
|
||||
g_system->delayMillis(30);
|
||||
}
|
||||
|
||||
if (_si == 0) return NEW_GAME; // new game
|
||||
|
||||
// load game
|
||||
|
||||
// TODO: allow the user to change her mind in this screen, that is
|
||||
// don't force her to start at the intro when she closes her load
|
||||
// game window without picking a savegame.
|
||||
// The 2 strcpy's below act as workaround to prevent crashes for
|
||||
// time being.
|
||||
strcpy(_location._name, "fogne.dough");
|
||||
loadGame();
|
||||
|
||||
return LOAD_GAME; // load game
|
||||
return _si ? LOAD_GAME : NEW_GAME;
|
||||
}
|
||||
|
||||
|
||||
@ -313,7 +342,7 @@ int Parallaction_ns::guiGetSelectedBlock(const Common::Point &p, Common::Rect &r
|
||||
//
|
||||
// character selection and protection
|
||||
//
|
||||
void Parallaction_ns::guiSelectCharacter() {
|
||||
int Parallaction_ns::guiSelectCharacter() {
|
||||
debugC(1, kDebugMenu, "Parallaction_ns::guiselectCharacter()");
|
||||
|
||||
Graphics::Surface v14;
|
||||
@ -331,7 +360,7 @@ void Parallaction_ns::guiSelectCharacter() {
|
||||
|
||||
uint16 (*keys)[PASSWORD_LEN] = (getPlatform() == Common::kPlatformAmiga && (getFeatures() & GF_LANG_MULT)) ? _amigaKeys : _pcKeys;
|
||||
uint16 points[3];
|
||||
bool matched = false;
|
||||
int character = -1;
|
||||
uint16 _di = 0;
|
||||
|
||||
while (true) {
|
||||
@ -349,7 +378,6 @@ void Parallaction_ns::guiSelectCharacter() {
|
||||
_mouseButtons = kMouseNone;
|
||||
do {
|
||||
updateInput();
|
||||
g_system->delayMillis(30);
|
||||
_gfx->updateScreen();
|
||||
} while (_mouseButtons != kMouseLeftUp); // waits for left click
|
||||
|
||||
@ -366,7 +394,7 @@ void Parallaction_ns::guiSelectCharacter() {
|
||||
}
|
||||
|
||||
if (points[i] == PASSWORD_LEN) {
|
||||
matched = true;
|
||||
character = i;
|
||||
}
|
||||
}
|
||||
|
||||
@ -374,7 +402,7 @@ void Parallaction_ns::guiSelectCharacter() {
|
||||
}
|
||||
}
|
||||
|
||||
if (matched) {
|
||||
if (character != -1) {
|
||||
break;
|
||||
}
|
||||
|
||||
@ -387,24 +415,12 @@ void Parallaction_ns::guiSelectCharacter() {
|
||||
_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront);
|
||||
}
|
||||
|
||||
if (points[1] == PASSWORD_LEN) {
|
||||
sprintf(_location._name, "test.%s", _dinoName);
|
||||
} else
|
||||
if (points[2] == PASSWORD_LEN) {
|
||||
sprintf(_location._name, "test.%s", _donnaName);
|
||||
} else
|
||||
if (points[0] == PASSWORD_LEN) {
|
||||
sprintf(_location._name, "test.%s", _doughName);
|
||||
}
|
||||
|
||||
_gfx->setBlackPalette();
|
||||
_gfx->updateScreen();
|
||||
|
||||
_engineFlags |= kEngineChangeLocation;
|
||||
|
||||
v14.free();
|
||||
|
||||
return;
|
||||
return character;
|
||||
|
||||
}
|
||||
|
||||
|
@ -369,8 +369,8 @@ public:
|
||||
|
||||
int init();
|
||||
|
||||
virtual void loadGame() = 0;
|
||||
virtual void saveGame() = 0;
|
||||
virtual bool loadGame() = 0;
|
||||
virtual bool saveGame() = 0;
|
||||
|
||||
uint16 updateInput();
|
||||
|
||||
@ -661,8 +661,8 @@ public:
|
||||
const JobFn *_jobsFn;
|
||||
JobOpcode* createJobOpcode(uint functionId, Job *job);
|
||||
|
||||
void loadGame();
|
||||
void saveGame();
|
||||
bool loadGame();
|
||||
bool saveGame();
|
||||
|
||||
|
||||
private:
|
||||
@ -902,10 +902,12 @@ protected:
|
||||
DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(move);
|
||||
DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(endscript);
|
||||
|
||||
void selectCharacterForNewLocation();
|
||||
|
||||
void guiStart();
|
||||
void guiSelectCharacter();
|
||||
int guiSelectCharacter();
|
||||
void guiSplash();
|
||||
void guiNewGame();
|
||||
int guiNewGame();
|
||||
uint16 guiChooseLanguage();
|
||||
uint16 guiSelectGame();
|
||||
int guiGetSelectedBlock(const Common::Point &p, Common::Rect& r);
|
||||
|
@ -259,19 +259,16 @@ void Parallaction_ns::callFunction(uint index, void* parm) {
|
||||
|
||||
int Parallaction_ns::go() {
|
||||
|
||||
_globalTable = _disk->loadTable("global");
|
||||
|
||||
guiStart();
|
||||
|
||||
LocationName locname;
|
||||
locname.bind(_location._name);
|
||||
|
||||
_char.setName(locname.character());
|
||||
changeCharacter(locname.character());
|
||||
|
||||
strcpy(_location._name, locname.location());
|
||||
|
||||
_globalTable = _disk->loadTable("global");
|
||||
|
||||
_engineFlags &= ~kEngineChangeLocation;
|
||||
changeCharacter(_char.getName());
|
||||
|
||||
strcpy(_saveData1, _location._name);
|
||||
parseLocation(_location._name);
|
||||
|
||||
@ -454,5 +451,4 @@ JobOpcode* Parallaction_ns::createJobOpcode(uint functionId, Job *job) {
|
||||
return new OpcodeImpl2<Parallaction_ns>(this, _jobsFn[functionId], job);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Parallaction
|
||||
|
@ -373,11 +373,11 @@ int Parallaction_ns::selectSaveFile(uint16 arg_0, const char* caption, const cha
|
||||
|
||||
|
||||
|
||||
void Parallaction_ns::loadGame() {
|
||||
bool Parallaction_ns::loadGame() {
|
||||
|
||||
int _di = selectSaveFile( 0, "Load file", "Load" );
|
||||
if (_di == -1) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
doLoadGame(_di);
|
||||
@ -387,18 +387,19 @@ void Parallaction_ns::loadGame() {
|
||||
|
||||
setArrowCursor();
|
||||
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Parallaction_ns::saveGame() {
|
||||
bool Parallaction_ns::saveGame() {
|
||||
|
||||
if (!scumm_stricmp(_location._name, "caveau"))
|
||||
return;
|
||||
if (!scumm_stricmp(_location._name, "caveau")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int slot = selectSaveFile( 1, "Save file", "Save" );
|
||||
if (slot == -1) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
doSaveGame(slot, _saveFileName.c_str());
|
||||
@ -406,9 +407,7 @@ void Parallaction_ns::saveGame() {
|
||||
GUI::TimedMessageDialog dialog("Saving game...", 1500);
|
||||
dialog.runModal();
|
||||
|
||||
return;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user