WAGE: Implemented the rest of menu commands

This commit is contained in:
Eugene Sandulenko 2023-09-10 18:07:53 +02:00
parent 745b3e3124
commit d40bf2ce6c
No known key found for this signature in database
GPG Key ID: 014D387312D34F08
6 changed files with 50 additions and 4 deletions

View File

@ -268,6 +268,8 @@ Designed *Obj::removeFromCharOrScene() {
}
void Obj::resetState(Chr *owner, Scene *scene) {
removeFromCharOrScene();
warning("STUB: Obj::resetState()");
}

View File

@ -64,9 +64,9 @@ namespace Wage {
static const Graphics::MacMenuData menuSubItems[] = {
{ kMenuHighLevel, "File", 0, 0, false },
{ kMenuHighLevel, "Edit", 0, 0, false },
{ kMenuFile, "New", kMenuActionNew, 0, false },
{ kMenuFile, "New", kMenuActionNew, 0, true },
{ kMenuFile, "Open...", kMenuActionOpen, 0, true },
{ kMenuFile, "Close", kMenuActionClose, 0, true },
{ kMenuFile, "Close", kMenuActionClose, 0, false },
{ kMenuFile, "Save", kMenuActionSave, 0, false },
{ kMenuFile, "Save as...", kMenuActionSaveAs, 0, true },
{ kMenuFile, "Revert", kMenuActionRevert, 0, false },
@ -266,10 +266,20 @@ void Gui::executeMenuCommand(int action, Common::String &text) {
case kMenuActionAbout:
_engine->aboutDialog();
break;
case kMenuActionNew:
_engine->_restartRequested = true;
break;
case kMenuActionClose:
// This is a no-op as we do not let new game to be opened
break;
case kMenuActionRevert:
warning("STUB: executeMenuCommand: action: %d", action);
if (_engine->_defaultSaveSlot != -1) {
_engine->_isGameOver = false;
_engine->loadGameState(_engine->_defaultSaveSlot);
}
break;
case kMenuActionOpen:
@ -410,4 +420,8 @@ void Gui::enableSave() {
_menu->enableCommand(kMenuFile, kMenuActionSave, true);
}
void Gui::enableRevert() {
_menu->enableCommand(kMenuFile, kMenuActionRevert, true);
}
} // End of namespace Wage

View File

@ -137,6 +137,7 @@ public:
void disableAllMenus();
void enableNewGameMenus();
void enableSave();
void enableRevert();
bool processSceneEvents(WindowClick click, Common::Event &event);
void executeMenuCommand(int action, Common::String &text);

View File

@ -700,6 +700,7 @@ int WageEngine::loadGame(int slotId) {
}
Common::Error WageEngine::loadGameState(int slot) {
warning("LOADING %d", slot);
if (loadGame(slot) == 0) {
if (slot != getAutosaveSlot()) {
_defaultSaveSlot = slot;

View File

@ -154,6 +154,9 @@ Common::Error WageEngine::run() {
while (!_shouldQuit) {
processEvents();
if (_restartRequested)
restart();
_gui->draw();
g_system->updateScreen();
g_system->delayMillis(50);
@ -162,6 +165,27 @@ Common::Error WageEngine::run() {
return Common::kNoError;
}
void WageEngine::restart() {
_restartRequested = false;
delete _gui;
delete _world;
_world = new World(this);
if (!_world->loadWorld(_resManager))
return;
_shouldQuit = false;
_gui = new Gui(this);
_temporarilyHidden = true;
performInitialSetup();
Common::String input("look");
processTurn(&input, NULL);
}
void WageEngine::processEvents() {
Common::Event event;
@ -189,6 +213,7 @@ void WageEngine::processEvents() {
processTurn(&_inputText, NULL);
_gui->disableUndo();
_gui->enableRevert();
break;
}
default:
@ -365,7 +390,7 @@ void WageEngine::wearObjs(Chr* chr) {
}
void WageEngine::doClose() {
warning("STUB: doClose()");
// No op on ScummVM since we do not allow to load arbitrary games
}
Scene *WageEngine::getSceneByName(Common::String &location) {

View File

@ -204,6 +204,7 @@ public:
bool _temporarilyHidden;
bool _isGameOver;
bool _commandWasQuick;
bool _restartRequested = false;
bool _shouldQuit;
int _defaultSaveSlot = -1;
@ -242,6 +243,8 @@ private:
int saveGame(const Common::String &fileName, const Common::String &descriptionString);
int loadGame(int slotId);
void restart();
private:
const ADGameDescription *_gameDescription;