当前位置: 首页>>代码示例>>C#>>正文


C# Widgets.ScrollItemWidget类代码示例

本文整理汇总了C#中OpenRA.Widgets.ScrollItemWidget的典型用法代码示例。如果您正苦于以下问题:C# ScrollItemWidget类的具体用法?C# ScrollItemWidget怎么用?C# ScrollItemWidget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ScrollItemWidget类属于OpenRA.Widgets命名空间,在下文中一共展示了ScrollItemWidget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TileSelectorLogic

		public TileSelectorLogic(Widget widget, WorldRenderer worldRenderer, Ruleset modRules)
		{
			var tileset = modRules.TileSets[worldRenderer.World.Map.Tileset];

			editor = widget.Parent.Get<EditorViewportControllerWidget>("MAP_EDITOR");
			panel = widget.Get<ScrollPanelWidget>("TILETEMPLATE_LIST");
			itemTemplate = panel.Get<ScrollItemWidget>("TILEPREVIEW_TEMPLATE");
			panel.Layout = new GridLayout(panel);

			var tileCategorySelector = widget.Get<DropDownButtonWidget>("TILE_CATEGORY");
			var categories = tileset.EditorTemplateOrder;
			Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) =>
			{
				var item = ScrollItemWidget.Setup(template,
					() => tileCategorySelector.Text == option,
					() => { tileCategorySelector.Text = option; IntializeTilePreview(widget, worldRenderer, tileset, option); });

				item.Get<LabelWidget>("LABEL").GetText = () => option;
				return item;
			};

			tileCategorySelector.OnClick = () =>
				tileCategorySelector.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 270, categories, setupItem);

			tileCategorySelector.Text = categories.First();
			IntializeTilePreview(widget, worldRenderer, tileset, categories.First());
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:27,代码来源:TileSelectorLogic.cs

示例2: ScrollItemWidget

 protected ScrollItemWidget(ScrollItemWidget other)
     : base(other)
 {
     IsVisible = () => false;
     VisualHeight = 0;
     IgnoreChildMouseOver = true;
 }
开发者ID:sonygod,项目名称:OpenRA-Dedicated-20120504,代码行数:7,代码来源:ScrollItemWidget.cs

示例3: Setup

 public static ScrollItemWidget Setup(string key, ScrollItemWidget template, Func<bool> isSelected, Action onClick, Action onDoubleClick)
 {
     var w = Setup(template, isSelected, onClick);
     w.OnDoubleClick = onDoubleClick;
     w.ItemKey = key;
     return w;
 }
开发者ID:RunCraze,项目名称:OpenRA,代码行数:7,代码来源:ScrollItemWidget.cs

示例4: 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

