Exemplo n.º 1
0
        private void load(FrameworkConfigManager frameworkConfig)
        {
            this.frameworkConfig = frameworkConfig;

            if (!Host.IsPrimaryInstance && !DebugUtils.IsDebugBuild)
            {
                Logger.Log(@"osu! does not support multiple running instances.", LoggingTarget.Runtime, LogLevel.Error);
                Environment.Exit(0);
            }

            if (args?.Length > 0)
            {
                var paths = args.Where(a => !a.StartsWith(@"-")).ToArray();
                if (paths.Length > 0)
                {
                    Task.Run(() => Import(paths));
                }
            }

            dependencies.CacheAs(this);

            dependencies.Cache(SentryLogger);

            dependencies.Cache(osuLogo = new OsuLogo {
                Alpha = 0
            });

            // bind config int to database RulesetInfo
            configRuleset         = LocalConfig.GetBindable <int>(OsuSetting.Ruleset);
            Ruleset.Value         = RulesetStore.GetRuleset(configRuleset.Value) ?? RulesetStore.AvailableRulesets.First();
            Ruleset.ValueChanged += r => configRuleset.Value = r.NewValue.ID ?? 0;

            // bind config int to database SkinInfo
            configSkin = LocalConfig.GetBindable <int>(OsuSetting.Skin);
            SkinManager.CurrentSkinInfo.ValueChanged += skin => configSkin.Value = skin.NewValue.ID;
            configSkin.ValueChanged += skinId =>
            {
                var skinInfo = SkinManager.Query(s => s.ID == skinId.NewValue);

                if (skinInfo == null)
                {
                    switch (skinId.NewValue)
                    {
                    case -1:
                        skinInfo = DefaultLegacySkin.Info;
                        break;

                    default:
                        skinInfo = SkinInfo.Default;
                        break;
                    }
                }

                SkinManager.CurrentSkinInfo.Value = skinInfo;
            };
            configSkin.TriggerChange();

            IsActive.BindValueChanged(active => updateActiveState(active.NewValue), true);

            Audio.AddAdjustment(AdjustableProperty.Volume, inactiveVolumeFade);

            SelectedMods.BindValueChanged(modsChanged);
            Beatmap.BindValueChanged(beatmapChanged, true);
        }
Exemplo n.º 2
0
 public override void SetupWindow(FrameworkConfigManager config)
 {
     Resize += onResize;
 }
Exemplo n.º 3
0
 private void load(FrameworkConfigManager frameworkConfig, OsuConfigManager osuConfig)
 {
     BeginTracking(this, frameworkConfig);
     BeginTracking(this, osuConfig);
 }
 private void load(FrameworkConfigManager config)
 {
     volume          = config.GetBindable <double>(FrameworkSetting.VolumeUniversal);
     volumeAtStartup = volume.Value;
     volume.Value    = 0;
 }
Exemplo n.º 5
0
        private void setupConfig()
        {
            Dependencies.Cache(debugConfig  = new FrameworkDebugConfigManager());
            Dependencies.Cache(config       = new FrameworkConfigManager(Storage));
            Dependencies.Cache(Localisation = new LocalisationEngine(config));

            activeGCMode = debugConfig.GetBindable <GCLatencyMode>(DebugSetting.ActiveGCMode);
            activeGCMode.ValueChanged += newMode =>
            {
                GCSettings.LatencyMode = IsActive ? newMode : GCLatencyMode.Interactive;
            };

            frameSyncMode = config.GetBindable <FrameSync>(FrameworkSetting.FrameSync);
            frameSyncMode.ValueChanged += newMode =>
            {
                float refreshRate = DisplayDevice.Default.RefreshRate;

                float drawLimiter   = refreshRate;
                float updateLimiter = drawLimiter * 2;

                setVSyncMode();

                switch (newMode)
                {
                case FrameSync.VSync:
                    drawLimiter    = int.MaxValue;
                    updateLimiter *= 2;
                    break;

                case FrameSync.Limit2x:
                    drawLimiter   *= 2;
                    updateLimiter *= 2;
                    break;

                case FrameSync.Limit4x:
                    drawLimiter   *= 4;
                    updateLimiter *= 4;
                    break;

                case FrameSync.Limit8x:
                    drawLimiter   *= 8;
                    updateLimiter *= 8;
                    break;

                case FrameSync.Unlimited:
                    drawLimiter = updateLimiter = int.MaxValue;
                    break;
                }

                if (DrawThread != null)
                {
                    DrawThread.ActiveHz = drawLimiter;
                }
                if (UpdateThread != null)
                {
                    UpdateThread.ActiveHz = updateLimiter;
                }
            };

            enabledInputHandlers = config.GetBindable <string>(FrameworkSetting.ActiveInputHandlers);
            enabledInputHandlers.ValueChanged += enabledString =>
            {
                var  configHandlers = enabledString.Split(' ').Where(s => !string.IsNullOrWhiteSpace(s));
                bool useDefaults    = !configHandlers.Any();

                // make sure all the handlers in the configuration file are available, else reset to sane defaults.
                foreach (string handler in configHandlers)
                {
                    if (AvailableInputHandlers.All(h => h.ToString() != handler))
                    {
                        useDefaults = true;
                        break;
                    }
                }

                if (useDefaults)
                {
                    resetInputHandlers();
                    enabledInputHandlers.Value = string.Join(" ", AvailableInputHandlers.Where(h => h.Enabled).Select(h => h.ToString()));
                }
                else
                {
                    foreach (var handler in AvailableInputHandlers)
                    {
                        var handlerType = handler.ToString();
                        handler.Enabled.Value = configHandlers.Any(ch => ch == handlerType);
                    }
                }
            };

            cursorSensitivity = config.GetBindable <double>(FrameworkSetting.CursorSensitivity);
        }
