Added empty_name to PackageChoiceField;

Package choice fields now reflect in scripts as "/:NO-WARN-DEP:packagename". This suppresses warnings when loading files in that package or using the package as a symbol font.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1187 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2008-08-31 19:42:30 +00:00
parent 20b40585f6
commit 56463a8806
7 changed files with 38 additions and 21 deletions
+8 -5
View File
@@ -25,6 +25,7 @@ IMPLEMENT_REFLECTION(PackageChoiceField) {
REFLECT(match);
REFLECT(initial);
REFLECT(required);
REFLECT(empty_name);
}
// ----------------------------------------------------------------------------- : PackageChoiceStyle
@@ -73,12 +74,14 @@ void PackageChoiceValue::reflect(Writer& tag) {
REFLECT_NAMELESS(package_name);
}
void PackageChoiceValue::reflect(GetDefaultMember& tag) {
if (!package_name.empty() && package_name != field().initial) {
// add a space to the name, to indicate the dependency doesn't have to be marked
// see also SymbolFontRef::loadFont
REFLECT_NAMELESS(_(" ") + package_name);
} else {
if (package_name.empty()) {
REFLECT_NAMELESS(package_name);
} else if(package_name != field().initial) {
// add a space to the name, to indicate the dependency doesn't have to be marked
// see also PackageManager::openFileFromPackage and SymbolFontRef::loadFont
REFLECT_NAMELESS(_("/:NO-WARN-DEP:") + package_name);
} else {
REFLECT_NAMELESS(_("/") + package_name);
}
}
void PackageChoiceValue::reflect(GetMember& tag) {}
+2 -1
View File
@@ -25,13 +25,14 @@ DECLARE_POINTER_TYPE(PackageChoiceValue);
/// A field for PackageChoice values, it contains a list of choices for PackageChoices
class PackageChoiceField : public Field {
public:
PackageChoiceField() : required(true) {}
PackageChoiceField() : required(true), empty_name(_("none")) {}
DECLARE_FIELD_TYPE(PackageChoice);
OptionalScript script; ///< Script to apply to all values
String match; ///< Package filenames to match
String initial; ///< Initial value
bool required; ///< Is selecting a package required?
String empty_name; ///< Displayed name for the empty value (if !required)
virtual void initDependencies(Context&, const Dependency&) const;
};
+1 -1
View File
@@ -577,7 +577,7 @@ void SymbolFontRef::loadFont(Context& ctx) {
font = SymbolFontP();
} else {
font = SymbolFont::byName(name);
if (name().GetChar(0) != _(' ')) {
if (starts_with(name(),_("/:NO-WARN-DEP:"))) {
// ensure the dependency on the font is present in the stylesheet this ref is in
// Getting this stylesheet from the context is a bit of a hack
// If the name starts with a ' ', no dependency is needed;