Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
dustdustinthewind committed Nov 7, 2020
2 parents 6981f9d + 76d29ac commit 6d772f3
Show file tree
Hide file tree
Showing 22 changed files with 1,185 additions and 844 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.4.4-alpha] - 2020-11-07

### Added
- Archive maps. While in the song select, press F8 (default) to archive the currently playing map as a .psm file. You can find the .psm in your Songs folder.
- Individual Map Offset. Useful for converts, this is a value inside a map .psc file that changes the offset of the map (not user friendly). This offset stacks on top of the global offset value (if you have a global offset of -7ms and a map offset of 5ms the total offset for the map would be -2ms)
- Added 'MapOffset" value to config. Lets you choose the map offset before converting.
- Custom Judgement values. You can change judgements in game with a slider, or in the config file under the `[Judgements]` section

### Changed
- Check the songs database on launch, if there are no found songs, refresh the database. This should fix some issues where the songs would dissapear and require a manual refresh to bring back.

## [1.4.3-alpha] - 2020-03-07

### Added
Expand Down Expand Up @@ -142,7 +153,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Leaderboard for past scores


[unreleased]: https://github.com/PulsarcGame/Pulsarc/compare/v1.4.2-alpha...HEAD
[unreleased]: https://github.com/PulsarcGame/Pulsarc/compare/v1.4.4-alpha...HEAD
[1.4.4-alpha]: https://github.com/PulsarcGame/Pulsarc/compare/v1.4.3-alpha...v1.4.4-alpha
[1.4.3-alpha]: https://github.com/PulsarcGame/Pulsarc/compare/v1.4.2-alpha...v1.4.3-alpha
[1.4.2-alpha]: https://github.com/PulsarcGame/Pulsarc/compare/v1.4.1-alpha...v1.4.2-alpha
[1.4.1-alpha]: https://github.com/PulsarcGame/Pulsarc/compare/v1.4.0-alpha...v1.4.1-alpha
[1.4.0-alpha]: https://github.com/PulsarcGame/Pulsarc/compare/v1.3.2-alpha...v1.4.0-alpha
Expand Down
18 changes: 10 additions & 8 deletions Pulsarc/Beatmaps/Beatmap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ public class Beatmap
// How many keys this Beatmap uses.
public int KeyCount { get; set; } = 4;

// How the audio will offset (in ms).
// Why a string? Because SQL doesn't like negative's for some reason, no clue why.
public string MapOffset { get; set; } = "0";

// The calculated difficulty of this Beatmap.
public double Difficulty { get; set; } = 0;

Expand Down Expand Up @@ -78,11 +82,15 @@ public string GetHash()
// The hash is modified for any metadata or arc/sv change
int arcCount = 0;
foreach (Arc arc in Arcs)
{
arcCount += arc.Time + arc.Type;
}

int eventCount = 0;
foreach (Event evnt in Events)
{
eventCount += evnt.Time + evnt.Time + (int)evnt.Type;
}

string uniqueMapDescriptor = Artist + Title + Mapper + Version + arcCount + ',' + eventCount;
return BitConverter.ToString(
Expand All @@ -99,10 +107,7 @@ public string GetHash()
/// Get the locally saved scores for this beatmap.
/// </summary>
/// <returns></returns>
public List<ScoreData> GetLocalScores()
{
return DataManager.ScoreDB.GetScores(GetHash());
}
public List<ScoreData> GetLocalScores() => DataManager.ScoreDB.GetScores(GetHash());

/// <summary>
/// Get the audio path to this beatmap's audio file.
Expand All @@ -126,9 +131,6 @@ public string GetFullAudioPath()
/// Format is "Artist - Title [Version] (Mapper)"
/// </summary>
/// <returns></returns>
public override string ToString()
{
return $"{Artist} - {Title} [{Version}] ({Mapper})";
}
public override string ToString() => $"{Artist} - {Title} [{Version}] ({Mapper})";
}
}
72 changes: 70 additions & 2 deletions Pulsarc/Beatmaps/BeatmapHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
using Pulsarc.Utils.SQLite;
using Wobble.Logging;
using Pulsarc.Utils;
using ICSharpCode.SharpZipLib;
using ICSharpCode.SharpZipLib.Zip;
using ICSharpCode.SharpZipLib.Core;

