summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVittorio Romeo <vittorio.romeo@outlook.com>2020-11-04 23:36:40 +0000
committerGitHub <noreply@github.com>2020-11-04 23:36:40 +0000
commitcefcb88da3e12fa14fb015014295abba57bc8984 (patch)
tree07f4cdc2abb95fa4e869ca57d3e297952f0f197e
parent1f77e5cf8a7259ef86653837341ab5d4199ba767 (diff)
parent6f36defe471a11856319901035557f2d1d8972a9 (diff)
Merge branch 'master' into messages_to_eventsmessages_to_events
-rw-r--r--_RELEASE/Packs/cube/Scripts/utils.lua8
-rw-r--r--_RELEASE/Packs/experimental/Scripts/utils.lua8
-rw-r--r--_RELEASE/Packs/hypercube/Scripts/utils.lua8
-rw-r--r--_RELEASE/Packs/workshopexample/Scripts/utils.lua8
m---------extlibs/SSVMenuSystem0
-rw-r--r--include/SSVOpenHexagon/Core/Steam.hpp1
-rw-r--r--include/SSVOpenHexagon/Data/ProfileData.hpp15
-rw-r--r--include/SSVOpenHexagon/Global/Config.hpp13
-rw-r--r--include/SSVOpenHexagon/Global/Version.hpp38
-rw-r--r--include/SSVOpenHexagon/Utils/Utils.hpp2
-rw-r--r--src/SSVOpenHexagon/Core/HGScripting.cpp16
-rw-r--r--src/SSVOpenHexagon/Core/MenuGame.cpp9
-rw-r--r--src/SSVOpenHexagon/Core/main.cpp4
-rw-r--r--src/SSVOpenHexagon/Global/Assets.cpp8
-rw-r--r--src/SSVOpenHexagon/Global/Config.cpp11
-rw-r--r--src/SSVOpenHexagon/Utils/Utils.cpp15
16 files changed, 145 insertions, 19 deletions
diff --git a/_RELEASE/Packs/cube/Scripts/utils.lua b/_RELEASE/Packs/cube/Scripts/utils.lua
index 2b17fc03..34558004 100644
--- a/_RELEASE/Packs/cube/Scripts/utils.lua
+++ b/_RELEASE/Packs/cube/Scripts/utils.lua
@@ -112,6 +112,14 @@ KeyCode = {
-- Additional functions that help simplify certain calculations, including complex mathematical calculations
-- Ordered alphabetically
+-- Checks to see if the current version of the game is equal to or greater than the version specified
+-- Useful if you are developing a level in a beta branch or GitHub build.
+function atRequiredVersion(mMinimumMajor, mMinimumMinor, mMinimumMicro)
+ return u_getVersionMajor() >= mMinimumMajor and
+ u_getVersionMinor() >= mMinimumMinor and
+ u_getVersionMicro() >= mMinimumMicro;
+end
+
-- Converts Beats Per Minute (BPM) into period in Frames Per Beat (FPB)
function BPMtoFPB(bpm)
return (FPS * 60)/bpm;
diff --git a/_RELEASE/Packs/experimental/Scripts/utils.lua b/_RELEASE/Packs/experimental/Scripts/utils.lua
index 2b17fc03..34558004 100644
--- a/_RELEASE/Packs/experimental/Scripts/utils.lua
+++ b/_RELEASE/Packs/experimental/Scripts/utils.lua
@@ -112,6 +112,14 @@ KeyCode = {
-- Additional functions that help simplify certain calculations, including complex mathematical calculations
-- Ordered alphabetically
+-- Checks to see if the current version of the game is equal to or greater than the version specified
+-- Useful if you are developing a level in a beta branch or GitHub build.
+function atRequiredVersion(mMinimumMajor, mMinimumMinor, mMinimumMicro)
+ return u_getVersionMajor() >= mMinimumMajor and
+ u_getVersionMinor() >= mMinimumMinor and
+ u_getVersionMicro() >= mMinimumMicro;
+end
+
-- Converts Beats Per Minute (BPM) into period in Frames Per Beat (FPB)
function BPMtoFPB(bpm)
return (FPS * 60)/bpm;
diff --git a/_RELEASE/Packs/hypercube/Scripts/utils.lua b/_RELEASE/Packs/hypercube/Scripts/utils.lua
index 2b17fc03..34558004 100644
--- a/_RELEASE/Packs/hypercube/Scripts/utils.lua
+++ b/_RELEASE/Packs/hypercube/Scripts/utils.lua
@@ -112,6 +112,14 @@ KeyCode = {
-- Additional functions that help simplify certain calculations, including complex mathematical calculations
-- Ordered alphabetically
+-- Checks to see if the current version of the game is equal to or greater than the version specified
+-- Useful if you are developing a level in a beta branch or GitHub build.
+function atRequiredVersion(mMinimumMajor, mMinimumMinor, mMinimumMicro)
+ return u_getVersionMajor() >= mMinimumMajor and
+ u_getVersionMinor() >= mMinimumMinor and
+ u_getVersionMicro() >= mMinimumMicro;
+end
+
-- Converts Beats Per Minute (BPM) into period in Frames Per Beat (FPB)
function BPMtoFPB(bpm)
return (FPS * 60)/bpm;
diff --git a/_RELEASE/Packs/workshopexample/Scripts/utils.lua b/_RELEASE/Packs/workshopexample/Scripts/utils.lua
index 2b17fc03..34558004 100644
--- a/_RELEASE/Packs/workshopexample/Scripts/utils.lua
+++ b/_RELEASE/Packs/workshopexample/Scripts/utils.lua
@@ -112,6 +112,14 @@ KeyCode = {
-- Additional functions that help simplify certain calculations, including complex mathematical calculations
-- Ordered alphabetically
+-- Checks to see if the current version of the game is equal to or greater than the version specified
+-- Useful if you are developing a level in a beta branch or GitHub build.
+function atRequiredVersion(mMinimumMajor, mMinimumMinor, mMinimumMicro)
+ return u_getVersionMajor() >= mMinimumMajor and
+ u_getVersionMinor() >= mMinimumMinor and
+ u_getVersionMicro() >= mMinimumMicro;
+end
+
-- Converts Beats Per Minute (BPM) into period in Frames Per Beat (FPB)
function BPMtoFPB(bpm)
return (FPS * 60)/bpm;
diff --git a/extlibs/SSVMenuSystem b/extlibs/SSVMenuSystem
-Subproject 8046647aba1237a47e999e37068bf337c4bbd4b
+Subproject 25a466eda68b94dd1a61a8af7f2b7b04ecb73a1
diff --git a/include/SSVOpenHexagon/Core/Steam.hpp b/include/SSVOpenHexagon/Core/Steam.hpp
index 4c057331..7b49288b 100644
--- a/include/SSVOpenHexagon/Core/Steam.hpp
+++ b/include/SSVOpenHexagon/Core/Steam.hpp
@@ -8,6 +8,7 @@
#include "steam/steam_api.h"
#include <functional>
+#include <string>
#include <string_view>
#include <unordered_set>
diff --git a/include/SSVOpenHexagon/Data/ProfileData.hpp b/include/SSVOpenHexagon/Data/ProfileData.hpp
index 28321796..2c2b691d 100644
--- a/include/SSVOpenHexagon/Data/ProfileData.hpp
+++ b/include/SSVOpenHexagon/Data/ProfileData.hpp
@@ -4,20 +4,22 @@
#pragma once
+#include "SSVOpenHexagon/Global/Version.hpp"
#include "SSVOpenHexagon/SSVUtilsJson/SSVUtilsJson.hpp"
namespace hg
{
+
class ProfileData
{
private:
- float version;
+ GameVersion version;
std::string name;
ssvuj::Obj scores;
std::vector<std::string> trackedNames;
public:
- ProfileData(float mVersion, const std::string& mName,
+ ProfileData(const GameVersion mVersion, const std::string& mName,
const ssvuj::Obj& mScores,
const std::vector<std::string>& mTrackedNames)
: version{mVersion}, name{mName}, scores{mScores}, trackedNames{
@@ -25,22 +27,23 @@ public:
{
}
- [[nodiscard]] float getVersion() const
+ [[nodiscard]] constexpr GameVersion getVersion() const noexcept
{
return version;
}
- [[nodiscard]] const std::string& getName() const
+ [[nodiscard]] const std::string& getName() const noexcept
{
return name;
}
- [[nodiscard]] const ssvuj::Obj& getScores() const
+ [[nodiscard]] const ssvuj::Obj& getScores() const noexcept
{
return scores;
}
- [[nodiscard]] const std::vector<std::string>& getTrackedNames() const
+ [[nodiscard]] const std::vector<std::string>&
+ getTrackedNames() const noexcept
{
return trackedNames;
}
diff --git a/include/SSVOpenHexagon/Global/Config.hpp b/include/SSVOpenHexagon/Global/Config.hpp
index 4395bb64..831ca414 100644
--- a/include/SSVOpenHexagon/Global/Config.hpp
+++ b/include/SSVOpenHexagon/Global/Config.hpp
@@ -4,6 +4,8 @@
#pragma once
+#include "SSVOpenHexagon/Global/Version.hpp"
+
#include <vector>
#include <string>
@@ -20,6 +22,8 @@ class Trigger;
namespace hg::Config
{
+inline constexpr GameVersion GAME_VERSION{2, 0, 3};
+
void loadConfig(const std::vector<std::string>& mOverridesIds);
void resetConfigToDefaults();
void resetBindsToDefaults();
@@ -96,8 +100,6 @@ void setSaveLocalBestReplayToFile(bool mX);
[[nodiscard]] bool getVsync();
[[nodiscard]] bool getAutoZoomFactor();
[[nodiscard]] bool getFullscreen();
-[[nodiscard, gnu::const]] float getVersion();
-[[nodiscard, gnu::const]] const char* getVersionString();
[[nodiscard]] bool getWindowedAutoResolution();
[[nodiscard]] bool getFullscreenAutoResolution();
[[nodiscard]] unsigned int getFullscreenWidth();
@@ -109,6 +111,13 @@ void setSaveLocalBestReplayToFile(bool mX);
[[nodiscard]] bool getShowMessages();
[[nodiscard]] bool getRotateToStart();
+[[nodiscard, gnu::const]] inline constexpr GameVersion getVersion()
+{
+ return GAME_VERSION;
+}
+
+[[nodiscard]] const std::string& getVersionString();
+
[[nodiscard]] bool getDebug();
[[nodiscard]] bool getPulse();
[[nodiscard]] bool getBeatPulse();
diff --git a/include/SSVOpenHexagon/Global/Version.hpp b/include/SSVOpenHexagon/Global/Version.hpp
new file mode 100644
index 00000000..602eedc8
--- /dev/null
+++ b/include/SSVOpenHexagon/Global/Version.hpp
@@ -0,0 +1,38 @@
+// Copyright (c) 2013-2020 Vittorio Romeo
+// License: Academic Free License ("AFL") v. 3.0
+// AFL License page: https://opensource.org/licenses/AFL-3.0
+
+#pragma once
+
+#include <tuple>
+
+namespace hg
+{
+
+// Allow us to represent the game's version in a major.minor.micro format
+struct GameVersion
+{
+ int major;
+ int minor;
+ int micro;
+
+ constexpr bool operator<(const GameVersion& rhs) const noexcept
+ {
+ return std::tie(major, minor, micro) <
+ std::tie(rhs.major, rhs.minor, rhs.micro);
+ }
+
+ constexpr bool operator>(const GameVersion& rhs) const noexcept
+ {
+ return std::tie(major, minor, micro) >
+ std::tie(rhs.major, rhs.minor, rhs.micro);
+ }
+
+ constexpr bool operator==(GameVersion other) const noexcept
+ {
+ return (major == other.major) && (minor == other.minor) &&
+ (micro == other.micro);
+ }
+};
+
+} // namespace hg
diff --git a/include/SSVOpenHexagon/Utils/Utils.hpp b/include/SSVOpenHexagon/Utils/Utils.hpp
index cf647231..d3193dfc 100644
--- a/include/SSVOpenHexagon/Utils/Utils.hpp
+++ b/include/SSVOpenHexagon/Utils/Utils.hpp
@@ -7,6 +7,7 @@
#include "SSVOpenHexagon/Data/LevelData.hpp"
#include "SSVOpenHexagon/Data/ProfileData.hpp"
#include "SSVOpenHexagon/Data/MusicData.hpp"
+#include "SSVOpenHexagon/Global/Version.hpp"
#include "SSVOpenHexagon/Utils/LuaWrapper.hpp"
#include "SSVOpenHexagon/SSVUtilsJson/SSVUtilsJson.hpp"
@@ -53,6 +54,7 @@ inline void uppercasify(std::string& s)
}
MusicData loadMusicFromJson(const ssvuj::Obj& mRoot);
+GameVersion loadVersionFromJson(const ssvuj::Obj& mRoot);
ProfileData loadProfileFromJson(const ssvuj::Obj& mRoot);
std::string getLocalValidator(const std::string& mId, float mDifficultyMult);
diff --git a/src/SSVOpenHexagon/Core/HGScripting.cpp b/src/SSVOpenHexagon/Core/HGScripting.cpp
index 012b066c..0f77996f 100644
--- a/src/SSVOpenHexagon/Core/HGScripting.cpp
+++ b/src/SSVOpenHexagon/Core/HGScripting.cpp
@@ -175,6 +175,22 @@ void HexagonGame::initLua_Utils()
.doc(
"Force-swaps (180 degrees) the player when invoked. If `$0` is "
"`true`, the swap sound will be played.");
+
+ addLuaFn("u_getVersionMajor", //
+ [this] { return Config::getVersion().major; })
+ .doc("Returns the major of the current version of the game");
+
+ addLuaFn("u_getVersionMinor", //
+ [this] { return Config::getVersion().minor; })
+ .doc("Returns the minor of the current version of the game");
+
+ addLuaFn("u_getVersionMicro", //
+ [this] { return Config::getVersion().micro; })
+ .doc("Returns the micro of the current version of the game");
+
+ addLuaFn("u_getVersionString", //
+ [this] { return Config::getVersionString(); })
+ .doc("Returns the string representing the current version of the game");
}
void HexagonGame::initLua_AudioControl()
diff --git a/src/SSVOpenHexagon/Core/MenuGame.cpp b/src/SSVOpenHexagon/Core/MenuGame.cpp
index 5232601b..dde4a0f6 100644
--- a/src/SSVOpenHexagon/Core/MenuGame.cpp
+++ b/src/SSVOpenHexagon/Core/MenuGame.cpp
@@ -1116,6 +1116,15 @@ void MenuGame::initLua(Lua::LuaContext& mLua)
mLua.writeVariable("l_getPulseSpeed", [this] { return levelStatus.pulseSpeed; });
mLua.writeVariable("l_getPulseSpeedR", [this] { return levelStatus.pulseSpeedR; });
+ mLua.writeVariable(
+ "u_getVersionMajor", [this] { return Config::getVersion().major; });
+ mLua.writeVariable(
+ "u_getVersionMinor", [this] { return Config::getVersion().minor; });
+ mLua.writeVariable(
+ "u_getVersionMicro", [this] { return Config::getVersion().micro; });
+ mLua.writeVariable(
+ "u_getVersionString", [this] { return Config::getVersionString(); });
+
mLua.writeVariable("l_setRotationSpeed",
[this](float mValue) { levelStatus.rotationSpeed = mValue; });
diff --git a/src/SSVOpenHexagon/Core/main.cpp b/src/SSVOpenHexagon/Core/main.cpp
index 147fc481..0404c79b 100644
--- a/src/SSVOpenHexagon/Core/main.cpp
+++ b/src/SSVOpenHexagon/Core/main.cpp
@@ -74,8 +74,8 @@ ParsedArgs parseArgs(int argc, char* argv[])
std::string makeWindowTitle()
{
- return "Open Hexagon " + std::string{hg::Config::getVersionString()} +
- " - by vittorio romeo - http://vittorioromeo.info";
+ return "Open Hexagon " + hg::Config::getVersionString() +
+ " - by Vittorio Romeo - https://vittorioromeo.info";
}
std::optional<std::string> getFirstReplayFilenameFromArgs(
diff --git a/src/SSVOpenHexagon/Global/Assets.cpp b/src/SSVOpenHexagon/Global/Assets.cpp
index d7f64a95..d153bbe4 100644
--- a/src/SSVOpenHexagon/Global/Assets.cpp
+++ b/src/SSVOpenHexagon/Global/Assets.cpp
@@ -327,7 +327,13 @@ void HGAssets::saveCurrentLocalProfile()
}
ssvuj::Obj profileRoot;
- ssvuj::arch(profileRoot, "version", Config::getVersion());
+ ssvuj::Obj currentVersion;
+
+ ssvuj::arch(currentVersion, "major", Config::GAME_VERSION.major);
+ ssvuj::arch(currentVersion, "minor", Config::GAME_VERSION.minor);
+ ssvuj::arch(currentVersion, "micro", Config::GAME_VERSION.micro);
+
+ ssvuj::arch(profileRoot, "version", currentVersion);
ssvuj::arch(profileRoot, "name", getCurrentLocalProfile().getName());
ssvuj::arch(profileRoot, "scores", getCurrentLocalProfile().getScores());
diff --git a/src/SSVOpenHexagon/Global/Config.cpp b/src/SSVOpenHexagon/Global/Config.cpp
index 5a0ef5e7..5d60c804 100644
--- a/src/SSVOpenHexagon/Global/Config.cpp
+++ b/src/SSVOpenHexagon/Global/Config.cpp
@@ -707,14 +707,13 @@ void setSaveLocalBestReplayToFile(bool mX)
return fullscreen();
}
-[[nodiscard, gnu::const]] float getVersion()
+[[nodiscard]] const std::string& getVersionString()
{
- return 2.03f;
-}
+ static std::string result{std::to_string(GAME_VERSION.major) + "." +
+ std::to_string(GAME_VERSION.minor) + "." +
+ std::to_string(GAME_VERSION.micro)};
-[[nodiscard, gnu::const]] const char* getVersionString()
-{
- return "2.03";
+ return result;
}
[[nodiscard]] bool getWindowedAutoResolution()
diff --git a/src/SSVOpenHexagon/Utils/Utils.cpp b/src/SSVOpenHexagon/Utils/Utils.cpp
index 1fb25d9f..d8ccc299 100644
--- a/src/SSVOpenHexagon/Utils/Utils.cpp
+++ b/src/SSVOpenHexagon/Utils/Utils.cpp
@@ -41,10 +41,21 @@ MusicData loadMusicFromJson(const ssvuj::Obj& mRoot)
return result;
}
+GameVersion loadVersionFromJson(const ssvuj::Obj& mRoot)
+{
+ return {ssvuj::getExtr<int>(mRoot, "major"),
+ ssvuj::getExtr<int>(mRoot, "minor"),
+ ssvuj::getExtr<int>(mRoot, "micro")};
+}
+
ProfileData loadProfileFromJson(const ssvuj::Obj& mRoot)
{
- return {ssvuj::getExtr<float>(mRoot, "version"),
- ssvuj::getExtr<std::string>(mRoot, "name"),
+ GameVersion version{-1, 0, 0};
+ if(ssvuj::isObj("version"))
+ {
+ version = loadVersionFromJson(ssvuj::getObj(mRoot, "version"));
+ }
+ return {version, ssvuj::getExtr<std::string>(mRoot, "name"),
ssvuj::getObj(mRoot, "scores"),
ssvuj::getExtr<std::vector<std::string>>(mRoot, "trackedNames", {})};
}