Esempio n. 1
0
        /// <summary>
        /// Processes mouse events for combo editing.
        /// </summary>
        /// <param name="otherRow">Mouse event args for a mouse event.</param>
		private void ProcessMouse(MouseEventArgs e) {
            if (!new Rectangle(0, 0, Width, Height).Contains(e.X, e.Y))
                return;

			if(e.Button == MouseButtons.Left) {
				if(ModifierKeys == Keys.Control) { // Copy entire combo from tiles
					int Combo = e.X / 16 + (e.Y / 16) * 16;
                    CreateComboAutomatically(Combo);

                    canDrawWholeCombo = false; // See XML summary
                } else if(ModifierKeys == Keys.Shift) { // Copy single tile
                    int tileX = e.X / 8;
                    int tileY = (e.Y + _ScrollPos * 16) / 8;
                    int Combo = tileX / 2 + (tileY / 2) * 16;
                    int tile = tileX % 2 + 2 * (tileY % 2);

                    // Chain combo edits from a single mouse stroke into a single action
                    if (chainCombo == null)
                        chainCombo = Program.Actions.ModifyCombo(level, Combo, tile, _CurrentTile);
                    else {
                        chainCombo = chainCombo.CreateChainableAction(Combo, tile, _CurrentTile);
                    }

                    Program.PerformAction(chainCombo);

                    ////int ComboTileX = destTileX % 2;
                    ////int ComboTileY = destTileY % 2;

                    ////Combo ClickedCombo = _Combos[Combo];
                    ////ClickedCombo[ComboTileX + ComboTileY * 2] = _CurrentTile;

                    ////// Show changes
                    ////DrawCombo(otherRow.xTile / 16, otherRow.yTile / 16);
                    ////this.Invalidate(new Rectangle((otherRow.xTile / 16) * 16,
                    ////                            (otherRow.yTile / 16) * 16,
                    ////                            16, 16));
                    isDrawing = true;
                }

            } else if(e.Button == MouseButtons.Right) {
                // On right click, select the clicked combo for painting
                int tileX = e.X / 8;
                int tileY = (e.Y + _ScrollPos * 16) / 8;
                int Combo = tileX / 2 + (tileY / 2) * 16;
                int ComboTileX = tileX % 2;
                int ComboTileY = tileY % 2;

                Combo ClickedCombo = _Combos[Combo];
                _CurrentTile = ClickedCombo[ComboTileX + ComboTileY * 2];
                if(UserGrabbedCombo != null)
                    UserGrabbedCombo(this, null);
            }
		}
Esempio n. 2
0
        /// <summary>
        /// Assembles a combo from the selected tile and the three following it.
        /// </summary>
        /// <param name="Combo">Index of the combo to overwrite.</param>
        private void CreateComboAutomatically(int Combo) {
            Combo comboToEdit = _Combos[Combo];

            // Isolate this action from other combo actions
            BreakActionChain();

            // Note the side effect in the conditional statements below.
            // They cause each action to be chained off the previous action.
            ModifyCombo action = Program.Actions.ModifyCombo(level, Combo, 0, _CurrentTile);
            Program.PerformAction(action);
            comboToEdit[0] = (byte)_CurrentTile;
            if (_CurrentTile < 254)
                Program.PerformAction(action = action.CreateChainableAction(Combo, 1, _CurrentTile + 1));
            if (_CurrentTile < 253)
                Program.PerformAction(action = action.CreateChainableAction(Combo, 2, _CurrentTile + 2));
            if (_CurrentTile < 252)
                Program.PerformAction(action = action.CreateChainableAction(Combo, 3, _CurrentTile + 3));

            BreakActionChain();
        }
Esempio n. 3
0
 void BreakActionChain() {
     chainCombo = null;
 }