コード例 #1
0
        public override void Initialize(MapPanel mapPanel, MapLayerFlag activeLayers, ToolStripStatusLabel toolStatusLabel, ToolTip mouseToolTip, IGamePlugin plugin, UndoRedoList <UndoRedoEventArgs> undoRedoList)
        {
            GenericTypeListBox.Types = plugin.Map.OverlayTypes.
                                       Where(t => t.IsPlaceable && ((t.Theaters == null) || t.Theaters.Contains(plugin.Map.Theater))).
                                       OrderBy(t => t.Name);

            Tool = new OverlaysTool(mapPanel, activeLayers, toolStatusLabel,
                                    GenericTypeListBox, GenericTypeMapPanel, plugin, undoRedoList);
        }
コード例 #2
0
 public override void Initialize(MapPanel mapPanel, MapLayerFlag activeLayers, ToolStripStatusLabel toolStatusLabel, ToolTip mouseToolTip, IGamePlugin plugin, UndoRedoList <UndoRedoEventArgs> undoRedoList)
 {
     ObjectTypeListBox.Types = plugin.Map.BuildingTypes
                               .Where(t => (t.Theaters == null) || t.Theaters.Contains(plugin.Map.Theater))
                               .OrderBy(t => t.IsFake)
                               .ThenBy(t => t.Name);
     Tool = new BuildingTool(mapPanel, activeLayers, toolStatusLabel, ObjectTypeListBox,
                             ObjectTypeMapPanel, ObjectProperties, plugin, undoRedoList);
 }
コード例 #3
0
        public ResourcesTool(MapPanel mapPanel, MapLayerFlag layers, ToolStripStatusLabel statusLbl, Label totalResourcesLbl, NumericUpDown brushSizeNud, CheckBox gemsCheckBox, IGamePlugin plugin, UndoRedoList <UndoRedoEventArgs> url)
            : base(mapPanel, layers, statusLbl, plugin, url)
        {
            this.totalResourcesLbl = totalResourcesLbl;
            this.brushSizeNud      = brushSizeNud;
            this.gemsCheckBox      = gemsCheckBox;

            this.brushSizeNud.ValueChanged += BrushSizeNud_ValueChanged;

            navigationWidget.MouseoverSize = new Size((int)brushSizeNud.Value, (int)brushSizeNud.Value);

            Update();
        }
コード例 #4
0
        public CellTriggersTool(MapPanel mapPanel, MapLayerFlag layers, ToolStripStatusLabel statusLbl, ComboBox triggerCombo, IGamePlugin plugin, UndoRedoList <UndoRedoEventArgs> url)
            : base(mapPanel, layers, statusLbl, plugin, url)
        {
            this.mapPanel.MouseDown            += MapPanel_MouseDown;
            this.mapPanel.MouseUp              += MapPanel_MouseUp;
            this.mapPanel.MouseMove            += MapPanel_MouseMove;
            (this.mapPanel as Control).KeyDown += WaypointsTool_KeyDown;
            (this.mapPanel as Control).KeyUp   += WaypointsTool_KeyUp;

            this.triggerCombo = triggerCombo;

            navigationWidget.MouseCellChanged += MouseoverWidget_MouseCellChanged;

            UpdateStatus();
        }
コード例 #5
0
        public ResourcesTool(MapPanel mapPanel, MapLayerFlag layers, ToolStripStatusLabel statusLbl, Label totalResourcesLbl, NumericUpDown brushSizeNud, CheckBox gemsCheckBox, IGamePlugin plugin, UndoRedoList <UndoRedoEventArgs> url)
            : base(mapPanel, layers, statusLbl, plugin, url)
        {
            this.mapPanel.MouseDown            += MapPanel_MouseDown;
            this.mapPanel.MouseUp              += MapPanel_MouseUp;
            (this.mapPanel as Control).KeyDown += ResourceTool_KeyDown;

            this.totalResourcesLbl = totalResourcesLbl;
            this.brushSizeNud      = brushSizeNud;
            this.gemsCheckBox      = gemsCheckBox;

            this.brushSizeNud.ValueChanged += BrushSizeNud_ValueChanged;

            navigationWidget.MouseCellChanged += MouseoverWidget_MouseCellChanged;
            navigationWidget.MouseoverSize     = new Size((int)brushSizeNud.Value, (int)brushSizeNud.Value);

            url.Undone += Url_UndoRedo;
            url.Redone += Url_UndoRedo;

            Update();

            UpdateStatus();
        }
