Repair-by-conyard moved into a user setting (disabled by default)

This commit is contained in:
Paul Chote
2010-01-03 12:55:37 +13:00
parent 109a1253b2
commit 50cc9175bf
4 changed files with 44 additions and 27 deletions

View File

@@ -246,12 +246,12 @@ namespace OpenRa.Game
void DrawButtons() void DrawButtons()
{ {
// Repair // Repair
Rectangle repairRect = new Rectangle(Game.viewport.Width - 100, 5,repairButton.Image.bounds.Width, repairButton.Image.bounds.Height); Rectangle repairRect = new Rectangle(Game.viewport.Width - 100, 5, repairButton.Image.bounds.Width, repairButton.Image.bounds.Height);
var repairDrawPos = Game.viewport.Location + new float2(repairRect.Location); var repairDrawPos = Game.viewport.Location + new float2(repairRect.Location);
var hasFact = Game.world.Actors.Any(a => a.Owner == Game.LocalPlayer && a.traits.Contains<ConstructionYard>()); var hasFact = Game.world.Actors.Any(a => a.Owner == Game.LocalPlayer && a.traits.Contains<ConstructionYard>());
if (!hasFact) if (Game.Settings.RepairRequiresConyard && !hasFact)
repairButton.ReplaceAnim("disabled"); repairButton.ReplaceAnim("disabled");
else else
{ {
@@ -260,13 +260,13 @@ namespace OpenRa.Game
} }
buildPaletteRenderer.DrawSprite(repairButton.Image, repairDrawPos, PaletteType.Chrome); buildPaletteRenderer.DrawSprite(repairButton.Image, repairDrawPos, PaletteType.Chrome);
// Sell
Rectangle sellRect = new Rectangle(Game.viewport.Width - 60, 5, Rectangle sellRect = new Rectangle(Game.viewport.Width - 60, 5,
sellButton.Image.bounds.Width, sellButton.Image.bounds.Height); sellButton.Image.bounds.Width, sellButton.Image.bounds.Height);
var sellDrawPos = Game.viewport.Location + new float2(sellRect.Location); var sellDrawPos = Game.viewport.Location + new float2(sellRect.Location);
repairButton.ReplaceAnim(Game.controller.orderGenerator is SellOrderGenerator ? "pressed" : "normal"); sellButton.ReplaceAnim(Game.controller.orderGenerator is SellOrderGenerator ? "pressed" : "normal");
AddButton(sellRect, isLmb => Game.controller.ToggleInputMode<SellOrderGenerator>()); AddButton(sellRect, isLmb => Game.controller.ToggleInputMode<SellOrderGenerator>());
buildPaletteRenderer.DrawSprite(sellButton.Image, sellDrawPos, PaletteType.Chrome); buildPaletteRenderer.DrawSprite(sellButton.Image, sellDrawPos, PaletteType.Chrome);

View File

@@ -3,19 +3,30 @@ namespace OpenRa.Game.GameRules
{ {
class UserSettings class UserSettings
{ {
// Debug settings
public readonly bool UnitDebug = false; public readonly bool UnitDebug = false;
public readonly bool BuildingDebug = false; public readonly bool BuildingDebug = false;
public readonly bool PathDebug = false; public readonly bool PathDebug = false;
// Window settings
public readonly int Width = 0;
public readonly int Height = 0;
public readonly bool Fullscreen = false;
// Internal game settings
public readonly int Timestep = 40; public readonly int Timestep = 40;
public readonly string Replay = ""; public readonly int SheetSize = 512;
// External game settings
public readonly bool UseAftermath = false; public readonly bool UseAftermath = false;
public readonly string NetworkHost = ""; public readonly string NetworkHost = "";
public readonly int NetworkPort = 0; public readonly int NetworkPort = 0;
public readonly int SheetSize = 512;
public readonly bool Fullscreen = false;
public readonly string Map = "scm12ea.ini"; public readonly string Map = "scm12ea.ini";
public readonly int Player = 1; public readonly int Player = 1;
public readonly int Width = 0; public readonly string Replay = "";
public readonly int Height = 0;
// Gameplay options
public readonly bool RepairRequiresConyard = false;
} }
} }

View File

@@ -45,28 +45,31 @@ namespace OpenRa.Game
// Load user settings // Load user settings
Game.Settings = new UserSettings(); Game.Settings = new UserSettings();
try
{
FileSystem.MountTemporary(new Folder("./"));
IniFile SettingsRules = new IniFile(FileSystem.Open("settings.ini"));
FieldLoader.Load(Game.Settings, SettingsRules.GetSection("Settings"));
FileSystem.UnmountTemporaryPackages();
}
catch (FileNotFoundException) {}
UiOverlay.ShowUnitDebug = Game.Settings.UnitDebug;
UiOverlay.ShowBuildDebug = Game.Settings.BuildingDebug;
WorldRenderer.ShowUnitPaths = Game.Settings.PathDebug;
Renderer.SheetSize = Game.Settings.SheetSize;
while (!File.Exists("redalert.mix")) while (!File.Exists("redalert.mix"))
{ {
var current = Directory.GetCurrentDirectory(); var current = Directory.GetCurrentDirectory();
if (Directory.GetDirectoryRoot(current) == current) if (Directory.GetDirectoryRoot(current) == current)
throw new InvalidOperationException("Unable to load MIX files."); throw new InvalidOperationException("Unable to load MIX files.");
Directory.SetCurrentDirectory(".."); 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) { }
} }
UiOverlay.ShowUnitDebug = Game.Settings.UnitDebug;
UiOverlay.ShowBuildDebug = Game.Settings.BuildingDebug;
WorldRenderer.ShowUnitPaths = Game.Settings.PathDebug;
Renderer.SheetSize = Game.Settings.SheetSize;
FileSystem.MountDefaultPackages(); FileSystem.MountDefaultPackages();
if (Game.Settings.UseAftermath) if (Game.Settings.UseAftermath)

View File

@@ -36,11 +36,14 @@ namespace OpenRa.Game.Orders
public void Tick() public void Tick()
{ {
var hasFact = Game.world.Actors if (Game.Settings.RepairRequiresConyard)
.Any(a => a.Owner == Game.LocalPlayer && a.traits.Contains<ConstructionYard>()); {
var hasFact = Game.world.Actors
if (!hasFact) .Any(a => a.Owner == Game.LocalPlayer && a.traits.Contains<ConstructionYard>());
Game.controller.CancelInputMode();
if (!hasFact)
Game.controller.CancelInputMode();
}
} }