示例#1
0
        private void listLoop_DoubleClick(object sender, EventArgs e)
        {
            int index = (int)treeView1.SelectedNode.Tag;
            if (listLoop.Items.Count > 0)
            {
                if (listLoop.Items.Count == 0 || listLoop.SelectedIndex < 0 || listLoop.SelectedItem == null)
                    return;
                txtval.Visible = true;
                listPresets.Items.Clear();

                switch (modlist[index].loopval[listLoop.SelectedIndex].scrID)
                {
                    case ScriptType.ScriptID.INT:
                        {
                            txtval.Text = modlist[index].loopval[listLoop.SelectedIndex].intval.ToString();
                        } break;
                    case ScriptType.ScriptID.SHORT:
                        {
                            txtval.Text = modlist[index].loopval[listLoop.SelectedIndex].shortval.ToString();
                        } break;
                    case ScriptType.ScriptID.BYTE:
                        {
                            txtval.Text = modlist[index].loopval[listLoop.SelectedIndex].byteval.ToString();
                        } break;
                    case ScriptType.ScriptID.BOOL:
                        {
                            txtval.Text = modlist[index].loopval[listLoop.SelectedIndex].boolval.ToString();
                        } break;
                    case ScriptType.ScriptID.SPELL:
                        {
                            foreach (ThingDb.Spell spell in ThingDb.Spells.Values)
                            {
                                listPresets.Items.Add(spell.Name);
                            }

                            txtval.Text = System.Text.ASCIIEncoding.ASCII.GetString(modlist[index].loopval[listLoop.SelectedIndex].val);
                        } break;
                    case ScriptType.ScriptID.ENCHANTMENT:
                        {
                            listPresets.Items.AddRange(objEnchants.ToArray());
                            txtval.Text = System.Text.ASCIIEncoding.ASCII.GetString(modlist[index].loopval[listLoop.SelectedIndex].val);
                        } break;
                    case ScriptType.ScriptID.OBJECT:
                        {
                            ObjectEditorDialog enchantDlg = new ObjectEditorDialog();
              
                            enchantDlg.Object = modlist[index].loopval[listLoop.SelectedIndex];
                            if (enchantDlg.ShowDialog() == DialogResult.OK)
                            {
                                listLoop.Items[listLoop.SelectedIndex] = System.Text.ASCIIEncoding.ASCII.GetString(enchantDlg.Object.val);
                            }
                        } break;
                    case ScriptType.ScriptID.ABILITY:
                        {
                            foreach (ThingDb.Ability ability in ThingDb.Abilities.Values)
                            {
                                listPresets.Items.Add(ability.Name);
                            }
                            txtval.Text = System.Text.ASCIIEncoding.ASCII.GetString(modlist[index].loopval[listLoop.SelectedIndex].val);
                        } break;
                    case ScriptType.ScriptID.PROP:
                    case ScriptType.ScriptID.STRING:
                        {
                            txtval.Text = System.Text.ASCIIEncoding.ASCII.GetString(modlist[index].loopval[listLoop.SelectedIndex].val);
                        } break;
                    case ScriptType.ScriptID.VOID:
                        {
                            MessageBox.Show("You cannot edit void values in the edit dialog yet.");
                        } break;
                    case ScriptType.ScriptID.COLOR:
                        {
                            txtval.Visible = false;
                            ColorDialog ColorDialog1 = new ColorDialog();
                            ColorDialog1.AllowFullOpen = true;
                            ColorDialog1.FullOpen = true;
                            ColorDialog1.ShowHelp = true;
                            ColorDialog1.Color = modlist[index].loopval[listLoop.SelectedIndex].col;
                            ColorDialog1.ShowDialog();
                            modlist[index].loopval[listLoop.SelectedIndex].col = ColorDialog1.Color;

                        } break;
                    case ScriptType.ScriptID.HIDDEN: break;
                    default: txtval.Text = "ERROR, NO VALUE"; break;
                }
            }
        }
