mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-13 05:57:00 -04:00
Working on installer packages;
Nicer warnings about using spaces for indentation git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@321 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -0,0 +1,19 @@
|
|||||||
|
//+----------------------------------------------------------------------------+
|
||||||
|
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
||||||
|
//| Copyright: (C) 2001 - 2007 Twan van Laarhoven |
|
||||||
|
//| License: GNU General Public License 2 or later (see file COPYING) |
|
||||||
|
//+----------------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------- : Includes
|
||||||
|
|
||||||
|
#include <data/installer.hpp>
|
||||||
|
#include <script/to_value.hpp>
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------- : Installer
|
||||||
|
|
||||||
|
String Installer::typeName() const { return _("installer"); }
|
||||||
|
|
||||||
|
IMPLEMENT_REFLECTION(Installer) {
|
||||||
|
REFLECT_BASE(Packaged);
|
||||||
|
REFLECT(packages);
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
//+----------------------------------------------------------------------------+
|
||||||
|
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
||||||
|
//| Copyright: (C) 2001 - 2007 Twan van Laarhoven |
|
||||||
|
//| License: GNU General Public License 2 or later (see file COPYING) |
|
||||||
|
//+----------------------------------------------------------------------------+
|
||||||
|
|
||||||
|
#ifndef HEADER_DATA_INSTALLER
|
||||||
|
#define HEADER_DATA_INSTALLER
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------- : Includes
|
||||||
|
|
||||||
|
#include <util/prec.hpp>
|
||||||
|
#include <util/io/package.hpp>
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------- : Installer
|
||||||
|
|
||||||
|
/// A package that contains other packages that can be installed
|
||||||
|
class Installer : public Packaged {
|
||||||
|
public:
|
||||||
|
String prefered_filename; ///< What filename should be used (by default)
|
||||||
|
vector<String> packages; ///< Packages to install
|
||||||
|
|
||||||
|
/// Install all the packages
|
||||||
|
void install();
|
||||||
|
|
||||||
|
/// Add a package to the installer (if it is not already added).
|
||||||
|
/** The first package gives the name of the installer.
|
||||||
|
*/
|
||||||
|
void addPackage(const Packaged& package);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
String typeName() const;
|
||||||
|
DECLARE_REFLECTION();
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------- : EOF
|
||||||
|
#endif
|
||||||
+8
-2
@@ -1636,6 +1636,12 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath=".\data\font.hpp">
|
RelativePath=".\data\font.hpp">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\data\installer.cpp">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\data\installer.hpp">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\data\keyword.cpp">
|
RelativePath=".\data\keyword.cpp">
|
||||||
</File>
|
</File>
|
||||||
@@ -2933,10 +2939,10 @@
|
|||||||
RelativePath="..\conversion-todo.txt">
|
RelativePath="..\conversion-todo.txt">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\data\nl.mse-locale\locale">
|
RelativePath="..\data\en.mse-locale\locale">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\data\en.mse-locale\locale">
|
RelativePath="..\data\nl.mse-locale\locale">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\main.cpp">
|
RelativePath=".\main.cpp">
|
||||||
|
|||||||
@@ -28,11 +28,6 @@ String IncludePackage::typeName() const { return _("include"); }
|
|||||||
|
|
||||||
IMPLEMENT_REFLECTION(IncludePackage) {
|
IMPLEMENT_REFLECTION(IncludePackage) {
|
||||||
REFLECT_BASE(Packaged);
|
REFLECT_BASE(Packaged);
|
||||||
REFLECT_IF_READING {
|
|
||||||
// ingore
|
|
||||||
String version;
|
|
||||||
REFLECT(version);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : PackageManager
|
// ----------------------------------------------------------------------------- : PackageManager
|
||||||
|
|||||||
+12
-3
@@ -100,7 +100,7 @@ void Reader::moveNext() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Reader::readLine() {
|
void Reader::readLine(bool in_string) {
|
||||||
// fix UTF8 in ascii builds; skip BOM
|
// fix UTF8 in ascii builds; skip BOM
|
||||||
line = decodeUTF8BOM(stream.ReadLine());
|
line = decodeUTF8BOM(stream.ReadLine());
|
||||||
line_number += 1;
|
line_number += 1;
|
||||||
@@ -121,7 +121,16 @@ void Reader::readLine() {
|
|||||||
indent = -1;
|
indent = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
key = cannocial_name_form(trim(line.substr(indent, pos - indent)));
|
key = line.substr(indent, pos - indent);
|
||||||
|
if (!in_string && starts_with(key, _(" "))) {
|
||||||
|
warning(_("key: '") + key + _("' starts with a space; only use TABs for indentation!"));
|
||||||
|
// try to fix up: 8 spaces is a tab
|
||||||
|
while (starts_with(key, _(" "))) {
|
||||||
|
key = key.substr(8);
|
||||||
|
indent += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
key = cannocial_name_form(trim(key));
|
||||||
value = pos == String::npos ? _("") : trim_left(line.substr(pos+1));
|
value = pos == String::npos ? _("") : trim_left(line.substr(pos+1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,7 +186,7 @@ const String& Reader::getValue() {
|
|||||||
if (!first) multi_line_str += _('\n');
|
if (!first) multi_line_str += _('\n');
|
||||||
first = false;
|
first = false;
|
||||||
multi_line_str += line.substr(expected_indent); // strip expected indent
|
multi_line_str += line.substr(expected_indent); // strip expected indent
|
||||||
readLine();
|
readLine(true);
|
||||||
}
|
}
|
||||||
// moveNext(), but without emptying multi_line_str
|
// moveNext(), but without emptying multi_line_str
|
||||||
just_opened = false;
|
just_opened = false;
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ class Reader {
|
|||||||
/// Move to the next non empty line
|
/// Move to the next non empty line
|
||||||
void moveNext();
|
void moveNext();
|
||||||
/// Reads the next line from the input, and stores it in line/key/value/indent
|
/// Reads the next line from the input, and stores it in line/key/value/indent
|
||||||
void readLine();
|
void readLine(bool in_string = false);
|
||||||
|
|
||||||
/// Return the value on the current line
|
/// Return the value on the current line
|
||||||
const String& getValue();
|
const String& getValue();
|
||||||
|
|||||||
Reference in New Issue
Block a user