mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
e46cbe66b2
Added 'right' and 'bottom' properties to style as an alternative way of specifying width/height; Added content_width, content_height and content_lines properties that give feedback on text rendering; Always show warnings when showing errors and vice-versa, this prevents script errors from appearing before the reader/parse error that caused them; Finally some preliminairy work on export templates git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@428 0fc631ac-6414-0410-93d0-97cfa31319b6
69 lines
2.7 KiB
C++
69 lines
2.7 KiB
C++
//+----------------------------------------------------------------------------+
|
|
//| 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_UTIL_DELAYED_INDEX_MAPS
|
|
#define HEADER_UTIL_DELAYED_INDEX_MAPS
|
|
|
|
// ----------------------------------------------------------------------------- : Includes
|
|
|
|
#include <util/prec.hpp>
|
|
#include <util/smart_ptr.hpp>
|
|
#include <util/index_map.hpp>
|
|
#include <util/reflect.hpp>
|
|
#include <wx/sstream.h>
|
|
|
|
// ----------------------------------------------------------------------------- : DelayedIndexMaps
|
|
|
|
template <typename Key, typename Value>
|
|
IndexMap<Key,Value>& DelayedIndexMaps<Key,Value>::get(const String& name, const vector<Key>& init_with) {
|
|
intrusive_ptr<DelayedIndexMapsData<Key,Value> >& item = data[name];
|
|
if (!item) { // no item, make a new one
|
|
item = new_intrusive<DelayedIndexMapsData<Key,Value> >();
|
|
item->read_data.init(init_with);
|
|
} else if (!item->unread_data.empty()) { // not read, read now
|
|
item->read_data.init(init_with);
|
|
Reader reader(new_shared1<wxStringInputStream>(item->unread_data), _("delayed data for ") + name);
|
|
reader.handle_greedy(item->read_data);
|
|
item->unread_data.clear();
|
|
}
|
|
return item->read_data;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------------- : Reflection
|
|
|
|
// custom reflection : it's a template class
|
|
template <typename Key, typename Value> void Reader::handle(DelayedIndexMaps<Key,Value>& dim) {
|
|
handle(dim.data);
|
|
}
|
|
template <typename Key, typename Value> void Writer::handle(const DelayedIndexMaps<Key,Value>& dim) {
|
|
handle(dim.data);
|
|
}
|
|
template <typename Key, typename Value> void GetMember::handle(const DelayedIndexMaps<Key,Value>& dim) {
|
|
handle(dim.data);
|
|
}
|
|
|
|
// custom reflection : read into unread_data
|
|
template <typename Key, typename Value>
|
|
void Reader::handle(DelayedIndexMapsData<Key,Value>& d) {
|
|
handle(d.unread_data);
|
|
if (d.unread_data.empty()) d.unread_data = _("\n"); // never empty (invariant)
|
|
}
|
|
template <typename Key, typename Value>
|
|
void Writer::handle(const DelayedIndexMapsData<Key,Value>& d) {
|
|
handle(d.read_data);
|
|
}
|
|
template <typename Key, typename Value>
|
|
void GetMember::handle(const DelayedIndexMapsData<Key,Value>& d) {
|
|
handle(d.read_data);
|
|
}
|
|
template <typename Key, typename Value>
|
|
void GetDefaultMember::handle(const DelayedIndexMapsData<Key,Value>&) {
|
|
handle(d.read_data);
|
|
}
|
|
|
|
// ----------------------------------------------------------------------------- : EOF
|
|
#endif
|