From a1fc5406ea60374ab8a371ff0d3e92662ae9e748 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 3 Jan 2010 20:07:56 +1300 Subject: [PATCH 1/4] settings stuff --- OpenRa.Game/GameRules/UserSettings.cs | 2 +- OpenRa.Game/MainWindow.cs | 37 ++++++++++++--------------- settings-netplay-local.ini | 3 +++ 3 files changed, 20 insertions(+), 22 deletions(-) create mode 100644 settings-netplay-local.ini diff --git a/OpenRa.Game/GameRules/UserSettings.cs b/OpenRa.Game/GameRules/UserSettings.cs index bc502d4c36..fd102cf4bd 100644 --- a/OpenRa.Game/GameRules/UserSettings.cs +++ b/OpenRa.Game/GameRules/UserSettings.cs @@ -26,7 +26,7 @@ namespace OpenRa.Game.GameRules public readonly string Replay = ""; // Gameplay options - public readonly bool RepairRequiresConyard = false; + public readonly bool RepairRequiresConyard = true; } } diff --git a/OpenRa.Game/MainWindow.cs b/OpenRa.Game/MainWindow.cs index 8d1d61ce81..67a8d7c6e6 100755 --- a/OpenRa.Game/MainWindow.cs +++ b/OpenRa.Game/MainWindow.cs @@ -4,9 +4,9 @@ using System.IO; using System.Runtime.InteropServices; using System.Windows.Forms; using OpenRa.FileFormats; +using OpenRa.Game.GameRules; using OpenRa.Game.Graphics; using OpenRa.Game.Orders; -using OpenRa.Game.GameRules; namespace OpenRa.Game @@ -31,51 +31,33 @@ namespace OpenRa.Game [DllImport("user32")] static extern int ShowCursor([MarshalAs(UnmanagedType.Bool)] bool visible); - - public MainWindow(Settings settings) { - - FormBorderStyle = FormBorderStyle.None; BackColor = Color.Black; StartPosition = FormStartPosition.Manual; Location = Point.Empty; Visible = true; - // Load user settings - Game.Settings = new UserSettings(); - while (!File.Exists("redalert.mix")) { var current = Directory.GetCurrentDirectory(); if (Directory.GetDirectoryRoot(current) == current) throw new InvalidOperationException("Unable to load MIX files."); Directory.SetCurrentDirectory(".."); - - try - { - // settings.ini should be located with the mix files - FileSystem.MountTemporary(new Folder("./")); - IniFile SettingsRules = new IniFile(FileSystem.Open("settings.ini")); - FieldLoader.Load(Game.Settings, SettingsRules.GetSection("Settings")); - FileSystem.UnmountTemporaryPackages(); - } - catch (FileNotFoundException) { } } + LoadUserSettings(settings); + UiOverlay.ShowUnitDebug = Game.Settings.UnitDebug; UiOverlay.ShowBuildDebug = Game.Settings.BuildingDebug; WorldRenderer.ShowUnitPaths = Game.Settings.PathDebug; Renderer.SheetSize = Game.Settings.SheetSize; - FileSystem.MountDefaultPackages(); if (Game.Settings.UseAftermath) - { FileSystem.MountAftermathPackages(); - } bool windowed = !Game.Settings.Fullscreen; renderer = new Renderer(this, GetResolution(settings), windowed); @@ -89,6 +71,19 @@ namespace OpenRa.Game Game.ResetTimer(); } + static void LoadUserSettings(Settings settings) + { + Game.Settings = new UserSettings(); + var settingsFile = settings.GetValue("settings", "settings.ini"); + // if (FileSystem.Exists(settingsFile)) + { + FileSystem.MountTemporary(new Folder("./")); + FieldLoader.Load(Game.Settings, + new IniFile(FileSystem.Open(settingsFile)).GetSection("Settings")); + FileSystem.UnmountTemporaryPackages(); + } + } + internal void Run() { while (Created && Visible) diff --git a/settings-netplay-local.ini b/settings-netplay-local.ini new file mode 100644 index 0000000000..7d13c14222 --- /dev/null +++ b/settings-netplay-local.ini @@ -0,0 +1,3 @@ +[Settings] +NetworkHost=localhost +NetworkPort=1234 \ No newline at end of file From c35f3f0bfb6ed014380169404d929f276d9fd385 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 3 Jan 2010 20:16:55 +1300 Subject: [PATCH 2/4] invuln etc palette need hacked too. --- OpenRa.Game/Traits/ChronoshiftDeploy.cs | 3 ++- settings-netplay-local-aftermath.ini | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 settings-netplay-local-aftermath.ini diff --git a/OpenRa.Game/Traits/ChronoshiftDeploy.cs b/OpenRa.Game/Traits/ChronoshiftDeploy.cs index b2c280cf8e..df9726d26f 100644 --- a/OpenRa.Game/Traits/ChronoshiftDeploy.cs +++ b/OpenRa.Game/Traits/ChronoshiftDeploy.cs @@ -2,6 +2,7 @@ using System.Linq; using OpenRa.Game.Orders; using System.Drawing; +using OpenRa.Game.Graphics; namespace OpenRa.Game.Traits { @@ -109,7 +110,7 @@ namespace OpenRa.Game.Traits var f = 1 - (animationTick * 1.0f / animationLength); using (var bitmapCopy = new Bitmap(bmp)) - for (int j = 0; j < 8; j++) + for (int j = 0; j < (int)PaletteType.Chrome; j++) for (int i = 0; i < bmp.Width; i++) { var h = bitmapCopy.GetPixel(i, j).GetHue(); // 0-360 diff --git a/settings-netplay-local-aftermath.ini b/settings-netplay-local-aftermath.ini new file mode 100644 index 0000000000..fef7a12f8c --- /dev/null +++ b/settings-netplay-local-aftermath.ini @@ -0,0 +1,4 @@ +[Settings] +NetworkHost=localhost +NetworkPort=1234 +UseAftermath=yes \ No newline at end of file From 41e04c96386e4329098836e61ec1d15836afba14 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 3 Jan 2010 20:19:00 +1300 Subject: [PATCH 3/4] min build palette height = 4 --- OpenRa.Game/Chrome.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/OpenRa.Game/Chrome.cs b/OpenRa.Game/Chrome.cs index 12844e1aed..c40e233cbb 100644 --- a/OpenRa.Game/Chrome.cs +++ b/OpenRa.Game/Chrome.cs @@ -40,6 +40,8 @@ namespace OpenRa.Game readonly int paletteColumns; readonly int2 paletteOrigin; + + const int MinRows = 4; public Chrome(Renderer r) { @@ -96,7 +98,7 @@ namespace OpenRa.Game cantBuild = new Animation("clock"); cantBuild.PlayFetchIndex("idle", () => 0); - digitSprites = OpenRa.Game.Graphics.Util.MakeArray(10, a => a) + digitSprites = Graphics.Util.MakeArray(10, a => a) .Select(n => new Sprite(specialBin, new Rectangle(32 + 13 * n, 0, 13, 17), TextureChannel.Alpha)).ToList(); shimSprites = new[] @@ -392,7 +394,7 @@ namespace OpenRa.Game if (++x == columns) { x = 0; y++; } } - while (x != 0) + while (x != 0 || y < MinRows) { var rect = new Rectangle(origin.X + x * 64, origin.Y + 48 * y, 64, 48); var drawPos = Game.viewport.Location + new float2(rect.Location); From 5757b904b29fadcdb0c4a8fde69dbc10a6bb3d15 Mon Sep 17 00:00:00 2001 From: Alli Date: Sun, 3 Jan 2010 21:39:44 +1300 Subject: [PATCH 4/4] uncommented settings.ini existance check --- OpenRa.Game/MainWindow.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenRa.Game/MainWindow.cs b/OpenRa.Game/MainWindow.cs index 67a8d7c6e6..d4d570a4ff 100755 --- a/OpenRa.Game/MainWindow.cs +++ b/OpenRa.Game/MainWindow.cs @@ -75,7 +75,7 @@ namespace OpenRa.Game { Game.Settings = new UserSettings(); var settingsFile = settings.GetValue("settings", "settings.ini"); - // if (FileSystem.Exists(settingsFile)) + if (FileSystem.Exists(settingsFile)) { FileSystem.MountTemporary(new Folder("./")); FieldLoader.Load(Game.Settings,