Fix a collection of whitespace-style issues in Mods.Common.

This commit is contained in:
Paul Chote
2014-12-14 17:04:37 +13:00
parent 299a933dac
commit ecd3809bc2
51 changed files with 142 additions and 149 deletions

View File

@@ -18,9 +18,9 @@ namespace OpenRA.Mods.Common.Widgets
{
public class ColorMixerWidget : Widget
{
public float[] SRange = {0.0f, 1.0f};
public float[] VRange = {0.2f, 1.0f};
public event Action OnChange = () => {};
public float[] SRange = { 0.0f, 1.0f };
public float[] VRange = { 0.2f, 1.0f };
public event Action OnChange = () => { };
float H, S, V;
byte[] front, back;
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Widgets
Thread workerThread;
bool workerAlive;
public ColorMixerWidget() {}
public ColorMixerWidget() { }
public ColorMixerWidget(ColorMixerWidget other)
: base(other)
{
@@ -47,10 +47,10 @@ namespace OpenRA.Mods.Common.Widgets
base.Initialize(args);
// Bitmap data is generated in a background thread and then flipped
front = new byte[4*256*256];
back = new byte[4*256*256];
front = new byte[4 * 256 * 256];
back = new byte[4 * 256 * 256];
var rect = new Rectangle((int)(255*SRange[0]), (int)(255*(1 - VRange[1])), (int)(255*(SRange[1] - SRange[0]))+1, (int)(255*(VRange[1] - VRange[0])) + 1);
var rect = new Rectangle((int)(255 * SRange[0]), (int)(255 * (1 - VRange[1])), (int)(255 * (SRange[1] - SRange[0])) + 1, (int)(255 * (VRange[1] - VRange[0])) + 1);
var mixerSheet = new Sheet(new Size(256, 256));
mixerSheet.GetTexture().SetData(front, 256, 256);
mixerSprite = new Sprite(mixerSheet, rect, TextureChannel.Alpha);
@@ -87,6 +87,7 @@ namespace OpenRA.Mods.Common.Widgets
workerAlive = false;
break;
}
update = false;
// Take a local copy of the hue to generate to avoid tearing
@@ -142,8 +143,8 @@ namespace OpenRA.Mods.Common.Widgets
void SetValueFromPx(int2 xy)
{
var rb = RenderBounds;
var s = SRange[0] + xy.X*(SRange[1] - SRange[0])/rb.Width;
var v = SRange[1] - xy.Y*(VRange[1] - VRange[0])/rb.Height;
var s = SRange[0] + xy.X * (SRange[1] - SRange[0]) / rb.Width;
var v = SRange[1] - xy.Y * (VRange[1] - VRange[0]) / rb.Height;
S = s.Clamp(SRange[0], SRange[1]);
V = v.Clamp(VRange[0], VRange[1]);
}
@@ -151,8 +152,8 @@ namespace OpenRA.Mods.Common.Widgets
int2 PxFromValue()
{
var rb = RenderBounds;
var x = RenderBounds.Width*(S - SRange[0])/(SRange[1] - SRange[0]);
var y = RenderBounds.Height*(1 - (V - VRange[0])/(VRange[1] - VRange[0]));
var x = RenderBounds.Width * (S - SRange[0]) / (SRange[1] - SRange[0]);
var y = RenderBounds.Height * (1 - (V - VRange[0]) / (VRange[1] - VRange[0]));
return new int2((int)x.Clamp(0, rb.Width), (int)y.Clamp(0, rb.Height));
}
@@ -184,6 +185,7 @@ namespace OpenRA.Mods.Common.Widgets
SetValueFromPx(mi.Location - RenderOrigin);
OnChange();
}
break;
}
@@ -204,7 +206,7 @@ namespace OpenRA.Mods.Common.Widgets
public void Set(HSLColor color)
{
float h,s,v;
float h, s, v;
color.ToHSV(out h, out s, out v);
if (H != h || S != s || V != v)

View File

@@ -49,19 +49,13 @@ namespace OpenRA.Mods.Common.Widgets
Func<bool> doValidate = null;
ButtonWidget acceptButton = null, cancelButton = null;
//
// Title
//
panel.Get<LabelWidget>("PROMPT_TITLE").GetText = () => title;
//
// Prompt
//
panel.Get<LabelWidget>("PROMPT_TEXT").GetText = () => prompt;
//
// Text input
//
var input = panel.Get<TextFieldWidget>("INPUT_TEXT");
var isValid = false;
input.Text = initialText;
@@ -86,9 +80,7 @@ namespace OpenRA.Mods.Common.Widgets
input.CursorPosition = input.Text.Length;
input.OnTextEdited = () => doValidate();
//
// Buttons
//
acceptButton = panel.Get<ButtonWidget>("ACCEPT_BUTTON");
if (!string.IsNullOrEmpty(acceptText))
acceptButton.GetText = () => acceptText;
@@ -113,9 +105,7 @@ namespace OpenRA.Mods.Common.Widgets
onCancel();
};
//
// Validation
//
doValidate = () =>
{
if (inputValidator == null)

View File

@@ -39,6 +39,7 @@ namespace OpenRA.Mods.Common.Widgets
for (var h = 0; h < 256; h++)
*(c + h) = HSLColor.FromHSV(h / 255f, 1, 1).RGB.ToArgb();
}
hueBitmap.UnlockBits(bitmapData);
hueSheet.GetTexture().SetData(hueBitmap);
}

