added total cash count to editor status bar

This commit is contained in:
Matthias Mailänder
2013-03-29 22:38:39 +01:00
parent db4f880d61
commit 918f27575d
4 changed files with 87 additions and 16 deletions

View File

@@ -119,6 +119,7 @@ namespace OpenRA.Editor
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();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
@@ -528,7 +529,7 @@ namespace OpenRA.Editor
this.newToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("newToolStripMenuItem.Image")));
this.newToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Fuchsia;
this.newToolStripMenuItem.Name = "newToolStripMenuItem";
this.newToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.newToolStripMenuItem.Size = new System.Drawing.Size(123, 22);
this.newToolStripMenuItem.Text = "&New...";
this.newToolStripMenuItem.ToolTipText = "Create a new blank map.";
this.newToolStripMenuItem.Click += new System.EventHandler(this.NewClicked);
@@ -536,13 +537,13 @@ namespace OpenRA.Editor
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(149, 6);
this.toolStripSeparator1.Size = new System.Drawing.Size(120, 6);
//
// openToolStripMenuItem
//
this.openToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("openToolStripMenuItem.Image")));
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
this.openToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.openToolStripMenuItem.Size = new System.Drawing.Size(123, 22);
this.openToolStripMenuItem.Text = "&Open...";
this.openToolStripMenuItem.ToolTipText = "Open an existing map.";
this.openToolStripMenuItem.Click += new System.EventHandler(this.OpenClicked);
@@ -552,7 +553,7 @@ namespace OpenRA.Editor
this.saveToolStripMenuItem.Enabled = false;
this.saveToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("saveToolStripMenuItem.Image")));
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
this.saveToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.saveToolStripMenuItem.Size = new System.Drawing.Size(123, 22);
this.saveToolStripMenuItem.Text = "&Save";
this.saveToolStripMenuItem.ToolTipText = "Quicksave current map.";
this.saveToolStripMenuItem.Click += new System.EventHandler(this.SaveClicked);
@@ -562,7 +563,7 @@ namespace OpenRA.Editor
this.saveAsToolStripMenuItem.Enabled = false;
this.saveAsToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("saveAsToolStripMenuItem.Image")));
this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem";
this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(123, 22);
this.saveAsToolStripMenuItem.Text = "Save &As...";
this.saveAsToolStripMenuItem.ToolTipText = "Save the map while choosing a filename.";
this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.SaveAsClicked);
@@ -570,7 +571,7 @@ namespace OpenRA.Editor
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(149, 6);
this.toolStripSeparator2.Size = new System.Drawing.Size(120, 6);
//
// toolStripMenuItem1
//
@@ -579,7 +580,7 @@ namespace OpenRA.Editor
this.toolStripMenuItem1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripMenuItem1.Image")));
this.toolStripMenuItem1.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(152, 22);
this.toolStripMenuItem1.Size = new System.Drawing.Size(123, 22);
this.toolStripMenuItem1.Text = "&Import";
//
// cCRedAlertMapToolStripMenuItem
@@ -599,7 +600,7 @@ namespace OpenRA.Editor
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(152, 22);
this.mnuExport.Size = new System.Drawing.Size(123, 22);
this.mnuExport.Text = "&Export";
//
// mnuMinimapToPNG
@@ -623,14 +624,14 @@ namespace OpenRA.Editor
// toolStripSeparator3
//
this.toolStripSeparator3.Name = "toolStripSeparator3";
this.toolStripSeparator3.Size = new System.Drawing.Size(149, 6);
this.toolStripSeparator3.Size = new System.Drawing.Size(120, 6);
//
// exitToolStripMenuItem
//
this.exitToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("exitToolStripMenuItem.Image")));
this.exitToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta;
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
this.exitToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.exitToolStripMenuItem.Size = new System.Drawing.Size(123, 22);
this.exitToolStripMenuItem.Text = "E&xit";
this.exitToolStripMenuItem.ToolTipText = "Quit the map editor.";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.CloseClicked);
@@ -847,6 +848,7 @@ namespace OpenRA.Editor
//
this.statusStrip1.Dock = System.Windows.Forms.DockStyle.None;
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.cashToolStripStatusLabel,
this.toolStripStatusLabelFiller,
this.toolStripStatusLabelMousePosition});
this.statusStrip1.Location = new System.Drawing.Point(0, 0);
@@ -858,7 +860,7 @@ namespace OpenRA.Editor
// toolStripStatusLabelFiller
//
this.toolStripStatusLabelFiller.Name = "toolStripStatusLabelFiller";
this.toolStripStatusLabelFiller.Size = new System.Drawing.Size(932, 17);
this.toolStripStatusLabelFiller.Size = new System.Drawing.Size(872, 17);
this.toolStripStatusLabelFiller.Spring = true;
//
// toolStripStatusLabelMousePosition
@@ -932,6 +934,14 @@ namespace OpenRA.Editor
//
this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.menuStrip1);
//
// cashToolStripStatusLabel
//
this.cashToolStripStatusLabel.Image = ((System.Drawing.Image)(resources.GetObject("cashToolStripStatusLabel.Image")));
this.cashToolStripStatusLabel.Name = "cashToolStripStatusLabel";
this.cashToolStripStatusLabel.Size = new System.Drawing.Size(29, 17);
this.cashToolStripStatusLabel.Text = "0";
this.cashToolStripStatusLabel.ToolTipText = "Net worth of the maps resources in cash";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -977,8 +987,8 @@ namespace OpenRA.Editor
this.toolStripContainer1.ResumeLayout(false);
this.toolStripContainer1.PerformLayout();
this.ResumeLayout(false);
}
private System.Windows.Forms.ToolStripStatusLabel cashToolStripStatusLabel;
#endregion

