Add version to Pack.ini, auto populate this value in the Pack.ini if it isn't manually provided

This commit is contained in:
Crash Cringle
2025-03-03 23:25:32 -08:00
committed by teejusb
parent 48b5b35e23
commit ec814a6b74
2 changed files with 30 additions and 1 deletions
+20 -1
View File
@@ -20,7 +20,8 @@
* with the Waiei Group.ini-lua project still actively
* being developed.
*/
const RString INI_FILE = "Pack.ini";
const RString INI_FILE = "Pack.ini";
const int INI_VERSION = 1;
Group::Group() {
m_sDisplayTitle = "";
@@ -82,8 +83,26 @@ Group::Group(const RString& sDir, const RString& sGroupDirName) {
}
}
ini.GetValue("Group", "Year", m_iYearReleased);
RString sVersion = "";
ini.GetValue("Group", "Version", sVersion);
Trim(sVersion);
if (!sVersion.empty()) {
m_iVersion = StringToInt(sVersion);
} else {
// If the version is not set, set it to the current version
// and write it to the file.
m_iVersion = INI_VERSION;
ini.SetValue("Group", "Version", INI_VERSION);
if( !ini.WriteFile(sPackIniPath)) {
RString sError = ssprintf( "Error writing pack.ini ", sPackIniPath.c_str(), ini.GetError().c_str() );
Dialog::OK( sError );
}
}
} else {
m_bHasPackIni = false;
m_iVersion = INI_VERSION;
fOffset = PREFSMAN->m_fMachineSyncBias;
}
+10
View File
@@ -103,6 +103,13 @@ public:
*/
int GetYearReleased() const { return m_iYearReleased; };
/**
* @brief The version of the Pack.ini info
*
*/
int GetVersion() const { return m_iVersion; };
private:
/**
* @brief This is the title of the group as its displayed to the user
@@ -136,6 +143,9 @@ public:
/** @brief The year the group was released */
int m_iYearReleased;
/** @brief The version of the Pack.ini info */
int m_iVersion;
};
#endif