當前位置: 首頁>>代碼示例>>C#>>正文


C# ScrollItemWidget.Get方法代碼示例

本文整理匯總了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;
        }
開發者ID:CH4Code,項目名稱:OpenRA,代碼行數:28,代碼來源:LobbyUtils.cs

示例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;
        }
開發者ID:Generalcamo,項目名稱:OpenRA,代碼行數:10,代碼來源:LobbyUtils.cs

示例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;
        }
開發者ID:rhamilton1415,項目名稱:OpenRA,代碼行數:19,代碼來源:LobbyUtils.cs

示例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; };
        }
開發者ID:Tsher,項目名稱:OpenRA,代碼行數:19,代碼來源:SettingsMenuLogic.cs


注:本文中的OpenRA.Widgets.ScrollItemWidget.Get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。