Added cell pos and world pos to debug
This commit is contained in:
44
OpenRA.Mods.Common/Widgets/Logic/Ingame/DebugLogic.cs
Normal file
44
OpenRA.Mods.Common/Widgets/Logic/Ingame/DebugLogic.cs
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2019 The OpenRA Developers (see AUTHORS)
|
||||||
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
|
* available to you 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. For more
|
||||||
|
* information, see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Mods.Common.Traits;
|
||||||
|
using OpenRA.Network;
|
||||||
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Common.Widgets.Logic.Ingame
|
||||||
|
{
|
||||||
|
public class DebugLogic : ChromeLogic
|
||||||
|
{
|
||||||
|
[ObjectCreator.UseCtor]
|
||||||
|
public DebugLogic(Widget widget, OrderManager orderManager, World world, WorldRenderer worldRenderer)
|
||||||
|
{
|
||||||
|
var geometryOverlay = world.WorldActor.TraitOrDefault<TerrainGeometryOverlay>();
|
||||||
|
if (geometryOverlay != null)
|
||||||
|
{
|
||||||
|
var labelWidget = widget.Get<LabelWidget>("DEBUG_TEXT");
|
||||||
|
|
||||||
|
var cellPosText = new CachedTransform<int2, string>(t =>
|
||||||
|
{
|
||||||
|
var cell = worldRenderer.Viewport.ViewToWorld(Viewport.LastMousePos);
|
||||||
|
var map = worldRenderer.World.Map;
|
||||||
|
var wpos = map.CenterOfCell(cell);
|
||||||
|
return map.Height.Contains(cell) ? "({0},{1}) ({2})".F(cell, map.Height[cell], wpos) : "";
|
||||||
|
});
|
||||||
|
|
||||||
|
labelWidget.GetText = () => cellPosText.Update(Viewport.LastMousePos);
|
||||||
|
|
||||||
|
labelWidget.IsVisible = () => geometryOverlay.Enabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using OpenRA.Mods.Common.Commands;
|
||||||
using OpenRA.Mods.Common.Scripting;
|
using OpenRA.Mods.Common.Scripting;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
@@ -53,6 +54,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var devMode = world.LocalPlayer.PlayerActor.Trait<DeveloperMode>();
|
||||||
|
if (devMode.Enabled)
|
||||||
|
Game.LoadWidget(world, "DEBUG_WIDGETS", worldRoot, new WidgetArgs());
|
||||||
|
|
||||||
Game.LoadWidget(world, "CHAT_PANEL", worldRoot, new WidgetArgs() { { "isMenuChat", false } });
|
Game.LoadWidget(world, "CHAT_PANEL", worldRoot, new WidgetArgs() { { "isMenuChat", false } });
|
||||||
|
|
||||||
world.GameOver += () =>
|
world.GameOver += () =>
|
||||||
|
|||||||
14
mods/cnc/chrome/ingame-debuginfo.yaml
Normal file
14
mods/cnc/chrome/ingame-debuginfo.yaml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
Container@DEBUG_WIDGETS:
|
||||||
|
Logic: DebugLogic
|
||||||
|
X: WINDOW_RIGHT / 2 - WIDTH
|
||||||
|
Y: 60
|
||||||
|
Width: 100
|
||||||
|
Height: 55
|
||||||
|
Children:
|
||||||
|
Label@DEBUG_TEXT:
|
||||||
|
Y: 35
|
||||||
|
Width: PARENT_RIGHT
|
||||||
|
Height: 15
|
||||||
|
Align: Center
|
||||||
|
Font: Bold
|
||||||
|
Contrast: true
|
||||||
@@ -120,6 +120,7 @@ ChromeLayout:
|
|||||||
cnc|chrome/ingame-infoobjectives.yaml
|
cnc|chrome/ingame-infoobjectives.yaml
|
||||||
cnc|chrome/ingame-infostats.yaml
|
cnc|chrome/ingame-infostats.yaml
|
||||||
cnc|chrome/ingame-observerstats.yaml
|
cnc|chrome/ingame-observerstats.yaml
|
||||||
|
cnc|chrome/ingame-debuginfo.yaml
|
||||||
cnc|chrome/music.yaml
|
cnc|chrome/music.yaml
|
||||||
cnc|chrome/settings.yaml
|
cnc|chrome/settings.yaml
|
||||||
cnc|chrome/credits.yaml
|
cnc|chrome/credits.yaml
|
||||||
|
|||||||
14
mods/common/chrome/ingame-debuginfo.yaml
Normal file
14
mods/common/chrome/ingame-debuginfo.yaml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
Container@DEBUG_WIDGETS:
|
||||||
|
Logic: DebugLogic
|
||||||
|
X: WINDOW_RIGHT / 2 - WIDTH
|
||||||
|
Y: 60
|
||||||
|
Width: 100
|
||||||
|
Height: 55
|
||||||
|
Children:
|
||||||
|
Label@DEBUG_TEXT:
|
||||||
|
Y: 35
|
||||||
|
Width: PARENT_RIGHT
|
||||||
|
Height: 15
|
||||||
|
Align: Center
|
||||||
|
Font: Bold
|
||||||
|
Contrast: true
|
||||||
@@ -80,6 +80,7 @@ ChromeLayout:
|
|||||||
d2k|chrome/ingame-player.yaml
|
d2k|chrome/ingame-player.yaml
|
||||||
common|chrome/ingame-perf.yaml
|
common|chrome/ingame-perf.yaml
|
||||||
common|chrome/ingame-debug.yaml
|
common|chrome/ingame-debug.yaml
|
||||||
|
common|chrome/ingame-debuginfo.yaml
|
||||||
common|chrome/ingame-infochat.yaml
|
common|chrome/ingame-infochat.yaml
|
||||||
d2k|chrome/mainmenu.yaml
|
d2k|chrome/mainmenu.yaml
|
||||||
common|chrome/settings.yaml
|
common|chrome/settings.yaml
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ ChromeLayout:
|
|||||||
ra|chrome/ingame-player.yaml
|
ra|chrome/ingame-player.yaml
|
||||||
common|chrome/ingame-perf.yaml
|
common|chrome/ingame-perf.yaml
|
||||||
common|chrome/ingame-debug.yaml
|
common|chrome/ingame-debug.yaml
|
||||||
|
common|chrome/ingame-debuginfo.yaml
|
||||||
common|chrome/ingame-infochat.yaml
|
common|chrome/ingame-infochat.yaml
|
||||||
common|chrome/mainmenu.yaml
|
common|chrome/mainmenu.yaml
|
||||||
common|chrome/settings.yaml
|
common|chrome/settings.yaml
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ ChromeLayout:
|
|||||||
ts|chrome/ingame-player.yaml
|
ts|chrome/ingame-player.yaml
|
||||||
common|chrome/ingame-perf.yaml
|
common|chrome/ingame-perf.yaml
|
||||||
ts|chrome/ingame-debug.yaml
|
ts|chrome/ingame-debug.yaml
|
||||||
|
common|chrome/ingame-debuginfo.yaml
|
||||||
common|chrome/ingame-infochat.yaml
|
common|chrome/ingame-infochat.yaml
|
||||||
common|chrome/mainmenu.yaml
|
common|chrome/mainmenu.yaml
|
||||||
ts|chrome/mainmenu-prerelease-notification.yaml
|
ts|chrome/mainmenu-prerelease-notification.yaml
|
||||||
|
|||||||
Reference in New Issue
Block a user