Beispiel #1
0
 /// <summary>
 /// Helper method. Applies the value change specified by 'args' to the item property specified if the value is >= 0.
 /// </summary>
 /// <param name="property"></param>
 /// <param name="args"></param>
 static void SetItemValue(Editroid.Actions.ItemProperty property, ItemUiSetterArgs args)
 {
     if (args.EnteredValue >= 0)
     {
         args.EditedProperty = property;
         args.AssignedValue  = args.EnteredValue;
     }
 }
Beispiel #2
0
        void OnUiButtonClick(object sender, EventArgs e)
        {
            if (!IsUpdating)
            {
                var  button   = ((ToolStripButton)sender);
                bool newState = !button.Checked;

                // Get the UI logic
                var elem = GetElementByRole(ControlLookup[button]);
                // Execute the "setter", which produces information necessary to create and execute an undo/redo event
                var args = new ItemUiSetterArgs(SelectedItem);
                args.EnteredValue = newState ? 1 : 0;
                elem.Setter(args);

                if (args.EditedProperty != Editroid.Actions.ItemProperty.invalid)
                {
                    CreateAndExecuteAction(args.EditedProperty, args.AssignedValue);
                }
            }
        }
Beispiel #3
0
        private void ProcessTextboxInput(ToolStripTextBox txt)
        {
            int  value;
            bool invalid = false;

            BeginUpdate();

            var elem = GetElementByRole(ControlLookup[txt]);

            if (int.TryParse(txt.Text, System.Globalization.NumberStyles.HexNumber, null, out value))
            {
                if (value >= elem.Minimum && value <= elem.Maximum)
                {
                    ItemUiSetterArgs args = new ItemUiSetterArgs(SelectedItem);
                    args.EnteredValue = value;
                    elem.Setter(args);
                    if (args.EditedProperty != ItemProperty.invalid)
                    {
                        CreateAndExecuteAction(args.EditedProperty, args.AssignedValue);
                    }
                }
                else
                {
                    invalid = true;
                }
            }
            else
            {
                invalid = true;
            }

            // If a nonsensical value is entered, re-display current value
            if (invalid)
            {
                PopulateUiElement(elem);
            }
            EndUpdate();
        }
Beispiel #4
0
        void OnUiSelectedIndexChanged(object sender, EventArgs e)
        {
            if (!IsUpdating)
            {
                var combo         = ((ToolStripComboBox)sender);
                int selectedValue = combo.SelectedIndex;

                // If the combobox has an associated list, the actual selected value is the list item whose index is specified by combo.SelectedIndex.
                ItemUiComboList list;
                if (ControlLists.TryGetValue(combo, out list))
                {
                    if (selectedValue >= 0 && selectedValue < list.Items.Count)
                    {
                        selectedValue = list.Items[selectedValue].Value;
                    }
                    else
                    {
                        selectedValue = -1;
                    }
                }

                // If selectedValue < 0, then either nothing is actually selected, or an "other" item was selected. In either case, we'll want to ignore the input.
                if (selectedValue >= 0)
                {
                    // Get the UI logic
                    var elem = GetElementByRole(ControlLookup[combo]);
                    // Execute the "setter", which produces information necessary to create and execute an undo/redo event
                    var args = new ItemUiSetterArgs(SelectedItem);
                    args.EnteredValue = selectedValue;
                    elem.Setter(args);

                    if (args.EditedProperty != Editroid.Actions.ItemProperty.invalid)
                    {
                        CreateAndExecuteAction(args.EditedProperty, args.AssignedValue);
                    }
                }
            }
        }
Beispiel #5
0
 /// <summary>
 /// Helper method. Applies the value change specified by 'args' to the item's sprite slot value if the value is >= 0.
 /// </summary>
 /// <param name="args"></param>
 static void SetItemSlot(ItemUiSetterArgs args)
 {
     SetItemValue(Editroid.Actions.ItemProperty.enemy_slot, args);
 }