From 0ee38571a651993478435155532f83fa9befaaac Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 6 Mar 2017 17:09:48 +0900 Subject: [PATCH] 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 @@ class OsuGameDesktop : OsuGame { private VersionManager versionManager; - public override bool IsDeployedBuild => versionManager.IsDeployedBuild; - public OsuGameDesktop(string[] args = null) : base(args) { @@ -44,7 +42,7 @@ public override void SetHost(GameHost host) 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.Graphics; using System.Net.Http; using osu.Framework.Logging; +using osu.Game; namespace osu.Desktop.Overlays { @@ -27,16 +28,12 @@ public class VersionManager : OverlayContainer 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 @@ private void load(NotificationManager notification, OsuColour colours, TextureSt 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 @@ private void load(NotificationManager notification, OsuColour colours, TextureSt 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 @@ private void load(NotificationManager notification, OsuColour colours, TextureSt } }; - if (IsDeployedBuild) + if (game.IsDeployedBuild) checkForUpdateAsync(); } @@ -228,6 +214,7 @@ private void load(OsuColour colours) 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 @@ public class OsuGameBase : Framework.Game, IOnlineComponent 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() {