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

gamemessage.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/gamemessage.h"
00024 
00025 #include "common/file.h"
00026 #include "common/ini-file.h"
00027 
00028 #include "gui/message.h"
00029 
00030 namespace Stark {
00031 
00032 GameMessage::GameMessage() :
00033         _texts() {
00034     Common::File tmp;
00035     if (!tmp.open("language.ini")) {
00036         warning("Unable to open 'language.ini'");
00037         return;
00038     }
00039 
00040     // Skip the head of the language.ini that is in an unsupported format
00041     Common::String line;
00042     while (!tmp.eos() && !tmp.err()) {
00043         line = tmp.readLine();
00044         if (line.size() > 2 && line[0] == '-' && line[1] == '-') {
00045             break;
00046         }
00047     }
00048 
00049     Common::INIFile file;
00050     if(file.loadFromStream(tmp)) {
00051         Common::String section = "Language";
00052         Common::String key, text;
00053 
00054         for (uint i = 2; i <= 400; ++i) {
00055             key = Common::String::format("%03d", i);
00056             if (file.hasKey(key, section)) {
00057                 file.getKey(key, section, text);
00058                 _texts[i] = text;
00059             }
00060         }
00061     }
00062 
00063     // Pre-process some of the texts
00064     if (_texts.contains(kYes)) {
00065         Common::replace(_texts[kYes], "&", "");
00066     }
00067     if (_texts.contains(kNo)) {
00068         Common::replace(_texts[kNo], "&", "");
00069     }
00070     if (_texts.contains(kOverwriteSave)) {
00071         Common::replace(_texts[kOverwriteSave], "\\n", "\n");
00072     }
00073 }
00074 
00075 Common::String GameMessage::getDefaultText(TextKey key) {
00076     switch(key) {
00077         case kOverwriteSave:
00078             return "Are you sure you want to overwrite the savegame:\n'%s' ?";
00079         case kEndAndLoad:
00080             return "Are you sure you want to end your current game and load a new one ?";
00081         case kInventory:
00082             return "Inventory";
00083         case kOptions:
00084             return "Options";
00085         case kQuit:
00086             return "Quit";
00087         case kQuitGamePrompt:
00088             return "Are you sure you want to quit this game ?";
00089         case kQuitPrompt:
00090             return "Are you sure you want to quit ?";
00091         case kYes:
00092             return "Yes";
00093         case kNo:
00094             return "No";
00095         default:
00096             return "Unimplemented message text";
00097     }
00098 }
00099 
00100 } // End of namespace Stark


Generated on Sat Mar 23 2019 05:01:39 for ResidualVM by doxygen 1.7.1
curved edge   curved edge