Basic white-boxing of all game modes.

This commit is contained in:
Dean Herbert 2016-09-29 20:13:58 +09:00
parent 8470961c2a
commit 154226b9a3
19 changed files with 472 additions and 46 deletions

View File

@ -0,0 +1,15 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.GameModes.Charts
{
class ChartInfo : GameModeWhiteBox
{
}
}

View File

@ -0,0 +1,15 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
namespace osu.Game.GameModes.Charts
{
class ChartListing : GameModeWhiteBox
{
protected override IEnumerable<Type> PossibleChildren => new[] {
typeof(ChartInfo)
};
}
}

View File

@ -0,0 +1,9 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
namespace osu.Game.GameModes.Direct
{
class OnlineListing : GameModeWhiteBox
{
}
}

View File

@ -0,0 +1,15 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.GameModes.Edit
{
class Editor : GameModeWhiteBox
{
}
}

View File

@ -0,0 +1,15 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
namespace osu.Game.GameModes.Edit
{
class SongSelectEdit : GameModeWhiteBox
{
protected override IEnumerable<Type> PossibleChildren => new[] {
typeof(Editor)
};
}
}

View File

@ -0,0 +1,138 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using osu.Framework.GameModes;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Drawables;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transformations;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.MathUtils;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.GameModes
{
public class GameModeWhiteBox : GameMode
{
private Button popButton;
const int transition_time = 1000;
protected virtual IEnumerable<Type> PossibleChildren => null;
private FlowContainer childModeButtons;
protected override double OnEntering(GameMode last)
{
//only show the pop button if we are entered form another gamemode.
popButton.Alpha = 1;
MoveTo(new Vector2(ActualSize.X, 0));
MoveTo(Vector2.Zero, transition_time, EasingTypes.OutQuint);
return transition_time;
}
protected override double OnExiting(GameMode next)
{
MoveTo(new Vector2(ActualSize.X, 0), transition_time, EasingTypes.OutQuint);
return transition_time;
}
protected override double OnSuspending(GameMode next)
{
Content.MoveTo(new Vector2(-ActualSize.X, 0), transition_time, EasingTypes.OutQuint);
return transition_time;
}
protected override double OnResuming(GameMode last)
{
Content.MoveTo(Vector2.Zero, transition_time, EasingTypes.OutQuint);
return transition_time;
}
public override void Load()
{
base.Load();
Children = new Drawable[]
{
new Box
{
SizeMode = InheritMode.XY,
Size = new Vector2(1),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Colour = getColourFor(GetType())
},
new SpriteText
{
Text = GetType().Name,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
TextSize = 50,
},
new SpriteText
{
Text = GetType().Namespace,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Position = new Vector2(0, 30)
},
popButton = new Button
{
Text = @"Back",
SizeMode = InheritMode.X,
Size = new Vector2(0.1f, 40),
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Colour = new Color4(235, 51, 153, 255),
Alpha = 0,
Action = delegate {
Exit();
}
},
childModeButtons = new FlowContainer
{
Direction = FlowDirection.VerticalOnly,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
SizeMode = InheritMode.XY,
Size = new Vector2(0.1f, 1)
}
};
if (PossibleChildren != null)
{
foreach (Type t in PossibleChildren)
{
childModeButtons.Add(new Button
{
Text = $@"{t.Name}",
SizeMode = InheritMode.X,
Size = new Vector2(1, 40),
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
Colour = getColourFor(t),
Action = delegate
{
Push(Activator.CreateInstance(t) as GameMode);
}
});
}
}
}
private Color4 getColourFor(Type type)
{
int hash = type.Name.GetHashCode();
byte r = (byte)MathHelper.Clamp(((hash & 0xFF0000) >> 16) * 0.8f, 20, 255);
byte g = (byte)MathHelper.Clamp(((hash & 0x00FF00) >> 8) * 0.8f, 20, 255);
byte b = (byte)MathHelper.Clamp((hash & 0x0000FF) * 0.8f, 20, 255);
return new Color4(r, g, b, 255);
}
}
}

