Developer Mode (pchote: amended)

This commit is contained in:
alzeih
2010-06-26 00:04:36 +12:00
parent f39f7fc23e
commit f92b59e6db
12 changed files with 262 additions and 12 deletions

View File

@@ -24,8 +24,9 @@ namespace OpenRA.GameRules
public bool PathDebug = false;
public bool PerfDebug = false;
public bool IndexDebug = false;
public bool RecordSyncReports = true;
public bool ShowGameTimer = true;
public bool RecordSyncReports = true;
public bool ShowGameTimer = true;
public bool DeveloperMode = false;
// Window settings
public WindowMode WindowMode = WindowMode.PseudoFullscreen;

View File

@@ -236,7 +236,8 @@
<Project>{BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}</Project>
<Name>OpenRA.FileFormats</Name>
</ProjectReference>
</ItemGroup>
<Compile Include="Widgets\Delegates\DeveloperModeDelegate.cs" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
<Visible>False</Visible>

View File

@@ -24,7 +24,7 @@ namespace OpenRA
// brutal hack
Application.CurrentCulture = CultureInfo.InvariantCulture;
if (Debugger.IsAttached || args.Contains("--just-die"))
if (Debugger.IsAttached)
{
Run(args);
return;
@@ -38,7 +38,8 @@ namespace OpenRA
{
Log.AddChannel("exception", "openra.exception.txt", true, false);
Log.Write("exception", "{0}", e.ToString());
Log.Upload(Game.GetGameId());
if (!Game.Settings.DeveloperMode || ( Game.Settings.DeveloperMode && Game.GetGameId() != 0) )
Log.Upload(Game.GetGameId());
throw;
}
}

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Traits
{
class ProductionQueueInfo : ITraitInfo
{
public readonly float BuildSpeed = 0.4f;
public float BuildSpeed = 0.4f;
public readonly int LowPowerSlowdown = 3;
public object Create(ActorInitializer init) { return new ProductionQueue(init.self); }
}

View File

@@ -53,7 +53,7 @@ namespace OpenRA.Widgets
var wasPressed = Depressed;
return (LoseFocus(mi) && wasPressed);
}
if (mi.Event == MouseInputEvent.Down)
Depressed = true;
else if (mi.Event == MouseInputEvent.Move && Focused)

View File

@@ -0,0 +1,96 @@
#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 <http://www.gnu.org/licenses/>.
*/
#endregion
using System;
using OpenRA;
using OpenRA.Traits;
using OpenRA.Widgets;
namespace OpenRA.Widgets.Delegates
{
public class DeveloperModeDelegate : IWidgetDelegate
{
float oldBuildSpeed = 0;
bool slowed = false;
public DeveloperModeDelegate ()
{
var devmodeBG = Chrome.rootWidget.GetWidget("INGAME_ROOT").GetWidget("DEVELOPERMODE_BG");
var devModeButton = Chrome.rootWidget.GetWidget<ButtonWidget>("INGAME_DEVELOPERMODE_BUTTON");
devModeButton.OnMouseUp = mi =>
{
devmodeBG.Visible ^= true;
return true;
};
devmodeBG.GetWidget<CheckboxWidget>("SETTINGS_CHECKBOX_SHROUD").Checked =
() => Game.world.LocalPlayer.Shroud.Disabled;
devmodeBG.GetWidget<CheckboxWidget>("SETTINGS_CHECKBOX_SHROUD").OnMouseDown = mi =>
{
Game.world.LocalPlayer.Shroud.Disabled ^= true;
return true;
};
devmodeBG.GetWidget<CheckboxWidget>("SETTINGS_CHECKBOX_UNITDEBUG").Checked =
() => {return Game.Settings.UnitDebug;};
devmodeBG.GetWidget("SETTINGS_CHECKBOX_UNITDEBUG").OnMouseDown = mi => {
Game.Settings.UnitDebug ^= true;
return true;
};
devmodeBG.GetWidget<CheckboxWidget>("SETTINGS_CHECKBOX_PATHDEBUG").Checked =
() => {return Game.Settings.PathDebug;};
devmodeBG.GetWidget("SETTINGS_CHECKBOX_PATHDEBUG").OnMouseDown = mi => {
Game.Settings.PathDebug ^= true;
return true;
};
devmodeBG.GetWidget<CheckboxWidget>("SETTINGS_CHECKBOX_INDEXDEBUG").Checked =
() => {return Game.Settings.IndexDebug;};
devmodeBG.GetWidget("SETTINGS_CHECKBOX_INDEXDEBUG").OnMouseDown = mi => {
Game.Settings.IndexDebug ^= true;
return true;
};
//danger will robinson
devmodeBG.GetWidget<ButtonWidget>("SETTINGS_GIVE_CASH").OnMouseUp = mi =>
{
Game.world.LocalPlayer.PlayerActor.traits.Get<PlayerResources>().GiveCash(5000);
return true;
};
devmodeBG.GetWidget<CheckboxWidget>("SETTINGS_BUILD_SPEED").OnMouseDown = mi =>
{
oldBuildSpeed = (!slowed)? Game.world.LocalPlayer.PlayerActor.Info.Traits.Get<ProductionQueueInfo>().BuildSpeed : oldBuildSpeed;
Game.world.LocalPlayer.PlayerActor.Info.Traits.Get<ProductionQueueInfo>().BuildSpeed = (slowed)? oldBuildSpeed : 0;
slowed ^= true;
return true;
};
devmodeBG.GetWidget<CheckboxWidget>("SETTINGS_BUILD_SPEED").Checked =
() => {return slowed;};
devModeButton.IsVisible = () => { return Game.Settings.DeveloperMode; };
}
}
}

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Widgets.Delegates
Chrome.rootWidget.GetWidget("INGAME_DIPLOMACY_BUTTON").OnMouseUp = mi =>
{
diplomacyBG.Visible = !diplomacyBG.Visible;
if (diplomacyBG.Visible)
if (diplomacyBG.IsVisible())
LayoutDialog(diplomacyBG);
return true;
};

View File

@@ -126,7 +126,7 @@ namespace OpenRA.Widgets
}
public override bool HandleInput(MouseInput mi)
{
{
if (mi.Event == MouseInputEvent.Down)
{
var action = buttons.Where(a => a.First.Contains(mi.Location.ToPoint()))

View File

@@ -140,7 +140,7 @@ namespace OpenRA.Widgets
public Rectangle GetEventBounds()
{
return Children
.Where(c => c.Visible)
.Where(c => c.IsVisible())
.Select(c => c.GetEventBounds())
.Aggregate(RenderBounds, Rectangle.Union);
}