示例5: ServerBrowserLogic

        public ServerBrowserLogic(Widget widget, Action onStart, Action onExit)
        {
            panel = widget;
            this.onStart = onStart;

            serverList = panel.Get<ScrollPanelWidget>("SERVER_LIST");
            serverTemplate = serverList.Get<ScrollItemWidget>("SERVER_TEMPLATE");

            // Menu buttons
            var refreshButton = panel.Get<ButtonWidget>("REFRESH_BUTTON");
            refreshButton.IsDisabled = () => searchStatus == SearchStatus.Fetching;
            refreshButton.GetText = () => searchStatus == SearchStatus.Fetching ? "Refreshing..." : "Refresh";
            refreshButton.OnClick = RefreshServerList;

            panel.Get<ButtonWidget>("DIRECTCONNECT_BUTTON").OnClick = OpenDirectConnectPanel;
            panel.Get<ButtonWidget>("CREATE_BUTTON").OnClick = OpenCreateServerPanel;

            var join = panel.Get<ButtonWidget>("JOIN_BUTTON");
            join.IsDisabled = () => currentServer == null || !currentServer.CanJoin();
            join.OnClick = () => Join(currentServer);

            panel.Get<ButtonWidget>("BACK_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); };

            // Display the progress label over the server list
            // The text is only visible when the list is empty
            var progressText = panel.Get<LabelWidget>("PROGRESS_LABEL");
            progressText.IsVisible = () => searchStatus != SearchStatus.Hidden;
            progressText.GetText = ProgressLabelText;

            var showWaitingCheckbox = panel.GetOrNull<CheckboxWidget>("WAITING_FOR_PLAYERS");
            if (showWaitingCheckbox != null)
            {
                showWaitingCheckbox.IsChecked = () => showWaiting;
                showWaitingCheckbox.OnClick = () => { showWaiting ^= true; RefreshServerList(); };
            }

            var showEmptyCheckbox = panel.GetOrNull<CheckboxWidget>("EMPTY");
            if (showEmptyCheckbox != null)
            {
                showEmptyCheckbox.IsChecked = () => showEmpty;
                showEmptyCheckbox.OnClick = () => { showEmpty ^= true; RefreshServerList(); };
            }

            var showAlreadyStartedCheckbox = panel.GetOrNull<CheckboxWidget>("ALREADY_STARTED");
            if (showAlreadyStartedCheckbox != null)
            {
                showAlreadyStartedCheckbox.IsChecked = () => showStarted;
                showAlreadyStartedCheckbox.OnClick = () => { showStarted ^= true; RefreshServerList(); };
            }

            var showIncompatibleCheckbox = panel.GetOrNull<CheckboxWidget>("INCOMPATIBLE_VERSION");
            if (showIncompatibleCheckbox != null)
            {
                showIncompatibleCheckbox.IsChecked = () => showIncompatible;
                showIncompatibleCheckbox.OnClick = () => { showIncompatible ^= true; RefreshServerList(); };
            }

            // Game.LoadWidget(null, "SERVERBROWSER_IRC", panel.Get("IRC_ROOT"), new WidgetArgs());
            RefreshServerList();
        }
开发者ID:RunCraze,项目名称:OpenRA,代码行数:60,代码来源:ServerBrowserLogic.cs

示例6: CncServerBrowserLogic

        public CncServerBrowserLogic([ObjectCreator.Param] Widget widget,
		                            [ObjectCreator.Param] Action openLobby,
		                            [ObjectCreator.Param] Action onExit)
        {
            var panel = widget.GetWidget("SERVERBROWSER_PANEL");
            var sl = panel.GetWidget<ScrollPanelWidget>("SERVER_LIST");

            // Menu buttons
            var refreshButton = panel.GetWidget<ButtonWidget>("REFRESH_BUTTON");
            refreshButton.IsDisabled = () => searchStatus == SearchStatus.Fetching;
            refreshButton.OnClick = () =>
            {
                searchStatus = SearchStatus.Fetching;
                sl.RemoveChildren();
                currentServer = null;
                ServerList.Query(games => RefreshServerList(panel, games));
            };

            var join = panel.GetWidget<ButtonWidget>("JOIN_BUTTON");
            join.IsDisabled = () => currentServer == null || !currentServer.CanJoin();
            join.OnClick = () =>
            {
                if (currentServer == null)
                    return;

                var host = currentServer.Address.Split(':')[0];
                var port = int.Parse(currentServer.Address.Split(':')[1]);

                Widget.CloseWindow();
                CncConnectingLogic.Connect(host, port, openLobby, onExit);
            };

            panel.GetWidget<ButtonWidget>("BACK_BUTTON").OnClick = () => { Widget.CloseWindow(); onExit(); };

            // Server list
            serverTemplate = sl.GetWidget<ScrollItemWidget>("SERVER_TEMPLATE");

            // Display the progress label over the server list
            // The text is only visible when the list is empty
            var progressText = panel.GetWidget<LabelWidget>("PROGRESS_LABEL");
            progressText.IsVisible = () => searchStatus != SearchStatus.Hidden;
            progressText.GetText = ProgressLabelText;

            // Map preview
            var preview = panel.GetWidget<MapPreviewWidget>("MAP_PREVIEW");
            preview.Map = () => CurrentMap();
            preview.IsVisible = () => CurrentMap() != null;

            // Server info
            var infoPanel = panel.GetWidget("SERVER_INFO");
            infoPanel.IsVisible = () => currentServer != null;
            infoPanel.GetWidget<LabelWidget>("SERVER_IP").GetText = () => currentServer.Address;
            infoPanel.GetWidget<LabelWidget>("SERVER_MODS").GetText = () => ServerBrowserLogic.GenerateModsLabel(currentServer);
            infoPanel.GetWidget<LabelWidget>("MAP_TITLE").GetText = () => (CurrentMap() != null) ? CurrentMap().Title : "Unknown";
            infoPanel.GetWidget<LabelWidget>("MAP_PLAYERS").GetText = () => GetPlayersLabel(currentServer);

            ServerList.Query(games => RefreshServerList(panel, games));
        }
开发者ID:hoxworth,项目名称:OpenRA,代码行数:58,代码来源:CncServerBrowserLogic.cs

示例7: ServerBrowserLogic

        public ServerBrowserLogic(Widget widget, Action openLobby, Action onExit)
        {
            var panel = widget;
            OpenLobby = openLobby;
            OnExit = onExit;
            var sl = panel.Get<ScrollPanelWidget>("SERVER_LIST");

            // Menu buttons
            var refreshButton = panel.Get<ButtonWidget>("REFRESH_BUTTON");
            refreshButton.IsDisabled = () => searchStatus == SearchStatus.Fetching;
            refreshButton.OnClick = () => ServerList.Query(games => RefreshServerList(panel, games));

            var join = panel.Get<ButtonWidget>("JOIN_BUTTON");
            join.IsDisabled = () => currentServer == null || !currentServer.CanJoin();
            join.OnClick = () => Join(currentServer);

            panel.Get<ButtonWidget>("BACK_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); };

            // Server list
            serverTemplate = sl.Get<ScrollItemWidget>("SERVER_TEMPLATE");

            // Display the progress label over the server list
            // The text is only visible when the list is empty
            var progressText = panel.Get<LabelWidget>("PROGRESS_LABEL");
            progressText.IsVisible = () => searchStatus != SearchStatus.Hidden;
            progressText.GetText = ProgressLabelText;

            var showWaitingCheckbox = panel.GetOrNull<CheckboxWidget>("WAITING_FOR_PLAYERS");
            if (showWaitingCheckbox != null)
            {
                showWaitingCheckbox.IsChecked = () => showWaiting;
                showWaitingCheckbox.OnClick = () => { showWaiting ^= true; ServerList.Query(games => RefreshServerList(panel, games)); };
            }

            var showEmptyCheckbox = panel.GetOrNull<CheckboxWidget>("EMPTY");
            if (showEmptyCheckbox != null)
            {
                showEmptyCheckbox.IsChecked = () => showEmpty;
                showEmptyCheckbox.OnClick = () => { showEmpty ^= true; ServerList.Query(games => RefreshServerList(panel, games)); };
            }

            var showAlreadyStartedCheckbox = panel.GetOrNull<CheckboxWidget>("ALREADY_STARTED");
            if (showAlreadyStartedCheckbox != null)
            {
                showAlreadyStartedCheckbox.IsChecked = () => showStarted;
                showAlreadyStartedCheckbox.OnClick = () => { showStarted ^= true; ServerList.Query(games => RefreshServerList(panel, games)); };
            }

            var showIncompatibleCheckbox = panel.GetOrNull<CheckboxWidget>("INCOMPATIBLE_VERSION");
            if (showIncompatibleCheckbox != null)
            {
                showIncompatibleCheckbox.IsChecked = () => showIncompatible;
                showIncompatibleCheckbox.OnClick = () => { showIncompatible ^= true; ServerList.Query(games => RefreshServerList(panel, games)); };
            }

            ServerList.Query(games => RefreshServerList(panel, games));
        }
开发者ID:Tsher,项目名称:OpenRA,代码行数:57,代码来源:ServerBrowserLogic.cs

示例8: AddReplay

 void AddReplay(ScrollPanelWidget list, string filename, ScrollItemWidget template)
 {
     var item = ScrollItemWidget.Setup(template,
         () => currentReplay != null && currentReplay.Filename == filename,
         () => SelectReplay(filename));
     var f = Path.GetFileName(filename);
     item.Get<LabelWidget>("TITLE").GetText = () => f;
     list.AddChild(item);
 }
开发者ID:sonygod,项目名称:OpenRA-Dedicated-20120504,代码行数:9,代码来源:ReplayBrowserLogic.cs

示例9: ReplayBrowserLogic

        public ReplayBrowserLogic(Widget widget, ModData modData, Action onExit, Action onStart)
        {
            panel = widget;

            this.modData = modData;
            this.onStart = onStart;
            Game.BeforeGameStart += OnGameStart;

            playerList = panel.Get<ScrollPanelWidget>("PLAYER_LIST");
            playerHeader = playerList.Get<ScrollItemWidget>("HEADER");
            playerTemplate = playerList.Get<ScrollItemWidget>("TEMPLATE");
            playerList.RemoveChildren();

            panel.Get<ButtonWidget>("CANCEL_BUTTON").OnClick = () => { cancelLoadingReplays = true; Ui.CloseWindow(); onExit(); };

            replayList = panel.Get<ScrollPanelWidget>("REPLAY_LIST");
            var template = panel.Get<ScrollItemWidget>("REPLAY_TEMPLATE");

            var mod = modData.Manifest;
            var dir = Platform.ResolvePath("^", "Replays", mod.Id, mod.Metadata.Version);

            if (Directory.Exists(dir))
                ThreadPool.QueueUserWorkItem(_ => LoadReplays(dir, template));

            var watch = panel.Get<ButtonWidget>("WATCH_BUTTON");
            watch.IsDisabled = () => selectedReplay == null || selectedReplay.GameInfo.MapPreview.Status != MapStatus.Available;
            watch.OnClick = () => { WatchReplay(); };

            panel.Get("REPLAY_INFO").IsVisible = () => selectedReplay != null;

            var preview = panel.Get<MapPreviewWidget>("MAP_PREVIEW");
            preview.SpawnOccupants = () => selectedSpawns;
            preview.Preview = () => selectedReplay != null ? selectedReplay.GameInfo.MapPreview : null;

            var titleLabel = panel.GetOrNull<LabelWidget>("MAP_TITLE");
            if (titleLabel != null)
            {
                titleLabel.IsVisible = () => selectedReplay != null;

                var font = Game.Renderer.Fonts[titleLabel.Font];
                var title = new CachedTransform<MapPreview, string>(m => WidgetUtils.TruncateText(m.Title, titleLabel.Bounds.Width, font));
                titleLabel.GetText = () => title.Update(selectedReplay.GameInfo.MapPreview);
            }

            var type = panel.GetOrNull<LabelWidget>("MAP_TYPE");
            if (type != null)
            {
                var mapType = new CachedTransform<MapPreview, string>(m => m.Categories.FirstOrDefault() ?? "");
                type.GetText = () => mapType.Update(selectedReplay.GameInfo.MapPreview);
            }

            panel.Get<LabelWidget>("DURATION").GetText = () => WidgetUtils.FormatTimeSeconds((int)selectedReplay.GameInfo.Duration.TotalSeconds);

            SetupFilters();
            SetupManagement();
        }
开发者ID:pchote,项目名称:OpenRA,代码行数:56,代码来源:ReplayBrowserLogic.cs

示例10: MapChooserLogic

        internal MapChooserLogic(Widget widget, string initialMap, Action onExit, Action<Map> onSelect)
        {
            map = Game.modData.AvailableMaps[WidgetUtils.ChooseInitialMap(initialMap)];

            widget.Get<ButtonWidget>("BUTTON_OK").OnClick = () => { Ui.CloseWindow(); onSelect(map); };
            widget.Get<ButtonWidget>("BUTTON_CANCEL").OnClick = () => { Ui.CloseWindow(); onExit(); };

            scrollpanel = widget.Get<ScrollPanelWidget>("MAP_LIST");
            scrollpanel.ScrollVelocity = 40f;
            scrollpanel.Layout = new GridLayout(scrollpanel);

            itemTemplate = scrollpanel.Get<ScrollItemWidget>("MAP_TEMPLATE");

            var gameModeDropdown = widget.GetOrNull<DropDownButtonWidget>("GAMEMODE_FILTER");
            if (gameModeDropdown != null)
            {
                var selectableMaps = Game.modData.AvailableMaps.Where(m => m.Value.Selectable).ToList();
                var gameModes = selectableMaps
                    .GroupBy(m => m.Value.Type)
                    .Select(g => Pair.New(g.Key, g.Count())).ToList();

                // 'all game types' extra item
                gameModes.Insert(0, Pair.New(null as string, selectableMaps.Count()));

                Func<Pair<string, int>, string> showItem =
                    x => "{0} ({1})".F(x.First ?? "All Game Types", x.Second);

                Func<Pair<string, int>, ScrollItemWidget, ScrollItemWidget> setupItem = (ii, template) =>
                {
                    var item = ScrollItemWidget.Setup(template,
                        () => gameMode == ii.First,
                        () => { gameMode = ii.First; EnumerateMaps(onSelect); });
                    item.Get<LabelWidget>("LABEL").GetText = () => showItem(ii);
                    return item;
                };

                gameModeDropdown.OnClick = () =>
                    gameModeDropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 210, gameModes, setupItem);

                gameModeDropdown.GetText = () => showItem(gameModes.First(m => m.First == gameMode));
            }

            var randomMapButton = widget.GetOrNull<ButtonWidget>("RANDOMMAP_BUTTON");
            if (randomMapButton != null)
            {
                randomMapButton.OnClick = () =>
                {
                    var kv = visibleMaps.Random(Game.CosmeticRandom);
                    map = kv.Value;
                    scrollpanel.ScrollToItem(kv.Key);
                };
                randomMapButton.IsDisabled = () => visibleMaps == null || visibleMaps.Count == 0;
            }

            EnumerateMaps(onSelect);
        }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:56,代码来源:MapChooserLogic.cs

示例11: 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

示例12: MusicPlayerLogic

        public MusicPlayerLogic(Widget widget, Ruleset modRules, Action onExit)
        {
            this.modRules = modRules;

            var panel = widget.Get("MUSIC_PANEL");

            musicList = panel.Get<ScrollPanelWidget>("MUSIC_LIST");
            itemTemplate = musicList.Get<ScrollItemWidget>("MUSIC_TEMPLATE");

            BuildMusicTable();

            Func<bool> noMusic = () => !installed;
            panel.Get("NO_MUSIC_LABEL").IsVisible = noMusic;

            var playButton = panel.Get<ButtonWidget>("BUTTON_PLAY");
            playButton.OnClick = Play;
            playButton.IsDisabled = noMusic;
            playButton.IsVisible = () => !Sound.MusicPlaying;

            var pauseButton = panel.Get<ButtonWidget>("BUTTON_PAUSE");
            pauseButton.OnClick = Sound.PauseMusic;
            pauseButton.IsDisabled = noMusic;
            pauseButton.IsVisible = () => Sound.MusicPlaying;

            var stopButton = panel.Get<ButtonWidget>("BUTTON_STOP");
            stopButton.OnClick = Sound.StopMusic;
            stopButton.IsDisabled = noMusic;

            var nextButton = panel.Get<ButtonWidget>("BUTTON_NEXT");
            nextButton.OnClick = () => { currentSong = GetNextSong(); Play(); };
            nextButton.IsDisabled = noMusic;

            var prevButton = panel.Get<ButtonWidget>("BUTTON_PREV");
            prevButton.OnClick = () => { currentSong = GetPrevSong(); Play(); };
            prevButton.IsDisabled = noMusic;

            var shuffleCheckbox = panel.Get<CheckboxWidget>("SHUFFLE");
            shuffleCheckbox.IsChecked = () => Game.Settings.Sound.Shuffle;
            shuffleCheckbox.OnClick = () => Game.Settings.Sound.Shuffle ^= true;

            var repeatCheckbox = panel.Get<CheckboxWidget>("REPEAT");
            repeatCheckbox.IsChecked = () => Game.Settings.Sound.Repeat;
            repeatCheckbox.OnClick = () => Game.Settings.Sound.Repeat ^= true;

            panel.Get<LabelWidget>("TIME_LABEL").GetText = () => (currentSong == null) ? "" :
                "{0:D2}:{1:D2} / {2:D2}:{3:D2}".F((int)Sound.MusicSeekPosition / 60, (int)Sound.MusicSeekPosition % 60,
                    currentSong.Length / 60, currentSong.Length % 60);

            var musicSlider = panel.Get<SliderWidget>("MUSIC_SLIDER");
            musicSlider.OnChange += x => Sound.MusicVolume = x;
            musicSlider.Value = Sound.MusicVolume;

            panel.Get<ButtonWidget>("BACK_BUTTON").OnClick = () => { Game.Settings.Save(); Ui.CloseWindow(); onExit(); };
        }
开发者ID:RunCraze,项目名称:OpenRA,代码行数:54,代码来源:MusicPlayerLogic.cs

示例13: LayerSelectorLogic

        public LayerSelectorLogic(Widget widget, WorldRenderer worldRenderer)
        {
            this.worldRenderer = worldRenderer;
            editor = widget.Parent.Get<EditorViewportControllerWidget>("MAP_EDITOR");

            layerTemplateList = widget.Get<ScrollPanelWidget>("LAYERTEMPLATE_LIST");
            layerTemplateList.Layout = new GridLayout(layerTemplateList);
            layerPreviewTemplate = layerTemplateList.Get<ScrollItemWidget>("LAYERPREVIEW_TEMPLATE");

            IntializeLayerPreview(widget);
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:11,代码来源:LayerSelectorLogic.cs

示例14: ActorSelectorLogic

        public ActorSelectorLogic(Widget widget, World world, WorldRenderer worldRenderer)
        {
            mapRules = world.Map.Rules;
            this.world = world;
            this.worldRenderer = worldRenderer;

            editor = widget.Parent.Get<EditorViewportControllerWidget>("MAP_EDITOR");
            ownersDropDown = widget.Get<DropDownButtonWidget>("OWNERS_DROPDOWN");

            panel = widget.Get<ScrollPanelWidget>("ACTORTEMPLATE_LIST");
            itemTemplate = panel.Get<ScrollItemWidget>("ACTORPREVIEW_TEMPLATE");
            panel.Layout = new GridLayout(panel);

            var editorLayer = world.WorldActor.Trait<EditorActorLayer>();

            selectedOwner = editorLayer.Players.Players.Values.First();
            Func<PlayerReference, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) =>
            {
                var item = ScrollItemWidget.Setup(template, () => selectedOwner == option, () =>
                {
                    selectedOwner = option;

                    ownersDropDown.Text = selectedOwner.Name;
                    ownersDropDown.TextColor = selectedOwner.Color.RGB;

                    IntializeActorPreviews();
                });

                item.Get<LabelWidget>("LABEL").GetText = () => option.Name;
                item.GetColor = () => option.Color.RGB;

                return item;
            };

            ownersDropDown.OnClick = () =>
            {
                var owners = editorLayer.Players.Players.Values.OrderBy(p => p.Name);
                ownersDropDown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 270, owners, setupItem);
            };

            ownersDropDown.Text = selectedOwner.Name;
            ownersDropDown.TextColor = selectedOwner.Color.RGB;

            IntializeActorPreviews();
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:45,代码来源:ActorSelectorLogic.cs

示例15: MapChooserLogic

        internal MapChooserLogic([ObjectCreator.Param] Widget widget,
			[ObjectCreator.Param] string initialMap,
			[ObjectCreator.Param] Action onExit,
			[ObjectCreator.Param] Action<Map> onSelect)
        {
            map = Game.modData.AvailableMaps[WidgetUtils.ChooseInitialMap(initialMap)];

            widget.GetWidget<ButtonWidget>("BUTTON_OK").OnClick = () => { Widget.CloseWindow(); onSelect(map); };
            widget.GetWidget<ButtonWidget>("BUTTON_CANCEL").OnClick = () => { Widget.CloseWindow(); onExit(); };

            scrollpanel = widget.GetWidget<ScrollPanelWidget>("MAP_LIST");
            itemTemplate = scrollpanel.GetWidget<ScrollItemWidget>("MAP_TEMPLATE");

            var gameModeDropdown = widget.GetWidget<DropDownButtonWidget>("GAMEMODE_FILTER");
            if (gameModeDropdown != null)
            {
                var selectableMaps = Game.modData.AvailableMaps.Where(m => m.Value.Selectable);
                var gameModes = selectableMaps
                    .GroupBy(m => m.Value.Type)
                    .Select(g => Pair.New(g.Key, g.Count())).ToList();

                // 'all game types' extra item
                gameModes.Insert( 0, Pair.New( null as string, selectableMaps.Count() ) );

                Func<Pair<string,int>, string> showItem =
                    x => "{0} ({1})".F( x.First ?? "All Game Types", x.Second );

                Func<Pair<string,int>, ScrollItemWidget, ScrollItemWidget> setupItem = (ii, template) =>
                {
                    var item = ScrollItemWidget.Setup(template,
                        () => gameMode == ii.First,
                        () => { gameMode = ii.First; EnumerateMaps(); });
                    item.GetWidget<LabelWidget>("LABEL").GetText = () => showItem(ii);
                    return item;
                };

                gameModeDropdown.OnClick = () =>
                    gameModeDropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 210, gameModes, setupItem);

                gameModeDropdown.GetText = () => showItem(gameModes.First(m => m.First == gameMode));
            }

            EnumerateMaps();
        }
开发者ID:hoxworth,项目名称:OpenRA,代码行数:44,代码来源:MapChooserLogic.cs


注:本文中的OpenRA.Widgets.ScrollItemWidget类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。