1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:12:54 +08:00

Merge pull request #9247 from MiraiSubject/headless-tournamentgamebase

Move graphics from TournamentGameBase to TournamentGame
This commit is contained in:
Dean Herbert 2020-06-12 11:21:43 +09:00 committed by GitHub
commit 276c9da43f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 89 additions and 95 deletions

View File

@ -1,11 +1,19 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Drawing;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Colour;
using osu.Game.Graphics.Cursor;
using osu.Game.Tournament.Models;
using osu.Game.Graphics;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Tournament
@ -21,19 +29,87 @@ namespace osu.Game.Tournament
public static readonly Color4 ELEMENT_FOREGROUND_COLOUR = Color4Extensions.FromHex("#000");
public static readonly Color4 TEXT_COLOUR = Color4Extensions.FromHex("#fff");
private Drawable heightWarning;
private Bindable<Size> windowSize;
protected override void LoadComplete()
[BackgroundDependencyLoader]
private void load(FrameworkConfigManager frameworkConfig)
{
base.LoadComplete();
Add(new OsuContextMenuContainer
windowSize = frameworkConfig.GetBindable<Size>(FrameworkSetting.WindowedSize);
windowSize.BindValueChanged(size => ScheduleAfterChildren(() =>
{
RelativeSizeAxes = Axes.Both,
Child = new TournamentSceneManager()
});
var minWidth = (int)(size.NewValue.Height / 768f * TournamentSceneManager.REQUIRED_WIDTH) - 1;
// we don't want to show the menu cursor as it would appear on stream output.
MenuCursorContainer.Cursor.Alpha = 0;
heightWarning.Alpha = size.NewValue.Width < minWidth ? 1 : 0;
}), 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 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)
}
}
},
new OsuContextMenuContainer
{
RelativeSizeAxes = Axes.Both,
Child = new TournamentSceneManager()
}
});
}
}
}

View File

@ -2,34 +2,25 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Drawing;
using System.IO;
using System.Linq;
using Newtonsoft.Json;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Textures;
using osu.Framework.Input;
using osu.Framework.IO.Stores;
using osu.Framework.Platform;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Online.API.Requests;
using osu.Game.Tournament.IPC;
using osu.Game.Tournament.Models;
using osu.Game.Users;
using osuTK;
using osuTK.Graphics;
using osuTK.Input;
namespace osu.Game.Tournament
{
[Cached(typeof(TournamentGameBase))]
public abstract class TournamentGameBase : OsuGameBase
public class TournamentGameBase : OsuGameBase
{
private const string bracket_filename = "bracket.json";
@ -40,19 +31,15 @@ namespace osu.Game.Tournament
private TournamentStorage tournamentStorage;
private DependencyContainer dependencies;
private Bindable<Size> windowSize;
private FileBasedIPC ipc;
private Drawable heightWarning;
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
return dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
}
[BackgroundDependencyLoader]
private void load(Storage storage, FrameworkConfigManager frameworkConfig)
private void load(Storage storage)
{
Resources.AddStore(new DllResourceStore(typeof(TournamentGameBase).Assembly));
@ -62,83 +49,12 @@ namespace osu.Game.Tournament
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)
}
}
},
});
}
private void readBracket()
@ -313,6 +229,8 @@ namespace osu.Game.Tournament
protected override void LoadComplete()
{
MenuCursorContainer.Cursor.AlwaysPresent = true; // required for tooltip display
// we don't want to show the menu cursor as it would appear on stream output.
MenuCursorContainer.Cursor.Alpha = 0;
base.LoadComplete();