Exemplo n.º 1
0
 public override void AfterSetEdControl()
 {
     this.oldData = UndoManager.Clone(EdControl.Level.Blocks);
 }
Exemplo n.º 2
0
        private void saveSettings()
        {
            if (updating)
            {
                return;
            }
            byte[][] newData = UndoManager.Clone(Level.Blocks);
            newData[0][0]  = (byte)startEntranceUpDown.Value;
            newData[0][1]  = (byte)midwayEntranceUpDown.Value;
            newData[0][4]  = (byte)((int)timeLimitUpDown.Value & 255);
            newData[0][5]  = (byte)((int)timeLimitUpDown.Value >> 8);
            newData[0][26] = (byte)((int)soundSetUpDown.Value & 255);

            byte settingsByte = 0x00;

            if (levelWrapCheckBox.Checked)
            {
                settingsByte |= 0x20;
            }
            if (forceMiniCheckBox.Checked)
            {
                settingsByte |= 0x01;
            }
            if (miniMarioPhysicsCheckBox.Checked)
            {
                settingsByte |= 0x02;
            }
            newData[0][2] = settingsByte;

            int oldTileset  = newData[0][0xC];
            int oldBottomBg = newData[0][6];

            newData[0][0xC] = (byte)tilesetComboBox.SelectedIndex; // ncg
            newData[3][4]   = (byte)tilesetComboBox.SelectedIndex; // ncl

            int FGIndex = bgTopLayerComboBox.SelectedIndex;

            if (FGIndex == bgTopLayerComboBox.Items.Count - 1)
            {
                FGIndex = 0xFFFF;
            }
            newData[0][0x12] = (byte)FGIndex;        // ncg
            newData[0][0x13] = (byte)(FGIndex >> 8); // ncg
            newData[4][4]    = (byte)FGIndex;        // ncl
            newData[4][5]    = (byte)(FGIndex >> 8); // ncg
            newData[4][2]    = (byte)FGIndex;        // nsc
            newData[4][3]    = (byte)(FGIndex >> 8); // ncg

            int BGIndex = bgBottomLayerComboBox.SelectedIndex;

            if (BGIndex == bgBottomLayerComboBox.Items.Count - 1)
            {
                BGIndex = 0xFFFF;
            }
            newData[0][6] = (byte)BGIndex;        // ncg
            newData[0][7] = (byte)(BGIndex >> 8); // ncg
            newData[2][4] = (byte)BGIndex;        // ncl
            newData[2][5] = (byte)(BGIndex >> 8); // ncg
            newData[2][2] = (byte)BGIndex;        // nsc
            newData[2][3] = (byte)(BGIndex >> 8); // ncg


            ComboBox[] checkthese = new ComboBox[] {
                set1ComboBox, set2ComboBox, set3ComboBox, set4ComboBox,
                set5ComboBox, set6ComboBox, set7ComboBox, set8ComboBox,
                set9ComboBox, set10ComboBox, set16ComboBox
            };

            int[] checkthese_idx = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 15 };

            for (int CheckIdx = 0; CheckIdx < checkthese.Length; CheckIdx++)
            {
                string Item        = (string)(checkthese[CheckIdx].Items[Math.Max(0, checkthese[CheckIdx].SelectedIndex)]);
                int    cpos        = Item.IndexOf(':');
                int    modifierval = int.Parse(Item.Substring(0, cpos));
                newData[13][checkthese_idx[CheckIdx]] = (byte)modifierval;
            }

            EdControl.UndoManager.Do(new ChangeLevelSettingsAction(newData));
            if (oldTileset != newData[0][0xC] || oldBottomBg != newData[0][6])
            {
                EdControl.editor.LevelConfigForm_ReloadTileset();
            }
            else
            {
                EdControl.Invalidate();
            }
        }
Exemplo n.º 3
0
 public override void Redo()
 {
     EdControl.Level.Blocks = UndoManager.Clone(newData);
     EdControl.Level.CalculateSpriteModifiers();
     EdControl.config.LoadSettings();
 }