示例#2
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {

            if (treeView1.SelectedNode.Parent == null || treeView1.SelectedNode.Parent.Name != "ROOT")
                return;
            if (treeView1.Nodes.Count == 0 || treeView1.SelectedNode == null)
                return;
            txtval.Visible = true;
            listPresets.Items.Clear();
            listLoop.Items.Clear();
            button1.Enabled = false;
            button2.Enabled = false;

            int index = (int)treeView1.SelectedNode.Tag;
            if (modlist.Count > 0 && modlist.Count >= index)
            {
                switch (modlist[index].scrID)
                {
                    case ScriptType.ScriptID.INT:
                        {
                            txtval.Text = modlist[index].intval.ToString();
                        } break;
                    case ScriptType.ScriptID.SHORT:
                        {
                            txtval.Text = modlist[index].shortval.ToString();
                        } break;
                    case ScriptType.ScriptID.BYTE:
                        {
                            txtval.Text = modlist[index].byteval.ToString();
                        } break;
                    case ScriptType.ScriptID.BOOL:
                        {
                            txtval.Text = modlist[index].boolval.ToString();
                        } break;
                    case ScriptType.ScriptID.DIRECTION:
                        {
                            listPresets.Items.Add(ScriptType.Direction.East);
                            listPresets.Items.Add(ScriptType.Direction.North);
                            listPresets.Items.Add(ScriptType.Direction.NorthEast);
                            listPresets.Items.Add(ScriptType.Direction.NorthWest);
                            listPresets.Items.Add(ScriptType.Direction.South);
                            listPresets.Items.Add(ScriptType.Direction.SouthEast);
                            listPresets.Items.Add(ScriptType.Direction.SouthWest);
                            listPresets.Items.Add(ScriptType.Direction.West);
                            try
                            {
                                listPresets.SelectedIndex = listPresets.Items.IndexOf(modlist[index].dirval);
                            }
                            catch
                            {
                                MessageBox.Show("INVALID DIRECTION SPECIFIED IN MODBOX!!!");
                            }
                            //txtval.Text = System.Text.ASCIIEncoding.ASCII.GetString(modlist[listMod.SelectedIndex].val);
                        } break;
                    case ScriptType.ScriptID.SPELL:
                        {
                            foreach (ThingDb.Spell spell in ThingDb.Spells.Values)
                            {
                                listPresets.Items.Add(spell.Name);
                            }

                            txtval.Text = System.Text.ASCIIEncoding.ASCII.GetString(modlist[index].val);
                        } break;
                    case ScriptType.ScriptID.ENCHANTMENT:
                        {
                            listPresets.Items.AddRange(objEnchants.ToArray());
                            txtval.Text = System.Text.ASCIIEncoding.ASCII.GetString(modlist[index].val);
                        } break;
                    case ScriptType.ScriptID.OBJECT:
                        {
                            ObjectEditorDialog enchantDlg = new ObjectEditorDialog();
                            enchantDlg.Object = modlist[index];
                            if (enchantDlg.ShowDialog() == DialogResult.OK)
                            {
                            }
                        } break;
                    case ScriptType.ScriptID.ABILITY:
                        {
                            foreach (ThingDb.Ability ability in ThingDb.Abilities.Values)
                            {
                                listPresets.Items.Add(ability.Name);
                            }
                            txtval.Text = System.Text.ASCIIEncoding.ASCII.GetString(modlist[index].val);
                        } break;
                    case ScriptType.ScriptID.PROP:
                    case ScriptType.ScriptID.STRING:
                        {
                            txtval.Text = System.Text.ASCIIEncoding.ASCII.GetString(modlist[index].val);
                        } break;
                    case ScriptType.ScriptID.LOOP:
                        {
                            button1.Enabled = true;
                            button2.Enabled = true;
                            for (int i = 0; i < modlist[index].loopval.Count; i++)
                            {
                                if (modlist[index].loopval[i].scrID == ScriptType.ScriptID.OBJECT)
                                    listLoop.Items.Add(System.Text.ASCIIEncoding.ASCII.GetString(modlist[index].loopval[i].val));
                                else
                                    listLoop.Items.Add(modlist[index].loopval[i].scrID);
                            }

                        } break;
                    case ScriptType.ScriptID.VOID:
                        {
                            MessageBox.Show("You cannot edit void values in the edit dialog yet.");
                        } break;
                    case ScriptType.ScriptID.COLOR:
                        {
                            txtval.Visible = false;
                            ColorDialog ColorDialog1 = new ColorDialog();
                            ColorDialog1.AllowFullOpen = true;
                            ColorDialog1.FullOpen = true;
                            ColorDialog1.ShowHelp = true;
                            ColorDialog1.Color = modlist[index].col;
                            ColorDialog1.ShowDialog();
                            modlist[index].col = ColorDialog1.Color;

                        } break;
                    case ScriptType.ScriptID.HIDDEN: break;
                    default: txtval.Text = "ERROR, NO VALUE"; break;
                }

            }
            else
                txtval.Text = "ERROR, BAD MOD / BAD TEMPLATE";
        }