mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 21:06:59 -04:00
paritially implemented MultipleChoice viewer/editor
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@222 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -212,11 +212,14 @@ IMPLEMENT_REFLECTION_ENUM(ChoicePopupStyle) {
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION_ENUM(ChoiceRenderStyle) {
|
||||
VALUE_N("text", RENDER_TEXT);
|
||||
VALUE_N("image", RENDER_IMAGE);
|
||||
VALUE_N("both", RENDER_BOTH);
|
||||
VALUE_N("hidden", RENDER_HIDDEN);
|
||||
VALUE_N("image hidden", RENDER_HIDDEN_IMAGE);
|
||||
VALUE_N("text", RENDER_TEXT);
|
||||
VALUE_N("image", RENDER_IMAGE);
|
||||
VALUE_N("both", RENDER_BOTH);
|
||||
VALUE_N("hidden", RENDER_HIDDEN);
|
||||
VALUE_N("image hidden", RENDER_HIDDEN_IMAGE);
|
||||
VALUE_N("checklist", RENDER_TEXT_CHECKLIST);
|
||||
VALUE_N("image checklist", RENDER_IMAGE_CHECKLIST);
|
||||
VALUE_N("both checklist", RENDER_BOTH_CHECKLIST);
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION(ChoiceStyle) {
|
||||
|
||||
@@ -103,11 +103,15 @@ enum ChoicePopupStyle
|
||||
};
|
||||
// How should a choice value be rendered?
|
||||
enum ChoiceRenderStyle
|
||||
{ RENDER_TEXT = 0x01 // render the name as text
|
||||
, RENDER_IMAGE = 0x10 // render an image
|
||||
, RENDER_BOTH = RENDER_TEXT | RENDER_IMAGE
|
||||
, RENDER_HIDDEN = 0x20 // don't render anything, only have a menu
|
||||
, RENDER_HIDDEN_IMAGE = RENDER_HIDDEN | RENDER_IMAGE
|
||||
{ RENDER_TEXT = 0x01 // render the name as text
|
||||
, 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_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
|
||||
};
|
||||
|
||||
/// The Style for a ChoiceField
|
||||
@@ -147,9 +151,9 @@ class ChoiceStyle : public Style {
|
||||
/// The Value in a ChoiceField
|
||||
class ChoiceValue : public Value {
|
||||
public:
|
||||
inline ChoiceValue(const ChoiceFieldP& field)
|
||||
inline ChoiceValue(const ChoiceFieldP& field, bool initial_empty = false)
|
||||
: Value(field)
|
||||
, value(field->initial.empty()
|
||||
, value(field->initial.empty() && !initial_empty
|
||||
? field->choices->choiceName(0) // first choice
|
||||
: field->initial, true)
|
||||
{}
|
||||
|
||||
@@ -51,3 +51,22 @@ IMPLEMENT_REFLECTION(MultipleChoiceStyle) {
|
||||
IMPLEMENT_REFLECTION_NAMELESS(MultipleChoiceValue) {
|
||||
REFLECT_BASE(ChoiceValue);
|
||||
}
|
||||
|
||||
void MultipleChoiceValue::get(vector<String>& out) const {
|
||||
// split the value
|
||||
out.clear();
|
||||
bool is_new = true;
|
||||
FOR_EACH_CONST(c, value()) {
|
||||
if (c == _(',')) {
|
||||
is_new = true;
|
||||
} else if (is_new) {
|
||||
if (c != _(' ')) { // ignore whitespace after ,
|
||||
is_new = false;
|
||||
out.push_back(String(1, c));
|
||||
}
|
||||
} else {
|
||||
assert(!out.empty());
|
||||
out.back() += c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,13 +57,13 @@ class MultipleChoiceStyle : public ChoiceStyle {
|
||||
*/
|
||||
class MultipleChoiceValue : public ChoiceValue {
|
||||
public:
|
||||
inline MultipleChoiceValue(const MultipleChoiceFieldP& field) : ChoiceValue(field) {}
|
||||
inline MultipleChoiceValue(const MultipleChoiceFieldP& field) : ChoiceValue(field, true) {}
|
||||
DECLARE_HAS_FIELD(MultipleChoice);
|
||||
|
||||
// no extra data
|
||||
|
||||
/// Splits the value, stores the selected choices in the out parameter
|
||||
void get(vector<String>& out);
|
||||
void get(vector<String>& out) const;
|
||||
|
||||
private:
|
||||
DECLARE_REFLECTION();
|
||||
|
||||
@@ -40,6 +40,7 @@ IMPLEMENT_REFLECTION(Game) {
|
||||
REFLECT_BASE(Packaged);
|
||||
REFLECT(init_script);
|
||||
REFLECT(set_fields);
|
||||
REFLECT(default_set_style);
|
||||
REFLECT(card_fields);
|
||||
REFLECT(statistics_dimensions);
|
||||
REFLECT(statistics_categories);
|
||||
|
||||
+8
-6
@@ -16,6 +16,7 @@
|
||||
#include <util/dynamic_arg.hpp>
|
||||
|
||||
DECLARE_POINTER_TYPE(Field);
|
||||
DECLARE_POINTER_TYPE(Style);
|
||||
DECLARE_POINTER_TYPE(Game);
|
||||
DECLARE_POINTER_TYPE(StatsDimension);
|
||||
DECLARE_POINTER_TYPE(StatsCategory);
|
||||
@@ -33,9 +34,10 @@ class Game : public Packaged {
|
||||
public:
|
||||
Game();
|
||||
|
||||
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
|
||||
OptionalScript init_script; ///< Script of variables available to other scripts in this game
|
||||
vector<FieldP> set_fields; ///< Fields for set information
|
||||
IndexMap<FieldP,StyleP> default_set_style; ///< Default style for the set fields, because it is often the same
|
||||
vector<FieldP> card_fields; ///< Fields on each card
|
||||
vector<StatsDimensionP> statistics_dimensions; ///< (Additional) statistics dimensions
|
||||
vector<StatsCategoryP> statistics_categories; ///< (Additional) statistics categories
|
||||
|
||||
@@ -44,9 +46,9 @@ class Game : public Packaged {
|
||||
vector<KeywordModeP> keyword_modes; ///< Modes of keywords
|
||||
vector<KeywordP> keywords; ///< Keywords for use in text
|
||||
|
||||
Dependencies dependent_scripts_cards; ///< scripts that depend on the card list
|
||||
Dependencies dependent_scripts_keywords; ///< scripts that depend on the keywords
|
||||
bool dependencies_initialized; ///< are the script dependencies comming from this game all initialized?
|
||||
Dependencies dependent_scripts_cards; ///< scripts that depend on the card list
|
||||
Dependencies dependent_scripts_keywords; ///< scripts that depend on the keywords
|
||||
bool dependencies_initialized; ///< are the script dependencies comming from this game all initialized?
|
||||
|
||||
/// Loads the game with a particular name, for example "magic"
|
||||
static GameP byName(const String& name);
|
||||
|
||||
Reference in New Issue
Block a user