Skip to content

Commit

Permalink
Implement version check
Browse files Browse the repository at this point in the history
  • Loading branch information
psiberx committed Dec 24, 2022
1 parent 24d5869 commit 029ad4a
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 50 deletions.
21 changes: 14 additions & 7 deletions src/App/Facade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ void App::Facade::ExecuteTweak(Red::CName aName)
Core::Resolve<TweakService>()->ExecuteTweak(aName);
}

bool App::Facade::Require(Red::CString& aVersion)
{
const auto requirement = semver::from_string_noexcept(aVersion.c_str());
return requirement.has_value() ? Project::Version >= requirement.value() : false;
}

Red::CString App::Facade::GetVersion()
{
return Project::Version.to_string().c_str();
Expand All @@ -48,11 +54,12 @@ void App::Facade::OnRegister(Descriptor* aType)

void App::Facade::OnDescribe(Descriptor* aType)
{
aType->AddFunction<&Reload>("Reload", { .isFinal = true });
aType->AddFunction<&ImportAll>("ImportAll", { .isFinal = true });
aType->AddFunction<&ImportDir>("ImportDir", { .isFinal = true });
aType->AddFunction<&ImportTweak>("Import", { .isFinal = true });
aType->AddFunction<&ExecuteAll>("ExecuteAll", { .isFinal = true });
aType->AddFunction<&ExecuteTweak>("Execute", { .isFinal = true });
aType->AddFunction<&GetVersion>("Version", { .isFinal = true });
aType->AddFunction<&Reload>("Reload");
aType->AddFunction<&ImportAll>("ImportAll");
aType->AddFunction<&ImportDir>("ImportDir");
aType->AddFunction<&ImportTweak>("Import");
aType->AddFunction<&ExecuteAll>("ExecuteAll");
aType->AddFunction<&ExecuteTweak>("Execute");
aType->AddFunction<&Require>("Require");
aType->AddFunction<&GetVersion>("Version");
}
1 change: 1 addition & 0 deletions src/App/Facade.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Facade : public Red::Rtti::Class<Facade>
static void ImportTweak(Red::CString& aPath);
static void ExecuteAll();
static void ExecuteTweak(Red::CName aName);
static bool Require(Red::CString& aVersion);
static Red::CString GetVersion();

private:
Expand Down
2 changes: 1 addition & 1 deletion src/App/Project.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ constexpr auto Author = "psiberx";
constexpr auto NameW = L"TweakXL";
constexpr auto AuthorW = L"psiberx";

constexpr auto Version = semver::from_string_noexcept("1.1.0").value();
constexpr auto Version = semver::from_string_noexcept("1.1.1").value();
}
8 changes: 4 additions & 4 deletions src/App/Version.rc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#define VER_PRODUCTVERSION 1,1,0,0
#define VER_FILEVERSION 1,1,0,2211261928
#define VER_PRODUCTVERSION 1,1,1,0
#define VER_FILEVERSION 1,1,1,2212240832

#define VER_PRODUCTNAME_STR "TweakXL\0"
#define VER_PRODUCTVERSION_STR "1.1.0\0"
#define VER_FILEVERSION_STR "1.1.0.2211261928\0"
#define VER_PRODUCTVERSION_STR "1.1.1\0"
#define VER_FILEVERSION_STR "1.1.1.2212240832\0"

1 VERSIONINFO
FILEVERSION VER_FILEVERSION
Expand Down
3 changes: 1 addition & 2 deletions support/redscript/ScriptableTweak.reds
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

public abstract native class ScriptableTweak {
protected cb func OnApply() -> Void
protected cb func OnApply() -> Void
}
24 changes: 12 additions & 12 deletions support/redscript/TweakDBInterface.reds
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ public final static native func GetRecordByIndex(type: CName, index: Uint32) ->

@addMethod(TweakDBInterface)
public final static func GetRecords(keys: array<TweakDBID>) -> array<ref<TweakDBRecord>> {
let records: array<ref<TweakDBRecord>>;
for key in keys {
let record = TweakDBInterface.GetRecord(key);
if IsDefined(record) {
ArrayPush(records, record);
let records: array<ref<TweakDBRecord>>;
for key in keys {
let record = TweakDBInterface.GetRecord(key);
if IsDefined(record) {
ArrayPush(records, record);
}
}
}
return records;
return records;
}

@addMethod(TweakDBInterface)
public final static func GetRecordIDs(type: CName) -> array<TweakDBID> {
let ids: array<TweakDBID>;
for record in TweakDBInterface.GetRecords(type) {
ArrayPush(ids, record.GetID());
}
return ids;
let ids: array<TweakDBID>;
for record in TweakDBInterface.GetRecords(type) {
ArrayPush(ids, record.GetID());
}
return ids;
}
46 changes: 23 additions & 23 deletions support/redscript/TweakDBManager.reds
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@

public abstract native class TweakDBManager {
public final static native func SetFlat(id: TweakDBID, value: Variant) -> Bool
public final static native func CreateRecord(id: TweakDBID, type: CName) -> Bool
public final static native func CloneRecord(id: TweakDBID, base: TweakDBID) -> Bool
public final static native func UpdateRecord(id: TweakDBID) -> Bool
public final static native func RegisterName(name: CName) -> Bool
public final static native func SetFlat(id: TweakDBID, value: Variant) -> Bool
public final static native func CreateRecord(id: TweakDBID, type: CName) -> Bool
public final static native func CloneRecord(id: TweakDBID, base: TweakDBID) -> Bool
public final static native func UpdateRecord(id: TweakDBID) -> Bool
public final static native func RegisterName(name: CName) -> Bool
public final static func SetFlat(name: CName, value: Variant) -> Bool {
if TweakDBManager.SetFlat(TDBID.Create(NameToString(name)), value) {
TweakDBManager.RegisterName(name);
return true;
public final static func SetFlat(name: CName, value: Variant) -> Bool {
if TweakDBManager.SetFlat(TDBID.Create(NameToString(name)), value) {
TweakDBManager.RegisterName(name);
return true;
}
return false;
}
return false;
}
public final static func CreateRecord(name: CName, type: CName) -> Bool {
if TweakDBManager.CreateRecord(TDBID.Create(NameToString(name)), type) {
TweakDBManager.RegisterName(name);
return true;
public final static func CreateRecord(name: CName, type: CName) -> Bool {
if TweakDBManager.CreateRecord(TDBID.Create(NameToString(name)), type) {
TweakDBManager.RegisterName(name);
return true;
}
return false;
}
return false;
}
public final static func CloneRecord(name: CName, base: TweakDBID) -> Bool {
if TweakDBManager.CloneRecord(TDBID.Create(NameToString(name)), base) {
TweakDBManager.RegisterName(name);
return true;
public final static func CloneRecord(name: CName, base: TweakDBID) -> Bool {
if TweakDBManager.CloneRecord(TDBID.Create(NameToString(name)), base) {
TweakDBManager.RegisterName(name);
return true;
}
return false;
}
return false;
}
}
5 changes: 5 additions & 0 deletions support/redscript/TweakXL.reds
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

public abstract native class TweakXL {
public static native func Require(version: String) -> Bool
public static native func Version() -> String
}
2 changes: 1 addition & 1 deletion xmake.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set_xmakever("2.5.9")

set_project("TweakXL")
set_version("1.1.0", {build = "%y%m%d%H%M"})
set_version("1.1.1", {build = "%y%m%d%H%M"})

set_arch("x64")
set_languages("cxx20", "cxx2a")
Expand Down

0 comments on commit 029ad4a

Please sign in to comment.