Developer Mode (pchote: amended)
This commit is contained in:
@@ -26,6 +26,7 @@ namespace OpenRA.GameRules
|
||||
public bool IndexDebug = false;
|
||||
public bool RecordSyncReports = true;
|
||||
public bool ShowGameTimer = true;
|
||||
public bool DeveloperMode = false;
|
||||
|
||||
// Window settings
|
||||
public WindowMode WindowMode = WindowMode.PseudoFullscreen;
|
||||
|
||||
@@ -236,6 +236,7 @@
|
||||
<Project>{BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}</Project>
|
||||
<Name>OpenRA.FileFormats</Name>
|
||||
</ProjectReference>
|
||||
<Compile Include="Widgets\Delegates\DeveloperModeDelegate.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
|
||||
|
||||
@@ -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,6 +38,7 @@ namespace OpenRA
|
||||
{
|
||||
Log.AddChannel("exception", "openra.exception.txt", true, false);
|
||||
Log.Write("exception", "{0}", e.ToString());
|
||||
if (!Game.Settings.DeveloperMode || ( Game.Settings.DeveloperMode && Game.GetGameId() != 0) )
|
||||
Log.Upload(Game.GetGameId());
|
||||
throw;
|
||||
}
|
||||
|
||||
@@ -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); }
|
||||
}
|
||||
|
||||
96
OpenRA.Game/Widgets/Delegates/DeveloperModeDelegate.cs
Normal file
96
OpenRA.Game/Widgets/Delegates/DeveloperModeDelegate.cs
Normal 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; };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -233,4 +233,9 @@ copy "$(TargetPath)" "$(SolutionDir)mods/ra/"
|
||||
cd "$(SolutionDir)"
|
||||
ralint ra</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Widgets\" />
|
||||
<Folder Include="Widgets\Delegates\" />
|
||||
<Folder Include="Widgets\Delegates\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -46,6 +46,15 @@ Container@ROOT:
|
||||
Bold:True
|
||||
WorldTooltip@INGAME_WORLD_TOOLTIP:
|
||||
Id:INGAME_WORLD_TOOLTIP
|
||||
Button@INGAME_DEVELOPERMODE_BUTTON:
|
||||
Id:INGAME_DEVELOPERMODE_BUTTON
|
||||
X:324
|
||||
Y:0
|
||||
Width:160
|
||||
Height:25
|
||||
Text:Developer Mode
|
||||
Visible:false
|
||||
Bold:True
|
||||
RadarBin@INGAME_RADAR_BIN:
|
||||
Id:INGAME_RADAR_BIN
|
||||
PowerBin@INGAME_POWER_BIN:
|
||||
@@ -147,3 +156,67 @@ Container@ROOT:
|
||||
Width: 760
|
||||
Height: 30
|
||||
ClickThrough: True
|
||||
Background@DEVELOPERMODE_BG:
|
||||
Id:DEVELOPERMODE_BG
|
||||
Delegate:DeveloperModeDelegate
|
||||
X:(WINDOW_RIGHT - WIDTH)/2
|
||||
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
||||
Width:450
|
||||
Height:400
|
||||
Visible:false
|
||||
Children:
|
||||
Label@LABEL_TITLE:
|
||||
Id:LABEL_TITLE
|
||||
X:(PARENT_RIGHT - WIDTH)/2
|
||||
Y:20
|
||||
Width:250
|
||||
Height:25
|
||||
Text:Developer Mode
|
||||
Align:Center
|
||||
Checkbox@SETTINGS_CHECKBOX_SHROUD
|
||||
Id:SETTINGS_CHECKBOX_SHROUD
|
||||
X:100
|
||||
Y:50
|
||||
Height:20
|
||||
Width:20
|
||||
Text:Disable Shroud
|
||||
Checkbox@SETTINGS_CHECKBOX_UNITDEBUG:
|
||||
Id:SETTINGS_CHECKBOX_UNITDEBUG
|
||||
X:100
|
||||
Y:80
|
||||
Width:300
|
||||
Height:20
|
||||
Text:Show Occupied Cells
|
||||
Checkbox@SETTINGS_CHECKBOX_PATHDEBUG:
|
||||
Id:SETTINGS_CHECKBOX_PATHDEBUG
|
||||
X:100
|
||||
Y:110
|
||||
Width:300
|
||||
Height:20
|
||||
Text:Show Unit Paths
|
||||
Checkbox@SETTINGS_CHECKBOX_INDEXDEBUG:
|
||||
Id:SETTINGS_CHECKBOX_INDEXDEBUG
|
||||
X:100
|
||||
Y:140
|
||||
Width:300
|
||||
Height:20
|
||||
Text:Show Spatial Index Debug
|
||||
Label@LABEL_MP_WARNING
|
||||
Id:LABEL_MP_WARNING
|
||||
X:100
|
||||
Y:170
|
||||
Text:May cause errors under multiplayer:
|
||||
Button@SETTINGS_GIVE_CASH
|
||||
Id:SETTINGS_GIVE_CASH
|
||||
X:100
|
||||
Y:200
|
||||
Width:150
|
||||
Height:20
|
||||
Text: Give Cash
|
||||
Checkbox@SETTINGS_BUILD_SPEED
|
||||
Id:SETTINGS_BUILD_SPEED
|
||||
X:100
|
||||
Y:230
|
||||
Width:20
|
||||
Height:20
|
||||
Text:Instant Build Speed
|
||||
@@ -43,6 +43,15 @@ Container@ROOT:
|
||||
Bold:True
|
||||
WorldTooltip@INGAME_WORLD_TOOLTIP:
|
||||
Id:INGAME_WORLD_TOOLTIP
|
||||
Button@INGAME_DEVELOPERMODE_BUTTON:
|
||||
Id:INGAME_DEVELOPERMODE_BUTTON
|
||||
X:324
|
||||
Y:0
|
||||
Width:160
|
||||
Height:25
|
||||
Text:Developer Mode
|
||||
Visible:false
|
||||
Bold:True
|
||||
RadarBin@INGAME_RADAR_BIN:
|
||||
Id:INGAME_RADAR_BIN
|
||||
PowerBin@INGAME_POWER_BIN:
|
||||
@@ -144,3 +153,67 @@ Container@ROOT:
|
||||
Width: 760
|
||||
Height: 30
|
||||
ClickThrough: True
|
||||
Background@DEVELOPERMODE_BG:
|
||||
Id:DEVELOPERMODE_BG
|
||||
Delegate:DeveloperModeDelegate
|
||||
X:(WINDOW_RIGHT - WIDTH)/2
|
||||
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
||||
Width:450
|
||||
Height:400
|
||||
Visible:false
|
||||
Children:
|
||||
Label@LABEL_TITLE:
|
||||
Id:LABEL_TITLE
|
||||
X:(PARENT_RIGHT - WIDTH)/2
|
||||
Y:20
|
||||
Width:250
|
||||
Height:25
|
||||
Text:Developer Mode
|
||||
Align:Center
|
||||
Checkbox@SETTINGS_CHECKBOX_SHROUD
|
||||
Id:SETTINGS_CHECKBOX_SHROUD
|
||||
X:100
|
||||
Y:50
|
||||
Height:20
|
||||
Width:20
|
||||
Text:Disable Shroud
|
||||
Checkbox@SETTINGS_CHECKBOX_UNITDEBUG:
|
||||
Id:SETTINGS_CHECKBOX_UNITDEBUG
|
||||
X:100
|
||||
Y:80
|
||||
Width:300
|
||||
Height:20
|
||||
Text:Show Occupied Cells
|
||||
Checkbox@SETTINGS_CHECKBOX_PATHDEBUG:
|
||||
Id:SETTINGS_CHECKBOX_PATHDEBUG
|
||||
X:100
|
||||
Y:110
|
||||
Width:300
|
||||
Height:20
|
||||
Text:Show Unit Paths
|
||||
Checkbox@SETTINGS_CHECKBOX_INDEXDEBUG:
|
||||
Id:SETTINGS_CHECKBOX_INDEXDEBUG
|
||||
X:100
|
||||
Y:140
|
||||
Width:300
|
||||
Height:20
|
||||
Text:Show Spatial Index Debug
|
||||
Label@LABEL_MP_WARNING
|
||||
Id:LABEL_MP_WARNING
|
||||
X:100
|
||||
Y:170
|
||||
Text:May cause errors under multiplayer:
|
||||
Button@SETTINGS_GIVE_CASH
|
||||
Id:SETTINGS_GIVE_CASH
|
||||
X:100
|
||||
Y:200
|
||||
Width:150
|
||||
Height:20
|
||||
Text: Give Cash
|
||||
Checkbox@SETTINGS_BUILD_SPEED
|
||||
Id:SETTINGS_BUILD_SPEED
|
||||
X:100
|
||||
Y:230
|
||||
Width:20
|
||||
Height:20
|
||||
Text:Instant Build Speed
|
||||
Reference in New Issue
Block a user