Exemplo n.º 6
0
        private void load(Storage storage, GameHost host, FrameworkConfigManager frameworkConfig, FontStore fonts, Game game, AudioManager audio)
        {
            interactive = host.Window != null;
            config      = new TestBrowserConfig(storage);

            exit = host.Exit;

            audio.AddAdjustment(AdjustableProperty.Frequency, audioRateAdjust);

            var resources = game.Resources;

            //Roboto
            game.AddFont(resources, @"Fonts/Roboto/Roboto-Regular");
            game.AddFont(resources, @"Fonts/Roboto/Roboto-Bold");

            //RobotoCondensed
            game.AddFont(resources, @"Fonts/RobotoCondensed/RobotoCondensed-Regular");
            game.AddFont(resources, @"Fonts/RobotoCondensed/RobotoCondensed-Bold");

            showLogOverlay = frameworkConfig.GetBindable <bool>(FrameworkSetting.ShowLogOverlay);

            var rateAdjustClock = new StopwatchClock(true);
            var framedClock     = new FramedClock(rateAdjustClock);

            Children = new Drawable[]
            {
                mainContainer = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Padding          = new MarginPadding {
                        Left = test_list_width
                    },
                    Children = new Drawable[]
                    {
                        new SafeAreaContainer
                        {
                            SafeAreaOverrideEdges = Edges.Right | Edges.Bottom,
                            RelativeSizeAxes      = Axes.Both,
                            Child = testContentContainer = new Container
                            {
                                Clock            = framedClock,
                                RelativeSizeAxes = Axes.Both,
                                Padding          = new MarginPadding {
                                    Top = 50
                                },
                                Child = compilingNotice = new Container
                                {
                                    Alpha        = 0,
                                    Anchor       = Anchor.Centre,
                                    Origin       = Anchor.Centre,
                                    Masking      = true,
                                    Depth        = float.MinValue,
                                    CornerRadius = 5,
                                    AutoSizeAxes = Axes.Both,
                                    Children     = new Drawable[]
                                    {
                                        new Box
                                        {
                                            RelativeSizeAxes = Axes.Both,
                                            Colour           = Color4.Black,
                                        },
                                        new SpriteText
                                        {
                                            Font = new FontUsage(size: 30),
                                            Text = @"Compiling new version..."
                                        }
                                    },
                                }
                            }
                        },
                        toolbar = new TestBrowserToolbar
                        {
                            RelativeSizeAxes = Axes.X,
                            Height           = 50,
                        },
                    }
                },
                leftContainer = new Container
                {
                    RelativeSizeAxes = Axes.Y,
                    Size             = new Vector2(test_list_width, 1),
                    Masking          = true,
                    Children         = new Drawable[]
                    {
                        new SafeAreaContainer
                        {
                            SafeAreaOverrideEdges = Edges.Left | Edges.Top | Edges.Bottom,
                            RelativeSizeAxes      = Axes.Both,
                            Child = new Box
                            {
                                Colour           = FrameworkColour.GreenDark,
                                RelativeSizeAxes = Axes.Both
                            }
                        },
                        new FillFlowContainer
                        {
                            Direction        = FillDirection.Vertical,
                            RelativeSizeAxes = Axes.Both,
                            Children         = new Drawable[]
                            {
                                searchTextBox = new TestBrowserTextBox
                                {
                                    OnCommit = delegate
                                    {
                                        var firstTest = leftFlowContainer.Where(b => b.IsPresent).SelectMany(b => b.FilterableChildren).OfType <TestSubButton>()
                                                        .FirstOrDefault(b => b.MatchingFilter)?.TestType;
                                        if (firstTest != null)
                                        {
                                            LoadTest(firstTest);
                                        }
                                    },
                                    Height           = 25,
                                    RelativeSizeAxes = Axes.X,
                                    PlaceholderText  = "type to search",
                                    Depth            = -1,
                                },
                                new BasicScrollContainer
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    Masking          = false,
                                    Child            = leftFlowContainer = new SearchContainer <TestGroupButton>
                                    {
                                        Padding = new MarginPadding {
                                            Top = 3, Bottom = 20
                                        },
                                        Direction        = FillDirection.Vertical,
                                        AutoSizeAxes     = Axes.Y,
                                        RelativeSizeAxes = Axes.X,
                                    }
                                }
                            }
                        }
                    }
                },
            };

            searchTextBox.Current.ValueChanged += e => leftFlowContainer.SearchTerm = e.NewValue;

            if (RuntimeInfo.IsDesktop)
            {
                backgroundCompiler = new DynamicClassCompiler <TestScene>();
                backgroundCompiler.CompilationStarted  += compileStarted;
                backgroundCompiler.CompilationFinished += compileFinished;
                backgroundCompiler.CompilationFailed   += compileFailed;

                try
                {
                    backgroundCompiler.Start();
                }
                catch
                {
                    //it's okay for this to fail for now.
                }
            }

            foreach (Assembly asm in assemblies)
            {
                toolbar.AddAssembly(asm.GetName().Name, asm);
            }

            Assembly.BindValueChanged(updateList);
            RunAllSteps.BindValueChanged(v => runTests(null));
            PlaybackRate.BindValueChanged(e =>
            {
                rateAdjustClock.Rate  = e.NewValue;
                audioRateAdjust.Value = e.NewValue;
            }, true);
        }
Exemplo n.º 7
0
 private void load(FrameworkConfigManager config)
 {
     this.config = config;
 }
