Exemplo n.º 1
0
        private void InsertButton_Click(object sender, EventArgs e)
        {
            int newelem = ElementNumber + 1;

            switch (EditorTabs.SelectedIndex)
            {
            case 0:
            {
                ListAddTransaction transaction = new ListAddTransaction("New robot", datafile, "ReplacedRobots", newelem, new Robot(), ElementNumber, 0);
                transactionManager.ApplyTransaction(transaction);
            }
            break;

            case 1:
            {
                ListAddTransaction transaction = new ListAddTransaction("New model", datafile, "ReplacedModels", newelem, new Polymodel(10), ElementNumber, 1);
                transactionManager.ApplyTransaction(transaction);
            }
            break;
            }

            ResetMaxes();
            ElementSpinner.Value = newelem;
        }
Exemplo n.º 2
0
        private void InsertElem_Click(object sender, EventArgs e)
        {
            HAMType type = typeTable[EditorTabs.SelectedIndex];

            /*int newID = datafile.AddElement(type);
             * if (newID != -1)
             * {
             *  //Update the maximum of the numeric up/down control and ensure that any comboboxes that need to be regenerated for the current element are
             *  ElementListInit();
             *  ElementSpinner.Value = newID;
             * }*/
            int         newNum      = 0;
            Transaction transaction = null;

            switch (type)
            {
            case HAMType.TMAPInfo:
                newNum      = datafile.Textures.Count;
                transaction = new AddTextureTransaction("Add Texture", datafile, "Textures", "TMapInfo", datafile.Textures.Count, 0, new TMAPInfo(), ElementNumber, PageNumber);
                break;

            case HAMType.VClip:
                newNum      = datafile.VClips.Count;
                transaction = new ListAddTransaction("Add VClip", datafile, "VClips", datafile.VClips.Count, new VClip(), ElementNumber, PageNumber);
                break;

            case HAMType.EClip:
                newNum      = datafile.EClips.Count;
                transaction = new ListAddTransaction("Add EClip", datafile, "EClips", datafile.EClips.Count, new EClip(), ElementNumber, PageNumber);
                break;

            case HAMType.WClip:
                newNum      = datafile.WClips.Count;
                transaction = new ListAddTransaction("Add WClip", datafile, "WClips", datafile.WClips.Count, new WClip(), ElementNumber, PageNumber);
                break;

            case HAMType.Robot:
                newNum      = datafile.Robots.Count;
                transaction = new ListAddTransaction("Add Robot", datafile, "Robots", datafile.Robots.Count, new Robot(), ElementNumber, PageNumber);
                break;

            case HAMType.Weapon:
                newNum      = datafile.Weapons.Count;
                transaction = new ListAddTransaction("Add Weapon", datafile, "Weapons", datafile.Weapons.Count, new Weapon(), ElementNumber, PageNumber);
                break;

            case HAMType.Model:
                newNum      = datafile.Models.Count;
                transaction = new ListAddTransaction("Add Polymodel", datafile, "Models", datafile.Models.Count, new Polymodel(10), ElementNumber, PageNumber);
                break;

            case HAMType.Powerup:
                newNum      = datafile.Powerups.Count;
                transaction = new ListAddTransaction("Add Powerup", datafile, "Powerups", datafile.Powerups.Count, new Powerup(), ElementNumber, PageNumber);
                break;

            case HAMType.Reactor:
                newNum      = datafile.Reactors.Count;
                transaction = new ListAddTransaction("Add Reactor", datafile, "Reactors", datafile.Reactors.Count, new Reactor(), ElementNumber, PageNumber);
                break;

            case HAMType.Cockpit:
                newNum      = datafile.Cockpits.Count;
                transaction = new ListAddTransaction("Add Cockpit bitmap", datafile, "Cockpits", datafile.Cockpits.Count, (ushort)0, ElementNumber, PageNumber);
                break;
            }

            if (transaction != null)
            {
                transactionManager.ApplyTransaction(transaction);
                ElementListInit(); //Ensure all local lists are updated, and update the spinner.
                ElementSpinner.Value = newNum;
            }
        }