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

@@ -28,119 +28,131 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.button2 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.title = new System.Windows.Forms.TextBox(); this.title = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.desc = new System.Windows.Forms.TextBox(); this.desc = new System.Windows.Forms.TextBox();
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.SuspendLayout(); this.useAsShellmap = new System.Windows.Forms.CheckBox();
// this.SuspendLayout();
// button2 //
// // 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.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button2.Location = new System.Drawing.Point(196, 193); this.button2.DialogResult = System.Windows.Forms.DialogResult.OK;
this.button2.Name = "button2"; this.button2.Location = new System.Drawing.Point(196, 193);
this.button2.Size = new System.Drawing.Size(75, 23); this.button2.Name = "button2";
this.button2.TabIndex = 14; this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.Text = "OK"; this.button2.TabIndex = 14;
this.button2.UseVisualStyleBackColor = true; this.button2.Text = "OK";
// this.button2.UseVisualStyleBackColor = true;
// button1 //
// // 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.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button1.Location = new System.Drawing.Point(277, 193); this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button1.Name = "button1"; this.button1.Location = new System.Drawing.Point(277, 193);
this.button1.Size = new System.Drawing.Size(75, 23); this.button1.Name = "button1";
this.button1.TabIndex = 15; this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.Text = "Cancel"; this.button1.TabIndex = 15;
this.button1.UseVisualStyleBackColor = true; this.button1.Text = "Cancel";
// this.button1.UseVisualStyleBackColor = true;
// label1 //
// // label1
this.label1.AutoSize = true; //
this.label1.Location = new System.Drawing.Point(12, 50); this.label1.AutoSize = true;
this.label1.Name = "label1"; this.label1.Location = new System.Drawing.Point(12, 50);
this.label1.Size = new System.Drawing.Size(27, 13); this.label1.Name = "label1";
this.label1.TabIndex = 16; this.label1.Size = new System.Drawing.Size(27, 13);
this.label1.Text = "Title"; this.label1.TabIndex = 16;
// this.label1.Text = "Title";
// title //
// // title
this.title.Location = new System.Drawing.Point(66, 47); //
this.title.Name = "title"; this.title.Location = new System.Drawing.Point(66, 47);
this.title.Size = new System.Drawing.Size(286, 20); this.title.Name = "title";
this.title.TabIndex = 17; this.title.Size = new System.Drawing.Size(286, 20);
// this.title.TabIndex = 17;
// label2 //
// // label2
this.label2.AutoSize = true; //
this.label2.Location = new System.Drawing.Point(12, 76); this.label2.AutoSize = true;
this.label2.Name = "label2"; this.label2.Location = new System.Drawing.Point(12, 76);
this.label2.Size = new System.Drawing.Size(32, 13); this.label2.Name = "label2";
this.label2.TabIndex = 16; this.label2.Size = new System.Drawing.Size(32, 13);
this.label2.Text = "Desc"; this.label2.TabIndex = 16;
// this.label2.Text = "Desc";
// desc //
// // desc
this.desc.Location = new System.Drawing.Point(66, 73); //
this.desc.Name = "desc"; this.desc.Location = new System.Drawing.Point(66, 73);
this.desc.Size = new System.Drawing.Size(286, 20); this.desc.Name = "desc";
this.desc.TabIndex = 17; this.desc.Size = new System.Drawing.Size(286, 20);
// this.desc.TabIndex = 17;
// selectable //
// // selectable
this.selectable.AutoSize = true; //
this.selectable.Location = new System.Drawing.Point(118, 138); this.selectable.AutoSize = true;
this.selectable.Name = "selectable"; this.selectable.Location = new System.Drawing.Point(118, 138);
this.selectable.Size = new System.Drawing.Size(130, 17); this.selectable.Name = "selectable";
this.selectable.TabIndex = 18; this.selectable.Size = new System.Drawing.Size(130, 17);
this.selectable.Text = "Show in Map Chooser"; this.selectable.TabIndex = 18;
this.selectable.UseVisualStyleBackColor = true; this.selectable.Text = "Show in Map Chooser";
// this.selectable.UseVisualStyleBackColor = true;
// label3 //
// // label3
this.label3.AutoSize = true; //
this.label3.Location = new System.Drawing.Point(12, 102); this.label3.AutoSize = true;
this.label3.Name = "label3"; this.label3.Location = new System.Drawing.Point(12, 102);
this.label3.Size = new System.Drawing.Size(38, 13); this.label3.Name = "label3";
this.label3.TabIndex = 16; this.label3.Size = new System.Drawing.Size(38, 13);
this.label3.Text = "Author"; this.label3.TabIndex = 16;
// this.label3.Text = "Author";
// author //
// // author
this.author.Location = new System.Drawing.Point(66, 99); //
this.author.Name = "author"; this.author.Location = new System.Drawing.Point(66, 99);
this.author.Size = new System.Drawing.Size(286, 20); this.author.Name = "author";
this.author.TabIndex = 17; this.author.Size = new System.Drawing.Size(286, 20);
// this.author.TabIndex = 17;
// PropertiesDialog //
// // checkBox1
this.AcceptButton = this.button2; //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.useAsShellmap.AutoSize = true;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.useAsShellmap.Location = new System.Drawing.Point(118, 161);
this.CancelButton = this.button1; this.useAsShellmap.Name = "checkBox1";
this.ClientSize = new System.Drawing.Size(370, 228); this.useAsShellmap.Size = new System.Drawing.Size(105, 17);
this.Controls.Add(this.selectable); this.useAsShellmap.TabIndex = 18;
this.Controls.Add(this.author); this.useAsShellmap.Text = "Use as Shellmap";
this.Controls.Add(this.label3); this.useAsShellmap.UseVisualStyleBackColor = true;
this.Controls.Add(this.desc); //
this.Controls.Add(this.label2); // PropertiesDialog
this.Controls.Add(this.title); //
this.Controls.Add(this.label1); this.AcceptButton = this.button2;
this.Controls.Add(this.button2); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.Controls.Add(this.button1); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.CancelButton = this.button1;
this.Name = "PropertiesDialog"; this.ClientSize = new System.Drawing.Size(370, 228);
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Controls.Add(this.useAsShellmap);
this.Text = "PropertiesDialog"; this.Controls.Add(this.selectable);
this.ResumeLayout(false); this.Controls.Add(this.author);
this.PerformLayout(); 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; 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