mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-29 09:28:15 +03:00
Add ifversion
This command adds `ifversion`, as both a simplified and internal command. The system works like so: - `ifversion(2.6,script2)` -> If you're on 2.6.0 or greater - `ifversion(2.6.0,script2)` -> Same as above - `ifversion(2.6.3,script2)` -> You're using 2.6.3 or greater - `ifversion(2.5,script2)` -> You're using 2.5 or greater - `ifversion(2,script2)` -> You're using 2.0.0 or greater (yep...) `ReleaseVersion.h` has a few new defines to make this possible, being `MAJOR_VERSION`, `MINOR_VERSION` and `PATCH_VERSION`. With the help of a few macros, `RELEASE_VERSION` is now constructed using those.
This commit is contained in:
@@ -1,6 +1,17 @@
|
||||
#ifndef RELEASEVERSION_H
|
||||
#define RELEASEVERSION_H
|
||||
|
||||
#define RELEASE_VERSION "v2.5"
|
||||
#define MAJOR_VERSION 2
|
||||
#define MINOR_VERSION 5
|
||||
#define PATCH_VERSION 0
|
||||
|
||||
#define VVV_STRINGIFY(x) #x
|
||||
#define VVV_TOSTRING(x) VVV_STRINGIFY(x)
|
||||
|
||||
#if PATCH_VERSION == 0
|
||||
#define RELEASE_VERSION "v" VVV_TOSTRING(MAJOR_VERSION) "." VVV_TOSTRING(MINOR_VERSION)
|
||||
#else
|
||||
#define RELEASE_VERSION "v" VVV_TOSTRING(MAJOR_VERSION) "." VVV_TOSTRING(MINOR_VERSION) "." VVV_TOSTRING(PATCH_VERSION)
|
||||
#endif
|
||||
|
||||
#endif /* RELEASEVERSION_H */
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "LocalizationStorage.h"
|
||||
#include "Map.h"
|
||||
#include "Music.h"
|
||||
#include "ReleaseVersion.h"
|
||||
#include "Unreachable.h"
|
||||
#include "UtilityClass.h"
|
||||
#include "VFormat.h"
|
||||
@@ -338,6 +339,67 @@ void scriptclass::run(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (words[0] == "ifversion")
|
||||
{
|
||||
// A short for each is SURELY enough
|
||||
unsigned short version[3] = { 0, 0, 0 };
|
||||
bool valid_version = true;
|
||||
int current = 0;
|
||||
|
||||
// Crawl through the string
|
||||
for (int i = 0; i < words[1].size(); i++)
|
||||
{
|
||||
// If the current character is a number, add it to the current version part
|
||||
if (words[1][i] >= '0' && words[1][i] <= '9')
|
||||
{
|
||||
version[current] = version[current] * 10 + (words[1][i] - '0');
|
||||
}
|
||||
else if (words[1][i] == '.')
|
||||
{
|
||||
current++;
|
||||
if (current >= 3)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Unexpected character
|
||||
valid_version = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (valid_version)
|
||||
{
|
||||
bool version_is_met = false;
|
||||
|
||||
if (MAJOR_VERSION > version[0])
|
||||
{
|
||||
version_is_met = true;
|
||||
}
|
||||
else if (MAJOR_VERSION == version[0])
|
||||
{
|
||||
if (MINOR_VERSION > version[1])
|
||||
{
|
||||
version_is_met = true;
|
||||
}
|
||||
else if (MINOR_VERSION == version[1])
|
||||
{
|
||||
if (PATCH_VERSION >= version[2])
|
||||
{
|
||||
version_is_met = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (version_is_met)
|
||||
{
|
||||
loadalts("custom_" + words[2], "custom_" + raw_words[2]);
|
||||
position--;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (words[0] == "customiftrinkets")
|
||||
{
|
||||
if (game.trinkets() >= ss_toi(words[1]))
|
||||
@@ -3574,6 +3636,9 @@ bool scriptclass::loadcustom(const std::string& t)
|
||||
}else if(words[0] == "iftrinketsless"){
|
||||
if(customtextmode==1){ add("endtext"); customtextmode=0;}
|
||||
add("custom"+lines[i]);
|
||||
}else if(words[0] == "ifversion"){
|
||||
if(customtextmode==1){ add("endtext"); customtextmode=0;}
|
||||
add(lines[i]);
|
||||
}else if(words[0] == "textcase"){
|
||||
if(customtextmode==1){ add("endtext"); customtextmode=0;}
|
||||
add(lines[i]);
|
||||
|
||||
Reference in New Issue
Block a user