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

@@ -251,7 +251,7 @@ namespace OpenRa.Game
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");
else
{
@@ -260,13 +260,13 @@ namespace OpenRa.Game
}
buildPaletteRenderer.DrawSprite(repairButton.Image, repairDrawPos, PaletteType.Chrome);
// Sell
Rectangle sellRect = new Rectangle(Game.viewport.Width - 60, 5,
sellButton.Image.bounds.Width, sellButton.Image.bounds.Height);
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>());
buildPaletteRenderer.DrawSprite(sellButton.Image, sellDrawPos, PaletteType.Chrome);

View File

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

View File

@@ -45,19 +45,6 @@ namespace OpenRa.Game
// Load user settings
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"))
{
@@ -65,7 +52,23 @@ namespace OpenRa.Game
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) { }
}
UiOverlay.ShowUnitDebug = Game.Settings.UnitDebug;
UiOverlay.ShowBuildDebug = Game.Settings.BuildingDebug;
WorldRenderer.ShowUnitPaths = Game.Settings.PathDebug;
Renderer.SheetSize = Game.Settings.SheetSize;
FileSystem.MountDefaultPackages();

View File

@@ -35,6 +35,8 @@ namespace OpenRa.Game.Orders
}
public void Tick()
{
if (Game.Settings.RepairRequiresConyard)
{
var hasFact = Game.world.Actors
.Any(a => a.Owner == Game.LocalPlayer && a.traits.Contains<ConstructionYard>());
@@ -42,6 +44,7 @@ namespace OpenRa.Game.Orders
if (!hasFact)
Game.controller.CancelInputMode();
}
}
public void Render() {}