Add support for custom mission timers: UserInterfaceGlobal
This commit is contained in:
@@ -9,10 +9,11 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using OpenRA.Scripting;
|
||||||
|
|
||||||
namespace OpenRA.Graphics
|
namespace OpenRA.Graphics
|
||||||
{
|
{
|
||||||
public struct HSLColor
|
public struct HSLColor : IScriptBindable
|
||||||
{
|
{
|
||||||
public readonly byte H;
|
public readonly byte H;
|
||||||
public readonly byte S;
|
public readonly byte S;
|
||||||
|
|||||||
@@ -176,6 +176,8 @@
|
|||||||
<Compile Include="Orders\UnitOrderTargeter.cs" />
|
<Compile Include="Orders\UnitOrderTargeter.cs" />
|
||||||
<Compile Include="Pathfinder\CellInfo.cs" />
|
<Compile Include="Pathfinder\CellInfo.cs" />
|
||||||
<Compile Include="PlayerExtensions.cs" />
|
<Compile Include="PlayerExtensions.cs" />
|
||||||
|
<Compile Include="Scripting\Global\HSLColorGlobal.cs" />
|
||||||
|
<Compile Include="Scripting\Global\UserInterfaceGlobal.cs" />
|
||||||
<Compile Include="ServerTraits\ColorValidator.cs" />
|
<Compile Include="ServerTraits\ColorValidator.cs" />
|
||||||
<Compile Include="ServerTraits\LobbyCommands.cs" />
|
<Compile Include="ServerTraits\LobbyCommands.cs" />
|
||||||
<Compile Include="ServerTraits\LobbySettingsNotification.cs" />
|
<Compile Include="ServerTraits\LobbySettingsNotification.cs" />
|
||||||
|
|||||||
32
OpenRA.Mods.Common/Scripting/Global/HSLColorGlobal.cs
Normal file
32
OpenRA.Mods.Common/Scripting/Global/HSLColorGlobal.cs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2015 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. For more information,
|
||||||
|
* see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Scripting;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Common.Scripting.Global
|
||||||
|
{
|
||||||
|
[ScriptGlobal("HSLColor")]
|
||||||
|
public class HSLColorGlobal : ScriptGlobal
|
||||||
|
{
|
||||||
|
public HSLColorGlobal(ScriptContext context)
|
||||||
|
: base(context) { }
|
||||||
|
|
||||||
|
[Desc("Create a new HSL color with the specified hue/saturation/luminosity.")]
|
||||||
|
public HSLColor New(int hue, int saturation, int luminosity)
|
||||||
|
{
|
||||||
|
var h = (byte)hue.Clamp(0, 255);
|
||||||
|
var s = (byte)saturation.Clamp(0, 255);
|
||||||
|
var l = (byte)luminosity.Clamp(0, 255);
|
||||||
|
|
||||||
|
return new HSLColor(h, s, l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
35
OpenRA.Mods.Common/Scripting/Global/UserInterfaceGlobal.cs
Normal file
35
OpenRA.Mods.Common/Scripting/Global/UserInterfaceGlobal.cs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2015 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. For more information,
|
||||||
|
* see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System.Drawing;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Mods.Common.Widgets;
|
||||||
|
using OpenRA.Scripting;
|
||||||
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Common.Scripting.Global
|
||||||
|
{
|
||||||
|
[ScriptGlobal("UserInterface")]
|
||||||
|
public class UserInterfaceGlobal : ScriptGlobal
|
||||||
|
{
|
||||||
|
public UserInterfaceGlobal(ScriptContext context)
|
||||||
|
: base(context) { }
|
||||||
|
|
||||||
|
[Desc("Displays a text message at the top center of the screen.")]
|
||||||
|
public void SetMissionText(string text, HSLColor? color = null)
|
||||||
|
{
|
||||||
|
var luaLabel = Ui.Root.Get("INGAME_ROOT").Get<LabelWidget>("MISSION_TEXT");
|
||||||
|
luaLabel.GetText = () => text;
|
||||||
|
|
||||||
|
Color c = color.HasValue ? HSLColor.RGBFromHSL(color.Value.H / 255f, color.Value.S / 255f, color.Value.L / 255f) : Color.White;
|
||||||
|
luaLabel.GetColor = () => c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -39,6 +39,14 @@ Container@INGAME_ROOT:
|
|||||||
Container@PLAYER_ROOT:
|
Container@PLAYER_ROOT:
|
||||||
Container@MENU_ROOT:
|
Container@MENU_ROOT:
|
||||||
TooltipContainer@TOOLTIP_CONTAINER:
|
TooltipContainer@TOOLTIP_CONTAINER:
|
||||||
|
Label@MISSION_TEXT:
|
||||||
|
X: WINDOW_RIGHT/2 - 256
|
||||||
|
Y: 22
|
||||||
|
Width: 512
|
||||||
|
Height: 25
|
||||||
|
Font: Bold
|
||||||
|
Align: Center
|
||||||
|
Contrast: true
|
||||||
|
|
||||||
Container@PERF_WIDGETS:
|
Container@PERF_WIDGETS:
|
||||||
Logic: PerfDebugLogic
|
Logic: PerfDebugLogic
|
||||||
|
|||||||
@@ -46,3 +46,11 @@ Container@INGAME_ROOT:
|
|||||||
Contrast: true
|
Contrast: true
|
||||||
Container@MENU_ROOT:
|
Container@MENU_ROOT:
|
||||||
TooltipContainer@TOOLTIP_CONTAINER:
|
TooltipContainer@TOOLTIP_CONTAINER:
|
||||||
|
Label@MISSION_TEXT:
|
||||||
|
X: WINDOW_RIGHT/2 - 256
|
||||||
|
Y: 22
|
||||||
|
Width: 512
|
||||||
|
Height: 25
|
||||||
|
Font: Bold
|
||||||
|
Align: Center
|
||||||
|
Contrast: true
|
||||||
|
|||||||
@@ -27,3 +27,11 @@ Container@INGAME_ROOT:
|
|||||||
Container@PERF_ROOT:
|
Container@PERF_ROOT:
|
||||||
Container@MENU_ROOT:
|
Container@MENU_ROOT:
|
||||||
TooltipContainer@TOOLTIP_CONTAINER:
|
TooltipContainer@TOOLTIP_CONTAINER:
|
||||||
|
Label@MISSION_TEXT:
|
||||||
|
X: WINDOW_RIGHT/2 - 256
|
||||||
|
Y: 22
|
||||||
|
Width: 512
|
||||||
|
Height: 25
|
||||||
|
Font: Bold
|
||||||
|
Align: Center
|
||||||
|
Contrast: true
|
||||||
|
|||||||
Reference in New Issue
Block a user