Split some useful bits from CncIngameMenuLogic into CncWidgetUtils for use elsewhere
This commit is contained in:
44
OpenRA.Mods.Cnc/Widgets/CncWidgetUtils.cs
Normal file
44
OpenRA.Mods.Cnc/Widgets/CncWidgetUtils.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Cnc.Widgets
|
||||
{
|
||||
public static class CncWidgetUtils
|
||||
{
|
||||
public static string ActiveModVersion()
|
||||
{
|
||||
var mod = Game.modData.Manifest.Mods[0];
|
||||
return Mod.AllMods[mod].Version;
|
||||
}
|
||||
|
||||
public static void PromptConfirmAction(string title, string text, Action onConfirm, Action onCancel)
|
||||
{
|
||||
var prompt = Widget.OpenWindow("CONFIRM_PROMPT");
|
||||
prompt.GetWidget<LabelWidget>("PROMPT_TITLE").GetText = () => title;
|
||||
prompt.GetWidget<LabelWidget>("PROMPT_TEXT").GetText = () => text;
|
||||
|
||||
prompt.GetWidget<ButtonWidget>("CONFIRM_BUTTON").OnClick = () =>
|
||||
{
|
||||
Widget.CloseWindow();
|
||||
onConfirm();
|
||||
};
|
||||
|
||||
prompt.GetWidget<ButtonWidget>("CANCEL_BUTTON").OnClick = () =>
|
||||
{
|
||||
Widget.CloseWindow();
|
||||
onCancel();
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user