From dca15cadb95a0caa428fbf09b6621a6734864f9e Mon Sep 17 00:00:00 2001 From: Bob Date: Mon, 22 Mar 2010 19:28:37 +1200 Subject: [PATCH] fixed line-endings on *.cs --- OpenRA.FileFormats/AudLoader.cs | 20 +- OpenRA.FileFormats/TerrainColorSet.cs | 138 +++---- OpenRA.Game/Chrome/BackgroundWidget.cs | 28 +- OpenRA.Game/Chrome/ButtonWidget.cs | 82 ++--- OpenRA.Game/Chrome/CheckboxWidget.cs | 36 +- OpenRA.Game/Chrome/DefaultWidgetDelegates.cs | 344 +++++++++--------- OpenRA.Game/Chrome/LabelWidget.cs | 60 +-- OpenRA.Game/Chrome/Widget.cs | 192 +++++----- OpenRA.Game/Traits/Activities/Repair.cs | 2 +- OpenRA.Game/Traits/Activities/Wait.cs | 64 ++-- OpenRA.Game/Traits/CrateAction.cs | 120 +++--- OpenRA.Game/Traits/HasUnitOnBuild.cs | 98 ++--- OpenRA.Game/Traits/LineBuild.cs | 70 ++-- OpenRA.Game/Traits/Player/EvaAlerts.cs | 126 +++---- .../Traits/Render/RenderBuildingWall.cs | 206 +++++------ .../Traits/Render/RenderBuildingWarFactory.cs | 2 +- OpenRA.Game/Traits/Wall.cs | 64 ++-- OpenRA.Game/Traits/World/ScreenShaker.cs | 88 ++--- OpenRA.Game/Traits/World/Theater.cs | 66 ++-- .../Crates/ResetRadarCrateAction.cs | 82 ++--- 20 files changed, 944 insertions(+), 944 deletions(-) diff --git a/OpenRA.FileFormats/AudLoader.cs b/OpenRA.FileFormats/AudLoader.cs index 9bc8c84d10..a2004b27c0 100644 --- a/OpenRA.FileFormats/AudLoader.cs +++ b/OpenRA.FileFormats/AudLoader.cs @@ -55,16 +55,16 @@ namespace OpenRA.FileFormats public static class AudLoader { static int[] IndexAdjust = { -1, -1, -1, -1, 2, 4, 6, 8 }; - static int[] StepTable = { - 7, 8, 9, 10, 11, 12, 13, 14, 16, - 17, 19, 21, 23, 25, 28, 31, 34, 37, - 41, 45, 50, 55, 60, 66, 73, 80, 88, - 97, 107, 118, 130, 143, 157, 173, 190, 209, - 230, 253, 279, 307, 337, 371, 408, 449, 494, - 544, 598, 658, 724, 796, 876, 963, 1060, 1166, - 1282, 1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, - 3024, 3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484, - 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, 15289, + static int[] StepTable = { + 7, 8, 9, 10, 11, 12, 13, 14, 16, + 17, 19, 21, 23, 25, 28, 31, 34, 37, + 41, 45, 50, 55, 60, 66, 73, 80, 88, + 97, 107, 118, 130, 143, 157, 173, 190, 209, + 230, 253, 279, 307, 337, 371, 408, 449, 494, + 544, 598, 658, 724, 796, 876, 963, 1060, 1166, + 1282, 1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, + 3024, 3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484, + 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 }; static short DecodeSample(byte b, ref int index, ref int current) diff --git a/OpenRA.FileFormats/TerrainColorSet.cs b/OpenRA.FileFormats/TerrainColorSet.cs index aa6fd169ea..f3e0583cd9 100644 --- a/OpenRA.FileFormats/TerrainColorSet.cs +++ b/OpenRA.FileFormats/TerrainColorSet.cs @@ -1,69 +1,69 @@ -#region Copyright & License Information -/* - * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. - * This file is part of OpenRA. - * - * OpenRA is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * OpenRA is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with OpenRA. If not, see . - */ -#endregion - -using System.Collections.Generic; -using System.IO; -using System.Drawing; -using System; -namespace OpenRA.FileFormats -{ - public class TerrainColorSet - { - public readonly Dictionary colors = new Dictionary(); - - string NextLine( StreamReader reader ) - { - string ret; - do - { - ret = reader.ReadLine(); - if( ret == null ) - return null; - ret = ret.Trim(); - } - while( ret.Length == 0 || ret[ 0 ] == ';' ); - return ret; - } - - public TerrainColorSet( string colorFile ) - { - StreamReader file = new StreamReader( FileSystem.Open(colorFile) ); - - while( true ) - { - string line = NextLine( file ); - if( line == null ) - break; - string[] kv = line.Split('='); - TerrainType key = (TerrainType)Enum.Parse(typeof(TerrainType),kv[0]); - string[] entries = kv[1].Split(','); - Color val = Color.FromArgb(int.Parse(entries[0]),int.Parse(entries[1]),int.Parse(entries[2])); - colors.Add(key,val); - } - - file.Close(); - } - - public Color ColorForTerrainType(TerrainType type) - { - return colors[type]; - } - } -} +#region Copyright & License Information +/* + * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. + * This file is part of OpenRA. + * + * OpenRA is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OpenRA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenRA. If not, see . + */ +#endregion + +using System.Collections.Generic; +using System.IO; +using System.Drawing; +using System; +namespace OpenRA.FileFormats +{ + public class TerrainColorSet + { + public readonly Dictionary colors = new Dictionary(); + + string NextLine( StreamReader reader ) + { + string ret; + do + { + ret = reader.ReadLine(); + if( ret == null ) + return null; + ret = ret.Trim(); + } + while( ret.Length == 0 || ret[ 0 ] == ';' ); + return ret; + } + + public TerrainColorSet( string colorFile ) + { + StreamReader file = new StreamReader( FileSystem.Open(colorFile) ); + + while( true ) + { + string line = NextLine( file ); + if( line == null ) + break; + string[] kv = line.Split('='); + TerrainType key = (TerrainType)Enum.Parse(typeof(TerrainType),kv[0]); + string[] entries = kv[1].Split(','); + Color val = Color.FromArgb(int.Parse(entries[0]),int.Parse(entries[1]),int.Parse(entries[2])); + colors.Add(key,val); + } + + file.Close(); + } + + public Color ColorForTerrainType(TerrainType type) + { + return colors[type]; + } + } +} diff --git a/OpenRA.Game/Chrome/BackgroundWidget.cs b/OpenRA.Game/Chrome/BackgroundWidget.cs index dc8fe3532d..4ea5297424 100644 --- a/OpenRA.Game/Chrome/BackgroundWidget.cs +++ b/OpenRA.Game/Chrome/BackgroundWidget.cs @@ -23,21 +23,21 @@ using OpenRA.Graphics; using System.Drawing; using System; -namespace OpenRA.Widgets -{ - class BackgroundWidget : Widget - { - public override void Draw() - { - if (!Visible) - { - base.Draw(); - return; +namespace OpenRA.Widgets +{ + class BackgroundWidget : Widget + { + public override void Draw() + { + if (!Visible) + { + base.Draw(); + return; } - WidgetUtils.DrawPanel("dialog", Bounds, null); - base.Draw(); - } + WidgetUtils.DrawPanel("dialog", Bounds, null); + base.Draw(); + } } static class WidgetUtils @@ -79,5 +79,5 @@ namespace OpenRA.Widgets r.Device.DisableScissor(); } - } + } } \ No newline at end of file diff --git a/OpenRA.Game/Chrome/ButtonWidget.cs b/OpenRA.Game/Chrome/ButtonWidget.cs index c9fc2d5dd5..19af6a6103 100644 --- a/OpenRA.Game/Chrome/ButtonWidget.cs +++ b/OpenRA.Game/Chrome/ButtonWidget.cs @@ -21,45 +21,45 @@ using System.Drawing; using OpenRA.Graphics; -namespace OpenRA.Widgets -{ - class ButtonWidget : Widget - { - public string Text = ""; - public bool Depressed = false; - public int VisualHeight = 1; - public override bool HandleInput(MouseInput mi) - { - if (Game.chrome.selectedWidget == this) - Depressed = (GetEventBounds().Contains(mi.Location.X,mi.Location.Y)) ? true : false; - - // Relinquish focus - if (Game.chrome.selectedWidget == this && mi.Event == MouseInputEvent.Up) - { - Game.chrome.selectedWidget = null; - Depressed = false; - } - - // Are we able to handle this event? - if (!Visible || !GetEventBounds().Contains(mi.Location.X,mi.Location.Y)) - return base.HandleInput(mi); - - - if (base.HandleInput(mi)) - return true; - - // Give button focus only while the mouse is down - // This is a bit of a hack: it will become cleaner soonish - // It will also steal events from any potential children - // We also want to play a click sound - if (mi.Event == MouseInputEvent.Down) - { - Game.chrome.selectedWidget = this; - Depressed = true; - return true; - } - - return false; +namespace OpenRA.Widgets +{ + class ButtonWidget : Widget + { + public string Text = ""; + public bool Depressed = false; + public int VisualHeight = 1; + public override bool HandleInput(MouseInput mi) + { + if (Game.chrome.selectedWidget == this) + Depressed = (GetEventBounds().Contains(mi.Location.X,mi.Location.Y)) ? true : false; + + // Relinquish focus + if (Game.chrome.selectedWidget == this && mi.Event == MouseInputEvent.Up) + { + Game.chrome.selectedWidget = null; + Depressed = false; + } + + // Are we able to handle this event? + if (!Visible || !GetEventBounds().Contains(mi.Location.X,mi.Location.Y)) + return base.HandleInput(mi); + + + if (base.HandleInput(mi)) + return true; + + // Give button focus only while the mouse is down + // This is a bit of a hack: it will become cleaner soonish + // It will also steal events from any potential children + // We also want to play a click sound + if (mi.Event == MouseInputEvent.Down) + { + Game.chrome.selectedWidget = this; + Depressed = true; + return true; + } + + return false; } public override void Draw() @@ -78,6 +78,6 @@ namespace OpenRA.Widgets Game.chrome.renderer.BoldFont.Measure(Text).Y / 2) + stateOffset, Color.White)); base.Draw(); - } - } + } + } } \ No newline at end of file diff --git a/OpenRA.Game/Chrome/CheckboxWidget.cs b/OpenRA.Game/Chrome/CheckboxWidget.cs index d210543d1c..6fa4581508 100644 --- a/OpenRA.Game/Chrome/CheckboxWidget.cs +++ b/OpenRA.Game/Chrome/CheckboxWidget.cs @@ -16,22 +16,22 @@ * You should have received a copy of the GNU General Public License * along with OpenRA. If not, see . */ -#endregion - +#endregion + using OpenRA.Graphics; using System.Drawing; -namespace OpenRA.Widgets -{ - class CheckboxWidget : Widget - { - public override void Draw() - { - if (!Visible) - { - base.Draw(); - return; - } +namespace OpenRA.Widgets +{ + class CheckboxWidget : Widget + { + public override void Draw() + { + if (!Visible) + { + base.Draw(); + return; + } var selected = InputHandler.Value != null ? InputHandler.Value.GetState(this) : false; @@ -47,9 +47,9 @@ namespace OpenRA.Widgets Bounds.Height - 9), Color.White); Game.chrome.lineRenderer.Flush(); - } - - base.Draw(); - } - } + } + + base.Draw(); + } + } } \ No newline at end of file diff --git a/OpenRA.Game/Chrome/DefaultWidgetDelegates.cs b/OpenRA.Game/Chrome/DefaultWidgetDelegates.cs index 2f833ad836..c997ebfa4e 100644 --- a/OpenRA.Game/Chrome/DefaultWidgetDelegates.cs +++ b/OpenRA.Game/Chrome/DefaultWidgetDelegates.cs @@ -22,184 +22,184 @@ using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Net; -using OpenRA.Server; - -namespace OpenRA.Widgets.Delegates -{ - public class WidgetDelegate - { - // For checkboxes - public virtual bool GetState(Widget w) { return false; } - - // For any widget - public virtual bool OnMouseDown(Widget w, MouseInput mi) { return false; } - public virtual bool OnMouseUp(Widget w, MouseInput mi) { return false; } - public virtual bool OnMouseMove(Widget w, MouseInput mi) { return false; } - } - - public class MainMenuButtonsDelegate : WidgetDelegate - { - public override bool OnMouseUp(Widget w, MouseInput mi) - { - // Main Menu root - if (w.Id == "MAINMENU_BUTTON_QUIT") - { - Game.Exit(); - return true; - } - return false; - } - } - - public class CreateServerMenuDelegate : WidgetDelegate - { - static bool AdvertiseServerOnline = Game.Settings.InternetServer; - - public override bool GetState(Widget w) - { - if (w.Id == "CREATESERVER_CHECKBOX_ONLINE") - return AdvertiseServerOnline; - - return false; - } - - public override bool OnMouseDown(Widget w, MouseInput mi) - { - if (w.Id == "CREATESERVER_CHECKBOX_ONLINE") - { - AdvertiseServerOnline = !AdvertiseServerOnline; - return true; - } - - return false; - } - - public override bool OnMouseUp(Widget w, MouseInput mi) - { - if (w.Id == "MAINMENU_BUTTON_CREATE") - { - Game.chrome.rootWidget.GetWidget("MAINMENU_BG").Visible = false; - Game.chrome.rootWidget.GetWidget("CREATESERVER_BG").Visible = true; - return true; - } - - if (w.Id == "CREATESERVER_BUTTON_CANCEL") - { - Game.chrome.rootWidget.GetWidget("MAINMENU_BG").Visible = true; - Game.chrome.rootWidget.GetWidget("CREATESERVER_BG").Visible = false; - return true; - } - - if (w.Id == "CREATESERVER_BUTTON_START") - { - Game.chrome.rootWidget.GetWidget("CREATESERVER_BG").Visible = false; - Log.Write("Creating server"); - - Server.Server.ServerMain(AdvertiseServerOnline, Game.Settings.MasterServer, - Game.Settings.GameName, Game.Settings.ListenPort, - Game.Settings.ExternalPort, Game.Settings.InitialMods); - - Log.Write("Joining server"); - Game.JoinServer(IPAddress.Loopback.ToString(), Game.Settings.ListenPort); - return true; - } - - return false; - } - } - - public class ServerBrowserDelegate : WidgetDelegate - { - static GameServer[] GameList; - static List GameButtons = new List(); - - public override bool OnMouseUp(Widget w, MouseInput mi) - { - // Main Menu root - if (w.Id == "MAINMENU_BUTTON_JOIN") +using OpenRA.Server; + +namespace OpenRA.Widgets.Delegates +{ + public class WidgetDelegate + { + // For checkboxes + public virtual bool GetState(Widget w) { return false; } + + // For any widget + public virtual bool OnMouseDown(Widget w, MouseInput mi) { return false; } + public virtual bool OnMouseUp(Widget w, MouseInput mi) { return false; } + public virtual bool OnMouseMove(Widget w, MouseInput mi) { return false; } + } + + public class MainMenuButtonsDelegate : WidgetDelegate + { + public override bool OnMouseUp(Widget w, MouseInput mi) + { + // Main Menu root + if (w.Id == "MAINMENU_BUTTON_QUIT") + { + Game.Exit(); + return true; + } + return false; + } + } + + public class CreateServerMenuDelegate : WidgetDelegate + { + static bool AdvertiseServerOnline = Game.Settings.InternetServer; + + public override bool GetState(Widget w) + { + if (w.Id == "CREATESERVER_CHECKBOX_ONLINE") + return AdvertiseServerOnline; + + return false; + } + + public override bool OnMouseDown(Widget w, MouseInput mi) + { + if (w.Id == "CREATESERVER_CHECKBOX_ONLINE") + { + AdvertiseServerOnline = !AdvertiseServerOnline; + return true; + } + + return false; + } + + public override bool OnMouseUp(Widget w, MouseInput mi) + { + if (w.Id == "MAINMENU_BUTTON_CREATE") { Game.chrome.rootWidget.GetWidget("MAINMENU_BG").Visible = false; - Widget bg = Game.chrome.rootWidget.GetWidget("JOINSERVER_BG"); - bg.Visible = true; - - int height = 50; - int width = 300; - int i = 0; + Game.chrome.rootWidget.GetWidget("CREATESERVER_BG").Visible = true; + return true; + } + + if (w.Id == "CREATESERVER_BUTTON_CANCEL") + { + Game.chrome.rootWidget.GetWidget("MAINMENU_BG").Visible = true; + Game.chrome.rootWidget.GetWidget("CREATESERVER_BG").Visible = false; + return true; + } + + if (w.Id == "CREATESERVER_BUTTON_START") + { + Game.chrome.rootWidget.GetWidget("CREATESERVER_BG").Visible = false; + Log.Write("Creating server"); + + Server.Server.ServerMain(AdvertiseServerOnline, Game.Settings.MasterServer, + Game.Settings.GameName, Game.Settings.ListenPort, + Game.Settings.ExternalPort, Game.Settings.InitialMods); + + Log.Write("Joining server"); + Game.JoinServer(IPAddress.Loopback.ToString(), Game.Settings.ListenPort); + return true; + } + + return false; + } + } + + public class ServerBrowserDelegate : WidgetDelegate + { + static GameServer[] GameList; + static List GameButtons = new List(); + + public override bool OnMouseUp(Widget w, MouseInput mi) + { + // Main Menu root + if (w.Id == "MAINMENU_BUTTON_JOIN") + { + Game.chrome.rootWidget.GetWidget("MAINMENU_BG").Visible = false; + Widget bg = Game.chrome.rootWidget.GetWidget("JOINSERVER_BG"); + bg.Visible = true; + + int height = 50; + int width = 300; + int i = 0; GameList = MasterServerQuery.GetGameList(Game.Settings.MasterServer).ToArray(); bg.Children.RemoveAll(a => GameButtons.Contains(a)); - GameButtons.Clear(); - - foreach (var game in GameList) - { - ButtonWidget b = new ButtonWidget(); - b.Bounds = new Rectangle(bg.Bounds.X + 20, bg.Bounds.Y + height, width, 25); - b.GetType().GetField("Id").SetValue( b, "JOIN_GAME_{0}".F(i)); - b.GetType().GetField("Text").SetValue( b, "{0} ({1})".F(game.Name, game.Address)); - b.GetType().GetField("Delegate").SetValue( b, "ServerBrowserDelegate"); - + GameButtons.Clear(); + + foreach (var game in GameList) + { + ButtonWidget b = new ButtonWidget(); + b.Bounds = new Rectangle(bg.Bounds.X + 20, bg.Bounds.Y + height, width, 25); + b.GetType().GetField("Id").SetValue( b, "JOIN_GAME_{0}".F(i)); + b.GetType().GetField("Text").SetValue( b, "{0} ({1})".F(game.Name, game.Address)); + b.GetType().GetField("Delegate").SetValue( b, "ServerBrowserDelegate"); + bg.AddChild(b); - GameButtons.Add(b); - - height += 35; - } - - return true; - } - - if (w.Id == "JOINSERVER_BUTTON_DIRECTCONNECT") - { - Game.chrome.rootWidget.GetWidget("JOINSERVER_BG").Visible = false; - Game.JoinServer(Game.Settings.NetworkHost, Game.Settings.NetworkPort); - return true; - } - - if (w.Id.Substring(0,10) == "JOIN_GAME_") - { - Game.chrome.rootWidget.GetWidget("JOINSERVER_BG").Visible = false; - int index = int.Parse(w.Id.Substring(10)); - var game = GameList[index]; - Game.JoinServer(game.Address.Split(':')[0], int.Parse(game.Address.Split(':')[1])); - return true; - } - - if (w.Id == "JOINSERVER_BUTTON_CANCEL") + GameButtons.Add(b); + + height += 35; + } + + return true; + } + + if (w.Id == "JOINSERVER_BUTTON_DIRECTCONNECT") { Game.chrome.rootWidget.GetWidget("JOINSERVER_BG").Visible = false; - Game.chrome.rootWidget.GetWidget("MAINMENU_BG").Visible = true; - return true; - } - - return false; - } - } - - public class ConnectionDialogsDelegate : WidgetDelegate - { - public override bool OnMouseUp(Widget w, MouseInput mi) - { - // Main Menu root - if (w.Id == "CONNECTION_BUTTON_ABORT") - { - Game.chrome.rootWidget.GetWidget("MAINMENU_BG").Visible = true; - Game.chrome.rootWidget.GetWidget("CONNECTING_BG").Visible = false; - return true; - } - - if (w.Id == "CONNECTION_BUTTON_CANCEL") - { - Game.chrome.rootWidget.GetWidget("MAINMENU_BG").Visible = true; - Game.chrome.rootWidget.GetWidget("CONNECTION_FAILED_BG").Visible = false; - return true; - } - - if (w.Id == "CONNECTION_BUTTON_RETRY") - { - Game.JoinServer(Game.CurrentHost,Game.CurrentPort); - return true; - } - return false; - } - } - + Game.JoinServer(Game.Settings.NetworkHost, Game.Settings.NetworkPort); + return true; + } + + if (w.Id.Substring(0,10) == "JOIN_GAME_") + { + Game.chrome.rootWidget.GetWidget("JOINSERVER_BG").Visible = false; + int index = int.Parse(w.Id.Substring(10)); + var game = GameList[index]; + Game.JoinServer(game.Address.Split(':')[0], int.Parse(game.Address.Split(':')[1])); + return true; + } + + if (w.Id == "JOINSERVER_BUTTON_CANCEL") + { + Game.chrome.rootWidget.GetWidget("JOINSERVER_BG").Visible = false; + Game.chrome.rootWidget.GetWidget("MAINMENU_BG").Visible = true; + return true; + } + + return false; + } + } + + public class ConnectionDialogsDelegate : WidgetDelegate + { + public override bool OnMouseUp(Widget w, MouseInput mi) + { + // Main Menu root + if (w.Id == "CONNECTION_BUTTON_ABORT") + { + Game.chrome.rootWidget.GetWidget("MAINMENU_BG").Visible = true; + Game.chrome.rootWidget.GetWidget("CONNECTING_BG").Visible = false; + return true; + } + + if (w.Id == "CONNECTION_BUTTON_CANCEL") + { + Game.chrome.rootWidget.GetWidget("MAINMENU_BG").Visible = true; + Game.chrome.rootWidget.GetWidget("CONNECTION_FAILED_BG").Visible = false; + return true; + } + + if (w.Id == "CONNECTION_BUTTON_RETRY") + { + Game.JoinServer(Game.CurrentHost,Game.CurrentPort); + return true; + } + return false; + } + } + } \ No newline at end of file diff --git a/OpenRA.Game/Chrome/LabelWidget.cs b/OpenRA.Game/Chrome/LabelWidget.cs index b85875bdbb..c6ca55d855 100644 --- a/OpenRA.Game/Chrome/LabelWidget.cs +++ b/OpenRA.Game/Chrome/LabelWidget.cs @@ -20,34 +20,34 @@ using System.Drawing; -namespace OpenRA.Widgets -{ - class LabelWidget : Widget - { - public string Text = ""; - public string Align = "Left"; - - public override void Draw() - { - if (!Visible) - { - base.Draw(); - return; - } - - Rectangle r = Bounds; - Game.chrome.renderer.Device.EnableScissor(r.Left, r.Top, r.Width, r.Height); - - int2 bounds = Game.chrome.renderer.BoldFont.Measure(Text); - int2 position = new int2(Bounds.X,Bounds.Y); - - if (Align == "Center") - position = new int2(Bounds.X+Bounds.Width/2, Bounds.Y+Bounds.Height/2) - new int2(bounds.X / 2, bounds.Y/2); - - - Game.chrome.renderer.BoldFont.DrawText(Game.chrome.rgbaRenderer, Text, position, Color.White); - Game.chrome.renderer.Device.DisableScissor(); - base.Draw(); - } - } +namespace OpenRA.Widgets +{ + class LabelWidget : Widget + { + public string Text = ""; + public string Align = "Left"; + + public override void Draw() + { + if (!Visible) + { + base.Draw(); + return; + } + + Rectangle r = Bounds; + Game.chrome.renderer.Device.EnableScissor(r.Left, r.Top, r.Width, r.Height); + + int2 bounds = Game.chrome.renderer.BoldFont.Measure(Text); + int2 position = new int2(Bounds.X,Bounds.Y); + + if (Align == "Center") + position = new int2(Bounds.X+Bounds.Width/2, Bounds.Y+Bounds.Height/2) - new int2(bounds.X / 2, bounds.Y/2); + + + Game.chrome.renderer.BoldFont.DrawText(Game.chrome.rgbaRenderer, Text, position, Color.White); + Game.chrome.renderer.Device.DisableScissor(); + base.Draw(); + } + } } \ No newline at end of file diff --git a/OpenRA.Game/Chrome/Widget.cs b/OpenRA.Game/Chrome/Widget.cs index d14e3871d0..104553a296 100644 --- a/OpenRA.Game/Chrome/Widget.cs +++ b/OpenRA.Game/Chrome/Widget.cs @@ -23,54 +23,54 @@ using System.Collections.Generic; using System.Drawing; using System.Linq; using OpenRA.FileFormats; -using OpenRA.Widgets.Delegates; - -namespace OpenRA.Widgets -{ - public class Widget - { - // Info defined in YAML - public readonly string Id = null; - public readonly string X = "0"; - public readonly string Y = "0"; - public readonly string Width = "0"; - public readonly string Height = "0"; +using OpenRA.Widgets.Delegates; + +namespace OpenRA.Widgets +{ + public class Widget + { + // Info defined in YAML + public readonly string Id = null; + public readonly string X = "0"; + public readonly string Y = "0"; + public readonly string Width = "0"; + public readonly string Height = "0"; public readonly string Delegate = null; - public Lazy InputHandler; - - public bool Visible = true; - public readonly List Children = new List(); - - // Calculated internally - public Rectangle Bounds; + public Lazy InputHandler; + + public bool Visible = true; + public readonly List Children = new List(); + + // Calculated internally + public Rectangle Bounds; public Widget Parent = null; - public Widget() { InputHandler = Lazy.New(() => BindHandler(Delegate)); } - - public virtual void Initialize() - { - // Parse the YAML equations to find the widget bounds - Rectangle parentBounds = (Parent == null) ? new Rectangle(0,0,Game.viewport.Width,Game.viewport.Height) : Parent.Bounds; - - Dictionary substitutions = new Dictionary(); - substitutions.Add("WINDOW_RIGHT", Game.viewport.Width); - substitutions.Add("WINDOW_BOTTOM", Game.viewport.Height); - substitutions.Add("PARENT_RIGHT", parentBounds.Width); - substitutions.Add("PARENT_BOTTOM", parentBounds.Height); - int width = Evaluator.Evaluate(Width, substitutions); - int height = Evaluator.Evaluate(Height, substitutions); - - substitutions.Add("WIDTH", width); - substitutions.Add("HEIGHT", height); - - Bounds = new Rectangle(parentBounds.X + Evaluator.Evaluate(X, substitutions), - parentBounds.Y + Evaluator.Evaluate(Y, substitutions), - width, - height); - - foreach (var child in Children) - child.Initialize(); + public Widget() { InputHandler = Lazy.New(() => BindHandler(Delegate)); } + + public virtual void Initialize() + { + // Parse the YAML equations to find the widget bounds + Rectangle parentBounds = (Parent == null) ? new Rectangle(0,0,Game.viewport.Width,Game.viewport.Height) : Parent.Bounds; + + Dictionary substitutions = new Dictionary(); + substitutions.Add("WINDOW_RIGHT", Game.viewport.Width); + substitutions.Add("WINDOW_BOTTOM", Game.viewport.Height); + substitutions.Add("PARENT_RIGHT", parentBounds.Width); + substitutions.Add("PARENT_BOTTOM", parentBounds.Height); + int width = Evaluator.Evaluate(Width, substitutions); + int height = Evaluator.Evaluate(Height, substitutions); + + substitutions.Add("WIDTH", width); + substitutions.Add("HEIGHT", height); + + Bounds = new Rectangle(parentBounds.X + Evaluator.Evaluate(X, substitutions), + parentBounds.Y + Evaluator.Evaluate(Y, substitutions), + width, + height); + + foreach (var child in Children) + child.Initialize(); } public Rectangle GetEventBounds() @@ -92,59 +92,59 @@ namespace OpenRA.Widgets } throw new InvalidOperationException("Cannot locate widget delegate: {0}".F(name)); - } - - public virtual bool HandleInput(MouseInput mi) - { - // Are we able to handle this event? - if (!Visible || !GetEventBounds().Contains(mi.Location.X,mi.Location.Y)) - return false; - - // Can any of our children handle this? - foreach (var child in Children) - if (child.HandleInput(mi)) - return true; - - // Mousedown - if (InputHandler.Value != null && mi.Event == MouseInputEvent.Down) - return InputHandler.Value.OnMouseDown(this, mi); - - // Mouseup + } + + public virtual bool HandleInput(MouseInput mi) + { + // Are we able to handle this event? + if (!Visible || !GetEventBounds().Contains(mi.Location.X,mi.Location.Y)) + return false; + + // Can any of our children handle this? + foreach (var child in Children) + if (child.HandleInput(mi)) + return true; + + // Mousedown + if (InputHandler.Value != null && mi.Event == MouseInputEvent.Down) + return InputHandler.Value.OnMouseDown(this, mi); + + // Mouseup if (InputHandler.Value != null && mi.Event == MouseInputEvent.Up) - return InputHandler.Value.OnMouseUp(this, mi); - - // Mousemove - if (InputHandler.Value != null && mi.Event == MouseInputEvent.Move) - return InputHandler.Value.OnMouseMove(this, mi); - return false; - } - - public virtual void Draw() - { - if (Visible) - foreach (var child in Children) - child.Draw(); - } - - public void AddChild(Widget child) - { - child.Parent = this; - Children.Add( child ); - } - - public Widget GetWidget(string id) - { - if (this.Id == id) - return this; - - foreach (var child in Children) - if (child.GetWidget(id) != null) - return child; - - return null; - } - + return InputHandler.Value.OnMouseUp(this, mi); + + // Mousemove + if (InputHandler.Value != null && mi.Event == MouseInputEvent.Move) + return InputHandler.Value.OnMouseMove(this, mi); + return false; + } + + public virtual void Draw() + { + if (Visible) + foreach (var child in Children) + child.Draw(); + } + + public void AddChild(Widget child) + { + child.Parent = this; + Children.Add( child ); + } + + public Widget GetWidget(string id) + { + if (this.Id == id) + return this; + + foreach (var child in Children) + if (child.GetWidget(id) != null) + return child; + + return null; + } + } - class ContainerWidget : Widget { } + class ContainerWidget : Widget { } } \ No newline at end of file diff --git a/OpenRA.Game/Traits/Activities/Repair.cs b/OpenRA.Game/Traits/Activities/Repair.cs index ec36aff0aa..1231240046 100644 --- a/OpenRA.Game/Traits/Activities/Repair.cs +++ b/OpenRA.Game/Traits/Activities/Repair.cs @@ -56,7 +56,7 @@ namespace OpenRA.Traits.Activities .FirstOrDefault(a => a.traits.Contains()); if (hostBuilding != null) - hostBuilding.traits.Get() + hostBuilding.traits.Get() .PlayCustomAnim(hostBuilding, "active"); remainingTicks = (int)(Rules.General.RepairRate * 60 * 25); diff --git a/OpenRA.Game/Traits/Activities/Wait.cs b/OpenRA.Game/Traits/Activities/Wait.cs index 4566380c5d..c95d99785f 100644 --- a/OpenRA.Game/Traits/Activities/Wait.cs +++ b/OpenRA.Game/Traits/Activities/Wait.cs @@ -1,32 +1,32 @@ - -using System; - -namespace OpenRA.Traits.Activities -{ - - public class Wait: IActivity - { - int remainingTicks; - - public Wait (int period) - { - remainingTicks = period; - } - - public IActivity Tick (Actor self) - { - if (remainingTicks-- == 0) return NextActivity; - return this; - } - - - public void Cancel (Actor self) - { - remainingTicks = 0; NextActivity = null; - } - - - public IActivity NextActivity { get; set; } - - } -} + +using System; + +namespace OpenRA.Traits.Activities +{ + + public class Wait: IActivity + { + int remainingTicks; + + public Wait (int period) + { + remainingTicks = period; + } + + public IActivity Tick (Actor self) + { + if (remainingTicks-- == 0) return NextActivity; + return this; + } + + + public void Cancel (Actor self) + { + remainingTicks = 0; NextActivity = null; + } + + + public IActivity NextActivity { get; set; } + + } +} diff --git a/OpenRA.Game/Traits/CrateAction.cs b/OpenRA.Game/Traits/CrateAction.cs index 3365cdd064..43e6bf7aa5 100644 --- a/OpenRA.Game/Traits/CrateAction.cs +++ b/OpenRA.Game/Traits/CrateAction.cs @@ -1,60 +1,60 @@ -#region Copyright & License Information -/* - * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. - * This file is part of OpenRA. - * - * OpenRA is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * OpenRA is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with OpenRA. If not, see . - */ -#endregion - -using OpenRA.Effects; - -namespace OpenRA.Traits -{ - public class CrateActionInfo : ITraitInfo - { - public int SelectionShares = 10; - public string Effect = null; - public string Notification = null; - public virtual object Create(Actor self) { return new CrateAction(self, this); } - } - - public class CrateAction - { - public Actor self; - public CrateActionInfo info; - - public CrateAction(Actor self, CrateActionInfo info) - { - this.self = self; - this.info = info; - } - - public virtual int GetSelectionShares(Actor collector) - { - return info.SelectionShares; - } - - public virtual void Activate(Actor collector) - { - Sound.PlayToPlayer(collector.Owner, info.Notification); - - collector.World.AddFrameEndTask(w => - { - if (info.Effect != null) - w.Add(new CrateEffect(collector, info.Effect)); - }); - } - } -} +#region Copyright & License Information +/* + * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. + * This file is part of OpenRA. + * + * OpenRA is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OpenRA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenRA. If not, see . + */ +#endregion + +using OpenRA.Effects; + +namespace OpenRA.Traits +{ + public class CrateActionInfo : ITraitInfo + { + public int SelectionShares = 10; + public string Effect = null; + public string Notification = null; + public virtual object Create(Actor self) { return new CrateAction(self, this); } + } + + public class CrateAction + { + public Actor self; + public CrateActionInfo info; + + public CrateAction(Actor self, CrateActionInfo info) + { + this.self = self; + this.info = info; + } + + public virtual int GetSelectionShares(Actor collector) + { + return info.SelectionShares; + } + + public virtual void Activate(Actor collector) + { + Sound.PlayToPlayer(collector.Owner, info.Notification); + + collector.World.AddFrameEndTask(w => + { + if (info.Effect != null) + w.Add(new CrateEffect(collector, info.Effect)); + }); + } + } +} diff --git a/OpenRA.Game/Traits/HasUnitOnBuild.cs b/OpenRA.Game/Traits/HasUnitOnBuild.cs index afec5f9600..dd18c2b722 100644 --- a/OpenRA.Game/Traits/HasUnitOnBuild.cs +++ b/OpenRA.Game/Traits/HasUnitOnBuild.cs @@ -1,49 +1,49 @@ - -using System; - -namespace OpenRA.Traits -{ - - class HasUnitOnBuildInfo : ITraitInfo - { - public readonly string Unit = null; - public readonly string InitialActivity = null; - public readonly int2 SpawnOffset = int2.Zero; - public readonly int Facing = 0; - - public object Create( Actor self ) { return new HasUnitOnBuild(self); } - } - - public class HasUnitOnBuild - { - - public HasUnitOnBuild(Actor self) - { - var info = self.Info.Traits.Get(); - - self.World.AddFrameEndTask( - w => - { - var unit = w.CreateActor(info.Unit, self.Location - + info.SpawnOffset, self.Owner); - var unitTrait = unit.traits.Get(); - unitTrait.Facing = info.Facing; - - if (info.InitialActivity != null) - { - foreach (var mod in Game.ModAssemblies) - { - var fullTypeName = mod.Second + "." + info.InitialActivity; - var activity = (IActivity)mod.First.CreateInstance(fullTypeName); - if (activity == null) continue; - - unit.QueueActivity( activity ); - return; - } - - throw new InvalidOperationException("Cannot locate Activity: `{0}`".F(info.InitialActivity)); - } - }); - } - } -} + +using System; + +namespace OpenRA.Traits +{ + + class HasUnitOnBuildInfo : ITraitInfo + { + public readonly string Unit = null; + public readonly string InitialActivity = null; + public readonly int2 SpawnOffset = int2.Zero; + public readonly int Facing = 0; + + public object Create( Actor self ) { return new HasUnitOnBuild(self); } + } + + public class HasUnitOnBuild + { + + public HasUnitOnBuild(Actor self) + { + var info = self.Info.Traits.Get(); + + self.World.AddFrameEndTask( + w => + { + var unit = w.CreateActor(info.Unit, self.Location + + info.SpawnOffset, self.Owner); + var unitTrait = unit.traits.Get(); + unitTrait.Facing = info.Facing; + + if (info.InitialActivity != null) + { + foreach (var mod in Game.ModAssemblies) + { + var fullTypeName = mod.Second + "." + info.InitialActivity; + var activity = (IActivity)mod.First.CreateInstance(fullTypeName); + if (activity == null) continue; + + unit.QueueActivity( activity ); + return; + } + + throw new InvalidOperationException("Cannot locate Activity: `{0}`".F(info.InitialActivity)); + } + }); + } + } +} diff --git a/OpenRA.Game/Traits/LineBuild.cs b/OpenRA.Game/Traits/LineBuild.cs index 40d7b55830..2708010f07 100644 --- a/OpenRA.Game/Traits/LineBuild.cs +++ b/OpenRA.Game/Traits/LineBuild.cs @@ -1,35 +1,35 @@ -#region Copyright & License Information -/* - * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. - * This file is part of OpenRA. - * - * OpenRA is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * OpenRA is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with OpenRA. If not, see . - */ -#endregion - -using System; -using System.Collections.Generic; -using System.Linq; -using OpenRA.Effects; -using OpenRA.GameRules; -using OpenRA.Traits.Activities; - -namespace OpenRA.Traits -{ - public class LineBuildInfo : StatelessTraitInfo - { - public readonly int Range = 5; - } - public class LineBuild {} -} +#region Copyright & License Information +/* + * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. + * This file is part of OpenRA. + * + * OpenRA is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OpenRA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenRA. If not, see . + */ +#endregion + +using System; +using System.Collections.Generic; +using System.Linq; +using OpenRA.Effects; +using OpenRA.GameRules; +using OpenRA.Traits.Activities; + +namespace OpenRA.Traits +{ + public class LineBuildInfo : StatelessTraitInfo + { + public readonly int Range = 5; + } + public class LineBuild {} +} diff --git a/OpenRA.Game/Traits/Player/EvaAlerts.cs b/OpenRA.Game/Traits/Player/EvaAlerts.cs index 516a68b90e..5a4e20c2a1 100644 --- a/OpenRA.Game/Traits/Player/EvaAlerts.cs +++ b/OpenRA.Game/Traits/Player/EvaAlerts.cs @@ -1,63 +1,63 @@ -#region Copyright & License Information -/* - * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. - * This file is part of OpenRA. - * - * OpenRA is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * OpenRA is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with OpenRA. If not, see . - */ -#endregion - - -namespace OpenRA.Traits -{ - class EvaAlertsInfo : StatelessTraitInfo - { - // Sound effects - public readonly string TabClick = "ramenu1.aud"; - - public readonly string ChatBeep = "rabeep1.aud"; - public readonly string RadarUp = "radaron2.aud"; - public readonly string RadarDown = "radardn1.aud"; - - public readonly string CashTickUp = "cashup1.aud"; - public readonly string CashTickDown = "cashdn1.aud"; - - // Build Palette - public readonly string BuildPaletteOpen = "bleep13.aud"; - public readonly string BuildPaletteClose = "bleep13.aud"; - public readonly string BuildingSelectAudio = "abldgin1.aud"; - public readonly string BuildingReadyAudio = "conscmp1.aud"; - public readonly string BuildingCannotPlaceAudio = "nodeply1.aud"; - public readonly string UnitSelectAudio = "train1.aud"; - public readonly string UnitReadyAudio = "unitrdy1.aud"; - public readonly string OnHoldAudio = "onhold1.aud"; - public readonly string CancelledAudio = "cancld1.aud"; - public readonly string ClickAudio = "ramenu1.aud"; - - - // For manual powerup/down in ra-ng - public readonly string DisablePower = "bleep11.aud"; - public readonly string EnablePower = "bleep12.aud"; - - // Eva speech - public readonly string LowPower = "lopower1.aud"; - public readonly string SilosNeeded = "silond1.aud"; - public readonly string UnitLost = "unitlst1.aud"; - public readonly string NavalUnitLost = "navylst1.aud"; - public readonly string PrimaryBuildingSelected = "pribldg1.aud"; - public readonly string CreditsStolen = "credit1.aud"; - } - - class EvaAlerts {} -} +#region Copyright & License Information +/* + * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. + * This file is part of OpenRA. + * + * OpenRA is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OpenRA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenRA. If not, see . + */ +#endregion + + +namespace OpenRA.Traits +{ + class EvaAlertsInfo : StatelessTraitInfo + { + // Sound effects + public readonly string TabClick = "ramenu1.aud"; + + public readonly string ChatBeep = "rabeep1.aud"; + public readonly string RadarUp = "radaron2.aud"; + public readonly string RadarDown = "radardn1.aud"; + + public readonly string CashTickUp = "cashup1.aud"; + public readonly string CashTickDown = "cashdn1.aud"; + + // Build Palette + public readonly string BuildPaletteOpen = "bleep13.aud"; + public readonly string BuildPaletteClose = "bleep13.aud"; + public readonly string BuildingSelectAudio = "abldgin1.aud"; + public readonly string BuildingReadyAudio = "conscmp1.aud"; + public readonly string BuildingCannotPlaceAudio = "nodeply1.aud"; + public readonly string UnitSelectAudio = "train1.aud"; + public readonly string UnitReadyAudio = "unitrdy1.aud"; + public readonly string OnHoldAudio = "onhold1.aud"; + public readonly string CancelledAudio = "cancld1.aud"; + public readonly string ClickAudio = "ramenu1.aud"; + + + // For manual powerup/down in ra-ng + public readonly string DisablePower = "bleep11.aud"; + public readonly string EnablePower = "bleep12.aud"; + + // Eva speech + public readonly string LowPower = "lopower1.aud"; + public readonly string SilosNeeded = "silond1.aud"; + public readonly string UnitLost = "unitlst1.aud"; + public readonly string NavalUnitLost = "navylst1.aud"; + public readonly string PrimaryBuildingSelected = "pribldg1.aud"; + public readonly string CreditsStolen = "credit1.aud"; + } + + class EvaAlerts {} +} diff --git a/OpenRA.Game/Traits/Render/RenderBuildingWall.cs b/OpenRA.Game/Traits/Render/RenderBuildingWall.cs index ec81026f40..2535c90f5c 100644 --- a/OpenRA.Game/Traits/Render/RenderBuildingWall.cs +++ b/OpenRA.Game/Traits/Render/RenderBuildingWall.cs @@ -1,103 +1,103 @@ -#region Copyright & License Information -/* - * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. - * This file is part of OpenRA. - * - * OpenRA is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * OpenRA is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with OpenRA. If not, see . - */ -#endregion - -using System.Linq; - -namespace OpenRA.Traits -{ - class RenderBuildingWallInfo : RenderBuildingInfo - { - public readonly int DamageStates = 2; - public override object Create(Actor self) { return new RenderBuildingWall(self); } - } - - class RenderBuildingWall : RenderBuilding - { - string seqName; - int damageStates; - Actor self; - - public RenderBuildingWall(Actor self) - : base(self) - { - seqName = "idle"; - this.self = self; - this.damageStates = self.Info.Traits.Get().DamageStates; - } - - public override void Damaged(Actor self, AttackInfo e) - { - if (!e.DamageStateChanged) return; - - switch (e.DamageState) - { - case DamageState.Normal: - seqName = "idle"; - break; - case DamageState.ThreeQuarter: - if (damageStates >= 4) - seqName = "minor-damaged-idle"; - break; - case DamageState.Half: - seqName = "damaged-idle"; - Sound.Play(self.Info.Traits.Get().DamagedSound); - break; - case DamageState.Quarter: - if (damageStates >= 3) - { - seqName = "critical-idle"; - Sound.Play(self.Info.Traits.Get().DamagedSound); - } - break; - } - } - - public override void Tick(Actor self) - { - base.Tick(self); - - // TODO: This only needs updating when a wall is built or destroyed - int index = NearbyWalls( self.Location ); - - anim.PlayFetchIndex(seqName, () => index); - - } - bool IsWall( int x, int y) - { - return self.World.Queries.WithTrait().Any(a => (a.Actor.Info.Name == self.Info.Name && a.Actor.Location.X == x && a.Actor.Location.Y == y)); - } - - int NearbyWalls( int2 xy ) - { - int ret = 0; - - if( IsWall( xy.X, xy.Y - 1 ) ) - ret |= 1; - if( IsWall( xy.X + 1, xy.Y ) ) - ret |= 2; - if( IsWall( xy.X, xy.Y + 1 ) ) - ret |= 4; - if( IsWall( xy.X - 1, xy.Y ) ) - ret |= 8; - return ret; - } - - } -} +#region Copyright & License Information +/* + * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. + * This file is part of OpenRA. + * + * OpenRA is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OpenRA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenRA. If not, see . + */ +#endregion + +using System.Linq; + +namespace OpenRA.Traits +{ + class RenderBuildingWallInfo : RenderBuildingInfo + { + public readonly int DamageStates = 2; + public override object Create(Actor self) { return new RenderBuildingWall(self); } + } + + class RenderBuildingWall : RenderBuilding + { + string seqName; + int damageStates; + Actor self; + + public RenderBuildingWall(Actor self) + : base(self) + { + seqName = "idle"; + this.self = self; + this.damageStates = self.Info.Traits.Get().DamageStates; + } + + public override void Damaged(Actor self, AttackInfo e) + { + if (!e.DamageStateChanged) return; + + switch (e.DamageState) + { + case DamageState.Normal: + seqName = "idle"; + break; + case DamageState.ThreeQuarter: + if (damageStates >= 4) + seqName = "minor-damaged-idle"; + break; + case DamageState.Half: + seqName = "damaged-idle"; + Sound.Play(self.Info.Traits.Get().DamagedSound); + break; + case DamageState.Quarter: + if (damageStates >= 3) + { + seqName = "critical-idle"; + Sound.Play(self.Info.Traits.Get().DamagedSound); + } + break; + } + } + + public override void Tick(Actor self) + { + base.Tick(self); + + // TODO: This only needs updating when a wall is built or destroyed + int index = NearbyWalls( self.Location ); + + anim.PlayFetchIndex(seqName, () => index); + + } + bool IsWall( int x, int y) + { + return self.World.Queries.WithTrait().Any(a => (a.Actor.Info.Name == self.Info.Name && a.Actor.Location.X == x && a.Actor.Location.Y == y)); + } + + int NearbyWalls( int2 xy ) + { + int ret = 0; + + if( IsWall( xy.X, xy.Y - 1 ) ) + ret |= 1; + if( IsWall( xy.X + 1, xy.Y ) ) + ret |= 2; + if( IsWall( xy.X, xy.Y + 1 ) ) + ret |= 4; + if( IsWall( xy.X - 1, xy.Y ) ) + ret |= 8; + return ret; + } + + } +} diff --git a/OpenRA.Game/Traits/Render/RenderBuildingWarFactory.cs b/OpenRA.Game/Traits/Render/RenderBuildingWarFactory.cs index 969fba8f4c..d5deeae26d 100644 --- a/OpenRA.Game/Traits/Render/RenderBuildingWarFactory.cs +++ b/OpenRA.Game/Traits/Render/RenderBuildingWarFactory.cs @@ -52,7 +52,7 @@ namespace OpenRA.Traits public void Tick(Actor self) { - if (isOpen && !self.World.WorldActor.traits.Get() + if (isOpen && !self.World.WorldActor.traits.Get() .GetUnitsAt(((1f/Game.CellSize) * self.CenterLocation).ToInt2()).Any()) { isOpen = false; diff --git a/OpenRA.Game/Traits/Wall.cs b/OpenRA.Game/Traits/Wall.cs index e1f1f8a443..ca73d5d60a 100644 --- a/OpenRA.Game/Traits/Wall.cs +++ b/OpenRA.Game/Traits/Wall.cs @@ -1,32 +1,32 @@ -#region Copyright & License Information -/* - * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. - * This file is part of OpenRA. - * - * OpenRA is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * OpenRA is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with OpenRA. If not, see . - */ -#endregion - -using System; -using System.Collections.Generic; -using System.Linq; -using OpenRA.Effects; -using OpenRA.GameRules; -using OpenRA.Traits.Activities; - -namespace OpenRA.Traits -{ - public class WallInfo : StatelessTraitInfo {} - public class Wall {} -} +#region Copyright & License Information +/* + * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. + * This file is part of OpenRA. + * + * OpenRA is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OpenRA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenRA. If not, see . + */ +#endregion + +using System; +using System.Collections.Generic; +using System.Linq; +using OpenRA.Effects; +using OpenRA.GameRules; +using OpenRA.Traits.Activities; + +namespace OpenRA.Traits +{ + public class WallInfo : StatelessTraitInfo {} + public class Wall {} +} diff --git a/OpenRA.Game/Traits/World/ScreenShaker.cs b/OpenRA.Game/Traits/World/ScreenShaker.cs index b2bcb74374..b825a3ff64 100644 --- a/OpenRA.Game/Traits/World/ScreenShaker.cs +++ b/OpenRA.Game/Traits/World/ScreenShaker.cs @@ -21,52 +21,52 @@ using System; using System.Collections.Generic; using System.Linq; -using OpenRA.FileFormats; - -namespace OpenRA.Traits -{ - class ScreenShakerInfo : ITraitInfo - { - public object Create( Actor self ) { return new ScreenShaker(); } - } - - public class ScreenShaker : ITick - { - int ticks = 0; - List> shakeEffects = new List>(); - - public void Tick (Actor self) - { +using OpenRA.FileFormats; + +namespace OpenRA.Traits +{ + class ScreenShakerInfo : ITraitInfo + { + public object Create( Actor self ) { return new ScreenShaker(); } + } + + public class ScreenShaker : ITick + { + int ticks = 0; + List> shakeEffects = new List>(); + + public void Tick (Actor self) + { Game.viewport.Scroll(getScrollOffset()); - shakeEffects.RemoveAll(t => t.a == ticks); - ticks++; - } - - public void AddEffect(int time, float2 position, int intensity) - { - shakeEffects.Add(Tuple.New(ticks + time, position, intensity)); - } - - public float2 getScrollOffset() - { - int xFreq = 4; - int yFreq = 5; - - return GetIntensity() * new float2( - (float) Math.Sin((ticks*2*Math.PI)/xFreq) , - (float) Math.Cos((ticks*2*Math.PI)/yFreq)); - } - - public float GetIntensity() + shakeEffects.RemoveAll(t => t.a == ticks); + ticks++; + } + + public void AddEffect(int time, float2 position, int intensity) + { + shakeEffects.Add(Tuple.New(ticks + time, position, intensity)); + } + + public float2 getScrollOffset() + { + int xFreq = 4; + int yFreq = 5; + + return GetIntensity() * new float2( + (float) Math.Sin((ticks*2*Math.PI)/xFreq) , + (float) Math.Cos((ticks*2*Math.PI)/yFreq)); + } + + public float GetIntensity() { var cp = Game.viewport.Location + .5f * new float2(Game.viewport.Width, Game.viewport.Height); - var intensity = 24 * 24 * 100 * shakeEffects.Sum( - e => e.c / (e.b - cp).LengthSquared); - - return Math.Min(intensity, 10); - } - - } -} + var intensity = 24 * 24 * 100 * shakeEffects.Sum( + e => e.c / (e.b - cp).LengthSquared); + + return Math.Min(intensity, 10); + } + + } +} diff --git a/OpenRA.Game/Traits/World/Theater.cs b/OpenRA.Game/Traits/World/Theater.cs index e35850267b..3b0054752d 100644 --- a/OpenRA.Game/Traits/World/Theater.cs +++ b/OpenRA.Game/Traits/World/Theater.cs @@ -1,33 +1,33 @@ -#region Copyright & License Information -/* - * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. - * This file is part of OpenRA. - * - * OpenRA is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * OpenRA is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with OpenRA. If not, see . - */ -#endregion - -namespace OpenRA.Traits -{ - class TheaterInfo : StatelessTraitInfo - { - public readonly string Name = null; - public readonly string Theater = null; - public readonly string Suffix = null; - public readonly string Tileset = null; - public readonly string Templates = null; - public readonly string MapColors = null; - } - class Theater {} -} +#region Copyright & License Information +/* + * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. + * This file is part of OpenRA. + * + * OpenRA is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OpenRA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenRA. If not, see . + */ +#endregion + +namespace OpenRA.Traits +{ + class TheaterInfo : StatelessTraitInfo + { + public readonly string Name = null; + public readonly string Theater = null; + public readonly string Suffix = null; + public readonly string Tileset = null; + public readonly string Templates = null; + public readonly string MapColors = null; + } + class Theater {} +} diff --git a/OpenRA.Mods.RA/Crates/ResetRadarCrateAction.cs b/OpenRA.Mods.RA/Crates/ResetRadarCrateAction.cs index f893855d6c..ba386e42cd 100644 --- a/OpenRA.Mods.RA/Crates/ResetRadarCrateAction.cs +++ b/OpenRA.Mods.RA/Crates/ResetRadarCrateAction.cs @@ -1,41 +1,41 @@ -#region Copyright & License Information -/* - * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. - * This file is part of OpenRA. - * - * OpenRA is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * OpenRA is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with OpenRA. If not, see . - */ -#endregion - -using OpenRA.Traits; - -namespace OpenRA.Mods.RA -{ - class HideMapCrateActionInfo : CrateActionInfo - { - public override object Create(Actor self) { return new HideMapCrateAction(self, this); } - } - - class HideMapCrateAction : CrateAction - { - public HideMapCrateAction(Actor self, HideMapCrateActionInfo info) - : base(self, info) {} - - public override void Activate(Actor collector) - { - collector.Owner.Shroud.ResetExplored(); - base.Activate(collector); - } - } -} +#region Copyright & License Information +/* + * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. + * This file is part of OpenRA. + * + * OpenRA is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OpenRA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenRA. If not, see . + */ +#endregion + +using OpenRA.Traits; + +namespace OpenRA.Mods.RA +{ + class HideMapCrateActionInfo : CrateActionInfo + { + public override object Create(Actor self) { return new HideMapCrateAction(self, this); } + } + + class HideMapCrateAction : CrateAction + { + public HideMapCrateAction(Actor self, HideMapCrateActionInfo info) + : base(self, info) {} + + public override void Activate(Actor collector) + { + collector.Owner.Shroud.ResetExplored(); + base.Activate(collector); + } + } +}