Stylecop clean Editor

This commit is contained in:
Matthias Mailänder
2013-08-07 13:49:48 +02:00
parent 57f7f71c8d
commit 2dbc4f4786
17 changed files with 897 additions and 974 deletions

View File

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

View File

@@ -41,7 +41,7 @@ namespace OpenRA.Editor
{
var r = new TextBox();
r.Text = FieldSaver.FormatValue(getter(), t);
r.LostFocus += (e,_) => setter(FieldLoader.GetValue("<editor internals>", t, r.Text));
r.LostFocus += (e, _) => setter(FieldLoader.GetValue("<editor internals>", t, r.Text));
r.Enabled = false;
return r;
}

View File

@@ -17,12 +17,12 @@ namespace OpenRA.Editor
{
class ActorTool : ITool
{
ActorTemplate Actor;
public ActorTool(ActorTemplate actor) { this.Actor = actor; }
ActorTemplate actorTemplate;
public ActorTool(ActorTemplate actor) { this.actorTemplate = actor; }
public void Preview(Surface surface, SGraphics g)
{
surface.DrawActor(g, surface.GetBrushLocation(), Actor,
surface.DrawActor(g, surface.GetBrushLocation(), actorTemplate,
surface.GetPaletteForPlayer(surface.NewActorOwner));
}
@@ -33,17 +33,17 @@ namespace OpenRA.Editor
var owner = surface.NewActorOwner;
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 OwnerInit( owner)
new LocationInit(surface.GetBrushLocation()),
new OwnerInit(owner)
};
}
string NextActorName(Surface surface)
{
var id = 0;
for (; ; )
for (;;)
{
var possible = "Actor{0}".F(id++);
if (!surface.Map.Actors.Value.ContainsKey(possible)) return possible;

View File

@@ -19,14 +19,14 @@ namespace OpenRA.Editor
{
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)
{
// 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 pos = surface.GetBrushLocation();
@@ -46,7 +46,7 @@ namespace OpenRA.Editor
surface.Map.MapTiles.Value[u + pos.X, v + pos.Y] =
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,
};
@@ -62,11 +62,11 @@ namespace OpenRA.Editor
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().Y * surface.Zoom + surface.GetOffset().Y,
Brush.Bitmap.Width * surface.Zoom,
Brush.Bitmap.Height * surface.Zoom);
brushTemplate.Bitmap.Width * surface.Zoom,
brushTemplate.Bitmap.Height * surface.Zoom);
}
void FloodFillWithBrush(Surface s, CPos pos)
@@ -96,7 +96,7 @@ namespace OpenRA.Editor
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))
maybeEnqueue(x, p.Y - 1);
if (s.Map.MapTiles.Value[x, p.Y + 1].Equals(replace))
@@ -111,7 +111,7 @@ namespace OpenRA.Editor
CPos FindEdge(Surface s, CPos p, CVec d, TileReference<ushort, byte> replace)
{
for (; ; )
for (;;)
{
var q = p + d;
if (!s.Map.IsInMap(q)) return p;

View File

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

View File

@@ -15,7 +15,7 @@ namespace OpenRA.Editor
{
public partial class ErrorListDialog : Form
{
public ErrorListDialog( IEnumerable<string> errors )
public ErrorListDialog(IEnumerable<string> errors)
{
InitializeComponent();
foreach (var e in errors)

View File

@@ -24,9 +24,8 @@ namespace OpenRA.Editor
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
@@ -42,7 +41,7 @@ namespace OpenRA.Editor
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.splitContainer1 = 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.tabPage1 = new System.Windows.Forms.TabPage();
this.tilePalette = new System.Windows.Forms.FlowLayoutPanel();
@@ -77,7 +76,7 @@ namespace OpenRA.Editor
this.eraserToolStripButton = new System.Windows.Forms.ToolStripButton();
this.toolStripMenuItemCopySelection = new System.Windows.Forms.ToolStripButton();
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.fileToolStripMenuItem = 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.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.cCRedAlertMapToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.mnuExport = new System.Windows.Forms.ToolStripMenuItem();
this.mnuMinimapToPNG = new System.Windows.Forms.ToolStripMenuItem();
this.redAlertMapToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.miniMapExport = new System.Windows.Forms.ToolStripMenuItem();
this.miniMapToPng = new System.Windows.Forms.ToolStripMenuItem();
this.fullMapRenderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -120,11 +119,11 @@ namespace OpenRA.Editor
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.toolStripStatusLabelFiller = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabelMousePosition = new System.Windows.Forms.ToolStripStatusLabel();
this.BottomToolStripPanel = new System.Windows.Forms.ToolStripPanel();
this.TopToolStripPanel = new System.Windows.Forms.ToolStripPanel();
this.RightToolStripPanel = new System.Windows.Forms.ToolStripPanel();
this.LeftToolStripPanel = new System.Windows.Forms.ToolStripPanel();
this.ContentPanel = new System.Windows.Forms.ToolStripContentPanel();
this.bottomToolStripPanel = new System.Windows.Forms.ToolStripPanel();
this.topToolStripPanel = new System.Windows.Forms.ToolStripPanel();
this.rightToolStripPanel = new System.Windows.Forms.ToolStripPanel();
this.leftToolStripPanel = new System.Windows.Forms.ToolStripPanel();
this.contentPanel = new System.Windows.Forms.ToolStripContentPanel();
this.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer();
this.cashToolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel();
this.splitContainer1.Panel1.SuspendLayout();
@@ -133,7 +132,7 @@ namespace OpenRA.Editor
this.splitContainer2.Panel1.SuspendLayout();
this.splitContainer2.Panel2.SuspendLayout();
this.splitContainer2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pmMiniMap)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.miniMapBox)).BeginInit();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.tabPage2.SuspendLayout();
@@ -177,7 +176,7 @@ namespace OpenRA.Editor
//
// splitContainer2.Panel1
//
this.splitContainer2.Panel1.Controls.Add(this.pmMiniMap);
this.splitContainer2.Panel1.Controls.Add(this.miniMapBox);
//
// splitContainer2.Panel2
//
@@ -188,15 +187,15 @@ namespace OpenRA.Editor
//
// pmMiniMap
//
this.pmMiniMap.BackColor = System.Drawing.Color.Black;
this.pmMiniMap.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.pmMiniMap.Dock = System.Windows.Forms.DockStyle.Fill;
this.pmMiniMap.Location = new System.Drawing.Point(0, 0);
this.pmMiniMap.Name = "pmMiniMap";
this.pmMiniMap.Size = new System.Drawing.Size(198, 153);
this.pmMiniMap.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pmMiniMap.TabIndex = 1;
this.pmMiniMap.TabStop = false;
this.miniMapBox.BackColor = System.Drawing.Color.Black;
this.miniMapBox.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.miniMapBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.miniMapBox.Location = new System.Drawing.Point(0, 0);
this.miniMapBox.Name = "pmMiniMap";
this.miniMapBox.Size = new System.Drawing.Size(198, 153);
this.miniMapBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.miniMapBox.TabIndex = 1;
this.miniMapBox.TabStop = false;
//
// tabControl1
//
@@ -356,7 +355,7 @@ namespace OpenRA.Editor
this.eraserToolStripButton,
this.toolStripMenuItemCopySelection,
this.toolStripSeparator7,
this.QuickhelpToolStripButton});
this.quickhelpToolStripButton});
this.toolStrip1.Location = new System.Drawing.Point(0, 0);
this.toolStrip1.Name = "toolStrip1";
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.Text = "&New...";
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
//
@@ -383,7 +382,7 @@ namespace OpenRA.Editor
this.toolStripMenuItemOpen.Size = new System.Drawing.Size(23, 22);
this.toolStripMenuItemOpen.Text = "&Open...";
this.toolStripMenuItemOpen.ToolTipText = "Open an existing map.";
this.toolStripMenuItemOpen.Click += new System.EventHandler(this.toolStripMenuItemOpenClick);
this.toolStripMenuItemOpen.Click += new System.EventHandler(this.ToolStripMenuItemOpenClick);
//
// toolStripMenuItemSave
//
@@ -394,7 +393,7 @@ namespace OpenRA.Editor
this.toolStripMenuItemSave.Size = new System.Drawing.Size(23, 22);
this.toolStripMenuItemSave.Text = "&Save";
this.toolStripMenuItemSave.ToolTipText = "Quicksave current map.";
this.toolStripMenuItemSave.Click += new System.EventHandler(this.toolStripMenuItemSaveClick);
this.toolStripMenuItemSave.Click += new System.EventHandler(this.ToolStripMenuItemSaveClick);
//
// toolStripSeparator
//
@@ -410,7 +409,7 @@ namespace OpenRA.Editor
this.toolStripMenuItemProperties.Size = new System.Drawing.Size(23, 22);
this.toolStripMenuItemProperties.Text = "&Properties...";
this.toolStripMenuItemProperties.ToolTipText = "Edit Metadata";
this.toolStripMenuItemProperties.Click += new System.EventHandler(this.toolStripMenuItemPropertiesClick);
this.toolStripMenuItemProperties.Click += new System.EventHandler(this.ToolStripMenuItemPropertiesClick);
//
// toolStripMenuItemResize
//
@@ -421,7 +420,7 @@ namespace OpenRA.Editor
this.toolStripMenuItemResize.Size = new System.Drawing.Size(23, 22);
this.toolStripMenuItemResize.Text = "&Resize...";
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
//
@@ -436,7 +435,7 @@ namespace OpenRA.Editor
this.toolStripMenuItemShowActorNames.Size = new System.Drawing.Size(23, 22);
this.toolStripMenuItemShowActorNames.Text = "Show Actor &Names";
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
//
@@ -446,7 +445,7 @@ namespace OpenRA.Editor
this.toolStripMenuItemShowGrid.Size = new System.Drawing.Size(23, 22);
this.toolStripMenuItemShowGrid.Text = "Show &Grid";
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
//
@@ -461,7 +460,7 @@ namespace OpenRA.Editor
this.zoomIntoolStripButton.Name = "zoomIntoolStripButton";
this.zoomIntoolStripButton.Size = new System.Drawing.Size(23, 22);
this.zoomIntoolStripButton.Text = "Zoom in";
this.zoomIntoolStripButton.Click += new System.EventHandler(this.zoomInToolStripButtonClick);
this.zoomIntoolStripButton.Click += new System.EventHandler(this.ZoomInToolStripButtonClick);
//
// zoomOutToolStripButton
//
@@ -471,7 +470,7 @@ namespace OpenRA.Editor
this.zoomOutToolStripButton.Name = "zoomOutToolStripButton";
this.zoomOutToolStripButton.Size = new System.Drawing.Size(23, 22);
this.zoomOutToolStripButton.Text = "Zoom out";
this.zoomOutToolStripButton.Click += new System.EventHandler(this.zoomOutToolStripButtonClick);
this.zoomOutToolStripButton.Click += new System.EventHandler(this.ZoomOutToolStripButtonClick);
//
// panToolStripButton
//
@@ -481,7 +480,7 @@ namespace OpenRA.Editor
this.panToolStripButton.Name = "panToolStripButton";
this.panToolStripButton.Size = new System.Drawing.Size(23, 22);
this.panToolStripButton.Text = "Pan view";
this.panToolStripButton.Click += new System.EventHandler(this.panToolStripButtonClick);
this.panToolStripButton.Click += new System.EventHandler(this.PanToolStripButtonClick);
//
// showRulerToolStripItem
//
@@ -490,7 +489,7 @@ namespace OpenRA.Editor
this.showRulerToolStripItem.Name = "showRulerToolStripItem";
this.showRulerToolStripItem.Size = new System.Drawing.Size(23, 22);
this.showRulerToolStripItem.Text = "Show Ruler";
this.showRulerToolStripItem.Click += new System.EventHandler(this.showRulerToolStripItemClick);
this.showRulerToolStripItem.Click += new System.EventHandler(this.ShowRulerToolStripItemClick);
//
// toolStripSeparator10
//
@@ -505,7 +504,7 @@ namespace OpenRA.Editor
this.toolStripMenuItemFixOpenAreas.Size = new System.Drawing.Size(23, 22);
this.toolStripMenuItemFixOpenAreas.Text = "&Fix Open Areas";
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
//
@@ -515,7 +514,7 @@ namespace OpenRA.Editor
this.toolStripMenuItemSetupDefaultPlayers.Size = new System.Drawing.Size(23, 22);
this.toolStripMenuItemSetupDefaultPlayers.Text = "&Setup Default Players";
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
//
@@ -540,7 +539,7 @@ namespace OpenRA.Editor
this.toolStripMenuItemCopySelection.Size = new System.Drawing.Size(23, 22);
this.toolStripMenuItemCopySelection.Text = "Copy Selection";
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
//
@@ -549,14 +548,14 @@ namespace OpenRA.Editor
//
// QuickhelpToolStripButton
//
this.QuickhelpToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.QuickhelpToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("QuickhelpToolStripButton.Image")));
this.QuickhelpToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.QuickhelpToolStripButton.Name = "QuickhelpToolStripButton";
this.QuickhelpToolStripButton.Size = new System.Drawing.Size(23, 22);
this.QuickhelpToolStripButton.Text = "Help";
this.QuickhelpToolStripButton.ToolTipText = "Display the mapping tutorial in the OpenRA wiki.";
this.QuickhelpToolStripButton.Click += new System.EventHandler(this.helpToolStripButton_Click);
this.quickhelpToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.quickhelpToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("QuickhelpToolStripButton.Image")));
this.quickhelpToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.quickhelpToolStripButton.Name = "QuickhelpToolStripButton";
this.quickhelpToolStripButton.Size = new System.Drawing.Size(23, 22);
this.quickhelpToolStripButton.Text = "Help";
this.quickhelpToolStripButton.ToolTipText = "Display the mapping tutorial in the OpenRA wiki.";
this.quickhelpToolStripButton.Click += new System.EventHandler(this.HelpToolStripButton_Click);
//
// menuStrip1
//
@@ -584,7 +583,7 @@ namespace OpenRA.Editor
this.saveAsToolStripMenuItem,
this.toolStripSeparator2,
this.toolStripMenuItem1,
this.mnuExport,
this.miniMapExport,
this.toolStripSeparator3,
this.exitToolStripMenuItem});
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
@@ -643,7 +642,7 @@ namespace OpenRA.Editor
// toolStripMenuItem1
//
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.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
@@ -652,33 +651,33 @@ namespace OpenRA.Editor
//
// cCRedAlertMapToolStripMenuItem
//
this.cCRedAlertMapToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("cCRedAlertMapToolStripMenuItem.Image")));
this.cCRedAlertMapToolStripMenuItem.Name = "cCRedAlertMapToolStripMenuItem";
this.cCRedAlertMapToolStripMenuItem.Size = new System.Drawing.Size(188, 22);
this.cCRedAlertMapToolStripMenuItem.Text = "&Legacy Map Format...";
this.cCRedAlertMapToolStripMenuItem.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.Image = ((System.Drawing.Image)(resources.GetObject("cCRedAlertMapToolStripMenuItem.Image")));
this.redAlertMapToolStripMenuItem.Name = "cCRedAlertMapToolStripMenuItem";
this.redAlertMapToolStripMenuItem.Size = new System.Drawing.Size(188, 22);
this.redAlertMapToolStripMenuItem.Text = "&Legacy Map Format...";
this.redAlertMapToolStripMenuItem.ToolTipText = "Import an original C&C / Red Alert and convert it to the .oramap format.";
this.redAlertMapToolStripMenuItem.Click += new System.EventHandler(this.ImportLegacyMapClicked);
//
// mnuExport
//
this.mnuExport.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.mnuMinimapToPNG,
this.miniMapExport.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.miniMapToPng,
this.fullMapRenderToolStripMenuItem});
this.mnuExport.Image = ((System.Drawing.Image)(resources.GetObject("mnuExport.Image")));
this.mnuExport.ImageTransparentColor = System.Drawing.Color.Magenta;
this.mnuExport.Name = "mnuExport";
this.mnuExport.Size = new System.Drawing.Size(123, 22);
this.mnuExport.Text = "&Export";
this.miniMapExport.Image = ((System.Drawing.Image)(resources.GetObject("mnuExport.Image")));
this.miniMapExport.ImageTransparentColor = System.Drawing.Color.Magenta;
this.miniMapExport.Name = "mnuExport";
this.miniMapExport.Size = new System.Drawing.Size(123, 22);
this.miniMapExport.Text = "&Export";
//
// mnuMinimapToPNG
//
this.mnuMinimapToPNG.Enabled = false;
this.mnuMinimapToPNG.Image = ((System.Drawing.Image)(resources.GetObject("mnuMinimapToPNG.Image")));
this.mnuMinimapToPNG.Name = "mnuMinimapToPNG";
this.mnuMinimapToPNG.Size = new System.Drawing.Size(163, 22);
this.mnuMinimapToPNG.Text = "Minimap to PNG";
this.mnuMinimapToPNG.ToolTipText = "Save the map radar display as an image.";
this.mnuMinimapToPNG.Click += new System.EventHandler(this.ExportMinimap);
this.miniMapToPng.Enabled = false;
this.miniMapToPng.Image = ((System.Drawing.Image)(resources.GetObject("mnuMinimapToPNG.Image")));
this.miniMapToPng.Name = "mnuMinimapToPNG";
this.miniMapToPng.Size = new System.Drawing.Size(163, 22);
this.miniMapToPng.Text = "Minimap to PNG";
this.miniMapToPng.ToolTipText = "Save the map radar display as an image.";
this.miniMapToPng.Click += new System.EventHandler(this.ExportMinimap);
//
// fullMapRenderToolStripMenuItem
//
@@ -770,7 +769,7 @@ namespace OpenRA.Editor
this.showRulerToolStripMenuItem.Name = "showRulerToolStripMenuItem";
this.showRulerToolStripMenuItem.Size = new System.Drawing.Size(185, 22);
this.showRulerToolStripMenuItem.Text = "Show Ruler";
this.showRulerToolStripMenuItem.Click += new System.EventHandler(this.showRulerToolStripMenuItemClick);
this.showRulerToolStripMenuItem.Click += new System.EventHandler(this.ShowRulerToolStripMenuItemClick);
//
// toolStripSeparator5
//
@@ -807,7 +806,7 @@ namespace OpenRA.Editor
this.copySelectionToolStripMenuItem.Size = new System.Drawing.Size(185, 22);
this.copySelectionToolStripMenuItem.Text = "Copy Selection";
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
//
@@ -850,7 +849,7 @@ namespace OpenRA.Editor
this.openRAWebsiteToolStripMenuItem.Size = new System.Drawing.Size(183, 22);
this.openRAWebsiteToolStripMenuItem.Text = "OpenRA &Website";
this.openRAWebsiteToolStripMenuItem.ToolTipText = "Visit the OpenRA homepage.";
this.openRAWebsiteToolStripMenuItem.Click += new System.EventHandler(this.openRAWebsiteToolStripMenuItemClick);
this.openRAWebsiteToolStripMenuItem.Click += new System.EventHandler(this.OpenRAWebsiteToolStripMenuItemClick);
//
// openRAResourcesToolStripMenuItem
//
@@ -859,7 +858,7 @@ namespace OpenRA.Editor
this.openRAResourcesToolStripMenuItem.Size = new System.Drawing.Size(183, 22);
this.openRAResourcesToolStripMenuItem.Text = "OpenRA &Resources";
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
//
@@ -868,7 +867,7 @@ namespace OpenRA.Editor
this.wikiDocumentationToolStripMenuItem.Size = new System.Drawing.Size(183, 22);
this.wikiDocumentationToolStripMenuItem.Text = "Wiki &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
//
@@ -877,7 +876,7 @@ namespace OpenRA.Editor
this.discussionForumsToolStripMenuItem.Size = new System.Drawing.Size(183, 22);
this.discussionForumsToolStripMenuItem.Text = "Discussion &Forums";
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
//
@@ -886,7 +885,7 @@ namespace OpenRA.Editor
this.sourceCodeToolStripMenuItem.Size = new System.Drawing.Size(183, 22);
this.sourceCodeToolStripMenuItem.Text = "Source &Code";
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
//
@@ -895,7 +894,7 @@ namespace OpenRA.Editor
this.issueTrackerToolStripMenuItem.Size = new System.Drawing.Size(183, 22);
this.issueTrackerToolStripMenuItem.Text = "Issue &Tracker";
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
//
@@ -904,7 +903,7 @@ namespace OpenRA.Editor
this.developerBountiesToolStripMenuItem.Size = new System.Drawing.Size(183, 22);
this.developerBountiesToolStripMenuItem.Text = "Developer &Bounties";
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
//
@@ -918,7 +917,7 @@ namespace OpenRA.Editor
this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
this.aboutToolStripMenuItem.Size = new System.Drawing.Size(183, 22);
this.aboutToolStripMenuItem.Text = "&About";
this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItemClick);
this.aboutToolStripMenuItem.Click += new System.EventHandler(this.AboutToolStripMenuItemClick);
//
// statusStrip1
//
@@ -949,43 +948,43 @@ namespace OpenRA.Editor
//
// BottomToolStripPanel
//
this.BottomToolStripPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
this.BottomToolStripPanel.Location = new System.Drawing.Point(0, 25);
this.BottomToolStripPanel.Name = "BottomToolStripPanel";
this.BottomToolStripPanel.Orientation = System.Windows.Forms.Orientation.Horizontal;
this.BottomToolStripPanel.RowMargin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.BottomToolStripPanel.Size = new System.Drawing.Size(985, 0);
this.bottomToolStripPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
this.bottomToolStripPanel.Location = new System.Drawing.Point(0, 25);
this.bottomToolStripPanel.Name = "BottomToolStripPanel";
this.bottomToolStripPanel.Orientation = System.Windows.Forms.Orientation.Horizontal;
this.bottomToolStripPanel.RowMargin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.bottomToolStripPanel.Size = new System.Drawing.Size(985, 0);
//
// TopToolStripPanel
//
this.TopToolStripPanel.Dock = System.Windows.Forms.DockStyle.Top;
this.TopToolStripPanel.Location = new System.Drawing.Point(0, 0);
this.TopToolStripPanel.Name = "TopToolStripPanel";
this.TopToolStripPanel.Orientation = System.Windows.Forms.Orientation.Horizontal;
this.TopToolStripPanel.RowMargin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.TopToolStripPanel.Size = new System.Drawing.Size(985, 0);
this.topToolStripPanel.Dock = System.Windows.Forms.DockStyle.Top;
this.topToolStripPanel.Location = new System.Drawing.Point(0, 0);
this.topToolStripPanel.Name = "TopToolStripPanel";
this.topToolStripPanel.Orientation = System.Windows.Forms.Orientation.Horizontal;
this.topToolStripPanel.RowMargin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.topToolStripPanel.Size = new System.Drawing.Size(985, 0);
//
// RightToolStripPanel
//
this.RightToolStripPanel.Dock = System.Windows.Forms.DockStyle.Right;
this.RightToolStripPanel.Location = new System.Drawing.Point(985, 0);
this.RightToolStripPanel.Name = "RightToolStripPanel";
this.RightToolStripPanel.Orientation = System.Windows.Forms.Orientation.Vertical;
this.RightToolStripPanel.RowMargin = new System.Windows.Forms.Padding(0, 3, 0, 0);
this.RightToolStripPanel.Size = new System.Drawing.Size(0, 25);
this.rightToolStripPanel.Dock = System.Windows.Forms.DockStyle.Right;
this.rightToolStripPanel.Location = new System.Drawing.Point(985, 0);
this.rightToolStripPanel.Name = "RightToolStripPanel";
this.rightToolStripPanel.Orientation = System.Windows.Forms.Orientation.Vertical;
this.rightToolStripPanel.RowMargin = new System.Windows.Forms.Padding(0, 3, 0, 0);
this.rightToolStripPanel.Size = new System.Drawing.Size(0, 25);
//
// LeftToolStripPanel
//
this.LeftToolStripPanel.Dock = System.Windows.Forms.DockStyle.Left;
this.LeftToolStripPanel.Location = new System.Drawing.Point(0, 0);
this.LeftToolStripPanel.Name = "LeftToolStripPanel";
this.LeftToolStripPanel.Orientation = System.Windows.Forms.Orientation.Vertical;
this.LeftToolStripPanel.RowMargin = new System.Windows.Forms.Padding(0, 3, 0, 0);
this.LeftToolStripPanel.Size = new System.Drawing.Size(0, 25);
this.leftToolStripPanel.Dock = System.Windows.Forms.DockStyle.Left;
this.leftToolStripPanel.Location = new System.Drawing.Point(0, 0);
this.leftToolStripPanel.Name = "LeftToolStripPanel";
this.leftToolStripPanel.Orientation = System.Windows.Forms.Orientation.Vertical;
this.leftToolStripPanel.RowMargin = new System.Windows.Forms.Padding(0, 3, 0, 0);
this.leftToolStripPanel.Size = new System.Drawing.Size(0, 25);
//
// ContentPanel
//
this.ContentPanel.Size = new System.Drawing.Size(985, 25);
this.contentPanel.Size = new System.Drawing.Size(985, 25);
//
// toolStripContainer1
//
@@ -1039,7 +1038,7 @@ namespace OpenRA.Editor
this.splitContainer2.Panel1.ResumeLayout(false);
this.splitContainer2.Panel2.ResumeLayout(false);
this.splitContainer2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pmMiniMap)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.miniMapBox)).EndInit();
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
@@ -1084,7 +1083,7 @@ namespace OpenRA.Editor
private System.Windows.Forms.TabPage tabPage3;
private System.Windows.Forms.FlowLayoutPanel resourcePalette;
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 splitContainer3;
private System.Windows.Forms.StatusStrip statusStrip1;
@@ -1099,9 +1098,9 @@ namespace OpenRA.Editor
private System.Windows.Forms.ToolStripMenuItem saveAsToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem cCRedAlertMapToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem mnuExport;
private System.Windows.Forms.ToolStripMenuItem mnuMinimapToPNG;
private System.Windows.Forms.ToolStripMenuItem redAlertMapToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem miniMapExport;
private System.Windows.Forms.ToolStripMenuItem miniMapToPng;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem mapToolStripMenuItem;
@@ -1133,12 +1132,12 @@ namespace OpenRA.Editor
private System.Windows.Forms.ToolStrip toolStrip1;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator7;
private System.Windows.Forms.ToolStripButton QuickhelpToolStripButton;
private System.Windows.Forms.ToolStripPanel BottomToolStripPanel;
private System.Windows.Forms.ToolStripPanel TopToolStripPanel;
private System.Windows.Forms.ToolStripPanel RightToolStripPanel;
private System.Windows.Forms.ToolStripPanel LeftToolStripPanel;
private System.Windows.Forms.ToolStripContentPanel ContentPanel;
private System.Windows.Forms.ToolStripButton quickhelpToolStripButton;
private System.Windows.Forms.ToolStripPanel bottomToolStripPanel;
private System.Windows.Forms.ToolStripPanel topToolStripPanel;
private System.Windows.Forms.ToolStripPanel rightToolStripPanel;
private System.Windows.Forms.ToolStripPanel leftToolStripPanel;
private System.Windows.Forms.ToolStripContentPanel contentPanel;
private System.Windows.Forms.ToolStripButton toolStripMenuItemNew;
private System.Windows.Forms.ToolStripButton toolStripMenuItemOpen;
private System.Windows.Forms.ToolStripButton toolStripMenuItemSave;
@@ -1156,4 +1155,3 @@ namespace OpenRA.Editor
private System.Windows.Forms.ToolStripMenuItem fullMapRenderToolStripMenuItem;
}
}

