mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-09 11:20:56 +00:00
MM: Created YAML file reader for representing string constants
This commit is contained in:
parent
3aeb06b42e
commit
fe3d35a58c
14
devtools/create_mm/files/mm1/strings_en.yml
Normal file
14
devtools/create_mm/files/mm1/strings_en.yml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
dialogs:
|
||||||
|
ready:
|
||||||
|
1: " ARE YOU READY? "
|
||||||
|
2: "THEN PRESS ENTER!"
|
||||||
|
main_menu:
|
||||||
|
title1: "MIGHT AND MAGIC"
|
||||||
|
title2: "SECRET OF THE INNER SANCTUM"
|
||||||
|
title3: "OPTIONS"
|
||||||
|
title4: "-------"
|
||||||
|
option1: "'C'.......CREATE NEW CHARACTERS"
|
||||||
|
option2: "'V'.......VIEW ALL CHARACTERS"
|
||||||
|
option3: "'#'.......GO TO TOWN"
|
||||||
|
copyright1: "COPR. 1986,1987-JON VAN CANEGHEM"
|
||||||
|
copyright2: "ALL RIGHTS RESERVED"
|
1
devtools/create_mm/files/mm1/version.txt
Normal file
1
devtools/create_mm/files/mm1/version.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
1.0
|
@ -1,2 +1,3 @@
|
|||||||
engines/mm/detection.cpp
|
engines/mm/detection.cpp
|
||||||
|
engines/mm/utils/engine_data.cpp
|
||||||
engines/mm/xeen/saves.cpp
|
engines/mm/xeen/saves.cpp
|
||||||
|
44
engines/mm/mm1/globals.cpp
Normal file
44
engines/mm/mm1/globals.cpp
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/* ScummVM - Graphic Adventure Engine
|
||||||
|
*
|
||||||
|
* ScummVM is the legal property of its developers, whose names
|
||||||
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||||
|
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "engines/engine.h"
|
||||||
|
#include "mm/mm1/globals.h"
|
||||||
|
#include "mm/utils/engine_data.h"
|
||||||
|
|
||||||
|
namespace MM {
|
||||||
|
namespace MM1 {
|
||||||
|
|
||||||
|
bool Globals::load() {
|
||||||
|
// Initialise engine data for the game
|
||||||
|
Common::U32String errMsg;
|
||||||
|
if (!load_engine_data("mm1", 1, 0, errMsg)) {
|
||||||
|
GUIErrorMessage(errMsg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_strings.load("strings_en.yml"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace MM1
|
||||||
|
} // namespace MM
|
46
engines/mm/mm1/globals.h
Normal file
46
engines/mm/mm1/globals.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/* ScummVM - Graphic Adventure Engine
|
||||||
|
*
|
||||||
|
* ScummVM is the legal property of its developers, whose names
|
||||||
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||||
|
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MM1_GLOBALS_H
|
||||||
|
#define MM1_GLOBALS_H
|
||||||
|
|
||||||
|
#include "mm/utils/strings_data.h"
|
||||||
|
|
||||||
|
namespace MM {
|
||||||
|
namespace MM1 {
|
||||||
|
|
||||||
|
class Globals {
|
||||||
|
public:
|
||||||
|
StringsData _strings;
|
||||||
|
public:
|
||||||
|
Globals() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads data for the globals
|
||||||
|
*/
|
||||||
|
bool load();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace MM1
|
||||||
|
} // namespace MM
|
||||||
|
|
||||||
|
#endif
|
@ -43,10 +43,16 @@ MM1Engine::~MM1Engine() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Common::Error MM1Engine::run() {
|
Common::Error MM1Engine::run() {
|
||||||
|
// Initialize graphics mode
|
||||||
initGraphics(320, 200);
|
initGraphics(320, 200);
|
||||||
Gfx::GFX::setEgaPalette(0);
|
Gfx::GFX::setEgaPalette(0);
|
||||||
Views::TitleView screenView(this);
|
|
||||||
|
|
||||||
|
// Load globals
|
||||||
|
if (!_globals.load())
|
||||||
|
return Common::kNoError;
|
||||||
|
|
||||||
|
// Run the game
|
||||||
|
Views::TitleView screenView(this);
|
||||||
runGame();
|
runGame();
|
||||||
return Common::kNoError;
|
return Common::kNoError;
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "mm/detection.h"
|
#include "mm/detection.h"
|
||||||
#include "mm/mm.h"
|
#include "mm/mm.h"
|
||||||
#include "mm/mm1/events.h"
|
#include "mm/mm1/events.h"
|
||||||
|
#include "mm/mm1/globals.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the Might and Magic I engine
|
* This is the Might and Magic I engine
|
||||||
@ -41,6 +42,8 @@ private:
|
|||||||
// Engine APIs
|
// Engine APIs
|
||||||
Common::Error run() override;
|
Common::Error run() override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Globals _globals;
|
||||||
public:
|
public:
|
||||||
MM1Engine(OSystem *syst, const MightAndMagicGameDescription *gameDesc);
|
MM1Engine(OSystem *syst, const MightAndMagicGameDescription *gameDesc);
|
||||||
~MM1Engine() override;
|
~MM1Engine() override;
|
||||||
|
@ -3,7 +3,9 @@ MODULE := engines/mm
|
|||||||
MODULE_OBJS := \
|
MODULE_OBJS := \
|
||||||
metaengine.o \
|
metaengine.o \
|
||||||
utils/engine_data.o \
|
utils/engine_data.o \
|
||||||
|
utils/strings_data.o \
|
||||||
mm1/events.o \
|
mm1/events.o \
|
||||||
|
mm1/globals.o \
|
||||||
mm1/mm1.o \
|
mm1/mm1.o \
|
||||||
mm1/gfx/gfx.o \
|
mm1/gfx/gfx.o \
|
||||||
mm1/gfx/screen_decoder.o \
|
mm1/gfx/screen_decoder.o \
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
* within it, and as part of the release process, this folder will be
|
* within it, and as part of the release process, this folder will be
|
||||||
* zipped up as a file 'mm.dat', and included with ScummVM releases.
|
* zipped up as a file 'mm.dat', and included with ScummVM releases.
|
||||||
*
|
*
|
||||||
* For development purposes, if you go the Edit Game dialog for a
|
* For development purposes, if you go the Game Options dialog for a
|
||||||
* game in the ScummVM launcher, and set the extra path to
|
* game in the ScummVM launcher, and set the extra path to
|
||||||
* /devtools/create_mm, the engine will access the files directly
|
* /devtools/create_mm, the engine will access the files directly
|
||||||
* without requiring you to keep regenerating mm.dat.
|
* without requiring you to keep regenerating mm.dat.
|
||||||
|
98
engines/mm/utils/strings_data.cpp
Normal file
98
engines/mm/utils/strings_data.cpp
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
/* ScummVM - Graphic Adventure Engine
|
||||||
|
*
|
||||||
|
* ScummVM is the legal property of its developers, whose names
|
||||||
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||||
|
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "common/array.h"
|
||||||
|
#include "common/file.h"
|
||||||
|
#include "mm/utils/strings_data.h"
|
||||||
|
|
||||||
|
namespace MM {
|
||||||
|
|
||||||
|
bool StringsData::load(const Common::String &filename) {
|
||||||
|
Common::File f;
|
||||||
|
Common::Array<Common::String> prefixKeys;
|
||||||
|
Common::String key, value, fullKey;
|
||||||
|
size_t p;
|
||||||
|
|
||||||
|
if (!f.open(filename))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
while (!f.eos()) {
|
||||||
|
// Get the next line
|
||||||
|
Common::String line = f.readLine();
|
||||||
|
|
||||||
|
// Check for blank or commen tlines
|
||||||
|
Common::String lineTrimmed = line;
|
||||||
|
lineTrimmed.trim();
|
||||||
|
if (lineTrimmed.empty() || lineTrimmed.hasPrefix("#"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Count number of tabs for identation amount
|
||||||
|
size_t numTabs = 0;
|
||||||
|
while (line.hasPrefix("\t")) {
|
||||||
|
line.deleteChar(0);
|
||||||
|
++numTabs;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Split key and value if present
|
||||||
|
p = line.findFirstOf(":");
|
||||||
|
if (p == Common::String::npos)
|
||||||
|
error("Line encountered without colon");
|
||||||
|
|
||||||
|
key = Common::String(line.c_str(), line.c_str() + p);
|
||||||
|
value = Common::String(line.c_str() + p + 1);
|
||||||
|
key.trim();
|
||||||
|
value.trim();
|
||||||
|
|
||||||
|
// Handle quoted string values
|
||||||
|
if (value.hasPrefix("\"") && value.hasSuffix("\"")) {
|
||||||
|
value.deleteChar(0);
|
||||||
|
value.deleteLastChar();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle the entries
|
||||||
|
if (numTabs == prefixKeys.size()) {
|
||||||
|
// Do nothing
|
||||||
|
} else if (numTabs < prefixKeys.size()) {
|
||||||
|
// Drop off prefixes to the desired indentation
|
||||||
|
prefixKeys.resize(numTabs);
|
||||||
|
} else {
|
||||||
|
error("Incorrect indentation");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value.empty()) {
|
||||||
|
prefixKeys.push_back(key);
|
||||||
|
} else {
|
||||||
|
// Form a key from the prefix and current key
|
||||||
|
fullKey = "";
|
||||||
|
for (size_t i = 0; i < prefixKeys.size(); ++i) {
|
||||||
|
fullKey += prefixKeys[i];
|
||||||
|
fullKey += ".";
|
||||||
|
}
|
||||||
|
|
||||||
|
fullKey = fullKey + key;
|
||||||
|
(*this)[fullKey] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace MM
|
41
engines/mm/utils/strings_data.h
Normal file
41
engines/mm/utils/strings_data.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/* ScummVM - Graphic Adventure Engine
|
||||||
|
*
|
||||||
|
* ScummVM is the legal property of its developers, whose names
|
||||||
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||||
|
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MM_UTILS_STRINGS_DATA_H
|
||||||
|
#define MM_UTILS_STRINGS_DATA_H
|
||||||
|
|
||||||
|
#include "common/hash-str.h"
|
||||||
|
|
||||||
|
namespace MM {
|
||||||
|
|
||||||
|
class StringsData : public Common::StringMap {
|
||||||
|
public:
|
||||||
|
StringsData() : Common::StringMap() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the data
|
||||||
|
*/
|
||||||
|
bool load(const Common::String &filename);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace MM
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user