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


C# Widgets.ScrollPanelWidget类代码示例

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


ScrollPanelWidget类属于OpenRA.Widgets命名空间,在下文中一共展示了ScrollPanelWidget类的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: DiplomacyLogic

        public DiplomacyLogic(Widget widget, Action onExit, World world)
        {
            this.world = world;

            diplomacyPanel = widget.Get<ScrollPanelWidget>("DIPLOMACY_PANEL");

            LayoutPlayers();
        }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:8,代码来源:DiplomacyLogic.cs

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

示例4: ModContentLogic

        public ModContentLogic(Widget widget, Manifest mod, ModContent content, Action onCancel)
        {
            this.content = content;

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

            var modFileSystem = new FileSystem.FileSystem(Game.Mods);
            modFileSystem.LoadFromManifest(mod);

            var sourceYaml = MiniYaml.Load(modFileSystem, content.Sources, null);
            foreach (var s in sourceYaml)
                sources.Add(s.Key, new ModContent.ModSource(s.Value));

            var downloadYaml = MiniYaml.Load(modFileSystem, content.Downloads, null);
            foreach (var d in downloadYaml)
                downloads.Add(d.Key, new ModContent.ModDownload(d.Value));

            modFileSystem.UnmountAll();

            scrollPanel = panel.Get<ScrollPanelWidget>("PACKAGES");
            template = scrollPanel.Get<ContainerWidget>("PACKAGE_TEMPLATE");

            var headerTemplate = panel.Get<LabelWidget>("HEADER_TEMPLATE");
            var headerLines = !string.IsNullOrEmpty(content.HeaderMessage) ? content.HeaderMessage.Replace("\\n", "\n").Split('\n') : new string[0];
            var headerHeight = 0;
            foreach (var l in headerLines)
            {
                var line = (LabelWidget)headerTemplate.Clone();
                line.GetText = () => l;
                line.Bounds.Y += headerHeight;
                panel.AddChild(line);

                headerHeight += headerTemplate.Bounds.Height;
            }

            panel.Bounds.Height += headerHeight;
            panel.Bounds.Y -= headerHeight / 2;
            scrollPanel.Bounds.Y += headerHeight;

            var discButton = panel.Get<ButtonWidget>("CHECK_DISC_BUTTON");
            discButton.Bounds.Y += headerHeight;
            discButton.IsVisible = () => discAvailable;

            discButton.OnClick = () => Ui.OpenWindow("DISC_INSTALL_PANEL", new WidgetArgs
            {
                { "afterInstall", () => { } },
                { "sources", sources },
                { "content", content }
            });

            var backButton = panel.Get<ButtonWidget>("BACK_BUTTON");
            backButton.Bounds.Y += headerHeight;
            backButton.OnClick = () => { Ui.CloseWindow(); onCancel(); };

            PopulateContentList();
            Game.RunAfterTick(Ui.ResetTooltips);
        }
开发者ID:pchote,项目名称:OpenRA,代码行数:57,代码来源:ModContentLogic.cs

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

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

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

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

