1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-20 04:23:14 +08:00

Automatically keep window wide enough to display correctly

This commit is contained in:
Dean Herbert 2018-11-06 19:23:16 +09:00
parent ca9df94ea2
commit 3427127589

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Drawing;
using System.IO;
using Newtonsoft.Json;
using osu.Framework.Allocation;
@ -27,16 +28,20 @@ namespace osu.Game.Tournament
[Cached]
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
private Bindable<Size> windowSize;
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
return dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
}
[BackgroundDependencyLoader]
private void load(Storage storage)
private void load(Storage storage, FrameworkConfigManager frameworkConfig)
{
this.storage = storage;
windowSize = frameworkConfig.GetBindable<Size>(FrameworkSetting.WindowedSize);
string content = null;
if (storage.Exists(bracket_filename))
using (Stream stream = storage.GetStream(bracket_filename, FileAccess.Read, FileMode.Open))
@ -81,6 +86,18 @@ namespace osu.Game.Tournament
MenuCursorContainer.Cursor.Alpha = 0;
}
protected override void Update()
{
base.Update();
var minWidth = (int)(windowSize.Value.Height / 9f * 16 + 400);
if (windowSize.Value.Width < minWidth)
{
// todo: can be removed after ppy/osu-framework#1975
windowSize.Value = Host.Window.ClientSize = new Size(minWidth, windowSize.Value.Height);
}
}
protected virtual void SaveChanges()
{
using (var stream = storage.GetStream(bracket_filename, FileAccess.Write, FileMode.Create))