예제 #1
0
		protected GameCollection(CollectionType type, TheaterType theater, EngineType engine, IniFile rules, IniFile art) {
			Engine = engine;
			Theater = theater;
			Type = type;
			Rules = rules;
			Art = art;
		}
예제 #2
0
 public Theater(TheaterType theaterType, EngineType engine, IniFile rules, IniFile art)
 {
     _theaterType = theaterType;
     _engine = engine;
     _rules = rules;
     _art = art;
 }
예제 #3
0
        public Theater(TheaterType theaterType, EngineType engine, VirtualFileSystem vfs)
        {
            _theaterType = theaterType;
            _vfs         = vfs;
            if (engine == EngineType.RedAlert2 || engine == EngineType.TiberianSun)
            {
                _rules = _vfs.Open <IniFile>("rules.ini");
                _art   = _vfs.Open <IniFile>("art.ini");
            }
            else if (engine == EngineType.YurisRevenge)
            {
                _rules = _vfs.Open <IniFile>("rulesmd.ini");
                _art   = _vfs.Open <IniFile>("artmd.ini");
            }
            else if (engine == EngineType.Firestorm)
            {
                _rules = _vfs.Open <IniFile>("rules.ini");
                var fsRules = _vfs.Open <IniFile>("firestrm.ini");
                Logger.Info("Merging Firestorm rules with TS rules");
                _rules.MergeWith(fsRules);
                _art = _vfs.Open <IniFile>("artmd.ini");
            }

            _rules.LoadAresIncludes(_vfs);
        }
예제 #4
0
 public Theater(TheaterType theaterType, EngineType engine, IniFile rules, IniFile art)
 {
     _theaterType = theaterType;
     _engine      = engine;
     _rules       = rules;
     _art         = art;
 }
예제 #5
0
 protected GameCollection(CollectionType type, TheaterType theater, EngineType engine, IniFile rules, IniFile art)
 {
     Engine  = engine;
     Theater = theater;
     Type    = type;
     Rules   = rules;
     Art     = art;
 }
예제 #6
0
 protected GameCollection(CollectionType type, TheaterType theater, ModConfig config, VirtualFileSystem vfs, IniFile rules, IniFile art)
 {
     _config = config;
     _vfs    = vfs;
     Theater = theater;
     Type    = type;
     Rules   = rules;
     Art     = art;
 }
예제 #7
0
        public Theater(TheaterType theaterType, ModConfig config, VirtualFileSystem vfs, IniFile rules, IniFile art)
        {
            _theaterType = theaterType;
            _config      = config;
            _vfs         = vfs;
            _rules       = rules;
            _art         = art;

            _rules.LoadAresIncludes(vfs);
        }
예제 #8
0
        public static (Rectangle, Action <Graphics>) Render(TheaterType theater, OverlayType[] tiberiumOrGoldTypes, OverlayType[] gemTypes, Point topLeft, Size tileSize, int tileScale, Overlay overlay)
        {
            var name = overlay.Type.Name;

            if (overlay.Type.IsGem)
            {
                name = gemTypes[new Random(randomSeed ^ topLeft.GetHashCode()).Next(tiberiumOrGoldTypes.Length)].Name;
            }
            else if (overlay.Type.IsTiberiumOrGold)
            {
                name = tiberiumOrGoldTypes[new Random(randomSeed ^ topLeft.GetHashCode()).Next(tiberiumOrGoldTypes.Length)].Name;
            }

            if (Globals.TheTilesetManager.GetTileData(theater.Tilesets, name, overlay.Icon, out Tile tile))
            {
                var size     = (overlay.Type.IsCrate || overlay.Type.IsFlag) ? new Size(tile.Image.Width / tileScale, tile.Image.Height / tileScale) : tileSize;
                var location = new Point(topLeft.X * tileSize.Width, topLeft.Y * tileSize.Height)
                               + new Size(tileSize.Width / 2, tileSize.Height / 2)
                               - new Size(size.Width / 2, size.Height / 2);
                var overlayBounds = new Rectangle(location, size);

                var tint = overlay.Tint;
                void render(Graphics g)
                {
                    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);
                    }

                    g.DrawImage(tile.Image, overlayBounds, 0, 0, tile.Image.Width, tile.Image.Height, GraphicsUnit.Pixel, imageAttributes);
                }

                return(overlayBounds, render);
            }
            else
            {
                Debug.Print(string.Format("Overlay {0} ({1}) not found", overlay.Type.Name, overlay.Icon));
                return(Rectangle.Empty, (g) => { });
            }
        }
예제 #9
0
		public ObjectCollection(CollectionType type, TheaterType theater, EngineType engine, IniFile rules, IniFile art,
			IniFile.IniSection objectsList, PaletteCollection palettes)
			: base(type, theater, engine, rules, art) {

			Palettes = palettes;
			if (engine >= EngineType.RedAlert2) {
				string fireNames = Rules.ReadString(Engine == EngineType.RedAlert2 ? "AudioVisual" : "General",
					"DamageFireTypes", "FIRE01,FIRE02,FIRE03");
				FireNames = fireNames.Split(new[] { ',', '.' }, StringSplitOptions.RemoveEmptyEntries);
			}

			foreach (var entry in objectsList.OrderedEntries) {
				if (!string.IsNullOrEmpty(entry.Value)) {
					Logger.Trace("Loading object {0}.{1}", objectsList.Name, entry.Value);
					AddObject(entry.Value);
				}
			}
		}
        public static List <TheaterType> getAlltTheater()
        {
            List <TheaterType> list = new List <TheaterType>();
            string             sql  = "SELECT * FROM dbo.LoaiRap";
            DataTable          a    = DataAccess.ReadDataBySQL(sql);

            foreach (DataRow dr in a.Rows)
            {
                TheaterType r = new TheaterType();
                r.ID          = Convert.ToInt32(dr["id"].ToString());
                r.Name        = dr["name"].ToString();
                r.Description = dr["Description"].ToString();
                r.ImageTitle  = dr["imageTitle"].ToString();
                r.ImageView   = dr["imageView"].ToString();
                list.Add(r);
            }
            return(list);
        }
예제 #11
0
		public Theater(TheaterType theaterType, EngineType engine) {
			_theaterType = theaterType;
			_engine = engine;
			if (engine == EngineType.RedAlert2 || engine == EngineType.TiberianSun) {
				_rules = VFS.Open<IniFile>("rules.ini");
				_art = VFS.Open<IniFile>("art.ini");
			}
			else if (engine == EngineType.YurisRevenge) {
				_rules = VFS.Open<IniFile>("rulesmd.ini");
				_art = VFS.Open<IniFile>("artmd.ini");
			}
			else if (engine == EngineType.Firestorm) {
				_rules = VFS.Open<IniFile>("rules.ini");
				var fsRules = VFS.Open<IniFile>("firestrm.ini");
				Logger.Info("Merging Firestorm rules with TS rules");
				_rules.MergeWith(fsRules);
				_art = VFS.Open<IniFile>("artmd.ini");
			}
		}
예제 #12
0
        public ObjectCollection(CollectionType type, TheaterType theater, EngineType engine, IniFile rules, IniFile art,
                                IniFile.IniSection objectsList, PaletteCollection palettes)
            : base(type, theater, engine, rules, art)
        {
            Palettes = palettes;
            if (engine >= EngineType.RedAlert2)
            {
                string fireNames = Rules.ReadString(Engine == EngineType.RedAlert2 ? "AudioVisual" : "General",
                                                    "DamageFireTypes", "FIRE01,FIRE02,FIRE03");
                FireNames = fireNames.Split(new[] { ',', '.' }, StringSplitOptions.RemoveEmptyEntries);
            }

            foreach (var entry in objectsList.OrderedEntries)
            {
                if (!string.IsNullOrEmpty(entry.Value))
                {
                    Logger.Trace("Loading object {0}.{1}", objectsList.Name, entry.Value);
                    AddObject(entry.Value);
                }
            }
        }
        public static TheaterType getTheaterTypeByID(int a)
        {
            TheaterType r   = new TheaterType();
            string      sql = "SELECT id,name,Description,imageTitle,imageView FROM dbo.LoaiRap WHERE id = @id";

            SqlParameter[] param = new SqlParameter[] {
                new SqlParameter("@id", SqlDbType.Int)
            };
            param[0].Value = a;
            DataTable dt = DataAccess.ReadDataBySQLWithParameter(sql, param);

            foreach (DataRow dr in dt.Rows)
            {
                r.ID          = Convert.ToInt32(dr["id"].ToString());
                r.Name        = dr["name"].ToString();
                r.Description = dr["Description"].ToString();
                r.ImageTitle  = dr["imageTitle"].ToString();
                r.ImageView   = dr["imageView"].ToString();
            }
            return(r);
        }
예제 #14
0
 public Theater(TheaterType theaterType, EngineType engine)
 {
     _theaterType = theaterType;
     _engine      = engine;
     if (engine == EngineType.RedAlert2 || engine == EngineType.TiberianSun)
     {
         _rules = VFS.Open <IniFile>("rules.ini");
         _art   = VFS.Open <IniFile>("art.ini");
     }
     else if (engine == EngineType.YurisRevenge)
     {
         _rules = VFS.Open <IniFile>("rulesmd.ini");
         _art   = VFS.Open <IniFile>("artmd.ini");
     }
     else if (engine == EngineType.Firestorm)
     {
         _rules = VFS.Open <IniFile>("rules.ini");
         var fsRules = VFS.Open <IniFile>("firestrm.ini");
         Logger.Info("Merging Firestorm rules with TS rules");
         _rules.MergeWith(fsRules);
         _art = VFS.Open <IniFile>("artmd.ini");
     }
 }
예제 #15
0
        public static (Rectangle, Action <Graphics>) Render(TheaterType theater, Point topLeft, Size tileSize, Smudge smudge)
        {
            var tint            = smudge.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);
            }

            if (Globals.TheTilesetManager.GetTileData(theater.Tilesets, smudge.Type.Name, smudge.Icon, out Tile tile))
            {
                var location     = new Point(topLeft.X * tileSize.Width, topLeft.Y * tileSize.Height);
                var smudgeBounds = new Rectangle(location, smudge.Type.RenderSize);

                void render(Graphics g)
                {
                    g.DrawImage(tile.Image, smudgeBounds, 0, 0, tile.Image.Width, tile.Image.Height, GraphicsUnit.Pixel, imageAttributes);
                }

                return(smudgeBounds, render);
            }
            else
            {
                Debug.Print(string.Format("Smudge {0} ({1}) not found", smudge.Type.Name, smudge.Icon));
                return(Rectangle.Empty, (g) => { });
            }
        }
예제 #16
0
        public TileCollection(TheaterType theater, ModConfig config, VirtualFileSystem vfs, IniFile rules, IniFile art, TheaterSettings theaterSettings, IniFile theaterIni = null)
            : base(CollectionType.Tiles, theater, config, vfs, rules, art)
        {
            _theaterSettings = theaterSettings;
            if (theaterIni == null)
            {
                _theaterIni = _vfs.Open <IniFile>(theaterSettings.TheaterIni);
                if (_theaterIni == null)
                {
                    Logger.Warn("Unavailable theater loaded, theater.ini not found");
                    return;
                }
            }
            else
            {
                _theaterIni = theaterIni;
            }

            #region Set numbers

            IniFile.IniSection General = _theaterIni.GetSection("General");
            ACliffMMPieces      = General.ReadShort("ACliffMMPieces", -1);
            ACliffPieces        = General.ReadShort("ACliffPieces", -1);
            BlackTile           = General.ReadShort("BlackTile", -1);
            BlueMoldTile        = General.ReadShort("BlueMoldTile", -1);
            BridgeBottomLeft1   = General.ReadShort("BridgeBottomLeft1", -1);
            BridgeBottomLeft2   = General.ReadShort("BridgeBottomLeft2", -1);
            BridgeBottomRight1  = General.ReadShort("BridgeBottomRight1", -1);
            BridgeBottomRight2  = General.ReadShort("BridgeBottomRight2", -1);
            BridgeMiddle1       = General.ReadShort("BridgeMiddle1", -1);
            BridgeMiddle2       = General.ReadShort("BridgeMiddle2", -1);
            BridgeSet           = General.ReadShort("BridgeSet", -1);
            BridgeTopLeft1      = General.ReadShort("BridgeTopLeft1", -1);
            BridgeTopLeft2      = General.ReadShort("BridgeTopLeft2", -1);
            BridgeTopRight1     = General.ReadShort("BridgeTopRight1", -1);
            BridgeTopRight2     = General.ReadShort("BridgeTopRight2", -1);
            ClearTile           = General.ReadShort("ClearTile", -1);
            ClearToBlueMoldLat  = General.ReadShort("ClearToBlueMoldLat", -1);
            ClearToCrystalLat   = General.ReadShort("ClearToCrystalLat", -1);
            ClearToGreenLat     = General.ReadShort("ClearToGreenLat", -1);
            ClearToPaveLat      = General.ReadShort("ClearToPaveLat", -1);
            ClearToRoughLat     = General.ReadShort("ClearToRoughLat", -1);
            ClearToSandLat      = General.ReadShort("ClearToSandLat", -1);
            CliffRamps          = General.ReadShort("CliffRamps", -1);
            CliffSet            = General.ReadShort("CliffSet", -1);
            CrystalCliff        = General.ReadShort("CrystalCliff", -1);
            CrystalTile         = General.ReadShort("CrystalTile", -1);
            DestroyableCliffs   = General.ReadShort("DestroyableCliffs", -1);
            DirtRoadCurve       = General.ReadShort("DirtRoadCurve", -1);
            DirtRoadJunction    = General.ReadShort("DirtRoadJunction", -1);
            DirtRoadSlopes      = General.ReadShort("DirtRoadSlopes", -1);
            DirtRoadStraight    = General.ReadShort("DirtRoadStraight", -1);
            DirtTrackTunnels    = General.ReadShort("DirtTrackTunnels", -1);
            DirtTunnels         = General.ReadShort("DirtTunnels", -1);
            GreenTile           = General.ReadShort("GreenTile", -1);
            HeightBase          = General.ReadShort("HeightBase", -1);
            Ice1Set             = General.ReadShort("Ice1Set", -1);
            Ice2Set             = General.ReadShort("Ice2Set", -1);
            Ice3Set             = General.ReadShort("Ice3Set", -1);
            IceShoreSet         = General.ReadShort("IceShoreSet", -1);
            MMRampBase          = General.ReadShort("MMRampBase", -1);
            MMWaterCliffAPieces = General.ReadShort("MMWaterCliffAPieces", -1);
            Medians             = General.ReadShort("Medians", -1);
            MiscPaveTile        = General.ReadShort("MiscPaveTile", -1);
            MonorailSlopes      = General.ReadShort("MonorailSlopes", -1);
            PaveTile            = General.ReadShort("PaveTile", -1);
            PavedRoadEnds       = General.ReadShort("PavedRoadEnds", -1);
            PavedRoadSlopes     = General.ReadShort("PavedRoadSlopes", -1);
            PavedRoads          = General.ReadShort("PavedRoads", -1);
            RampBase            = General.ReadShort("RampBase", -1);
            RampSmooth          = General.ReadShort("RampSmooth", -1);
            Rocks             = General.ReadShort("Rocks", -1);
            RoughGround       = General.ReadShort("RoughGround", -1);
            RoughTile         = General.ReadShort("RoughTile", -1);
            SandTile          = General.ReadShort("SandTile", -1);
            ShorePieces       = General.ReadShort("ShorePieces", -1);
            SlopeSetPieces    = General.ReadShort("SlopeSetPieces", -1);
            SlopeSetPieces2   = General.ReadShort("SlopeSetPieces2", -1);
            SwampTile         = General.ReadShort("SwampTile", -1);
            TrackTunnels      = General.ReadShort("TrackTunnels", -1);
            TrainBridgeSet    = General.ReadShort("TrainBridgeSet", -1);
            Tunnels           = General.ReadShort("Tunnels", -1);
            WaterBridge       = General.ReadShort("WaterBridge", -1);
            WaterCaves        = General.ReadShort("WaterCaves", -1);
            WaterCliffAPieces = General.ReadShort("WaterCliffAPieces", -1);
            WaterCliffs       = General.ReadShort("WaterCliffs", -1);
            WaterSet          = General.ReadShort("WaterSet", -1);
            WaterfallEast     = General.ReadShort("WaterfallEast", -1);
            WaterfallNorth    = General.ReadShort("WaterfallNorth", -1);
            WaterfallSouth    = General.ReadShort("WaterfallSouth", -1);
            WaterfallWest     = General.ReadShort("WaterfallWest", -1);
            WaterToSwampLat   = General.ReadShort("WaterToSwampLat", -1);
            WoodBridgeSet     = General.ReadShort("WoodBridgeSet", -1);

            #endregion
        }
예제 #17
0
        public static (Rectangle, Action <Graphics>) Render(TheaterType theater, Point topLeft, Size tileSize, Infantry infantry, InfantryStoppingType infantryStoppingType)
        {
            var icon = HumanShape[Facing32[infantry.Direction.ID]];

            string teamColor = infantry.House?.UnitTeamColor;

            if (Globals.TheTilesetManager.GetTeamColorTileData(theater.Tilesets, infantry.Type.Name, icon, Globals.TheTeamColorManager[teamColor], out Tile tile))
            {
                var baseLocation = new Point(topLeft.X * tileSize.Width, topLeft.Y * tileSize.Height)
                                   + new Size(tileSize.Width / 2, tileSize.Height / 2);

                var offset = Point.Empty;
                switch (infantryStoppingType)
                {
                case InfantryStoppingType.UpperLeft:
                    offset.X = -tileSize.Width / 4;
                    offset.Y = -tileSize.Height / 4;
                    break;

                case InfantryStoppingType.UpperRight:
                    offset.X = tileSize.Width / 4;
                    offset.Y = -tileSize.Height / 4;
                    break;

                case InfantryStoppingType.LowerLeft:
                    offset.X = -tileSize.Width / 4;
                    offset.Y = tileSize.Height / 4;
                    break;

                case InfantryStoppingType.LowerRight:
                    offset.X = tileSize.Width / 4;
                    offset.Y = tileSize.Height / 4;
                    break;
                }
                baseLocation.Offset(offset);

                var virtualBounds = new Rectangle(
                    new Point(baseLocation.X - (tile.OpaqueBounds.Width / 2), baseLocation.Y - tile.OpaqueBounds.Height),
                    tile.OpaqueBounds.Size
                    );
                var renderBounds = new Rectangle(
                    baseLocation - new Size(infantry.Type.RenderSize.Width / 2, infantry.Type.RenderSize.Height / 2),
                    infantry.Type.RenderSize
                    );

                var tint = infantry.Tint;
                void render(Graphics g)
                {
                    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);
                    }
                    g.DrawImage(tile.Image, renderBounds, 0, 0, tile.Image.Width, tile.Image.Height, GraphicsUnit.Pixel, imageAttributes);
                }

                return(virtualBounds, render);
            }
            else
            {
                Debug.Print(string.Format("Infantry {0} ({1}) not found", infantry.Type.Name, icon));
                return(Rectangle.Empty, (g) => { });
            }
        }
예제 #18
0
		public TileCollection(CollectionType type, TheaterType theater, EngineType engine, IniFile rules, IniFile art,
			TheaterSettings theaterSettings, IniFile theaterIni=null)
			: base(type, theater, engine, rules, art) {

			_theaterSettings = theaterSettings;
			if (theaterIni == null) {
				_theaterIni = VFS.Open<IniFile>(theaterSettings.TheaterIni);
				if (_theaterIni == null) {
					Logger.Warn("Unavailable theater loaded, theater.ini not found");
					return;
				}
			}
			else _theaterIni = theaterIni;

			#region Set numbers

			IniFile.IniSection General = _theaterIni.GetSection("General");
			ACliffMMPieces = General.ReadShort("ACliffMMPieces", -1);
			ACliffPieces = General.ReadShort("ACliffPieces", -1);
			BlackTile = General.ReadShort("BlackTile", -1);
			BridgeBottomLeft1 = General.ReadShort("BridgeBottomLeft1", -1);
			BridgeBottomLeft2 = General.ReadShort("BridgeBottomLeft2", -1);
			BridgeBottomRight1 = General.ReadShort("BridgeBottomRight1", -1);
			BridgeBottomRight2 = General.ReadShort("BridgeBottomRight2", -1);
			BridgeMiddle1 = General.ReadShort("BridgeMiddle1", -1);
			BridgeMiddle2 = General.ReadShort("BridgeMiddle2", -1);
			BridgeSet = General.ReadShort("BridgeSet", -1);
			BridgeTopLeft1 = General.ReadShort("BridgeTopLeft1", -1);
			BridgeTopLeft2 = General.ReadShort("BridgeTopLeft2", -1);
			BridgeTopRight1 = General.ReadShort("BridgeTopRight1", -1);
			BridgeTopRight2 = General.ReadShort("BridgeTopRight2", -1);
			ClearTile = General.ReadShort("ClearTile", -1);
			ClearToGreenLat = General.ReadShort("ClearToGreenLat", -1);
			ClearToPaveLat = General.ReadShort("ClearToPaveLat", -1);
			ClearToRoughLat = General.ReadShort("ClearToRoughLat", -1);
			ClearToSandLat = General.ReadShort("ClearToSandLat", -1);
			CliffRamps = General.ReadShort("CliffRamps", -1);
			CliffSet = General.ReadShort("CliffSet", -1);
			DestroyableCliffs = General.ReadShort("DestroyableCliffs", -1);
			DirtRoadCurve = General.ReadShort("DirtRoadCurve", -1);
			DirtRoadJunction = General.ReadShort("DirtRoadJunction", -1);
			DirtRoadSlopes = General.ReadShort("DirtRoadSlopes", -1);
			DirtRoadStraight = General.ReadShort("DirtRoadStraight", -1);
			DirtTrackTunnels = General.ReadShort("DirtTrackTunnels", -1);
			DirtTunnels = General.ReadShort("DirtTunnels", -1);
			GreenTile = General.ReadShort("GreenTile", -1);
			HeightBase = General.ReadShort("HeightBase", -1);
			Ice1Set = General.ReadShort("Ice1Set", -1);
			Ice2Set = General.ReadShort("Ice2Set", -1);
			Ice3Set = General.ReadShort("Ice3Set", -1);
			IceShoreSet = General.ReadShort("IceShoreSet", -1);
			MMRampBase = General.ReadShort("MMRampBase", -1);
			MMWaterCliffAPieces = General.ReadShort("MMWaterCliffAPieces", -1);
			Medians = General.ReadShort("Medians", -1);
			MiscPaveTile = General.ReadShort("MiscPaveTile", -1);
			MonorailSlopes = General.ReadShort("MonorailSlopes", -1);
			PaveTile = General.ReadShort("PaveTile", -1);
			PavedRoadEnds = General.ReadShort("PavedRoadEnds", -1);
			PavedRoadSlopes = General.ReadShort("PavedRoadSlopes", -1);
			PavedRoads = General.ReadShort("PavedRoads", -1);
			RampBase = General.ReadShort("RampBase", -1);
			RampSmooth = General.ReadShort("RampSmooth", -1);
			Rocks = General.ReadShort("Rocks", -1);
			RoughGround = General.ReadShort("RoughGround", -1);
			RoughTile = General.ReadShort("RoughTile", -1);
			SandTile = General.ReadShort("SandTile", -1);
			ShorePieces = General.ReadShort("ShorePieces", -1);
			SlopeSetPieces = General.ReadShort("SlopeSetPieces", -1);
			SlopeSetPieces2 = General.ReadShort("SlopeSetPieces2", -1);
			TrackTunnels = General.ReadShort("TrackTunnels", -1);
			TrainBridgeSet = General.ReadShort("TrainBridgeSet", -1);
			Tunnels = General.ReadShort("Tunnels", -1);
			WaterBridge = General.ReadShort("WaterBridge", -1);
			WaterCaves = General.ReadShort("WaterCaves", -1);
			WaterCliffAPieces = General.ReadShort("WaterCliffAPieces", -1);
			WaterCliffs = General.ReadShort("WaterCliffs", -1);
			WaterSet = General.ReadShort("WaterSet", -1);
			WaterfallEast = General.ReadShort("WaterfallEast", -1);
			WaterfallNorth = General.ReadShort("WaterfallNorth", -1);
			WaterfallSouth = General.ReadShort("WaterfallSouth", -1);
			WaterfallWest = General.ReadShort("WaterfallWest", -1);
			WoodBridgeSet = General.ReadShort("WoodBridgeSet", -1);

			#endregion
		}
예제 #19
0
		public TheaterSettings GetTheater(TheaterType th) {
			return Theaters.FirstOrDefault(t => t.Type.Equals(th));
		}
예제 #20
0
		public static bool SetActiveTheater(TheaterType theater) {
			ActiveTheater = ActiveConfig.Theaters.First(t => t.Type == theater);
			return ActiveTheater != null;
		}
예제 #21
0
 public static bool SetActiveTheater(TheaterType theater)
 {
     ActiveTheater = ActiveConfig.Theaters.First(t => t.Type == theater);
     return(ActiveTheater != null);
 }
예제 #22
0
 public TheaterSettings GetTheater(TheaterType th)
 {
     return(Theaters.FirstOrDefault(t => t.Type.Equals(th)));
 }
예제 #23
0
        /// <summary>Detect map type.</summary>
        /// <param name="rules">The rules.ini file to be used.</param>
        /// <returns>The engine to be used to render this map.</returns>
        public static EngineType DetectEngineType(MapFile mf)
        {
            var vfsTS  = new VFS();
            var vfsFS  = new VFS();
            var vfsRA2 = new VFS();
            var vfsYR  = new VFS();

            if (Directory.Exists(VFS.TSInstallDir))
            {
                vfsTS.ScanMixDir(VFS.TSInstallDir, EngineType.TiberianSun);
                vfsFS.ScanMixDir(VFS.TSInstallDir, EngineType.Firestorm);
            }

            if (Directory.Exists(VFS.RA2InstallDir))
            {
                vfsRA2.ScanMixDir(VFS.RA2InstallDir, EngineType.RedAlert2);
                vfsYR.ScanMixDir(VFS.RA2InstallDir, EngineType.YurisRevenge);
            }

            IniFile rulesTS = vfsTS.OpenFile <IniFile>("rules.ini");
            IniFile rulesFS = vfsFS.OpenFile <IniFile>("rules.ini");

            if (rulesFS != null)
            {
                rulesFS.MergeWith(vfsFS.OpenFile <IniFile>("firestrm.ini"));
            }

            IniFile rulesRA2 = vfsRA2.OpenFile <IniFile>("rules.ini");
            IniFile rulesYR  = vfsYR.OpenFile <IniFile>("rulesmd.ini");

            TheaterType     theater = Theater.TheaterTypeFromString(mf.ReadString("Map", "Theater"));
            TheaterSettings thsTS   = ModConfig.DefaultsTS.GetTheater(theater);
            TheaterSettings thsFS   = ModConfig.DefaultsFS.GetTheater(theater);
            TheaterSettings thsRA2  = ModConfig.DefaultsRA2.GetTheater(theater);
            TheaterSettings thsYR   = ModConfig.DefaultsYR.GetTheater(theater);

            if (thsTS != null)
            {
                foreach (var f in thsTS.Mixes)
                {
                    vfsTS.AddFile(f);
                }
            }

            if (thsFS != null)
            {
                foreach (var f in thsFS.Mixes)
                {
                    vfsFS.AddFile(f);
                }
            }

            if (thsRA2 != null)
            {
                foreach (var f in thsRA2.Mixes)
                {
                    vfsRA2.AddFile(f);
                }
            }

            if (thsYR != null)
            {
                foreach (var f in thsYR.Mixes)
                {
                    vfsYR.AddFile(f);
                }
            }

            var ret = DetectEngineFromRules(mf, rulesTS, rulesFS, rulesRA2, rulesYR, thsTS, thsFS, thsRA2, thsYR, vfsTS, vfsFS, vfsRA2, vfsYR);

            Logger.Debug("Engine type detected as {0}", ret);
            return(ret);
        }
예제 #24
0
        public static (Rectangle, Action <Graphics>) Render(GameType gameType, TheaterType theater, Point topLeft, Size tileSize, Unit unit)
        {
            int icon = 0;

            if (gameType == GameType.TiberianDawn)
            {
                if (unit.Type == TiberianDawn.UnitTypes.GunBoat)
                {
                    switch (unit.Direction.Facing)
                    {
                    case FacingType.NorthEast:
                    case FacingType.East:
                    case FacingType.SouthEast:
                        icon = 96;
                        break;

                    default:
                        icon = 0;
                        break;
                    }
                }
                else if ((unit.Type == TiberianDawn.UnitTypes.Tric) ||
                         (unit.Type == TiberianDawn.UnitTypes.Trex) ||
                         (unit.Type == TiberianDawn.UnitTypes.Rapt) ||
                         (unit.Type == TiberianDawn.UnitTypes.Steg))
                {
                    var facing = ((unit.Direction.ID + 0x10) & 0xFF) >> 5;
                    icon = BodyShape[facing + ((facing > 0) ? 24 : 0)];
                }
                else if ((unit.Type == TiberianDawn.UnitTypes.Hover) ||
                         (unit.Type == TiberianDawn.UnitTypes.Visceroid))
                {
                    icon = 0;
                }
                else
                {
                    icon = BodyShape[Facing32[unit.Direction.ID]];
                }
            }
            else if (gameType == GameType.RedAlert)
            {
                if (unit.Type.IsAircraft)
                {
                    if ((unit.Type == RedAlert.UnitTypes.Tran) ||
                        (unit.Type == RedAlert.UnitTypes.Heli) ||
                        (unit.Type == RedAlert.UnitTypes.Hind))
                    {
                        icon = BodyShape[Facing32[unit.Direction.ID]];
                    }
                    else
                    {
                        icon = BodyShape[Facing16[unit.Direction.ID] * 2] / 2;
                    }
                }
                else if (unit.Type.IsVessel)
                {
                    if ((unit.Type == RedAlert.UnitTypes.Transport) ||
                        (unit.Type == RedAlert.UnitTypes.Carrier))
                    {
                        icon = 0;
                    }
                    else
                    {
                        icon = BodyShape[Facing16[unit.Direction.ID] * 2] >> 1;
                    }
                }
                else
                {
                    if ((unit.Type == RedAlert.UnitTypes.Ant1) ||
                        (unit.Type == RedAlert.UnitTypes.Ant2) ||
                        (unit.Type == RedAlert.UnitTypes.Ant3))
                    {
                        icon = ((BodyShape[Facing32[unit.Direction.ID]] + 2) / 4) & 0x07;
                    }
                    else
                    {
                        icon = BodyShape[Facing32[unit.Direction.ID]];
                    }
                }
            }

            string teamColor = null;

            if (unit.House != null)
            {
                if (!unit.House.OverrideTeamColors.TryGetValue(unit.Type.Name, out teamColor))
                {
                    teamColor = unit.House.UnitTeamColor;
                }
            }

            if (Globals.TheTilesetManager.GetTeamColorTileData(theater.Tilesets, unit.Type.Name, icon, Globals.TheTeamColorManager[teamColor], out Tile tile))
            {
                var location =
                    new Point(topLeft.X * tileSize.Width, topLeft.Y * tileSize.Height) +
                    new Size(tileSize.Width / 2, tileSize.Height / 2);
                var renderBounds = new Rectangle(
                    location - new Size(unit.Type.RenderSize.Width / 2, unit.Type.RenderSize.Height / 2),
                    unit.Type.RenderSize
                    );

                Tile radarTile = null;
                if ((unit.Type == RedAlert.UnitTypes.MGG) ||
                    (unit.Type == RedAlert.UnitTypes.MRJammer) ||
                    (unit.Type == RedAlert.UnitTypes.Tesla))
                {
                    Globals.TheTilesetManager.GetTeamColorTileData(theater.Tilesets, unit.Type.Name, 32, Globals.TheTeamColorManager[teamColor], out radarTile);
                }

                Tile turretTile = null;
                if (unit.Type.HasTurret)
                {
                    var turretName = unit.Type.Name;
                    var turretIcon = icon + 32;
                    if (unit.Type == RedAlert.UnitTypes.Phase)
                    {
                        turretIcon += 6;
                    }
#if TODO
                    else if (unit.Type == RedAlert.UnitTypes.Cruiser)
                    {
                        turretName = "TURR";
                        turretIcon = BodyShape[Facing32[unit.Direction.ID]];
                    }
                    else if (unit.Type == RedAlert.UnitTypes.Destroyer)
                    {
                        turretName = "SSAM";
                        turretIcon = BodyShape[Facing32[unit.Direction.ID]];
                    }
                    else if (unit.Type == RedAlert.UnitTypes.PTBoat)
                    {
                        turretName = "MGUN";
                        turretIcon = BodyShape[Facing32[unit.Direction.ID]];
                    }
#endif

                    Globals.TheTilesetManager.GetTeamColorTileData(theater.Tilesets, turretName, turretIcon, Globals.TheTeamColorManager[teamColor], out turretTile);
                }

                var tint = unit.Tint;
                void render(Graphics g)
                {
                    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);
                    }

                    g.DrawImage(tile.Image, renderBounds, 0, 0, tile.Image.Width, tile.Image.Height, GraphicsUnit.Pixel, imageAttributes);

                    if (radarTile != null)
                    {
                        Point turretAdjust = Point.Empty;
                        if (unit.Type == RedAlert.UnitTypes.MGG)
                        {
                            turretAdjust = TurretAdjust[Facing32[unit.Direction.ID]];
                        }
                        else if (unit.Type != RedAlert.UnitTypes.Tesla)
                        {
                            turretAdjust.Y = -5;
                        }

                        var radarBounds = renderBounds;
                        radarBounds.Offset(
                            turretAdjust.X * tileSize.Width / Globals.PixelWidth,
                            turretAdjust.Y * tileSize.Height / Globals.PixelHeight
                            );

                        g.DrawImage(radarTile.Image, radarBounds, 0, 0, tile.Image.Width, tile.Image.Height, GraphicsUnit.Pixel, imageAttributes);
                    }
                    if (turretTile != null)
                    {
                        Point turretAdjust = Point.Empty;
                        if (gameType == GameType.RedAlert)
                        {
                            if (unit.Type.IsVessel)
                            {
                            }
                            else if (unit.Type == RedAlert.UnitTypes.Jeep)
                            {
                                turretAdjust.Y = -4;
                            }
                        }
                        else if (gameType == GameType.TiberianDawn)
                        {
                            if ((unit.Type == TiberianDawn.UnitTypes.Jeep) ||
                                (unit.Type == TiberianDawn.UnitTypes.Buggy))
                            {
                                turretAdjust.Y = -4;
                            }
                            else if ((unit.Type == TiberianDawn.UnitTypes.SAM) ||
                                     (unit.Type == TiberianDawn.UnitTypes.MLRS))
                            {
                                turretAdjust = TurretAdjust[Facing32[unit.Direction.ID]];
                            }
                        }

                        var turretBounds = renderBounds;
                        turretBounds.Offset(
                            turretAdjust.X * tileSize.Width / Globals.PixelWidth,
                            turretAdjust.Y * tileSize.Height / Globals.PixelHeight
                            );

                        g.DrawImage(turretTile.Image, turretBounds, 0, 0, tile.Image.Width, tile.Image.Height, GraphicsUnit.Pixel, imageAttributes);
                    }
                }

                return(renderBounds, render);
            }
            else
            {
                Debug.Print(string.Format("Unit {0} ({1}) not found", unit.Type.Name, icon));
                return(Rectangle.Empty, (g) => { });
            }
        }
예제 #25
0
        public static (Rectangle, Action <Graphics>) Render(GameType gameType, TheaterType theater, Point topLeft, Size tileSize, int tileScale, Building building)
        {
            var tint = building.Tint;

            var stringFormat = new StringFormat
            {
                Alignment     = StringAlignment.Center,
                LineAlignment = StringAlignment.Center
            };
            var fakeBackgroundBrush = new SolidBrush(Color.FromArgb(building.Tint.A / 2, Color.Black));
            var fakeTextBrush       = new SolidBrush(Color.FromArgb(building.Tint.A, Color.White));
            var baseBackgroundBrush = new SolidBrush(Color.FromArgb(building.Tint.A / 2, Color.Black));
            var baseTextBrush       = new SolidBrush(Color.FromArgb(building.Tint.A, Color.Red));

            var icon = 0;

            if (building.Type.HasTurret)
            {
                icon = BodyShape[Facing32[building.Direction.ID]];
                if (building.Strength < 128)
                {
                    switch (gameType)
                    {
                    case GameType.TiberianDawn:
                        icon += 64;
                        break;

                    case GameType.RedAlert:
                        icon += building.Type.Equals("sam") ? 35 : 64;
                        break;
                    }
                }
            }
            else
            {
                if (building.Strength <= 1)
                {
                    icon = -1;
                }
                else if (building.Strength < 128)
                {
                    icon = -2;
                    if (building.Type.Equals("weap") || building.Type.Equals("weaf"))
                    {
                        icon = 1;
                    }
                    else if ((gameType == GameType.TiberianDawn) && building.Type.Equals("proc"))
                    {
                        icon = 30;
                    }
                    else if (building.Type.Equals("eye"))
                    {
                        icon = 16;
                    }
                    else if (building.Type.Equals("silo"))
                    {
                        icon = 5;
                    }
                    else if (building.Type.Equals("fix"))
                    {
                        icon = 7;
                    }
                    else if (building.Type.Equals("v19"))
                    {
                        icon = 14;
                    }
                }
            }

            if (Globals.TheTilesetManager.GetTeamColorTileData(theater.Tilesets, building.Type.Tilename, icon, Globals.TheTeamColorManager[building.House.BuildingTeamColor], out Tile tile))
            {
                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 maxSize  = new Size(building.Type.Size.Width * tileSize.Width, building.Type.Size.Height * tileSize.Height);
                if ((size.Width >= size.Height) && (size.Width > maxSize.Width))
                {
                    size.Height = size.Height * maxSize.Width / size.Width;
                    size.Width  = maxSize.Width;
                }
                else if ((size.Height >= size.Width) && (size.Height > maxSize.Height))
                {
                    size.Width  = size.Width * maxSize.Height / size.Height;
                    size.Height = maxSize.Height;
                }
                var buildingBounds = new Rectangle(location, size);

                Tile factoryOverlayTile = null;
                if (building.Type.FactoryOverlay != null)
                {
                    int overlayIcon = 0;
                    if (building.Strength < 128)
                    {
                        switch (gameType)
                        {
                        case GameType.TiberianDawn:
                            overlayIcon = 10;
                            break;

                        case GameType.RedAlert:
                            overlayIcon = 4;
                            break;
                        }
                    }

                    Globals.TheTilesetManager.GetTeamColorTileData(theater.Tilesets, building.Type.FactoryOverlay, overlayIcon, Globals.TheTeamColorManager[building.House.BuildingTeamColor], out factoryOverlayTile);
                }

                void render(Graphics g)
                {
                    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);
                    }

                    if (factoryOverlayTile != null)
                    {
                        g.DrawImage(tile.Image, buildingBounds, 0, 0, tile.Image.Width, tile.Image.Height, GraphicsUnit.Pixel, imageAttributes);
                        g.DrawImage(factoryOverlayTile.Image, buildingBounds, 0, 0, tile.Image.Width, tile.Image.Height, GraphicsUnit.Pixel, imageAttributes);
                    }
                    else
                    {
                        g.DrawImage(tile.Image, buildingBounds, 0, 0, tile.Image.Width, tile.Image.Height, GraphicsUnit.Pixel, imageAttributes);
                    }

                    if (building.Type.IsFake)
                    {
                        var text       = Globals.TheGameTextManager["TEXT_UI_FAKE"];
                        var textSize   = g.MeasureString(text, SystemFonts.CaptionFont) + new SizeF(6.0f, 6.0f);
                        var textBounds = new RectangleF(buildingBounds.Location, textSize);
                        g.FillRectangle(fakeBackgroundBrush, textBounds);
                        g.DrawString(text, SystemFonts.CaptionFont, fakeTextBrush, textBounds, stringFormat);
                    }

                    if (building.BasePriority >= 0)
                    {
                        var text       = building.BasePriority.ToString();
                        var textSize   = g.MeasureString(text, SystemFonts.CaptionFont) + new SizeF(6.0f, 6.0f);
                        var textBounds = new RectangleF(buildingBounds.Location +
                                                        new Size((int)((buildingBounds.Width - textSize.Width) / 2.0f), (int)(buildingBounds.Height - textSize.Height)),
                                                        textSize
                                                        );
                        g.FillRectangle(baseBackgroundBrush, textBounds);
                        g.DrawString(text, SystemFonts.CaptionFont, baseTextBrush, textBounds, stringFormat);
                    }
                }

                return(buildingBounds, render);
            }
            else
            {
                Debug.Print(string.Format("Building {0} (0) not found", building.Type.Name));
                return(Rectangle.Empty, (g) => { });
            }
        }