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.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;
}
}

View File

@@ -28,119 +28,131 @@
/// </summary>
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;
}
}

View File

@@ -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)

View File

@@ -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";

View File

@@ -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<string,object>(), 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);

View File

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

View File

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

View File

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

View File

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