예제 #1
0
        public EditorVisibilityHelper(EditorDefinition parent, WorldModel worldModel, Element source)
        {
            m_parent           = parent;
            m_worldModel       = worldModel;
            m_relatedAttribute = source.Fields.GetString("relatedattribute");
            if (m_relatedAttribute != null)
            {
                m_alwaysVisible = false;
            }
            m_visibleIfRelatedAttributeIsType = source.Fields.GetString("relatedattributedisplaytype");
            m_visibleIfElementInheritsType    = source.Fields.GetAsType <QuestList <string> >("mustinherit");
            m_notVisibleIfElementInheritsType = source.Fields.GetAsType <QuestList <string> >("mustnotinherit");
            if (m_visibleIfElementInheritsType != null || m_notVisibleIfElementInheritsType != null)
            {
                m_alwaysVisible = false;
            }
            m_filterGroup = source.Fields.GetString("filtergroup");
            m_filter      = source.Fields.GetString("filter");
            if (m_filter != null)
            {
                m_alwaysVisible = false;
            }

            string expression = source.Fields.GetString("onlydisplayif");

            if (expression != null)
            {
                m_visibilityExpression = new Expression <bool>(Utility.ConvertVariablesToFleeFormat(expression), new TextAdventures.Quest.Scripts.ScriptContext(worldModel, true));
                m_alwaysVisible        = false;
            }
        }
예제 #2
0
        public EditorControl(EditorDefinition parent, WorldModel worldModel, Element source)
        {
            m_parent      = parent;
            m_worldModel  = worldModel;
            m_source      = source;
            m_controlType = source.Fields.GetString("controltype");
            m_caption     = source.Fields.GetString("caption");
            m_attribute   = source.Fields.GetString("attribute");
            if (source.Fields.HasType <int>("height"))
            {
                m_height = source.Fields.GetAsType <int>("height");
            }
            if (source.Fields.HasType <int>("width"))
            {
                m_width = source.Fields.GetAsType <int>("width");
            }
            if (source.Fields.HasType <bool>("expand"))
            {
                m_expand = source.Fields.GetAsType <bool>("expand");
            }
            m_visibilityHelper           = new EditorVisibilityHelper(parent, worldModel, source);
            IsControlVisibleInSimpleMode = !source.Fields.GetAsType <bool>("advanced");
            m_id = source.Name;

            if (source.Fields.HasString("filtergroup"))
            {
                parent.RegisterFilter(source.Fields.GetString("filtergroup"), source.Fields.GetString("filter"), m_attribute);
            }
        }
예제 #3
0
        public ExpressionTemplateEditorData(string expression, EditorDefinition definition, IEditorData parentData)
        {
            // We get passed in an expression like "Got(myobject)"
            // The definition has pattern like "Got(#object#)" (as a regex)
            // We create the parameter dictionary in the same way as the command parser, so
            // we end up with a dictionary like "object=myobject".

            m_parameters = Utility.Populate(definition.Pattern, expression);
            m_originalPattern = definition.OriginalPattern;
            m_parentData = parentData;
        }
예제 #4
0
        public ExpressionTemplateEditorData(string expression, EditorDefinition definition, IEditorData parentData)
        {
            // We get passed in an expression like "Got(myobject)"
            // The definition has pattern like "Got(#object#)" (as a regex)
            // We create the parameter dictionary in the same way as the command parser, so
            // we end up with a dictionary like "object=myobject".

            m_parameters      = Utility.Populate(definition.Pattern, expression);
            m_originalPattern = definition.OriginalPattern;
            m_parentData      = parentData;
        }
예제 #5
0
        public EditorTab(EditorDefinition parent, WorldModel worldModel, Element source)
        {
            m_controls = new Dictionary <string, IEditorControl>();
            m_caption  = source.Fields.GetString("caption");
            IsTabVisibleInSimpleMode = !source.Fields.GetAsType <bool>("advanced");

            foreach (Element e in worldModel.Elements.GetElements(ElementType.EditorControl))
            {
                if (e.Parent == source)
                {
                    m_controls.Add(e.Name, new EditorControl(parent, worldModel, e));
                }
            }
            m_visibilityHelper = new EditorVisibilityHelper(parent, worldModel, source);
            m_source           = source;
        }
예제 #6
0
파일: EditorTab.cs 프로젝트: JatinR/quest
        public EditorTab(EditorDefinition parent, WorldModel worldModel, Element source)
        {
            m_controls = new Dictionary<string, IEditorControl>();
            m_caption = source.Fields.GetString("caption");
            IsTabVisibleInSimpleMode = !source.Fields.GetAsType<bool>("advanced");

            foreach (Element e in worldModel.Elements.GetElements(ElementType.EditorControl))
            {
                if (e.Parent == source)
                {
                    m_controls.Add(e.Name, new EditorControl(parent, worldModel, e));
                }
            }
            m_visibilityHelper = new EditorVisibilityHelper(parent, worldModel, source);
            m_source = source;
        }
