Skip to content

Commit

Permalink
Merge pull request #7 from opcon/develop
Browse files Browse the repository at this point in the history
Version 0.11
  • Loading branch information
opcon committed May 11, 2016
2 parents d1cf3f1 + b1525df commit a3fefdb
Show file tree
Hide file tree
Showing 100 changed files with 1,010 additions and 2,270 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,8 @@ $RECYCLE.BIN/
*.sublime*

*.csv

# Squirrel and autobuild/release stuff
Releases/
SquirrelReleases/
*.rar
Binary file modified .nuget/NuGet.exe
Binary file not shown.
23 changes: 22 additions & 1 deletion BeatDetection/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,35 @@
<setting name="DifficultyLevel" serializeAs="String">
<value>2</value>
</setting>
<setting name="OnsetOnline" serializeAs="String">
<value>True</value>
</setting>
<setting name="OnsetSlicePaddingLength" serializeAs="String">
<value>0.2</value>
</setting>
<setting name="OnsetSliceLength" serializeAs="String">
<value>10</value>
</setting>
<setting name="Debug" serializeAs="String">
<value>False</value>
</setting>
<setting name="UpgradeRequired" serializeAs="String">
<value>True</value>
</setting>
<setting name="DatabaseFile" serializeAs="String">
<value>turnt-ninja.db</value>
</setting>
<setting name="PlayerName" serializeAs="String">
<value>opcon</value>
</setting>
</BeatDetection.Properties.Settings>
</userSettings>
<applicationSettings>
<BeatDetection.Properties.Settings>
<setting name="FileFilter" serializeAs="String">
<value>.mp3,.flac,.wav,.m4a,.wma</value>
</setting>
<setting name="TempFolderName" serializeAs="String">
<setting name="AppDataFolderName" serializeAs="String">
<value>turnt-ninja</value>
</setting>
</BeatDetection.Properties.Settings>
Expand Down
1 change: 1 addition & 0 deletions BeatDetection/Audio/AudioFeatures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ private void ApplyCorrection(List<float> onsets, float correction)

private string GetOnsetFilePath(string audioPath)
{
if (!Directory.Exists(_csvDirectory)) Directory.CreateDirectory(_csvDirectory);
return Path.Combine(_csvDirectory, String.Format("{0}_{1}", Path.GetFileNameWithoutExtension(audioPath), _outputSuffix) + ".csv");
}
}
Expand Down
50 changes: 50 additions & 0 deletions BeatDetection/BeatDetection.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,56 @@
<HintPath>..\packages\CSCore.1.1-beta2\lib\net35-client\CSCore.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="DeltaCompressionDotNet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1d14d6e5194e7f4a, processorArchitecture=MSIL">
<HintPath>..\packages\DeltaCompressionDotNet.1.0.0\lib\net45\DeltaCompressionDotNet.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="DeltaCompressionDotNet.MsDelta, Version=1.0.0.0, Culture=neutral, PublicKeyToken=46b2138a390abf55, processorArchitecture=MSIL">
<HintPath>..\packages\DeltaCompressionDotNet.1.0.0\lib\net45\DeltaCompressionDotNet.MsDelta.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="DeltaCompressionDotNet.PatchApi, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3e8888ee913ed789, processorArchitecture=MSIL">
<HintPath>..\packages\DeltaCompressionDotNet.1.0.0\lib\net45\DeltaCompressionDotNet.PatchApi.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Gwen">
<HintPath>..\Dependencies\Gwen.NET\Gwen.dll</HintPath>
</Reference>
<Reference Include="Gwen.Renderer.OpenTK">
<HintPath>..\Dependencies\Gwen.NET\Gwen.Renderer.OpenTK.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\squirrel.windows.1.4.0\lib\Net45\ICSharpCode.SharpZipLib.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="LiteDB, Version=1.0.4.0, Culture=neutral, PublicKeyToken=5c2fff750805920e, processorArchitecture=MSIL">
<HintPath>..\packages\LiteDB.1.0.4\lib\net40\LiteDB.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Mono.Cecil, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Mono.Cecil.Mdb, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Mdb.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Mono.Cecil.Pdb, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Pdb.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Mono.Cecil.Rocks, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Rocks.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NuGet.Squirrel, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\squirrel.windows.1.4.0\lib\Net45\NuGet.Squirrel.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="OnsetDetection">
<HintPath>..\..\onset-detection\bin\Release\OnsetDetection.dll</HintPath>
</Reference>
Expand All @@ -83,6 +123,14 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Libraries\SoundCloud.API.Client\SoundCloud.API.Client\bin\Debug\SoundCloud.API.Client.dll</HintPath>
</Reference>
<Reference Include="Splat, Version=1.6.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Splat.1.6.2\lib\Net45\Splat.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Squirrel, Version=1.4.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\squirrel.windows.1.4.0\lib\Net45\Squirrel.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
Expand Down Expand Up @@ -118,6 +166,7 @@
<Compile Include="FileSystem\SoundCloudFileSystem.cs" />
<Compile Include="Game\BeatCollection.cs" />
<Compile Include="Game\Difficulty.cs" />
<Compile Include="Game\HighScore.cs" />
<Compile Include="Game\StageAudio.cs" />
<Compile Include="Core\PolarPolygon.cs" />
<Compile Include="Game\Stage.cs" />
Expand All @@ -130,6 +179,7 @@
<Compile Include="GUI\MenuScene.cs" />
<Compile Include="Game\Player.cs" />
<Compile Include="GUI\OptionsScene.cs" />
<Compile Include="GUI\UpdateScene.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Core\HUSLColor.cs" />
Expand Down
11 changes: 8 additions & 3 deletions BeatDetection/Core/Settings/PropertySettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,14 @@ public void Save()