Exemplo n.º 8
0
        private void load(Storage storage, GameHost host, FrameworkConfigManager frameworkConfig)
        {
            interactive = host.Window != null;
            config      = new TestBrowserConfig(storage);

            exit = host.Exit;

            showLogOverlay = frameworkConfig.GetBindable <bool>(FrameworkSetting.ShowLogOverlay);

            rateBindable = new BindableDouble(1)
            {
                MinValue = 0,
                MaxValue = 2,
            };

            var rateAdjustClock = new StopwatchClock(true);
            var framedClock     = new FramedClock(rateAdjustClock);

            Children = new Drawable[]
            {
                leftContainer = new Container
                {
                    RelativeSizeAxes = Axes.Y,
                    Size             = new Vector2(test_list_width, 1),
                    Children         = new Drawable[]
                    {
                        new Box
                        {
                            Colour           = Color4.DimGray,
                            RelativeSizeAxes = Axes.Both
                        },
                        new FillFlowContainer
                        {
                            Direction        = FillDirection.Vertical,
                            RelativeSizeAxes = Axes.Both,
                            Children         = new Drawable[]
                            {
                                searchTextBox = new TextBox
                                {
                                    OnCommit = delegate
                                    {
                                        var firstVisible = leftFlowContainer.FirstOrDefault(b => b.IsPresent);
                                        if (firstVisible != null)
                                        {
                                            LoadTest(firstVisible.TestType);
                                        }
                                    },
                                    Height           = 20,
                                    RelativeSizeAxes = Axes.X,
                                    PlaceholderText  = "type to search"
                                },
                                new ScrollContainer
                                {
                                    Padding = new MarginPadding {
                                        Top = 3, Bottom = 20
                                    },
                                    RelativeSizeAxes         = Axes.Both,
                                    ScrollbarOverlapsContent = false,
                                    Child = leftFlowContainer = new SearchContainer <TestCaseButton>
                                    {
                                        Padding          = new MarginPadding(3),
                                        Direction        = FillDirection.Vertical,
                                        Spacing          = new Vector2(0, 5),
                                        AutoSizeAxes     = Axes.Y,
                                        RelativeSizeAxes = Axes.X,
                                    }
                                }
                            }
                        }
                    }
                },
                mainContainer = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Padding          = new MarginPadding {
                        Left = test_list_width
                    },
                    Children = new Drawable[]
                    {
                        toolbar = new Toolbar
                        {
                            RelativeSizeAxes = Axes.X,
                            Height           = 50,
                            Depth            = -1,
                        },
                        testContentContainer = new Container
                        {
                            Clock            = framedClock,
                            RelativeSizeAxes = Axes.Both,
                            Padding          = new MarginPadding {
                                Top = 50
                            },
                            Child = compilingNotice = new Container
                            {
                                Alpha        = 0,
                                Anchor       = Anchor.Centre,
                                Origin       = Anchor.Centre,
                                Masking      = true,
                                Depth        = float.MinValue,
                                CornerRadius = 5,
                                AutoSizeAxes = Axes.Both,
                                Children     = new Drawable[]
                                {
                                    new Box
                                    {
                                        RelativeSizeAxes = Axes.Both,
                                        Colour           = Color4.Black,
                                    },
                                    new SpriteText
                                    {
                                        TextSize = 30,
                                        Text     = @"Compiling new version..."
                                    }
                                },
                            }
                        }
                    }
                }
            };

            searchTextBox.Current.ValueChanged += newValue => leftFlowContainer.SearchTerm = newValue;

            backgroundCompiler = new DynamicClassCompiler <TestCase>
            {
                CompilationStarted  = compileStarted,
                CompilationFinished = compileFinished,
                CompilationFailed   = compileFailed
            };
            try
            {
                backgroundCompiler.Start();
            }
            catch
            {
                //it's okay for this to fail for now.
            }

            foreach (Assembly asm in assemblies)
            {
                toolbar.AssemblyDropdown.AddDropdownItem(asm.GetName().Name, asm);
            }

            toolbar.AssemblyDropdown.Current.ValueChanged += updateList;
            toolbar.RunAllSteps.Current.ValueChanged      += v => runTests(null);
            toolbar.RateAdjustSlider.Current.BindTo(rateBindable);

            rateBindable.ValueChanged += v => rateAdjustClock.Rate = v;
            rateBindable.TriggerChange();
        }
Exemplo n.º 9
0
        private void load(FrameworkConfigManager config, OsuGameBase game)
        {
            this.game = game;

            letterboxing   = config.GetBindable <bool>(FrameworkSetting.Letterboxing);
            sizeFullscreen = config.GetBindable <Size>(FrameworkSetting.SizeFullscreen);

            Container resolutionSettingsContainer;

            Children = new Drawable[]
            {
                windowModeDropdown = new SettingsEnumDropdown <WindowMode>
                {
                    LabelText = "Screen mode",
                    Bindable  = config.GetBindable <WindowMode>(FrameworkSetting.WindowMode),
                },
                resolutionSettingsContainer = new Container
                {
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y
                },
                new SettingsCheckbox
                {
                    LabelText = "Letterboxing",
                    Bindable  = letterboxing,
                },
                letterboxSettings = new FillFlowContainer
                {
                    Direction        = FillDirection.Vertical,
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    AutoSizeDuration = transition_duration,
                    AutoSizeEasing   = Easing.OutQuint,
                    Masking          = true,

                    Children = new Drawable[]
                    {
                        new SettingsSlider <double>
                        {
                            LabelText    = "Horizontal position",
                            Bindable     = config.GetBindable <double>(FrameworkSetting.LetterboxPositionX),
                            KeyboardStep = 0.01f
                        },
                        new SettingsSlider <double>
                        {
                            LabelText    = "Vertical position",
                            Bindable     = config.GetBindable <double>(FrameworkSetting.LetterboxPositionY),
                            KeyboardStep = 0.01f
                        },
                    }
                },
            };

            var resolutions = getResolutions();

            if (resolutions.Count > 1)
            {
                resolutionSettingsContainer.Child = resolutionDropdown = new SettingsDropdown <Size>
                {
                    LabelText             = "Resolution",
                    ShowsDefaultIndicator = false,
                    Items    = resolutions,
                    Bindable = sizeFullscreen
                };

                windowModeDropdown.Bindable.BindValueChanged(windowMode =>
                {
                    if (windowMode == WindowMode.Fullscreen)
                    {
                        resolutionDropdown.Show();
                        sizeFullscreen.TriggerChange();
                    }
                    else
                    {
                        resolutionDropdown.Hide();
                    }
                }, true);
            }

            letterboxing.BindValueChanged(isVisible =>
            {
                letterboxSettings.ClearTransforms();
                letterboxSettings.AutoSizeAxes = isVisible ? Axes.Y : Axes.None;

                if (!isVisible)
                {
                    letterboxSettings.ResizeHeightTo(0, transition_duration, Easing.OutQuint);
                }
            }, true);
        }
