示例#1
0
 public void MouseDown(MouseEventArgs e)
 {
     modMath.sXY_int _int;
     this.Map.SuppressMinimap = true;
     _int.X = e.X;
     _int.Y = e.Y;
     if (e.Button == MouseButtons.Left)
     {
         this.MouseLeftDown = new clsMouseDown();
         if (this.IsViewPosOverMinimap(_int))
         {
             this.MouseLeftDown.OverMinimap = new clsMouseDown.clsOverMinimap();
             this.MouseLeftDown.OverMinimap.DownPos = _int;
             modMath.sXY_int tileNum = new modMath.sXY_int((int) Math.Round(Conversion.Int((double) (_int.X * this.Tiles_Per_Minimap_Pixel))), (int) Math.Round(Conversion.Int((double) (_int.Y * this.Tiles_Per_Minimap_Pixel))));
             this.Map.TileNumClampToMap(tileNum);
             this.LookAtTile(tileNum);
         }
         else
         {
             clsMouseOver.clsOverTerrain mouseOverTerrain = this.GetMouseOverTerrain();
             if (mouseOverTerrain != null)
             {
                 this.MouseLeftDown.OverTerrain = new clsMouseDown.clsOverTerrain();
                 this.MouseLeftDown.OverTerrain.DownPos = mouseOverTerrain.Pos;
                 if (modTools.Tool == modTools.Tools.ObjectSelect)
                 {
                     if (modControls.KeyboardProfile.Active(modControls.Control_Picker))
                     {
                         if (mouseOverTerrain.Units.Count > 0)
                         {
                             if (mouseOverTerrain.Units.Count == 1)
                             {
                                 modMain.frmMainInstance.ObjectPicker(mouseOverTerrain.Units[0].Type);
                             }
                             else
                             {
                                 this.MapView.ListSelectBegin(true);
                             }
                         }
                     }
                     else if (modControls.KeyboardProfile.Active(modControls.Control_ScriptPosition))
                     {
                         clsMap.clsScriptPosition position = clsMap.clsScriptPosition.Create(this.Map);
                         if (position != null)
                         {
                             position.PosX = this.MouseLeftDown.OverTerrain.DownPos.Horizontal.X;
                             position.PosY = this.MouseLeftDown.OverTerrain.DownPos.Horizontal.Y;
                             modMain.frmMainInstance.ScriptMarkerLists_Update();
                         }
                     }
                     else
                     {
                         if (!modControls.KeyboardProfile.Active(modControls.Control_Unit_Multiselect))
                         {
                             this.Map.SelectedUnits.Clear();
                         }
                         modMain.frmMainInstance.SelectedObject_Changed();
                         this.Map.Unit_Selected_Area_VertexA = new modMath.clsXY_int(mouseOverTerrain.Vertex.Normal);
                         this.MapView.DrawViewLater();
                     }
                 }
                 else if (modTools.Tool == modTools.Tools.TerrainBrush)
                 {
                     if (this.Map.Tileset != null)
                     {
                         if (modControls.KeyboardProfile.Active(modControls.Control_Picker))
                         {
                             modMain.frmMainInstance.TerrainPicker();
                         }
                         else
                         {
                             this.Apply_Terrain();
                             if (modMain.frmMainInstance.cbxAutoTexSetHeight.Checked)
                             {
                                 this.Apply_Height_Set(modProgram.TerrainBrush, modMain.frmMainInstance.HeightSetPalette[modMain.frmMainInstance.tabHeightSetL.SelectedIndex]);
                             }
                         }
                     }
                 }
                 else if (modTools.Tool == modTools.Tools.HeightSetBrush)
                 {
                     if (modControls.KeyboardProfile.Active(modControls.Control_Picker))
                     {
                         modMain.frmMainInstance.HeightPickerL();
                     }
                     else
                     {
                         this.Apply_Height_Set(modProgram.HeightBrush, modMain.frmMainInstance.HeightSetPalette[modMain.frmMainInstance.tabHeightSetL.SelectedIndex]);
                     }
                 }
                 else if (modTools.Tool == modTools.Tools.TextureBrush)
                 {
                     if (this.Map.Tileset != null)
                     {
                         if (modControls.KeyboardProfile.Active(modControls.Control_Picker))
                         {
                             modMain.frmMainInstance.TexturePicker();
                         }
                         else
                         {
                             this.Apply_Texture();
                         }
                     }
                 }
                 else if (modTools.Tool == modTools.Tools.CliffTriangle)
                 {
                     this.Apply_CliffTriangle(false);
                 }
                 else if (modTools.Tool == modTools.Tools.CliffBrush)
                 {
                     this.Apply_Cliff();
                 }
                 else if (modTools.Tool == modTools.Tools.CliffRemove)
                 {
                     this.Apply_Cliff_Remove();
                 }
                 else if (modTools.Tool == modTools.Tools.TerrainFill)
                 {
                     if (this.Map.Tileset != null)
                     {
                         if (modControls.KeyboardProfile.Active(modControls.Control_Picker))
                         {
                             modMain.frmMainInstance.TerrainPicker();
                         }
                         else
                         {
                             this.Apply_Terrain_Fill(modMain.frmMainInstance.FillCliffAction, modMain.frmMainInstance.cbxFillInside.Checked);
                             this.MapView.DrawViewLater();
                         }
                     }
                 }
                 else if (modTools.Tool == modTools.Tools.RoadPlace)
                 {
                     if (this.Map.Tileset != null)
                     {
                         this.Apply_Road();
                     }
                 }
                 else if (modTools.Tool == modTools.Tools.RoadLines)
                 {
                     if (this.Map.Tileset != null)
                     {
                         this.Apply_Road_Line_Selection();
                     }
                 }
                 else if (modTools.Tool == modTools.Tools.RoadRemove)
                 {
                     this.Apply_Road_Remove();
                 }
                 else if (modTools.Tool == modTools.Tools.ObjectPlace)
                 {
                     if ((modMain.frmMainInstance.SingleSelectedObjectType != null) & (this.Map.SelectedUnitGroup != null))
                     {
                         clsMap.clsUnitCreate objectCreator = new clsMap.clsUnitCreate();
                         this.Map.SetObjectCreatorDefaults(objectCreator);
                         objectCreator.Horizontal = mouseOverTerrain.Pos.Horizontal;
                         objectCreator.Perform();
                         this.Map.UndoStepCreate("Place Object");
                         this.Map.Update();
                         this.Map.MinimapMakeLater();
                         this.MapView.DrawViewLater();
                     }
                 }
                 else if (modTools.Tool == modTools.Tools.ObjectLines)
                 {
                     this.ApplyObjectLine();
                 }
                 else if (modTools.Tool == modTools.Tools.TerrainSelect)
                 {
                     if (this.Map.Selected_Area_VertexA == null)
                     {
                         this.Map.Selected_Area_VertexA = new modMath.clsXY_int(mouseOverTerrain.Vertex.Normal);
                         this.MapView.DrawViewLater();
                     }
                     else if (this.Map.Selected_Area_VertexB == null)
                     {
                         this.Map.Selected_Area_VertexB = new modMath.clsXY_int(mouseOverTerrain.Vertex.Normal);
                         this.MapView.DrawViewLater();
                     }
                     else
                     {
                         this.Map.Selected_Area_VertexA = null;
                         this.Map.Selected_Area_VertexB = null;
                         this.MapView.DrawViewLater();
                     }
                 }
                 else if (modTools.Tool == modTools.Tools.Gateways)
                 {
                     this.Apply_Gateway();
                 }
             }
             else if (modTools.Tool == modTools.Tools.ObjectSelect)
             {
                 this.Map.SelectedUnits.Clear();
                 modMain.frmMainInstance.SelectedObject_Changed();
             }
         }
     }
     else if (e.Button == MouseButtons.Right)
     {
         this.MouseRightDown = new clsMouseDown();
         if (this.IsViewPosOverMinimap(_int))
         {
             this.MouseRightDown.OverMinimap = new clsMouseDown.clsOverMinimap();
             this.MouseRightDown.OverMinimap.DownPos = _int;
         }
         else
         {
             clsMouseOver.clsOverTerrain terrain2 = this.GetMouseOverTerrain();
             if (terrain2 != null)
             {
                 this.MouseRightDown.OverTerrain = new clsMouseDown.clsOverTerrain();
                 this.MouseRightDown.OverTerrain.DownPos = terrain2.Pos;
             }
         }
         if ((modTools.Tool == modTools.Tools.RoadLines) | (modTools.Tool == modTools.Tools.ObjectLines))
         {
             this.Map.Selected_Tile_A = null;
             this.MapView.DrawViewLater();
         }
         else if (modTools.Tool == modTools.Tools.TerrainSelect)
         {
             this.Map.Selected_Area_VertexA = null;
             this.Map.Selected_Area_VertexB = null;
             this.MapView.DrawViewLater();
         }
         else if (modTools.Tool == modTools.Tools.CliffTriangle)
         {
             this.Apply_CliffTriangle(true);
         }
         else if (modTools.Tool == modTools.Tools.Gateways)
         {
             this.Map.Selected_Tile_A = null;
             this.Map.Selected_Tile_B = null;
             this.MapView.DrawViewLater();
         }
         else if (modTools.Tool == modTools.Tools.HeightSetBrush)
         {
             if (modControls.KeyboardProfile.Active(modControls.Control_Picker))
             {
                 modMain.frmMainInstance.HeightPickerR();
             }
             else
             {
                 this.Apply_Height_Set(modProgram.HeightBrush, modMain.frmMainInstance.HeightSetPalette[modMain.frmMainInstance.tabHeightSetR.SelectedIndex]);
             }
         }
     }
 }
