mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 05:07:00 -04:00
separate short_name for packages, moved full_name,short_name and icon_filename to Packaged
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@173 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+15
-4
@@ -60,9 +60,6 @@ String Package::fullName() const {
|
||||
const String& Package::absoluteFilename() const {
|
||||
return filename;
|
||||
}
|
||||
InputStreamP Package::openIconFile() {
|
||||
return InputStreamP();
|
||||
}
|
||||
|
||||
|
||||
void Package::open(const String& n) {
|
||||
@@ -408,12 +405,21 @@ String Package::toStandardName(const String& name) {
|
||||
|
||||
// note: reflection must be declared before it is used
|
||||
IMPLEMENT_REFLECTION(Packaged) {
|
||||
// default does nothing
|
||||
REFLECT(short_name);
|
||||
REFLECT(full_name);
|
||||
REFLECT_N("icon", icon_filename);
|
||||
}
|
||||
|
||||
Packaged::Packaged() {
|
||||
}
|
||||
|
||||
InputStreamP Packaged::openIconFile() {
|
||||
if (!icon_filename.empty()) {
|
||||
return openIn(icon_filename);
|
||||
} else {
|
||||
return InputStreamP();
|
||||
}
|
||||
}
|
||||
void Packaged::open(const String& package) {
|
||||
Package::open(package);
|
||||
Reader reader(openIn(typeName()), absoluteFilename() + _("/") + typeName());
|
||||
@@ -436,3 +442,8 @@ void Packaged::saveAs(const String& package) {
|
||||
referenceFile(typeName());
|
||||
Package::saveAs(package);
|
||||
}
|
||||
|
||||
void Packaged::validate(Version) {
|
||||
// a default for the short name
|
||||
if (short_name.empty()) short_name = name();
|
||||
}
|
||||
@@ -64,10 +64,7 @@ class Package {
|
||||
const String& absoluteFilename() const;
|
||||
/// The time this package was last modified
|
||||
inline wxDateTime lastModified() const { return modified; }
|
||||
|
||||
/// Get an input stream for the package icon, if there is any
|
||||
virtual InputStreamP openIconFile();
|
||||
|
||||
|
||||
/// Open a package, should only be called when the package is constructed using the default constructor!
|
||||
/// @pre open not called before [TODO]
|
||||
void open(const String& package);
|
||||
@@ -187,6 +184,13 @@ class Packaged : public Package {
|
||||
Packaged();
|
||||
virtual ~Packaged() {}
|
||||
|
||||
String short_name; ///< Short name of this package
|
||||
String full_name; ///< Name of this package, for menus etc.
|
||||
String icon_filename; ///< Filename of icon to use in package lists
|
||||
|
||||
/// Get an input stream for the package icon, if there is any
|
||||
InputStreamP openIconFile();
|
||||
|
||||
/// Open a package, and read the data
|
||||
void open(const String& package);
|
||||
void save();
|
||||
@@ -196,7 +200,7 @@ class Packaged : public Package {
|
||||
/// filename of the data file, and extension of the package file
|
||||
virtual String typeName() const = 0;
|
||||
/// Can be overloaded to do validation after loading
|
||||
virtual void validate(Version file_app_version) {}
|
||||
virtual void validate(Version file_app_version);
|
||||
|
||||
DECLARE_REFLECTION_VIRTUAL();
|
||||
};
|
||||
|
||||
@@ -26,10 +26,10 @@ class IncludePackage : public Packaged {
|
||||
String IncludePackage::typeName() const { return _("include"); }
|
||||
|
||||
IMPLEMENT_REFLECTION(IncludePackage) {
|
||||
REFLECT_BASE(Packaged);
|
||||
if (tag.reading()) {
|
||||
// ingore
|
||||
String full_name, version;
|
||||
REFLECT(full_name);
|
||||
String version;
|
||||
REFLECT(version);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user