Exemplo n.º 10
0
        private void load(FrameworkConfigManager config, GameHost host)
        {
            window = host.Window;
            config.BindWith(FrameworkSetting.SizeFullscreen, sizeFullscreen);
            config.BindWith(FrameworkSetting.WindowMode, windowMode);
            currentWindowMode.Text = $"Window Mode: {windowMode}";

            if (window == null)
            {
                return;
            }

            displaysDropdown.Items = window.Displays;
            displaysDropdown.Current.BindTo(window.CurrentDisplay);

            supportedWindowModes.Text = $"Supported Window Modes: {string.Join(", ", window.SupportedWindowModes)}";

            // so the test case doesn't change fullscreen size just when you enter it
            AddStep("nothing", () => { });

            var initialWindowMode = windowMode.Value;

            // if we support windowed mode, switch to it and test resizing the window
            if (window.SupportedWindowModes.Contains(WindowMode.Windowed))
            {
                AddStep("change to windowed", () => windowMode.Value = WindowMode.Windowed);
                AddStep("change window size", () => config.GetBindable <Size>(FrameworkSetting.WindowedSize).Value = new Size(640, 640));
            }

            // if we support borderless, test that it can be used
            if (window.SupportedWindowModes.Contains(WindowMode.Borderless))
            {
                AddStep("change to borderless", () => windowMode.Value = WindowMode.Borderless);
            }

            // if we support fullscreen mode, switch to it and test swapping resolutions
            if (window.SupportedWindowModes.Contains(WindowMode.Fullscreen))
            {
                AddStep("change to fullscreen", () => windowMode.Value = WindowMode.Fullscreen);
                testResolution(1920, 1080);
                testResolution(1280, 960);
                testResolution(9999, 9999);
            }

            // go back to initial window mode
            AddStep($"revert to {initialWindowMode.ToString()}", () => windowMode.Value = initialWindowMode);

            // show the available displays
            AddStep("query Window.Displays", () =>
            {
                var displaysArray = window.Displays.ToArray();
                Logger.Log($"Available displays: {displaysArray.Length}");
                displaysArray.ForEach(display =>
                {
                    Logger.Log(display.ToString());
                    display.DisplayModes.ForEach(mode => Logger.Log($"-- {mode}"));
                });
            });

            AddStep("query Window.CurrentDisplay", () => Logger.Log(window.CurrentDisplay.ToString()));

            AddStep("query Window.CurrentDisplayMode", () => Logger.Log(window.CurrentDisplayMode.ToString()));
        }
Exemplo n.º 11
0
 private void load(FrameworkConfigManager config)
 {
 }
Exemplo n.º 12
0
        private void load(FrameworkConfigManager config)
        {
            Resources = new ResourceStore <byte[]>();
            Resources.AddStore(new NamespacedResourceStore <byte[]>(new DllResourceStore(typeof(Game).Assembly), @"Resources"));

            Textures = new TextureStore(Host.CreateTextureLoaderStore(new NamespacedResourceStore <byte[]>(Resources, @"Textures")));
            Textures.AddStore(Host.CreateTextureLoaderStore(new OnlineStore()));
            dependencies.Cache(Textures);

            var tracks = new ResourceStore <byte[]>();

            tracks.AddStore(new NamespacedResourceStore <byte[]>(Resources, @"Tracks"));
            tracks.AddStore(new OnlineStore());

            var samples = new ResourceStore <byte[]>();

            samples.AddStore(new NamespacedResourceStore <byte[]>(Resources, @"Samples"));
            samples.AddStore(new OnlineStore());

            Audio = new AudioManager(Host.AudioThread, tracks, samples)
            {
                EventScheduler = Scheduler
            };
            dependencies.Cache(Audio);

            dependencies.CacheAs(Audio.Tracks);
            dependencies.CacheAs(Audio.Samples);

            // attach our bindables to the audio subsystem.
            config.BindWith(FrameworkSetting.AudioDevice, Audio.AudioDevice);
            config.BindWith(FrameworkSetting.VolumeUniversal, Audio.Volume);
            config.BindWith(FrameworkSetting.VolumeEffect, Audio.VolumeSample);
            config.BindWith(FrameworkSetting.VolumeMusic, Audio.VolumeTrack);

            Shaders = new ShaderManager(new NamespacedResourceStore <byte[]>(Resources, @"Shaders"));
            dependencies.Cache(Shaders);

            var cacheStorage = Host.Storage.GetStorageForDirectory(Path.Combine("cache", "fonts"));

            // base store is for user fonts
            Fonts = new FontStore(useAtlas: true, cacheStorage: cacheStorage);

            // nested store for framework provided fonts.
            // note that currently this means there could be two async font load operations.
            Fonts.AddStore(localFonts = new FontStore(useAtlas: false));

            addFont(localFonts, Resources, @"Fonts/OpenSans/OpenSans");
            addFont(localFonts, Resources, @"Fonts/OpenSans/OpenSans-Bold");
            addFont(localFonts, Resources, @"Fonts/OpenSans/OpenSans-Italic");
            addFont(localFonts, Resources, @"Fonts/OpenSans/OpenSans-BoldItalic");

            addFont(Fonts, Resources, @"Fonts/FontAwesome5/FontAwesome-Solid");
            addFont(Fonts, Resources, @"Fonts/FontAwesome5/FontAwesome-Regular");
            addFont(Fonts, Resources, @"Fonts/FontAwesome5/FontAwesome-Brands");

            dependencies.Cache(Fonts);

            Localisation = new LocalisationManager(config);
            dependencies.Cache(Localisation);

            logOverlayVisibility = config.GetBindable <bool>(FrameworkSetting.ShowLogOverlay);
            logOverlayVisibility.BindValueChanged(visibility =>
            {
                if (visibility.NewValue)
                {
                    if (logOverlay == null)
                    {
                        LoadComponentAsync(logOverlay = new LogOverlay
                        {
                            Depth = float.MinValue / 2,
                        }, AddInternal);
                    }

                    logOverlay.Show();
                }
                else
                {
                    logOverlay?.Hide();
                }
            }, true);
        }
Exemplo n.º 13
0
 public override void SetupWindow(FrameworkConfigManager config)
 {
     Resize += onResize;
     // for now, let's just say the cursor is always in the window.
     CursorInWindow = true;
 }
