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.

This commit is contained in:
Chris Forbes
2010-12-28 19:13:56 +13:00
parent aecf19ed64
commit 44e668e804
9 changed files with 146 additions and 122 deletions

View File

@@ -332,6 +332,7 @@ namespace OpenRA.Editor
pd.desc.Text = surface1.Map.Description; pd.desc.Text = surface1.Map.Description;
pd.author.Text = surface1.Map.Author; pd.author.Text = surface1.Map.Author;
pd.selectable.Checked = surface1.Map.Selectable; pd.selectable.Checked = surface1.Map.Selectable;
pd.useAsShellmap.Checked = surface1.Map.UseAsShellmap;
if (DialogResult.OK != pd.ShowDialog()) if (DialogResult.OK != pd.ShowDialog())
return; return;
@@ -340,6 +341,7 @@ namespace OpenRA.Editor
surface1.Map.Description = pd.desc.Text; surface1.Map.Description = pd.desc.Text;
surface1.Map.Author = pd.author.Text; surface1.Map.Author = pd.author.Text;
surface1.Map.Selectable = pd.selectable.Checked; surface1.Map.Selectable = pd.selectable.Checked;
surface1.Map.UseAsShellmap = pd.useAsShellmap.Checked;
} }
} }

View File

@@ -37,6 +37,7 @@
this.selectable = new System.Windows.Forms.CheckBox(); this.selectable = new System.Windows.Forms.CheckBox();
this.label3 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label();
this.author = new System.Windows.Forms.TextBox(); this.author = new System.Windows.Forms.TextBox();
this.useAsShellmap = new System.Windows.Forms.CheckBox();
this.SuspendLayout(); this.SuspendLayout();
// //
// button2 // button2
@@ -119,6 +120,16 @@
this.author.Size = new System.Drawing.Size(286, 20); this.author.Size = new System.Drawing.Size(286, 20);
this.author.TabIndex = 17; 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 // PropertiesDialog
// //
this.AcceptButton = this.button2; this.AcceptButton = this.button2;
@@ -126,6 +137,7 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.button1; this.CancelButton = this.button1;
this.ClientSize = new System.Drawing.Size(370, 228); this.ClientSize = new System.Drawing.Size(370, 228);
this.Controls.Add(this.useAsShellmap);
this.Controls.Add(this.selectable); this.Controls.Add(this.selectable);
this.Controls.Add(this.author); this.Controls.Add(this.author);
this.Controls.Add(this.label3); this.Controls.Add(this.label3);
@@ -155,5 +167,6 @@
public System.Windows.Forms.CheckBox selectable; public System.Windows.Forms.CheckBox selectable;
private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label3;
public System.Windows.Forms.TextBox author; public System.Windows.Forms.TextBox author;
public System.Windows.Forms.CheckBox useAsShellmap;
} }
} }

View File

@@ -21,7 +21,7 @@ namespace OpenRA.FileFormats
Mods, Folders, Packages, Rules, ServerTraits, Mods, Folders, Packages, Rules, ServerTraits,
Sequences, Cursors, Chrome, Assemblies, ChromeLayout, Sequences, Cursors, Chrome, Assemblies, ChromeLayout,
Weapons, Voices, Music, Movies, TileSets; Weapons, Voices, Music, Movies, TileSets;
public readonly string ShellmapUid, LoadScreen; public readonly string LoadScreen;
public readonly int TileSize = 24; public readonly int TileSize = 24;
public Manifest(string[] mods) public Manifest(string[] mods)
@@ -47,7 +47,6 @@ namespace OpenRA.FileFormats
Movies = YamlList(yaml, "Movies"); Movies = YamlList(yaml, "Movies");
TileSets = YamlList(yaml, "TileSets"); TileSets = YamlList(yaml, "TileSets");
ShellmapUid = yaml.First( x => x.Key == "ShellmapUid" ).Value.Value;
LoadScreen = yaml.First( x => x.Key == "LoadScreen" ).Value.Value; LoadScreen = yaml.First( x => x.Key == "LoadScreen" ).Value.Value;
if (yaml.FirstOrDefault( x => x.Key == "TileSize" ) != null) if (yaml.FirstOrDefault( x => x.Key == "TileSize" ) != null)

View File

@@ -23,6 +23,7 @@ namespace OpenRA.FileFormats
// Yaml map data // Yaml map data
public string Uid { get; protected set; } 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 Title;
[FieldLoader.Load] public string Type = "Conquest"; [FieldLoader.Load] public string Type = "Conquest";

View File

@@ -238,9 +238,9 @@ namespace OpenRA
PerfHistory.items["text"].hasNormalTick = false; PerfHistory.items["text"].hasNormalTick = false;
PerfHistory.items["cursor"].hasNormalTick = false; PerfHistory.items["cursor"].hasNormalTick = false;
JoinLocal(); JoinLocal();
StartGame(modData.Manifest.ShellmapUid);
StartGame(ChooseShellmap());
// TODO: unhardcode this // TODO: unhardcode this
modData.WidgetLoader.LoadWidget( new Dictionary<string,object>(), Widget.RootWidget, "PERF_BG" ); modData.WidgetLoader.LoadWidget( new Dictionary<string,object>(), Widget.RootWidget, "PERF_BG" );
@@ -249,6 +249,13 @@ namespace OpenRA
Game.orderManager.LastTickTime = Environment.TickCount; Game.orderManager.LastTickTime = Environment.TickCount;
} }
static string ChooseShellmap()
{
return modData.AvailableMaps
.Where(m => m.Value.UseAsShellmap)
.Random(CosmeticRandom).Key;
}
static bool quit; static bool quit;
internal static void Run() internal static void Run()
{ {
@@ -274,7 +281,7 @@ namespace OpenRA
server.Shutdown(); server.Shutdown();
orderManager.Dispose(); orderManager.Dispose();
var shellmap = modData.Manifest.ShellmapUid; var shellmap = ChooseShellmap();
JoinLocal(); JoinLocal();
StartGame(shellmap); StartGame(shellmap);

View File

@@ -18,6 +18,8 @@ TopLeft: 8,1
BottomRight: 88,46 BottomRight: 88,46
UseAsShellmap: yes
Players: Players:
PlayerReference@Nod: PlayerReference@Nod:
Name: Nod Name: Nod

View File

@@ -84,7 +84,6 @@ TileSets:
mods/cnc/tilesets/snow.yaml mods/cnc/tilesets/snow.yaml
LoadScreen: CncLoadScreen LoadScreen: CncLoadScreen
ShellmapUid:2cc2a95c89dc6594acec52d7acbc720f45fc5d9e
ServerTraits: ServerTraits:
PlayerCommands PlayerCommands
LobbyCommands LobbyCommands

View File

@@ -2,7 +2,7 @@ Selectable: False
MapFormat: 3 MapFormat: 3
Title: <none> Title: OpenRA Shellmap
Author: Westwood Studios Author: Westwood Studios
@@ -16,6 +16,8 @@ TopLeft: 26,36
BottomRight: 118,93 BottomRight: 118,93
UseAsShellmap: yes
Players: Players:
PlayerReference@Neutral: PlayerReference@Neutral:
Name: Neutral Name: Neutral

View File

@@ -78,7 +78,6 @@ Movies:
mods/ra/movies2.yaml mods/ra/movies2.yaml
LoadScreen: RALoadScreen LoadScreen: RALoadScreen
ShellmapUid:a628d8d09c2275ca22e1dc84e41491978a96a71e
ServerTraits: ServerTraits:
PlayerCommands PlayerCommands
LobbyCommands LobbyCommands