diff --git a/src/data/game.cpp b/src/data/game.cpp index fcc30a57..9c552df4 100644 --- a/src/data/game.cpp +++ b/src/data/game.cpp @@ -36,18 +36,8 @@ bool Game::isMagic() const { String Game::typeNameStatic() { return _("game"); } String Game::typeName() const { return _("game"); } -String Game::fullName() const { return full_name; } -InputStreamP Game::openIconFile() { - if (!icon_filename.empty()) { - return openIn(icon_filename); - } else { - return InputStreamP(); - } -} - IMPLEMENT_REFLECTION(Game) { - REFLECT(full_name); - REFLECT_N("icon", icon_filename); + REFLECT_BASE(Packaged); REFLECT(init_script); REFLECT(set_fields); REFLECT(card_fields); @@ -59,9 +49,8 @@ IMPLEMENT_REFLECTION(Game) { // REFLECT(word_lists); } -void Game::validate(Version) { - // a default for the full name - if (full_name.empty()) full_name = name(); +void Game::validate(Version v) { + Packaged::validate(v); // automatic statistics dimensions { vector dims; diff --git a/src/data/game.hpp b/src/data/game.hpp index 9c058ff6..7a4c7c4d 100644 --- a/src/data/game.hpp +++ b/src/data/game.hpp @@ -33,8 +33,6 @@ class Game : public Packaged { public: Game(); - String full_name; ///< Name of this game, for menus etc. - String icon_filename; ///< Filename of icon to use in NewWindow OptionalScript init_script; ///< Script of variables available to other scripts in this game vector set_fields; ///< Fields for set information vector card_fields; ///< Fields on each card @@ -57,8 +55,6 @@ class Game : public Packaged { static String typeNameStatic(); virtual String typeName() const; - virtual String fullName() const; - virtual InputStreamP openIconFile(); protected: virtual void validate(Version); diff --git a/src/data/locale.cpp b/src/data/locale.cpp index 2d99dda3..fbaa4c4f 100644 --- a/src/data/locale.cpp +++ b/src/data/locale.cpp @@ -21,7 +21,7 @@ LocaleP Locale::byName(const String& name) { } IMPLEMENT_REFLECTION(Locale) { - REFLECT(full_name); + REFLECT_BASE(Packaged); REFLECT_N("menu", translations[LOCALE_CAT_MENU]); REFLECT_N("help", translations[LOCALE_CAT_HELP]); REFLECT_N("tool", translations[LOCALE_CAT_TOOL]); diff --git a/src/data/locale.hpp b/src/data/locale.hpp index bb810da5..dfd845df 100644 --- a/src/data/locale.hpp +++ b/src/data/locale.hpp @@ -29,8 +29,6 @@ class GameLocale { /// A collection of translations of messages class Locale : public Packaged { public: - /// Name of this locale - String full_name; /// Translations of UI strings in each category map translations[LOCALE_CAT_MAX]; /// Translations of game specific texts, by game name diff --git a/src/data/stylesheet.cpp b/src/data/stylesheet.cpp index e652eef9..d32477c5 100644 --- a/src/data/stylesheet.cpp +++ b/src/data/stylesheet.cpp @@ -36,15 +36,6 @@ String StyleSheet::stylesheetName() const { String StyleSheet::typeNameStatic() { return _("style"); } String StyleSheet::typeName() const { return _("style"); } -String StyleSheet::fullName() const { return full_name; } -InputStreamP StyleSheet::openIconFile() { - if (!icon_filename.empty()) { - return openIn(icon_filename); - } else { - return game->openIconFile(); // use game icon by default - } -} - StyleP StyleSheet::styleFor(const FieldP& field) { if (card_style.containsKey(field)) { return card_style[field]; @@ -70,8 +61,7 @@ IMPLEMENT_REFLECTION(StyleSheet) { tag.addAlias(300, _("extra style"),_("styling style")); REFLECT(game); - REFLECT(full_name); - REFLECT_N("icon", icon_filename); + REFLECT_BASE(Packaged); REFLECT(init_script); REFLECT(card_width); REFLECT(card_height); @@ -90,11 +80,6 @@ IMPLEMENT_REFLECTION(StyleSheet) { REFLECT(styling_style); } -void StyleSheet::validate(Version) { - // a default for the full name - if (full_name.empty()) full_name = name(); -} - // special behaviour of reading/writing StyleSheetPs: only read/write the name diff --git a/src/data/stylesheet.hpp b/src/data/stylesheet.hpp index 9b25047b..58c8f97e 100644 --- a/src/data/stylesheet.hpp +++ b/src/data/stylesheet.hpp @@ -27,8 +27,6 @@ class StyleSheet : public Packaged { StyleSheet(); GameP game; ///< The game this stylesheet is made for - String full_name; ///< Name of this game, for menus etc. - String icon_filename; ///< Filename of icon to use in NewWindow OptionalScript init_script; ///< Script of variables available to other scripts in this stylesheet double card_width; ///< The width of a card in pixels double card_height; ///< The height of a card in pixels @@ -60,11 +58,8 @@ class StyleSheet : public Packaged { static String typeNameStatic(); virtual String typeName() const; - virtual String fullName() const; - virtual InputStreamP openIconFile(); protected: - virtual void validate(Version); DECLARE_REFLECTION(); }; diff --git a/src/gui/control/package_list.cpp b/src/gui/control/package_list.cpp index 204c5407..76d88a70 100644 --- a/src/gui/control/package_list.cpp +++ b/src/gui/control/package_list.cpp @@ -33,14 +33,14 @@ void PackageList::drawItem(DC& dc, int x, int y, size_t item, bool selected) { } // draw short name dc.SetFont(wxFont(12,wxSWISS,wxNORMAL,wxBOLD,false,_("Arial"))); - dc.GetTextExtent(capitalize(d.package->name()), &w, &h); + dc.GetTextExtent(capitalize(d.package->short_name), &w, &h); pos = align_in_rect(ALIGN_CENTER, RealSize(w,h), rect); - dc.DrawText(capitalize(d.package->name()), pos.x, pos.y + 110); + dc.DrawText(capitalize(d.package->short_name), pos.x, pos.y + 110); // draw name dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); - dc.GetTextExtent(d.package->fullName(), &w, &h); + dc.GetTextExtent(d.package->full_name, &w, &h); RealPoint text_pos = align_in_rect(ALIGN_CENTER, RealSize(w,h), rect); - dc.DrawText(d.package->fullName(), text_pos.x, text_pos.y + 130); + dc.DrawText(d.package->full_name, text_pos.x, text_pos.y + 130); } void PackageList::showData(const String& pattern) { @@ -51,7 +51,7 @@ void PackageList::showData(const String& pattern) { while (!f.empty()) { // try to open the package // try { - PackageP package = ::packages.openAny(f); + PackagedP package = ::packages.openAny(f); // open image InputStreamP stream = package->openIconFile(); Image img; diff --git a/src/gui/control/package_list.hpp b/src/gui/control/package_list.hpp index 9e91c9ec..34aac9b2 100644 --- a/src/gui/control/package_list.hpp +++ b/src/gui/control/package_list.hpp @@ -12,7 +12,7 @@ #include #include -DECLARE_POINTER_TYPE(Package); +DECLARE_POINTER_TYPE(Packaged); // ----------------------------------------------------------------------------- : PackageList @@ -59,9 +59,9 @@ class PackageList : public GalleryList { // Information about a package struct PackageData { PackageData() {} - PackageData(const PackageP& package, const Bitmap& image) : package(package), image(image) {} - PackageP package; - Bitmap image; + PackageData(const PackagedP& package, const Bitmap& image) : package(package), image(image) {} + PackagedP package; + Bitmap image; }; /// The displayed packages vector packages; diff --git a/src/mse.vcproj b/src/mse.vcproj index 237e20ec..fd7f2b8e 100644 --- a/src/mse.vcproj +++ b/src/mse.vcproj @@ -97,7 +97,7 @@ BufferSecurityCheck="FALSE" EnableFunctionLevelLinking="TRUE" RuntimeTypeInfo="TRUE" - UsePrecompiledHeader="2" + UsePrecompiledHeader="0" PrecompiledHeaderThrough="util/prec.hpp" PrecompiledHeaderFile="" AssemblerListingLocation="$(OutDir)" diff --git a/src/util/io/package.cpp b/src/util/io/package.cpp index 4ea22b1c..ff6037dd 100644 --- a/src/util/io/package.cpp +++ b/src/util/io/package.cpp @@ -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(); +} \ No newline at end of file diff --git a/src/util/io/package.hpp b/src/util/io/package.hpp index a6d96341..d6d2d50a 100644 --- a/src/util/io/package.hpp +++ b/src/util/io/package.hpp @@ -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(); }; diff --git a/src/util/io/package_manager.cpp b/src/util/io/package_manager.cpp index 0f92a7e2..3dda65f8 100644 --- a/src/util/io/package_manager.cpp +++ b/src/util/io/package_manager.cpp @@ -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); } }