mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57: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:
+3
-14
@@ -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<StatsDimensionP> dims;
|
||||
|
||||
@@ -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<FieldP> set_fields; ///< Fields for set information
|
||||
vector<FieldP> 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);
|
||||
|
||||
+1
-1
@@ -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]);
|
||||
|
||||
@@ -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<String,String> translations[LOCALE_CAT_MAX];
|
||||
/// Translations of game specific texts, by game name
|
||||
|
||||
+1
-16
@@ -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
|
||||
|
||||
|
||||
@@ -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();
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/control/gallery_list.hpp>
|
||||
|
||||
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<PackageData> packages;
|
||||
|
||||
+1
-1
@@ -97,7 +97,7 @@
|
||||
BufferSecurityCheck="FALSE"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
RuntimeTypeInfo="TRUE"
|
||||
UsePrecompiledHeader="2"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderThrough="util/prec.hpp"
|
||||
PrecompiledHeaderFile=""
|
||||
AssemblerListingLocation="$(OutDir)"
|
||||
|
||||
+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