Example #1
0
 protected BackgroundWidget(BackgroundWidget other)
     : base(other)
 {
     Background = other.Background;
     ClickThrough = other.ClickThrough;
     Draggable = other.Draggable;
 }
        public D2GameScreenLogic(Widget widget, World world)
        {
            var mainMenu = widget.Get <ButtonWidget>("mentat");

            mainMenu.OnClick     = OpenMentat;
            mentatabkg           = widget.Get <BackgroundWidget>("mentatabkg");
            mentatabkg.IsVisible = () => vismentata;
        }
Example #3
0
        private void Start()
        {
            InputSystem.Get().bWorldInputEnabled = false;

            if (AddBackground)
            {
                Background = Instantiate(CorePrefabsConfig.Get().BackgroundWidgetPrefab);

                if (Background)
                {
                    Background.SetParent(transform);
                    Background.transform.SetSiblingIndex(0);
                    Background.Show();
                }
            }

            StartOpenWindowEvent();
            OnStartOpenWindow?.Invoke();
        }
Example #4
0
        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 <VideoPlayerWidget>("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 => n.Key).ToList();

                    var previews = modData.MapCache
                                   .Where(p => p.Class == MapClassification.System && p.Status == MapStatus.Available)
                                   .Select(p => new
                    {
                        Preview = p,
                        Index   = missionMapPaths.IndexOf(Path.GetFileName(p.Package.Name))
                    })
                                   .Where(x => x.Index != -1)
                                   .OrderBy(x => x.Index)
                                   .Select(x => x.Preview);

                    if (previews.Any())
                    {
                        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 to reduce jank
            new Thread(() =>
            {
                foreach (var p in allPreviews)
                {
                    p.GetMinimap();
                }
            }).Start();

            var startButton = widget.Get <ButtonWidget>("STARTGAME_BUTTON");

            startButton.OnClick    = StartMissionClicked;
            startButton.IsDisabled = () => selectedMap == null;

            widget.Get <ButtonWidget>("BACK_BUTTON").OnClick = () =>
            {
                StopVideo(videoPlayer);
                Game.Disconnect();
                Ui.CloseWindow();
                onExit();
            };
        }
Example #5
0
        public ActorEditLogic(Widget widget, World world, WorldRenderer worldRenderer, Dictionary <string, MiniYaml> logicArgs)
        {
            this.worldRenderer  = worldRenderer;
            editorActorLayer    = world.WorldActor.Trait <EditorActorLayer>();
            editorActionManager = world.WorldActor.Trait <EditorActionManager>();

            editor         = widget.Parent.Get <EditorViewportControllerWidget>("MAP_EDITOR");
            actorEditPanel = editor.Get <BackgroundWidget>("ACTOR_EDIT_PANEL");

            typeLabel    = actorEditPanel.Get <LabelWidget>("ACTOR_TYPE_LABEL");
            actorIDField = actorEditPanel.Get <TextFieldWidget>("ACTOR_ID");

            initContainer   = actorEditPanel.Get("ACTOR_INIT_CONTAINER");
            buttonContainer = actorEditPanel.Get("BUTTON_CONTAINER");

            checkboxOptionTemplate = initContainer.Get("CHECKBOX_OPTION_TEMPLATE");
            sliderOptionTemplate   = initContainer.Get("SLIDER_OPTION_TEMPLATE");
            dropdownOptionTemplate = initContainer.Get("DROPDOWN_OPTION_TEMPLATE");
            initContainer.RemoveChildren();

            var deleteButton = actorEditPanel.Get <ButtonWidget>("DELETE_BUTTON");
            var cancelButton = actorEditPanel.Get <ButtonWidget>("CANCEL_BUTTON");
            var okButton     = actorEditPanel.Get <ButtonWidget>("OK_BUTTON");

            actorIDErrorLabel           = actorEditPanel.Get <LabelWidget>("ACTOR_ID_ERROR_LABEL");
            actorIDErrorLabel.IsVisible = () => actorIDStatus != ActorIDStatus.Normal;
            actorIDErrorLabel.GetText   = () => actorIDStatus == ActorIDStatus.Duplicate ?
                                          "Duplicate Actor ID" : "Enter an Actor ID";

            MiniYaml yaml;

            if (logicArgs.TryGetValue("EditPanelPadding", out yaml))
            {
                editPanelPadding = FieldLoader.GetValue <int>("EditPanelPadding", yaml.Value);
            }

            okButton.IsDisabled      = () => !IsValid() || !editActorPreview.IsDirty;
            okButton.OnClick         = Save;
            cancelButton.OnClick     = Cancel;
            deleteButton.OnClick     = Delete;
            actorEditPanel.IsVisible = () => CurrentActor != null &&
                                       editor.CurrentBrush == editor.DefaultBrush &&
                                       Game.RunTime > lastScrollTime + scrollVisibleTimeout;

            actorIDField.OnEscKey = () =>
            {
                actorIDField.YieldKeyboardFocus();
                return(true);
            };

            actorIDField.OnTextEdited = () =>
            {
                var actorId = actorIDField.Text.Trim();
                if (string.IsNullOrWhiteSpace(actorId))
                {
                    nextActorIDStatus = ActorIDStatus.Empty;
                    return;
                }

                // Check for duplicate actor ID
                if (CurrentActor.ID.Equals(actorId, StringComparison.OrdinalIgnoreCase))
                {
                    if (editorActorLayer[actorId] != null)
                    {
                        nextActorIDStatus = ActorIDStatus.Duplicate;
                        return;
                    }
                }

                SetActorID(actorId);
                nextActorIDStatus = ActorIDStatus.Normal;
            };

            actorIDField.OnLoseFocus = () =>
            {
                // Reset invalid IDs back to their starting value
                if (actorIDStatus != ActorIDStatus.Normal)
                {
                    SetActorID(initialActorID);
                }
            };
        }
        public Dune2VideoWSAPlayerLogic(Widget widget, World world, ModData modData)
        {
            this.modData          = modData;
            fullscreenVideoPlayer = widget.Get <BackgroundWidget>("MAINMENU_PRERELEASE_NOTIFICATION");
            //fullscreenVideoPlayer = Ui.LoadWidget<BackgroundWidget>("MAINMENU_PRERELEASE_NOTIFICATION", Ui.Root, new WidgetArgs { { "world", world } });
            var fsPlayer = fullscreenVideoPlayer.Get <WsaPlayerWidget>("PLAYER");

            fullscreenVideoPlayer.Visible = true;
            fsPlayer.VideoStackList       = new System.Collections.Generic.Queue <string>();

            //fsPlayer.VideoStackList.Enqueue("WESTWOOD.WSA");
            //fsPlayer.VideoStackList.Enqueue("AND.ENG");
            //fsPlayer.VideoStackList.Enqueue("VIRGIN.CPS");
            //fsPlayer.VideoStackList.Enqueue("SCREEN.CPS");
            //fsPlayer.VideoStackList.Enqueue("INTRO1.WSA");
            //fsPlayer.VideoStackList.Enqueue("INTRO2.WSA");
            //fsPlayer.VideoStackList.Enqueue("INTRO3.WSA");
            //fsPlayer.VideoStackList.Enqueue("INTRO4.WSA");
            //fsPlayer.VideoStackList.Enqueue("INTRO5.WSA");
            //fsPlayer.VideoStackList.Enqueue("INTRO6.WSA");
            //fsPlayer.VideoStackList.Enqueue("INTRO7A.WSA");
            //fsPlayer.VideoStackList.Enqueue("INTRO7B.WSA");
            //fsPlayer.VideoStackList.Enqueue("INTRO8A.WSA");
            //fsPlayer.VideoStackList.Enqueue("INTRO8B.WSA");
            //fsPlayer.VideoStackList.Enqueue("INTRO8C.WSA");
            //fsPlayer.VideoStackList.Enqueue("INTRO9.WSA");
            //fsPlayer.VideoStackList.Enqueue("INTRO10.WSA");
            //fsPlayer.VideoStackList.Enqueue("INTRO11.WSA");

            List <FrameSoundLine> fl = new List <FrameSoundLine>();

            fl.Add(new FrameSoundLine()
            {
                WSAfilename = "INTRO1.WSA", FrameNumber = 0, VOCfilename = "DUNE0.ADL"
            });
            fl.Add(new FrameSoundLine()
            {
                WSAfilename = "INTRO1.WSA", FrameNumber = 31, VOCfilename = "DUNE.VOC"
            });
            fl.Add(new FrameSoundLine()
            {
                WSAfilename = "INTRO1.WSA", FrameNumber = 37, VOCfilename = "BLDING.VOC"
            });
            fl.Add(new FrameSoundLine()
            {
                WSAfilename = "INTRO1.WSA", FrameNumber = 48, VOCfilename = "DYNASTY.VOC"
            });
            fsPlayer.frameSoundLine = fl;

            List <FrameTextLine> ftl = new List <FrameTextLine>();

            ftl.Add(new FrameTextLine()
            {
                WSAfilename = "INTRO1.WSA", FrameNumber = 37, Text = "The Building of A Dynasty", Pos = new float2(230, 560), TextColor = Color.FromArgb(250, 0, 32)
            });
            ftl.Add(new FrameTextLine()
            {
                WSAfilename = "INTRO2.WSA", FrameNumber = 0, Text = "", Pos = new float2(230, 560), TextColor = Color.FromArgb(250, 0, 32)
            });
            fsPlayer.frameTextLine = ftl;
            // PlayVideoStack(fsPlayer, () => { });
            PlayVideoStack(fsPlayer, () => ShowMainMenu(world));
        }
Example #7
0
 protected BackgroundWidget(BackgroundWidget other)
     : base(other)
 {
     Background = other.Background;
 }
Example #8
0
        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");

            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();
            };
        }
Example #9
0
 protected BackgroundWidget(BackgroundWidget other)
     : base(other)
 {
     Background   = other.Background;
     ClickThrough = other.ClickThrough;
 }