Reader now warns about invalid UTF-8 files;

Fixed possible hang when reading multiline strings with incorrect indentation;
Warnings from reading are shown also in NewSetWindow;
Script parse errors get reported with the correct line number;

Added support for showing multiple choice fields as a single image;
Added 'line_below' to ChoiceField::Choice, for putting a line below menu items.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@420 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-06-12 19:35:24 +00:00
parent 27833003c8
commit 8b11433cbd
20 changed files with 318 additions and 86 deletions
+8 -1
View File
@@ -49,9 +49,11 @@ IMPLEMENT_REFLECTION(ChoiceField) {
ChoiceField::Choice::Choice()
: first_id(0)
, line_below(false), enabled(true)
{}
ChoiceField::Choice::Choice(const String& name)
: name(name), first_id(0)
, line_below(false), enabled(true)
{}
@@ -138,11 +140,13 @@ String ChoiceField::Choice::choiceNameNice(int id) const {
IMPLEMENT_REFLECTION_NO_GET_MEMBER(ChoiceField::Choice) {
if (isGroup() || (tag.reading() && tag.isComplex())) {
if (isGroup() || line_below || enabled.isScripted() || (tag.reading() && tag.isComplex())) {
// complex values are groups
REFLECT(name);
REFLECT_N("group_choice", default_name);
REFLECT(choices);
REFLECT(line_below);
REFLECT(enabled);
} else {
REFLECT_NAMELESS(name);
}
@@ -237,6 +241,9 @@ IMPLEMENT_REFLECTION_ENUM(ChoiceRenderStyle) {
VALUE_N("checklist", RENDER_TEXT_CHECKLIST);
VALUE_N("image checklist", RENDER_IMAGE_CHECKLIST);
VALUE_N("both checklist", RENDER_BOTH_CHECKLIST);
VALUE_N("text list", RENDER_IMAGE_LIST);
VALUE_N("image list", RENDER_IMAGE_LIST);
VALUE_N("both list", RENDER_IMAGE_LIST);
}
IMPLEMENT_REFLECTION(ChoiceStyle) {
+9 -3
View File
@@ -52,9 +52,11 @@ class ChoiceField::Choice : public IntrusivePtrBase<ChoiceField::Choice> {
Choice();
Choice(const String& name);
String name; ///< Name/value of the item
String default_name; ///< A default item, if this is a group and default_name.empty() there is no default
vector<ChoiceP> choices; ///< Choices and sub groups in this group
String name; ///< Name/value of the item
String default_name; ///< A default item, if this is a group and default_name.empty() there is no default
vector<ChoiceP> choices; ///< Choices and sub groups in this group
bool line_below; ///< Show a line after this item?
Scriptable<bool> enabled; ///< Is this item enabled?
/// First item-id in this group (can be the default item)
/** Item-ids are consecutive integers, a group uses all ids [first_id..lastId()).
* The top level group has first_id 0.
@@ -109,11 +111,15 @@ enum ChoiceRenderStyle
, RENDER_IMAGE = 0x10 // render an image
, RENDER_HIDDEN = 0x20 // don't render anything, only have a menu
, RENDER_CHECKLIST = 0x100 // render as a checklist, intended for multiple choice
, RENDER_LIST = 0x200 // render as a list of images/text, intended for multiple choice
, RENDER_BOTH = RENDER_TEXT | RENDER_IMAGE
, RENDER_HIDDEN_IMAGE = RENDER_HIDDEN | RENDER_IMAGE
, RENDER_TEXT_CHECKLIST = RENDER_CHECKLIST | RENDER_TEXT
, RENDER_IMAGE_CHECKLIST = RENDER_CHECKLIST | RENDER_IMAGE
, RENDER_BOTH_CHECKLIST = RENDER_CHECKLIST | RENDER_BOTH
, RENDER_TEXT_LIST = RENDER_LIST | RENDER_TEXT
, RENDER_IMAGE_LIST = RENDER_LIST | RENDER_IMAGE
, RENDER_BOTH_LIST = RENDER_LIST | RENDER_BOTH
};
enum ThumbnailStatus
+1
View File
@@ -25,6 +25,7 @@ IMPLEMENT_REFLECTION(MultipleChoiceField) {
REFLECT_BASE(ChoiceField);
REFLECT(minimum_selection);
REFLECT(maximum_selection);
REFLECT(empty_choice);
}
// ----------------------------------------------------------------------------- : MultipleChoiceStyle
+6 -1
View File
@@ -25,6 +25,7 @@ class MultipleChoiceField : public ChoiceField {
DECLARE_FIELD_TYPE(MultipleChoiceField);
UInt minimum_selection, maximum_selection; ///< How many choices can be selected simultaniously?
String empty_choice; ///< Name to use when nothing is selected
private:
DECLARE_REFLECTION();
@@ -56,7 +57,7 @@ class MultipleChoiceValue : public ChoiceValue {
inline MultipleChoiceValue(const MultipleChoiceFieldP& field) : ChoiceValue(field, true) {}
DECLARE_HAS_FIELD(MultipleChoice);
// no extra data
String last_choice; ///< Which of the choices was selected/deselected last?
/// Splits the value, stores the selected choices in the out parameter
void get(vector<String>& out) const;
@@ -65,6 +66,10 @@ class MultipleChoiceValue : public ChoiceValue {
DECLARE_REFLECTION();
};
// ----------------------------------------------------------------------------- : Utilities
/// Is the given choice selected in the value?
bool chosen(const String& multiple_choice_value, const String& chioce);
// ----------------------------------------------------------------------------- : EOF
#endif