protected BackgroundWidget(BackgroundWidget other) : base(other) { Background = other.Background; ClickThrough = other.ClickThrough; Draggable = other.Draggable; }
public MissionBrowserLogic(Widget widget, World world, Action onStart, Action onExit) { this.onStart = onStart; missionList = widget.Get<ScrollPanelWidget>("MISSION_LIST"); headerTemplate = widget.Get<ScrollItemWidget>("HEADER"); template = widget.Get<ScrollItemWidget>("TEMPLATE"); var title = widget.GetOrNull<LabelWidget>("MISSIONBROWSER_TITLE"); if (title != null) title.GetText = () => playingVideo != PlayingVideo.None ? selectedMapPreview.Title : title.Text; widget.Get("MISSION_INFO").IsVisible = () => selectedMapPreview != null; var previewWidget = widget.Get<MapPreviewWidget>("MISSION_PREVIEW"); previewWidget.Preview = () => selectedMapPreview; previewWidget.IsVisible = () => playingVideo == PlayingVideo.None; videoPlayer = widget.Get<VqaPlayerWidget>("MISSION_VIDEO"); widget.Get("MISSION_BIN").IsVisible = () => playingVideo != PlayingVideo.None; fullscreenVideoPlayer = Ui.LoadWidget<BackgroundWidget>("FULLSCREEN_PLAYER", Ui.Root, new WidgetArgs { { "world", world } }); descriptionPanel = widget.Get<ScrollPanelWidget>("MISSION_DESCRIPTION_PANEL"); description = descriptionPanel.Get<LabelWidget>("MISSION_DESCRIPTION"); descriptionFont = Game.Renderer.Fonts[description.Font]; difficultyButton = widget.Get<DropDownButtonWidget>("DIFFICULTY_DROPDOWNBUTTON"); gameSpeedButton = widget.GetOrNull<DropDownButtonWidget>("GAMESPEED_DROPDOWNBUTTON"); startBriefingVideoButton = widget.Get<ButtonWidget>("START_BRIEFING_VIDEO_BUTTON"); stopBriefingVideoButton = widget.Get<ButtonWidget>("STOP_BRIEFING_VIDEO_BUTTON"); stopBriefingVideoButton.IsVisible = () => playingVideo == PlayingVideo.Briefing; stopBriefingVideoButton.OnClick = () => StopVideo(videoPlayer); startInfoVideoButton = widget.Get<ButtonWidget>("START_INFO_VIDEO_BUTTON"); stopInfoVideoButton = widget.Get<ButtonWidget>("STOP_INFO_VIDEO_BUTTON"); stopInfoVideoButton.IsVisible = () => playingVideo == PlayingVideo.Info; stopInfoVideoButton.OnClick = () => StopVideo(videoPlayer); var allMaps = new List<Map>(); missionList.RemoveChildren(); // Add a group for each campaign if (Game.ModData.Manifest.Missions.Any()) { var yaml = Game.ModData.Manifest.Missions.Select(MiniYaml.FromFile).Aggregate(MiniYaml.MergeLiberal); foreach (var kv in yaml) { var missionMapPaths = kv.Value.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); CreateMissionGroup(kv.Key, maps); allMaps.AddRange(maps); } } // Add an additional group for loose missions var looseMissions = Game.ModData.MapCache .Where(p => p.Status == MapStatus.Available && p.Map.Visibility.HasFlag(MapVisibility.MissionSelector) && !allMaps.Contains(p.Map)) .Select(p => p.Map); if (looseMissions.Any()) { CreateMissionGroup("Missions", looseMissions); allMaps.AddRange(looseMissions); } if (allMaps.Any()) SelectMap(allMaps.First()); var startButton = widget.Get<ButtonWidget>("STARTGAME_BUTTON"); startButton.OnClick = StartMissionClicked; startButton.IsDisabled = () => selectedMapPreview == null || selectedMapPreview.RuleStatus != MapRuleStatus.Cached; widget.Get<ButtonWidget>("BACK_BUTTON").OnClick = () => { StopVideo(videoPlayer); Game.Disconnect(); Ui.CloseWindow(); onExit(); }; }
public MissionBrowserLogic(Widget widget, ModData modData, World world, Action onStart, Action onExit) { this.modData = modData; this.onStart = onStart; Game.BeforeGameStart += OnGameStart; missionList = widget.Get<ScrollPanelWidget>("MISSION_LIST"); headerTemplate = widget.Get<ScrollItemWidget>("HEADER"); template = widget.Get<ScrollItemWidget>("TEMPLATE"); var title = widget.GetOrNull<LabelWidget>("MISSIONBROWSER_TITLE"); if (title != null) title.GetText = () => playingVideo != PlayingVideo.None ? selectedMap.Title : title.Text; widget.Get("MISSION_INFO").IsVisible = () => selectedMap != null; var previewWidget = widget.Get<MapPreviewWidget>("MISSION_PREVIEW"); previewWidget.Preview = () => selectedMap; previewWidget.IsVisible = () => playingVideo == PlayingVideo.None; videoPlayer = widget.Get<VqaPlayerWidget>("MISSION_VIDEO"); widget.Get("MISSION_BIN").IsVisible = () => playingVideo != PlayingVideo.None; fullscreenVideoPlayer = Ui.LoadWidget<BackgroundWidget>("FULLSCREEN_PLAYER", Ui.Root, new WidgetArgs { { "world", world } }); descriptionPanel = widget.Get<ScrollPanelWidget>("MISSION_DESCRIPTION_PANEL"); description = descriptionPanel.Get<LabelWidget>("MISSION_DESCRIPTION"); descriptionFont = Game.Renderer.Fonts[description.Font]; difficultyButton = widget.Get<DropDownButtonWidget>("DIFFICULTY_DROPDOWNBUTTON"); gameSpeedButton = widget.GetOrNull<DropDownButtonWidget>("GAMESPEED_DROPDOWNBUTTON"); startBriefingVideoButton = widget.Get<ButtonWidget>("START_BRIEFING_VIDEO_BUTTON"); stopBriefingVideoButton = widget.Get<ButtonWidget>("STOP_BRIEFING_VIDEO_BUTTON"); stopBriefingVideoButton.IsVisible = () => playingVideo == PlayingVideo.Briefing; stopBriefingVideoButton.OnClick = () => StopVideo(videoPlayer); startInfoVideoButton = widget.Get<ButtonWidget>("START_INFO_VIDEO_BUTTON"); stopInfoVideoButton = widget.Get<ButtonWidget>("STOP_INFO_VIDEO_BUTTON"); stopInfoVideoButton.IsVisible = () => playingVideo == PlayingVideo.Info; stopInfoVideoButton.OnClick = () => StopVideo(videoPlayer); var allPreviews = new List<MapPreview>(); missionList.RemoveChildren(); // Add a group for each campaign if (modData.Manifest.Missions.Any()) { var yaml = MiniYaml.Merge(modData.Manifest.Missions.Select( m => MiniYaml.FromStream(modData.DefaultFileSystem.Open(m), m))); foreach (var kv in yaml) { var missionMapPaths = kv.Value.Nodes.Select(n => Path.GetFullPath(n.Key)).ToList(); var previews = modData.MapCache .Where(p => p.Status == MapStatus.Available && missionMapPaths.Contains(p.Package.Name)) .OrderBy(p => missionMapPaths.IndexOf(p.Package.Name)); CreateMissionGroup(kv.Key, previews); allPreviews.AddRange(previews); } } // Add an additional group for loose missions var loosePreviews = modData.MapCache .Where(p => p.Status == MapStatus.Available && p.Visibility.HasFlag(MapVisibility.MissionSelector) && !allPreviews.Any(a => a.Uid == p.Uid)); if (loosePreviews.Any()) { CreateMissionGroup("Missions", loosePreviews); allPreviews.AddRange(loosePreviews); } if (allPreviews.Any()) SelectMap(allPreviews.First()); // Preload map preview and rules to reduce jank new Thread(() => { foreach (var p in allPreviews) { p.GetMinimap(); p.PreloadRules(); } }).Start(); var startButton = widget.Get<ButtonWidget>("STARTGAME_BUTTON"); startButton.OnClick = StartMissionClicked; startButton.IsDisabled = () => selectedMap == null || selectedMap.InvalidCustomRules; widget.Get<ButtonWidget>("BACK_BUTTON").OnClick = () => { StopVideo(videoPlayer); Game.Disconnect(); Ui.CloseWindow(); onExit(); }; }
protected BackgroundWidget(BackgroundWidget other) : base(other) { Background = other.Background; }