示例9: GlobalChatLogic

        public GlobalChatLogic(Widget widget)
        {
            historyPanel = widget.Get<ScrollPanelWidget>("HISTORY_PANEL");
            historyTemplate = historyPanel.Get<LabelWidget>("HISTORY_TEMPLATE");
            nicknamePanel = widget.Get<ScrollPanelWidget>("NICKNAME_PANEL");
            nicknameTemplate = nicknamePanel.Get("NICKNAME_TEMPLATE");

            historyPanel.Bind(Game.GlobalChat.History, MakeHistoryWidget, HistoryWidgetEquals, true);
            nicknamePanel.Bind(Game.GlobalChat.Users, MakeUserWidget, UserWidgetEquals, false);

            inputBox = widget.Get<TextFieldWidget>("CHAT_TEXTFIELD");
            inputBox.IsDisabled = () => Game.GlobalChat.ConnectionStatus != ChatConnectionStatus.Joined;
            inputBox.OnEnterKey = EnterPressed;

            // Set a random default nick
            if (Game.Settings.Chat.Nickname == new ChatSettings().Nickname)
                Game.Settings.Chat.Nickname += Game.CosmeticRandom.Next(100, 999);

            var nicknameBox = widget.Get<TextFieldWidget>("NICKNAME_TEXTFIELD");
            nicknameBox.Text = Game.GlobalChat.SanitizedName(Game.Settings.Chat.Nickname);
            nicknameBox.OnTextEdited = () =>
            {
                nicknameBox.Text = Game.GlobalChat.SanitizedName(nicknameBox.Text);
            };

            var connectPanel = widget.Get("GLOBALCHAT_CONNECT_PANEL");
            connectPanel.IsVisible = () => Game.GlobalChat.ConnectionStatus == ChatConnectionStatus.Disconnected;

            var disconnectButton = widget.Get<ButtonWidget>("DISCONNECT_BUTTON");
            disconnectButton.OnClick = Game.GlobalChat.Disconnect;

            var connectAutomaticallyCheckBox = connectPanel.Get<CheckboxWidget>("CONNECT_AUTOMATICALLY_CHECKBOX");
            connectAutomaticallyCheckBox.IsChecked = () => Game.Settings.Chat.ConnectAutomatically;
            connectAutomaticallyCheckBox.OnClick = () => { Game.Settings.Chat.ConnectAutomatically ^= true; Game.Settings.Save(); };

            var connectButton = connectPanel.Get<ButtonWidget>("CONNECT_BUTTON");
            connectButton.IsDisabled = () => !Game.GlobalChat.IsValidNickname(nicknameBox.Text);
            connectButton.OnClick = () =>
            {
                Game.Settings.Chat.Nickname = nicknameBox.Text;
                Game.Settings.Save();
                Game.GlobalChat.Connect();
            };

            var mainPanel = widget.Get("GLOBALCHAT_MAIN_PANEL");
            mainPanel.IsVisible = () => Game.GlobalChat.ConnectionStatus != ChatConnectionStatus.Disconnected;

            mainPanel.Get<LabelWidget>("CHANNEL_TOPIC").GetText = () => Game.GlobalChat.Topic;

            if (Game.Settings.Chat.ConnectAutomatically && Game.GlobalChat.IsValidNickname(Game.Settings.Chat.Nickname))
                Game.GlobalChat.Connect();
        }
开发者ID:RRRlizhen,项目名称:OpenRA,代码行数:52,代码来源:GlobalChatLogic.cs

示例10: MissionBrowserLogic

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

            var missionList = widget.Get<ScrollPanelWidget>("MISSION_LIST");
            var template = widget.Get<ScrollItemWidget>("MISSION_TEMPLATE");

            widget.Get("MISSION_INFO").IsVisible = () => selectedMapPreview != null;

            var previewWidget = widget.Get<MapPreviewWidget>("MISSION_PREVIEW");
            previewWidget.Preview = () => selectedMapPreview;

            descriptionPanel = widget.Get<ScrollPanelWidget>("MISSION_DESCRIPTION_PANEL");
            description = widget.Get<LabelWidget>("MISSION_DESCRIPTION");
            descriptionFont = Game.Renderer.Fonts[description.Font];

            var yaml = new MiniYaml(null, Game.modData.Manifest.Missions.Select(MiniYaml.FromFile).Aggregate(MiniYaml.MergeLiberal)).NodesDict;

            var missionMapPaths = yaml["Missions"].Nodes.Select(n => Path.GetFullPath(n.Key));

            var maps = Game.modData.MapCache
                .Where(p => p.Status == MapStatus.Available && missionMapPaths.Contains(Path.GetFullPath(p.Map.Path)))
                .Select(p => p.Map);

            missionList.RemoveChildren();
            foreach (var m in maps)
            {
                var map = m;

                var item = ScrollItemWidget.Setup(template,
                    () => selectedMapPreview != null && selectedMapPreview.Uid == map.Uid,
                    () => SelectMap(map),
                    StartMission);

                item.Get<LabelWidget>("TITLE").GetText = () => map.Title;
                missionList.AddChild(item);
            }

            if (maps.Any())
                SelectMap(maps.First());

            widget.Get<ButtonWidget>("STARTGAME_BUTTON").OnClick = StartMission;

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

