Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions RhythmGameUtilities/Scripts/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ public static class CommonInternal
{

[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
public static extern float Lerp(float a, float b, float t);
public static extern float LerpInternal(float a, float b, float t);

[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
public static extern float InverseLerp(float a, float b, float v);
public static extern float InverseLerpInternal(float a, float b, float v);

}

Expand All @@ -25,7 +25,7 @@ public static class Common
/// <param name="t">The value used for interpolation.</param>
public static float Lerp(float a, float b, float t)
{
return CommonInternal.Lerp(a, b, t);
return CommonInternal.LerpInternal(a, b, t);
}

/// <summary>
Expand All @@ -36,7 +36,7 @@ public static float Lerp(float a, float b, float t)
/// <param name="v">The value in the middle.</param>
public static float InverseLerp(float a, float b, float v)
{
return CommonInternal.InverseLerp(a, b, v);
return CommonInternal.InverseLerpInternal(a, b, v);
}

}
Expand Down
16 changes: 8 additions & 8 deletions RhythmGameUtilities/Scripts/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ internal static class UtilitiesInternal
{

[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
public static extern float ConvertTickToPosition(int tick, int resolution);
public static extern float ConvertTickToPositionInternal(int tick, int resolution);

[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
public static extern int ConvertSecondsToTicksInternal(float seconds, int resolution, Tempo[] tempoChanges,
int tempoChangesSize, TimeSignature[] timeSignatures, int timeSignaturesSize);

[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
public static extern bool IsOnTheBeat(int bpm, float currentTime, float delta);
public static extern bool IsOnTheBeatInternal(int bpm, float currentTime, float delta);

[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
public static extern int RoundUpToTheNearestMultiplier(int value, int multiplier);
public static extern int RoundUpToTheNearestMultiplierInternal(int value, int multiplier);

[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
public static extern float CalculateAccuracyRatio(int position, int currentPosition, int delta);
public static extern float CalculateAccuracyRatioInternal(int position, int currentPosition, int delta);

[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr CalculateBeatBarsInternal(Tempo[] tempoChanges, int tempoChangesSize, int resolution,
Expand All @@ -42,7 +42,7 @@ public static class Utilities
/// <param name="resolution">The resolution of the song.</param>
public static float ConvertTickToPosition(int tick, int resolution)
{
return UtilitiesInternal.ConvertTickToPosition(tick, resolution);
return UtilitiesInternal.ConvertTickToPositionInternal(tick, resolution);
}

/// <summary>
Expand All @@ -67,7 +67,7 @@ public static int ConvertSecondsToTicks(float seconds, int resolution, Tempo[] t
/// <param name="delta">The plus/minus delta to test the current time against.</param>
public static bool IsOnTheBeat(int bpm, float currentTime, float delta = 0.05f)
{
return UtilitiesInternal.IsOnTheBeat(bpm, currentTime, delta);
return UtilitiesInternal.IsOnTheBeatInternal(bpm, currentTime, delta);
}

/// <summary>
Expand All @@ -77,7 +77,7 @@ public static bool IsOnTheBeat(int bpm, float currentTime, float delta = 0.05f)
/// <param name="multiplier">The multiplier to round using.</param>
public static int RoundUpToTheNearestMultiplier(int value, int multiplier)
{
return UtilitiesInternal.RoundUpToTheNearestMultiplier(value, multiplier);
return UtilitiesInternal.RoundUpToTheNearestMultiplierInternal(value, multiplier);
}

public static BeatBar[] CalculateBeatBars(Tempo[] tempoChanges, int resolution = 192, int ts = 4,
Expand Down Expand Up @@ -140,7 +140,7 @@ public static BeatBar[] CalculateBeatBars(Tempo[] tempoChanges, int resolution =
/// <param name="delta">The plus/minus delta to test the current position against.</param>
public static float CalculateAccuracyRatio(int position, int currentPosition, int delta = 50)
{
return UtilitiesInternal.CalculateAccuracyRatio(position, currentPosition, delta);
return UtilitiesInternal.CalculateAccuracyRatioInternal(position, currentPosition, delta);
}

}
Expand Down
8 changes: 4 additions & 4 deletions UnityPackage/Scripts/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ public static class CommonInternal
{

[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
public static extern float Lerp(float a, float b, float t);
public static extern float LerpInternal(float a, float b, float t);

[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
public static extern float InverseLerp(float a, float b, float v);
public static extern float InverseLerpInternal(float a, float b, float v);

}

Expand All @@ -25,7 +25,7 @@ public static class Common
/// <param name="t">The value used for interpolation.</param>
public static float Lerp(float a, float b, float t)
{
return CommonInternal.Lerp(a, b, t);
return CommonInternal.LerpInternal(a, b, t);
}

/// <summary>
Expand All @@ -36,7 +36,7 @@ public static float Lerp(float a, float b, float t)
/// <param name="v">The value in the middle.</param>
public static float InverseLerp(float a, float b, float v)
{
return CommonInternal.InverseLerp(a, b, v);
return CommonInternal.InverseLerpInternal(a, b, v);
}

}
Expand Down
16 changes: 8 additions & 8 deletions UnityPackage/Scripts/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ internal static class UtilitiesInternal
{

[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
public static extern float ConvertTickToPosition(int tick, int resolution);
public static extern float ConvertTickToPositionInternal(int tick, int resolution);

[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
public static extern int ConvertSecondsToTicksInternal(float seconds, int resolution, Tempo[] tempoChanges,
int tempoChangesSize, TimeSignature[] timeSignatures, int timeSignaturesSize);

[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
public static extern bool IsOnTheBeat(int bpm, float currentTime, float delta);
public static extern bool IsOnTheBeatInternal(int bpm, float currentTime, float delta);

[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
public static extern int RoundUpToTheNearestMultiplier(int value, int multiplier);
public static extern int RoundUpToTheNearestMultiplierInternal(int value, int multiplier);

[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
public static extern float CalculateAccuracyRatio(int position, int currentPosition, int delta);
public static extern float CalculateAccuracyRatioInternal(int position, int currentPosition, int delta);

[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr CalculateBeatBarsInternal(Tempo[] tempoChanges, int tempoChangesSize, int resolution,
Expand All @@ -42,7 +42,7 @@ public static class Utilities
/// <param name="resolution">The resolution of the song.</param>
public static float ConvertTickToPosition(int tick, int resolution)
{
return UtilitiesInternal.ConvertTickToPosition(tick, resolution);
return UtilitiesInternal.ConvertTickToPositionInternal(tick, resolution);
}

/// <summary>
Expand All @@ -67,7 +67,7 @@ public static int ConvertSecondsToTicks(float seconds, int resolution, Tempo[] t
/// <param name="delta">The plus/minus delta to test the current time against.</param>
public static bool IsOnTheBeat(int bpm, float currentTime, float delta = 0.05f)
{
return UtilitiesInternal.IsOnTheBeat(bpm, currentTime, delta);
return UtilitiesInternal.IsOnTheBeatInternal(bpm, currentTime, delta);
}

/// <summary>
Expand All @@ -77,7 +77,7 @@ public static bool IsOnTheBeat(int bpm, float currentTime, float delta = 0.05f)
/// <param name="multiplier">The multiplier to round using.</param>
public static int RoundUpToTheNearestMultiplier(int value, int multiplier)
{
return UtilitiesInternal.RoundUpToTheNearestMultiplier(value, multiplier);
return UtilitiesInternal.RoundUpToTheNearestMultiplierInternal(value, multiplier);
}

public static BeatBar[] CalculateBeatBars(Tempo[] tempoChanges, int resolution = 192, int ts = 4,
Expand Down Expand Up @@ -140,7 +140,7 @@ public static BeatBar[] CalculateBeatBars(Tempo[] tempoChanges, int resolution =
/// <param name="delta">The plus/minus delta to test the current position against.</param>
public static float CalculateAccuracyRatio(int position, int currentPosition, int delta = 50)
{
return UtilitiesInternal.CalculateAccuracyRatio(position, currentPosition, delta);
return UtilitiesInternal.CalculateAccuracyRatioInternal(position, currentPosition, delta);
}

}
Expand Down
13 changes: 7 additions & 6 deletions include/RhythmGameUtilities/Common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ extern "C"
* @private
*/

std::string Trim(const char *contents)
inline std::string Trim(const char *contents)
{
return std::regex_replace(contents, std::regex("^\\s+|\\s+$"), "");
}
Expand All @@ -64,7 +64,8 @@ std::string Trim(const char *contents)
* @private
*/

std::vector<std::string> Split(const char *contents, const char delimiter)
inline std::vector<std::string> Split(const char *contents,
const char delimiter)
{
auto parts = std::vector<std::string>();

Expand All @@ -80,8 +81,8 @@ std::vector<std::string> Split(const char *contents, const char delimiter)
return parts;
}

std::vector<std::string> FindAllMatches(const char *contents,
std::regex pattern)
inline std::vector<std::string> FindAllMatches(const char *contents,
std::regex pattern)
{
auto currentMatch =
std::cregex_iterator(contents, contents + strlen(contents), pattern);
Expand All @@ -101,8 +102,8 @@ std::vector<std::string> FindAllMatches(const char *contents,
return matches;
}

std::vector<std::string> FindMatchGroups(const char *contents,
std::regex pattern)
inline std::vector<std::string> FindMatchGroups(const char *contents,
std::regex pattern)
{
auto currentMatch =
std::cregex_iterator(contents, contents + strlen(contents), pattern);
Expand Down
27 changes: 27 additions & 0 deletions include/RhythmGameUtilities/CommonInternal.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once

#include "Common.hpp"

#ifdef _WIN32
#define PACKAGE_API __declspec(dllexport)
#else
#define PACKAGE_API
#endif

namespace RhythmGameUtilities
{

extern "C"
{
PACKAGE_API float LerpInternal(float a, float b, float t)
{
return Lerp(a, b, t);
}

PACKAGE_API float InverseLerpInternal(float a, float b, float v)
{
return InverseLerp(a, b, v);
}
}

} // namespace RhythmGameUtilities
2 changes: 1 addition & 1 deletion include/RhythmGameUtilities/Enums/Difficulty.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ typedef enum Difficulty

} DifficultyType;

std::string ToString(Difficulty difficulty)
inline std::string ToString(Difficulty difficulty)
{
switch (difficulty)
{
Expand Down
2 changes: 1 addition & 1 deletion include/RhythmGameUtilities/Enums/NamedSection.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ typedef enum NamedSection
Events
} NamedSectionType;

std::string ToString(NamedSection namedSection)
inline std::string ToString(NamedSection namedSection)
{
switch (namedSection)
{
Expand Down
2 changes: 1 addition & 1 deletion include/RhythmGameUtilities/Enums/TypeCode.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ typedef enum TypeCode

} TypeCodeType;

std::string ToString(TypeCode typeCode)
inline std::string ToString(TypeCode typeCode)
{
switch (typeCode)
{
Expand Down
4 changes: 2 additions & 2 deletions include/RhythmGameUtilities/File.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace RhythmGameUtilities
* @public
*/

std::vector<uint8_t> ReadBytesFromFile(const char *path)
inline std::vector<uint8_t> ReadBytesFromFile(const char *path)
{
std::ifstream file(path, std::ios::binary | std::ios::ate);

Expand All @@ -43,7 +43,7 @@ std::vector<uint8_t> ReadBytesFromFile(const char *path)
* @public
*/

std::string ReadStringFromFile(const char *path)
inline std::string ReadStringFromFile(const char *path)
{
std::ifstream file(path);

Expand Down
20 changes: 7 additions & 13 deletions include/RhythmGameUtilities/Parsers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@

#include "Common.hpp"

#ifdef _WIN32
#define PACKAGE_API __declspec(dllexport)
#else
#define PACKAGE_API
#endif

namespace RhythmGameUtilities
{

Expand All @@ -45,8 +39,8 @@ std::regex CHART_SECTION_LINE_PATTERN("([^=]+)\\s*=([^\\r\\n]+)");

std::regex JSON_VALUE_PATTERN("(\"[^\"]+\"|\\S+)");

std::map<std::string,
std::vector<std::pair<std::string, std::vector<std::string>>>>
inline std::map<std::string,
std::vector<std::pair<std::string, std::vector<std::string>>>>
ParseSectionsFromChart(const char *contents)
{
auto matches = FindAllMatches(contents, CHART_SECTION_PATTERN);
Expand Down Expand Up @@ -93,7 +87,7 @@ ParseSectionsFromChart(const char *contents)
return sections;
}

std::map<std::string, std::string> ParseMetaDataFromChartSection(
inline std::map<std::string, std::string> ParseMetaDataFromChartSection(
std::vector<std::pair<std::string, std::vector<std::string>>> section)
{
auto data = std::map<std::string, std::string>();
Expand All @@ -106,7 +100,7 @@ std::map<std::string, std::string> ParseMetaDataFromChartSection(
return data;
}

std::vector<TimeSignature> ParseTimeSignatureChangesFromChartSection(
inline std::vector<TimeSignature> ParseTimeSignatureChangesFromChartSection(
std::vector<std::pair<std::string, std::vector<std::string>>> section)
{
auto timeSignaturesChanges = std::vector<TimeSignature>();
Expand All @@ -127,7 +121,7 @@ std::vector<TimeSignature> ParseTimeSignatureChangesFromChartSection(
return timeSignaturesChanges;
}

std::vector<Tempo> ParseTempoChangesFromChartSection(
inline std::vector<Tempo> ParseTempoChangesFromChartSection(
std::vector<std::pair<std::string, std::vector<std::string>>> section)
{
auto tempoChanges = std::vector<Tempo>();
Expand All @@ -146,7 +140,7 @@ std::vector<Tempo> ParseTempoChangesFromChartSection(
return tempoChanges;
}

std::vector<Note> ParseNotesFromChartSection(
inline std::vector<Note> ParseNotesFromChartSection(
std::vector<std::pair<std::string, std::vector<std::string>>> section)
{
auto notes = std::vector<Note>();
Expand All @@ -164,7 +158,7 @@ std::vector<Note> ParseNotesFromChartSection(
return notes;
}

std::map<int, std::string> ParseLyricsFromChartSection(
inline std::map<int, std::string> ParseLyricsFromChartSection(
std::vector<std::pair<std::string, std::vector<std::string>>> section)
{
auto lyrics = std::map<int, std::string>();
Expand Down
5 changes: 2 additions & 3 deletions include/RhythmGameUtilities/ParsersInternal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ namespace RhythmGameUtilities

extern "C"
{
PACKAGE_API
ChartSectionInternal *ParseSectionsFromChartInternal(const char *contents,
int *outSize)
PACKAGE_API ChartSectionInternal *
ParseSectionsFromChartInternal(const char *contents, int *outSize)
{
auto internalSections = ParseSectionsFromChart(contents);

Expand Down
1 change: 1 addition & 0 deletions include/RhythmGameUtilities/RhythmGameUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "Audio.hpp"
#include "Common.hpp"
#include "CommonInternal.hpp"
#include "Parsers.hpp"
#include "ParsersInternal.hpp"
#include "Utilities.hpp"
Expand Down
Loading