mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -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) {
|
||||
|
||||
@@ -122,6 +122,8 @@ class Set : public Packaged {
|
||||
|
||||
private:
|
||||
DECLARE_REFLECTION();
|
||||
template <typename Tag>
|
||||
void reflect_cards (Tag& tag);
|
||||
|
||||
/// Object for managing and executing scripts
|
||||
scoped_ptr<SetScriptManager> script_manager;
|
||||
|
||||
@@ -249,6 +249,7 @@ IMPLEMENT_REFLECTION_NO_SCRIPT(Settings) {
|
||||
REFLECT(set_window_height);
|
||||
REFLECT(card_notes_height);
|
||||
REFLECT(open_sets_in_new_window);
|
||||
REFLECT(save_cards_separately);
|
||||
REFLECT(symbol_grid_size);
|
||||
REFLECT(symbol_grid);
|
||||
REFLECT(symbol_grid_snap);
|
||||
|
||||
@@ -145,6 +145,9 @@ class Settings {
|
||||
UInt set_window_height;
|
||||
UInt card_notes_height;
|
||||
bool open_sets_in_new_window;
|
||||
|
||||
// --------------------------------------------------- : Set saving
|
||||
bool save_cards_separately;
|
||||
|
||||
// --------------------------------------------------- : Symbol editor
|
||||
UInt symbol_grid_size;
|
||||
|
||||
Reference in New Issue
Block a user