Skip to content
Draft
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
9 changes: 9 additions & 0 deletions Mammoth/Include/TSEVersions.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
constexpr DWORD API_VERSION = 56;
constexpr DWORD UNIVERSE_SAVE_VERSION = 41;
constexpr DWORD SYSTEM_SAVE_VERSION = 213;
constexpr DWORD SETTINGS_VERSION = 1;

// Uncomment out the following define when building a stable release

Expand Down Expand Up @@ -1312,3 +1313,11 @@ constexpr DWORD SYSTEM_SAVE_VERSION = 213;
// 213: 2.0 Alpha 2
// Change DiceRange to use -1 for not set
//

// SETTINGS VERSION HISTORY ---------------------------------------------------
//
// 0: Unknown version (2.0 Alpha 6 or older)
//
// 1: 2.0 Alpha 7
// Added versioning for settings file
//
36 changes: 24 additions & 12 deletions Mammoth/TSUI/CExtensionListMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,51 +366,58 @@ ALERROR CExtensionListMap::WriteList (IWriteStream &Output, DWORD dwAdventure, b

CString sData;
if (bDebugMode)
sData = strPatternSubst(CONSTLIT("\t\t<Default unid=\"0x%x\" debugMode=\"true\">"), dwAdventure);
sData = strPatternSubst(CONSTLIT("\t\t<Default unid=\"0x%x\" debugMode=\"true\">\r\n"), dwAdventure);
else
sData = strPatternSubst(CONSTLIT("\t\t<Default unid=\"0x%x\">"), dwAdventure);
sData = strPatternSubst(CONSTLIT("\t\t<Default unid=\"0x%x\">\r\n"), dwAdventure);

if (error = Output.Write(sData))
return error;

// First we write out the list of enabled extensions

sData = CONSTLIT("<Enabled>");
sData = CONSTLIT("\t\t\t<Enabled>\r\n");
if (error = Output.Write(sData))
return error;

bool bFirstEntry = true;
bool bFoundEnabled = false;
for (i = 0; i < List.GetCount(); i++)
{
if (List.GetValue(i))
{
CString sEntry;
if (bFirstEntry)
{
sEntry = strPatternSubst(CONSTLIT("0x%x"), List.GetKey(i));
sEntry = strPatternSubst(CONSTLIT("\t\t\t\t0x%x"), List.GetKey(i));
bFirstEntry = false;
}
else
sEntry = strPatternSubst(CONSTLIT(", 0x%x"), List.GetKey(i));
sEntry = strPatternSubst(CONSTLIT(",\r\n\t\t\t\t0x%x"), List.GetKey(i));

bFoundEnabled = true;

if (error = Output.Write(sEntry))
return error;
}
}

sData = CONSTLIT("</Enabled>");
if (bFoundEnabled)
Output.Write(CONSTLIT("\r\n"));

sData = CONSTLIT("\t\t\t</Enabled>\r\n");
if (error = Output.Write(sData))
return error;

// Now we write the disabled extensions

sData = CONSTLIT("<Disabled>");
sData = CONSTLIT("\t\t\t<Disabled>\r\n");
if (error = Output.Write(sData))
return error;

bool bFoundDisabled = false;
if (bDisabledIfNotInList)
{
sData = CONSTLIT("*");
sData = CONSTLIT("\t\t\t\t*\r\n");
if (error = Output.Write(sData))
return error;
}
Expand All @@ -424,25 +431,30 @@ ALERROR CExtensionListMap::WriteList (IWriteStream &Output, DWORD dwAdventure, b
CString sEntry;
if (bFirstEntry)
{
sEntry = strPatternSubst(CONSTLIT("0x%x"), List.GetKey(i));
sEntry = strPatternSubst(CONSTLIT("\t\t\t\t0x%x"), List.GetKey(i));
bFirstEntry = false;
}
else
sEntry = strPatternSubst(CONSTLIT(", 0x%x"), List.GetKey(i));
sEntry = strPatternSubst(CONSTLIT(",\r\n\t\t\t\t0x%x"), List.GetKey(i));

bFoundDisabled = true;

if (error = Output.Write(sEntry))
return error;
}
}
}

