ICB: Added return to launcher functionality

This commit is contained in:
Paweł Kołodziejski 2021-03-13 07:48:34 +01:00
parent 0a305db7ec
commit 22fb7015ff
3 changed files with 34 additions and 19 deletions

View File

@ -135,9 +135,15 @@ Common::KeymapArray IcbEngine::initKeymapsIcb(const char *target) {
return Keymap::arrayOf(engineKeyMap);
}
bool IcbEngine::hasFeature(EngineFeature f) const {
return
(f == kSupportsReturnToLauncher);
}
// TODO: Refactor, this is currently implemented in p4_pc.cpp
void InitEngine(const char *cmdLine);
bool mainLoopIteration();
void quitEngine();
Common::Error IcbEngine::run() {
initGfx(false, false);
@ -152,6 +158,10 @@ void IcbEngine::initGfx(bool hwAccel, bool fullscreen) {
void IcbEngine::mainLoop() {
while (mainLoopIteration()) {
if (shouldQuit()) {
quitEngine();
break;
}
}
}

View File

@ -42,10 +42,11 @@ public:
Common::RandomSource *getRandomSource() { return _randomSource; }
static Common::Array<Common::Keymap *> initKeymapsIcb(const char *target);
bool hasFeature(EngineFeature f) const override;
protected:
// Engine APIs
virtual Common::Error run();
virtual Common::Error run() override;
private:
void initGfx(bool hwAccel, bool fullscreen);

View File

@ -262,6 +262,27 @@ void InitEngine(const char *lpCmdLine) {
ReadConfigFromIniFile();
}
void quitEngine() {
Zdebug("\nap closed");
Zdebug("Be Vigilant!\n");
if (g_mission)
g_icb_mission->___delete_mission();
Close_Sound_Engine();
if (surface_manager)
delete surface_manager;
Save_config_file(); // write user options ini file
DestoryRevRenderDevice();
// Shutdown the runtime cluster manager
g_theClusterManager->Shutdown();
DestroyGlobalObjects();
}
bool mainLoopIteration() {
Common::Event event;
@ -309,24 +330,7 @@ bool mainLoopIteration() {
break;
case Common::EVENT_QUIT:
Zdebug("\nap closed");
Zdebug("Be Vigilant!\n");
if (g_mission)
g_icb_mission->___delete_mission();
Close_Sound_Engine();
if (surface_manager)
delete surface_manager;
Save_config_file(); // write user options ini file
DestoryRevRenderDevice();
// Shutdown the runtime cluster manager
g_theClusterManager->Shutdown();
DestroyGlobalObjects();
quitEngine();
return false;
default:
break;