示例#2
0
        public void ApplyObjectLine()
        {
            if ( Program.frmMainInstance.SingleSelectedObjectType != null && Map.SelectedUnitGroup != null )
            {
                clsMouseOver.clsOverTerrain MouseOverTerrian = GetMouseOverTerrain();

                if ( MouseOverTerrian == null )
                {
                    return;
                }

                int Num = 0;
                int A = 0;
                int B = 0;
                sXY_int Tile = MouseOverTerrian.Tile.Normal;

                if ( Map.Selected_Tile_A != null )
                {
                    if ( Tile.X == Map.Selected_Tile_A.X )
                    {
                        if ( Tile.Y <= Map.Selected_Tile_A.Y )
                        {
                            A = Tile.Y;
                            B = Map.Selected_Tile_A.Y;
                        }
                        else
                        {
                            A = Map.Selected_Tile_A.Y;
                            B = Tile.Y;
                        }
                        clsMap.clsUnitCreate objectCreator = new clsMap.clsUnitCreate();
                        Map.SetObjectCreatorDefaults(objectCreator);
                        for ( Num = A; Num <= B; Num++ )
                        {
                            objectCreator.Horizontal.X = (int)((Tile.X + 0.5D) * App.TerrainGridSpacing);
                            objectCreator.Horizontal.Y = (int)((Num + 0.5D) * App.TerrainGridSpacing);
                            objectCreator.Perform();
                        }

                        Map.UndoStepCreate("Object Line");
                        Map.Update();
                        Map.MinimapMakeLater();
                        Map.Selected_Tile_A = null;
                        MapViewControl.DrawViewLater();
                    }
                    else if ( Tile.Y == Map.Selected_Tile_A.Y )
                    {
                        if ( Tile.X <= Map.Selected_Tile_A.X )
                        {
                            A = Tile.X;
                            B = Map.Selected_Tile_A.X;
                        }
                        else
                        {
                            A = Map.Selected_Tile_A.X;
                            B = Tile.X;
                        }
                        clsMap.clsUnitCreate objectCreator = new clsMap.clsUnitCreate();
                        Map.SetObjectCreatorDefaults(objectCreator);
                        for ( Num = A; Num <= B; Num++ )
                        {
                            objectCreator.Horizontal.X = (int)((Num + 0.5D) * App.TerrainGridSpacing);
                            objectCreator.Horizontal.Y = (int)((Tile.Y + 0.5D) * App.TerrainGridSpacing);
                            objectCreator.Perform();
                        }

                        Map.UndoStepCreate("Object Line");
                        Map.Update();
                        Map.MinimapMakeLater();
                        Map.Selected_Tile_A = null;
                        MapViewControl.DrawViewLater();
                    }
                    else
                    {
                    }
                }
                else
                {
                    Map.Selected_Tile_A = new clsXY_int(Tile);
                }
            }
        }