예제 #7
0
        public EditorControl(EditorDefinition parent, WorldModel worldModel, Element source)
        {
            m_parent = parent;
            m_worldModel = worldModel;
            m_source = source;
            m_controlType = source.Fields.GetString("controltype");
            m_caption = source.Fields.GetString("caption");
            m_attribute = source.Fields.GetString("attribute");
            if (source.Fields.HasType<int>("height")) m_height = source.Fields.GetAsType<int>("height");
            if (source.Fields.HasType<int>("width")) m_width = source.Fields.GetAsType<int>("width");
            if (source.Fields.HasType<bool>("expand")) m_expand = source.Fields.GetAsType<bool>("expand");            
            m_visibilityHelper = new EditorVisibilityHelper(parent, worldModel, source);
            IsControlVisibleInSimpleMode = !source.Fields.GetAsType<bool>("advanced");
            m_id = source.Name;

            if (source.Fields.HasString("filtergroup"))
            {
                parent.RegisterFilter(source.Fields.GetString("filtergroup"), source.Fields.GetString("filter"), m_attribute);
            }
        }
예제 #8
0
        public EditorVisibilityHelper(EditorDefinition parent, WorldModel worldModel, Element source)
        {
            m_parent = parent;
            m_worldModel = worldModel;
            m_relatedAttribute = source.Fields.GetString("relatedattribute");
            if (m_relatedAttribute != null) m_alwaysVisible = false;
            m_visibleIfRelatedAttributeIsType = source.Fields.GetString("relatedattributedisplaytype");
            m_visibleIfElementInheritsType = source.Fields.GetAsType<QuestList<string>>("mustinherit");
            m_notVisibleIfElementInheritsType = source.Fields.GetAsType<QuestList<string>>("mustnotinherit");
            if (m_visibleIfElementInheritsType != null || m_notVisibleIfElementInheritsType != null) m_alwaysVisible = false;
            m_filterGroup = source.Fields.GetString("filtergroup");
            m_filter = source.Fields.GetString("filter");
            if (m_filter != null) m_alwaysVisible = false;

            string expression = source.Fields.GetString("onlydisplayif");
            if (expression != null)
            {
                m_visibilityExpression = new Expression<bool>(Utility.ConvertVariablesToFleeFormat(expression), new TextAdventures.Quest.Scripts.ScriptContext(worldModel, true));
                m_alwaysVisible = false;
            }
        }
예제 #9
0
        public bool Initialise(string filename, string libFolder = null)
        {
            m_filename = filename;
            m_worldModel = new WorldModel(filename, libFolder, null);
            m_scriptFactory = new ScriptFactory(m_worldModel);
            m_worldModel.ElementFieldUpdated += m_worldModel_ElementFieldUpdated;
            m_worldModel.ElementRefreshed += m_worldModel_ElementRefreshed;
            m_worldModel.ElementMetaFieldUpdated += m_worldModel_ElementMetaFieldUpdated;
            m_worldModel.UndoLogger.TransactionsUpdated += UndoLogger_TransactionsUpdated;
            m_worldModel.Elements.ElementRenamed += Elements_ElementRenamed;
            m_worldModel.LoadStatus += m_worldModel_LoadStatus;

            bool ok = m_worldModel.InitialiseEdit();

            if (ok)
            {
                if (m_worldModel.Game.Fields.Get("_editorstyle") as string == "gamebook")
                {
                    m_editorStyle = EditorStyle.GameBook;
                    m_ignoredTypes.Add(ElementType.Template);
                    m_ignoredTypes.Add(ElementType.ObjectType);
                }

                // need to initialise the EditableScriptFactory after we've loaded the game XML above,
                // as the editor definitions contain the "friendly" templates for script commands.
                m_editableScriptFactory = new EditableScriptFactory(this, m_scriptFactory, m_worldModel);

                m_initialised = true;

                m_worldModel.ObjectsUpdated += m_worldModel_ObjectsUpdated;

                foreach (Element e in m_worldModel.Elements.GetElements(ElementType.Editor))
                {
                    EditorDefinition def = new EditorDefinition(m_worldModel, e);
                    if (def.AppliesTo != null)
                    {
                        // Normal editor definition for editing an element or a script command
                        m_editorDefinitions.Add(def.AppliesTo, def);
                    }
                    else if (def.Pattern != null)
                    {
                        // Editor definition for an expression template in the "if" editor
                        m_expressionDefinitions.Add(def.Pattern, def);
                    }
                }

                if (m_worldModel.Version == WorldModelVersion.v500)
                {
                    m_worldModel.Elements.Get("game").Fields.Set("gameid", GetNewGameId());
                }
            }
            else
            {
                string message = "Failed to load game due to the following errors:" + Environment.NewLine;
                foreach (string error in m_worldModel.Errors)
                {
                    message += "* " + error + Environment.NewLine;
                }
                ShowMessage(this, new ShowMessageEventArgs { Message = message });
            }

            return ok;
        }