sData = CONSTLIT("</Disabled>");
if (bFoundDisabled)
Output.Write(CONSTLIT("\r\n"));

sData = CONSTLIT("\t\t\t</Disabled>\r\n");
if (error = Output.Write(sData))
return error;

// Done

sData = CONSTLIT("</Default>\r\n");
sData = CONSTLIT("\t\t</Default>\r\n");
if (error = Output.Write(sData))
return error;

Expand Down
27 changes: 26 additions & 1 deletion Transcendence/Transcendence/CGameSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#define NAME_ATTRIB CONSTLIT("name")
#define PATH_ATTRIB CONSTLIT("path")
#define VALUE_ATTRIB CONSTLIT("value")
#define VERSION_ATTRIB CONSTLIT("version")

#define REGISTRY_COMPANY_NAME CONSTLIT("Neurohack")
#define REGISTRY_PRODUCT_NAME CONSTLIT("Transcendence")
Expand Down Expand Up @@ -72,6 +73,7 @@ SOptionDefaults g_OptionData[CGameSettings::OPTIONS_COUNT] =
{ "noAutoUpdate", optionBoolean, "false", 0 },

// Video options

{ "forceDirectX", optionBoolean, "false", 0 },
{ "forceNonDirectX", optionBoolean, "false", 0 },
{ "forceExclusive", optionBoolean, "false", 0 },
Expand All @@ -90,13 +92,15 @@ SOptionDefaults g_OptionData[CGameSettings::OPTIONS_COUNT] =
{ "use60fps", optionBoolean, "true", 0 },

// Sounds options

{ "noSound", optionBoolean, "false", 0 },
{ "noMusic", optionBoolean, "false", 0 },
{ "soundVolume", optionInteger, "7", 0 },
{ "musicVolume", optionInteger, "7", 0 },
{ "musicPath", optionString, "", 0 },

// Accessibility options

{ "colorIFFPlayer", optionString, "#FFFFFF", 0 },
{ "colorIFFFriendly", optionString, "#50FF50", 0 }, // H:120 S:69 B:100
{ "colorIFFNeutral", optionString, "#4FA7FF", 0 }, // H:210 S:69 B:100
Expand All @@ -106,6 +110,7 @@ SOptionDefaults g_OptionData[CGameSettings::OPTIONS_COUNT] =
{ "colorIFFProjectile", optionString, "#FFFF00", 0 }, // H:60 S:100 B:100

// Debug options

{ "debugMode", optionBoolean, "false", 0 },
{ "debugGame", optionBoolean, "false", 0 },
{ "debugSaveFiles", optionBoolean, "false", 0 },
Expand Down Expand Up @@ -210,6 +215,26 @@ ALERROR CGameSettings::Load (const CString &sFilespec, CString *retsError)
}
}

// Get the version of the settings file
// Default is settings version 0, which means that this settings file was
// made prior to version 2.0 Alpha 7

int iSettingsVersion = pData->GetAttributeIntegerBounded(VERSION_ATTRIB, 0, -1, 0);

// If the settings version is older than the current settings version, we will
// need to mark it as modified to ensure that it gets saved in the new format

if (iSettingsVersion < SETTINGS_VERSION)
m_bModified = true;

// If the settings version is newer than the current settings version, we need
// to do something (TBD). For now lets just attempt to load and resave it but
// this should be changed in the future.

if (iSettingsVersion > SETTINGS_VERSION)
m_bModified = true;


// Keep track of which settings we've seen

bool bLoaded[OPTIONS_COUNT];
Expand Down Expand Up @@ -374,7 +399,7 @@ ALERROR CGameSettings::Save (const CString &sFilespec)

// Write the XML header

CString sData = CONSTLIT("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n\r\n<TranscendenceSettings>\r\n\r\n");
CString sData = strPatternSubst(CONSTLIT("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n\r\n<TranscendenceSettings version=\"%s\">\r\n\r\n"), strFromInt(SETTINGS_VERSION));
if (error = DataFile.Write(sData.GetPointer(), sData.GetLength(), NULL))
return error;

Expand Down