예제 #1
0
        protected virtual void Add(string attributeName, Func <object> createAttributeValue)
        {
            if (attributeName.Length == 0)
            {
                PopupEditors.EditStringResult result = PopupEditors.EditString(L.T("EditorEnterNameAttribute"), string.Empty);
                if (result.Cancelled)
                {
                    return;
                }
                attributeName = result.Result;
            }

            bool setSelection = true;

            if (!lstAttributes.Items.ContainsKey(attributeName))
            {
                m_controller.StartTransaction(string.Format("Add '{0}' attribute", attributeName));

                ValidationResult setAttrResult = m_data.SetAttribute(attributeName, createAttributeValue());
                if (!setAttrResult.Valid)
                {
                    PopupEditors.DisplayValidationError(setAttrResult, attributeName, "Unable to add attribute");
                    setSelection = false;
                }

                m_controller.EndTransaction();
            }

            if (setSelection)
            {
                lstAttributes.Items[attributeName].Selected = true;
                lstAttributes.SelectedItems[0].EnsureVisible();
            }
        }
예제 #2
0
        protected override void AddNewValue(PopupEditors.EditStringResult addKey)
        {
            IEditableScripts script = Controller.CreateNewEditableScripts(null, null, null, true);

            if (List == null)
            {
                Value = Controller.CreateNewEditableScriptDictionary(ElementName, AttributeName, addKey.Result, script, true);

                // Script will have been cloned, so ensure we use a reference to the script that actually appears in the dictionary
                script = List[addKey.Result];
            }
            else
            {
                List.Add(addKey.Result, script);
            }

            PopupEditors.EditScript(Controller, ref script, null, null, false, () => RaiseDirty(new DataModifiedEventArgs(null, List)));
        }
예제 #3
0
        protected override void AddNewValue(PopupEditors.EditStringResult addKey)
        {
            var addValue = PopupEditors.EditString(ControlData.GetString("valueprompt"), string.Empty, allowEmptyString: true);

            if (addValue.Cancelled)
            {
                return;
            }

            PrepareForEditing();

            if (List == null)
            {
                Value = Controller.CreateNewEditableStringDictionary(ElementName, AttributeName, addKey.Result, addValue.Result, true);
            }
            else
            {
                List.Add(addKey.Result, addValue.Result);
            }
        }
예제 #4
0
        protected override void Add()
        {
            // TO DO: This fetches all verbs in the game, but verbs can be defined in rooms, so we should
            // filter out any out-of-scope verbs.

            IDictionary <string, string> availableVerbs = Controller.GetVerbProperties();

            PopupEditors.EditStringResult result = PopupEditors.EditString(
                "Please enter a name for the new verb",
                string.Empty,
                availableVerbs.Values);

            if (result.Cancelled)
            {
                return;
            }

            string selectedPattern   = result.Result.ToLower();
            string selectedAttribute = Controller.GetVerbAttributeForPattern(selectedPattern);

            AddVerb(selectedPattern, selectedAttribute);
        }
예제 #5
0
 protected abstract void AddNewValue(PopupEditors.EditStringResult addKey);