Add transient notifications pool
This commit is contained in:
committed by
Paul Chote
parent
e22b6de4e8
commit
a1e6ac85dc
@@ -37,7 +37,8 @@ namespace OpenRA
|
|||||||
public enum TextNotificationPoolFilters
|
public enum TextNotificationPoolFilters
|
||||||
{
|
{
|
||||||
None = 0,
|
None = 0,
|
||||||
Feedback = 1
|
Feedback = 1,
|
||||||
|
Transients = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum WorldViewport { Native, Close, Medium, Far }
|
public enum WorldViewport { Native, Close, Medium, Far }
|
||||||
@@ -273,7 +274,7 @@ namespace OpenRA
|
|||||||
[Desc("Allow mods to enable the Discord service that can interact with a local Discord client.")]
|
[Desc("Allow mods to enable the Discord service that can interact with a local Discord client.")]
|
||||||
public bool EnableDiscordService = true;
|
public bool EnableDiscordService = true;
|
||||||
|
|
||||||
public TextNotificationPoolFilters TextNotificationPoolFilters = TextNotificationPoolFilters.Feedback;
|
public TextNotificationPoolFilters TextNotificationPoolFilters = TextNotificationPoolFilters.Feedback | TextNotificationPoolFilters.Transients;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Settings
|
public class Settings
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ using OpenRA.Primitives;
|
|||||||
|
|
||||||
namespace OpenRA
|
namespace OpenRA
|
||||||
{
|
{
|
||||||
public enum TextNotificationPool { System, Chat, Mission, Feedback }
|
public enum TextNotificationPool { System, Chat, Mission, Feedback, Transients }
|
||||||
|
|
||||||
public class TextNotification : IEquatable<TextNotification>
|
public class TextNotification : IEquatable<TextNotification>
|
||||||
{
|
{
|
||||||
@@ -37,7 +37,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
public bool CanIncrementOnDuplicate()
|
public bool CanIncrementOnDuplicate()
|
||||||
{
|
{
|
||||||
return Pool == TextNotificationPool.Feedback || Pool == TextNotificationPool.System;
|
return Pool == TextNotificationPool.Feedback || Pool == TextNotificationPool.System || Pool == TextNotificationPool.Transients;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool operator ==(TextNotification me, TextNotification other) { return me.GetHashCode() == other.GetHashCode(); }
|
public static bool operator ==(TextNotification me, TextNotification other) { return me.GetHashCode() == other.GetHashCode(); }
|
||||||
|
|||||||
@@ -26,6 +26,14 @@ namespace OpenRA
|
|||||||
SystemMessageLabel = "Battlefield Control";
|
SystemMessageLabel = "Battlefield Control";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void AddTransientLine(string text)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(text))
|
||||||
|
return;
|
||||||
|
|
||||||
|
AddTextNotification(TextNotificationPool.Transients, SystemMessageLabel, text);
|
||||||
|
}
|
||||||
|
|
||||||
public static void AddFeedbackLine(string text)
|
public static void AddFeedbackLine(string text)
|
||||||
{
|
{
|
||||||
AddTextNotification(TextNotificationPool.Feedback, SystemMessageLabel, text);
|
AddTextNotification(TextNotificationPool.Feedback, SystemMessageLabel, text);
|
||||||
@@ -69,6 +77,7 @@ namespace OpenRA
|
|||||||
return pool == TextNotificationPool.Chat ||
|
return pool == TextNotificationPool.Chat ||
|
||||||
pool == TextNotificationPool.System ||
|
pool == TextNotificationPool.System ||
|
||||||
pool == TextNotificationPool.Mission ||
|
pool == TextNotificationPool.Mission ||
|
||||||
|
(pool == TextNotificationPool.Transients && filters.HasFlag(TextNotificationPoolFilters.Transients)) ||
|
||||||
(pool == TextNotificationPool.Feedback && filters.HasFlag(TextNotificationPoolFilters.Feedback));
|
(pool == TextNotificationPool.Feedback && filters.HasFlag(TextNotificationPoolFilters.Feedback));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
static bool IsNotificationEligible(TextNotification notification)
|
static bool IsNotificationEligible(TextNotification notification)
|
||||||
{
|
{
|
||||||
return notification.Pool == TextNotificationPool.Feedback;
|
return notification.Pool == TextNotificationPool.Transients || notification.Pool == TextNotificationPool.Feedback;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool disposed = false;
|
bool disposed = false;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
public string SystemTemplate = "SYSTEM_LINE_TEMPLATE";
|
public string SystemTemplate = "SYSTEM_LINE_TEMPLATE";
|
||||||
public string MissionTemplate = "CHAT_LINE_TEMPLATE";
|
public string MissionTemplate = "CHAT_LINE_TEMPLATE";
|
||||||
public string FeedbackTemplate = "TRANSIENT_LINE_TEMPLATE";
|
public string FeedbackTemplate = "TRANSIENT_LINE_TEMPLATE";
|
||||||
|
public string TransientsTemplate = "TRANSIENT_LINE_TEMPLATE";
|
||||||
readonly Dictionary<TextNotificationPool, Widget> templates = new Dictionary<TextNotificationPool, Widget>();
|
readonly Dictionary<TextNotificationPool, Widget> templates = new Dictionary<TextNotificationPool, Widget>();
|
||||||
|
|
||||||
readonly List<int> expirations = new List<int>();
|
readonly List<int> expirations = new List<int>();
|
||||||
@@ -43,6 +44,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
templates.Add(TextNotificationPool.System, Ui.LoadWidget(SystemTemplate, null, new WidgetArgs()));
|
templates.Add(TextNotificationPool.System, Ui.LoadWidget(SystemTemplate, null, new WidgetArgs()));
|
||||||
templates.Add(TextNotificationPool.Mission, Ui.LoadWidget(MissionTemplate, null, new WidgetArgs()));
|
templates.Add(TextNotificationPool.Mission, Ui.LoadWidget(MissionTemplate, null, new WidgetArgs()));
|
||||||
templates.Add(TextNotificationPool.Feedback, Ui.LoadWidget(FeedbackTemplate, null, new WidgetArgs()));
|
templates.Add(TextNotificationPool.Feedback, Ui.LoadWidget(FeedbackTemplate, null, new WidgetArgs()));
|
||||||
|
templates.Add(TextNotificationPool.Transients, Ui.LoadWidget(TransientsTemplate, null, new WidgetArgs()));
|
||||||
|
|
||||||
// HACK: Assume that all templates use the same font
|
// HACK: Assume that all templates use the same font
|
||||||
var lineHeight = Game.Renderer.Fonts[templates[TextNotificationPool.Chat].Get<LabelWidget>("TEXT").Font].Measure("").Y;
|
var lineHeight = Game.Renderer.Fonts[templates[TextNotificationPool.Chat].Get<LabelWidget>("TEXT").Font].Measure("").Y;
|
||||||
|
|||||||
Reference in New Issue
Block a user