Commit 73d6577a authored by twanvl's avatar twanvl

mtg editor import

parent ef68b5a7
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
class Game; class Game;
DECLARE_POINTER_TYPE(Set); DECLARE_POINTER_TYPE(Set);
DECLARE_POINTER_TYPE(Card);
DECLARE_POINTER_TYPE(FileFormat); DECLARE_POINTER_TYPE(FileFormat);
// ----------------------------------------------------------------------------- : FileFormat // ----------------------------------------------------------------------------- : FileFormat
...@@ -78,5 +79,16 @@ FileFormatP mse1_file_format(); ...@@ -78,5 +79,16 @@ FileFormatP mse1_file_format();
FileFormatP mse2_file_format(); FileFormatP mse2_file_format();
FileFormatP mtg_editor_file_format(); FileFormatP mtg_editor_file_format();
// ----------------------------------------------------------------------------- : Other ways to export
/// Export images for each card in a set to a list of files
void export_images(Window* parent, const SetP& set);
/// Export the image of a single card
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);
// ----------------------------------------------------------------------------- : EOF // ----------------------------------------------------------------------------- : EOF
#endif #endif
...@@ -75,7 +75,7 @@ SetP MSE1FileFormat::importSet(const String& filename) { ...@@ -75,7 +75,7 @@ SetP MSE1FileFormat::importSet(const String& filename) {
if (stylesheet.substr(0,3) == _("old")) { if (stylesheet.substr(0,3) == _("old")) {
try { try {
set->stylesheet = StyleSheet::byGameAndName(*set->game, _("old")); set->stylesheet = StyleSheet::byGameAndName(*set->game, _("old"));
} catch (Error) { } catch (const Error&) {
// If old style doesn't work try the new one // If old style doesn't work try the new one
set->stylesheet = StyleSheet::byGameAndName(*set->game, _("new")); set->stylesheet = StyleSheet::byGameAndName(*set->game, _("new"));
} }
......
This diff is collapsed.
...@@ -64,7 +64,7 @@ class OptionalScript { ...@@ -64,7 +64,7 @@ class OptionalScript {
template <typename T> template <typename T>
bool invokeOnDefault(Context& ctx, Defaultable<T>& value) const { bool invokeOnDefault(Context& ctx, Defaultable<T>& value) const {
if (value.isDefault() && invokeOn(ctx, value)) { if (value.isDefault() && invokeOn(ctx, value)) {
value.setDefault(); // restore defaultness value.makeDefault(); // restore defaultness
return true; return true;
} else { } else {
return false; return false;
......
...@@ -49,7 +49,7 @@ class Defaultable { ...@@ -49,7 +49,7 @@ class Defaultable {
/// Is this value in the default state? /// Is this value in the default state?
inline bool isDefault() const { return is_default; } inline bool isDefault() const { return is_default; }
/// Set the defaultness to true /// Set the defaultness to true
inline void setDefault() { is_default = true; } inline void makeDefault() { is_default = true; }
/// Set the defaultness to false /// Set the defaultness to false
inline void unsetDefault() { is_default = false; } inline void unsetDefault() { is_default = false; }
......
...@@ -66,6 +66,12 @@ String substr_replace(const String& input, size_t start, size_t end, const Strin ...@@ -66,6 +66,12 @@ String substr_replace(const String& input, size_t start, size_t end, const Strin
return input.substr(0,start) + replacement + input.substr(end); return input.substr(0,start) + replacement + input.substr(end);
} }
String replace_all(const String& heystack, const String& needle, const String& replacement) {
String ret = heystack;
ret.Replace(needle, replacement);
return ret;
}
// ----------------------------------------------------------------------------- : Words // ----------------------------------------------------------------------------- : Words
String last_word(const String& s) { String last_word(const String& s) {
......
...@@ -84,6 +84,9 @@ String trim_left(const String&); ...@@ -84,6 +84,9 @@ String trim_left(const String&);
/// Replace the substring [start...end) of 'input' with 'replacement' /// Replace the substring [start...end) of 'input' with 'replacement'
String substr_replace(const String& input, size_t start, size_t end, const String& replacement); String substr_replace(const String& input, size_t start, size_t end, const String& replacement);
/// Replace all occurences of one needle with replacement
String replace_all(const String& heystack, const String& needle, const String& replacement);
// ----------------------------------------------------------------------------- : Words // ----------------------------------------------------------------------------- : Words
/// Returns the last word in a string /// Returns the last word in a string
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment