From 724928cf56837f0fb35fcb998ec0c0ae492fbc97 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Thu, 4 Mar 2010 18:26:43 +1300 Subject: [PATCH] Theater definitions in yaml --- OpenRA.FileFormats/Map.cs | 2 -- OpenRA.FileFormats/TileSet.cs | 12 +++++------ OpenRA.FileFormats/Walkability.cs | 4 ++-- OpenRA.Game/Chrome.cs | 4 +++- OpenRA.Game/OpenRA.Game.csproj | 1 + OpenRA.Game/Traits/World/Theater.cs | 32 +++++++++++++++++++++++++++++ OpenRA.Game/World.cs | 9 +++++--- mods/cnc/system.yaml | 18 ++++++++++++++++ mods/cnc/vehicles.yaml | 2 +- mods/ra/rules.yaml | 14 ++++++++++++- 10 files changed, 82 insertions(+), 16 deletions(-) create mode 100644 OpenRA.Game/Traits/World/Theater.cs diff --git a/OpenRA.FileFormats/Map.cs b/OpenRA.FileFormats/Map.cs index c1e9d9db1b..a02ede172c 100644 --- a/OpenRA.FileFormats/Map.cs +++ b/OpenRA.FileFormats/Map.cs @@ -51,8 +51,6 @@ namespace OpenRA.FileFormats return s.Length <= maxLength ? s : s.Substring(0,maxLength ); } - public string TileSuffix { get { return "." + Truncate(Theater, 3); } } - public Map(string filename) { IniFile file = new IniFile(FileSystem.Open(filename)); diff --git a/OpenRA.FileFormats/TileSet.cs b/OpenRA.FileFormats/TileSet.cs index 14349d633b..eb6ca1d4bb 100644 --- a/OpenRA.FileFormats/TileSet.cs +++ b/OpenRA.FileFormats/TileSet.cs @@ -28,7 +28,7 @@ namespace OpenRA.FileFormats { public readonly Dictionary tiles = new Dictionary(); - public readonly Walkability Walkability = new Walkability(); + public readonly Walkability Walkability; public readonly Dictionary walk = new Dictionary(); @@ -46,12 +46,12 @@ namespace OpenRA.FileFormats return ret; } - public TileSet( string suffix ) + public TileSet( string tilesetFile, string templatesFile, string suffix ) { - Walkability = new Walkability(); + Walkability = new Walkability(templatesFile); - char tileSetChar = char.ToUpperInvariant( suffix[ 1 ] ); - StreamReader tileIdFile = new StreamReader( FileSystem.Open( "tileSet.til" ) ); + char tileSetChar = char.ToUpperInvariant( suffix[ 0 ] ); + StreamReader tileIdFile = new StreamReader( FileSystem.Open(tilesetFile) ); while( true ) { @@ -74,7 +74,7 @@ namespace OpenRA.FileFormats if (!walk.ContainsKey((ushort)(start + i))) walk.Add((ushort)(start + i), Walkability.GetWalkability(tilename)); - using( Stream s = FileSystem.Open( tilename + suffix ) ) + using( Stream s = FileSystem.Open( tilename + "." + suffix ) ) { if( !tiles.ContainsKey( (ushort)( start + i ) ) ) tiles.Add( (ushort)( start + i ), new Terrain( s ) ); diff --git a/OpenRA.FileFormats/Walkability.cs b/OpenRA.FileFormats/Walkability.cs index 1d99ecf3d4..3469ab71da 100644 --- a/OpenRA.FileFormats/Walkability.cs +++ b/OpenRA.FileFormats/Walkability.cs @@ -38,9 +38,9 @@ namespace OpenRA.FileFormats Dictionary walkability = new Dictionary(); - public Walkability() + public Walkability(string templatesFile) { - var file = new IniFile( FileSystem.Open( "templates.ini" ) ); + var file = new IniFile( FileSystem.Open( templatesFile ) ); foreach (var section in file.Sections) { diff --git a/OpenRA.Game/Chrome.cs b/OpenRA.Game/Chrome.cs index fd4f86ea5a..31d4e9985f 100644 --- a/OpenRA.Game/Chrome.cs +++ b/OpenRA.Game/Chrome.cs @@ -339,7 +339,9 @@ namespace OpenRA DrawCentered("Size: {0}x{1}".F(currentMap.Map.Width, currentMap.Map.Height), new int2(mapRect.Left + mapRect.Width / 2, y), Color.White); y += 20; - DrawCentered("Theater: {0}".F(currentMap.Map.Theater, currentMap.Map.Height), + + TheaterInfo theaterInfo = Game.world.WorldActor.Info.Traits.WithInterface().Where(t => t.Theater == currentMap.Map.Theater).FirstOrDefault(); + DrawCentered("Theater: {0}".F(theaterInfo.Name, currentMap.Map.Height), new int2(mapRect.Left + mapRect.Width / 2, y), Color.White); y += 20; DrawCentered("Spawnpoints: {0}".F(currentMap.Map.SpawnPoints.Count()), diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index 7671f0c818..ae61fd5e55 100644 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -269,6 +269,7 @@ + diff --git a/OpenRA.Game/Traits/World/Theater.cs b/OpenRA.Game/Traits/World/Theater.cs new file mode 100644 index 0000000000..b34e802e8d --- /dev/null +++ b/OpenRA.Game/Traits/World/Theater.cs @@ -0,0 +1,32 @@ +#region Copyright & License Information +/* + * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. + * This file is part of OpenRA. + * + * OpenRA is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OpenRA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenRA. If not, see . + */ +#endregion + +namespace OpenRA.Traits +{ + class TheaterInfo : StatelessTraitInfo + { + public readonly string Name = null; + public readonly string Theater = null; + public readonly string Suffix = null; + public readonly string Tileset = null; + public readonly string Templates = null; + } + class Theater {} +} diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs index 0657173785..7fa2019793 100644 --- a/OpenRA.Game/World.cs +++ b/OpenRA.Game/World.cs @@ -59,8 +59,7 @@ namespace OpenRA Game.IssueOrder(Order.Chat("/name " + Game.Settings.PlayerName)); } - public readonly Actor WorldActor; - + public readonly Actor WorldActor; public readonly PathFinder PathFinder; public readonly Map Map; @@ -75,9 +74,13 @@ namespace OpenRA public World() { Timer.Time( "----World.ctor" ); + Map = new Map( Game.LobbyInfo.GlobalSettings.Map ); Timer.Time( "new Map: {0}" ); - TileSet = new TileSet( Map.TileSuffix ); + + TheaterInfo theaterInfo = Rules.Info["world"].Traits.WithInterface().Where(t => t.Theater == Map.Theater).FirstOrDefault(); + TileSet = new TileSet(theaterInfo.Tileset, theaterInfo.Templates, theaterInfo.Suffix); + SpriteSheetBuilder.Initialize( Map ); Timer.Time( "Tileset: {0}" ); diff --git a/mods/cnc/system.yaml b/mods/cnc/system.yaml index c224da4140..a9dbac63b3 100644 --- a/mods/cnc/system.yaml +++ b/mods/cnc/system.yaml @@ -205,3 +205,21 @@ World: Name: Tiberium GrowthInterval: 1 SpreadInterval: 6 + Theater@DESERT: + Name:Desert + Theater:DESERT + Suffix:des + Templates:templates.ini + Tileset:tileSet.til + Theater@WINTER: + Name:Winter + Theater:WINTER + Suffix:win + Templates:templates.ini + Tileset:tileSet.til + Theater@TEMPERAT: + Name:Temperate + Theater:TEMPERAT + Suffix:tem + Templates:templates.ini + Tileset:tileSet.til \ No newline at end of file diff --git a/mods/cnc/vehicles.yaml b/mods/cnc/vehicles.yaml index ff84a70e6a..6c54f1be46 100644 --- a/mods/cnc/vehicles.yaml +++ b/mods/cnc/vehicles.yaml @@ -21,7 +21,7 @@ MCV: Offset:-1,-1 DeployDirections: 96 TransformSounds: constru2.aud, hvydoor1.aud - NoTransformSounds: nodeply1.aud + NoTransformSounds: deploy1.aud RenderUnit: HARV: diff --git a/mods/ra/rules.yaml b/mods/ra/rules.yaml index 6be0b8fb5e..a405bd3085 100644 --- a/mods/ra/rules.yaml +++ b/mods/ra/rules.yaml @@ -244,7 +244,19 @@ World: SpriteNames: gem01,gem02,gem03,gem04 ValuePerUnit: 50 Name: Gems - + Theater@SNOW: + Name:Snow + Theater:SNOW + Suffix:sno + Templates:templates.ini + Tileset:tileSet.til + Theater@TEMPERAT: + Name:Temperate + Theater:TEMPERAT + Suffix:tem + Templates:templates.ini + Tileset:tileSet.til + MGG: GeneratesGap: Range: 10