ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

gamechapter.cpp

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the AUTHORS
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #include "engines/stark/services/gamechapter.h"
00024 #include "engines/stark/services/services.h"
00025 #include "engines/stark/services/global.h"
00026 
00027 #include "common/tokenizer.h"
00028 #include "common/ini-file.h"
00029 
00030 namespace Stark {
00031 
00032 GameChapter::GameChapter() : _errorText("Unknown Chapter") {
00033     Common::INIFile file;
00034     if (!file.loadFromFile("chapters.ini")) {
00035         error("Opening file 'chapters.ini' failed");
00036         return;
00037     }
00038 
00039     Common::String section = file.getSections().front().name;
00040     
00041     int index = 0;
00042     Common::String key = Common::String::format("%02d", index);
00043     Common::String value;
00044 
00045     while (file.hasKey(key, section)) {
00046         file.getKey(key, section, value);
00047         _chapterEntries.push_back(ChapterEntry());
00048 
00049         Common::StringTokenizer tokens(value, ":");
00050         _chapterEntries.back().title = tokens.nextToken();
00051         _chapterEntries.back().title.trim();
00052         _chapterEntries.back().subtitle = tokens.nextToken();
00053         _chapterEntries.back().subtitle.trim();
00054 
00055         ++index;
00056         key = Common::String::format("%02d", index);
00057     }
00058 
00059     if (index < _numChapter) {
00060         error("File 'chapters.ini' is incomplete");
00061     }
00062 }
00063 
00064 const Common::String &GameChapter::getCurrentChapterTitle() const {
00065     return getChapterTitle(StarkGlobal->getCurrentChapter());
00066 }
00067 
00068 const Common::String &GameChapter::getCurrentChapterSubtitle() const {
00069     return getChapterSubtitle(StarkGlobal->getCurrentChapter());
00070 }
00071 
00072 } // End of namespace Stark


Generated on Sat May 25 2019 05:00:45 for ResidualVM by doxygen 1.7.1
curved edge   curved edge