View File

@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Widgets
if (TooltipContainer == null)
return;
tooltipContainer.Value.SetTooltip(TooltipTemplate, new WidgetArgs() {{ "getText", GetTooltipText }});
tooltipContainer.Value.SetTooltip(TooltipTemplate, new WidgetArgs() { { "getText", GetTooltipText } });
}
public override void MouseExited()

View File

@@ -74,5 +74,4 @@ namespace OpenRA.Mods.Common.Widgets.Logic
color.AttachPanel(colorChooser, onExit);
}
}
}
}

View File

@@ -94,7 +94,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
catch (Exception) { }
}
ModMetadata initialMod = null;
ModMetadata.AllMods.TryGetValue(Game.Settings.Game.PreviousMod, out initialMod);
SelectMod(initialMod ?? ModMetadata.AllMods["ra"]);

View File

@@ -333,6 +333,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var productionTemplate = hotkeyList.Get("PRODUCTION_TEMPLATE");
hotkeyList.RemoveChildren();
Func<bool> returnTrue = () => true;
Action doNothing = () => { };
// Game
{
var hotkeys = new Dictionary<string, string>()
@@ -358,7 +361,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{ "TogglePixelDoubleKey", "Toggle pixel doubling" },
};
var header = ScrollItemWidget.Setup(hotkeyHeader, () => true, () => {});
var header = ScrollItemWidget.Setup(hotkeyHeader, returnTrue, doNothing);
header.Get<LabelWidget>("LABEL").GetText = () => "Game Commands";
hotkeyList.AddChild(header);
@@ -374,7 +377,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{ "ObserverWorldView", "Disable Shroud" }
};
var header = ScrollItemWidget.Setup(hotkeyHeader, () => true, () => {});
var header = ScrollItemWidget.Setup(hotkeyHeader, returnTrue, doNothing);
header.Get<LabelWidget>("LABEL").GetText = () => "Observer Commands";
hotkeyList.AddChild(header);
@@ -394,7 +397,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{ "GuardKey", "Guard" }
};
var header = ScrollItemWidget.Setup(hotkeyHeader, () => true, () => {});
var header = ScrollItemWidget.Setup(hotkeyHeader, returnTrue, doNothing);
header.Get<LabelWidget>("LABEL").GetText = () => "Unit Commands";
hotkeyList.AddChild(header);
@@ -408,7 +411,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
for (var i = 1; i <= 24; i++)
hotkeys.Add("Production{0:D2}Key".F(i), "Slot {0}".F(i));
var header = ScrollItemWidget.Setup(hotkeyHeader, () => true, () => {});
var header = ScrollItemWidget.Setup(hotkeyHeader, returnTrue, doNothing);
header.Get<LabelWidget>("LABEL").GetText = () => "Production Commands";
hotkeyList.AddChild(header);
@@ -423,7 +426,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{ "DevReloadChromeKey", "Reload Chrome" }
};
var header = ScrollItemWidget.Setup(hotkeyHeader, () => true, () => {});
var header = ScrollItemWidget.Setup(hotkeyHeader, returnTrue, doNothing);
header.Get<LabelWidget>("LABEL").GetText = () => "Developer commands";
hotkeyList.AddChild(header);

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Widgets
public Func<bool> IsEnabled = () => true;
public Action AfterOpen = () => { };
public Action AfterClose = () => { };
public Action<float> Animating = _ => {};
public Action<float> Animating = _ => { };
float radarMinimapHeight;
int frame;