View File

@ -21,6 +21,15 @@ namespace osu.Game.GameModes.Menu
{
public class ButtonSystem : OsuLargeComponent
{
public Action OnEdit;
public Action OnExit;
public Action OnDirect;
public Action OnSolo;
public Action OnSettings;
public Action OnMulti;
public Action OnChart;
public Action OnTest;
private FlowContainerWithOrigin buttonFlow;
const float button_area_height = 128;
@ -71,7 +80,7 @@ namespace osu.Game.GameModes.Menu
Padding = new Vector2(-wedge_width, 0),
Children = new Drawable[]
{
settingsButton = new Button(@"settings", @"options", FontAwesome.gear, new Color4(85, 85, 85, 255), onSettings, -wedge_width, Key.O),
settingsButton = new Button(@"settings", @"options", FontAwesome.gear, new Color4(85, 85, 85, 255), OnSettings, -wedge_width, Key.O),
backButton = new Button(@"back", @"back", FontAwesome.fa_osu_left_o, new Color4(51, 58, 94, 255), onBack, -wedge_width, Key.Escape),
iconFacade = new Container //need a container to make the osu! icon flow properly.
{
@ -91,14 +100,14 @@ namespace osu.Game.GameModes.Menu
buttonFlow.Position = new Vector2(wedge_width * 2 - (button_width + osuLogo.SizeForFlow / 4), 0);
buttonsPlay.Add((Button)buttonFlow.Add(new Button(@"solo", @"freeplay", FontAwesome.user, new Color4(102, 68, 204, 255), onSolo, wedge_width, Key.P)));
buttonsPlay.Add((Button)buttonFlow.Add(new Button(@"multi", @"multiplayer", FontAwesome.users, new Color4(94, 63, 186, 255), onMulti, 0, Key.M)));
buttonsPlay.Add((Button)buttonFlow.Add(new Button(@"chart", @"charts", FontAwesome.fa_osu_charts, new Color4(80, 53, 160, 255), onChart)));
buttonsPlay.Add((Button)buttonFlow.Add(new Button(@"tests", @"tests", FontAwesome.terminal, new Color4(80, 53, 160, 255), onTest, 0, Key.T)));
buttonsPlay.Add((Button)buttonFlow.Add(new Button(@"solo", @"freeplay", FontAwesome.user, new Color4(102, 68, 204, 255), OnSolo, wedge_width, Key.P)));
buttonsPlay.Add((Button)buttonFlow.Add(new Button(@"multi", @"multiplayer", FontAwesome.users, new Color4(94, 63, 186, 255), OnMulti, 0, Key.M)));
buttonsPlay.Add((Button)buttonFlow.Add(new Button(@"chart", @"charts", FontAwesome.fa_osu_charts, new Color4(80, 53, 160, 255), OnChart)));
buttonsPlay.Add((Button)buttonFlow.Add(new Button(@"tests", @"tests", FontAwesome.terminal, new Color4(80, 53, 160, 255), OnTest, 0, Key.T)));
buttonsTopLevel.Add((Button)buttonFlow.Add(new Button(@"play", @"play", FontAwesome.fa_osu_logo, new Color4(102, 68, 204, 255), onPlay, wedge_width, Key.P)));
buttonsTopLevel.Add((Button)buttonFlow.Add(new Button(@"osu!editor", @"edit", FontAwesome.fa_osu_edit_o, new Color4(238, 170, 0, 255), onEdit, 0, Key.E)));
buttonsTopLevel.Add((Button)buttonFlow.Add(new Button(@"osu!direct", @"direct", FontAwesome.fa_osu_chevron_down_o, new Color4(165, 204, 0, 255), onDirect, 0, Key.D)));
buttonsTopLevel.Add((Button)buttonFlow.Add(new Button(@"osu!editor", @"edit", FontAwesome.fa_osu_edit_o, new Color4(238, 170, 0, 255), OnEdit, 0, Key.E)));
buttonsTopLevel.Add((Button)buttonFlow.Add(new Button(@"osu!direct", @"direct", FontAwesome.fa_osu_chevron_down_o, new Color4(165, 204, 0, 255), OnDirect, 0, Key.D)));
buttonsTopLevel.Add((Button)buttonFlow.Add(new Button(@"exit", @"exit", FontAwesome.fa_osu_cross_o, new Color4(238, 51, 153, 255), onExit, 0, Key.Q)));
}
@ -108,31 +117,15 @@ namespace osu.Game.GameModes.Menu
return true;
}
private void onSettings()
{
//OsuGame.Options.LoginOnly = false;
//OsuGame.Options.Expanded = true;
}
private void onPlay()
{
State = MenuState.Play;
}
private void onEdit()
{
//OsuGame.ChangeMode(OsuModes.SelectEdit);
}
private void onDirect()
{
//OsuGame.ChangeMode(OsuModes.OnlineSelection);
}
private void onExit()
{
//OsuGame.ChangeMode(OsuModes.Exit);
State = MenuState.Exit;
OnExit?.Invoke();
}
private void onBack()
@ -140,27 +133,6 @@ namespace osu.Game.GameModes.Menu
State = MenuState.TopLevel;
}
private void onSolo()
{
//OsuGame.ChangeMode(OsuModes.SelectPlay);
}
private void onMulti()
{
//OsuGame.ChangeMode(OsuModes.Lobby);
}
private void onChart()
{
//OsuGame.ChangeMode(OsuModes.Charts);
}
private void onTest()
{
//OsuGame.ChangeMode(OsuModes.FieldTest);
}
private void onOsuLogo()
{
switch (state)

View File

@ -4,7 +4,13 @@
using osu.Framework.Audio.Sample;
using osu.Framework.Audio.Track;
using osu.Framework.GameModes;
using osu.Framework.GameModes.Testing;
using osu.Framework.Graphics;
using osu.Game.GameModes.Charts;
using osu.Game.GameModes.Direct;
using osu.Game.GameModes.Edit;
using osu.Game.GameModes.Multiplayer;
using osu.Game.GameModes.Play;
namespace osu.Game.GameModes.Menu
{
@ -19,10 +25,21 @@ namespace osu.Game.GameModes.Menu
base.Load();
AudioSample welcome = Game.Audio.Sample.Get(@"welcome");
welcome.Play();
Children = new Drawable[]
{
new ButtonSystem(),
new ButtonSystem()
{
OnChart = delegate { Push(new ChartListing()); },
OnDirect = delegate { Push(new OnlineListing()); },
OnEdit = delegate { Push(new SongSelectEdit()); },
OnSolo = delegate { Push(new SongSelectPlay()); },
OnMulti = delegate { Push(new Lobby()); },
OnTest = delegate { Push(new TestBrowser()); },
OnExit = delegate { Game.Host.Exit(); },
OnSettings = delegate { (Game as OsuGame).Options.PoppedOut = !(Game as OsuGame).Options.PoppedOut; },
}
};
}
}

View File

@ -0,0 +1,19 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.GameModes.Multiplayer
{
class Lobby : GameModeWhiteBox
{
protected override IEnumerable<Type> PossibleChildren => new[] {
typeof(MatchCreate),
typeof(Match)
};
}
}

View File

@ -0,0 +1,20 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Game.GameModes.Play;
namespace osu.Game.GameModes.Multiplayer
{
class Match : GameModeWhiteBox
{
protected override IEnumerable<Type> PossibleChildren => new[] {
typeof(MatchSongSelect),
typeof(Player),
};
}
}

View File

@ -0,0 +1,18 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.GameModes.Multiplayer
{
class MatchCreate : GameModeWhiteBox
{
protected override IEnumerable<Type> PossibleChildren => new[] {
typeof(Match)
};
}
}

View File

@ -0,0 +1,15 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.GameModes.Multiplayer
{
class MatchSongSelect : GameModeWhiteBox
{
}
}

View File

@ -0,0 +1,15 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.GameModes.Play
{
class ModSelect : GameModeWhiteBox
{
}
}

View File

@ -0,0 +1,18 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.GameModes.Play
{
class Player : GameModeWhiteBox
{
protected override IEnumerable<Type> PossibleChildren => new[] {
typeof(Results)
};
}
}

View File

@ -0,0 +1,15 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.GameModes.Play
{
class Results : GameModeWhiteBox
{
}
}

View File

@ -0,0 +1,16 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
namespace osu.Game.GameModes.Play
{
class SongSelectPlay : GameModeWhiteBox
{
protected override IEnumerable<Type> PossibleChildren => new[] {
typeof(ModSelect),
typeof(Player)
};
}
}

View File

@ -7,6 +7,7 @@ using osu.Game.Configuration;
using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.Processing;
using osu.Game.Online.API;
using osu.Game.Overlays;
namespace osu.Game
{
@ -16,6 +17,8 @@ namespace osu.Game
protected override string MainResourceFile => @"osu.Game.Resources.dll";
public Options Options;
internal APIAccess API;
protected override Container AddTarget => ratioContainer?.IsLoaded == true ? ratioContainer : base.AddTarget;
@ -45,6 +48,7 @@ namespace osu.Game
{
Children = new Drawable[]
{
Options = new Options(),
new OsuCursorContainer()
}
}

View File

@ -0,0 +1,75 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Drawables;
using osu.Framework.Graphics.Transformations;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Input;
using OpenTK.Input;
namespace osu.Game.Overlays
{
public class Options : Container
{
const float width = 300;
public override void Load()
{
base.Load();
Depth = float.MaxValue;
SizeMode = InheritMode.Y;
Size = new Vector2(width, 1);
Position = new Vector2(-width, 0);
Children = new Drawable[]
{
new Box
{
SizeMode = InheritMode.XY,
Colour = new Color4(0.1f, 0.1f, 0.1f, 0.9f)
}
};
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
switch (args.Key)
{
case Key.Escape:
if (!poppedOut) return false;
PoppedOut = false;
return true;
}
return base.OnKeyDown(state, args);
}
private bool poppedOut;
public bool PoppedOut
{
get { return poppedOut; }
set
{
if (value == poppedOut) return;
poppedOut = value;
if (poppedOut)
{
MoveTo(new Vector2(0, 0), 300, EasingTypes.Out);
}
else
{
MoveTo(new Vector2(-width, 0), 300, EasingTypes.Out);
}
}
}
}
}

View File

@ -46,8 +46,22 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Configuration\OsuConfigManager.cs" />
<Compile Include="GameModes\Charts\ChartInfo.cs" />
<Compile Include="GameModes\Edit\Editor.cs" />
<Compile Include="GameModes\GameModeWhiteBox.cs" />
<Compile Include="GameModes\Menu\ButtonSystem.cs" />
<Compile Include="GameModes\Menu\MainMenu.cs" />
<Compile Include="GameModes\Multiplayer\Lobby.cs" />
<Compile Include="GameModes\Multiplayer\Match.cs" />
<Compile Include="GameModes\Multiplayer\MatchCreate.cs" />
<Compile Include="GameModes\Multiplayer\MatchSongSelect.cs" />
<Compile Include="GameModes\Play\ModSelect.cs" />
<Compile Include="GameModes\Play\Player.cs" />
<Compile Include="GameModes\Charts\ChartListing.cs" />
<Compile Include="GameModes\Play\Results.cs" />
<Compile Include="GameModes\Direct\OnlineListing.cs" />
<Compile Include="GameModes\Play\SongSelectPlay.cs" />
<Compile Include="GameModes\Edit\SongSelectEdit.cs" />
<Compile Include="Graphics\Containers\OsuComponent.cs" />
<Compile Include="Graphics\Containers\OsuGameMode.cs" />
<Compile Include="Graphics\Containers\OsuLargeComponent.cs" />
@ -69,6 +83,7 @@
<Compile Include="Online\Chat\Message.cs" />
<Compile Include="OsuGame.cs" />
<Compile Include="OsuGameBase.cs" />
<Compile Include="Overlays\Options.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>