- no longer try to draw fields with huge or negative size

- download icons of packages

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@799 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-12-29 23:51:19 +00:00
parent fb972ed10a
commit 3ceec52c1c
15 changed files with 176 additions and 89 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ String ExportTemplate::typeName() const { return _("export-template"); }
void ExportTemplate::validate(Version) {
if (!game) {
throw Error(_ERROR_("no game specified for export template"));
throw Error(_ERROR_1_("no game specified",_TYPE_("export template")));
}
// an export template depends on the game it is made for
requireDependency(game.get());
+32 -11
View File
@@ -97,9 +97,9 @@ intrusive_ptr<Field> read_new<Field>(Reader& reader) {
Style::Style(const FieldP& field)
: fieldP(field)
, z_index(0)
, left(-1), top(-1)
, width(-1), height(-1)
, right(-1), bottom(-1)
, left (1000000), top (1000000)
, width(0), height(0)
, right(1000000), bottom(1000000)
, angle(0)
, visible(true)
, automatic_side(AUTO_UNKNOWN)
@@ -139,14 +139,14 @@ int Style::update(Context& ctx) {
| visible.update(ctx);
// determine automatic_side and attachment of rotation point
if (automatic_side == AUTO_UNKNOWN) {
if (right == -1) automatic_side = (AutomaticSide)(automatic_side | AUTO_RIGHT);
else if (width == -1) automatic_side = (AutomaticSide)(automatic_side | AUTO_WIDTH);
else if (left == -1) automatic_side = (AutomaticSide)(automatic_side | AUTO_LEFT);
else automatic_side = (AutomaticSide)(automatic_side | AUTO_LR);
if (bottom == -1) automatic_side = (AutomaticSide)(automatic_side | AUTO_BOTTOM);
else if (height == -1) automatic_side = (AutomaticSide)(automatic_side | AUTO_HEIGHT);
else if (top == -1) automatic_side = (AutomaticSide)(automatic_side | AUTO_TOP);
else automatic_side = (AutomaticSide)(automatic_side | AUTO_TB);
if (right == 1000000) automatic_side = (AutomaticSide)(automatic_side | AUTO_RIGHT);
else if (width == 0) automatic_side = (AutomaticSide)(automatic_side | AUTO_WIDTH);
else if (left == 1000000) automatic_side = (AutomaticSide)(automatic_side | AUTO_LEFT);
else automatic_side = (AutomaticSide)(automatic_side | AUTO_LR);
if (bottom == 1000000) automatic_side = (AutomaticSide)(automatic_side | AUTO_BOTTOM);
else if (height == 0) automatic_side = (AutomaticSide)(automatic_side | AUTO_HEIGHT);
else if (top == 1000000) automatic_side = (AutomaticSide)(automatic_side | AUTO_TOP);
else automatic_side = (AutomaticSide)(automatic_side | AUTO_TB);
changed = true;
}
if (!changed) return CHANGE_NONE;
@@ -171,10 +171,31 @@ int Style::update(Context& ctx) {
top = top + height * (1 - c);
}
}
if (width < 0) width = -width;
if (height < 0) height = -height;
// done
return CHANGE_OTHER;
}
bool Style::isVisible() const {
return visible
&& (width) > 0
&& abs(left) < 100000
&& abs(right) < 100000
&& (height) > 0
&& abs(top) < 100000
&& abs(bottom) < 100000;
}
bool Style::hasSize() const {
int h = (abs(width) > 0 || width .isScripted())
+ (abs(left) < 100000 || left .isScripted())
+ (abs(right) < 100000 || right .isScripted());
int v = (abs(height) > 0 || height.isScripted())
+ (abs(top) < 100000 || top .isScripted())
+ (abs(bottom) < 100000 || bottom.isScripted());
return h >= 2 && v >= 2;
}
void Style::initDependencies(Context& ctx, const Dependency& dep) const {
// left .initDependencies(ctx,dep);
// top .initDependencies(ctx,dep);
+5
View File
@@ -115,6 +115,11 @@ class Style : public IntrusivePtrVirtualBase {
inline RealRect getExternalRect() const { return RealRect (left, top, width, height); }
inline RealRect getInternalRect() const { return RealRect(0, 0, width, height); }
/// Does this style have a non-zero size (or is it scripted)?
bool hasSize() const;
/// Is this style visible, and does it have a sane size
bool isVisible() const;
/// Get a copy of this style
virtual StyleP clone() const = 0;
+5
View File
@@ -217,6 +217,10 @@ IMPLEMENT_REFLECTION_NO_SCRIPT(PackageDescription) {
REFLECT_N("depends ons", dependencies);
}
void PackageDescription::merge(const PackageDescription& p2) {
if (!icon.Ok() && !icon_url) icon = p2.icon;
}
IMPLEMENT_REFLECTION_NO_SCRIPT(InstallerDescription) {
REFLECT(packages);
}
@@ -290,6 +294,7 @@ bool InstallablePackage::has(PackageAction act) const {
void InstallablePackage::merge(const InstallablePackage& p) {
if (!installed) installed = p.installed;
if (!installer) {
p.description->merge(*description);
description = p.description; // installer has new description
installer = p.installer;
}
+3 -9
View File
@@ -26,15 +26,6 @@ class Installer : public Packaged {
String prefered_filename; ///< What filename should be used (by default)
vector<PackageDescriptionP> packages; ///< Packages to install
/*
/// Load an installer from a file, and run it
static void installFrom(const String& filename, bool message_on_success, bool local);
/// Install all the packages
void install(bool local, bool check_dependencies = true);
/// Install a specific package
void install(const String& package);
*/
/// Add a package to the installer (if it is not already added).
/** If the package is named *.mse-installer uses it as the filename instead */
void addPackage(const String& package);
@@ -67,6 +58,9 @@ class PackageDescription : public IntrusivePtrBase<PackageDescription> {
String description; ///< Changelog/description
vector<PackageDependencyP> dependencies; ///< Dependencies of this package
/// Merge two descriptions a package. This package takes precedence
void merge(const PackageDescription& p2);
DECLARE_REFLECTION();
};
+1 -1
View File
@@ -134,7 +134,7 @@ void Set::validate(Version file_app_version) {
Packaged::validate(file_app_version);
// are the
if (!game) {
throw Error(_ERROR_("no game specified for the set"));
throw Error(_ERROR_1_("no game specified",_TYPE_("set")));
}
if (!stylesheet) {
// TODO : Allow user to select a different style
+1 -1
View File
@@ -67,7 +67,7 @@ String StyleSheet::typeName() const { return _("style"); }
void StyleSheet::validate(Version ver) {
Packaged::validate(ver);
if (!game) {
throw Error(_ERROR_("no game specified for stylesheet"));
throw Error(_ERROR_1_("no game specified",_TYPE_("stylesheet")));
}
// a stylsheet depends on the game it is made for
requireDependency(game.get());