diff --git a/Novetus/Novetus.Launch/LocalFuncs.cs b/Novetus/Novetus.Launch/LocalFuncs.cs
index 8b1f91e..a6b1991 100644
--- a/Novetus/Novetus.Launch/LocalFuncs.cs
+++ b/Novetus/Novetus.Launch/LocalFuncs.cs
@@ -3,6 +3,7 @@ using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
+using System.Reflection;
#endregion
namespace Novetus.Launch
@@ -20,25 +21,7 @@ namespace Novetus.Launch
public static void LaunchApplication(string appName, string args = "")
{
- LaunchApplicationExt(LocalPaths.BinPath, appName, args);
- }
-
- public static string GetVersion(string infopath)
- {
- //READ
- string version;
- INIFile ini = new INIFile(infopath);
- string section = "ProgramInfo";
- bool extendedversionnumber = Convert.ToBoolean(ini.IniReadValue(section, "ExtendedVersionNumber", "False"));
- version = (extendedversionnumber ? ini.IniReadValue(section, "ExtendedVersionTemplate", "%version%") : ini.IniReadValue(section, "Branch", "0.0"));
-
- var versionInfo = FileVersionInfo.GetVersionInfo(LocalPaths.BinPath + "\\" + LocalPaths.LauncherName);
- string extendedversionrevision = ini.IniReadValue(section, "ExtendedVersionRevision", "1");
- version = version.Replace("%version%", ini.IniReadValue(section, "Branch", "0.0"))
- .Replace("%build%", versionInfo.ProductBuildPart.ToString())
- .Replace("%revision%", versionInfo.FilePrivatePart.ToString())
- .Replace("%extended-revision%", extendedversionrevision);
- return version;
+ LaunchApplicationExt(LocalPaths.FixedBinDir, appName, args);
}
}
#endregion
diff --git a/Novetus/Novetus.Launch/LocalPaths.cs b/Novetus/Novetus.Launch/LocalPaths.cs
index 5bf4077..dca2c6a 100644
--- a/Novetus/Novetus.Launch/LocalPaths.cs
+++ b/Novetus/Novetus.Launch/LocalPaths.cs
@@ -9,19 +9,19 @@ namespace Novetus.Launch
public class LocalPaths
{
- #region Base Paths
- public static readonly string RootPathLauncher = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
- public static readonly string BasePathLauncher = RootPathLauncher.Replace(@"\", @"\\");
- public static readonly string BinPath = BasePathLauncher + @"\\bin";
- public static readonly string ConfigPath = BasePathLauncher + @"\\config";
- #endregion
+ public static readonly string FixedBinDir = GlobalPaths.BasePathLauncher + @"\\bin";
+ public static readonly string FixedConfigDir = GlobalPaths.BasePathLauncher + @"\\config";
#region File Names
public static readonly string LauncherName = "Novetus.exe";
public static readonly string CMDName = "NovetusCMD.exe";
public static readonly string URIName = "NovetusURI.exe";
public static readonly string DependencyLauncherName = "Novetus_dependency_installer.bat";
- public static readonly string LauncherInfoFile = "info.ini";
+ #endregion
+
+ #region File Paths
+ public static readonly string LauncherPath = FixedBinDir + "\\" + LauncherName;
+ public static readonly string InfoPath = FixedConfigDir + "\\" + GlobalPaths.InfoName;
#endregion
}
#endregion
diff --git a/Novetus/Novetus.Launch/Novetus.Launch.csproj b/Novetus/Novetus.Launch/Novetus.Launch.csproj
index 9b39220..5ab17d5 100644
--- a/Novetus/Novetus.Launch/Novetus.Launch.csproj
+++ b/Novetus/Novetus.Launch/Novetus.Launch.csproj
@@ -18,7 +18,7 @@
full
false
bin\Debug\
- DEBUG;TRACE
+ TRACE;DEBUG;BASICLAUNCHER
prompt
4
@@ -47,9 +47,6 @@
-
- INIFile.cs
-
@@ -88,6 +85,7 @@
+
SET path=$(SolutionDir)build
diff --git a/Novetus/Novetus.Launch/NovetusLaunchForm.cs b/Novetus/Novetus.Launch/NovetusLaunchForm.cs
index 0c08730..ac4c4d5 100644
--- a/Novetus/Novetus.Launch/NovetusLaunchForm.cs
+++ b/Novetus/Novetus.Launch/NovetusLaunchForm.cs
@@ -18,6 +18,8 @@ namespace Novetus.Launch
//use novetus font for label!!
//https://stackoverflow.com/questions/1297264/using-custom-fonts-on-a-label-on-winforms
+ GlobalFuncs.ReadInfoFile(LocalPaths.InfoPath, true, LocalPaths.LauncherPath);
+
PrivateFontCollection pfc = new PrivateFontCollection();
int fontLength = Properties.Resources.Montserrat_SemiBold.Length;
byte[] fontdata = Properties.Resources.Montserrat_SemiBold;
@@ -26,7 +28,7 @@ namespace Novetus.Launch
pfc.AddMemoryFont(data, fontLength);
VersionLabel.Font = new Font(pfc.Families[0], VersionLabel.Font.Size);
- VersionLabel.Text = LocalFuncs.GetVersion(LocalPaths.ConfigPath + @"\\" + LocalPaths.LauncherInfoFile).ToUpper();
+ VersionLabel.Text = GlobalVars.ProgramInformation.Version.ToUpper();
LaunchNovetusButton.Font = new Font(pfc.Families[0], VersionLabel.Font.Size);
@@ -59,7 +61,7 @@ namespace Novetus.Launch
private void DependencyInstallerButton_Click(object sender, EventArgs e)
{
- LocalFuncs.LaunchApplicationExt(LocalPaths.BasePathLauncher, LocalPaths.DependencyLauncherName);
+ LocalFuncs.LaunchApplicationExt(GlobalPaths.BasePathLauncher, LocalPaths.DependencyLauncherName);
Close();
}
diff --git a/Novetus/Novetus.sln b/Novetus/Novetus.sln
index d26dd1b..9a1c71d 100644
--- a/Novetus/Novetus.sln
+++ b/Novetus/Novetus.sln
@@ -21,6 +21,7 @@ Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
NovetusCore\NovetusCore.projitems*{2070eaa6-7606-4006-a628-5705c24a3644}*SharedItemsImports = 4
NovetusCore\NovetusCore.projitems*{bac99c87-f6c1-4ed0-aa2e-05c6ae8979ea}*SharedItemsImports = 4
+ NovetusCore\NovetusCore.projitems*{d7b467ee-a4b9-42fb-aa83-f487da0f5cb1}*SharedItemsImports = 4
NovetusCore\NovetusCore.projitems*{debcc57d-9a3b-4d7c-8693-fa4aec56c8c1}*SharedItemsImports = 13
NovetusCore\NovetusCore.projitems*{f92ffbed-2767-4676-9711-bb89cda58a43}*SharedItemsImports = 4
EndGlobalSection
diff --git a/Novetus/NovetusCMD/NovetusCMD.cs b/Novetus/NovetusCMD/NovetusCMD.cs
index aeda8c0..7dff749 100644
--- a/Novetus/NovetusCMD/NovetusCMD.cs
+++ b/Novetus/NovetusCMD/NovetusCMD.cs
@@ -136,7 +136,8 @@ namespace NovetusCMD
if (!LocalVars.PrintHelp)
{
- GlobalFuncs.ReadInfoFile(GlobalPaths.ConfigDir + "\\" + GlobalPaths.InfoName, true);
+ GlobalFuncs.ReadInfoFile(GlobalPaths.ConfigDir + "\\" + GlobalPaths.InfoName, true,
+ GlobalPaths.RootPathLauncher + "\\Novetus.exe");
Console.Title = "Novetus " + GlobalVars.ProgramInformation.Version + " CMD";
GlobalFuncs.ConsolePrint("NovetusCMD version " + GlobalVars.ProgramInformation.Version + " loaded.", 1);
diff --git a/Novetus/NovetusCore/StorageAndFunctions/GlobalFuncs.cs b/Novetus/NovetusCore/StorageAndFunctions/GlobalFuncs.cs
index 123b8d4..ee456b3 100644
--- a/Novetus/NovetusCore/StorageAndFunctions/GlobalFuncs.cs
+++ b/Novetus/NovetusCore/StorageAndFunctions/GlobalFuncs.cs
@@ -19,7 +19,7 @@ using System.Xml.Linq;
#region Global Functions
public class GlobalFuncs
{
- public static void ReadInfoFile(string infopath, bool cmd = false)
+ public static void ReadInfoFile(string infopath, bool other = false, string exepath = "")
{
//READ
string versionbranch, defaultclient, defaultmap, regclient1,
@@ -39,27 +39,38 @@ public class GlobalFuncs
extendedversionnumber = ini.IniReadValue(section, "ExtendedVersionNumber", "False");
extendedversioneditchangelog = ini.IniReadValue(section, "ExtendedVersionEditChangelog", "False");
extendedversiontemplate = ini.IniReadValue(section, "ExtendedVersionTemplate", "%version%");
- extendedversionrevision = ini.IniReadValue(section, "ExtendedVersionRevision", "1");
+ extendedversionrevision = ini.IniReadValue(section, "ExtendedVersionRevision", "-1");
try
{
GlobalVars.ExtendedVersionNumber = Convert.ToBoolean(extendedversionnumber);
if (GlobalVars.ExtendedVersionNumber)
{
- if (cmd)
+ if (other)
{
- var versionInfo = FileVersionInfo.GetVersionInfo(GlobalPaths.RootPathLauncher + "\\Novetus.exe");
- GlobalVars.ProgramInformation.Version = extendedversiontemplate.Replace("%version%", versionbranch)
- .Replace("%build%", versionInfo.ProductBuildPart.ToString())
- .Replace("%revision%", versionInfo.FilePrivatePart.ToString())
- .Replace("%extended-revision%", extendedversionrevision);
+ if (!string.IsNullOrWhiteSpace(exepath))
+ {
+ string dateformat = GetLinkerTimestampUtc(exepath).ToString("MM.yyyy");
+ var versionInfo = FileVersionInfo.GetVersionInfo(exepath);
+ GlobalVars.ProgramInformation.Version = extendedversiontemplate.Replace("%version%", versionbranch)
+ .Replace("%build%", versionInfo.ProductBuildPart.ToString())
+ .Replace("%revision%", versionInfo.FilePrivatePart.ToString())
+ .Replace("%extended-revision%", (!extendedversionrevision.Equals("-1") ? extendedversionrevision : ""))
+ .Replace("%compile-date%", dateformat);
+ }
+ else
+ {
+ return;
+ }
}
else
{
+ string dateformat = GetLinkerTimestampUtc(Assembly.GetExecutingAssembly()).ToString("MM.yyyy");
GlobalVars.ProgramInformation.Version = extendedversiontemplate.Replace("%version%", versionbranch)
.Replace("%build%", Assembly.GetExecutingAssembly().GetName().Version.Build.ToString())
.Replace("%revision%", Assembly.GetExecutingAssembly().GetName().Version.Revision.ToString())
- .Replace("%extended-revision%", extendedversionrevision);
+ .Replace("%extended-revision%", (!extendedversionrevision.Equals("-1") ? extendedversionrevision : ""))
+ .Replace("%compile-date%", dateformat);
}
bool changelogedit = Convert.ToBoolean(extendedversioneditchangelog);
@@ -95,7 +106,7 @@ public class GlobalFuncs
}
catch (Exception)
{
- ReadInfoFile(infopath, cmd);
+ ReadInfoFile(infopath, other);
}
}
@@ -1696,11 +1707,13 @@ public class GlobalFuncs
return Regex.Replace(lines, @"^\s*$\n|\r", string.Empty, RegexOptions.Multiline).TrimEnd();
}
+#if !BASICLAUNCHER
//task.delay is only available on net 4.5.......
public static async void Delay(int miliseconds)
{
await TaskEx.Delay(miliseconds);
}
+#endif
// Credit to Carrot for the original code. Rewote it to be smaller.
public static string CryptStringWithByte(string word)
@@ -1750,5 +1763,29 @@ public class GlobalFuncs
adjustedSize,
SizeSuffixes[mag]);
}
+
+ //https://www.meziantou.net/getting-the-date-of-build-of-a-dotnet-assembly-at-runtime.htm
+ public static DateTime GetLinkerTimestampUtc(Assembly assembly)
+ {
+ var location = assembly.Location;
+ return GetLinkerTimestampUtc(location);
+ }
+
+ public static DateTime GetLinkerTimestampUtc(string filePath)
+ {
+ const int peHeaderOffset = 60;
+ const int linkerTimestampOffset = 8;
+ var bytes = new byte[2048];
+
+ using (var file = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
+ {
+ file.Read(bytes, 0, bytes.Length);
+ }
+
+ var headerPos = BitConverter.ToInt32(bytes, peHeaderOffset);
+ var secondsSince1970 = BitConverter.ToInt32(bytes, headerPos + linkerTimestampOffset);
+ var dt = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+ return dt.AddSeconds(secondsSince1970);
+ }
}
#endregion
diff --git a/Novetus/NovetusCore/StorageAndFunctions/GlobalPaths.cs b/Novetus/NovetusCore/StorageAndFunctions/GlobalPaths.cs
index 5df6c2e..624d9dc 100644
--- a/Novetus/NovetusCore/StorageAndFunctions/GlobalPaths.cs
+++ b/Novetus/NovetusCore/StorageAndFunctions/GlobalPaths.cs
@@ -13,6 +13,7 @@ public class GlobalPaths
public static readonly string RootPath = Directory.GetParent(RootPathLauncher).ToString();
public static readonly string BasePath = RootPath.Replace(@"\", @"\\");
public static readonly string DataPath = BasePath + @"\\shareddata";
+ public static readonly string BinDir = BasePath + @"\\bin";
public static readonly string ConfigDir = BasePath + @"\\config";
public static readonly string ConfigDirClients = ConfigDir + @"\\clients";
public static readonly string ConfigDirTemplates = ConfigDir + @"\\itemtemplates";
diff --git a/Novetus/NovetusCore/StorageAndFunctions/NetFuncs.cs b/Novetus/NovetusCore/StorageAndFunctions/NetFuncs.cs
index 4b0b956..7f962af 100644
--- a/Novetus/NovetusCore/StorageAndFunctions/NetFuncs.cs
+++ b/Novetus/NovetusCore/StorageAndFunctions/NetFuncs.cs
@@ -1,4 +1,5 @@
-#region Usings
+#if !BASICLAUNCHER
+#region Usings
using Mono.Nat;
using System;
#endregion
@@ -52,3 +53,4 @@ public static class NetFuncs
}
}
#endregion
+#endif
diff --git a/Novetus/NovetusCore/StorageAndFunctions/ScriptFuncs.cs b/Novetus/NovetusCore/StorageAndFunctions/ScriptFuncs.cs
index 672d142..b1f1a35 100644
--- a/Novetus/NovetusCore/StorageAndFunctions/ScriptFuncs.cs
+++ b/Novetus/NovetusCore/StorageAndFunctions/ScriptFuncs.cs
@@ -2,7 +2,6 @@
using System;
using System.Collections.Generic;
using System.IO;
-using System.Net.PeerToPeer.Collaboration;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Windows.Forms;
diff --git a/Novetus/NovetusCore/StorageAndFunctions/SecurityFuncs.cs b/Novetus/NovetusCore/StorageAndFunctions/SecurityFuncs.cs
index b12a3eb..d0692d2 100644
--- a/Novetus/NovetusCore/StorageAndFunctions/SecurityFuncs.cs
+++ b/Novetus/NovetusCore/StorageAndFunctions/SecurityFuncs.cs
@@ -267,10 +267,12 @@ public class SecurityFuncs
return ipAddress;
}
+ #if !BASICLAUNCHER
public static async Task GetExternalIPAddressAsync()
{
var task = Task.Factory.StartNew(() => GetExternalIPAddress());
return await task;
}
+ #endif
}
#endregion
\ No newline at end of file
diff --git a/Novetus/NovetusURI/Forms/InstallForm.Designer.cs b/Novetus/NovetusURI/Forms/InstallForm.Designer.cs
index 547f12f..e941edf 100644
--- a/Novetus/NovetusURI/Forms/InstallForm.Designer.cs
+++ b/Novetus/NovetusURI/Forms/InstallForm.Designer.cs
@@ -52,6 +52,7 @@
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "InstallForm";
this.Text = "Novetus URI Installer";
+ this.Load += new System.EventHandler(this.InstallForm_Load);
this.ResumeLayout(false);
}
diff --git a/Novetus/NovetusURI/Forms/InstallForm.cs b/Novetus/NovetusURI/Forms/InstallForm.cs
index 2b93212..4db469b 100644
--- a/Novetus/NovetusURI/Forms/InstallForm.cs
+++ b/Novetus/NovetusURI/Forms/InstallForm.cs
@@ -16,6 +16,11 @@ namespace NovetusURI
#endregion
#region Form Events
+ private void InstallForm_Load(object sender, EventArgs e)
+ {
+ CenterToScreen();
+ }
+
private void button1_Click(object sender, EventArgs e)
{
LocalFuncs.RegisterURI(this);
diff --git a/Novetus/NovetusURI/Forms/LoaderForm.cs b/Novetus/NovetusURI/Forms/LoaderForm.cs
index 3ed9e8c..26fadf6 100644
--- a/Novetus/NovetusURI/Forms/LoaderForm.cs
+++ b/Novetus/NovetusURI/Forms/LoaderForm.cs
@@ -94,6 +94,7 @@ namespace NovetusURI
else
{
Visible = true;
+ CenterToScreen();
if (GlobalVars.UserConfiguration.DiscordPresence)
{
label1.Text = "Starting Discord Rich Presence...";
diff --git a/Novetus/NovetusURI/Forms/QuickConfigure.cs b/Novetus/NovetusURI/Forms/QuickConfigure.cs
index 17c376a..59506a2 100644
--- a/Novetus/NovetusURI/Forms/QuickConfigure.cs
+++ b/Novetus/NovetusURI/Forms/QuickConfigure.cs
@@ -20,6 +20,7 @@ namespace NovetusURI
void QuickConfigureLoad(object sender, EventArgs e)
{
ReadConfigValues(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName);
+ CenterToScreen();
}
void Button3Click(object sender, EventArgs e)