예제 #1
0
 public GlobalActionContainer(VignetteApplicationBase game)
     : base(matchingMode: KeyCombinationMatchingMode.Modifiers)
 {
     if (game is IKeyBindingHandler <GlobalAction> )
     {
         handler = game;
     }
 }
예제 #2
0
        private void load(VignetteApplicationBase app, GameHost host, TextureStore textures)
        {
            SpriteIcon.Texture = textures.Get("branding");
            Action             = () => host.OpenUrlExternally("https://github.com/vignette-project/vignette");

            if (app.IsDevelopmentBuild)
            {
                SpriteText.Add(new Badge(FluentSharedColours.Red10, "Local"));
            }

            if (VignetteApplicationBase.IsInsiderBuild)
            {
                SpriteText.Add(new Badge(FluentSharedColours.GreenCyan10, "Insiders"));
            }
        }
        private void load(ApplicationConfigManager appConfig, FrameworkConfigManager frameworkConfig, VignetteApplicationBase app, GameHost host, TextureStore textures, ThemeStore themes, Storage storage)
        {
            if (host.Window != null)
            {
                currentDisplay.BindTo(host.Window.CurrentDisplayBindable);
                windowModes.BindTo(host.Window.SupportedWindowModes);
            }

            var windowSizeBindable = frameworkConfig.GetBindable <Size>(FrameworkSetting.WindowedSize);
            var brandingText       = new ThemedTextFlowContainer
            {
                Anchor           = Anchor.Centre,
                Origin           = Anchor.Centre,
                AutoSizeAxes     = Axes.Y,
                TextAnchor       = Anchor.BottomCentre,
                RelativeSizeAxes = Axes.X,
            };

            brandingText.AddText(app.Version, (s) => s.Font = SegoeUI.SemiBold.With(size: 16, fixedWidth: true));

            Children = new Drawable[]
            {
                new ThemedSpriteText
                {
                    Font = SegoeUI.Bold.With(size: 18),
                    Text = "Interface"
                },
                themesDropdown = new ThemeSettingDropdown
                {
                    Label      = "Theme",
                    ItemSource = themes.Loaded,
                },
                new ThemedTextButton
                {
                    Text   = "Open Themes Folder",
                    Width  = 200,
                    Action = () => themes.OpenInNativeExplorer(),
                },
                new ThemedSpriteText
                {
                    Font = SegoeUI.Bold.With(size: 18),
                    Text = "Graphics"
                },
                new LabelledDropdown <WindowMode>
                {
                    Label      = "Window Mode",
                    ItemSource = windowModes,
                    Current    = frameworkConfig.GetBindable <WindowMode>(FrameworkSetting.WindowMode),
                },
                resizableCheckbox = new ThemedCheckbox
                {
                    Text    = "Resizable Window",
                    Current = appConfig.GetBindable <bool>(ApplicationSetting.WindowResizable),
                },
                resolutionDropdown = new ResolutionSettingDropdown
                {
                    Label      = "Resolution",
                    ItemSource = resolutions,
                    Current    = frameworkConfig.GetBindable <Size>(FrameworkSetting.SizeFullscreen),
                },
                new LabelledEnumDropdown <FrameSync>
                {
                    Label   = "Frame Limiter",
                    Current = frameworkConfig.GetBindable <FrameSync>(FrameworkSetting.FrameSync),
                },
                new LabelledEnumDropdown <ExecutionMode>
                {
                    Label   = "Threading Mode",
                    Current = frameworkConfig.GetBindable <ExecutionMode>(FrameworkSetting.ExecutionMode),
                },
                new ThemedSpriteText
                {
                    Font = SegoeUI.Bold.With(size: 18),
                    Text = "Debug"
                },
                new ThemedCheckbox
                {
                    Text    = "Show FPS",
                    Current = appConfig.GetBindable <bool>(ApplicationSetting.ShowFpsOverlay),
                },
                new ThemedCheckbox
                {
                    Text    = "Show Log Overlay",
                    Current = frameworkConfig.GetBindable <bool>(FrameworkSetting.ShowLogOverlay),
                },
                new ThemedTextButton
                {
                    Text   = "Open Vignette Folder",
                    Width  = 200,
                    Action = () => storage.OpenInNativeExplorer(),
                },
                new ThemedTextButton
                {
                    Text   = "Open Logs Folder",
                    Width  = 200,
                    Action = () => storage.OpenPathInNativeExplorer("./logs"),
                },
                new FillFlowContainer
                {
                    Margin = new MarginPadding {
                        Top = 30
                    },
                    Spacing          = new Vector2(0, 15),
                    Direction        = FillDirection.Vertical,
                    AutoSizeAxes     = Axes.Y,
                    RelativeSizeAxes = Axes.X,
                    Children         = new Drawable[]
                    {
                        new ThemedSprite
                        {
                            Size    = new Vector2(32),
                            Anchor  = Anchor.Centre,
                            Origin  = Anchor.Centre,
                            Texture = textures.Get("branding"),
                        },
                        brandingText
                    }
                }
            };

            resolutionDropdown.Current.BindValueChanged((e) => windowSizeBindable.Value = e.NewValue, true);
            resizableCheckbox.Current.BindValueChanged((e) =>
            {
                if (host.Window is SDL2DesktopWindow window)
                {
                    window.Resizable = e.NewValue;
                }

                resolutionDropdown.Alpha = !e.NewValue ? 1 : 0;

                if (!e.NewValue)
                {
                    resolutionDropdown.Current.TriggerChange();
                }
            }, true);

            var themeConfig = appConfig.GetBindable <string>(ApplicationSetting.Theme);

            themesDropdown.Current.Value         = themes.GetReference(themeConfig.Value);
            themesDropdown.Current.ValueChanged += e => themeConfig.Value = e.NewValue.Name;
        }