namespace Pulsarc.Beatmaps
{
Expand Down Expand Up @@ -47,7 +50,17 @@ static public Beatmap Load(string path, string fileName)
case "Title":
case "Artist":
case "Mapper":
case "Version":
case "Version":
case "MapOffset":
try
{
parsed.GetType().GetProperty(type).SetValue(parsed, rightPart);
}
catch
{
PulsarcLogger.Error($"Unknown beatmap field : {type}", LogType.Runtime);
}
break;
case "Audio":
try
{
Expand Down Expand Up @@ -98,7 +111,8 @@ static public Beatmap Load(string path, string fileName)
state = type;
break;
default:
PulsarcLogger.Error($"Unknown beatmap field : {type}", LogType.Runtime);
// Should probably ingore this really, like why would we need to know that?
//PulsarcLogger.Error($"Unknown beatmap field : {type}", LogType.Runtime);
break;
}
}
Expand Down Expand Up @@ -219,6 +233,9 @@ static public void Save(Beatmap beatmap, string file_path)
WriteProperty(file, beatmap, "KeyCount");
WriteProperty(file, beatmap, "Difficulty");

file.WriteLine("");
WriteProperty(file, beatmap, "MapOffset");

// Write Events
file.WriteLine("");
file.WriteLine("Events:");
Expand Down Expand Up @@ -252,6 +269,57 @@ static public void Save(Beatmap beatmap, string file_path)
}
}

public static void SaveAsZip(Beatmap beatmap)
{
using (FileStream output = File.Create($"Songs/{beatmap}.psm"))
using (ZipOutputStream zipStream = new ZipOutputStream(output))
{
zipStream.SetLevel(3);

int folderOffset = beatmap.Path.Length
+ ((beatmap.Path.EndsWith("/") || beatmap.Path.EndsWith("\\")) ? 0 : 1);

// Compress the folder
CompressFolder(beatmap.Path, zipStream, folderOffset);
}

void CompressFolder(string path, ZipOutputStream zipStream, int folderOffset)
{
string[] fileNames = Directory.GetFiles(beatmap.Path);

foreach (string fileName in fileNames)
{
FileInfo info = new FileInfo(fileName);

string entryName = fileName.Substring(folderOffset);
entryName = ZipEntry.CleanName(entryName);

ZipEntry entry = new ZipEntry(entryName)
{
DateTime = info.LastWriteTime,
Size = info.Length,
};

zipStream.PutNextEntry(entry);

byte[] buffer = new byte[4096];
using (FileStream input = File.OpenRead(fileName))
{
StreamUtils.Copy(input, zipStream, buffer);
}

zipStream.CloseEntry();
}

// Compress subfolders
string[] folders = Directory.GetDirectories(beatmap.Path);
foreach (string folder in folders)
{
CompressFolder(folder, zipStream, folderOffset);
}
}
}

/// <summary>
/// Write a property to file
/// </summary>
Expand Down
4 changes: 3 additions & 1 deletion Pulsarc/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ public static class Program
[STAThread]
static void Main()
{
// Checks for updates and applies them if found, otherwises launches the game.
/* //Checks for updates and applies them if found, otherwises launches the game.
#if !DEBUG
Updater.CheckForUpdates();
#endif
Commented out as CheckForUpdates with release 1.4.4-alpha as it serves little purpose in
Pulsarc's current state and may cause issues when the server goes down.*/

using (var game = new Pulsarc())
{
Expand Down
4 changes: 2 additions & 2 deletions Pulsarc/Pulsarc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<AssemblyName>Pulsarc</AssemblyName>
<ApplicationIcon>Icon.ico</ApplicationIcon>
<StartupObject></StartupObject>
<AssemblyVersion>1.4.3.0</AssemblyVersion>
<FileVersion>1.4.3.0</FileVersion>
<AssemblyVersion>1.4.4.0</AssemblyVersion>
<FileVersion>1.4.4.0</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 3 additions & 1 deletion Pulsarc/Skinning/Skin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ private static void LoadSettings(string skinFolder)
LoadSkinTexture($"{skinFolder}UI/Settings/", "settings_icon_gameplay");
LoadSkinTexture($"{skinFolder}UI/Settings/", "settings_icon_audio");
LoadSkinTexture($"{skinFolder}UI/Settings/", "settings_icon_bindings");
LoadSkinTexture($"{skinFolder}UI/Settings/", "settings_icon_judgements");

// Settings elements
LoadSkinTexture($"{skinFolder}UI/Settings/", "slider_select");
Expand All @@ -171,7 +172,8 @@ private static void LoadGrades(string skinFolder)
}

private static void LoadJudges(string skinFolder)
{
{
Judgement.Refresh();
foreach (JudgementValue judge in Judgement.Judgements)
Judges.Add(judge.Score, LoadTexture($"{skinFolder}Judgements/", judge.Name));
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 6d772f3

Please sign in to comment.