From 353bc0ddf70453e228c3d3bc072b04a775a06abd Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Mon, 29 Aug 2016 20:37:48 +1000 Subject: [PATCH 01/49] Default Online setting for OnsetDetector to false --- src/TurntNinja/App.config | 154 +++++++++--------- .../Properties/Settings.Designer.cs | 2 +- src/TurntNinja/Properties/Settings.settings | 2 +- 3 files changed, 79 insertions(+), 79 deletions(-) diff --git a/src/TurntNinja/App.config b/src/TurntNinja/App.config index 1dd4375..d523b46 100644 --- a/src/TurntNinja/App.config +++ b/src/TurntNinja/App.config @@ -32,86 +32,86 @@ - - 0 - - - 1 - - - 1280 - - - 720 - - - 4 - - - True - - - Normal - - - 9 - - - False - - - 50 - - - 0 - - - True - - - 0.2 - - - 10 - - - False - - - True - - - turnt-ninja.db - - - opcon - - - - - - False - - - True - - + + 0 + + + 1 + + + 1280 + + + 720 + + + 4 + + + True + + + Normal + + + 9 + + + False + + + 50 + + + 0 + + + False + + + 0.2 + + + 10 + + + False + + + True + + + turnt-ninja.db + + + opcon + + + + + + False + + + True + + - - .mp3,.flac,.wav,.m4a,.wma - - - turnt-ninja - - - oeoywrZVrjYlcctPZZ3uTXFPp9ItVUkR3w28u+WDdd9SqYzE1PRkb+WPZsYQ+VvOfUjFQOlQ1tXc7oDXY4Km7A== - - - jA9OAo1hWfHPOoMipHAAaFxFf2N7iP8zuBEI9LVQq5ET0vc8yqnLsO/oNMqCcki0rvD4CQrkMz7fWHQ4rWuHAyRfY+7nxGinxdbgIaceyVtKOJLsSnbBh4/NBq3OkBIAFG2GTxUhWqyJbxNhgzbu+0HM8jv43LY53bxhwIALt+A= - - + + .mp3,.flac,.wav,.m4a,.wma + + + turnt-ninja + + + oeoywrZVrjYlcctPZZ3uTXFPp9ItVUkR3w28u+WDdd9SqYzE1PRkb+WPZsYQ+VvOfUjFQOlQ1tXc7oDXY4Km7A== + + + jA9OAo1hWfHPOoMipHAAaFxFf2N7iP8zuBEI9LVQq5ET0vc8yqnLsO/oNMqCcki0rvD4CQrkMz7fWHQ4rWuHAyRfY+7nxGinxdbgIaceyVtKOJLsSnbBh4/NBq3OkBIAFG2GTxUhWqyJbxNhgzbu+0HM8jv43LY53bxhwIALt+A= + + diff --git a/src/TurntNinja/Properties/Settings.Designer.cs b/src/TurntNinja/Properties/Settings.Designer.cs index 217772d..8cbc0c3 100644 --- a/src/TurntNinja/Properties/Settings.Designer.cs +++ b/src/TurntNinja/Properties/Settings.Designer.cs @@ -175,7 +175,7 @@ public int DifficultyLevel { [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("True")] + [global::System.Configuration.DefaultSettingValueAttribute("False")] public bool OnsetOnline { get { return ((bool)(this["OnsetOnline"])); diff --git a/src/TurntNinja/Properties/Settings.settings b/src/TurntNinja/Properties/Settings.settings index 2d0d74e..e3412cc 100644 --- a/src/TurntNinja/Properties/Settings.settings +++ b/src/TurntNinja/Properties/Settings.settings @@ -42,7 +42,7 @@ 0 - True + False 0.2 From dc473768e310f284856a310cebf5d2d6ea96d3ce Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Mon, 29 Aug 2016 20:38:16 +1000 Subject: [PATCH 02/49] Change analysing song wording --- src/TurntNinja/Audio/AudioFeatures.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TurntNinja/Audio/AudioFeatures.cs b/src/TurntNinja/Audio/AudioFeatures.cs index 705f6d7..8308eb1 100644 --- a/src/TurntNinja/Audio/AudioFeatures.cs +++ b/src/TurntNinja/Audio/AudioFeatures.cs @@ -46,7 +46,7 @@ public bool SongAnalysed(string audioPath) public void Extract(CSCore.IWaveSource audioSource, Song s) { - _currentTask = "Extracting Onsets"; + _currentTask = "Analysing Song..."; List onsets; if (SongAnalysed(s.SongBase.InternalName)) From bdf851f21fb4b8803b4484190c581a27b7aee945 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Mon, 29 Aug 2016 20:42:12 +1000 Subject: [PATCH 03/49] Change geometry builder to have a percentage chance of producing large chunks --- src/TurntNinja/Generation/StageGeometryBuilder.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/TurntNinja/Generation/StageGeometryBuilder.cs b/src/TurntNinja/Generation/StageGeometryBuilder.cs index f0fb915..6f96ac1 100644 --- a/src/TurntNinja/Generation/StageGeometryBuilder.cs +++ b/src/TurntNinja/Generation/StageGeometryBuilder.cs @@ -113,6 +113,8 @@ private void BuildGeometry() float samePatternChance = 0.90f; float onsetStart = 0.0f; float onsetEnd = 0.0f; + float veryCloseJoinChance = 0.5f; + float joinFunctionMultiplier = 20.0f; bool[] sides; @@ -125,7 +127,9 @@ private void BuildGeometry() foreach (var b in _goodBeats) { // are we extending an existing structure? - if (b - prevTime < _builderOptions.VeryCloseDistance) + double t = Math.Exp(-joinFunctionMultiplier*(b - prevTime - _builderOptions.VeryCloseDistance) + Math.Log(veryCloseJoinChance)); + Console.WriteLine(t); + if (_random.NextDouble() < t) { structures[currentStructureIndex].End = b; } From e3dc33ba405e0798c15dba5ac3b865292d9000a5 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Mon, 29 Aug 2016 20:42:54 +1000 Subject: [PATCH 04/49] Remove extra rotation on beat --- src/TurntNinja/Game/StageGeometry.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TurntNinja/Game/StageGeometry.cs b/src/TurntNinja/Game/StageGeometry.cs index 1f081be..0e8aea9 100644 --- a/src/TurntNinja/Game/StageGeometry.cs +++ b/src/TurntNinja/Game/StageGeometry.cs @@ -114,8 +114,8 @@ public void Update(double time) CenterPolygon.PulseMultiplier = Onsets.PulseDataCollection[CurrentOnset].PulseMultiplier; ParentStage.SceneManager.ScreenCamera.ExtraScale = CenterPolygon.Pulsing ? (float)Math.Pow(Onsets.BeatFrequencies[CurrentOnset],3) * 0.2f : 0; - if (Onsets.CloseToNextOnset(CurrentOnset, 0.01f)) - _extraRotation = 0.005f; + //if (Onsets.CloseToNextOnset(CurrentOnset, 0.01f)) + // _extraRotation = 0.005f; if (ParentStage.AI) { From de9455761479dabb0fafa83ce7d0964c7d97bcb5 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Mon, 29 Aug 2016 20:43:27 +1000 Subject: [PATCH 05/49] Add chance to swap foreground and background colours Also improved colour updating in general --- src/TurntNinja/Game/StageGeometry.cs | 37 ++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/src/TurntNinja/Game/StageGeometry.cs b/src/TurntNinja/Game/StageGeometry.cs index 0e8aea9..1ccb997 100644 --- a/src/TurntNinja/Game/StageGeometry.cs +++ b/src/TurntNinja/Game/StageGeometry.cs @@ -24,6 +24,7 @@ class StageGeometry : IDisposable private double _initialHue; private double _extraHue = 0.0; private double _hueWobbleAmount = 30; + private bool _swapColours = false; private HUSLColor _baseColour; public Stage ParentStage; @@ -166,8 +167,8 @@ public void Update(double time) BackgroundPolygon.Position.Azimuth = CenterPolygon.Position.Azimuth; BackgroundPolygon.Update(time, false); - if (frameCount == 10) - UpdateColours(time); + //if (frameCount == 2) + UpdateColours(time); } @@ -294,12 +295,15 @@ public void UpdateColours(double time) } //_baseColour.H += time*50f*(!OutOfBeats ? BeatFrequencies[_beats.Index] : 1); - if (CurrentOnset - _previousBeat > 3) - { - _previousBeat = CurrentOnset; - _extraHue = ((_random.NextDouble() > 0.5) ? -1 : 1) * (90 + (_hueWobbleAmount * _random.NextDouble() - _hueWobbleAmount / 2)); + bool swapColours = false; + + // Only update colours if more than 3 beats have passed since last time + if (CurrentOnset - _previousBeat < 3) return; + + _previousBeat = CurrentOnset; + _extraHue = ((_random.NextDouble() > 0.5) ? -1 : 1) * (90 + (_hueWobbleAmount * _random.NextDouble() - _hueWobbleAmount / 2)); + _swapColours = (_random.NextDouble() > 0.95) ? !_swapColours : _swapColours; - } _baseColour.H = _initialHue + (CurrentOnset) * 5; _baseColour.L = ColourModifiers.baseLightness; _baseColour.S = ColourModifiers.baseSaturation; @@ -345,6 +349,25 @@ public void UpdateColours(double time) _colours.EvenOutlineColour = HUSLColor.ToColor4(GetOutlineColour(fEven)); _colours.OddOpposingColour = HUSLColor.ToColor4(fOdd); _colours.OddOutlineColour = HUSLColor.ToColor4(GetOutlineColour(fOdd)); + + // Black and White + //_colours.EvenOpposingColour = _colours.OddOpposingColour = Color4.Black; + //_colours.EvenBackgroundColour = _colours.OddBackgroundColour = Color4.White; + //_colours.OddOutlineColour = _colours.EvenOutlineColour = Color4.White; + + // Swap colours if required + if (_swapColours) + { + // Handle outlines for black and white + // _colours.OddOutlineColour = _colours.EvenOutlineColour = Color4.Black; + + var t1 = _colours.EvenBackgroundColour; + var t2 = _colours.OddBackgroundColour; + _colours.EvenBackgroundColour = _colours.OddOpposingColour; + _colours.OddBackgroundColour = _colours.EvenOpposingColour; + _colours.EvenOpposingColour = t2; + _colours.OddOpposingColour = t1; + } } From a6204a08d41f1f9429d8a3b6a0a8bd7dfe25781b Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Mon, 29 Aug 2016 20:43:49 +1000 Subject: [PATCH 06/49] Sey minimum time delta for onset detection to 5 milliseconds --- src/TurntNinja/Game/Stage.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/TurntNinja/Game/Stage.cs b/src/TurntNinja/Game/Stage.cs index 62954a7..c709136 100644 --- a/src/TurntNinja/Game/Stage.cs +++ b/src/TurntNinja/Game/Stage.cs @@ -165,6 +165,7 @@ public void LoadAsync(Song song, float audioCorrection, float maxAudioVolume, IP private void LoadAudioFeatures(CSCore.IWaveSource audioSource, float correction, IProgress progress, Song s) { var options = DetectorOptions.Default; + options.MinimumTimeDelta = 5f; options.ActivationThreshold = (float)SceneManager.GameSettings["OnsetActivationThreshold"]; options.AdaptiveWhitening = (bool)SceneManager.GameSettings["OnsetAdaptiveWhitening"]; options.Online = (bool)SceneManager.GameSettings["OnsetOnline"]; From 0c520c24a5303d5a9139419c5de59de9d06dd057 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Wed, 31 Aug 2016 14:56:28 +1000 Subject: [PATCH 07/49] Bump version number to 0.13 --- src/TurntNinja/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TurntNinja/Properties/AssemblyInfo.cs b/src/TurntNinja/Properties/AssemblyInfo.cs index fb55a4c..d92d031 100644 --- a/src/TurntNinja/Properties/AssemblyInfo.cs +++ b/src/TurntNinja/Properties/AssemblyInfo.cs @@ -32,4 +32,4 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.12.*")] +[assembly: AssemblyVersion("0.13.*")] From f55354b4732924dd9c7dba8262804cf42e06f0b0 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Wed, 31 Aug 2016 14:58:42 +1000 Subject: [PATCH 08/49] Update packages --- paket.lock | 16 +++++----- src/TurntNinja/App.config | 45 ++++++++++++++++------------- src/TurntNinja/SharpFont.dll.config | 5 ---- src/TurntNinja/TurntNinja.csproj | 9 +++--- 4 files changed, 38 insertions(+), 37 deletions(-) delete mode 100644 src/TurntNinja/SharpFont.dll.config diff --git a/paket.lock b/paket.lock index a64aed5..1266772 100644 --- a/paket.lock +++ b/paket.lock @@ -5,11 +5,13 @@ NUGET ColorMine (1.1.3) - framework: >= net45 DeltaCompressionDotNet (1.0) - framework: >= net45 HUSL (1.0.1) - framework: >= net45 - LiteDB (2.0) - framework: >= net45 + LiteDB (2.0.2) - framework: >= net45 MathNet.Numerics (3.13) - framework: >= net45 Mono.Cecil (0.9.6.1) - framework: >= net45 Newtonsoft.Json (9.0.1) NuGet.CommandLine (3.4.3) + SharpFont (4.0.1) - framework: >= net45 + SharpFont.Dependencies SharpRaven (2.1) Newtonsoft.Json (>= 6.0.6) Splat (1.6.2) - framework: >= net45 @@ -19,9 +21,9 @@ NUGET Splat (>= 1.6.2) TagLib.Portable (1.0.4) - framework: >= net45 remote: https://ci.appveyor.com/nuget/cscore-lt381sf5ht3e - CSCore (1.1.24) - CSCore.OSX (1.1.24) - CSCore (>= 1.1.24) + CSCore (1.1.29) + CSCore.OSX (1.1.29) + CSCore (>= 1.1.29) remote: https://ci.appveyor.com/nuget/gwen-nolegacy-opentk-renderer-y8bf4l8s9nxo Gwen (3.0.6026.7037) - framework: >= net45 OpenTK.Next (>= 1.1.1616.8959) @@ -41,19 +43,17 @@ NUGET OpenTK.Next (>= 1.1.1616.8959) SharpFont (>= 3.1) SharpFont.Dependencies (>= 2.6) - SharpFont (3.1.0) - framework: >= net45 - SharpFont.Dependencies SharpFont.Dependencies (2.6) - framework: >= net45 GROUP Build NUGET remote: https://www.nuget.org/api/v2 - FAKE (4.38) + FAKE (4.39) GROUP Deploy NUGET remote: https://www.nuget.org/api/v2 - ILRepack (2.0.10) + ILRepack (2.0.11) Microsoft.Data.Edm (5.6.1) Microsoft.Data.OData (5.6.1) Microsoft.Data.Edm (5.6.1) diff --git a/src/TurntNinja/App.config b/src/TurntNinja/App.config index d523b46..5791520 100644 --- a/src/TurntNinja/App.config +++ b/src/TurntNinja/App.config @@ -1,10 +1,10 @@  - +
- +
@@ -12,24 +12,29 @@ - - - True - - - - - True - - - - - True - - - - - + + + + True + + + + + True + + + + + True + + + + + True + + + + diff --git a/src/TurntNinja/SharpFont.dll.config b/src/TurntNinja/SharpFont.dll.config deleted file mode 100644 index c108ab7..0000000 --- a/src/TurntNinja/SharpFont.dll.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/src/TurntNinja/TurntNinja.csproj b/src/TurntNinja/TurntNinja.csproj index 7da46e1..c877831 100644 --- a/src/TurntNinja/TurntNinja.csproj +++ b/src/TurntNinja/TurntNinja.csproj @@ -132,6 +132,10 @@ Settings.Designer.cs Designer + + SharpFont.dll.config + Always + @@ -161,9 +165,6 @@ True - - Always - @@ -440,7 +441,7 @@ - ..\..\packages\SharpFont\lib\net20\SharpFont.dll + ..\..\packages\SharpFont\lib\net45\SharpFont.dll True True From 5ca03ebff119ca90014739f7221eaea8c9028fa4 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Wed, 31 Aug 2016 14:58:59 +1000 Subject: [PATCH 09/49] Remove debugging print in StageGeometryBuilder --- src/TurntNinja/Generation/StageGeometryBuilder.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/TurntNinja/Generation/StageGeometryBuilder.cs b/src/TurntNinja/Generation/StageGeometryBuilder.cs index 6f96ac1..6a75191 100644 --- a/src/TurntNinja/Generation/StageGeometryBuilder.cs +++ b/src/TurntNinja/Generation/StageGeometryBuilder.cs @@ -128,7 +128,6 @@ private void BuildGeometry() { // are we extending an existing structure? double t = Math.Exp(-joinFunctionMultiplier*(b - prevTime - _builderOptions.VeryCloseDistance) + Math.Log(veryCloseJoinChance)); - Console.WriteLine(t); if (_random.NextDouble() < t) { structures[currentStructureIndex].End = b; From a747427d62ddf708ce29a2a711fd188b1717b69a Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Wed, 31 Aug 2016 14:59:13 +1000 Subject: [PATCH 10/49] Add async error reporting methods --- .../Logging/SentryErrorReporting.cs | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/TurntNinja/Logging/SentryErrorReporting.cs b/src/TurntNinja/Logging/SentryErrorReporting.cs index 8323ea6..f961b72 100644 --- a/src/TurntNinja/Logging/SentryErrorReporting.cs +++ b/src/TurntNinja/Logging/SentryErrorReporting.cs @@ -32,20 +32,40 @@ public SentryErrorReporting(string sentryURL, string environment, string version private void InitialiseSentryClient() { - _sentryClient = new RavenClient(_sentryDsn, null, null, new SentryUserGUIDFactory(_userGUID)); + _sentryClient = new RavenClient(_sentryDsn, new CustomJsonPacketFactory(), null, new SentryUserGUIDFactory(_userGUID)); } public string ReportError(Exception ex) { - var sentryEvent = new SentryEvent(ex); - return _sentryClient.Capture(sentryEvent); + return ReportErrorAsync(ex).Result; } public string ReportMessage(string message) + { + return ReportMessageAsync(message).Result; + } + + public Task ReportErrorAsync(Exception ex) + { + var sentryEvent = new SentryEvent(ex); + return _sentryClient.CaptureAsync(sentryEvent); + } + + public Task ReportMessageAsync(string message) { var sentryMessage = new SentryMessage(message); var sentryEvent = new SentryEvent(sentryMessage); - return _sentryClient.Capture(sentryEvent); + return _sentryClient.CaptureAsync(sentryEvent); + } + } + + class CustomJsonPacketFactory : JsonPacketFactory + { + protected override JsonPacket OnCreate(JsonPacket jsonPacket) + { + // Scrub servername from the json packet since we don't need it + jsonPacket.ServerName = ""; + return jsonPacket; } } From a8d1b5897a4d5aa1d62d6538cbd65422f602c583 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Wed, 31 Aug 2016 19:10:07 +1000 Subject: [PATCH 11/49] Reset Player to Play position for main menu --- src/TurntNinja/GUI/MenuScene.cs | 1 + src/TurntNinja/Game/Player.cs | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/TurntNinja/GUI/MenuScene.cs b/src/TurntNinja/GUI/MenuScene.cs index e795827..ac656b1 100644 --- a/src/TurntNinja/GUI/MenuScene.cs +++ b/src/TurntNinja/GUI/MenuScene.cs @@ -60,6 +60,7 @@ public override void Load() _shaderProgram.Load(vert, frag); _player = new Player(); + _player.Position = new PolarVector(1.5 * (Math.PI / 3) - _player.Length * 0.5f, _player.Position.Radius); _player.ShaderProgram = _shaderProgram; _centerPolygon = new PolarPolygon(Enumerable.Repeat(true, 6).ToList(), new PolarVector(0.5, 0), 50, 80, 0); _centerPolygon.ShaderProgram = _shaderProgram; diff --git a/src/TurntNinja/Game/Player.cs b/src/TurntNinja/Game/Player.cs index c581f8f..7f47931 100644 --- a/src/TurntNinja/Game/Player.cs +++ b/src/TurntNinja/Game/Player.cs @@ -67,12 +67,16 @@ public PolarVector Velocity private Input _currentFramesInput; private ShaderProgram _shaderProgram; + const float PLAYER_RADIUS = 180f; + const float PLAYER_WIDTH = 20; + const float PLAYER_LENGTH_DEGREES = 10; + public Player() { - _position = new PolarVector(0, 180); + _length = MathHelper.DegreesToRadians(PLAYER_LENGTH_DEGREES); + _width = PLAYER_WIDTH; + _position = new PolarVector(1.5 * (Math.PI / 3) - _length * 0.5f, PLAYER_RADIUS); _velocity = new PolarVector(-9, 0); - _length = (10) * (0.0174533); - _width = 20; Direction = 1; UseGamePad = false; } @@ -131,6 +135,7 @@ public void Reset() { Score = 0; Hits = 0; + _position = new PolarVector(1.5 * (Math.PI / 3) - _length * 0.5f, PLAYER_RADIUS); } public List GetBounds() From 79b96b2eb1a8d07b8ded9d0cba745b8c554599e3 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Wed, 31 Aug 2016 19:10:16 +1000 Subject: [PATCH 12/49] Remove mouse control from main menu --- src/TurntNinja/GUI/MenuScene.cs | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/TurntNinja/GUI/MenuScene.cs b/src/TurntNinja/GUI/MenuScene.cs index ac656b1..848a8ff 100644 --- a/src/TurntNinja/GUI/MenuScene.cs +++ b/src/TurntNinja/GUI/MenuScene.cs @@ -77,9 +77,6 @@ public override void Load() skin.DefaultFont = new Gwen.Font(guiRenderer, SceneManager.FontPath, 30); _GUIComponents = new GUIComponentContainer(guiRenderer, skin); - var desiredCoords = SceneManager.GameWindow.PointToScreen(new Point(WindowWidth/2, WindowHeight/8)); - Mouse.SetPosition(desiredCoords.X, desiredCoords.Y); - Loaded = true; } @@ -151,12 +148,6 @@ private int GetSelectedSide() private void DoGUI() { - //are we using the mouse to navigate? - if (InputSystem.HasMouseMoved) - { - _player.Position = new PolarVector(Math.Atan2(-InputSystem.MouseXY.Y + SceneManager.Height/2.0f, InputSystem.MouseXY.X - SceneManager.Width / 2.0f) - _player.Length*0.5f, _player.Position.Radius); - } - int selectedSide = GetSelectedSide(); if (_selectedMenuItem != (MainMenuOptions) selectedSide) _selectedItemChanged = true; _selectedMenuItem = (MainMenuOptions) selectedSide; @@ -181,7 +172,6 @@ private void DoGUI() case MainMenuOptions.ComingSoon: _selectedMenuItemText = "Coming Soon"; break; - case MainMenuOptions.None: default: _selectedMenuItem = MainMenuOptions.None; _selectedMenuItemText = ""; @@ -189,7 +179,7 @@ private void DoGUI() } // we have selected the current menu item - if (InputSystem.NewKeys.Contains(Key.Enter) || InputSystem.ReleasedButtons.Contains(MouseButton.Left)) + if (InputSystem.NewKeys.Contains(Key.Enter)) { switch (_selectedMenuItem) { @@ -211,9 +201,6 @@ private void DoGUI() case MainMenuOptions.Update: SceneManager.AddScene(new UpdateScene(), this); break; - case MainMenuOptions.None: - default: - break; } } } From b42009ec41d04369f21d35d346293924fba249fa Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Wed, 31 Aug 2016 19:10:22 +1000 Subject: [PATCH 13/49] Remove unused code --- src/TurntNinja/Game/Stage.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/TurntNinja/Game/Stage.cs b/src/TurntNinja/Game/Stage.cs index c709136..4a19af4 100644 --- a/src/TurntNinja/Game/Stage.cs +++ b/src/TurntNinja/Game/Stage.cs @@ -265,7 +265,6 @@ public void Dispose() MultiplierFontDrawing.Dispose(); ScoreFontDrawing.Dispose(); StageGeometry.Dispose(); - //_stageAudio.Dispose(); } public void Reset(bool resetPlayerScore) @@ -273,8 +272,6 @@ public void Reset(bool resetPlayerScore) _stageAudio.FadeOut(500, 0, 0.01f, FadeEndAction.Stop).ContinueWith((t) => _stageAudio.Dispose()); StageGeometry.CenterPolygon.Position.Azimuth = 0; if (resetPlayerScore) StageGeometry.Player.Reset(); - //reset hit hexagons - //StageGeometry.Player.Hits = 0; } } } From 1dfb2c7bff9969760fd02550e4792d799d18e805 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Wed, 31 Aug 2016 21:50:22 +1000 Subject: [PATCH 14/49] Remap keypad enter to regular enter --- src/TurntNinja/GUI/MenuScene.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/TurntNinja/GUI/MenuScene.cs b/src/TurntNinja/GUI/MenuScene.cs index 848a8ff..0d68c08 100644 --- a/src/TurntNinja/GUI/MenuScene.cs +++ b/src/TurntNinja/GUI/MenuScene.cs @@ -46,6 +46,9 @@ public override void Load() { SceneManager.GameWindow.Cursor = MouseCursor.Default; + // Remap keypad enter to normal enter + InputSystem.KeyRemappings.Add(Key.KeypadEnter, Key.Enter); + _gameVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); // Choose correct version directive because OSX is dumb @@ -231,6 +234,9 @@ public override void Draw(double time) public override void Dispose() { + // Remove key remapping + InputSystem.KeyRemappings.Remove(Key.KeypadEnter); + _GUIComponents.Dispose(); if (_shaderProgram != null) { From 619af5e242a4d217db15f0c17237f81ebf05a53f Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Wed, 31 Aug 2016 21:50:39 +1000 Subject: [PATCH 15/49] Use proper font in Loading Scene --- src/TurntNinja/GUI/LoadingScene.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/TurntNinja/GUI/LoadingScene.cs b/src/TurntNinja/GUI/LoadingScene.cs index 9016a81..a9c5a8c 100644 --- a/src/TurntNinja/GUI/LoadingScene.cs +++ b/src/TurntNinja/GUI/LoadingScene.cs @@ -35,7 +35,7 @@ class LoadingScene : Scene private ProcessedText _loadingText; private ProcessedText _songText; private Vector3 _loadingTextPosition; - private QFont _loadingFont; + private GameFont _loadingFont; private QFontDrawing _loadingFontDrawing; private QFontRenderOptions _loadingFontRenderOptions; private ShaderProgram _shaderProgram; @@ -67,13 +67,13 @@ public override void Load() _loadingFontRenderOptions = new QFontRenderOptions(); _loadingFontRenderOptions.DropShadowActive = true; - _loadingFont = new QFont(SceneManager.FontPath, 30, new QFontBuilderConfiguration(true), FontStyle.Regular); + _loadingFont = SceneManager.GameFontLibrary.GetFirstOrDefault(GameFontType.Heading); _loadingFontDrawing = new QFontDrawing(); _loadingFontDrawing.ProjectionMatrix = SceneManager.ScreenCamera.ScreenProjectionMatrix; - _loadingText = QFontDrawingPrimitive.ProcessText(_loadingFont, _loadingFontRenderOptions, "Loading", new SizeF(200, -1), QFontAlignment.Centre); + _loadingText = QFontDrawingPrimitive.ProcessText(_loadingFont.Font, _loadingFontRenderOptions, "Loading", new SizeF(200, -1), QFontAlignment.Centre); _loadingTextPosition = CalculateTextPosition(new Vector3((float)SceneManager.GameWindow.Width/ 2, SceneManager.GameWindow.Height/ 2, 0f), _loadingText); - _songText = QFontDrawingPrimitive.ProcessText(_loadingFont, _loadingFontRenderOptions, _song.SongBase.Identifier, new SizeF(SceneManager.GameWindow.Width - 40, -1), QFontAlignment.Centre); + _songText = QFontDrawingPrimitive.ProcessText(_loadingFont.Font, _loadingFontRenderOptions, _song.SongBase.Identifier, new SizeF(SceneManager.GameWindow.Width - 40, -1), QFontAlignment.Centre); //Get difficulty options DifficultyOptions dOptions; @@ -115,7 +115,7 @@ public override void CallBack(GUICallbackEventArgs e) public override void Resize(EventArgs e) { - _loadingText = QFontDrawingPrimitive.ProcessText(_loadingFont, _loadingFontRenderOptions, "Loading", new SizeF(1000, -1), QFontAlignment.Centre); + _loadingText = QFontDrawingPrimitive.ProcessText(_loadingFont.Font, _loadingFontRenderOptions, "Loading", new SizeF(1000, -1), QFontAlignment.Centre); _loadingFontDrawing.ProjectionMatrix = SceneManager.ScreenCamera.ScreenProjectionMatrix; _loadingTextPosition = CalculateTextPosition(new Vector3(SceneManager.ScreenCamera.PreferredWidth / 2, SceneManager.ScreenCamera.PreferredHeight / 2, 0f), _loadingText); } @@ -159,11 +159,11 @@ public override void Draw(double time) _loadingFontDrawing.DrawingPrimitives.Clear(); float yOffset = 0; - yOffset += _loadingFontDrawing.Print(_loadingFont, _loadingText, _loadingTextPosition).Height; + yOffset += _loadingFontDrawing.Print(_loadingFont.Font, _loadingText, _loadingTextPosition).Height; yOffset = MathHelper.Clamp(yOffset + 200 - 50*SceneManager.ScreenCamera.Scale.Y, yOffset, SceneManager.GameWindow.Height*0.5f); var pos = new Vector3(0, -yOffset, 0); - yOffset += _loadingFontDrawing.Print(_loadingFont, _songText, pos).Height; - yOffset += _loadingFontDrawing.Print(_loadingFont, _loadingStatus, new Vector3(0, -yOffset, 0), QFontAlignment.Centre).Height; + yOffset += _loadingFontDrawing.Print(_loadingFont.Font, _songText, pos).Height; + yOffset += _loadingFontDrawing.Print(_loadingFont.Font, _loadingStatus, new Vector3(0, -yOffset, 0), QFontAlignment.Centre).Height; _loadingFontDrawing.RefreshBuffers(); _loadingFontDrawing.Draw(); } @@ -179,7 +179,7 @@ public override void Dispose() private Vector3 CalculateTextPosition(Vector3 center, ProcessedText text) { - var size = _loadingFont.Measure(text); + var size = _loadingFont.Font.Measure(text); return new Vector3(0, size.Height/2, 0f); } } From 2670d0806c4e4d1230f29616e26aec9087ceec2b Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Wed, 31 Aug 2016 21:50:56 +1000 Subject: [PATCH 16/49] Use proper font in End Game Scene --- src/TurntNinja/GUI/EndGameScene.cs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/TurntNinja/GUI/EndGameScene.cs b/src/TurntNinja/GUI/EndGameScene.cs index a4c4f49..c98cd28 100644 --- a/src/TurntNinja/GUI/EndGameScene.cs +++ b/src/TurntNinja/GUI/EndGameScene.cs @@ -19,7 +19,7 @@ namespace TurntNinja.GUI { class EndGameScene : Scene { - private QFont _font; + private GameFont _font; private QFontDrawing _fontDrawing; private SizeF _endGameTextSize; private string _endGameText = "Press Enter to Continue"; @@ -37,7 +37,7 @@ public EndGameScene(Stage stage) public override void Load() { - _font = new QFont(SceneManager.FontPath, 50, new QFontBuilderConfiguration(true), FontStyle.Regular); + _font = SceneManager.GameFontLibrary.GetFirstOrDefault("selected"); _fontDrawing = new QFontDrawing(); SceneManager.RemoveScene(ParentScene); SceneManager.ScreenCamera.ExtraScale = 0; @@ -119,27 +119,28 @@ private void UpdateText() { _fontDrawing.ProjectionMatrix = SceneManager.ScreenCamera.ScreenProjectionMatrix; _fontDrawing.DrawingPrimitives.Clear(); - _endGameTextSize = _font.Measure(_endGameText); + _endGameTextSize = _font.Font.Measure(_endGameText); float fontOffset = 0; float endOffset = 0; if (_newHighScore) { - fontOffset += _fontDrawing.Print(_font, "New High Score", new Vector3(0, 2.0f * _endGameTextSize.Height, 0), QFontAlignment.Centre, Color.White).Height; - fontOffset += _fontDrawing.Print(_font, string.Format("Score: {0}", _highestScore.Score.ToString("N0", CultureInfo.CurrentCulture)), new Vector3(0, 0, 0), QFontAlignment.Centre, Color.White).Height; - fontOffset += _fontDrawing.Print(_font, string.Format("Accuracy: {0}%", _highestScore.Accuracy.ToString("#.##")), new Vector3(0, - _endGameTextSize.Height, 0), QFontAlignment.Centre, Color.White).Height; + fontOffset += _fontDrawing.Print(_font.Font, "New High Score", new Vector3(0, 2.0f * _endGameTextSize.Height, 0), QFontAlignment.Centre, Color.White).Height; + fontOffset += _fontDrawing.Print(_font.Font, string.Format("Score: {0}", _highestScore.Score.ToString("N0", CultureInfo.CurrentCulture)), new Vector3(0, 0, 0), QFontAlignment.Centre, Color.White).Height; + fontOffset += _fontDrawing.Print(_font.Font, string.Format("Accuracy: {0}%", _highestScore.Accuracy.ToString("#.##")), new Vector3(0, - _endGameTextSize.Height, 0), QFontAlignment.Centre, Color.White).Height; endOffset = -3.0f * _endGameTextSize.Height; } else { - fontOffset += _fontDrawing.Print(_font, string.Format("High Score: {0}", _highestScore.Score), new Vector3(0, 2.0f * _endGameTextSize.Height, 0), QFontAlignment.Centre, Color.White).Height; - fontOffset += _fontDrawing.Print(_font, string.Format("Score: {0}", _newScore.Score.ToString("N0", CultureInfo.CurrentCulture)), new Vector3(0, 0, 0), QFontAlignment.Centre, Color.White).Height; - fontOffset += _fontDrawing.Print(_font, string.Format("Accuracy: {0}%", _newScore.Accuracy.ToString("#.##")), new Vector3(0, -_endGameTextSize.Height, 0), QFontAlignment.Centre, Color.White).Height; + fontOffset += _fontDrawing.Print(_font.Font, string.Format("High Score: {0}", _highestScore.Score), new Vector3(0, 2.0f * _endGameTextSize.Height, 0), QFontAlignment.Centre, Color.White).Height; + fontOffset += _fontDrawing.Print(_font.Font, string.Format("Score: {0}", _newScore.Score.ToString("N0", CultureInfo.CurrentCulture)), new Vector3(0, 0, 0), QFontAlignment.Centre, Color.White).Height; + fontOffset += _fontDrawing.Print(_font.Font, string.Format("Accuracy: {0}%", _newScore.Accuracy.ToString("#.##")), new Vector3(0, -_endGameTextSize.Height, 0), QFontAlignment.Centre, Color.White).Height; endOffset = -3.0f * _endGameTextSize.Height; } - _fontDrawing.Print(_font, _endGameText, new Vector3(0, -(WindowHeight)/2.0f + _endGameTextSize.Height + 20, 0), QFontAlignment.Centre, Color.White); - _fontDrawing.Print(_font, string.Format("{0} - {1}", _stage.CurrentSong.SongBase.Identifier, _stage.CurrentDifficulty), new Vector3(0, (WindowHeight)/2.0f - 20, 0), QFontAlignment.Centre, Color.White); + _fontDrawing.Print(_font.Font, _endGameText, new Vector3(0, -(WindowHeight)/2.0f + _endGameTextSize.Height + 20, 0), QFontAlignment.Centre, Color.White); + _fontDrawing.Print(_font.Font, string.Format("{0} - {1}", _stage.CurrentSong.SongBase.Identifier, _stage.CurrentDifficulty), new Vector3(0, (WindowHeight) / 2.0f - 20, 0), + new SizeF(WindowWidth * 0.75f, -1), QFontAlignment.Centre, new QFontRenderOptions { Colour = Color.White }); _fontDrawing.RefreshBuffers(); } From 3e312716f7dc62191e36f878b35a3ca3d908bc90 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Wed, 31 Aug 2016 21:51:27 +1000 Subject: [PATCH 17/49] Add key repeat to backspace key in Choose Song Scene --- src/TurntNinja/GUI/ChooseSongScene.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/TurntNinja/GUI/ChooseSongScene.cs b/src/TurntNinja/GUI/ChooseSongScene.cs index 0d2f757..746dde7 100644 --- a/src/TurntNinja/GUI/ChooseSongScene.cs +++ b/src/TurntNinja/GUI/ChooseSongScene.cs @@ -46,8 +46,7 @@ public override void Load() InputSystem.RepeatingKeys.Add(Key.Down, KeyRepeatSettings.Default); InputSystem.RepeatingKeys.Add(Key.Up, KeyRepeatSettings.Default); - InputSystem.RepeatingKeys.Add(Key.Left, KeyRepeatSettings.Default); - InputSystem.RepeatingKeys.Add(Key.Right, KeyRepeatSettings.Default); + InputSystem.RepeatingKeys.Add(Key.BackSpace, KeyRepeatSettings.Default); _directoryBrowser = new DirectoryBrowser(SceneManager, this); _directoryBrowser.AddFileSystem(new LocalFileSystem(SceneManager.Directories)); @@ -148,8 +147,7 @@ public override void Dispose() { InputSystem.RepeatingKeys.Remove(Key.Down); InputSystem.RepeatingKeys.Remove(Key.Up); - InputSystem.RepeatingKeys.Remove(Key.Left); - InputSystem.RepeatingKeys.Remove(Key.Right); + InputSystem.RepeatingKeys.Remove(Key.BackSpace); } } } From 842e018303c996e412f8b616a5f9cd34a5857b00 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Wed, 31 Aug 2016 21:51:48 +1000 Subject: [PATCH 18/49] Change LocalFileSystem friendly name to Local songs --- src/TurntNinja/FileSystem/LocalFileSystem.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/TurntNinja/FileSystem/LocalFileSystem.cs b/src/TurntNinja/FileSystem/LocalFileSystem.cs index b608219..1336dc0 100644 --- a/src/TurntNinja/FileSystem/LocalFileSystem.cs +++ b/src/TurntNinja/FileSystem/LocalFileSystem.cs @@ -22,7 +22,7 @@ class LocalFileSystem : IFileSystem public ReadOnlyCollection FileSystemEntryCollection { get { return _localFileSystemEntries.AsReadOnly(); } } public List FileSystemCollection { get; set; } - public string FriendlyName { get { return "Local File System"; } } + public string FriendlyName { get { return "Local Songs"; } } public LocalFileSystem(IDirectoryHandler directoryHandler) { @@ -118,9 +118,11 @@ private int EnterPath(string directoryPath) { Path = Path.Combine(directoryPath, "../"), EntryType = FileBrowserEntryType.Directory | FileBrowserEntryType.Special, - Name = "Up a Directory" + Name = "Back" }); + _localFileSystemEntries.Add(_entrySeparator); + int desiredIndex = _localFileSystemEntries.Count; // Add the new directories From 445d7feba27dd2613b0c43005d150c26d0bff338 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Wed, 31 Aug 2016 21:53:12 +1000 Subject: [PATCH 19/49] Add new method for choosing filesystems Now press left/right to switch between filesystems in a circular buffer type effect Moved currently selected song text to middle of screen Improved algorithm for deciding how many lines of text to show on screen Moved search information to bottom of screen --- src/TurntNinja/FileSystem/DirectoryBrowser.cs | 105 ++++++++++++------ 1 file changed, 73 insertions(+), 32 deletions(-) diff --git a/src/TurntNinja/FileSystem/DirectoryBrowser.cs b/src/TurntNinja/FileSystem/DirectoryBrowser.cs index 07e4fb2..6942f98 100644 --- a/src/TurntNinja/FileSystem/DirectoryBrowser.cs +++ b/src/TurntNinja/FileSystem/DirectoryBrowser.cs @@ -33,7 +33,6 @@ class DirectoryBrowser int _fileSystemEntryIndex = 0; int _directoryBrowserEntryIndex = 0; - int _fileSystemEntryIndexOffset { get { return _fileSystemCollection.Count + 1; } } int _halfEntryDrawCount = 10; @@ -57,7 +56,8 @@ public DirectoryBrowser(SceneManager parentSceneManager, ChooseSongScene parentS _unselectedFont = _parentManager.GameFontLibrary.GetFirstOrDefault(GameFontType.Body); _selectedFont = _parentManager.GameFontLibrary.GetFirstOrDefault("selected"); _searchFont = _parentManager.GameFontLibrary.GetFirstOrDefault(GameFontType.Heading); - _halfEntryDrawCount = (int)(_parentManager.Width / _unselectedFont.MaxLineHeight) / 2 - (int)(_selectedFont.MaxLineHeight / (float)_unselectedFont.MaxLineHeight) -1; + + Resize(_parentManager.Width, _parentManager.Height); EntrySeparator = new FileBrowserEntry { @@ -76,7 +76,7 @@ public void AddFileSystem(IFileSystem fileSystem) private void LoadFileSystem(IFileSystem fileSystem) { - _directoryBrowserEntryIndex = fileSystem.Initialise(EntrySeparator) + _fileSystemEntryIndexOffset; + _directoryBrowserEntryIndex = fileSystem.Initialise(EntrySeparator); SwitchFileSystem(fileSystem); } @@ -103,11 +103,25 @@ public void RefreshRecentSongFilesystem() public void Resize(int wWidth, int wHeight) { - _halfEntryDrawCount = (int) (wHeight / _unselectedFont.MaxLineHeight) / 2 - (int) (_selectedFont.MaxLineHeight / (float)_unselectedFont.MaxLineHeight) -1; + // Account for file system chooser, selected song and search bar + float height = wHeight - 3*_selectedFont.MaxLineHeight; + _halfEntryDrawCount = (int) (height / _unselectedFont.MaxLineHeight) / 2; } public void Update(double time) { + // Check if we are switching file systems + if (InputSystem.NewKeys.Contains(Key.Left)) + { + var index = _fileSystemCollection.IndexOf(_currentFileSystem); + SwitchFileSystem(_fileSystemCollection[(index - 1 + _fileSystemCollection.Count) % _fileSystemCollection.Count]); + } + if (InputSystem.NewKeys.Contains(Key.Right)) + { + var index = _fileSystemCollection.IndexOf(_currentFileSystem); + SwitchFileSystem(_fileSystemCollection[(index + 1 + _fileSystemCollection.Count) % _fileSystemCollection.Count]); + } + if (InputSystem.NewKeys.Contains(Key.Enter) && !_fileSystemEntries[_directoryBrowserEntryIndex].EntryType.HasFlag(FileBrowserEntryType.Separator)) { SoundCloudFileSystem sfc; @@ -118,13 +132,13 @@ public void Update(double time) } else { - _fileSystemEntryIndex = _directoryBrowserEntryIndex - _fileSystemEntryIndexOffset; + _fileSystemEntryIndex = _directoryBrowserEntryIndex; if (_fileSystemEntryIndex >= 0) { var isSong = _currentFileSystem.EntrySelected(ref _fileSystemEntryIndex); if (isSong) _parentScene.SongChosen(_currentFileSystem.LoadSongInformation(_fileSystemEntryIndex)); - _directoryBrowserEntryIndex = _fileSystemEntryIndex + _fileSystemEntryIndexOffset; + _directoryBrowserEntryIndex = _fileSystemEntryIndex; } else { @@ -139,15 +153,15 @@ public void Update(double time) // Update the entry list _fileSystemEntries.Clear(); - // Add the filesystem plugins - _fileSystemEntries.AddRange(_fileSystemCollection.Select(fs => new FileBrowserEntry - { - Name = fs.FriendlyName, - Path = "", - EntryType = FileBrowserEntryType.Plugin - })); - - _fileSystemEntries.Add(EntrySeparator); +// // Add the filesystem plugins +// _fileSystemEntries.AddRange(_fileSystemCollection.Select(fs => new FileBrowserEntry +// { +// Name = fs.FriendlyName, +// Path = "", +// EntryType = FileBrowserEntryType.Plugin +// })); +// +// _fileSystemEntries.Add(EntrySeparator); // Add the current filesystem's files _fileSystemEntries.AddRange(_currentFileSystem.FileSystemEntryCollection); @@ -157,10 +171,10 @@ public void Update(double time) _directoryBrowserEntryIndex--; if (InputSystem.NewKeys.Contains(Key.Down)) _directoryBrowserEntryIndex++; - if (InputSystem.NewKeys.Contains(Key.Left)) - _directoryBrowserEntryIndex -= 10; - if (InputSystem.NewKeys.Contains(Key.Right)) - _directoryBrowserEntryIndex += 10; +// if (InputSystem.NewKeys.Contains(Key.Left)) +// _directoryBrowserEntryIndex -= 10; +// if (InputSystem.NewKeys.Contains(Key.Right)) +// _directoryBrowserEntryIndex += 10; _searchElapsedTime += time; if (_searchElapsedTime - _searchLastTime > _searchTimeout) @@ -183,11 +197,6 @@ public void Update(double time) _searchElapsedTime = _searchLastTime = 0.0f; } - if (InputSystem.NewKeys.Contains(Key.Enter)) - { - - } - // Clamp the index if (_directoryBrowserEntryIndex < 0) _directoryBrowserEntryIndex = 0; if (_directoryBrowserEntryIndex >= _fileSystemEntries.Count) _directoryBrowserEntryIndex = _fileSystemEntries.Count - 1; @@ -195,20 +204,52 @@ public void Update(double time) public void Draw(double time) { - float startY = _unselectedFont.MaxLineHeight * (_halfEntryDrawCount); var col = Color4.Black; col.A = 0.90f; - for (int i = _directoryBrowserEntryIndex - (_halfEntryDrawCount); i < _directoryBrowserEntryIndex + _halfEntryDrawCount; i++) + if (_fileSystemEntries.Count > 0) { - if (i >= 0 && i < _fileSystemEntries.Count && i != _directoryBrowserEntryIndex) - _parentManager.DrawTextLine(_fileSystemEntries[i].Name, new Vector3(0, startY, 0), col, QuickFont.QFontAlignment.Centre, _unselectedFont.Font); - if (i == _directoryBrowserEntryIndex) startY -= _selectedFont.MaxLineHeight; - if (i != _directoryBrowserEntryIndex) startY -= _unselectedFont.MaxLineHeight; + var s = _selectedFont.Font.Measure(_fileSystemEntries[_directoryBrowserEntryIndex].Name); + _parentManager.DrawTextLine(_fileSystemEntries[_directoryBrowserEntryIndex].Name, new Vector3(0, +s.Height / 2.0f, 0), Color4.White, QuickFont.QFontAlignment.Centre, _selectedFont.Font); + + float startY = _unselectedFont.MaxLineHeight * (_halfEntryDrawCount) + s.Height * 0.5f; + for (int i = _directoryBrowserEntryIndex - (_halfEntryDrawCount); i < _directoryBrowserEntryIndex + _halfEntryDrawCount; i++) + { + if (i >= 0 && i < _fileSystemEntries.Count && i != _directoryBrowserEntryIndex) + _parentManager.DrawTextLine(_fileSystemEntries[i].Name, new Vector3(0, startY, 0), col, QuickFont.QFontAlignment.Centre, _unselectedFont.Font); + if (i == _directoryBrowserEntryIndex) + startY -= _selectedFont.MaxLineHeight; + if (i != _directoryBrowserEntryIndex) + startY -= _unselectedFont.MaxLineHeight; + } } - _parentManager.DrawTextLine(_fileSystemEntries[_directoryBrowserEntryIndex].Name, new Vector3(0, 0, 0), Color4.White, QuickFont.QFontAlignment.Centre, _selectedFont.Font); - _parentManager.DrawTextLine(string.Format("Search: {0}", _searchString), new Vector3(0, (_parentManager.Height / 2), 0), Color4.White, QuickFont.QFontAlignment.Centre, _searchFont.Font); + // Draw file systems + var size = _parentManager.DrawTextLine(_currentFileSystem.FriendlyName, new Vector3(0, (_parentManager.Height / 2), 0), Color4.White, QuickFont.QFontAlignment.Centre, _selectedFont.Font); + + int currentFSIndex = _fileSystemCollection.IndexOf(_currentFileSystem); + + // Draw two file systems on either side + + col.A = 0.4f; + // Draw next fs on right + _parentManager.DrawTextLine( + _fileSystemCollection[(currentFSIndex + 1 + _fileSystemCollection.Count) % _fileSystemCollection.Count].FriendlyName, + new Vector3(size.Width * 0.75f, _parentManager.Height / 2, 0), + col, + QuickFont.QFontAlignment.Left, + _selectedFont.Font); + + // Draw previous fs on left + _parentManager.DrawTextLine( + _fileSystemCollection[(currentFSIndex - 1 + _fileSystemCollection.Count) % _fileSystemCollection.Count].FriendlyName, + new Vector3(-size.Width * 0.75f, _parentManager.Height / 2, 0), + col, + QuickFont.QFontAlignment.Right, + _selectedFont.Font); + + var searchString = string.Format("Search: {0}", _searchString); + _parentManager.DrawTextLine(searchString, new Vector3(0, -(_parentManager.Height / 2) + _searchFont.MaxLineHeight, 0), Color4.White, QuickFont.QFontAlignment.Centre, _searchFont.Font); } } } From 51b6cae8c4795fab405b04bb66493a5b83d24704 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Thu, 1 Sep 2016 13:24:59 +1000 Subject: [PATCH 20/49] Add privatePath for assembly probing --- src/TurntNinja/App.config | 204 ++++++++++++++-------------- src/TurntNinja/GameController.cs | 220 +++++++++++++++++++++++++++++++ src/TurntNinja/Program.cs | 211 +---------------------------- src/TurntNinja/TurntNinja.csproj | 4 + 4 files changed, 327 insertions(+), 312 deletions(-) create mode 100644 src/TurntNinja/GameController.cs diff --git a/src/TurntNinja/App.config b/src/TurntNinja/App.config index 5791520..4b0fa82 100644 --- a/src/TurntNinja/App.config +++ b/src/TurntNinja/App.config @@ -12,111 +12,111 @@ - - - - True - - - - - True - - - - - True - - - - - True - - - - + + + + True + + + + + True + + + + + True + + + + + True + + + + + - - 0 - - - 1 - - - 1280 - - - 720 - - - 4 - - - True - - - Normal - - - 9 - - - False - - - 50 - - - 0 - - - False - - - 0.2 - - - 10 - - - False - - - True - - - turnt-ninja.db - - - opcon - - - - - - False - - - True - - + + 0 + + + 1 + + + 1280 + + + 720 + + + 4 + + + True + + + Normal + + + 9 + + + False + + + 50 + + + 0 + + + False + + + 0.2 + + + 10 + + + False + + + True + + + turnt-ninja.db + + + opcon + + + + + + False + + + True + + - - .mp3,.flac,.wav,.m4a,.wma - - - turnt-ninja - - - oeoywrZVrjYlcctPZZ3uTXFPp9ItVUkR3w28u+WDdd9SqYzE1PRkb+WPZsYQ+VvOfUjFQOlQ1tXc7oDXY4Km7A== - - - jA9OAo1hWfHPOoMipHAAaFxFf2N7iP8zuBEI9LVQq5ET0vc8yqnLsO/oNMqCcki0rvD4CQrkMz7fWHQ4rWuHAyRfY+7nxGinxdbgIaceyVtKOJLsSnbBh4/NBq3OkBIAFG2GTxUhWqyJbxNhgzbu+0HM8jv43LY53bxhwIALt+A= - - + + .mp3,.flac,.wav,.m4a,.wma + + + turnt-ninja + + + oeoywrZVrjYlcctPZZ3uTXFPp9ItVUkR3w28u+WDdd9SqYzE1PRkb+WPZsYQ+VvOfUjFQOlQ1tXc7oDXY4Km7A== + + + jA9OAo1hWfHPOoMipHAAaFxFf2N7iP8zuBEI9LVQq5ET0vc8yqnLsO/oNMqCcki0rvD4CQrkMz7fWHQ4rWuHAyRfY+7nxGinxdbgIaceyVtKOJLsSnbBh4/NBq3OkBIAFG2GTxUhWqyJbxNhgzbu+0HM8jv43LY53bxhwIALt+A= + + - - + \ No newline at end of file diff --git a/src/TurntNinja/GameController.cs b/src/TurntNinja/GameController.cs new file mode 100644 index 0000000..f21880a --- /dev/null +++ b/src/TurntNinja/GameController.cs @@ -0,0 +1,220 @@ +using System; +using System.Diagnostics; +using System.Drawing; +using System.IO; +using TurntNinja.Game; +using TurntNinja.GUI; +using OpenTK; +using OpenTK.Graphics; +using OpenTK.Graphics.OpenGL4; +using OpenTK.Input; +using QuickFont; +using QuickFont.Configuration; +using Substructio.Core; +using Substructio.Core.Settings; +using Substructio.GUI; +using System.Threading.Tasks; +using System.Collections.Generic; + +namespace TurntNinja +{ + public sealed class GameController : GameWindow + { + private SceneManager _gameSceneManager; + private const float prefWidth = 1920; + private const float prefHeight = 1080; + + float correction = 0.0f; + + private Stopwatch _watch; + + private double _lag = 0.0; + private double _dt = 16.0 / 1000; + + private Stage _stage; + + private IGameSettings _gameSettings; + private IDirectoryHandler _directoryHandler; + + public ValueWrapper DebugMode = new ValueWrapper(); + + public GameController(IGameSettings gameSettings, int rX, int rY, GraphicsMode graphicsMode, + string title, int major, int minor, IDirectoryHandler directoryHandler) + : base(rX, rY, graphicsMode, title, GameWindowFlags.Default, DisplayDevice.Default, + major, minor, GraphicsContextFlags.Default) + { + KeyDown += Keyboard_KeyDown; + this.VSync = (bool)gameSettings["VSync"] ? VSyncMode.On : VSyncMode.Off; + this.WindowState = (WindowState)Enum.Parse(typeof(WindowState), (string)gameSettings["WindowState"]); + DebugMode.Value = (bool)gameSettings["Debug"]; + _gameSettings = gameSettings; + _directoryHandler = directoryHandler; + } + + /// + /// Occurs when a key is pressed. + /// + /// The KeyboardDevice which generated this event. + /// The key that was pressed. + void Keyboard_KeyDown(object sender, KeyboardKeyEventArgs e) + { + if (e.Key == Key.F11) + { + WindowState = WindowState == WindowState.Fullscreen ? WindowState.Normal : WindowState.Fullscreen; + _gameSettings["WindowState"] = WindowState.ToString(); + } + } + + protected override void OnKeyPress(KeyPressEventArgs e) + { + if (Focused) + InputSystem.KeyPressed(e); + base.OnKeyPress(e); + } + + /// + /// Setup OpenGL and load resources here. + /// + /// Not used. + protected override void OnLoad(EventArgs e) + { + //fontPath = Path.Combine(_directoryHandler["Fonts"].FullName, "./Chamgagne Limousines/Champagne & Limousines Italic.ttf"); + //fontPath = Path.Combine(_directoryHandler["Fonts"].FullName, "./Ostrich Sans/OstrichSans-Black.otf"); + var menuFontPath = Path.Combine(_directoryHandler["Fonts"].FullName, "./Oswald-Bold.ttf"); + var versionFontPath = _directoryHandler.Locate("Fonts", "./Oswald-Regular.ttf"); + var bodyFontPath = _directoryHandler.Locate("Fonts", "./Open Sans/OpenSans-Light.ttf"); + var largeBodyFontPath = _directoryHandler.Locate("Fonts", "./Open Sans/OpenSans-Regular.ttf"); + //var selectedFontPath = _directoryHandler.Locate("Fonts", "./Open Sans/OpenSans-Bold.ttf"); + var selectedFontPath = Path.Combine(_directoryHandler["Fonts"].FullName, "./Oswald-Bold.ttf"); + + Console.WriteLine("Initializing"); + var gameCamera = new Camera(prefWidth, prefHeight, Width, Height, Mouse); + gameCamera.CameraBounds = gameCamera.OriginalBounds = new Polygon(new Vector2(-prefWidth * 10, -prefHeight * 10), (int)prefWidth * 20, (int)(prefHeight * 20)); + + // Register OSX codecs if running on OSX + if (PlatformDetection.RunningPlatform() == Platform.MacOSX) + CSCore.OSXCoreAudio.OSXAudio.RegisterCodecs(); + + var fontLibrary = new FontLibrary(); + + // Default font + var gameFont = new QFont(bodyFontPath, 18, new QFontBuilderConfiguration() { SuperSampleLevels = 2 }); + fontLibrary.AddFont(new GameFont(gameFont, GameFontType.Default, new Vector2(Width, Height))); + + // Menu font + fontLibrary.AddFont( + new GameFont(new QFont(menuFontPath, 50, new QFontBuilderConfiguration(true)), + GameFontType.Menu, + new Vector2(Width, Height))); + + // Menu World font + fontLibrary.AddFont( + new GameFont(new QFont(menuFontPath, 70, new QFontBuilderConfiguration(true) { SuperSampleLevels = 2, PageMaxTextureSize = 8192, Characters = CharacterSet.BasicSet }), + "menuworld", + new Vector2(Width, Height))); + + // Heading font + fontLibrary.AddFont( + new GameFont(new QFont(menuFontPath, 20, new QFontBuilderConfiguration(true) { SuperSampleLevels = 2 }), + GameFontType.Heading, + new Vector2(Width, Height))); + + // Large body font + fontLibrary.AddFont( + new GameFont(new QFont(largeBodyFontPath, 25, new QFontBuilderConfiguration() { SuperSampleLevels = 1 }), + "largebody", + new Vector2(Width, Height))); + + // Version text font + fontLibrary.AddFont( + new GameFont(new QFont(versionFontPath, 15, new QFontBuilderConfiguration()), + "versiontext", + new Vector2(Width, Height))); + + // Selected text font (song browser + fontLibrary.AddFont( + new GameFont(new QFont(selectedFontPath, 34, new QFontBuilderConfiguration() { SuperSampleLevels = 2, Characters = CharacterSet.General }), + "selected", + new Vector2(Width, Height))); + + _gameSceneManager = new SceneManager(this, gameCamera, fontLibrary, bodyFontPath, _directoryHandler, _gameSettings, DebugMode); + _gameSceneManager.AddScene(new MenuScene(), null); + + if ((bool)ServiceLocator.Settings["FirstRun"]) + _gameSceneManager.AddScene(new FirstRunScene(), null); + + Keyboard.KeyDown += (o, args) => InputSystem.KeyDown(args); + Keyboard.KeyUp += (o, args) => InputSystem.KeyUp(args); + Mouse.ButtonDown += (o, args) => InputSystem.MouseDown(args); + Mouse.ButtonUp += (o, args) => InputSystem.MouseUp(args); + Mouse.WheelChanged += (o, args) => InputSystem.MouseWheelChanged(args); + Mouse.Move += (o, args) => InputSystem.MouseMoved(args); + + GL.ClearColor(Color.CornflowerBlue); + + _watch = new Stopwatch(); + } + + /// + /// Respond to resize events here. + /// + /// Contains information on the new GameWindow size. + /// There is no need to call the base implementation. + protected override void OnResize(EventArgs e) + { + GL.Viewport(0, 0, Width, Height); + + _gameSceneManager.Resize(e); + } + + /// + /// Add your game logic here. + /// + /// Contains timing information. + /// There is no need to call the base implementation. + protected override void OnUpdateFrame(FrameEventArgs e) + { + if (_gameSceneManager.ExitRequested) + { + Exit(); + return; + } + + _lag += e.Time; + while (_lag >= _dt) + { + _gameSceneManager.Update(_dt); + if (InputSystem.NewKeys.Contains(Key.F12)) + DebugMode.Value = !DebugMode.Value; + + InputSystem.Update(this.Focused, _dt); + + _lag -= _dt; + } + } + + /// + /// Add your game rendering code here. + /// + /// Contains timing information. + /// There is no need to call the base implementation. + protected override void OnRenderFrame(FrameEventArgs e) + { + + GL.Clear(ClearBufferMask.ColorBufferBit); + + _gameSceneManager.Draw(e.Time); + + this.SwapBuffers(); + } + + protected override void OnUnload(EventArgs e) + { + ServiceLocator.Analytics.TrackApplicationShutdown(); + _gameSceneManager.Dispose(); + _gameSettings["Debug"] = DebugMode.Value; + ServiceLocator.Settings.Save(); + base.OnUnload(e); + } + } +} \ No newline at end of file diff --git a/src/TurntNinja/Program.cs b/src/TurntNinja/Program.cs index b4770ed..0aa275b 100644 --- a/src/TurntNinja/Program.cs +++ b/src/TurntNinja/Program.cs @@ -1,232 +1,23 @@ using System; using System.Diagnostics; -using System.Drawing; using System.IO; using System.Reflection; using TurntNinja.Core.Settings; -using TurntNinja.Game; -using TurntNinja.GUI; using TurntNinja.Logging; using OpenTK; using OpenTK.Graphics; -using OpenTK.Graphics.OpenGL4; -using OpenTK.Input; -using QuickFont; -using QuickFont.Configuration; using Substructio.Core; -using Substructio.Core.Settings; -using Substructio.GUI; using Substructio.IO; -using Squirrel; using System.Threading.Tasks; using System.Collections.Generic; namespace TurntNinja { - /// - /// Demonstrates the GameWindow class. - /// - public sealed class GameController : GameWindow + public static class TurntNinjaGame { - private SceneManager _gameSceneManager; - private const float prefWidth = 1920; - private const float prefHeight = 1080; - - float correction = 0.0f; - - private Stopwatch _watch; - - private double _lag = 0.0; - private double _dt = 16.0 / 1000; - - private Stage _stage; - - private IGameSettings _gameSettings; - private IDirectoryHandler _directoryHandler; private static CrashReporter _crashReporter; - public ValueWrapper DebugMode = new ValueWrapper(); - - public GameController(IGameSettings gameSettings, int rX, int rY, GraphicsMode graphicsMode, - string title, int major, int minor, IDirectoryHandler directoryHandler) - : base(rX, rY, graphicsMode, title, GameWindowFlags.Default, DisplayDevice.Default, - major, minor, GraphicsContextFlags.Default) - { - KeyDown += Keyboard_KeyDown; - this.VSync = (bool)gameSettings["VSync"] ? VSyncMode.On : VSyncMode.Off; - this.WindowState = (WindowState)Enum.Parse(typeof(WindowState), (string)gameSettings["WindowState"]); - DebugMode.Value = (bool)gameSettings["Debug"]; - _gameSettings = gameSettings; - _directoryHandler = directoryHandler; - } - - /// - /// Occurs when a key is pressed. - /// - /// The KeyboardDevice which generated this event. - /// The key that was pressed. - void Keyboard_KeyDown(object sender, KeyboardKeyEventArgs e) - { - if (e.Key == Key.F11) - { - WindowState = WindowState == WindowState.Fullscreen ? WindowState.Normal : WindowState.Fullscreen; - _gameSettings["WindowState"] = WindowState.ToString(); - } - } - - protected override void OnKeyPress(KeyPressEventArgs e) - { - if (Focused) - InputSystem.KeyPressed(e); - base.OnKeyPress(e); - } - - /// - /// Setup OpenGL and load resources here. - /// - /// Not used. - protected override void OnLoad(EventArgs e) - { - //fontPath = Path.Combine(_directoryHandler["Fonts"].FullName, "./Chamgagne Limousines/Champagne & Limousines Italic.ttf"); - //fontPath = Path.Combine(_directoryHandler["Fonts"].FullName, "./Ostrich Sans/OstrichSans-Black.otf"); - var menuFontPath = Path.Combine(_directoryHandler["Fonts"].FullName, "./Oswald-Bold.ttf"); - var versionFontPath = _directoryHandler.Locate("Fonts", "./Oswald-Regular.ttf"); - var bodyFontPath = _directoryHandler.Locate("Fonts", "./Open Sans/OpenSans-Light.ttf"); - var largeBodyFontPath = _directoryHandler.Locate("Fonts", "./Open Sans/OpenSans-Regular.ttf"); - //var selectedFontPath = _directoryHandler.Locate("Fonts", "./Open Sans/OpenSans-Bold.ttf"); - var selectedFontPath = Path.Combine(_directoryHandler["Fonts"].FullName, "./Oswald-Bold.ttf"); - - Console.WriteLine("Initializing"); - var gameCamera = new Camera(prefWidth, prefHeight, Width, Height, Mouse); - gameCamera.CameraBounds = gameCamera.OriginalBounds = new Polygon(new Vector2(-prefWidth * 10, -prefHeight * 10), (int)prefWidth * 20, (int)(prefHeight * 20)); - - // Register OSX codecs if running on OSX - if (PlatformDetection.RunningPlatform() == Platform.MacOSX) - CSCore.OSXCoreAudio.OSXAudio.RegisterCodecs(); - - var fontLibrary = new FontLibrary(); - - // Default font - var gameFont = new QFont(bodyFontPath, 18, new QFontBuilderConfiguration() { SuperSampleLevels = 2 }); - fontLibrary.AddFont(new GameFont(gameFont, GameFontType.Default, new Vector2(Width, Height))); - - // Menu font - fontLibrary.AddFont( - new GameFont(new QFont(menuFontPath, 50, new QFontBuilderConfiguration(true)), - GameFontType.Menu, - new Vector2(Width, Height))); - - // Menu World font - fontLibrary.AddFont( - new GameFont(new QFont(menuFontPath, 70, new QFontBuilderConfiguration(true) { SuperSampleLevels = 2, PageMaxTextureSize = 8192, Characters = CharacterSet.BasicSet }), - "menuworld", - new Vector2(Width, Height))); - - // Heading font - fontLibrary.AddFont( - new GameFont(new QFont(menuFontPath, 20, new QFontBuilderConfiguration(true) { SuperSampleLevels = 2 }), - GameFontType.Heading, - new Vector2(Width, Height))); - - // Large body font - fontLibrary.AddFont( - new GameFont(new QFont(largeBodyFontPath, 25, new QFontBuilderConfiguration() { SuperSampleLevels = 1 }), - "largebody", - new Vector2(Width, Height))); - - // Version text font - fontLibrary.AddFont( - new GameFont(new QFont(versionFontPath, 15, new QFontBuilderConfiguration()), - "versiontext", - new Vector2(Width, Height))); - - // Selected text font (song browser - fontLibrary.AddFont( - new GameFont(new QFont(selectedFontPath, 34, new QFontBuilderConfiguration() { SuperSampleLevels = 2, Characters = CharacterSet.General }), - "selected", - new Vector2(Width, Height))); - - _gameSceneManager = new SceneManager(this, gameCamera, fontLibrary, bodyFontPath, _directoryHandler, _gameSettings, DebugMode); - _gameSceneManager.AddScene(new MenuScene(), null); - - if ((bool)ServiceLocator.Settings["FirstRun"]) - _gameSceneManager.AddScene(new FirstRunScene(), null); - - Keyboard.KeyDown += (o, args) => InputSystem.KeyDown(args); - Keyboard.KeyUp += (o, args) => InputSystem.KeyUp(args); - Mouse.ButtonDown += (o, args) => InputSystem.MouseDown(args); - Mouse.ButtonUp += (o, args) => InputSystem.MouseUp(args); - Mouse.WheelChanged += (o, args) => InputSystem.MouseWheelChanged(args); - Mouse.Move += (o, args) => InputSystem.MouseMoved(args); - - GL.ClearColor(Color.CornflowerBlue); - - _watch = new Stopwatch(); - } - - /// - /// Respond to resize events here. - /// - /// Contains information on the new GameWindow size. - /// There is no need to call the base implementation. - protected override void OnResize(EventArgs e) - { - GL.Viewport(0, 0, Width, Height); - - _gameSceneManager.Resize(e); - } - - /// - /// Add your game logic here. - /// - /// Contains timing information. - /// There is no need to call the base implementation. - protected override void OnUpdateFrame(FrameEventArgs e) - { - if (_gameSceneManager.ExitRequested) - { - Exit(); - return; - } - - _lag += e.Time; - while (_lag >= _dt) - { - _gameSceneManager.Update(_dt); - if (InputSystem.NewKeys.Contains(Key.F12)) - DebugMode.Value = !DebugMode.Value; - - InputSystem.Update(this.Focused, _dt); - - _lag -= _dt; - } - } - - /// - /// Add your game rendering code here. - /// - /// Contains timing information. - /// There is no need to call the base implementation. - protected override void OnRenderFrame(FrameEventArgs e) - { - - GL.Clear(ClearBufferMask.ColorBufferBit); - - _gameSceneManager.Draw(e.Time); - - this.SwapBuffers(); - } - - protected override void OnUnload(EventArgs e) - { - ServiceLocator.Analytics.TrackApplicationShutdown(); - _gameSceneManager.Dispose(); - _gameSettings["Debug"] = DebugMode.Value; - ServiceLocator.Settings.Save(); - base.OnUnload(e); - } - [STAThread] public static void Main(string[] args) { diff --git a/src/TurntNinja/TurntNinja.csproj b/src/TurntNinja/TurntNinja.csproj index c877831..f8582f8 100644 --- a/src/TurntNinja/TurntNinja.csproj +++ b/src/TurntNinja/TurntNinja.csproj @@ -122,6 +122,7 @@ Settings.settings + @@ -136,6 +137,9 @@ SharpFont.dll.config Always + + build.fsx + From b5a10233fb1dda5f77c1a22b7cd6df1497ff2a00 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Thu, 1 Sep 2016 13:25:09 +1000 Subject: [PATCH 21/49] Update build script --- build.fsx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/build.fsx b/build.fsx index 7f91365..3766c83 100644 --- a/build.fsx +++ b/build.fsx @@ -22,6 +22,7 @@ let substructioDir = parentDir + substructioFolder + "/" let substructioBuildDir = substructioDir + buildDirBase + mode + "/" let contentDirDeployName = "Content" let licenseDirDeployName = "Licenses" +let dllDirDeployName = "Dependencies" // MonoKickStart properties let monoKickStartRepo = @"https://github.com/MonoGame/MonoKickstart" @@ -47,6 +48,9 @@ let deployName = let tempDirName = lazy tempDirBase + deployName.Value + "/" +let tempDirZipName = lazy + tempDirBase + deployName.Value + "-zip/" + let tempMergedDirName = lazy tempDirBase + deployName.Value + "-merged/" @@ -60,7 +64,7 @@ let deployZipMergedPath = lazy deployDir + deployZipMergedName.Value // Tool names -let squirrelToolName = "squirrel.exe" +let squirrelToolName = "Squirrel.exe" let ILMergeToolName = "ILRepack.exe" // Targets @@ -124,7 +128,7 @@ Target "CleanDeploy" (fun _ -> CleanDir deployDir ) -Target "DeployZip" (fun _ -> +Target "CopyToTemp" (fun _ -> ensureDirectory deployDir let mainFiles = !! (sprintf "%s*.dll" buildDir) ++ (sprintf "%s*.config" buildDir) ++ (sprintf "%s*.exe" buildDir) -- (sprintf "%s*vshost*" buildDir) @@ -132,7 +136,9 @@ Target "DeployZip" (fun _ -> CopyFiles tempDirName.Value mainFiles CopyDir (tempDirName.Value + contentDirDeployName) "src/TurntNinja/Content/" (fun x -> true) CopyDir (tempDirName.Value + licenseDirDeployName) "docs/licenses" (fun x-> true) +) +Target "DeployZip" (fun _ -> let dInfo = new System.IO.DirectoryInfo(tempDirName.Value) Zip tempDirName.Value deployZipPath.Value [ for f in dInfo.EnumerateFiles("*", System.IO.SearchOption.AllDirectories) do yield f.FullName] //ArchiveHelper.Tar.GZip.CompressWithDefaults (directoryInfo artifactTempDir) (fileInfo (deployDir + deployName + ".tar.gz")) (dInfo.EnumerateFiles("*", System.IO.SearchOption.AllDirectories)) @@ -156,13 +162,14 @@ Target "DeploySquirrel" (fun _ -> OutputPath = deployDir WorkingDir = tempDirName.Value }) - "src\TurntNinja\TurntNinja.nuspec" + "src/TurntNinja/TurntNinja.nuspec" + let squirrelPath = findToolInSubPath squirrelToolName "" // Create squirrel package Squirrel.SquirrelPack (fun p -> {p with ReleaseDir = squirrelDeployDir - ToolPath = findToolInSubPath squirrelToolName "" + ToolPath = squirrelPath }) packagePath ) @@ -248,7 +255,7 @@ Target "Default" (fun _ -> "DeployZip" ==> "DeploySquirrel" -"DeploySquirrel" +"DeployZip" ==> "Deploy" // Deploy zip conditional target to ensure that we are built From c6075b5381098652ea6add39c0bd6adcbeb3df34 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Thu, 1 Sep 2016 13:59:01 +1000 Subject: [PATCH 22/49] Update build script to use new folder structure dlls are now in the Dependencies folder, which produces a cleaner application directory layout Also added a DeployAll target, that deploys merged, zip and Squirrel packages of Turnt Ninja --- build.fsx | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/build.fsx b/build.fsx index 3766c83..6262f35 100644 --- a/build.fsx +++ b/build.fsx @@ -49,7 +49,7 @@ let tempDirName = lazy tempDirBase + deployName.Value + "/" let tempDirZipName = lazy - tempDirBase + deployName.Value + "-zip/" + tempDirBase + deployName.Value + "-zip/" let tempMergedDirName = lazy tempDirBase + deployName.Value + "-merged/" @@ -139,8 +139,16 @@ Target "CopyToTemp" (fun _ -> ) Target "DeployZip" (fun _ -> - let dInfo = new System.IO.DirectoryInfo(tempDirName.Value) - Zip tempDirName.Value deployZipPath.Value [ for f in dInfo.EnumerateFiles("*", System.IO.SearchOption.AllDirectories) do yield f.FullName] + CopyDir tempDirZipName.Value tempDirName.Value (fun x -> true) + + let filesToMove = !! (sprintf "%s*.dll" tempDirZipName.Value) ++ (sprintf "%s*.dll.config" tempDirZipName.Value) + + Copy (tempDirZipName.Value + dllDirDeployName) filesToMove + + DeleteFiles filesToMove + + let dInfo = new System.IO.DirectoryInfo(tempDirZipName.Value) + Zip tempDirZipName.Value deployZipPath.Value [ for f in dInfo.EnumerateFiles("*", System.IO.SearchOption.AllDirectories) do yield f.FullName] //ArchiveHelper.Tar.GZip.CompressWithDefaults (directoryInfo artifactTempDir) (fileInfo (deployDir + deployName + ".tar.gz")) (dInfo.EnumerateFiles("*", System.IO.SearchOption.AllDirectories)) ) @@ -160,7 +168,7 @@ Target "DeploySquirrel" (fun _ -> ("**/*.*", Some @"lib/net45", None) ] OutputPath = deployDir - WorkingDir = tempDirName.Value + WorkingDir = tempDirZipName.Value }) "src/TurntNinja/TurntNinja.nuspec" @@ -208,6 +216,7 @@ Target "DeployKickStart" (fun _ -> ) Target "Deploy" (fun _ -> ()) +Target "DeployAll" (fun _ -> ()) Target "PushArtifacts" (fun _ -> match buildServer with @@ -244,12 +253,15 @@ Target "Default" (fun _ -> ==> "CleanSubstructio" "CleanTemp" + ==> "CopyToTemp" + +"CopyToTemp" ==> "DeployZip" "DeployZip" ==> "PushArtifacts" -"DeployZip" +"CopyToTemp" ==> "DeployMerged" "DeployZip" @@ -257,10 +269,19 @@ Target "Default" (fun _ -> "DeployZip" ==> "Deploy" + +"DeployZip" + ==> "DeployAll" + +"DeployMerged" + ==> "DeployAll" + +"DeploySquirrel" + ==> "DeployAll" -// Deploy zip conditional target to ensure that we are built +// CopyToTemp conditional target to ensure that we are built "Build" - =?> ("DeployZip", not (fileExists appPath)) + =?> ("CopyToTemp", not (fileExists appPath)) // start build RunTargetOrDefault "Default" From 36fcef98a01fae35a84fb02c1a3f34e3a855a0f5 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Thu, 1 Sep 2016 14:01:47 +1000 Subject: [PATCH 23/49] Copy OpenTK.dll.config to output directory --- src/TurntNinja/TurntNinja.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/TurntNinja/TurntNinja.csproj b/src/TurntNinja/TurntNinja.csproj index f8582f8..1507f19 100644 --- a/src/TurntNinja/TurntNinja.csproj +++ b/src/TurntNinja/TurntNinja.csproj @@ -168,6 +168,7 @@ True + PreserveNewest From c5480f61fd350cbe60bfe8237615584c41e3cac0 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Thu, 1 Sep 2016 14:43:49 +1000 Subject: [PATCH 24/49] Fix crash on SDL and Linux SDL could not handle a 24bit depth buffer, use 32 instead. Possibly because color format and depth buffer were mismatched --- src/TurntNinja/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TurntNinja/Program.cs b/src/TurntNinja/Program.cs index 0aa275b..54ebe3f 100644 --- a/src/TurntNinja/Program.cs +++ b/src/TurntNinja/Program.cs @@ -140,7 +140,7 @@ public static void Main(string[] args) int rX = (int)ServiceLocator.Settings["ResolutionX"]; int rY = (int)ServiceLocator.Settings["ResolutionY"]; int FSAASamples = (int)ServiceLocator.Settings["AntiAliasingSamples"]; - GraphicsMode graphicsMode = new GraphicsMode(32, 24, 8, FSAASamples, GraphicsMode.Default.AccumulatorFormat, 3); + GraphicsMode graphicsMode = new GraphicsMode(32, 32, 8, FSAASamples, GraphicsMode.Default.AccumulatorFormat, 3); // Choose right OpenGL version for mac int major = 3; From 1b25192053db3dbc81d950ce2d77610264c2f6ca Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Fri, 2 Sep 2016 01:31:38 +1000 Subject: [PATCH 25/49] Last commit of options scene before the downfal --- src/TurntNinja/GUI/OptionsScene.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/TurntNinja/GUI/OptionsScene.cs b/src/TurntNinja/GUI/OptionsScene.cs index 7d552cc..d7f4f0f 100644 --- a/src/TurntNinja/GUI/OptionsScene.cs +++ b/src/TurntNinja/GUI/OptionsScene.cs @@ -266,5 +266,13 @@ public override void Dispose() InputSystem.RemoveGUIInput(_input); _canvas.Dispose(); } + + public override void EnterFocus() + { + } + + public override void ExitFocus() + { + } } } From 9d0ba58010ef0e11e5c711f29567a30d85c10a0c Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Fri, 2 Sep 2016 01:32:52 +1000 Subject: [PATCH 26/49] Add methods for Enter/Exit focus to all Scene subclasses --- src/TurntNinja/GUI/ChooseSongScene.cs | 16 +++++++++++----- src/TurntNinja/GUI/EndGameScene.cs | 9 ++++++++- src/TurntNinja/GUI/FirstRunScene.cs | 8 ++++++++ src/TurntNinja/GUI/GameScene.cs | 8 ++++++++ src/TurntNinja/GUI/LoadingScene.cs | 8 ++++++++ src/TurntNinja/GUI/MenuScene.cs | 8 ++++++++ src/TurntNinja/GUI/UpdateScene.cs | 7 +++++++ 7 files changed, 58 insertions(+), 6 deletions(-) diff --git a/src/TurntNinja/GUI/ChooseSongScene.cs b/src/TurntNinja/GUI/ChooseSongScene.cs index 746dde7..c19dbbe 100644 --- a/src/TurntNinja/GUI/ChooseSongScene.cs +++ b/src/TurntNinja/GUI/ChooseSongScene.cs @@ -43,11 +43,6 @@ public ChooseSongScene(GUIComponentContainer guiComponents, PolarPolygon centerP public override void Load() { - - InputSystem.RepeatingKeys.Add(Key.Down, KeyRepeatSettings.Default); - InputSystem.RepeatingKeys.Add(Key.Up, KeyRepeatSettings.Default); - InputSystem.RepeatingKeys.Add(Key.BackSpace, KeyRepeatSettings.Default); - _directoryBrowser = new DirectoryBrowser(SceneManager, this); _directoryBrowser.AddFileSystem(new LocalFileSystem(SceneManager.Directories)); _directoryBrowser.AddFileSystem(new SoundCloudFileSystem()); @@ -144,6 +139,17 @@ public override void Draw(double time) } public override void Dispose() + { + } + + public override void EnterFocus() + { + InputSystem.RepeatingKeys.Add(Key.Down, KeyRepeatSettings.Default); + InputSystem.RepeatingKeys.Add(Key.Up, KeyRepeatSettings.Default); + InputSystem.RepeatingKeys.Add(Key.BackSpace, KeyRepeatSettings.Default); + } + + public override void ExitFocus() { InputSystem.RepeatingKeys.Remove(Key.Down); InputSystem.RepeatingKeys.Remove(Key.Up); diff --git a/src/TurntNinja/GUI/EndGameScene.cs b/src/TurntNinja/GUI/EndGameScene.cs index c98cd28..8df0da1 100644 --- a/src/TurntNinja/GUI/EndGameScene.cs +++ b/src/TurntNinja/GUI/EndGameScene.cs @@ -161,8 +161,15 @@ public override void Draw(double time) public override void Dispose() { _stage.Dispose(); - _font.Dispose(); _fontDrawing.Dispose(); } + + public override void EnterFocus() + { + } + + public override void ExitFocus() + { + } } } diff --git a/src/TurntNinja/GUI/FirstRunScene.cs b/src/TurntNinja/GUI/FirstRunScene.cs index 397a846..6783920 100644 --- a/src/TurntNinja/GUI/FirstRunScene.cs +++ b/src/TurntNinja/GUI/FirstRunScene.cs @@ -120,5 +120,13 @@ public override void Update(double time, bool focused = false) _fontDrawing.Print(_bodyFont.Font, _bodyList, new Vector3(-WindowWidth*0.25f, (headerOffset - (_headerSize.Height)) - _bodyText1Size.Height, 0), new SizeF(WindowWidth * _bodyTextWidth, -1), QFontAlignment.Left); _fontDrawing.Print(_bodyFont.Font, _bodyText2, new Vector3(0, (headerOffset - (_headerSize.Height)) - _bodyText1Size.Height - _bodyListSize.Height, 0), new SizeF(WindowWidth * _bodyTextWidth, -1), QFontAlignment.Centre); } + + public override void EnterFocus() + { + } + + public override void ExitFocus() + { + } } } diff --git a/src/TurntNinja/GUI/GameScene.cs b/src/TurntNinja/GUI/GameScene.cs index 31de3d7..b3728e9 100644 --- a/src/TurntNinja/GUI/GameScene.cs +++ b/src/TurntNinja/GUI/GameScene.cs @@ -121,5 +121,13 @@ public override void Dispose() _stage.Dispose(); _stage = null; } + + public override void EnterFocus() + { + } + + public override void ExitFocus() + { + } } } diff --git a/src/TurntNinja/GUI/LoadingScene.cs b/src/TurntNinja/GUI/LoadingScene.cs index a9c5a8c..d586b37 100644 --- a/src/TurntNinja/GUI/LoadingScene.cs +++ b/src/TurntNinja/GUI/LoadingScene.cs @@ -182,5 +182,13 @@ private Vector3 CalculateTextPosition(Vector3 center, ProcessedText text) var size = _loadingFont.Font.Measure(text); return new Vector3(0, size.Height/2, 0f); } + + public override void EnterFocus() + { + } + + public override void ExitFocus() + { + } } } diff --git a/src/TurntNinja/GUI/MenuScene.cs b/src/TurntNinja/GUI/MenuScene.cs index 0d68c08..f4a0a11 100644 --- a/src/TurntNinja/GUI/MenuScene.cs +++ b/src/TurntNinja/GUI/MenuScene.cs @@ -246,6 +246,14 @@ public override void Dispose() _menuFontDrawing.Dispose(); _menuFont.Dispose(); } + + public override void EnterFocus() + { + } + + public override void ExitFocus() + { + } } enum MainMenuOptions diff --git a/src/TurntNinja/GUI/UpdateScene.cs b/src/TurntNinja/GUI/UpdateScene.cs index 964da97..14d35b7 100644 --- a/src/TurntNinja/GUI/UpdateScene.cs +++ b/src/TurntNinja/GUI/UpdateScene.cs @@ -209,5 +209,12 @@ public static string RemoveHtmlTags(string html) return Regex.Replace(html, "<.+?>", string.Empty); } + public override void EnterFocus() + { + } + + public override void ExitFocus() + { + } } } From 2798d247a00f1fc09345df16b5c48befceb62886 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Fri, 2 Sep 2016 01:33:03 +1000 Subject: [PATCH 27/49] Fix analysing song wording --- src/TurntNinja/Audio/AudioFeatures.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TurntNinja/Audio/AudioFeatures.cs b/src/TurntNinja/Audio/AudioFeatures.cs index 8308eb1..3d666ca 100644 --- a/src/TurntNinja/Audio/AudioFeatures.cs +++ b/src/TurntNinja/Audio/AudioFeatures.cs @@ -46,7 +46,7 @@ public bool SongAnalysed(string audioPath) public void Extract(CSCore.IWaveSource audioSource, Song s) { - _currentTask = "Analysing Song..."; + _currentTask = "Analysing Song"; List onsets; if (SongAnalysed(s.SongBase.InternalName)) From 49210750eb29af5030d2130c170ec56a08639c5d Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Fri, 2 Sep 2016 01:33:52 +1000 Subject: [PATCH 28/49] Improved directory browser layout Selected song text now directly in centre of screen Spacing of songs now even --- src/TurntNinja/FileSystem/DirectoryBrowser.cs | 56 +++++++++++++------ 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/src/TurntNinja/FileSystem/DirectoryBrowser.cs b/src/TurntNinja/FileSystem/DirectoryBrowser.cs index 6942f98..8fa8a40 100644 --- a/src/TurntNinja/FileSystem/DirectoryBrowser.cs +++ b/src/TurntNinja/FileSystem/DirectoryBrowser.cs @@ -12,6 +12,7 @@ using OpenTK.Graphics; using System.Globalization; using System.IO; +using QuickFont; namespace TurntNinja.FileSystem { @@ -41,6 +42,8 @@ class DirectoryBrowser double _searchLastTime = 0.0f; double _searchElapsedTime = 0.0f; + QFontDrawing _qfontDrawing; + public string SearchString { get { return _searchString; } @@ -57,6 +60,8 @@ public DirectoryBrowser(SceneManager parentSceneManager, ChooseSongScene parentS _selectedFont = _parentManager.GameFontLibrary.GetFirstOrDefault("selected"); _searchFont = _parentManager.GameFontLibrary.GetFirstOrDefault(GameFontType.Heading); + _qfontDrawing = new QFontDrawing(); + Resize(_parentManager.Width, _parentManager.Height); EntrySeparator = new FileBrowserEntry @@ -103,9 +108,11 @@ public void RefreshRecentSongFilesystem() public void Resize(int wWidth, int wHeight) { - // Account for file system chooser, selected song and search bar + // Account for file system chooser, selected song and search bar and spacing float height = wHeight - 3*_selectedFont.MaxLineHeight; _halfEntryDrawCount = (int) (height / _unselectedFont.MaxLineHeight) / 2; + + _qfontDrawing.ProjectionMatrix = _parentScene.SceneManager.ScreenCamera.ScreenProjectionMatrix; } public void Update(double time) @@ -204,49 +211,62 @@ public void Update(double time) public void Draw(double time) { + _qfontDrawing.DrawingPrimitives.Clear(); var col = Color4.Black; col.A = 0.90f; if (_fileSystemEntries.Count > 0) { var s = _selectedFont.Font.Measure(_fileSystemEntries[_directoryBrowserEntryIndex].Name); - _parentManager.DrawTextLine(_fileSystemEntries[_directoryBrowserEntryIndex].Name, new Vector3(0, +s.Height / 2.0f, 0), Color4.White, QuickFont.QFontAlignment.Centre, _selectedFont.Font); + _parentManager.DrawTextLine(_fileSystemEntries[_directoryBrowserEntryIndex].Name, new Vector3(0, s.Height / 2.0f, 0), Color4.White, QFontAlignment.Centre, _selectedFont.Font); - float startY = _unselectedFont.MaxLineHeight * (_halfEntryDrawCount) + s.Height * 0.5f; + float startY = _unselectedFont.MaxLineHeight * (_halfEntryDrawCount) + s.Height * 0.5f + _unselectedFont.MaxLineHeight * 0.5f; for (int i = _directoryBrowserEntryIndex - (_halfEntryDrawCount); i < _directoryBrowserEntryIndex + _halfEntryDrawCount; i++) { if (i >= 0 && i < _fileSystemEntries.Count && i != _directoryBrowserEntryIndex) - _parentManager.DrawTextLine(_fileSystemEntries[i].Name, new Vector3(0, startY, 0), col, QuickFont.QFontAlignment.Centre, _unselectedFont.Font); + _parentManager.DrawTextLine(_fileSystemEntries[i].Name, new Vector3(0, startY, 0), col, QFontAlignment.Centre, _unselectedFont.Font); if (i == _directoryBrowserEntryIndex) - startY -= _selectedFont.MaxLineHeight; + startY -= s.Height + _unselectedFont.MaxLineHeight * 1.5f; if (i != _directoryBrowserEntryIndex) startY -= _unselectedFont.MaxLineHeight; } } // Draw file systems - var size = _parentManager.DrawTextLine(_currentFileSystem.FriendlyName, new Vector3(0, (_parentManager.Height / 2), 0), Color4.White, QuickFont.QFontAlignment.Centre, _selectedFont.Font); + var size = _parentManager.DrawTextLine(_currentFileSystem.FriendlyName, new Vector3(0, (_parentManager.Height / 2), 0), Color4.White, QFontAlignment.Centre, _selectedFont.Font); int currentFSIndex = _fileSystemCollection.IndexOf(_currentFileSystem); // Draw two file systems on either side - - col.A = 0.4f; + + col = Color4.White; + col.A = 0.70f; + + var dp = new QFontDrawingPrimitive(_selectedFont.Font, new QFontRenderOptions { Colour = (System.Drawing.Color)col }); // Draw next fs on right - _parentManager.DrawTextLine( + dp.Print( _fileSystemCollection[(currentFSIndex + 1 + _fileSystemCollection.Count) % _fileSystemCollection.Count].FriendlyName, - new Vector3(size.Width * 0.75f, _parentManager.Height / 2, 0), - col, - QuickFont.QFontAlignment.Left, - _selectedFont.Font); + Vector3.Zero, + QFontAlignment.Left); + dp.ModelViewMatrix = Matrix4.CreateTranslation(new Vector3(0, size.Height * 2.0f, 0)) + * Matrix4.CreateScale(0.9f) + * Matrix4.CreateTranslation(new Vector3(size.Width * 0.75f, _parentManager.Height / 2 - size.Height * 2.0f, 0)); + + _qfontDrawing.DrawingPrimitives.Add(dp); + dp = new QFontDrawingPrimitive(_selectedFont.Font, new QFontRenderOptions { Colour = (System.Drawing.Color)col }); // Draw previous fs on left - _parentManager.DrawTextLine( + dp.Print( _fileSystemCollection[(currentFSIndex - 1 + _fileSystemCollection.Count) % _fileSystemCollection.Count].FriendlyName, - new Vector3(-size.Width * 0.75f, _parentManager.Height / 2, 0), - col, - QuickFont.QFontAlignment.Right, - _selectedFont.Font); + Vector3.Zero, + QFontAlignment.Right); + dp.ModelViewMatrix = Matrix4.CreateTranslation(new Vector3(0, size.Height * 2.0f, 0)) + * Matrix4.CreateScale(0.9f) + * Matrix4.CreateTranslation(new Vector3(-size.Width * 0.75f, _parentManager.Height / 2 - size.Height * 2.0f, 0)); + _qfontDrawing.DrawingPrimitives.Add(dp); + + _qfontDrawing.RefreshBuffers(); + _qfontDrawing.Draw(); var searchString = string.Format("Search: {0}", _searchString); _parentManager.DrawTextLine(searchString, new Vector3(0, -(_parentManager.Height / 2) + _searchFont.MaxLineHeight, 0), Color4.White, QuickFont.QFontAlignment.Centre, _searchFont.Font); From 90937cf53957713c5a8e8ae813c6ccae0057e0b6 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Fri, 2 Sep 2016 01:34:15 +1000 Subject: [PATCH 29/49] Use Wasapi on windows, rather than old WaveOut --- src/TurntNinja/Game/StageAudio.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TurntNinja/Game/StageAudio.cs b/src/TurntNinja/Game/StageAudio.cs index 455a041..16cbce3 100644 --- a/src/TurntNinja/Game/StageAudio.cs +++ b/src/TurntNinja/Game/StageAudio.cs @@ -263,7 +263,7 @@ public void Init(IWaveSource source) _soundSource = source; // Use ALSound out if we are running on Mac/Linux _soundOut = (PlatformDetection.RunningPlatform() == Platform.Windows) ? - (ISoundOut) new WaveOut() : new ALSoundOut(); + (ISoundOut) new WasapiOut() : new ALSoundOut(); _soundOut.Initialize(_soundSource); _soundOut.Stopped += (sender, args) => { if (args.HasError) throw new Exception("exception thrown on stoping audio", args.Exception); }; } From 7e144ac9808e19048ee91606053a6247ff204e90 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Fri, 2 Sep 2016 01:34:32 +1000 Subject: [PATCH 30/49] increase background polygon size --- src/TurntNinja/Generation/StageGeometryBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TurntNinja/Generation/StageGeometryBuilder.cs b/src/TurntNinja/Generation/StageGeometryBuilder.cs index 6a75191..bcef1d4 100644 --- a/src/TurntNinja/Generation/StageGeometryBuilder.cs +++ b/src/TurntNinja/Generation/StageGeometryBuilder.cs @@ -40,7 +40,7 @@ public StageGeometry Build(AudioFeatures audioFeatures, Random random, GeometryB BuildGeometry(); SetStartColour(); - var backgroundPolygon = new PolarPolygon(6, new PolarVector(0.5, 0), 50000, -20, 0); + var backgroundPolygon = new PolarPolygon(6, new PolarVector(0.5, 0), 500000, -20, 0); backgroundPolygon.ShaderProgram = _builderOptions.GeometryShaderProgram; return new StageGeometry(_onsets, _onsetDrawing, _segmentStartColour, _random) {BackgroundPolygon = backgroundPolygon}; From bd602d65f3d64cfc971858838c71d0020473034e Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Fri, 2 Sep 2016 01:35:13 +1000 Subject: [PATCH 31/49] whitespace --- src/TurntNinja/Generation/StageGeometryBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TurntNinja/Generation/StageGeometryBuilder.cs b/src/TurntNinja/Generation/StageGeometryBuilder.cs index bcef1d4..e7b5aad 100644 --- a/src/TurntNinja/Generation/StageGeometryBuilder.cs +++ b/src/TurntNinja/Generation/StageGeometryBuilder.cs @@ -91,7 +91,7 @@ private void BuildBeatFrequencyList() //weight--; } - _beatFrequencies[i] = 1/(differenceSum/total); + _beatFrequencies[i] = 1 / (differenceSum / total); } _beatFrequencies[_beatFrequencies.Length - 1] = _beatFrequencies[_beatFrequencies.Length - 2]; From a24366206d8e54867747f9e39ba64a72336af89d Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Fri, 2 Sep 2016 01:35:21 +1000 Subject: [PATCH 32/49] remove unused code --- src/TurntNinja/Generation/StageGeometryBuilder.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/TurntNinja/Generation/StageGeometryBuilder.cs b/src/TurntNinja/Generation/StageGeometryBuilder.cs index e7b5aad..9581924 100644 --- a/src/TurntNinja/Generation/StageGeometryBuilder.cs +++ b/src/TurntNinja/Generation/StageGeometryBuilder.cs @@ -111,8 +111,6 @@ private void BuildGeometry() //set initial previous time to -1 so that the first polygon generated is always unique and doesn't trigger 'beat too close to previous' case double prevTime = -1.0; float samePatternChance = 0.90f; - float onsetStart = 0.0f; - float onsetEnd = 0.0f; float veryCloseJoinChance = 0.5f; float joinFunctionMultiplier = 20.0f; From 2c9554b1d54c329c78b15c3025ed0dd6cd699734 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Fri, 2 Sep 2016 01:36:00 +1000 Subject: [PATCH 33/49] Tweak level generation to have chance to swap skip pattern If beat within close distance. The opening is kept the same though --- .../Generation/StageGeometryBuilder.cs | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/TurntNinja/Generation/StageGeometryBuilder.cs b/src/TurntNinja/Generation/StageGeometryBuilder.cs index 9581924..9088ed4 100644 --- a/src/TurntNinja/Generation/StageGeometryBuilder.cs +++ b/src/TurntNinja/Generation/StageGeometryBuilder.cs @@ -159,14 +159,21 @@ private void BuildGeometry() } else if (s.Start - prevTime < _builderOptions.CloseDistance) { - //randomly choose relative orientation difference compared to previous beat - var r = _random.Next(0, 2); - if (r == 0) r = -1; - - //this beat is reasonably close to the previous one, use the same skip pattern but a different (+/- 1) orientation - start = (prevStart + 6) + r; - if (_random.NextDouble() < samePatternChance) - skip = prevSkip; + if (_random.NextDouble() < 0.5) + { + //randomly choose relative orientation difference compared to previous beat + var r = _random.Next(0, 2); + if (r == 0) r = -1; + + //this beat is reasonably close to the previous one, use the same skip pattern but a different (+/- 1) orientation + start = (prevStart + 6) + r; + if (_random.NextDouble() < samePatternChance) + skip = prevSkip; + } + else + { + start = prevStart; + } } else { From 29b4515d3e6135d57244304a6ef7c5f2aaa67b3f Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Fri, 2 Sep 2016 01:36:19 +1000 Subject: [PATCH 34/49] Tweak skip function to produce less of single skip hexagons --- src/TurntNinja/Generation/StageGeometryBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TurntNinja/Generation/StageGeometryBuilder.cs b/src/TurntNinja/Generation/StageGeometryBuilder.cs index 9088ed4..3bdd4cf 100644 --- a/src/TurntNinja/Generation/StageGeometryBuilder.cs +++ b/src/TurntNinja/Generation/StageGeometryBuilder.cs @@ -261,7 +261,7 @@ class GeometryBuilderOptions public GeometryBuilderOptions(ShaderProgram geometryShaderProgram) { GeometryShaderProgram = geometryShaderProgram; - SkipFunction = () => (int) (3*Math.Pow(RandomFunction.NextDouble(), 4)) + 1; + SkipFunction = () => (int) (3*Math.Pow(RandomFunction.NextDouble(), 2)) + 1; } public void ApplyDifficulty(DifficultyOptions options) From 789d4b5307bbf3ab0a95712353f4cbee9f4df7b9 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Fri, 2 Sep 2016 01:36:48 +1000 Subject: [PATCH 35/49] FirstRun scene now requires Enter to opt-in, Escape to opt-out Fixed wording as well --- src/TurntNinja/GUI/FirstRunScene.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/TurntNinja/GUI/FirstRunScene.cs b/src/TurntNinja/GUI/FirstRunScene.cs index 6783920..9bc8a24 100644 --- a/src/TurntNinja/GUI/FirstRunScene.cs +++ b/src/TurntNinja/GUI/FirstRunScene.cs @@ -31,7 +31,7 @@ class FirstRunScene : Scene string _headerText = "WELCOME TO TURNT NINJA"; string _bodyList = - "* Your operating system\n" + + "* Operating system version\n" + "* Game resolution\n" + "* Number of songs played\n" + "* Crash reports\n"; @@ -42,7 +42,7 @@ class FirstRunScene : Scene "data is collected if you opt in:\n"; string _bodyText2 = - "\nPlease press Enter to opt in, or any other key to opt out.\n\nThank you,\nPatrick"; + "\nPlease press Enter to opt in, or Escape to opt out.\n\nThank you,\nPatrick"; public FirstRunScene() { @@ -101,7 +101,7 @@ public override void Update(double time, bool focused = false) SceneManager.RemoveScene(this, true); } - else if (InputSystem.NewKeys.Any()) + else if (InputSystem.NewKeys.Contains(OpenTK.Input.Key.Escape)) { ServiceLocator.Settings["Analytics"] = false; From 5634302b76f74ce14b7212d4564911fc5a0206b2 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Fri, 2 Sep 2016 01:37:02 +1000 Subject: [PATCH 36/49] Fix disposing resources that aren't ours in LoadingScene --- src/TurntNinja/GUI/LoadingScene.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/TurntNinja/GUI/LoadingScene.cs b/src/TurntNinja/GUI/LoadingScene.cs index d586b37..dbeacda 100644 --- a/src/TurntNinja/GUI/LoadingScene.cs +++ b/src/TurntNinja/GUI/LoadingScene.cs @@ -170,9 +170,8 @@ public override void Draw(double time) public override void Dispose() { - if (_loadingFont != null) + if (_loadingFontDrawing != null) { - _loadingFont.Dispose(); _loadingFontDrawing.Dispose(); } } From d2c4529b5091e48964940bd5f7ff7cae4750ca55 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Fri, 2 Sep 2016 01:38:10 +1000 Subject: [PATCH 37/49] Add redesigned Options menu Faster Cleaner Looks nicer(ish) More cross-platform Doesn't use Gwen.NET (!) Extensible Easy to add new settings Also added two new settings (Fullscreen, Analytics) --- src/TurntNinja/GUI/MenuScene.cs | 2 +- src/TurntNinja/GUI/OptionsScene.cs | 562 +++++++++++++++++++---------- 2 files changed, 373 insertions(+), 191 deletions(-) diff --git a/src/TurntNinja/GUI/MenuScene.cs b/src/TurntNinja/GUI/MenuScene.cs index f4a0a11..9b07876 100644 --- a/src/TurntNinja/GUI/MenuScene.cs +++ b/src/TurntNinja/GUI/MenuScene.cs @@ -196,7 +196,7 @@ private void DoGUI() cs.Visible = true; break; case MainMenuOptions.Options: - SceneManager.AddScene(new OptionsScene(_GUIComponents), this); + SceneManager.AddScene(new OptionsScene(), this); break; case MainMenuOptions.Exit: Exit(); diff --git a/src/TurntNinja/GUI/OptionsScene.cs b/src/TurntNinja/GUI/OptionsScene.cs index d7f4f0f..6737292 100644 --- a/src/TurntNinja/GUI/OptionsScene.cs +++ b/src/TurntNinja/GUI/OptionsScene.cs @@ -6,273 +6,455 @@ using System.Text; using System.Threading.Tasks; using Substructio.GUI; -using Gwen; -using Gwen.Control; -using Gwen.Control.Layout; -using Gwen.Input; using Substructio.Core; -using Key = OpenTK.Input.Key; using TurntNinja.Game; +using OpenTK.Input; +using QuickFont; +using OpenTK; +using OpenTK.Graphics; namespace TurntNinja.GUI { class OptionsScene : Scene - { - private GUIComponentContainer _GUIComponents; - private Canvas _canvas; - private OpenTKAlternative _input; - private HorizontalSlider _correctionSlider; - private HorizontalSlider _volumeSlider; - private HorizontalSlider _difficultySlider; - private NumericUpDown _numericCorrection; - private NumericUpDown _numericVolume; - private Label _correctionLabel; - private Label _volumeLabel; - private Label _difficultyLabel; - private Label _currentDifficultyLabel; - private Base _correctionOptionsContainer; - private Base _volumeOptionsContainer; - private Base _difficultyOptionsContainer; + { private float _audioCorrection; - private float _maxAudioVolume; private DifficultyLevels _currentDifficulty; + private QFontDrawing _optionsDrawing; + private GameFont _optionsFont; + private GameFont _valueFont; + + List _options; + int _currentlySelectedOption = 0; - public OptionsScene(GUIComponentContainer guiComponents) + public OptionsScene() { - _GUIComponents = guiComponents; Exclusive = true; } public override void Load() { - _audioCorrection = (float)SceneManager.GameSettings["AudioCorrection"] * 1000f; - var vol = (float)SceneManager.GameSettings["MaxAudioVolume"]; - _maxAudioVolume = vol * 100f; - _currentDifficulty = (DifficultyLevels)SceneManager.GameSettings["DifficultyLevel"]; + _optionsFont = SceneManager.GameFontLibrary.GetFirstOrDefault(GameFontType.Heading); + _valueFont = SceneManager.GameFontLibrary.GetFirstOrDefault(GameFontType.Heading); + _optionsDrawing = new QFontDrawing(); + _optionsDrawing.ProjectionMatrix = SceneManager.ScreenCamera.ScreenProjectionMatrix; - _GUIComponents.Resize(SceneManager.ScreenCamera.ScreenProjectionMatrix, WindowWidth, WindowHeight); - _canvas = new Canvas(_GUIComponents.Skin); - _canvas.SetSize(WindowWidth, WindowHeight); - _input = new OpenTKAlternative(_canvas); - InputSystem.AddGUIInput(_input); + _options = new List(); - _difficultyOptionsContainer = new Base(_canvas); + var audioCorrection = (float)SceneManager.GameSettings["AudioCorrection"] * 1000f; + var vol = (float)Math.Round((float)SceneManager.GameSettings["MaxAudioVolume"] * 100); + var currentDifficulty = (DifficultyLevels)SceneManager.GameSettings["DifficultyLevel"]; + var analytics = (bool)ServiceLocator.Settings["Analytics"]; + var windowMode = (string)ServiceLocator.Settings["WindowState"]; - _difficultyLabel = new Label(_difficultyOptionsContainer) + _options.Add(new NumericOption { - Text = "Difficulty Level", - AutoSizeToContents = true, - TextColor = Color.White - }; - - _currentDifficultyLabel = new Label(_difficultyOptionsContainer) + FriendlyName = "Volume", + SettingName = "MaxAudioVolume", + Minimum = 0.0f, + Maximum = 100.0f, + Scale = 100.0f, + Round = true, + Step = 1.0f, + Value = vol + }); + + _options.Add(new NumericOption { - Text = _currentDifficulty.ToString(), - AutoSizeToContents = true, - TextColor = Color.White - }; - - _difficultySlider = new HorizontalSlider(_difficultyOptionsContainer); - _difficultySlider.SetRange(0, Enum.GetValues(typeof(DifficultyLevels)).Length - 1); - _difficultySlider.SetNotchSpacing(1); - _difficultySlider.SetSize(200, 20); - _difficultySlider.SnapToNotches = true; - - _difficultySlider.ValueChanged += (sender, arguments) => + FriendlyName = "Audio Correction", + SettingName = "AudioCorrection", + Minimum = -1000.0f, + Maximum = 1000.0f, + Scale = 1000.0f, + Round = true, + Step = 2.0f, + Value = audioCorrection + }); + + _options.Add(new EnumOption { - _currentDifficultyLabel.Text = ((DifficultyLevels)((int)_difficultySlider.Value)).ToString(); - _currentDifficulty = ((DifficultyLevels)((int)_difficultySlider.Value)); - }; + FriendlyName = "Difficulty", + SettingName = "DifficultyLevel", + Values = Enum.GetNames(typeof(DifficultyLevels)).ToList(), + CurrentIndex = Enum.GetNames(typeof(DifficultyLevels)).ToList().IndexOf(currentDifficulty.ToString()) + }); - _correctionOptionsContainer = new Base(_canvas); + _options.Add(new BoolOption + { + FriendlyName = "Analytics", + SettingName = "Analytics", + Value = analytics + }); - _correctionLabel = new Label(_correctionOptionsContainer) + var windowModes = new List { WindowState.Fullscreen.ToString(), WindowState.Normal.ToString() }; + _options.Add(new StringOption { - Text = "Audio Correction in Milliseconds", - AutoSizeToContents = true, - TextColor = Color.White - }; - - var range = 2000; - var notchSpacing = 200; - _correctionSlider = new HorizontalSlider(_correctionOptionsContainer); - _correctionSlider.SetRange(-range, range); - _correctionSlider.SetSize(200, 20); - _correctionSlider.SetNotchSpacing(notchSpacing); - _correctionSlider.SnapToNotches = false; - - _numericCorrection = new NumericUpDown(_correctionOptionsContainer) + FriendlyName = "Window Mode", + SettingName = "WindowState", + Values = windowModes, + CurrentIndex = windowModes.IndexOf(windowMode), + CallbackFunction = (s) => SceneManager.GameWindow.WindowState = (WindowState)Enum.Parse(typeof(WindowState), s) + }); + + foreach (var op in _options) { - Min = -2000, - Max = 2000, - IsTabable = false + op.Sanitise(); + } + Loaded = true; + } + + public override void CallBack(GUICallbackEventArgs e) + { + throw new NotImplementedException(); + } - }; - _numericCorrection.SetSize(130, _correctionLabel.Height + 10); - _numericCorrection.Margin = Margin.Two; + public override void Resize(EventArgs e) + { + _optionsDrawing.ProjectionMatrix = SceneManager.ScreenCamera.ScreenProjectionMatrix; + } - _correctionSlider.ValueChanged += (sender, arguments) => + public override void Update(double time, bool focused = false) + { + if (InputSystem.NewKeys.Contains(Key.Down)) { - if (_correctionSlider.Value != (int) Math.Round(_correctionSlider.Value)) - _correctionSlider.Value = (int) Math.Round(_correctionSlider.Value); - if (_numericCorrection.Value != _correctionSlider.Value) - _numericCorrection.Value = _correctionSlider.Value; - Debug.Print("Correction slider changed, value is " + _correctionSlider.Value); - }; - - _numericCorrection.ValueChanged += (sender, arguments) => + _currentlySelectedOption += 1; + if (_currentlySelectedOption >= _options.Count) _currentlySelectedOption = 0; + } + if (InputSystem.NewKeys.Contains(Key.Up)) { - if (_numericCorrection.Value != (int) Math.Round(_numericCorrection.Value)) - _numericCorrection.Value = (int) Math.Round(_numericCorrection.Value); - if (_correctionSlider.Value != _numericCorrection.Value) - _correctionSlider.Value = _numericCorrection.Value; - Debug.Print("Numeric Correction changed, value is " + _numericCorrection.Value); - }; - - _volumeOptionsContainer = new Base(_canvas); + _currentlySelectedOption -= 1; + if (_currentlySelectedOption < 0) _currentlySelectedOption = _options.Count - 1; + } - _volumeLabel = new Label(_volumeOptionsContainer) + var currentOption = _options[_currentlySelectedOption]; + if (InputSystem.NewKeys.Contains(Key.Left) && currentOption.CanMoveBackward()) { - Text = "Audio Volume", - AutoSizeToContents = true, - TextColor = Color.White - }; - - _volumeSlider = new HorizontalSlider(_volumeOptionsContainer); - _volumeSlider.SetSize(200, 20); - _volumeSlider.SetRange(0,100); - _volumeSlider.SetNotchSpacing(10); - _volumeSlider.SnapToNotches = false; - - _numericVolume = new NumericUpDown(_volumeOptionsContainer) + currentOption.MovePrevious(); + currentOption.RaiseOptionChanged(); + } + + if (InputSystem.NewKeys.Contains(Key.Right) && currentOption.CanMoveForward()) { - Min = 0, - Max = 100, - IsTabable = false - }; - _numericVolume.SetSize(100, _correctionLabel.Height + 10); - _numericVolume.Margin = Margin.Two; - - _volumeSlider.ValueChanged += (sender, arguments) => + currentOption.MoveNext(); + currentOption.RaiseOptionChanged(); + } + + if (InputSystem.NewKeys.Contains(Key.Escape)) { - if (_volumeSlider.Value != (int)Math.Round(_volumeSlider.Value)) - _volumeSlider.Value = (int)Math.Round(_volumeSlider.Value); - if (_numericVolume.Value != _volumeSlider.Value) - _numericVolume.Value = _volumeSlider.Value; - Debug.Print("Volume slider changed, value is " + _volumeSlider.Value); - }; - - _numericVolume.ValueChanged += (sender, arguments) => + foreach (var op in _options) + { + op.Sanitise(); + op.SaveSettings(); + } + SceneManager.RemoveScene(this, true); + } + } + + public override void Draw(double time) + { + _optionsDrawing.DrawingPrimitives.Clear(); + + float lineStep = Math.Max(_optionsFont.MaxLineHeight, _valueFont.MaxLineHeight); + float height = lineStep * _options.Count; + + float currentY = height / 2.0f; + + foreach (var op in _options) { - if (_numericVolume.Value != (int)Math.Round(_numericVolume.Value)) - _numericVolume.Value = (int)Math.Round(_numericVolume.Value); - if (_volumeSlider.Value != _numericVolume.Value) - _volumeSlider.Value = _numericVolume.Value; - Debug.Print("Numeric volume changed, value is " + _numericVolume.Value); - }; + var settingColour = Color4.White; + if (_options[_currentlySelectedOption] != op) + { + settingColour = Color.Black; + settingColour.A = 0.90f; + } + + var dp = new QFontDrawingPrimitive(_optionsFont.Font, new QFontRenderOptions { Colour = (Color)settingColour }); + dp.Print(op.FriendlyName + ":", Vector3.Zero, QFontAlignment.Centre); + dp.ModelViewMatrix = Matrix4.CreateTranslation(0, _optionsFont.MaxLineHeight * 0.5f, 0) + * Matrix4.CreateTranslation(-WindowWidth * 0.15f, currentY, 0); + _optionsDrawing.DrawingPrimitives.Add(dp); + + dp = new QFontDrawingPrimitive(_valueFont.Font, new QFontRenderOptions { Colour = (Color)settingColour }); + var valueSize = dp.Print(op.GetValue(), Vector3.Zero, QFontAlignment.Centre); + dp.ModelViewMatrix = Matrix4.CreateTranslation(0, _valueFont.MaxLineHeight * 0.5f, 0) + * Matrix4.CreateTranslation(WindowWidth * 0.15f, currentY, 0); + _optionsDrawing.DrawingPrimitives.Add(dp); + + if (op.CanMoveForward()) + { + dp = new QFontDrawingPrimitive(_valueFont.Font, new QFontRenderOptions { Colour = (Color)settingColour }); + dp.Print(op.GetNextValue(), Vector3.Zero, QFontAlignment.Left); + dp.ModelViewMatrix = Matrix4.CreateTranslation(0, _valueFont.MaxLineHeight * 0.5f, 0) + * Matrix4.CreateScale(0.80f) + * Matrix4.CreateTranslation(WindowWidth * 0.15f + valueSize.Width * 1.25f, currentY, 0); + _optionsDrawing.DrawingPrimitives.Add(dp); + } + if (op.CanMoveBackward()) + { + dp = new QFontDrawingPrimitive(_valueFont.Font, new QFontRenderOptions { Colour = (Color)settingColour }); + dp.Print(op.GetPrevValue(), Vector3.Zero, QFontAlignment.Right); + dp.ModelViewMatrix = Matrix4.CreateTranslation(0, _valueFont.MaxLineHeight * 0.5f, 0) + * Matrix4.CreateScale(0.80f) + * Matrix4.CreateTranslation(WindowWidth * 0.15f - valueSize.Width * 1.25f, currentY, 0); + _optionsDrawing.DrawingPrimitives.Add(dp); + } + + currentY -= lineStep; + } - _difficultySlider.Value = (int)_currentDifficulty; - _correctionSlider.Value = _numericCorrection.Value = _audioCorrection; - _volumeSlider.Value = _numericVolume.Value = _maxAudioVolume; - LayoutGUI(); + _optionsDrawing.RefreshBuffers(); + _optionsDrawing.Draw(); + } - _difficultySlider.Focus(); + public override void Dispose() + { + _optionsDrawing.Dispose(); + } - Loaded = true; + public override void EnterFocus() + { + InputSystem.RepeatingKeys.Add(Key.Left, KeyRepeatSettings.Default); + InputSystem.RepeatingKeys.Add(Key.Right, KeyRepeatSettings.Default); + InputSystem.RepeatingKeys.Add(Key.Up, KeyRepeatSettings.Default); + InputSystem.RepeatingKeys.Add(Key.Down, KeyRepeatSettings.Default); } - private void LayoutGUI() + public override void ExitFocus() { - //layout difficulty slider so that it's centered in the container - _difficultySlider.SetPosition((_difficultyLabel.Width - _difficultySlider.Width)/2, _difficultyLabel.Height); + InputSystem.RepeatingKeys.Remove(Key.Left); + InputSystem.RepeatingKeys.Remove(Key.Right); + InputSystem.RepeatingKeys.Remove(Key.Up); + InputSystem.RepeatingKeys.Remove(Key.Down); + } + } - //layout difficulty label - _difficultyLabel.SetPosition(0, 0); + public abstract class OptionBase + { + public string FriendlyName { get; set; } + public string SettingName { get; set; } - //layout current difficulty label - _currentDifficultyLabel.SetPosition((_difficultyLabel.Width - _currentDifficultyLabel.Width)/2, _difficultyLabel.Height + _difficultySlider.Height); + public abstract string GetValue(); + public abstract string GetNextValue(); + public abstract string GetPrevValue(); - //layout correction slider - _correctionSlider.SetPosition(-(_correctionSlider.Width + _numericCorrection.Width + 10) / 2 + _correctionLabel.TextWidth / 2, _correctionLabel.Height * 2); + public abstract bool CanMoveForward(); + public abstract bool CanMoveBackward(); - //layout numeric correction - Align.PlaceRightBottom(_numericCorrection, _correctionSlider, 10); + public abstract void SaveSettings(); - //layout volume slider - _volumeSlider.SetPosition(0, _volumeLabel.Height * 2); + public abstract void MoveNext(); + public abstract void MovePrevious(); + public abstract void Sanitise(); - //layout volume label - _volumeLabel.SetPosition((_volumeSlider.Width + _numericVolume.Width + 10)/2 - _volumeLabel.Width/2, 0); + public void RaiseOptionChanged() + { + OptionCallback.Invoke(this); + } - //layout numeric volume - Align.PlaceRightBottom(_numericVolume, _volumeSlider, 10); + public delegate void OptionCallbackEvent(OptionBase sender); - //size containers to their children - _correctionOptionsContainer.SizeToChildren(); - _volumeOptionsContainer.SizeToChildren(); - _difficultyOptionsContainer.SizeToChildren(); + public event OptionCallbackEvent OptionCallback; + } - //find max width - var maxWidth = Math.Max(_correctionOptionsContainer.Width, _volumeOptionsContainer.Width); + public class BoolOption : OptionBase + { + public bool Value { get; set; } - var h = _difficultyOptionsContainer.Height; - _difficultyOptionsContainer.SetPosition((WindowWidth / 2 - _difficultyOptionsContainer.Width / 2), WindowHeight / 2 - h); + public BoolOption() + { + OptionCallback += (s) => CallbackFunction(Value); + } - //layout correction options container - _correctionOptionsContainer.SetPosition((int)(WindowWidth / 2 - maxWidth + (maxWidth - _correctionOptionsContainer.Width)/2), WindowHeight / 2 - _correctionOptionsContainer.Height / 2 + h); + public override bool CanMoveBackward() + { + return Value; + } - //layout volume options container - _volumeOptionsContainer.SetPosition((int) (WindowWidth / 2 + (maxWidth - _volumeOptionsContainer.Width)/2), WindowHeight / 2 - _volumeOptionsContainer.Height / 2 + h); + public override bool CanMoveForward() + { + return !Value; + } + public override string GetNextValue() + { + return (!Value).ToString(); } - public override void CallBack(GUICallbackEventArgs e) + public override string GetPrevValue() { - throw new NotImplementedException(); + return (!Value).ToString(); } - public override void Resize(EventArgs e) + public override string GetValue() { - _GUIComponents.Resize(SceneManager.ScreenCamera.ScreenProjectionMatrix, WindowWidth, WindowHeight); - _canvas.SetSize(WindowWidth, WindowHeight); - LayoutGUI(); + return Value.ToString(); } - public override void Update(double time, bool focused = false) + public override void MoveNext() { - if (InputSystem.NewKeys.Contains(Key.Escape)) - { - _audioCorrection = _correctionSlider.Value*0.001f; - _maxAudioVolume = _volumeSlider.Value*0.01f; - SceneManager.GameSettings["AudioCorrection"] = _audioCorrection; - SceneManager.GameSettings["MaxAudioVolume"] = _maxAudioVolume; - SceneManager.GameSettings["DifficultyLevel"] = (int)_currentDifficulty; - SceneManager.RemoveScene(this); - } + Value = !Value; + } - if (InputSystem.NewKeys.Contains(Key.Tab) && _volumeSlider.HasFocus) - _difficultySlider.Focus(); + public override void MovePrevious() + { + Value = !Value; } - public override void Draw(double time) + public override void Sanitise() { - _canvas.RenderCanvas(); } - public override void Dispose() + public override void SaveSettings() { - InputSystem.RemoveGUIInput(_input); - _canvas.Dispose(); + ServiceLocator.Settings[SettingName] = Value; } - public override void EnterFocus() + public Action CallbackFunction { get; set; } = (_) => { }; + } + + public class StringOption : OptionBase + { + public string CurrentValue { get { return Values[CurrentIndex]; } } + public int CurrentIndex { get; set; } = 0; + public List Values { get; set; } + + public StringOption() { + OptionCallback += (_) => CallbackFunction(CurrentValue); } - public override void ExitFocus() + public override bool CanMoveBackward() + { + return CurrentIndex > 0; + } + + public override bool CanMoveForward() + { + return CurrentIndex < Values.Count - 1; + } + + public override string GetNextValue() + { + return Values[CurrentIndex + 1]; + } + + public override string GetPrevValue() + { + return Values[CurrentIndex - 1]; + } + + public override string GetValue() + { + return CurrentValue; + } + + public override void MoveNext() + { + CurrentIndex += 1; + } + + public override void MovePrevious() + { + CurrentIndex -= 1; + } + + public override void Sanitise() + { + MathHelper.Clamp(CurrentIndex, 0, Values.Count - 1); + } + + public override void SaveSettings() + { + ServiceLocator.Settings[SettingName] = CurrentValue; + } + + public Action CallbackFunction { get; set; } = (_) => { }; + } + + public class EnumOption : StringOption + { + public override void SaveSettings() { + ServiceLocator.Settings[SettingName] = Enum.Parse(typeof(T), CurrentValue); } } + + public class NumericOption : OptionBase + { + public float Value { get; set; } + public float Step { get; set; } + public float Maximum { get; set; } + public float Minimum { get; set; } + public bool Round { get; set; } + public float Scale { get; set; } = 0.0f; + + public NumericOption() + { + OptionCallback += (_) => CallbackFunction(Value); + } + + public override bool CanMoveBackward() + { + return Value >= (Minimum + Step); + } + + public override bool CanMoveForward() + { + return Value <= (Maximum - Step); + } + + public override string GetNextValue() + { + return GetNext().ToString(); + } + + public override string GetPrevValue() + { + return GetPrevious().ToString(); + } + + public override string GetValue() + { + return Value.ToString(); + } + + public override void MoveNext() + { + Value = GetNext(); + } + + public override void MovePrevious() + { + Value = GetPrevious(); + } + + public override void Sanitise() + { + Value = MathHelper.Clamp(Value, Minimum, Maximum); + } + + public override void SaveSettings() + { + ServiceLocator.Settings[SettingName] = Value / Scale; + } + + private float GetNext() + { + var n = Value + Step; + n = MathHelper.Clamp(n, Minimum, Maximum); + if (Round) n = (float)Math.Round(n); + return n; + } + + private float GetPrevious() + { + var n = Value - Step; + n = MathHelper.Clamp(n, Minimum, Maximum); + if (Round) n = (float)Math.Round(n); + return n; + } + + public Action CallbackFunction { get; set; } = (_) => { }; + } } From 89607438cae0c0e16c354fb5b997a8945633b962 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Fri, 2 Sep 2016 01:38:23 +1000 Subject: [PATCH 38/49] Use a better font choice in UpdateScene --- src/TurntNinja/GUI/UpdateScene.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/TurntNinja/GUI/UpdateScene.cs b/src/TurntNinja/GUI/UpdateScene.cs index 14d35b7..7580dc8 100644 --- a/src/TurntNinja/GUI/UpdateScene.cs +++ b/src/TurntNinja/GUI/UpdateScene.cs @@ -26,6 +26,7 @@ class UpdateScene : Scene private Dictionary _releaseNotes; Exception _ex = null; CancellationTokenSource _cancellationTokenSource; + GameFont _updateFont; const string LOCALPACKAGEHOST = @"D:\Patrick\Documents\Development\Game Related\turnt-ninja\Releases"; const string GITHUBPACKAGEHOST = "https://github.com/opcon/turnt-ninja"; @@ -45,12 +46,13 @@ public UpdateScene() public override void Draw(double time) { - var tSize = SceneManager.DefaultFont.Font.Measure(_statusString); - SceneManager.DrawTextLine(_statusString, new OpenTK.Vector3(0, tSize.Height/2, 0), Color4.White); + var tSize = _updateFont.Font.Measure(_statusString); + SceneManager.DrawTextLine(_statusString, new OpenTK.Vector3(0, tSize.Height/2, 0), Color4.White, font: _updateFont.Font); } public override void Load() { + _updateFont = SceneManager.GameFontLibrary.GetFirstOrDefault(GameFontType.Heading); _cancellationTokenSource = new CancellationTokenSource(); if (_isSquirrel) From aee33a62ac4d47e69e63d7aedb18b027342b9bb5 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Sat, 3 Sep 2016 19:57:22 +1000 Subject: [PATCH 39/49] don't show recent file system first if it is empty Show Local File System instead --- src/TurntNinja/FileSystem/DirectoryBrowser.cs | 11 +++++++++-- src/TurntNinja/GUI/ChooseSongScene.cs | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/TurntNinja/FileSystem/DirectoryBrowser.cs b/src/TurntNinja/FileSystem/DirectoryBrowser.cs index 8fa8a40..eb39a40 100644 --- a/src/TurntNinja/FileSystem/DirectoryBrowser.cs +++ b/src/TurntNinja/FileSystem/DirectoryBrowser.cs @@ -97,6 +97,12 @@ private void ResetSearch() _searchString = ""; } + public void SwitchCurrentFileSystemIfEmpty() + { + if (_currentFileSystem.FileSystemEntryCollection.Count == 0) + SwitchFileSystem(_fileSystemCollection.Find(f => f is LocalFileSystem)); + } + public void RefreshRecentSongFilesystem() { foreach (var f in _fileSystemCollection) @@ -238,6 +244,7 @@ public void Draw(double time) int currentFSIndex = _fileSystemCollection.IndexOf(_currentFileSystem); // Draw two file systems on either side + float unselectedFsScale = 0.9f; col = Color4.White; col.A = 0.70f; @@ -249,7 +256,7 @@ public void Draw(double time) Vector3.Zero, QFontAlignment.Left); dp.ModelViewMatrix = Matrix4.CreateTranslation(new Vector3(0, size.Height * 2.0f, 0)) - * Matrix4.CreateScale(0.9f) + * Matrix4.CreateScale(unselectedFsScale) * Matrix4.CreateTranslation(new Vector3(size.Width * 0.75f, _parentManager.Height / 2 - size.Height * 2.0f, 0)); _qfontDrawing.DrawingPrimitives.Add(dp); @@ -261,7 +268,7 @@ public void Draw(double time) Vector3.Zero, QFontAlignment.Right); dp.ModelViewMatrix = Matrix4.CreateTranslation(new Vector3(0, size.Height * 2.0f, 0)) - * Matrix4.CreateScale(0.9f) + * Matrix4.CreateScale(unselectedFsScale) * Matrix4.CreateTranslation(new Vector3(-size.Width * 0.75f, _parentManager.Height / 2 - size.Height * 2.0f, 0)); _qfontDrawing.DrawingPrimitives.Add(dp); diff --git a/src/TurntNinja/GUI/ChooseSongScene.cs b/src/TurntNinja/GUI/ChooseSongScene.cs index c19dbbe..cd1422a 100644 --- a/src/TurntNinja/GUI/ChooseSongScene.cs +++ b/src/TurntNinja/GUI/ChooseSongScene.cs @@ -56,6 +56,8 @@ public override void Load() // Make sure to add recent file system last! _directoryBrowser.AddFileSystem(new RecentFileSystem(_recentSongs)); + _directoryBrowser.SwitchCurrentFileSystemIfEmpty(); + _directoryBrowser.Resize(WindowWidth, WindowHeight); Loaded = true; } From bc441b9fefd689199ecd04172208a5f64ee9c7ff Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Sat, 3 Sep 2016 19:58:22 +1000 Subject: [PATCH 40/49] Improve Options Scene scaling Also add audio correction units (ms) --- src/TurntNinja/GUI/OptionsScene.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/TurntNinja/GUI/OptionsScene.cs b/src/TurntNinja/GUI/OptionsScene.cs index 6737292..40558d3 100644 --- a/src/TurntNinja/GUI/OptionsScene.cs +++ b/src/TurntNinja/GUI/OptionsScene.cs @@ -61,7 +61,7 @@ public override void Load() _options.Add(new NumericOption { - FriendlyName = "Audio Correction", + FriendlyName = "Audio Correction (ms)", SettingName = "AudioCorrection", Minimum = -1000.0f, Maximum = 1000.0f, @@ -158,6 +158,7 @@ public override void Draw(double time) float height = lineStep * _options.Count; float currentY = height / 2.0f; + float unselectedValueScale = 0.8f; foreach (var op in _options) { @@ -184,18 +185,16 @@ public override void Draw(double time) { dp = new QFontDrawingPrimitive(_valueFont.Font, new QFontRenderOptions { Colour = (Color)settingColour }); dp.Print(op.GetNextValue(), Vector3.Zero, QFontAlignment.Left); - dp.ModelViewMatrix = Matrix4.CreateTranslation(0, _valueFont.MaxLineHeight * 0.5f, 0) - * Matrix4.CreateScale(0.80f) - * Matrix4.CreateTranslation(WindowWidth * 0.15f + valueSize.Width * 1.25f, currentY, 0); + dp.ModelViewMatrix = Matrix4.CreateScale(unselectedValueScale) + * Matrix4.CreateTranslation(WindowWidth * 0.15f + valueSize.Width * 1.25f, currentY + _valueFont.Font.MaxLineHeight * 0.5f * unselectedValueScale, 0); _optionsDrawing.DrawingPrimitives.Add(dp); } if (op.CanMoveBackward()) { dp = new QFontDrawingPrimitive(_valueFont.Font, new QFontRenderOptions { Colour = (Color)settingColour }); dp.Print(op.GetPrevValue(), Vector3.Zero, QFontAlignment.Right); - dp.ModelViewMatrix = Matrix4.CreateTranslation(0, _valueFont.MaxLineHeight * 0.5f, 0) - * Matrix4.CreateScale(0.80f) - * Matrix4.CreateTranslation(WindowWidth * 0.15f - valueSize.Width * 1.25f, currentY, 0); + dp.ModelViewMatrix = Matrix4.CreateScale(unselectedValueScale) + * Matrix4.CreateTranslation(WindowWidth * 0.15f - valueSize.Width * 1.25f, currentY + _valueFont.Font.MaxLineHeight * 0.5f * unselectedValueScale, 0); _optionsDrawing.DrawingPrimitives.Add(dp); } From c02b8d01689df77098b9ebe5533048f943ccf0be Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Sat, 3 Sep 2016 23:20:27 +1000 Subject: [PATCH 41/49] Decrease onset threshold to 2.5 --- src/TurntNinja/App.config | 154 +++++++++--------- .../Properties/Settings.Designer.cs | 2 +- src/TurntNinja/Properties/Settings.settings | 2 +- 3 files changed, 79 insertions(+), 79 deletions(-) diff --git a/src/TurntNinja/App.config b/src/TurntNinja/App.config index 4b0fa82..9036ad2 100644 --- a/src/TurntNinja/App.config +++ b/src/TurntNinja/App.config @@ -38,85 +38,85 @@ - - 0 - - - 1 - - - 1280 - - - 720 - - - 4 - - - True - - - Normal - - - 9 - - - False - - - 50 - - - 0 - - - False - - - 0.2 - - - 10 - - - False - - - True - - - turnt-ninja.db - - - opcon - - - - - - False - - - True - - + + 0 + + + 1 + + + 1280 + + + 720 + + + 4 + + + True + + + Normal + + + 2.5 + + + False + + + 50 + + + 0 + + + False + + + 0.2 + + + 10 + + + False + + + True + + + turnt-ninja.db + + + opcon + + + + + + False + + + True + + - - .mp3,.flac,.wav,.m4a,.wma - - - turnt-ninja - - - oeoywrZVrjYlcctPZZ3uTXFPp9ItVUkR3w28u+WDdd9SqYzE1PRkb+WPZsYQ+VvOfUjFQOlQ1tXc7oDXY4Km7A== - - - jA9OAo1hWfHPOoMipHAAaFxFf2N7iP8zuBEI9LVQq5ET0vc8yqnLsO/oNMqCcki0rvD4CQrkMz7fWHQ4rWuHAyRfY+7nxGinxdbgIaceyVtKOJLsSnbBh4/NBq3OkBIAFG2GTxUhWqyJbxNhgzbu+0HM8jv43LY53bxhwIALt+A= - - + + .mp3,.flac,.wav,.m4a,.wma + + + turnt-ninja + + + oeoywrZVrjYlcctPZZ3uTXFPp9ItVUkR3w28u+WDdd9SqYzE1PRkb+WPZsYQ+VvOfUjFQOlQ1tXc7oDXY4Km7A== + + + jA9OAo1hWfHPOoMipHAAaFxFf2N7iP8zuBEI9LVQq5ET0vc8yqnLsO/oNMqCcki0rvD4CQrkMz7fWHQ4rWuHAyRfY+7nxGinxdbgIaceyVtKOJLsSnbBh4/NBq3OkBIAFG2GTxUhWqyJbxNhgzbu+0HM8jv43LY53bxhwIALt+A= + + \ No newline at end of file diff --git a/src/TurntNinja/Properties/Settings.Designer.cs b/src/TurntNinja/Properties/Settings.Designer.cs index 8cbc0c3..8e73397 100644 --- a/src/TurntNinja/Properties/Settings.Designer.cs +++ b/src/TurntNinja/Properties/Settings.Designer.cs @@ -127,7 +127,7 @@ public string AppDataFolderName { [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("9")] + [global::System.Configuration.DefaultSettingValueAttribute("2.5")] public float OnsetActivationThreshold { get { return ((float)(this["OnsetActivationThreshold"])); diff --git a/src/TurntNinja/Properties/Settings.settings b/src/TurntNinja/Properties/Settings.settings index e3412cc..a69ebdf 100644 --- a/src/TurntNinja/Properties/Settings.settings +++ b/src/TurntNinja/Properties/Settings.settings @@ -30,7 +30,7 @@ turnt-ninja - 9 + 2.5 False From c5e1426d6ac3e9a4dc1b8db45a50c84f25988af5 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Sat, 3 Sep 2016 23:20:38 +1000 Subject: [PATCH 42/49] Fix enum settings not saving correctly --- src/TurntNinja/GUI/OptionsScene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TurntNinja/GUI/OptionsScene.cs b/src/TurntNinja/GUI/OptionsScene.cs index 40558d3..b2ce494 100644 --- a/src/TurntNinja/GUI/OptionsScene.cs +++ b/src/TurntNinja/GUI/OptionsScene.cs @@ -375,7 +375,7 @@ public class EnumOption : StringOption { public override void SaveSettings() { - ServiceLocator.Settings[SettingName] = Enum.Parse(typeof(T), CurrentValue); + ServiceLocator.Settings[SettingName] = (int)Enum.Parse(typeof(T), CurrentValue); } } From 698ab66d231cdcdfe34c93a8bc709bd52d8cf9d5 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Sun, 4 Sep 2016 00:00:04 +1000 Subject: [PATCH 43/49] Increase minimum onset delta to 7.5f --- src/TurntNinja/Game/Stage.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TurntNinja/Game/Stage.cs b/src/TurntNinja/Game/Stage.cs index 4a19af4..9046e34 100644 --- a/src/TurntNinja/Game/Stage.cs +++ b/src/TurntNinja/Game/Stage.cs @@ -165,7 +165,7 @@ public void LoadAsync(Song song, float audioCorrection, float maxAudioVolume, IP private void LoadAudioFeatures(CSCore.IWaveSource audioSource, float correction, IProgress progress, Song s) { var options = DetectorOptions.Default; - options.MinimumTimeDelta = 5f; + options.MinimumTimeDelta = 7.5f; options.ActivationThreshold = (float)SceneManager.GameSettings["OnsetActivationThreshold"]; options.AdaptiveWhitening = (bool)SceneManager.GameSettings["OnsetAdaptiveWhitening"]; options.Online = (bool)SceneManager.GameSettings["OnsetOnline"]; From 25d938f6ff63ceed2c13a89844a29bd4f0a69537 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Sun, 25 Sep 2016 16:06:39 +1000 Subject: [PATCH 44/49] Update MathNet.Numerics from 3.13 to 3.13.1 --- paket.dependencies | 2 +- paket.lock | 2 +- src/TurntNinja/paket.references | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/paket.dependencies b/paket.dependencies index a356e3f..40e9cef 100644 --- a/paket.dependencies +++ b/paket.dependencies @@ -38,4 +38,4 @@ nuget Microsoft.Data.Services.Client = 5.6.1 group Build source https://www.nuget.org/api/v2/ - nuget FAKE + nuget FAKE \ No newline at end of file diff --git a/paket.lock b/paket.lock index 1266772..7b185e9 100644 --- a/paket.lock +++ b/paket.lock @@ -6,7 +6,7 @@ NUGET DeltaCompressionDotNet (1.0) - framework: >= net45 HUSL (1.0.1) - framework: >= net45 LiteDB (2.0.2) - framework: >= net45 - MathNet.Numerics (3.13) - framework: >= net45 + MathNet.Numerics (3.13.1) - framework: >= net45 Mono.Cecil (0.9.6.1) - framework: >= net45 Newtonsoft.Json (9.0.1) NuGet.CommandLine (3.4.3) diff --git a/src/TurntNinja/paket.references b/src/TurntNinja/paket.references index 431ff49..c8abbc5 100644 --- a/src/TurntNinja/paket.references +++ b/src/TurntNinja/paket.references @@ -18,4 +18,4 @@ Splat squirrel.windows TagLib.Portable SharpRaven -AcoustID.NET +AcoustID.NET \ No newline at end of file From f684aef6caf5551f9aecebfe808cc965a6b65882 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Sun, 25 Sep 2016 16:07:39 +1000 Subject: [PATCH 45/49] Update project file --- src/TurntNinja/TurntNinja.csproj | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/TurntNinja/TurntNinja.csproj b/src/TurntNinja/TurntNinja.csproj index 1507f19..7c53a55 100644 --- a/src/TurntNinja/TurntNinja.csproj +++ b/src/TurntNinja/TurntNinja.csproj @@ -1,5 +1,5 @@  - + @@ -168,7 +168,6 @@ True - PreserveNewest From 1a32839f625b046ebb5ce2ac712260663d2a3be1 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Sun, 25 Sep 2016 16:51:07 +1000 Subject: [PATCH 46/49] Add new colourmode setting for black and white or regular --- src/TurntNinja/App.config | 61 ++++++++++--------- .../Properties/Settings.Designer.cs | 12 ++++ src/TurntNinja/Properties/Settings.settings | 3 + 3 files changed, 47 insertions(+), 29 deletions(-) diff --git a/src/TurntNinja/App.config b/src/TurntNinja/App.config index 9036ad2..38347f5 100644 --- a/src/TurntNinja/App.config +++ b/src/TurntNinja/App.config @@ -1,41 +1,41 @@ - + -
+
-
+
- + - - - - True - - - - - True - - - - - True - - - - - True - - - - - + + + + + True + + + + + True + + + + + True + + + + + True + + + + @@ -101,6 +101,9 @@ True + + 0 + @@ -119,4 +122,4 @@ - \ No newline at end of file + diff --git a/src/TurntNinja/Properties/Settings.Designer.cs b/src/TurntNinja/Properties/Settings.Designer.cs index 8e73397..481b145 100644 --- a/src/TurntNinja/Properties/Settings.Designer.cs +++ b/src/TurntNinja/Properties/Settings.Designer.cs @@ -313,5 +313,17 @@ public bool FirstRun { this["FirstRun"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("0")] + public int ColourMode { + get { + return ((int)(this["ColourMode"])); + } + set { + this["ColourMode"] = value; + } + } } } diff --git a/src/TurntNinja/Properties/Settings.settings b/src/TurntNinja/Properties/Settings.settings index a69ebdf..03f3a15 100644 --- a/src/TurntNinja/Properties/Settings.settings +++ b/src/TurntNinja/Properties/Settings.settings @@ -77,5 +77,8 @@ True + + 0 + \ No newline at end of file From f33b5d3fcf31acb22b81c0a1dac9b90c23fdbae3 Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Sun, 25 Sep 2016 16:51:35 +1000 Subject: [PATCH 47/49] Add black and white mode selectable from options menu Also increased perspective shift amount --- src/TurntNinja/GUI/GameScene.cs | 2 +- src/TurntNinja/GUI/OptionsScene.cs | 11 ++++++++++- src/TurntNinja/Game/Stage.cs | 6 ++++-- src/TurntNinja/Game/StageGeometry.cs | 29 +++++++++++++++++++++++----- 4 files changed, 39 insertions(+), 9 deletions(-) diff --git a/src/TurntNinja/GUI/GameScene.cs b/src/TurntNinja/GUI/GameScene.cs index b3728e9..97da5fd 100644 --- a/src/TurntNinja/GUI/GameScene.cs +++ b/src/TurntNinja/GUI/GameScene.cs @@ -86,7 +86,7 @@ public override void Update(double time, bool focused = false) public override void Draw(double time) { _elapsedTime += time; - var rot = Matrix4.CreateRotationX((float)((MathHelper.PiOver4 / 1.5)*Math.Sin((_elapsedTime*0.18)))); + var rot = Matrix4.CreateRotationX((float)((MathHelper.PiOver4 / 1.25)*Math.Sin((_elapsedTime*0.20)))); ShaderProgram.Bind(); ShaderProgram.SetUniform("mvp", Matrix4.Mult(rot, SceneManager.ScreenCamera.WorldModelViewProjection)); _stage.Draw(time); diff --git a/src/TurntNinja/GUI/OptionsScene.cs b/src/TurntNinja/GUI/OptionsScene.cs index b2ce494..88a5e83 100644 --- a/src/TurntNinja/GUI/OptionsScene.cs +++ b/src/TurntNinja/GUI/OptionsScene.cs @@ -46,6 +46,7 @@ public override void Load() var currentDifficulty = (DifficultyLevels)SceneManager.GameSettings["DifficultyLevel"]; var analytics = (bool)ServiceLocator.Settings["Analytics"]; var windowMode = (string)ServiceLocator.Settings["WindowState"]; + var colourMode = (ColourMode)ServiceLocator.Settings["ColourMode"]; _options.Add(new NumericOption { @@ -86,7 +87,7 @@ public override void Load() Value = analytics }); - var windowModes = new List { WindowState.Fullscreen.ToString(), WindowState.Normal.ToString() }; + var windowModes = new List { WindowState.Fullscreen.ToString(), WindowState.Normal.ToString() }; _options.Add(new StringOption { FriendlyName = "Window Mode", @@ -96,6 +97,14 @@ public override void Load() CallbackFunction = (s) => SceneManager.GameWindow.WindowState = (WindowState)Enum.Parse(typeof(WindowState), s) }); + _options.Add(new EnumOption + { + FriendlyName = "Colour Mode", + SettingName = "ColourMode", + Values = Enum.GetNames(typeof(ColourMode)).ToList(), + CurrentIndex = Enum.GetNames(typeof(ColourMode)).ToList().IndexOf(colourMode.ToString()) + }); + foreach (var op in _options) { op.Sanitise(); diff --git a/src/TurntNinja/Game/Stage.cs b/src/TurntNinja/Game/Stage.cs index 9046e34..114c1d7 100644 --- a/src/TurntNinja/Game/Stage.cs +++ b/src/TurntNinja/Game/Stage.cs @@ -147,6 +147,7 @@ public void LoadAsync(Song song, float audioCorrection, float maxAudioVolume, IP StageGeometry.Player = player; StageGeometry.CenterPolygon = centerPolygon; StageGeometry.RotationSpeed = _difficultyOptions.RotationSpeed; + StageGeometry.CurrentColourMode = (ColourMode)ServiceLocator.Settings["ColourMode"]; progress.Report("Load complete"); Thread.Sleep(1000); @@ -244,12 +245,13 @@ public void Draw(double time) MultiplierFontDrawing.DrawingPrimitives.Clear(); MultiplierFontDrawing.Print(MultiplierFont.Font, _centerText, new Vector3(0, MultiplierFont.Font.Measure("0", QFontAlignment.Centre).Height * 0.5f, 0), - QFontAlignment.Centre); + QFontAlignment.Centre, (Color?)StageGeometry.TextColour); MultiplierFontDrawing.RefreshBuffers(); MultiplierFontDrawing.Draw(); ScoreFontDrawing.DrawingPrimitives.Clear(); - ScoreFontDrawing.Print(MultiplierFont.Font, StageGeometry.Player.Score.ToString("N0", CultureInfo.CurrentCulture), new Vector3(-SceneManager.Width / 2 + 20, SceneManager.Height/2 - 10, 0), QFontAlignment.Left, Color.White); + ScoreFontDrawing.Print(MultiplierFont.Font, StageGeometry.Player.Score.ToString("N0", CultureInfo.CurrentCulture), new Vector3(-SceneManager.Width / 2 + 20, SceneManager.Height / 2 - 10, 0), + QFontAlignment.Left, (Color?)StageGeometry.TextColour); ScoreFontDrawing.RefreshBuffers(); ScoreFontDrawing.Draw(); } diff --git a/src/TurntNinja/Game/StageGeometry.cs b/src/TurntNinja/Game/StageGeometry.cs index 1ccb997..1fdb064 100644 --- a/src/TurntNinja/Game/StageGeometry.cs +++ b/src/TurntNinja/Game/StageGeometry.cs @@ -12,6 +12,7 @@ using Substructio.Core.Math; using HUSL; using OpenTK.Input; +using System.Drawing; namespace TurntNinja.Game { @@ -81,6 +82,9 @@ public bool OutOfBeats get { return Onsets.OnsetIndex == Onsets.Count; } } + public Color4 TextColour { get; internal set; } = Color.White; + public ColourMode CurrentColourMode { get; set; } = ColourMode.Regular; + internal StageGeometry (OnsetCollection onsets, OnsetDrawing onsetDrawing, Color4 segmentStartColour, Random random) { Onsets = onsets; @@ -211,7 +215,10 @@ public void Draw(double time) ParentStage.ShaderProgram.SetUniform("in_color", _colours.OddOutlineColour); CenterPolygon.DrawOutline(time, 2); - ParentStage.ShaderProgram.SetUniform("in_color", Color4.White); + if (CurrentColourMode == ColourMode.BlackAndWhite) + ParentStage.ShaderProgram.SetUniform("in_color", _colours.EvenOpposingColour); + else if (CurrentColourMode == ColourMode.Regular) + ParentStage.ShaderProgram.SetUniform("in_color", Color4.White); Player.Draw(time); ParentStage.ShaderProgram.SetUniform("in_color", Color4.SkyBlue); //_p2.Draw(time); @@ -351,15 +358,19 @@ public void UpdateColours(double time) _colours.OddOutlineColour = HUSLColor.ToColor4(GetOutlineColour(fOdd)); // Black and White - //_colours.EvenOpposingColour = _colours.OddOpposingColour = Color4.Black; - //_colours.EvenBackgroundColour = _colours.OddBackgroundColour = Color4.White; - //_colours.OddOutlineColour = _colours.EvenOutlineColour = Color4.White; + if (CurrentColourMode == ColourMode.BlackAndWhite) + { + _colours.EvenOpposingColour = _colours.OddOpposingColour = Color4.Black; + _colours.EvenBackgroundColour = _colours.OddBackgroundColour = Color4.White; + _colours.OddOutlineColour = _colours.EvenOutlineColour = Color4.White; + } // Swap colours if required if (_swapColours) { // Handle outlines for black and white - // _colours.OddOutlineColour = _colours.EvenOutlineColour = Color4.Black; + if (CurrentColourMode == ColourMode.BlackAndWhite) + _colours.OddOutlineColour = _colours.EvenOutlineColour = Color4.Black; var t1 = _colours.EvenBackgroundColour; var t2 = _colours.OddBackgroundColour; @@ -368,6 +379,8 @@ public void UpdateColours(double time) _colours.EvenOpposingColour = t2; _colours.OddOpposingColour = t1; } + if (CurrentColourMode == ColourMode.BlackAndWhite) + TextColour = _colours.OddOpposingColour; } @@ -423,4 +436,10 @@ public override string ToString() } } + + enum ColourMode + { + BlackAndWhite = 1, + Regular = 0 + } } From 10d85b73f7b5eecbeed28f9c336951b22e6d579e Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Mon, 26 Sep 2016 12:10:41 +1000 Subject: [PATCH 48/49] change overall background colour them to black and white --- src/TurntNinja/FileSystem/DirectoryBrowser.cs | 5 ++--- src/TurntNinja/GUI/OptionsScene.cs | 2 ++ src/TurntNinja/GameController.cs | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/TurntNinja/FileSystem/DirectoryBrowser.cs b/src/TurntNinja/FileSystem/DirectoryBrowser.cs index eb39a40..163912e 100644 --- a/src/TurntNinja/FileSystem/DirectoryBrowser.cs +++ b/src/TurntNinja/FileSystem/DirectoryBrowser.cs @@ -218,8 +218,7 @@ public void Update(double time) public void Draw(double time) { _qfontDrawing.DrawingPrimitives.Clear(); - var col = Color4.Black; - col.A = 0.90f; + var col = Color4.White; if (_fileSystemEntries.Count > 0) { @@ -247,7 +246,7 @@ public void Draw(double time) float unselectedFsScale = 0.9f; col = Color4.White; - col.A = 0.70f; + col.A = 1.0f; var dp = new QFontDrawingPrimitive(_selectedFont.Font, new QFontRenderOptions { Colour = (System.Drawing.Color)col }); // Draw next fs on right diff --git a/src/TurntNinja/GUI/OptionsScene.cs b/src/TurntNinja/GUI/OptionsScene.cs index 88a5e83..bc1e0af 100644 --- a/src/TurntNinja/GUI/OptionsScene.cs +++ b/src/TurntNinja/GUI/OptionsScene.cs @@ -222,6 +222,7 @@ public override void Dispose() public override void EnterFocus() { + OpenTK.Graphics.OpenGL4.GL.ClearColor(Color.White); InputSystem.RepeatingKeys.Add(Key.Left, KeyRepeatSettings.Default); InputSystem.RepeatingKeys.Add(Key.Right, KeyRepeatSettings.Default); InputSystem.RepeatingKeys.Add(Key.Up, KeyRepeatSettings.Default); @@ -230,6 +231,7 @@ public override void EnterFocus() public override void ExitFocus() { + OpenTK.Graphics.OpenGL4.GL.ClearColor(Color.Black); InputSystem.RepeatingKeys.Remove(Key.Left); InputSystem.RepeatingKeys.Remove(Key.Right); InputSystem.RepeatingKeys.Remove(Key.Up); diff --git a/src/TurntNinja/GameController.cs b/src/TurntNinja/GameController.cs index f21880a..13ff22b 100644 --- a/src/TurntNinja/GameController.cs +++ b/src/TurntNinja/GameController.cs @@ -150,7 +150,7 @@ protected override void OnLoad(EventArgs e) Mouse.WheelChanged += (o, args) => InputSystem.MouseWheelChanged(args); Mouse.Move += (o, args) => InputSystem.MouseMoved(args); - GL.ClearColor(Color.CornflowerBlue); + GL.ClearColor(Color.Black); _watch = new Stopwatch(); } From 6b690986b13e24ddfe951bf181cd1e9be76c3e9e Mon Sep 17 00:00:00 2001 From: Patrick Yates Date: Mon, 26 Sep 2016 12:11:19 +1000 Subject: [PATCH 49/49] Only swap colours if more than 300ms has passed since last swap prevents quick flashing which could possibly cause epilepsy? --- src/TurntNinja/Game/StageGeometry.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/TurntNinja/Game/StageGeometry.cs b/src/TurntNinja/Game/StageGeometry.cs index 1fdb064..1d8b034 100644 --- a/src/TurntNinja/Game/StageGeometry.cs +++ b/src/TurntNinja/Game/StageGeometry.cs @@ -26,6 +26,8 @@ class StageGeometry : IDisposable private double _extraHue = 0.0; private double _hueWobbleAmount = 30; private bool _swapColours = false; + private double _lastSwapTime = -10.0f; + const double MIN_COLOUR_SWAP_TIME = 0.3f; private HUSLColor _baseColour; public Stage ParentStage; @@ -302,14 +304,18 @@ public void UpdateColours(double time) } //_baseColour.H += time*50f*(!OutOfBeats ? BeatFrequencies[_beats.Index] : 1); - bool swapColours = false; // Only update colours if more than 3 beats have passed since last time if (CurrentOnset - _previousBeat < 3) return; _previousBeat = CurrentOnset; _extraHue = ((_random.NextDouble() > 0.5) ? -1 : 1) * (90 + (_hueWobbleAmount * _random.NextDouble() - _hueWobbleAmount / 2)); - _swapColours = (_random.NextDouble() > 0.95) ? !_swapColours : _swapColours; + double swapChance = CurrentColourMode == ColourMode.BlackAndWhite ? 0.9 : 0.95; + if ((_elapsedTime - _lastSwapTime) > MIN_COLOUR_SWAP_TIME && _random.NextDouble() > swapChance) + { + _swapColours = !_swapColours; + _lastSwapTime = _elapsedTime; + } _baseColour.H = _initialHue + (CurrentOnset) * 5; _baseColour.L = ColourModifiers.baseLightness;