Merge pull request #3634 from Mailaender/style

StyleCop Cleanup
This commit is contained in:
Paul Chote
2013-08-09 19:19:03 -07:00
110 changed files with 3457 additions and 3832 deletions

View File

@@ -194,15 +194,15 @@ tsbuild_TARGET = OpenRA.TilesetBuilder.exe
tsbuild_KIND = winexe tsbuild_KIND = winexe
tsbuild_DEPS = $(fileformats_TARGET) $(game_TARGET) tsbuild_DEPS = $(fileformats_TARGET) $(game_TARGET)
tsbuild_LIBS = $(COMMON_LIBS) $(tsbuild_DEPS) System.Windows.Forms.dll tsbuild_LIBS = $(COMMON_LIBS) $(tsbuild_DEPS) System.Windows.Forms.dll
tsbuild_EXTRA = -resource:OpenRA.TilesetBuilder.frmBuilder.resources -resource:OpenRA.TilesetBuilder.frmNew.resources -resource:OpenRA.TilesetBuilder.Surface.resources tsbuild_EXTRA = -resource:OpenRA.TilesetBuilder.FormBuilder.resources -resource:OpenRA.TilesetBuilder.FormNew.resources -resource:OpenRA.TilesetBuilder.Surface.resources
PROGRAMS += tsbuild PROGRAMS += tsbuild
OpenRA.TilesetBuilder.frmBuilder.resources: OpenRA.TilesetBuilder.FormBuilder.resources:
resgen2 OpenRA.TilesetBuilder/frmBuilder.resx OpenRA.TilesetBuilder.frmBuilder.resources 1> /dev/null resgen2 OpenRA.TilesetBuilder/FormBuilder.resx OpenRA.TilesetBuilder.FormBuilder.resources 1> /dev/null
OpenRA.TilesetBuilder.frmNew.resources: OpenRA.TilesetBuilder.FormNew.resources:
resgen2 OpenRA.TilesetBuilder/frmNew.resx OpenRA.TilesetBuilder.frmNew.resources 1> /dev/null resgen2 OpenRA.TilesetBuilder/frmNew.resx OpenRA.TilesetBuilder.FormNew.resources 1> /dev/null
OpenRA.TilesetBuilder.Surface.resources: OpenRA.TilesetBuilder.Surface.resources:
resgen2 OpenRA.TilesetBuilder/Surface.resx OpenRA.TilesetBuilder.Surface.resources 1> /dev/null resgen2 OpenRA.TilesetBuilder/Surface.resx OpenRA.TilesetBuilder.Surface.resources 1> /dev/null
tsbuild: OpenRA.TilesetBuilder.frmBuilder.resources OpenRA.TilesetBuilder.frmNew.resources OpenRA.TilesetBuilder.Surface.resources $(tsbuild_TARGET) tsbuild: OpenRA.TilesetBuilder.FormBuilder.resources OpenRA.TilesetBuilder.FormNew.resources OpenRA.TilesetBuilder.Surface.resources $(tsbuild_TARGET)
##### Launchers / Utilities ##### ##### Launchers / Utilities #####

View File

@@ -14,9 +14,7 @@
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
if (disposing && (components != null)) if (disposing && (components != null))
{
components.Dispose(); components.Dispose();
}
base.Dispose(disposing); base.Dispose(disposing);
} }

View File

@@ -17,12 +17,12 @@ namespace OpenRA.Editor
{ {
class ActorTool : ITool class ActorTool : ITool
{ {
ActorTemplate Actor; ActorTemplate actorTemplate;
public ActorTool(ActorTemplate actor) { this.Actor = actor; } public ActorTool(ActorTemplate actor) { this.actorTemplate = actor; }
public void Preview(Surface surface, SGraphics g) public void Preview(Surface surface, SGraphics g)
{ {
surface.DrawActor(g, surface.GetBrushLocation(), Actor, surface.DrawActor(g, surface.GetBrushLocation(), actorTemplate,
surface.GetPaletteForPlayer(surface.NewActorOwner)); surface.GetPaletteForPlayer(surface.NewActorOwner));
} }
@@ -33,7 +33,7 @@ namespace OpenRA.Editor
var owner = surface.NewActorOwner; var owner = surface.NewActorOwner;
var id = NextActorName(surface); var id = NextActorName(surface);
surface.Map.Actors.Value[id] = new ActorReference(Actor.Info.Name.ToLowerInvariant()) surface.Map.Actors.Value[id] = new ActorReference(actorTemplate.Info.Name.ToLowerInvariant())
{ {
new LocationInit(surface.GetBrushLocation()), new LocationInit(surface.GetBrushLocation()),
new OwnerInit(owner) new OwnerInit(owner)

View File

@@ -19,14 +19,14 @@ namespace OpenRA.Editor
{ {
class BrushTool : ITool class BrushTool : ITool
{ {
BrushTemplate Brush; BrushTemplate brushTemplate;
public BrushTool(BrushTemplate brush) { this.Brush = brush; } public BrushTool(BrushTemplate brush) { this.brushTemplate = brush; }
public void Apply(Surface surface) public void Apply(Surface surface)
{ {
// change the bits in the map // change the bits in the map
var template = surface.TileSet.Templates[Brush.N]; var template = surface.TileSet.Templates[brushTemplate.N];
var tile = template.Data; var tile = template.Data;
var pos = surface.GetBrushLocation(); var pos = surface.GetBrushLocation();
@@ -46,7 +46,7 @@ namespace OpenRA.Editor
surface.Map.MapTiles.Value[u + pos.X, v + pos.Y] = surface.Map.MapTiles.Value[u + pos.X, v + pos.Y] =
new TileReference<ushort, byte> new TileReference<ushort, byte>
{ {
type = Brush.N, type = brushTemplate.N,
index = template.PickAny ? (byte)((u + pos.X) % 4 + ((v + pos.Y) % 4) * 4) : (byte)z, index = template.PickAny ? (byte)((u + pos.X) % 4 + ((v + pos.Y) % 4) * 4) : (byte)z,
}; };
@@ -62,11 +62,11 @@ namespace OpenRA.Editor
public void Preview(Surface surface, SGraphics g) public void Preview(Surface surface, SGraphics g)
{ {
g.DrawImage(Brush.Bitmap, g.DrawImage(brushTemplate.Bitmap,
surface.TileSet.TileSize * surface.GetBrushLocation().X * surface.Zoom + surface.GetOffset().X, surface.TileSet.TileSize * surface.GetBrushLocation().X * surface.Zoom + surface.GetOffset().X,
surface.TileSet.TileSize * surface.GetBrushLocation().Y * surface.Zoom + surface.GetOffset().Y, surface.TileSet.TileSize * surface.GetBrushLocation().Y * surface.Zoom + surface.GetOffset().Y,
Brush.Bitmap.Width * surface.Zoom, brushTemplate.Bitmap.Width * surface.Zoom,
Brush.Bitmap.Height * surface.Zoom); brushTemplate.Bitmap.Height * surface.Zoom);
} }
void FloodFillWithBrush(Surface s, CPos pos) void FloodFillWithBrush(Surface s, CPos pos)
@@ -96,7 +96,7 @@ namespace OpenRA.Editor
for (var x = a.X; x <= b.X; x++) for (var x = a.X; x <= b.X; x++)
{ {
s.Map.MapTiles.Value[x, p.Y] = new TileReference<ushort, byte> { type = Brush.N, index = (byte)0 }; s.Map.MapTiles.Value[x, p.Y] = new TileReference<ushort, byte> { type = brushTemplate.N, index = (byte)0 };
if (s.Map.MapTiles.Value[x, p.Y - 1].Equals(replace)) if (s.Map.MapTiles.Value[x, p.Y - 1].Equals(replace))
maybeEnqueue(x, p.Y - 1); maybeEnqueue(x, p.Y - 1);
if (s.Map.MapTiles.Value[x, p.Y + 1].Equals(replace)) if (s.Map.MapTiles.Value[x, p.Y + 1].Equals(replace))

View File

@@ -24,9 +24,7 @@ namespace OpenRA.Editor
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
if (disposing && (components != null)) if (disposing && (components != null))
{
components.Dispose(); components.Dispose();
}
base.Dispose(disposing); base.Dispose(disposing);
} }

View File

@@ -24,9 +24,8 @@ namespace OpenRA.Editor
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
if (disposing && (components != null)) if (disposing && (components != null))
{
components.Dispose(); components.Dispose();
}
base.Dispose(disposing); base.Dispose(disposing);
} }
@@ -42,7 +41,7 @@ namespace OpenRA.Editor
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.splitContainer2 = new System.Windows.Forms.SplitContainer(); this.splitContainer2 = new System.Windows.Forms.SplitContainer();
this.pmMiniMap = new System.Windows.Forms.PictureBox(); this.miniMapBox = new System.Windows.Forms.PictureBox();
this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage(); this.tabPage1 = new System.Windows.Forms.TabPage();
this.tilePalette = new System.Windows.Forms.FlowLayoutPanel(); this.tilePalette = new System.Windows.Forms.FlowLayoutPanel();
@@ -77,7 +76,7 @@ namespace OpenRA.Editor
this.eraserToolStripButton = new System.Windows.Forms.ToolStripButton(); this.eraserToolStripButton = new System.Windows.Forms.ToolStripButton();
this.toolStripMenuItemCopySelection = new System.Windows.Forms.ToolStripButton(); this.toolStripMenuItemCopySelection = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator();
this.QuickhelpToolStripButton = new System.Windows.Forms.ToolStripButton(); this.quickhelpToolStripButton = new System.Windows.Forms.ToolStripButton();
this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -87,9 +86,9 @@ namespace OpenRA.Editor
this.saveAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.saveAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.cCRedAlertMapToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.redAlertMapToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.mnuExport = new System.Windows.Forms.ToolStripMenuItem(); this.miniMapExport = new System.Windows.Forms.ToolStripMenuItem();
this.mnuMinimapToPNG = new System.Windows.Forms.ToolStripMenuItem(); this.miniMapToPng = new System.Windows.Forms.ToolStripMenuItem();
this.fullMapRenderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.fullMapRenderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -120,11 +119,11 @@ namespace OpenRA.Editor
this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.toolStripStatusLabelFiller = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabelFiller = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabelMousePosition = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabelMousePosition = new System.Windows.Forms.ToolStripStatusLabel();
this.BottomToolStripPanel = new System.Windows.Forms.ToolStripPanel(); this.bottomToolStripPanel = new System.Windows.Forms.ToolStripPanel();
this.TopToolStripPanel = new System.Windows.Forms.ToolStripPanel(); this.topToolStripPanel = new System.Windows.Forms.ToolStripPanel();
this.RightToolStripPanel = new System.Windows.Forms.ToolStripPanel(); this.rightToolStripPanel = new System.Windows.Forms.ToolStripPanel();
this.LeftToolStripPanel = new System.Windows.Forms.ToolStripPanel(); this.leftToolStripPanel = new System.Windows.Forms.ToolStripPanel();
this.ContentPanel = new System.Windows.Forms.ToolStripContentPanel(); this.contentPanel = new System.Windows.Forms.ToolStripContentPanel();
this.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer(); this.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer();
this.cashToolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel(); this.cashToolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel();
this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel1.SuspendLayout();
@@ -133,7 +132,7 @@ namespace OpenRA.Editor
this.splitContainer2.Panel1.SuspendLayout(); this.splitContainer2.Panel1.SuspendLayout();
this.splitContainer2.Panel2.SuspendLayout(); this.splitContainer2.Panel2.SuspendLayout();
this.splitContainer2.SuspendLayout(); this.splitContainer2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pmMiniMap)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.miniMapBox)).BeginInit();
this.tabControl1.SuspendLayout(); this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout(); this.tabPage1.SuspendLayout();
this.tabPage2.SuspendLayout(); this.tabPage2.SuspendLayout();
@@ -177,7 +176,7 @@ namespace OpenRA.Editor
// //
// splitContainer2.Panel1 // splitContainer2.Panel1
// //
this.splitContainer2.Panel1.Controls.Add(this.pmMiniMap); this.splitContainer2.Panel1.Controls.Add(this.miniMapBox);
// //
// splitContainer2.Panel2 // splitContainer2.Panel2
// //
@@ -188,15 +187,15 @@ namespace OpenRA.Editor
// //
// pmMiniMap // pmMiniMap
// //
this.pmMiniMap.BackColor = System.Drawing.Color.Black; this.miniMapBox.BackColor = System.Drawing.Color.Black;
this.pmMiniMap.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.miniMapBox.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.pmMiniMap.Dock = System.Windows.Forms.DockStyle.Fill; this.miniMapBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.pmMiniMap.Location = new System.Drawing.Point(0, 0); this.miniMapBox.Location = new System.Drawing.Point(0, 0);
this.pmMiniMap.Name = "pmMiniMap"; this.miniMapBox.Name = "pmMiniMap";
this.pmMiniMap.Size = new System.Drawing.Size(198, 153); this.miniMapBox.Size = new System.Drawing.Size(198, 153);
this.pmMiniMap.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; this.miniMapBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pmMiniMap.TabIndex = 1; this.miniMapBox.TabIndex = 1;
this.pmMiniMap.TabStop = false; this.miniMapBox.TabStop = false;
// //
// tabControl1 // tabControl1
// //
@@ -356,7 +355,7 @@ namespace OpenRA.Editor
this.eraserToolStripButton, this.eraserToolStripButton,
this.toolStripMenuItemCopySelection, this.toolStripMenuItemCopySelection,
this.toolStripSeparator7, this.toolStripSeparator7,
this.QuickhelpToolStripButton}); this.quickhelpToolStripButton});
this.toolStrip1.Location = new System.Drawing.Point(0, 0); this.toolStrip1.Location = new System.Drawing.Point(0, 0);
this.toolStrip1.Name = "toolStrip1"; this.toolStrip1.Name = "toolStrip1";
this.toolStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional; this.toolStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional;
@@ -373,7 +372,7 @@ namespace OpenRA.Editor
this.toolStripMenuItemNew.Size = new System.Drawing.Size(23, 22); this.toolStripMenuItemNew.Size = new System.Drawing.Size(23, 22);
this.toolStripMenuItemNew.Text = "&New..."; this.toolStripMenuItemNew.Text = "&New...";
this.toolStripMenuItemNew.ToolTipText = "Create a new blank map."; this.toolStripMenuItemNew.ToolTipText = "Create a new blank map.";
this.toolStripMenuItemNew.Click += new System.EventHandler(this.toolStripMenuItemNewClick); this.toolStripMenuItemNew.Click += new System.EventHandler(this.ToolStripMenuItemNewClick);
// //
// toolStripMenuItemOpen // toolStripMenuItemOpen
// //
@@ -383,7 +382,7 @@ namespace OpenRA.Editor
this.toolStripMenuItemOpen.Size = new System.Drawing.Size(23, 22); this.toolStripMenuItemOpen.Size = new System.Drawing.Size(23, 22);
this.toolStripMenuItemOpen.Text = "&Open..."; this.toolStripMenuItemOpen.Text = "&Open...";
this.toolStripMenuItemOpen.ToolTipText = "Open an existing map."; this.toolStripMenuItemOpen.ToolTipText = "Open an existing map.";
this.toolStripMenuItemOpen.Click += new System.EventHandler(this.toolStripMenuItemOpenClick); this.toolStripMenuItemOpen.Click += new System.EventHandler(this.ToolStripMenuItemOpenClick);
// //
// toolStripMenuItemSave // toolStripMenuItemSave
// //
@@ -394,7 +393,7 @@ namespace OpenRA.Editor
this.toolStripMenuItemSave.Size = new System.Drawing.Size(23, 22); this.toolStripMenuItemSave.Size = new System.Drawing.Size(23, 22);
this.toolStripMenuItemSave.Text = "&Save"; this.toolStripMenuItemSave.Text = "&Save";
this.toolStripMenuItemSave.ToolTipText = "Quicksave current map."; this.toolStripMenuItemSave.ToolTipText = "Quicksave current map.";
this.toolStripMenuItemSave.Click += new System.EventHandler(this.toolStripMenuItemSaveClick); this.toolStripMenuItemSave.Click += new System.EventHandler(this.ToolStripMenuItemSaveClick);
// //
// toolStripSeparator // toolStripSeparator
// //
@@ -410,7 +409,7 @@ namespace OpenRA.Editor
this.toolStripMenuItemProperties.Size = new System.Drawing.Size(23, 22); this.toolStripMenuItemProperties.Size = new System.Drawing.Size(23, 22);
this.toolStripMenuItemProperties.Text = "&Properties..."; this.toolStripMenuItemProperties.Text = "&Properties...";
this.toolStripMenuItemProperties.ToolTipText = "Edit Metadata"; this.toolStripMenuItemProperties.ToolTipText = "Edit Metadata";
this.toolStripMenuItemProperties.Click += new System.EventHandler(this.toolStripMenuItemPropertiesClick); this.toolStripMenuItemProperties.Click += new System.EventHandler(this.ToolStripMenuItemPropertiesClick);
// //
// toolStripMenuItemResize // toolStripMenuItemResize
// //
@@ -421,7 +420,7 @@ namespace OpenRA.Editor
this.toolStripMenuItemResize.Size = new System.Drawing.Size(23, 22); this.toolStripMenuItemResize.Size = new System.Drawing.Size(23, 22);
this.toolStripMenuItemResize.Text = "&Resize..."; this.toolStripMenuItemResize.Text = "&Resize...";
this.toolStripMenuItemResize.ToolTipText = "Change the map borders and dimensions."; this.toolStripMenuItemResize.ToolTipText = "Change the map borders and dimensions.";
this.toolStripMenuItemResize.Click += new System.EventHandler(this.toolStripMenuItemResizeClick); this.toolStripMenuItemResize.Click += new System.EventHandler(this.ToolStripMenuItemResizeClick);
// //
// toolStripSeparator8 // toolStripSeparator8
// //
@@ -436,7 +435,7 @@ namespace OpenRA.Editor
this.toolStripMenuItemShowActorNames.Size = new System.Drawing.Size(23, 22); this.toolStripMenuItemShowActorNames.Size = new System.Drawing.Size(23, 22);
this.toolStripMenuItemShowActorNames.Text = "Show Actor &Names"; this.toolStripMenuItemShowActorNames.Text = "Show Actor &Names";
this.toolStripMenuItemShowActorNames.ToolTipText = "If the actor has a custom name, display it."; this.toolStripMenuItemShowActorNames.ToolTipText = "If the actor has a custom name, display it.";
this.toolStripMenuItemShowActorNames.Click += new System.EventHandler(this.toolStripMenuItemShowActorNamesClick); this.toolStripMenuItemShowActorNames.Click += new System.EventHandler(this.ToolStripMenuItemShowActorNamesClick);
// //
// toolStripMenuItemShowGrid // toolStripMenuItemShowGrid
// //
@@ -446,7 +445,7 @@ namespace OpenRA.Editor
this.toolStripMenuItemShowGrid.Size = new System.Drawing.Size(23, 22); this.toolStripMenuItemShowGrid.Size = new System.Drawing.Size(23, 22);
this.toolStripMenuItemShowGrid.Text = "Show &Grid"; this.toolStripMenuItemShowGrid.Text = "Show &Grid";
this.toolStripMenuItemShowGrid.ToolTipText = "Enable a grid overlay for better orientation."; this.toolStripMenuItemShowGrid.ToolTipText = "Enable a grid overlay for better orientation.";
this.toolStripMenuItemShowGrid.Click += new System.EventHandler(this.toolStripMenuItemShowGridClick); this.toolStripMenuItemShowGrid.Click += new System.EventHandler(this.ToolStripMenuItemShowGridClick);
// //
// toolStripSeparator12 // toolStripSeparator12
// //
@@ -461,7 +460,7 @@ namespace OpenRA.Editor
this.zoomIntoolStripButton.Name = "zoomIntoolStripButton"; this.zoomIntoolStripButton.Name = "zoomIntoolStripButton";
this.zoomIntoolStripButton.Size = new System.Drawing.Size(23, 22); this.zoomIntoolStripButton.Size = new System.Drawing.Size(23, 22);
this.zoomIntoolStripButton.Text = "Zoom in"; this.zoomIntoolStripButton.Text = "Zoom in";
this.zoomIntoolStripButton.Click += new System.EventHandler(this.zoomInToolStripButtonClick); this.zoomIntoolStripButton.Click += new System.EventHandler(this.ZoomInToolStripButtonClick);
// //
// zoomOutToolStripButton // zoomOutToolStripButton
// //
@@ -471,7 +470,7 @@ namespace OpenRA.Editor
this.zoomOutToolStripButton.Name = "zoomOutToolStripButton"; this.zoomOutToolStripButton.Name = "zoomOutToolStripButton";
this.zoomOutToolStripButton.Size = new System.Drawing.Size(23, 22); this.zoomOutToolStripButton.Size = new System.Drawing.Size(23, 22);
this.zoomOutToolStripButton.Text = "Zoom out"; this.zoomOutToolStripButton.Text = "Zoom out";
this.zoomOutToolStripButton.Click += new System.EventHandler(this.zoomOutToolStripButtonClick); this.zoomOutToolStripButton.Click += new System.EventHandler(this.ZoomOutToolStripButtonClick);
// //
// panToolStripButton // panToolStripButton
// //
@@ -481,7 +480,7 @@ namespace OpenRA.Editor
this.panToolStripButton.Name = "panToolStripButton"; this.panToolStripButton.Name = "panToolStripButton";
this.panToolStripButton.Size = new System.Drawing.Size(23, 22); this.panToolStripButton.Size = new System.Drawing.Size(23, 22);
this.panToolStripButton.Text = "Pan view"; this.panToolStripButton.Text = "Pan view";
this.panToolStripButton.Click += new System.EventHandler(this.panToolStripButtonClick); this.panToolStripButton.Click += new System.EventHandler(this.PanToolStripButtonClick);
// //
// showRulerToolStripItem // showRulerToolStripItem
// //
@@ -490,7 +489,7 @@ namespace OpenRA.Editor
this.showRulerToolStripItem.Name = "showRulerToolStripItem"; this.showRulerToolStripItem.Name = "showRulerToolStripItem";
this.showRulerToolStripItem.Size = new System.Drawing.Size(23, 22); this.showRulerToolStripItem.Size = new System.Drawing.Size(23, 22);
this.showRulerToolStripItem.Text = "Show Ruler"; this.showRulerToolStripItem.Text = "Show Ruler";
this.showRulerToolStripItem.Click += new System.EventHandler(this.showRulerToolStripItemClick); this.showRulerToolStripItem.Click += new System.EventHandler(this.ShowRulerToolStripItemClick);
// //
// toolStripSeparator10 // toolStripSeparator10
// //
@@ -505,7 +504,7 @@ namespace OpenRA.Editor
this.toolStripMenuItemFixOpenAreas.Size = new System.Drawing.Size(23, 22); this.toolStripMenuItemFixOpenAreas.Size = new System.Drawing.Size(23, 22);
this.toolStripMenuItemFixOpenAreas.Text = "&Fix Open Areas"; this.toolStripMenuItemFixOpenAreas.Text = "&Fix Open Areas";
this.toolStripMenuItemFixOpenAreas.ToolTipText = "Add some randomness into clear tiles."; this.toolStripMenuItemFixOpenAreas.ToolTipText = "Add some randomness into clear tiles.";
this.toolStripMenuItemFixOpenAreas.Click += new System.EventHandler(this.toolStripMenuItemFixOpenAreasClick); this.toolStripMenuItemFixOpenAreas.Click += new System.EventHandler(this.ToolStripMenuItemFixOpenAreasClick);
// //
// toolStripMenuItemSetupDefaultPlayers // toolStripMenuItemSetupDefaultPlayers
// //
@@ -515,7 +514,7 @@ namespace OpenRA.Editor
this.toolStripMenuItemSetupDefaultPlayers.Size = new System.Drawing.Size(23, 22); this.toolStripMenuItemSetupDefaultPlayers.Size = new System.Drawing.Size(23, 22);
this.toolStripMenuItemSetupDefaultPlayers.Text = "&Setup Default Players"; this.toolStripMenuItemSetupDefaultPlayers.Text = "&Setup Default Players";
this.toolStripMenuItemSetupDefaultPlayers.ToolTipText = "Setup the players for each spawnpoint placed."; this.toolStripMenuItemSetupDefaultPlayers.ToolTipText = "Setup the players for each spawnpoint placed.";
this.toolStripMenuItemSetupDefaultPlayers.Click += new System.EventHandler(this.toolStripMenuItemSetupDefaultPlayersClick); this.toolStripMenuItemSetupDefaultPlayers.Click += new System.EventHandler(this.ToolStripMenuItemSetupDefaultPlayersClick);
// //
// toolStripSeparator11 // toolStripSeparator11
// //
@@ -540,7 +539,7 @@ namespace OpenRA.Editor
this.toolStripMenuItemCopySelection.Size = new System.Drawing.Size(23, 22); this.toolStripMenuItemCopySelection.Size = new System.Drawing.Size(23, 22);
this.toolStripMenuItemCopySelection.Text = "Copy Selection"; this.toolStripMenuItemCopySelection.Text = "Copy Selection";
this.toolStripMenuItemCopySelection.ToolTipText = "Copy the current selection and paste it again on left-click."; this.toolStripMenuItemCopySelection.ToolTipText = "Copy the current selection and paste it again on left-click.";
this.toolStripMenuItemCopySelection.Click += new System.EventHandler(this.toolStripMenuItemCopySelectionClick); this.toolStripMenuItemCopySelection.Click += new System.EventHandler(this.ToolStripMenuItemCopySelectionClick);
// //
// toolStripSeparator7 // toolStripSeparator7
// //
@@ -549,14 +548,14 @@ namespace OpenRA.Editor
// //
// QuickhelpToolStripButton // QuickhelpToolStripButton
// //
this.QuickhelpToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.quickhelpToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.QuickhelpToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("QuickhelpToolStripButton.Image"))); this.quickhelpToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("QuickhelpToolStripButton.Image")));
this.QuickhelpToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta; this.quickhelpToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.QuickhelpToolStripButton.Name = "QuickhelpToolStripButton"; this.quickhelpToolStripButton.Name = "QuickhelpToolStripButton";
this.QuickhelpToolStripButton.Size = new System.Drawing.Size(23, 22); this.quickhelpToolStripButton.Size = new System.Drawing.Size(23, 22);
this.QuickhelpToolStripButton.Text = "Help"; this.quickhelpToolStripButton.Text = "Help";
this.QuickhelpToolStripButton.ToolTipText = "Display the mapping tutorial in the OpenRA wiki."; this.quickhelpToolStripButton.ToolTipText = "Display the mapping tutorial in the OpenRA wiki.";
this.QuickhelpToolStripButton.Click += new System.EventHandler(this.helpToolStripButton_Click); this.quickhelpToolStripButton.Click += new System.EventHandler(this.HelpToolStripButton_Click);
// //
// menuStrip1 // menuStrip1
// //
@@ -584,7 +583,7 @@ namespace OpenRA.Editor
this.saveAsToolStripMenuItem, this.saveAsToolStripMenuItem,
this.toolStripSeparator2, this.toolStripSeparator2,
this.toolStripMenuItem1, this.toolStripMenuItem1,
this.mnuExport, this.miniMapExport,
this.toolStripSeparator3, this.toolStripSeparator3,
this.exitToolStripMenuItem}); this.exitToolStripMenuItem});
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
@@ -643,7 +642,7 @@ namespace OpenRA.Editor
// toolStripMenuItem1 // toolStripMenuItem1
// //
this.toolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.cCRedAlertMapToolStripMenuItem}); this.redAlertMapToolStripMenuItem});
this.toolStripMenuItem1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripMenuItem1.Image"))); this.toolStripMenuItem1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripMenuItem1.Image")));
this.toolStripMenuItem1.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripMenuItem1.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripMenuItem1.Name = "toolStripMenuItem1"; this.toolStripMenuItem1.Name = "toolStripMenuItem1";
@@ -652,33 +651,33 @@ namespace OpenRA.Editor
// //
// cCRedAlertMapToolStripMenuItem // cCRedAlertMapToolStripMenuItem
// //
this.cCRedAlertMapToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("cCRedAlertMapToolStripMenuItem.Image"))); this.redAlertMapToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("cCRedAlertMapToolStripMenuItem.Image")));
this.cCRedAlertMapToolStripMenuItem.Name = "cCRedAlertMapToolStripMenuItem"; this.redAlertMapToolStripMenuItem.Name = "cCRedAlertMapToolStripMenuItem";
this.cCRedAlertMapToolStripMenuItem.Size = new System.Drawing.Size(188, 22); this.redAlertMapToolStripMenuItem.Size = new System.Drawing.Size(188, 22);
this.cCRedAlertMapToolStripMenuItem.Text = "&Legacy Map Format..."; this.redAlertMapToolStripMenuItem.Text = "&Legacy Map Format...";
this.cCRedAlertMapToolStripMenuItem.ToolTipText = "Import an original C&C / Red Alert and convert it to the .oramap format."; this.redAlertMapToolStripMenuItem.ToolTipText = "Import an original C&C / Red Alert and convert it to the .oramap format.";
this.cCRedAlertMapToolStripMenuItem.Click += new System.EventHandler(this.ImportLegacyMapClicked); this.redAlertMapToolStripMenuItem.Click += new System.EventHandler(this.ImportLegacyMapClicked);
// //
// mnuExport // mnuExport
// //
this.mnuExport.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.miniMapExport.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.mnuMinimapToPNG, this.miniMapToPng,
this.fullMapRenderToolStripMenuItem}); this.fullMapRenderToolStripMenuItem});
this.mnuExport.Image = ((System.Drawing.Image)(resources.GetObject("mnuExport.Image"))); this.miniMapExport.Image = ((System.Drawing.Image)(resources.GetObject("mnuExport.Image")));
this.mnuExport.ImageTransparentColor = System.Drawing.Color.Magenta; this.miniMapExport.ImageTransparentColor = System.Drawing.Color.Magenta;
this.mnuExport.Name = "mnuExport"; this.miniMapExport.Name = "mnuExport";
this.mnuExport.Size = new System.Drawing.Size(123, 22); this.miniMapExport.Size = new System.Drawing.Size(123, 22);
this.mnuExport.Text = "&Export"; this.miniMapExport.Text = "&Export";
// //
// mnuMinimapToPNG // mnuMinimapToPNG
// //
this.mnuMinimapToPNG.Enabled = false; this.miniMapToPng.Enabled = false;
this.mnuMinimapToPNG.Image = ((System.Drawing.Image)(resources.GetObject("mnuMinimapToPNG.Image"))); this.miniMapToPng.Image = ((System.Drawing.Image)(resources.GetObject("mnuMinimapToPNG.Image")));
this.mnuMinimapToPNG.Name = "mnuMinimapToPNG"; this.miniMapToPng.Name = "mnuMinimapToPNG";
this.mnuMinimapToPNG.Size = new System.Drawing.Size(163, 22); this.miniMapToPng.Size = new System.Drawing.Size(163, 22);
this.mnuMinimapToPNG.Text = "Minimap to PNG"; this.miniMapToPng.Text = "Minimap to PNG";
this.mnuMinimapToPNG.ToolTipText = "Save the map radar display as an image."; this.miniMapToPng.ToolTipText = "Save the map radar display as an image.";
this.mnuMinimapToPNG.Click += new System.EventHandler(this.ExportMinimap); this.miniMapToPng.Click += new System.EventHandler(this.ExportMinimap);
// //
// fullMapRenderToolStripMenuItem // fullMapRenderToolStripMenuItem
// //
@@ -770,7 +769,7 @@ namespace OpenRA.Editor
this.showRulerToolStripMenuItem.Name = "showRulerToolStripMenuItem"; this.showRulerToolStripMenuItem.Name = "showRulerToolStripMenuItem";
this.showRulerToolStripMenuItem.Size = new System.Drawing.Size(185, 22); this.showRulerToolStripMenuItem.Size = new System.Drawing.Size(185, 22);
this.showRulerToolStripMenuItem.Text = "Show Ruler"; this.showRulerToolStripMenuItem.Text = "Show Ruler";
this.showRulerToolStripMenuItem.Click += new System.EventHandler(this.showRulerToolStripMenuItemClick); this.showRulerToolStripMenuItem.Click += new System.EventHandler(this.ShowRulerToolStripMenuItemClick);
// //
// toolStripSeparator5 // toolStripSeparator5
// //
@@ -807,7 +806,7 @@ namespace OpenRA.Editor
this.copySelectionToolStripMenuItem.Size = new System.Drawing.Size(185, 22); this.copySelectionToolStripMenuItem.Size = new System.Drawing.Size(185, 22);
this.copySelectionToolStripMenuItem.Text = "Copy Selection"; this.copySelectionToolStripMenuItem.Text = "Copy Selection";
this.copySelectionToolStripMenuItem.ToolTipText = "Copy the current selection and paste it again on left-click."; this.copySelectionToolStripMenuItem.ToolTipText = "Copy the current selection and paste it again on left-click.";
this.copySelectionToolStripMenuItem.Click += new System.EventHandler(this.copySelectionToolStripMenuItemClick); this.copySelectionToolStripMenuItem.Click += new System.EventHandler(this.CopySelectionToolStripMenuItemClick);
// //
// toolStripComboBox1 // toolStripComboBox1
// //
@@ -850,7 +849,7 @@ namespace OpenRA.Editor
this.openRAWebsiteToolStripMenuItem.Size = new System.Drawing.Size(183, 22); this.openRAWebsiteToolStripMenuItem.Size = new System.Drawing.Size(183, 22);
this.openRAWebsiteToolStripMenuItem.Text = "OpenRA &Website"; this.openRAWebsiteToolStripMenuItem.Text = "OpenRA &Website";
this.openRAWebsiteToolStripMenuItem.ToolTipText = "Visit the OpenRA homepage."; this.openRAWebsiteToolStripMenuItem.ToolTipText = "Visit the OpenRA homepage.";
this.openRAWebsiteToolStripMenuItem.Click += new System.EventHandler(this.openRAWebsiteToolStripMenuItemClick); this.openRAWebsiteToolStripMenuItem.Click += new System.EventHandler(this.OpenRAWebsiteToolStripMenuItemClick);
// //
// openRAResourcesToolStripMenuItem // openRAResourcesToolStripMenuItem
// //
@@ -859,7 +858,7 @@ namespace OpenRA.Editor
this.openRAResourcesToolStripMenuItem.Size = new System.Drawing.Size(183, 22); this.openRAResourcesToolStripMenuItem.Size = new System.Drawing.Size(183, 22);
this.openRAResourcesToolStripMenuItem.Text = "OpenRA &Resources"; this.openRAResourcesToolStripMenuItem.Text = "OpenRA &Resources";
this.openRAResourcesToolStripMenuItem.ToolTipText = "Share your maps and replays by uploading on this file exchange community."; this.openRAResourcesToolStripMenuItem.ToolTipText = "Share your maps and replays by uploading on this file exchange community.";
this.openRAResourcesToolStripMenuItem.Click += new System.EventHandler(this.openRAResourcesToolStripMenuItemClick); this.openRAResourcesToolStripMenuItem.Click += new System.EventHandler(this.OpenRAResourcesToolStripMenuItemClick);
// //
// wikiDocumentationToolStripMenuItem // wikiDocumentationToolStripMenuItem
// //
@@ -868,7 +867,7 @@ namespace OpenRA.Editor
this.wikiDocumentationToolStripMenuItem.Size = new System.Drawing.Size(183, 22); this.wikiDocumentationToolStripMenuItem.Size = new System.Drawing.Size(183, 22);
this.wikiDocumentationToolStripMenuItem.Text = "Wiki &Documentation"; this.wikiDocumentationToolStripMenuItem.Text = "Wiki &Documentation";
this.wikiDocumentationToolStripMenuItem.ToolTipText = "Read and contribute to the developer documentation."; this.wikiDocumentationToolStripMenuItem.ToolTipText = "Read and contribute to the developer documentation.";
this.wikiDocumentationToolStripMenuItem.Click += new System.EventHandler(this.wikiDocumentationToolStripMenuItemClick); this.wikiDocumentationToolStripMenuItem.Click += new System.EventHandler(this.WikiDocumentationToolStripMenuItemClick);
// //
// discussionForumsToolStripMenuItem // discussionForumsToolStripMenuItem
// //
@@ -877,7 +876,7 @@ namespace OpenRA.Editor
this.discussionForumsToolStripMenuItem.Size = new System.Drawing.Size(183, 22); this.discussionForumsToolStripMenuItem.Size = new System.Drawing.Size(183, 22);
this.discussionForumsToolStripMenuItem.Text = "Discussion &Forums"; this.discussionForumsToolStripMenuItem.Text = "Discussion &Forums";
this.discussionForumsToolStripMenuItem.ToolTipText = "Discuss OpenRA related matters in a bulletin board forum."; this.discussionForumsToolStripMenuItem.ToolTipText = "Discuss OpenRA related matters in a bulletin board forum.";
this.discussionForumsToolStripMenuItem.Click += new System.EventHandler(this.discussionForumsToolStripMenuItemClick); this.discussionForumsToolStripMenuItem.Click += new System.EventHandler(this.DiscussionForumsToolStripMenuItemClick);
// //
// sourceCodeToolStripMenuItem // sourceCodeToolStripMenuItem
// //
@@ -886,7 +885,7 @@ namespace OpenRA.Editor
this.sourceCodeToolStripMenuItem.Size = new System.Drawing.Size(183, 22); this.sourceCodeToolStripMenuItem.Size = new System.Drawing.Size(183, 22);
this.sourceCodeToolStripMenuItem.Text = "Source &Code"; this.sourceCodeToolStripMenuItem.Text = "Source &Code";
this.sourceCodeToolStripMenuItem.ToolTipText = "Browse and download the source code. Fix what annoys you. Patches are welcome."; this.sourceCodeToolStripMenuItem.ToolTipText = "Browse and download the source code. Fix what annoys you. Patches are welcome.";
this.sourceCodeToolStripMenuItem.Click += new System.EventHandler(this.sourceCodeToolStripMenuItemClick); this.sourceCodeToolStripMenuItem.Click += new System.EventHandler(this.SourceCodeToolStripMenuItemClick);
// //
// issueTrackerToolStripMenuItem // issueTrackerToolStripMenuItem
// //
@@ -895,7 +894,7 @@ namespace OpenRA.Editor
this.issueTrackerToolStripMenuItem.Size = new System.Drawing.Size(183, 22); this.issueTrackerToolStripMenuItem.Size = new System.Drawing.Size(183, 22);
this.issueTrackerToolStripMenuItem.Text = "Issue &Tracker"; this.issueTrackerToolStripMenuItem.Text = "Issue &Tracker";
this.issueTrackerToolStripMenuItem.ToolTipText = "Report problems and request features."; this.issueTrackerToolStripMenuItem.ToolTipText = "Report problems and request features.";
this.issueTrackerToolStripMenuItem.Click += new System.EventHandler(this.issueTrackerToolStripMenuItemClick); this.issueTrackerToolStripMenuItem.Click += new System.EventHandler(this.IssueTrackerToolStripMenuItemClick);
// //
// developerBountiesToolStripMenuItem // developerBountiesToolStripMenuItem
// //
@@ -904,7 +903,7 @@ namespace OpenRA.Editor
this.developerBountiesToolStripMenuItem.Size = new System.Drawing.Size(183, 22); this.developerBountiesToolStripMenuItem.Size = new System.Drawing.Size(183, 22);
this.developerBountiesToolStripMenuItem.Text = "Developer &Bounties"; this.developerBountiesToolStripMenuItem.Text = "Developer &Bounties";
this.developerBountiesToolStripMenuItem.ToolTipText = "Hire a developer to get OpenRA modified to your wishes."; this.developerBountiesToolStripMenuItem.ToolTipText = "Hire a developer to get OpenRA modified to your wishes.";
this.developerBountiesToolStripMenuItem.Click += new System.EventHandler(this.developerBountiesToolStripMenuItemClick); this.developerBountiesToolStripMenuItem.Click += new System.EventHandler(this.DeveloperBountiesToolStripMenuItemClick);
// //
// toolStripSeparator6 // toolStripSeparator6
// //
@@ -918,7 +917,7 @@ namespace OpenRA.Editor
this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem"; this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
this.aboutToolStripMenuItem.Size = new System.Drawing.Size(183, 22); this.aboutToolStripMenuItem.Size = new System.Drawing.Size(183, 22);
this.aboutToolStripMenuItem.Text = "&About"; this.aboutToolStripMenuItem.Text = "&About";
this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItemClick); this.aboutToolStripMenuItem.Click += new System.EventHandler(this.AboutToolStripMenuItemClick);
// //
// statusStrip1 // statusStrip1
// //
@@ -949,43 +948,43 @@ namespace OpenRA.Editor
// //
// BottomToolStripPanel // BottomToolStripPanel
// //
this.BottomToolStripPanel.Dock = System.Windows.Forms.DockStyle.Bottom; this.bottomToolStripPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
this.BottomToolStripPanel.Location = new System.Drawing.Point(0, 25); this.bottomToolStripPanel.Location = new System.Drawing.Point(0, 25);
this.BottomToolStripPanel.Name = "BottomToolStripPanel"; this.bottomToolStripPanel.Name = "BottomToolStripPanel";
this.BottomToolStripPanel.Orientation = System.Windows.Forms.Orientation.Horizontal; this.bottomToolStripPanel.Orientation = System.Windows.Forms.Orientation.Horizontal;
this.BottomToolStripPanel.RowMargin = new System.Windows.Forms.Padding(3, 0, 0, 0); this.bottomToolStripPanel.RowMargin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.BottomToolStripPanel.Size = new System.Drawing.Size(985, 0); this.bottomToolStripPanel.Size = new System.Drawing.Size(985, 0);
// //
// TopToolStripPanel // TopToolStripPanel
// //
this.TopToolStripPanel.Dock = System.Windows.Forms.DockStyle.Top; this.topToolStripPanel.Dock = System.Windows.Forms.DockStyle.Top;
this.TopToolStripPanel.Location = new System.Drawing.Point(0, 0); this.topToolStripPanel.Location = new System.Drawing.Point(0, 0);
this.TopToolStripPanel.Name = "TopToolStripPanel"; this.topToolStripPanel.Name = "TopToolStripPanel";
this.TopToolStripPanel.Orientation = System.Windows.Forms.Orientation.Horizontal; this.topToolStripPanel.Orientation = System.Windows.Forms.Orientation.Horizontal;
this.TopToolStripPanel.RowMargin = new System.Windows.Forms.Padding(3, 0, 0, 0); this.topToolStripPanel.RowMargin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.TopToolStripPanel.Size = new System.Drawing.Size(985, 0); this.topToolStripPanel.Size = new System.Drawing.Size(985, 0);
// //
// RightToolStripPanel // RightToolStripPanel
// //
this.RightToolStripPanel.Dock = System.Windows.Forms.DockStyle.Right; this.rightToolStripPanel.Dock = System.Windows.Forms.DockStyle.Right;
this.RightToolStripPanel.Location = new System.Drawing.Point(985, 0); this.rightToolStripPanel.Location = new System.Drawing.Point(985, 0);
this.RightToolStripPanel.Name = "RightToolStripPanel"; this.rightToolStripPanel.Name = "RightToolStripPanel";
this.RightToolStripPanel.Orientation = System.Windows.Forms.Orientation.Vertical; this.rightToolStripPanel.Orientation = System.Windows.Forms.Orientation.Vertical;
this.RightToolStripPanel.RowMargin = new System.Windows.Forms.Padding(0, 3, 0, 0); this.rightToolStripPanel.RowMargin = new System.Windows.Forms.Padding(0, 3, 0, 0);
this.RightToolStripPanel.Size = new System.Drawing.Size(0, 25); this.rightToolStripPanel.Size = new System.Drawing.Size(0, 25);
// //
// LeftToolStripPanel // LeftToolStripPanel
// //
this.LeftToolStripPanel.Dock = System.Windows.Forms.DockStyle.Left; this.leftToolStripPanel.Dock = System.Windows.Forms.DockStyle.Left;
this.LeftToolStripPanel.Location = new System.Drawing.Point(0, 0); this.leftToolStripPanel.Location = new System.Drawing.Point(0, 0);
this.LeftToolStripPanel.Name = "LeftToolStripPanel"; this.leftToolStripPanel.Name = "LeftToolStripPanel";
this.LeftToolStripPanel.Orientation = System.Windows.Forms.Orientation.Vertical; this.leftToolStripPanel.Orientation = System.Windows.Forms.Orientation.Vertical;
this.LeftToolStripPanel.RowMargin = new System.Windows.Forms.Padding(0, 3, 0, 0); this.leftToolStripPanel.RowMargin = new System.Windows.Forms.Padding(0, 3, 0, 0);
this.LeftToolStripPanel.Size = new System.Drawing.Size(0, 25); this.leftToolStripPanel.Size = new System.Drawing.Size(0, 25);
// //
// ContentPanel // ContentPanel
// //
this.ContentPanel.Size = new System.Drawing.Size(985, 25); this.contentPanel.Size = new System.Drawing.Size(985, 25);
// //
// toolStripContainer1 // toolStripContainer1
// //
@@ -1039,7 +1038,7 @@ namespace OpenRA.Editor
this.splitContainer2.Panel1.ResumeLayout(false); this.splitContainer2.Panel1.ResumeLayout(false);
this.splitContainer2.Panel2.ResumeLayout(false); this.splitContainer2.Panel2.ResumeLayout(false);
this.splitContainer2.ResumeLayout(false); this.splitContainer2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pmMiniMap)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.miniMapBox)).EndInit();
this.tabControl1.ResumeLayout(false); this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false); this.tabPage1.ResumeLayout(false);
this.tabPage2.ResumeLayout(false); this.tabPage2.ResumeLayout(false);
@@ -1084,7 +1083,7 @@ namespace OpenRA.Editor
private System.Windows.Forms.TabPage tabPage3; private System.Windows.Forms.TabPage tabPage3;
private System.Windows.Forms.FlowLayoutPanel resourcePalette; private System.Windows.Forms.FlowLayoutPanel resourcePalette;
private Surface surface1; private Surface surface1;
private System.Windows.Forms.PictureBox pmMiniMap; private System.Windows.Forms.PictureBox miniMapBox;
private System.Windows.Forms.SplitContainer splitContainer2; private System.Windows.Forms.SplitContainer splitContainer2;
private System.Windows.Forms.SplitContainer splitContainer3; private System.Windows.Forms.SplitContainer splitContainer3;
private System.Windows.Forms.StatusStrip statusStrip1; private System.Windows.Forms.StatusStrip statusStrip1;
@@ -1099,9 +1098,9 @@ namespace OpenRA.Editor
private System.Windows.Forms.ToolStripMenuItem saveAsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem saveAsToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem cCRedAlertMapToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem redAlertMapToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem mnuExport; private System.Windows.Forms.ToolStripMenuItem miniMapExport;
private System.Windows.Forms.ToolStripMenuItem mnuMinimapToPNG; private System.Windows.Forms.ToolStripMenuItem miniMapToPng;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem mapToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem mapToolStripMenuItem;
@@ -1133,12 +1132,12 @@ namespace OpenRA.Editor
private System.Windows.Forms.ToolStrip toolStrip1; private System.Windows.Forms.ToolStrip toolStrip1;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator; private System.Windows.Forms.ToolStripSeparator toolStripSeparator;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator7; private System.Windows.Forms.ToolStripSeparator toolStripSeparator7;
private System.Windows.Forms.ToolStripButton QuickhelpToolStripButton; private System.Windows.Forms.ToolStripButton quickhelpToolStripButton;
private System.Windows.Forms.ToolStripPanel BottomToolStripPanel; private System.Windows.Forms.ToolStripPanel bottomToolStripPanel;
private System.Windows.Forms.ToolStripPanel TopToolStripPanel; private System.Windows.Forms.ToolStripPanel topToolStripPanel;
private System.Windows.Forms.ToolStripPanel RightToolStripPanel; private System.Windows.Forms.ToolStripPanel rightToolStripPanel;
private System.Windows.Forms.ToolStripPanel LeftToolStripPanel; private System.Windows.Forms.ToolStripPanel leftToolStripPanel;
private System.Windows.Forms.ToolStripContentPanel ContentPanel; private System.Windows.Forms.ToolStripContentPanel contentPanel;
private System.Windows.Forms.ToolStripButton toolStripMenuItemNew; private System.Windows.Forms.ToolStripButton toolStripMenuItemNew;
private System.Windows.Forms.ToolStripButton toolStripMenuItemOpen; private System.Windows.Forms.ToolStripButton toolStripMenuItemOpen;
private System.Windows.Forms.ToolStripButton toolStripMenuItemSave; private System.Windows.Forms.ToolStripButton toolStripMenuItemSave;
@@ -1156,4 +1155,3 @@ namespace OpenRA.Editor
private System.Windows.Forms.ToolStripMenuItem fullMapRenderToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem fullMapRenderToolStripMenuItem;
} }
} }

View File

@@ -43,7 +43,7 @@ namespace OpenRA.Editor
actorPalette.ResumeLayout(); actorPalette.ResumeLayout();
resourcePalette.ResumeLayout(); resourcePalette.ResumeLayout();
surface1.Bind(null, null, null, null); surface1.Bind(null, null, null, null);
pmMiniMap.Image = null; miniMapBox.Image = null;
currentMod = toolStripComboBox1.SelectedItem as string; currentMod = toolStripComboBox1.SelectedItem as string;
Game.modData = new ModData(currentMod); Game.modData = new ModData(currentMod);
@@ -69,7 +69,7 @@ namespace OpenRA.Editor
void OnMapChanged() void OnMapChanged()
{ {
MakeDirty(); MakeDirty();
pmMiniMap.Image = Minimap.AddStaticResources(surface1.Map, Minimap.TerrainBitmap(surface1.Map, true)); miniMapBox.Image = Minimap.AddStaticResources(surface1.Map, Minimap.TerrainBitmap(surface1.Map, true));
cashToolStripStatusLabel.Text = CalculateTotalResource().ToString(); cashToolStripStatusLabel.Text = CalculateTotalResource().ToString();
} }
@@ -120,6 +120,7 @@ namespace OpenRA.Editor
map.MakeDefaultPlayers(); map.MakeDefaultPlayers();
PrepareMapResources(Game.modData.Manifest, map); PrepareMapResources(Game.modData.Manifest, map);
// Calculate total net worth of resources in cash // Calculate total net worth of resources in cash
cashToolStripStatusLabel.Text = CalculateTotalResource().ToString(); cashToolStripStatusLabel.Text = CalculateTotalResource().ToString();
@@ -144,19 +145,20 @@ namespace OpenRA.Editor
Rules.LoadRules(manifest, map); Rules.LoadRules(manifest, map);
tileset = Rules.TileSets[map.Tileset]; tileset = Rules.TileSets[map.Tileset];
tileset.LoadTiles(); tileset.LoadTiles();
int[] ShadowIndex = { 3, 4 }; var shadowIndex = new int[] { 3, 4 };
var palette = new Palette(FileSystem.Open(tileset.Palette), ShadowIndex); var palette = new Palette(FileSystem.Open(tileset.Palette), shadowIndex);
// required for desert terrain in RA // required for desert terrain in RA
var playerPalette = tileset.PlayerPalette ?? tileset.Palette; var playerPalette = tileset.PlayerPalette ?? tileset.Palette;
var PlayerPalette = new Palette(FileSystem.Open(playerPalette), ShadowIndex); var shadowedPalette = new Palette(FileSystem.Open(playerPalette), shadowIndex);
surface1.Bind(map, tileset, palette, shadowedPalette);
surface1.Bind(map, tileset, palette, PlayerPalette);
// construct the palette of tiles // construct the palette of tiles
var palettes = new[] { tilePalette, actorPalette, resourcePalette }; var palettes = new[] { tilePalette, actorPalette, resourcePalette };
foreach (var p in palettes) { p.Visible = false; p.SuspendLayout(); } foreach (var p in palettes) { p.Visible = false; p.SuspendLayout(); }
string[] templateOrder = tileset.EditorTemplateOrder ?? new string[]{}; var templateOrder = tileset.EditorTemplateOrder ?? new string[] { };
foreach (var tc in tileset.Templates.GroupBy(t => t.Value.Category).OrderBy(t => templateOrder.ToList().IndexOf(t.Key))) foreach (var tc in tileset.Templates.GroupBy(t => t.Value.Category).OrderBy(t => templateOrder.ToList().IndexOf(t.Key)))
{ {
var category = tc.Key ?? "(Uncategorized)"; var category = tc.Key ?? "(Uncategorized)";
@@ -170,6 +172,7 @@ namespace OpenRA.Editor
TextAlign = ContentAlignment.MiddleLeft, TextAlign = ContentAlignment.MiddleLeft,
Width = tilePalette.ClientSize.Width, Width = tilePalette.ClientSize.Width,
}; };
// hook this manually, anchoring inside FlowLayoutPanel is flaky. // hook this manually, anchoring inside FlowLayoutPanel is flaky.
tilePalette.Resize += (_, e) => categoryHeader.Width = tilePalette.ClientSize.Width; tilePalette.Resize += (_, e) => categoryHeader.Width = tilePalette.ClientSize.Width;
@@ -196,12 +199,7 @@ namespace OpenRA.Editor
var template = t.Value; var template = t.Value;
tilePalette.Controls.Add(ibox); tilePalette.Controls.Add(ibox);
tt.SetToolTip(ibox, tt.SetToolTip(ibox, "{1}:{0} ({2}x{3})".F(template.Image, template.Id, template.Size.X, template.Size.Y));
"{1}:{0} ({2}x{3})".F(
template.Image,
template.Id,
template.Size.X,
template.Size.Y));
} }
catch { } catch { }
} }
@@ -222,13 +220,14 @@ namespace OpenRA.Editor
if (etf != null && etf.RequireTilesets != null if (etf != null && etf.RequireTilesets != null
&& !etf.RequireTilesets.Contains(tileset.Id)) continue; && !etf.RequireTilesets.Contains(tileset.Id)) continue;
var TemplatePalette = PlayerPalette; var templatePalette = shadowedPalette;
var rsi = info.Traits.GetOrDefault<RenderSimpleInfo>(); var rsi = info.Traits.GetOrDefault<RenderSimpleInfo>();
// exception for desert buildings // exception for desert buildings
if (rsi != null && rsi.Palette != null && rsi.Palette.Contains("terrain")) if (rsi != null && rsi.Palette != null && rsi.Palette.Contains("terrain"))
TemplatePalette = palette; templatePalette = palette;
var template = RenderUtils.RenderActor(info, tileset, TemplatePalette); var template = RenderUtils.RenderActor(info, tileset, templatePalette);
var ibox = new PictureBox var ibox = new PictureBox
{ {
Image = template.Bitmap, Image = template.Bitmap,
@@ -242,9 +241,7 @@ namespace OpenRA.Editor
actorPalette.Controls.Add(ibox); actorPalette.Controls.Add(ibox);
tt.SetToolTip(ibox, tt.SetToolTip(ibox, "{0}".F(info.Name));
"{0}".F(
info.Name));
actorTemplates.Add(template); actorTemplates.Add(template);
} }
@@ -259,7 +256,7 @@ namespace OpenRA.Editor
{ {
try try
{ {
var template = RenderUtils.RenderResourceType(a, tileset.Extensions, PlayerPalette); var template = RenderUtils.RenderResourceType(a, tileset.Extensions, shadowedPalette);
var ibox = new PictureBox var ibox = new PictureBox
{ {
Image = template.Bitmap, Image = template.Bitmap,
@@ -269,16 +266,11 @@ namespace OpenRA.Editor
BorderStyle = BorderStyle.FixedSingle BorderStyle = BorderStyle.FixedSingle
}; };
ibox.Click += (_, e) => surface1.SetTool(new ResourceTool(template)); ibox.Click += (_, e) => surface1.SetTool(new ResourceTool(template));
resourcePalette.Controls.Add(ibox); resourcePalette.Controls.Add(ibox);
tt.SetToolTip(ibox, tt.SetToolTip(ibox, "{0}:{1}cr".F(template.Info.Name, template.Info.ValuePerUnit));
"{0}:{1}cr".F(
template.Info.Name,
template.Info.ValuePerUnit));
resourceTemplates.Add(template); resourceTemplates.Add(template);
} }
@@ -293,7 +285,7 @@ namespace OpenRA.Editor
p.ResumeLayout(); p.ResumeLayout();
} }
pmMiniMap.Image = Minimap.AddStaticResources(surface1.Map, Minimap.TerrainBitmap(surface1.Map, true)); miniMapBox.Image = Minimap.AddStaticResources(surface1.Map, Minimap.TerrainBitmap(surface1.Map, true));
propertiesToolStripMenuItem.Enabled = true; propertiesToolStripMenuItem.Enabled = true;
toolStripMenuItemProperties.Enabled = true; toolStripMenuItemProperties.Enabled = true;
@@ -302,7 +294,7 @@ namespace OpenRA.Editor
saveToolStripMenuItem.Enabled = true; saveToolStripMenuItem.Enabled = true;
toolStripMenuItemSave.Enabled = true; toolStripMenuItemSave.Enabled = true;
saveAsToolStripMenuItem.Enabled = true; saveAsToolStripMenuItem.Enabled = true;
mnuMinimapToPNG.Enabled = true; // TODO: what is this VB naming bullshit doing here? miniMapToPng.Enabled = true;
PopulateActorOwnerChooser(); PopulateActorOwnerChooser();
} }
@@ -319,24 +311,24 @@ namespace OpenRA.Editor
{ {
using (var rd = new ResizeDialog()) using (var rd = new ResizeDialog())
{ {
rd.width.Value = surface1.Map.MapSize.X; rd.MapWidth.Value = surface1.Map.MapSize.X;
rd.height.Value = surface1.Map.MapSize.Y; rd.MapHeight.Value = surface1.Map.MapSize.Y;
rd.cordonLeft.Value = surface1.Map.Bounds.Left; rd.CordonLeft.Value = surface1.Map.Bounds.Left;
rd.cordonTop.Value = surface1.Map.Bounds.Top; rd.CordonTop.Value = surface1.Map.Bounds.Top;
rd.cordonRight.Value = surface1.Map.Bounds.Right; rd.CordonRight.Value = surface1.Map.Bounds.Right;
rd.cordonBottom.Value = surface1.Map.Bounds.Bottom; rd.CordonBottom.Value = surface1.Map.Bounds.Bottom;
if (DialogResult.OK != rd.ShowDialog()) if (DialogResult.OK != rd.ShowDialog())
return; return;
surface1.Map.ResizeCordon((int)rd.cordonLeft.Value, surface1.Map.ResizeCordon((int)rd.CordonLeft.Value,
(int)rd.cordonTop.Value, (int)rd.CordonTop.Value,
(int)rd.cordonRight.Value, (int)rd.CordonRight.Value,
(int)rd.cordonBottom.Value); (int)rd.CordonBottom.Value);
if ((int)rd.width.Value != surface1.Map.MapSize.X || (int)rd.height.Value != surface1.Map.MapSize.Y) if ((int)rd.MapWidth.Value != surface1.Map.MapSize.X || (int)rd.MapHeight.Value != surface1.Map.MapSize.Y)
{ {
surface1.Map.Resize((int)rd.width.Value, (int)rd.height.Value); surface1.Map.Resize((int)rd.MapWidth.Value, (int)rd.MapHeight.Value);
surface1.Bind(surface1.Map, surface1.TileSet, surface1.Palette, surface1.PlayerPalette); // rebind it to invalidate all caches surface1.Bind(surface1.Map, surface1.TileSet, surface1.Palette, surface1.PlayerPalette); // rebind it to invalidate all caches
} }
@@ -353,25 +345,24 @@ namespace OpenRA.Editor
surface1.Map.Save(loadedMapName); surface1.Map.Save(loadedMapName);
dirty = false; dirty = false;
} }
} }
void SaveAsClicked(object sender, EventArgs e) void SaveAsClicked(object sender, EventArgs e)
{ {
using (var nms = new MapSelect(currentMod)) using (var nms = new MapSelect(currentMod))
{ {
nms.txtNew.ReadOnly = false; nms.NewText.ReadOnly = false;
nms.btnOk.Text = "Save"; nms.ButtonOkay.Text = "Save";
nms.txtNew.Text = "unnamed"; nms.NewText.Text = "unnamed";
nms.txtPathOut.ReadOnly = false; nms.PathOutText.ReadOnly = false;
if (DialogResult.OK == nms.ShowDialog()) if (DialogResult.OK == nms.ShowDialog())
{ {
if (nms.txtNew.Text == "") if (nms.NewText.Text == "")
nms.txtNew.Text = "unnamed"; nms.NewText.Text = "unnamed";
// TODO: Allow the user to choose map format (directory vs oramap) // TODO: Allow the user to choose map format (directory vs oramap)
loadedMapName = Path.Combine(nms.MapFolderPath, nms.txtNew.Text + ".oramap"); loadedMapName = Path.Combine(nms.MapFolderPath, nms.NewText.Text + ".oramap");
SaveClicked(sender, e); SaveClicked(sender, e);
} }
} }
@@ -381,12 +372,12 @@ namespace OpenRA.Editor
{ {
using (var nms = new MapSelect(currentMod)) using (var nms = new MapSelect(currentMod))
{ {
nms.txtNew.ReadOnly = true; nms.NewText.ReadOnly = true;
nms.txtPathOut.ReadOnly = true; nms.PathOutText.ReadOnly = true;
nms.btnOk.Text = "Open"; nms.ButtonOkay.Text = "Open";
if (DialogResult.OK == nms.ShowDialog()) if (DialogResult.OK == nms.ShowDialog())
LoadMap(nms.txtNew.Tag as string); LoadMap(nms.NewText.Tag as string);
} }
} }
@@ -394,17 +385,17 @@ namespace OpenRA.Editor
{ {
using (var nmd = new NewMapDialog()) using (var nmd = new NewMapDialog())
{ {
nmd.theater.Items.Clear(); nmd.TheaterBox.Items.Clear();
nmd.theater.Items.AddRange(Rules.TileSets.Select(a => a.Value.Id).ToArray()); nmd.TheaterBox.Items.AddRange(Rules.TileSets.Select(a => a.Value.Id).ToArray());
nmd.theater.SelectedIndex = 0; nmd.TheaterBox.SelectedIndex = 0;
if (DialogResult.OK == nmd.ShowDialog()) if (DialogResult.OK == nmd.ShowDialog())
{ {
var map = Map.FromTileset(nmd.theater.SelectedItem as string); var map = Map.FromTileset(nmd.TheaterBox.SelectedItem as string);
map.Resize((int)nmd.width.Value, (int)nmd.height.Value); map.Resize((int)nmd.MapWidth.Value, (int)nmd.MapHeight.Value);
map.ResizeCordon((int)nmd.cordonLeft.Value, (int)nmd.cordonTop.Value, map.ResizeCordon((int)nmd.CordonLeft.Value, (int)nmd.CordonTop.Value,
(int)nmd.cordonRight.Value, (int)nmd.cordonBottom.Value); (int)nmd.CordonRight.Value, (int)nmd.CordonBottom.Value);
map.Players.Clear(); map.Players.Clear();
map.MakeDefaultPlayers(); map.MakeDefaultPlayers();
@@ -418,20 +409,20 @@ namespace OpenRA.Editor
{ {
using (var pd = new PropertiesDialog()) using (var pd = new PropertiesDialog())
{ {
pd.title.Text = surface1.Map.Title; pd.TitleBox.Text = surface1.Map.Title;
pd.desc.Text = surface1.Map.Description; pd.DescBox.Text = surface1.Map.Description;
pd.author.Text = surface1.Map.Author; pd.AuthorBox.Text = surface1.Map.Author;
pd.selectable.Checked = surface1.Map.Selectable; pd.SelectableCheckBox.Checked = surface1.Map.Selectable;
pd.useAsShellmap.Checked = surface1.Map.UseAsShellmap; pd.ShellmapCheckBox.Checked = surface1.Map.UseAsShellmap;
if (DialogResult.OK != pd.ShowDialog()) if (DialogResult.OK != pd.ShowDialog())
return; return;
surface1.Map.Title = pd.title.Text; surface1.Map.Title = pd.TitleBox.Text;
surface1.Map.Description = pd.desc.Text; surface1.Map.Description = pd.DescBox.Text;
surface1.Map.Author = pd.author.Text; surface1.Map.Author = pd.AuthorBox.Text;
surface1.Map.Selectable = pd.selectable.Checked; surface1.Map.Selectable = pd.SelectableCheckBox.Checked;
surface1.Map.UseAsShellmap = pd.useAsShellmap.Checked; surface1.Map.UseAsShellmap = pd.ShellmapCheckBox.Checked;
} }
} }
@@ -489,15 +480,18 @@ namespace OpenRA.Editor
void ExportMinimap(object sender, EventArgs e) void ExportMinimap(object sender, EventArgs e)
{ {
using( var sfd = new SaveFileDialog() { using (var sfd = new SaveFileDialog()
{
InitialDirectory = Path.Combine(Environment.CurrentDirectory, "maps"), InitialDirectory = Path.Combine(Environment.CurrentDirectory, "maps"),
DefaultExt = "*.png", DefaultExt = "*.png",
Filter = "PNG Image (*.png)|*.png", Filter = "PNG Image (*.png)|*.png",
Title = "Export Minimap to PNG", Title = "Export Minimap to PNG",
FileName = Path.ChangeExtension(loadedMapName, ".png"), FileName = Path.ChangeExtension(loadedMapName, ".png"),
RestoreDirectory = true } ) RestoreDirectory = true
})
if (DialogResult.OK == sfd.ShowDialog()) if (DialogResult.OK == sfd.ShowDialog())
pmMiniMap.Image.Save(sfd.FileName); miniMapBox.Image.Save(sfd.FileName);
} }
void ShowActorNamesClicked(object sender, EventArgs e) void ShowActorNamesClicked(object sender, EventArgs e)
@@ -571,47 +565,47 @@ namespace OpenRA.Editor
surface1.NewActorOwner = player.Name; surface1.NewActorOwner = player.Name;
} }
private void copySelectionToolStripMenuItemClick(object sender, EventArgs e) void CopySelectionToolStripMenuItemClick(object sender, EventArgs e)
{ {
surface1.CopySelection(); surface1.CopySelection();
} }
private void openRAWebsiteToolStripMenuItemClick(object sender, EventArgs e) void OpenRAWebsiteToolStripMenuItemClick(object sender, EventArgs e)
{ {
System.Diagnostics.Process.Start("http://www.open-ra.org"); System.Diagnostics.Process.Start("http://www.open-ra.org");
} }
private void openRAResourcesToolStripMenuItemClick(object sender, EventArgs e) void OpenRAResourcesToolStripMenuItemClick(object sender, EventArgs e)
{ {
System.Diagnostics.Process.Start("http://content.open-ra.org"); System.Diagnostics.Process.Start("http://content.open-ra.org");
} }
private void wikiDocumentationToolStripMenuItemClick(object sender, EventArgs e) void WikiDocumentationToolStripMenuItemClick(object sender, EventArgs e)
{ {
System.Diagnostics.Process.Start("http://github.com/OpenRA/OpenRA/wiki"); System.Diagnostics.Process.Start("http://github.com/OpenRA/OpenRA/wiki");
} }
private void discussionForumsToolStripMenuItemClick(object sender, EventArgs e) void DiscussionForumsToolStripMenuItemClick(object sender, EventArgs e)
{ {
System.Diagnostics.Process.Start("http://www.sleipnirstuff.com/forum/viewforum.php?f=80"); System.Diagnostics.Process.Start("http://www.sleipnirstuff.com/forum/viewforum.php?f=80");
} }
private void issueTrackerToolStripMenuItemClick(object sender, EventArgs e) void IssueTrackerToolStripMenuItemClick(object sender, EventArgs e)
{ {
System.Diagnostics.Process.Start("http://github.com/OpenRA/OpenRA/issues"); System.Diagnostics.Process.Start("http://github.com/OpenRA/OpenRA/issues");
} }
private void developerBountiesToolStripMenuItemClick(object sender, EventArgs e) void DeveloperBountiesToolStripMenuItemClick(object sender, EventArgs e)
{ {
System.Diagnostics.Process.Start("https://www.bountysource.com/#repos/OpenRA/OpenRA"); System.Diagnostics.Process.Start("https://www.bountysource.com/#repos/OpenRA/OpenRA");
} }
private void sourceCodeToolStripMenuItemClick(object sender, EventArgs e) void SourceCodeToolStripMenuItemClick(object sender, EventArgs e)
{ {
System.Diagnostics.Process.Start("http://github.com/OpenRA/OpenRA"); System.Diagnostics.Process.Start("http://github.com/OpenRA/OpenRA");
} }
private void aboutToolStripMenuItemClick(object sender, EventArgs e) void AboutToolStripMenuItemClick(object sender, EventArgs e)
{ {
MessageBox.Show("OpenRA and OpenRA Editor are Free/Libre Open Source Software released under the GNU General Public License version 3. See AUTHORS and COPYING for details.", MessageBox.Show("OpenRA and OpenRA Editor are Free/Libre Open Source Software released under the GNU General Public License version 3. See AUTHORS and COPYING for details.",
"About", "About",
@@ -619,74 +613,75 @@ namespace OpenRA.Editor
MessageBoxIcon.Asterisk); MessageBoxIcon.Asterisk);
} }
private void helpToolStripButton_Click(object sender, EventArgs e) void HelpToolStripButton_Click(object sender, EventArgs e)
{ {
System.Diagnostics.Process.Start("http://github.com/OpenRA/OpenRA/wiki/Mapping"); System.Diagnostics.Process.Start("http://github.com/OpenRA/OpenRA/wiki/Mapping");
} }
private void toolStripMenuItemNewClick(object sender, EventArgs e) void ToolStripMenuItemNewClick(object sender, EventArgs e)
{ {
NewClicked(sender, e); NewClicked(sender, e);
} }
private void toolStripMenuItemOpenClick(object sender, EventArgs e) void ToolStripMenuItemOpenClick(object sender, EventArgs e)
{ {
OpenClicked(sender, e); OpenClicked(sender, e);
} }
private void toolStripMenuItemSaveClick(object sender, EventArgs e) void ToolStripMenuItemSaveClick(object sender, EventArgs e)
{ {
SaveClicked(sender, e); SaveClicked(sender, e);
} }
private void toolStripMenuItemPropertiesClick(object sender, EventArgs e) void ToolStripMenuItemPropertiesClick(object sender, EventArgs e)
{ {
PropertiesClicked(sender, e); PropertiesClicked(sender, e);
} }
private void toolStripMenuItemResizeClick(object sender, EventArgs e) void ToolStripMenuItemResizeClick(object sender, EventArgs e)
{ {
ResizeClicked(sender, e); ResizeClicked(sender, e);
} }
private void toolStripMenuItemShowActorNamesClick(object sender, EventArgs e) void ToolStripMenuItemShowActorNamesClick(object sender, EventArgs e)
{ {
ShowActorNamesClicked(sender, e); ShowActorNamesClicked(sender, e);
} }
private void toolStripMenuItemFixOpenAreasClick(object sender, EventArgs e) void ToolStripMenuItemFixOpenAreasClick(object sender, EventArgs e)
{ {
FixOpenAreas(sender, e); FixOpenAreas(sender, e);
} }
private void toolStripMenuItemSetupDefaultPlayersClick(object sender, EventArgs e) void ToolStripMenuItemSetupDefaultPlayersClick(object sender, EventArgs e)
{ {
SetupDefaultPlayers(sender, e); SetupDefaultPlayers(sender, e);
} }
private void toolStripMenuItemCopySelectionClick(object sender, EventArgs e) void ToolStripMenuItemCopySelectionClick(object sender, EventArgs e)
{ {
copySelectionToolStripMenuItemClick(sender, e); CopySelectionToolStripMenuItemClick(sender, e);
} }
private void toolStripMenuItemShowGridClick(object sender, EventArgs e) void ToolStripMenuItemShowGridClick(object sender, EventArgs e)
{ {
ShowGridClicked(sender, e); ShowGridClicked(sender, e);
} }
public int CalculateTotalResource() public int CalculateTotalResource()
{ {
int TotalResource = 0; int totalResource = 0;
for (int i = 0; i < surface1.Map.MapSize.X; i++) for (int i = 0; i < surface1.Map.MapSize.X; i++)
for (int j = 0; j < surface1.Map.MapSize.Y; j++) for (int j = 0; j < surface1.Map.MapSize.Y; j++)
{ {
if (surface1.Map.MapResources.Value[i, j].type != 0) if (surface1.Map.MapResources.Value[i, j].type != 0)
TotalResource += GetResourceValue(i, j); totalResource += GetResourceValue(i, j);
}
return TotalResource;
} }
int GetAdjecentCellsWith(int ResourceType, int x, int y) return totalResource;
}
int GetAdjecentCellsWith(int resourceType, int x, int y)
{ {
int sum = 0; int sum = 0;
for (var u = -1; u < 2; u++) for (var u = -1; u < 2; u++)
@@ -694,27 +689,28 @@ namespace OpenRA.Editor
{ {
if (!surface1.Map.IsInMap(new CPos(x + u, y + v))) if (!surface1.Map.IsInMap(new CPos(x + u, y + v)))
continue; continue;
if (surface1.Map.MapResources.Value[x + u, y + v].type == ResourceType) if (surface1.Map.MapResources.Value[x + u, y + v].type == resourceType)
++sum; ++sum;
} }
return sum; return sum;
} }
int GetResourceValue(int x, int y) int GetResourceValue(int x, int y)
{ {
int ImageLength = 0; int imageLength = 0;
int type = surface1.Map.MapResources.Value[x, y].type; int type = surface1.Map.MapResources.Value[x, y].type;
var template = surface1.ResourceTemplates.Where(a => a.Value.Info.ResourceType == type).FirstOrDefault().Value; var template = surface1.ResourceTemplates.Where(a => a.Value.Info.ResourceType == type).FirstOrDefault().Value;
if (type == 1) if (type == 1)
ImageLength = 12; imageLength = 12;
else if (type == 2) else if (type == 2)
ImageLength = 3; imageLength = 3;
int density = (GetAdjecentCellsWith(type ,x , y) * ImageLength - 1) / 9; int density = (GetAdjecentCellsWith(type, x, y) * imageLength - 1) / 9;
int value = template.Info.ValuePerUnit; int value = template.Info.ValuePerUnit;
return (density) * value; return density * value;
} }
void zoomInToolStripButtonClick(object sender, System.EventArgs e) void ZoomInToolStripButtonClick(object sender, System.EventArgs e)
{ {
if (surface1.Map == null) return; if (surface1.Map == null) return;
@@ -723,7 +719,7 @@ namespace OpenRA.Editor
surface1.Invalidate(); surface1.Invalidate();
} }
void zoomOutToolStripButtonClick(object sender, System.EventArgs e) void ZoomOutToolStripButtonClick(object sender, System.EventArgs e)
{ {
if (surface1.Map == null) return; if (surface1.Map == null) return;
@@ -732,13 +728,13 @@ namespace OpenRA.Editor
surface1.Invalidate(); surface1.Invalidate();
} }
void panToolStripButtonClick(object sender, System.EventArgs e) void PanToolStripButtonClick(object sender, System.EventArgs e)
{ {
panToolStripButton.Checked ^= true; panToolStripButton.Checked ^= true;
surface1.IsPanning = panToolStripButton.Checked; surface1.IsPanning = panToolStripButton.Checked;
} }
void showRulerToolStripMenuItemClick(object sender, EventArgs e) void ShowRulerToolStripMenuItemClick(object sender, EventArgs e)
{ {
showRulerToolStripMenuItem.Checked ^= true; showRulerToolStripMenuItem.Checked ^= true;
showRulerToolStripItem.Checked ^= true; showRulerToolStripItem.Checked ^= true;
@@ -746,9 +742,9 @@ namespace OpenRA.Editor
surface1.Chunks.Clear(); surface1.Chunks.Clear();
} }
void showRulerToolStripItemClick(object sender, System.EventArgs e) void ShowRulerToolStripItemClick(object sender, System.EventArgs e)
{ {
showRulerToolStripMenuItemClick(sender, e); ShowRulerToolStripMenuItemClick(sender, e);
} }
void EraserToolStripButtonClick(object sender, System.EventArgs e) void EraserToolStripButtonClick(object sender, System.EventArgs e)

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Editor
public class LegacyMapImporter public class LegacyMapImporter
{ {
// Mapping from ra overlay index to type string // Mapping from ra overlay index to type string
static string[] raOverlayNames = static string[] redAlertOverlayNames =
{ {
"sbag", "cycl", "brik", "fenc", "wood", "sbag", "cycl", "brik", "fenc", "wood",
"gold01", "gold02", "gold03", "gold04", "gold01", "gold02", "gold03", "gold04",
@@ -34,18 +34,17 @@ namespace OpenRA.Editor
static Dictionary<string, Pair<byte, byte>> overlayResourceMapping = new Dictionary<string, Pair<byte, byte>>() static Dictionary<string, Pair<byte, byte>> overlayResourceMapping = new Dictionary<string, Pair<byte, byte>>()
{ {
// RA Gems, Gold // RA Gold & Gems
{ "gold01", new Pair<byte, byte>(1, 0) }, { "gold01", new Pair<byte, byte>(1, 0) },
{ "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) },
{ "ti3", new Pair<byte, byte>(1, 2) }, { "ti3", new Pair<byte, byte>(1, 2) },
@@ -97,10 +96,15 @@ namespace OpenRA.Editor
{ "black", HSLColor.FromRGB(80, 80, 80) }, { "black", HSLColor.FromRGB(80, 80, 80) },
}; };
int MapSize; static string Truncate(string s, int maxLength)
int ActorCount = 0; {
Map Map = new Map(); return s.Length <= maxLength ? s : s.Substring(0, maxLength);
List<string> Players = new List<string>(); }
int mapSize;
int actorCount = 0;
Map map = new Map();
List<string> players = new List<string>();
Action<string> errorHandler; Action<string> errorHandler;
LegacyMapImporter(string filename, Action<string> errorHandler) LegacyMapImporter(string filename, Action<string> errorHandler)
@@ -112,36 +116,35 @@ namespace OpenRA.Editor
public static Map Import(string filename, Action<string> errorHandler) public static Map Import(string filename, Action<string> errorHandler)
{ {
var converter = new LegacyMapImporter(filename, errorHandler); var converter = new LegacyMapImporter(filename, errorHandler);
return converter.Map; return converter.map;
} }
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 mapSection = file.GetSection("Map");
var legacyMapFormat = (IniMapFormat)int.Parse(basic.GetValue("NewINIFormat", "0")); var legacyMapFormat = (IniMapFormat)int.Parse(basic.GetValue("NewINIFormat", "0"));
var XOffset = int.Parse(map.GetValue("X", "0")); var offsetX = int.Parse(mapSection.GetValue("X", "0"));
var YOffset = int.Parse(map.GetValue("Y", "0")); var offsetY = int.Parse(mapSection.GetValue("Y", "0"));
var Width = int.Parse(map.GetValue("Width", "0")); var width = int.Parse(mapSection.GetValue("Width", "0"));
var Height = int.Parse(map.GetValue("Height", "0")); var height = int.Parse(mapSection.GetValue("Height", "0"));
MapSize = (legacyMapFormat == IniMapFormat.RedAlert) ? 128 : 64; mapSize = (legacyMapFormat == IniMapFormat.RedAlert) ? 128 : 64;
Map.Title = basic.GetValue("Name", "(null)"); map.Title = basic.GetValue("Name", "(null)");
Map.Author = "Westwood Studios"; map.Author = "Westwood Studios";
Map.Tileset = Truncate(map.GetValue("Theater", "TEMPERAT"), 8); map.Tileset = Truncate(mapSection.GetValue("Theater", "TEMPERAT"), 8);
Map.MapSize.X = MapSize; map.MapSize.X = mapSize;
Map.MapSize.Y = MapSize; map.MapSize.Y = mapSize;
Map.Bounds = Rectangle.FromLTRB(XOffset, YOffset, XOffset + Width, YOffset + Height); map.Bounds = Rectangle.FromLTRB(offsetX, offsetY, offsetX + width, offsetY + 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)
{ {
@@ -149,8 +152,9 @@ namespace OpenRA.Editor
UnpackRAOverlayData(ReadPackedSection(file.GetSection("OverlayPack"))); UnpackRAOverlayData(ReadPackedSection(file.GetSection("OverlayPack")));
ReadRATrees(file); ReadRATrees(file);
} }
else // CNC else
{ {
// CnC
UnpackCncTileData(FileSystem.Open(iniFile.Substring(0, iniFile.Length - 4) + ".bin")); UnpackCncTileData(FileSystem.Open(iniFile.Substring(0, iniFile.Length - 4) + ".bin"));
ReadCncOverlay(file); ReadCncOverlay(file);
ReadCncTrees(file); ReadCncTrees(file);
@@ -161,25 +165,23 @@ namespace OpenRA.Editor
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)
{ {
var a = new ActorReference("waypoint"); var a = new ActorReference("waypoint");
a.Add(new LocationInit((CPos)kv.Second)); a.Add(new LocationInit((CPos)kv.Second));
a.Add(new OwnerInit("Neutral")); a.Add(new OwnerInit("Neutral"));
Map.Actors.Value.Add("waypoint" + kv.First, a); map.Actors.Value.Add("waypoint" + kv.First, a);
} }
} }
static int2 LocationFromMapOffset(int offset, int mapSize) static int2 LocationFromMapOffset(int offset, int mapSize)
@@ -246,35 +248,35 @@ namespace OpenRA.Editor
void UnpackRATileData(MemoryStream ms) void UnpackRATileData(MemoryStream ms)
{ {
for (int i = 0; i < MapSize; i++) for (int i = 0; i < mapSize; i++)
for (int j = 0; j < MapSize; j++) for (int j = 0; j < mapSize; j++)
Map.MapTiles.Value[i, j] = new TileReference<ushort, byte>(); map.MapTiles.Value[i, j] = new TileReference<ushort, byte>();
for (int j = 0; j < MapSize; j++) for (int j = 0; j < mapSize; j++)
for (int i = 0; i < MapSize; i++) for (int i = 0; i < mapSize; i++)
Map.MapTiles.Value[i, j].type = ReadWord(ms); map.MapTiles.Value[i, j].type = ReadWord(ms);
for (int j = 0; j < MapSize; j++) for (int j = 0; j < mapSize; j++)
for (int i = 0; i < MapSize; i++) for (int i = 0; i < mapSize; i++)
Map.MapTiles.Value[i, j].index = ReadByte(ms); map.MapTiles.Value[i, j].index = ReadByte(ms);
} }
void UnpackRAOverlayData(MemoryStream ms) void UnpackRAOverlayData(MemoryStream ms)
{ {
for (int j = 0; j < MapSize; j++) for (int j = 0; j < mapSize; j++)
for (int i = 0; i < MapSize; i++) for (int i = 0; i < mapSize; i++)
{ {
byte o = ReadByte(ms); byte o = ReadByte(ms);
var res = Pair.New((byte)0, (byte)0); var res = Pair.New((byte)0, (byte)0);
if (o != 255 && overlayResourceMapping.ContainsKey(raOverlayNames[o])) if (o != 255 && overlayResourceMapping.ContainsKey(redAlertOverlayNames[o]))
res = overlayResourceMapping[raOverlayNames[o]]; res = overlayResourceMapping[redAlertOverlayNames[o]];
Map.MapResources.Value[i, j] = new TileReference<byte, byte>(res.First, res.Second); map.MapResources.Value[i, j] = new TileReference<byte, byte>(res.First, res.Second);
if (o != 255 && overlayActorMapping.ContainsKey(raOverlayNames[o])) if (o != 255 && overlayActorMapping.ContainsKey(redAlertOverlayNames[o]))
Map.Actors.Value.Add("Actor" + ActorCount++, map.Actors.Value.Add("Actor" + actorCount++,
new ActorReference(overlayActorMapping[raOverlayNames[o]]) new ActorReference(overlayActorMapping[redAlertOverlayNames[o]])
{ {
new LocationInit(new CPos(i, j)), new LocationInit(new CPos(i, j)),
new OwnerInit("Neutral") new OwnerInit("Neutral")
@@ -291,10 +293,10 @@ 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 CPos(loc % MapSize, loc / MapSize)), new LocationInit(new CPos(loc % mapSize, loc / mapSize)),
new OwnerInit("Neutral") new OwnerInit("Neutral")
}); });
} }
@@ -302,15 +304,15 @@ namespace OpenRA.Editor
void UnpackCncTileData(Stream ms) void UnpackCncTileData(Stream ms)
{ {
for (int i = 0; i < MapSize; i++) for (int i = 0; i < mapSize; i++)
for (int j = 0; j < MapSize; j++) for (int j = 0; j < mapSize; j++)
Map.MapTiles.Value[i, j] = new TileReference<ushort, byte>(); map.MapTiles.Value[i, j] = new TileReference<ushort, byte>();
for (int j = 0; j < MapSize; j++) for (int j = 0; j < mapSize; j++)
for (int i = 0; i < MapSize; i++) for (int i = 0; i < mapSize; i++)
{ {
Map.MapTiles.Value[i, j].type = ReadByte(ms); map.MapTiles.Value[i, j].type = ReadByte(ms);
Map.MapTiles.Value[i, j].index = ReadByte(ms); map.MapTiles.Value[i, j].index = ReadByte(ms);
} }
} }
@@ -323,16 +325,16 @@ namespace OpenRA.Editor
foreach (KeyValuePair<string, string> kv in overlay) foreach (KeyValuePair<string, string> kv in overlay)
{ {
var loc = int.Parse(kv.Key); var loc = int.Parse(kv.Key);
var cell = new CPos(loc % MapSize, loc / MapSize); var cell = new CPos(loc % mapSize, loc / mapSize);
var res = Pair.New((byte)0, (byte)0); var res = Pair.New((byte)0, (byte)0);
if (overlayResourceMapping.ContainsKey(kv.Value.ToLower())) if (overlayResourceMapping.ContainsKey(kv.Value.ToLower()))
res = overlayResourceMapping[kv.Value.ToLower()]; res = overlayResourceMapping[kv.Value.ToLower()];
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),
@@ -350,10 +352,10 @@ 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.Split(',')[0].ToLowerInvariant()) new ActorReference(kv.Value.Split(',')[0].ToLowerInvariant())
{ {
new LocationInit(new CPos(loc % MapSize, loc / MapSize)), new LocationInit(new CPos(loc % mapSize, loc / mapSize)),
new OwnerInit("Neutral") new OwnerInit("Neutral")
}); });
} }
@@ -366,21 +368,19 @@ namespace OpenRA.Editor
// Structures: num=owner,type,health,location,turret-facing,trigger // Structures: num=owner,type,health,location,turret-facing,trigger
// Units: num=owner,type,health,location,facing,action,trigger // Units: num=owner,type,health,location,facing,action,trigger
// Infantry: num=owner,type,health,location,subcell,action,facing,trigger // Infantry: num=owner,type,health,location,subcell,action,facing,trigger
try try
{ {
var parts = s.Value.Split(','); var parts = s.Value.Split(',');
var loc = int.Parse(parts[3]); var loc = int.Parse(parts[3]);
if (parts[0] == "") if (parts[0] == "")
parts[0] = "Neutral"; parts[0] = "Neutral";
if (!Players.Contains(parts[0])) if (!players.Contains(parts[0]))
Players.Add(parts[0]); players.Add(parts[0]);
var actor = new ActorReference(parts[1].ToLowerInvariant()) var actor = new ActorReference(parts[1].ToLowerInvariant())
{ {
new LocationInit(new CPos(loc % MapSize, loc / MapSize)), new LocationInit(new CPos(loc % mapSize, loc / mapSize)),
new OwnerInit(parts[0]), new OwnerInit(parts[0]),
new HealthInit(float.Parse(parts[2], NumberFormatInfo.InvariantInfo) / 256), new HealthInit(float.Parse(parts[2], NumberFormatInfo.InvariantInfo) / 256),
new FacingInit((section == "INFANTRY") ? int.Parse(parts[6]) : int.Parse(parts[4])), new FacingInit((section == "INFANTRY") ? int.Parse(parts[6]) : int.Parse(parts[4])),
@@ -392,7 +392,7 @@ namespace OpenRA.Editor
if (!Rules.Info.ContainsKey(parts[1].ToLowerInvariant())) if (!Rules.Info.ContainsKey(parts[1].ToLowerInvariant()))
errorHandler("Ignoring unknown actor type: `{0}`".F(parts[1].ToLowerInvariant())); errorHandler("Ignoring unknown actor type: `{0}`".F(parts[1].ToLowerInvariant()));
else else
Map.Actors.Value.Add("Actor" + ActorCount++, actor); map.Actors.Value.Add("Actor" + actorCount++, actor);
} }
catch (Exception) catch (Exception)
{ {
@@ -408,7 +408,7 @@ namespace OpenRA.Editor
// loc=type,loc,depth // loc=type,loc,depth
var parts = s.Value.Split(','); var parts = s.Value.Split(',');
var loc = int.Parse(parts[1]); var loc = int.Parse(parts[1]);
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])));
} }
} }
@@ -479,18 +479,13 @@ namespace OpenRA.Editor
pr.InitialCash = int.Parse(s.Value); pr.InitialCash = int.Parse(s.Value);
break; break;
case "Allies": case "Allies":
pr.Allies = s.Value.Split(',').Intersect(Players).Except(neutral).ToArray(); pr.Allies = s.Value.Split(',').Intersect(players).Except(neutral).ToArray();
pr.Enemies = s.Value.Split(',').SymmetricDifference(Players).Except(neutral).ToArray(); pr.Enemies = s.Value.Split(',').SymmetricDifference(players).Except(neutral).ToArray();
break; break;
} }
} }
Map.Players.Add(section, pr); map.Players.Add(section, pr);
}
static string Truncate(string s, int maxLength)
{
return s.Length <= maxLength ? s : s.Substring(0, maxLength);
} }
} }
} }

View File

@@ -22,53 +22,49 @@ namespace OpenRA.Editor
{ {
components.Dispose(); components.Dispose();
} }
base.Dispose(disposing); base.Dispose(disposing);
} }
#region Код, автоматически созданный конструктором форм Windows
// TODO: // TODO:
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MapSelect)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MapSelect));
this.MapList = new System.Windows.Forms.ListView(); this.MapList = new System.Windows.Forms.ListView();
this.colMapName = new System.Windows.Forms.ColumnHeader("(отсутствует)"); this.ColumnMapName = new System.Windows.Forms.ColumnHeader("(none)");
this.MapIconsList = new System.Windows.Forms.ImageList(this.components); this.MapIconsList = new System.Windows.Forms.ImageList(this.components);
this.btnCancel = new System.Windows.Forms.Button(); this.ButtonCancel = new System.Windows.Forms.Button();
this.btnOk = new System.Windows.Forms.Button(); this.ButtonOkay = new System.Windows.Forms.Button();
this.lblNew = new System.Windows.Forms.Label(); this.NewLabel = new System.Windows.Forms.Label();
this.txtNew = new System.Windows.Forms.TextBox(); this.NewText = new System.Windows.Forms.TextBox();
this.pbMinimap = new System.Windows.Forms.PictureBox(); this.MiniMapBox = new System.Windows.Forms.PictureBox();
this.pnlBottom = new System.Windows.Forms.Panel(); this.BottomPanel = new System.Windows.Forms.Panel();
this.txtPathOut = new System.Windows.Forms.TextBox(); this.PathOutText = new System.Windows.Forms.TextBox();
this.lblPathOut = new System.Windows.Forms.Label(); this.PathOutLabel = new System.Windows.Forms.Label();
this.lblPath = new System.Windows.Forms.Label(); this.PathLabel = new System.Windows.Forms.Label();
this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.SplitContainer1 = new System.Windows.Forms.SplitContainer();
this.lblMapList = new System.Windows.Forms.Label(); this.MapListLabel = new System.Windows.Forms.Label();
this.txtDesc = new System.Windows.Forms.TextBox(); this.DescTxt = new System.Windows.Forms.TextBox();
this.lblDesc = new System.Windows.Forms.Label(); this.DescLabel = new System.Windows.Forms.Label();
this.txtTheater = new System.Windows.Forms.TextBox(); this.TheaterText = new System.Windows.Forms.TextBox();
this.lblTheater = new System.Windows.Forms.Label(); this.TheaterLabel = new System.Windows.Forms.Label();
this.txtAuthor = new System.Windows.Forms.TextBox(); this.AuthorText = new System.Windows.Forms.TextBox();
this.lblAuthor = new System.Windows.Forms.Label(); this.AuthorLabel = new System.Windows.Forms.Label();
this.txtTitle = new System.Windows.Forms.TextBox(); this.TitleText = new System.Windows.Forms.TextBox();
this.lblMapName = new System.Windows.Forms.Label(); this.MapNameLabel = new System.Windows.Forms.Label();
this.lblMinimap = new System.Windows.Forms.Label(); this.MiniMapLabel = new System.Windows.Forms.Label();
this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.pictureBox1 = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.pbMinimap)).BeginInit(); ((System.ComponentModel.ISupportInitialize)this.MiniMapBox).BeginInit();
this.pnlBottom.SuspendLayout(); this.BottomPanel.SuspendLayout();
this.splitContainer1.Panel1.SuspendLayout(); this.SplitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout(); this.SplitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout(); this.SplitContainer1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)this.pictureBox1).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
//
// 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.ColumnMapName });
this.colMapName});
this.MapList.FullRowSelect = true; this.MapList.FullRowSelect = true;
this.MapList.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; this.MapList.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
this.MapList.LargeImageList = this.MapIconsList; this.MapList.LargeImageList = this.MapIconsList;
@@ -82,250 +78,198 @@ 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 this.ColumnMapName.Text = "Map name";
// this.ColumnMapName.Width = 240;
this.colMapName.Text = "Map name";
this.colMapName.Width = 240;
//
// 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 this.ButtonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
// this.ButtonCancel.Location = new System.Drawing.Point(407, 35);
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.ButtonCancel.Name = "btnCancel";
this.btnCancel.Location = new System.Drawing.Point(407, 35); this.ButtonCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.Name = "btnCancel"; this.ButtonCancel.TabIndex = 3;
this.btnCancel.Size = new System.Drawing.Size(75, 23); this.ButtonCancel.Text = "Cancel";
this.btnCancel.TabIndex = 3; this.ButtonCancel.UseVisualStyleBackColor = true;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true; this.ButtonOkay.DialogResult = System.Windows.Forms.DialogResult.OK;
// this.ButtonOkay.Location = new System.Drawing.Point(326, 35);
// btnOk this.ButtonOkay.Name = "btnOk";
// this.ButtonOkay.Size = new System.Drawing.Size(75, 23);
this.btnOk.DialogResult = System.Windows.Forms.DialogResult.OK; this.ButtonOkay.TabIndex = 2;
this.btnOk.Location = new System.Drawing.Point(326, 35); this.ButtonOkay.Text = "Open";
this.btnOk.Name = "btnOk"; this.ButtonOkay.UseVisualStyleBackColor = true;
this.btnOk.Size = new System.Drawing.Size(75, 23);
this.btnOk.TabIndex = 2; this.NewLabel.AutoSize = true;
this.btnOk.Text = "Open"; this.NewLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (byte)204);
this.btnOk.UseVisualStyleBackColor = true; this.NewLabel.Location = new System.Drawing.Point(12, 40);
// this.NewLabel.Name = "lblNew";
// lblNew this.NewLabel.Size = new System.Drawing.Size(69, 13);
// this.NewLabel.TabIndex = 3;
this.lblNew.AutoSize = true; this.NewLabel.Text = "Map name:";
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.NewText.BackColor = System.Drawing.SystemColors.Window;
this.lblNew.Name = "lblNew"; this.NewText.Location = new System.Drawing.Point(88, 37);
this.lblNew.Size = new System.Drawing.Size(69, 13); this.NewText.Name = "txtNew";
this.lblNew.TabIndex = 3; this.NewText.ReadOnly = true;
this.lblNew.Text = "Map name:"; this.NewText.Size = new System.Drawing.Size(232, 20);
// this.NewText.TabIndex = 1;
// txtNew
// this.MiniMapBox.BackColor = System.Drawing.Color.Black;
this.txtNew.BackColor = System.Drawing.SystemColors.Window; this.MiniMapBox.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.txtNew.Location = new System.Drawing.Point(88, 37); this.MiniMapBox.Location = new System.Drawing.Point(32, 25);
this.txtNew.Name = "txtNew"; this.MiniMapBox.Name = "pbMinimap";
this.txtNew.ReadOnly = true; this.MiniMapBox.Size = new System.Drawing.Size(124, 124);
this.txtNew.Size = new System.Drawing.Size(232, 20); this.MiniMapBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.txtNew.TabIndex = 1; this.MiniMapBox.TabIndex = 5;
// this.MiniMapBox.TabStop = false;
// pbMinimap
// this.BottomPanel.Controls.Add(this.pictureBox1);
this.pbMinimap.BackColor = System.Drawing.Color.Black; this.BottomPanel.Controls.Add(this.PathOutText);
this.pbMinimap.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.BottomPanel.Controls.Add(this.PathOutLabel);
this.pbMinimap.Location = new System.Drawing.Point(32, 25); this.BottomPanel.Controls.Add(this.PathLabel);
this.pbMinimap.Name = "pbMinimap"; this.BottomPanel.Controls.Add(this.ButtonCancel);
this.pbMinimap.Size = new System.Drawing.Size(124, 124); this.BottomPanel.Controls.Add(this.ButtonOkay);
this.pbMinimap.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; this.BottomPanel.Controls.Add(this.NewText);
this.pbMinimap.TabIndex = 5; this.BottomPanel.Controls.Add(this.NewLabel);
this.pbMinimap.TabStop = false; this.BottomPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
// this.BottomPanel.Location = new System.Drawing.Point(0, 332);
// pnlBottom this.BottomPanel.MaximumSize = new System.Drawing.Size(0, 70);
// this.BottomPanel.Name = "pnlBottom";
this.pnlBottom.Controls.Add(this.pictureBox1); this.BottomPanel.Size = new System.Drawing.Size(494, 70);
this.pnlBottom.Controls.Add(this.txtPathOut); this.BottomPanel.TabIndex = 6;
this.pnlBottom.Controls.Add(this.lblPathOut);
this.pnlBottom.Controls.Add(this.lblPath); this.PathOutText.BackColor = System.Drawing.SystemColors.Window;
this.pnlBottom.Controls.Add(this.btnCancel); this.PathOutText.Location = new System.Drawing.Point(55, 10);
this.pnlBottom.Controls.Add(this.btnOk); this.PathOutText.Name = "txtPathOut";
this.pnlBottom.Controls.Add(this.txtNew); this.PathOutText.ReadOnly = true;
this.pnlBottom.Controls.Add(this.lblNew); this.PathOutText.Size = new System.Drawing.Size(265, 20);
this.pnlBottom.Dock = System.Windows.Forms.DockStyle.Bottom; this.PathOutText.TabIndex = 0;
this.pnlBottom.Location = new System.Drawing.Point(0, 332); this.PathOutText.TextChanged += new System.EventHandler(this.PathOutTextChanged);
this.pnlBottom.MaximumSize = new System.Drawing.Size(0, 70);
this.pnlBottom.Name = "pnlBottom"; this.PathOutLabel.AutoSize = true;
this.pnlBottom.Size = new System.Drawing.Size(494, 70); this.PathOutLabel.Location = new System.Drawing.Point(55, 13);
this.pnlBottom.TabIndex = 6; this.PathOutLabel.Name = "lblPathOut";
// this.PathOutLabel.Size = new System.Drawing.Size(0, 13);
// txtPathOut this.PathOutLabel.TabIndex = 6;
//
this.txtPathOut.BackColor = System.Drawing.SystemColors.Window; this.PathLabel.AutoSize = true;
this.txtPathOut.Location = new System.Drawing.Point(55, 10); this.PathLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (byte)204);
this.txtPathOut.Name = "txtPathOut"; this.PathLabel.Location = new System.Drawing.Point(12, 13);
this.txtPathOut.ReadOnly = true; this.PathLabel.Name = "lblPath";
this.txtPathOut.Size = new System.Drawing.Size(265, 20); this.PathLabel.Size = new System.Drawing.Size(37, 13);
this.txtPathOut.TabIndex = 0; this.PathLabel.TabIndex = 5;
this.txtPathOut.TextChanged += new System.EventHandler(this.txtPathOut_TextChanged); this.PathLabel.Text = "Path:";
//
// lblPathOut this.SplitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
// this.SplitContainer1.Location = new System.Drawing.Point(0, 0);
this.lblPathOut.AutoSize = true; this.SplitContainer1.Name = "splitContainer1";
this.lblPathOut.Location = new System.Drawing.Point(55, 13);
this.lblPathOut.Name = "lblPathOut"; this.SplitContainer1.Panel1.Controls.Add(this.MapListLabel);
this.lblPathOut.Size = new System.Drawing.Size(0, 13); this.SplitContainer1.Panel1.Controls.Add(this.MapList);
this.lblPathOut.TabIndex = 6;
// this.SplitContainer1.Panel2.Controls.Add(this.DescTxt);
// lblPath this.SplitContainer1.Panel2.Controls.Add(this.DescLabel);
// this.SplitContainer1.Panel2.Controls.Add(this.TheaterText);
this.lblPath.AutoSize = true; this.SplitContainer1.Panel2.Controls.Add(this.TheaterLabel);
this.lblPath.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); this.SplitContainer1.Panel2.Controls.Add(this.AuthorText);
this.lblPath.Location = new System.Drawing.Point(12, 13); this.SplitContainer1.Panel2.Controls.Add(this.AuthorLabel);
this.lblPath.Name = "lblPath"; this.SplitContainer1.Panel2.Controls.Add(this.TitleText);
this.lblPath.Size = new System.Drawing.Size(37, 13); this.SplitContainer1.Panel2.Controls.Add(this.MapNameLabel);
this.lblPath.TabIndex = 5; this.SplitContainer1.Panel2.Controls.Add(this.MiniMapLabel);
this.lblPath.Text = "Path:"; this.SplitContainer1.Panel2.Controls.Add(this.MiniMapBox);
// this.SplitContainer1.Size = new System.Drawing.Size(494, 332);
// splitContainer1 this.SplitContainer1.SplitterDistance = 300;
// this.SplitContainer1.TabIndex = 7;
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.Location = new System.Drawing.Point(0, 0); this.MapListLabel.AutoSize = true;
this.splitContainer1.Name = "splitContainer1"; this.MapListLabel.Location = new System.Drawing.Point(12, 9);
// this.MapListLabel.Name = "lblMapList";
// splitContainer1.Panel1 this.MapListLabel.Size = new System.Drawing.Size(81, 13);
// this.MapListLabel.TabIndex = 1;
this.splitContainer1.Panel1.Controls.Add(this.lblMapList); this.MapListLabel.Text = "Available maps:";
this.splitContainer1.Panel1.Controls.Add(this.MapList);
// this.DescTxt.BackColor = System.Drawing.SystemColors.ButtonFace;
// splitContainer1.Panel2 this.DescTxt.Location = new System.Drawing.Point(16, 289);
// this.DescTxt.Name = "txtDesc";
this.splitContainer1.Panel2.Controls.Add(this.txtDesc); this.DescTxt.ReadOnly = true;
this.splitContainer1.Panel2.Controls.Add(this.lblDesc); this.DescTxt.Size = new System.Drawing.Size(162, 20);
this.splitContainer1.Panel2.Controls.Add(this.txtTheater); this.DescTxt.TabIndex = 14;
this.splitContainer1.Panel2.Controls.Add(this.lblTheater);
this.splitContainer1.Panel2.Controls.Add(this.txtAuthor); this.DescLabel.AutoSize = true;
this.splitContainer1.Panel2.Controls.Add(this.lblAuthor); this.DescLabel.Location = new System.Drawing.Point(13, 273);
this.splitContainer1.Panel2.Controls.Add(this.txtTitle); this.DescLabel.Name = "lblDesc";
this.splitContainer1.Panel2.Controls.Add(this.lblMapName); this.DescLabel.Size = new System.Drawing.Size(63, 13);
this.splitContainer1.Panel2.Controls.Add(this.lblMinimap); this.DescLabel.TabIndex = 13;
this.splitContainer1.Panel2.Controls.Add(this.pbMinimap); this.DescLabel.Text = "Description:";
this.splitContainer1.Size = new System.Drawing.Size(494, 332);
this.splitContainer1.SplitterDistance = 300; this.TheaterText.BackColor = System.Drawing.SystemColors.ButtonFace;
this.splitContainer1.TabIndex = 7; this.TheaterText.Location = new System.Drawing.Point(16, 252);
// this.TheaterText.Name = "txtTheater";
// lblMapList this.TheaterText.ReadOnly = true;
// this.TheaterText.Size = new System.Drawing.Size(162, 20);
this.lblMapList.AutoSize = true; this.TheaterText.TabIndex = 12;
this.lblMapList.Location = new System.Drawing.Point(12, 9);
this.lblMapList.Name = "lblMapList"; this.TheaterLabel.AutoSize = true;
this.lblMapList.Size = new System.Drawing.Size(81, 13); this.TheaterLabel.Location = new System.Drawing.Point(13, 236);
this.lblMapList.TabIndex = 1; this.TheaterLabel.Name = "lblTheater";
this.lblMapList.Text = "Available maps:"; this.TheaterLabel.Size = new System.Drawing.Size(47, 13);
// this.TheaterLabel.TabIndex = 11;
// txtDesc this.TheaterLabel.Text = "Tileset:";
//
this.txtDesc.BackColor = System.Drawing.SystemColors.ButtonFace; this.AuthorText.BackColor = System.Drawing.SystemColors.ButtonFace;
this.txtDesc.Location = new System.Drawing.Point(16, 289); this.AuthorText.Location = new System.Drawing.Point(16, 214);
this.txtDesc.Name = "txtDesc"; this.AuthorText.Name = "txtAuthor";
this.txtDesc.ReadOnly = true; this.AuthorText.ReadOnly = true;
this.txtDesc.Size = new System.Drawing.Size(162, 20); this.AuthorText.Size = new System.Drawing.Size(162, 20);
this.txtDesc.TabIndex = 14; this.AuthorText.TabIndex = 10;
//
// lblDesc this.AuthorLabel.AutoSize = true;
// this.AuthorLabel.Location = new System.Drawing.Point(13, 198);
this.lblDesc.AutoSize = true; this.AuthorLabel.Name = "lblAuthor";
this.lblDesc.Location = new System.Drawing.Point(13, 273); this.AuthorLabel.Size = new System.Drawing.Size(41, 13);
this.lblDesc.Name = "lblDesc"; this.AuthorLabel.TabIndex = 9;
this.lblDesc.Size = new System.Drawing.Size(63, 13); this.AuthorLabel.Text = "Author:";
this.lblDesc.TabIndex = 13;
this.lblDesc.Text = "Description:"; this.TitleText.BackColor = System.Drawing.SystemColors.ButtonFace;
// this.TitleText.Location = new System.Drawing.Point(16, 177);
// txtTheater this.TitleText.Name = "txtTitle";
// this.TitleText.ReadOnly = true;
this.txtTheater.BackColor = System.Drawing.SystemColors.ButtonFace; this.TitleText.Size = new System.Drawing.Size(162, 20);
this.txtTheater.Location = new System.Drawing.Point(16, 252); this.TitleText.TabIndex = 8;
this.txtTheater.Name = "txtTheater";
this.txtTheater.ReadOnly = true; this.MapNameLabel.AutoSize = true;
this.txtTheater.Size = new System.Drawing.Size(162, 20); this.MapNameLabel.Location = new System.Drawing.Point(13, 161);
this.txtTheater.TabIndex = 12; this.MapNameLabel.Name = "lblMapName";
// this.MapNameLabel.Size = new System.Drawing.Size(30, 13);
// lblTheater this.MapNameLabel.TabIndex = 7;
// this.MapNameLabel.Text = "Title:";
this.lblTheater.AutoSize = true;
this.lblTheater.Location = new System.Drawing.Point(13, 236); this.MiniMapLabel.AutoSize = true;
this.lblTheater.Name = "lblTheater"; this.MiniMapLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, (byte)204);
this.lblTheater.Size = new System.Drawing.Size(47, 13); this.MiniMapLabel.Location = new System.Drawing.Point(29, 9);
this.lblTheater.TabIndex = 11; this.MiniMapLabel.Name = "lblMinimap";
this.lblTheater.Text = "Tileset:"; this.MiniMapLabel.Size = new System.Drawing.Size(71, 13);
// this.MiniMapLabel.TabIndex = 6;
// txtAuthor this.MiniMapLabel.Text = "Map preview:";
//
this.txtAuthor.BackColor = System.Drawing.SystemColors.ButtonFace; this.pictureBox1.Image = (System.Drawing.Image)resources.GetObject("pictureBox1.Image");
this.txtAuthor.Location = new System.Drawing.Point(16, 214);
this.txtAuthor.Name = "txtAuthor";
this.txtAuthor.ReadOnly = true;
this.txtAuthor.Size = new System.Drawing.Size(162, 20);
this.txtAuthor.TabIndex = 10;
//
// lblAuthor
//
this.lblAuthor.AutoSize = true;
this.lblAuthor.Location = new System.Drawing.Point(13, 198);
this.lblAuthor.Name = "lblAuthor";
this.lblAuthor.Size = new System.Drawing.Size(41, 13);
this.lblAuthor.TabIndex = 9;
this.lblAuthor.Text = "Author:";
//
// txtTitle
//
this.txtTitle.BackColor = System.Drawing.SystemColors.ButtonFace;
this.txtTitle.Location = new System.Drawing.Point(16, 177);
this.txtTitle.Name = "txtTitle";
this.txtTitle.ReadOnly = true;
this.txtTitle.Size = new System.Drawing.Size(162, 20);
this.txtTitle.TabIndex = 8;
//
// lblMapName
//
this.lblMapName.AutoSize = true;
this.lblMapName.Location = new System.Drawing.Point(13, 161);
this.lblMapName.Name = "lblMapName";
this.lblMapName.Size = new System.Drawing.Size(30, 13);
this.lblMapName.TabIndex = 7;
this.lblMapName.Text = "Title:";
//
// lblMinimap
//
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.Location = new System.Drawing.Point(29, 9);
this.lblMinimap.Name = "lblMinimap";
this.lblMinimap.Size = new System.Drawing.Size(71, 13);
this.lblMinimap.TabIndex = 6;
this.lblMinimap.Text = "Map preview:";
//
// pictureBox1
//
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";
this.pictureBox1.Size = new System.Drawing.Size(54, 35); this.pictureBox1.Size = new System.Drawing.Size(54, 35);
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 this.AcceptButton = this.ButtonOkay;
//
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;
this.CancelButton = this.btnCancel; this.CancelButton = this.ButtonCancel;
this.ClientSize = new System.Drawing.Size(494, 402); this.ClientSize = new System.Drawing.Size(494, 402);
this.Controls.Add(this.splitContainer1); this.Controls.Add(this.SplitContainer1);
this.Controls.Add(this.pnlBottom); this.Controls.Add(this.BottomPanel);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false; this.MaximizeBox = false;
this.MinimizeBox = false; this.MinimizeBox = false;
@@ -335,44 +279,41 @@ namespace OpenRA.Editor
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Select map"; this.Text = "Select map";
this.Load += new System.EventHandler(this.MapSelect_Load); this.Load += new System.EventHandler(this.MapSelect_Load);
((System.ComponentModel.ISupportInitialize)(this.pbMinimap)).EndInit(); ((System.ComponentModel.ISupportInitialize)this.MiniMapBox).EndInit();
this.pnlBottom.ResumeLayout(false); this.BottomPanel.ResumeLayout(false);
this.pnlBottom.PerformLayout(); this.BottomPanel.PerformLayout();
this.splitContainer1.Panel1.ResumeLayout(false); this.SplitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel1.PerformLayout(); this.SplitContainer1.Panel1.PerformLayout();
this.splitContainer1.Panel2.ResumeLayout(false); this.SplitContainer1.Panel2.ResumeLayout(false);
this.splitContainer1.Panel2.PerformLayout(); this.SplitContainer1.Panel2.PerformLayout();
this.splitContainer1.ResumeLayout(false); this.SplitContainer1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); ((System.ComponentModel.ISupportInitialize)this.pictureBox1).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
} }
#endregion
public System.Windows.Forms.ListView MapList; public System.Windows.Forms.ListView MapList;
public System.Windows.Forms.Button btnCancel; public System.Windows.Forms.Button ButtonCancel;
public System.Windows.Forms.Button btnOk; public System.Windows.Forms.Button ButtonOkay;
public System.Windows.Forms.Label lblNew; public System.Windows.Forms.Label NewLabel;
public System.Windows.Forms.TextBox txtNew; public System.Windows.Forms.TextBox NewText;
public System.Windows.Forms.ColumnHeader colMapName; public System.Windows.Forms.ColumnHeader ColumnMapName;
public System.Windows.Forms.ImageList MapIconsList; public System.Windows.Forms.ImageList MapIconsList;
public System.Windows.Forms.PictureBox pbMinimap; public System.Windows.Forms.PictureBox MiniMapBox;
public System.Windows.Forms.Panel pnlBottom; public System.Windows.Forms.Panel BottomPanel;
public System.Windows.Forms.SplitContainer splitContainer1; public System.Windows.Forms.SplitContainer SplitContainer1;
public System.Windows.Forms.Label lblMinimap; public System.Windows.Forms.Label MiniMapLabel;
public System.Windows.Forms.TextBox txtTheater; public System.Windows.Forms.TextBox TheaterText;
public System.Windows.Forms.Label lblTheater; public System.Windows.Forms.Label TheaterLabel;
public System.Windows.Forms.TextBox txtAuthor; public System.Windows.Forms.TextBox AuthorText;
public System.Windows.Forms.Label lblAuthor; public System.Windows.Forms.Label AuthorLabel;
public System.Windows.Forms.TextBox txtTitle; public System.Windows.Forms.TextBox TitleText;
public System.Windows.Forms.Label lblMapName; public System.Windows.Forms.Label MapNameLabel;
public System.Windows.Forms.TextBox txtDesc; public System.Windows.Forms.TextBox DescTxt;
public System.Windows.Forms.Label lblDesc; public System.Windows.Forms.Label DescLabel;
public System.Windows.Forms.Label lblMapList; public System.Windows.Forms.Label MapListLabel;
public System.Windows.Forms.Label lblPathOut; public System.Windows.Forms.Label PathOutLabel;
public System.Windows.Forms.Label lblPath; public System.Windows.Forms.Label PathLabel;
public System.Windows.Forms.TextBox txtPathOut; public System.Windows.Forms.TextBox PathOutText;
private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.PictureBox pictureBox1;
} }
} }

View File

@@ -40,7 +40,7 @@ namespace OpenRA.Editor
void MapSelect_Load(object sender, EventArgs e) void MapSelect_Load(object sender, EventArgs e)
{ {
MapList.Items.Clear(); MapList.Items.Clear();
txtPathOut.Text = MapFolderPath; PathOutText.Text = MapFolderPath;
if (DirectoryIsEmpty(MapFolderPath)) if (DirectoryIsEmpty(MapFolderPath))
return; return;
@@ -55,7 +55,7 @@ namespace OpenRA.Editor
} }
// hack // hack
if (txtNew.Text != "unnamed") if (NewText.Text != "unnamed")
MapList.Items[0].Selected = true; MapList.Items[0].Selected = true;
} }
@@ -63,31 +63,30 @@ namespace OpenRA.Editor
{ {
if (MapList.SelectedItems.Count == 1) if (MapList.SelectedItems.Count == 1)
{ {
txtNew.Text = MapList.SelectedItems[0].Text; NewText.Text = MapList.SelectedItems[0].Text;
txtNew.Tag = MapList.SelectedItems[0].Tag; NewText.Tag = MapList.SelectedItems[0].Tag;
var map = new Map(txtNew.Tag as string); var map = new Map(NewText.Tag as string);
txtTitle.Text = map.Title; TitleText.Text = map.Title;
txtAuthor.Text = map.Author; AuthorText.Text = map.Author;
txtTheater.Text = map.Tileset; TheaterText.Text = map.Tileset;
txtDesc.Text = map.Description; DescTxt.Text = map.Description;
pbMinimap.Image = null; MiniMapBox.Image = null;
try try
{ {
pbMinimap.Image = Minimap.AddStaticResources(map, Minimap.TerrainBitmap(map, true)); MiniMapBox.Image = Minimap.AddStaticResources(map, Minimap.TerrainBitmap(map, true));
} }
catch (Exception ed) catch (Exception ed)
{ {
Console.WriteLine("No map preview image found: {0}", ed.ToString()); Console.WriteLine("No map preview image found: {0}", ed.ToString());
} }
finally { }
} }
} }
void txtPathOut_TextChanged(object sender, EventArgs e) void PathOutTextChanged(object sender, EventArgs e)
{ {
MapFolderPath = txtPathOut.Text; MapFolderPath = PathOutText.Text;
} }
} }
} }

169
OpenRA.Editor/NewMapDialog.Designer.cs generated Executable file → Normal file
View File

@@ -24,9 +24,8 @@ namespace OpenRA.Editor
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
if (disposing && (components != null)) if (disposing && (components != null))
{
components.Dispose(); components.Dispose();
}
base.Dispose(disposing); base.Dispose(disposing);
} }
@@ -43,20 +42,20 @@ namespace OpenRA.Editor
this.label3 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.cordonBottom = new System.Windows.Forms.NumericUpDown(); this.CordonBottom = new System.Windows.Forms.NumericUpDown();
this.cordonTop = new System.Windows.Forms.NumericUpDown(); this.CordonTop = new System.Windows.Forms.NumericUpDown();
this.cordonRight = new System.Windows.Forms.NumericUpDown(); this.CordonRight = new System.Windows.Forms.NumericUpDown();
this.cordonLeft = new System.Windows.Forms.NumericUpDown(); this.CordonLeft = new System.Windows.Forms.NumericUpDown();
this.height = new System.Windows.Forms.NumericUpDown(); this.MapHeight = new System.Windows.Forms.NumericUpDown();
this.width = new System.Windows.Forms.NumericUpDown(); this.MapWidth = new System.Windows.Forms.NumericUpDown();
this.label4 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label();
this.theater = new System.Windows.Forms.ComboBox(); this.TheaterBox = new System.Windows.Forms.ComboBox();
((System.ComponentModel.ISupportInitialize)(this.cordonBottom)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.CordonBottom)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.cordonTop)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.CordonTop)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.cordonRight)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.CordonRight)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.cordonLeft)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.CordonLeft)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.height)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.MapHeight)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.width)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.MapWidth)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// button2 // button2
@@ -108,121 +107,121 @@ namespace OpenRA.Editor
// //
// 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,
0, 0,
0, 0,
0}); 0});
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 = 5; this.CordonBottom.TabIndex = 5;
this.cordonBottom.Value = new decimal(new int[] { this.CordonBottom.Value = new decimal(new int[] {
112, 112,
0, 0,
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,
0, 0,
0, 0,
0}); 0});
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 = 3; this.CordonTop.TabIndex = 3;
this.cordonTop.Value = new decimal(new int[] { this.CordonTop.Value = new decimal(new int[] {
16, 16,
0, 0,
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,
0, 0,
0, 0,
0}); 0});
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 = 4; this.CordonRight.TabIndex = 4;
this.cordonRight.Value = new decimal(new int[] { this.CordonRight.Value = new decimal(new int[] {
112, 112,
0, 0,
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,
0, 0,
0, 0,
0}); 0});
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 = 2; this.CordonLeft.TabIndex = 2;
this.cordonLeft.Value = new decimal(new int[] { this.CordonLeft.Value = new decimal(new int[] {
16, 16,
0, 0,
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.MapHeight.Increment = new decimal(new int[] {
8, 8,
0, 0,
0, 0,
0}); 0});
this.height.Location = new System.Drawing.Point(280, 23); this.MapHeight.Location = new System.Drawing.Point(280, 23);
this.height.Maximum = new decimal(new int[] { this.MapHeight.Maximum = new decimal(new int[] {
2048, 2048,
0, 0,
0, 0,
0}); 0});
this.height.Name = "height"; this.MapHeight.Name = "height";
this.height.Size = new System.Drawing.Size(105, 20); this.MapHeight.Size = new System.Drawing.Size(105, 20);
this.height.TabIndex = 1; this.MapHeight.TabIndex = 1;
this.height.Value = new decimal(new int[] { this.MapHeight.Value = new decimal(new int[] {
128, 128,
0, 0,
0, 0,
0}); 0});
this.height.Enter += new System.EventHandler(this.SelectText); this.MapHeight.Enter += new System.EventHandler(this.SelectText);
// //
// width // width
// //
this.width.Increment = new decimal(new int[] { this.MapWidth.Increment = new decimal(new int[] {
8, 8,
0, 0,
0, 0,
0}); 0});
this.width.Location = new System.Drawing.Point(169, 23); this.MapWidth.Location = new System.Drawing.Point(169, 23);
this.width.Maximum = new decimal(new int[] { this.MapWidth.Maximum = new decimal(new int[] {
2048, 2048,
0, 0,
0, 0,
0}); 0});
this.width.Name = "width"; this.MapWidth.Name = "width";
this.width.Size = new System.Drawing.Size(105, 20); this.MapWidth.Size = new System.Drawing.Size(105, 20);
this.width.TabIndex = 0; this.MapWidth.TabIndex = 0;
this.width.Value = new decimal(new int[] { this.MapWidth.Value = new decimal(new int[] {
128, 128,
0, 0,
0, 0,
0}); 0});
this.width.Enter += new System.EventHandler(this.SelectText); this.MapWidth.Enter += new System.EventHandler(this.SelectText);
// //
// label4 // label4
// //
@@ -235,12 +234,12 @@ namespace OpenRA.Editor
// //
// theater // theater
// //
this.theater.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.TheaterBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.theater.FormattingEnabled = true; this.TheaterBox.FormattingEnabled = true;
this.theater.Location = new System.Drawing.Point(169, 121); this.TheaterBox.Location = new System.Drawing.Point(169, 121);
this.theater.Name = "theater"; this.TheaterBox.Name = "theater";
this.theater.Size = new System.Drawing.Size(216, 21); this.TheaterBox.Size = new System.Drawing.Size(216, 21);
this.theater.TabIndex = 6; this.TheaterBox.TabIndex = 6;
// //
// NewMapDialog // NewMapDialog
// //
@@ -249,29 +248,29 @@ namespace OpenRA.Editor
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.button1; this.CancelButton = this.button1;
this.ClientSize = new System.Drawing.Size(418, 210); this.ClientSize = new System.Drawing.Size(418, 210);
this.Controls.Add(this.theater); this.Controls.Add(this.TheaterBox);
this.Controls.Add(this.label4); this.Controls.Add(this.label4);
this.Controls.Add(this.button2); this.Controls.Add(this.button2);
this.Controls.Add(this.button1); this.Controls.Add(this.button1);
this.Controls.Add(this.label3); this.Controls.Add(this.label3);
this.Controls.Add(this.label2); this.Controls.Add(this.label2);
this.Controls.Add(this.label1); this.Controls.Add(this.label1);
this.Controls.Add(this.cordonBottom); this.Controls.Add(this.CordonBottom);
this.Controls.Add(this.cordonTop); this.Controls.Add(this.CordonTop);
this.Controls.Add(this.cordonRight); this.Controls.Add(this.CordonRight);
this.Controls.Add(this.cordonLeft); this.Controls.Add(this.CordonLeft);
this.Controls.Add(this.height); this.Controls.Add(this.MapHeight);
this.Controls.Add(this.width); this.Controls.Add(this.MapWidth);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Name = "NewMapDialog"; this.Name = "NewMapDialog";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "New Map"; this.Text = "New Map";
((System.ComponentModel.ISupportInitialize)(this.cordonBottom)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.CordonBottom)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.cordonTop)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.CordonTop)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.cordonRight)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.CordonRight)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.cordonLeft)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.CordonLeft)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.height)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.MapHeight)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.width)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.MapWidth)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@@ -284,13 +283,13 @@ namespace OpenRA.Editor
private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
public System.Windows.Forms.NumericUpDown cordonBottom; public System.Windows.Forms.NumericUpDown CordonBottom;
public System.Windows.Forms.NumericUpDown cordonTop; public System.Windows.Forms.NumericUpDown CordonTop;
public System.Windows.Forms.NumericUpDown cordonRight; public System.Windows.Forms.NumericUpDown CordonRight;
public System.Windows.Forms.NumericUpDown cordonLeft; public System.Windows.Forms.NumericUpDown CordonLeft;
public System.Windows.Forms.NumericUpDown height; public System.Windows.Forms.NumericUpDown MapHeight;
public System.Windows.Forms.NumericUpDown width; public System.Windows.Forms.NumericUpDown MapWidth;
private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label4;
public System.Windows.Forms.ComboBox theater; public System.Windows.Forms.ComboBox TheaterBox;
} }
} }

View File

@@ -116,7 +116,6 @@
<Compile Include="PropertiesDialog.Designer.cs"> <Compile Include="PropertiesDialog.Designer.cs">
<DependentUpon>PropertiesDialog.cs</DependentUpon> <DependentUpon>PropertiesDialog.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="ActorPropertiesDialog.resx"> <EmbeddedResource Include="ActorPropertiesDialog.resx">
<DependentUpon>ActorPropertiesDialog.cs</DependentUpon> <DependentUpon>ActorPropertiesDialog.cs</DependentUpon>
<SubType>Designer</SubType> <SubType>Designer</SubType>

View File

@@ -40,12 +40,13 @@ namespace OpenRA.Editor
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);
// Touch the lazy bits to initialize them // Touch the lazy bits to initialize them
map.Actors.Force(); map.Actors.Force();
map.Smudges.Force(); map.Smudges.Force();
@@ -54,6 +55,5 @@ namespace OpenRA.Editor
map.Save(path); map.Save(path);
} }
} }
} }
} }

View File

@@ -1,46 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* 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
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OpenRA.Editor")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("OpenRA.Editor")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 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
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("e18ea68f-f344-46c9-b026-8bda76fa91f8")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -24,9 +24,8 @@ namespace OpenRA.Editor
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
if (disposing && (components != null)) if (disposing && (components != null))
{
components.Dispose(); components.Dispose();
}
base.Dispose(disposing); base.Dispose(disposing);
} }
@@ -41,13 +40,13 @@ namespace OpenRA.Editor
this.button2 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.title = new System.Windows.Forms.TextBox(); this.TitleBox = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.desc = new System.Windows.Forms.TextBox(); this.DescBox = new System.Windows.Forms.TextBox();
this.selectable = new System.Windows.Forms.CheckBox(); this.SelectableCheckBox = new System.Windows.Forms.CheckBox();
this.label3 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label();
this.author = new System.Windows.Forms.TextBox(); this.AuthorBox = new System.Windows.Forms.TextBox();
this.useAsShellmap = new System.Windows.Forms.CheckBox(); this.ShellmapCheckBox = new System.Windows.Forms.CheckBox();
this.SuspendLayout(); this.SuspendLayout();
// //
// button2 // button2
@@ -83,10 +82,10 @@ namespace OpenRA.Editor
// //
// title // title
// //
this.title.Location = new System.Drawing.Point(66, 47); this.TitleBox.Location = new System.Drawing.Point(66, 47);
this.title.Name = "title"; this.TitleBox.Name = "title";
this.title.Size = new System.Drawing.Size(286, 20); this.TitleBox.Size = new System.Drawing.Size(286, 20);
this.title.TabIndex = 17; this.TitleBox.TabIndex = 17;
// //
// label2 // label2
// //
@@ -99,20 +98,20 @@ namespace OpenRA.Editor
// //
// desc // desc
// //
this.desc.Location = new System.Drawing.Point(66, 73); this.DescBox.Location = new System.Drawing.Point(66, 73);
this.desc.Name = "desc"; this.DescBox.Name = "desc";
this.desc.Size = new System.Drawing.Size(286, 20); this.DescBox.Size = new System.Drawing.Size(286, 20);
this.desc.TabIndex = 17; this.DescBox.TabIndex = 17;
// //
// selectable // selectable
// //
this.selectable.AutoSize = true; this.SelectableCheckBox.AutoSize = true;
this.selectable.Location = new System.Drawing.Point(118, 138); this.SelectableCheckBox.Location = new System.Drawing.Point(118, 138);
this.selectable.Name = "selectable"; this.SelectableCheckBox.Name = "selectable";
this.selectable.Size = new System.Drawing.Size(130, 17); this.SelectableCheckBox.Size = new System.Drawing.Size(130, 17);
this.selectable.TabIndex = 18; this.SelectableCheckBox.TabIndex = 18;
this.selectable.Text = "Show in Map Chooser"; this.SelectableCheckBox.Text = "Show in Map Chooser";
this.selectable.UseVisualStyleBackColor = true; this.SelectableCheckBox.UseVisualStyleBackColor = true;
// //
// label3 // label3
// //
@@ -125,20 +124,20 @@ namespace OpenRA.Editor
// //
// author // author
// //
this.author.Location = new System.Drawing.Point(66, 99); this.AuthorBox.Location = new System.Drawing.Point(66, 99);
this.author.Name = "author"; this.AuthorBox.Name = "author";
this.author.Size = new System.Drawing.Size(286, 20); this.AuthorBox.Size = new System.Drawing.Size(286, 20);
this.author.TabIndex = 17; this.AuthorBox.TabIndex = 17;
// //
// checkBox1 // checkBox1
// //
this.useAsShellmap.AutoSize = true; this.ShellmapCheckBox.AutoSize = true;
this.useAsShellmap.Location = new System.Drawing.Point(118, 161); this.ShellmapCheckBox.Location = new System.Drawing.Point(118, 161);
this.useAsShellmap.Name = "checkBox1"; this.ShellmapCheckBox.Name = "checkBox1";
this.useAsShellmap.Size = new System.Drawing.Size(105, 17); this.ShellmapCheckBox.Size = new System.Drawing.Size(105, 17);
this.useAsShellmap.TabIndex = 18; this.ShellmapCheckBox.TabIndex = 18;
this.useAsShellmap.Text = "Use as Shellmap"; this.ShellmapCheckBox.Text = "Use as Shellmap";
this.useAsShellmap.UseVisualStyleBackColor = true; this.ShellmapCheckBox.UseVisualStyleBackColor = true;
// //
// PropertiesDialog // PropertiesDialog
// //
@@ -147,13 +146,13 @@ namespace OpenRA.Editor
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.button1; this.CancelButton = this.button1;
this.ClientSize = new System.Drawing.Size(370, 228); this.ClientSize = new System.Drawing.Size(370, 228);
this.Controls.Add(this.useAsShellmap); this.Controls.Add(this.ShellmapCheckBox);
this.Controls.Add(this.selectable); this.Controls.Add(this.SelectableCheckBox);
this.Controls.Add(this.author); this.Controls.Add(this.AuthorBox);
this.Controls.Add(this.label3); this.Controls.Add(this.label3);
this.Controls.Add(this.desc); this.Controls.Add(this.DescBox);
this.Controls.Add(this.label2); this.Controls.Add(this.label2);
this.Controls.Add(this.title); this.Controls.Add(this.TitleBox);
this.Controls.Add(this.label1); this.Controls.Add(this.label1);
this.Controls.Add(this.button2); this.Controls.Add(this.button2);
this.Controls.Add(this.button1); this.Controls.Add(this.button1);
@@ -171,12 +170,12 @@ namespace OpenRA.Editor
private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
public System.Windows.Forms.TextBox title; public System.Windows.Forms.TextBox TitleBox;
private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label2;
public System.Windows.Forms.TextBox desc; public System.Windows.Forms.TextBox DescBox;
public System.Windows.Forms.CheckBox selectable; public System.Windows.Forms.CheckBox SelectableCheckBox;
private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label3;
public System.Windows.Forms.TextBox author; public System.Windows.Forms.TextBox AuthorBox;
public System.Windows.Forms.CheckBox useAsShellmap; public System.Windows.Forms.CheckBox ShellmapCheckBox;
} }
} }

View File

@@ -24,9 +24,8 @@ namespace OpenRA.Editor
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
if (disposing && (components != null)) if (disposing && (components != null))
{
components.Dispose(); components.Dispose();
}
base.Dispose(disposing); base.Dispose(disposing);
} }
@@ -38,41 +37,41 @@ namespace OpenRA.Editor
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.width = new System.Windows.Forms.NumericUpDown(); this.MapWidth = new System.Windows.Forms.NumericUpDown();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.cordonLeft = new System.Windows.Forms.NumericUpDown(); this.CordonLeft = new System.Windows.Forms.NumericUpDown();
this.cordonTop = new System.Windows.Forms.NumericUpDown(); this.CordonTop = new System.Windows.Forms.NumericUpDown();
this.cordonRight = new System.Windows.Forms.NumericUpDown(); this.CordonRight = new System.Windows.Forms.NumericUpDown();
this.cordonBottom = new System.Windows.Forms.NumericUpDown(); this.CordonBottom = new System.Windows.Forms.NumericUpDown();
this.label3 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button();
this.height = new System.Windows.Forms.NumericUpDown(); this.MapHeight = new System.Windows.Forms.NumericUpDown();
((System.ComponentModel.ISupportInitialize)(this.width)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.MapWidth)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.cordonLeft)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.CordonLeft)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.cordonTop)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.CordonTop)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.cordonRight)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.CordonRight)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.cordonBottom)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.CordonBottom)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.height)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.MapHeight)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// width // width
// //
this.width.Increment = new decimal(new int[] { this.MapWidth.Increment = new decimal(new int[] {
8, 8,
0, 0,
0, 0,
0}); 0});
this.width.Location = new System.Drawing.Point(161, 18); this.MapWidth.Location = new System.Drawing.Point(161, 18);
this.width.Maximum = new decimal(new int[] { this.MapWidth.Maximum = new decimal(new int[] {
2048, 2048,
0, 0,
0, 0,
0}); 0});
this.width.Name = "width"; this.MapWidth.Name = "width";
this.width.Size = new System.Drawing.Size(105, 20); this.MapWidth.Size = new System.Drawing.Size(105, 20);
this.width.TabIndex = 0; this.MapWidth.TabIndex = 0;
// //
// label1 // label1
// //
@@ -94,51 +93,51 @@ namespace OpenRA.Editor
// //
// 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,
0, 0,
0, 0,
0}); 0});
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,
0, 0,
0, 0,
0}); 0});
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,
0, 0,
0, 0,
0}); 0});
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,
0, 0,
0, 0,
0}); 0});
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
// //
@@ -171,20 +170,20 @@ namespace OpenRA.Editor
// //
// height // height
// //
this.height.Increment = new decimal(new int[] { this.MapHeight.Increment = new decimal(new int[] {
8, 8,
0, 0,
0, 0,
0}); 0});
this.height.Location = new System.Drawing.Point(272, 18); this.MapHeight.Location = new System.Drawing.Point(272, 18);
this.height.Maximum = new decimal(new int[] { this.MapHeight.Maximum = new decimal(new int[] {
2048, 2048,
0, 0,
0, 0,
0}); 0});
this.height.Name = "height"; this.MapHeight.Name = "height";
this.height.Size = new System.Drawing.Size(105, 20); this.MapHeight.Size = new System.Drawing.Size(105, 20);
this.height.TabIndex = 0; this.MapHeight.TabIndex = 0;
// //
// ResizeDialog // ResizeDialog
// //
@@ -198,22 +197,22 @@ namespace OpenRA.Editor
this.Controls.Add(this.label3); this.Controls.Add(this.label3);
this.Controls.Add(this.label2); this.Controls.Add(this.label2);
this.Controls.Add(this.label1); this.Controls.Add(this.label1);
this.Controls.Add(this.cordonBottom); this.Controls.Add(this.CordonBottom);
this.Controls.Add(this.cordonTop); this.Controls.Add(this.CordonTop);
this.Controls.Add(this.cordonRight); this.Controls.Add(this.CordonRight);
this.Controls.Add(this.cordonLeft); this.Controls.Add(this.CordonLeft);
this.Controls.Add(this.height); this.Controls.Add(this.MapHeight);
this.Controls.Add(this.width); this.Controls.Add(this.MapWidth);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Name = "ResizeDialog"; this.Name = "ResizeDialog";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Resize Map"; this.Text = "Resize Map";
((System.ComponentModel.ISupportInitialize)(this.width)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.MapWidth)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.cordonLeft)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.CordonLeft)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.cordonTop)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.CordonTop)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.cordonRight)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.CordonRight)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.cordonBottom)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.CordonBottom)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.height)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.MapHeight)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@@ -226,11 +225,11 @@ namespace OpenRA.Editor
private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button2;
public System.Windows.Forms.NumericUpDown width; public System.Windows.Forms.NumericUpDown MapWidth;
public System.Windows.Forms.NumericUpDown cordonLeft; public System.Windows.Forms.NumericUpDown CordonLeft;
public System.Windows.Forms.NumericUpDown cordonTop; public System.Windows.Forms.NumericUpDown CordonTop;
public System.Windows.Forms.NumericUpDown cordonRight; public System.Windows.Forms.NumericUpDown CordonRight;
public System.Windows.Forms.NumericUpDown cordonBottom; public System.Windows.Forms.NumericUpDown CordonBottom;
public System.Windows.Forms.NumericUpDown height; public System.Windows.Forms.NumericUpDown MapHeight;
} }
} }

View File

@@ -17,21 +17,21 @@ namespace OpenRA.Editor
{ {
class ResourceTool : ITool class ResourceTool : ITool
{ {
ResourceTemplate Resource; ResourceTemplate resourceTemplate;
public ResourceTool(ResourceTemplate resource) { Resource = resource; } public ResourceTool(ResourceTemplate resource) { resourceTemplate = resource; }
public void Apply(Surface surface) public void Apply(Surface surface)
{ {
surface.Map.MapResources.Value[surface.GetBrushLocation().X, surface.GetBrushLocation().Y] surface.Map.MapResources.Value[surface.GetBrushLocation().X, surface.GetBrushLocation().Y]
= new TileReference<byte, byte> = new TileReference<byte, byte>
{ {
type = (byte)Resource.Info.ResourceType, type = (byte)resourceTemplate.Info.ResourceType,
index = (byte)random.Next(Resource.Info.SpriteNames.Length) index = (byte)random.Next(resourceTemplate.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))
{ {
@@ -42,7 +42,7 @@ namespace OpenRA.Editor
public void Preview(Surface surface, SGraphics g) public void Preview(Surface surface, SGraphics g)
{ {
surface.DrawImage(g, Resource.Bitmap, surface.GetBrushLocation(), false, null); surface.DrawImage(g, resourceTemplate.Bitmap, surface.GetBrushLocation(), false, null);
} }
Random random = new Random(); Random random = new Random();

View File

@@ -302,6 +302,16 @@
<BooleanProperty Name="Enabled">False</BooleanProperty> <BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings> </RuleSettings>
</Rule> </Rule>
<Rule Name="ParameterMustFollowComma">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="SplitParametersMustStartOnLineAfterDeclaration">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules> </Rules>
<AnalyzerSettings /> <AnalyzerSettings />
</Analyzer> </Analyzer>

View File

@@ -21,6 +21,24 @@ using SGraphics = System.Drawing.Graphics;
namespace OpenRA.Editor namespace OpenRA.Editor
{ {
static class ActorReferenceExts
{
public static CPos Location(this ActorReference ar)
{
return (CPos)ar.InitDict.Get<LocationInit>().value;
}
public static void DrawStringContrast(this SGraphics g, Font f, string s, int x, int y, Brush fg, Brush bg)
{
g.DrawString(s, f, bg, x - 1, y - 1);
g.DrawString(s, f, bg, x + 1, y - 1);
g.DrawString(s, f, bg, x - 1, y + 1);
g.DrawString(s, f, bg, x + 1, y + 1);
g.DrawString(s, f, fg, x, y);
}
}
class Surface : Control class Surface : Control
{ {
public Map Map { get; private set; } public Map Map { get; private set; }
@@ -33,7 +51,7 @@ namespace OpenRA.Editor
public float Zoom = 1.0f; public float Zoom = 1.0f;
ITool Tool; ITool currentTool;
public bool IsPanning; public bool IsPanning;
public bool IsErasing; public bool IsErasing;
@@ -53,7 +71,7 @@ namespace OpenRA.Editor
public event Action<string> MousePositionChanged = _ => { }; public event Action<string> MousePositionChanged = _ => { };
public event Action<KeyValuePair<string, ActorReference>> ActorDoubleClicked = _ => { }; public event Action<KeyValuePair<string, ActorReference>> ActorDoubleClicked = _ => { };
Dictionary<string, ActorTemplate> ActorTemplates = new Dictionary<string, ActorTemplate>(); Dictionary<string, ActorTemplate> actorTemplates = new Dictionary<string, ActorTemplate>();
public Dictionary<int, ResourceTemplate> ResourceTemplates = new Dictionary<int, ResourceTemplate>(); public Dictionary<int, ResourceTemplate> ResourceTemplates = new Dictionary<int, ResourceTemplate>();
static readonly Font MarkerFont = new Font(FontFamily.GenericSansSerif, 12.0f, FontStyle.Regular); static readonly Font MarkerFont = new Font(FontFamily.GenericSansSerif, 12.0f, FontStyle.Regular);
@@ -67,16 +85,16 @@ namespace OpenRA.Editor
TileSet = ts; TileSet = ts;
Palette = p; Palette = p;
PlayerPalette = pp; PlayerPalette = pp;
PlayerPalettes = null; playerPalettes = null;
Chunks.Clear(); Chunks.Clear();
Tool = null; currentTool = null;
} }
public void SetTool(ITool tool) { Tool = tool; ClearSelection(); } public void SetTool(ITool tool) { currentTool = tool; ClearSelection(); }
public void BindActorTemplates(IEnumerable<ActorTemplate> templates) public void BindActorTemplates(IEnumerable<ActorTemplate> templates)
{ {
ActorTemplates = templates.ToDictionary(a => a.Info.Name.ToLowerInvariant()); actorTemplates = templates.ToDictionary(a => a.Info.Name.ToLowerInvariant());
} }
public void BindResourceTemplates(IEnumerable<ResourceTemplate> templates) public void BindResourceTemplates(IEnumerable<ResourceTemplate> templates)
@@ -99,7 +117,8 @@ namespace OpenRA.Editor
static readonly Pen SelectionPen = new Pen(Color.Blue); static readonly Pen SelectionPen = new Pen(Color.Blue);
static readonly Pen PastePen = new Pen(Color.Green); static readonly Pen PastePen = new Pen(Color.Green);
static readonly Pen CordonPen = new Pen(Color.Red); static readonly Pen CordonPen = new Pen(Color.Red);
int2 MousePos;
int2 mousePos;
public void Scroll(int2 dx) public void Scroll(int2 dx)
{ {
@@ -151,12 +170,12 @@ namespace OpenRA.Editor
if (Map == null) return; if (Map == null) return;
var oldMousePos = MousePos; var oldMousePos = mousePos;
MousePos = new int2(e.Location); mousePos = new int2(e.Location);
MousePositionChanged(GetBrushLocation().ToString()); MousePositionChanged(GetBrushLocation().ToString());
if (e.Button == MouseButtons.Middle || (e.Button != MouseButtons.None && IsPanning)) if (e.Button == MouseButtons.Middle || (e.Button != MouseButtons.None && IsPanning))
Scroll(oldMousePos - MousePos); Scroll(oldMousePos - mousePos);
else else
{ {
if (e.Button == MouseButtons.Right || (IsErasing && e.Button == MouseButtons.Left)) if (e.Button == MouseButtons.Right || (IsErasing && e.Button == MouseButtons.Left))
@@ -180,7 +199,7 @@ namespace OpenRA.Editor
brushLocation.Y < 0) brushLocation.Y < 0)
return; return;
Tool = null; currentTool = 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);
@@ -188,7 +207,7 @@ namespace OpenRA.Editor
if (Map.MapResources.Value[brushLocation.X, brushLocation.Y].type != 0) if (Map.MapResources.Value[brushLocation.X, brushLocation.Y].type != 0)
{ {
Map.MapResources.Value[brushLocation.X, brushLocation.Y] = new TileReference<byte, byte>(); Map.MapResources.Value[brushLocation.X, brushLocation.Y] = new TileReference<byte, byte>();
var ch = new int2((brushLocation.X) / ChunkSize, (brushLocation.Y) / ChunkSize); var ch = new int2(brushLocation.X / ChunkSize, brushLocation.Y / ChunkSize);
if (Chunks.ContainsKey(ch)) if (Chunks.ContainsKey(ch))
{ {
Chunks[ch].Dispose(); Chunks[ch].Dispose();
@@ -202,9 +221,9 @@ namespace OpenRA.Editor
void Draw() void Draw()
{ {
if (Tool != null) if (currentTool != null)
{ {
Tool.Apply(this); currentTool.Apply(this);
AfterChange(); AfterChange();
} }
else if (IsPaste) else if (IsPaste)
@@ -237,7 +256,6 @@ namespace OpenRA.Editor
Bitmap RenderChunk(int u, int v) Bitmap RenderChunk(int u, int v)
{ {
var bitmap = new Bitmap(ChunkSize * TileSet.TileSize, ChunkSize * TileSet.TileSize); var bitmap = new Bitmap(ChunkSize * TileSet.TileSize, ChunkSize * TileSet.TileSize);
var data = bitmap.LockBits(bitmap.Bounds(), var data = bitmap.LockBits(bitmap.Bounds(),
@@ -297,15 +315,15 @@ namespace OpenRA.Editor
public CPos GetBrushLocation() public CPos GetBrushLocation()
{ {
var vX = (int)Math.Floor((MousePos.X - Offset.X) / Zoom); var vX = (int)Math.Floor((mousePos.X - Offset.X) / Zoom);
var vY = (int)Math.Floor((MousePos.Y - Offset.Y) / Zoom); var vY = (int)Math.Floor((mousePos.Y - Offset.Y) / Zoom);
return new CPos(vX / TileSet.TileSize, vY / TileSet.TileSize); return new CPos(vX / TileSet.TileSize, vY / TileSet.TileSize);
} }
public CPos GetBrushLocationBR() public CPos GetBrushLocationBR()
{ {
var vX = (int)Math.Floor((MousePos.X - Offset.X) / Zoom); var vX = (int)Math.Floor((mousePos.X - Offset.X) / Zoom);
var vY = (int)Math.Floor((MousePos.Y - Offset.Y) / Zoom); var vY = (int)Math.Floor((mousePos.Y - Offset.Y) / Zoom);
return new CPos((vX + TileSet.TileSize - 1) / TileSet.TileSize, return new CPos((vX + TileSet.TileSize - 1) / TileSet.TileSize,
(vY + TileSet.TileSize - 1) / TileSet.TileSize); (vY + TileSet.TileSize - 1) / TileSet.TileSize);
} }
@@ -361,14 +379,14 @@ namespace OpenRA.Editor
return new Palette(PlayerPalette, remap).AsSystemPalette(); return new Palette(PlayerPalette, remap).AsSystemPalette();
} }
Cache<string, ColorPalette> PlayerPalettes; Cache<string, ColorPalette> playerPalettes;
public ColorPalette GetPaletteForPlayer(string player) public ColorPalette GetPaletteForPlayer(string player)
{ {
if (PlayerPalettes == null) if (playerPalettes == null)
PlayerPalettes = new Cache<string, ColorPalette>(GetPaletteForPlayerInner); playerPalettes = new Cache<string, ColorPalette>(GetPaletteForPlayerInner);
return PlayerPalettes[player]; return playerPalettes[player];
} }
ColorPalette GetPaletteForActor(ActorReference ar) ColorPalette GetPaletteForActor(ActorReference ar)
@@ -393,10 +411,10 @@ namespace OpenRA.Editor
var bmp = Chunks[x]; var bmp = Chunks[x];
float DrawX = TileSet.TileSize * (float)ChunkSize * (float)x.X * Zoom + Offset.X; var drawX = TileSet.TileSize * (float)ChunkSize * (float)x.X * Zoom + Offset.X;
float DrawY = TileSet.TileSize * (float)ChunkSize * (float)x.Y * Zoom + Offset.Y; var drawY = TileSet.TileSize * (float)ChunkSize * (float)x.Y * Zoom + Offset.Y;
RectangleF sourceRect = new RectangleF(0, 0, bmp.Width, bmp.Height); RectangleF sourceRect = new RectangleF(0, 0, bmp.Width, bmp.Height);
RectangleF destRect = new RectangleF(DrawX, DrawY, bmp.Width * Zoom, bmp.Height * Zoom); RectangleF destRect = new RectangleF(drawX, drawY, bmp.Width * Zoom, bmp.Height * Zoom);
e.Graphics.DrawImage(bmp, destRect, sourceRect, GraphicsUnit.Pixel); e.Graphics.DrawImage(bmp, destRect, sourceRect, GraphicsUnit.Pixel);
} }
@@ -427,8 +445,8 @@ namespace OpenRA.Editor
foreach (var ar in Map.Actors.Value) foreach (var ar in Map.Actors.Value)
{ {
if (ActorTemplates.ContainsKey(ar.Value.Type)) if (actorTemplates.ContainsKey(ar.Value.Type))
DrawActor(e.Graphics, ar.Value.Location(), ActorTemplates[ar.Value.Type], DrawActor(e.Graphics, ar.Value.Location(), actorTemplates[ar.Value.Type],
GetPaletteForActor(ar.Value)); GetPaletteForActor(ar.Value));
else else
Console.WriteLine("Warning: Unknown or excluded actor: {0}", ar.Value.Type); Console.WriteLine("Warning: Unknown or excluded actor: {0}", ar.Value.Type);
@@ -464,14 +482,14 @@ namespace OpenRA.Editor
} }
} }
if (Tool != null) if (currentTool != null)
Tool.Preview(this, e.Graphics); currentTool.Preview(this, e.Graphics);
if (Tool == null) if (currentTool == null)
{ {
var x = Map.Actors.Value.FirstOrDefault(a => a.Value.Location() == GetBrushLocation()); var x = Map.Actors.Value.FirstOrDefault(a => a.Value.Location() == GetBrushLocation());
if (x.Key != null) if (x.Key != null)
DrawActorBorder(e.Graphics, x.Value.Location(), ActorTemplates[x.Value.Type]); DrawActorBorder(e.Graphics, x.Value.Location(), actorTemplates[x.Value.Type]);
} }
} }
@@ -525,6 +543,7 @@ namespace OpenRA.Editor
} }
} }
} }
AfterChange(); AfterChange();
} }
@@ -536,22 +555,4 @@ namespace OpenRA.Editor
ResourceSelection = null; ResourceSelection = null;
} }
} }
static class ActorReferenceExts
{
public static CPos Location(this ActorReference ar)
{
return (CPos)ar.InitDict.Get<LocationInit>().value;
}
public static void DrawStringContrast(this SGraphics g, Font f, string s, int x, int y, Brush fg, Brush bg)
{
g.DrawString(s, f, bg, x - 1, y - 1);
g.DrawString(s, f, bg, x + 1, y - 1);
g.DrawString(s, f, bg, x - 1, y + 1);
g.DrawString(s, f, bg, x + 1, y + 1);
g.DrawString(s, f, fg, x, y);
}
}
} }

View File

@@ -39,6 +39,7 @@ namespace OpenRA.FileFormats
default: s.Push(int.Parse(t)); break; default: s.Push(int.Parse(t)); break;
} }
} }
return s.Pop(); return s.Pop();
} }

View File

@@ -204,8 +204,8 @@ namespace OpenRA
// If any duplicates were found, log it and throw a descriptive error // If any duplicates were found, log it and throw a descriptive error
if (dupKeys.Count > 0) if (dupKeys.Count > 0)
{ {
string badKeysFormatted = String.Join(", ", dupKeys.Select(p => "{0}: [{1}]".F(logKey(p.Key), String.Join(",", p.Value.ToArray()))).ToArray()); var badKeysFormatted = string.Join(", ", dupKeys.Select(p => "{0}: [{1}]".F(logKey(p.Key), string.Join(",", p.Value.ToArray()))).ToArray());
string msg = "{0}, duplicate values found for the following keys: {1}".F(debugName, badKeysFormatted); var msg = "{0}, duplicate values found for the following keys: {1}".F(debugName, badKeysFormatted);
Log.Write("debug", msg); Log.Write("debug", msg);
throw new ArgumentException(msg); throw new ArgumentException(msg);
} }
@@ -232,6 +232,16 @@ namespace OpenRA
return result; return result;
} }
public static T[,] ResizeArray<T>(T[,] ts, T t, int width, int height)
{
var result = new T[width, height];
for (var i = 0; i < width; i++)
for (var j = 0; j < height; j++)
result[i, j] = i <= ts.GetUpperBound(0) && j <= ts.GetUpperBound(1)
? ts[i, j] : t;
return result;
}
public static Rectangle Bounds(this Bitmap b) { return new Rectangle(0, 0, b.Width, b.Height); } public static Rectangle Bounds(this Bitmap b) { return new Rectangle(0, 0, b.Width, b.Height); }
public static int ToBits(this IEnumerable<bool> bits) public static int ToBits(this IEnumerable<bool> bits)
@@ -240,7 +250,7 @@ namespace OpenRA
var result = 0; var result = 0;
foreach (var b in bits) foreach (var b in bits)
if (b) if (b)
result |= (1 << i++); result |= 1 << i++;
else else
i++; i++;
if (i > 33) if (i > 33)

View File

@@ -11,9 +11,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Globalization;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Globalization;
namespace OpenRA.FileFormats namespace OpenRA.FileFormats
{ {
@@ -61,6 +61,7 @@ namespace OpenRA.FileFormats
throw new InvalidOperationException("The field {0} has multiple definitions:\n{1}" throw new InvalidOperationException("The field {0} has multiple definitions:\n{1}"
.F(fieldName, n.Select(m => "\t- " + m.Location).JoinWith("\n"))); .F(fieldName, n.Select(m => "\t- " + m.Location).JoinWith("\n")));
} }
throw new InvalidOperationException("TryGetValueFromYaml: unable to load field {0} (of type {1})".F(fieldName, fieldType)); throw new InvalidOperationException("TryGetValueFromYaml: unable to load field {0} (of type {1})".F(fieldName, fieldType));
} }
@@ -103,6 +104,7 @@ namespace OpenRA.FileFormats
public static object GetValue(string field, Type fieldType, string x) public static object GetValue(string field, Type fieldType, string x)
{ {
if (x != null) x = x.Trim(); if (x != null) x = x.Trim();
if (fieldType == typeof(int)) if (fieldType == typeof(int))
{ {
int res; int res;
@@ -151,6 +153,7 @@ namespace OpenRA.FileFormats
else if (fieldType == typeof(HSLColor)) else if (fieldType == typeof(HSLColor))
{ {
var parts = x.Split(','); var parts = x.Split(',');
// Allow old ColorRamp format to be parsed as HSLColor // Allow old ColorRamp format to be parsed as HSLColor
if (parts.Length == 3 || parts.Length == 4) if (parts.Length == 3 || parts.Length == 4)
return new HSLColor( return new HSLColor(
@@ -213,6 +216,7 @@ namespace OpenRA.FileFormats
if (int.TryParse(x, out rr) && int.TryParse(x, out rp) && int.TryParse(x, out ry)) if (int.TryParse(x, out rr) && int.TryParse(x, out rp) && int.TryParse(x, out ry))
return new WRot(new WAngle(rr), new WAngle(rp), new WAngle(ry)); return new WRot(new WAngle(rr), new WAngle(rp), new WAngle(ry));
} }
return InvalidValueAction(x, fieldType, field); return InvalidValueAction(x, fieldType, field);
} }
@@ -238,11 +242,13 @@ namespace OpenRA.FileFormats
ret.SetValue(GetValue(field, fieldType.GetElementType(), parts[i].Trim()), i); ret.SetValue(GetValue(field, fieldType.GetElementType(), parts[i].Trim()), i);
return ret; return ret;
} }
else if (fieldType == typeof(int2)) else if (fieldType == typeof(int2))
{ {
var parts = x.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var parts = x.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
return new int2(int.Parse(parts[0]), int.Parse(parts[1])); return new int2(int.Parse(parts[0]), int.Parse(parts[1]));
} }
else if (fieldType == typeof(float2)) else if (fieldType == typeof(float2))
{ {
var parts = x.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var parts = x.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
@@ -255,11 +261,13 @@ namespace OpenRA.FileFormats
yy = res * (parts[1].Contains('%') ? 0.01f : 1f); yy = res * (parts[1].Contains('%') ? 0.01f : 1f);
return new float2(xx, yy); return new float2(xx, yy);
} }
else if (fieldType == typeof(Rectangle)) else if (fieldType == typeof(Rectangle))
{ {
var parts = x.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var parts = x.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
return new Rectangle(int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]), int.Parse(parts[3])); return new Rectangle(int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]), int.Parse(parts[3]));
} }
else if (fieldType.IsGenericType && fieldType.GetGenericTypeDefinition() == typeof(Bits<>)) else if (fieldType.IsGenericType && fieldType.GetGenericTypeDefinition() == typeof(Bits<>))
{ {
var parts = x.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var parts = x.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
@@ -321,9 +329,9 @@ namespace OpenRA.FileFormats
internal Func<MiniYaml, object> LoaderFunc(FieldInfo field) internal Func<MiniYaml, object> LoaderFunc(FieldInfo field)
{ {
const BindingFlags bf = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static; const BindingFlags BindingFlag = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static;
if (loaderFuncCache == null) if (loaderFuncCache == null)
loaderFuncCache = (Func<MiniYaml, object>)Delegate.CreateDelegate( typeof( Func<MiniYaml, object> ), field.DeclaringType.GetMethod( Loader, bf ) ); loaderFuncCache = (Func<MiniYaml, object>)Delegate.CreateDelegate(typeof(Func<MiniYaml, object>), field.DeclaringType.GetMethod(Loader, BindingFlag));
return loaderFuncCache; return loaderFuncCache;
} }
} }
@@ -355,9 +363,7 @@ namespace OpenRA.FileFormats
var fields = o.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance) var fields = o.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance)
.Where(f => FormatValue(o, f) != FormatValue(from, f)); .Where(f => FormatValue(o, f) != FormatValue(from, f));
return new MiniYaml( null, fields.Select( f => new MiniYamlNode( return new MiniYaml(null, fields.Select(f => new MiniYamlNode(f.Name, FormatValue(o, f))).ToList());
f.Name,
FormatValue( o, f ) ) ).ToList() );
} }
public static MiniYamlNode SaveField(object o, string field) public static MiniYamlNode SaveField(object o, string field)

View File

@@ -44,8 +44,8 @@ namespace OpenRA.FileFormats
public static class AudLoader public static class AudLoader
{ {
static int[] IndexAdjust = { -1, -1, -1, -1, 2, 4, 6, 8 }; static int[] indexAdjust = { -1, -1, -1, -1, 2, 4, 6, 8 };
static int[] StepTable = { static int[] stepTable = {
7, 8, 9, 10, 11, 12, 13, 14, 16, 7, 8, 9, 10, 11, 12, 13, 14, 16,
17, 19, 21, 23, 25, 28, 31, 34, 37, 17, 19, 21, 23, 25, 28, 31, 34, 37,
41, 45, 50, 55, 60, 66, 73, 80, 88, 41, 45, 50, 55, 60, 66, 73, 80, 88,
@@ -62,14 +62,14 @@ namespace OpenRA.FileFormats
var sb = (b & 8) != 0; var sb = (b & 8) != 0;
b &= 7; b &= 7;
var delta = (StepTable[index] * b) / 4 + StepTable[index] / 8; var delta = (stepTable[index] * b) / 4 + stepTable[index] / 8;
if (sb) delta = -delta; if (sb) delta = -delta;
current += delta; current += delta;
if (current > short.MaxValue) current = short.MaxValue; if (current > short.MaxValue) current = short.MaxValue;
if (current < short.MinValue) current = short.MinValue; if (current < short.MinValue) current = short.MinValue;
index += IndexAdjust[b]; index += indexAdjust[b];
if (index < 0) index = 0; if (index < 0) index = 0;
if (index > 88) index = 88; if (index > 88) index = 88;

View File

@@ -59,24 +59,24 @@ namespace OpenRA.FileFormats
// 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); var br = new BitReader(src);
// Are literals coded? // Are literals coded?
int coded = br.ReadBits(8); var 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); var EncodedLiterals = coded == 1;
// log2(dictionary size) - 6 // log2(dictionary size) - 6
int dict = br.ReadBits(8); var 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) var first = true; // true to check distances (for first 4K)
byte[] outBuffer = new byte[MAXWIN]; // output buffer and sliding window var outBuffer = new byte[MAXWIN]; // output buffer and sliding window
var ms = new MemoryStream(); var ms = new MemoryStream();
// decode literals and length/distance pairs // decode literals and length/distance pairs
@@ -86,9 +86,11 @@ namespace OpenRA.FileFormats
if (br.ReadBits(1) == 1) if (br.ReadBits(1) == 1)
{ {
// Length // Length
int symbol = Decode(lencode, br); var symbol = Decode(lencode, br);
int len = lengthbase[symbol] + br.ReadBits(extra[symbol]); var len = lengthbase[symbol] + br.ReadBits(extra[symbol]);
if (len == 519) // Magic number for "done"
// Magic number for "done"
if (len == 519)
{ {
for (int i = 0; i < next; i++) for (int i = 0; i < next; i++)
ms.WriteByte(outBuffer[i]); ms.WriteByte(outBuffer[i]);
@@ -97,7 +99,7 @@ namespace OpenRA.FileFormats
// Distance // Distance
symbol = len == 2 ? 2 : dict; symbol = len == 2 ? 2 : dict;
int dist = Decode(distcode, br) << symbol; var dist = Decode(distcode, br) << symbol;
dist += br.ReadBits(symbol); dist += br.ReadBits(symbol);
dist++; dist++;
@@ -107,10 +109,10 @@ namespace OpenRA.FileFormats
// copy length bytes from distance bytes back // copy length bytes from distance bytes back
do do
{ {
int dest = next; var dest = next;
int source = dest - dist; var source = dest - dist;
int copy = MAXWIN; var copy = MAXWIN;
if (next < dist) if (next < dist)
{ {
source += copy; source += copy;
@@ -140,9 +142,10 @@ namespace OpenRA.FileFormats
} }
} while (len != 0); } while (len != 0);
} }
else // literal value // literal value
else
{ {
int symbol = EncodedLiterals ? Decode(litcode, br) : br.ReadBits(8); var symbol = EncodedLiterals ? Decode(litcode, br) : br.ReadBits(8);
outBuffer[next++] = (byte)symbol; outBuffer[next++] = (byte)symbol;
if (next == MAXWIN) if (next == MAXWIN)
{ {
@@ -160,9 +163,9 @@ namespace OpenRA.FileFormats
// 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 var code = 0; // len bits being decoded
int first = 0; // first code of length len var first = 0; // first code of length len
int index = 0; // index of first code of length len in symbol table var index = 0; // index of first code of length len in symbol table
short next = 1; short next = 1;
while (true) while (true)
{ {
@@ -193,8 +196,8 @@ namespace OpenRA.FileFormats
public int ReadBits(int count) public int ReadBits(int count)
{ {
int ret = 0; var ret = 0;
int filled = 0; var filled = 0;
while (filled < count) while (filled < count)
{ {
if (bitCount == 0) if (bitCount == 0)
@@ -208,6 +211,7 @@ namespace OpenRA.FileFormats
bitCount--; bitCount--;
filled++; filled++;
} }
return ret; return ret;
} }
} }
@@ -226,21 +230,22 @@ namespace OpenRA.FileFormats
public short[] Count; // number of symbols of each length public short[] Count; // number of symbols of each length
public short[] Symbol; // canonically ordered symbols public short[] Symbol; // canonically ordered symbols
public Huffman(byte[] rep, int n, short SymbolCount) public Huffman(byte[] rep, int n, short symbolCount)
{ {
short[] length = new short[256]; // code lengths var length = new short[256]; // code lengths
int s = 0; // current symbol var 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)
{ {
int num = (code >> 4) + 1; // Number of codes (top four bits plus 1) var num = (code >> 4) + 1; // Number of codes (top four bits plus 1)
byte len = (byte)(code & 15); // Code length (low four bits) var len = (byte)(code & 15); // Code length (low four bits)
do do
{ {
length[s++] = len; length[s++] = len;
} while (--num > 0); } while (--num > 0);
} }
n = s; n = s;
// count number of codes of each length // count number of codes of each length
@@ -253,24 +258,22 @@ namespace OpenRA.FileFormats
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 var left = 1; // one possible code of zero length
for (int len = 1; len <= Blast.MAXBITS; len++) for (int len = 1; len <= Blast.MAXBITS; len++)
{ {
left <<= 1; left <<= 1; // one more bit, double codes left
// one more bit, double codes left left -= Count[len]; // deduct count from possible codes
left -= Count[len];
// deduct count from possible codes
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]; var 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++)
if (length[i] != 0) if (length[i] != 0)
Symbol[offs[length[i]]++] = i; Symbol[offs[length[i]]++] = i;

View File

@@ -38,7 +38,7 @@ namespace OpenRA.FileFormats
while (!reader.EndOfStream) while (!reader.EndOfStream)
{ {
string line = reader.ReadLine(); var line = reader.ReadLine();
if (line.Length == 0) continue; if (line.Length == 0) continue;
@@ -68,7 +68,7 @@ namespace OpenRA.FileFormats
bool ProcessEntry(string line, IniSection currentSection) bool ProcessEntry(string line, IniSection currentSection)
{ {
int comment = line.IndexOf( ';' ); var comment = line.IndexOf(';');
if (comment >= 0) if (comment >= 0)
line = line.Substring(0, comment); line = line.Substring(0, comment);

View File

@@ -17,6 +17,30 @@ namespace OpenRA.FileFormats
{ {
using MiniYamlNodes = List<MiniYamlNode>; using MiniYamlNodes = List<MiniYamlNode>;
public static class MiniYamlExts
{
public static void WriteToFile(this MiniYamlNodes y, string filename)
{
File.WriteAllLines(filename, y.ToLines(true).Select(x => x.TrimEnd()).ToArray());
}
public static string WriteToString(this MiniYamlNodes y)
{
return y.ToLines(true).Select(x => x.TrimEnd()).JoinWith("\n");
}
public static IEnumerable<string> ToLines(this MiniYamlNodes y, bool lowest)
{
foreach (var kv in y)
{
foreach (var line in kv.Value.ToLines(kv.Key))
yield return line;
if (lowest)
yield return "";
}
}
}
public class MiniYamlNode public class MiniYamlNode
{ {
public struct SourceLocation public struct SourceLocation
@@ -42,18 +66,13 @@ namespace OpenRA.FileFormats
} }
public MiniYamlNode(string k, string v) public MiniYamlNode(string k, string v)
: this( k, v, null ) : this(k, v, null) { }
{
}
public MiniYamlNode(string k, string v, List<MiniYamlNode> n) public MiniYamlNode(string k, string v, List<MiniYamlNode> n)
: this( k, new MiniYaml( v, n ) ) : this(k, new MiniYaml(v, n)) { }
{
}
public MiniYamlNode(string k, string v, List<MiniYamlNode> n, SourceLocation loc) public MiniYamlNode(string k, string v, List<MiniYamlNode> n, SourceLocation loc)
: this( k, new MiniYaml( v, n ), loc ) : this(k, new MiniYaml(v, n), loc) { }
{
}
public override string ToString() public override string ToString()
{ {
@@ -77,6 +96,7 @@ namespace OpenRA.FileFormats
throw new InvalidDataException("Duplicate key `{0}' in MiniYaml".F(y.Key)); throw new InvalidDataException("Duplicate key `{0}' in MiniYaml".F(y.Key));
ret.Add(y.Key, y.Value); ret.Add(y.Key, y.Value);
} }
return ret; return ret;
} }
} }
@@ -99,6 +119,11 @@ 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());
} }
public static List<MiniYamlNode> NodesOrEmpty(MiniYaml y, string s)
{
return y.NodesDict.ContainsKey(s) ? y.NodesDict[s].Nodes : new List<MiniYamlNode>();
}
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>>();
@@ -128,6 +153,7 @@ namespace OpenRA.FileFormats
levels.Add(d); levels.Add(d);
} }
return levels[0]; return levels[0];
} }
@@ -200,9 +226,9 @@ namespace OpenRA.FileFormats
var ret = new List<MiniYamlNode>(); var ret = new List<MiniYamlNode>();
var aDict = a.ToDictionaryWithConflictLog(x => x.Key, "MiniYaml.Merge", null, x => "{0} (at {1})".F(x.Key, x.Location)); var dictA = a.ToDictionaryWithConflictLog(x => x.Key, "MiniYaml.Merge", null, x => "{0} (at {1})".F(x.Key, x.Location));
var bDict = b.ToDictionaryWithConflictLog(x => x.Key, "MiniYaml.Merge", null, x => "{0} (at {1})".F(x.Key, x.Location)); var dictB = b.ToDictionaryWithConflictLog(x => x.Key, "MiniYaml.Merge", null, x => "{0} (at {1})".F(x.Key, x.Location));
var keys = aDict.Keys.Union( bDict.Keys ).ToList(); var keys = dictA.Keys.Union(dictB.Keys).ToList();
var noInherit = keys.Where(x => x.Length > 0 && x[0] == '-') var noInherit = keys.Where(x => x.Length > 0 && x[0] == '-')
.ToDictionary(x => x.Substring(1), x => false); .ToDictionary(x => x.Substring(1), x => false);
@@ -210,8 +236,8 @@ namespace OpenRA.FileFormats
foreach (var key in keys) foreach (var key in keys)
{ {
MiniYamlNode aa, bb; MiniYamlNode aa, bb;
aDict.TryGetValue( key, out aa ); dictA.TryGetValue(key, out aa);
bDict.TryGetValue( key, out bb ); dictB.TryGetValue(key, out bb);
if (noInherit.ContainsKey(key)) if (noInherit.ContainsKey(key))
{ {
@@ -266,30 +292,6 @@ namespace OpenRA.FileFormats
} }
} }
public static class MiniYamlExts
{
public static void WriteToFile(this MiniYamlNodes y, string filename)
{
File.WriteAllLines(filename, y.ToLines(true).Select(x => x.TrimEnd()).ToArray());
}
public static string WriteToString(this MiniYamlNodes y)
{
return y.ToLines(true).Select(x => x.TrimEnd()).JoinWith("\n");
}
public static IEnumerable<string> ToLines(this MiniYamlNodes y, bool lowest)
{
foreach (var kv in y)
{
foreach (var line in kv.Value.ToLines(kv.Key))
yield return line;
if (lowest)
yield return "";
}
}
}
public class YamlException : Exception public class YamlException : Exception
{ {
public YamlException(string s) : base(s) { } public YamlException(string s) : base(s) { }

View File

@@ -126,7 +126,6 @@
<Compile Include="Primitives\Set.cs" /> <Compile Include="Primitives\Set.cs" />
<Compile Include="Primitives\float2.cs" /> <Compile Include="Primitives\float2.cs" />
<Compile Include="Primitives\int2.cs" /> <Compile Include="Primitives\int2.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Support\Log.cs" /> <Compile Include="Support\Log.cs" />
<Compile Include="Support\Stopwatch.cs" /> <Compile Include="Support\Stopwatch.cs" />
<Compile Include="Support\Timer.cs" /> <Compile Include="Support\Timer.cs" />

View File

@@ -1,26 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* 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
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("OpenRA.FileFormats")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OpenRA.FileFormats")]
[assembly: AssemblyCopyright("Copyright © 2007,2009,2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -252,6 +252,11 @@
<BooleanProperty Name="Enabled">False</BooleanProperty> <BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings> </RuleSettings>
</Rule> </Rule>
<Rule Name="ChainedStatementBlocksMustNotBePrecededByBlankLine">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules> </Rules>
<AnalyzerSettings /> <AnalyzerSettings />
</Analyzer> </Analyzer>
@@ -302,6 +307,16 @@
<BooleanProperty Name="Enabled">False</BooleanProperty> <BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings> </RuleSettings>
</Rule> </Rule>
<Rule Name="ParameterMustFollowComma">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="SplitParametersMustStartOnLineAfterDeclaration">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules> </Rules>
<AnalyzerSettings /> <AnalyzerSettings />
</Analyzer> </Analyzer>

View File

@@ -22,7 +22,7 @@ namespace OpenRA
{ {
public class Map public class Map
{ {
[FieldLoader.Ignore] IFolder Container; [FieldLoader.Ignore] IFolder container;
public string Path { get; private set; } public string Path { get; private set; }
// Yaml map data // Yaml map data
@@ -44,14 +44,6 @@ namespace OpenRA
public int PlayerCount { get { return Players.Count(p => p.Value.Playable); } } public int PlayerCount { get { return Players.Count(p => p.Value.Playable); } }
public int2[] GetSpawnPoints()
{
return Actors.Value.Values
.Where(a => a.Type == "mpspawn")
.Select(a => a.InitDict.Get<LocationInit>().value)
.ToArray();
}
public Rectangle Bounds; public Rectangle Bounds;
// Yaml map data // Yaml map data
@@ -73,8 +65,6 @@ namespace OpenRA
[FieldLoader.Ignore] public Lazy<TileReference<byte, byte>[,]> MapResources; [FieldLoader.Ignore] public Lazy<TileReference<byte, byte>[,]> MapResources;
[FieldLoader.Ignore] public string[,] CustomTerrain; [FieldLoader.Ignore] public string[,] CustomTerrain;
public Map() {} /* doesn't really produce a valid map, but enough for loading a mod */
public static Map FromTileset(string tileset) public static Map FromTileset(string tileset)
{ {
var tile = OpenRA.Rules.TileSets[tileset].Templates.First(); var tile = OpenRA.Rules.TileSets[tileset].Templates.First();
@@ -98,20 +88,22 @@ namespace OpenRA
void AssertExists(string filename) void AssertExists(string filename)
{ {
using(var s = Container.GetContent(filename)) using (var s = container.GetContent(filename))
if (s == null) if (s == null)
throw new InvalidOperationException("Required file {0} not present in this map".F(filename)); throw new InvalidOperationException("Required file {0} not present in this map".F(filename));
} }
public Map() { } /* doesn't really produce a valid map, but enough for loading a mod */
public Map(string path) public Map(string path)
{ {
Path = path; Path = path;
Container = FileSystem.OpenPackage(path, null, int.MaxValue); container = FileSystem.OpenPackage(path, null, int.MaxValue);
AssertExists("map.yaml"); AssertExists("map.yaml");
AssertExists("map.bin"); AssertExists("map.bin");
var yaml = new MiniYaml( null, MiniYaml.FromStream(Container.GetContent("map.yaml")) ); var yaml = new MiniYaml(null, MiniYaml.FromStream(container.GetContent("map.yaml")));
FieldLoader.Load(this, yaml); FieldLoader.Load(this, yaml);
Uid = ComputeHash(); Uid = ComputeHash();
@@ -150,12 +142,12 @@ namespace OpenRA
return ret; return ret;
}); });
Rules = NodesOrEmpty(yaml, "Rules"); Rules = MiniYaml.NodesOrEmpty(yaml, "Rules");
Sequences = NodesOrEmpty(yaml, "Sequences"); Sequences = MiniYaml.NodesOrEmpty(yaml, "Sequences");
VoxelSequences = NodesOrEmpty(yaml, "VoxelSequences"); VoxelSequences = MiniYaml.NodesOrEmpty(yaml, "VoxelSequences");
Weapons = NodesOrEmpty(yaml, "Weapons"); Weapons = MiniYaml.NodesOrEmpty(yaml, "Weapons");
Voices = NodesOrEmpty(yaml, "Voices"); Voices = MiniYaml.NodesOrEmpty(yaml, "Voices");
Notifications = NodesOrEmpty(yaml, "Notifications"); Notifications = MiniYaml.NodesOrEmpty(yaml, "Notifications");
CustomTerrain = new string[MapSize.X, MapSize.Y]; CustomTerrain = new string[MapSize.X, MapSize.Y];
@@ -163,9 +155,12 @@ namespace OpenRA
MapResources = Lazy.New(() => LoadResourceTiles()); MapResources = Lazy.New(() => LoadResourceTiles());
} }
static List<MiniYamlNode> NodesOrEmpty(MiniYaml y, string s) public int2[] GetSpawnPoints()
{ {
return y.NodesDict.ContainsKey(s) ? y.NodesDict[s].Nodes : new List<MiniYamlNode>(); return Actors.Value.Values
.Where(a => a.Type == "mpspawn")
.Select(a => a.InitDict.Get<LocationInit>().value)
.ToArray();
} }
public void Save(string toPath) public void Save(string toPath)
@@ -197,14 +192,10 @@ namespace OpenRA
} }
root.Add(new MiniYamlNode("Players", null, root.Add(new MiniYamlNode("Players", null,
Players.Select( p => new MiniYamlNode( Players.Select(p => new MiniYamlNode("PlayerReference@{0}".F(p.Key), FieldSaver.SaveDifferences(p.Value, new PlayerReference()))).ToList()));
"PlayerReference@{0}".F( p.Key ),
FieldSaver.SaveDifferences( p.Value, new PlayerReference() ) ) ).ToList() ) );
root.Add(new MiniYamlNode("Actors", null, root.Add(new MiniYamlNode("Actors", null,
Actors.Value.Select( x => new MiniYamlNode( Actors.Value.Select(x => new MiniYamlNode(x.Key, x.Value.Save())).ToList()));
x.Key,
x.Value.Save() ) ).ToList() ) );
root.Add(new MiniYamlNode("Smudges", MiniYaml.FromList<SmudgeReference>(Smudges.Value))); root.Add(new MiniYamlNode("Smudges", MiniYaml.FromList<SmudgeReference>(Smudges.Value)));
root.Add(new MiniYamlNode("Rules", null, Rules)); root.Add(new MiniYamlNode("Rules", null, Rules));
@@ -226,17 +217,17 @@ namespace OpenRA
// Create a new map package // Create a new map package
// TODO: Add other files (custom assets) to the entries list // TODO: Add other files (custom assets) to the entries list
Container = FileSystem.CreatePackage(Path, int.MaxValue, entries); container = FileSystem.CreatePackage(Path, int.MaxValue, entries);
} }
// Update existing package // Update existing package
Container.Write(entries); container.Write(entries);
} }
public TileReference<ushort, byte>[,] LoadMapTiles() public TileReference<ushort, byte>[,] LoadMapTiles()
{ {
var tiles = new TileReference<ushort, byte>[MapSize.X, MapSize.Y]; var tiles = new TileReference<ushort, byte>[MapSize.X, MapSize.Y];
using (var dataStream = Container.GetContent("map.bin")) using (var dataStream = container.GetContent("map.bin"))
{ {
if (dataStream.ReadUInt8() != 1) if (dataStream.ReadUInt8() != 1)
throw new InvalidDataException("Unknown binary map format"); throw new InvalidDataException("Unknown binary map format");
@@ -260,6 +251,7 @@ namespace OpenRA
tiles[i, j] = new TileReference<ushort, byte>(tile, index); tiles[i, j] = new TileReference<ushort, byte>(tile, index);
} }
} }
return tiles; return tiles;
} }
@@ -267,7 +259,7 @@ namespace OpenRA
{ {
var resources = new TileReference<byte, byte>[MapSize.X, MapSize.Y]; var resources = new TileReference<byte, byte>[MapSize.X, MapSize.Y];
using (var dataStream = Container.GetContent("map.bin")) using (var dataStream = container.GetContent("map.bin"))
{ {
if (dataStream.ReadUInt8() != 1) if (dataStream.ReadUInt8() != 1)
throw new InvalidDataException("Unknown binary map format"); throw new InvalidDataException("Unknown binary map format");
@@ -291,6 +283,7 @@ namespace OpenRA
resources[i, j] = new TileReference<byte, byte>(type, index); resources[i, j] = new TileReference<byte, byte>(type, index);
} }
} }
return resources; return resources;
} }
@@ -314,8 +307,8 @@ namespace OpenRA
for (var j = 0; j < MapSize.Y; j++) for (var j = 0; j < MapSize.Y; j++)
{ {
writer.Write(MapTiles.Value[i, j].type); writer.Write(MapTiles.Value[i, j].type);
var PickAny = OpenRA.Rules.TileSets[Tileset].Templates[MapTiles.Value[i, j].type].PickAny; var pickAny = OpenRA.Rules.TileSets[Tileset].Templates[MapTiles.Value[i, j].type].PickAny;
writer.Write(PickAny ? (byte)(i % 4 + (j % 4) * 4) : MapTiles.Value[i, j].index); writer.Write(pickAny ? (byte)(i % 4 + (j % 4) * 4) : MapTiles.Value[i, j].index);
} }
// Resource data // Resource data
@@ -326,29 +319,20 @@ namespace OpenRA
writer.Write(MapResources.Value[i, j].index); writer.Write(MapResources.Value[i, j].index);
} }
} }
return dataStream.ToArray(); return dataStream.ToArray();
} }
public bool IsInMap(CPos xy) { return IsInMap(xy.X, xy.Y); } public bool IsInMap(CPos xy) { return IsInMap(xy.X, xy.Y); }
public bool IsInMap(int x, int y) { return Bounds.Contains(x, y); } public bool IsInMap(int x, int y) { return Bounds.Contains(x, y); }
static T[,] ResizeArray<T>(T[,] ts, T t, int width, int height)
{
var result = new T[width, height];
for (var i = 0; i < width; i++)
for (var j = 0; j < height; j++)
result[i, j] = i <= ts.GetUpperBound(0) && j <= ts.GetUpperBound(1)
? ts[i, j] : t;
return result;
}
public void Resize(int width, int height) // editor magic. public void Resize(int width, int height) // editor magic.
{ {
var oldMapTiles = MapTiles.Value; var oldMapTiles = MapTiles.Value;
var oldMapResources = MapResources.Value; var oldMapResources = MapResources.Value;
MapTiles = Lazy.New(() => ResizeArray(oldMapTiles, oldMapTiles[0, 0], width, height)); MapTiles = Lazy.New(() => Exts.ResizeArray(oldMapTiles, oldMapTiles[0, 0], width, height));
MapResources = Lazy.New(() => ResizeArray(oldMapResources, oldMapResources[0, 0], width, height)); MapResources = Lazy.New(() => Exts.ResizeArray(oldMapResources, oldMapResources[0, 0], width, height));
MapSize = new int2(width, height); MapSize = new int2(width, height);
} }
@@ -361,8 +345,8 @@ namespace OpenRA
{ {
// UID is calculated by taking an SHA1 of the yaml and binary data // UID is calculated by taking an SHA1 of the yaml and binary data
// Read the relevant data into a buffer // Read the relevant data into a buffer
var data = Container.GetContent("map.yaml").ReadAllBytes() var data = container.GetContent("map.yaml").ReadAllBytes()
.Concat(Container.GetContent("map.bin").ReadAllBytes()).ToArray(); .Concat(container.GetContent("map.bin").ReadAllBytes()).ToArray();
// Take the SHA1 // Take the SHA1
using (var csp = SHA1.Create()) using (var csp = SHA1.Create())

View File

@@ -30,6 +30,18 @@ namespace OpenRA
public SpriteLoader SpriteLoader; public SpriteLoader SpriteLoader;
public VoxelLoader VoxelLoader; public VoxelLoader VoxelLoader;
public static IEnumerable<string> FindMapsIn(string dir)
{
string[] noMaps = { };
if (!Directory.Exists(dir))
return noMaps;
return Directory.GetDirectories(dir)
.Concat(Directory.GetFiles(dir, "*.zip"))
.Concat(Directory.GetFiles(dir, "*.oramap"));
}
public ModData(params string[] mods) public ModData(params string[] mods)
{ {
Manifest = new Manifest(mods); Manifest = new Manifest(mods);
@@ -45,7 +57,6 @@ namespace OpenRA
FileSystem.UnmountAll(); FileSystem.UnmountAll();
foreach (var dir in Manifest.Folders) foreach (var dir in Manifest.Folders)
FileSystem.Mount(dir); FileSystem.Mount(dir);
} }
public void InitializeLoaders() public void InitializeLoaders()
@@ -76,24 +87,13 @@ namespace OpenRA
Rules.LoadRules(Manifest, map); Rules.LoadRules(Manifest, map);
SpriteLoader = new SpriteLoader(Rules.TileSets[map.Tileset].Extensions, SheetBuilder); SpriteLoader = new SpriteLoader(Rules.TileSets[map.Tileset].Extensions, SheetBuilder);
// TODO: Don't load the sequences for assets that are not used in this tileset. Maybe use the existing EditorTilesetFilters. // TODO: Don't load the sequences for assets that are not used in this tileset. Maybe use the existing EditorTilesetFilters.
SequenceProvider.Initialize(Manifest.Sequences, map.Sequences); SequenceProvider.Initialize(Manifest.Sequences, map.Sequences);
VoxelProvider.Initialize(Manifest.VoxelSequences, map.VoxelSequences); VoxelProvider.Initialize(Manifest.VoxelSequences, map.VoxelSequences);
return map; return map;
} }
public static IEnumerable<string> FindMapsIn(string dir)
{
string[] NoMaps = { };
if (!Directory.Exists(dir))
return NoMaps;
return Directory.GetDirectories(dir)
.Concat(Directory.GetFiles(dir, "*.zip"))
.Concat(Directory.GetFiles(dir, "*.oramap"));
}
Dictionary<string, Map> FindMaps(string[] mods) Dictionary<string, Map> FindMaps(string[] mods)
{ {
var paths = mods.SelectMany(p => FindMapsIn("mods{0}{1}{0}maps{0}".F(Path.DirectorySeparatorChar, p))) var paths = mods.SelectMany(p => FindMapsIn("mods{0}{1}{0}maps{0}".F(Path.DirectorySeparatorChar, p)))

View File

@@ -19,7 +19,7 @@ namespace OpenRA
{ {
public class ObjectCreator public class ObjectCreator
{ {
Pair<Assembly, string>[] ModAssemblies; Pair<Assembly, string>[] modAssemblies;
public ObjectCreator(Manifest manifest) public ObjectCreator(Manifest manifest)
{ {
@@ -35,7 +35,7 @@ namespace OpenRA
asms.AddRange(asm.GetNamespaces().Select(ns => Pair.New(asm, ns))); asms.AddRange(asm.GetNamespaces().Select(ns => Pair.New(asm, ns)));
} }
ModAssemblies = asms.ToArray(); modAssemblies = asms.ToArray();
} }
public static Action<string> MissingTypeAction = public static Action<string> MissingTypeAction =
@@ -48,7 +48,7 @@ namespace OpenRA
public T CreateObject<T>(string className, Dictionary<string, object> args) public T CreateObject<T>(string className, Dictionary<string, object> args)
{ {
foreach( var mod in ModAssemblies ) foreach (var mod in modAssemblies)
{ {
var type = mod.First.GetType(mod.Second + "." + className, false); var type = mod.First.GetType(mod.Second + "." + className, false);
if (type == null) continue; if (type == null) continue;
@@ -63,6 +63,7 @@ namespace OpenRA
else else
throw new InvalidOperationException("ObjectCreator: UseCtor on multiple constructors; invalid."); throw new InvalidOperationException("ObjectCreator: UseCtor on multiple constructors; invalid.");
} }
MissingTypeAction(className); MissingTypeAction(className);
return default(T); return default(T);
} }
@@ -82,13 +83,14 @@ namespace OpenRA
if (!args.ContainsKey(key)) throw new InvalidOperationException("ObjectCreator: key `{0}' not found".F(key)); if (!args.ContainsKey(key)) throw new InvalidOperationException("ObjectCreator: key `{0}' not found".F(key));
a[i] = args[key]; a[i] = args[key];
} }
return ctor.Invoke(a); return ctor.Invoke(a);
} }
public IEnumerable<Type> GetTypesImplementing<T>() public IEnumerable<Type> GetTypesImplementing<T>()
{ {
var it = typeof(T); var it = typeof(T);
return ModAssemblies.Select( ma => ma.First ).Distinct() return modAssemblies.Select(ma => ma.First).Distinct()
.SelectMany(ma => ma.GetTypes() .SelectMany(ma => ma.GetTypes()
.Where(t => t != it && it.IsAssignableFrom(t))); .Where(t => t != it && it.IsAssignableFrom(t)));
} }

View File

@@ -146,7 +146,6 @@
<Compile Include="Orders\IOrderGenerator.cs" /> <Compile Include="Orders\IOrderGenerator.cs" />
<Compile Include="Orders\UnitOrderGenerator.cs" /> <Compile Include="Orders\UnitOrderGenerator.cs" />
<Compile Include="Player.cs" /> <Compile Include="Player.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Selection.cs" /> <Compile Include="Selection.cs" />
<Compile Include="Server\Connection.cs" /> <Compile Include="Server\Connection.cs" />
<Compile Include="Server\Exts.cs" /> <Compile Include="Server\Exts.cs" />

View File

@@ -1,27 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* 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
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("OpenRA")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OpenRA")]
[assembly: AssemblyCopyright("Copyright © 2007,2009,2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -302,6 +302,16 @@
<BooleanProperty Name="Enabled">False</BooleanProperty> <BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings> </RuleSettings>
</Rule> </Rule>
<Rule Name="ParameterMustFollowComma">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="SplitParametersMustStartOnLineAfterDeclaration">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules> </Rules>
<AnalyzerSettings /> <AnalyzerSettings />
</Analyzer> </Analyzer>

View File

@@ -19,19 +19,19 @@ namespace OpenRA.Mods.Cnc
{ {
public class CncLoadScreen : ILoadScreen public class CncLoadScreen : ILoadScreen
{ {
Dictionary<string, string> Info; Dictionary<string, string> loadInfo;
Stopwatch loadTimer = new Stopwatch(); Stopwatch loadTimer = new Stopwatch();
Sprite[] ss; Sprite[] ss;
int loadTick; int loadTick;
float2 nodPos, gdiPos, evaPos; float2 nodPos, gdiPos, evaPos;
Sprite nodLogo, gdiLogo, evaLogo, brightBlock, dimBlock; Sprite nodLogo, gdiLogo, evaLogo, brightBlock, dimBlock;
Rectangle Bounds; Rectangle bounds;
Renderer r; Renderer r;
NullInputHandler nih = new NullInputHandler(); NullInputHandler nih = new NullInputHandler();
public void Init(Dictionary<string, string> info) public void Init(Dictionary<string, string> info)
{ {
Info = info; loadInfo = info;
// Avoid standard loading mechanisms so we // Avoid standard loading mechanisms so we
// can display loadscreen as early as possible // can display loadscreen as early as possible
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Cnc
var s = new Sheet("mods/cnc/uibits/chrome.png"); var s = new Sheet("mods/cnc/uibits/chrome.png");
var res = Renderer.Resolution; var res = Renderer.Resolution;
Bounds = new Rectangle(0, 0, res.Width, res.Height); bounds = new Rectangle(0, 0, res.Width, res.Height);
ss = new[] ss = new[]
{ {
@@ -57,9 +57,9 @@ namespace OpenRA.Mods.Cnc
nodLogo = new Sprite(s, new Rectangle(0, 256, 256, 256), TextureChannel.Alpha); nodLogo = new Sprite(s, new Rectangle(0, 256, 256, 256), TextureChannel.Alpha);
gdiLogo = new Sprite(s, new Rectangle(256, 256, 256, 256), TextureChannel.Alpha); gdiLogo = new Sprite(s, new Rectangle(256, 256, 256, 256), TextureChannel.Alpha);
evaLogo = new Sprite(s, new Rectangle(256, 64, 128, 64), TextureChannel.Alpha); evaLogo = new Sprite(s, new Rectangle(256, 64, 128, 64), TextureChannel.Alpha);
nodPos = new float2(Bounds.Width / 2 - 384, Bounds.Height / 2 - 128); nodPos = new float2(bounds.Width / 2 - 384, bounds.Height / 2 - 128);
gdiPos = new float2(Bounds.Width / 2 + 128, Bounds.Height / 2 - 128); gdiPos = new float2(bounds.Width / 2 + 128, bounds.Height / 2 - 128);
evaPos = new float2(Bounds.Width - 43 - 128, 43); evaPos = new float2(bounds.Width - 43 - 128, 43);
brightBlock = new Sprite(s, new Rectangle(320, 0, 16, 35), TextureChannel.Alpha); brightBlock = new Sprite(s, new Rectangle(320, 0, 16, 35), TextureChannel.Alpha);
dimBlock = new Sprite(s, new Rectangle(336, 0, 16, 35), TextureChannel.Alpha); dimBlock = new Sprite(s, new Rectangle(336, 0, 16, 35), TextureChannel.Alpha);
@@ -83,19 +83,19 @@ namespace OpenRA.Mods.Cnc
r.RgbaSpriteRenderer.DrawSprite(nodLogo, nodPos); r.RgbaSpriteRenderer.DrawSprite(nodLogo, nodPos);
r.RgbaSpriteRenderer.DrawSprite(evaLogo, evaPos); r.RgbaSpriteRenderer.DrawSprite(evaLogo, evaPos);
WidgetUtils.DrawPanelPartial(ss, Bounds, PanelSides.Edges); WidgetUtils.DrawPanelPartial(ss, bounds, PanelSides.Edges);
var barY = Bounds.Height - 78; var barY = bounds.Height - 78;
if (!setup && r.Fonts != null) if (!setup && r.Fonts != null)
{ {
loadingFont = r.Fonts["BigBold"]; loadingFont = r.Fonts["BigBold"];
loadingText = "Loading"; loadingText = "Loading";
loadingPos = new float2((Bounds.Width - loadingFont.Measure(loadingText).X) / 2, barY); loadingPos = new float2((bounds.Width - loadingFont.Measure(loadingText).X) / 2, barY);
versionFont = r.Fonts["Regular"]; versionFont = r.Fonts["Regular"];
versionText = WidgetUtils.ActiveModVersion(); versionText = WidgetUtils.ActiveModVersion();
var versionSize = versionFont.Measure(versionText); var versionSize = versionFont.Measure(versionText);
versionPos = new float2(Bounds.Width - 107 - versionSize.X/2, 115 - versionSize.Y/2); versionPos = new float2(bounds.Width - 107 - versionSize.X / 2, 115 - versionSize.Y / 2);
setup = true; setup = true;
} }
@@ -109,9 +109,9 @@ namespace OpenRA.Mods.Cnc
{ {
var block = loadTick == i ? brightBlock : dimBlock; var block = loadTick == i ? brightBlock : dimBlock;
r.RgbaSpriteRenderer.DrawSprite(block, r.RgbaSpriteRenderer.DrawSprite(block,
new float2(Bounds.Width / 2 - 114 - i * 32, barY)); new float2(bounds.Width / 2 - 114 - i * 32, barY));
r.RgbaSpriteRenderer.DrawSprite(block, r.RgbaSpriteRenderer.DrawSprite(block,
new float2(Bounds.Width / 2 + 114 + i * 32 - 16, barY)); new float2(bounds.Width / 2 + 114 + i * 32 - 16, barY));
} }
r.EndFrame(nih); r.EndFrame(nih);
@@ -125,19 +125,18 @@ namespace OpenRA.Mods.Cnc
void TestAndContinue() void TestAndContinue()
{ {
Ui.ResetAll(); Ui.ResetAll();
if (!FileSystem.Exists(Info["TestFile"])) if (!FileSystem.Exists(loadInfo["TestFile"]))
{ {
var args = new WidgetArgs() var args = new WidgetArgs()
{ {
{ "continueLoading", () => TestAndContinue() }, { "continueLoading", () => TestAndContinue() },
{ "installData", Info } { "installData", loadInfo }
}; };
Ui.LoadWidget(Info["InstallerBackgroundWidget"], Ui.Root, args); Ui.LoadWidget(loadInfo["InstallerBackgroundWidget"], Ui.Root, args);
Ui.OpenWindow(Info["InstallerMenuWidget"], args); Ui.OpenWindow(loadInfo["InstallerMenuWidget"], args);
} }
else else
Game.LoadShellMap(); Game.LoadShellMap();
} }
} }
} }

View File

@@ -21,16 +21,16 @@ namespace OpenRA.Mods.RA
class CncShellmapScript : IWorldLoaded, ITick class CncShellmapScript : IWorldLoaded, ITick
{ {
Dictionary<string, Actor> Actors; static CPos viewportOrigin;
static CPos ViewportOrigin; Dictionary<string, Actor> actors;
public void WorldLoaded(World w) public void WorldLoaded(World w)
{ {
var b = w.Map.Bounds; var b = w.Map.Bounds;
ViewportOrigin = new CPos(b.Left + b.Width/2, b.Top + b.Height/2); viewportOrigin = new CPos(b.Left + b.Width / 2, b.Top + b.Height / 2);
Game.MoveViewport(ViewportOrigin.ToFloat2()); Game.MoveViewport(viewportOrigin.ToFloat2());
Actors = w.WorldActor.Trait<SpawnMapActors>().Actors; actors = w.WorldActor.Trait<SpawnMapActors>().Actors;
SetViewport(); SetViewport();
} }
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.RA
void SetViewport() void SetViewport()
{ {
var t = (ticks + 45) % (360f * speed) * (Math.PI / 180) * 1f / speed; var t = (ticks + 45) % (360f * speed) * (Math.PI / 180) * 1f / speed;
var loc = ViewportOrigin.ToFloat2() + (new float2(-15,4) * float2.FromAngle( (float)t )); var loc = viewportOrigin.ToFloat2() + (new float2(-15, 4) * float2.FromAngle((float)t));
Game.viewport.Center(loc); Game.viewport.Center(loc);
} }
@@ -51,16 +51,16 @@ namespace OpenRA.Mods.RA
if (ticks == 0) if (ticks == 0)
{ {
LoopTrack(Actors["boat1"], Actors["tl1"].Location, Actors["tr1"].Location); LoopTrack(actors["boat1"], actors["tl1"].Location, actors["tr1"].Location);
LoopTrack(Actors["boat3"], Actors["tl1"].Location, Actors["tr1"].Location); LoopTrack(actors["boat3"], actors["tl1"].Location, actors["tr1"].Location);
LoopTrack(Actors["boat2"], Actors["tl3"].Location, Actors["tr3"].Location); LoopTrack(actors["boat2"], actors["tl3"].Location, actors["tr3"].Location);
LoopTrack(Actors["boat4"], Actors["tl3"].Location, Actors["tr3"].Location); LoopTrack(actors["boat4"], actors["tl3"].Location, actors["tr3"].Location);
CreateUnitsInTransport(Actors["lst1"], new string[] {"htnk"}); CreateUnitsInTransport(actors["lst1"], new string[] { "htnk" });
CreateUnitsInTransport(Actors["lst2"], new string[] {"mcv"}); CreateUnitsInTransport(actors["lst2"], new string[] { "mcv" });
CreateUnitsInTransport(Actors["lst3"], new string[] {"htnk"}); CreateUnitsInTransport(actors["lst3"], new string[] { "htnk" });
LoopTrack(Actors["lst1"], Actors["tl2"].Location, Actors["tr2"].Location); LoopTrack(actors["lst1"], actors["tl2"].Location, actors["tr2"].Location);
LoopTrack(Actors["lst2"], Actors["tl2"].Location, Actors["tr2"].Location); LoopTrack(actors["lst2"], actors["tl2"].Location, actors["tr2"].Location);
LoopTrack(Actors["lst3"], Actors["tl2"].Location, Actors["tr2"].Location); LoopTrack(actors["lst3"], actors["tl2"].Location, actors["tr2"].Location);
} }
ticks++; ticks++;

View File

@@ -15,9 +15,9 @@ using OpenRA.FileFormats;
using OpenRA.Mods.RA; using OpenRA.Mods.RA;
using OpenRA.Mods.RA.Activities; using OpenRA.Mods.RA.Activities;
using OpenRA.Mods.RA.Move; using OpenRA.Mods.RA.Move;
using OpenRA.Scripting;
using OpenRA.Traits; using OpenRA.Traits;
using OpenRA.Widgets; using OpenRA.Widgets;
using OpenRA.Scripting;
namespace OpenRA.Mods.Cnc.Missions namespace OpenRA.Mods.Cnc.Missions
{ {
@@ -25,13 +25,13 @@ namespace OpenRA.Mods.Cnc.Missions
class Gdi01Script : IWorldLoaded, ITick class Gdi01Script : IWorldLoaded, ITick
{ {
Dictionary<string, Actor> Actors; Dictionary<string, Actor> actors;
Dictionary<string, Player> Players; Dictionary<string, Player> players;
public void WorldLoaded(World w) public void WorldLoaded(World w)
{ {
Players = w.Players.ToDictionary(p => p.InternalName); players = w.Players.ToDictionary(p => p.InternalName);
Actors = w.WorldActor.Trait<SpawnMapActors>().Actors; actors = w.WorldActor.Trait<SpawnMapActors>().Actors;
var b = w.Map.Bounds; var b = w.Map.Bounds;
Game.MoveViewport(new CPos(b.Left + b.Width / 2, b.Top + b.Height / 2).ToFloat2()); Game.MoveViewport(new CPos(b.Left + b.Width / 2, b.Top + b.Height / 2).ToFloat2());
@@ -48,10 +48,10 @@ namespace OpenRA.Mods.Cnc.Missions
{ {
Action afterFMV = () => Action afterFMV = () =>
{ {
Players["GoodGuy"].WinState = WinState.Won; players["GoodGuy"].WinState = WinState.Won;
started = false; started = false;
Sound.StopMusic(); Sound.StopMusic();
Sound.PlayToPlayer(Players["GoodGuy"], "accom1.aud"); Sound.PlayToPlayer(players["GoodGuy"], "accom1.aud");
}; };
Game.RunAfterDelay(0, () => Media.PlayFMVFullscreen(w, "consyard.vqa", afterFMV)); Game.RunAfterDelay(0, () => Media.PlayFMVFullscreen(w, "consyard.vqa", afterFMV));
} }
@@ -60,10 +60,10 @@ namespace OpenRA.Mods.Cnc.Missions
{ {
Action afterFMV = () => Action afterFMV = () =>
{ {
Players["GoodGuy"].WinState = WinState.Lost; players["GoodGuy"].WinState = WinState.Lost;
started = false; started = false;
Sound.StopMusic(); Sound.StopMusic();
Sound.PlayToPlayer(Players["GoodGuy"], "fail1.aud"); Sound.PlayToPlayer(players["GoodGuy"], "fail1.aud");
}; };
Game.RunAfterDelay(0, () => Media.PlayFMVFullscreen(w, "gameover.vqa", afterFMV)); Game.RunAfterDelay(0, () => Media.PlayFMVFullscreen(w, "gameover.vqa", afterFMV));
} }
@@ -87,22 +87,24 @@ namespace OpenRA.Mods.Cnc.Missions
{ {
var a = self.World.CreateActor(i.ToLowerInvariant(), new TypeDictionary var a = self.World.CreateActor(i.ToLowerInvariant(), new TypeDictionary
{ {
new OwnerInit(Players["BadGuy"]), new OwnerInit(players["BadGuy"]),
new FacingInit(0), new FacingInit(0),
new LocationInit(Actors["nod0"].Location), new LocationInit(actors["nod0"].Location),
}); });
var mobile = a.Trait<Mobile>(); var mobile = a.Trait<Mobile>();
a.QueueActivity(mobile.MoveTo(Actors["nod1"].Location, 2 )); a.QueueActivity(mobile.MoveTo(actors["nod1"].Location, 2));
a.QueueActivity(mobile.MoveTo(Actors["nod2"].Location, 2 )); a.QueueActivity(mobile.MoveTo(actors["nod2"].Location, 2));
a.QueueActivity(mobile.MoveTo(Actors["nod3"].Location, 2 )); a.QueueActivity(mobile.MoveTo(actors["nod3"].Location, 2));
// TODO: Queue hunt order // TODO: Queue hunt order
} }
}); });
} }
// GoodGuy win conditions // GoodGuy win conditions
// BadGuy is dead // BadGuy is dead
var badcount = self.World.Actors.Count(a => a != a.Owner.PlayerActor && var badcount = self.World.Actors.Count(a => a != a.Owner.PlayerActor &&
a.Owner == Players["BadGuy"] && !a.IsDead()); a.Owner == players["BadGuy"] && !a.IsDead());
if (badcount != lastBadCount) if (badcount != lastBadCount)
{ {
Game.Debug("{0} badguys remain".F(badcount)); Game.Debug("{0} badguys remain".F(badcount));
@@ -114,7 +116,7 @@ namespace OpenRA.Mods.Cnc.Missions
// GoodGuy lose conditions: MCV/cyard must survive // GoodGuy lose conditions: MCV/cyard must survive
var hasAnything = self.World.ActorsWithTrait<MustBeDestroyed>() var hasAnything = self.World.ActorsWithTrait<MustBeDestroyed>()
.Any( a => a.Actor.Owner == Players["GoodGuy"] ); .Any(a => a.Actor.Owner == players["GoodGuy"]);
if (!hasAnything) if (!hasAnything)
OnLose(self.World); OnLose(self.World);
@@ -122,41 +124,41 @@ namespace OpenRA.Mods.Cnc.Missions
if (ticks == 25 * 5) if (ticks == 25 * 5)
{ {
ReinforceFromSea(self.World, ReinforceFromSea(self.World,
Actors["lstStart"].Location, actors["lstStart"].Location,
Actors["lstEnd"].Location, actors["lstEnd"].Location,
new CPos(53, 53), new CPos(53, 53),
new string[] { "e1", "e1", "e1" }, new string[] { "e1", "e1", "e1" },
Players["GoodGuy"]); players["GoodGuy"]);
} }
if (ticks == 25 * 15) if (ticks == 25 * 15)
{ {
ReinforceFromSea(self.World, ReinforceFromSea(self.World,
Actors["lstStart"].Location, actors["lstStart"].Location,
Actors["lstEnd"].Location, actors["lstEnd"].Location,
new CPos(53, 53), new CPos(53, 53),
new string[] { "e1", "e1", "e1" }, new string[] { "e1", "e1", "e1" },
Players["GoodGuy"]); players["GoodGuy"]);
} }
if (ticks == 25 * 30) if (ticks == 25 * 30)
{ {
ReinforceFromSea(self.World, ReinforceFromSea(self.World,
Actors["lstStart"].Location, actors["lstStart"].Location,
Actors["lstEnd"].Location, actors["lstEnd"].Location,
new CPos(53, 53), new CPos(53, 53),
new string[] { "jeep" }, new string[] { "jeep" },
Players["GoodGuy"]); players["GoodGuy"]);
} }
if (ticks == 25 * 60) if (ticks == 25 * 60)
{ {
ReinforceFromSea(self.World, ReinforceFromSea(self.World,
Actors["lstStart"].Location, actors["lstStart"].Location,
Actors["lstEnd"].Location, actors["lstEnd"].Location,
new CPos(53, 53), new CPos(53, 53),
new string[] { "jeep" }, new string[] { "jeep" },
Players["GoodGuy"]); players["GoodGuy"]);
} }
ticks++; ticks++;
@@ -164,11 +166,11 @@ namespace OpenRA.Mods.Cnc.Missions
void SetGunboatPath() void SetGunboatPath()
{ {
var self = Actors[ "Gunboat" ]; var self = actors["Gunboat"];
var mobile = self.Trait<Mobile>(); var mobile = self.Trait<Mobile>();
self.Trait<AutoTarget>().stance = UnitStance.AttackAnything; // TODO: this is ignored self.Trait<AutoTarget>().stance = UnitStance.AttackAnything; // TODO: this is ignored
self.QueueActivity(mobile.ScriptedMove(Actors["gunboatLeft"].Location)); self.QueueActivity(mobile.ScriptedMove(actors["gunboatLeft"].Location));
self.QueueActivity(mobile.ScriptedMove(Actors["gunboatRight"].Location)); self.QueueActivity(mobile.ScriptedMove(actors["gunboatRight"].Location));
self.QueueActivity(new CallFunc(() => SetGunboatPath())); self.QueueActivity(new CallFunc(() => SetGunboatPath()));
} }

View File

@@ -11,16 +11,16 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Mods.Cnc; using OpenRA.Mods.Cnc;
using OpenRA.Mods.RA; using OpenRA.Mods.RA;
using OpenRA.Mods.RA.Air;
using OpenRA.Mods.RA.Move;
using OpenRA.Mods.RA.Activities; using OpenRA.Mods.RA.Activities;
using OpenRA.Mods.RA.Missions; using OpenRA.Mods.RA.Air;
using OpenRA.Mods.RA.Buildings; using OpenRA.Mods.RA.Buildings;
using OpenRA.Mods.RA.Missions;
using OpenRA.Mods.RA.Move;
using OpenRA.Scripting; using OpenRA.Scripting;
using OpenRA.Traits; using OpenRA.Traits;
using OpenRA.FileFormats;
namespace OpenRA.Mods.Cnc.Missions namespace OpenRA.Mods.Cnc.Missions
{ {
@@ -90,6 +90,7 @@ namespace OpenRA.Mods.Cnc.Missions
NODReinforceNthA(); NODReinforceNthA();
Sound.Play("reinfor1.aud"); Sound.Play("reinfor1.aud");
} }
if (world.FrameNumber == 1400) if (world.FrameNumber == 1400)
{ {
NODReinforceNthB(); NODReinforceNthB();
@@ -107,6 +108,7 @@ namespace OpenRA.Mods.Cnc.Missions
Sound.Play("reinfor1.aud"); Sound.Play("reinfor1.aud");
} }
} }
if (levelvillage.Status == ObjectiveStatus.InProgress) if (levelvillage.Status == ObjectiveStatus.InProgress)
{ {
if (vil01.Destroyed && vil02.Destroyed && vil03.Destroyed && vil04.Destroyed && vil05.Destroyed && vil06.Destroyed && if (vil01.Destroyed && vil02.Destroyed && vil03.Destroyed && vil04.Destroyed && vil05.Destroyed && vil06.Destroyed &&

View File

@@ -84,7 +84,6 @@
<Compile Include="PoisonedByTiberium.cs" /> <Compile Include="PoisonedByTiberium.cs" />
<Compile Include="ProductionAirdrop.cs" /> <Compile Include="ProductionAirdrop.cs" />
<Compile Include="ProductionQueueFromSelection.cs" /> <Compile Include="ProductionQueueFromSelection.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="WithCargo.cs" /> <Compile Include="WithCargo.cs" />
<Compile Include="RenderGunboat.cs" /> <Compile Include="RenderGunboat.cs" />
<Compile Include="SpawnViceroid.cs" /> <Compile Include="SpawnViceroid.cs" />

View File

@@ -25,8 +25,8 @@ namespace OpenRA.Mods.Cnc.Widgets
class ProductionQueueFromSelection : INotifySelection class ProductionQueueFromSelection : INotifySelection
{ {
Lazy<ProductionTabsWidget> tabsWidget;
readonly World world; readonly World world;
Lazy<ProductionTabsWidget> tabsWidget;
public ProductionQueueFromSelection(World world, ProductionQueueFromSelectionInfo info) public ProductionQueueFromSelection(World world, ProductionQueueFromSelectionInfo info)
{ {

View File

@@ -1,46 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* 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
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OpenRA.Mods.Cnc")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OpenRA.Mods.Cnc")]
[assembly: AssemblyCopyright("Copyright © 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 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
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("3b31edcf-34e4-4a58-8130-88b15b046d10")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -302,6 +302,16 @@
<BooleanProperty Name="Enabled">False</BooleanProperty> <BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings> </RuleSettings>
</Rule> </Rule>
<Rule Name="ParameterMustFollowComma">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="SplitParametersMustStartOnLineAfterDeclaration">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules> </Rules>
<AnalyzerSettings /> <AnalyzerSettings />
</Analyzer> </Analyzer>

View File

@@ -26,28 +26,28 @@ namespace OpenRA.Mods.Cnc
class SpawnViceroid : INotifyKilled class SpawnViceroid : INotifyKilled
{ {
readonly SpawnViceroidInfo Info; readonly SpawnViceroidInfo spawnViceroidInfo;
public SpawnViceroid(SpawnViceroidInfo info) { Info = info; } public SpawnViceroid(SpawnViceroidInfo info) { spawnViceroidInfo = info; }
public void Killed(Actor self, AttackInfo e) public void Killed(Actor self, AttackInfo e)
{ {
if (e.Warhead == null || e.Warhead.InfDeath != Info.InfDeath) return; if (e.Warhead == null || e.Warhead.InfDeath != spawnViceroidInfo.InfDeath) return;
if (self.World.SharedRandom.Next(100) > Info.Probability) return; if (self.World.SharedRandom.Next(100) > spawnViceroidInfo.Probability) return;
self.World.AddFrameEndTask(w => self.World.AddFrameEndTask(w =>
{ {
var td = new TypeDictionary var td = new TypeDictionary
{ {
new LocationInit(self.Location), new LocationInit(self.Location),
new OwnerInit( self.World.Players.First(p => p.InternalName == Info.Owner) ) new OwnerInit(self.World.Players.First(p => p.InternalName == spawnViceroidInfo.Owner))
}; };
var facing = self.TraitOrDefault<IFacing>(); var facing = self.TraitOrDefault<IFacing>();
if (facing != null) if (facing != null)
td.Add(new FacingInit(facing.Facing)); td.Add(new FacingInit(facing.Facing));
w.CreateActor(Info.ViceroidActor, td); w.CreateActor(spawnViceroidInfo.ViceroidActor, td);
}); });
} }
} }

View File

@@ -20,8 +20,7 @@ namespace OpenRA.Mods.Cnc
public class TiberiumRefinery : OreRefinery public class TiberiumRefinery : OreRefinery
{ {
public TiberiumRefinery(Actor self, TiberiumRefineryInfo info) public TiberiumRefinery(Actor self, TiberiumRefineryInfo info) : base(self, info) { }
: base(self, info) {}
public override Activity DockSequence(Actor harv, Actor self) public override Activity DockSequence(Actor harv, Actor self)
{ {

View File

@@ -34,4 +34,3 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
} }
} }
} }

View File

@@ -24,6 +24,17 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
Widget ingameRoot; Widget ingameRoot;
World world; World world;
static void BindOrderButton<T>(World world, Widget parent, string button, string icon)
where T : IOrderGenerator, new()
{
var w = parent.Get<ButtonWidget>(button);
w.OnClick = () => world.ToggleInputMode<T>();
w.IsHighlighted = () => world.OrderGenerator is T;
w.Get<ImageWidget>("ICON").GetImageName =
() => world.OrderGenerator is T ? icon + "-active" : icon;
}
void AddChatLine(Color c, string from, string text) void AddChatLine(Color c, string from, string text)
{ {
ingameRoot.Get<ChatDisplayWidget>("CHAT_DISPLAY").AddLine(c, from, text); ingameRoot.Get<ChatDisplayWidget>("CHAT_DISPLAY").AddLine(c, from, text);
@@ -114,7 +125,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
.Any(a => a.Actor.Owner == world.LocalPlayer && a.Trait.IsActive); .Any(a => a.Actor.Owner == world.LocalPlayer && a.Trait.IsActive);
if (radarEnabled != cachedRadarEnabled) if (radarEnabled != cachedRadarEnabled)
Sound.PlayNotification(null, "Sounds", (radarEnabled ? "RadarUp" : "RadarDown"), null); Sound.PlayNotification(null, "Sounds", radarEnabled ? "RadarUp" : "RadarDown", null);
cachedRadarEnabled = radarEnabled; cachedRadarEnabled = radarEnabled;
// Switch to observer mode after win/loss // Switch to observer mode after win/loss
@@ -152,16 +163,5 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
return Color.LimeGreen; return Color.LimeGreen;
}; };
} }
static void BindOrderButton<T>(World world, Widget parent, string button, string icon)
where T : IOrderGenerator, new()
{
var w = parent.Get<ButtonWidget>(button);
w.OnClick = () => world.ToggleInputMode<T>();
w.IsHighlighted = () => world.OrderGenerator is T;
w.Get<ImageWidget>("ICON").GetImageName =
() => world.OrderGenerator is T ? icon+"-active" : icon;
}
} }
} }

View File

@@ -92,35 +92,35 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
// Menu panels - ordered from lowest to highest priority // Menu panels - ordered from lowest to highest priority
var panelParent = Game.OpenWindow(world, "INGAME_MENU_PANEL"); var panelParent = Game.OpenWindow(world, "INGAME_MENU_PANEL");
PanelType Panel = PanelType.Objectives; PanelType panelType = PanelType.Objectives;
var visibleButtons = 0; var visibleButtons = 0;
// Debug / Cheats panel // Debug / Cheats panel
var debugButton = panelParent.Get<ButtonWidget>("DEBUG_BUTTON"); var debugButton = panelParent.Get<ButtonWidget>("DEBUG_BUTTON");
debugButton.OnClick = () => Panel = PanelType.Debug; debugButton.OnClick = () => panelType = PanelType.Debug;
debugButton.IsHighlighted = () => Panel == PanelType.Debug; debugButton.IsHighlighted = () => panelType == PanelType.Debug;
if (world.LocalPlayer != null && world.LobbyInfo.GlobalSettings.AllowCheats) if (world.LocalPlayer != null && world.LobbyInfo.GlobalSettings.AllowCheats)
{ {
Panel = PanelType.Debug; panelType = PanelType.Debug;
visibleButtons++; visibleButtons++;
var debugPanel = Game.LoadWidget(world, "CHEATS_PANEL", panelParent, new WidgetArgs() { { "onExit", doNothing } }); var debugPanel = Game.LoadWidget(world, "CHEATS_PANEL", panelParent, new WidgetArgs() { { "onExit", doNothing } });
debugPanel.IsVisible = () => Panel == PanelType.Debug; debugPanel.IsVisible = () => panelType == PanelType.Debug;
debugButton.IsVisible = () => visibleButtons > 1; debugButton.IsVisible = () => visibleButtons > 1;
} }
// Mission objectives // Mission objectives
var iop = world.WorldActor.TraitsImplementing<IObjectivesPanel>().FirstOrDefault(); var iop = world.WorldActor.TraitsImplementing<IObjectivesPanel>().FirstOrDefault();
var objectivesButton = panelParent.Get<ButtonWidget>("OBJECTIVES_BUTTON"); var objectivesButton = panelParent.Get<ButtonWidget>("OBJECTIVES_BUTTON");
objectivesButton.OnClick = () => Panel = PanelType.Objectives; objectivesButton.OnClick = () => panelType = PanelType.Objectives;
objectivesButton.IsHighlighted = () => Panel == PanelType.Objectives; objectivesButton.IsHighlighted = () => panelType == PanelType.Objectives;
if (iop != null && iop.ObjectivesPanel != null) if (iop != null && iop.ObjectivesPanel != null)
{ {
Panel = PanelType.Objectives; panelType = PanelType.Objectives;
visibleButtons++; visibleButtons++;
var objectivesPanel = Game.LoadWidget(world, iop.ObjectivesPanel, panelParent, new WidgetArgs()); var objectivesPanel = Game.LoadWidget(world, iop.ObjectivesPanel, panelParent, new WidgetArgs());
objectivesPanel.IsVisible = () => Panel == PanelType.Objectives; objectivesPanel.IsVisible = () => panelType == PanelType.Objectives;
objectivesButton.IsVisible = () => visibleButtons > 1; objectivesButton.IsVisible = () => visibleButtons > 1;
} }
} }

View File

@@ -44,7 +44,6 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
Ui.OpenWindow("MODS_PANEL", new WidgetArgs() Ui.OpenWindow("MODS_PANEL", new WidgetArgs()
{ {
{ "onExit", () => { } }, { "onExit", () => { } },
// Close this panel
{ "onSwitch", Ui.CloseWindow }, { "onSwitch", Ui.CloseWindow },
}); });
}; };

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
{ {
enum MenuType { Main, Multiplayer, Settings, None } enum MenuType { Main, Multiplayer, Settings, None }
MenuType Menu = MenuType.Main; MenuType menuType = MenuType.Main;
Widget rootMenu; Widget rootMenu;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
@@ -32,85 +32,85 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
// Menu buttons // Menu buttons
var mainMenu = widget.Get("MAIN_MENU"); var mainMenu = widget.Get("MAIN_MENU");
mainMenu.IsVisible = () => Menu == MenuType.Main; mainMenu.IsVisible = () => menuType == MenuType.Main;
mainMenu.Get<ButtonWidget>("SOLO_BUTTON").OnClick = StartSkirmishGame; mainMenu.Get<ButtonWidget>("SOLO_BUTTON").OnClick = StartSkirmishGame;
mainMenu.Get<ButtonWidget>("MULTIPLAYER_BUTTON").OnClick = () => Menu = MenuType.Multiplayer; mainMenu.Get<ButtonWidget>("MULTIPLAYER_BUTTON").OnClick = () => menuType = MenuType.Multiplayer;
mainMenu.Get<ButtonWidget>("MODS_BUTTON").OnClick = () => mainMenu.Get<ButtonWidget>("MODS_BUTTON").OnClick = () =>
{ {
Menu = MenuType.None; menuType = MenuType.None;
Ui.OpenWindow("MODS_PANEL", new WidgetArgs() Ui.OpenWindow("MODS_PANEL", new WidgetArgs()
{ {
{ "onExit", () => Menu = MenuType.Main }, { "onExit", () => menuType = MenuType.Main },
{ "onSwitch", RemoveShellmapUI } { "onSwitch", RemoveShellmapUI }
}); });
}; };
mainMenu.Get<ButtonWidget>("SETTINGS_BUTTON").OnClick = () => Menu = MenuType.Settings; mainMenu.Get<ButtonWidget>("SETTINGS_BUTTON").OnClick = () => menuType = MenuType.Settings;
mainMenu.Get<ButtonWidget>("QUIT_BUTTON").OnClick = Game.Exit; mainMenu.Get<ButtonWidget>("QUIT_BUTTON").OnClick = Game.Exit;
// Multiplayer menu // Multiplayer menu
var multiplayerMenu = widget.Get("MULTIPLAYER_MENU"); var multiplayerMenu = widget.Get("MULTIPLAYER_MENU");
multiplayerMenu.IsVisible = () => Menu == MenuType.Multiplayer; multiplayerMenu.IsVisible = () => menuType == MenuType.Multiplayer;
multiplayerMenu.Get<ButtonWidget>("BACK_BUTTON").OnClick = () => Menu = MenuType.Main; multiplayerMenu.Get<ButtonWidget>("BACK_BUTTON").OnClick = () => menuType = MenuType.Main;
multiplayerMenu.Get<ButtonWidget>("JOIN_BUTTON").OnClick = () => OpenGamePanel("SERVERBROWSER_PANEL"); multiplayerMenu.Get<ButtonWidget>("JOIN_BUTTON").OnClick = () => OpenGamePanel("SERVERBROWSER_PANEL");
multiplayerMenu.Get<ButtonWidget>("CREATE_BUTTON").OnClick = () => OpenGamePanel("CREATESERVER_PANEL"); multiplayerMenu.Get<ButtonWidget>("CREATE_BUTTON").OnClick = () => OpenGamePanel("CREATESERVER_PANEL");
multiplayerMenu.Get<ButtonWidget>("DIRECTCONNECT_BUTTON").OnClick = () => OpenGamePanel("DIRECTCONNECT_PANEL"); multiplayerMenu.Get<ButtonWidget>("DIRECTCONNECT_BUTTON").OnClick = () => OpenGamePanel("DIRECTCONNECT_PANEL");
// Settings menu // Settings menu
var settingsMenu = widget.Get("SETTINGS_MENU"); var settingsMenu = widget.Get("SETTINGS_MENU");
settingsMenu.IsVisible = () => Menu == MenuType.Settings; settingsMenu.IsVisible = () => menuType == MenuType.Settings;
settingsMenu.Get<ButtonWidget>("REPLAYS_BUTTON").OnClick = () => settingsMenu.Get<ButtonWidget>("REPLAYS_BUTTON").OnClick = () =>
{ {
Menu = MenuType.None; menuType = MenuType.None;
Ui.OpenWindow("REPLAYBROWSER_PANEL", new WidgetArgs() Ui.OpenWindow("REPLAYBROWSER_PANEL", new WidgetArgs()
{ {
{ "onExit", () => Menu = MenuType.Settings }, { "onExit", () => menuType = MenuType.Settings },
{ "onStart", RemoveShellmapUI } { "onStart", RemoveShellmapUI }
}); });
}; };
settingsMenu.Get<ButtonWidget>("MUSIC_BUTTON").OnClick = () => settingsMenu.Get<ButtonWidget>("MUSIC_BUTTON").OnClick = () =>
{ {
Menu = MenuType.None; menuType = MenuType.None;
Ui.OpenWindow("MUSIC_PANEL", new WidgetArgs() Ui.OpenWindow("MUSIC_PANEL", new WidgetArgs()
{ {
{ "onExit", () => Menu = MenuType.Settings }, { "onExit", () => menuType = MenuType.Settings },
}); });
}; };
settingsMenu.Get<ButtonWidget>("CREDITS_BUTTON").OnClick = () => settingsMenu.Get<ButtonWidget>("CREDITS_BUTTON").OnClick = () =>
{ {
Menu = MenuType.None; menuType = MenuType.None;
Ui.OpenWindow("CREDITS_PANEL", new WidgetArgs() Ui.OpenWindow("CREDITS_PANEL", new WidgetArgs()
{ {
{ "onExit", () => Menu = MenuType.Settings }, { "onExit", () => menuType = MenuType.Settings },
}); });
}; };
settingsMenu.Get<ButtonWidget>("SETTINGS_BUTTON").OnClick = () => settingsMenu.Get<ButtonWidget>("SETTINGS_BUTTON").OnClick = () =>
{ {
Menu = MenuType.None; menuType = MenuType.None;
Game.OpenWindow("SETTINGS_PANEL", new WidgetArgs() Game.OpenWindow("SETTINGS_PANEL", new WidgetArgs()
{ {
{ "onExit", () => Menu = MenuType.Settings }, { "onExit", () => menuType = MenuType.Settings },
}); });
}; };
settingsMenu.Get<ButtonWidget>("BACK_BUTTON").OnClick = () => Menu = MenuType.Main; settingsMenu.Get<ButtonWidget>("BACK_BUTTON").OnClick = () => menuType = MenuType.Main;
rootMenu.Get<ImageWidget>("RECBLOCK").IsVisible = () => world.FrameNumber / 25 % 2 == 0; rootMenu.Get<ImageWidget>("RECBLOCK").IsVisible = () => world.FrameNumber / 25 % 2 == 0;
} }
void OpenGamePanel(string id) void OpenGamePanel(string id)
{ {
Menu = MenuType.None; menuType = MenuType.None;
Ui.OpenWindow(id, new WidgetArgs() Ui.OpenWindow(id, new WidgetArgs()
{ {
{ "onExit", () => Menu = MenuType.Multiplayer }, { "onExit", () => menuType = MenuType.Multiplayer },
{ "openLobby", () => OpenLobbyPanel(MenuType.Multiplayer, false) } { "openLobby", () => OpenLobbyPanel(MenuType.Multiplayer, false) }
}); });
} }
@@ -122,10 +122,10 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
void OpenLobbyPanel(MenuType menu, bool addBots) void OpenLobbyPanel(MenuType menu, bool addBots)
{ {
Menu = MenuType.None; menuType = MenuType.None;
Game.OpenWindow("SERVER_LOBBY", new WidgetArgs() Game.OpenWindow("SERVER_LOBBY", new WidgetArgs()
{ {
{ "onExit", () => { Game.Disconnect(); Menu = menu; } }, { "onExit", () => { Game.Disconnect(); menuType = menu; } },
{ "onStart", RemoveShellmapUI }, { "onStart", RemoveShellmapUI },
{ "addBots", addBots } { "addBots", addBots }
}); });
@@ -138,7 +138,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
ConnectionLogic.Connect(IPAddress.Loopback.ToString(), ConnectionLogic.Connect(IPAddress.Loopback.ToString(),
Game.CreateLocalServer(map), Game.CreateLocalServer(map),
() => OpenLobbyPanel(MenuType.Main, true), () => OpenLobbyPanel(MenuType.Main, true),
() => { Game.CloseServer(); Menu = MenuType.Main; }); () => { Game.CloseServer(); menuType = MenuType.Main; });
} }
} }
} }

View File

@@ -16,9 +16,9 @@ using OpenRA.FileFormats;
using OpenRA.FileFormats.Graphics; using OpenRA.FileFormats.Graphics;
using OpenRA.GameRules; using OpenRA.GameRules;
using OpenRA.Mods.RA; using OpenRA.Mods.RA;
using OpenRA.Mods.RA.Widgets;
using OpenRA.Mods.RA.Widgets.Logic; using OpenRA.Mods.RA.Widgets.Logic;
using OpenRA.Widgets; using OpenRA.Widgets;
using OpenRA.Mods.RA.Widgets;
namespace OpenRA.Mods.Cnc.Widgets.Logic namespace OpenRA.Mods.Cnc.Widgets.Logic
{ {
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
enum PanelType { General, Input } enum PanelType { General, Input }
SoundDevice soundDevice; SoundDevice soundDevice;
PanelType Settings = PanelType.General; PanelType settingsPanel = PanelType.General;
ColorPreviewManagerWidget colorPreview; ColorPreviewManagerWidget colorPreview;
World world; World world;
@@ -39,11 +39,11 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
// General pane // General pane
var generalButton = panel.Get<ButtonWidget>("GENERAL_BUTTON"); var generalButton = panel.Get<ButtonWidget>("GENERAL_BUTTON");
generalButton.OnClick = () => Settings = PanelType.General; generalButton.OnClick = () => settingsPanel = PanelType.General;
generalButton.IsHighlighted = () => Settings == PanelType.General; generalButton.IsHighlighted = () => settingsPanel == PanelType.General;
var generalPane = panel.Get("GENERAL_CONTROLS"); var generalPane = panel.Get("GENERAL_CONTROLS");
generalPane.IsVisible = () => Settings == PanelType.General; generalPane.IsVisible = () => settingsPanel == PanelType.General;
var gameSettings = Game.Settings.Game; var gameSettings = Game.Settings.Game;
var playerSettings = Game.Settings.Player; var playerSettings = Game.Settings.Player;
@@ -122,11 +122,11 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
// Input pane // Input pane
var inputPane = panel.Get("INPUT_CONTROLS"); var inputPane = panel.Get("INPUT_CONTROLS");
inputPane.IsVisible = () => Settings == PanelType.Input; inputPane.IsVisible = () => settingsPanel == PanelType.Input;
var inputButton = panel.Get<ButtonWidget>("INPUT_BUTTON"); var inputButton = panel.Get<ButtonWidget>("INPUT_BUTTON");
inputButton.OnClick = () => Settings = PanelType.Input; inputButton.OnClick = () => settingsPanel = PanelType.Input;
inputButton.IsHighlighted = () => Settings == PanelType.Input; inputButton.IsHighlighted = () => settingsPanel == PanelType.Input;
var classicMouseCheckbox = inputPane.Get<CheckboxWidget>("CLASSICORDERS_CHECKBOX"); var classicMouseCheckbox = inputPane.Get<CheckboxWidget>("CLASSICORDERS_CHECKBOX");
classicMouseCheckbox.IsChecked = () => gameSettings.UseClassicMouseStyle; classicMouseCheckbox.IsChecked = () => gameSettings.UseClassicMouseStyle;
@@ -163,26 +163,6 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
}; };
} }
bool ShowColorPicker(DropDownButtonWidget color, PlayerSettings s)
{
Action<HSLColor> onChange = c => colorPreview.Color = c;
Action onExit = () =>
{
s.Color = colorPreview.Color;
color.RemovePanel();
};
var colorChooser = Game.LoadWidget(world, "COLOR_CHOOSER", null, new WidgetArgs()
{
{ "onExit", onExit },
{ "onChange", onChange },
{ "initialColor", s.Color }
});
color.AttachPanel(colorChooser, onExit);
return true;
}
static bool ShowMouseScrollDropdown(DropDownButtonWidget dropdown, GameSettings s) static bool ShowMouseScrollDropdown(DropDownButtonWidget dropdown, GameSettings s)
{ {
var options = new Dictionary<string, MouseScrollType>() var options = new Dictionary<string, MouseScrollType>()
@@ -205,6 +185,26 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
return true; return true;
} }
bool ShowColorPicker(DropDownButtonWidget color, PlayerSettings s)
{
Action<HSLColor> onChange = c => colorPreview.Color = c;
Action onExit = () =>
{
s.Color = colorPreview.Color;
color.RemovePanel();
};
var colorChooser = Game.LoadWidget(world, "COLOR_CHOOSER", null, new WidgetArgs()
{
{ "onExit", onExit },
{ "onChange", onChange },
{ "initialColor", s.Color }
});
color.AttachPanel(colorChooser, onExit);
return true;
}
bool ShowAudioDeviceDropdown(DropDownButtonWidget dropdown, SoundSettings s, SoundDevice[] devices) bool ShowAudioDeviceDropdown(DropDownButtonWidget dropdown, SoundSettings s, SoundDevice[] devices)
{ {
var i = 0; var i = 0;

View File

@@ -10,8 +10,8 @@
using System; using System;
using System.Drawing; using System.Drawing;
using OpenRA.Mods.RA.Orders;
using OpenRA.Mods.RA.Buildings; using OpenRA.Mods.RA.Buildings;
using OpenRA.Mods.RA.Orders;
using OpenRA.Traits; using OpenRA.Traits;
using OpenRA.Widgets; using OpenRA.Widgets;

View File

@@ -23,8 +23,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public ProductionTooltipLogic(Widget widget, TooltipContainerWidget tooltipContainer, ProductionPaletteWidget palette) public ProductionTooltipLogic(Widget widget, TooltipContainerWidget tooltipContainer, ProductionPaletteWidget palette)
{ {
var pm = palette.world.LocalPlayer.PlayerActor.Trait<PowerManager>(); var pm = palette.World.LocalPlayer.PlayerActor.Trait<PowerManager>();
var pr = palette.world.LocalPlayer.PlayerActor.Trait<PlayerResources>(); var pr = palette.World.LocalPlayer.PlayerActor.Trait<PlayerResources>();
widget.IsVisible = () => palette.TooltipActor != null; widget.IsVisible = () => palette.TooltipActor != null;
var nameLabel = widget.Get<LabelWidget>("NAME"); var nameLabel = widget.Get<LabelWidget>("NAME");
@@ -99,4 +99,3 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
} }
} }
} }

View File

@@ -65,4 +65,3 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
} }
} }
} }

View File

@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Cnc.Widgets
public readonly string HoldText = ""; public readonly string HoldText = "";
public string TooltipActor { get; private set; } public string TooltipActor { get; private set; }
public readonly World world; public readonly World World;
Lazy<TooltipContainerWidget> tooltipContainer; Lazy<TooltipContainerWidget> tooltipContainer;
ProductionQueue currentQueue; ProductionQueue currentQueue;
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Cnc.Widgets
} }
public override Rectangle EventBounds { get { return eventBounds; } } public override Rectangle EventBounds { get { return eventBounds; } }
Dictionary<Rectangle, ProductionIcon> Icons = new Dictionary<Rectangle, ProductionIcon>(); Dictionary<Rectangle, ProductionIcon> icons = new Dictionary<Rectangle, ProductionIcon>();
Dictionary<string, Sprite> iconSprites; Dictionary<string, Sprite> iconSprites;
Animation cantBuild, clock; Animation cantBuild, clock;
Rectangle eventBounds = Rectangle.Empty; Rectangle eventBounds = Rectangle.Empty;
@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Cnc.Widgets
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public ProductionPaletteWidget(World world, WorldRenderer worldRenderer) public ProductionPaletteWidget(World world, WorldRenderer worldRenderer)
{ {
this.world = world; this.World = world;
this.worldRenderer = worldRenderer; this.worldRenderer = worldRenderer;
tooltipContainer = Lazy.New(() => tooltipContainer = Lazy.New(() =>
Ui.Root.Get<TooltipContainerWidget>(TooltipContainer)); Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));
@@ -104,7 +104,7 @@ namespace OpenRA.Mods.Cnc.Widgets
public override bool HandleMouseInput(MouseInput mi) public override bool HandleMouseInput(MouseInput mi)
{ {
var icon = Icons.Where(i => i.Key.Contains(mi.Location)) var icon = icons.Where(i => i.Key.Contains(mi.Location))
.Select(i => i.Value).FirstOrDefault(); .Select(i => i.Value).FirstOrDefault();
if (mi.Event == MouseInputEvent.Move) if (mi.Event == MouseInputEvent.Move)
@@ -126,29 +126,28 @@ namespace OpenRA.Mods.Cnc.Widgets
if (first != null && first.Done && actor.Traits.Contains<BuildingInfo>()) if (first != null && first.Done && actor.Traits.Contains<BuildingInfo>())
{ {
Sound.Play(TabClick); Sound.Play(TabClick);
world.OrderGenerator = new PlaceBuildingOrderGenerator(CurrentQueue.self, icon.Name); World.OrderGenerator = new PlaceBuildingOrderGenerator(CurrentQueue.self, icon.Name);
} }
// Resume a paused item
else if (first != null && first.Paused) else if (first != null && first.Paused)
{ {
// Resume a paused item
Sound.Play(TabClick); Sound.Play(TabClick);
world.IssueOrder(Order.PauseProduction(CurrentQueue.self, icon.Name, false)); World.IssueOrder(Order.PauseProduction(CurrentQueue.self, icon.Name, false));
} }
// Queue a new item
else if (CurrentQueue.BuildableItems().Any(a => a.Name == icon.Name)) else if (CurrentQueue.BuildableItems().Any(a => a.Name == icon.Name))
{ {
// Queue a new item
Sound.Play(TabClick); Sound.Play(TabClick);
Sound.PlayNotification(world.LocalPlayer, "Speech", CurrentQueue.Info.QueuedAudio, world.LocalPlayer.Country.Race); Sound.PlayNotification(World.LocalPlayer, "Speech", CurrentQueue.Info.QueuedAudio, World.LocalPlayer.Country.Race);
world.IssueOrder(Order.StartProduction(CurrentQueue.self, icon.Name, World.IssueOrder(Order.StartProduction(CurrentQueue.self, icon.Name,
Game.GetModifierKeys().HasModifier(Modifiers.Shift) ? 5 : 1)); Game.GetModifierKeys().HasModifier(Modifiers.Shift) ? 5 : 1));
} }
else else
Sound.Play(DisabledTabClick); Sound.Play(DisabledTabClick);
} }
// Hold/Cancel an existing item
else if (mi.Button == MouseButton.Right) else if (mi.Button == MouseButton.Right)
{ {
// Hold/Cancel an existing item
if (first != null) if (first != null)
{ {
Sound.Play(TabClick); Sound.Play(TabClick);
@@ -156,25 +155,26 @@ namespace OpenRA.Mods.Cnc.Widgets
// instant cancel of things we havent started yet and things that are finished // instant cancel of things we havent started yet and things that are finished
if (first.Paused || first.Done || first.TotalCost == first.RemainingCost) if (first.Paused || first.Done || first.TotalCost == first.RemainingCost)
{ {
Sound.PlayNotification(world.LocalPlayer, "Speech", CurrentQueue.Info.CancelledAudio, world.LocalPlayer.Country.Race); Sound.PlayNotification(World.LocalPlayer, "Speech", CurrentQueue.Info.CancelledAudio, World.LocalPlayer.Country.Race);
world.IssueOrder(Order.CancelProduction(CurrentQueue.self, icon.Name, World.IssueOrder(Order.CancelProduction(CurrentQueue.self, icon.Name,
Game.GetModifierKeys().HasModifier(Modifiers.Shift) ? 5 : 1)); Game.GetModifierKeys().HasModifier(Modifiers.Shift) ? 5 : 1));
} }
else else
{ {
Sound.PlayNotification(world.LocalPlayer, "Speech", CurrentQueue.Info.OnHoldAudio, world.LocalPlayer.Country.Race); Sound.PlayNotification(World.LocalPlayer, "Speech", CurrentQueue.Info.OnHoldAudio, World.LocalPlayer.Country.Race);
world.IssueOrder(Order.PauseProduction(CurrentQueue.self, icon.Name, true)); World.IssueOrder(Order.PauseProduction(CurrentQueue.self, icon.Name, true));
} }
} }
else else
Sound.Play(DisabledTabClick); Sound.Play(DisabledTabClick);
} }
return true; return true;
} }
public void RefreshIcons() public void RefreshIcons()
{ {
Icons = new Dictionary<Rectangle, ProductionIcon>(); icons = new Dictionary<Rectangle, ProductionIcon>();
if (CurrentQueue == null) if (CurrentQueue == null)
return; return;
@@ -193,11 +193,11 @@ namespace OpenRA.Mods.Cnc.Widgets
Pos = new float2(rect.Location), Pos = new float2(rect.Location),
Queued = CurrentQueue.AllQueued().Where(a => a.Item == item.Name).ToList(), Queued = CurrentQueue.AllQueued().Where(a => a.Item == item.Name).ToList(),
}; };
Icons.Add(rect, pi); icons.Add(rect, pi);
i++; i++;
} }
eventBounds = Icons.Keys.Aggregate(Rectangle.Union); eventBounds = icons.Keys.Aggregate(Rectangle.Union);
} }
public override void Draw() public override void Draw()
@@ -214,11 +214,11 @@ namespace OpenRA.Mods.Cnc.Widgets
var buildableItems = CurrentQueue.BuildableItems().OrderBy(a => a.Traits.Get<BuildableInfo>().BuildPaletteOrder); var buildableItems = CurrentQueue.BuildableItems().OrderBy(a => a.Traits.Get<BuildableInfo>().BuildPaletteOrder);
// Background // Background
foreach (var rect in Icons.Keys) foreach (var rect in icons.Keys)
WidgetUtils.DrawPanel("panel-black", rect.InflateBy(1, 1, 1, 1)); WidgetUtils.DrawPanel("panel-black", rect.InflateBy(1, 1, 1, 1));
// Icons // Icons
foreach (var icon in Icons.Values) foreach (var icon in icons.Values)
{ {
WidgetUtils.DrawSHP(icon.Sprite, icon.Pos, worldRenderer); WidgetUtils.DrawSHP(icon.Sprite, icon.Pos, worldRenderer);
@@ -237,7 +237,7 @@ namespace OpenRA.Mods.Cnc.Widgets
} }
// Overlays // Overlays
foreach (var icon in Icons.Values) foreach (var icon in icons.Values)
{ {
var total = icon.Queued.Count; var total = icon.Queued.Count;
if (total > 0) if (total > 0)
@@ -267,7 +267,7 @@ namespace OpenRA.Mods.Cnc.Widgets
public override string GetCursor(int2 pos) public override string GetCursor(int2 pos)
{ {
var icon = Icons.Where(i => i.Key.Contains(pos)) var icon = icons.Where(i => i.Key.Contains(pos))
.Select(i => i.Value).FirstOrDefault(); .Select(i => i.Value).FirstOrDefault();
return icon != null ? base.GetCursor(pos) : null; return icon != null ? base.GetCursor(pos) : null;

View File

@@ -68,8 +68,8 @@ namespace OpenRA.Mods.Cnc.Widgets
public readonly int ArrowWidth = 20; public readonly int ArrowWidth = 20;
public Dictionary<string, ProductionTabGroup> Groups; public Dictionary<string, ProductionTabGroup> Groups;
int ContentWidth = 0; int contentWidth = 0;
float ListOffset = 0; float listOffset = 0;
bool leftPressed = false; bool leftPressed = false;
bool rightPressed = false; bool rightPressed = false;
Rectangle leftButtonRect; Rectangle leftButtonRect;
@@ -107,10 +107,14 @@ namespace OpenRA.Mods.Cnc.Widgets
public string QueueGroup public string QueueGroup
{ {
get { return queueGroup; } get
{
return queueGroup;
}
set set
{ {
ListOffset = 0; listOffset = 0;
queueGroup = value; queueGroup = value;
SelectNextTab(false); SelectNextTab(false);
} }
@@ -118,7 +122,11 @@ namespace OpenRA.Mods.Cnc.Widgets
public ProductionQueue CurrentQueue public ProductionQueue CurrentQueue
{ {
get { return paletteWidget.Value.CurrentQueue; } get
{
return paletteWidget.Value.CurrentQueue;
}
set set
{ {
paletteWidget.Value.CurrentQueue = value; paletteWidget.Value.CurrentQueue = value;
@@ -134,9 +142,9 @@ namespace OpenRA.Mods.Cnc.Widgets
leftButtonRect = new Rectangle(rb.X, rb.Y, ArrowWidth, rb.Height); leftButtonRect = new Rectangle(rb.X, rb.Y, ArrowWidth, rb.Height);
rightButtonRect = new Rectangle(rb.Right - ArrowWidth, rb.Y, ArrowWidth, rb.Height); rightButtonRect = new Rectangle(rb.Right - ArrowWidth, rb.Y, ArrowWidth, rb.Height);
var leftDisabled = ListOffset >= 0; var leftDisabled = listOffset >= 0;
var leftHover = Ui.MouseOverWidget == this && leftButtonRect.Contains(Viewport.LastMousePos); var leftHover = Ui.MouseOverWidget == this && leftButtonRect.Contains(Viewport.LastMousePos);
var rightDisabled = ListOffset <= Bounds.Width - rightButtonRect.Width - leftButtonRect.Width - ContentWidth; var rightDisabled = listOffset <= Bounds.Width - rightButtonRect.Width - leftButtonRect.Width - contentWidth;
var rightHover = Ui.MouseOverWidget == this && rightButtonRect.Contains(Viewport.LastMousePos); var rightHover = Ui.MouseOverWidget == this && rightButtonRect.Contains(Viewport.LastMousePos);
WidgetUtils.DrawPanel("panel-black", rb); WidgetUtils.DrawPanel("panel-black", rb);
@@ -150,17 +158,17 @@ namespace OpenRA.Mods.Cnc.Widgets
// Draw tab buttons // Draw tab buttons
Game.Renderer.EnableScissor(leftButtonRect.Right, rb.Y + 1, rightButtonRect.Left - leftButtonRect.Right - 1, rb.Height); Game.Renderer.EnableScissor(leftButtonRect.Right, rb.Y + 1, rightButtonRect.Left - leftButtonRect.Right - 1, rb.Height);
var origin = new int2(leftButtonRect.Right - 1 + (int)ListOffset, leftButtonRect.Y); var origin = new int2(leftButtonRect.Right - 1 + (int)listOffset, leftButtonRect.Y);
SpriteFont font = Game.Renderer.Fonts["TinyBold"]; SpriteFont font = Game.Renderer.Fonts["TinyBold"];
ContentWidth = 0; contentWidth = 0;
foreach (var tab in Groups[queueGroup].Tabs) foreach (var tab in Groups[queueGroup].Tabs)
{ {
var rect = new Rectangle(origin.X + ContentWidth, origin.Y, TabWidth, rb.Height); var rect = new Rectangle(origin.X + contentWidth, origin.Y, TabWidth, rb.Height);
var hover = !leftHover && !rightHover && Ui.MouseOverWidget == this && rect.Contains(Viewport.LastMousePos); var hover = !leftHover && !rightHover && Ui.MouseOverWidget == this && rect.Contains(Viewport.LastMousePos);
var baseName = tab.Queue == CurrentQueue ? "button-highlighted" : "button"; var baseName = tab.Queue == CurrentQueue ? "button-highlighted" : "button";
ButtonWidget.DrawBackground(baseName, rect, false, false, hover, false); ButtonWidget.DrawBackground(baseName, rect, false, false, hover, false);
ContentWidth += TabWidth - 1; contentWidth += TabWidth - 1;
int2 textSize = font.Measure(tab.Name); int2 textSize = font.Measure(tab.Name);
int2 position = new int2(rect.X + (rect.Width - textSize.X) / 2, rect.Y + (rect.Height - textSize.Y) / 2); int2 position = new int2(rect.X + (rect.Width - textSize.X) / 2, rect.Y + (rect.Height - textSize.Y) / 2);
@@ -172,8 +180,8 @@ namespace OpenRA.Mods.Cnc.Widgets
void Scroll(int direction) void Scroll(int direction)
{ {
ListOffset += direction*ScrollVelocity; listOffset += direction * ScrollVelocity;
ListOffset = Math.Min(0,Math.Max(Bounds.Width - rightButtonRect.Width - leftButtonRect.Width - ContentWidth, ListOffset)); listOffset = Math.Min(0, Math.Max(Bounds.Width - rightButtonRect.Width - leftButtonRect.Width - contentWidth, listOffset));
} }
// Is added to world.ActorAdded by the SidebarLogic handler // Is added to world.ActorAdded by the SidebarLogic handler
@@ -242,8 +250,8 @@ namespace OpenRA.Mods.Cnc.Widgets
leftPressed = leftButtonRect.Contains(mi.Location); leftPressed = leftButtonRect.Contains(mi.Location);
rightPressed = rightButtonRect.Contains(mi.Location); rightPressed = rightButtonRect.Contains(mi.Location);
var leftDisabled = ListOffset >= 0; var leftDisabled = listOffset >= 0;
var rightDisabled = ListOffset <= Bounds.Width - rightButtonRect.Width - leftButtonRect.Width - ContentWidth; var rightDisabled = listOffset <= Bounds.Width - rightButtonRect.Width - leftButtonRect.Width - contentWidth;
if (leftPressed || rightPressed) if (leftPressed || rightPressed)
{ {
@@ -254,8 +262,8 @@ namespace OpenRA.Mods.Cnc.Widgets
} }
// Check production tabs // Check production tabs
var offsetloc = mi.Location - new int2(leftButtonRect.Right - 1 + (int)ListOffset, leftButtonRect.Y); var offsetloc = mi.Location - new int2(leftButtonRect.Right - 1 + (int)listOffset, leftButtonRect.Y);
if (offsetloc.X > 0 && offsetloc.X < ContentWidth) if (offsetloc.X > 0 && offsetloc.X < contentWidth)
{ {
CurrentQueue = Groups[queueGroup].Tabs[offsetloc.X / (TabWidth - 1)].Queue; CurrentQueue = Groups[queueGroup].Tabs[offsetloc.X / (TabWidth - 1)].Queue;
Sound.PlayNotification(null, "Sounds", "ClickSound", null); Sound.PlayNotification(null, "Sounds", "ClickSound", null);

View File

@@ -14,31 +14,33 @@ using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Widgets;
using OpenRA.Mods.RA; using OpenRA.Mods.RA;
using OpenRA.Widgets;
namespace OpenRA.Mods.Cnc.Widgets namespace OpenRA.Mods.Cnc.Widgets
{ {
public class SupportPowersWidget : Widget public class SupportPowersWidget : Widget
{ {
public int Spacing = 10;
public readonly string ReadyText = ""; public readonly string ReadyText = "";
public readonly string HoldText = ""; public readonly string HoldText = "";
Dictionary<string, Sprite> iconSprites;
Animation clock;
Dictionary<Rectangle, SupportPowerIcon> Icons = new Dictionary<Rectangle, SupportPowerIcon>();
public readonly string TooltipContainer; public readonly string TooltipContainer;
public readonly string TooltipTemplate = "SUPPORT_POWER_TOOLTIP"; public readonly string TooltipTemplate = "SUPPORT_POWER_TOOLTIP";
public int Spacing = 10;
readonly WorldRenderer worldRenderer;
readonly SupportPowerManager spm;
Dictionary<string, Sprite> iconSprites;
Animation clock;
Dictionary<Rectangle, SupportPowerIcon> icons = new Dictionary<Rectangle, SupportPowerIcon>();
public SupportPowerInstance TooltipPower { get; private set; } public SupportPowerInstance TooltipPower { get; private set; }
Lazy<TooltipContainerWidget> tooltipContainer; Lazy<TooltipContainerWidget> tooltipContainer;
Rectangle eventBounds; Rectangle eventBounds;
public override Rectangle EventBounds { get { return eventBounds; } } public override Rectangle EventBounds { get { return eventBounds; } }
readonly WorldRenderer worldRenderer;
readonly SupportPowerManager spm;
SpriteFont overlayFont; SpriteFont overlayFont;
float2 holdOffset, readyOffset, timeOffset; float2 holdOffset, readyOffset, timeOffset;
@@ -68,7 +70,7 @@ namespace OpenRA.Mods.Cnc.Widgets
public void RefreshIcons() public void RefreshIcons()
{ {
Icons = new Dictionary<Rectangle, SupportPowerIcon>(); icons = new Dictionary<Rectangle, SupportPowerIcon>();
var powers = spm.Powers.Values.Where(p => !p.Disabled); var powers = spm.Powers.Values.Where(p => !p.Disabled);
var i = 0; var i = 0;
@@ -83,11 +85,11 @@ namespace OpenRA.Mods.Cnc.Widgets
Sprite = iconSprites[p.Info.Image] Sprite = iconSprites[p.Info.Image]
}; };
Icons.Add(rect, power); icons.Add(rect, power);
i++; i++;
} }
eventBounds = (Icons.Count == 0) ? Rectangle.Empty : Icons.Keys.Aggregate(Rectangle.Union); eventBounds = (icons.Count == 0) ? Rectangle.Empty : icons.Keys.Aggregate(Rectangle.Union);
} }
public override void Draw() public override void Draw()
@@ -98,11 +100,11 @@ namespace OpenRA.Mods.Cnc.Widgets
timeOffset = new float2(32, 24) - overlayFont.Measure(WidgetUtils.FormatTime(0)) / 2; timeOffset = new float2(32, 24) - overlayFont.Measure(WidgetUtils.FormatTime(0)) / 2;
// Background // Background
foreach (var rect in Icons.Keys) foreach (var rect in icons.Keys)
WidgetUtils.DrawPanel("panel-black", rect.InflateBy(1, 1, 1, 1)); WidgetUtils.DrawPanel("panel-black", rect.InflateBy(1, 1, 1, 1));
// Icons // Icons
foreach (var p in Icons.Values) foreach (var p in icons.Values)
{ {
WidgetUtils.DrawSHP(p.Sprite, p.Pos, worldRenderer); WidgetUtils.DrawSHP(p.Sprite, p.Pos, worldRenderer);
@@ -115,7 +117,7 @@ namespace OpenRA.Mods.Cnc.Widgets
} }
// Overlay // Overlay
foreach (var p in Icons.Values) foreach (var p in icons.Values)
{ {
if (p.Power.Ready) if (p.Power.Ready)
overlayFont.DrawTextWithContrast(ReadyText, overlayFont.DrawTextWithContrast(ReadyText,
@@ -155,7 +157,7 @@ namespace OpenRA.Mods.Cnc.Widgets
{ {
if (mi.Event == MouseInputEvent.Move) if (mi.Event == MouseInputEvent.Move)
{ {
var icon = Icons.Where(i => i.Key.Contains(mi.Location)) var icon = icons.Where(i => i.Key.Contains(mi.Location))
.Select(i => i.Value).FirstOrDefault(); .Select(i => i.Value).FirstOrDefault();
TooltipPower = (icon != null) ? icon.Power : null; TooltipPower = (icon != null) ? icon.Power : null;
return false; return false;
@@ -164,7 +166,7 @@ namespace OpenRA.Mods.Cnc.Widgets
if (mi.Event != MouseInputEvent.Down) if (mi.Event != MouseInputEvent.Down)
return false; return false;
var clicked = Icons.Where(i => i.Key.Contains(mi.Location)) var clicked = icons.Where(i => i.Key.Contains(mi.Location))
.Select(i => i.Value).FirstOrDefault(); .Select(i => i.Value).FirstOrDefault();
if (clicked != null) if (clicked != null)

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Cnc
{ {
Cargo cargo; Cargo cargo;
IFacing facing; IFacing facing;
WithCargoInfo Info; WithCargoInfo cargoInfo;
WVec[] positions; WVec[] positions;
IBodyOrientation body; IBodyOrientation body;
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Cnc
{ {
cargo = self.Trait<Cargo>(); cargo = self.Trait<Cargo>();
facing = self.TraitOrDefault<IFacing>(); facing = self.TraitOrDefault<IFacing>();
Info = info; cargoInfo = info;
body = self.Trait<IBodyOrientation>(); body = self.Trait<IBodyOrientation>();
@@ -66,7 +66,7 @@ namespace OpenRA.Mods.Cnc
cargoFacing.Facing = facing.Facing; cargoFacing.Facing = facing.Facing;
var cargoPassenger = c.Trait<Passenger>(); var cargoPassenger = c.Trait<Passenger>();
if (Info.DisplayTypes.Contains(cargoPassenger.info.CargoType)) if (cargoInfo.DisplayTypes.Contains(cargoPassenger.info.CargoType))
{ {
var offset = pos - c.CenterPosition + body.LocalToWorld(positions[i++ % positions.Length].Rotate(bodyOrientation)); var offset = pos - c.CenterPosition + body.LocalToWorld(positions[i++ % positions.Length].Rotate(bodyOrientation));
foreach (var cr in c.Render(wr)) foreach (var cr in c.Render(wr))

View File

@@ -21,10 +21,10 @@ namespace OpenRA.Mods.RA
class CaptureNotification : INotifyCapture class CaptureNotification : INotifyCapture
{ {
CaptureNotificationInfo Info; CaptureNotificationInfo captureInfo;
public CaptureNotification(CaptureNotificationInfo info) public CaptureNotification(CaptureNotificationInfo info)
{ {
Info = info; captureInfo = info;
} }
public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner) public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner)
@@ -32,8 +32,7 @@ namespace OpenRA.Mods.RA
if (captor.World.LocalPlayer != captor.Owner) if (captor.World.LocalPlayer != captor.Owner)
return; return;
Sound.PlayNotification(captor.World.LocalPlayer, "Speech", Info.Notification, newOwner.Country.Race); Sound.PlayNotification(captor.World.LocalPlayer, "Speech", captureInfo.Notification, newOwner.Country.Race);
} }
} }
} }

View File

@@ -9,8 +9,8 @@
#endregion #endregion
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Drawing; using System.Drawing;
using System.IO;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Network; using OpenRA.Network;
@@ -21,27 +21,28 @@ namespace OpenRA.Mods.D2k
{ {
public class D2kLoadScreen : ILoadScreen public class D2kLoadScreen : ILoadScreen
{ {
Dictionary<string, string> Info; public static string[] Comments = new[] { "Filling Crates...", "Breeding Sandworms..." };
static string[] Comments = new[] {"Filling Crates...", "Breeding Sandworms..."}; public Dictionary<string, string> Info;
Stopwatch lastLoadScreen = new Stopwatch(); Stopwatch lastLoadScreen = new Stopwatch();
Rectangle StripeRect; Rectangle stripeRect;
Sprite Stripe, Logo; Sprite stripe, Logo;
float2 LogoPos; float2 logoPos;
Renderer r; Renderer r;
public void Init(Dictionary<string, string> info) public void Init(Dictionary<string, string> info)
{ {
Info = info; Info = info;
// Avoid standard loading mechanisms so we // Avoid standard loading mechanisms so we
// can display loadscreen as early as possible // can display loadscreen as early as possible
r = Game.Renderer; r = Game.Renderer;
if (r == null) return; if (r == null) return;
var s = new Sheet("mods/d2k/uibits/loadscreen.png"); var s = new Sheet("mods/d2k/uibits/loadscreen.png");
Logo = new Sprite(s, new Rectangle(0, 0, 256, 256), TextureChannel.Alpha); Logo = new Sprite(s, new Rectangle(0, 0, 256, 256), TextureChannel.Alpha);
Stripe = new Sprite(s, new Rectangle(256,0,256,256), TextureChannel.Alpha); stripe = new Sprite(s, new Rectangle(256, 0, 256, 256), TextureChannel.Alpha);
StripeRect = new Rectangle(0, Renderer.Resolution.Height/2 - 128, Renderer.Resolution.Width, 256); stripeRect = new Rectangle(0, Renderer.Resolution.Height / 2 - 128, Renderer.Resolution.Width, 256);
LogoPos = new float2(Renderer.Resolution.Width/2 - 128, Renderer.Resolution.Height/2 - 128); logoPos = new float2(Renderer.Resolution.Width / 2 - 128, Renderer.Resolution.Height / 2 - 128);
} }
public void Display() public void Display()
@@ -61,8 +62,8 @@ namespace OpenRA.Mods.D2k
var textSize = r.Fonts["Bold"].Measure(text); var textSize = r.Fonts["Bold"].Measure(text);
r.BeginFrame(float2.Zero, 1f); r.BeginFrame(float2.Zero, 1f);
WidgetUtils.FillRectWithSprite(StripeRect, Stripe); WidgetUtils.FillRectWithSprite(stripeRect, stripe);
r.RgbaSpriteRenderer.DrawSprite(Logo, LogoPos); r.RgbaSpriteRenderer.DrawSprite(Logo, logoPos);
r.Fonts["Bold"].DrawText(text, new float2(Renderer.Resolution.Width - textSize.X - 20, Renderer.Resolution.Height - textSize.Y - 20), Color.White); r.Fonts["Bold"].DrawText(text, new float2(Renderer.Resolution.Width - textSize.X - 20, Renderer.Resolution.Height - textSize.Y - 20), Color.White);
r.EndFrame(new NullInputHandler()); r.EndFrame(new NullInputHandler());
} }

View File

@@ -77,7 +77,6 @@
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="D2kLoadScreen.cs" /> <Compile Include="D2kLoadScreen.cs" />
<Compile Include="Widgets\Logic\D2kInstallLogic.cs" /> <Compile Include="Widgets\Logic\D2kInstallLogic.cs" />
<Compile Include="Widgets\Logic\D2kExtractGameFilesLogic.cs" /> <Compile Include="Widgets\Logic\D2kExtractGameFilesLogic.cs" />

View File

@@ -1,39 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2012 The OpenRA Developers (see AUTHORS)
* 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
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle("OpenRA.Mods.D2k")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OpenRA.Mods.D2k")]
[assembly: AssemblyCopyright("Copyright © 2012")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]

View File

@@ -302,6 +302,16 @@
<BooleanProperty Name="Enabled">False</BooleanProperty> <BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings> </RuleSettings>
</Rule> </Rule>
<Rule Name="ParameterMustFollowComma">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="SplitParametersMustStartOnLineAfterDeclaration">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules> </Rules>
<AnalyzerSettings /> <AnalyzerSettings />
</Analyzer> </Analyzer>

File diff suppressed because it is too large Load Diff

View File

@@ -14,8 +14,8 @@ using System.Linq;
using System.Threading; using System.Threading;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.FileFormats.Graphics; using OpenRA.FileFormats.Graphics;
using OpenRA.Widgets;
using OpenRA.Utility; using OpenRA.Utility;
using OpenRA.Widgets;
namespace OpenRA.Mods.D2k.Widgets.Logic namespace OpenRA.Mods.D2k.Widgets.Logic
{ {

View File

@@ -43,7 +43,6 @@ namespace OpenRA.Mods.D2k.Widgets.Logic
Ui.OpenWindow("MODS_PANEL", new WidgetArgs() Ui.OpenWindow("MODS_PANEL", new WidgetArgs()
{ {
{ "onExit", () => { } }, { "onExit", () => { } },
// Close this panel
{ "onSwitch", Ui.CloseWindow }, { "onSwitch", Ui.CloseWindow },
}); });
}; };

View File

@@ -303,7 +303,6 @@
<Compile Include="PrimaryBuilding.cs" /> <Compile Include="PrimaryBuilding.cs" />
<Compile Include="Production.cs" /> <Compile Include="Production.cs" />
<Compile Include="ProductionBar.cs" /> <Compile Include="ProductionBar.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ProvidesRadar.cs" /> <Compile Include="ProvidesRadar.cs" />
<Compile Include="ProximityCaptor.cs" /> <Compile Include="ProximityCaptor.cs" />
<Compile Include="ProximityCapturable.cs" /> <Compile Include="ProximityCapturable.cs" />

View File

@@ -1,46 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* 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
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OpenRA.Mods.RA")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OpenRA.Mods.RA")]
[assembly: AssemblyCopyright("Copyright © 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 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
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("23828b43-3536-4681-bc2f-2eb2e0972354")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -302,6 +302,16 @@
<BooleanProperty Name="Enabled">False</BooleanProperty> <BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings> </RuleSettings>
</Rule> </Rule>
<Rule Name="ParameterMustFollowComma">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="SplitParametersMustStartOnLineAfterDeclaration">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules> </Rules>
<AnalyzerSettings /> <AnalyzerSettings />
</Analyzer> </Analyzer>

View File

@@ -35,9 +35,7 @@
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
</ItemGroup> <Reference Include="System.Drawing" />
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup> <ItemGroup>
@@ -54,4 +52,7 @@
<Name>OpenRA.FileFormats</Name> <Name>OpenRA.FileFormats</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Compile Include="TSLoadScreen.cs" />
</ItemGroup>
</Project> </Project>

View File

@@ -1,37 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
* 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
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle("OpenRA.Mods.TS")]
[assembly: AssemblyDescription("Tiberian Sun Mod")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OpenRA.Mods.TS")]
[assembly: AssemblyCopyright("Copyright © 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion("1.0.*")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]

View File

@@ -302,6 +302,16 @@
<BooleanProperty Name="Enabled">False</BooleanProperty> <BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings> </RuleSettings>
</Rule> </Rule>
<Rule Name="ParameterMustFollowComma">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="SplitParametersMustStartOnLineAfterDeclaration">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules> </Rules>
<AnalyzerSettings /> <AnalyzerSettings />
</Analyzer> </Analyzer>

View File

@@ -0,0 +1,92 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* 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
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using System.Collections.Generic;
using System.Drawing;
using OpenRA.FileFormats;
using OpenRA.Graphics;
using OpenRA.Network;
using OpenRA.Support;
using OpenRA.Widgets;
namespace OpenRA.Mods.TS
{
public class TSLoadScreen : ILoadScreen
{
Dictionary<string, string> Info;
static string[] Comments = new[] { "Updating EVA installation..." };
Stopwatch lastLoadScreen = new Stopwatch();
Rectangle StripeRect;
Sprite Stripe, Logo;
float2 LogoPos;
Renderer r;
public void Init(Dictionary<string, string> info)
{
Info = info;
// Avoid standard loading mechanisms so we
// can display loadscreen as early as possible
r = Game.Renderer;
if (r == null) return;
var s = new Sheet(Info["LoadScreenImage"]);
Logo = new Sprite(s, new Rectangle(0,0,256,256), TextureChannel.Alpha);
Stripe = new Sprite(s, new Rectangle(256,0,256,256), TextureChannel.Alpha);
StripeRect = new Rectangle(0, Renderer.Resolution.Height/2 - 128, Renderer.Resolution.Width, 256);
LogoPos = new float2(Renderer.Resolution.Width/2 - 128, Renderer.Resolution.Height/2 - 128);
}
public void Display()
{
if (r == null)
return;
// Update text at most every 0.5 seconds
if (lastLoadScreen.ElapsedTime() < 0.5)
return;
if (r.Fonts == null)
return;
lastLoadScreen.Reset();
var text = Comments.Random(Game.CosmeticRandom);
var textSize = r.Fonts["Bold"].Measure(text);
r.BeginFrame(float2.Zero, 1f);
WidgetUtils.FillRectWithSprite(StripeRect, Stripe);
r.RgbaSpriteRenderer.DrawSprite(Logo, LogoPos);
r.Fonts["Bold"].DrawText(text, new float2(Renderer.Resolution.Width - textSize.X - 20, Renderer.Resolution.Height - textSize.Y - 20), Color.White);
r.EndFrame( new NullInputHandler() );
}
public void StartGame()
{
TestAndContinue();
}
void TestAndContinue()
{
Ui.ResetAll();
if (!FileSystem.Exists(Info["TestFile"]))
{
var args = new WidgetArgs()
{
{ "continueLoading", () => TestAndContinue() },
{ "installData", Info }
};
Ui.OpenWindow(Info["InstallerMenuWidget"], args);
}
else
Game.LoadShellMap();
}
}
}

View File

@@ -77,7 +77,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="GraphicsDevice.cs" /> <Compile Include="GraphicsDevice.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Shader.cs" /> <Compile Include="Shader.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -1,46 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* 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
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OpenRA.Renderer.Cg")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("OpenRA.Renderer.Cg")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 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
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("5531344c-b25d-4641-bc3c-fe035cc777bd")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -302,6 +302,16 @@
<BooleanProperty Name="Enabled">False</BooleanProperty> <BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings> </RuleSettings>
</Rule> </Rule>
<Rule Name="ParameterMustFollowComma">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="SplitParametersMustStartOnLineAfterDeclaration">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules> </Rules>
<AnalyzerSettings /> <AnalyzerSettings />
</Analyzer> </Analyzer>

View File

@@ -75,7 +75,6 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="GraphicsDevice.cs" /> <Compile Include="GraphicsDevice.cs" />
<Compile Include="Shader.cs" /> <Compile Include="Shader.cs" />
</ItemGroup> </ItemGroup>

View File

@@ -1,27 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle("OpenRA.Renderer.Gl")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion("1.0.*")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]

View File

@@ -302,6 +302,16 @@
<BooleanProperty Name="Enabled">False</BooleanProperty> <BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings> </RuleSettings>
</Rule> </Rule>
<Rule Name="ParameterMustFollowComma">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="SplitParametersMustStartOnLineAfterDeclaration">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules> </Rules>
<AnalyzerSettings /> <AnalyzerSettings />
</Analyzer> </Analyzer>

View File

@@ -69,7 +69,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="NullGraphicsDevice.cs" /> <Compile Include="NullGraphicsDevice.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj"> <ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">

View File

@@ -1,46 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* 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
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OpenRA.Renderer.Null")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OpenRA.Renderer.Null")]
[assembly: AssemblyCopyright("Copyright © 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 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
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("c7dff231-d517-400e-bc98-ff10c99fd660")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -302,6 +302,16 @@
<BooleanProperty Name="Enabled">False</BooleanProperty> <BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings> </RuleSettings>
</Rule> </Rule>
<Rule Name="ParameterMustFollowComma">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="SplitParametersMustStartOnLineAfterDeclaration">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules> </Rules>
<AnalyzerSettings /> <AnalyzerSettings />
</Analyzer> </Analyzer>

View File

@@ -302,6 +302,16 @@
<BooleanProperty Name="Enabled">False</BooleanProperty> <BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings> </RuleSettings>
</Rule> </Rule>
<Rule Name="ParameterMustFollowComma">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="SplitParametersMustStartOnLineAfterDeclaration">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules> </Rules>
<AnalyzerSettings /> <AnalyzerSettings />
</Analyzer> </Analyzer>

View File

@@ -1,6 +1,6 @@
namespace OpenRA.TilesetBuilder namespace OpenRA.TilesetBuilder
{ {
partial class frmBuilder partial class FormBuilder
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@@ -17,6 +17,7 @@
{ {
components.Dispose(); components.Dispose();
} }
base.Dispose(disposing); base.Dispose(disposing);
} }
@@ -29,11 +30,11 @@
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmBuilder)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormBuilder));
this.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer(); this.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer();
this.panel1 = new System.Windows.Forms.Panel(); this.panel1 = new System.Windows.Forms.Panel();
this.imageList = new System.Windows.Forms.ImageList(this.components); this.ImageList = new System.Windows.Forms.ImageList(this.components);
this.tsTerrainTypes = new System.Windows.Forms.ToolStrip(); this.terrainTypes = new System.Windows.Forms.ToolStrip();
this.toolStripLabel3 = new System.Windows.Forms.ToolStripLabel(); this.toolStripLabel3 = new System.Windows.Forms.ToolStripLabel();
this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripLabel4 = new System.Windows.Forms.ToolStripLabel(); this.toolStripLabel4 = new System.Windows.Forms.ToolStripLabel();
@@ -60,7 +61,7 @@
this.toolStripContainer1.TopToolStripPanel.SuspendLayout(); this.toolStripContainer1.TopToolStripPanel.SuspendLayout();
this.toolStripContainer1.SuspendLayout(); this.toolStripContainer1.SuspendLayout();
this.panel1.SuspendLayout(); this.panel1.SuspendLayout();
this.tsTerrainTypes.SuspendLayout(); this.terrainTypes.SuspendLayout();
this.toolStrip1.SuspendLayout(); this.toolStrip1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
@@ -70,7 +71,7 @@
// toolStripContainer1.ContentPanel // toolStripContainer1.ContentPanel
// //
this.toolStripContainer1.ContentPanel.Controls.Add(this.panel1); this.toolStripContainer1.ContentPanel.Controls.Add(this.panel1);
this.toolStripContainer1.ContentPanel.Controls.Add(this.tsTerrainTypes); this.toolStripContainer1.ContentPanel.Controls.Add(this.terrainTypes);
this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(908, 571); this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(908, 571);
this.toolStripContainer1.Dock = System.Windows.Forms.DockStyle.Fill; this.toolStripContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.toolStripContainer1.Location = new System.Drawing.Point(0, 0); this.toolStripContainer1.Location = new System.Drawing.Point(0, 0);
@@ -83,7 +84,6 @@
// //
this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.toolStrip1); this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.toolStrip1);
this.toolStripContainer1.TopToolStripPanel.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional; this.toolStripContainer1.TopToolStripPanel.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional;
this.toolStripContainer1.TopToolStripPanel.Click += new System.EventHandler(this.toolStripContainer1_TopToolStripPanel_Click);
// //
// panel1 // panel1
// //
@@ -98,24 +98,24 @@
// //
// imageList // imageList
// //
this.imageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList.ImageStream"))); this.ImageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList.ImageStream")));
this.imageList.TransparentColor = System.Drawing.Color.Transparent; this.ImageList.TransparentColor = System.Drawing.Color.Transparent;
this.imageList.Images.SetKeyName(0, "clear.png"); this.ImageList.Images.SetKeyName(0, "clear.png");
this.imageList.Images.SetKeyName(1, "water.png"); this.ImageList.Images.SetKeyName(1, "water.png");
this.imageList.Images.SetKeyName(2, "road.png"); this.ImageList.Images.SetKeyName(2, "road.png");
this.imageList.Images.SetKeyName(3, "rock.png"); this.ImageList.Images.SetKeyName(3, "rock.png");
this.imageList.Images.SetKeyName(4, "river.png"); this.ImageList.Images.SetKeyName(4, "river.png");
this.imageList.Images.SetKeyName(5, "rough.png"); this.ImageList.Images.SetKeyName(5, "rough.png");
this.imageList.Images.SetKeyName(6, "wall.png"); this.ImageList.Images.SetKeyName(6, "wall.png");
this.imageList.Images.SetKeyName(7, "beach.png"); this.ImageList.Images.SetKeyName(7, "beach.png");
this.imageList.Images.SetKeyName(8, "tree.png"); this.ImageList.Images.SetKeyName(8, "tree.png");
this.imageList.Images.SetKeyName(9, "tiberium.png"); this.ImageList.Images.SetKeyName(9, "tiberium.png");
// //
// tsTerrainTypes // tsTerrainTypes
// //
this.tsTerrainTypes.AutoSize = false; this.terrainTypes.AutoSize = false;
this.tsTerrainTypes.Dock = System.Windows.Forms.DockStyle.Right; this.terrainTypes.Dock = System.Windows.Forms.DockStyle.Right;
this.tsTerrainTypes.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.terrainTypes.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripLabel3, this.toolStripLabel3,
this.toolStripSeparator3, this.toolStripSeparator3,
this.toolStripLabel4, this.toolStripLabel4,
@@ -130,12 +130,12 @@
this.toolStripLabel2, this.toolStripLabel2,
this.toolStripSeparator4, this.toolStripSeparator4,
this.toolStripButton1}); this.toolStripButton1});
this.tsTerrainTypes.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.VerticalStackWithOverflow; this.terrainTypes.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.VerticalStackWithOverflow;
this.tsTerrainTypes.Location = new System.Drawing.Point(788, 0); this.terrainTypes.Location = new System.Drawing.Point(788, 0);
this.tsTerrainTypes.Name = "tsTerrainTypes"; this.terrainTypes.Name = "tsTerrainTypes";
this.tsTerrainTypes.Size = new System.Drawing.Size(120, 571); this.terrainTypes.Size = new System.Drawing.Size(120, 571);
this.tsTerrainTypes.TabIndex = 1; this.terrainTypes.TabIndex = 1;
this.tsTerrainTypes.Text = "toolStrip3"; this.terrainTypes.Text = "toolStrip3";
// //
// toolStripLabel3 // toolStripLabel3
// //
@@ -161,7 +161,7 @@
this.txtTilesetName.Name = "txtTilesetName"; this.txtTilesetName.Name = "txtTilesetName";
this.txtTilesetName.Size = new System.Drawing.Size(116, 21); this.txtTilesetName.Size = new System.Drawing.Size(116, 21);
this.txtTilesetName.Text = "Temperat"; this.txtTilesetName.Text = "Temperat";
this.txtTilesetName.TextChanged += new System.EventHandler(this.txtTilesetName_TextChanged); this.txtTilesetName.TextChanged += new System.EventHandler(this.TilesetNameChanged);
// //
// toolStripLabel5 // toolStripLabel5
// //
@@ -254,7 +254,7 @@
this.toolStripButton15.Size = new System.Drawing.Size(48, 22); this.toolStripButton15.Size = new System.Drawing.Size(48, 22);
this.toolStripButton15.Text = "New"; this.toolStripButton15.Text = "New";
this.toolStripButton15.ToolTipText = "Create new tileset"; this.toolStripButton15.ToolTipText = "Create new tileset";
this.toolStripButton15.Click += new System.EventHandler(this.toolStripButton15_Click); this.toolStripButton15.Click += new System.EventHandler(this.NewTilesetButton);
// //
// toolStripButton2 // toolStripButton2
// //
@@ -305,7 +305,7 @@
// surface1 // surface1
// //
this.surface1.BackColor = System.Drawing.Color.Black; this.surface1.BackColor = System.Drawing.Color.Black;
this.surface1.ImagesList = this.imageList; this.surface1.ImagesList = this.ImageList;
this.surface1.Location = new System.Drawing.Point(0, 0); this.surface1.Location = new System.Drawing.Point(0, 0);
this.surface1.Name = "surface1"; this.surface1.Name = "surface1";
this.surface1.ShowTerrainTypes = this.toolStripButton3.Checked; this.surface1.ShowTerrainTypes = this.toolStripButton3.Checked;
@@ -328,8 +328,8 @@
this.toolStripContainer1.ResumeLayout(false); this.toolStripContainer1.ResumeLayout(false);
this.toolStripContainer1.PerformLayout(); this.toolStripContainer1.PerformLayout();
this.panel1.ResumeLayout(false); this.panel1.ResumeLayout(false);
this.tsTerrainTypes.ResumeLayout(false); this.terrainTypes.ResumeLayout(false);
this.tsTerrainTypes.PerformLayout(); this.terrainTypes.PerformLayout();
this.toolStrip1.ResumeLayout(false); this.toolStrip1.ResumeLayout(false);
this.toolStrip1.PerformLayout(); this.toolStrip1.PerformLayout();
this.ResumeLayout(false); this.ResumeLayout(false);
@@ -345,8 +345,8 @@
private System.Windows.Forms.ToolStripButton toolStripButton14; private System.Windows.Forms.ToolStripButton toolStripButton14;
private System.Windows.Forms.ToolStripButton toolStripButton15; private System.Windows.Forms.ToolStripButton toolStripButton15;
private System.Windows.Forms.ToolStripButton toolStripButton16; private System.Windows.Forms.ToolStripButton toolStripButton16;
public System.Windows.Forms.ImageList imageList; public System.Windows.Forms.ImageList ImageList;
private System.Windows.Forms.ToolStrip tsTerrainTypes; private System.Windows.Forms.ToolStrip terrainTypes;
private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Panel panel1;
private Surface surface1; private Surface surface1;
private System.Windows.Forms.ToolStripLabel toolStripLabel2; private System.Windows.Forms.ToolStripLabel toolStripLabel2;
@@ -365,4 +365,3 @@
private System.Windows.Forms.ToolStripTextBox txtPal; private System.Windows.Forms.ToolStripTextBox txtPal;
} }
} }

View File

@@ -14,19 +14,19 @@ using System.Drawing;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms; using System.Windows.Forms;
using System.Xml; using System.Xml;
using System.Runtime.InteropServices;
using OpenRA.FileFormats; using OpenRA.FileFormats;
namespace OpenRA.TilesetBuilder namespace OpenRA.TilesetBuilder
{ {
public partial class frmBuilder : Form public partial class FormBuilder : Form
{ {
string srcfile; string srcfile;
int size; int size;
public TerrainTypeInfo[] TerrainType; public TerrainTypeInfo[] TerrainType;
public Palette tpal; public Palette TerrainPalette;
public bool PaletteFromImage = true; public bool PaletteFromImage = true;
public string PaletteFile = ""; public string PaletteFile = "";
public string ImageFile = ""; public string ImageFile = "";
@@ -40,13 +40,13 @@ namespace OpenRA.TilesetBuilder
public void CreateNewTileset() public void CreateNewTileset()
{ {
this.Show(); this.Show();
using (var fNew = new frmNew { }) using (var formNew = new FormNew { })
if (DialogResult.OK == fNew.ShowDialog()) if (DialogResult.OK == formNew.ShowDialog())
{ {
PaletteFromImage = fNew.PaletteFromImage; PaletteFromImage = formNew.PaletteFromImage;
PaletteFile = fNew.PaletteFile; PaletteFile = formNew.PaletteFile;
ImageFile = fNew.ImageFile; ImageFile = formNew.ImageFile;
TileSize = fNew.TileSize; TileSize = formNew.TileSize;
srcfile = ImageFile; srcfile = ImageFile;
this.size = TileSize; this.size = TileSize;
@@ -56,12 +56,12 @@ namespace OpenRA.TilesetBuilder
Bitmap rbitmap = fbitmap.Clone(new Rectangle(0, 0, fbitmap.Width, fbitmap.Height), Bitmap rbitmap = fbitmap.Clone(new Rectangle(0, 0, fbitmap.Width, fbitmap.Height),
fbitmap.PixelFormat); fbitmap.PixelFormat);
int[] ShadowIndex = { }; int[] shadowIndex = { };
if (!PaletteFromImage) if (!PaletteFromImage)
{ {
tpal = Palette.Load(PaletteFile, ShadowIndex); TerrainPalette = Palette.Load(PaletteFile, shadowIndex);
rbitmap.Palette = tpal.AsSystemPalette(); rbitmap.Palette = TerrainPalette.AsSystemPalette();
} }
surface1.Image = (Bitmap)rbitmap; surface1.Image = (Bitmap)rbitmap;
@@ -75,18 +75,18 @@ namespace OpenRA.TilesetBuilder
} }
} }
public frmBuilder(string src, string tsize, bool AutoExport, string OutputDir) public FormBuilder(string src, string tsize, bool autoExport, string outputDir)
{ {
InitializeComponent(); InitializeComponent();
Dictionary<string, TerrainTypeInfo> DefTerrain = new Dictionary<string, TerrainTypeInfo>(); Dictionary<string, TerrainTypeInfo> terrainDefinition = new Dictionary<string, TerrainTypeInfo>();
int size = int.Parse(tsize); int size = int.Parse(tsize);
var yaml = MiniYaml.DictFromFile("OpenRA.TilesetBuilder/defaults.yaml"); var yaml = MiniYaml.DictFromFile("OpenRA.TilesetBuilder/defaults.yaml");
DefTerrain = yaml["Terrain"].NodesDict.Values.Select(y => new TerrainTypeInfo(y)).ToDictionary(t => t.Type); terrainDefinition = yaml["Terrain"].NodesDict.Values.Select(y => new TerrainTypeInfo(y)).ToDictionary(t => t.Type);
int i = 0; int i = 0;
surface1.icon = new Bitmap[DefTerrain.Keys.Count]; surface1.Icon = new Bitmap[terrainDefinition.Keys.Count];
TerrainType = new TerrainTypeInfo[DefTerrain.Keys.Count]; TerrainType = new TerrainTypeInfo[terrainDefinition.Keys.Count];
var title = this.Text; var title = this.Text;
surface1.UpdateMouseTilePosition += (x, y, tileNr) => surface1.UpdateMouseTilePosition += (x, y, tileNr) =>
@@ -95,29 +95,30 @@ namespace OpenRA.TilesetBuilder
}; };
surface1.Enabled = false; surface1.Enabled = false;
foreach (var deftype in DefTerrain) foreach (var deftype in terrainDefinition)
{ {
Bitmap icon = new Bitmap(16, 16); var icon = new Bitmap(16, 16);
int x, y;
// Loop through the images pixels to reset color. // Loop through the images pixels to reset color.
for (x = 0; x < icon.Width; x++) for (var x = 0; x < icon.Width; x++)
{ {
for (y = 0; y < icon.Height; y++) for (var y = 0; y < icon.Height; y++)
{ {
Color newColor = deftype.Value.Color; Color newColor = deftype.Value.Color;
icon.SetPixel(x, y, newColor); icon.SetPixel(x, y, newColor);
} }
} }
surface1.icon[i] = icon;
surface1.Icon[i] = icon;
TerrainType[i] = deftype.Value; TerrainType[i] = deftype.Value;
ToolStripButton TerrainTypeButton = new ToolStripButton(deftype.Key, icon, TerrainTypeSelectorClicked); var terrainTypeButton = new ToolStripButton(deftype.Key, icon, TerrainTypeSelectorClicked);
TerrainTypeButton.ToolTipText = deftype.Key; terrainTypeButton.ToolTipText = deftype.Key;
TerrainTypeButton.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; terrainTypeButton.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
TerrainTypeButton.Tag = i.ToString(); terrainTypeButton.Tag = i.ToString();
TerrainTypeButton.ImageAlign = ContentAlignment.MiddleLeft; terrainTypeButton.ImageAlign = ContentAlignment.MiddleLeft;
i++; i++;
tsTerrainTypes.Items.Add(TerrainTypeButton); terrainTypes.Items.Add(terrainTypeButton);
} }
if (src.Length > 0) if (src.Length > 0)
@@ -139,9 +140,9 @@ namespace OpenRA.TilesetBuilder
CreateNewTileset(); CreateNewTileset();
} }
if (AutoExport) if (autoExport)
{ {
Export(OutputDir); Export(outputDir);
Application.Exit(); Application.Exit();
} }
} }
@@ -254,15 +255,15 @@ namespace OpenRA.TilesetBuilder
string ExportTemplate(Template t, int n, string suffix, string dir) string ExportTemplate(Template t, int n, string suffix, string dir)
{ {
var TileSize = size; var tileSize = size;
var filename = Path.Combine(dir, "{0}{1:00}{2}".F(txtTilesetName.Text, n, suffix)); var filename = Path.Combine(dir, "{0}{1:00}{2}".F(txtTilesetName.Text, n, suffix));
var totalTiles = t.Width * t.Height; var totalTiles = t.Width * t.Height;
var ms = new MemoryStream(); var ms = new MemoryStream();
using (var bw = new BinaryWriter(ms)) using (var bw = new BinaryWriter(ms))
{ {
bw.Write((ushort)TileSize); bw.Write((ushort)tileSize);
bw.Write((ushort)TileSize); bw.Write((ushort)tileSize);
bw.Write((uint)totalTiles); bw.Write((uint)totalTiles);
bw.Write((ushort)t.Width); bw.Write((ushort)t.Width);
bw.Write((ushort)t.Height); bw.Write((ushort)t.Height);
@@ -290,16 +291,15 @@ namespace OpenRA.TilesetBuilder
{ {
if (t.Cells.ContainsKey(new int2(u + t.Left, v + t.Top))) if (t.Cells.ContainsKey(new int2(u + t.Left, v + t.Top)))
{ {
byte* q = p + data.Stride * TileSize * (v + t.Top) + TileSize * (u + t.Left); byte* q = p + data.Stride * tileSize * (v + t.Top) + tileSize * (u + t.Left);
for (var j = 0; j < TileSize; j++) for (var j = 0; j < tileSize; j++)
for (var i = 0; i < TileSize; i++) for (var i = 0; i < tileSize; i++)
{ {
bw.Write(q[i + j * data.Stride]); bw.Write(q[i + j * data.Stride]);
} }
} }
else else
for (var x = 0; x < TileSize * TileSize; x++) for (var x = 0; x < tileSize * tileSize; x++)
bw.Write((byte)0); /* TODO: don't fill with air */ bw.Write((byte)0); /* TODO: don't fill with air */
} }
} }
@@ -334,12 +334,13 @@ namespace OpenRA.TilesetBuilder
File.WriteAllBytes(filename, bytes); File.WriteAllBytes(filename, bytes);
} }
return filename; return filename;
} }
public void Export (string OutputDir) public void Export(string outputDir)
{ {
var dir = Path.Combine(Path.GetDirectoryName(srcfile), Platform.SupportDir+OutputDir); var dir = Path.Combine(Path.GetDirectoryName(srcfile), Platform.SupportDir + outputDir);
Directory.CreateDirectory(dir); Directory.CreateDirectory(dir);
var tilesetName = txtTilesetName.Text; var tilesetName = txtTilesetName.Text;
var tilesetID = txtID.Text; var tilesetID = txtID.Text;
@@ -350,30 +351,24 @@ namespace OpenRA.TilesetBuilder
if (tilesetID.Length < 1) { tilesetID = "TEMPERAT"; } if (tilesetID.Length < 1) { tilesetID = "TEMPERAT"; }
if (tilesetPalette.Length < 1) { tilesetPalette = "temperat"; } if (tilesetPalette.Length < 1) { tilesetPalette = "temperat"; }
if (tilesetExt.Length < 1) { tilesetExt = ".tem,.shp"; } if (tilesetExt.Length < 1) { tilesetExt = ".tem,.shp"; }
// Create a Tileset definition // Create a Tileset definition
// TODO: Pull this info from the GUI // TODO: Pull this info from the GUI
var tilesetFile = ""; var tilesetFile = "";
//var mixFile = "";
tilesetFile = tilesetName.ToLower(); tilesetFile = tilesetName.ToLower();
if (tilesetFile.Length < 8) if (tilesetFile.Length < 8)
{
tilesetFile = tilesetName.ToLower() + ".yaml"; tilesetFile = tilesetName.ToLower() + ".yaml";
//mixFile = tilesetName.ToLower() + ".mix";
}
else else
{
tilesetFile = tilesetName.ToLower().Substring(0, 8) + ".yaml"; tilesetFile = tilesetName.ToLower().Substring(0, 8) + ".yaml";
//mixFile = tilesetName.ToLower().Substring(0, 8) + ".mix";
}
string[] Ext = tilesetExt.Split(','); var ext = tilesetExt.Split(',');
var tileset = new TileSet() var tileset = new TileSet()
{ {
Name = tilesetName, Name = tilesetName,
Id = tilesetID.ToUpper(), Id = tilesetID.ToUpper(),
TileSize = size, TileSize = size,
Palette = tilesetPalette.ToLower(), Palette = tilesetPalette.ToLower(),
Extensions = new string[] { Ext[0], Ext[1] } Extensions = new string[] { ext[0], ext[1] }
}; };
// List of files to add to the mix file // List of files to add to the mix file
@@ -408,7 +403,7 @@ namespace OpenRA.TilesetBuilder
{ {
string ttype = "Clear"; string ttype = "Clear";
ttype = TerrainType[surface1.TerrainTypes[t.Key.X, t.Key.Y]].Type; ttype = TerrainType[surface1.TerrainTypes[t.Key.X, t.Key.Y]].Type;
var idx = ((t.Key.X - tp.Left) + tp.Width * (t.Key.Y - tp.Top)); var idx = (t.Key.X - tp.Left) + tp.Width * (t.Key.Y - tp.Top);
template.Tiles.Add((byte)idx, ttype); template.Tiles.Add((byte)idx, ttype);
} }
@@ -417,13 +412,6 @@ namespace OpenRA.TilesetBuilder
} }
tileset.Save(Path.Combine(dir, tilesetFile)); tileset.Save(Path.Combine(dir, tilesetFile));
//throw new NotImplementedException("NotI");
//PackageWriter.CreateMix(Path.Combine(dir, mixFile),fileList);
// Cleanup
//foreach (var file in fileList)
//File.Delete(file);
Console.WriteLine("Finished export"); Console.WriteLine("Finished export");
} }
@@ -437,7 +425,7 @@ namespace OpenRA.TilesetBuilder
{ {
foreach (var t in tp.Cells) foreach (var t in tp.Cells)
{ {
var idx = ((t.Key.X - tp.Left) + tp.Width * (t.Key.Y - tp.Top)); var idx = (t.Key.X - tp.Left) + tp.Width * (t.Key.Y - tp.Top);
// TemplateID CellID tilenr TemplateW TemplateH XinTilesPNG YinTilesPNG // TemplateID CellID tilenr TemplateW TemplateH XinTilesPNG YinTilesPNG
Console.WriteLine("{0} {1} {2} {3} {4} {5} {6}", Console.WriteLine("{0} {1} {2} {3} {4} {5} {6}",
@@ -447,8 +435,7 @@ namespace OpenRA.TilesetBuilder
tp.Width, tp.Width,
tp.Height, tp.Height,
t.Key.X, t.Key.X,
t.Key.Y t.Key.Y);
);
} }
cur++; cur++;
@@ -457,23 +444,14 @@ namespace OpenRA.TilesetBuilder
Console.WriteLine("# end\n"); Console.WriteLine("# end\n");
} }
private void toolStripContainer1_TopToolStripPanel_Click(object sender, EventArgs e) private void TilesetNameChanged(object sender, EventArgs e)
{
}
private void surface1_Click(object sender, EventArgs e)
{
}
private void txtTilesetName_TextChanged(object sender, EventArgs e)
{ {
var tilesetFile = txtTilesetName.Text; var tilesetFile = txtTilesetName.Text;
if (tilesetFile.Length > 8) if (tilesetFile.Length > 8)
{ {
tilesetFile = tilesetFile.ToLower().Substring(0, 8); tilesetFile = tilesetFile.ToLower().Substring(0, 8);
} }
txtID.Text = tilesetFile.ToUpper(); txtID.Text = tilesetFile.ToUpper();
txtPal.Text = tilesetFile.ToLower() + ".pal"; txtPal.Text = tilesetFile.ToLower() + ".pal";
if (tilesetFile.Length < 3) if (tilesetFile.Length < 3)
@@ -486,7 +464,7 @@ namespace OpenRA.TilesetBuilder
} }
} }
private void toolStripButton15_Click(object sender, EventArgs e) private void NewTilesetButton(object sender, EventArgs e)
{ {
CreateNewTileset(); CreateNewTileset();
} }

View File

@@ -1,6 +1,6 @@
namespace OpenRA.TilesetBuilder namespace OpenRA.TilesetBuilder
{ {
partial class frmNew partial class FormNew
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@@ -17,6 +17,7 @@
{ {
components.Dispose(); components.Dispose();
} }
base.Dispose(disposing); base.Dispose(disposing);
} }
@@ -65,7 +66,7 @@
0, 0,
0, 0,
0}); 0});
this.numSize.ValueChanged += new System.EventHandler(this.numSize_ValueChanged); this.numSize.ValueChanged += new System.EventHandler(this.NumSizeValueChanged);
// //
// label1 // label1
// //
@@ -102,7 +103,7 @@
this.btnPalBrowse.TabIndex = 4; this.btnPalBrowse.TabIndex = 4;
this.btnPalBrowse.Text = "..."; this.btnPalBrowse.Text = "...";
this.btnPalBrowse.UseVisualStyleBackColor = true; this.btnPalBrowse.UseVisualStyleBackColor = true;
this.btnPalBrowse.Click += new System.EventHandler(this.btnPalBrowse_Click); this.btnPalBrowse.Click += new System.EventHandler(this.PaletteBrowseClick);
// //
// chkUsePalFromImage // chkUsePalFromImage
// //
@@ -115,7 +116,7 @@
this.chkUsePalFromImage.TabIndex = 5; this.chkUsePalFromImage.TabIndex = 5;
this.chkUsePalFromImage.Text = "Use palette from image"; this.chkUsePalFromImage.Text = "Use palette from image";
this.chkUsePalFromImage.UseVisualStyleBackColor = true; this.chkUsePalFromImage.UseVisualStyleBackColor = true;
this.chkUsePalFromImage.CheckedChanged += new System.EventHandler(this.chkUsePalFromImage_CheckedChanged); this.chkUsePalFromImage.CheckedChanged += new System.EventHandler(this.UsePaletteFromImageCheckedChanged);
// //
// label3 // label3
// //
@@ -145,7 +146,7 @@
this.btnImgBrowse.TabIndex = 9; this.btnImgBrowse.TabIndex = 9;
this.btnImgBrowse.Text = "..."; this.btnImgBrowse.Text = "...";
this.btnImgBrowse.UseVisualStyleBackColor = true; this.btnImgBrowse.UseVisualStyleBackColor = true;
this.btnImgBrowse.Click += new System.EventHandler(this.btnImgBrowse_Click); this.btnImgBrowse.Click += new System.EventHandler(this.ImageBrowseClick);
// //
// txtImage // txtImage
// //
@@ -164,7 +165,7 @@
this.btnCancel.TabIndex = 10; this.btnCancel.TabIndex = 10;
this.btnCancel.Text = "Cancel"; this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true; this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); this.btnCancel.Click += new System.EventHandler(this.CancelButtonClick);
// //
// btnOk // btnOk
// //
@@ -174,7 +175,7 @@
this.btnOk.TabIndex = 11; this.btnOk.TabIndex = 11;
this.btnOk.Text = "OK"; this.btnOk.Text = "OK";
this.btnOk.UseVisualStyleBackColor = true; this.btnOk.UseVisualStyleBackColor = true;
this.btnOk.Click += new System.EventHandler(this.btnOk_Click); this.btnOk.Click += new System.EventHandler(this.OkButtonClick);
// //
// frmNew // frmNew
// //

View File

@@ -8,24 +8,24 @@ using System.Windows.Forms;
namespace OpenRA.TilesetBuilder namespace OpenRA.TilesetBuilder
{ {
public partial class frmNew : Form public partial class FormNew : Form
{ {
public bool PaletteFromImage = true; public bool PaletteFromImage = true;
public string PaletteFile = ""; public string PaletteFile = "";
public string ImageFile = ""; public string ImageFile = "";
public int TileSize = 24; public int TileSize = 24;
public frmNew() public FormNew()
{ {
InitializeComponent(); InitializeComponent();
} }
private void btnCancel_Click(object sender, EventArgs e) private void CancelButtonClick(object sender, EventArgs e)
{ {
Close(); Close();
} }
private void btnOk_Click(object sender, EventArgs e) private void OkButtonClick(object sender, EventArgs e)
{ {
if (!PaletteFromImage) if (!PaletteFromImage)
{ {
@@ -34,6 +34,7 @@ namespace OpenRA.TilesetBuilder
MessageBox.Show("No palette specified", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); MessageBox.Show("No palette specified", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
} }
} }
if (ImageFile.Length < 5) if (ImageFile.Length < 5)
{ {
MessageBox.Show("No image selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("No image selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
@@ -45,7 +46,7 @@ namespace OpenRA.TilesetBuilder
} }
} }
private void chkUsePalFromImage_CheckedChanged(object sender, EventArgs e) private void UsePaletteFromImageCheckedChanged(object sender, EventArgs e)
{ {
if (chkUsePalFromImage.Checked) if (chkUsePalFromImage.Checked)
{ {
@@ -59,7 +60,7 @@ namespace OpenRA.TilesetBuilder
} }
} }
private void btnPalBrowse_Click(object sender, EventArgs e) private void PaletteBrowseClick(object sender, EventArgs e)
{ {
using (var ofd = new OpenFileDialog { Filter = "C&C Palette (*.pal)|*.pal" }) using (var ofd = new OpenFileDialog { Filter = "C&C Palette (*.pal)|*.pal" })
if (DialogResult.OK == ofd.ShowDialog()) if (DialogResult.OK == ofd.ShowDialog())
@@ -69,7 +70,7 @@ namespace OpenRA.TilesetBuilder
} }
} }
private void btnImgBrowse_Click(object sender, EventArgs e) private void ImageBrowseClick(object sender, EventArgs e)
{ {
using (var ofd = new OpenFileDialog { Filter = "8bit Image (*.png,*.pcx,*.bmp)|*.png;*.pcx;*.bmp" }) using (var ofd = new OpenFileDialog { Filter = "8bit Image (*.png,*.pcx,*.bmp)|*.png;*.pcx;*.bmp" })
if (DialogResult.OK == ofd.ShowDialog()) if (DialogResult.OK == ofd.ShowDialog())
@@ -80,7 +81,7 @@ namespace OpenRA.TilesetBuilder
} }
} }
private void numSize_ValueChanged(object sender, EventArgs e) private void NumSizeValueChanged(object sender, EventArgs e)
{ {
TileSize = (int)numSize.Value; TileSize = (int)numSize.Value;
} }

View File

@@ -74,25 +74,9 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="frmBuilder.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmBuilder.Designer.cs">
<DependentUpon>frmBuilder.cs</DependentUpon>
</Compile>
<Compile Include="frmNew.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmNew.Designer.cs">
<DependentUpon>frmNew.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="frmBuilder.resx">
<DependentUpon>frmBuilder.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmNew.resx"> <EmbeddedResource Include="frmNew.resx">
<DependentUpon>frmNew.cs</DependentUpon> <DependentUpon>FormNew.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
@@ -120,6 +104,21 @@
<SubType>Component</SubType> <SubType>Component</SubType>
</Compile> </Compile>
<Compile Include="Template.cs" /> <Compile Include="Template.cs" />
<Compile Include="FormBuilder.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormBuilder.Designer.cs">
<DependentUpon>FormBuilder.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="FormBuilder.resx">
<DependentUpon>FormBuilder.cs</DependentUpon>
</EmbeddedResource>
<Compile Include="FormNew.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormNew.Designer.cs">
<DependentUpon>FormNew.cs</DependentUpon>
</Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj"> <ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">

View File

@@ -21,17 +21,17 @@ namespace OpenRA.TilesetBuilder
{ {
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
//Console.WriteLine("{0} {1} {2} {3}",args[0], args[1], args[2], args[3]);
if (args.Length < 1) if (args.Length < 1)
{ {
Application.Run(new frmBuilder("", "0", false, "Tilesets")); Application.Run(new FormBuilder("", "0", false, "Tilesets"));
} }
else else
{ {
if (args.Contains("--export")) if (args.Contains("--export"))
Application.Run(new frmBuilder(args[0], args[1], true, args[3])); Application.Run(new FormBuilder(args[0], args[1], true, args[3]));
else else
Application.Run(new frmBuilder(args[0], args[1], false, "Tilesets")); Application.Run(new FormBuilder(args[0], args[1], false, "Tilesets"));
} }
} }
} }

View File

@@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OpenRA.TilesetBuilder")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OpenRA.TilesetBuilder")]
[assembly: AssemblyCopyright("Copyright © 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 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
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("9efec6a6-74f7-4a7d-a509-aba2aae75bcc")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -302,6 +302,16 @@
<BooleanProperty Name="Enabled">False</BooleanProperty> <BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings> </RuleSettings>
</Rule> </Rule>
<Rule Name="ParameterMustFollowComma">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="SplitParametersMustStartOnLineAfterDeclaration">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules> </Rules>
<AnalyzerSettings /> <AnalyzerSettings />
</Analyzer> </Analyzer>

View File

@@ -9,31 +9,29 @@ namespace OpenRA.TilesetBuilder
class Surface : Control class Surface : Control
{ {
public Bitmap Image; public Bitmap Image;
private ImageList ImagesListControl;
public int[,] TerrainTypes; public int[,] TerrainTypes;
public List<Template> Templates = new List<Template>(); public List<Template> Templates = new List<Template>();
private bool bShowTerrainTypes;
public string InputMode; public string InputMode;
public Bitmap[] icon; public Bitmap[] Icon;
public int TileSize; public int TileSize;
public int TilesPerRow; public int TilesPerRow;
//private System.ComponentModel.IContainer components;
public event Action<int, int, int> UpdateMouseTilePosition = (x, y, t) => { }; public event Action<int, int, int> UpdateMouseTilePosition = (x, y, t) => { };
Template CurrentTemplate; Template currentTemplate;
ImageList imagesListControl;
bool showTerrainTypes;
public bool ShowTerrainTypes public bool ShowTerrainTypes
{ {
get { return bShowTerrainTypes; } get { return showTerrainTypes; }
set { bShowTerrainTypes = value; } set { showTerrainTypes = value; }
} }
public ImageList ImagesList public ImageList ImagesList
{ {
get { return ImagesListControl; } get { return imagesListControl; }
set { ImagesListControl = value; } set { imagesListControl = value; }
} }
public Surface() public Surface()
@@ -60,12 +58,12 @@ namespace OpenRA.TilesetBuilder
for (var j = 0; j <= TerrainTypes.GetUpperBound(1); j++) for (var j = 0; j <= TerrainTypes.GetUpperBound(1); j++)
if (TerrainTypes[i, j] != 0) if (TerrainTypes[i, j] != 0)
{ {
//e.Graphics.FillRectangle(Brushes.Black, TileSize * i + 8, TileSize * j + 8, 16, 16); ////e.Graphics.FillRectangle(Brushes.Black, TileSize * i + 8, TileSize * j + 8, 16, 16);
e.Graphics.DrawImage(icon[TerrainTypes[i, j]], TileSize * i + 8, TileSize * j + 8, 16, 16); e.Graphics.DrawImage(Icon[TerrainTypes[i, j]], TileSize * i + 8, TileSize * j + 8, 16, 16);
//e.Graphics.DrawString(TerrainTypes[i, j].ToString(), ////e.Graphics.DrawString(TerrainTypes[i, j].ToString(),
//Font, Brushes.LimeGreen, TileSize * i + 10, TileSize * j + 10); ////Font, Brushes.LimeGreen, TileSize * i + 10, TileSize * j + 10);
} }
} }
@@ -76,7 +74,7 @@ namespace OpenRA.TilesetBuilder
foreach (var c in t.Cells.Keys) foreach (var c in t.Cells.Keys)
{ {
if (CurrentTemplate == t) if (currentTemplate == t)
e.Graphics.FillRectangle(currentBrush, TileSize * c.X, TileSize * c.Y, TileSize, TileSize); e.Graphics.FillRectangle(currentBrush, TileSize * c.X, TileSize * c.Y, TileSize, TileSize);
if (!t.Cells.ContainsKey(c + new int2(-1, 0))) if (!t.Cells.ContainsKey(c + new int2(-1, 0)))
@@ -99,9 +97,9 @@ namespace OpenRA.TilesetBuilder
{ {
if (e.Button == MouseButtons.Left) if (e.Button == MouseButtons.Left)
{ {
CurrentTemplate = Templates.FirstOrDefault(t => t.Cells.ContainsKey(pos)); currentTemplate = Templates.FirstOrDefault(t => t.Cells.ContainsKey(pos));
if (CurrentTemplate == null) if (currentTemplate == null)
Templates.Add(CurrentTemplate = new Template { Cells = new Dictionary<int2, bool> { { pos, true } } }); Templates.Add(currentTemplate = new Template { Cells = new Dictionary<int2, bool> { { pos, true } } });
Invalidate(); Invalidate();
} }
@@ -109,7 +107,7 @@ namespace OpenRA.TilesetBuilder
if (e.Button == MouseButtons.Right) if (e.Button == MouseButtons.Right)
{ {
Templates.RemoveAll(t => t.Cells.ContainsKey(pos)); Templates.RemoveAll(t => t.Cells.ContainsKey(pos));
CurrentTemplate = null; currentTemplate = null;
Invalidate(); Invalidate();
} }
} }
@@ -126,11 +124,11 @@ namespace OpenRA.TilesetBuilder
if (InputMode == null) if (InputMode == null)
{ {
if (e.Button == MouseButtons.Left && CurrentTemplate != null) if (e.Button == MouseButtons.Left && currentTemplate != null)
{ {
if (!CurrentTemplate.Cells.ContainsKey(pos)) if (!currentTemplate.Cells.ContainsKey(pos))
{ {
CurrentTemplate.Cells[pos] = true; currentTemplate.Cells[pos] = true;
Invalidate(); Invalidate();
} }
} }

View File

@@ -82,15 +82,16 @@ namespace OpenRA.Utility
var dest = Path.ChangeExtension(src, ".png"); var dest = Path.ChangeExtension(src, ".png");
var srcImage = ShpReader.Load(src); var srcImage = ShpReader.Load(src);
int[] ShadowIndex = { }; var shadowIndex = new int[] { };
if (args.Contains("--noshadow")) if (args.Contains("--noshadow"))
{ {
Array.Resize(ref ShadowIndex, ShadowIndex.Length + 3); Array.Resize(ref shadowIndex, shadowIndex.Length + 3);
ShadowIndex[ShadowIndex.Length - 1] = 1; shadowIndex[shadowIndex.Length - 1] = 1;
ShadowIndex[ShadowIndex.Length - 2] = 3; shadowIndex[shadowIndex.Length - 2] = 3;
ShadowIndex[ShadowIndex.Length - 1] = 4; shadowIndex[shadowIndex.Length - 3] = 4;
} }
var palette = Palette.Load(args[2], ShadowIndex);
var palette = Palette.Load(args[2], shadowIndex);
using (var bitmap = new Bitmap(srcImage.ImageCount * srcImage.Width, srcImage.Height, PixelFormat.Format8bppIndexed)) using (var bitmap = new Bitmap(srcImage.ImageCount * srcImage.Width, srcImage.Height, PixelFormat.Format8bppIndexed))
{ {
@@ -119,41 +120,44 @@ namespace OpenRA.Utility
public static void ConvertR8ToPng(string[] args) public static void ConvertR8ToPng(string[] args)
{ {
var srcImage = new R8Reader(File.OpenRead(args[1])); var srcImage = new R8Reader(File.OpenRead(args[1]));
int[] ShadowIndex = { }; var shadowIndex = new int[] { };
if (args.Contains("--noshadow")) if (args.Contains("--noshadow"))
{ {
Array.Resize(ref ShadowIndex, ShadowIndex.Length + 1); Array.Resize(ref shadowIndex, shadowIndex.Length + 1);
ShadowIndex[ShadowIndex.Length - 1] = 3; shadowIndex[shadowIndex.Length - 1] = 3;
} }
var palette = Palette.Load(args[2], ShadowIndex);
var palette = Palette.Load(args[2], shadowIndex);
var startFrame = int.Parse(args[3]); var startFrame = int.Parse(args[3]);
var endFrame = int.Parse(args[4]) + 1; var endFrame = int.Parse(args[4]) + 1;
var filename = args[5]; var filename = args[5];
var FrameCount = endFrame - startFrame; var frameCount = endFrame - startFrame;
var frame = srcImage[startFrame]; var frame = srcImage[startFrame];
var bitmap = new Bitmap(frame.FrameSize.Width * FrameCount, frame.FrameSize.Height, PixelFormat.Format8bppIndexed); var bitmap = new Bitmap(frame.FrameSize.Width * frameCount, frame.FrameSize.Height, PixelFormat.Format8bppIndexed);
bitmap.Palette = palette.AsSystemPalette(); bitmap.Palette = palette.AsSystemPalette();
int x = 0; int x = 0;
frame = srcImage[startFrame]; frame = srcImage[startFrame];
if (args.Contains("--infantry")) //resorting to RA/CnC compatible counter-clockwise frame order // resorting to RA/CnC compatible counter-clockwise frame order
if (args.Contains("--infantry"))
{ {
endFrame = startFrame - 1; endFrame = startFrame - 1;
for (int e = 8; e < FrameCount+1; e=e+8) //assuming 8 facings each animation set
{
// assuming 8 facings each animation set
for (int e = 8; e < frameCount + 1; e = e + 8)
{
for (int f = startFrame + e - 1; f > endFrame; f--) for (int f = startFrame + e - 1; f > endFrame; f--)
{ {
var OffsetX = frame.FrameSize.Width/2 - frame.Size.Width/2; var offsetX = frame.FrameSize.Width / 2 - frame.Size.Width / 2;
var OffsetY = frame.FrameSize.Height/2 - frame.Size.Height/2; var offsetY = frame.FrameSize.Height / 2 - frame.Size.Height / 2;
Console.WriteLine("calculated OffsetX: {0}", OffsetX); Console.WriteLine("calculated OffsetX: {0}", offsetX);
Console.WriteLine("calculated OffsetY: {0}", OffsetY); Console.WriteLine("calculated OffsetY: {0}", offsetY);
var data = bitmap.LockBits(new Rectangle(x+OffsetX, 0+OffsetY, frame.Size.Width, frame.Size.Height), ImageLockMode.WriteOnly, var data = bitmap.LockBits(new Rectangle(x + offsetX, 0 + offsetY, frame.Size.Width, frame.Size.Height), ImageLockMode.WriteOnly,
PixelFormat.Format8bppIndexed); PixelFormat.Format8bppIndexed);
for (var i = 0; i < frame.Size.Height; i++) for (var i = 0; i < frame.Size.Height; i++)
@@ -167,26 +171,26 @@ namespace OpenRA.Utility
frame = srcImage[f]; frame = srcImage[f];
Console.WriteLine("f: {0}", f); Console.WriteLine("f: {0}", f);
} }
endFrame = startFrame + e - 1; endFrame = startFrame + e - 1;
frame = srcImage[startFrame + e]; frame = srcImage[startFrame + e];
Console.WriteLine("e: {0}", e); Console.WriteLine("e: {0}", e);
Console.WriteLine("FrameCount: {0}", FrameCount); Console.WriteLine("FrameCount: {0}", frameCount);
} }
} }
//resorting to RA/CnC compatible counter-clockwise frame order
else if (args.Contains("--vehicle") || args.Contains("--projectile")) else if (args.Contains("--vehicle") || args.Contains("--projectile"))
{ {
frame = srcImage[startFrame]; frame = srcImage[startFrame];
for (int f = endFrame - 1; f > startFrame - 1; f--) for (int f = endFrame - 1; f > startFrame - 1; f--)
{ {
var OffsetX = frame.FrameSize.Width/2 - frame.Offset.X; var offsetX = frame.FrameSize.Width / 2 - frame.Offset.X;
var OffsetY = frame.FrameSize.Height/2 - frame.Offset.Y; var offsetY = frame.FrameSize.Height / 2 - frame.Offset.Y;
Console.WriteLine("calculated OffsetX: {0}", OffsetX); Console.WriteLine("calculated OffsetX: {0}", offsetX);
Console.WriteLine("calculated OffsetY: {0}", OffsetY); Console.WriteLine("calculated OffsetY: {0}", offsetY);
var data = bitmap.LockBits(new Rectangle(x+OffsetX, 0+OffsetY, frame.Size.Width, frame.Size.Height), ImageLockMode.WriteOnly, var data = bitmap.LockBits(new Rectangle(x + offsetX, 0 + offsetY, frame.Size.Width, frame.Size.Height), ImageLockMode.WriteOnly,
PixelFormat.Format8bppIndexed); PixelFormat.Format8bppIndexed);
for (var i = 0; i < frame.Size.Height; i++) for (var i = 0; i < frame.Size.Height; i++)
@@ -200,19 +204,19 @@ namespace OpenRA.Utility
frame = srcImage[f]; frame = srcImage[f];
} }
} }
else if (args.Contains("--turret")) //resorting to RA/CnC compatible counter-clockwise frame order else if (args.Contains("--turret"))
{ {
frame = srcImage[startFrame]; frame = srcImage[startFrame];
for (int f = endFrame - 1; f > startFrame - 1; f--) for (int f = endFrame - 1; f > startFrame - 1; f--)
{ {
var OffsetX = Math.Abs(frame.Offset.X); var offsetX = Math.Abs(frame.Offset.X);
var OffsetY = frame.FrameSize.Height - Math.Abs(frame.Offset.Y); var offsetY = frame.FrameSize.Height - Math.Abs(frame.Offset.Y);
Console.WriteLine("calculated OffsetX: {0}", OffsetX); Console.WriteLine("calculated OffsetX: {0}", offsetX);
Console.WriteLine("calculated OffsetY: {0}", OffsetY); Console.WriteLine("calculated OffsetY: {0}", offsetY);
var data = bitmap.LockBits(new Rectangle(x+OffsetX, 0+OffsetY, frame.Size.Width, frame.Size.Height), ImageLockMode.WriteOnly, var data = bitmap.LockBits(new Rectangle(x + offsetX, 0 + offsetY, frame.Size.Width, frame.Size.Height), ImageLockMode.WriteOnly,
PixelFormat.Format8bppIndexed); PixelFormat.Format8bppIndexed);
for (var i = 0; i < frame.Size.Height; i++) for (var i = 0; i < frame.Size.Height; i++)
@@ -226,21 +230,22 @@ namespace OpenRA.Utility
frame = srcImage[f]; frame = srcImage[f];
} }
} }
else if (args.Contains("--wall")) //complex resorting to RA/CnC compatible frame order else if (args.Contains("--wall"))
{ {
int[] D2kBrikFrameOrder = {1, 4, 2, 12, 5, 6, 16, 9, 3, 13, 7, 8, 14, 10, 11, 15, 17, 20, 18, 28, 21, 22, 32, 25, 19, 29, 23, 24, 30, 26, 27, 31}; // complex resorting to RA/CnC compatible frame order
foreach (int o in D2kBrikFrameOrder) var d2kBrikFrameOrder = new int[] { 1, 4, 2, 12, 5, 6, 16, 9, 3, 13, 7, 8, 14, 10, 11, 15, 17, 20, 18, 28, 21, 22, 32, 25, 19, 29, 23, 24, 30, 26, 27, 31 };
foreach (int o in d2kBrikFrameOrder)
{ {
int f = startFrame -1 + o; var f = startFrame - 1 + o;
frame = srcImage[f]; frame = srcImage[f];
var OffsetX = Math.Abs(frame.Offset.X); var offsetX = Math.Abs(frame.Offset.X);
var OffsetY = frame.FrameSize.Height - Math.Abs(frame.Offset.Y); var offsetY = frame.FrameSize.Height - Math.Abs(frame.Offset.Y);
Console.WriteLine("calculated OffsetX: {0}", OffsetX); Console.WriteLine("calculated OffsetX: {0}", offsetX);
Console.WriteLine("calculated OffsetY: {0}", OffsetY); Console.WriteLine("calculated OffsetY: {0}", offsetY);
var data = bitmap.LockBits(new Rectangle(x+OffsetX, 0+OffsetY, frame.Size.Width, frame.Size.Height), ImageLockMode.WriteOnly, var data = bitmap.LockBits(new Rectangle(x + offsetX, 0 + offsetY, frame.Size.Width, frame.Size.Height), ImageLockMode.WriteOnly,
PixelFormat.Format8bppIndexed); PixelFormat.Format8bppIndexed);
for (var i = 0; i < frame.Size.Height; i++) for (var i = 0; i < frame.Size.Height; i++)
@@ -262,7 +267,7 @@ namespace OpenRA.Utility
{ {
for (int w = 0; w < 20; w++) for (int w = 0; w < 20; w++)
{ {
if (h * 20 + w < FrameCount) if (h * 20 + w < frameCount)
{ {
Console.WriteLine(f); Console.WriteLine(f);
frame = srcImage[f]; frame = srcImage[f];
@@ -279,6 +284,7 @@ namespace OpenRA.Utility
} }
} }
} }
bitmap = tileset; bitmap = tileset;
} }
else else
@@ -286,22 +292,23 @@ namespace OpenRA.Utility
for (int f = startFrame; f < endFrame; f++) for (int f = startFrame; f < endFrame; f++)
{ {
frame = srcImage[f]; frame = srcImage[f];
int OffsetX = 0; var offsetX = 0;
int OffsetY = 0; var offsetY = 0;
if (args.Contains("--infantrydeath")) if (args.Contains("--infantrydeath"))
{ {
OffsetX = frame.FrameSize.Width/2 - frame.Size.Width/2; offsetX = frame.FrameSize.Width / 2 - frame.Size.Width / 2;
OffsetY = frame.FrameSize.Height/2 - frame.Size.Height/2; offsetY = frame.FrameSize.Height / 2 - frame.Size.Height / 2;
} }
else if (args.Contains("--building")) else if (args.Contains("--building"))
{ {
OffsetX = Math.Abs(frame.Offset.X); offsetX = Math.Abs(frame.Offset.X);
OffsetY = frame.FrameSize.Height - Math.Abs(frame.Offset.Y); offsetY = frame.FrameSize.Height - Math.Abs(frame.Offset.Y);
} }
Console.WriteLine("calculated OffsetX: {0}", OffsetX);
Console.WriteLine("calculated OffsetY: {0}", OffsetY);
var data = bitmap.LockBits(new Rectangle(x+OffsetX, 0+OffsetY, frame.Size.Width, frame.Size.Height), ImageLockMode.WriteOnly, Console.WriteLine("calculated OffsetX: {0}", offsetX);
Console.WriteLine("calculated OffsetY: {0}", offsetY);
var data = bitmap.LockBits(new Rectangle(x + offsetX, 0 + offsetY, frame.Size.Width, frame.Size.Height), ImageLockMode.WriteOnly,
PixelFormat.Format8bppIndexed); PixelFormat.Format8bppIndexed);
for (var i = 0; i < frame.Size.Height; i++) for (var i = 0; i < frame.Size.Height; i++)
@@ -313,6 +320,7 @@ namespace OpenRA.Utility
x += frame.FrameSize.Width; x += frame.FrameSize.Width;
} }
} }
bitmap.Save(filename + ".png"); bitmap.Save(filename + ".png");
Console.WriteLine(filename + ".png saved"); Console.WriteLine(filename + ".png saved");
} }
@@ -322,7 +330,7 @@ namespace OpenRA.Utility
var mods = args[1].Split(','); var mods = args[1].Split(',');
var theater = args[2]; var theater = args[2];
var templateNames = args.Skip(3); var templateNames = args.Skip(3);
int[] ShadowIndex = { 3, 4 }; var shadowIndex = new int[] { 3, 4 };
var manifest = new Manifest(mods); var manifest = new Manifest(mods);
FileSystem.LoadFromManifest(manifest); FileSystem.LoadFromManifest(manifest);
@@ -334,7 +342,7 @@ namespace OpenRA.Utility
throw new InvalidOperationException("No theater named '{0}'".F(theater)); throw new InvalidOperationException("No theater named '{0}'".F(theater));
tileset.LoadTiles(); tileset.LoadTiles();
var palette = new Palette(FileSystem.Open(tileset.Palette), ShadowIndex); var palette = new Palette(FileSystem.Open(tileset.Palette), shadowIndex);
foreach (var templateName in templateNames) foreach (var templateName in templateNames)
{ {
@@ -419,17 +427,17 @@ namespace OpenRA.Utility
FileSystem.LoadFromManifest(Game.modData.Manifest); FileSystem.LoadFromManifest(Game.modData.Manifest);
Rules.LoadRules(Game.modData.Manifest, new Map()); Rules.LoadRules(Game.modData.Manifest, new Map());
var destPaletteInfo = Rules.Info["player"].Traits.Get<PlayerColorPaletteInfo>(); var destPaletteInfo = Rules.Info["player"].Traits.Get<PlayerColorPaletteInfo>();
int[] destRemapIndex = destPaletteInfo.RemapIndex; var destRemapIndex = destPaletteInfo.RemapIndex;
var shadowIndex = new int[] { };
int[] ShadowIndex = { };
// the remap range is always 16 entries, but their location and order changes // the remap range is always 16 entries, but their location and order changes
for (var i = 0; i < 16; i++) for (var i = 0; i < 16; i++)
remap[PlayerColorRemap.GetRemapIndex(srcRemapIndex, i)] remap[PlayerColorRemap.GetRemapIndex(srcRemapIndex, i)]
= PlayerColorRemap.GetRemapIndex(destRemapIndex, i); = PlayerColorRemap.GetRemapIndex(destRemapIndex, i);
// map everything else to the best match based on channel-wise distance // map everything else to the best match based on channel-wise distance
var srcPalette = Palette.Load(args[1].Split(':')[1], ShadowIndex); var srcPalette = Palette.Load(args[1].Split(':')[1], shadowIndex);
var destPalette = Palette.Load(args[2].Split(':')[1], ShadowIndex); var destPalette = Palette.Load(args[2].Split(':')[1], shadowIndex);
var fullIndexRange = Exts.MakeArray<int>(256, x => x); var fullIndexRange = Exts.MakeArray<int>(256, x => x);
@@ -447,7 +455,6 @@ namespace OpenRA.Utility
srcImage.Frames.Select(im => im.Image.Select(px => (byte)remap[px]).ToArray())); srcImage.Frames.Select(im => im.Image.Select(px => (byte)remap[px]).ToArray()));
} }
//This is needed because the run and shoot animation are next to each other for each sequence in RA/CnC, but not in D2k.
public static void TransposeShp(string[] args) public static void TransposeShp(string[] args)
{ {
var srcImage = ShpReader.Load(args[1]); var srcImage = ShpReader.Load(args[1]);

View File

@@ -76,7 +76,6 @@
<ItemGroup> <ItemGroup>
<Compile Include="Command.cs" /> <Compile Include="Command.cs" />
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj"> <ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">

View File

@@ -1,46 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* 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
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OpenRA.Utility")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OpenRA")]
[assembly: AssemblyCopyright("Copyright © 2010 The OpenRA Developers")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 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
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("64363ecc-4102-4a38-a108-427de0af5dcb")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -302,6 +302,16 @@
<BooleanProperty Name="Enabled">False</BooleanProperty> <BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings> </RuleSettings>
</Rule> </Rule>
<Rule Name="ParameterMustFollowComma">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="SplitParametersMustStartOnLineAfterDeclaration">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules> </Rules>
<AnalyzerSettings /> <AnalyzerSettings />
</Analyzer> </Analyzer>

View File

@@ -1,46 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* 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
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("RALint")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RALint")]
[assembly: AssemblyCopyright("Copyright © 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 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
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("722ef098-e9f3-4e3c-b374-3388dfad8979")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -71,7 +71,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="RALint.cs" /> <Compile Include="RALint.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj"> <ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">

View File

@@ -132,7 +132,7 @@ Music:
Movies: Movies:
LoadScreen: RALoadScreen LoadScreen: TSLoadScreen
LoadScreenImage: mods/ts/uibits/loadscreen.png LoadScreenImage: mods/ts/uibits/loadscreen.png
InstallerMenuWidget: INSTALL_PANEL InstallerMenuWidget: INSTALL_PANEL
TestFile: tibsun.mix TestFile: tibsun.mix