コード例 #6
0
 public abstract void Initialize(MapPanel mapPanel, MapLayerFlag activeLayers, ToolStripStatusLabel toolStatusLabel, ToolTip mouseToolTip, IGamePlugin plugin, UndoRedoList <UndoRedoEventArgs> undoRedoList);
コード例 #7
0
 public override void Initialize(MapPanel mapPanel, MapLayerFlag activeLayers, ToolStripStatusLabel toolStatusLabel,
                                 ToolTip mouseToolTip, IGamePlugin plugin, UndoRedoList <UndoRedoEventArgs> undoRedoList)
 {
     GenericTypeListBox.Types = plugin.Map.SmudgeTypes.Where(t => (t.Flag & SmudgeTypeFlag.Bib) == SmudgeTypeFlag.None).OrderBy(t => t.Name);
     Tool = new SmudgeTool(mapPanel, activeLayers, toolStatusLabel, GenericTypeListBox, GenericTypeMapPanel, plugin, undoRedoList);
 }
コード例 #8
0
 public override void Initialize(MapPanel mapPanel, MapLayerFlag activeLayers, ToolStripStatusLabel toolStatusLabel, ToolTip mouseToolTip, IGamePlugin plugin, UndoRedoList <UndoRedoEventArgs> undoRedoList)
 {
     TerrainTypeComboBox.Types = plugin.Map.TerrainTypes.Where(t => t.Theaters.Contains(plugin.Map.Theater)).OrderBy(t => t.Name);
     Tool = new TerrainTool(mapPanel, activeLayers, toolStatusLabel, TerrainTypeComboBox,
                            TerrainTypeMapPanel, TerrainProperties, plugin, undoRedoList);
 }
コード例 #9
0
 public override void Initialize(MapPanel mapPanel, MapLayerFlag activeLayers, ToolStripStatusLabel toolStatusLabel, ToolTip mouseToolTip, IGamePlugin plugin, UndoRedoList <UndoRedoEventArgs> undoRedoList)
 {
     ObjectTypeListBox.Types = plugin.Map.UnitTypes.Where(t => !t.IsFixedWing).OrderBy(t => t.Name);
     Tool = new UnitTool(mapPanel, activeLayers, toolStatusLabel, ObjectTypeListBox,
                         ObjectTypeMapPanel, ObjectProperties, plugin, undoRedoList);
 }
コード例 #10
0
 public CellTriggersTool(MapPanel mapPanel, MapLayerFlag layers, ToolStripStatusLabel statusLbl, ComboBox triggerCombo, IGamePlugin plugin, UndoRedoList <UndoRedoEventArgs> url)
     : base(mapPanel, layers, statusLbl, plugin, url)
 {
     this.triggerCombo = triggerCombo;
 }
コード例 #11
0
 public override void Initialize(MapPanel mapPanel, MapLayerFlag activeLayers, ToolStripStatusLabel toolStatusLabel, ToolTip mouseToolTip, IGamePlugin plugin, UndoRedoList <UndoRedoEventArgs> undoRedoList)
 {
     TriggerCombo.DataSource = plugin.Map.Triggers.Select(t => t.Name).ToArray();
     Tool = new CellTriggersTool(mapPanel, activeLayers, toolStatusLabel, TriggerCombo, plugin, undoRedoList);
 }
コード例 #12
0
 public static void Render(GameType gameType, Map map, Graphics graphics, ISet <Point> locations, MapLayerFlag layers)
 {
     Render(gameType, map, graphics, locations, layers, Globals.TileScale);
 }