Exemplo n.º 14
0
        private void load(Storage storage, FrameworkConfigManager frameworkConfig)
        {
            Resources.AddStore(new DllResourceStore(@"osu.Game.Tournament.dll"));

            Fonts.AddStore(new GlyphStore(Resources, @"Resources/Fonts/Aquatico-Regular"));
            Fonts.AddStore(new GlyphStore(Resources, @"Resources/Fonts/Aquatico-Light"));

            Textures.AddStore(new TextureLoaderStore(new ResourceStore <byte[]>(new StorageBackedResourceStore(storage))));

            this.storage = storage;

            windowSize = frameworkConfig.GetBindable <Size>(FrameworkSetting.WindowedSize);
            windowSize.BindValueChanged(size => ScheduleAfterChildren(() =>
            {
                var minWidth = (int)(size.NewValue.Height / 9f * 16 + 400);

                heightWarning.Alpha = size.NewValue.Width < minWidth ? 1 : 0;
            }), true);

            readBracket();

            ladder.CurrentMatch.Value = ladder.Matches.FirstOrDefault(p => p.Current.Value);

            dependencies.CacheAs <MatchIPCInfo>(ipc = new FileBasedIPC());
            Add(ipc);

            AddRange(new[]
            {
                new TourneyButton
                {
                    Text    = "Save Changes",
                    Width   = 140,
                    Height  = 50,
                    Depth   = float.MinValue,
                    Anchor  = Anchor.BottomRight,
                    Origin  = Anchor.BottomRight,
                    Padding = new MarginPadding(10),
                    Action  = SaveChanges,
                },
                heightWarning = new Container
                {
                    Masking      = true,
                    CornerRadius = 5,
                    Depth        = float.MinValue,
                    Anchor       = Anchor.Centre,
                    Origin       = Anchor.Centre,
                    AutoSizeAxes = Axes.Both,
                    Children     = new Drawable[]
                    {
                        new Box
                        {
                            Colour           = Color4.Red,
                            RelativeSizeAxes = Axes.Both,
                        },
                        new OsuSpriteText
                        {
                            Text    = "Please make the window wider",
                            Font    = OsuFont.Default.With(weight: "bold"),
                            Colour  = Color4.White,
                            Padding = new MarginPadding(20)
                        }
                    }
                },
            });
        }
Exemplo n.º 15
0
        private void load(FrameworkConfigManager config, OsuConfigManager osuConfig, OsuGameBase game, GameHost host)
        {
            this.game = game;

            scalingMode      = osuConfig.GetBindable <ScalingMode>(OsuSetting.Scaling);
            sizeFullscreen   = config.GetBindable <Size>(FrameworkSetting.SizeFullscreen);
            scalingSizeX     = osuConfig.GetBindable <float>(OsuSetting.ScalingSizeX);
            scalingSizeY     = osuConfig.GetBindable <float>(OsuSetting.ScalingSizeY);
            scalingPositionX = osuConfig.GetBindable <float>(OsuSetting.ScalingPositionX);
            scalingPositionY = osuConfig.GetBindable <float>(OsuSetting.ScalingPositionY);

            if (host.Window != null)
            {
                windowModes.BindTo(host.Window.SupportedWindowModes);
            }

            Container resolutionSettingsContainer;

            Children = new Drawable[]
            {
                windowModeDropdown = new SettingsDropdown <WindowMode>
                {
                    LabelText  = "Screen mode",
                    Bindable   = config.GetBindable <WindowMode>(FrameworkSetting.WindowMode),
                    ItemSource = windowModes,
                },
                resolutionSettingsContainer = new Container
                {
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y
                },
                new SettingsSlider <float, UIScaleSlider>
                {
                    LabelText             = "UI Scaling",
                    TransferValueOnCommit = true,
                    Bindable     = osuConfig.GetBindable <float>(OsuSetting.UIScale),
                    KeyboardStep = 0.01f,
                    Keywords     = new[] { "scale", "letterbox" },
                },
                new SettingsEnumDropdown <ScalingMode>
                {
                    LabelText = "Screen Scaling",
                    Bindable  = osuConfig.GetBindable <ScalingMode>(OsuSetting.Scaling),
                    Keywords  = new[] { "scale", "letterbox" },
                },
                scalingSettings = new FillFlowContainer <SettingsSlider <float> >
                {
                    Direction        = FillDirection.Vertical,
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    AutoSizeDuration = transition_duration,
                    AutoSizeEasing   = Easing.OutQuint,
                    Masking          = true,
                    Children         = new[]
                    {
                        new SettingsSlider <float>
                        {
                            LabelText    = "Horizontal position",
                            Bindable     = scalingPositionX,
                            KeyboardStep = 0.01f
                        },
                        new SettingsSlider <float>
                        {
                            LabelText    = "Vertical position",
                            Bindable     = scalingPositionY,
                            KeyboardStep = 0.01f
                        },
                        new SettingsSlider <float>
                        {
                            LabelText    = "Horizontal scale",
                            Bindable     = scalingSizeX,
                            KeyboardStep = 0.01f
                        },
                        new SettingsSlider <float>
                        {
                            LabelText    = "Vertical scale",
                            Bindable     = scalingSizeY,
                            KeyboardStep = 0.01f
                        },
                    }
                },
            };

            scalingSettings.ForEach(s => bindPreviewEvent(s.Bindable));

            var resolutions = getResolutions();

            if (resolutions.Count > 1)
            {
                resolutionSettingsContainer.Child = resolutionDropdown = new ResolutionSettingsDropdown
                {
                    LabelText             = "Resolution",
                    ShowsDefaultIndicator = false,
                    Items    = resolutions,
                    Bindable = sizeFullscreen
                };

                windowModeDropdown.Bindable.BindValueChanged(mode =>
                {
                    if (mode.NewValue == WindowMode.Fullscreen)
                    {
                        resolutionDropdown.Show();
                        sizeFullscreen.TriggerChange();
                    }
                    else
                    {
                        resolutionDropdown.Hide();
                    }
                }, true);
            }

            scalingMode.BindValueChanged(mode =>
            {
                scalingSettings.ClearTransforms();
                scalingSettings.AutoSizeAxes = mode.NewValue != ScalingMode.Off ? Axes.Y : Axes.None;

                if (mode.NewValue == ScalingMode.Off)
                {
                    scalingSettings.ResizeHeightTo(0, transition_duration, Easing.OutQuint);
                }

                scalingSettings.ForEach(s => s.TransferValueOnCommit = mode.NewValue == ScalingMode.Everything);
            }, true);

            windowModes.ItemsAdded   += _ => windowModesChanged();
            windowModes.ItemsRemoved += _ => windowModesChanged();

            windowModesChanged();
        }
