示例#1
0
 public static DialogResult Show(GlobalVariable variable, Game game)
 {
     GlobalVariableDialog dialog = new GlobalVariableDialog(variable, game);
     DialogResult result = dialog.ShowDialog();
     dialog.Dispose();
     return result;
 }
示例#2
0
 public GlobalVariables(XmlNode node)
 {
     foreach (XmlNode childNode in SerializeUtils.GetChildNodes(node, "Variables"))
     {
         GlobalVariable newVariable = new GlobalVariable(childNode);
         _variables.Add(newVariable.Name, newVariable);
     }
 }
示例#3
0
 private void AddNewVariableToList(GlobalVariable variable)
 {
     _variables.Add(variable);
     int addAtIndex = 0;
     if (lvwWords.SelectedIndices.Count > 0)
     {
         addAtIndex = lvwWords.SelectedIndices[0] + 1;
     }
     ListViewItem addedItem = lvwWords.Items.Insert(addAtIndex, CreateListItemFromVariable(variable));
     addedItem.Selected = true;
     addedItem.EnsureVisible();
     OnGlobalVariableChanged();
 }
示例#4
0
        public GlobalVariableDialog(GlobalVariable variable, Game game)
        {
            InitializeComponent();
            _variable = variable;
            _game = game;
            PopulateTypeList();
            txtName.Text = variable.Name ?? string.Empty;
            txtDefaultValue.Text = variable.DefaultValue ?? string.Empty;

            foreach (GlobalVariableType varType in cmbType.Items)
            {
                if (varType.TypeName == variable.Type)
                {
                    cmbType.SelectedItem = varType;
                    break;
                }
            }

            Utilities.CheckLabelWidthsOnForm(this);
        }
示例#5
0
 public void VariableRenamed(GlobalVariable variable, string oldName)
 {
     _variables.Remove(oldName);
     _variables.Add(variable.Name, variable);
 }
示例#6
0
 public void Remove(GlobalVariable variable)
 {
     _variables.Remove(variable.Name);
 }
示例#7
0
 public void Add(GlobalVariable variable)
 {
     _variables.Add(variable.Name, variable);
 }
示例#8
0
 private void ContextMenuEventHandler(object sender, EventArgs e)
 {
     ToolStripMenuItem item = (ToolStripMenuItem)sender;
     GlobalVariable selectedVariable = null;
     if (lvwWords.SelectedItems.Count > 0)
     {
         selectedVariable = ((GlobalVariable)lvwWords.SelectedItems[0].Tag);
     }
     if ((item.Name == MENU_ITEM_EDIT_WORD) && (selectedVariable != null))
     {
         EditSelectedVariable(selectedVariable);
     }
     else if (item.Name == MENU_ITEM_ADD_WORD)
     {
         GlobalVariable variable = new GlobalVariable();
         if (GlobalVariableDialog.Show(variable, _game) == DialogResult.OK)
         {
             AddNewVariableToList(variable);
         }
     }
     else if (item.Name == MENU_ITEM_DELETE_WORD)
     {
         if (Factory.GUIController.ShowQuestion("Are you sure you want to remove the variable '" + selectedVariable.Name + "'? If you are using it in your scripts, your game will no longer compile.", MessageBoxIcon.Warning) == DialogResult.Yes)
         {
             lvwWords.Items.RemoveAt(lvwWords.SelectedIndices[0]);
             _variables.Remove(selectedVariable);
             OnGlobalVariableChanged();
         }
     }
 }
示例#9
0
        private void EditSelectedVariable(GlobalVariable variable)
        {
            string nameWas = variable.Name;
            if (GlobalVariableDialog.Show(variable, _game) == DialogResult.OK)
            {
                if (variable.Name != nameWas)
                {
                    _variables.VariableRenamed(variable, nameWas);
                }

                lvwWords.SelectedItems[0].SubItems[0].Text = variable.Name;
                lvwWords.SelectedItems[0].SubItems[1].Text = variable.Type;
                lvwWords.SelectedItems[0].SubItems[2].Text = variable.DefaultValue;
                OnGlobalVariableChanged();
            }
        }
示例#10
0
 private ListViewItem CreateListItemFromVariable(GlobalVariable variable)
 {
     ListViewItem newItem = new ListViewItem(new string[] { variable.Name, variable.Type, variable.DefaultValue });
     newItem.Tag = variable;
     return newItem;
 }
示例#11
0
 private void FindSelectedVariable(GlobalVariable variable)
 {
     TextProcessing.FindAllUsages findAllUsages = new TextProcessing.FindAllUsages(null,
         null, null, AGSEditor.Instance);
     findAllUsages.Find(null, variable.Name);
 }
示例#12
0
 public void VariableRenamed(GlobalVariable variable, string oldName)
 {
     _variables.Remove(oldName);
     _variables.Add(variable.Name, variable);
 }
示例#13
0
 public void Remove(GlobalVariable variable)
 {
     _variables.Remove(variable.Name);
 }
示例#14
0
 public void Add(GlobalVariable variable)
 {
     _variables.Add(variable.Name, variable);
 }