示例11: DiplomacyLogic

		public DiplomacyLogic(Widget widget, Action onExit, World world)
		{
			this.world = world;

			diplomacyPanel = widget.Get<ScrollPanelWidget>("DIPLOMACY_PANEL");

			LayoutPlayers();

			var close = widget.GetOrNull<ButtonWidget>("CLOSE");
			if (close != null)
				close.OnClick = () =>
				{
					Ui.CloseWindow();
					Ui.Root.RemoveChild(widget);
					onExit();
				};
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:17,代码来源:DiplomacyLogic.cs

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

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

示例14: PopulateObjectivesList

        void PopulateObjectivesList(MissionObjectives mo, ScrollPanelWidget parent, ContainerWidget template)
        {
            parent.RemoveChildren();

            foreach (var o in mo.Objectives.OrderBy(o => o.Type))
            {
                var objective = o; // Work around the loop closure issue in older versions of C#
                var widget = template.Clone();

                var label = widget.Get<LabelWidget>("OBJECTIVE_TYPE");
                label.GetText = () => objective.Type == ObjectiveType.Primary ? "Primary" : "Secondary";

                var checkbox = widget.Get<CheckboxWidget>("OBJECTIVE_STATUS");
                checkbox.IsChecked = () => objective.State != ObjectiveState.Incomplete;
                checkbox.GetCheckType = () => objective.State == ObjectiveState.Completed ? "checked" : "crossed";
                checkbox.GetText = () => objective.Description;

                parent.AddChild(widget);
            }
        }
开发者ID:ushardul,项目名称:OpenRA,代码行数:20,代码来源:GameInfoObjectivesLogic.cs

示例15: MusicPlayerLogic

        public MusicPlayerLogic(Widget widget, Ruleset modRules, World world, Action onExit)
        {
            var panel = widget.Get("MUSIC_PANEL");

            musicList = panel.Get<ScrollPanelWidget>("MUSIC_LIST");
            itemTemplate = musicList.Get<ScrollItemWidget>("MUSIC_TEMPLATE");
            musicPlaylist = world.WorldActor.Trait<MusicPlaylist>();

            BuildMusicTable();

            Func<bool> noMusic = () => !musicPlaylist.IsMusicAvailable;
            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 = () => { musicPlaylist.Stop(); };
            stopButton.IsDisabled = noMusic;

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

            var prevButton = panel.Get<ButtonWidget>("BUTTON_PREV");
            prevButton.OnClick = () => { currentSong = musicPlaylist.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;

            var installButton = widget.GetOrNull<ButtonWidget>("INSTALL_BUTTON");
            if (installButton != null)
            {
                installButton.IsDisabled = () => world == null || world.Type != WorldType.Shellmap;
                var args = new string[] { "Install.Music=true" };
                installButton.OnClick = () =>
                    Game.RunAfterTick(() =>
                        Game.InitializeMod(Game.Settings.Game.Mod, new Arguments(args)));

                var installData = Game.ModData.Manifest.Get<ContentInstaller>();
                installButton.IsVisible = () => modRules.InstalledMusic.ToArray().Length <= installData.ShippedSoundtracks;
            }

            var songWatcher = widget.GetOrNull<LogicTickerWidget>("SONG_WATCHER");
            if (songWatcher != null)
            {
                songWatcher.OnTick = () =>
                {
                    if (Sound.CurrentMusic == null || currentSong == Sound.CurrentMusic)
                        return;

                    currentSong = Sound.CurrentMusic;
                };
            }

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


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