Exemplo n.º 16
0
        private void load(OsuConfigManager osuConfig, FrameworkConfigManager config)
        {
            Children = new Drawable[]
            {
                new SettingsCheckbox
                {
                    LabelText = "Raw input",
                    Bindable  = rawInputToggle
                },
                sensitivity = new SensitivitySetting
                {
                    LabelText = "Cursor sensitivity",
                    Bindable  = config.GetBindable <double>(FrameworkSetting.CursorSensitivity)
                },
                new SettingsCheckbox
                {
                    LabelText = "Map absolute input to window",
                    Bindable  = config.GetBindable <bool>(FrameworkSetting.MapAbsoluteInputToWindow)
                },
                new SettingsEnumDropdown <ConfineMouseMode>
                {
                    LabelText = "Confine mouse cursor to window",
                    Bindable  = config.GetBindable <ConfineMouseMode>(FrameworkSetting.ConfineMouseMode),
                },
                new SettingsCheckbox
                {
                    LabelText = "Disable mouse wheel during gameplay",
                    Bindable  = osuConfig.GetBindable <bool>(OsuSetting.MouseDisableWheel)
                },
                new SettingsCheckbox
                {
                    LabelText = "Disable mouse buttons during gameplay",
                    Bindable  = osuConfig.GetBindable <bool>(OsuSetting.MouseDisableButtons)
                },
            };

            if (RuntimeInfo.OS != RuntimeInfo.Platform.Windows)
            {
                rawInputToggle.Disabled       = true;
                sensitivity.Bindable.Disabled = true;
            }
            else
            {
                rawInputToggle.ValueChanged += enabled =>
                {
                    // this is temporary until we support per-handler settings.
                    const string raw_mouse_handler      = @"OsuTKRawMouseHandler";
                    const string standard_mouse_handler = @"OsuTKMouseHandler";

                    ignoredInputHandler.Value = enabled.NewValue ? standard_mouse_handler : raw_mouse_handler;
                };

                ignoredInputHandler = config.GetBindable <string>(FrameworkSetting.IgnoredInputHandlers);
                ignoredInputHandler.ValueChanged += handler =>
                {
                    bool raw = !handler.NewValue.Contains("Raw");
                    rawInputToggle.Value          = raw;
                    sensitivity.Bindable.Disabled = !raw;
                };

                ignoredInputHandler.TriggerChange();
            }
        }
Exemplo n.º 17
0
        private void load(FrameworkConfigManager config, OsuConfigManager osuConfig, GameHost host)
        {
            scalingMode      = osuConfig.GetBindable <ScalingMode>(OsuSetting.Scaling);
            sizeFullscreen   = config.GetBindable <Size>(FrameworkSetting.SizeFullscreen);
            scalingSizeX     = osuConfig.GetBindable <float>(OsuSetting.ScalingSizeX);
            scalingSizeY     = osuConfig.GetBindable <float>(OsuSetting.ScalingSizeY);
            scalingPositionX = osuConfig.GetBindable <float>(OsuSetting.ScalingPositionX);
            scalingPositionY = osuConfig.GetBindable <float>(OsuSetting.ScalingPositionY);

            if (host.Window != null)
            {
                currentDisplay.BindTo(host.Window.CurrentDisplayBindable);
                windowModes.BindTo(host.Window.SupportedWindowModes);
            }

            Children = new Drawable[]
            {
                windowModeDropdown = new SettingsDropdown <WindowMode>
                {
                    LabelText  = GraphicsSettingsStrings.ScreenMode,
                    ItemSource = windowModes,
                    Current    = config.GetBindable <WindowMode>(FrameworkSetting.WindowMode),
                },
                resolutionDropdown = new ResolutionSettingsDropdown
                {
                    LabelText             = GraphicsSettingsStrings.Resolution,
                    ShowsDefaultIndicator = false,
                    ItemSource            = resolutions,
                    Current = sizeFullscreen
                },
                new SettingsSlider <float, UIScaleSlider>
                {
                    LabelText             = GraphicsSettingsStrings.UIScaling,
                    TransferValueOnCommit = true,
                    Current      = osuConfig.GetBindable <float>(OsuSetting.UIScale),
                    KeyboardStep = 0.01f,
                    Keywords     = new[] { "scale", "letterbox" },
                },
                new SettingsEnumDropdown <ScalingMode>
                {
                    LabelText = GraphicsSettingsStrings.ScreenScaling,
                    Current   = osuConfig.GetBindable <ScalingMode>(OsuSetting.Scaling),
                    Keywords  = new[] { "scale", "letterbox" },
                },
                scalingSettings = new FillFlowContainer <SettingsSlider <float> >
                {
                    Direction        = FillDirection.Vertical,
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    Masking          = true,
                    Children         = new[]
                    {
                        new SettingsSlider <float>
                        {
                            LabelText           = GraphicsSettingsStrings.HorizontalPosition,
                            Current             = scalingPositionX,
                            KeyboardStep        = 0.01f,
                            DisplayAsPercentage = true
                        },
                        new SettingsSlider <float>
                        {
                            LabelText           = GraphicsSettingsStrings.VerticalPosition,
                            Current             = scalingPositionY,
                            KeyboardStep        = 0.01f,
                            DisplayAsPercentage = true
                        },
                        new SettingsSlider <float>
                        {
                            LabelText           = GraphicsSettingsStrings.HorizontalScale,
                            Current             = scalingSizeX,
                            KeyboardStep        = 0.01f,
                            DisplayAsPercentage = true
                        },
                        new SettingsSlider <float>
                        {
                            LabelText           = GraphicsSettingsStrings.VerticalScale,
                            Current             = scalingSizeY,
                            KeyboardStep        = 0.01f,
                            DisplayAsPercentage = true
                        },
                    }
                },
            };
        }