View File

@@ -43,7 +43,7 @@ namespace OpenRA.Editor
actorPalette.ResumeLayout();
resourcePalette.ResumeLayout();
surface1.Bind(null, null, null, null);
pmMiniMap.Image = null;
miniMapBox.Image = null;
currentMod = toolStripComboBox1.SelectedItem as string;
Game.modData = new ModData(currentMod);
@@ -69,13 +69,13 @@ namespace OpenRA.Editor
void OnMapChanged()
{
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();
}
void ActorDoubleClicked(KeyValuePair<string,ActorReference> kv)
void ActorDoubleClicked(KeyValuePair<string, ActorReference> kv)
{
using( var apd = new ActorPropertiesDialog() )
using (var apd = new ActorPropertiesDialog())
{
var name = kv.Key;
apd.AddRow("(Name)", apd.MakeEditorControl(typeof(string), () => name, v => name = (string)v));
@@ -84,11 +84,11 @@ namespace OpenRA.Editor
var objSaved = kv.Value.Save();
// TODO: make this work properly
foreach( var init in Rules.Info[kv.Value.Type].GetInitKeys() )
foreach (var init in Rules.Info[kv.Value.Type].GetInitKeys())
apd.AddRow(init.First,
apd.MakeEditorControl(init.Second,
() => objSaved.NodesDict.ContainsKey( init.First ) ? objSaved.NodesDict[init.First].Value : null,
_ => {}));
() => objSaved.NodesDict.ContainsKey(init.First) ? objSaved.NodesDict[init.First].Value : null,
_ => { }));
apd.ShowDialog();
@@ -120,7 +120,8 @@ namespace OpenRA.Editor
map.MakeDefaultPlayers();
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();
dirty = false;
@@ -144,19 +145,20 @@ namespace OpenRA.Editor
Rules.LoadRules(manifest, map);
tileset = Rules.TileSets[map.Tileset];
tileset.LoadTiles();
int[] ShadowIndex = { 3, 4 };
var palette = new Palette(FileSystem.Open(tileset.Palette), ShadowIndex);
var shadowIndex = new int[] { 3, 4 };
var palette = new Palette(FileSystem.Open(tileset.Palette), shadowIndex);
// required for desert terrain in RA
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
var palettes = new[] { tilePalette, actorPalette, resourcePalette };
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)))
{
var category = tc.Key ?? "(Uncategorized)";
@@ -170,15 +172,16 @@ namespace OpenRA.Editor
TextAlign = ContentAlignment.MiddleLeft,
Width = tilePalette.ClientSize.Width,
};
// hook this manually, anchoring inside FlowLayoutPanel is flaky.
tilePalette.Resize += (_,e) => categoryHeader.Width = tilePalette.ClientSize.Width;
tilePalette.Resize += (_, e) => categoryHeader.Width = tilePalette.ClientSize.Width;
if (tilePalette.Controls.Count > 0)
tilePalette.SetFlowBreak(
tilePalette.Controls[tilePalette.Controls.Count - 1], true);
tilePalette.Controls.Add(categoryHeader);
foreach( var t in tc )
foreach (var t in tc)
{
try
{
@@ -196,12 +199,7 @@ namespace OpenRA.Editor
var template = t.Value;
tilePalette.Controls.Add(ibox);
tt.SetToolTip(ibox,
"{1}:{0} ({2}x{3})".F(
template.Image,
template.Id,
template.Size.X,
template.Size.Y));
tt.SetToolTip(ibox, "{1}:{0} ({2}x{3})".F(template.Image, template.Id, template.Size.X, template.Size.Y));
}
catch { }
}
@@ -222,13 +220,14 @@ namespace OpenRA.Editor
if (etf != null && etf.RequireTilesets != null
&& !etf.RequireTilesets.Contains(tileset.Id)) continue;
var TemplatePalette = PlayerPalette;
var templatePalette = shadowedPalette;
var rsi = info.Traits.GetOrDefault<RenderSimpleInfo>();
// exception for desert buildings
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
{
Image = template.Bitmap,
@@ -242,9 +241,7 @@ namespace OpenRA.Editor
actorPalette.Controls.Add(ibox);
tt.SetToolTip(ibox,
"{0}".F(
info.Name));
tt.SetToolTip(ibox, "{0}".F(info.Name));
actorTemplates.Add(template);
}
@@ -259,7 +256,7 @@ namespace OpenRA.Editor
{
try
{
var template = RenderUtils.RenderResourceType(a, tileset.Extensions, PlayerPalette);
var template = RenderUtils.RenderResourceType(a, tileset.Extensions, shadowedPalette);
var ibox = new PictureBox
{
Image = template.Bitmap,
@@ -269,16 +266,11 @@ namespace OpenRA.Editor
BorderStyle = BorderStyle.FixedSingle
};
ibox.Click += (_, e) => surface1.SetTool(new ResourceTool(template));
resourcePalette.Controls.Add(ibox);
tt.SetToolTip(ibox,
"{0}:{1}cr".F(
template.Info.Name,
template.Info.ValuePerUnit));
tt.SetToolTip(ibox, "{0}:{1}cr".F(template.Info.Name, template.Info.ValuePerUnit));
resourceTemplates.Add(template);
}
@@ -293,7 +285,7 @@ namespace OpenRA.Editor
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;
toolStripMenuItemProperties.Enabled = true;
@@ -302,7 +294,7 @@ namespace OpenRA.Editor
saveToolStripMenuItem.Enabled = true;
toolStripMenuItemSave.Enabled = true;
saveAsToolStripMenuItem.Enabled = true;
mnuMinimapToPNG.Enabled = true; // TODO: what is this VB naming bullshit doing here?
miniMapToPng.Enabled = true;
PopulateActorOwnerChooser();
}
@@ -319,24 +311,24 @@ namespace OpenRA.Editor
{
using (var rd = new ResizeDialog())
{
rd.width.Value = surface1.Map.MapSize.X;
rd.height.Value = surface1.Map.MapSize.Y;
rd.cordonLeft.Value = surface1.Map.Bounds.Left;
rd.cordonTop.Value = surface1.Map.Bounds.Top;
rd.cordonRight.Value = surface1.Map.Bounds.Right;
rd.cordonBottom.Value = surface1.Map.Bounds.Bottom;
rd.MapWidth.Value = surface1.Map.MapSize.X;
rd.MapHeight.Value = surface1.Map.MapSize.Y;
rd.CordonLeft.Value = surface1.Map.Bounds.Left;
rd.CordonTop.Value = surface1.Map.Bounds.Top;
rd.CordonRight.Value = surface1.Map.Bounds.Right;
rd.CordonBottom.Value = surface1.Map.Bounds.Bottom;
if (DialogResult.OK != rd.ShowDialog())
return;
surface1.Map.ResizeCordon((int)rd.cordonLeft.Value,
(int)rd.cordonTop.Value,
(int)rd.cordonRight.Value,
(int)rd.cordonBottom.Value);
surface1.Map.ResizeCordon((int)rd.CordonLeft.Value,
(int)rd.CordonTop.Value,
(int)rd.CordonRight.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
}
@@ -353,25 +345,24 @@ namespace OpenRA.Editor
surface1.Map.Save(loadedMapName);
dirty = false;
}
}
void SaveAsClicked(object sender, EventArgs e)
{
using (var nms = new MapSelect(currentMod))
{
nms.txtNew.ReadOnly = false;
nms.btnOk.Text = "Save";
nms.txtNew.Text = "unnamed";
nms.txtPathOut.ReadOnly = false;
nms.NewText.ReadOnly = false;
nms.ButtonOkay.Text = "Save";
nms.NewText.Text = "unnamed";
nms.PathOutText.ReadOnly = false;
if (DialogResult.OK == nms.ShowDialog())
{
if (nms.txtNew.Text == "")
nms.txtNew.Text = "unnamed";
if (nms.NewText.Text == "")
nms.NewText.Text = "unnamed";
// 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);
}
}
@@ -381,12 +372,12 @@ namespace OpenRA.Editor
{
using (var nms = new MapSelect(currentMod))
{
nms.txtNew.ReadOnly = true;
nms.txtPathOut.ReadOnly = true;
nms.btnOk.Text = "Open";
nms.NewText.ReadOnly = true;
nms.PathOutText.ReadOnly = true;
nms.ButtonOkay.Text = "Open";
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())
{
nmd.theater.Items.Clear();
nmd.theater.Items.AddRange(Rules.TileSets.Select(a => a.Value.Id).ToArray());
nmd.theater.SelectedIndex = 0;
nmd.TheaterBox.Items.Clear();
nmd.TheaterBox.Items.AddRange(Rules.TileSets.Select(a => a.Value.Id).ToArray());
nmd.TheaterBox.SelectedIndex = 0;
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.ResizeCordon((int)nmd.cordonLeft.Value, (int)nmd.cordonTop.Value,
(int)nmd.cordonRight.Value, (int)nmd.cordonBottom.Value);
map.Resize((int)nmd.MapWidth.Value, (int)nmd.MapHeight.Value);
map.ResizeCordon((int)nmd.CordonLeft.Value, (int)nmd.CordonTop.Value,
(int)nmd.CordonRight.Value, (int)nmd.CordonBottom.Value);
map.Players.Clear();
map.MakeDefaultPlayers();
@@ -418,20 +409,20 @@ namespace OpenRA.Editor
{
using (var pd = new PropertiesDialog())
{
pd.title.Text = surface1.Map.Title;
pd.desc.Text = surface1.Map.Description;
pd.author.Text = surface1.Map.Author;
pd.selectable.Checked = surface1.Map.Selectable;
pd.useAsShellmap.Checked = surface1.Map.UseAsShellmap;
pd.TitleBox.Text = surface1.Map.Title;
pd.DescBox.Text = surface1.Map.Description;
pd.AuthorBox.Text = surface1.Map.Author;
pd.SelectableCheckBox.Checked = surface1.Map.Selectable;
pd.ShellmapCheckBox.Checked = surface1.Map.UseAsShellmap;
if (DialogResult.OK != pd.ShowDialog())
return;
surface1.Map.Title = pd.title.Text;
surface1.Map.Description = pd.desc.Text;
surface1.Map.Author = pd.author.Text;
surface1.Map.Selectable = pd.selectable.Checked;
surface1.Map.UseAsShellmap = pd.useAsShellmap.Checked;
surface1.Map.Title = pd.TitleBox.Text;
surface1.Map.Description = pd.DescBox.Text;
surface1.Map.Author = pd.AuthorBox.Text;
surface1.Map.Selectable = pd.SelectableCheckBox.Checked;
surface1.Map.UseAsShellmap = pd.ShellmapCheckBox.Checked;
}
}
@@ -489,15 +480,18 @@ namespace OpenRA.Editor
void ExportMinimap(object sender, EventArgs e)
{
using( var sfd = new SaveFileDialog() {
using (var sfd = new SaveFileDialog()
{
InitialDirectory = Path.Combine(Environment.CurrentDirectory, "maps"),
DefaultExt = "*.png",
Filter = "PNG Image (*.png)|*.png",
Title = "Export Minimap to PNG",
FileName = Path.ChangeExtension(loadedMapName, ".png"),
RestoreDirectory = true } )
RestoreDirectory = true
})
if (DialogResult.OK == sfd.ShowDialog())
pmMiniMap.Image.Save(sfd.FileName);
miniMapBox.Image.Save(sfd.FileName);
}
void ShowActorNamesClicked(object sender, EventArgs e)
@@ -559,10 +553,10 @@ namespace OpenRA.Editor
return;
var color = player.Color.RGB;
using( var brush = new SolidBrush(color) )
e.Graphics.FillRectangle( brush, e.Bounds.Left + 2, e.Bounds.Top + 2, e.Bounds.Height + 6, e.Bounds.Height - 4 );
using( var foreBrush = new SolidBrush(e.ForeColor) )
e.Graphics.DrawString( player.Name, e.Font, foreBrush, e.Bounds.Left + e.Bounds.Height + 12, e.Bounds.Top );
using (var brush = new SolidBrush(color))
e.Graphics.FillRectangle(brush, e.Bounds.Left + 2, e.Bounds.Top + 2, e.Bounds.Height + 6, e.Bounds.Height - 4);
using (var foreBrush = new SolidBrush(e.ForeColor))
e.Graphics.DrawString(player.Name, e.Font, foreBrush, e.Bounds.Left + e.Bounds.Height + 12, e.Bounds.Top);
}
void OnSelectedPlayerChanged(object sender, EventArgs e)
@@ -571,47 +565,47 @@ namespace OpenRA.Editor
surface1.NewActorOwner = player.Name;
}
private void copySelectionToolStripMenuItemClick(object sender, EventArgs e)
void CopySelectionToolStripMenuItemClick(object sender, EventArgs e)
{
surface1.CopySelection();
}
private void openRAWebsiteToolStripMenuItemClick(object sender, EventArgs e)
void OpenRAWebsiteToolStripMenuItemClick(object sender, EventArgs e)
{
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");
}
private void wikiDocumentationToolStripMenuItemClick(object sender, EventArgs e)
void WikiDocumentationToolStripMenuItemClick(object sender, EventArgs e)
{
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");
}
private void issueTrackerToolStripMenuItemClick(object sender, EventArgs e)
void IssueTrackerToolStripMenuItemClick(object sender, EventArgs e)
{
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");
}
private void sourceCodeToolStripMenuItemClick(object sender, EventArgs e)
void SourceCodeToolStripMenuItemClick(object sender, EventArgs e)
{
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.",
"About",
@@ -619,74 +613,75 @@ namespace OpenRA.Editor
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");
}
private void toolStripMenuItemNewClick(object sender, EventArgs e)
void ToolStripMenuItemNewClick(object sender, EventArgs e)
{
NewClicked(sender, e);
}
private void toolStripMenuItemOpenClick(object sender, EventArgs e)
void ToolStripMenuItemOpenClick(object sender, EventArgs e)
{
OpenClicked(sender, e);
}
private void toolStripMenuItemSaveClick(object sender, EventArgs e)
void ToolStripMenuItemSaveClick(object sender, EventArgs e)
{
SaveClicked(sender, e);
}
private void toolStripMenuItemPropertiesClick(object sender, EventArgs e)
void ToolStripMenuItemPropertiesClick(object sender, EventArgs e)
{
PropertiesClicked(sender, e);
}
private void toolStripMenuItemResizeClick(object sender, EventArgs e)
void ToolStripMenuItemResizeClick(object sender, EventArgs e)
{
ResizeClicked(sender, e);
}
private void toolStripMenuItemShowActorNamesClick(object sender, EventArgs e)
void ToolStripMenuItemShowActorNamesClick(object sender, EventArgs e)
{
ShowActorNamesClicked(sender, e);
}
private void toolStripMenuItemFixOpenAreasClick(object sender, EventArgs e)
void ToolStripMenuItemFixOpenAreasClick(object sender, EventArgs e)
{
FixOpenAreas(sender, e);
}
private void toolStripMenuItemSetupDefaultPlayersClick(object sender, EventArgs e)
void ToolStripMenuItemSetupDefaultPlayersClick(object sender, EventArgs 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);
}
public int CalculateTotalResource()
{
int TotalResource = 0;
for(int i = 0; i < surface1.Map.MapSize.X; i++)
int totalResource = 0;
for (int i = 0; i < surface1.Map.MapSize.X; i++)
for (int j = 0; j < surface1.Map.MapSize.Y; j++)
{
if (surface1.Map.MapResources.Value[i, j].type != 0)
TotalResource += GetResourceValue(i, j);
}
return TotalResource;
totalResource += GetResourceValue(i, j);
}
int GetAdjecentCellsWith(int ResourceType, int x, int y)
return totalResource;
}
int GetAdjecentCellsWith(int resourceType, int x, int y)
{
int sum = 0;
for (var u = -1; u < 2; u++)
@@ -694,27 +689,28 @@ namespace OpenRA.Editor
{
if (!surface1.Map.IsInMap(new CPos(x + u, y + v)))
continue;
if (surface1.Map.MapResources.Value[x + u, y + v].type == ResourceType)
if (surface1.Map.MapResources.Value[x + u, y + v].type == resourceType)
++sum;
}
return sum;
}
int GetResourceValue(int x, int y)
{
int ImageLength = 0;
int imageLength = 0;
int type = surface1.Map.MapResources.Value[x, y].type;
var template = surface1.ResourceTemplates.Where(a => a.Value.Info.ResourceType == type).FirstOrDefault().Value;
if (type == 1)
ImageLength = 12;
imageLength = 12;
else if (type == 2)
ImageLength = 3;
int density = (GetAdjecentCellsWith(type ,x , y) * ImageLength - 1) / 9;
imageLength = 3;
int density = (GetAdjecentCellsWith(type, x, y) * imageLength - 1) / 9;
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;
@@ -723,7 +719,7 @@ namespace OpenRA.Editor
surface1.Invalidate();
}
void zoomOutToolStripButtonClick(object sender, System.EventArgs e)
void ZoomOutToolStripButtonClick(object sender, System.EventArgs e)
{
if (surface1.Map == null) return;
@@ -732,13 +728,13 @@ namespace OpenRA.Editor
surface1.Invalidate();
}
void panToolStripButtonClick(object sender, System.EventArgs e)
void PanToolStripButtonClick(object sender, System.EventArgs e)
{
panToolStripButton.Checked ^= true;
surface1.IsPanning = panToolStripButton.Checked;
}
void showRulerToolStripMenuItemClick(object sender, EventArgs e)
void ShowRulerToolStripMenuItemClick(object sender, EventArgs e)
{
showRulerToolStripMenuItem.Checked ^= true;
showRulerToolStripItem.Checked ^= true;
@@ -746,9 +742,9 @@ namespace OpenRA.Editor
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)

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Editor
public class LegacyMapImporter
{
// Mapping from ra overlay index to type string
static string[] raOverlayNames =
static string[] redAlertOverlayNames =
{
"sbag", "cycl", "brik", "fenc", "wood",
"gold01", "gold02", "gold03", "gold04",
@@ -34,73 +34,77 @@ namespace OpenRA.Editor
static Dictionary<string, Pair<byte, byte>> overlayResourceMapping = new Dictionary<string, Pair<byte, byte>>()
{
// RA Gems, Gold
{ "gold01", new Pair<byte,byte>(1,0) },
{ "gold02", new Pair<byte,byte>(1,1) },
{ "gold03", new Pair<byte,byte>(1,2) },
{ "gold04", new Pair<byte,byte>(1,3) },
// RA Gold & Gems
{ "gold01", new Pair<byte, byte>(1, 0) },
{ "gold02", new Pair<byte, byte>(1, 1) },
{ "gold03", new Pair<byte, byte>(1, 2) },
{ "gold04", new Pair<byte, byte>(1, 3) },
{ "gem01", new Pair<byte, byte>(2, 0) },
{ "gem02", new Pair<byte, byte>(2, 1) },
{ "gem03", new Pair<byte, byte>(2, 2) },
{ "gem04", new Pair<byte, byte>(2, 3) },
{ "gem01", new Pair<byte,byte>(2,0) },
{ "gem02", new Pair<byte,byte>(2,1) },
{ "gem03", new Pair<byte,byte>(2,2) },
{ "gem04", new Pair<byte,byte>(2,3) },
// cnc tiberium
{ "ti1", new Pair<byte,byte>(1,0) },
{ "ti2", new Pair<byte,byte>(1,1) },
{ "ti3", new Pair<byte,byte>(1,2) },
{ "ti4", new Pair<byte,byte>(1,3) },
{ "ti5", new Pair<byte,byte>(1,4) },
{ "ti6", new Pair<byte,byte>(1,5) },
{ "ti7", new Pair<byte,byte>(1,6) },
{ "ti8", new Pair<byte,byte>(1,7) },
{ "ti9", new Pair<byte,byte>(1,8) },
{ "ti10", new Pair<byte,byte>(1,9) },
{ "ti11", new Pair<byte,byte>(1,10) },
{ "ti12", new Pair<byte,byte>(1,11) },
// CnC Tiberium
{ "ti1", new Pair<byte, byte>(1, 0) },
{ "ti2", new Pair<byte, byte>(1, 1) },
{ "ti3", new Pair<byte, byte>(1, 2) },
{ "ti4", new Pair<byte, byte>(1, 3) },
{ "ti5", new Pair<byte, byte>(1, 4) },
{ "ti6", new Pair<byte, byte>(1, 5) },
{ "ti7", new Pair<byte, byte>(1, 6) },
{ "ti8", new Pair<byte, byte>(1, 7) },
{ "ti9", new Pair<byte, byte>(1, 8) },
{ "ti10", new Pair<byte, byte>(1, 9) },
{ "ti11", new Pair<byte, byte>(1, 10) },
{ "ti12", new Pair<byte, byte>(1, 11) },
};
static Dictionary<string, string> overlayActorMapping = new Dictionary<string, string>() {
// Fences
{"sbag","sbag"},
{"cycl","cycl"},
{"brik","brik"},
{"fenc","fenc"},
{"wood","wood"},
{ "sbag", "sbag" },
{ "cycl", "cycl" },
{ "brik", "brik" },
{ "fenc", "fenc" },
{ "wood", "wood" },
// Fields
{"v12","v12"},
{"v13","v13"},
{"v14","v14"},
{"v15","v15"},
{"v16","v16"},
{"v17","v17"},
{"v18","v18"},
{ "v12", "v12" },
{ "v13", "v13" },
{ "v14", "v14" },
{ "v15", "v15" },
{ "v16", "v16" },
{ "v17", "v17" },
{ "v18", "v18" },
// Crates
// {"wcrate","crate"},
// {"scrate","crate"},
// { "wcrate", "crate" },
// { "scrate", "crate" },
};
// TODO: fix this -- will have bitrotted pretty badly.
static Dictionary<string, HSLColor> namedColorMapping = new Dictionary<string, HSLColor>()
{
{ "gold", HSLColor.FromRGB(246,214,121) },
{ "blue", HSLColor.FromRGB(226,230,246) },
{ "red", HSLColor.FromRGB(255,20,0) },
{ "neutral", HSLColor.FromRGB(238,238,238) },
{ "orange", HSLColor.FromRGB(255,230,149) },
{ "teal", HSLColor.FromRGB(93,194,165) },
{ "salmon", HSLColor.FromRGB(210,153,125) },
{ "green", HSLColor.FromRGB(160,240,140) },
{ "white", HSLColor.FromRGB(255,255,255) },
{ "black", HSLColor.FromRGB(80,80,80) },
{ "gold", HSLColor.FromRGB(246, 214, 121) },
{ "blue", HSLColor.FromRGB(226, 230, 246) },
{ "red", HSLColor.FromRGB(255, 20, 0) },
{ "neutral", HSLColor.FromRGB(238, 238, 238) },
{ "orange", HSLColor.FromRGB(255, 230, 149) },
{ "teal", HSLColor.FromRGB(93, 194, 165) },
{ "salmon", HSLColor.FromRGB(210, 153, 125) },
{ "green", HSLColor.FromRGB(160, 240, 140) },
{ "white", HSLColor.FromRGB(255, 255, 255) },
{ "black", HSLColor.FromRGB(80, 80, 80) },
};
int MapSize;
int ActorCount = 0;
Map Map = new Map();
List<string> Players = new List<string>();
static string Truncate(string s, int maxLength)
{
return s.Length <= maxLength ? s : s.Substring(0, maxLength);
}
int mapSize;
int actorCount = 0;
Map map = new Map();
List<string> players = new List<string>();
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)
{
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)
{
var file = new IniFile(FileSystem.Open(iniFile));
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 XOffset = int.Parse(map.GetValue("X", "0"));
var YOffset = int.Parse(map.GetValue("Y", "0"));
var Width = int.Parse(map.GetValue("Width", "0"));
var Height = int.Parse(map.GetValue("Height", "0"));
MapSize = (legacyMapFormat == IniMapFormat.RedAlert) ? 128 : 64;
var offsetX = int.Parse(mapSection.GetValue("X", "0"));
var offsetY = int.Parse(mapSection.GetValue("Y", "0"));
var width = int.Parse(mapSection.GetValue("Width", "0"));
var height = int.Parse(mapSection.GetValue("Height", "0"));
mapSize = (legacyMapFormat == IniMapFormat.RedAlert) ? 128 : 64;
Map.Title = basic.GetValue("Name", "(null)");
Map.Author = "Westwood Studios";
Map.Tileset = Truncate(map.GetValue("Theater", "TEMPERAT"), 8);
Map.MapSize.X = MapSize;
Map.MapSize.Y = MapSize;
Map.Bounds = Rectangle.FromLTRB(XOffset, YOffset, XOffset + Width, YOffset + Height);
Map.Selectable = true;
map.Title = basic.GetValue("Name", "(null)");
map.Author = "Westwood Studios";
map.Tileset = Truncate(mapSection.GetValue("Theater", "TEMPERAT"), 8);
map.MapSize.X = mapSize;
map.MapSize.Y = mapSize;
map.Bounds = Rectangle.FromLTRB(offsetX, offsetY, offsetX + width, offsetY + height);
map.Selectable = true;
Map.Smudges = Lazy.New(() => new List<SmudgeReference>());
Map.Actors = Lazy.New(() => new Dictionary<string, ActorReference>());
Map.MapResources = Lazy.New(() => new TileReference<byte, byte>[MapSize, MapSize]);
Map.MapTiles = Lazy.New(() => new TileReference<ushort, byte>[MapSize, MapSize]);
map.Smudges = Lazy.New(() => new List<SmudgeReference>());
map.Actors = Lazy.New(() => new Dictionary<string, ActorReference>());
map.MapResources = Lazy.New(() => new TileReference<byte, byte>[mapSize, mapSize]);
map.MapTiles = Lazy.New(() => new TileReference<ushort, byte>[mapSize, mapSize]);
if (legacyMapFormat == IniMapFormat.RedAlert)
{
@@ -149,8 +152,9 @@ namespace OpenRA.Editor
UnpackRAOverlayData(ReadPackedSection(file.GetSection("OverlayPack")));
ReadRATrees(file);
}
else // CNC
else
{
// CnC
UnpackCncTileData(FileSystem.Open(iniFile.Substring(0, iniFile.Length - 4) + ".bin"));
ReadCncOverlay(file);
ReadCncTrees(file);
@@ -161,25 +165,23 @@ namespace OpenRA.Editor
LoadActors(file, "INFANTRY");
LoadSmudges(file, "SMUDGE");
foreach (var p in Players)
LoadPlayer(file, p, (legacyMapFormat == IniMapFormat.RedAlert));
foreach (var p in players)
LoadPlayer(file, p, legacyMapFormat == IniMapFormat.RedAlert);
var wps = file.GetSection("Waypoints")
.Where(kv => int.Parse(kv.Value) > 0)
.Select(kv => Pair.New(int.Parse(kv.Key),
LocationFromMapOffset(int.Parse(kv.Value), MapSize)))
LocationFromMapOffset(int.Parse(kv.Value), mapSize)))
.ToArray();
// Add waypoint actors
foreach( var kv in wps )
foreach (var kv in wps)
{
var a = new ActorReference("waypoint");
a.Add(new LocationInit((CPos)kv.Second));
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)
@@ -190,7 +192,7 @@ namespace OpenRA.Editor
static MemoryStream ReadPackedSection(IniSection mapPackSection)
{
var sb = new StringBuilder();
for (int i = 1; ; i++)
for (int i = 1;; i++)
{
var line = mapPackSection.GetValue(i.ToString(), null);
if (line == null)
@@ -246,38 +248,38 @@ namespace OpenRA.Editor
void UnpackRATileData(MemoryStream ms)
{
for (int i = 0; i < MapSize; i++)
for (int j = 0; j < MapSize; j++)
Map.MapTiles.Value[i, j] = new TileReference<ushort, byte>();
for (int i = 0; i < mapSize; i++)
for (int j = 0; j < mapSize; j++)
map.MapTiles.Value[i, j] = new TileReference<ushort, byte>();
for (int j = 0; j < MapSize; j++)
for (int i = 0; i < MapSize; i++)
Map.MapTiles.Value[i, j].type = ReadWord(ms);
for (int j = 0; j < mapSize; j++)
for (int i = 0; i < mapSize; i++)
map.MapTiles.Value[i, j].type = ReadWord(ms);
for (int j = 0; j < MapSize; j++)
for (int i = 0; i < MapSize; i++)
Map.MapTiles.Value[i, j].index = ReadByte(ms);
for (int j = 0; j < mapSize; j++)
for (int i = 0; i < mapSize; i++)
map.MapTiles.Value[i, j].index = ReadByte(ms);
}
void UnpackRAOverlayData(MemoryStream ms)
{
for (int j = 0; j < MapSize; j++)
for (int i = 0; i < MapSize; i++)
for (int j = 0; j < mapSize; j++)
for (int i = 0; i < mapSize; i++)
{
byte o = ReadByte(ms);
var res = Pair.New((byte)0, (byte)0);
if (o != 255 && overlayResourceMapping.ContainsKey(raOverlayNames[o]))
res = overlayResourceMapping[raOverlayNames[o]];
if (o != 255 && overlayResourceMapping.ContainsKey(redAlertOverlayNames[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]))
Map.Actors.Value.Add("Actor" + ActorCount++,
new ActorReference(overlayActorMapping[raOverlayNames[o]])
if (o != 255 && overlayActorMapping.ContainsKey(redAlertOverlayNames[o]))
map.Actors.Value.Add("Actor" + actorCount++,
new ActorReference(overlayActorMapping[redAlertOverlayNames[o]])
{
new LocationInit( new CPos(i, j) ),
new OwnerInit( "Neutral" )
new LocationInit(new CPos(i, j)),
new OwnerInit("Neutral")
});
}
}
@@ -291,10 +293,10 @@ namespace OpenRA.Editor
foreach (KeyValuePair<string, string> kv in terrain)
{
var loc = int.Parse(kv.Key);
Map.Actors.Value.Add("Actor" + ActorCount++,
map.Actors.Value.Add("Actor" + actorCount++,
new ActorReference(kv.Value.ToLowerInvariant())
{
new LocationInit(new CPos(loc % MapSize, loc / MapSize)),
new LocationInit(new CPos(loc % mapSize, loc / mapSize)),
new OwnerInit("Neutral")
});
}
@@ -302,15 +304,15 @@ namespace OpenRA.Editor
void UnpackCncTileData(Stream ms)
{
for (int i = 0; i < MapSize; i++)
for (int j = 0; j < MapSize; j++)
Map.MapTiles.Value[i, j] = new TileReference<ushort, byte>();
for (int i = 0; i < mapSize; i++)
for (int j = 0; j < mapSize; j++)
map.MapTiles.Value[i, j] = new TileReference<ushort, byte>();
for (int j = 0; j < MapSize; j++)
for (int i = 0; i < MapSize; i++)
for (int j = 0; j < mapSize; j++)
for (int i = 0; i < mapSize; i++)
{
Map.MapTiles.Value[i, j].type = ReadByte(ms);
Map.MapTiles.Value[i, j].index = ReadByte(ms);
map.MapTiles.Value[i, j].type = ReadByte(ms);
map.MapTiles.Value[i, j].index = ReadByte(ms);
}
}
@@ -323,16 +325,16 @@ namespace OpenRA.Editor
foreach (KeyValuePair<string, string> kv in overlay)
{
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);
if (overlayResourceMapping.ContainsKey(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()))
Map.Actors.Value.Add("Actor" + ActorCount++,
map.Actors.Value.Add("Actor" + actorCount++,
new ActorReference(overlayActorMapping[kv.Value.ToLower()])
{
new LocationInit(cell),
@@ -350,10 +352,10 @@ namespace OpenRA.Editor
foreach (KeyValuePair<string, string> kv in terrain)
{
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 LocationInit(new CPos(loc % MapSize, loc / MapSize)),
new LocationInit(new CPos(loc % mapSize, loc / mapSize)),
new OwnerInit("Neutral")
});
}
@@ -363,26 +365,24 @@ namespace OpenRA.Editor
{
foreach (var s in file.GetSection(section, true))
{
//Structures: num=owner,type,health,location,turret-facing,trigger
//Units: num=owner,type,health,location,facing,action,trigger
//Infantry: num=owner,type,health,location,subcell,action,facing,trigger
// Structures: num=owner,type,health,location,turret-facing,trigger
// Units: num=owner,type,health,location,facing,action,trigger
// Infantry: num=owner,type,health,location,subcell,action,facing,trigger
try
{
var parts = s.Value.Split(',');
var loc = int.Parse(parts[3]);
if (parts[0] == "")
parts[0] = "Neutral";
if (!Players.Contains(parts[0]))
Players.Add(parts[0]);
if (!players.Contains(parts[0]))
players.Add(parts[0]);
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 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])),
};
@@ -392,7 +392,7 @@ namespace OpenRA.Editor
if (!Rules.Info.ContainsKey(parts[1].ToLowerInvariant()))
errorHandler("Ignoring unknown actor type: `{0}`".F(parts[1].ToLowerInvariant()));
else
Map.Actors.Value.Add("Actor" + ActorCount++, actor);
map.Actors.Value.Add("Actor" + actorCount++, actor);
}
catch (Exception)
{
@@ -405,10 +405,10 @@ namespace OpenRA.Editor
{
foreach (var s in file.GetSection(section, true))
{
//loc=type,loc,depth
// loc=type,loc,depth
var parts = s.Value.Split(',');
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])));
}
}
@@ -444,7 +444,7 @@ namespace OpenRA.Editor
break;
case "Greece":
case "GoodGuy":
c = isRA? "blue" : "gold";
c = isRA ? "blue" : "gold";
race = isRA ? "allies" : "gdi";
break;
case "USSR":
@@ -469,28 +469,23 @@ namespace OpenRA.Editor
Color = namedColorMapping[c]
};
var neutral = new [] {"Neutral"};
var neutral = new[] { "Neutral" };
foreach (var s in file.GetSection(section, true))
{
Console.WriteLine(s.Key);
switch(s.Key)
switch (s.Key)
{
case "Credits":
pr.InitialCash = int.Parse(s.Value);
break;
case "Allies":
pr.Allies = s.Value.Split(',').Intersect(Players).Except(neutral).ToArray();
pr.Enemies = s.Value.Split(',').SymmetricDifference(Players).Except(neutral).ToArray();
pr.Allies = s.Value.Split(',').Intersect(players).Except(neutral).ToArray();
pr.Enemies = s.Value.Split(',').SymmetricDifference(players).Except(neutral).ToArray();
break;
}
}
Map.Players.Add(section, pr);
}
static string Truncate(string s, int maxLength)
{
return s.Length <= maxLength ? s : s.Substring(0, maxLength);
map.Players.Add(section, pr);
}
}
}