View File

@@ -70,6 +70,7 @@ namespace OpenRA.Editor
{
MakeDirty();
pmMiniMap.Image = Minimap.AddStaticResources(surface1.Map, Minimap.TerrainBitmap(surface1.Map, true));
cashToolStripStatusLabel.Text = CalculateTotalResource().ToString();
}
void ActorDoubleClicked(KeyValuePair<string,ActorReference> kv)
@@ -119,6 +120,8 @@ namespace OpenRA.Editor
map.MakeDefaultPlayers();
PrepareMapResources(Game.modData.Manifest, map);
//Calculate total net worth of resources in cash
cashToolStripStatusLabel.Text = CalculateTotalResource().ToString();
dirty = false;
}
@@ -670,5 +673,45 @@ namespace OpenRA.Editor
{
ShowGridClicked(sender, e);
}
public int CalculateTotalResource()
{
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;
}
int GetAdjecentCellsWith(int ResourceType, int x, int y)
{
int sum = 0;
for (var u = -1; u < 2; u++)
for (var v = -1; v < 2; v++)
{
if (!surface1.Map.IsInMap(new CPos(x + u, y + v)))
continue;
if (surface1.Map.MapResources.Value[x + u, y + v].type == ResourceType)
++sum;
}
return sum;
}
int GetResourceValue(int x, int y)
{
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;
else if (type == 2)
ImageLength = 3;
int density = (GetAdjecentCellsWith(type ,x , y) * ImageLength - 1) / 9;
int value = template.Info.ValuePerUnit;
return (density) * value;
}
}
}

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
@@ -421,7 +421,7 @@
<data name="mnuMinimapToPNG.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGOfPtRkwAAACBjSFJNAAB6
JQAAgIMAAPn/AACA6QAAdTAAAOpgAAA6mAAAF2+SX8VGAAAACXBIWXMAAAsRAAALEQF/ZF+RAAAB+UlE
JQAAgIMAAPn/AACA6QAAdTAAAOpgAAA6mAAAF2+SX8VGAAAACXBIWXMAAAsQAAALEAGtI711AAAB+UlE
QVQ4T6WRX0hTYRjGve0iiAq6CovsphHWRaXrogshbEIgiEzbjFLQq266WZG76I8kRIRtIZJhW2NOq5Ga
uTkbrmZzf2gyTY8ipIwlYkJIIZP563xHZhtbF9YDz3l53vO9v/N93ykA/svKo883w5vRaZzeKV6NxOh1
R+keimB7G8TaF6DL6afzpY+OHi/tdg9PbG5M1iF5NAOwU53WNIiyBRBfFvpmbGJeX0bk3FFsxQdgc/OP
@@ -436,7 +436,7 @@
<data name="fullMapRenderToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGOfPtRkwAAACBjSFJNAAB6
JQAAgIMAAPn/AACA6QAAdTAAAOpgAAA6mAAAF2+SX8VGAAAACXBIWXMAAAsRAAALEQF/ZF+RAAACRElE
JQAAgIMAAPn/AACA6QAAdTAAAOpgAAA6mAAAF2+SX8VGAAAACXBIWXMAAAsQAAALEAGtI711AAACRElE
QVQ4T6WTXUiTcRSHdxkRRBdB0IUREV1ETSKIwoyQAsmV5IUhfaBUoJSUWJbLxAVZWixBRUcrNT8qM1PL
hpmoKGkf2pzOpLlAi9QtndKHzfm084a9uzCKujjv1Z7n/M85v2mA/yrlk3eng8DKKWsn62YLFwob0ec8
JimrhnhDJbGp5cQkFxOVaGZPgsmPBgi8M/y2Pn8D99Qsw+5ZBj746HL6WLMz/e8ELpsd+6FgbAe1WNts
@@ -729,6 +729,24 @@
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>313, 17</value>
</metadata>
<data name="cashToolStripStatusLabel.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29m
dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAALSSURBVDhPjVLbS5NxGN4/sLm5ZeqWJdlNJ7oIoQPR
hWBEIF4VGYUUUSBk0kUidCdTA0UMdBKGkugssxKdeMDcbHn43FjzgGtuNs+HuX07fPu+be7pLdnF1Isu
Hvi9vO/ved73fV4RgAMQLMezeHPGcsiUEeUYFYITKj4wpjQFjMq8/bUJQRwhc4Y/stYCcFYg8ANgBxDZ
aIHPkG7fX5sQxPFXFaFZwDMIbH0AVhux626DdziV0om1CUEcgXEVdr39iG12IEbKkYVSRJxlcA8cpXRi
bUIQh9+oRNilRnDyOvyjF8H2nwI3dQ9buv8kYA1piJJyeP4phJ/5CI1fQ5C5i/XuI5ROrBXxpgxJiDm2
zE0oo8ExJQLf03mfPh28vZT2dxX+4Qvw9pyEMFeElS7FQQJuUlUR/l0L8E5a3BxtnUF4Qwuv/jSE2Ufg
zbfAGa/Q+wlcHYcQkL+IhWz00UJ2GYAdHWK+4X/z+kcvwzdwDp7PJ6ibfDhbkw8SsKNEEDQj5jUg5hlC
lPyPrmuwRvMK1vvgmRsI6rPBWwthbz6EwPMtDRGyi7e9BDddiOBUDvhfj7HcqYBvJBus7gx8X9IR0CnB
divg7ZLD/VHOb7bLTOutsjzR9kAqoqQcWdIg7KyEMP+CyB5isV1ODhSQAzlge1LoLvQ0polgpE77wC1W
wtUktYs2dJRkhxGij5ylgLzPQXS1GvaWZJo7F2zveeyQ6t5lDu1d5to7GvkT7A1JEK1+TdEGFqrpUxPC
jnKEF8rgsxbBqc0CaymE4CjBdu9ZBG2vENvpQWyrjbqtAWu+g9laiVbk6lQUuycfUEtVEJYqELA9w+pI
LmY00sHpeiljrUsS5jVS17bhJpGUIOR4Dr/1Nlb6LsFSJS4WOdrlmfb3crWtWcbMNcmEmUYZY62Xqi1v
pJnxTTveSjNtDUnquToJM10jESyvxYypUqxmysWZfwCSxP6Dn1PvvAAAAABJRU5ErkJggg==
</value>
</data>
<data name="toolStripStatusLabelMousePosition.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8

View File

@@ -52,7 +52,7 @@ namespace OpenRA.Editor
public event Action<KeyValuePair<string, ActorReference>> ActorDoubleClicked = _ => { };
Dictionary<string, ActorTemplate> ActorTemplates = new Dictionary<string, ActorTemplate>();
Dictionary<int, ResourceTemplate> ResourceTemplates = new Dictionary<int, ResourceTemplate>();
public Dictionary<int, ResourceTemplate> ResourceTemplates = new Dictionary<int, ResourceTemplate>();
public Keys GetModifiers() { return ModifierKeys; }