public ExpressionTemplateEditorData(string expression, EditorDefinition definition) { // 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; }
public EditorTab(EditorDefinition parent, WorldModel worldModel, Element source) { m_controls = new Dictionary<string, IEditorControl>(); m_caption = source.Fields.GetString("caption"); 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); }
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); if (source.Fields.HasString("filtergroup")) { parent.RegisterFilter(source.Fields.GetString("filtergroup"), source.Fields.GetString("filter"), m_attribute); } }
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.GetString("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), worldModel); m_alwaysVisible = false; } }
public bool Initialise(string filename) { m_filename = filename; m_worldModel = new WorldModel(filename, 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; bool ok = m_worldModel.InitialiseEdit(); // 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 (ok) { UpdateTree(); } 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(message); } return ok; }