mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
MSE can now save cards in separate files (needs manual config editing still).
Trailing slashes are stripped from commandline arguments (because directory.mse-set/ should be accepted) git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1386 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+37
-1
@@ -180,7 +180,8 @@ IMPLEMENT_REFLECTION(Set) {
|
||||
if (stylesheet) {
|
||||
REFLECT_N("styling", styling_data);
|
||||
}
|
||||
REFLECT(cards);
|
||||
// Experimental: save each card to a different file
|
||||
reflect_cards(tag);
|
||||
REFLECT(keywords);
|
||||
REFLECT(pack_types);
|
||||
}
|
||||
@@ -188,6 +189,41 @@ IMPLEMENT_REFLECTION(Set) {
|
||||
REFLECT(apprentice_code);
|
||||
}
|
||||
|
||||
// TODO: this function sucks
|
||||
bool isnt_filename_safe (Char c) {
|
||||
return !((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'z') ||
|
||||
(c >= _('0') && c <= _('9')) || c == _(' '));
|
||||
}
|
||||
|
||||
// TODO: make this a more generic function to be used elsewhere
|
||||
template <typename Tag>
|
||||
void Set::reflect_cards (Tag& tag) {
|
||||
REFLECT(cards);
|
||||
}
|
||||
|
||||
template <>
|
||||
void Set::reflect_cards<Writer> (Writer& tag) {
|
||||
if (settings.save_cards_separately) {
|
||||
set<String> used;
|
||||
FOR_EACH(card, cards) {
|
||||
String filename = normalize_internal_filename(clean_filename(card->identification()));
|
||||
String full_name = filename;
|
||||
int i = 0;
|
||||
|
||||
while (used.find(full_name) != used.end()) {
|
||||
full_name = filename << _(".") << ++i;
|
||||
}
|
||||
used.insert(full_name);
|
||||
|
||||
Writer writer(openOut(full_name), app_version);
|
||||
writer.handle(_("card"), card);
|
||||
REFLECT_N("include file", full_name);
|
||||
}
|
||||
} else {
|
||||
REFLECT(cards);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Script utilities
|
||||
|
||||
ScriptValueP make_iterator(const Set& set) {
|
||||
|
||||
Reference in New Issue
Block a user