From 44e668e8048025b5378fd8b1305c967091ebb14c Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 28 Dec 2010 19:13:56 +1300 Subject: [PATCH] choose a random map with MapStub.UseAsShellmap as the shellmap, rather than hardcoding a sha1 in mod.yaml; add editor support for the new flag too. --- OpenRA.Editor/Form1.cs | 2 + OpenRA.Editor/PropertiesDialog.Designer.cs | 239 +++++++++++---------- OpenRA.FileFormats/Manifest.cs | 3 +- OpenRA.FileFormats/Map/MapStub.cs | 3 +- OpenRA.Game/Game.cs | 13 +- mods/cnc/maps/shellmap/map.yaml | 2 + mods/cnc/mod.yaml | 1 - mods/ra/maps/shellmap/map.yaml | 4 +- mods/ra/mod.yaml | 1 - 9 files changed, 146 insertions(+), 122 deletions(-) diff --git a/OpenRA.Editor/Form1.cs b/OpenRA.Editor/Form1.cs index d7061e5ad7..a1064f377e 100755 --- a/OpenRA.Editor/Form1.cs +++ b/OpenRA.Editor/Form1.cs @@ -332,6 +332,7 @@ namespace OpenRA.Editor pd.desc.Text = surface1.Map.Description; pd.author.Text = surface1.Map.Author; pd.selectable.Checked = surface1.Map.Selectable; + pd.useAsShellmap.Checked = surface1.Map.UseAsShellmap; if (DialogResult.OK != pd.ShowDialog()) return; @@ -340,6 +341,7 @@ namespace OpenRA.Editor surface1.Map.Description = pd.desc.Text; surface1.Map.Author = pd.author.Text; surface1.Map.Selectable = pd.selectable.Checked; + surface1.Map.UseAsShellmap = pd.useAsShellmap.Checked; } } diff --git a/OpenRA.Editor/PropertiesDialog.Designer.cs b/OpenRA.Editor/PropertiesDialog.Designer.cs index b4a7758396..0410d9c72d 100644 --- a/OpenRA.Editor/PropertiesDialog.Designer.cs +++ b/OpenRA.Editor/PropertiesDialog.Designer.cs @@ -28,119 +28,131 @@ /// private void InitializeComponent() { - this.button2 = new System.Windows.Forms.Button(); - this.button1 = new System.Windows.Forms.Button(); - this.label1 = new System.Windows.Forms.Label(); - this.title = new System.Windows.Forms.TextBox(); - this.label2 = new System.Windows.Forms.Label(); - this.desc = new System.Windows.Forms.TextBox(); - this.selectable = new System.Windows.Forms.CheckBox(); - this.label3 = new System.Windows.Forms.Label(); - this.author = new System.Windows.Forms.TextBox(); - this.SuspendLayout(); - // - // button2 - // - this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.button2.DialogResult = System.Windows.Forms.DialogResult.OK; - this.button2.Location = new System.Drawing.Point(196, 193); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(75, 23); - this.button2.TabIndex = 14; - this.button2.Text = "OK"; - this.button2.UseVisualStyleBackColor = true; - // - // button1 - // - this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.button1.Location = new System.Drawing.Point(277, 193); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(75, 23); - this.button1.TabIndex = 15; - this.button1.Text = "Cancel"; - this.button1.UseVisualStyleBackColor = true; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(12, 50); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(27, 13); - this.label1.TabIndex = 16; - this.label1.Text = "Title"; - // - // title - // - this.title.Location = new System.Drawing.Point(66, 47); - this.title.Name = "title"; - this.title.Size = new System.Drawing.Size(286, 20); - this.title.TabIndex = 17; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(12, 76); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(32, 13); - this.label2.TabIndex = 16; - this.label2.Text = "Desc"; - // - // desc - // - this.desc.Location = new System.Drawing.Point(66, 73); - this.desc.Name = "desc"; - this.desc.Size = new System.Drawing.Size(286, 20); - this.desc.TabIndex = 17; - // - // selectable - // - this.selectable.AutoSize = true; - this.selectable.Location = new System.Drawing.Point(118, 138); - this.selectable.Name = "selectable"; - this.selectable.Size = new System.Drawing.Size(130, 17); - this.selectable.TabIndex = 18; - this.selectable.Text = "Show in Map Chooser"; - this.selectable.UseVisualStyleBackColor = true; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(12, 102); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(38, 13); - this.label3.TabIndex = 16; - this.label3.Text = "Author"; - // - // author - // - this.author.Location = new System.Drawing.Point(66, 99); - this.author.Name = "author"; - this.author.Size = new System.Drawing.Size(286, 20); - this.author.TabIndex = 17; - // - // PropertiesDialog - // - this.AcceptButton = this.button2; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.button1; - this.ClientSize = new System.Drawing.Size(370, 228); - this.Controls.Add(this.selectable); - this.Controls.Add(this.author); - this.Controls.Add(this.label3); - this.Controls.Add(this.desc); - this.Controls.Add(this.label2); - this.Controls.Add(this.title); - this.Controls.Add(this.label1); - this.Controls.Add(this.button2); - this.Controls.Add(this.button1); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.Name = "PropertiesDialog"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "PropertiesDialog"; - this.ResumeLayout(false); - this.PerformLayout(); + this.button2 = new System.Windows.Forms.Button(); + this.button1 = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.title = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.desc = new System.Windows.Forms.TextBox(); + this.selectable = new System.Windows.Forms.CheckBox(); + this.label3 = new System.Windows.Forms.Label(); + this.author = new System.Windows.Forms.TextBox(); + this.useAsShellmap = new System.Windows.Forms.CheckBox(); + this.SuspendLayout(); + // + // button2 + // + this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button2.DialogResult = System.Windows.Forms.DialogResult.OK; + this.button2.Location = new System.Drawing.Point(196, 193); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(75, 23); + this.button2.TabIndex = 14; + this.button2.Text = "OK"; + this.button2.UseVisualStyleBackColor = true; + // + // button1 + // + this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.button1.Location = new System.Drawing.Point(277, 193); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.TabIndex = 15; + this.button1.Text = "Cancel"; + this.button1.UseVisualStyleBackColor = true; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 50); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(27, 13); + this.label1.TabIndex = 16; + this.label1.Text = "Title"; + // + // title + // + this.title.Location = new System.Drawing.Point(66, 47); + this.title.Name = "title"; + this.title.Size = new System.Drawing.Size(286, 20); + this.title.TabIndex = 17; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(12, 76); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(32, 13); + this.label2.TabIndex = 16; + this.label2.Text = "Desc"; + // + // desc + // + this.desc.Location = new System.Drawing.Point(66, 73); + this.desc.Name = "desc"; + this.desc.Size = new System.Drawing.Size(286, 20); + this.desc.TabIndex = 17; + // + // selectable + // + this.selectable.AutoSize = true; + this.selectable.Location = new System.Drawing.Point(118, 138); + this.selectable.Name = "selectable"; + this.selectable.Size = new System.Drawing.Size(130, 17); + this.selectable.TabIndex = 18; + this.selectable.Text = "Show in Map Chooser"; + this.selectable.UseVisualStyleBackColor = true; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(12, 102); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(38, 13); + this.label3.TabIndex = 16; + this.label3.Text = "Author"; + // + // author + // + this.author.Location = new System.Drawing.Point(66, 99); + this.author.Name = "author"; + this.author.Size = new System.Drawing.Size(286, 20); + this.author.TabIndex = 17; + // + // checkBox1 + // + this.useAsShellmap.AutoSize = true; + this.useAsShellmap.Location = new System.Drawing.Point(118, 161); + this.useAsShellmap.Name = "checkBox1"; + this.useAsShellmap.Size = new System.Drawing.Size(105, 17); + this.useAsShellmap.TabIndex = 18; + this.useAsShellmap.Text = "Use as Shellmap"; + this.useAsShellmap.UseVisualStyleBackColor = true; + // + // PropertiesDialog + // + this.AcceptButton = this.button2; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.button1; + this.ClientSize = new System.Drawing.Size(370, 228); + this.Controls.Add(this.useAsShellmap); + this.Controls.Add(this.selectable); + this.Controls.Add(this.author); + this.Controls.Add(this.label3); + this.Controls.Add(this.desc); + this.Controls.Add(this.label2); + this.Controls.Add(this.title); + this.Controls.Add(this.label1); + this.Controls.Add(this.button2); + this.Controls.Add(this.button1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Name = "PropertiesDialog"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "PropertiesDialog"; + this.ResumeLayout(false); + this.PerformLayout(); } @@ -155,5 +167,6 @@ public System.Windows.Forms.CheckBox selectable; private System.Windows.Forms.Label label3; public System.Windows.Forms.TextBox author; + public System.Windows.Forms.CheckBox useAsShellmap; } } \ No newline at end of file diff --git a/OpenRA.FileFormats/Manifest.cs b/OpenRA.FileFormats/Manifest.cs index e029c08a95..905b30e055 100644 --- a/OpenRA.FileFormats/Manifest.cs +++ b/OpenRA.FileFormats/Manifest.cs @@ -21,7 +21,7 @@ namespace OpenRA.FileFormats Mods, Folders, Packages, Rules, ServerTraits, Sequences, Cursors, Chrome, Assemblies, ChromeLayout, Weapons, Voices, Music, Movies, TileSets; - public readonly string ShellmapUid, LoadScreen; + public readonly string LoadScreen; public readonly int TileSize = 24; public Manifest(string[] mods) @@ -47,7 +47,6 @@ namespace OpenRA.FileFormats Movies = YamlList(yaml, "Movies"); TileSets = YamlList(yaml, "TileSets"); - ShellmapUid = yaml.First( x => x.Key == "ShellmapUid" ).Value.Value; LoadScreen = yaml.First( x => x.Key == "LoadScreen" ).Value.Value; if (yaml.FirstOrDefault( x => x.Key == "TileSize" ) != null) diff --git a/OpenRA.FileFormats/Map/MapStub.cs b/OpenRA.FileFormats/Map/MapStub.cs index f4fba25c6a..6a69540090 100644 --- a/OpenRA.FileFormats/Map/MapStub.cs +++ b/OpenRA.FileFormats/Map/MapStub.cs @@ -22,7 +22,8 @@ namespace OpenRA.FileFormats // Yaml map data public string Uid { get; protected set; } - [FieldLoader.Load] public bool Selectable; + [FieldLoader.Load] public bool Selectable; + [FieldLoader.Load] public bool UseAsShellmap; [FieldLoader.Load] public string Title; [FieldLoader.Load] public string Type = "Conquest"; diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 51c0f7d3cb..24368d1824 100755 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -238,9 +238,9 @@ namespace OpenRA PerfHistory.items["text"].hasNormalTick = false; PerfHistory.items["cursor"].hasNormalTick = false; - JoinLocal(); - StartGame(modData.Manifest.ShellmapUid); + + StartGame(ChooseShellmap()); // TODO: unhardcode this modData.WidgetLoader.LoadWidget( new Dictionary(), Widget.RootWidget, "PERF_BG" ); @@ -249,6 +249,13 @@ namespace OpenRA Game.orderManager.LastTickTime = Environment.TickCount; } + static string ChooseShellmap() + { + return modData.AvailableMaps + .Where(m => m.Value.UseAsShellmap) + .Random(CosmeticRandom).Key; + } + static bool quit; internal static void Run() { @@ -274,7 +281,7 @@ namespace OpenRA server.Shutdown(); orderManager.Dispose(); - var shellmap = modData.Manifest.ShellmapUid; + var shellmap = ChooseShellmap(); JoinLocal(); StartGame(shellmap); diff --git a/mods/cnc/maps/shellmap/map.yaml b/mods/cnc/maps/shellmap/map.yaml index 0966e6cbdd..b73e679fa7 100644 --- a/mods/cnc/maps/shellmap/map.yaml +++ b/mods/cnc/maps/shellmap/map.yaml @@ -18,6 +18,8 @@ TopLeft: 8,1 BottomRight: 88,46 +UseAsShellmap: yes + Players: PlayerReference@Nod: Name: Nod diff --git a/mods/cnc/mod.yaml b/mods/cnc/mod.yaml index 3c923e886f..821aecf062 100644 --- a/mods/cnc/mod.yaml +++ b/mods/cnc/mod.yaml @@ -84,7 +84,6 @@ TileSets: mods/cnc/tilesets/snow.yaml LoadScreen: CncLoadScreen -ShellmapUid:2cc2a95c89dc6594acec52d7acbc720f45fc5d9e ServerTraits: PlayerCommands LobbyCommands diff --git a/mods/ra/maps/shellmap/map.yaml b/mods/ra/maps/shellmap/map.yaml index 0e2426ac26..79aee6c631 100644 --- a/mods/ra/maps/shellmap/map.yaml +++ b/mods/ra/maps/shellmap/map.yaml @@ -2,7 +2,7 @@ Selectable: False MapFormat: 3 -Title: +Title: OpenRA Shellmap Author: Westwood Studios @@ -16,6 +16,8 @@ TopLeft: 26,36 BottomRight: 118,93 +UseAsShellmap: yes + Players: PlayerReference@Neutral: Name: Neutral diff --git a/mods/ra/mod.yaml b/mods/ra/mod.yaml index 74d7aa0009..53e08f3a4e 100644 --- a/mods/ra/mod.yaml +++ b/mods/ra/mod.yaml @@ -78,7 +78,6 @@ Movies: mods/ra/movies2.yaml LoadScreen: RALoadScreen -ShellmapUid:a628d8d09c2275ca22e1dc84e41491978a96a71e ServerTraits: PlayerCommands LobbyCommands