Exemplo n.º 18
0
        private void load(FrameworkConfigManager frameworkConfig, GameHost host)
        {
            windowSize = frameworkConfig.GetBindable<Size>(FrameworkSetting.WindowedSize);
            windowMode = frameworkConfig.GetBindable<WindowMode>(FrameworkSetting.WindowMode);

            Add(loadingSpinner = new LoadingSpinner(true, true)
            {
                Anchor = Anchor.BottomRight,
                Origin = Anchor.BottomRight,
                Margin = new MarginPadding(40),
            });

            // in order to have the OS mouse cursor visible, relative mode needs to be disabled.
            // can potentially be removed when https://github.com/ppy/osu-framework/issues/4309 is resolved.
            var mouseHandler = host.AvailableInputHandlers.OfType<MouseHandler>().FirstOrDefault();

            if (mouseHandler != null)
                mouseHandler.UseRelativeMode.Value = false;

            loadingSpinner.Show();

            BracketLoadTask.ContinueWith(t =>
            {
                if (t.IsFaulted)
                {
                    Schedule(() =>
                    {
                        loadingSpinner.Hide();
                        loadingSpinner.Expire();

                        Logger.Error(t.Exception, "Couldn't load bracket with error");
                        Add(new WarningBox($"Your {BRACKET_FILENAME} file could not be parsed. Please check runtime.log for more details."));
                    });

                    return;
                }

                LoadComponentsAsync(new[]
                {
                    new Container
                    {
                        CornerRadius = 10,
                        Depth = float.MinValue,
                        Position = new Vector2(5),
                        Masking = true,
                        AutoSizeAxes = Axes.Both,
                        Anchor = Anchor.BottomRight,
                        Origin = Anchor.BottomRight,
                        Children = new Drawable[]
                        {
                            new Box
                            {
                                Colour = OsuColour.Gray(0.2f),
                                RelativeSizeAxes = Axes.Both,
                            },
                            new TourneyButton
                            {
                                Text = "Save Changes",
                                Width = 140,
                                Height = 50,
                                Padding = new MarginPadding
                                {
                                    Top = 10,
                                    Left = 10,
                                },
                                Margin = new MarginPadding
                                {
                                    Right = 10,
                                    Bottom = 10,
                                },
                                Action = SaveChanges,
                            },
                        }
                    },
                    heightWarning = new WarningBox("Please make the window wider")
                    {
                        Anchor = Anchor.BottomCentre,
                        Origin = Anchor.BottomCentre,
                        Margin = new MarginPadding(20),
                    },
                    new OsuContextMenuContainer
                    {
                        RelativeSizeAxes = Axes.Both,
                        Child = new TournamentSceneManager()
                    }
                }, drawables =>
                {
                    loadingSpinner.Hide();
                    loadingSpinner.Expire();

                    AddRange(drawables);

                    windowSize.BindValueChanged(size => ScheduleAfterChildren(() =>
                    {
                        int minWidth = (int)(size.NewValue.Height / 768f * TournamentSceneManager.REQUIRED_WIDTH) - 1;
                        heightWarning.Alpha = size.NewValue.Width < minWidth ? 1 : 0;
                    }), true);

                    windowMode.BindValueChanged(mode => ScheduleAfterChildren(() =>
                    {
                        windowMode.Value = WindowMode.Windowed;
                    }), true);
                });
            });
        }
Exemplo n.º 19
0
 public void Setup()
 {
     config  = new FakeFrameworkConfigManager();
     manager = new LocalisationManager(config);
     manager.AddLanguage("en", new FakeStorage("en"));
 }
Exemplo n.º 20
0
 private void load(FrameworkConfigManager config)
 {
     enabled = config.GetBindable <bool>(FrameworkConfig.ShowLogOverlay);
     State   = enabled.Value ? Visibility.Visible : Visibility.Hidden;
 }
Exemplo n.º 21
0
        private void load(FrameworkConfigManager frameworkConfig)
        {
            windowSize = frameworkConfig.GetBindable <Size>(FrameworkSetting.WindowedSize);
            windowSize.BindValueChanged(size => ScheduleAfterChildren(() =>
            {
                var minWidth = (int)(size.NewValue.Height / 768f * TournamentSceneManager.REQUIRED_WIDTH) - 1;

                heightWarning.Alpha = size.NewValue.Width < minWidth ? 1 : 0;
            }), true);

            windowMode = frameworkConfig.GetBindable <WindowMode>(FrameworkSetting.WindowMode);
            windowMode.BindValueChanged(mode => ScheduleAfterChildren(() =>
            {
                windowMode.Value = WindowMode.Windowed;
            }), true);

            AddRange(new[]
            {
                new Container
                {
                    CornerRadius = 10,
                    Depth        = float.MinValue,
                    Position     = new Vector2(5),
                    Masking      = true,
                    AutoSizeAxes = Axes.Both,
                    Anchor       = Anchor.BottomRight,
                    Origin       = Anchor.BottomRight,
                    Children     = new Drawable[]
                    {
                        new Box
                        {
                            Colour           = OsuColour.Gray(0.2f),
                            RelativeSizeAxes = Axes.Both,
                        },
                        new TourneyButton
                        {
                            Text    = "Save Changes",
                            Width   = 140,
                            Height  = 50,
                            Padding = new MarginPadding
                            {
                                Top  = 10,
                                Left = 10,
                            },
                            Margin = new MarginPadding
                            {
                                Right  = 10,
                                Bottom = 10,
                            },
                            Action = SaveChanges,
                        },
                    }
                },
                heightWarning = new WarningBox("Please make the window wider"),
                new OsuContextMenuContainer
                {
                    RelativeSizeAxes = Axes.Both,
                    Child            = new TournamentSceneManager()
                }
            });
        }
Exemplo n.º 22
0
 public abstract void SetupWindow(FrameworkConfigManager config);
Exemplo n.º 23
0
 private void load(FrameworkConfigManager configManager)
 {
     executionMode = configManager.GetBindable <ExecutionMode>(FrameworkSetting.ExecutionMode);
 }
