本文整理汇总了C#中OpenRA.Widgets.ScrollItemWidget.Get方法的典型用法代码示例。如果您正苦于以下问题:C# ScrollItemWidget.Get方法的具体用法?C# ScrollItemWidget.Get怎么用?C# ScrollItemWidget.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenRA.Widgets.ScrollItemWidget
的用法示例。
在下文中一共展示了ScrollItemWidget.Get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddPlayerFlagAndName
public static void AddPlayerFlagAndName(ScrollItemWidget template, Player player)
{
var flag = template.Get<ImageWidget>("FLAG");
flag.GetImageCollection = () => "flags";
if (player.World.RenderPlayer != null && player.World.RenderPlayer.Stances[player] != Stance.Ally)
flag.GetImageName = () => player.DisplayFaction.InternalName;
else
flag.GetImageName = () => player.Faction.InternalName;
var client = player.World.LobbyInfo.ClientWithIndex(player.ClientIndex);
var playerName = template.Get<LabelWidget>("PLAYER");
var playerNameFont = Game.Renderer.Fonts[playerName.Font];
var suffixLength = new CachedTransform<string, int>(s => playerNameFont.Measure(s).X);
var name = new CachedTransform<Pair<string, int>, string>(c =>
WidgetUtils.TruncateText(c.First, playerName.Bounds.Width - c.Second, playerNameFont));
playerName.GetText = () =>
{
var suffix = player.WinState == WinState.Undefined ? "" : " (" + player.WinState + ")";
if (client != null && client.State == Session.ClientState.Disconnected)
suffix = " (Gone)";
var sl = suffixLength.Update(suffix);
return name.Update(Pair.New(player.PlayerName, sl)) + suffix;
};
playerName.GetColor = () => player.Color.RGB;
}
示例2: AddPlayerFlagAndName
public static void AddPlayerFlagAndName(ScrollItemWidget template, Player player)
{
var flag = template.Get<ImageWidget>("FLAG");
flag.GetImageName = () => player.Country.Race;
flag.GetImageCollection = () => "flags";
var playerName = template.Get<LabelWidget>("PLAYER");
playerName.GetText = () => player.PlayerName + (player.WinState == WinState.Undefined ? "" : " (" + player.WinState + ")");
playerName.GetColor = () => player.Color.RGB;
}
示例3: AddPlayerFlagAndName
public static void AddPlayerFlagAndName(ScrollItemWidget template, Player player)
{
var flag = template.Get<ImageWidget>("FLAG");
flag.GetImageCollection = () => "flags";
if (player.World.RenderPlayer != null && player.World.RenderPlayer.Stances[player] != Stance.Ally)
flag.GetImageName = () => player.DisplayFaction.InternalName;
else
flag.GetImageName = () => player.Faction.InternalName;
var playerName = template.Get<LabelWidget>("PLAYER");
var client = player.World.LobbyInfo.ClientWithIndex(player.ClientIndex);
playerName.GetText = () =>
{
if (client != null && client.State == Network.Session.ClientState.Disconnected)
return player.PlayerName + " (Gone)";
return player.PlayerName + (player.WinState == WinState.Undefined ? "" : " (" + player.WinState + ")");
};
playerName.GetColor = () => player.Color.RGB;
}
示例4: SetupKeyBinding
void SetupKeyBinding(ScrollItemWidget keyWidget, string description, Func<string> getValue, Action<string> setValue)
{
keyWidget.Get<LabelWidget>("FUNCTION").GetText = () => description;
var textBox = keyWidget.Get<TextFieldWidget>("HOTKEY");
textBox.Text = getValue();
textBox.OnLoseFocus = () =>
{
textBox.Text.Trim();
if (textBox.Text.Length == 0)
textBox.Text = getValue();
else
setValue(textBox.Text);
};
textBox.OnEnterKey = () => { textBox.LoseFocus(); return true; };
}