fix trailing whitespace everywhere

This commit is contained in:
Chris Forbes
2011-09-25 14:37:12 +13:00
parent 0eb98ef3b5
commit 55036cd58c
596 changed files with 3194 additions and 3194 deletions

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -22,7 +22,7 @@ namespace OpenRA.Editor
public void Preview(Surface surface, SGraphics g) public void Preview(Surface surface, SGraphics g)
{ {
/* todo: include the player /* todo: include the player
* in the brush so we can color new buildings too */ * in the brush so we can color new buildings too */
surface.DrawActor(g, surface.GetBrushLocation(), Actor, null); surface.DrawActor(g, surface.GetBrushLocation(), Actor, null);

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -42,9 +42,9 @@ namespace OpenRA.Editor
this.listBox1 = new System.Windows.Forms.ListBox(); this.listBox1 = new System.Windows.Forms.ListBox();
this.button1 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout(); this.SuspendLayout();
// //
// label1 // label1
// //
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.label1.Location = new System.Drawing.Point(10, 9); this.label1.Location = new System.Drawing.Point(10, 9);
@@ -52,9 +52,9 @@ namespace OpenRA.Editor
this.label1.Size = new System.Drawing.Size(610, 23); this.label1.Size = new System.Drawing.Size(610, 23);
this.label1.TabIndex = 0; this.label1.TabIndex = 0;
this.label1.Text = "Your map import completed, but with errors:"; this.label1.Text = "Your map import completed, but with errors:";
// //
// listBox1 // listBox1
// //
this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
@@ -63,9 +63,9 @@ namespace OpenRA.Editor
this.listBox1.Name = "listBox1"; this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(607, 316); this.listBox1.Size = new System.Drawing.Size(607, 316);
this.listBox1.TabIndex = 1; this.listBox1.TabIndex = 1;
// //
// button1 // button1
// //
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 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.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button1.Location = new System.Drawing.Point(545, 359); this.button1.Location = new System.Drawing.Point(545, 359);
@@ -74,9 +74,9 @@ namespace OpenRA.Editor
this.button1.TabIndex = 2; this.button1.TabIndex = 2;
this.button1.Text = "Close"; this.button1.Text = "Close";
this.button1.UseVisualStyleBackColor = true; this.button1.UseVisualStyleBackColor = true;
// //
// ErrorListDialog // ErrorListDialog
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(632, 394); this.ClientSize = new System.Drawing.Size(632, 394);

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -96,44 +96,44 @@ namespace OpenRA.Editor
this.menuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout();
this.statusStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// splitContainer1 // splitContainer1
// //
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.Location = new System.Drawing.Point(0, 0); this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Name = "splitContainer1"; this.splitContainer1.Name = "splitContainer1";
// //
// splitContainer1.Panel1 // splitContainer1.Panel1
// //
this.splitContainer1.Panel1.Controls.Add(this.splitContainer2); this.splitContainer1.Panel1.Controls.Add(this.splitContainer2);
// //
// splitContainer1.Panel2 // splitContainer1.Panel2
// //
this.splitContainer1.Panel2.Controls.Add(this.surface1); this.splitContainer1.Panel2.Controls.Add(this.surface1);
this.splitContainer1.Size = new System.Drawing.Size(985, 744); this.splitContainer1.Size = new System.Drawing.Size(985, 744);
this.splitContainer1.SplitterDistance = 198; this.splitContainer1.SplitterDistance = 198;
this.splitContainer1.TabIndex = 0; this.splitContainer1.TabIndex = 0;
// //
// splitContainer2 // splitContainer2
// //
this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill; this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer2.Location = new System.Drawing.Point(0, 0); this.splitContainer2.Location = new System.Drawing.Point(0, 0);
this.splitContainer2.Name = "splitContainer2"; this.splitContainer2.Name = "splitContainer2";
this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal; this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal;
// //
// splitContainer2.Panel1 // splitContainer2.Panel1
// //
this.splitContainer2.Panel1.Controls.Add(this.pmMiniMap); this.splitContainer2.Panel1.Controls.Add(this.pmMiniMap);
// //
// splitContainer2.Panel2 // splitContainer2.Panel2
// //
this.splitContainer2.Panel2.Controls.Add(this.tabControl1); this.splitContainer2.Panel2.Controls.Add(this.tabControl1);
this.splitContainer2.Size = new System.Drawing.Size(198, 744); this.splitContainer2.Size = new System.Drawing.Size(198, 744);
this.splitContainer2.SplitterDistance = 164; this.splitContainer2.SplitterDistance = 164;
this.splitContainer2.TabIndex = 1; this.splitContainer2.TabIndex = 1;
// //
// pmMiniMap // pmMiniMap
// //
this.pmMiniMap.BackColor = System.Drawing.Color.Black; this.pmMiniMap.BackColor = System.Drawing.Color.Black;
this.pmMiniMap.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.pmMiniMap.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.pmMiniMap.Dock = System.Windows.Forms.DockStyle.Fill; this.pmMiniMap.Dock = System.Windows.Forms.DockStyle.Fill;
@@ -143,9 +143,9 @@ namespace OpenRA.Editor
this.pmMiniMap.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; this.pmMiniMap.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pmMiniMap.TabIndex = 1; this.pmMiniMap.TabIndex = 1;
this.pmMiniMap.TabStop = false; this.pmMiniMap.TabStop = false;
// //
// tabControl1 // tabControl1
// //
this.tabControl1.Controls.Add(this.tabPage1); this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Controls.Add(this.tabPage2); this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Controls.Add(this.tabPage3); this.tabControl1.Controls.Add(this.tabPage3);
@@ -158,9 +158,9 @@ namespace OpenRA.Editor
this.tabControl1.SelectedIndex = 0; this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(198, 576); this.tabControl1.Size = new System.Drawing.Size(198, 576);
this.tabControl1.TabIndex = 0; this.tabControl1.TabIndex = 0;
// //
// tabPage1 // tabPage1
// //
this.tabPage1.Controls.Add(this.tilePalette); this.tabPage1.Controls.Add(this.tilePalette);
this.tabPage1.Location = new System.Drawing.Point(4, 20); this.tabPage1.Location = new System.Drawing.Point(4, 20);
this.tabPage1.Name = "tabPage1"; this.tabPage1.Name = "tabPage1";
@@ -169,9 +169,9 @@ namespace OpenRA.Editor
this.tabPage1.TabIndex = 0; this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "Templates"; this.tabPage1.Text = "Templates";
this.tabPage1.UseVisualStyleBackColor = true; this.tabPage1.UseVisualStyleBackColor = true;
// //
// tilePalette // tilePalette
// //
this.tilePalette.AutoScroll = true; this.tilePalette.AutoScroll = true;
this.tilePalette.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.tilePalette.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.tilePalette.Dock = System.Windows.Forms.DockStyle.Fill; this.tilePalette.Dock = System.Windows.Forms.DockStyle.Fill;
@@ -179,9 +179,9 @@ namespace OpenRA.Editor
this.tilePalette.Name = "tilePalette"; this.tilePalette.Name = "tilePalette";
this.tilePalette.Size = new System.Drawing.Size(184, 546); this.tilePalette.Size = new System.Drawing.Size(184, 546);
this.tilePalette.TabIndex = 1; this.tilePalette.TabIndex = 1;
// //
// tabPage2 // tabPage2
// //
this.tabPage2.Controls.Add(this.actorPalette); this.tabPage2.Controls.Add(this.actorPalette);
this.tabPage2.Location = new System.Drawing.Point(4, 20); this.tabPage2.Location = new System.Drawing.Point(4, 20);
this.tabPage2.Name = "tabPage2"; this.tabPage2.Name = "tabPage2";
@@ -190,9 +190,9 @@ namespace OpenRA.Editor
this.tabPage2.TabIndex = 1; this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "Actors"; this.tabPage2.Text = "Actors";
this.tabPage2.UseVisualStyleBackColor = true; this.tabPage2.UseVisualStyleBackColor = true;
// //
// actorPalette // actorPalette
// //
this.actorPalette.AutoScroll = true; this.actorPalette.AutoScroll = true;
this.actorPalette.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.actorPalette.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.actorPalette.Dock = System.Windows.Forms.DockStyle.Fill; this.actorPalette.Dock = System.Windows.Forms.DockStyle.Fill;
@@ -200,9 +200,9 @@ namespace OpenRA.Editor
this.actorPalette.Name = "actorPalette"; this.actorPalette.Name = "actorPalette";
this.actorPalette.Size = new System.Drawing.Size(184, 546); this.actorPalette.Size = new System.Drawing.Size(184, 546);
this.actorPalette.TabIndex = 2; this.actorPalette.TabIndex = 2;
// //
// tabPage3 // tabPage3
// //
this.tabPage3.Controls.Add(this.resourcePalette); this.tabPage3.Controls.Add(this.resourcePalette);
this.tabPage3.Location = new System.Drawing.Point(4, 20); this.tabPage3.Location = new System.Drawing.Point(4, 20);
this.tabPage3.Name = "tabPage3"; this.tabPage3.Name = "tabPage3";
@@ -210,9 +210,9 @@ namespace OpenRA.Editor
this.tabPage3.TabIndex = 2; this.tabPage3.TabIndex = 2;
this.tabPage3.Text = "Resources"; this.tabPage3.Text = "Resources";
this.tabPage3.UseVisualStyleBackColor = true; this.tabPage3.UseVisualStyleBackColor = true;
// //
// resourcePalette // resourcePalette
// //
this.resourcePalette.AutoScroll = true; this.resourcePalette.AutoScroll = true;
this.resourcePalette.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.resourcePalette.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.resourcePalette.Dock = System.Windows.Forms.DockStyle.Fill; this.resourcePalette.Dock = System.Windows.Forms.DockStyle.Fill;
@@ -220,9 +220,9 @@ namespace OpenRA.Editor
this.resourcePalette.Name = "resourcePalette"; this.resourcePalette.Name = "resourcePalette";
this.resourcePalette.Size = new System.Drawing.Size(190, 552); this.resourcePalette.Size = new System.Drawing.Size(190, 552);
this.resourcePalette.TabIndex = 3; this.resourcePalette.TabIndex = 3;
// //
// surface1 // surface1
// //
this.surface1.BackColor = System.Drawing.Color.Black; this.surface1.BackColor = System.Drawing.Color.Black;
this.surface1.Dock = System.Windows.Forms.DockStyle.Fill; this.surface1.Dock = System.Windows.Forms.DockStyle.Fill;
this.surface1.Location = new System.Drawing.Point(0, 0); this.surface1.Location = new System.Drawing.Point(0, 0);
@@ -230,39 +230,39 @@ namespace OpenRA.Editor
this.surface1.Size = new System.Drawing.Size(783, 744); this.surface1.Size = new System.Drawing.Size(783, 744);
this.surface1.TabIndex = 5; this.surface1.TabIndex = 5;
this.surface1.Text = "surface1"; this.surface1.Text = "surface1";
// //
// tt // tt
// //
this.tt.ShowAlways = true; this.tt.ShowAlways = true;
// //
// saveFileDialog // saveFileDialog
// //
this.saveFileDialog.DefaultExt = "*.png"; this.saveFileDialog.DefaultExt = "*.png";
this.saveFileDialog.Filter = "PNG Image (*.png)|"; this.saveFileDialog.Filter = "PNG Image (*.png)|";
this.saveFileDialog.Title = "Export minimap to PNG"; this.saveFileDialog.Title = "Export minimap to PNG";
// //
// splitContainer3 // splitContainer3
// //
this.splitContainer3.Dock = System.Windows.Forms.DockStyle.Fill; this.splitContainer3.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer3.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; this.splitContainer3.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
this.splitContainer3.IsSplitterFixed = true; this.splitContainer3.IsSplitterFixed = true;
this.splitContainer3.Location = new System.Drawing.Point(0, 0); this.splitContainer3.Location = new System.Drawing.Point(0, 0);
this.splitContainer3.Name = "splitContainer3"; this.splitContainer3.Name = "splitContainer3";
this.splitContainer3.Orientation = System.Windows.Forms.Orientation.Horizontal; this.splitContainer3.Orientation = System.Windows.Forms.Orientation.Horizontal;
// //
// splitContainer3.Panel1 // splitContainer3.Panel1
// //
this.splitContainer3.Panel1.Controls.Add(this.menuStrip1); this.splitContainer3.Panel1.Controls.Add(this.menuStrip1);
// //
// splitContainer3.Panel2 // splitContainer3.Panel2
// //
this.splitContainer3.Panel2.Controls.Add(this.splitContainer1); this.splitContainer3.Panel2.Controls.Add(this.splitContainer1);
this.splitContainer3.Size = new System.Drawing.Size(985, 773); this.splitContainer3.Size = new System.Drawing.Size(985, 773);
this.splitContainer3.SplitterDistance = 25; this.splitContainer3.SplitterDistance = 25;
this.splitContainer3.TabIndex = 6; this.splitContainer3.TabIndex = 6;
// //
// menuStrip1 // menuStrip1
// //
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileToolStripMenuItem, this.fileToolStripMenuItem,
this.mapToolStripMenuItem, this.mapToolStripMenuItem,
@@ -273,9 +273,9 @@ namespace OpenRA.Editor
this.menuStrip1.Size = new System.Drawing.Size(985, 27); this.menuStrip1.Size = new System.Drawing.Size(985, 27);
this.menuStrip1.TabIndex = 1; this.menuStrip1.TabIndex = 1;
this.menuStrip1.Text = "menuStrip1"; this.menuStrip1.Text = "menuStrip1";
// //
// fileToolStripMenuItem // fileToolStripMenuItem
// //
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.newToolStripMenuItem, this.newToolStripMenuItem,
this.toolStripSeparator1, this.toolStripSeparator1,
@@ -290,107 +290,107 @@ namespace OpenRA.Editor
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 23); this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 23);
this.fileToolStripMenuItem.Text = "&File"; this.fileToolStripMenuItem.Text = "&File";
// //
// newToolStripMenuItem // newToolStripMenuItem
// //
this.newToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("newToolStripMenuItem.Image"))); this.newToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("newToolStripMenuItem.Image")));
this.newToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Fuchsia; this.newToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Fuchsia;
this.newToolStripMenuItem.Name = "newToolStripMenuItem"; this.newToolStripMenuItem.Name = "newToolStripMenuItem";
this.newToolStripMenuItem.Size = new System.Drawing.Size(123, 22); this.newToolStripMenuItem.Size = new System.Drawing.Size(123, 22);
this.newToolStripMenuItem.Text = "&New..."; this.newToolStripMenuItem.Text = "&New...";
this.newToolStripMenuItem.Click += new System.EventHandler(this.NewClicked); this.newToolStripMenuItem.Click += new System.EventHandler(this.NewClicked);
// //
// toolStripSeparator1 // toolStripSeparator1
// //
this.toolStripSeparator1.Name = "toolStripSeparator1"; this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(120, 6); this.toolStripSeparator1.Size = new System.Drawing.Size(120, 6);
// //
// openToolStripMenuItem // openToolStripMenuItem
// //
this.openToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("openToolStripMenuItem.Image"))); this.openToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("openToolStripMenuItem.Image")));
this.openToolStripMenuItem.Name = "openToolStripMenuItem"; this.openToolStripMenuItem.Name = "openToolStripMenuItem";
this.openToolStripMenuItem.Size = new System.Drawing.Size(123, 22); this.openToolStripMenuItem.Size = new System.Drawing.Size(123, 22);
this.openToolStripMenuItem.Text = "&Open..."; this.openToolStripMenuItem.Text = "&Open...";
this.openToolStripMenuItem.Click += new System.EventHandler(this.OpenClicked); this.openToolStripMenuItem.Click += new System.EventHandler(this.OpenClicked);
// //
// saveToolStripMenuItem // saveToolStripMenuItem
// //
this.saveToolStripMenuItem.Enabled = false; this.saveToolStripMenuItem.Enabled = false;
this.saveToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("saveToolStripMenuItem.Image"))); this.saveToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("saveToolStripMenuItem.Image")));
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
this.saveToolStripMenuItem.Size = new System.Drawing.Size(123, 22); this.saveToolStripMenuItem.Size = new System.Drawing.Size(123, 22);
this.saveToolStripMenuItem.Text = "&Save"; this.saveToolStripMenuItem.Text = "&Save";
this.saveToolStripMenuItem.Click += new System.EventHandler(this.SaveClicked); this.saveToolStripMenuItem.Click += new System.EventHandler(this.SaveClicked);
// //
// saveAsToolStripMenuItem // saveAsToolStripMenuItem
// //
this.saveAsToolStripMenuItem.Enabled = false; this.saveAsToolStripMenuItem.Enabled = false;
this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem"; this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem";
this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(123, 22); this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(123, 22);
this.saveAsToolStripMenuItem.Text = "Save &As..."; this.saveAsToolStripMenuItem.Text = "Save &As...";
this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.SaveAsClicked); this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.SaveAsClicked);
// //
// toolStripSeparator2 // toolStripSeparator2
// //
this.toolStripSeparator2.Name = "toolStripSeparator2"; this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(120, 6); this.toolStripSeparator2.Size = new System.Drawing.Size(120, 6);
// //
// toolStripMenuItem1 // toolStripMenuItem1
// //
this.toolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.cCRedAlertMapToolStripMenuItem, this.cCRedAlertMapToolStripMenuItem,
this.bitmapToolStripMenuItem}); this.bitmapToolStripMenuItem});
this.toolStripMenuItem1.Name = "toolStripMenuItem1"; this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(123, 22); this.toolStripMenuItem1.Size = new System.Drawing.Size(123, 22);
this.toolStripMenuItem1.Text = "&Import"; this.toolStripMenuItem1.Text = "&Import";
// //
// cCRedAlertMapToolStripMenuItem // cCRedAlertMapToolStripMenuItem
// //
this.cCRedAlertMapToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("cCRedAlertMapToolStripMenuItem.Image"))); this.cCRedAlertMapToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("cCRedAlertMapToolStripMenuItem.Image")));
this.cCRedAlertMapToolStripMenuItem.Name = "cCRedAlertMapToolStripMenuItem"; this.cCRedAlertMapToolStripMenuItem.Name = "cCRedAlertMapToolStripMenuItem";
this.cCRedAlertMapToolStripMenuItem.Size = new System.Drawing.Size(195, 22); this.cCRedAlertMapToolStripMenuItem.Size = new System.Drawing.Size(195, 22);
this.cCRedAlertMapToolStripMenuItem.Text = "&C&&C / Red Alert Map..."; this.cCRedAlertMapToolStripMenuItem.Text = "&C&&C / Red Alert Map...";
this.cCRedAlertMapToolStripMenuItem.Click += new System.EventHandler(this.ImportLegacyMapClicked); this.cCRedAlertMapToolStripMenuItem.Click += new System.EventHandler(this.ImportLegacyMapClicked);
// //
// bitmapToolStripMenuItem // bitmapToolStripMenuItem
// //
this.bitmapToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("bitmapToolStripMenuItem.Image"))); this.bitmapToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("bitmapToolStripMenuItem.Image")));
this.bitmapToolStripMenuItem.Name = "bitmapToolStripMenuItem"; this.bitmapToolStripMenuItem.Name = "bitmapToolStripMenuItem";
this.bitmapToolStripMenuItem.Size = new System.Drawing.Size(195, 22); this.bitmapToolStripMenuItem.Size = new System.Drawing.Size(195, 22);
this.bitmapToolStripMenuItem.Text = "&Bitmap..."; this.bitmapToolStripMenuItem.Text = "&Bitmap...";
this.bitmapToolStripMenuItem.Visible = false; this.bitmapToolStripMenuItem.Visible = false;
// //
// mnuExport // mnuExport
// //
this.mnuExport.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.mnuExport.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.mnuMinimapToPNG}); this.mnuMinimapToPNG});
this.mnuExport.Name = "mnuExport"; this.mnuExport.Name = "mnuExport";
this.mnuExport.Size = new System.Drawing.Size(123, 22); this.mnuExport.Size = new System.Drawing.Size(123, 22);
this.mnuExport.Text = "&Export"; this.mnuExport.Text = "&Export";
// //
// mnuMinimapToPNG // mnuMinimapToPNG
// //
this.mnuMinimapToPNG.Enabled = false; this.mnuMinimapToPNG.Enabled = false;
this.mnuMinimapToPNG.Image = ((System.Drawing.Image)(resources.GetObject("mnuMinimapToPNG.Image"))); this.mnuMinimapToPNG.Image = ((System.Drawing.Image)(resources.GetObject("mnuMinimapToPNG.Image")));
this.mnuMinimapToPNG.Name = "mnuMinimapToPNG"; this.mnuMinimapToPNG.Name = "mnuMinimapToPNG";
this.mnuMinimapToPNG.Size = new System.Drawing.Size(163, 22); this.mnuMinimapToPNG.Size = new System.Drawing.Size(163, 22);
this.mnuMinimapToPNG.Text = "Minimap to PNG"; this.mnuMinimapToPNG.Text = "Minimap to PNG";
this.mnuMinimapToPNG.Click += new System.EventHandler(this.ExportMinimap); this.mnuMinimapToPNG.Click += new System.EventHandler(this.ExportMinimap);
// //
// toolStripSeparator3 // toolStripSeparator3
// //
this.toolStripSeparator3.Name = "toolStripSeparator3"; this.toolStripSeparator3.Name = "toolStripSeparator3";
this.toolStripSeparator3.Size = new System.Drawing.Size(120, 6); this.toolStripSeparator3.Size = new System.Drawing.Size(120, 6);
// //
// exitToolStripMenuItem // exitToolStripMenuItem
// //
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
this.exitToolStripMenuItem.Size = new System.Drawing.Size(123, 22); this.exitToolStripMenuItem.Size = new System.Drawing.Size(123, 22);
this.exitToolStripMenuItem.Text = "E&xit"; this.exitToolStripMenuItem.Text = "E&xit";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.CloseClicked); this.exitToolStripMenuItem.Click += new System.EventHandler(this.CloseClicked);
// //
// mapToolStripMenuItem // mapToolStripMenuItem
// //
this.mapToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.mapToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.propertiesToolStripMenuItem, this.propertiesToolStripMenuItem,
this.resizeToolStripMenuItem, this.resizeToolStripMenuItem,
@@ -399,48 +399,48 @@ namespace OpenRA.Editor
this.mapToolStripMenuItem.Name = "mapToolStripMenuItem"; this.mapToolStripMenuItem.Name = "mapToolStripMenuItem";
this.mapToolStripMenuItem.Size = new System.Drawing.Size(43, 23); this.mapToolStripMenuItem.Size = new System.Drawing.Size(43, 23);
this.mapToolStripMenuItem.Text = "&Map"; this.mapToolStripMenuItem.Text = "&Map";
// //
// propertiesToolStripMenuItem // propertiesToolStripMenuItem
// //
this.propertiesToolStripMenuItem.Enabled = false; this.propertiesToolStripMenuItem.Enabled = false;
this.propertiesToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("propertiesToolStripMenuItem.Image"))); this.propertiesToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("propertiesToolStripMenuItem.Image")));
this.propertiesToolStripMenuItem.Name = "propertiesToolStripMenuItem"; this.propertiesToolStripMenuItem.Name = "propertiesToolStripMenuItem";
this.propertiesToolStripMenuItem.Size = new System.Drawing.Size(175, 22); this.propertiesToolStripMenuItem.Size = new System.Drawing.Size(175, 22);
this.propertiesToolStripMenuItem.Text = "&Properties..."; this.propertiesToolStripMenuItem.Text = "&Properties...";
this.propertiesToolStripMenuItem.Click += new System.EventHandler(this.PropertiesClicked); this.propertiesToolStripMenuItem.Click += new System.EventHandler(this.PropertiesClicked);
// //
// resizeToolStripMenuItem // resizeToolStripMenuItem
// //
this.resizeToolStripMenuItem.Enabled = false; this.resizeToolStripMenuItem.Enabled = false;
this.resizeToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("resizeToolStripMenuItem.Image"))); this.resizeToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("resizeToolStripMenuItem.Image")));
this.resizeToolStripMenuItem.Name = "resizeToolStripMenuItem"; this.resizeToolStripMenuItem.Name = "resizeToolStripMenuItem";
this.resizeToolStripMenuItem.Size = new System.Drawing.Size(175, 22); this.resizeToolStripMenuItem.Size = new System.Drawing.Size(175, 22);
this.resizeToolStripMenuItem.Text = "&Resize..."; this.resizeToolStripMenuItem.Text = "&Resize...";
this.resizeToolStripMenuItem.Click += new System.EventHandler(this.ResizeClicked); this.resizeToolStripMenuItem.Click += new System.EventHandler(this.ResizeClicked);
// //
// showActorNamesToolStripMenuItem // showActorNamesToolStripMenuItem
// //
this.showActorNamesToolStripMenuItem.Name = "showActorNamesToolStripMenuItem"; this.showActorNamesToolStripMenuItem.Name = "showActorNamesToolStripMenuItem";
this.showActorNamesToolStripMenuItem.Size = new System.Drawing.Size(175, 22); this.showActorNamesToolStripMenuItem.Size = new System.Drawing.Size(175, 22);
this.showActorNamesToolStripMenuItem.Text = "Show Actor &Names"; this.showActorNamesToolStripMenuItem.Text = "Show Actor &Names";
this.showActorNamesToolStripMenuItem.Click += new System.EventHandler(this.ShowActorNamesClicked); this.showActorNamesToolStripMenuItem.Click += new System.EventHandler(this.ShowActorNamesClicked);
// //
// toolStripComboBox1 // toolStripComboBox1
// //
this.toolStripComboBox1.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; this.toolStripComboBox1.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
this.toolStripComboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.toolStripComboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.toolStripComboBox1.Name = "toolStripComboBox1"; this.toolStripComboBox1.Name = "toolStripComboBox1";
this.toolStripComboBox1.Size = new System.Drawing.Size(121, 23); this.toolStripComboBox1.Size = new System.Drawing.Size(121, 23);
// //
// toolStripLabel1 // toolStripLabel1
// //
this.toolStripLabel1.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; this.toolStripLabel1.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
this.toolStripLabel1.Name = "toolStripLabel1"; this.toolStripLabel1.Name = "toolStripLabel1";
this.toolStripLabel1.Size = new System.Drawing.Size(71, 20); this.toolStripLabel1.Size = new System.Drawing.Size(71, 20);
this.toolStripLabel1.Text = "Active Mod:"; this.toolStripLabel1.Text = "Active Mod:";
// //
// statusStrip1 // statusStrip1
// //
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabelFiller, this.toolStripStatusLabelFiller,
this.toolStripStatusLabelMousePosition}); this.toolStripStatusLabelMousePosition});
@@ -449,29 +449,29 @@ namespace OpenRA.Editor
this.statusStrip1.Size = new System.Drawing.Size(985, 22); this.statusStrip1.Size = new System.Drawing.Size(985, 22);
this.statusStrip1.TabIndex = 7; this.statusStrip1.TabIndex = 7;
this.statusStrip1.Text = "statusStrip1"; this.statusStrip1.Text = "statusStrip1";
// //
// toolStripStatusLabelFiller // toolStripStatusLabelFiller
// //
this.toolStripStatusLabelFiller.Name = "toolStripStatusLabelFiller"; this.toolStripStatusLabelFiller.Name = "toolStripStatusLabelFiller";
this.toolStripStatusLabelFiller.Size = new System.Drawing.Size(948, 17); this.toolStripStatusLabelFiller.Size = new System.Drawing.Size(948, 17);
this.toolStripStatusLabelFiller.Spring = true; this.toolStripStatusLabelFiller.Spring = true;
// //
// toolStripStatusLabelMousePosition // toolStripStatusLabelMousePosition
// //
this.toolStripStatusLabelMousePosition.Name = "toolStripStatusLabelMousePosition"; this.toolStripStatusLabelMousePosition.Name = "toolStripStatusLabelMousePosition";
this.toolStripStatusLabelMousePosition.RightToLeft = System.Windows.Forms.RightToLeft.Yes; this.toolStripStatusLabelMousePosition.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
this.toolStripStatusLabelMousePosition.Size = new System.Drawing.Size(22, 17); this.toolStripStatusLabelMousePosition.Size = new System.Drawing.Size(22, 17);
this.toolStripStatusLabelMousePosition.Text = "0,0"; this.toolStripStatusLabelMousePosition.Text = "0,0";
// //
// fixOpenAreasToolStripMenuItem // fixOpenAreasToolStripMenuItem
// //
this.fixOpenAreasToolStripMenuItem.Name = "fixOpenAreasToolStripMenuItem"; this.fixOpenAreasToolStripMenuItem.Name = "fixOpenAreasToolStripMenuItem";
this.fixOpenAreasToolStripMenuItem.Size = new System.Drawing.Size(175, 22); this.fixOpenAreasToolStripMenuItem.Size = new System.Drawing.Size(175, 22);
this.fixOpenAreasToolStripMenuItem.Text = "&Fix Open Areas"; this.fixOpenAreasToolStripMenuItem.Text = "&Fix Open Areas";
this.fixOpenAreasToolStripMenuItem.Click += new System.EventHandler(this.FixOpenAreas); this.fixOpenAreasToolStripMenuItem.Click += new System.EventHandler(this.FixOpenAreas);
// //
// Form1 // Form1
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(985, 773); this.ClientSize = new System.Drawing.Size(985, 773);

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -29,8 +29,8 @@ namespace OpenRA.Editor
currentMod = args.FirstOrDefault() ?? "ra"; currentMod = args.FirstOrDefault() ?? "ra";
toolStripComboBox1.Items.AddRange(Mod.AllMods.Keys.ToArray()); toolStripComboBox1.Items.AddRange(Mod.AllMods.Keys.ToArray());
toolStripComboBox1.SelectedIndexChanged += (_, e) => toolStripComboBox1.SelectedIndexChanged += (_, e) =>
{ {
tilePalette.SuspendLayout(); tilePalette.SuspendLayout();
actorPalette.SuspendLayout(); actorPalette.SuspendLayout();
@@ -44,19 +44,19 @@ namespace OpenRA.Editor
surface1.Bind(null, null, null); surface1.Bind(null, null, null);
pmMiniMap.Image = null; pmMiniMap.Image = null;
currentMod = toolStripComboBox1.SelectedItem as string; currentMod = toolStripComboBox1.SelectedItem as string;
Text = "OpenRA Editor (mod:{0})".F(currentMod); Text = "OpenRA Editor (mod:{0})".F(currentMod);
Game.modData = new ModData(currentMod); Game.modData = new ModData(currentMod);
FileSystem.LoadFromManifest(Game.modData.Manifest); FileSystem.LoadFromManifest(Game.modData.Manifest);
Rules.LoadRules(Game.modData.Manifest, new Map()); Rules.LoadRules(Game.modData.Manifest, new Map());
loadedMapName = null; loadedMapName = null;
}; };
toolStripComboBox1.SelectedItem = currentMod; toolStripComboBox1.SelectedItem = currentMod;
surface1.AfterChange += OnMapChanged; surface1.AfterChange += OnMapChanged;
surface1.MousePositionChanged += s => toolStripStatusLabelMousePosition.Text = s; surface1.MousePositionChanged += s => toolStripStatusLabelMousePosition.Text = s;
if (args.Length >= 2) if (args.Length >= 2)
LoadMap(args[1]); LoadMap(args[1]);
} }
@@ -366,7 +366,7 @@ namespace OpenRA.Editor
void ImportLegacyMapClicked(object sender, EventArgs e) void ImportLegacyMapClicked(object sender, EventArgs e)
{ {
using (var ofd = new OpenFileDialog { RestoreDirectory = true, using (var ofd = new OpenFileDialog { RestoreDirectory = true,
Filter = "Legacy maps (*.ini;*.mpr)|*.ini;*.mpr" }) Filter = "Legacy maps (*.ini;*.mpr)|*.ini;*.mpr" })
if (DialogResult.OK == ofd.ShowDialog()) if (DialogResult.OK == ofd.ShowDialog())
{ {
@@ -385,7 +385,7 @@ namespace OpenRA.Editor
eld.ShowDialog(); eld.ShowDialog();
map.MakeDefaultPlayers(); map.MakeDefaultPlayers();
map.Save(savePath); map.Save(savePath);
LoadMap(savePath); LoadMap(savePath);
loadedMapName = null; /* editor needs to think this hasnt been saved */ loadedMapName = null; /* editor needs to think this hasnt been saved */
@@ -433,7 +433,7 @@ namespace OpenRA.Editor
{ {
var tr = surface1.Map.MapTiles.Value[i, j]; var tr = surface1.Map.MapTiles.Value[i, j];
if (tr.type == 0xff || tr.type == 0xffff || tr.type == 1 || tr.type == 2) if (tr.type == 0xff || tr.type == 0xffff || tr.type == 1 || tr.type == 2)
tr.index = (byte)r.Next(0, tr.index = (byte)r.Next(0,
Rules.TileSets[surface1.Map.Tileset].Tiles[tr.type].TileBitmapBytes.Count); Rules.TileSets[surface1.Map.Tileset].Tiles[tr.type].TileBitmapBytes.Count);
surface1.Map.MapTiles.Value[i, j] = tr; surface1.Map.MapTiles.Value[i, j] = tr;

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -39,12 +39,12 @@ namespace OpenRA.Editor
{ "gold02", new Pair<byte,byte>(1,1) }, { "gold02", new Pair<byte,byte>(1,1) },
{ "gold03", new Pair<byte,byte>(1,2) }, { "gold03", new Pair<byte,byte>(1,2) },
{ "gold04", new Pair<byte,byte>(1,3) }, { "gold04", new Pair<byte,byte>(1,3) },
{ "gem01", new Pair<byte,byte>(2,0) }, { "gem01", new Pair<byte,byte>(2,0) },
{ "gem02", new Pair<byte,byte>(2,1) }, { "gem02", new Pair<byte,byte>(2,1) },
{ "gem03", new Pair<byte,byte>(2,2) }, { "gem03", new Pair<byte,byte>(2,2) },
{ "gem04", new Pair<byte,byte>(2,3) }, { "gem04", new Pair<byte,byte>(2,3) },
// cnc tiberium // cnc tiberium
{ "ti1", new Pair<byte,byte>(1,0) }, { "ti1", new Pair<byte,byte>(1,0) },
{ "ti2", new Pair<byte,byte>(1,1) }, { "ti2", new Pair<byte,byte>(1,1) },
@@ -67,7 +67,7 @@ namespace OpenRA.Editor
{"brik","brik"}, {"brik","brik"},
{"fenc","fenc"}, {"fenc","fenc"},
{"wood","wood"}, {"wood","wood"},
// Fields // Fields
{"v12","v12"}, {"v12","v12"},
{"v13","v13"}, {"v13","v13"},
@@ -76,12 +76,12 @@ namespace OpenRA.Editor
{"v16","v16"}, {"v16","v16"},
{"v17","v17"}, {"v17","v17"},
{"v18","v18"}, {"v18","v18"},
// Crates // Crates
// {"wcrate","crate"}, // {"wcrate","crate"},
// {"scrate","crate"}, // {"scrate","crate"},
}; };
// todo: fix this -- will have bitrotted pretty badly. // todo: fix this -- will have bitrotted pretty badly.
static Dictionary<string,Pair<Color,Color>> namedColorMapping = new Dictionary<string, Pair<Color, Color>>() static Dictionary<string,Pair<Color,Color>> namedColorMapping = new Dictionary<string, Pair<Color, Color>>()
{ {
@@ -96,13 +96,13 @@ namespace OpenRA.Editor
{"white",Pair.New(Color.FromArgb(255,255,255),Color.FromArgb(75,75,75))}, {"white",Pair.New(Color.FromArgb(255,255,255),Color.FromArgb(75,75,75))},
{"black",Pair.New(Color.FromArgb(80,80,80),Color.FromArgb(5,5,5))}, {"black",Pair.New(Color.FromArgb(80,80,80),Color.FromArgb(5,5,5))},
}; };
int MapSize; int MapSize;
int ActorCount = 0; int ActorCount = 0;
Map Map = new Map(); Map Map = new Map();
List<string> Players = new List<string>(); List<string> Players = new List<string>();
Action<string> errorHandler; Action<string> errorHandler;
LegacyMapImporter(string filename, Action<string> errorHandler) LegacyMapImporter(string filename, Action<string> errorHandler)
{ {
this.errorHandler = errorHandler; this.errorHandler = errorHandler;
@@ -116,10 +116,10 @@ namespace OpenRA.Editor
} }
enum IniMapFormat { RedAlert = 3, /* otherwise, cnc (2 variants exist, we don't care to differentiate) */ }; enum IniMapFormat { RedAlert = 3, /* otherwise, cnc (2 variants exist, we don't care to differentiate) */ };
public void ConvertIniMap(string iniFile) public void ConvertIniMap(string iniFile)
{ {
var file = new IniFile(FileSystem.Open(iniFile)); var file = new IniFile(FileSystem.Open(iniFile));
var basic = file.GetSection("Basic"); var basic = file.GetSection("Basic");
var map = file.GetSection("Map"); var map = file.GetSection("Map");
@@ -137,12 +137,12 @@ namespace OpenRA.Editor
Map.MapSize.Y = MapSize; Map.MapSize.Y = MapSize;
Map.Bounds = Rectangle.FromLTRB(XOffset, YOffset, XOffset + Width, YOffset + Height); Map.Bounds = Rectangle.FromLTRB(XOffset, YOffset, XOffset + Width, YOffset + Height);
Map.Selectable = true; Map.Selectable = true;
Map.Smudges = Lazy.New(() => new List<SmudgeReference>()); Map.Smudges = Lazy.New(() => new List<SmudgeReference>());
Map.Actors = Lazy.New(() => new Dictionary<string, ActorReference>()); Map.Actors = Lazy.New(() => new Dictionary<string, ActorReference>());
Map.MapResources = Lazy.New(() => new TileReference<byte, byte>[MapSize, MapSize]); Map.MapResources = Lazy.New(() => new TileReference<byte, byte>[MapSize, MapSize]);
Map.MapTiles = Lazy.New(() => new TileReference<ushort, byte>[MapSize, MapSize]); Map.MapTiles = Lazy.New(() => new TileReference<ushort, byte>[MapSize, MapSize]);
if (legacyMapFormat == IniMapFormat.RedAlert) if (legacyMapFormat == IniMapFormat.RedAlert)
{ {
UnpackRATileData(ReadPackedSection(file.GetSection("MapPack"))); UnpackRATileData(ReadPackedSection(file.GetSection("MapPack")));
@@ -155,22 +155,22 @@ namespace OpenRA.Editor
ReadCncOverlay(file); ReadCncOverlay(file);
ReadCncTrees(file); ReadCncTrees(file);
} }
LoadActors(file, "STRUCTURES"); LoadActors(file, "STRUCTURES");
LoadActors(file, "UNITS"); LoadActors(file, "UNITS");
LoadActors(file, "INFANTRY"); LoadActors(file, "INFANTRY");
LoadSmudges(file, "SMUDGE"); LoadSmudges(file, "SMUDGE");
foreach (var p in Players) foreach (var p in Players)
LoadPlayer(file, p, (legacyMapFormat == IniMapFormat.RedAlert)); LoadPlayer(file, p, (legacyMapFormat == IniMapFormat.RedAlert));
var wps = file.GetSection("Waypoints") var wps = file.GetSection("Waypoints")
.Where(kv => int.Parse(kv.Value) > 0) .Where(kv => int.Parse(kv.Value) > 0)
.Select(kv => Pair.New(int.Parse(kv.Key), .Select(kv => Pair.New(int.Parse(kv.Key),
LocationFromMapOffset(int.Parse(kv.Value), MapSize))) LocationFromMapOffset(int.Parse(kv.Value), MapSize)))
.ToArray(); .ToArray();
// Add waypoint actors // Add waypoint actors
foreach( var kv in wps ) foreach( var kv in wps )
{ {
@@ -179,7 +179,7 @@ namespace OpenRA.Editor
a.Add(new OwnerInit("Neutral")); a.Add(new OwnerInit("Neutral"));
Map.Actors.Value.Add("spawn" + kv.First, a); Map.Actors.Value.Add("spawn" + kv.First, a);
} }
} }
static int2 LocationFromMapOffset(int offset, int mapSize) static int2 LocationFromMapOffset(int offset, int mapSize)
@@ -243,7 +243,7 @@ namespace OpenRA.Editor
return ret; return ret;
} }
void UnpackRATileData(MemoryStream ms) void UnpackRATileData(MemoryStream ms)
{ {
for (int i = 0; i < MapSize; i++) for (int i = 0; i < MapSize; i++)
@@ -274,10 +274,10 @@ namespace OpenRA.Editor
if (o != 255 && overlayActorMapping.ContainsKey(raOverlayNames[o])) if (o != 255 && overlayActorMapping.ContainsKey(raOverlayNames[o]))
Map.Actors.Value.Add("Actor" + ActorCount++, Map.Actors.Value.Add("Actor" + ActorCount++,
new ActorReference(overlayActorMapping[raOverlayNames[o]]) new ActorReference(overlayActorMapping[raOverlayNames[o]])
{ {
new LocationInit( new int2(i, j) ), new LocationInit( new int2(i, j) ),
new OwnerInit( "Neutral" ) new OwnerInit( "Neutral" )
}); });
} }
} }
@@ -291,7 +291,7 @@ namespace OpenRA.Editor
foreach (KeyValuePair<string, string> kv in terrain) foreach (KeyValuePair<string, string> kv in terrain)
{ {
var loc = int.Parse(kv.Key); var loc = int.Parse(kv.Key);
Map.Actors.Value.Add("Actor" + ActorCount++, Map.Actors.Value.Add("Actor" + ActorCount++,
new ActorReference(kv.Value.ToLowerInvariant()) new ActorReference(kv.Value.ToLowerInvariant())
{ {
new LocationInit(new int2(loc % MapSize, loc / MapSize)), new LocationInit(new int2(loc % MapSize, loc / MapSize)),
@@ -313,7 +313,7 @@ namespace OpenRA.Editor
Map.MapTiles.Value[i, j].index = ReadByte(ms); Map.MapTiles.Value[i, j].index = ReadByte(ms);
} }
} }
void ReadCncOverlay(IniFile file) void ReadCncOverlay(IniFile file)
{ {
IniSection overlay = file.GetSection("OVERLAY", true); IniSection overlay = file.GetSection("OVERLAY", true);
@@ -332,7 +332,7 @@ namespace OpenRA.Editor
Map.MapResources.Value[cell.X, cell.Y] = new TileReference<byte, byte>(res.First, res.Second); Map.MapResources.Value[cell.X, cell.Y] = new TileReference<byte, byte>(res.First, res.Second);
if (overlayActorMapping.ContainsKey(kv.Value.ToLower())) if (overlayActorMapping.ContainsKey(kv.Value.ToLower()))
Map.Actors.Value.Add("Actor" + ActorCount++, Map.Actors.Value.Add("Actor" + ActorCount++,
new ActorReference(overlayActorMapping[kv.Value.ToLower()]) new ActorReference(overlayActorMapping[kv.Value.ToLower()])
{ {
new LocationInit(cell), new LocationInit(cell),
@@ -340,7 +340,7 @@ namespace OpenRA.Editor
}); });
} }
} }
void ReadCncTrees(IniFile file) void ReadCncTrees(IniFile file)
{ {
IniSection terrain = file.GetSection("TERRAIN", true); IniSection terrain = file.GetSection("TERRAIN", true);
@@ -401,7 +401,7 @@ namespace OpenRA.Editor
} }
} }
} }
void LoadSmudges(IniFile file, string section) void LoadSmudges(IniFile file, string section)
{ {
foreach (var s in file.GetSection(section, true)) foreach (var s in file.GetSection(section, true))
@@ -412,14 +412,14 @@ namespace OpenRA.Editor
Map.Smudges.Value.Add(new SmudgeReference(parts[0].ToLowerInvariant(), new int2(loc % MapSize, loc / MapSize), int.Parse(parts[2]))); Map.Smudges.Value.Add(new SmudgeReference(parts[0].ToLowerInvariant(), new int2(loc % MapSize, loc / MapSize), int.Parse(parts[2])));
} }
} }
void LoadPlayer(IniFile file, string section, bool isRA) void LoadPlayer(IniFile file, string section, bool isRA)
{ {
var c = section == "BadGuy" ? "red" : var c = section == "BadGuy" ? "red" :
isRA ? "blue" : "gold"; isRA ? "blue" : "gold";
var color = namedColorMapping[c]; var color = namedColorMapping[c];
var pr = new PlayerReference var pr = new PlayerReference
{ {
Name = section, Name = section,
@@ -432,7 +432,7 @@ namespace OpenRA.Editor
(byte)(color.First.GetBrightness() * 255), (byte)(color.First.GetBrightness() * 255),
(byte)(color.Second.GetBrightness() * 255)) (byte)(color.Second.GetBrightness() * 255))
}; };
var Neutral = new [] {"Neutral"}; var Neutral = new [] {"Neutral"};
foreach (var s in file.GetSection(section, true)) foreach (var s in file.GetSection(section, true))
{ {
@@ -448,7 +448,7 @@ namespace OpenRA.Editor
break; break;
} }
} }
Map.Players.Add(section, pr); Map.Players.Add(section, pr);
} }

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -70,9 +70,9 @@ namespace OpenRA.Editor
this.splitContainer1.SuspendLayout(); this.splitContainer1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// MapList // MapList
// //
this.MapList.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.MapList.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.MapList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.MapList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.colMapName}); this.colMapName});
@@ -89,20 +89,20 @@ namespace OpenRA.Editor
this.MapList.UseCompatibleStateImageBehavior = false; this.MapList.UseCompatibleStateImageBehavior = false;
this.MapList.View = System.Windows.Forms.View.Details; this.MapList.View = System.Windows.Forms.View.Details;
this.MapList.SelectedIndexChanged += new System.EventHandler(this.MapList_SelectedIndexChanged); this.MapList.SelectedIndexChanged += new System.EventHandler(this.MapList_SelectedIndexChanged);
// //
// colMapName // colMapName
// //
this.colMapName.Text = "Map name"; this.colMapName.Text = "Map name";
this.colMapName.Width = 240; this.colMapName.Width = 240;
// //
// MapIconsList // MapIconsList
// //
this.MapIconsList.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit; this.MapIconsList.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
this.MapIconsList.ImageSize = new System.Drawing.Size(24, 24); this.MapIconsList.ImageSize = new System.Drawing.Size(24, 24);
this.MapIconsList.TransparentColor = System.Drawing.Color.Transparent; this.MapIconsList.TransparentColor = System.Drawing.Color.Transparent;
// //
// btnCancel // btnCancel
// //
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(407, 35); this.btnCancel.Location = new System.Drawing.Point(407, 35);
this.btnCancel.Name = "btnCancel"; this.btnCancel.Name = "btnCancel";
@@ -110,9 +110,9 @@ namespace OpenRA.Editor
this.btnCancel.TabIndex = 3; this.btnCancel.TabIndex = 3;
this.btnCancel.Text = "Cancel"; this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true; this.btnCancel.UseVisualStyleBackColor = true;
// //
// btnOk // btnOk
// //
this.btnOk.DialogResult = System.Windows.Forms.DialogResult.OK; this.btnOk.DialogResult = System.Windows.Forms.DialogResult.OK;
this.btnOk.Location = new System.Drawing.Point(326, 35); this.btnOk.Location = new System.Drawing.Point(326, 35);
this.btnOk.Name = "btnOk"; this.btnOk.Name = "btnOk";
@@ -120,9 +120,9 @@ namespace OpenRA.Editor
this.btnOk.TabIndex = 2; this.btnOk.TabIndex = 2;
this.btnOk.Text = "Open"; this.btnOk.Text = "Open";
this.btnOk.UseVisualStyleBackColor = true; this.btnOk.UseVisualStyleBackColor = true;
// //
// lblNew // lblNew
// //
this.lblNew.AutoSize = true; this.lblNew.AutoSize = true;
this.lblNew.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); this.lblNew.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.lblNew.Location = new System.Drawing.Point(12, 40); this.lblNew.Location = new System.Drawing.Point(12, 40);
@@ -130,18 +130,18 @@ namespace OpenRA.Editor
this.lblNew.Size = new System.Drawing.Size(69, 13); this.lblNew.Size = new System.Drawing.Size(69, 13);
this.lblNew.TabIndex = 3; this.lblNew.TabIndex = 3;
this.lblNew.Text = "Map name:"; this.lblNew.Text = "Map name:";
// //
// txtNew // txtNew
// //
this.txtNew.BackColor = System.Drawing.SystemColors.Window; this.txtNew.BackColor = System.Drawing.SystemColors.Window;
this.txtNew.Location = new System.Drawing.Point(88, 37); this.txtNew.Location = new System.Drawing.Point(88, 37);
this.txtNew.Name = "txtNew"; this.txtNew.Name = "txtNew";
this.txtNew.ReadOnly = true; this.txtNew.ReadOnly = true;
this.txtNew.Size = new System.Drawing.Size(232, 20); this.txtNew.Size = new System.Drawing.Size(232, 20);
this.txtNew.TabIndex = 1; this.txtNew.TabIndex = 1;
// //
// pbMinimap // pbMinimap
// //
this.pbMinimap.BackColor = System.Drawing.Color.Black; this.pbMinimap.BackColor = System.Drawing.Color.Black;
this.pbMinimap.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.pbMinimap.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.pbMinimap.Location = new System.Drawing.Point(32, 25); this.pbMinimap.Location = new System.Drawing.Point(32, 25);
@@ -150,9 +150,9 @@ namespace OpenRA.Editor
this.pbMinimap.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; this.pbMinimap.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pbMinimap.TabIndex = 5; this.pbMinimap.TabIndex = 5;
this.pbMinimap.TabStop = false; this.pbMinimap.TabStop = false;
// //
// pnlBottom // pnlBottom
// //
this.pnlBottom.Controls.Add(this.pictureBox1); this.pnlBottom.Controls.Add(this.pictureBox1);
this.pnlBottom.Controls.Add(this.txtPathOut); this.pnlBottom.Controls.Add(this.txtPathOut);
this.pnlBottom.Controls.Add(this.lblPathOut); this.pnlBottom.Controls.Add(this.lblPathOut);
@@ -167,9 +167,9 @@ namespace OpenRA.Editor
this.pnlBottom.Name = "pnlBottom"; this.pnlBottom.Name = "pnlBottom";
this.pnlBottom.Size = new System.Drawing.Size(494, 70); this.pnlBottom.Size = new System.Drawing.Size(494, 70);
this.pnlBottom.TabIndex = 6; this.pnlBottom.TabIndex = 6;
// //
// txtPathOut // txtPathOut
// //
this.txtPathOut.BackColor = System.Drawing.SystemColors.Window; this.txtPathOut.BackColor = System.Drawing.SystemColors.Window;
this.txtPathOut.Location = new System.Drawing.Point(55, 10); this.txtPathOut.Location = new System.Drawing.Point(55, 10);
this.txtPathOut.Name = "txtPathOut"; this.txtPathOut.Name = "txtPathOut";
@@ -177,17 +177,17 @@ namespace OpenRA.Editor
this.txtPathOut.Size = new System.Drawing.Size(265, 20); this.txtPathOut.Size = new System.Drawing.Size(265, 20);
this.txtPathOut.TabIndex = 0; this.txtPathOut.TabIndex = 0;
this.txtPathOut.TextChanged += new System.EventHandler(this.txtPathOut_TextChanged); this.txtPathOut.TextChanged += new System.EventHandler(this.txtPathOut_TextChanged);
// //
// lblPathOut // lblPathOut
// //
this.lblPathOut.AutoSize = true; this.lblPathOut.AutoSize = true;
this.lblPathOut.Location = new System.Drawing.Point(55, 13); this.lblPathOut.Location = new System.Drawing.Point(55, 13);
this.lblPathOut.Name = "lblPathOut"; this.lblPathOut.Name = "lblPathOut";
this.lblPathOut.Size = new System.Drawing.Size(0, 13); this.lblPathOut.Size = new System.Drawing.Size(0, 13);
this.lblPathOut.TabIndex = 6; this.lblPathOut.TabIndex = 6;
// //
// lblPath // lblPath
// //
this.lblPath.AutoSize = true; this.lblPath.AutoSize = true;
this.lblPath.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); this.lblPath.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.lblPath.Location = new System.Drawing.Point(12, 13); this.lblPath.Location = new System.Drawing.Point(12, 13);
@@ -195,20 +195,20 @@ namespace OpenRA.Editor
this.lblPath.Size = new System.Drawing.Size(37, 13); this.lblPath.Size = new System.Drawing.Size(37, 13);
this.lblPath.TabIndex = 5; this.lblPath.TabIndex = 5;
this.lblPath.Text = "Path:"; this.lblPath.Text = "Path:";
// //
// splitContainer1 // splitContainer1
// //
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.Location = new System.Drawing.Point(0, 0); this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Name = "splitContainer1"; this.splitContainer1.Name = "splitContainer1";
// //
// splitContainer1.Panel1 // splitContainer1.Panel1
// //
this.splitContainer1.Panel1.Controls.Add(this.lblMapList); this.splitContainer1.Panel1.Controls.Add(this.lblMapList);
this.splitContainer1.Panel1.Controls.Add(this.MapList); this.splitContainer1.Panel1.Controls.Add(this.MapList);
// //
// splitContainer1.Panel2 // splitContainer1.Panel2
// //
this.splitContainer1.Panel2.Controls.Add(this.txtDesc); this.splitContainer1.Panel2.Controls.Add(this.txtDesc);
this.splitContainer1.Panel2.Controls.Add(this.lblDesc); this.splitContainer1.Panel2.Controls.Add(this.lblDesc);
this.splitContainer1.Panel2.Controls.Add(this.txtTheater); this.splitContainer1.Panel2.Controls.Add(this.txtTheater);
@@ -222,90 +222,90 @@ namespace OpenRA.Editor
this.splitContainer1.Size = new System.Drawing.Size(494, 332); this.splitContainer1.Size = new System.Drawing.Size(494, 332);
this.splitContainer1.SplitterDistance = 300; this.splitContainer1.SplitterDistance = 300;
this.splitContainer1.TabIndex = 7; this.splitContainer1.TabIndex = 7;
// //
// lblMapList // lblMapList
// //
this.lblMapList.AutoSize = true; this.lblMapList.AutoSize = true;
this.lblMapList.Location = new System.Drawing.Point(12, 9); this.lblMapList.Location = new System.Drawing.Point(12, 9);
this.lblMapList.Name = "lblMapList"; this.lblMapList.Name = "lblMapList";
this.lblMapList.Size = new System.Drawing.Size(81, 13); this.lblMapList.Size = new System.Drawing.Size(81, 13);
this.lblMapList.TabIndex = 1; this.lblMapList.TabIndex = 1;
this.lblMapList.Text = "Available maps:"; this.lblMapList.Text = "Available maps:";
// //
// txtDesc // txtDesc
// //
this.txtDesc.BackColor = System.Drawing.SystemColors.ButtonFace; this.txtDesc.BackColor = System.Drawing.SystemColors.ButtonFace;
this.txtDesc.Location = new System.Drawing.Point(16, 289); this.txtDesc.Location = new System.Drawing.Point(16, 289);
this.txtDesc.Name = "txtDesc"; this.txtDesc.Name = "txtDesc";
this.txtDesc.ReadOnly = true; this.txtDesc.ReadOnly = true;
this.txtDesc.Size = new System.Drawing.Size(162, 20); this.txtDesc.Size = new System.Drawing.Size(162, 20);
this.txtDesc.TabIndex = 14; this.txtDesc.TabIndex = 14;
// //
// lblDesc // lblDesc
// //
this.lblDesc.AutoSize = true; this.lblDesc.AutoSize = true;
this.lblDesc.Location = new System.Drawing.Point(13, 273); this.lblDesc.Location = new System.Drawing.Point(13, 273);
this.lblDesc.Name = "lblDesc"; this.lblDesc.Name = "lblDesc";
this.lblDesc.Size = new System.Drawing.Size(63, 13); this.lblDesc.Size = new System.Drawing.Size(63, 13);
this.lblDesc.TabIndex = 13; this.lblDesc.TabIndex = 13;
this.lblDesc.Text = "Description:"; this.lblDesc.Text = "Description:";
// //
// txtTheater // txtTheater
// //
this.txtTheater.BackColor = System.Drawing.SystemColors.ButtonFace; this.txtTheater.BackColor = System.Drawing.SystemColors.ButtonFace;
this.txtTheater.Location = new System.Drawing.Point(16, 252); this.txtTheater.Location = new System.Drawing.Point(16, 252);
this.txtTheater.Name = "txtTheater"; this.txtTheater.Name = "txtTheater";
this.txtTheater.ReadOnly = true; this.txtTheater.ReadOnly = true;
this.txtTheater.Size = new System.Drawing.Size(162, 20); this.txtTheater.Size = new System.Drawing.Size(162, 20);
this.txtTheater.TabIndex = 12; this.txtTheater.TabIndex = 12;
// //
// lblTheater // lblTheater
// //
this.lblTheater.AutoSize = true; this.lblTheater.AutoSize = true;
this.lblTheater.Location = new System.Drawing.Point(13, 236); this.lblTheater.Location = new System.Drawing.Point(13, 236);
this.lblTheater.Name = "lblTheater"; this.lblTheater.Name = "lblTheater";
this.lblTheater.Size = new System.Drawing.Size(47, 13); this.lblTheater.Size = new System.Drawing.Size(47, 13);
this.lblTheater.TabIndex = 11; this.lblTheater.TabIndex = 11;
this.lblTheater.Text = "Tileset:"; this.lblTheater.Text = "Tileset:";
// //
// txtAuthor // txtAuthor
// //
this.txtAuthor.BackColor = System.Drawing.SystemColors.ButtonFace; this.txtAuthor.BackColor = System.Drawing.SystemColors.ButtonFace;
this.txtAuthor.Location = new System.Drawing.Point(16, 214); this.txtAuthor.Location = new System.Drawing.Point(16, 214);
this.txtAuthor.Name = "txtAuthor"; this.txtAuthor.Name = "txtAuthor";
this.txtAuthor.ReadOnly = true; this.txtAuthor.ReadOnly = true;
this.txtAuthor.Size = new System.Drawing.Size(162, 20); this.txtAuthor.Size = new System.Drawing.Size(162, 20);
this.txtAuthor.TabIndex = 10; this.txtAuthor.TabIndex = 10;
// //
// lblAuthor // lblAuthor
// //
this.lblAuthor.AutoSize = true; this.lblAuthor.AutoSize = true;
this.lblAuthor.Location = new System.Drawing.Point(13, 198); this.lblAuthor.Location = new System.Drawing.Point(13, 198);
this.lblAuthor.Name = "lblAuthor"; this.lblAuthor.Name = "lblAuthor";
this.lblAuthor.Size = new System.Drawing.Size(41, 13); this.lblAuthor.Size = new System.Drawing.Size(41, 13);
this.lblAuthor.TabIndex = 9; this.lblAuthor.TabIndex = 9;
this.lblAuthor.Text = "Author:"; this.lblAuthor.Text = "Author:";
// //
// txtTitle // txtTitle
// //
this.txtTitle.BackColor = System.Drawing.SystemColors.ButtonFace; this.txtTitle.BackColor = System.Drawing.SystemColors.ButtonFace;
this.txtTitle.Location = new System.Drawing.Point(16, 177); this.txtTitle.Location = new System.Drawing.Point(16, 177);
this.txtTitle.Name = "txtTitle"; this.txtTitle.Name = "txtTitle";
this.txtTitle.ReadOnly = true; this.txtTitle.ReadOnly = true;
this.txtTitle.Size = new System.Drawing.Size(162, 20); this.txtTitle.Size = new System.Drawing.Size(162, 20);
this.txtTitle.TabIndex = 8; this.txtTitle.TabIndex = 8;
// //
// lblMapName // lblMapName
// //
this.lblMapName.AutoSize = true; this.lblMapName.AutoSize = true;
this.lblMapName.Location = new System.Drawing.Point(13, 161); this.lblMapName.Location = new System.Drawing.Point(13, 161);
this.lblMapName.Name = "lblMapName"; this.lblMapName.Name = "lblMapName";
this.lblMapName.Size = new System.Drawing.Size(30, 13); this.lblMapName.Size = new System.Drawing.Size(30, 13);
this.lblMapName.TabIndex = 7; this.lblMapName.TabIndex = 7;
this.lblMapName.Text = "Title:"; this.lblMapName.Text = "Title:";
// //
// lblMinimap // lblMinimap
// //
this.lblMinimap.AutoSize = true; this.lblMinimap.AutoSize = true;
this.lblMinimap.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); this.lblMinimap.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.lblMinimap.Location = new System.Drawing.Point(29, 9); this.lblMinimap.Location = new System.Drawing.Point(29, 9);
@@ -313,9 +313,9 @@ namespace OpenRA.Editor
this.lblMinimap.Size = new System.Drawing.Size(71, 13); this.lblMinimap.Size = new System.Drawing.Size(71, 13);
this.lblMinimap.TabIndex = 6; this.lblMinimap.TabIndex = 6;
this.lblMinimap.Text = "Map preview:"; this.lblMinimap.Text = "Map preview:";
// //
// pictureBox1 // pictureBox1
// //
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image"))); this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(336, -9); this.pictureBox1.Location = new System.Drawing.Point(336, -9);
this.pictureBox1.Name = "pictureBox1"; this.pictureBox1.Name = "pictureBox1";
@@ -323,9 +323,9 @@ namespace OpenRA.Editor
this.pictureBox1.TabIndex = 7; this.pictureBox1.TabIndex = 7;
this.pictureBox1.TabStop = false; this.pictureBox1.TabStop = false;
this.pictureBox1.Visible = false; this.pictureBox1.Visible = false;
// //
// MapSelect // MapSelect
// //
this.AcceptButton = this.btnOk; this.AcceptButton = this.btnOk;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -25,7 +25,7 @@ namespace OpenRA.Editor
{ {
MapFolderPath = new string[] { Environment.CurrentDirectory, "mods", currentMod, "maps" } MapFolderPath = new string[] { Environment.CurrentDirectory, "mods", currentMod, "maps" }
.Aggregate(Path.Combine); .Aggregate(Path.Combine);
InitializeComponent(); InitializeComponent();
MapIconsList.Images.Add(pictureBox1.Image); MapIconsList.Images.Add(pictureBox1.Image);
} }
@@ -34,7 +34,7 @@ namespace OpenRA.Editor
{ {
MapList.Items.Clear(); MapList.Items.Clear();
txtPathOut.Text = MapFolderPath; txtPathOut.Text = MapFolderPath;
foreach (var map in ModData.FindMapsIn(MapFolderPath)) foreach (var map in ModData.FindMapsIn(MapFolderPath))
{ {
ListViewItem map1 = new ListViewItem(); ListViewItem map1 = new ListViewItem();
@@ -43,7 +43,7 @@ namespace OpenRA.Editor
map1.ImageIndex = 0; map1.ImageIndex = 0;
MapList.Items.Add(map1); MapList.Items.Add(map1);
} }
// hack // hack
if (txtNew.Text != "unnamed") if (txtNew.Text != "unnamed")
MapList.Items[0].Selected = true; MapList.Items[0].Selected = true;
@@ -62,7 +62,7 @@ namespace OpenRA.Editor
txtTheater.Text = map.Tileset; txtTheater.Text = map.Tileset;
txtDesc.Text = map.Description; txtDesc.Text = map.Description;
pbMinimap.Image = null; pbMinimap.Image = null;
try try
{ {
pbMinimap.Image = Minimap.AddStaticResources(map, Minimap.TerrainBitmap(map, true)); pbMinimap.Image = Minimap.AddStaticResources(map, Minimap.TerrainBitmap(map, true));

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -58,9 +58,9 @@ namespace OpenRA.Editor
((System.ComponentModel.ISupportInitialize)(this.height)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.height)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.width)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.width)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// button2 // button2
// //
this.button2.DialogResult = System.Windows.Forms.DialogResult.OK; this.button2.DialogResult = System.Windows.Forms.DialogResult.OK;
this.button2.Location = new System.Drawing.Point(229, 160); this.button2.Location = new System.Drawing.Point(229, 160);
this.button2.Name = "button2"; this.button2.Name = "button2";
@@ -68,9 +68,9 @@ namespace OpenRA.Editor
this.button2.TabIndex = 7; this.button2.TabIndex = 7;
this.button2.Text = "OK"; this.button2.Text = "OK";
this.button2.UseVisualStyleBackColor = true; this.button2.UseVisualStyleBackColor = true;
// //
// button1 // button1
// //
this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button1.Location = new System.Drawing.Point(310, 160); this.button1.Location = new System.Drawing.Point(310, 160);
this.button1.Name = "button1"; this.button1.Name = "button1";
@@ -78,36 +78,36 @@ namespace OpenRA.Editor
this.button1.TabIndex = 8; this.button1.TabIndex = 8;
this.button1.Text = "Cancel"; this.button1.Text = "Cancel";
this.button1.UseVisualStyleBackColor = true; this.button1.UseVisualStyleBackColor = true;
// //
// label3 // label3
// //
this.label3.AutoSize = true; this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(31, 77); this.label3.Location = new System.Drawing.Point(31, 77);
this.label3.Name = "label3"; this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(107, 13); this.label3.Size = new System.Drawing.Size(107, 13);
this.label3.TabIndex = 9; this.label3.TabIndex = 9;
this.label3.Text = "Cordon Right/Bottom"; this.label3.Text = "Cordon Right/Bottom";
// //
// label2 // label2
// //
this.label2.AutoSize = true; this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(31, 51); this.label2.Location = new System.Drawing.Point(31, 51);
this.label2.Name = "label2"; this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(86, 13); this.label2.Size = new System.Drawing.Size(86, 13);
this.label2.TabIndex = 11; this.label2.TabIndex = 11;
this.label2.Text = "Cordon Left/Top"; this.label2.Text = "Cordon Left/Top";
// //
// label1 // label1
// //
this.label1.AutoSize = true; this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(31, 25); this.label1.Location = new System.Drawing.Point(31, 25);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(27, 13); this.label1.Size = new System.Drawing.Size(27, 13);
this.label1.TabIndex = 10; this.label1.TabIndex = 10;
this.label1.Text = "Size"; this.label1.Text = "Size";
// //
// cordonBottom // cordonBottom
// //
this.cordonBottom.Location = new System.Drawing.Point(280, 75); this.cordonBottom.Location = new System.Drawing.Point(280, 75);
this.cordonBottom.Maximum = new decimal(new int[] { this.cordonBottom.Maximum = new decimal(new int[] {
2048, 2048,
@@ -123,9 +123,9 @@ namespace OpenRA.Editor
0, 0,
0}); 0});
this.cordonBottom.Enter += new System.EventHandler(this.SelectText); this.cordonBottom.Enter += new System.EventHandler(this.SelectText);
// //
// cordonTop // cordonTop
// //
this.cordonTop.Location = new System.Drawing.Point(280, 49); this.cordonTop.Location = new System.Drawing.Point(280, 49);
this.cordonTop.Maximum = new decimal(new int[] { this.cordonTop.Maximum = new decimal(new int[] {
2048, 2048,
@@ -141,9 +141,9 @@ namespace OpenRA.Editor
0, 0,
0}); 0});
this.cordonTop.Enter += new System.EventHandler(this.SelectText); this.cordonTop.Enter += new System.EventHandler(this.SelectText);
// //
// cordonRight // cordonRight
// //
this.cordonRight.Location = new System.Drawing.Point(169, 75); this.cordonRight.Location = new System.Drawing.Point(169, 75);
this.cordonRight.Maximum = new decimal(new int[] { this.cordonRight.Maximum = new decimal(new int[] {
2048, 2048,
@@ -159,9 +159,9 @@ namespace OpenRA.Editor
0, 0,
0}); 0});
this.cordonRight.Enter += new System.EventHandler(this.SelectText); this.cordonRight.Enter += new System.EventHandler(this.SelectText);
// //
// cordonLeft // cordonLeft
// //
this.cordonLeft.Location = new System.Drawing.Point(169, 49); this.cordonLeft.Location = new System.Drawing.Point(169, 49);
this.cordonLeft.Maximum = new decimal(new int[] { this.cordonLeft.Maximum = new decimal(new int[] {
2048, 2048,
@@ -177,9 +177,9 @@ namespace OpenRA.Editor
0, 0,
0}); 0});
this.cordonLeft.Enter += new System.EventHandler(this.SelectText); this.cordonLeft.Enter += new System.EventHandler(this.SelectText);
// //
// height // height
// //
this.height.Increment = new decimal(new int[] { this.height.Increment = new decimal(new int[] {
8, 8,
0, 0,
@@ -200,9 +200,9 @@ namespace OpenRA.Editor
0, 0,
0}); 0});
this.height.Enter += new System.EventHandler(this.SelectText); this.height.Enter += new System.EventHandler(this.SelectText);
// //
// width // width
// //
this.width.Increment = new decimal(new int[] { this.width.Increment = new decimal(new int[] {
8, 8,
0, 0,
@@ -223,27 +223,27 @@ namespace OpenRA.Editor
0, 0,
0}); 0});
this.width.Enter += new System.EventHandler(this.SelectText); this.width.Enter += new System.EventHandler(this.SelectText);
// //
// label4 // label4
// //
this.label4.AutoSize = true; this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(31, 124); this.label4.Location = new System.Drawing.Point(31, 124);
this.label4.Name = "label4"; this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(44, 13); this.label4.Size = new System.Drawing.Size(44, 13);
this.label4.TabIndex = 14; this.label4.TabIndex = 14;
this.label4.Text = "Tileset"; this.label4.Text = "Tileset";
// //
// theater // theater
// //
this.theater.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.theater.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.theater.FormattingEnabled = true; this.theater.FormattingEnabled = true;
this.theater.Location = new System.Drawing.Point(169, 121); this.theater.Location = new System.Drawing.Point(169, 121);
this.theater.Name = "theater"; this.theater.Name = "theater";
this.theater.Size = new System.Drawing.Size(216, 21); this.theater.Size = new System.Drawing.Size(216, 21);
this.theater.TabIndex = 6; this.theater.TabIndex = 6;
// //
// NewMapDialog // NewMapDialog
// //
this.AcceptButton = this.button2; this.AcceptButton = this.button2;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -30,19 +30,19 @@ namespace OpenRA.Editor
UpgradeMaps(args[1]); UpgradeMaps(args[1]);
return; return;
} }
Application.CurrentCulture = CultureInfo.InvariantCulture; Application.CurrentCulture = CultureInfo.InvariantCulture;
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1(args)); Application.Run(new Form1(args));
} }
static void UpgradeMaps(string mod) static void UpgradeMaps(string mod)
{ {
var MapFolderPath = new string[] { Environment.CurrentDirectory, "mods", mod, "maps" } var MapFolderPath = new string[] { Environment.CurrentDirectory, "mods", mod, "maps" }
.Aggregate(Path.Combine); .Aggregate(Path.Combine);
foreach (var path in ModData.FindMapsIn(MapFolderPath)) foreach (var path in ModData.FindMapsIn(MapFolderPath))
{ {
var map = new Map(path); var map = new Map(path);
@@ -54,6 +54,6 @@ namespace OpenRA.Editor
map.Save(path); map.Save(path);
} }
} }
} }
} }

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -12,7 +12,7 @@ using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("OpenRA.Editor")] [assembly: AssemblyTitle("OpenRA.Editor")]
@@ -24,8 +24,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible // Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from // to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type. // COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
@@ -35,11 +35,11 @@ using System.Runtime.InteropServices;
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
// //
// Major Version // Major Version
// Minor Version // Minor Version
// Build Number // Build Number
// Revision // Revision
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.0.0")]

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -49,9 +49,9 @@ namespace OpenRA.Editor
this.author = new System.Windows.Forms.TextBox(); this.author = new System.Windows.Forms.TextBox();
this.useAsShellmap = new System.Windows.Forms.CheckBox(); this.useAsShellmap = new System.Windows.Forms.CheckBox();
this.SuspendLayout(); this.SuspendLayout();
// //
// button2 // button2
// //
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 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.DialogResult = System.Windows.Forms.DialogResult.OK;
this.button2.Location = new System.Drawing.Point(196, 193); this.button2.Location = new System.Drawing.Point(196, 193);
@@ -60,9 +60,9 @@ namespace OpenRA.Editor
this.button2.TabIndex = 14; this.button2.TabIndex = 14;
this.button2.Text = "OK"; this.button2.Text = "OK";
this.button2.UseVisualStyleBackColor = true; 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.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.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button1.Location = new System.Drawing.Point(277, 193); this.button1.Location = new System.Drawing.Point(277, 193);
@@ -71,41 +71,41 @@ namespace OpenRA.Editor
this.button1.TabIndex = 15; this.button1.TabIndex = 15;
this.button1.Text = "Cancel"; this.button1.Text = "Cancel";
this.button1.UseVisualStyleBackColor = true; this.button1.UseVisualStyleBackColor = true;
// //
// label1 // label1
// //
this.label1.AutoSize = true; this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 50); this.label1.Location = new System.Drawing.Point(12, 50);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(27, 13); this.label1.Size = new System.Drawing.Size(27, 13);
this.label1.TabIndex = 16; this.label1.TabIndex = 16;
this.label1.Text = "Title"; this.label1.Text = "Title";
// //
// title // title
// //
this.title.Location = new System.Drawing.Point(66, 47); this.title.Location = new System.Drawing.Point(66, 47);
this.title.Name = "title"; this.title.Name = "title";
this.title.Size = new System.Drawing.Size(286, 20); this.title.Size = new System.Drawing.Size(286, 20);
this.title.TabIndex = 17; this.title.TabIndex = 17;
// //
// label2 // label2
// //
this.label2.AutoSize = true; this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 76); this.label2.Location = new System.Drawing.Point(12, 76);
this.label2.Name = "label2"; this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(32, 13); this.label2.Size = new System.Drawing.Size(32, 13);
this.label2.TabIndex = 16; this.label2.TabIndex = 16;
this.label2.Text = "Desc"; this.label2.Text = "Desc";
// //
// desc // desc
// //
this.desc.Location = new System.Drawing.Point(66, 73); this.desc.Location = new System.Drawing.Point(66, 73);
this.desc.Name = "desc"; this.desc.Name = "desc";
this.desc.Size = new System.Drawing.Size(286, 20); this.desc.Size = new System.Drawing.Size(286, 20);
this.desc.TabIndex = 17; this.desc.TabIndex = 17;
// //
// selectable // selectable
// //
this.selectable.AutoSize = true; this.selectable.AutoSize = true;
this.selectable.Location = new System.Drawing.Point(118, 138); this.selectable.Location = new System.Drawing.Point(118, 138);
this.selectable.Name = "selectable"; this.selectable.Name = "selectable";
@@ -113,25 +113,25 @@ namespace OpenRA.Editor
this.selectable.TabIndex = 18; this.selectable.TabIndex = 18;
this.selectable.Text = "Show in Map Chooser"; this.selectable.Text = "Show in Map Chooser";
this.selectable.UseVisualStyleBackColor = true; this.selectable.UseVisualStyleBackColor = true;
// //
// label3 // label3
// //
this.label3.AutoSize = true; this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(12, 102); this.label3.Location = new System.Drawing.Point(12, 102);
this.label3.Name = "label3"; this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(38, 13); this.label3.Size = new System.Drawing.Size(38, 13);
this.label3.TabIndex = 16; this.label3.TabIndex = 16;
this.label3.Text = "Author"; this.label3.Text = "Author";
// //
// author // author
// //
this.author.Location = new System.Drawing.Point(66, 99); this.author.Location = new System.Drawing.Point(66, 99);
this.author.Name = "author"; this.author.Name = "author";
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 // checkBox1
// //
this.useAsShellmap.AutoSize = true; this.useAsShellmap.AutoSize = true;
this.useAsShellmap.Location = new System.Drawing.Point(118, 161); this.useAsShellmap.Location = new System.Drawing.Point(118, 161);
this.useAsShellmap.Name = "checkBox1"; this.useAsShellmap.Name = "checkBox1";
@@ -139,9 +139,9 @@ namespace OpenRA.Editor
this.useAsShellmap.TabIndex = 18; this.useAsShellmap.TabIndex = 18;
this.useAsShellmap.Text = "Use as Shellmap"; this.useAsShellmap.Text = "Use as Shellmap";
this.useAsShellmap.UseVisualStyleBackColor = true; this.useAsShellmap.UseVisualStyleBackColor = true;
// //
// PropertiesDialog // PropertiesDialog
// //
this.AcceptButton = this.button2; this.AcceptButton = this.button2;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -85,7 +85,7 @@ namespace OpenRA.Editor
public static ActorTemplate RenderActor(ActorInfo info, TileSet tileset, Palette p) public static ActorTemplate RenderActor(ActorInfo info, TileSet tileset, Palette p)
{ {
var image = RenderSimple.GetImage(info); var image = RenderSimple.GetImage(info);
using (var s = FileSystem.OpenWithExts(image, tileset.Extensions)) using (var s = FileSystem.OpenWithExts(image, tileset.Extensions))
{ {
var shp = new ShpReader(s); var shp = new ShpReader(s);

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -56,9 +56,9 @@ namespace OpenRA.Editor
((System.ComponentModel.ISupportInitialize)(this.cordonBottom)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.cordonBottom)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.height)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.height)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// width // width
// //
this.width.Increment = new decimal(new int[] { this.width.Increment = new decimal(new int[] {
8, 8,
0, 0,
@@ -73,27 +73,27 @@ namespace OpenRA.Editor
this.width.Name = "width"; this.width.Name = "width";
this.width.Size = new System.Drawing.Size(105, 20); this.width.Size = new System.Drawing.Size(105, 20);
this.width.TabIndex = 0; this.width.TabIndex = 0;
// //
// label1 // label1
// //
this.label1.AutoSize = true; this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(23, 20); this.label1.Location = new System.Drawing.Point(23, 20);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(27, 13); this.label1.Size = new System.Drawing.Size(27, 13);
this.label1.TabIndex = 1; this.label1.TabIndex = 1;
this.label1.Text = "Size"; this.label1.Text = "Size";
// //
// label2 // label2
// //
this.label2.AutoSize = true; this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(23, 46); this.label2.Location = new System.Drawing.Point(23, 46);
this.label2.Name = "label2"; this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(86, 13); this.label2.Size = new System.Drawing.Size(86, 13);
this.label2.TabIndex = 1; this.label2.TabIndex = 1;
this.label2.Text = "Cordon Left/Top"; this.label2.Text = "Cordon Left/Top";
// //
// cordonLeft // cordonLeft
// //
this.cordonLeft.Location = new System.Drawing.Point(161, 44); this.cordonLeft.Location = new System.Drawing.Point(161, 44);
this.cordonLeft.Maximum = new decimal(new int[] { this.cordonLeft.Maximum = new decimal(new int[] {
2048, 2048,
@@ -103,9 +103,9 @@ namespace OpenRA.Editor
this.cordonLeft.Name = "cordonLeft"; this.cordonLeft.Name = "cordonLeft";
this.cordonLeft.Size = new System.Drawing.Size(105, 20); this.cordonLeft.Size = new System.Drawing.Size(105, 20);
this.cordonLeft.TabIndex = 0; this.cordonLeft.TabIndex = 0;
// //
// cordonTop // cordonTop
// //
this.cordonTop.Location = new System.Drawing.Point(272, 44); this.cordonTop.Location = new System.Drawing.Point(272, 44);
this.cordonTop.Maximum = new decimal(new int[] { this.cordonTop.Maximum = new decimal(new int[] {
2048, 2048,
@@ -115,9 +115,9 @@ namespace OpenRA.Editor
this.cordonTop.Name = "cordonTop"; this.cordonTop.Name = "cordonTop";
this.cordonTop.Size = new System.Drawing.Size(105, 20); this.cordonTop.Size = new System.Drawing.Size(105, 20);
this.cordonTop.TabIndex = 0; this.cordonTop.TabIndex = 0;
// //
// cordonRight // cordonRight
// //
this.cordonRight.Location = new System.Drawing.Point(161, 70); this.cordonRight.Location = new System.Drawing.Point(161, 70);
this.cordonRight.Maximum = new decimal(new int[] { this.cordonRight.Maximum = new decimal(new int[] {
2048, 2048,
@@ -127,9 +127,9 @@ namespace OpenRA.Editor
this.cordonRight.Name = "cordonRight"; this.cordonRight.Name = "cordonRight";
this.cordonRight.Size = new System.Drawing.Size(105, 20); this.cordonRight.Size = new System.Drawing.Size(105, 20);
this.cordonRight.TabIndex = 0; this.cordonRight.TabIndex = 0;
// //
// cordonBottom // cordonBottom
// //
this.cordonBottom.Location = new System.Drawing.Point(272, 70); this.cordonBottom.Location = new System.Drawing.Point(272, 70);
this.cordonBottom.Maximum = new decimal(new int[] { this.cordonBottom.Maximum = new decimal(new int[] {
2048, 2048,
@@ -139,18 +139,18 @@ namespace OpenRA.Editor
this.cordonBottom.Name = "cordonBottom"; this.cordonBottom.Name = "cordonBottom";
this.cordonBottom.Size = new System.Drawing.Size(105, 20); this.cordonBottom.Size = new System.Drawing.Size(105, 20);
this.cordonBottom.TabIndex = 0; this.cordonBottom.TabIndex = 0;
// //
// label3 // label3
// //
this.label3.AutoSize = true; this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(23, 72); this.label3.Location = new System.Drawing.Point(23, 72);
this.label3.Name = "label3"; this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(107, 13); this.label3.Size = new System.Drawing.Size(107, 13);
this.label3.TabIndex = 1; this.label3.TabIndex = 1;
this.label3.Text = "Cordon Right/Bottom"; this.label3.Text = "Cordon Right/Bottom";
// //
// button1 // button1
// //
this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button1.Location = new System.Drawing.Point(302, 111); this.button1.Location = new System.Drawing.Point(302, 111);
this.button1.Name = "button1"; this.button1.Name = "button1";
@@ -158,9 +158,9 @@ namespace OpenRA.Editor
this.button1.TabIndex = 2; this.button1.TabIndex = 2;
this.button1.Text = "Cancel"; this.button1.Text = "Cancel";
this.button1.UseVisualStyleBackColor = true; this.button1.UseVisualStyleBackColor = true;
// //
// button2 // button2
// //
this.button2.DialogResult = System.Windows.Forms.DialogResult.OK; this.button2.DialogResult = System.Windows.Forms.DialogResult.OK;
this.button2.Location = new System.Drawing.Point(221, 111); this.button2.Location = new System.Drawing.Point(221, 111);
this.button2.Name = "button2"; this.button2.Name = "button2";
@@ -168,9 +168,9 @@ namespace OpenRA.Editor
this.button2.TabIndex = 2; this.button2.TabIndex = 2;
this.button2.Text = "OK"; this.button2.Text = "OK";
this.button2.UseVisualStyleBackColor = true; this.button2.UseVisualStyleBackColor = true;
// //
// height // height
// //
this.height.Increment = new decimal(new int[] { this.height.Increment = new decimal(new int[] {
8, 8,
0, 0,
@@ -185,9 +185,9 @@ namespace OpenRA.Editor
this.height.Name = "height"; this.height.Name = "height";
this.height.Size = new System.Drawing.Size(105, 20); this.height.Size = new System.Drawing.Size(105, 20);
this.height.TabIndex = 0; this.height.TabIndex = 0;
// //
// ResizeDialog // ResizeDialog
// //
this.AcceptButton = this.button2; this.AcceptButton = this.button2;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -30,7 +30,7 @@ namespace OpenRA.Editor
index = (byte)random.Next(Resource.Info.SpriteNames.Length) index = (byte)random.Next(Resource.Info.SpriteNames.Length)
}; };
var ch = new int2((surface.GetBrushLocation().X) / Surface.ChunkSize, var ch = new int2((surface.GetBrushLocation().X) / Surface.ChunkSize,
(surface.GetBrushLocation().Y) / Surface.ChunkSize); (surface.GetBrushLocation().Y) / Surface.ChunkSize);
if (surface.Chunks.ContainsKey(ch)) if (surface.Chunks.ContainsKey(ch))

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -33,7 +33,7 @@ namespace OpenRA.Editor
public float Zoom = 1.0f; public float Zoom = 1.0f;
ITool Tool; ITool Tool;
public bool IsPanning; public bool IsPanning;
public bool ShowActorNames; public bool ShowActorNames;
@@ -153,7 +153,7 @@ namespace OpenRA.Editor
return; return;
Tool = null; Tool = null;
var key = Map.Actors.Value.FirstOrDefault(a => a.Value.Location() == BrushLocation); var key = Map.Actors.Value.FirstOrDefault(a => a.Value.Location() == BrushLocation);
if (key.Key != null) Map.Actors.Value.Remove(key.Key); if (key.Key != null) Map.Actors.Value.Remove(key.Key);
@@ -286,7 +286,7 @@ namespace OpenRA.Editor
{ {
var centered = t.Appearance == null || !t.Appearance.RelativeToTopLeft; var centered = t.Appearance == null || !t.Appearance.RelativeToTopLeft;
var drawPos = GetDrawPosition(p, t.Bitmap, centered); var drawPos = GetDrawPosition(p, t.Bitmap, centered);
g.DrawRectangle(CordonPen, g.DrawRectangle(CordonPen,
drawPos.X, drawPos.Y, drawPos.X, drawPos.Y,
t.Bitmap.Width * Zoom, t.Bitmap.Height * Zoom); t.Bitmap.Width * Zoom, t.Bitmap.Height * Zoom);
@@ -360,7 +360,7 @@ namespace OpenRA.Editor
if (Tool != null) if (Tool != null)
Tool.Preview(this, e.Graphics); Tool.Preview(this, e.Graphics);
if (Tool == null) if (Tool == null)
{ {
var x = Map.Actors.Value.FirstOrDefault(a => a.Value.Location() == GetBrushLocation()); var x = Map.Actors.Value.FirstOrDefault(a => a.Value.Location() == GetBrushLocation());

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -61,11 +61,11 @@ namespace OpenRA.FileFormats
while ((temp = s.Pop()) != "(") yield return temp; while ((temp = s.Pop()) != "(") yield return temp;
} }
else if (char.IsNumber(t[0])) yield return t; else if (char.IsNumber(t[0])) yield return t;
else if (char.IsLetter(t[0])) else if (char.IsLetter(t[0]))
{ {
if (!syms.ContainsKey(t)) if (!syms.ContainsKey(t))
throw new InvalidOperationException("Substitution `{0}` undefined".F(t)); throw new InvalidOperationException("Substitution `{0}` undefined".F(t));
yield return syms[t].ToString(); yield return syms[t].ToString();
} }
else else
@@ -74,7 +74,7 @@ namespace OpenRA.FileFormats
s.Push(t); s.Push(t);
} }
} }
while (s.Count > 0) yield return s.Pop(); while (s.Count > 0) yield return s.Pop();
} }

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -111,11 +111,11 @@ namespace OpenRA
{ {
return (k & mod) == mod; return (k & mod) == mod;
} }
public static bool IsValidInput(this KeyInput key) public static bool IsValidInput(this KeyInput key)
{ {
return char.IsLetter(key.UnicodeChar) || char.IsDigit(key.UnicodeChar) || return char.IsLetter(key.UnicodeChar) || char.IsDigit(key.UnicodeChar) ||
char.IsSymbol(key.UnicodeChar) || char.IsSeparator(key.UnicodeChar) || char.IsSymbol(key.UnicodeChar) || char.IsSeparator(key.UnicodeChar) ||
char.IsPunctuation(key.UnicodeChar); char.IsPunctuation(key.UnicodeChar);
} }
@@ -149,7 +149,7 @@ namespace OpenRA
// this is probably a shockingly-slow way to do this, but it's concise. // this is probably a shockingly-slow way to do this, but it's concise.
return xs.Except(ys).Concat(ys.Except(xs)); return xs.Except(ys).Concat(ys.Except(xs));
} }
public static IEnumerable<T> Iterate<T>( this T t, Func<T,T> f ) public static IEnumerable<T> Iterate<T>( this T t, Func<T,T> f )
{ {
for(;;) { yield return t; t = f(t); } for(;;) { yield return t; t = f(t); }

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -77,7 +77,7 @@ namespace OpenRA.FileFormats
field.SetValue( self, GetValue( field.Name, field.FieldType, value ) ); field.SetValue( self, GetValue( field.Name, field.FieldType, value ) );
return; return;
} }
var prop = self.GetType().GetProperty( key.Trim() ); var prop = self.GetType().GetProperty( key.Trim() );
if (prop != null) if (prop != null)
@@ -207,7 +207,7 @@ namespace OpenRA.FileFormats
var argValues = new object[] { parts }; var argValues = new object[] { parts };
return fieldType.GetConstructor(argTypes).Invoke(argValues); return fieldType.GetConstructor(argTypes).Invoke(argValues);
} }
UnknownFieldAction("[Type] {0}".F(x),fieldType); UnknownFieldAction("[Type] {0}".F(x),fieldType);
return null; return null;
} }
@@ -304,7 +304,7 @@ namespace OpenRA.FileFormats
{ {
return new MiniYamlNode(field, FieldSaver.FormatValue( o, o.GetType().GetField(field) )); return new MiniYamlNode(field, FieldSaver.FormatValue( o, o.GetType().GetField(field) ));
} }
public static string FormatValue(object o, FieldInfo f) public static string FormatValue(object o, FieldInfo f)
{ {
var v = f.GetValue(o); var v = f.GetValue(o);

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -109,13 +109,13 @@ namespace OpenRA.FileFormats
/*var dataSize = */ br.ReadInt32(); /*var dataSize = */ br.ReadInt32();
var outputSize = br.ReadInt32(); var outputSize = br.ReadInt32();
var flags = (SoundFlags) br.ReadByte(); var flags = (SoundFlags) br.ReadByte();
var samples = outputSize; var samples = outputSize;
if (0 != (flags & SoundFlags.Stereo)) samples /= 2; if (0 != (flags & SoundFlags.Stereo)) samples /= 2;
if (0 != (flags & SoundFlags._16Bit)) samples /= 2; if (0 != (flags & SoundFlags._16Bit)) samples /= 2;
return samples / sampleRate; return samples / sampleRate;
} }
public static byte[] LoadSound(Stream s) public static byte[] LoadSound(Stream s)
{ {
var br = new BinaryReader(s); var br = new BinaryReader(s);
@@ -140,9 +140,9 @@ namespace OpenRA.FileFormats
var t = DecodeSample(b, ref index, ref currentSample); var t = DecodeSample(b, ref index, ref currentSample);
output[offset++] = (byte)t; output[offset++] = (byte)t;
output[offset++] = (byte)(t >> 8); output[offset++] = (byte)(t >> 8);
if (offset < outputSize) if (offset < outputSize)
{ {
/* possible that only half of the final byte is used! */ /* possible that only half of the final byte is used! */
t = DecodeSample((byte)(b >> 4), ref index, ref currentSample); t = DecodeSample((byte)(b >> 4), ref index, ref currentSample);
output[offset++] = (byte)t; output[offset++] = (byte)t;

View File

@@ -1,12 +1,12 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
* *
* This file is based on the blast routines (version 1.1 by Mark Adler) * This file is based on the blast routines (version 1.1 by Mark Adler)
* included in zlib/contrib * included in zlib/contrib
*/ */
#endregion #endregion
@@ -20,7 +20,7 @@ namespace OpenRA.FileFormats
{ {
public static readonly int MAXBITS = 13; // maximum code length public static readonly int MAXBITS = 13; // maximum code length
public static readonly int MAXWIN = 4096; // maximum window size public static readonly int MAXWIN = 4096; // maximum window size
static byte[] litlen = new byte[] { static byte[] litlen = new byte[] {
11, 124, 8, 7, 28, 7, 188, 13, 76, 4, 11, 124, 8, 7, 28, 7, 188, 13, 76, 4,
10, 8, 12, 10, 12, 10, 8, 23, 8, 9, 10, 8, 12, 10, 12, 10, 8, 23, 8, 9,
@@ -51,28 +51,28 @@ namespace OpenRA.FileFormats
0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2,
3, 4, 5, 6, 7, 8 3, 4, 5, 6, 7, 8
}; };
static Huffman litcode = new Huffman(litlen, litlen.Length, 256); static Huffman litcode = new Huffman(litlen, litlen.Length, 256);
static Huffman lencode = new Huffman(lenlen, lenlen.Length, 16); static Huffman lencode = new Huffman(lenlen, lenlen.Length, 16);
static Huffman distcode = new Huffman(distlen, distlen.Length, 64); static Huffman distcode = new Huffman(distlen, distlen.Length, 64);
// Decode PKWare Compression Library stream. // Decode PKWare Compression Library stream.
public static byte[] Decompress(byte[] src) public static byte[] Decompress(byte[] src)
{ {
BitReader br = new BitReader(src); BitReader br = new BitReader(src);
// Are literals coded? // Are literals coded?
int coded = br.ReadBits(8); int coded = br.ReadBits(8);
if (coded < 0 || coded > 1) if (coded < 0 || coded > 1)
throw new NotImplementedException("Invalid datastream"); throw new NotImplementedException("Invalid datastream");
bool EncodedLiterals = (coded == 1); bool EncodedLiterals = (coded == 1);
// log2(dictionary size) - 6 // log2(dictionary size) - 6
int dict = br.ReadBits(8); int dict = br.ReadBits(8);
if (dict < 4 || dict > 6) if (dict < 4 || dict > 6)
throw new InvalidDataException("Invalid dictionary size"); throw new InvalidDataException("Invalid dictionary size");
// output state // output state
ushort next = 0; // index of next write location in out[] ushort next = 0; // index of next write location in out[]
bool first = true; // true to check distances (for first 4K) bool first = true; // true to check distances (for first 4K)
@@ -94,33 +94,33 @@ namespace OpenRA.FileFormats
ms.WriteByte(outBuffer[i]); ms.WriteByte(outBuffer[i]);
break; break;
} }
// Distance // Distance
symbol = len == 2 ? 2 : dict; symbol = len == 2 ? 2 : dict;
int dist = Decode(distcode, br) << symbol; int dist = Decode(distcode, br) << symbol;
dist += br.ReadBits(symbol); dist += br.ReadBits(symbol);
dist++; dist++;
if (first && dist > next) if (first && dist > next)
throw new InvalidDataException("Attempt to jump before data"); throw new InvalidDataException("Attempt to jump before data");
// copy length bytes from distance bytes back // copy length bytes from distance bytes back
do do
{ {
int dest = next; int dest = next;
int source = dest - dist; int source = dest - dist;
int copy = MAXWIN; int copy = MAXWIN;
if (next < dist) if (next < dist)
{ {
source += copy; source += copy;
copy = dist; copy = dist;
} }
copy -= next; copy -= next;
if (copy > len) if (copy > len)
copy = len; copy = len;
len -= copy; len -= copy;
next += (ushort)copy; next += (ushort)copy;
@@ -129,7 +129,7 @@ namespace OpenRA.FileFormats
// the same as Array.Copy() // the same as Array.Copy()
while( copy-- > 0 ) while( copy-- > 0 )
outBuffer[dest++] = outBuffer[source++]; outBuffer[dest++] = outBuffer[source++];
// Flush window to outstream // Flush window to outstream
if (next == MAXWIN) if (next == MAXWIN)
{ {
@@ -153,11 +153,11 @@ namespace OpenRA.FileFormats
} }
} }
} while (true); } while (true);
return ms.ToArray(); return ms.ToArray();
} }
// Decode a code using huffman table h. // Decode a code using huffman table h.
static int Decode(Huffman h, BitReader br) static int Decode(Huffman h, BitReader br)
{ {
int code = 0; // len bits being decoded int code = 0; // len bits being decoded
@@ -178,7 +178,7 @@ namespace OpenRA.FileFormats
} }
} }
} }
class BitReader class BitReader
{ {
readonly byte[] src; readonly byte[] src;
@@ -190,7 +190,7 @@ namespace OpenRA.FileFormats
{ {
this.src = src; this.src = src;
} }
public int ReadBits(int count) public int ReadBits(int count)
{ {
int ret = 0; int ret = 0;
@@ -202,7 +202,7 @@ namespace OpenRA.FileFormats
bitBuffer = src[offset++]; bitBuffer = src[offset++];
bitCount = 8; bitCount = 8;
} }
ret |= (bitBuffer & 1) << filled; ret |= (bitBuffer & 1) << filled;
bitBuffer >>= 1; bitBuffer >>= 1;
bitCount--; bitCount--;
@@ -230,7 +230,7 @@ namespace OpenRA.FileFormats
{ {
short[] length = new short[256]; // code lengths short[] length = new short[256]; // code lengths
int s = 0; // current symbol int s = 0; // current symbol
// convert compact repeat counts into symbol bit length list // convert compact repeat counts into symbol bit length list
foreach (byte code in rep) foreach (byte code in rep)
{ {
@@ -242,16 +242,16 @@ namespace OpenRA.FileFormats
} while (--num > 0); } while (--num > 0);
} }
n = s; n = s;
// count number of codes of each length // count number of codes of each length
Count = new short[Blast.MAXBITS + 1]; Count = new short[Blast.MAXBITS + 1];
for (int i = 0; i < n; i++) for (int i = 0; i < n; i++)
Count[length[i]]++; Count[length[i]]++;
// no codes! // no codes!
if (Count[0] == n) if (Count[0] == n)
return; return;
// check for an over-subscribed or incomplete set of lengths // check for an over-subscribed or incomplete set of lengths
int left = 1; // one possible code of zero length int left = 1; // one possible code of zero length
for (int len = 1; len <= Blast.MAXBITS; len++) for (int len = 1; len <= Blast.MAXBITS; len++)
@@ -263,12 +263,12 @@ namespace OpenRA.FileFormats
if (left < 0) if (left < 0)
throw new InvalidDataException ("over subscribed code set"); throw new InvalidDataException ("over subscribed code set");
} }
// generate offsets into symbol table for each length for sorting // generate offsets into symbol table for each length for sorting
short[] offs = new short[Blast.MAXBITS + 1]; short[] offs = new short[Blast.MAXBITS + 1];
for (int len = 1; len < Blast.MAXBITS; len++) for (int len = 1; len < Blast.MAXBITS; len++)
offs[len + 1] = (short)(offs[len] + Count[len]); offs[len + 1] = (short)(offs[len] + Count[len]);
// put symbols in table sorted by length, by symbol order within each length // put symbols in table sorted by length, by symbol order within each length
Symbol = new short[SymbolCount]; Symbol = new short[SymbolCount];
for (short i = 0; i < n; i++) for (short i = 0; i < n; i++)

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -385,7 +385,7 @@ namespace OpenRA.FileFormats
void dec_bignum(uint[] n, uint len) void dec_bignum(uint[] n, uint len)
{ {
int i = 0; int i = 0;
while ((--n[i] == 0xffffffff) && (--len > 0)) while ((--n[i] == 0xffffffff) && (--len > 0))
i++; i++;
} }
@@ -495,7 +495,7 @@ namespace OpenRA.FileFormats
uint[] n3 = new uint[64]; uint[] n3 = new uint[64];
uint a = (pubkey.len - 1) / 8; uint a = (pubkey.len - 1) / 8;
while (a + 1 <= pre_len) while (a + 1 <= pre_len)
{ {
init_bignum(n2, 0, 64); init_bignum(n2, 0, 64);
fixed( uint * pn2 = &n2[0] ) fixed( uint * pn2 = &n2[0] )

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -129,7 +129,7 @@ namespace OpenRA.FileFormats
{ {
/* quick & dirty format80 encoder -- only uses raw copy operator, terminated with a zero-run. */ /* quick & dirty format80 encoder -- only uses raw copy operator, terminated with a zero-run. */
/* this does not produce good compression, but it's valid format80 */ /* this does not produce good compression, but it's valid format80 */
var ctx = new FastByteReader(src); var ctx = new FastByteReader(src);
var ms = new MemoryStream(); var ms = new MemoryStream();

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -54,7 +54,7 @@ namespace OpenRA.FileFormats
else else
return new Folder(filename, order, content); return new Folder(filename, order, content);
} }
public static IFolder OpenPackage(string filename, int order) public static IFolder OpenPackage(string filename, int order)
{ {
if (filename.EndsWith(".mix", StringComparison.InvariantCultureIgnoreCase)) if (filename.EndsWith(".mix", StringComparison.InvariantCultureIgnoreCase))
@@ -73,11 +73,11 @@ namespace OpenRA.FileFormats
{ {
var optional = name.StartsWith("~"); var optional = name.StartsWith("~");
if (optional) name = name.Substring(1); if (optional) name = name.Substring(1);
// paths starting with ^ are relative to the support dir // paths starting with ^ are relative to the support dir
if (name.StartsWith("^")) if (name.StartsWith("^"))
name = Platform.SupportDir+name.Substring(1); name = Platform.SupportDir+name.Substring(1);
var a = (Action)(() => FileSystem.MountInner(OpenPackage(name))); var a = (Action)(() => FileSystem.MountInner(OpenPackage(name)));
if (optional) if (optional)
@@ -198,7 +198,7 @@ namespace OpenRA.FileFormats
assemblyCache.Add(filename, a); assemblyCache.Add(filename, a);
return a; return a;
} }
return null; return null;
} }
} }

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -27,10 +27,10 @@ namespace OpenRA.FileFormats
this.priority = priority; this.priority = priority;
if (Directory.Exists(path)) if (Directory.Exists(path))
Directory.Delete(path, true); Directory.Delete(path, true);
Write(contents); Write(contents);
} }
public Folder(string path, int priority) public Folder(string path, int priority)
{ {
this.path = path; this.path = path;
@@ -50,7 +50,7 @@ namespace OpenRA.FileFormats
foreach( var filename in Directory.GetFiles( path, "*", SearchOption.TopDirectoryOnly ) ) foreach( var filename in Directory.GetFiles( path, "*", SearchOption.TopDirectoryOnly ) )
yield return PackageEntry.HashFilename( Path.GetFileName(filename) ); yield return PackageEntry.HashFilename( Path.GetFileName(filename) );
} }
public bool Exists(string filename) public bool Exists(string filename)
{ {
return File.Exists(Path.Combine(path,filename)); return File.Exists(Path.Combine(path,filename));
@@ -61,7 +61,7 @@ namespace OpenRA.FileFormats
{ {
get { return priority; } get { return priority; }
} }
public void Write(Dictionary<string, byte[]> contents) public void Write(Dictionary<string, byte[]> contents)
{ {
if (!Directory.Exists(path)) if (!Directory.Exists(path))

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -32,7 +32,7 @@ namespace OpenRA.FileFormats
uint signature = reader.ReadUInt32(); uint signature = reader.ReadUInt32();
if (signature != 0x8C655D13) if (signature != 0x8C655D13)
throw new InvalidDataException("Not an Installshield package"); throw new InvalidDataException("Not an Installshield package");
reader.ReadBytes(8); reader.ReadBytes(8);
/*var FileCount = */reader.ReadUInt16(); /*var FileCount = */reader.ReadUInt16();
reader.ReadBytes(4); reader.ReadBytes(4);
@@ -41,7 +41,7 @@ namespace OpenRA.FileFormats
var TOCAddress = reader.ReadInt32(); var TOCAddress = reader.ReadInt32();
reader.ReadBytes(4); reader.ReadBytes(4);
var DirCount = reader.ReadUInt16(); var DirCount = reader.ReadUInt16();
// Parse the directory list // Parse the directory list
s.Seek(TOCAddress, SeekOrigin.Begin); s.Seek(TOCAddress, SeekOrigin.Begin);
BinaryReader TOCreader = new BinaryReader(s); BinaryReader TOCreader = new BinaryReader(s);
@@ -56,15 +56,15 @@ namespace OpenRA.FileFormats
var ChunkSize = reader.ReadUInt16(); var ChunkSize = reader.ReadUInt16();
var NameLength = reader.ReadUInt16(); var NameLength = reader.ReadUInt16();
reader.ReadChars(NameLength); //var DirName = new String(reader.ReadChars(NameLength)); reader.ReadChars(NameLength); //var DirName = new String(reader.ReadChars(NameLength));
// Skip to the end of the chunk // Skip to the end of the chunk
reader.ReadBytes(ChunkSize - NameLength - 6); reader.ReadBytes(ChunkSize - NameLength - 6);
// Parse files // Parse files
for (var i = 0; i < FileCount; i++) for (var i = 0; i < FileCount; i++)
ParseFile(reader); ParseFile(reader);
} }
uint AccumulatedData = 0; uint AccumulatedData = 0;
void ParseFile(BinaryReader reader) void ParseFile(BinaryReader reader)
{ {
@@ -79,11 +79,11 @@ namespace OpenRA.FileFormats
var hash = PackageEntry.HashFilename(FileName); var hash = PackageEntry.HashFilename(FileName);
index.Add(hash, new PackageEntry(hash,AccumulatedData, CompressedSize)); index.Add(hash, new PackageEntry(hash,AccumulatedData, CompressedSize));
AccumulatedData += CompressedSize; AccumulatedData += CompressedSize;
// Skip to the end of the chunk // Skip to the end of the chunk
reader.ReadBytes(ChunkSize - NameLength - 30); reader.ReadBytes(ChunkSize - NameLength - 30);
} }
public Stream GetContent(uint hash) public Stream GetContent(uint hash)
{ {
PackageEntry e; PackageEntry e;
@@ -93,7 +93,7 @@ namespace OpenRA.FileFormats
s.Seek( dataStart + e.Offset, SeekOrigin.Begin ); s.Seek( dataStart + e.Offset, SeekOrigin.Begin );
byte[] data = new byte[ e.Length ]; byte[] data = new byte[ e.Length ];
s.Read( data, 0, (int)e.Length ); s.Read( data, 0, (int)e.Length );
return new MemoryStream(Blast.Decompress(data)); return new MemoryStream(Blast.Decompress(data));
} }
@@ -106,7 +106,7 @@ namespace OpenRA.FileFormats
{ {
return index.Keys; return index.Keys;
} }
public bool Exists(string filename) public bool Exists(string filename)
{ {
return index.ContainsKey(PackageEntry.HashFilename(filename)); return index.ContainsKey(PackageEntry.HashFilename(filename));
@@ -117,7 +117,7 @@ namespace OpenRA.FileFormats
{ {
get { return 2000 + priority; } get { return 2000 + priority; }
} }
public void Write(Dictionary<string, byte[]> contents) public void Write(Dictionary<string, byte[]> contents)
{ {
throw new NotImplementedException("Cannot save InstallShieldPackages."); throw new NotImplementedException("Cannot save InstallShieldPackages.");

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -31,14 +31,14 @@ namespace OpenRA.FileFormats
readonly long dataStart; readonly long dataStart;
readonly Stream s; readonly Stream s;
int priority; int priority;
// Create a new MixFile // Create a new MixFile
public MixFile(string filename, int priority, Dictionary<string, byte[]> contents) public MixFile(string filename, int priority, Dictionary<string, byte[]> contents)
{ {
this.priority = priority; this.priority = priority;
if (File.Exists(filename)) if (File.Exists(filename))
File.Delete(filename); File.Delete(filename);
s = File.Create(filename); s = File.Create(filename);
Write(contents); Write(contents);
} }
@@ -137,7 +137,7 @@ namespace OpenRA.FileFormats
dataStart = s.Position; dataStart = s.Position;
return items; return items;
} }
public Stream GetContent(uint hash) public Stream GetContent(uint hash)
{ {
PackageEntry e; PackageEntry e;
@@ -159,7 +159,7 @@ namespace OpenRA.FileFormats
{ {
return index.Keys; return index.Keys;
} }
public bool Exists(string filename) public bool Exists(string filename)
{ {
return index.ContainsKey(PackageEntry.HashFilename(filename)); return index.ContainsKey(PackageEntry.HashFilename(filename));
@@ -170,17 +170,17 @@ namespace OpenRA.FileFormats
{ {
get { return 1000 + priority; } get { return 1000 + priority; }
} }
public void Write(Dictionary<string, byte[]> contents) public void Write(Dictionary<string, byte[]> contents)
{ {
// Cannot modify existing mixfile - rename existing file and // Cannot modify existing mixfile - rename existing file and
// create a new one with original content plus modifications // create a new one with original content plus modifications
FileSystem.Unmount(this); FileSystem.Unmount(this);
// TODO: Add existing data to the contents list // TODO: Add existing data to the contents list
if (index.Count > 0) if (index.Count > 0)
throw new NotImplementedException("Updating mix files unfinished"); throw new NotImplementedException("Updating mix files unfinished");
// Construct a list of entries for the file header // Construct a list of entries for the file header
uint dataSize = 0; uint dataSize = 0;
var items = new List<PackageEntry>(); var items = new List<PackageEntry>();

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -44,7 +44,7 @@ namespace OpenRA.FileFormats
if (File.Exists(filename)) if (File.Exists(filename))
File.Delete(filename); File.Delete(filename);
pkg = SZipFile.Create(filename); pkg = SZipFile.Create(filename);
Write(contents); Write(contents);
} }
@@ -70,7 +70,7 @@ namespace OpenRA.FileFormats
foreach(ZipEntry entry in pkg) foreach(ZipEntry entry in pkg)
yield return PackageEntry.HashFilename(entry.Name); yield return PackageEntry.HashFilename(entry.Name);
} }
public bool Exists(string filename) public bool Exists(string filename)
{ {
return pkg.GetEntry(filename) != null; return pkg.GetEntry(filename) != null;
@@ -80,7 +80,7 @@ namespace OpenRA.FileFormats
{ {
get { return 500 + priority; } get { return 500 + priority; }
} }
public void Write(Dictionary<string, byte[]> contents) public void Write(Dictionary<string, byte[]> contents)
{ {
pkg.Close(); pkg.Close();
@@ -108,7 +108,7 @@ namespace OpenRA.FileFormats
{ {
this.data = data; this.data = data;
} }
public Stream GetSource() public Stream GetSource()
{ {
return new MemoryStream(data); return new MemoryStream(data);

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -83,14 +83,14 @@ namespace OpenRA.FileFormats
BinaryReader reader = new BinaryReader(stream); BinaryReader reader = new BinaryReader(stream);
ImageCount = reader.ReadUInt16(); ImageCount = reader.ReadUInt16();
//Last offset is pointer to end of file. //Last offset is pointer to end of file.
uint[] offsets = new uint[ImageCount + 1]; uint[] offsets = new uint[ImageCount + 1];
uint temp = reader.ReadUInt32(); uint temp = reader.ReadUInt32();
//If fourth byte in file is non-zero, the offsets are two bytes each. //If fourth byte in file is non-zero, the offsets are two bytes each.
bool twoByteOffsets = (temp & 0xFF0000) > 0; bool twoByteOffsets = (temp & 0xFF0000) > 0;
if (twoByteOffsets) if (twoByteOffsets)
{ {
offsets[0] = ((temp & 0xFFFF0000) >> 16) + 2; //Offset does not account for image count bytes offsets[0] = ((temp & 0xFFFF0000) >> 16) + 2; //Offset does not account for image count bytes
@@ -132,7 +132,7 @@ namespace OpenRA.FileFormats
{ {
get { return headers[index]; } get { return headers[index]; }
} }
public IEnumerator<Dune2ImageHeader> GetEnumerator() public IEnumerator<Dune2ImageHeader> GetEnumerator()
{ {
return headers.GetEnumerator(); return headers.GetEnumerator();

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -29,7 +29,7 @@ namespace OpenRA.FileFormats.Graphics
public interface IDeviceFactory public interface IDeviceFactory
{ {
IGraphicsDevice Create( Size size, WindowMode windowMode ); IGraphicsDevice Create( Size size, WindowMode windowMode );
} }
public interface IGraphicsDevice public interface IGraphicsDevice
@@ -75,8 +75,8 @@ namespace OpenRA.FileFormats.Graphics
public enum PrimitiveType public enum PrimitiveType
{ {
PointList, PointList,
LineList, LineList,
TriangleList, TriangleList,
QuadList, QuadList,
} }
@@ -86,7 +86,7 @@ namespace OpenRA.FileFormats.Graphics
public readonly T Start, End; public readonly T Start, End;
public Range( T start, T end ) { Start = start; End = end; } public Range( T start, T end ) { Start = start; End = end; }
} }
public enum WindowMode public enum WindowMode
{ {
Windowed, Windowed,

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS) * Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -19,7 +19,7 @@ namespace OpenRA.FileFormats
public readonly byte Framerate; public readonly byte Framerate;
public readonly ushort Width; public readonly ushort Width;
public readonly ushort Height; public readonly ushort Height;
Stream stream; Stream stream;
int currentFrame; int currentFrame;
ushort numColors; ushort numColors;
@@ -32,75 +32,75 @@ namespace OpenRA.FileFormats
// Stores a list of subpixels, referenced by the VPTZ chunk // Stores a list of subpixels, referenced by the VPTZ chunk
byte[] cbf; byte[] cbf;
byte[] cbp; byte[] cbp;
int cbChunk = 0; int cbChunk = 0;
int cbOffset = 0; int cbOffset = 0;
// Top half contains block info, bottom half contains references to cbf array // Top half contains block info, bottom half contains references to cbf array
byte[] origData; byte[] origData;
// Final frame output // Final frame output
uint[,] frameData; uint[,] frameData;
byte[] audioData; // audio for this frame: 22050Hz 16bit mono pcm, uncompressed. byte[] audioData; // audio for this frame: 22050Hz 16bit mono pcm, uncompressed.
public byte[] AudioData { get { return audioData; } } public byte[] AudioData { get { return audioData; } }
public int CurrentFrame { get { return currentFrame; } } public int CurrentFrame { get { return currentFrame; } }
public VqaReader( Stream stream ) public VqaReader( Stream stream )
{ {
this.stream = stream; this.stream = stream;
BinaryReader reader = new BinaryReader( stream ); BinaryReader reader = new BinaryReader( stream );
// Decode FORM chunk // Decode FORM chunk
if (new String(reader.ReadChars(4)) != "FORM") if (new String(reader.ReadChars(4)) != "FORM")
throw new InvalidDataException("Invalid vqa (invalid FORM section)"); throw new InvalidDataException("Invalid vqa (invalid FORM section)");
/*var length = */ reader.ReadUInt32(); /*var length = */ reader.ReadUInt32();
if (new String(reader.ReadChars(8)) != "WVQAVQHD") if (new String(reader.ReadChars(8)) != "WVQAVQHD")
throw new InvalidDataException("Invalid vqa (not WVQAVQHD)"); throw new InvalidDataException("Invalid vqa (not WVQAVQHD)");
/* var length = */reader.ReadUInt32(); /* var length = */reader.ReadUInt32();
/*var version = */reader.ReadUInt16(); /*var version = */reader.ReadUInt16();
/*var flags = */reader.ReadUInt16(); /*var flags = */reader.ReadUInt16();
Frames = reader.ReadUInt16(); Frames = reader.ReadUInt16();
Width = reader.ReadUInt16(); Width = reader.ReadUInt16();
Height = reader.ReadUInt16(); Height = reader.ReadUInt16();
blockWidth = reader.ReadByte(); blockWidth = reader.ReadByte();
blockHeight = reader.ReadByte(); blockHeight = reader.ReadByte();
Framerate = reader.ReadByte(); Framerate = reader.ReadByte();
cbParts = reader.ReadByte(); cbParts = reader.ReadByte();
blocks = new int2(Width / blockWidth, Height / blockHeight); blocks = new int2(Width / blockWidth, Height / blockHeight);
numColors = reader.ReadUInt16(); numColors = reader.ReadUInt16();
/*var maxBlocks = */reader.ReadUInt16(); /*var maxBlocks = */reader.ReadUInt16();
/*var unknown1 = */reader.ReadUInt16(); /*var unknown1 = */reader.ReadUInt16();
/*var unknown2 = */reader.ReadUInt32(); /*var unknown2 = */reader.ReadUInt32();
// Audio // Audio
/*var freq = */reader.ReadUInt16(); /*var freq = */reader.ReadUInt16();
/*var channels = */reader.ReadByte(); /*var channels = */reader.ReadByte();
/*var bits = */reader.ReadByte(); /*var bits = */reader.ReadByte();
/*var unknown3 = */reader.ReadChars(14); /*var unknown3 = */reader.ReadChars(14);
var frameSize = Exts.NextPowerOf2(Math.Max(Width,Height)); var frameSize = Exts.NextPowerOf2(Math.Max(Width,Height));
cbf = new byte[Width*Height]; cbf = new byte[Width*Height];
cbp = new byte[Width*Height]; cbp = new byte[Width*Height];
palette = new uint[numColors]; palette = new uint[numColors];
origData = new byte[2*blocks.X*blocks.Y]; origData = new byte[2*blocks.X*blocks.Y];
frameData = new uint[frameSize,frameSize]; frameData = new uint[frameSize,frameSize];
var type = new String(reader.ReadChars(4)); var type = new String(reader.ReadChars(4));
if (type != "FINF") if (type != "FINF")
{ {
reader.ReadBytes(27); reader.ReadBytes(27);
type = new String(reader.ReadChars(4)); type = new String(reader.ReadChars(4));
} }
/*var length = */reader.ReadUInt16(); /*var length = */reader.ReadUInt16();
/*var unknown4 = */reader.ReadUInt16(); /*var unknown4 = */reader.ReadUInt16();
// Frame offsets // Frame offsets
offsets = new UInt32[Frames]; offsets = new UInt32[Frames];
for (int i = 0; i < Frames; i++) for (int i = 0; i < Frames; i++)
@@ -111,7 +111,7 @@ namespace OpenRA.FileFormats
} }
CollectAudioData(); CollectAudioData();
Reset(); Reset();
} }
@@ -120,7 +120,7 @@ namespace OpenRA.FileFormats
currentFrame = cbOffset = cbChunk = 0; currentFrame = cbOffset = cbChunk = 0;
LoadFrame(); LoadFrame();
} }
void CollectAudioData() void CollectAudioData()
{ {
var ms = new MemoryStream(); var ms = new MemoryStream();
@@ -163,17 +163,17 @@ namespace OpenRA.FileFormats
currentFrame++; currentFrame++;
LoadFrame(); LoadFrame();
} }
void LoadFrame() void LoadFrame()
{ {
if (currentFrame >= Frames) if (currentFrame >= Frames)
return; return;
// Seek to the start of the frame // Seek to the start of the frame
stream.Seek(offsets[currentFrame], SeekOrigin.Begin); stream.Seek(offsets[currentFrame], SeekOrigin.Begin);
BinaryReader reader = new BinaryReader(stream); BinaryReader reader = new BinaryReader(stream);
var end = (currentFrame < Frames - 1) ? offsets[currentFrame+1] : stream.Length; var end = (currentFrame < Frames - 1) ? offsets[currentFrame+1] : stream.Length;
while(reader.BaseStream.Position < end) while(reader.BaseStream.Position < end)
{ {
var type = new String(reader.ReadChars(4)); var type = new String(reader.ReadChars(4));
@@ -189,17 +189,17 @@ namespace OpenRA.FileFormats
reader.ReadBytes((int)length); reader.ReadBytes((int)length);
break; break;
} }
// Chunks are aligned on even bytes; advance by a byte if the next one is null // Chunks are aligned on even bytes; advance by a byte if the next one is null
if (reader.PeekChar() == 0) reader.ReadByte(); if (reader.PeekChar() == 0) reader.ReadByte();
} }
} }
// VQA Frame // VQA Frame
public void DecodeVQFR(BinaryReader reader) public void DecodeVQFR(BinaryReader reader)
{ {
while(true) while(true)
{ {
// Chunks are aligned on even bytes; may be padded with a single null // Chunks are aligned on even bytes; may be padded with a single null
if (reader.PeekChar() == 0) reader.ReadByte(); if (reader.PeekChar() == 0) reader.ReadByte();
var type = new String(reader.ReadChars(4)); var type = new String(reader.ReadChars(4));
@@ -214,9 +214,9 @@ namespace OpenRA.FileFormats
case "CBF0": case "CBF0":
cbf = reader.ReadBytes(subchunkLength); cbf = reader.ReadBytes(subchunkLength);
break; break;
// frame-modifier chunk // frame-modifier chunk
case "CBP0": case "CBP0":
case "CBPZ": case "CBPZ":
// Partial buffer is full; dump and recreate // Partial buffer is full; dump and recreate
if (cbChunk == cbParts) if (cbChunk == cbParts)
@@ -225,16 +225,16 @@ namespace OpenRA.FileFormats
cbf = (byte[])cbp.Clone(); cbf = (byte[])cbp.Clone();
else else
Format80.DecodeInto( cbp, cbf ); Format80.DecodeInto( cbp, cbf );
cbOffset = cbChunk = 0; cbOffset = cbChunk = 0;
} }
var bytes = reader.ReadBytes(subchunkLength); var bytes = reader.ReadBytes(subchunkLength);
bytes.CopyTo(cbp,cbOffset); bytes.CopyTo(cbp,cbOffset);
cbOffset += subchunkLength; cbOffset += subchunkLength;
cbChunk++; cbChunk++;
break; break;
// Palette // Palette
case "CPL0": case "CPL0":
for (int i = 0; i < numColors; i++) for (int i = 0; i < numColors; i++)
@@ -245,7 +245,7 @@ namespace OpenRA.FileFormats
palette[i] = (uint)((255 << 24) | (r << 16) | (g << 8) | b); palette[i] = (uint)((255 << 24) | (r << 16) | (g << 8) | b);
} }
break; break;
// Frame data // Frame data
case "VPTZ": case "VPTZ":
Format80.DecodeInto( reader.ReadBytes(subchunkLength), origData ); Format80.DecodeInto( reader.ReadBytes(subchunkLength), origData );
@@ -256,7 +256,7 @@ namespace OpenRA.FileFormats
} }
} }
} }
int cachedFrame = -1; int cachedFrame = -1;
void DecodeFrameData( int frame ) void DecodeFrameData( int frame )

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -42,7 +42,7 @@ namespace OpenRA.FileFormats
{ {
if (!Directory.Exists(destPath)) if (!Directory.Exists(destPath))
Directory.CreateDirectory(destPath); Directory.CreateDirectory(destPath);
if (!Directory.Exists(srcPath)) { onError("Cannot find "+package); return false; } if (!Directory.Exists(srcPath)) { onError("Cannot find "+package); return false; }
FileSystem.Mount(srcPath); FileSystem.Mount(srcPath);
if (!FileSystem.Exists(package)) { onError("Cannot find "+package); return false; } if (!FileSystem.Exists(package)) { onError("Cannot find "+package); return false; }
@@ -60,7 +60,7 @@ namespace OpenRA.FileFormats
} }
return true; return true;
} }
public static bool CopyFiles(string srcPath, string[] files, string destPath, Action<string> onProgress, Action<string> onError) public static bool CopyFiles(string srcPath, string[] files, string destPath, Action<string> onProgress, Action<string> onError)
{ {
foreach (var file in files) foreach (var file in files)
@@ -77,7 +77,7 @@ namespace OpenRA.FileFormats
} }
return true; return true;
} }
public static bool ExtractZip(string zipFile, string dest, Action<string> onProgress, Action<string> onError) public static bool ExtractZip(string zipFile, string dest, Action<string> onProgress, Action<string> onError)
{ {
if (!File.Exists(zipFile)) if (!File.Exists(zipFile))
@@ -85,7 +85,7 @@ namespace OpenRA.FileFormats
onError("Invalid path: "+zipFile); onError("Invalid path: "+zipFile);
return false; return false;
} }
List<string> extracted = new List<string>(); List<string> extracted = new List<string>();
try try
{ {
@@ -96,26 +96,26 @@ namespace OpenRA.FileFormats
{ {
foreach(var f in extracted) foreach(var f in extracted)
File.Delete(f); File.Delete(f);
onError("Invalid archive"); onError("Invalid archive");
return false; return false;
} }
return true; return true;
} }
// TODO: this belongs in FileSystem/ZipFile // TODO: this belongs in FileSystem/ZipFile
static void ExtractZip(this ZipInputStream z, string destPath, List<string> extracted, Action<string> onProgress) static void ExtractZip(this ZipInputStream z, string destPath, List<string> extracted, Action<string> onProgress)
{ {
foreach (var entry in z.GetEntries()) foreach (var entry in z.GetEntries())
{ {
if (!entry.IsFile) continue; if (!entry.IsFile) continue;
onProgress(entry.Name); onProgress(entry.Name);
Directory.CreateDirectory(Path.Combine(destPath, Path.GetDirectoryName(entry.Name))); Directory.CreateDirectory(Path.Combine(destPath, Path.GetDirectoryName(entry.Name)));
var path = Path.Combine(destPath, entry.Name); var path = Path.Combine(destPath, entry.Name);
extracted.Add(path); extracted.Add(path);
using (var f = File.Create(path)) using (var f = File.Create(path))
{ {
int bufSize = 2048; int bufSize = 2048;
@@ -124,7 +124,7 @@ namespace OpenRA.FileFormats
f.Write(buf, 0, bufSize); f.Write(buf, 0, bufSize);
} }
} }
z.Close(); z.Close();
} }
} }

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -48,7 +48,7 @@ namespace OpenRA.FileFormats
Movies = YamlList(yaml, "Movies"); Movies = YamlList(yaml, "Movies");
TileSets = YamlList(yaml, "TileSets"); TileSets = YamlList(yaml, "TileSets");
ChromeMetrics = YamlList(yaml, "ChromeMetrics"); ChromeMetrics = YamlList(yaml, "ChromeMetrics");
LoadScreen = yaml["LoadScreen"]; LoadScreen = yaml["LoadScreen"];
Fonts = yaml["Fonts"].NodesDict.ToDictionary(x => x.Key, x => Pair.New(x.Value.NodesDict["Font"].Value, Fonts = yaml["Fonts"].NodesDict.ToDictionary(x => x.Key, x => Pair.New(x.Value.NodesDict["Font"].Value,
int.Parse(x.Value.NodesDict["Size"].Value))); int.Parse(x.Value.NodesDict["Size"].Value)));

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -39,7 +39,7 @@ namespace OpenRA.FileFormats
public int InitialCash = 0; public int InitialCash = 0;
public string[] Allies = {}; public string[] Allies = {};
public string[] Enemies = {}; public string[] Enemies = {};
public PlayerReference() {} public PlayerReference() {}
public PlayerReference(MiniYaml my) public PlayerReference(MiniYaml my)
{ {

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -21,7 +21,7 @@ namespace OpenRA.FileFormats
Location = location; Location = location;
Depth = depth; Depth = depth;
} }
public override string ToString () public override string ToString ()
{ {
return string.Format("{0} {1},{2} {3}", Type, Location.X,Location.Y, Depth); return string.Format("{0} {1},{2} {3}", Type, Location.X,Location.Y, Depth);

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -18,35 +18,35 @@ namespace OpenRA.FileFormats
public readonly List<byte[]> TileBitmapBytes = new List<byte[]>(); public readonly List<byte[]> TileBitmapBytes = new List<byte[]>();
public Terrain( Stream stream, int size ) public Terrain( Stream stream, int size )
{ {
// Try loading as a cnc .tem // Try loading as a cnc .tem
BinaryReader reader = new BinaryReader( stream ); BinaryReader reader = new BinaryReader( stream );
int Width = reader.ReadUInt16(); int Width = reader.ReadUInt16();
int Height = reader.ReadUInt16(); int Height = reader.ReadUInt16();
if( Width != size || Height != size ) if( Width != size || Height != size )
throw new InvalidDataException( "{0}x{1} != {2}x{2}".F(Width, Height, size ) ); throw new InvalidDataException( "{0}x{1} != {2}x{2}".F(Width, Height, size ) );
/*NumTiles = */reader.ReadUInt16(); /*NumTiles = */reader.ReadUInt16();
/*Zero1 = */reader.ReadUInt16(); /*Zero1 = */reader.ReadUInt16();
/*uint Size = */reader.ReadUInt32(); /*uint Size = */reader.ReadUInt32();
uint ImgStart = reader.ReadUInt32(); uint ImgStart = reader.ReadUInt32();
/*Zero2 = */reader.ReadUInt32(); /*Zero2 = */reader.ReadUInt32();
int IndexEnd, IndexStart; int IndexEnd, IndexStart;
if (reader.ReadUInt16() == 65535) // ID1 = FFFFh for cnc if (reader.ReadUInt16() == 65535) // ID1 = FFFFh for cnc
{ {
/*ID2 = */reader.ReadUInt16(); /*ID2 = */reader.ReadUInt16();
IndexEnd = reader.ReadInt32(); IndexEnd = reader.ReadInt32();
IndexStart = reader.ReadInt32(); IndexStart = reader.ReadInt32();
} }
else // Load as a ra .tem else // Load as a ra .tem
{ {
stream.Position = 0; stream.Position = 0;
reader = new BinaryReader( stream ); reader = new BinaryReader( stream );
Width = reader.ReadUInt16(); Width = reader.ReadUInt16();
Height = reader.ReadUInt16(); Height = reader.ReadUInt16();
/*NumTiles = */reader.ReadUInt16(); /*NumTiles = */reader.ReadUInt16();
reader.ReadUInt16(); reader.ReadUInt16();
/*XDim = */reader.ReadUInt16(); /*XDim = */reader.ReadUInt16();
@@ -57,7 +57,7 @@ namespace OpenRA.FileFormats
reader.ReadUInt32(); reader.ReadUInt32();
IndexEnd = reader.ReadInt32(); IndexEnd = reader.ReadInt32();
reader.ReadUInt32(); reader.ReadUInt32();
IndexStart = reader.ReadInt32(); IndexStart = reader.ReadInt32();
} }
stream.Position = IndexStart; stream.Position = IndexStart;

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -14,7 +14,7 @@ namespace OpenRA.FileFormats
{ {
public T type; public T type;
public U index; public U index;
public TileReference(T t, U i) public TileReference(T t, U i)
{ {
type = t; type = t;

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -27,7 +27,7 @@ namespace OpenRA.FileFormats
public TerrainTypeInfo(MiniYaml my) { FieldLoader.Load(this, my); } public TerrainTypeInfo(MiniYaml my) { FieldLoader.Load(this, my); }
public MiniYaml Save() { return FieldSaver.Save(this); } public MiniYaml Save() { return FieldSaver.Save(this); }
} }
public class TileTemplate public class TileTemplate
{ {
public ushort Id; public ushort Id;
@@ -37,7 +37,7 @@ namespace OpenRA.FileFormats
[FieldLoader.LoadUsing( "LoadTiles" )] [FieldLoader.LoadUsing( "LoadTiles" )]
public Dictionary<byte, string> Tiles = new Dictionary<byte, string>(); public Dictionary<byte, string> Tiles = new Dictionary<byte, string>();
public TileTemplate() {} public TileTemplate() {}
public TileTemplate(MiniYaml my) public TileTemplate(MiniYaml my)
{ {
@@ -50,7 +50,7 @@ namespace OpenRA.FileFormats
t => byte.Parse(t.Key), t => byte.Parse(t.Key),
t => t.Value.Value ); t => t.Value.Value );
} }
public MiniYaml Save() public MiniYaml Save()
{ {
var root = new List<MiniYamlNode>(); var root = new List<MiniYamlNode>();
@@ -63,11 +63,11 @@ namespace OpenRA.FileFormats
root.Add( new MiniYamlNode( "Tiles", null, root.Add( new MiniYamlNode( "Tiles", null,
Tiles.Select( x => new MiniYamlNode( x.Key.ToString(), x.Value ) ).ToList() ) ); Tiles.Select( x => new MiniYamlNode( x.Key.ToString(), x.Value ) ).ToList() ) );
return new MiniYaml(null, root); return new MiniYaml(null, root);
} }
} }
public class TileSet public class TileSet
{ {
public string Name; public string Name;
@@ -84,7 +84,7 @@ namespace OpenRA.FileFormats
public TileSet( string filepath ) public TileSet( string filepath )
{ {
var yaml = MiniYaml.DictFromFile( filepath ); var yaml = MiniYaml.DictFromFile( filepath );
// General info // General info
FieldLoader.Load(this, yaml["General"]); FieldLoader.Load(this, yaml["General"]);
@@ -96,7 +96,7 @@ namespace OpenRA.FileFormats
Templates = yaml["Templates"].NodesDict.Values Templates = yaml["Templates"].NodesDict.Values
.Select(y => new TileTemplate(y)).ToDictionary(t => t.Id); .Select(y => new TileTemplate(y)).ToDictionary(t => t.Id);
} }
public void LoadTiles() public void LoadTiles()
{ {
foreach (var t in Templates) foreach (var t in Templates)
@@ -106,9 +106,9 @@ namespace OpenRA.FileFormats
Tiles.Add( t.Key, new Terrain( s, TileSize ) ); Tiles.Add( t.Key, new Terrain( s, TileSize ) );
} }
} }
public void Save(string filepath) public void Save(string filepath)
{ {
var root = new List<MiniYamlNode>(); var root = new List<MiniYamlNode>();
var gen = new List<MiniYamlNode>(); var gen = new List<MiniYamlNode>();
foreach (var field in fields) foreach (var field in fields)
@@ -119,7 +119,7 @@ namespace OpenRA.FileFormats
} }
root.Add( new MiniYamlNode( "General", null, gen ) ); root.Add( new MiniYamlNode( "General", null, gen ) );
root.Add( new MiniYamlNode( "Terrain", null, root.Add( new MiniYamlNode( "Terrain", null,
Terrain.Select( t => new MiniYamlNode( Terrain.Select( t => new MiniYamlNode(
"TerrainType@{0}".F( t.Value.Type ), "TerrainType@{0}".F( t.Value.Type ),
t.Value.Save() ) ).ToList() ) ); t.Value.Save() ) ).ToList() ) );
@@ -129,14 +129,14 @@ namespace OpenRA.FileFormats
"Template@{0}".F( t.Value.Id ), "Template@{0}".F( t.Value.Id ),
t.Value.Save() ) ).ToList() ) ); t.Value.Save() ) ).ToList() ) );
root.WriteToFile(filepath); root.WriteToFile(filepath);
} }
public byte[] GetBytes(TileReference<ushort,byte> r) public byte[] GetBytes(TileReference<ushort,byte> r)
{ {
Terrain tile; Terrain tile;
if( Tiles.TryGetValue( r.type, out tile ) ) if( Tiles.TryGetValue( r.type, out tile ) )
return tile.TileBitmapBytes[ r.index ]; return tile.TileBitmapBytes[ r.index ];
byte[] missingTile = new byte[ TileSize * TileSize ]; byte[] missingTile = new byte[ TileSize * TileSize ];
for( int i = 0 ; i < missingTile.Length ; i++ ) for( int i = 0 ; i < missingTile.Length ; i++ )
missingTile[ i ] = 0x36; missingTile[ i ] = 0x36;

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -98,7 +98,7 @@ namespace OpenRA.FileFormats
{ {
return new MiniYaml( null, list.Select( x => new MiniYamlNode( x.ToString(), new MiniYaml( null ) ) ).ToList() ); return new MiniYaml( null, list.Select( x => new MiniYamlNode( x.ToString(), new MiniYaml( null ) ) ).ToList() );
} }
static List<MiniYamlNode> FromLines(string[] lines, string filename) static List<MiniYamlNode> FromLines(string[] lines, string filename)
{ {
var levels = new List<List<MiniYamlNode>>(); var levels = new List<List<MiniYamlNode>>();
@@ -121,7 +121,7 @@ namespace OpenRA.FileFormats
var d = new List<MiniYamlNode>(); var d = new List<MiniYamlNode>();
var rhs = SplitAtColon( ref t ); var rhs = SplitAtColon( ref t );
levels[ level ].Add( new MiniYamlNode( t, rhs, d, new MiniYamlNode.SourceLocation { Filename = filename, Line = lineNo } ) ); levels[ level ].Add( new MiniYamlNode( t, rhs, d, new MiniYamlNode.SourceLocation { Filename = filename, Line = lineNo } ) );
levels.Add(d); levels.Add(d);
} }
return levels[ 0 ]; return levels[ 0 ];
@@ -143,11 +143,11 @@ namespace OpenRA.FileFormats
{ {
StreamReader reader = new StreamReader( FileSystem.Open(path) ); StreamReader reader = new StreamReader( FileSystem.Open(path) );
List<string> lines = new List<string>(); List<string> lines = new List<string>();
while( !reader.EndOfStream ) while( !reader.EndOfStream )
lines.Add(reader.ReadLine()); lines.Add(reader.ReadLine());
reader.Close(); reader.Close();
return FromLines(lines.ToArray(), path); return FromLines(lines.ToArray(), path);
} }
@@ -162,7 +162,7 @@ namespace OpenRA.FileFormats
} }
public static List<MiniYamlNode> FromFile( string path ) public static List<MiniYamlNode> FromFile( string path )
{ {
return FromLines(File.ReadAllLines( path ), path); return FromLines(File.ReadAllLines( path ), path);
} }
@@ -273,7 +273,7 @@ namespace OpenRA.FileFormats
{ {
return string.Join("\n", y.ToLines(true).Select(x => x.TrimEnd()).ToArray()); return string.Join("\n", y.ToLines(true).Select(x => x.TrimEnd()).ToArray());
} }
public static IEnumerable<string> ToLines(this MiniYamlNodes y, bool lowest) public static IEnumerable<string> ToLines(this MiniYamlNodes y, bool lowest)
{ {
foreach (var kv in y) foreach (var kv in y)

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -20,21 +20,21 @@ namespace OpenRA.FileFormats
public readonly uint Offset; public readonly uint Offset;
public readonly uint Length; public readonly uint Length;
public PackageEntry(uint hash, uint offset, uint length) public PackageEntry(uint hash, uint offset, uint length)
{ {
Hash = hash; Hash = hash;
Offset = offset; Offset = offset;
Length = length; Length = length;
} }
public PackageEntry(BinaryReader r) public PackageEntry(BinaryReader r)
{ {
Hash = r.ReadUInt32(); Hash = r.ReadUInt32();
Offset = r.ReadUInt32(); Offset = r.ReadUInt32();
Length = r.ReadUInt32(); Length = r.ReadUInt32();
} }
public void Write(BinaryWriter w) public void Write(BinaryWriter w)
{ {
w.Write(Hash); w.Write(Hash);
@@ -63,7 +63,7 @@ namespace OpenRA.FileFormats
MemoryStream ms = new MemoryStream(Encoding.ASCII.GetBytes(name)); MemoryStream ms = new MemoryStream(Encoding.ASCII.GetBytes(name));
BinaryReader reader = new BinaryReader(ms); BinaryReader reader = new BinaryReader(ms);
int len = name.Length >> 2; int len = name.Length >> 2;
uint result = 0; uint result = 0;
while (len-- != 0) while (len-- != 0)
@@ -73,7 +73,7 @@ namespace OpenRA.FileFormats
} }
static Dictionary<uint, string> Names = new Dictionary<uint,string>(); static Dictionary<uint, string> Names = new Dictionary<uint,string>();
public static void AddStandardName(string s) public static void AddStandardName(string s)
{ {
uint hash = HashFilename(s); uint hash = HashFilename(s);

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -23,26 +23,26 @@ namespace OpenRA.FileFormats
{ {
return Color.FromArgb((int)colors[index]); return Color.FromArgb((int)colors[index]);
} }
public void SetColor(int index, Color color) public void SetColor(int index, Color color)
{ {
colors[index] = (uint)color.ToArgb(); colors[index] = (uint)color.ToArgb();
} }
public void SetColor(int index, uint color) public void SetColor(int index, uint color)
{ {
colors[index] = (uint)color; colors[index] = (uint)color;
} }
public uint[] Values public uint[] Values
{ {
get { return colors; } get { return colors; }
} }
public Palette(Stream s, bool remapTransparent) public Palette(Stream s, bool remapTransparent)
{ {
colors = new uint[256]; colors = new uint[256];
using (BinaryReader reader = new BinaryReader(s)) using (BinaryReader reader = new BinaryReader(s))
{ {
for (int i = 0; i < 256; i++) for (int i = 0; i < 256; i++)
@@ -69,26 +69,26 @@ namespace OpenRA.FileFormats
for(int i = 0; i < 256; i++) for(int i = 0; i < 256; i++)
colors[i] = (uint)r.GetRemappedColor(Color.FromArgb((int)p.colors[i]),i).ToArgb(); colors[i] = (uint)r.GetRemappedColor(Color.FromArgb((int)p.colors[i]),i).ToArgb();
} }
public Palette(Palette p) public Palette(Palette p)
{ {
colors = (uint[])p.colors.Clone(); colors = (uint[])p.colors.Clone();
} }
public ColorPalette AsSystemPalette() public ColorPalette AsSystemPalette()
{ {
ColorPalette pal; ColorPalette pal;
using (var b = new Bitmap(1, 1, PixelFormat.Format8bppIndexed)) using (var b = new Bitmap(1, 1, PixelFormat.Format8bppIndexed))
pal = b.Palette; pal = b.Palette;
for (var i = 0; i < 256; i++) for (var i = 0; i < 256; i++)
pal.Entries[i] = GetColor(i); pal.Entries[i] = GetColor(i);
// hack around a mono bug -- the palette flags get set wrong. // hack around a mono bug -- the palette flags get set wrong.
if (Platform.CurrentPlatform != PlatformType.Windows) if (Platform.CurrentPlatform != PlatformType.Windows)
typeof(ColorPalette).GetField("flags", typeof(ColorPalette).GetField("flags",
BindingFlags.Instance | BindingFlags.NonPublic).SetValue(pal, 1); BindingFlags.Instance | BindingFlags.NonPublic).SetValue(pal, 1);
return pal; return pal;
} }
} }

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -22,7 +22,7 @@ namespace OpenRA
public static PlatformType CurrentPlatform { get { return currentPlatform.Value; } } public static PlatformType CurrentPlatform { get { return currentPlatform.Value; } }
static Lazy<PlatformType> currentPlatform = new Lazy<PlatformType>(GetCurrentPlatform); static Lazy<PlatformType> currentPlatform = new Lazy<PlatformType>(GetCurrentPlatform);
static PlatformType GetCurrentPlatform() static PlatformType GetCurrentPlatform()
{ {
if (Environment.OSVersion.Platform == PlatformID.Win32NT) if (Environment.OSVersion.Platform == PlatformID.Win32NT)

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -42,11 +42,11 @@ namespace OpenRA.FileFormats
(int)(t * c2.G + (1 - t) * c1.G), (int)(t * c2.G + (1 - t) * c1.G),
(int)(t * c2.B + (1 - t) * c1.B)); (int)(t * c2.B + (1 - t) * c1.B));
} }
public Color GetRemappedColor(Color original, int index) public Color GetRemappedColor(Color original, int index)
{ {
Color c; Color c;
return remapColors.TryGetValue(index, out c) return remapColors.TryGetValue(index, out c)
? c : original; ? c : original;
} }
} }

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -40,7 +40,7 @@ namespace OpenRA.FileFormats
} }
public T Force() { return Value; } public T Force() { return Value; }
public void Invalidate() public void Invalidate()
{ {
hasValue = false; hasValue = false;

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -74,7 +74,7 @@ namespace OpenRA.FileFormats
public static class Pair public static class Pair
{ {
public static Pair<T, U> New<T, U>(T t, U u) { return new Pair<T, U>(t, u); } public static Pair<T, U> New<T, U>(T t, U u) { return new Pair<T, U>(t, u); }
static Pair() static Pair()
{ {
Pair<char,Color>.uc = new ColorEqualityComparer(); Pair<char,Color>.uc = new ColorEqualityComparer();

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -56,7 +56,7 @@ namespace OpenRA
public float2 ToFloat2() { return new float2(X, Y); } public float2 ToFloat2() { return new float2(X, Y); }
public override string ToString() { return string.Format("{0},{1}", X, Y); } public override string ToString() { return string.Format("{0},{1}", X, Y); }
// Change endianness of a uint32 // Change endianness of a uint32
public static uint Swap(uint orig) public static uint Swap(uint orig)
{ {
@@ -72,13 +72,13 @@ namespace OpenRA
{ {
return a + ( b - a ) * mul / div; return a + ( b - a ) * mul / div;
} }
public int2 Clamp(Rectangle r) public int2 Clamp(Rectangle r)
{ {
return new int2(Math.Min(r.Right, Math.Max(X, r.Left)), return new int2(Math.Min(r.Right, Math.Max(X, r.Left)),
Math.Min(r.Bottom, Math.Max(Y, r.Top))); Math.Min(r.Bottom, Math.Max(Y, r.Top)));
} }
public static int Dot(int2 a, int2 b) { return a.X * b.X + a.Y * b.Y; } public static int Dot(int2 a, int2 b) { return a.X * b.X + a.Y * b.Y; }
} }

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -33,7 +33,7 @@ namespace OpenRA
get { return LogPathPrefix; } get { return LogPathPrefix; }
set set
{ {
LogPathPrefix = value; LogPathPrefix = value;
Directory.CreateDirectory(LogPathPrefix); Directory.CreateDirectory(LogPathPrefix);
} }
} }
@@ -41,7 +41,7 @@ namespace OpenRA
static IEnumerable<string> FilenamesForChannel(string channelName, string baseFilename) static IEnumerable<string> FilenamesForChannel(string channelName, string baseFilename)
{ {
for(var i = 0;; i++ ) for(var i = 0;; i++ )
yield return Path.Combine(LogPathPrefix, yield return Path.Combine(LogPathPrefix,
i > 0 ? "{0}.{1}".F(baseFilename, i) : baseFilename); i > 0 ? "{0}.{1}".F(baseFilename, i) : baseFilename);
} }

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -18,11 +18,11 @@ namespace OpenRA.Thirdparty
{ {
uint[] mt = new uint[624]; uint[] mt = new uint[624];
int index = 0; int index = 0;
public int Last; public int Last;
public Random() : this(Environment.TickCount) { } public Random() : this(Environment.TickCount) { }
public Random(int seed) public Random(int seed)
{ {
mt[0] = (uint)seed; mt[0] = (uint)seed;

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -34,7 +34,7 @@ namespace OpenRA
public IOccupySpace OccupiesSpace { get { return occupySpace.Value; } } public IOccupySpace OccupiesSpace { get { return occupySpace.Value; } }
public int2 Location { get { return occupySpace.Value.TopLeft; } } public int2 Location { get { return occupySpace.Value.TopLeft; } }
public int2 CenterLocation public int2 CenterLocation
{ {
get get
@@ -44,7 +44,7 @@ namespace OpenRA
return HasLocation.PxPosition; return HasLocation.PxPosition;
} }
} }
[Sync] [Sync]
public Player Owner; public Player Owner;
@@ -71,7 +71,7 @@ namespace OpenRA
foreach (var trait in Info.TraitsInConstructOrder()) foreach (var trait in Info.TraitsInConstructOrder())
AddTrait(trait.Create(init)); AddTrait(trait.Create(init));
} }
Move = Lazy.New( () => TraitOrDefault<IMove>() ); Move = Lazy.New( () => TraitOrDefault<IMove>() );
Size = Lazy.New(() => Size = Lazy.New(() =>
@@ -88,7 +88,7 @@ namespace OpenRA
ApplyIRender = x => x.Render(this); ApplyIRender = x => x.Render(this);
ApplyRenderModifier = (m, p) => p.ModifyRender(this, m); ApplyRenderModifier = (m, p) => p.ModifyRender(this, m);
Bounds = Cached.New( () => CalculateBounds(false) ); Bounds = Cached.New( () => CalculateBounds(false) );
ExtendedBounds = Cached.New( () => CalculateBounds(true) ); ExtendedBounds = Cached.New( () => CalculateBounds(true) );
} }
@@ -97,7 +97,7 @@ namespace OpenRA
{ {
Bounds.Invalidate(); Bounds.Invalidate();
ExtendedBounds.Invalidate(); ExtendedBounds.Invalidate();
currentActivity = Util.RunActivity( this, currentActivity ); currentActivity = Util.RunActivity( this, currentActivity );
} }
@@ -117,7 +117,7 @@ namespace OpenRA
var sprites = TraitsImplementing<IRender>().SelectMany(ApplyIRender); var sprites = TraitsImplementing<IRender>().SelectMany(ApplyIRender);
return mods.Aggregate(sprites, ApplyRenderModifier); return mods.Aggregate(sprites, ApplyRenderModifier);
} }
// When useAltitude = true, the bounding box is extended // When useAltitude = true, the bounding box is extended
// vertically to altitude = 0 to support FindUnitsInCircle queries // vertically to altitude = 0 to support FindUnitsInCircle queries
// When false, the bounding box is given for the actor // When false, the bounding box is given for the actor
@@ -126,7 +126,7 @@ namespace OpenRA
{ {
var size = Size.Value; var size = Size.Value;
var loc = CenterLocation - size / 2; var loc = CenterLocation - size / 2;
var si = Info.Traits.GetOrDefault<SelectableInfo>(); var si = Info.Traits.GetOrDefault<SelectableInfo>();
if (si != null && si.Bounds != null && si.Bounds.Length > 2) if (si != null && si.Bounds != null && si.Bounds.Length > 2)
{ {
@@ -141,7 +141,7 @@ namespace OpenRA
if (useAltitude) if (useAltitude)
size = new int2(size.X, size.Y + move.Altitude); size = new int2(size.X, size.Y + move.Altitude);
} }
return new Rectangle(loc.X, loc.Y, size.X, size.Y); return new Rectangle(loc.X, loc.Y, size.X, size.Y);
} }

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -30,7 +30,7 @@ namespace OpenRA
public U Get<T,U>() where T : IActorInit<U> { return dict.Get<T>().Value( world ); } public U Get<T,U>() where T : IActorInit<U> { return dict.Get<T>().Value( world ); }
public bool Contains<T>() where T : IActorInit { return dict.Contains<T>(); } public bool Contains<T>() where T : IActorInit { return dict.Contains<T>(); }
} }
public interface IActorInit {} public interface IActorInit {}
public interface IActorInit<T> : IActorInit public interface IActorInit<T> : IActorInit

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -26,7 +26,7 @@ namespace OpenRA
BottomLeft, BottomLeft,
BottomRight BottomRight
} }
public class ActorMap public class ActorMap
{ {
class InfluenceNode class InfluenceNode
@@ -35,7 +35,7 @@ namespace OpenRA
public SubCell subCell; public SubCell subCell;
public Actor actor; public Actor actor;
} }
InfluenceNode[,] influence; InfluenceNode[,] influence;
Map map; Map map;
@@ -56,7 +56,7 @@ namespace OpenRA
if (!i.actor.Destroyed) if (!i.actor.Destroyed)
yield return i.actor; yield return i.actor;
} }
public IEnumerable<Actor> GetUnitsAt( int2 a, SubCell sub ) public IEnumerable<Actor> GetUnitsAt( int2 a, SubCell sub )
{ {
if (!map.IsInMap(a)) yield break; if (!map.IsInMap(a)) yield break;
@@ -65,12 +65,12 @@ namespace OpenRA
if (!i.actor.Destroyed && (i.subCell == sub || i.subCell == SubCell.FullCell)) if (!i.actor.Destroyed && (i.subCell == sub || i.subCell == SubCell.FullCell))
yield return i.actor; yield return i.actor;
} }
public bool HasFreeSubCell(int2 a) public bool HasFreeSubCell(int2 a)
{ {
if (!AnyUnitsAt(a)) if (!AnyUnitsAt(a))
return true; return true;
return new[]{ SubCell.TopLeft, SubCell.TopRight, SubCell.Center, return new[]{ SubCell.TopLeft, SubCell.TopRight, SubCell.Center,
SubCell.BottomLeft, SubCell.BottomRight }.Any(b => !AnyUnitsAt(a,b)); SubCell.BottomLeft, SubCell.BottomRight }.Any(b => !AnyUnitsAt(a,b));
} }
@@ -79,9 +79,9 @@ namespace OpenRA
{ {
return influence[ a.X, a.Y ] != null; return influence[ a.X, a.Y ] != null;
} }
public bool AnyUnitsAt(int2 a, SubCell sub) public bool AnyUnitsAt(int2 a, SubCell sub)
{ {
for( var i = influence[ a.X, a.Y ] ; i != null ; i = i.next ) for( var i = influence[ a.X, a.Y ] ; i != null ; i = i.next )
if (i.subCell == sub || i.subCell == SubCell.FullCell) if (i.subCell == sub || i.subCell == SubCell.FullCell)
return true; return true;

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -18,33 +18,33 @@ namespace OpenRA
{ {
WebClient wc; WebClient wc;
bool cancelled; bool cancelled;
public Download(string url, string path, Action<DownloadProgressChangedEventArgs> onProgress, Action<AsyncCompletedEventArgs, bool> onComplete) public Download(string url, string path, Action<DownloadProgressChangedEventArgs> onProgress, Action<AsyncCompletedEventArgs, bool> onComplete)
{ {
wc = new WebClient(); wc = new WebClient();
wc.Proxy = null; wc.Proxy = null;
wc.DownloadProgressChanged += (_,a) => onProgress(a); wc.DownloadProgressChanged += (_,a) => onProgress(a);
wc.DownloadFileCompleted += (_,a) => onComplete(a, cancelled); wc.DownloadFileCompleted += (_,a) => onComplete(a, cancelled);
Game.OnQuit += () => Cancel(); Game.OnQuit += () => Cancel();
wc.DownloadFileCompleted += (_,a) => {Game.OnQuit -= () => Cancel();}; wc.DownloadFileCompleted += (_,a) => {Game.OnQuit -= () => Cancel();};
wc.DownloadFileAsync(new Uri(url), path); wc.DownloadFileAsync(new Uri(url), path);
} }
public void Cancel() public void Cancel()
{ {
Game.OnQuit -= () => Cancel(); Game.OnQuit -= () => Cancel();
wc.CancelAsync(); wc.CancelAsync();
cancelled = true; cancelled = true;
} }
public static string FormatErrorMessage(Exception e) public static string FormatErrorMessage(Exception e)
{ {
var ex = e as System.Net.WebException; var ex = e as System.Net.WebException;
if (ex == null) return e.Message; if (ex == null) return e.Message;
switch(ex.Status) switch(ex.Status)
{ {
case WebExceptionStatus.NameResolutionFailure: case WebExceptionStatus.NameResolutionFailure:

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -36,7 +36,7 @@ namespace OpenRA.Effects
{ {
if (!target.IsInWorld) if (!target.IsInWorld)
yield break; yield break;
if (remainingTicks % 2 == 0) if (remainingTicks % 2 == 0)
foreach (var r in target.Render()) foreach (var r in target.Render())
yield return r.WithPalette("highlight"); yield return r.WithPalette("highlight");

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -55,9 +55,9 @@ namespace OpenRA
if( !Directory.Exists( path ) ) Directory.CreateDirectory( path ); if( !Directory.Exists( path ) ) Directory.CreateDirectory( path );
var replayFile = File.Create( Path.Combine( path, replayFilename ) ); var replayFile = File.Create( Path.Combine( path, replayFilename ) );
JoinInner(new OrderManager(host, port, JoinInner(new OrderManager(host, port,
new ReplayRecorderConnection(new NetworkConnection(host, port), replayFile))); new ReplayRecorderConnection(new NetworkConnection(host, port), replayFile)));
} }
static string ChooseReplayFilename() static string ChooseReplayFilename()
{ {
@@ -90,14 +90,14 @@ namespace OpenRA
public static event Action<OrderManager> ConnectionStateChanged = _ => { }; public static event Action<OrderManager> ConnectionStateChanged = _ => { };
static ConnectionState lastConnectionState = ConnectionState.PreConnecting; static ConnectionState lastConnectionState = ConnectionState.PreConnecting;
public static int LocalClientId { get { return orderManager.Connection.LocalClientId; } } public static int LocalClientId { get { return orderManager.Connection.LocalClientId; } }
// Hacky workaround for orderManager visibility // Hacky workaround for orderManager visibility
public static Widget OpenWindow(World world, string widget) public static Widget OpenWindow(World world, string widget)
{ {
return Widget.OpenWindow(widget, new WidgetArgs() {{ "world", world }, { "orderManager", orderManager }, { "worldRenderer", worldRenderer }}); return Widget.OpenWindow(widget, new WidgetArgs() {{ "world", world }, { "orderManager", orderManager }, { "worldRenderer", worldRenderer }});
} }
// Who came up with the great idea of making these things // Who came up with the great idea of making these things
// impossible for the things that want them to access them directly? // impossible for the things that want them to access them directly?
public static Widget OpenWindow(string widget, WidgetArgs args) public static Widget OpenWindow(string widget, WidgetArgs args)
@@ -109,7 +109,7 @@ namespace OpenRA
{ "worldRenderer", worldRenderer }, { "worldRenderer", worldRenderer },
}); });
} }
// Load a widget with world, orderManager, worldRenderer args, without adding it to the widget tree // Load a widget with world, orderManager, worldRenderer args, without adding it to the widget tree
public static Widget LoadWidget(World world, string id, Widget parent, WidgetArgs args) public static Widget LoadWidget(World world, string id, Widget parent, WidgetArgs args)
{ {
@@ -227,7 +227,7 @@ namespace OpenRA
{ {
get { return orderManager.Connection.LocalClientId == 0; } get { return orderManager.Connection.LocalClientId == 0; }
} }
public static Dictionary<String, Mod> CurrentMods public static Dictionary<String, Mod> CurrentMods
{ {
get { return Mod.AllMods.Where( k => modData.Manifest.Mods.Contains( k.Key )).ToDictionary( k => k.Key, k => k.Value ); } get { return Mod.AllMods.Where( k => modData.Manifest.Mods.Contains( k.Key )).ToDictionary( k => k.Key, k => k.Value ); }
@@ -242,7 +242,7 @@ namespace OpenRA
Console.WriteLine("Platform is {0}", Platform.CurrentPlatform); Console.WriteLine("Platform is {0}", Platform.CurrentPlatform);
AppDomain.CurrentDomain.AssemblyResolve += FileSystem.ResolveAssembly; AppDomain.CurrentDomain.AssemblyResolve += FileSystem.ResolveAssembly;
Settings = new Settings(Platform.SupportDir + "settings.yaml", args); Settings = new Settings(Platform.SupportDir + "settings.yaml", args);
Settings.Save(); Settings.Save();
@@ -254,15 +254,15 @@ namespace OpenRA
FileSystem.Mount("."); // Needed to access shaders FileSystem.Mount("."); // Needed to access shaders
Renderer.Initialize( Game.Settings.Graphics.Mode ); Renderer.Initialize( Game.Settings.Graphics.Mode );
Renderer = new Renderer(); Renderer = new Renderer();
Console.WriteLine("Available mods:"); Console.WriteLine("Available mods:");
foreach(var mod in Mod.AllMods) foreach(var mod in Mod.AllMods)
Console.WriteLine("\t{0}: {1} ({2})", mod.Key, mod.Value.Title, mod.Value.Version); Console.WriteLine("\t{0}: {1} ({2})", mod.Key, mod.Value.Title, mod.Value.Version);
Sound.Create(); Sound.Create();
InitializeWithMods(Settings.Game.Mods); InitializeWithMods(Settings.Game.Mods);
} }
public static void InitializeWithMods(string[] mods) public static void InitializeWithMods(string[] mods)
{ {
// Clear static state if we have switched mods // Clear static state if we have switched mods
@@ -277,7 +277,7 @@ namespace OpenRA
server.Shutdown(); server.Shutdown();
if (orderManager != null) if (orderManager != null)
orderManager.Dispose(); orderManager.Dispose();
// Discard any invalid mods // Discard any invalid mods
var mm = mods.Where( m => Mod.AllMods.ContainsKey( m ) ).ToArray(); var mm = mods.Where( m => Mod.AllMods.ContainsKey( m ) ).ToArray();
Console.WriteLine("Loading mods: {0}",string.Join(",",mm)); Console.WriteLine("Loading mods: {0}",string.Join(",",mm));
@@ -287,12 +287,12 @@ namespace OpenRA
Sound.StopMusic(); Sound.StopMusic();
Sound.StopVideo(); Sound.StopVideo();
Sound.Initialize(); Sound.Initialize();
modData = new ModData( mm ); modData = new ModData( mm );
Renderer.InitializeFonts(modData.Manifest); Renderer.InitializeFonts(modData.Manifest);
modData.LoadInitialAssets(); modData.LoadInitialAssets();
PerfHistory.items["render"].hasNormalTick = false; PerfHistory.items["render"].hasNormalTick = false;
PerfHistory.items["batches"].hasNormalTick = false; PerfHistory.items["batches"].hasNormalTick = false;
PerfHistory.items["render_widgets"].hasNormalTick = false; PerfHistory.items["render_widgets"].hasNormalTick = false;
@@ -300,23 +300,23 @@ namespace OpenRA
JoinLocal(); JoinLocal();
viewport = new Viewport(new int2(Renderer.Resolution), Rectangle.Empty, Renderer); viewport = new Viewport(new int2(Renderer.Resolution), Rectangle.Empty, Renderer);
modData.LoadScreen.StartGame(); modData.LoadScreen.StartGame();
} }
public static void LoadShellMap() public static void LoadShellMap()
{ {
StartGame(ChooseShellmap()); StartGame(ChooseShellmap());
} }
static string ChooseShellmap() static string ChooseShellmap()
{ {
var shellmaps = modData.AvailableMaps var shellmaps = modData.AvailableMaps
.Where(m => m.Value.UseAsShellmap); .Where(m => m.Value.UseAsShellmap);
if (shellmaps.Count() == 0) if (shellmaps.Count() == 0)
throw new InvalidDataException("No valid shellmaps available"); throw new InvalidDataException("No valid shellmaps available");
return shellmaps.Random(CosmeticRandom).Key; return shellmaps.Random(CosmeticRandom).Key;
} }
@@ -336,9 +336,9 @@ namespace OpenRA
public static void Debug(string s, params object[] args) public static void Debug(string s, params object[] args)
{ {
AddChatLine(Color.White, "Debug", String.Format(s,args)); AddChatLine(Color.White, "Debug", String.Format(s,args));
} }
public static void Disconnect() public static void Disconnect()
{ {
if (orderManager.world != null) if (orderManager.world != null)
@@ -347,7 +347,7 @@ namespace OpenRA
JoinLocal(); JoinLocal();
orderManager.Dispose(); orderManager.Dispose();
} }
public static void CloseServer() public static void CloseServer()
{ {
if (server != null) if (server != null)
@@ -358,7 +358,7 @@ namespace OpenRA
{ {
return modData.ObjectCreator.CreateObject<T>( name ); return modData.ObjectCreator.CreateObject<T>( name );
} }
public static void CreateServer(ServerSettings settings) public static void CreateServer(ServerSettings settings)
{ {
server = new Server.Server(new IPEndPoint(IPAddress.Any, settings.ListenPort), server = new Server.Server(new IPEndPoint(IPAddress.Any, settings.ListenPort),
@@ -366,7 +366,7 @@ namespace OpenRA
settings, settings,
modData); modData);
} }
public static int CreateLocalServer(string map) public static int CreateLocalServer(string map)
{ {
var settings = new ServerSettings() var settings = new ServerSettings()

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -28,16 +28,16 @@ namespace OpenRA.GameRules
Filename = (nd.ContainsKey("Filename") ? nd["Filename"].Value : key)+"."+ext; Filename = (nd.ContainsKey("Filename") ? nd["Filename"].Value : key)+"."+ext;
if (!FileSystem.Exists(Filename)) if (!FileSystem.Exists(Filename))
return; return;
Exists = true; Exists = true;
Length = (int)AudLoader.SoundLength(FileSystem.Open(Filename)); Length = (int)AudLoader.SoundLength(FileSystem.Open(Filename));
} }
public void Reload() public void Reload()
{ {
if (!FileSystem.Exists(Filename)) if (!FileSystem.Exists(Filename))
return; return;
Exists = true; Exists = true;
Length = (int)AudLoader.SoundLength(FileSystem.Open(Filename)); Length = (int)AudLoader.SoundLength(FileSystem.Open(Filename));
} }

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -33,7 +33,7 @@ namespace OpenRA
Voices = LoadYamlRules(m.Voices, map.Voices, (k, _) => new VoiceInfo(k.Value)); Voices = LoadYamlRules(m.Voices, map.Voices, (k, _) => new VoiceInfo(k.Value));
Music = LoadYamlRules(m.Music, new List<MiniYamlNode>(), (k, _) => new MusicInfo(k.Key, k.Value)); Music = LoadYamlRules(m.Music, new List<MiniYamlNode>(), (k, _) => new MusicInfo(k.Key, k.Value));
Movies = LoadYamlRules(m.Movies, new List<MiniYamlNode>(), (k, v) => k.Value.Value); Movies = LoadYamlRules(m.Movies, new List<MiniYamlNode>(), (k, v) => k.Value.Value);
TileSets = new Dictionary<string, TileSet>(); TileSets = new Dictionary<string, TileSet>();
foreach (var file in m.TileSets) foreach (var file in m.TileSets)
{ {
@@ -41,7 +41,7 @@ namespace OpenRA
TileSets.Add(t.Id,t); TileSets.Add(t.Id,t);
} }
} }
static Dictionary<string, T> LoadYamlRules<T>(string[] files, List<MiniYamlNode> dict, Func<MiniYamlNode, Dictionary<string, MiniYaml>, T> f) static Dictionary<string, T> LoadYamlRules<T>(string[] files, List<MiniYamlNode> dict, Func<MiniYamlNode, Dictionary<string, MiniYaml>, T> f)
{ {
var y = files.Select(a => MiniYaml.FromFile(a)).Aggregate(dict,MiniYaml.MergeLiberal); var y = files.Select(a => MiniYaml.FromFile(a)).Aggregate(dict,MiniYaml.MergeLiberal);

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -98,11 +98,11 @@ namespace OpenRA.GameRules
// Internal game settings // Internal game settings
public int Timestep = 40; public int Timestep = 40;
} }
public class Settings public class Settings
{ {
string SettingsFile; string SettingsFile;
public PlayerSettings Player = new PlayerSettings(); public PlayerSettings Player = new PlayerSettings();
public GameSettings Game = new GameSettings(); public GameSettings Game = new GameSettings();
public SoundSettings Sound = new SoundSettings(); public SoundSettings Sound = new SoundSettings();
@@ -111,7 +111,7 @@ namespace OpenRA.GameRules
public DebugSettings Debug = new DebugSettings(); public DebugSettings Debug = new DebugSettings();
public Dictionary<string, object> Sections; public Dictionary<string, object> Sections;
public Settings(string file, Arguments args) public Settings(string file, Arguments args)
{ {
SettingsFile = file; SettingsFile = file;
Sections = new Dictionary<string, object>() Sections = new Dictionary<string, object>()
{ {
@@ -122,46 +122,46 @@ namespace OpenRA.GameRules
{"Server", Server}, {"Server", Server},
{"Debug", Debug}, {"Debug", Debug},
}; };
// Override fieldloader to ignore invalid entries // Override fieldloader to ignore invalid entries
var err1 = FieldLoader.UnknownFieldAction; var err1 = FieldLoader.UnknownFieldAction;
var err2 = FieldLoader.InvalidValueAction; var err2 = FieldLoader.InvalidValueAction;
FieldLoader.UnknownFieldAction = (s,f) => FieldLoader.UnknownFieldAction = (s,f) =>
{ {
Console.WriteLine( "Ignoring unknown field `{0}` on `{1}`".F( s, f.Name ) ); Console.WriteLine( "Ignoring unknown field `{0}` on `{1}`".F( s, f.Name ) );
}; };
if (File.Exists(SettingsFile)) if (File.Exists(SettingsFile))
{ {
//Console.WriteLine("Loading settings file {0}",SettingsFile); //Console.WriteLine("Loading settings file {0}",SettingsFile);
var yaml = MiniYaml.DictFromFile(SettingsFile); var yaml = MiniYaml.DictFromFile(SettingsFile);
foreach (var kv in Sections) foreach (var kv in Sections)
if (yaml.ContainsKey(kv.Key)) if (yaml.ContainsKey(kv.Key))
LoadSectionYaml(yaml[kv.Key], kv.Value); LoadSectionYaml(yaml[kv.Key], kv.Value);
} }
// Override with commandline args // Override with commandline args
foreach (var kv in Sections) foreach (var kv in Sections)
foreach (var f in kv.Value.GetType().GetFields()) foreach (var f in kv.Value.GetType().GetFields())
if (args.Contains(kv.Key+"."+f.Name)) if (args.Contains(kv.Key+"."+f.Name))
FieldLoader.LoadField( kv.Value, f.Name, args.GetValue(kv.Key+"."+f.Name, "") ); FieldLoader.LoadField( kv.Value, f.Name, args.GetValue(kv.Key+"."+f.Name, "") );
FieldLoader.UnknownFieldAction = err1; FieldLoader.UnknownFieldAction = err1;
FieldLoader.InvalidValueAction = err2; FieldLoader.InvalidValueAction = err2;
} }
public void Save() public void Save()
{ {
var root = new List<MiniYamlNode>(); var root = new List<MiniYamlNode>();
foreach( var kv in Sections ) foreach( var kv in Sections )
root.Add( new MiniYamlNode( kv.Key, FieldSaver.SaveDifferences(kv.Value, Activator.CreateInstance(kv.Value.GetType())) ) ); root.Add( new MiniYamlNode( kv.Key, FieldSaver.SaveDifferences(kv.Value, Activator.CreateInstance(kv.Value.GetType())) ) );
root.WriteToFile(SettingsFile); root.WriteToFile(SettingsFile);
} }
void LoadSectionYaml(MiniYaml yaml, object section) void LoadSectionYaml(MiniYaml yaml, object section)
{ {
object defaults = Activator.CreateInstance(section.GetType()); object defaults = Activator.CreateInstance(section.GetType());
@@ -171,7 +171,7 @@ namespace OpenRA.GameRules
System.Console.WriteLine("FieldLoader: Cannot parse `{0}` into `{2}:{1}`; substituting default `{3}`".F(s,t.Name,f,ret) ); System.Console.WriteLine("FieldLoader: Cannot parse `{0}` into `{2}:{1}`; substituting default `{3}`".F(s,t.Name,f,ret) );
return ret; return ret;
}; };
FieldLoader.Load(section, yaml); FieldLoader.Load(section, yaml);
} }
} }

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -36,15 +36,15 @@ namespace OpenRA.GameRules
public VoiceInfo( MiniYaml y ) public VoiceInfo( MiniYaml y )
{ {
FieldLoader.Load( this, y ); FieldLoader.Load( this, y );
Variants = Load(y, "Variants"); Variants = Load(y, "Variants");
Voices = Load(y, "Voices"); Voices = Load(y, "Voices");
if (!Voices.ContainsKey("Attack")) if (!Voices.ContainsKey("Attack"))
Voices.Add("Attack", Voices["Move"]); Voices.Add("Attack", Voices["Move"]);
if (!Voices.ContainsKey("AttackMove")) if (!Voices.ContainsKey("AttackMove"))
Voices.Add("AttackMove", Voices["Move"]); Voices.Add("AttackMove", Voices["Move"]);
Pools = Lazy.New(() => Voices.ToDictionary( a => a.Key, a => new VoicePool(a.Value) )); Pools = Lazy.New(() => Voices.ToDictionary( a => a.Key, a => new VoicePool(a.Value) ));
} }
} }

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -19,7 +19,7 @@ namespace OpenRA.GameRules
public class WarheadInfo public class WarheadInfo
{ {
public readonly int Spread = 1; // distance (in pixels) from the explosion center at which damage is 1/2. public readonly int Spread = 1; // distance (in pixels) from the explosion center at which damage is 1/2.
[FieldLoader.LoadUsing( "LoadVersus" )] [FieldLoader.LoadUsing( "LoadVersus" )]
public readonly Dictionary<string, float> Versus; // damage vs each armortype public readonly Dictionary<string, float> Versus; // damage vs each armortype
public readonly bool Ore = false; // can this damage ore? public readonly bool Ore = false; // can this damage ore?
public readonly string Explosion = null; // explosion effect to use public readonly string Explosion = null; // explosion effect to use
@@ -40,7 +40,7 @@ namespace OpenRA.GameRules
if (health == null) return 0f; if (health == null) return 0f;
var armor = self.Info.Traits.GetOrDefault<ArmorInfo>(); var armor = self.Info.Traits.GetOrDefault<ArmorInfo>();
if (armor == null || armor.Type == null) return 1; if (armor == null || armor.Type == null) return 1;
float versus; float versus;
return Versus.TryGetValue(armor.Type, out versus) ? versus : 1; return Versus.TryGetValue(armor.Type, out versus) ? versus : 1;
} }
@@ -49,7 +49,7 @@ namespace OpenRA.GameRules
{ {
FieldLoader.Load( this, yaml ); FieldLoader.Load( this, yaml );
} }
static object LoadVersus( MiniYaml y ) static object LoadVersus( MiniYaml y )
{ {
return y.NodesDict.ContainsKey( "Versus" ) return y.NodesDict.ContainsKey( "Versus" )
@@ -59,7 +59,7 @@ namespace OpenRA.GameRules
: new Dictionary<string, float>(); : new Dictionary<string, float>();
} }
} }
public enum DamageModel public enum DamageModel

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -136,7 +136,7 @@ namespace OpenRA.Graphics
public void ChangeImage(string newImage, string newAnimIfMissing) public void ChangeImage(string newImage, string newAnimIfMissing)
{ {
newImage = newImage.ToLowerInvariant(); newImage = newImage.ToLowerInvariant();
if (name != newImage) if (name != newImage)
{ {
name = newImage.ToLowerInvariant(); name = newImage.ToLowerInvariant();

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -22,7 +22,7 @@ namespace OpenRA.Graphics
public string src; public string src;
public Dictionary<string, MappedImage> regions; public Dictionary<string, MappedImage> regions;
} }
static Dictionary<string, Collection> collections; static Dictionary<string, Collection> collections;
static Dictionary<string, Sheet> cachedSheets; static Dictionary<string, Sheet> cachedSheets;
static Dictionary<string, Dictionary<string, Sprite>> cachedSprites; static Dictionary<string, Dictionary<string, Sprite>> cachedSprites;
@@ -32,7 +32,7 @@ namespace OpenRA.Graphics
collections = new Dictionary<string, Collection>(); collections = new Dictionary<string, Collection>();
cachedSheets = new Dictionary<string, Sheet>(); cachedSheets = new Dictionary<string, Sheet>();
cachedSprites = new Dictionary<string, Dictionary<string, Sprite>>(); cachedSprites = new Dictionary<string, Dictionary<string, Sprite>>();
if (chromeFiles.Length == 0) if (chromeFiles.Length == 0)
return; return;
@@ -41,34 +41,34 @@ namespace OpenRA.Graphics
foreach (var c in chrome) foreach (var c in chrome)
LoadCollection(c.Key, c.Value); LoadCollection(c.Key, c.Value);
} }
public static void Save(string file) public static void Save(string file)
{ {
var root = new List<MiniYamlNode>(); var root = new List<MiniYamlNode>();
foreach (var kv in collections) foreach (var kv in collections)
root.Add(new MiniYamlNode(kv.Key, SaveCollection(kv.Value))); root.Add(new MiniYamlNode(kv.Key, SaveCollection(kv.Value)));
root.WriteToFile(file); root.WriteToFile(file);
} }
static MiniYaml SaveCollection(Collection collection) static MiniYaml SaveCollection(Collection collection)
{ {
var root = new List<MiniYamlNode>(); var root = new List<MiniYamlNode>();
foreach (var kv in collection.regions) foreach (var kv in collection.regions)
root.Add(new MiniYamlNode(kv.Key, kv.Value.Save(collection.src))); root.Add(new MiniYamlNode(kv.Key, kv.Value.Save(collection.src)));
return new MiniYaml(collection.src, root); return new MiniYaml(collection.src, root);
} }
static void LoadCollection(string name, MiniYaml yaml) static void LoadCollection(string name, MiniYaml yaml)
{ {
Game.modData.LoadScreen.Display(); Game.modData.LoadScreen.Display();
var collection = new Collection() var collection = new Collection()
{ {
src = yaml.Value, src = yaml.Value,
regions = yaml.Nodes.ToDictionary(n => n.Key, n => new MappedImage(yaml.Value, n.Value)) regions = yaml.Nodes.ToDictionary(n => n.Key, n => new MappedImage(yaml.Value, n.Value))
}; };
collections.Add(name, collection); collections.Add(name, collection);
} }
@@ -85,7 +85,7 @@ namespace OpenRA.Graphics
throw new InvalidOperationException( throw new InvalidOperationException(
"Collection `{0}` does not have an image `{1}`".F(collection, image)); "Collection `{0}` does not have an image `{1}`".F(collection, image));
} }
// Cached sheet // Cached sheet
Sheet sheet; Sheet sheet;
if (cachedSheets.ContainsKey(mi.src)) if (cachedSheets.ContainsKey(mi.src))

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -20,12 +20,12 @@ namespace OpenRA.Graphics
public static class CursorProvider public static class CursorProvider
{ {
static Dictionary<string, CursorSequence> cursors; static Dictionary<string, CursorSequence> cursors;
public static void Initialize(string[] sequenceFiles) public static void Initialize(string[] sequenceFiles)
{ {
cursors = new Dictionary<string, CursorSequence>(); cursors = new Dictionary<string, CursorSequence>();
var sequences = new MiniYaml(null, sequenceFiles.Select(s => MiniYaml.FromFile(s)).Aggregate(MiniYaml.MergeLiberal)); var sequences = new MiniYaml(null, sequenceFiles.Select(s => MiniYaml.FromFile(s)).Aggregate(MiniYaml.MergeLiberal));
foreach (var s in sequences.NodesDict["Palettes"].Nodes) foreach (var s in sequences.NodesDict["Palettes"].Nodes)
Game.modData.Palette.AddPalette(s.Key, new Palette(FileSystem.Open(s.Value.Value), false)); Game.modData.Palette.AddPalette(s.Key, new Palette(FileSystem.Open(s.Value.Value), false));
@@ -40,7 +40,7 @@ namespace OpenRA.Graphics
foreach (var sequence in cursor.Nodes) foreach (var sequence in cursor.Nodes)
cursors.Add(sequence.Key, new CursorSequence(cursorSrc, cursor.Value, sequence.Value)); cursors.Add(sequence.Key, new CursorSequence(cursorSrc, cursor.Value, sequence.Value));
} }
public static bool HasCursorSequence(string cursor) public static bool HasCursorSequence(string cursor)
{ {
return cursors.ContainsKey(cursor); return cursors.ContainsKey(cursor);

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -33,7 +33,7 @@ namespace OpenRA.Graphics
start = int.Parse(d["start"].Value); start = int.Parse(d["start"].Value);
this.palette = palette; this.palette = palette;
if ((d.ContainsKey("length") && d["length"].Value == "*") || (d.ContainsKey("end") && d["end"].Value == "*")) if ((d.ContainsKey("length") && d["length"].Value == "*") || (d.ContainsKey("end") && d["end"].Value == "*"))
length = sprites.Length - start; length = sprites.Length - start;
else if (d.ContainsKey("length")) else if (d.ContainsKey("length"))
@@ -42,7 +42,7 @@ namespace OpenRA.Graphics
length = int.Parse(d["end"].Value) - start; length = int.Parse(d["end"].Value) - start;
else else
length = 1; length = 1;
if (d.ContainsKey("x")) if (d.ContainsKey("x"))
int.TryParse(d["x"].Value, out Hotspot.X ); int.TryParse(d["x"].Value, out Hotspot.X );
if (d.ContainsKey("y")) if (d.ContainsKey("y"))

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -21,18 +21,18 @@ namespace OpenRA.Graphics
{ {
public const int MaxPalettes = 256; public const int MaxPalettes = 256;
int allocated = 0; int allocated = 0;
ITexture texture; ITexture texture;
Dictionary<string, Palette> palettes; Dictionary<string, Palette> palettes;
Dictionary<string, int> indices; Dictionary<string, int> indices;
public HardwarePalette() public HardwarePalette()
{ {
palettes = new Dictionary<string, Palette>(); palettes = new Dictionary<string, Palette>();
indices = new Dictionary<string, int>(); indices = new Dictionary<string, int>();
texture = Game.Renderer.Device.CreateTexture(); texture = Game.Renderer.Device.CreateTexture();
} }
public Palette GetPalette(string name) public Palette GetPalette(string name)
{ {
Palette ret; Palette ret;
@@ -48,12 +48,12 @@ namespace OpenRA.Graphics
throw new InvalidOperationException("Palette `{0}` does not exist".F(name)); throw new InvalidOperationException("Palette `{0}` does not exist".F(name));
return ret; return ret;
} }
public void AddPalette(string name, Palette p) public void AddPalette(string name, Palette p)
{ {
if (palettes.ContainsKey(name)) if (palettes.ContainsKey(name))
throw new InvalidOperationException("Palette {0} has already been defined".F(name)); throw new InvalidOperationException("Palette {0} has already been defined".F(name));
palettes.Add(name, p); palettes.Add(name, p);
indices.Add(name, allocated++); indices.Add(name, allocated++);
} }
@@ -62,10 +62,10 @@ namespace OpenRA.Graphics
public void Update(IEnumerable<IPaletteModifier> paletteMods) public void Update(IEnumerable<IPaletteModifier> paletteMods)
{ {
var copy = palettes.ToDictionary(p => p.Key, p => new Palette(p.Value)); var copy = palettes.ToDictionary(p => p.Key, p => new Palette(p.Value));
foreach (var mod in paletteMods) foreach (var mod in paletteMods)
mod.AdjustPalette(copy); mod.AdjustPalette(copy);
foreach (var pal in copy) foreach (var pal in copy)
{ {
var j = indices[pal.Key]; var j = indices[pal.Key];
@@ -73,7 +73,7 @@ namespace OpenRA.Graphics
for (var i = 0; i < 256; i++) for (var i = 0; i < 256; i++)
data[j,i] = c[i]; data[j,i] = c[i];
} }
// Doesn't work // Doesn't work
texture.SetData(data); texture.SetData(data);
Game.Renderer.PaletteTexture = texture; Game.Renderer.PaletteTexture = texture;

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -71,7 +71,7 @@ namespace OpenRA.Graphics
new float2( endColor.R / 255.0f, endColor.G / 255.0f ), new float2( endColor.R / 255.0f, endColor.G / 255.0f ),
new float2( endColor.B / 255.0f, endColor.A / 255.0f ) ); new float2( endColor.B / 255.0f, endColor.A / 255.0f ) );
} }
public void FillRect( RectangleF r, Color color ) public void FillRect( RectangleF r, Color color )
{ {
for (float y = r.Top; y < r.Bottom; y++) for (float y = r.Top; y < r.Bottom; y++)

Some files were not shown because too many files have changed in this diff Show More