mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 21:06:59 -04:00
Use LocalFileName class for file names inside a package.
This commit is contained in:
@@ -87,10 +87,10 @@ unique_ptr<ValueAction> value_action(const ChoiceValueP& value, const Defaultabl
|
||||
unique_ptr<ValueAction> value_action(const ColorValueP& value, const Defaultable<Color>& new_value) {
|
||||
return make_unique<SimpleValueAction<ColorValue, true>>(value, new_value);
|
||||
}
|
||||
unique_ptr<ValueAction> value_action(const ImageValueP& value, const FileName& new_value) {
|
||||
unique_ptr<ValueAction> value_action(const ImageValueP& value, const LocalFileName& new_value) {
|
||||
return make_unique<SimpleValueAction<ImageValue, false>>(value, new_value);
|
||||
}
|
||||
unique_ptr<ValueAction> value_action(const SymbolValueP& value, const FileName& new_value) {
|
||||
unique_ptr<ValueAction> value_action(const SymbolValueP& value, const LocalFileName& new_value) {
|
||||
return make_unique<SimpleValueAction<SymbolValue, false>>(value, new_value);
|
||||
}
|
||||
unique_ptr<ValueAction> value_action(const PackageChoiceValueP& value, const String& new_value) {
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
class Card;
|
||||
class StyleSheet;
|
||||
class LocalFileName;
|
||||
DECLARE_POINTER_TYPE(Set);
|
||||
DECLARE_POINTER_TYPE(Value);
|
||||
DECLARE_POINTER_TYPE(Style);
|
||||
@@ -57,8 +58,8 @@ class ValueAction : public Action {
|
||||
unique_ptr<ValueAction> value_action(const ChoiceValueP& value, const Defaultable<String>& new_value);
|
||||
unique_ptr<ValueAction> value_action(const MultipleChoiceValueP& value, const Defaultable<String>& new_value, const String& last_change);
|
||||
unique_ptr<ValueAction> value_action(const ColorValueP& value, const Defaultable<Color>& new_value);
|
||||
unique_ptr<ValueAction> value_action(const ImageValueP& value, const FileName& new_value);
|
||||
unique_ptr<ValueAction> value_action(const SymbolValueP& value, const FileName& new_value);
|
||||
unique_ptr<ValueAction> value_action(const ImageValueP& value, const LocalFileName& new_value);
|
||||
unique_ptr<ValueAction> value_action(const SymbolValueP& value, const LocalFileName& new_value);
|
||||
unique_ptr<ValueAction> value_action(const PackageChoiceValueP& value, const String& new_value);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Text
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <data/field.hpp>
|
||||
#include <script/scriptable.hpp>
|
||||
#include <script/image.hpp>
|
||||
#include <util/io/package.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- : ImageField
|
||||
|
||||
@@ -45,7 +46,7 @@ class ImageStyle : public Style {
|
||||
class ImageValue : public Value {
|
||||
public:
|
||||
inline ImageValue(const ImageFieldP& field) : Value(field) {}
|
||||
DECLARE_VALUE_TYPE(Image, FileName);
|
||||
DECLARE_VALUE_TYPE(Image, LocalFileName);
|
||||
|
||||
ValueType filename; ///< Filename of the image (in the current package), or ""
|
||||
Age last_update; ///< When was the image last changed?
|
||||
|
||||
@@ -51,6 +51,8 @@ String SymbolValue::toString() const {
|
||||
return filename.empty() ? wxEmptyString : _("<symbol>");
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION_NAMELESS(SymbolValue) {
|
||||
IMPLEMENT_REFLECTION_NO_GET_MEMBER(SymbolValue) {
|
||||
if (fieldP->save_value || !handler.isWriting) REFLECT_NAMELESS(filename);
|
||||
}
|
||||
void SymbolValue::reflect(GetMember& handler) {}
|
||||
void SymbolValue::reflect(GetDefaultMember& handler) {}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <util/prec.hpp>
|
||||
#include <data/field.hpp>
|
||||
#include <script/scriptable.hpp>
|
||||
#include <util/io/package.hpp>
|
||||
|
||||
DECLARE_POINTER_TYPE(SymbolFilter);
|
||||
DECLARE_POINTER_TYPE(SymbolVariation);
|
||||
@@ -65,7 +66,7 @@ class SymbolVariation : public IntrusivePtrBase<SymbolVariation> {
|
||||
class SymbolValue : public Value {
|
||||
public:
|
||||
inline SymbolValue(const SymbolFieldP& field) : Value(field) {}
|
||||
DECLARE_VALUE_TYPE(Symbol, FileName);
|
||||
DECLARE_VALUE_TYPE(Symbol, LocalFileName);
|
||||
|
||||
ValueType filename; ///< Filename of the symbol (in the current package)
|
||||
Age last_update; ///< When was the symbol last changed?
|
||||
|
||||
@@ -112,16 +112,16 @@ void read_mse1_card(Set& set, wxFileInputStream& f, wxTextInputStream& file) {
|
||||
card->value<TextValue>(_("name")) .value.assign(line);
|
||||
break;
|
||||
} case 'C': case 'D': { // image filename
|
||||
String image_file = set.newFileName(_("image"),_("")); // a new unique name in the package
|
||||
LocalFileName image_file = set.newFileName(_("image"),_("")); // a new unique name in the package
|
||||
if (wxCopyFile(line, set.nameOut(image_file), true)) {
|
||||
card->value<ImageValue>(_("image")) .filename = image_file;
|
||||
card->value<ImageValue>(_("image")).filename = image_file;
|
||||
}
|
||||
break;
|
||||
} case 'E': { // super type
|
||||
card->value<TextValue>(_("super type")) .value.assign(line);
|
||||
card->value<TextValue>(_("super type")).value.assign(line);
|
||||
break;
|
||||
} case 'F': { // sub type
|
||||
card->value<TextValue>(_("sub type")) .value.assign(line);
|
||||
card->value<TextValue>(_("sub type")).value.assign(line);
|
||||
break;
|
||||
} case 'G': { // casting cost
|
||||
card->value<TextValue>(_("casting cost")).value.assign(line);
|
||||
|
||||
@@ -152,7 +152,7 @@ SetP MtgEditorFileFormat::importSet(const String& filename) {
|
||||
}
|
||||
// copy image into set
|
||||
if (wxFileExists(line)) {
|
||||
String image_file = set->newFileName(_("image"),_(""));
|
||||
LocalFileName image_file = set->newFileName(_("image"),_(""));
|
||||
if (wxCopyFile(line, set->nameOut(image_file), true)) {
|
||||
current_card->value<ImageValue>(_("image")).filename = image_file;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user