本文整理匯總了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; };
}