public void Load()
{
Properties.Settings.Default.Reload();
var antiAliasingSamples = Properties.Settings.Default.AntiAliasingSamples;
antiAliasingSamples *= 2;
if (Properties.Settings.Default.UpgradeRequired)
{
Properties.Settings.Default.Upgrade();
Properties.Settings.Default.UpgradeRequired = false;
Properties.Settings.Default.Save();
}

//Properties.Settings.Default.Reload();
//load all the settings
_settings = new Dictionary<string, SettingsPropertyValue>();
SettingsPropertyValue[] values = new SettingsPropertyValue[Properties.Settings.Default.PropertyValues.Count];
Expand Down
45 changes: 42 additions & 3 deletions BeatDetection/FileSystem/DirectoryBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using BeatDetection.GUI;
using OpenTK;
using OpenTK.Graphics;
using System.Globalization;

namespace BeatDetection.FileSystem
{
Expand All @@ -32,6 +33,15 @@ class DirectoryBrowser
int _halfEntryDrawCount = 10;
float _verticalEntrySpacing = 30;

string _searchString = "";
float _searchTimeout = 2.0f;
double _searchLastTime = 0.0f;
double _searchElapsedTime = 0.0f;

public string SearchString
{
get { return _searchString; }
}

public DirectoryBrowser(SceneManager parentSceneManager, ChooseSongScene parentScene)
{
Expand Down Expand Up @@ -66,11 +76,24 @@ private void SwitchFileSystem(IFileSystem fileSystem)
fileSystem.Focused();
_currentFileSystem = fileSystem;
}

private void ResetSearch()
{
_searchLastTime = _searchElapsedTime = 0.0f;
_searchString = "";
}

public void Resize(int wWidth, int wHeight)
{
_halfEntryDrawCount = (int) (wHeight / _verticalEntrySpacing) / 2;
}

public void Update(double time)
{
if (InputSystem.NewKeys.Contains(Key.Enter) && !_fileSystemEntries[_directoryBrowserEntryIndex].EntryType.HasFlag(FileBrowserEntryType.Separator))
{
ResetSearch();

_fileSystemEntryIndex = _directoryBrowserEntryIndex - _fileSystemEntryIndexOffset;
if (_fileSystemEntryIndex >= 0)
{
Expand Down Expand Up @@ -113,12 +136,26 @@ public void Update(double time)
if (InputSystem.NewKeys.Contains(Key.Right))
_directoryBrowserEntryIndex += 10;

_searchElapsedTime += time;
if (_searchElapsedTime - _searchLastTime > _searchTimeout)
ResetSearch();

// Update text search
foreach (var c in InputSystem.PressedChars)
{
int match = _fileSystemEntries.FindIndex(fbe => fbe.Name.StartsWith(c.ToString(), StringComparison.CurrentCultureIgnoreCase) && !fbe.EntryType.HasFlag(FileBrowserEntryType.Special));
_searchString = (_searchString + c).ToLowerInvariant();
_searchElapsedTime = _searchLastTime = 0.0f;
int match = _fileSystemEntries.FindIndex(fbe => fbe.Name.StartsWith(_searchString, StringComparison.CurrentCultureIgnoreCase));
if (match < 0)
match = _fileSystemEntries.FindIndex(fbe => CultureInfo.CurrentCulture.CompareInfo.IndexOf(fbe.Name, _searchString, CompareOptions.IgnoreCase) >= 0 &&
!(fbe.EntryType.HasFlag(FileBrowserEntryType.Special) || fbe.EntryType.HasFlag(FileBrowserEntryType.Plugin)));
if (match >= 0) _directoryBrowserEntryIndex = match;
}
if (InputSystem.NewKeys.Contains(Key.BackSpace) && _searchString.Length > 0)
{
_searchString = _searchString.Substring(0, _searchString.Length - 1);
_searchElapsedTime = _searchLastTime = 0.0f;
}

// Clamp the index
if (_directoryBrowserEntryIndex < 0) _directoryBrowserEntryIndex = 0;
Expand All @@ -127,14 +164,16 @@ public void Update(double time)

public void Draw(double time)
{
float startY = _verticalEntrySpacing * _halfEntryDrawCount;
float startY = _verticalEntrySpacing * (_halfEntryDrawCount - 2);

for (int i = _directoryBrowserEntryIndex - _halfEntryDrawCount; i < _directoryBrowserEntryIndex + _halfEntryDrawCount; i++)
for (int i = _directoryBrowserEntryIndex - (_halfEntryDrawCount - 2); i < _directoryBrowserEntryIndex + _halfEntryDrawCount; i++)
{
if (i >= 0 && i < _fileSystemEntries.Count && i != _directoryBrowserEntryIndex) _parentManager.DrawTextLine(_fileSystemEntries[i].Name, new Vector3(0, startY, 0), Color4.Black, QuickFont.QFontAlignment.Centre);
startY -= 30;
}
_parentManager.DrawTextLine(_fileSystemEntries[_directoryBrowserEntryIndex].Name, new Vector3(0, 0, 0), Color4.White, QuickFont.QFontAlignment.Centre);

_parentManager.DrawTextLine(string.Format("Search: {0}", _searchString), new Vector3(0, _verticalEntrySpacing * _halfEntryDrawCount, 0), Color4.White, QuickFont.QFontAlignment.Centre);
}
}
}
38 changes: 35 additions & 3 deletions BeatDetection/FileSystem/LocalFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Threading.Tasks;
using BeatDetection.Audio;
using System.Diagnostics;
using Substructio.Core;

namespace BeatDetection.FileSystem
{
Expand All @@ -17,14 +18,16 @@ class LocalFileSystem : IFileSystem
List<FileBrowserEntry> _drives;
List<FileBrowserEntry> _localFileSystemEntries;
List<FileBrowserEntry> _userFolders;
DirectoryHandler _directoryHandler;

public ReadOnlyCollection<FileBrowserEntry> FileSystemEntryCollection { get { return _localFileSystemEntries.AsReadOnly(); } }
public List<IFileSystem> FileSystemCollection { get; set; }
public string FriendlyName { get { return "Local File System"; } }

public LocalFileSystem()
public LocalFileSystem(DirectoryHandler directoryHandler)
{
_fileFilter = CSCore.Codecs.CodecFactory.Instance.GetSupportedFileExtensions();
_directoryHandler = directoryHandler;

_drives = new List<FileBrowserEntry>();
_localFileSystemEntries = new List<FileBrowserEntry>();
Expand Down Expand Up @@ -81,16 +84,45 @@ private int EnterPath(string directoryPath)
// Add Drive/Directory separator
_localFileSystemEntries.Add(_entrySeparator);

int desiredIndex = _localFileSystemEntries.Count;
// Add user folders
_localFileSystemEntries.Add(new FileBrowserEntry
{
Path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
EntryType = FileBrowserEntryType.Directory,
Name = "My Documents"
});
_localFileSystemEntries.Add(new FileBrowserEntry
{
Path = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory),
EntryType = FileBrowserEntryType.Directory,
Name = "Desktop"
});
_localFileSystemEntries.Add(new FileBrowserEntry
{
Path = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic),
EntryType = FileBrowserEntryType.Directory,
Name = "My Music"
});

_localFileSystemEntries.Add(new FileBrowserEntry
{
Path = _directoryHandler["BundledSongs"].FullName,
EntryType = FileBrowserEntryType.Directory,
Name = "Bundled Songs"
});

_localFileSystemEntries.Add(_entrySeparator);

// Add shortcut to parent directory
_localFileSystemEntries.Add(new FileBrowserEntry
{
Path = Path.Combine(directoryPath, "../"),
EntryType = FileBrowserEntryType.Directory | FileBrowserEntryType.Special,
Name = "Parent Directory"
Name = "Up a Directory"
});

int desiredIndex = _localFileSystemEntries.Count;

// Add the new directories
foreach (var dir in childrenDirectories.OrderBy(Path.GetFileName))
{
Expand Down
Loading

0 comments on commit a3fefdb

Please sign in to comment.