mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 22:56:36 +09:00
Make a RulesetDatabase.
This commit is contained in:
@ -8,8 +8,8 @@ using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Modes;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Overlays.Toolbar
|
||||
@ -20,7 +20,7 @@ namespace osu.Game.Overlays.Toolbar
|
||||
public const float TOOLTIP_HEIGHT = 30;
|
||||
|
||||
public Action OnHome;
|
||||
public Action<Ruleset> OnRulesetChange;
|
||||
public Action<RulesetInfo> OnRulesetChange;
|
||||
|
||||
private readonly ToolbarModeSelector modeSelector;
|
||||
private readonly ToolbarUserArea userArea;
|
||||
@ -129,7 +129,7 @@ namespace osu.Game.Overlays.Toolbar
|
||||
}
|
||||
}
|
||||
|
||||
public void SetGameMode(Ruleset ruleset) => modeSelector.SetGameMode(ruleset);
|
||||
public void SetGameMode(RulesetInfo ruleset) => modeSelector.SetGameMode(ruleset);
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
|
@ -2,23 +2,26 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Modes;
|
||||
using osu.Game.Database;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.Toolbar
|
||||
{
|
||||
public class ToolbarModeButton : ToolbarButton
|
||||
{
|
||||
private Ruleset ruleset;
|
||||
public Ruleset Ruleset
|
||||
private RulesetInfo ruleset;
|
||||
public RulesetInfo Ruleset
|
||||
{
|
||||
get { return ruleset; }
|
||||
set
|
||||
{
|
||||
ruleset = value;
|
||||
TooltipMain = ruleset.Description;
|
||||
TooltipSub = $"Play some {ruleset.Description}";
|
||||
Icon = ruleset.Icon;
|
||||
|
||||
var rInstance = ruleset.CreateInstance();
|
||||
|
||||
TooltipMain = rInstance.Description;
|
||||
TooltipSub = $"Play some {rInstance.Description}";
|
||||
Icon = rInstance.Icon;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,12 +3,13 @@
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Caching;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Modes;
|
||||
using osu.Game.Database;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
@ -22,7 +23,7 @@ namespace osu.Game.Overlays.Toolbar
|
||||
private readonly Drawable modeButtonLine;
|
||||
private ToolbarModeButton activeButton;
|
||||
|
||||
public Action<Ruleset> OnRulesetChange;
|
||||
public Action<RulesetInfo> OnRulesetChange;
|
||||
|
||||
public ToolbarModeSelector()
|
||||
{
|
||||
@ -62,8 +63,12 @@ namespace osu.Game.Overlays.Toolbar
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
foreach (var ruleset in RulesetCollection.AllRulesets)
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(RulesetDatabase rulesets)
|
||||
{
|
||||
foreach (var ruleset in rulesets.AllRulesets)
|
||||
{
|
||||
modeButtons.Add(new ToolbarModeButton
|
||||
{
|
||||
@ -84,11 +89,11 @@ namespace osu.Game.Overlays.Toolbar
|
||||
Size = new Vector2(modeButtons.DrawSize.X, 1);
|
||||
}
|
||||
|
||||
public void SetGameMode(Ruleset ruleset)
|
||||
public void SetGameMode(RulesetInfo ruleset)
|
||||
{
|
||||
foreach (ToolbarModeButton m in modeButtons.Children.Cast<ToolbarModeButton>())
|
||||
{
|
||||
bool isActive = m.Ruleset == ruleset;
|
||||
bool isActive = m.Ruleset.ID == ruleset.ID;
|
||||
m.Active = isActive;
|
||||
if (isActive)
|
||||
activeButton = m;
|
||||
|
Reference in New Issue
Block a user