View File

@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Widgets
return;
Func<string> getText = () => TooltipFormat.F(GetUsed(), GetProvided());
tooltipContainer.Value.SetTooltip(TooltipTemplate, new WidgetArgs() {{ "getText", getText }});
tooltipContainer.Value.SetTooltip(TooltipTemplate, new WidgetArgs() { { "getText", getText } });
}
public override void MouseExited()
@@ -67,8 +67,8 @@ namespace OpenRA.Mods.Common.Widgets
while (max >= scaleBy)
scaleBy *= 2;
var providedFrac = providedLerp.Update(provided/scaleBy);
var usedFrac = usedLerp.Update(used/scaleBy);
var providedFrac = providedLerp.Update(provided / scaleBy);
var usedFrac = usedLerp.Update(used / scaleBy);
var b = RenderBounds;
var indicator = ChromeProvider.GetImage(IndicatorCollection, IndicatorImage);
@@ -83,10 +83,10 @@ namespace OpenRA.Mods.Common.Widgets
{
color = (i - 1 < b.Height / 2) ? color : colorDark;
var bottom = new float2(b.Left + i, b.Bottom);
var top = new float2(b.Left + i, b.Bottom + providedFrac*b.Height);
var top = new float2(b.Left + i, b.Bottom + providedFrac * b.Height);
// Indent corners
if ((i == 0 || i == b.Width - 1) && providedFrac*b.Height > 1)
if ((i == 0 || i == b.Width - 1) && providedFrac * b.Height > 1)
{
bottom.Y += 1;
top.Y -= 1;
@@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common.Widgets
}
else
Game.Renderer.LineRenderer.FillRect(new Rectangle(b.X, (int)float2.Lerp(b.Bottom, b.Top, providedFrac),
b.Width, (int)(providedFrac*b.Height)), color);
b.Width, (int)(providedFrac * b.Height)), color);
var x = (b.Left + b.Right - indicator.size.X) / 2;
var y = float2.Lerp(b.Bottom, b.Top, usedFrac) - indicator.size.Y / 2;
@@ -112,10 +112,10 @@ namespace OpenRA.Mods.Common.Widgets
{
color = (i - 1 < b.Height / 2) ? color : colorDark;
var left = new float2(b.Left, b.Top + i);
var right = new float2(b.Left + providedFrac*b.Width, b.Top + i);
var right = new float2(b.Left + providedFrac * b.Width, b.Top + i);
// Indent corners
if ((i == 0 || i == b.Height - 1) && providedFrac*b.Width > 1)
if ((i == 0 || i == b.Height - 1) && providedFrac * b.Width > 1)
{
left.X += 1;
right.X -= 1;
@@ -125,7 +125,7 @@ namespace OpenRA.Mods.Common.Widgets
}
}
else
Game.Renderer.LineRenderer.FillRect(new Rectangle(b.X, b.Y, (int)(providedFrac*b.Width), b.Height), color);
Game.Renderer.LineRenderer.FillRect(new Rectangle(b.X, b.Y, (int)(providedFrac * b.Width), b.Height), color);
var x = float2.Lerp(b.Left, b.Right, usedFrac) - indicator.size.X / 2;
var y = (b.Bottom + b.Top - indicator.size.Y) / 2;