示例#3
0
 public void ApplyObjectLine()
 {
     if ((modMain.frmMainInstance.SingleSelectedObjectType != null) & (this.Map.SelectedUnitGroup != null))
     {
         clsMouseOver.clsOverTerrain mouseOverTerrain = this.GetMouseOverTerrain();
         if (mouseOverTerrain != null)
         {
             modMath.sXY_int normal = mouseOverTerrain.Tile.Normal;
             if (this.Map.Selected_Tile_A != null)
             {
                 int y;
                 int x;
                 int num3;
                 if (normal.X == this.Map.Selected_Tile_A.X)
                 {
                     if (normal.Y <= this.Map.Selected_Tile_A.Y)
                     {
                         y = normal.Y;
                         x = this.Map.Selected_Tile_A.Y;
                     }
                     else
                     {
                         y = this.Map.Selected_Tile_A.Y;
                         x = normal.Y;
                     }
                     clsMap.clsUnitCreate objectCreator = new clsMap.clsUnitCreate();
                     this.Map.SetObjectCreatorDefaults(objectCreator);
                     int num4 = x;
                     for (num3 = y; num3 <= num4; num3++)
                     {
                         objectCreator.Horizontal.X = (int) Math.Round((double) ((normal.X + 0.5) * 128.0));
                         objectCreator.Horizontal.Y = (int) Math.Round((double) ((num3 + 0.5) * 128.0));
                         objectCreator.Perform();
                     }
                     this.Map.UndoStepCreate("Object Line");
                     this.Map.Update();
                     this.Map.MinimapMakeLater();
                     this.Map.Selected_Tile_A = null;
                     this.MapView.DrawViewLater();
                 }
                 else if (normal.Y == this.Map.Selected_Tile_A.Y)
                 {
                     if (normal.X <= this.Map.Selected_Tile_A.X)
                     {
                         y = normal.X;
                         x = this.Map.Selected_Tile_A.X;
                     }
                     else
                     {
                         y = this.Map.Selected_Tile_A.X;
                         x = normal.X;
                     }
                     clsMap.clsUnitCreate create2 = new clsMap.clsUnitCreate();
                     this.Map.SetObjectCreatorDefaults(create2);
                     int num5 = x;
                     for (num3 = y; num3 <= num5; num3++)
                     {
                         create2.Horizontal.X = (int) Math.Round((double) ((num3 + 0.5) * 128.0));
                         create2.Horizontal.Y = (int) Math.Round((double) ((normal.Y + 0.5) * 128.0));
                         create2.Perform();
                     }
                     this.Map.UndoStepCreate("Object Line");
                     this.Map.Update();
                     this.Map.MinimapMakeLater();
                     this.Map.Selected_Tile_A = null;
                     this.MapView.DrawViewLater();
                 }
             }
             else
             {
                 this.Map.Selected_Tile_A = new modMath.clsXY_int(normal);
             }
         }
     }
 }