コード例 #13
0
        public static void Render(GameType gameType, Map map, Graphics graphics, ISet <Point> locations, MapLayerFlag layers, int tileScale)
        {
            var tileSize            = new Size(Globals.OriginalTileWidth / tileScale, Globals.OriginalTileHeight / tileScale);
            var tiberiumOrGoldTypes = map.OverlayTypes.Where(t => t.IsTiberiumOrGold).Select(t => t).ToArray();
            var gemTypes            = map.OverlayTypes.Where(t => t.IsGem).ToArray();

            var overlappingRenderList = new List <(Rectangle, Action <Graphics>)>();

            Func <IEnumerable <Point> > renderLocations = null;

            if (locations != null)
            {
                renderLocations = () => locations;
            }
            else
            {
                IEnumerable <Point> allCells()
                {
                    for (var y = 0; y < map.Metrics.Height; ++y)
                    {
                        for (var x = 0; x < map.Metrics.Width; ++x)
                        {
                            yield return(new Point(x, y));
                        }
                    }
                }

                renderLocations = allCells;
            }

            if ((layers & MapLayerFlag.Template) != MapLayerFlag.None)
            {
                foreach (var topLeft in renderLocations())
                {
                    map.Metrics.GetCell(topLeft, out int cell);

                    var template = map.Templates[topLeft];
                    var name     = template?.Type.Name ?? map.TemplateTypes.Where(t => t.Equals("clear1")).FirstOrDefault().Name;
                    var icon     = template?.Icon ?? ((cell & 0x03) | ((cell >> 4) & 0x0C));

                    if (Globals.TheTilesetManager.GetTileData(map.Theater.Tilesets, name, icon, out Tile tile))
                    {
                        var renderBounds = new Rectangle(topLeft.X * tileSize.Width, topLeft.Y * tileSize.Height, tileSize.Width, tileSize.Height);
                        graphics.DrawImage(tile.Image, renderBounds);
                    }
                    else
                    {
                        Debug.Print(string.Format("Template {0} ({1}) not found", name, icon));
                    }
                }
            }

            if ((layers & MapLayerFlag.Smudge) != MapLayerFlag.None)
            {
                foreach (var topLeft in renderLocations())
                {
                    var smudge = map.Smudge[topLeft];
                    if (smudge != null)
                    {
                        Render(map.Theater, topLeft, tileSize, smudge).Item2(graphics);
                    }
                }
            }

            if ((layers & MapLayerFlag.OverlayAll) != MapLayerFlag.None)
            {
                foreach (var topLeft in renderLocations())
                {
                    var overlay = map.Overlay[topLeft];
                    if (overlay == null)
                    {
                        continue;
                    }

                    if ((overlay.Type.IsResource && ((layers & MapLayerFlag.Resources) != MapLayerFlag.None)) ||
                        (overlay.Type.IsWall && ((layers & MapLayerFlag.Walls) != MapLayerFlag.None)) ||
                        ((layers & MapLayerFlag.Overlay) != MapLayerFlag.None))
                    {
                        Render(map.Theater, tiberiumOrGoldTypes, gemTypes, topLeft, tileSize, tileScale, overlay).Item2(graphics);
                    }
                }
            }

            if ((layers & MapLayerFlag.Terrain) != MapLayerFlag.None)
            {
                foreach (var(topLeft, terrain) in map.Technos.OfType <Terrain>())
                {
                    if ((locations != null) && !locations.Contains(topLeft))
                    {
                        continue;
                    }

                    string tileName = terrain.Type.Name;
                    if ((terrain.Type.TemplateType & TemplateTypeFlag.OreMine) != TemplateTypeFlag.None)
                    {
                        tileName = "OREMINE";
                    }

                    if (Globals.TheTilesetManager.GetTileData(map.Theater.Tilesets, tileName, terrain.Icon, out Tile tile))
                    {
                        var tint            = terrain.Tint;
                        var imageAttributes = new ImageAttributes();
                        if (tint != Color.White)
                        {
                            var colorMatrix = new ColorMatrix(new float[][]
                            {
                                new float[] { tint.R / 255.0f, 0, 0, 0, 0 },
                                new float[] { 0, tint.G / 255.0f, 0, 0, 0 },
                                new float[] { 0, 0, tint.B / 255.0f, 0, 0 },
                                new float[] { 0, 0, 0, tint.A / 255.0f, 0 },
                                new float[] { 0, 0, 0, 0, 1 },
                            }
                                                              );
                            imageAttributes.SetColorMatrix(colorMatrix);
                        }

                        var location      = new Point(topLeft.X * tileSize.Width, topLeft.Y * tileSize.Height);
                        var size          = new Size(tile.Image.Width / tileScale, tile.Image.Height / tileScale);
                        var terrainBounds = new Rectangle(location, size);
                        overlappingRenderList.Add((terrainBounds, g => g.DrawImage(tile.Image, terrainBounds, 0, 0, tile.Image.Width, tile.Image.Height, GraphicsUnit.Pixel, imageAttributes)));
                    }
                    else
                    {
                        Debug.Print(string.Format("Terrain {0} ({1}) not found", tileName, terrain.Icon));
                    }
                }
            }

            if ((layers & MapLayerFlag.Buildings) != MapLayerFlag.None)
            {
                foreach (var(topLeft, building) in map.Buildings.OfType <Building>())
                {
                    if ((locations != null) && !locations.Contains(topLeft))
                    {
                        continue;
                    }

                    overlappingRenderList.Add(Render(gameType, map.Theater, topLeft, tileSize, tileScale, building));
                }
            }

            if ((layers & MapLayerFlag.Infantry) != MapLayerFlag.None)
            {
                foreach (var(topLeft, infantryGroup) in map.Technos.OfType <InfantryGroup>())
                {
                    if ((locations != null) && !locations.Contains(topLeft))
                    {
                        continue;
                    }

                    for (int i = 0; i < infantryGroup.Infantry.Length; ++i)
                    {
                        var infantry = infantryGroup.Infantry[i];
                        if (infantry == null)
                        {
                            continue;
                        }

                        overlappingRenderList.Add(Render(map.Theater, topLeft, tileSize, infantry, (InfantryStoppingType)i));
                    }
                }
            }

            if ((layers & MapLayerFlag.Units) != MapLayerFlag.None)
            {
                foreach (var(topLeft, unit) in map.Technos.OfType <Unit>())
                {
                    if ((locations != null) && !locations.Contains(topLeft))
                    {
                        continue;
                    }

                    overlappingRenderList.Add(Render(gameType, map.Theater, topLeft, tileSize, unit));
                }
            }

            foreach (var(location, renderer) in overlappingRenderList.Where(x => !x.Item1.IsEmpty).OrderBy(x => x.Item1.Bottom))
            {
                renderer(graphics);
            }
        }
