diff --git a/build.fsx b/build.fsx index 7f91365..6262f35 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,9 +136,19 @@ 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) +) - 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] +Target "DeployZip" (fun _ -> + 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)) ) @@ -154,15 +168,16 @@ Target "DeploySquirrel" (fun _ -> ("**/*.*", Some @"lib/net45", None) ] OutputPath = deployDir - WorkingDir = tempDirName.Value + WorkingDir = tempDirZipName.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 ) @@ -201,6 +216,7 @@ Target "DeployKickStart" (fun _ -> ) Target "Deploy" (fun _ -> ()) +Target "DeployAll" (fun _ -> ()) Target "PushArtifacts" (fun _ -> match buildServer with @@ -237,23 +253,35 @@ Target "Default" (fun _ -> ==> "CleanSubstructio" "CleanTemp" + ==> "CopyToTemp" + +"CopyToTemp" ==> "DeployZip" "DeployZip" ==> "PushArtifacts" -"DeployZip" +"CopyToTemp" ==> "DeployMerged" "DeployZip" ==> "DeploySquirrel" -"DeploySquirrel" +"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" 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 a64aed5..7b185e9 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 - MathNet.Numerics (3.13) - framework: >= net45 + LiteDB (2.0.2) - 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) + 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 1dd4375..38347f5 100644 --- a/src/TurntNinja/App.config +++ b/src/TurntNinja/App.config @@ -1,117 +1,125 @@ - + - -
+ +
- -
+ +
- + - - - True - - - - - True - - - - - True - - - - - + + + + + True + + + + + True + + + + + True + + + + + True + + + + - - 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 + + + 2.5 + + + False + + + 50 + + + 0 + + + False + + + 0.2 + + + 10 + + + False + + + True + + + turnt-ninja.db + + + opcon + + + + + + False + + + True + + + 0 + + - - .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/Audio/AudioFeatures.cs b/src/TurntNinja/Audio/AudioFeatures.cs index 705f6d7..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 = "Extracting Onsets"; + _currentTask = "Analysing Song"; List onsets; if (SongAnalysed(s.SongBase.InternalName)) diff --git a/src/TurntNinja/FileSystem/DirectoryBrowser.cs b/src/TurntNinja/FileSystem/DirectoryBrowser.cs index 07e4fb2..163912e 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 { @@ -33,7 +34,6 @@ class DirectoryBrowser int _fileSystemEntryIndex = 0; int _directoryBrowserEntryIndex = 0; - int _fileSystemEntryIndexOffset { get { return _fileSystemCollection.Count + 1; } } int _halfEntryDrawCount = 10; @@ -42,6 +42,8 @@ class DirectoryBrowser double _searchLastTime = 0.0f; double _searchElapsedTime = 0.0f; + QFontDrawing _qfontDrawing; + public string SearchString { get { return _searchString; } @@ -57,7 +59,10 @@ 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; + + _qfontDrawing = new QFontDrawing(); + + Resize(_parentManager.Width, _parentManager.Height); EntrySeparator = new FileBrowserEntry { @@ -76,7 +81,7 @@ public void AddFileSystem(IFileSystem fileSystem) private void LoadFileSystem(IFileSystem fileSystem) { - _directoryBrowserEntryIndex = fileSystem.Initialise(EntrySeparator) + _fileSystemEntryIndexOffset; + _directoryBrowserEntryIndex = fileSystem.Initialise(EntrySeparator); SwitchFileSystem(fileSystem); } @@ -92,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) @@ -103,11 +114,27 @@ 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 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) { + // 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 +145,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 +166,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 +184,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 +210,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 +217,65 @@ public void Update(double time) public void Draw(double time) { - float startY = _unselectedFont.MaxLineHeight * (_halfEntryDrawCount); - var col = Color4.Black; - col.A = 0.90f; + _qfontDrawing.DrawingPrimitives.Clear(); + var col = Color4.White; - 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, QFontAlignment.Centre, _selectedFont.Font); + + 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, QFontAlignment.Centre, _unselectedFont.Font); + if (i == _directoryBrowserEntryIndex) + startY -= s.Height + _unselectedFont.MaxLineHeight * 1.5f; + 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, QFontAlignment.Centre, _selectedFont.Font); + + int currentFSIndex = _fileSystemCollection.IndexOf(_currentFileSystem); + + // Draw two file systems on either side + float unselectedFsScale = 0.9f; + + col = Color4.White; + col.A = 1.0f; + + var dp = new QFontDrawingPrimitive(_selectedFont.Font, new QFontRenderOptions { Colour = (System.Drawing.Color)col }); + // Draw next fs on right + dp.Print( + _fileSystemCollection[(currentFSIndex + 1 + _fileSystemCollection.Count) % _fileSystemCollection.Count].FriendlyName, + Vector3.Zero, + QFontAlignment.Left); + dp.ModelViewMatrix = Matrix4.CreateTranslation(new Vector3(0, size.Height * 2.0f, 0)) + * Matrix4.CreateScale(unselectedFsScale) + * 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 + dp.Print( + _fileSystemCollection[(currentFSIndex - 1 + _fileSystemCollection.Count) % _fileSystemCollection.Count].FriendlyName, + Vector3.Zero, + QFontAlignment.Right); + dp.ModelViewMatrix = Matrix4.CreateTranslation(new Vector3(0, size.Height * 2.0f, 0)) + * Matrix4.CreateScale(unselectedFsScale) + * 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); } } } 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 diff --git a/src/TurntNinja/GUI/ChooseSongScene.cs b/src/TurntNinja/GUI/ChooseSongScene.cs index 0d2f757..cd1422a 100644 --- a/src/TurntNinja/GUI/ChooseSongScene.cs +++ b/src/TurntNinja/GUI/ChooseSongScene.cs @@ -43,12 +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.Left, KeyRepeatSettings.Default); - InputSystem.RepeatingKeys.Add(Key.Right, KeyRepeatSettings.Default); - _directoryBrowser = new DirectoryBrowser(SceneManager, this); _directoryBrowser.AddFileSystem(new LocalFileSystem(SceneManager.Directories)); _directoryBrowser.AddFileSystem(new SoundCloudFileSystem()); @@ -62,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; } @@ -145,11 +141,21 @@ 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); - InputSystem.RepeatingKeys.Remove(Key.Left); - InputSystem.RepeatingKeys.Remove(Key.Right); + InputSystem.RepeatingKeys.Remove(Key.BackSpace); } } } diff --git a/src/TurntNinja/GUI/EndGameScene.cs b/src/TurntNinja/GUI/EndGameScene.cs index a4c4f49..8df0da1 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(); } @@ -160,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..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; @@ -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..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); @@ -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 9016a81..dbeacda 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,28 +159,35 @@ 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(); } public override void Dispose() { - if (_loadingFont != null) + if (_loadingFontDrawing != null) { - _loadingFont.Dispose(); _loadingFontDrawing.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); } + + public override void EnterFocus() + { + } + + public override void ExitFocus() + { + } } } diff --git a/src/TurntNinja/GUI/MenuScene.cs b/src/TurntNinja/GUI/MenuScene.cs index e795827..9b07876 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 @@ -60,6 +63,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; @@ -76,9 +80,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; } @@ -150,12 +151,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; @@ -180,7 +175,6 @@ private void DoGUI() case MainMenuOptions.ComingSoon: _selectedMenuItemText = "Coming Soon"; break; - case MainMenuOptions.None: default: _selectedMenuItem = MainMenuOptions.None; _selectedMenuItemText = ""; @@ -188,7 +182,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) { @@ -202,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(); @@ -210,9 +204,6 @@ private void DoGUI() case MainMenuOptions.Update: SceneManager.AddScene(new UpdateScene(), this); break; - case MainMenuOptions.None: - default: - break; } } } @@ -243,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) { @@ -252,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/OptionsScene.cs b/src/TurntNinja/GUI/OptionsScene.cs index 7d552cc..bc1e0af 100644 --- a/src/TurntNinja/GUI/OptionsScene.cs +++ b/src/TurntNinja/GUI/OptionsScene.cs @@ -6,265 +6,465 @@ 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"]; + var colourMode = (ColourMode)ServiceLocator.Settings["ColourMode"]; - _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 (ms)", + 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) + }); + + _options.Add(new EnumOption { - Min = -2000, - Max = 2000, - IsTabable = false + FriendlyName = "Colour Mode", + SettingName = "ColourMode", + Values = Enum.GetNames(typeof(ColourMode)).ToList(), + CurrentIndex = Enum.GetNames(typeof(ColourMode)).ToList().IndexOf(colourMode.ToString()) + }); - }; - _numericCorrection.SetSize(130, _correctionLabel.Height + 10); - _numericCorrection.Margin = Margin.Two; + foreach (var op in _options) + { + op.Sanitise(); + } + Loaded = true; + } - _correctionSlider.ValueChanged += (sender, arguments) => + public override void CallBack(GUICallbackEventArgs e) + { + throw new NotImplementedException(); + } + + public override void Resize(EventArgs e) + { + _optionsDrawing.ProjectionMatrix = SceneManager.ScreenCamera.ScreenProjectionMatrix; + } + + 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; + float unselectedValueScale = 0.8f; + + 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.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.CreateScale(unselectedValueScale) + * Matrix4.CreateTranslation(WindowWidth * 0.15f - valueSize.Width * 1.25f, currentY + _valueFont.Font.MaxLineHeight * 0.5f * unselectedValueScale, 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() + { + 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); + 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); + OpenTK.Graphics.OpenGL4.GL.ClearColor(Color.Black); + InputSystem.RepeatingKeys.Remove(Key.Left); + InputSystem.RepeatingKeys.Remove(Key.Right); + InputSystem.RepeatingKeys.Remove(Key.Up); + InputSystem.RepeatingKeys.Remove(Key.Down); + } + } + + public abstract class OptionBase + { + public string FriendlyName { get; set; } + public string SettingName { get; set; } - //layout difficulty label - _difficultyLabel.SetPosition(0, 0); + public abstract string GetValue(); + public abstract string GetNextValue(); + public abstract string GetPrevValue(); - //layout current difficulty label - _currentDifficultyLabel.SetPosition((_difficultyLabel.Width - _currentDifficultyLabel.Width)/2, _difficultyLabel.Height + _difficultySlider.Height); + public abstract bool CanMoveForward(); + public abstract bool CanMoveBackward(); - //layout correction slider - _correctionSlider.SetPosition(-(_correctionSlider.Width + _numericCorrection.Width + 10) / 2 + _correctionLabel.TextWidth / 2, _correctionLabel.Height * 2); + public abstract void SaveSettings(); - //layout numeric correction - Align.PlaceRightBottom(_numericCorrection, _correctionSlider, 10); + public abstract void MoveNext(); + public abstract void MovePrevious(); + public abstract void Sanitise(); - //layout volume slider - _volumeSlider.SetPosition(0, _volumeLabel.Height * 2); + public void RaiseOptionChanged() + { + OptionCallback.Invoke(this); + } - //layout volume label - _volumeLabel.SetPosition((_volumeSlider.Width + _numericVolume.Width + 10)/2 - _volumeLabel.Width/2, 0); + public delegate void OptionCallbackEvent(OptionBase sender); - //layout numeric volume - Align.PlaceRightBottom(_numericVolume, _volumeSlider, 10); + public event OptionCallbackEvent OptionCallback; + } - //size containers to their children - _correctionOptionsContainer.SizeToChildren(); - _volumeOptionsContainer.SizeToChildren(); - _difficultyOptionsContainer.SizeToChildren(); + public class BoolOption : OptionBase + { + public bool Value { get; set; } - //find max width - var maxWidth = Math.Max(_correctionOptionsContainer.Width, _volumeOptionsContainer.Width); + public BoolOption() + { + OptionCallback += (s) => CallbackFunction(Value); + } - var h = _difficultyOptionsContainer.Height; - _difficultyOptionsContainer.SetPosition((WindowWidth / 2 - _difficultyOptionsContainer.Width / 2), WindowHeight / 2 - h); + public override bool CanMoveBackward() + { + return Value; + } - //layout correction options container - _correctionOptionsContainer.SetPosition((int)(WindowWidth / 2 - maxWidth + (maxWidth - _correctionOptionsContainer.Width)/2), WindowHeight / 2 - _correctionOptionsContainer.Height / 2 + h); + public override bool CanMoveForward() + { + return !Value; + } - //layout volume options container - _volumeOptionsContainer.SetPosition((int) (WindowWidth / 2 + (maxWidth - _volumeOptionsContainer.Width)/2), WindowHeight / 2 - _volumeOptionsContainer.Height / 2 + h); + public override string GetNextValue() + { + return (!Value).ToString(); + } + public override string GetPrevValue() + { + return (!Value).ToString(); } - public override void CallBack(GUICallbackEventArgs e) + public override string GetValue() { - throw new NotImplementedException(); + return Value.ToString(); } - public override void Resize(EventArgs e) + public override void MoveNext() { - _GUIComponents.Resize(SceneManager.ScreenCamera.ScreenProjectionMatrix, WindowWidth, WindowHeight); - _canvas.SetSize(WindowWidth, WindowHeight); - LayoutGUI(); + Value = !Value; } - public override void Update(double time, bool focused = false) + public override void MovePrevious() { - 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 Sanitise() + { } - public override void Draw(double time) + public override void SaveSettings() { - _canvas.RenderCanvas(); + ServiceLocator.Settings[SettingName] = Value; } - public override void Dispose() + 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 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() { - InputSystem.RemoveGUIInput(_input); - _canvas.Dispose(); + 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] = (int)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; } = (_) => { }; } } diff --git a/src/TurntNinja/GUI/UpdateScene.cs b/src/TurntNinja/GUI/UpdateScene.cs index 964da97..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) @@ -209,5 +211,12 @@ public static string RemoveHtmlTags(string html) return Regex.Replace(html, "<.+?>", string.Empty); } + public override void EnterFocus() + { + } + + public override void ExitFocus() + { + } } } 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() diff --git a/src/TurntNinja/Game/Stage.cs b/src/TurntNinja/Game/Stage.cs index 62954a7..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); @@ -165,6 +166,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 = 7.5f; options.ActivationThreshold = (float)SceneManager.GameSettings["OnsetActivationThreshold"]; options.AdaptiveWhitening = (bool)SceneManager.GameSettings["OnsetAdaptiveWhitening"]; options.Online = (bool)SceneManager.GameSettings["OnsetOnline"]; @@ -243,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(); } @@ -264,7 +267,6 @@ public void Dispose() MultiplierFontDrawing.Dispose(); ScoreFontDrawing.Dispose(); StageGeometry.Dispose(); - //_stageAudio.Dispose(); } public void Reset(bool resetPlayerScore) @@ -272,8 +274,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; } } } 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); }; } diff --git a/src/TurntNinja/Game/StageGeometry.cs b/src/TurntNinja/Game/StageGeometry.cs index 1f081be..1d8b034 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 { @@ -24,6 +25,9 @@ class StageGeometry : IDisposable private double _initialHue; 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; @@ -80,6 +84,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; @@ -114,8 +121,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) { @@ -166,8 +173,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); } @@ -210,7 +217,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); @@ -294,12 +304,19 @@ 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)); + // 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)); + 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; _baseColour.S = ColourModifiers.baseSaturation; @@ -345,6 +362,31 @@ 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 + 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 + if (CurrentColourMode == ColourMode.BlackAndWhite) + _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; + } + if (CurrentColourMode == ColourMode.BlackAndWhite) + TextColour = _colours.OddOpposingColour; } @@ -400,4 +442,10 @@ public override string ToString() } } + + enum ColourMode + { + BlackAndWhite = 1, + Regular = 0 + } } diff --git a/src/TurntNinja/GameController.cs b/src/TurntNinja/GameController.cs new file mode 100644 index 0000000..13ff22b --- /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.Black); + + _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/Generation/StageGeometryBuilder.cs b/src/TurntNinja/Generation/StageGeometryBuilder.cs index f0fb915..3bdd4cf 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}; @@ -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]; @@ -111,8 +111,8 @@ 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; bool[] sides; @@ -125,7 +125,8 @@ 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)); + if (_random.NextDouble() < t) { structures[currentStructureIndex].End = b; } @@ -158,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 { @@ -253,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) 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; } } diff --git a/src/TurntNinja/Program.cs b/src/TurntNinja/Program.cs index b4770ed..54ebe3f 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) { @@ -349,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; 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.*")] diff --git a/src/TurntNinja/Properties/Settings.Designer.cs b/src/TurntNinja/Properties/Settings.Designer.cs index 217772d..481b145 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"])); @@ -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"])); @@ -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 2d0d74e..03f3a15 100644 --- a/src/TurntNinja/Properties/Settings.settings +++ b/src/TurntNinja/Properties/Settings.settings @@ -30,7 +30,7 @@ turnt-ninja - 9 + 2.5 False @@ -42,7 +42,7 @@ 0 - True + False 0.2 @@ -77,5 +77,8 @@ True + + 0 + \ No newline at end of file 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..7c53a55 100644 --- a/src/TurntNinja/TurntNinja.csproj +++ b/src/TurntNinja/TurntNinja.csproj @@ -1,5 +1,5 @@  - + @@ -122,6 +122,7 @@ Settings.settings + @@ -132,6 +133,13 @@ Settings.Designer.cs Designer + + SharpFont.dll.config + Always + + + build.fsx + @@ -161,9 +169,6 @@ True - - Always - @@ -440,7 +445,7 @@ - ..\..\packages\SharpFont\lib\net20\SharpFont.dll + ..\..\packages\SharpFont\lib\net45\SharpFont.dll True True 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