mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Automatic use of singular names -> even more use of REFLECT instead of REFLECT_N.
This also works better for GetMember, since the plural names (which make sense for scripts) are the default. git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@16 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+2
-2
@@ -32,8 +32,8 @@ IMPLEMENT_REFLECTION(Game) {
|
||||
REFLECT(card_fields);
|
||||
// REFLECT_N("keyword parameter type", keyword_params);
|
||||
// REFLECT_N("keyword separator type", keyword_separators);
|
||||
// REFLECT_N("keyword", keywords);
|
||||
// REFLECT_N("word list", word_lists);
|
||||
// REFLECT(keywords);
|
||||
// REFLECT(word_lists);
|
||||
}
|
||||
|
||||
void Game::validate() {
|
||||
|
||||
@@ -95,7 +95,7 @@ String Settings::settingsFile() {
|
||||
|
||||
IMPLEMENT_REFLECTION(Settings) {
|
||||
// ioMseVersion(io, "settings", file_version);
|
||||
REFLECT_N("recent_set", recent_sets);
|
||||
REFLECT(recent_sets);
|
||||
REFLECT(set_window_maximized);
|
||||
REFLECT(set_window_width);
|
||||
REFLECT(set_window_height);
|
||||
|
||||
+2
-2
@@ -106,7 +106,7 @@ IMPLEMENT_REFLECTION_ENUM(SymbolPartCombine) {
|
||||
IMPLEMENT_REFLECTION(SymbolPart) {
|
||||
REFLECT(name);
|
||||
REFLECT(combine);
|
||||
REFLECT_N("point", points);
|
||||
REFLECT(points);
|
||||
// Fixes after reading
|
||||
if (tag.reading()) {
|
||||
// enforce constraints
|
||||
@@ -160,7 +160,7 @@ void SymbolPart::calculateBounds() {
|
||||
|
||||
IMPLEMENT_REFLECTION(Symbol) {
|
||||
//%% version?
|
||||
REFLECT_N("part", parts);
|
||||
REFLECT(parts);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : SymbolView
|
||||
|
||||
+2
-2
@@ -37,8 +37,8 @@ bool MSE::OnInit() {
|
||||
wxInitAllImageHandlers();
|
||||
initFileFormats();
|
||||
settings.read();
|
||||
//Window* wnd = new SymbolWindow(nullptr);
|
||||
Window* wnd = new SetWindow(nullptr, new_shared1<Set>(Game::byName(_("magic"))));
|
||||
Window* wnd = new SymbolWindow(nullptr);
|
||||
//Window* wnd = new SetWindow(nullptr, new_shared1<Set>(Game::byName(_("magic"))));
|
||||
wnd->Show();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include "../prec.hpp"
|
||||
#include <util/prec.hpp>
|
||||
#include <wx/txtstrm.h>
|
||||
|
||||
// ----------------------------------------------------------------------------- : Reader
|
||||
@@ -47,11 +47,12 @@ class Reader {
|
||||
exitBlock();
|
||||
}
|
||||
}
|
||||
/// Reads a vector from the input stream
|
||||
template <typename T>
|
||||
void handle(const Char* name, vector<T>& vector);
|
||||
|
||||
/// Reads an object of type T from the input stream
|
||||
template <typename T> void handle(T& object);
|
||||
/// Reads a vector from the input stream
|
||||
template <typename T> void handle(vector<T>& vector);
|
||||
/// Reads a shared_ptr from the input stream
|
||||
template <typename T> void handle(shared_ptr<T>& pointer);
|
||||
/// Reads a map from the input stream
|
||||
@@ -109,12 +110,12 @@ shared_ptr<T> read_new(Reader& reader) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Reader::handle(vector<T>& vector) {
|
||||
String vectorKey = key;
|
||||
while (key == vectorKey) { // TODO : check indent
|
||||
moveNext(); // skip key
|
||||
void Reader::handle(const Char* name, vector<T>& vector) {
|
||||
String vectorKey = singular_form(name);
|
||||
while (enterBlock(vectorKey)) {
|
||||
vector.resize(vector.size() + 1);
|
||||
handle(vector.back());
|
||||
exitBlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-9
@@ -34,6 +34,9 @@ class Writer {
|
||||
handle(object);
|
||||
exitBlock();
|
||||
}
|
||||
/// Write a vector to the output stream
|
||||
template <typename T>
|
||||
void handle(const Char* name, const vector<T>& vector);
|
||||
|
||||
/// Write a string to the output stream
|
||||
void handle(const String& str);
|
||||
@@ -41,8 +44,6 @@ class Writer {
|
||||
|
||||
/// Write an object of type T to the output stream
|
||||
template <typename T> void handle(const T& object);
|
||||
/// Write a vector to the output stream
|
||||
template <typename T> void handle(const vector<T>& vector);
|
||||
/// Write a shared_ptr to the output stream
|
||||
template <typename T> void handle(const shared_ptr<T>& pointer);
|
||||
/// Write a map to the output stream
|
||||
@@ -78,13 +79,13 @@ class Writer {
|
||||
// ----------------------------------------------------------------------------- : Container types
|
||||
|
||||
template <typename T>
|
||||
void Writer::handle(const vector<T>& vector) {
|
||||
/*String vectorKey = key;
|
||||
while (key == vectorKey) { // TODO : check indent
|
||||
moveNext(); // skip key
|
||||
vector.resize(vector.size() + 1);
|
||||
handle(vector.back());
|
||||
}*/
|
||||
void Writer::handle(const Char* name, const vector<T>& vec) {
|
||||
String vectorKey = singular_form(name);
|
||||
for (vector<T>::const_iterator it = vec.begin() ; it != vec.end() ; ++it) {
|
||||
enterBlock(vectorKey);
|
||||
handle(*it);
|
||||
exitBlock();
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
||||
@@ -133,3 +133,9 @@ String cannocial_name_form(const String& str) {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
String singular_form(const String& str) {
|
||||
assert(str.size() > 1);
|
||||
assert(str.GetChar(str.size() - 1) == _('s')); // ends in 's'
|
||||
return str.substr(0, str.size() - 1);
|
||||
}
|
||||
|
||||
@@ -106,5 +106,10 @@ String capitalize_sentence(const String&);
|
||||
*/
|
||||
String cannocial_name_form(const String&);
|
||||
|
||||
/// Returns the singular form of a string
|
||||
/** Used for reflection, for example "vector<T> apples" is written with keys "apple"
|
||||
*/
|
||||
String singular_form(const String&);
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user