コード例 #14
0
 public override void Initialize(MapPanel mapPanel, MapLayerFlag activeLayers, ToolStripStatusLabel toolStatusLabel,
                                 ToolTip mouseToolTip, IGamePlugin plugin, UndoRedoList <UndoRedoEventArgs> undoRedoList)
 {
     Tool = new ResourcesTool(mapPanel, activeLayers, toolStatusLabel, TotalResourcesLbl,
                              ResourceBrushSizeNud, GemsCheckBox, plugin, undoRedoList);
 }
コード例 #15
0
 public override void Initialize(MapPanel mapPanel, MapLayerFlag activeLayers, ToolStripStatusLabel toolStatusLabel, ToolTip mouseToolTip, IGamePlugin plugin, UndoRedoList <UndoRedoEventArgs> undoRedoList)
 {
     GenericTypeListBox.Types = plugin.Map.OverlayTypes.Where(t => t.IsWall).OrderBy(t => t.Name);
     Tool = new WallsTool(mapPanel, activeLayers, toolStatusLabel,
                          GenericTypeListBox, GenericTypeMapPanel, plugin, undoRedoList);
 }
コード例 #16
0
 public override void Initialize(MapPanel mapPanel, MapLayerFlag activeLayers, ToolStripStatusLabel toolStatusLabel, ToolTip mouseToolTip, IGamePlugin plugin, UndoRedoList <UndoRedoEventArgs> undoRedoList)
 {
     WaypointCombo.DataSource = plugin.Map.Waypoints.Select(w => w.Name).ToArray();
     Tool = new WaypointsTool(mapPanel, activeLayers, toolStatusLabel, WaypointCombo, plugin, undoRedoList);
 }
コード例 #17
0
 public override void Initialize(MapPanel mapPanel, MapLayerFlag activeLayers,
                                 ToolStripStatusLabel toolStatusLabel, ToolTip mouseToolTip, IGamePlugin plugin, UndoRedoList <UndoRedoEventArgs> undoRedoList)
 {
     Tool = new TemplateTool(mapPanel, activeLayers, toolStatusLabel,
                             TemplateTypeListView, TemplateTypeMapPanel, mouseToolTip, plugin, undoRedoList);
 }