mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
Magic Workstation spoiler format export
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@216 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -91,5 +91,8 @@ void export_image(const SetP& set, const CardP& card, const String& filename);
|
||||
/// Generate a bitmap image of a card
|
||||
Bitmap export_bitmap(const SetP& set, const CardP& card);
|
||||
|
||||
/// Export a set to Magic Workstation format
|
||||
void export_mws(const SetP& set);
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
#endif
|
||||
|
||||
@@ -143,13 +143,13 @@ SetP MtgEditorFileFormat::importSet(const String& filename) {
|
||||
target = ¤t_card->value<TextValue>(_("power")).value;
|
||||
} else if (line == _("#TOUGHNESS#####")) { // toughness
|
||||
target = ¤t_card->value<TextValue>(_("toughness")).value;
|
||||
} else if (line == _("#ILLUSTRATION##") || line == _("#ILLUSTRATION8#")) { // image
|
||||
} else if (line == _("#ILLUSTRATION##") || line == _("#ILLUSTRATION8#")) { // image
|
||||
target = 0;
|
||||
line = file.ReadLine();
|
||||
if (!wxFileExists(line)) {
|
||||
// based on card name and date
|
||||
line = filter1(filename) + set_date + _("/") +
|
||||
filter2(current_card->value<TextValue>(_("name")).value()) + card_date + _(".jpg");
|
||||
filter2(current_card->value<TextValue>(_("name")).value) + card_date + _(".jpg");
|
||||
}
|
||||
// copy image into set
|
||||
if (wxFileExists(line)) {
|
||||
@@ -177,16 +177,16 @@ SetP MtgEditorFileFormat::importSet(const String& filename) {
|
||||
|
||||
// set defaults for artist and copyright to that of the first card
|
||||
if (!set->cards.empty()) {
|
||||
String artist = set->cards[0]->value<TextValue>(_("illustrator")).value();
|
||||
String copyright = set->cards[0]->value<TextValue>(_("copyright")) .value();
|
||||
String artist = set->cards[0]->value<TextValue>(_("illustrator")).value;
|
||||
String copyright = set->cards[0]->value<TextValue>(_("copyright")) .value;
|
||||
set->value<TextValue>(_("artist")) .value.assign(artist);
|
||||
set->value<TextValue>(_("copyright")).value.assign(copyright);
|
||||
// which cards have this value?
|
||||
FOR_EACH(card, set->cards) {
|
||||
Defaultable<String>& card_artist = card->value<TextValue>(_("illustrator")).value;
|
||||
Defaultable<String>& card_copyright = card->value<TextValue>(_("copyright")) .value;
|
||||
if (card_artist() == artist) card_artist.makeDefault();
|
||||
if (card_copyright() == copyright) card_copyright.makeDefault();
|
||||
if (card_artist == artist) card_artist.makeDefault();
|
||||
if (card_copyright == copyright) card_copyright.makeDefault();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ String MtgEditorFileFormat::filter2(const String& str) {
|
||||
|
||||
void MtgEditorFileFormat::untag(const CardP& card, const String& field) {
|
||||
Defaultable<String>& value = card->value<TextValue>(field).value;
|
||||
value.assignDontChangeDefault(untag_no_escape(value()));
|
||||
value.assignDontChangeDefault(untag_no_escape(value));
|
||||
}
|
||||
|
||||
|
||||
|
||||
+97
-1
@@ -7,5 +7,101 @@
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <data/format/formats.hpp>
|
||||
#include <data/game.hpp>
|
||||
#include <data/set.hpp>
|
||||
#include <data/card.hpp>
|
||||
#include <data/field/text.hpp>
|
||||
#include <data/field/choice.hpp>
|
||||
#include <util/string.hpp>
|
||||
#include <util/tagged_string.hpp>
|
||||
#include <wx/wfstream.h>
|
||||
|
||||
// ----------------------------------------------------------------------------- :
|
||||
DECLARE_TYPEOF_COLLECTION(CardP);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Utilities
|
||||
|
||||
/// Convert a tagged string to MWS format: \t\t before each line beyond the first
|
||||
String untag_mws(const String& str) {
|
||||
return replace_all(untag(str), _("\n"), _("\n\t\t") );
|
||||
}
|
||||
//String untag_mws(const Defaultable<String>& str) {
|
||||
// str.
|
||||
//}
|
||||
|
||||
/// Code for card color in MWS format
|
||||
String card_color_mws(const String& col) {
|
||||
if (col == _("white")) return _("W");
|
||||
if (col == _("blue")) return _("U");
|
||||
if (col == _("black")) return _("B");
|
||||
if (col == _("red")) return _("R");
|
||||
if (col == _("green")) return _("G");
|
||||
if (col == _("colorless")) return _("Art");
|
||||
if (col.find(_("land")) != String::npos) {
|
||||
return _("Lnd"); // land
|
||||
} else {
|
||||
return _("Gld"); // multicolor
|
||||
}
|
||||
}
|
||||
|
||||
/// Code for card rarity, used for MWS and Apprentice
|
||||
String card_rarity_code(const String& rarity) {
|
||||
if (rarity == _("rare")) return _("R");
|
||||
if (rarity == _("uncommon")) return _("U");
|
||||
else return _("C");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : export_mws
|
||||
|
||||
void export_mws(const SetP& set) {
|
||||
if (!set->game->isMagic()) {
|
||||
throw Error(_("Can only export Magic sets to Magic Workstation"));
|
||||
}
|
||||
|
||||
// Select filename
|
||||
String name = wxFileSelector(_("Export to file"),_(""),_(""),_(""),
|
||||
_("Text files (*.txt)|*.txt|All Files|*.*"),
|
||||
wxSAVE | wxOVERWRITE_PROMPT);
|
||||
if (name.empty()) return;
|
||||
wxBusyCursor busy;
|
||||
// Open file
|
||||
wxFileOutputStream f(name);
|
||||
wxTextOutputStream file(f, wxEOL_DOS);
|
||||
|
||||
// Write header
|
||||
file.WriteString(set->value<TextValue>(_("title")).value + _(" Spoiler List\n"));
|
||||
file.WriteString(_("Set exported using Magic Set Editor 2, version ") + app_version.toString() + _("\n\n"));
|
||||
wxDateTime now = wxDateTime::Now();
|
||||
file.WriteString(_("Spoiler List created on ") + now.FormatISODate() + _(" ") + now.FormatISOTime());
|
||||
file.WriteString(_("\n\n"));
|
||||
|
||||
// Write cards
|
||||
FOR_EACH(card, set->cards) {
|
||||
file.WriteString(_("Card Name:\t"));
|
||||
file.WriteString(untag_mws(card->value<TextValue>(_("name")).value));
|
||||
file.WriteString(_("\nCard Color:\t"));
|
||||
file.WriteString(card_color_mws(card->value<ChoiceValue>(_("card color")).value));
|
||||
file.WriteString(_("\nMana Cost:\t"));
|
||||
file.WriteString(untag_mws(card->value<TextValue>(_("casting cost")).value));
|
||||
file.WriteString(_("\nType & Class:\t"));
|
||||
String sup_type = untag_mws(card->value<TextValue>(_("super type")).value);
|
||||
String sub_type = untag_mws(card->value<TextValue>(_("sub type")).value);
|
||||
if (sub_type.empty()) {
|
||||
file.WriteString(sup_type);
|
||||
} else {
|
||||
file.WriteString(sup_type + _(" - ") + sub_type);
|
||||
}
|
||||
file.WriteString(_("\nPow/Tou:\t"));
|
||||
file.WriteString(untag_mws(card->value<TextValue>(_("pt")).value));
|
||||
file.WriteString(_("\nCard Text:\t"));
|
||||
file.WriteString(untag_mws(card->value<TextValue>(_("rule text")).value));
|
||||
file.WriteString(_("\nFlavor Text:\t"));
|
||||
file.WriteString(untag_mws(card->value<TextValue>(_("flavor text")).value));
|
||||
file.WriteString(_("\nArtist:\t\t"));
|
||||
file.WriteString(untag_mws(card->value<TextValue>(_("illustrator")).value));
|
||||
file.WriteString(_("\nRarity:\t\t"));
|
||||
file.WriteString(card_rarity_code(card->value<ChoiceValue>(_("rarity")).value));
|
||||
file.WriteString(_("\nCard #:\t\t"));
|
||||
file.WriteString(untag_mws(card->value<TextValue>(_("card number")).value));
|
||||
file.WriteString(_("\n\n"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,11 +63,11 @@ StyleSheetSettings::StyleSheetSettings()
|
||||
{}
|
||||
|
||||
void StyleSheetSettings::useDefault(const StyleSheetSettings& ss) {
|
||||
if (card_zoom .isDefault()) card_zoom .assignDefault(ss.card_zoom());
|
||||
if (card_angle .isDefault()) card_angle .assignDefault(ss.card_angle());
|
||||
if (card_anti_alias .isDefault()) card_anti_alias .assignDefault(ss.card_anti_alias());
|
||||
if (card_borders .isDefault()) card_borders .assignDefault(ss.card_borders());
|
||||
if (card_normal_export.isDefault()) card_normal_export.assignDefault(ss.card_normal_export());
|
||||
if (card_zoom .isDefault()) card_zoom .assignDefault(ss.card_zoom);
|
||||
if (card_angle .isDefault()) card_angle .assignDefault(ss.card_angle);
|
||||
if (card_anti_alias .isDefault()) card_anti_alias .assignDefault(ss.card_anti_alias);
|
||||
if (card_borders .isDefault()) card_borders .assignDefault(ss.card_borders);
|
||||
if (card_normal_export.isDefault()) card_normal_export.assignDefault(ss.card_normal_export);
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION(StyleSheetSettings) {
|
||||
|
||||
Reference in New Issue
Block a user