From 0ee38571a651993478435155532f83fa9befaaac Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 6 Mar 2017 17:09:48 +0900 Subject: [PATCH 1/5] Move version-related properties to OsuGameBase. --- osu.Desktop/OsuGameDesktop.cs | 4 +-- osu.Desktop/Overlays/VersionManager.cs | 27 +++++-------------- osu.Game/OsuGame.cs | 2 -- osu.Game/OsuGameBase.cs | 36 ++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 25 deletions(-) diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index d9b9c31617..3f06b0429e 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -17,8 +17,6 @@ namespace osu.Desktop { private VersionManager versionManager; - public override bool IsDeployedBuild => versionManager.IsDeployedBuild; - public OsuGameDesktop(string[] args = null) : base(args) { @@ -44,7 +42,7 @@ namespace osu.Desktop if (desktopWindow != null) { desktopWindow.Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location); - desktopWindow.Title = @"osu!lazer"; + desktopWindow.Title = Name; desktopWindow.DragEnter += dragEnter; desktopWindow.DragDrop += dragDrop; diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs index 789fbb6af3..42de05df21 100644 --- a/osu.Desktop/Overlays/VersionManager.cs +++ b/osu.Desktop/Overlays/VersionManager.cs @@ -19,6 +19,7 @@ using OpenTK; using OpenTK.Graphics; using System.Net.Http; using osu.Framework.Logging; +using osu.Game; namespace osu.Desktop.Overlays { @@ -27,16 +28,12 @@ namespace osu.Desktop.Overlays private UpdateManager updateManager; private NotificationManager notificationManager; - AssemblyName assembly = Assembly.GetEntryAssembly().GetName(); - - public bool IsDeployedBuild => assembly.Version.Major > 0; - protected override bool HideOnEscape => false; public override bool HandleInput => false; [BackgroundDependencyLoader] - private void load(NotificationManager notification, OsuColour colours, TextureStore textures) + private void load(NotificationManager notification, OsuColour colours, TextureStore textures, OsuGameBase game) { notificationManager = notification; @@ -45,17 +42,6 @@ namespace osu.Desktop.Overlays Origin = Anchor.BottomCentre; Alpha = 0; - bool isDebug = false; - Debug.Assert(isDebug = true); - - string version; - if (!IsDeployedBuild) - { - version = @"local " + (isDebug ? @"debug" : @"release"); - } - else - version = $@"{assembly.Version.Major}.{assembly.Version.Minor}.{assembly.Version.Build}"; - Children = new Drawable[] { new FillFlowContainer @@ -76,12 +62,12 @@ namespace osu.Desktop.Overlays new OsuSpriteText { Font = @"Exo2.0-Bold", - Text = $@"osu!lazer" + Text = game.Name }, new OsuSpriteText { - Colour = isDebug ? colours.Red : Color4.White, - Text = version + Colour = game.IsDebug ? colours.Red : Color4.White, + Text = game.Version }, } }, @@ -104,7 +90,7 @@ namespace osu.Desktop.Overlays } }; - if (IsDeployedBuild) + if (game.IsDeployedBuild) checkForUpdateAsync(); } @@ -228,6 +214,7 @@ namespace osu.Desktop.Overlays new TextAwesome { Anchor = Anchor.Centre, + Origin = Anchor.Centre, Icon = FontAwesome.fa_upload, Colour = Color4.White, } diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 9f7e3e04dc..98bb70c2c5 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -32,8 +32,6 @@ namespace osu.Game { public class OsuGame : OsuGameBase { - public virtual bool IsDeployedBuild => false; - public Toolbar Toolbar; private ChatOverlay chat; diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 1c34743567..10373e584b 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -1,6 +1,8 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Diagnostics; +using System.Reflection; using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; @@ -37,6 +39,40 @@ namespace osu.Game public readonly Bindable Beatmap = new Bindable(); + protected AssemblyName AssemblyName => Assembly.GetEntryAssembly().GetName(); + + public bool IsDeployedBuild => AssemblyName.Version.Major > 0; + + public bool IsDebug + { + get + { + bool isDebug = false; + Debug.Assert(isDebug = true); + return isDebug; + } + } + + public string Version + { + get + { + bool isDebug = false; + Debug.Assert(isDebug = true); + + if (!IsDeployedBuild) + return @"local " + (isDebug ? @"debug" : @"release"); + + var assembly = AssemblyName; + return $@"{assembly.Version.Major}.{assembly.Version.Minor}.{assembly.Version.Build}"; + } + } + + public OsuGameBase() + { + Name = @"osu!lazer"; + } + [BackgroundDependencyLoader] private void load() { From b5aff9df5ffe36792cd44ea7732be647d7347bfe Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 6 Mar 2017 17:20:19 +0900 Subject: [PATCH 2/5] Add options footer. --- osu.Game/Overlays/Options/OptionsFooter.cs | 68 +++++++++++++++++++ .../Options/Sections/MaintenanceSection.cs | 14 ---- osu.Game/Overlays/OptionsOverlay.cs | 3 +- osu.Game/osu.Game.csproj | 1 + 4 files changed, 71 insertions(+), 15 deletions(-) create mode 100644 osu.Game/Overlays/Options/OptionsFooter.cs diff --git a/osu.Game/Overlays/Options/OptionsFooter.cs b/osu.Game/Overlays/Options/OptionsFooter.cs new file mode 100644 index 0000000000..23622aef08 --- /dev/null +++ b/osu.Game/Overlays/Options/OptionsFooter.cs @@ -0,0 +1,68 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Modes; +using OpenTK; +using OpenTK.Graphics; + +namespace osu.Game.Overlays.Options +{ + public class OptionsFooter : FillFlowContainer + { + [BackgroundDependencyLoader] + private void load(OsuGameBase game, OsuColour colours) + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + Direction = FillDirection.Vertical; + Padding = new MarginPadding { Top = 20, Bottom = 30 }; + + var modes = new List(); + + foreach (PlayMode m in Enum.GetValues(typeof(PlayMode))) + modes.Add(new TextAwesome + { + Icon = Ruleset.GetRuleset(m).Icon, + Colour = Color4.Gray, + }); + + Children = new Drawable[] + { + new FillFlowContainer + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Direction = FillDirection.Full, + AutoSizeAxes = Axes.Both, + Children = modes, + Spacing = new Vector2(5), + Padding = new MarginPadding { Bottom = 10 }, + }, + new OsuSpriteText + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Text = game.Name, + TextSize = 18, + Font = @"Exo2.0-Bold", + }, + new OsuSpriteText + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + TextSize = 14, + Text = game.Version, + Colour = game.IsDebug ? colours.Red : Color4.White, + }, + }; + } + } +} \ No newline at end of file diff --git a/osu.Game/Overlays/Options/Sections/MaintenanceSection.cs b/osu.Game/Overlays/Options/Sections/MaintenanceSection.cs index 6aa9b66f5c..30695eb963 100644 --- a/osu.Game/Overlays/Options/Sections/MaintenanceSection.cs +++ b/osu.Game/Overlays/Options/Sections/MaintenanceSection.cs @@ -39,20 +39,6 @@ namespace osu.Game.Overlays.Options.Sections RelativeSizeAxes = Axes.X, Text = "Run osu! updater", }, - new Container - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Children = new[] - { - new OptionLabel - { - Text = "osu!lazer", - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - }, - } - } }; } } diff --git a/osu.Game/Overlays/OptionsOverlay.cs b/osu.Game/Overlays/OptionsOverlay.cs index 89a2d029f6..04048dcf98 100644 --- a/osu.Game/Overlays/OptionsOverlay.cs +++ b/osu.Game/Overlays/OptionsOverlay.cs @@ -100,7 +100,8 @@ namespace osu.Game.Overlays RelativeSizeAxes = Axes.X, Direction = FillDirection.Vertical, Children = sections, - } + }, + new OptionsFooter() } } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index cf98450307..f38c2f7ba0 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -120,6 +120,7 @@ + From 1e48b0a03703fac0efe57fd941c83230b5f7bf7b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 6 Mar 2017 18:36:46 +0900 Subject: [PATCH 3/5] Ensure AssemblyName is never null (seems to be on CI server). --- osu.Game/OsuGameBase.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 10373e584b..77de2a176e 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using System.Diagnostics; using System.Reflection; using osu.Framework.Allocation; @@ -39,7 +40,7 @@ namespace osu.Game public readonly Bindable Beatmap = new Bindable(); - protected AssemblyName AssemblyName => Assembly.GetEntryAssembly().GetName(); + protected AssemblyName AssemblyName => Assembly.GetEntryAssembly()?.GetName() ?? new AssemblyName() { Version = new Version() }; public bool IsDeployedBuild => AssemblyName.Version.Major > 0; From 9fd16be2d44f79ba43f21ae297adcfdf11c3b090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Mon, 6 Mar 2017 19:59:29 +0100 Subject: [PATCH 4/5] Refactor IsDebug --- osu.Game/OsuGameBase.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 77de2a176e..c592ded666 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -49,6 +49,7 @@ namespace osu.Game get { bool isDebug = false; + // Debug.Assert conditions are only evaluated in debug mode Debug.Assert(isDebug = true); return isDebug; } @@ -58,11 +59,8 @@ namespace osu.Game { get { - bool isDebug = false; - Debug.Assert(isDebug = true); - if (!IsDeployedBuild) - return @"local " + (isDebug ? @"debug" : @"release"); + return @"local " + (IsDebug ? @"debug" : @"release"); var assembly = AssemblyName; return $@"{assembly.Version.Major}.{assembly.Version.Minor}.{assembly.Version.Build}"; From 1fdf865c885f7ac0ddbe18711094905ae3ca7101 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Mon, 6 Mar 2017 20:01:36 +0100 Subject: [PATCH 5/5] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 169f0a758c..460a8ce5a4 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 169f0a758c6b565ee42832f99bf4b5303f4413a6 +Subproject commit 460a8ce5a4bcdb64d87725012cb18fbdb7c38f21