示例#4
0
        public void MouseDown(MouseEventArgs e)
        {
            sXY_int ScreenPos = new sXY_int();

            Map.SuppressMinimap = true;

            ScreenPos.X = e.X;
            ScreenPos.Y = e.Y;
            if ( e.Button == MouseButtons.Left )
            {
                MouseLeftDown = new clsMouseDown();
                if ( IsViewPosOverMinimap(ScreenPos) )
                {
                    MouseLeftDown.OverMinimap = new clsMouseDown.clsOverMinimap();
                    MouseLeftDown.OverMinimap.DownPos = ScreenPos;
                    sXY_int Pos = new sXY_int((int)(Conversion.Int(ScreenPos.X * Tiles_Per_Minimap_Pixel)),
                        (int)Conversion.Int(ScreenPos.Y * Tiles_Per_Minimap_Pixel));
                    Map.TileNumClampToMap(Pos);
                    LookAtTile(Pos);
                }
                else
                {
                    clsMouseOver.clsOverTerrain MouseOverTerrain = GetMouseOverTerrain();
                    if ( MouseOverTerrain != null )
                    {
                        MouseLeftDown.OverTerrain = new clsMouseDown.clsOverTerrain();
                        MouseLeftDown.OverTerrain.DownPos = MouseOverTerrain.Pos;
                        if ( modTools.Tool == modTools.Tools.ObjectSelect )
                        {
                            if ( KeyboardManager.KeyboardProfile.Active(KeyboardManager.Picker) )
                            {
                                if ( MouseOverTerrain.Units.Count > 0 )
                                {
                                    if ( MouseOverTerrain.Units.Count == 1 )
                                    {
                                        Program.frmMainInstance.ObjectPicker(MouseOverTerrain.Units[0].Type);
                                    }
                                    else
                                    {
                                        MapViewControl.ListSelectBegin(true);
                                    }
                                }
                            }
                            else if ( KeyboardManager.KeyboardProfile.Active(KeyboardManager.ScriptPosition) )
                            {
                                clsMap.clsScriptPosition NewPosition = clsMap.clsScriptPosition.Create(Map);
                                if ( NewPosition != null )
                                {
                                    NewPosition.PosX = MouseLeftDown.OverTerrain.DownPos.Horizontal.X;
                                    NewPosition.PosY = MouseLeftDown.OverTerrain.DownPos.Horizontal.Y;
                                    Program.frmMainInstance.ScriptMarkerLists_Update();
                                }
                            }
                            else
                            {
                                if ( !KeyboardManager.KeyboardProfile.Active(KeyboardManager.UnitMultiselect) )
                                {
                                    Map.SelectedUnits.Clear();
                                }
                                Program.frmMainInstance.SelectedObject_Changed();
                                Map.Unit_Selected_Area_VertexA = new clsXY_int(MouseOverTerrain.Vertex.Normal);
                                MapViewControl.DrawViewLater();
                            }
                        }
                        else if ( modTools.Tool == modTools.Tools.TerrainBrush )
                        {
                            if ( Map.Tileset != null )
                            {
                                if ( KeyboardManager.KeyboardProfile.Active(KeyboardManager.Picker) )
                                {
                                    Program.frmMainInstance.TerrainPicker();
                                }
                                else
                                {
                                    Apply_Terrain();
                                    if ( Program.frmMainInstance.cbxAutoTexSetHeight.Checked )
                                    {
                                        Apply_Height_Set(App.TerrainBrush,
                                            Program.frmMainInstance.HeightSetPalette[Program.frmMainInstance.tabHeightSetL.SelectedIndex]);
                                    }
                                }
                            }
                        }
                        else if ( modTools.Tool == modTools.Tools.HeightSetBrush )
                        {
                            if ( KeyboardManager.KeyboardProfile.Active(KeyboardManager.Picker) )
                            {
                                Program.frmMainInstance.HeightPickerL();
                            }
                            else
                            {
                                Apply_Height_Set(App.HeightBrush, Program.frmMainInstance.HeightSetPalette[Program.frmMainInstance.tabHeightSetL.SelectedIndex]);
                            }
                        }
                        else if ( modTools.Tool == modTools.Tools.TextureBrush )
                        {
                            if ( Map.Tileset != null )
                            {
                                if ( KeyboardManager.KeyboardProfile.Active(KeyboardManager.Picker) )
                                {
                                    Program.frmMainInstance.TexturePicker();
                                }
                                else
                                {
                                    Apply_Texture();
                                }
                            }
                        }
                        else if ( modTools.Tool == modTools.Tools.CliffTriangle )
                        {
                            Apply_CliffTriangle(false);
                        }
                        else if ( modTools.Tool == modTools.Tools.CliffBrush )
                        {
                            Apply_Cliff();
                        }
                        else if ( modTools.Tool == modTools.Tools.CliffRemove )
                        {
                            Apply_Cliff_Remove();
                        }
                        else if ( modTools.Tool == modTools.Tools.TerrainFill )
                        {
                            if ( Map.Tileset != null )
                            {
                                if ( KeyboardManager.KeyboardProfile.Active(KeyboardManager.Picker) )
                                {
                                    Program.frmMainInstance.TerrainPicker();
                                }
                                else
                                {
                                    Apply_Terrain_Fill(Program.frmMainInstance.FillCliffAction, Program.frmMainInstance.cbxFillInside.Checked);
                                    MapViewControl.DrawViewLater();
                                }
                            }
                        }
                        else if ( modTools.Tool == modTools.Tools.RoadPlace )
                        {
                            if ( Map.Tileset != null )
                            {
                                Apply_Road();
                            }
                        }
                        else if ( modTools.Tool == modTools.Tools.RoadLines )
                        {
                            if ( Map.Tileset != null )
                            {
                                Apply_Road_Line_Selection();
                            }
                        }
                        else if ( modTools.Tool == modTools.Tools.RoadRemove )
                        {
                            Apply_Road_Remove();
                        }
                        else if ( modTools.Tool == modTools.Tools.ObjectPlace )
                        {
                            if ( Program.frmMainInstance.SingleSelectedObjectType != null && Map.SelectedUnitGroup != null )
                            {
                                clsMap.clsUnitCreate objectCreator = new clsMap.clsUnitCreate();
                                Map.SetObjectCreatorDefaults(objectCreator);
                                objectCreator.Horizontal = MouseOverTerrain.Pos.Horizontal;
                                objectCreator.Perform();
                                Map.UndoStepCreate("Place Object");
                                Map.Update();
                                Map.MinimapMakeLater();
                                MapViewControl.DrawViewLater();
                            }
                        }
                        else if ( modTools.Tool == modTools.Tools.ObjectLines )
                        {
                            ApplyObjectLine();
                        }
                        else if ( modTools.Tool == modTools.Tools.TerrainSelect )
                        {
                            if ( Map.Selected_Area_VertexA == null )
                            {
                                Map.Selected_Area_VertexA = new clsXY_int(MouseOverTerrain.Vertex.Normal);
                                MapViewControl.DrawViewLater();
                            }
                            else if ( Map.Selected_Area_VertexB == null )
                            {
                                Map.Selected_Area_VertexB = new clsXY_int(MouseOverTerrain.Vertex.Normal);
                                MapViewControl.DrawViewLater();
                            }
                            else
                            {
                                Map.Selected_Area_VertexA = null;
                                Map.Selected_Area_VertexB = null;
                                MapViewControl.DrawViewLater();
                            }
                        }
                        else if ( modTools.Tool == modTools.Tools.Gateways )
                        {
                            Apply_Gateway();
                        }
                    }
                    else if ( modTools.Tool == modTools.Tools.ObjectSelect )
                    {
                        Map.SelectedUnits.Clear();
                        Program.frmMainInstance.SelectedObject_Changed();
                    }
                }
            }
            else if ( e.Button == MouseButtons.Right )
            {
                MouseRightDown = new clsMouseDown();
                if ( IsViewPosOverMinimap(ScreenPos) )
                {
                    MouseRightDown.OverMinimap = new clsMouseDown.clsOverMinimap();
                    MouseRightDown.OverMinimap.DownPos = ScreenPos;
                }
                else
                {
                    clsMouseOver.clsOverTerrain MouseOverTerrain = GetMouseOverTerrain();
                    if ( MouseOverTerrain != null )
                    {
                        MouseRightDown.OverTerrain = new clsMouseDown.clsOverTerrain();
                        MouseRightDown.OverTerrain.DownPos = MouseOverTerrain.Pos;
                    }
                }
                if ( modTools.Tool == modTools.Tools.RoadLines || modTools.Tool == modTools.Tools.ObjectLines )
                {
                    Map.Selected_Tile_A = null;
                    MapViewControl.DrawViewLater();
                }
                else if ( modTools.Tool == modTools.Tools.TerrainSelect )
                {
                    Map.Selected_Area_VertexA = null;
                    Map.Selected_Area_VertexB = null;
                    MapViewControl.DrawViewLater();
                }
                else if ( modTools.Tool == modTools.Tools.CliffTriangle )
                {
                    Apply_CliffTriangle(true);
                }
                else if ( modTools.Tool == modTools.Tools.Gateways )
                {
                    Map.Selected_Tile_A = null;
                    Map.Selected_Tile_B = null;
                    MapViewControl.DrawViewLater();
                }
                else if ( modTools.Tool == modTools.Tools.HeightSetBrush )
                {
                    if ( KeyboardManager.KeyboardProfile.Active(KeyboardManager.Picker) )
                    {
                        Program.frmMainInstance.HeightPickerR();
                    }
                    else
                    {
                        Apply_Height_Set(App.HeightBrush, Program.frmMainInstance.HeightSetPalette[Program.frmMainInstance.tabHeightSetR.SelectedIndex]);
                    }
                }
            }
        }