Exemplo n.º 24
0
        private void setupConfig()
        {
            Dependencies.Cache(debugConfig  = new FrameworkDebugConfigManager());
            Dependencies.Cache(config       = new FrameworkConfigManager(Storage));
            Dependencies.Cache(Localisation = new LocalisationEngine(config));

            activeGCMode = debugConfig.GetBindable <GCLatencyMode>(DebugSetting.ActiveGCMode);
            activeGCMode.ValueChanged += newMode =>
            {
                GCSettings.LatencyMode = IsActive ? newMode : GCLatencyMode.Interactive;
            };

            frameSyncMode = config.GetBindable <FrameSync>(FrameworkSetting.FrameSync);
            frameSyncMode.ValueChanged += newMode =>
            {
                float refreshRate = DisplayDevice.Default.RefreshRate;
                // For invalid refresh rates let's assume 60 Hz as it is most common.
                if (refreshRate <= 0)
                {
                    refreshRate = 60;
                }

                float drawLimiter   = refreshRate;
                float updateLimiter = drawLimiter * 2;

                setVSyncMode();

                switch (newMode)
                {
                case FrameSync.VSync:
                    drawLimiter    = int.MaxValue;
                    updateLimiter *= 2;
                    break;

                case FrameSync.Limit2x:
                    drawLimiter   *= 2;
                    updateLimiter *= 2;
                    break;

                case FrameSync.Limit4x:
                    drawLimiter   *= 4;
                    updateLimiter *= 4;
                    break;

                case FrameSync.Limit8x:
                    drawLimiter   *= 8;
                    updateLimiter *= 8;
                    break;

                case FrameSync.Unlimited:
                    drawLimiter = updateLimiter = int.MaxValue;
                    break;
                }

                if (DrawThread != null)
                {
                    DrawThread.ActiveHz = drawLimiter;
                }
                if (UpdateThread != null)
                {
                    UpdateThread.ActiveHz = updateLimiter;
                }
            };

            ignoredInputHandlers = config.GetBindable <string>(FrameworkSetting.IgnoredInputHandlers);
            ignoredInputHandlers.ValueChanged += ignoredString =>
            {
                var configIgnores = ignoredString.Split(' ').Where(s => !string.IsNullOrWhiteSpace(s));

                // for now, we always want at least one handler disabled (don't want raw and non-raw mouse at once).
                bool restoreDefaults = !configIgnores.Any();

                if (restoreDefaults)
                {
                    resetInputHandlers();
                    ignoredInputHandlers.Value = string.Join(" ", AvailableInputHandlers.Where(h => !h.Enabled).Select(h => h.ToString()));
                }
                else
                {
                    foreach (var handler in AvailableInputHandlers)
                    {
                        var handlerType = handler.ToString();
                        handler.Enabled.Value = configIgnores.All(ch => ch != handlerType);
                    }
                }
            };

            cursorSensitivity = config.GetBindable <double>(FrameworkSetting.CursorSensitivity);

            performanceLogging = config.GetBindable <bool>(FrameworkSetting.PerformanceLogging);
            performanceLogging.ValueChanged += enabled => threads.ForEach(t => t.Monitor.EnablePerformanceProfiling = enabled);
            performanceLogging.TriggerChange();
        }
Exemplo n.º 25
0
 private void load(FrameworkConfigManager config)
 {
     enabled = config.GetBindable <bool>(FrameworkSetting.ShowLogOverlay);
     enabled.ValueChanged += val => State = val ? Visibility.Visible : Visibility.Hidden;
     enabled.TriggerChange();
 }
Exemplo n.º 26
0
        private void load(Storage storage, FrameworkConfigManager frameworkConfig)
        {
            Resources.AddStore(new DllResourceStore(typeof(TournamentGameBase).Assembly));

            dependencies.CacheAs(tournamentStorage = new TournamentStorage(storage));

            Textures.AddStore(new TextureLoaderStore(tournamentStorage));

            this.storage = storage;

            windowSize = frameworkConfig.GetBindable <Size>(FrameworkSetting.WindowedSize);
            windowSize.BindValueChanged(size => ScheduleAfterChildren(() =>
            {
                var minWidth = (int)(size.NewValue.Height / 768f * TournamentSceneManager.REQUIRED_WIDTH) - 1;

                heightWarning.Alpha = size.NewValue.Width < minWidth ? 1 : 0;
            }), true);

            readBracket();

            ladder.CurrentMatch.Value = ladder.Matches.FirstOrDefault(p => p.Current.Value);

            dependencies.CacheAs <MatchIPCInfo>(ipc = new FileBasedIPC());
            Add(ipc);

            AddRange(new[]
            {
                new Container
                {
                    CornerRadius = 10,
                    Depth        = float.MinValue,
                    Position     = new Vector2(5),
                    Masking      = true,
                    AutoSizeAxes = Axes.Both,
                    Anchor       = Anchor.BottomRight,
                    Origin       = Anchor.BottomRight,
                    Children     = new Drawable[]
                    {
                        new Box
                        {
                            Colour           = OsuColour.Gray(0.2f),
                            RelativeSizeAxes = Axes.Both,
                        },
                        new TourneyButton
                        {
                            Text    = "Save Changes",
                            Width   = 140,
                            Height  = 50,
                            Padding = new MarginPadding
                            {
                                Top  = 10,
                                Left = 10,
                            },
                            Margin = new MarginPadding
                            {
                                Right  = 10,
                                Bottom = 10,
                            },
                            Action = SaveChanges,
                        },
                    }
                },
                heightWarning = new Container
                {
                    Masking      = true,
                    CornerRadius = 5,
                    Depth        = float.MinValue,
                    Anchor       = Anchor.Centre,
                    Origin       = Anchor.Centre,
                    AutoSizeAxes = Axes.Both,
                    Children     = new Drawable[]
                    {
                        new Box
                        {
                            Colour           = Color4.Red,
                            RelativeSizeAxes = Axes.Both,
                        },
                        new TournamentSpriteText
                        {
                            Text    = "Please make the window wider",
                            Font    = OsuFont.Torus.With(weight: FontWeight.Bold),
                            Colour  = Color4.White,
                            Padding = new MarginPadding(20)
                        }
                    }
                },
            });
        }