mirror of
https://github.com/libretro/scummvm.git
synced 2025-05-13 09:36:21 +00:00
STARK: Obtain the chapter title and subtitle from chapters.ini
This commit is contained in:
parent
99ed19930b
commit
7fecbcbffe
@ -80,6 +80,7 @@ MODULE_OBJS := \
|
||||
services/staticprovider.o \
|
||||
services/userinterface.o \
|
||||
services/settings.o \
|
||||
services/gamechapter.o \
|
||||
stark.o \
|
||||
tools/abstractsyntaxtree.o \
|
||||
tools/block.o \
|
||||
|
63
engines/stark/services/gamechapter.cpp
Normal file
63
engines/stark/services/gamechapter.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
/* ResidualVM - A 3D game interpreter
|
||||
*
|
||||
* ResidualVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the AUTHORS
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "engines/stark/services/gamechapter.h"
|
||||
#include "engines/stark/services/services.h"
|
||||
#include "engines/stark/services/global.h"
|
||||
|
||||
#include "common/archive.h"
|
||||
#include "common/stream.h"
|
||||
#include "common/tokenizer.h"
|
||||
#include "common/debug.h"
|
||||
|
||||
namespace Stark {
|
||||
|
||||
GameChapter::GameChapter() {
|
||||
Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember("chapters.ini");
|
||||
if (!stream) {
|
||||
error("Opening 'chapters.ini' failed");
|
||||
return;
|
||||
}
|
||||
|
||||
Common::String line, title, subtitle;
|
||||
|
||||
// Assume that the formats of all chapters.ini are the same
|
||||
stream->readLine();
|
||||
while (!stream->eos()) {
|
||||
_chapterEntries.push_back(ChapterEntry());
|
||||
|
||||
line = stream->readLine();
|
||||
Common::StringTokenizer tokens(line, "=:");
|
||||
|
||||
tokens.nextToken();
|
||||
_chapterEntries.back().title = tokens.nextToken();
|
||||
_chapterEntries.back().title.trim();
|
||||
_chapterEntries.back().subtitle = tokens.nextToken();
|
||||
_chapterEntries.back().subtitle.trim();
|
||||
}
|
||||
}
|
||||
|
||||
int GameChapter::getActualCurrentChapter() {
|
||||
return StarkGlobal->getCurrentChapter() / 10;
|
||||
}
|
||||
|
||||
} // End of namespace Stark
|
62
engines/stark/services/gamechapter.h
Normal file
62
engines/stark/services/gamechapter.h
Normal file
@ -0,0 +1,62 @@
|
||||
/* ResidualVM - A 3D game interpreter
|
||||
*
|
||||
* ResidualVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the AUTHORS
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef STARK_SERVICES_GAME_CHAPTER_H
|
||||
#define STARK_SERVICES_GAME_CHAPTER_H
|
||||
|
||||
#include "common/str.h"
|
||||
#include "common/array.h"
|
||||
|
||||
namespace Stark {
|
||||
|
||||
/**
|
||||
* Game chapter services
|
||||
*
|
||||
* Provide the game chapter's title and subtitle
|
||||
*/
|
||||
class GameChapter {
|
||||
public:
|
||||
GameChapter();
|
||||
~GameChapter() {}
|
||||
|
||||
Common::String getCurrentChapterTitle() {
|
||||
return _chapterEntries[getActualCurrentChapter()].title;
|
||||
}
|
||||
|
||||
Common::String getCurrentChapterSubtitle() {
|
||||
return _chapterEntries[getActualCurrentChapter()].subtitle;
|
||||
}
|
||||
|
||||
private:
|
||||
struct ChapterEntry {
|
||||
Common::String title;
|
||||
Common::String subtitle;
|
||||
};
|
||||
|
||||
Common::Array<ChapterEntry> _chapterEntries;
|
||||
|
||||
int getActualCurrentChapter();
|
||||
};
|
||||
|
||||
} // End of namespace Stark
|
||||
|
||||
#endif // STARK_SERVICES_GAME_CHAPTER_H
|
@ -49,6 +49,7 @@ class StaticProvider;
|
||||
class Scene;
|
||||
class UserInterface;
|
||||
class Settings;
|
||||
class GameChapter;
|
||||
|
||||
/**
|
||||
* Public services available as a singleton
|
||||
@ -70,6 +71,7 @@ public:
|
||||
fontProvider = nullptr;
|
||||
gameDescription = nullptr;
|
||||
settings = nullptr;
|
||||
gameChapter = nullptr;
|
||||
}
|
||||
|
||||
ArchiveLoader *archiveLoader;
|
||||
@ -86,6 +88,7 @@ public:
|
||||
FontProvider *fontProvider;
|
||||
const ADGameDescription *gameDescription;
|
||||
Settings *settings;
|
||||
GameChapter *gameChapter;
|
||||
};
|
||||
|
||||
/** Shortcuts for accessing the services. */
|
||||
@ -103,6 +106,7 @@ public:
|
||||
#define StarkFontProvider StarkServices::instance().fontProvider
|
||||
#define StarkGameDescription StarkServices::instance().gameDescription
|
||||
#define StarkSettings StarkServices::instance().settings
|
||||
#define StarkGameChapter StarkServices::instance().gameChapter
|
||||
|
||||
} // End of namespace Stark
|
||||
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "engines/stark/services/stateprovider.h"
|
||||
#include "engines/stark/services/staticprovider.h"
|
||||
#include "engines/stark/services/settings.h"
|
||||
#include "engines/stark/services/gamechapter.h"
|
||||
#include "engines/stark/gfx/driver.h"
|
||||
#include "engines/stark/gfx/framelimiter.h"
|
||||
|
||||
@ -72,6 +73,7 @@ StarkEngine::StarkEngine(OSystem *syst, const ADGameDescription *gameDesc) :
|
||||
_userInterface(nullptr),
|
||||
_fontProvider(nullptr),
|
||||
_settings(nullptr),
|
||||
_gameChapter(nullptr),
|
||||
_lastClickTime(0) {
|
||||
// Add the available debug channels
|
||||
DebugMan.addDebugChannel(kDebugArchive, "Archive", "Debug the archive loading");
|
||||
@ -97,6 +99,7 @@ StarkEngine::~StarkEngine() {
|
||||
delete _userInterface;
|
||||
delete _fontProvider;
|
||||
delete _settings;
|
||||
delete _gameChapter;
|
||||
|
||||
StarkServices::destroy();
|
||||
}
|
||||
@ -122,6 +125,7 @@ Common::Error StarkEngine::run() {
|
||||
_gameInterface = new GameInterface();
|
||||
_userInterface = new UserInterface(_gfx);
|
||||
_settings = new Settings(_mixer);
|
||||
_gameChapter = new GameChapter();
|
||||
|
||||
// Setup the public services
|
||||
StarkServices &services = StarkServices::instance();
|
||||
@ -139,6 +143,7 @@ Common::Error StarkEngine::run() {
|
||||
services.fontProvider = _fontProvider;
|
||||
services.gameDescription = _gameDescription;
|
||||
services.settings = _settings;
|
||||
services.gameChapter = _gameChapter;
|
||||
|
||||
// Load global resources
|
||||
_staticProvider->init();
|
||||
|
@ -50,6 +50,7 @@ class StaticProvider;
|
||||
class ResourceProvider;
|
||||
class UserInterface;
|
||||
class Settings;
|
||||
class GameChapter;
|
||||
|
||||
class StarkEngine : public Engine {
|
||||
public:
|
||||
@ -90,6 +91,8 @@ private:
|
||||
ResourceProvider *_resourceProvider;
|
||||
FontProvider *_fontProvider;
|
||||
Settings *_settings;
|
||||
GameChapter *_gameChapter;
|
||||
|
||||
Common::RandomSource *_randomSource;
|
||||
|
||||
const ADGameDescription *_gameDescription;
|
||||
|
@ -122,50 +122,11 @@ void DiaryIndexScreen::quitHandler() {
|
||||
}
|
||||
|
||||
void DiaryIndexScreen::loadHandler() {
|
||||
// TODO: Implement the original load screen
|
||||
StarkUserInterface->changeScreen(Screen::kScreenLoadMenu);
|
||||
|
||||
/*
|
||||
GUI::SaveLoadChooser slc(_("Load game:"), _("Load"), false);
|
||||
|
||||
g_engine->pauseEngine(true);
|
||||
int slot = slc.runModalWithCurrentTarget();
|
||||
g_engine->pauseEngine(false);
|
||||
|
||||
if (slot >= 0) {
|
||||
StarkUserInterface->changeScreen(Screen::kScreenGame);
|
||||
|
||||
Common::Error loadError = g_engine->loadGameState(slot);
|
||||
|
||||
if (loadError.getCode() != Common::kNoError) {
|
||||
GUI::MessageDialog dialog(loadError.getDesc());
|
||||
dialog.runModal();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void DiaryIndexScreen::saveHandler() {
|
||||
// TODO: Implement the original save screen
|
||||
StarkUserInterface->changeScreen(Screen::kScreenSaveMenu);
|
||||
|
||||
/*
|
||||
GUI::SaveLoadChooser slc(_("Save game:"), _("Save"), true);
|
||||
|
||||
g_engine->pauseEngine(true);
|
||||
int slot = slc.runModalWithCurrentTarget();
|
||||
g_engine->pauseEngine(false);
|
||||
|
||||
if (slot >= 0) {
|
||||
Common::Error loadError = g_engine->saveGameState(slot, slc.getResultString());
|
||||
|
||||
if (loadError.getCode() != Common::kNoError) {
|
||||
GUI::MessageDialog dialog(loadError.getDesc());
|
||||
dialog.runModal();
|
||||
}
|
||||
|
||||
StarkUserInterface->changeScreen(Screen::kScreenGame);
|
||||
}*/
|
||||
}
|
||||
|
||||
} // End of namespace Stark
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "engines/stark/services/stateprovider.h"
|
||||
#include "engines/stark/services/global.h"
|
||||
#include "engines/stark/services/settings.h"
|
||||
#include "engines/stark/services/gamechapter.h"
|
||||
|
||||
#include "engines/stark/gfx/driver.h"
|
||||
#include "engines/stark/gfx/texture.h"
|
||||
@ -151,16 +152,7 @@ void SaveMenuScreen::open() {
|
||||
}
|
||||
|
||||
void SaveMenuScreen::onWidgetSelected(SaveDataWidget *widget) {
|
||||
int chapter = StarkGlobal->getCurrentChapter() / 10;
|
||||
|
||||
Common::String desc;
|
||||
if (chapter == 0) {
|
||||
desc = "Prologue";
|
||||
} else {
|
||||
desc = Common::String::format("Chapter %d", chapter);
|
||||
}
|
||||
|
||||
g_engine->saveGameState(widget->getSlot(), desc);
|
||||
checkError(g_engine->saveGameState(widget->getSlot(), StarkGameChapter->getCurrentChapterTitle()));
|
||||
|
||||
// Freeze the screen for a while to let the user notice the change
|
||||
widget->loadSaveDataElements();
|
||||
@ -179,7 +171,7 @@ void LoadMenuScreen::open() {
|
||||
}
|
||||
|
||||
void LoadMenuScreen::onWidgetSelected(SaveDataWidget *widget) {
|
||||
g_engine->loadGameState(widget->getSlot());
|
||||
checkError(g_engine->loadGameState(widget->getSlot()));
|
||||
}
|
||||
|
||||
SaveDataWidget::SaveDataWidget(int slot, Gfx::Driver *gfx, SaveLoadMenuScreen *screen) :
|
||||
|
Loading…
x
Reference in New Issue
Block a user