View File

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

View File

@@ -40,7 +40,7 @@ namespace OpenRA.Editor
void MapSelect_Load(object sender, EventArgs e)
{
MapList.Items.Clear();
txtPathOut.Text = MapFolderPath;
PathOutText.Text = MapFolderPath;
if (DirectoryIsEmpty(MapFolderPath))
return;
@@ -55,7 +55,7 @@ namespace OpenRA.Editor
}
// hack
if (txtNew.Text != "unnamed")
if (NewText.Text != "unnamed")
MapList.Items[0].Selected = true;
}
@@ -63,31 +63,30 @@ namespace OpenRA.Editor
{
if (MapList.SelectedItems.Count == 1)
{
txtNew.Text = MapList.SelectedItems[0].Text;
txtNew.Tag = MapList.SelectedItems[0].Tag;
NewText.Text = MapList.SelectedItems[0].Text;
NewText.Tag = MapList.SelectedItems[0].Tag;
var map = new Map(txtNew.Tag as string);
txtTitle.Text = map.Title;
txtAuthor.Text = map.Author;
txtTheater.Text = map.Tileset;
txtDesc.Text = map.Description;
pbMinimap.Image = null;
var map = new Map(NewText.Tag as string);
TitleText.Text = map.Title;
AuthorText.Text = map.Author;
TheaterText.Text = map.Tileset;
DescTxt.Text = map.Description;
MiniMapBox.Image = null;
try
{
pbMinimap.Image = Minimap.AddStaticResources(map, Minimap.TerrainBitmap(map, true));
MiniMapBox.Image = Minimap.AddStaticResources(map, Minimap.TerrainBitmap(map, true));
}
catch (Exception ed)
{
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)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
@@ -43,20 +42,20 @@ namespace OpenRA.Editor
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.cordonBottom = new System.Windows.Forms.NumericUpDown();
this.cordonTop = new System.Windows.Forms.NumericUpDown();
this.cordonRight = new System.Windows.Forms.NumericUpDown();
this.cordonLeft = new System.Windows.Forms.NumericUpDown();
this.height = new System.Windows.Forms.NumericUpDown();
this.width = new System.Windows.Forms.NumericUpDown();
this.CordonBottom = new System.Windows.Forms.NumericUpDown();
this.CordonTop = new System.Windows.Forms.NumericUpDown();
this.CordonRight = new System.Windows.Forms.NumericUpDown();
this.CordonLeft = new System.Windows.Forms.NumericUpDown();
this.MapHeight = new System.Windows.Forms.NumericUpDown();
this.MapWidth = new System.Windows.Forms.NumericUpDown();
this.label4 = new System.Windows.Forms.Label();
this.theater = new System.Windows.Forms.ComboBox();
((System.ComponentModel.ISupportInitialize)(this.cordonBottom)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.cordonTop)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.cordonRight)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.cordonLeft)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.height)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.width)).BeginInit();
this.TheaterBox = new System.Windows.Forms.ComboBox();
((System.ComponentModel.ISupportInitialize)(this.CordonBottom)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.CordonTop)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.CordonRight)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.CordonLeft)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.MapHeight)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.MapWidth)).BeginInit();
this.SuspendLayout();
//
// button2
@@ -108,121 +107,121 @@ namespace OpenRA.Editor
//
// cordonBottom
//
this.cordonBottom.Location = new System.Drawing.Point(280, 75);
this.cordonBottom.Maximum = new decimal(new int[] {
this.CordonBottom.Location = new System.Drawing.Point(280, 75);
this.CordonBottom.Maximum = new decimal(new int[] {
2048,
0,
0,
0});
this.cordonBottom.Name = "cordonBottom";
this.cordonBottom.Size = new System.Drawing.Size(105, 20);
this.cordonBottom.TabIndex = 5;
this.cordonBottom.Value = new decimal(new int[] {
this.CordonBottom.Name = "cordonBottom";
this.CordonBottom.Size = new System.Drawing.Size(105, 20);
this.CordonBottom.TabIndex = 5;
this.CordonBottom.Value = new decimal(new int[] {
112,
0,
0,
0});
this.cordonBottom.Enter += new System.EventHandler(this.SelectText);
this.CordonBottom.Enter += new System.EventHandler(this.SelectText);
//
// cordonTop
//
this.cordonTop.Location = new System.Drawing.Point(280, 49);
this.cordonTop.Maximum = new decimal(new int[] {
this.CordonTop.Location = new System.Drawing.Point(280, 49);
this.CordonTop.Maximum = new decimal(new int[] {
2048,
0,
0,
0});
this.cordonTop.Name = "cordonTop";
this.cordonTop.Size = new System.Drawing.Size(105, 20);
this.cordonTop.TabIndex = 3;
this.cordonTop.Value = new decimal(new int[] {
this.CordonTop.Name = "cordonTop";
this.CordonTop.Size = new System.Drawing.Size(105, 20);
this.CordonTop.TabIndex = 3;
this.CordonTop.Value = new decimal(new int[] {
16,
0,
0,
0});
this.cordonTop.Enter += new System.EventHandler(this.SelectText);
this.CordonTop.Enter += new System.EventHandler(this.SelectText);
//
// cordonRight
//
this.cordonRight.Location = new System.Drawing.Point(169, 75);
this.cordonRight.Maximum = new decimal(new int[] {
this.CordonRight.Location = new System.Drawing.Point(169, 75);
this.CordonRight.Maximum = new decimal(new int[] {
2048,
0,
0,
0});
this.cordonRight.Name = "cordonRight";
this.cordonRight.Size = new System.Drawing.Size(105, 20);
this.cordonRight.TabIndex = 4;
this.cordonRight.Value = new decimal(new int[] {
this.CordonRight.Name = "cordonRight";
this.CordonRight.Size = new System.Drawing.Size(105, 20);
this.CordonRight.TabIndex = 4;
this.CordonRight.Value = new decimal(new int[] {
112,
0,
0,
0});
this.cordonRight.Enter += new System.EventHandler(this.SelectText);
this.CordonRight.Enter += new System.EventHandler(this.SelectText);
//
// cordonLeft
//
this.cordonLeft.Location = new System.Drawing.Point(169, 49);
this.cordonLeft.Maximum = new decimal(new int[] {
this.CordonLeft.Location = new System.Drawing.Point(169, 49);
this.CordonLeft.Maximum = new decimal(new int[] {
2048,
0,
0,
0});
this.cordonLeft.Name = "cordonLeft";
this.cordonLeft.Size = new System.Drawing.Size(105, 20);
this.cordonLeft.TabIndex = 2;
this.cordonLeft.Value = new decimal(new int[] {
this.CordonLeft.Name = "cordonLeft";
this.CordonLeft.Size = new System.Drawing.Size(105, 20);
this.CordonLeft.TabIndex = 2;
this.CordonLeft.Value = new decimal(new int[] {
16,
0,
0,
0});
this.cordonLeft.Enter += new System.EventHandler(this.SelectText);
this.CordonLeft.Enter += new System.EventHandler(this.SelectText);
//
// height
//
this.height.Increment = new decimal(new int[] {
this.MapHeight.Increment = new decimal(new int[] {
8,
0,
0,
0});
this.height.Location = new System.Drawing.Point(280, 23);
this.height.Maximum = new decimal(new int[] {
this.MapHeight.Location = new System.Drawing.Point(280, 23);
this.MapHeight.Maximum = new decimal(new int[] {
2048,
0,
0,
0});
this.height.Name = "height";
this.height.Size = new System.Drawing.Size(105, 20);
this.height.TabIndex = 1;
this.height.Value = new decimal(new int[] {
this.MapHeight.Name = "height";
this.MapHeight.Size = new System.Drawing.Size(105, 20);
this.MapHeight.TabIndex = 1;
this.MapHeight.Value = new decimal(new int[] {
128,
0,
0,
0});
this.height.Enter += new System.EventHandler(this.SelectText);
this.MapHeight.Enter += new System.EventHandler(this.SelectText);
//
// width
//
this.width.Increment = new decimal(new int[] {
this.MapWidth.Increment = new decimal(new int[] {
8,
0,
0,
0});
this.width.Location = new System.Drawing.Point(169, 23);
this.width.Maximum = new decimal(new int[] {
this.MapWidth.Location = new System.Drawing.Point(169, 23);
this.MapWidth.Maximum = new decimal(new int[] {
2048,
0,
0,
0});
this.width.Name = "width";
this.width.Size = new System.Drawing.Size(105, 20);
this.width.TabIndex = 0;
this.width.Value = new decimal(new int[] {
this.MapWidth.Name = "width";
this.MapWidth.Size = new System.Drawing.Size(105, 20);
this.MapWidth.TabIndex = 0;
this.MapWidth.Value = new decimal(new int[] {
128,
0,
0,
0});
this.width.Enter += new System.EventHandler(this.SelectText);
this.MapWidth.Enter += new System.EventHandler(this.SelectText);
//
// label4
//
@@ -235,12 +234,12 @@ namespace OpenRA.Editor
//
// theater
//
this.theater.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.theater.FormattingEnabled = true;
this.theater.Location = new System.Drawing.Point(169, 121);
this.theater.Name = "theater";
this.theater.Size = new System.Drawing.Size(216, 21);
this.theater.TabIndex = 6;
this.TheaterBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.TheaterBox.FormattingEnabled = true;
this.TheaterBox.Location = new System.Drawing.Point(169, 121);
this.TheaterBox.Name = "theater";
this.TheaterBox.Size = new System.Drawing.Size(216, 21);
this.TheaterBox.TabIndex = 6;
//
// NewMapDialog
//
@@ -249,29 +248,29 @@ namespace OpenRA.Editor
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.button1;
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.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.cordonBottom);
this.Controls.Add(this.cordonTop);
this.Controls.Add(this.cordonRight);
this.Controls.Add(this.cordonLeft);
this.Controls.Add(this.height);
this.Controls.Add(this.width);
this.Controls.Add(this.CordonBottom);
this.Controls.Add(this.CordonTop);
this.Controls.Add(this.CordonRight);
this.Controls.Add(this.CordonLeft);
this.Controls.Add(this.MapHeight);
this.Controls.Add(this.MapWidth);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Name = "NewMapDialog";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "New Map";
((System.ComponentModel.ISupportInitialize)(this.cordonBottom)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.cordonTop)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.cordonRight)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.cordonLeft)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.height)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.width)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.CordonBottom)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.CordonTop)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.CordonRight)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.CordonLeft)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.MapHeight)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.MapWidth)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -284,13 +283,13 @@ namespace OpenRA.Editor
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
public System.Windows.Forms.NumericUpDown cordonBottom;
public System.Windows.Forms.NumericUpDown cordonTop;
public System.Windows.Forms.NumericUpDown cordonRight;
public System.Windows.Forms.NumericUpDown cordonLeft;
public System.Windows.Forms.NumericUpDown height;
public System.Windows.Forms.NumericUpDown width;
public System.Windows.Forms.NumericUpDown CordonBottom;
public System.Windows.Forms.NumericUpDown CordonTop;
public System.Windows.Forms.NumericUpDown CordonRight;
public System.Windows.Forms.NumericUpDown CordonLeft;
public System.Windows.Forms.NumericUpDown MapHeight;
public System.Windows.Forms.NumericUpDown MapWidth;
private System.Windows.Forms.Label label4;
public System.Windows.Forms.ComboBox theater;
public System.Windows.Forms.ComboBox TheaterBox;
}
}

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Editor
static class Program
{
[STAThread]
static void Main( string[] args )
static void Main(string[] args)
{
if (args.Length >= 2 && args[0] == "--convert")
{
@@ -40,12 +40,13 @@ namespace OpenRA.Editor
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);
foreach (var path in ModData.FindMapsIn(MapFolderPath))
foreach (var path in ModData.FindMapsIn(mapFolderPath))
{
var map = new Map(path);
// Touch the lazy bits to initialize them
map.Actors.Force();
map.Smudges.Force();
@@ -54,6 +55,5 @@ namespace OpenRA.Editor
map.Save(path);
}
}
}
}

View File

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

View File

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

View File

@@ -17,21 +17,21 @@ namespace OpenRA.Editor
{
class ResourceTool : ITool
{
ResourceTemplate Resource;
ResourceTemplate resourceTemplate;
public ResourceTool(ResourceTemplate resource) { Resource = resource; }
public ResourceTool(ResourceTemplate resource) { resourceTemplate = resource; }
public void Apply(Surface surface)
{
surface.Map.MapResources.Value[surface.GetBrushLocation().X, surface.GetBrushLocation().Y]
= new TileReference<byte, byte>
{
type = (byte)Resource.Info.ResourceType,
index = (byte)random.Next(Resource.Info.SpriteNames.Length)
type = (byte)resourceTemplate.Info.ResourceType,
index = (byte)random.Next(resourceTemplate.Info.SpriteNames.Length)
};
var ch = new int2((surface.GetBrushLocation().X) / Surface.ChunkSize,
(surface.GetBrushLocation().Y) / Surface.ChunkSize);
var ch = new int2(surface.GetBrushLocation().X / Surface.ChunkSize,
surface.GetBrushLocation().Y / Surface.ChunkSize);
if (surface.Chunks.ContainsKey(ch))
{
@@ -42,7 +42,7 @@ namespace OpenRA.Editor
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();

View File

@@ -21,6 +21,24 @@ using SGraphics = System.Drawing.Graphics;
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
{
public Map Map { get; private set; }
@@ -33,7 +51,7 @@ namespace OpenRA.Editor
public float Zoom = 1.0f;
ITool Tool;
ITool currentTool;
public bool IsPanning;
public bool IsErasing;
@@ -53,7 +71,7 @@ namespace OpenRA.Editor
public event Action<string> MousePositionChanged = _ => { };
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>();
static readonly Font MarkerFont = new Font(FontFamily.GenericSansSerif, 12.0f, FontStyle.Regular);
@@ -67,16 +85,16 @@ namespace OpenRA.Editor
TileSet = ts;
Palette = p;
PlayerPalette = pp;
PlayerPalettes = null;
playerPalettes = null;
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)
{
ActorTemplates = templates.ToDictionary(a => a.Info.Name.ToLowerInvariant());
actorTemplates = templates.ToDictionary(a => a.Info.Name.ToLowerInvariant());
}
public void BindResourceTemplates(IEnumerable<ResourceTemplate> templates)
@@ -99,7 +117,8 @@ namespace OpenRA.Editor
static readonly Pen SelectionPen = new Pen(Color.Blue);
static readonly Pen PastePen = new Pen(Color.Green);
static readonly Pen CordonPen = new Pen(Color.Red);
int2 MousePos;
int2 mousePos;
public void Scroll(int2 dx)
{
@@ -151,12 +170,12 @@ namespace OpenRA.Editor
if (Map == null) return;
var oldMousePos = MousePos;
MousePos = new int2(e.Location);
var oldMousePos = mousePos;
mousePos = new int2(e.Location);
MousePositionChanged(GetBrushLocation().ToString());
if (e.Button == MouseButtons.Middle || (e.Button != MouseButtons.None && IsPanning))
Scroll(oldMousePos - MousePos);
Scroll(oldMousePos - mousePos);
else
{
if (e.Button == MouseButtons.Right || (IsErasing && e.Button == MouseButtons.Left))
@@ -180,7 +199,7 @@ namespace OpenRA.Editor
brushLocation.Y < 0)
return;
Tool = null;
currentTool = null;
var key = Map.Actors.Value.FirstOrDefault(a => a.Value.Location() == brushLocation);
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)
{
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))
{
Chunks[ch].Dispose();
@@ -202,9 +221,9 @@ namespace OpenRA.Editor
void Draw()
{
if (Tool != null)
if (currentTool != null)
{
Tool.Apply(this);
currentTool.Apply(this);
AfterChange();
}
else if (IsPaste)
@@ -237,7 +256,6 @@ namespace OpenRA.Editor
Bitmap RenderChunk(int u, int v)
{
var bitmap = new Bitmap(ChunkSize * TileSet.TileSize, ChunkSize * TileSet.TileSize);
var data = bitmap.LockBits(bitmap.Bounds(),
@@ -284,12 +302,12 @@ namespace OpenRA.Editor
bitmap.UnlockBits(data);
if (ShowGrid)
using( var g = SGraphics.FromImage(bitmap) )
using (var g = SGraphics.FromImage(bitmap))
{
var rect = new Rectangle(0,0,bitmap.Width, bitmap.Height);
ControlPaint.DrawGrid( g, rect, new Size(2, Game.CellSize), Color.DarkRed );
ControlPaint.DrawGrid( g, rect, new Size(Game.CellSize, 2), Color.DarkRed );
ControlPaint.DrawGrid( g, rect, new Size(Game.CellSize, Game.CellSize), Color.Red );
var rect = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
ControlPaint.DrawGrid(g, rect, new Size(2, Game.CellSize), Color.DarkRed);
ControlPaint.DrawGrid(g, rect, new Size(Game.CellSize, 2), Color.DarkRed);
ControlPaint.DrawGrid(g, rect, new Size(Game.CellSize, Game.CellSize), Color.Red);
}
return bitmap;
@@ -297,15 +315,15 @@ namespace OpenRA.Editor
public CPos GetBrushLocation()
{
var vX = (int)Math.Floor((MousePos.X - Offset.X) / Zoom);
var vY = (int)Math.Floor((MousePos.Y - Offset.Y) / Zoom);
var vX = (int)Math.Floor((mousePos.X - Offset.X) / Zoom);
var vY = (int)Math.Floor((mousePos.Y - Offset.Y) / Zoom);
return new CPos(vX / TileSet.TileSize, vY / TileSet.TileSize);
}
public CPos GetBrushLocationBR()
{
var vX = (int)Math.Floor((MousePos.X - Offset.X) / Zoom);
var vY = (int)Math.Floor((MousePos.Y - Offset.Y) / Zoom);
var vX = (int)Math.Floor((mousePos.X - Offset.X) / Zoom);
var vY = (int)Math.Floor((mousePos.Y - Offset.Y) / Zoom);
return new CPos((vX + TileSet.TileSize - 1) / TileSet.TileSize,
(vY + TileSet.TileSize - 1) / TileSet.TileSize);
}
@@ -361,14 +379,14 @@ namespace OpenRA.Editor
return new Palette(PlayerPalette, remap).AsSystemPalette();
}
Cache<string, ColorPalette> PlayerPalettes;
Cache<string, ColorPalette> playerPalettes;
public ColorPalette GetPaletteForPlayer(string player)
{
if (PlayerPalettes == null)
PlayerPalettes = new Cache<string, ColorPalette>(GetPaletteForPlayerInner);
if (playerPalettes == null)
playerPalettes = new Cache<string, ColorPalette>(GetPaletteForPlayerInner);
return PlayerPalettes[player];
return playerPalettes[player];
}
ColorPalette GetPaletteForActor(ActorReference ar)
@@ -393,10 +411,10 @@ namespace OpenRA.Editor
var bmp = Chunks[x];
float DrawX = TileSet.TileSize * (float)ChunkSize * (float)x.X * Zoom + Offset.X;
float DrawY = TileSet.TileSize * (float)ChunkSize * (float)x.Y * Zoom + Offset.Y;
var drawX = TileSet.TileSize * (float)ChunkSize * (float)x.X * Zoom + Offset.X;
var drawY = TileSet.TileSize * (float)ChunkSize * (float)x.Y * Zoom + Offset.Y;
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);
}
@@ -427,8 +445,8 @@ namespace OpenRA.Editor
foreach (var ar in Map.Actors.Value)
{
if (ActorTemplates.ContainsKey(ar.Value.Type))
DrawActor(e.Graphics, ar.Value.Location(), ActorTemplates[ar.Value.Type],
if (actorTemplates.ContainsKey(ar.Value.Type))
DrawActor(e.Graphics, ar.Value.Location(), actorTemplates[ar.Value.Type],
GetPaletteForActor(ar.Value));
else
Console.WriteLine("Warning: Unknown or excluded actor: {0}", ar.Value.Type);
@@ -445,16 +463,16 @@ namespace OpenRA.Editor
if (ShowRuler && Zoom > 0.2)
{
for (int i = Map.Bounds.Left; i <= Map.Bounds.Right; i+=8)
for (int i = Map.Bounds.Left; i <= Map.Bounds.Right; i += 8)
{
if( i % 8 == 0)
if (i % 8 == 0)
{
PointF point = new PointF(i * TileSet.TileSize * Zoom + Offset.X, (Map.Bounds.Top - 8) * TileSet.TileSize * Zoom + Offset.Y);
e.Graphics.DrawString((i - Map.Bounds.Left).ToString(), MarkerFont, TextBrush, point);
}
}
for (int i = Map.Bounds.Top; i <= Map.Bounds.Bottom; i+=8)
for (int i = Map.Bounds.Top; i <= Map.Bounds.Bottom; i += 8)
{
if (i % 8 == 0)
{
@@ -464,14 +482,14 @@ namespace OpenRA.Editor
}
}
if (Tool != null)
Tool.Preview(this, e.Graphics);
if (currentTool != null)
currentTool.Preview(this, e.Graphics);
if (Tool == null)
if (currentTool == null)
{
var x = Map.Actors.Value.FirstOrDefault(a => a.Value.Location() == GetBrushLocation());
if (x.Key != null)
DrawActorBorder(e.Graphics, x.Value.Location(), ActorTemplates[x.Value.Type]);
DrawActorBorder(e.Graphics, x.Value.Location(), actorTemplates[x.Value.Type]);
}
}
@@ -493,7 +511,7 @@ namespace OpenRA.Editor
{
for (int y = 0; y < height; y++)
{
//TODO: crash prevention
// TODO: crash prevention
TileSelection[x, y] = Map.MapTiles.Value[start.X + x, start.Y + y];
ResourceSelection[x, y] = Map.MapResources.Value[start.X + x, start.Y + y];
}
@@ -513,7 +531,7 @@ namespace OpenRA.Editor
var mapX = loc.X + x;
var mapY = loc.Y + y;
//TODO: crash prevention for outside of bounds
// TODO: crash prevention for outside of bounds
Map.MapTiles.Value[mapX, mapY] = TileSelection[x, y];
Map.MapResources.Value[mapX, mapY] = ResourceSelection[x, y];
@@ -525,6 +543,7 @@ namespace OpenRA.Editor
}
}
}
AfterChange();
}
@@ -536,22 +555,4 @@ namespace OpenRA.Editor
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);
}
}
}