예제 #1
0
        private void mnuSTActionNew_Click(object sender, EventArgs e)
        {
            ScriptType st = SelectedScriptType();

            if (st == null)
            {
                return;
            }
            ScriptAction sa  = new ScriptAction(actionTypes[0], 0);
            int          idx = olvSTActions.SelectedIndex;

            idx = idx == -1 ? st.Actions.Count : idx + 1;
            st.Insert(sa, idx);
            olvSTActions.SetObjects(st.Actions);
            olvSTActions.SelectedIndex = idx;
        }
예제 #2
0
        private void olvSTActions_CellEditFinishing(object sender, BrightIdeasSoftware.CellEditEventArgs e)
        {
            if (e.Cancel)
            {
                return;
            }

            ScriptAction action = e.RowObject as ScriptAction;

            // action
            if (e.SubItemIndex == 1)
            {
                ComboBox cmb = e.Control as ComboBox;
                e.NewValue = cmb.SelectedItem;
            }
            // parameter
            else if (e.SubItemIndex == 2)
            {
                if ((action.Action.ParamType == ScriptParamType.Number) || (action.Action.ParamType == ScriptParamType.NumPlusMinus))
                {
                    NumericUpDown nud = e.Control as NumericUpDown;
                    action.Param = (int)nud.Value;
                }
                else if (action.Action.ParamType == ScriptParamType.AIObject)
                {
                    //action.Param =
                }
                else
                {
                    ComboBox cmb = e.Control as ComboBox;
                    action.Param = (int)(cmb.SelectedItem as IParamListEntry).ParamListIndex;
                }

                e.Cancel = true;
                olvSTActions.RefreshItem(e.ListViewItem);
            }
            // offset
            else if (e.SubItemIndex == 3)
            {
                ComboBox cmb = e.Control as ComboBox;
                action.Offset = cmb.SelectedIndex;
                e.Cancel      = true;
                olvSTActions.RefreshItem(e.ListViewItem);
            }
        }
예제 #3
0
        private void mnuSTActionDelete_Click(object sender, EventArgs e)
        {
            ScriptType st = SelectedScriptType();

            if (st == null)
            {
                return;
            }
            ScriptAction sa  = olvSTActions.SelectedObject as ScriptAction;
            int          idx = olvSTActions.SelectedIndex;

            if (idx == -1)
            {
                return;
            }
            st.Remove(sa);
            olvSTActions.SetObjects(st.Actions);
            idx = Math.Min(idx, st.Count - 1);
            olvSTActions.SelectedIndex = idx;
        }
예제 #4
0
        private void olvSTActions_CellEditStarting(object sender, BrightIdeasSoftware.CellEditEventArgs e)
        {
            ScriptAction action = e.RowObject as ScriptAction;

            // action
            if (e.SubItemIndex == 1)
            {
                uint idx = action.Action.Code;

                ComboBox cmb = new ComboBox();
                cmb.FlatStyle     = FlatStyle.Flat;
                cmb.DropDownStyle = ComboBoxStyle.DropDownList;
                cmb.Sorted        = true;
                foreach (IActionType entry in actionTypes)
                {
                    cmb.Items.Add(entry);
                }
                cmb.SelectedItem = action.Action;
                cmb.Bounds       = e.CellBounds;
                e.Control        = cmb;
            }
            // parameter
            else if (e.SubItemIndex == 2)
            {
                if ((action.Action.ParamType == ScriptParamType.Number) || (action.Action.ParamType == ScriptParamType.NumPlusMinus))
                {
                    NumericUpDown nud = new NumericUpDown();
                    if (action.Action.ParamType == ScriptParamType.Number)
                    {
                        nud.Minimum = 0;
                    }
                    else
                    {
                        nud.Minimum = -999999;
                    }
                    nud.Value  = action.Param;
                    nud.Bounds = e.CellBounds;
                    e.Control  = nud;
                }
                else
                {
                    ComboBox cmb = new ComboBox();
                    cmb.FlatStyle     = FlatStyle.Flat;
                    cmb.DropDownStyle = ComboBoxStyle.DropDownList;
                    cmb.Sorted        = true;
                    foreach (object obj in action.Action.List)
                    {
                        cmb.Items.Add(obj);
                    }
                    cmb.SelectedItem = action.ParamEntry;
                    cmb.Bounds       = e.CellBounds;
                    e.Control        = cmb;
                }
            }
            // offset
            else if (e.SubItemIndex == 3)
            {
                if (action.Action.ParamType != ScriptParamType.TechnoType)
                {
                    e.Cancel = true;
                    return;
                }

                ComboBox cmb = new ComboBox();
                cmb.FlatStyle     = FlatStyle.Flat;
                cmb.DropDownStyle = ComboBoxStyle.DropDownList;
                foreach (string s in ScriptAction.OffsetDescriptions())
                {
                    cmb.Items.Add(s);
                }
                cmb.SelectedIndex = (int)action.Offset;
                cmb.Bounds        = e.CellBounds;
                e.Control         = cmb;
            }
        }
예제 #5
0
 public ScriptAction(ScriptAction other)
 {
     this.action = other.action;
     this.param  = other.param;
     this.offset = other.offset;
 }