rename "snapshots" to "extended version numbers". Add "DisableEditingChangelog"

This commit is contained in:
Bitl 2021-08-13 11:26:18 -07:00
parent da3b537e96
commit 21ac15e0be
3 changed files with 27 additions and 21 deletions

View File

@ -29,15 +29,15 @@ namespace Novetus.Launch
string version; string version;
INIFile ini = new INIFile(infopath); INIFile ini = new INIFile(infopath);
string section = "ProgramInfo"; string section = "ProgramInfo";
bool isSnapshot = Convert.ToBoolean(ini.IniReadValue(section, "IsSnapshot", "False")); bool extendedversionnumber = Convert.ToBoolean(ini.IniReadValue(section, "ExtendedVersionNumber", "False"));
version = (isSnapshot ? ini.IniReadValue(section, "SnapshotTemplate", "%version% Snapshot (%build%.%revision%.%snapshot-revision%)") : ini.IniReadValue(section, "Branch", "0.0")); version = (extendedversionnumber ? ini.IniReadValue(section, "ExtendedVersionTemplate", "%version%") : ini.IniReadValue(section, "Branch", "0.0"));
var versionInfo = FileVersionInfo.GetVersionInfo(LocalPaths.BinPath + "\\" + LocalPaths.LauncherName); var versionInfo = FileVersionInfo.GetVersionInfo(LocalPaths.BinPath + "\\" + LocalPaths.LauncherName);
string snapshotrevision = ini.IniReadValue(section, "SnapshotRevision", "1"); string extendedversionrevision = ini.IniReadValue(section, "ExtendedVersionRevision", "1");
version = version.Replace("%version%", ini.IniReadValue(section, "Branch", "0.0")) version = version.Replace("%version%", ini.IniReadValue(section, "Branch", "0.0"))
.Replace("%build%", versionInfo.ProductBuildPart.ToString()) .Replace("%build%", versionInfo.ProductBuildPart.ToString())
.Replace("%revision%", versionInfo.FilePrivatePart.ToString()) .Replace("%revision%", versionInfo.FilePrivatePart.ToString())
.Replace("%snapshot-revision%", snapshotrevision); .Replace("%extended-revision%", extendedversionrevision);
return version; return version;
} }
} }

View File

@ -23,7 +23,7 @@ public class GlobalFuncs
{ {
//READ //READ
string versionbranch, defaultclient, defaultmap, regclient1, string versionbranch, defaultclient, defaultmap, regclient1,
regclient2, issnapshot, snapshottemplate, snapshotrevision; regclient2, extendedversionnumber, extendedversiontemplate, extendedversionrevision, disableeditingchangelog;
INIFile ini = new INIFile(infopath); INIFile ini = new INIFile(infopath);
@ -35,39 +35,45 @@ public class GlobalFuncs
defaultmap = ini.IniReadValue(section, "DefaultMap", "Dev - Baseplate2048.rbxl"); defaultmap = ini.IniReadValue(section, "DefaultMap", "Dev - Baseplate2048.rbxl");
regclient1 = ini.IniReadValue(section, "UserAgentRegisterClient1", "2007M"); regclient1 = ini.IniReadValue(section, "UserAgentRegisterClient1", "2007M");
regclient2 = ini.IniReadValue(section, "UserAgentRegisterClient2", "2009L"); regclient2 = ini.IniReadValue(section, "UserAgentRegisterClient2", "2009L");
issnapshot = ini.IniReadValue(section, "IsSnapshot", "False"); extendedversionnumber = ini.IniReadValue(section, "ExtendedVersionNumber", "False");
snapshottemplate = ini.IniReadValue(section, "SnapshotTemplate", "%version% Snapshot (%build%.%revision%.%snapshot-revision%)"); disableeditingchangelog = ini.IniReadValue(section, "DisableEditingChangelog", "False");
snapshotrevision = ini.IniReadValue(section, "SnapshotRevision", "1"); extendedversiontemplate = ini.IniReadValue(section, "ExtendedVersionTemplate", "%version%");
extendedversionrevision = ini.IniReadValue(section, "ExtendedVersionRevision", "1");
try try
{ {
GlobalVars.IsSnapshot = Convert.ToBoolean(issnapshot); GlobalVars.ExtendedVersionNumber = Convert.ToBoolean(extendedversionnumber);
if (GlobalVars.IsSnapshot) if (GlobalVars.ExtendedVersionNumber)
{ {
if (cmd) if (cmd)
{ {
var versionInfo = FileVersionInfo.GetVersionInfo(GlobalPaths.RootPathLauncher + "\\Novetus.exe"); var versionInfo = FileVersionInfo.GetVersionInfo(GlobalPaths.RootPathLauncher + "\\Novetus.exe");
GlobalVars.ProgramInformation.Version = snapshottemplate.Replace("%version%", versionbranch) GlobalVars.ProgramInformation.Version = extendedversiontemplate.Replace("%version%", versionbranch)
.Replace("%build%", versionInfo.ProductBuildPart.ToString()) .Replace("%build%", versionInfo.ProductBuildPart.ToString())
.Replace("%revision%", versionInfo.FilePrivatePart.ToString()) .Replace("%revision%", versionInfo.FilePrivatePart.ToString())
.Replace("%snapshot-revision%", snapshotrevision); .Replace("%extended-revision%", extendedversionrevision);
} }
else else
{ {
GlobalVars.ProgramInformation.Version = snapshottemplate.Replace("%version%", versionbranch) GlobalVars.ProgramInformation.Version = extendedversiontemplate.Replace("%version%", versionbranch)
.Replace("%build%", Assembly.GetExecutingAssembly().GetName().Version.Build.ToString()) .Replace("%build%", Assembly.GetExecutingAssembly().GetName().Version.Build.ToString())
.Replace("%revision%", Assembly.GetExecutingAssembly().GetName().Version.Revision.ToString()) .Replace("%revision%", Assembly.GetExecutingAssembly().GetName().Version.Revision.ToString())
.Replace("%snapshot-revision%", snapshotrevision); .Replace("%extended-revision%", extendedversionrevision);
} }
string changelog = GlobalPaths.BasePath + "\\changelog.txt"; bool disableedit = Convert.ToBoolean(disableeditingchangelog);
if (File.Exists(changelog))
if (!disableedit)
{ {
string[] changelogedit = File.ReadAllLines(changelog); string changelog = GlobalPaths.BasePath + "\\changelog.txt";
if (!changelogedit[0].Equals(GlobalVars.ProgramInformation.Version)) if (File.Exists(changelog))
{ {
changelogedit[0] = GlobalVars.ProgramInformation.Version; string[] changelogedit = File.ReadAllLines(changelog);
File.WriteAllLines(changelog, changelogedit); if (!changelogedit[0].Equals(GlobalVars.ProgramInformation.Version))
{
changelogedit[0] = GlobalVars.ProgramInformation.Version;
File.WriteAllLines(changelog, changelogedit);
}
} }
} }
} }

View File

@ -49,7 +49,7 @@ public static class GlobalVars
#endregion #endregion
#region Booleans #region Booleans
public static bool IsSnapshot = false; public static bool ExtendedVersionNumber = false;
public static bool LocalPlayMode = false; public static bool LocalPlayMode = false;
public static bool AdminMode = false; public static bool AdminMode = false;
#endregion #endregion