diff --git a/Novetus/Novetus.Bootstrapper/LocalPaths.cs b/Novetus/Novetus.Bootstrapper/LocalPaths.cs index 6129f8a..6292920 100644 --- a/Novetus/Novetus.Bootstrapper/LocalPaths.cs +++ b/Novetus/Novetus.Bootstrapper/LocalPaths.cs @@ -11,6 +11,7 @@ namespace Novetus.Bootstrapper { public static readonly string FixedBinDir = GlobalPaths.BasePathLauncher + @"\\bin"; public static readonly string FixedConfigDir = GlobalPaths.BasePathLauncher + @"\\config"; + public static readonly string FixedDataDir = FixedBinDir + @"\\data"; #region File Names public static readonly string LauncherName = "Novetus.exe"; diff --git a/Novetus/Novetus.Bootstrapper/Novetus.Bootstrapper.csproj b/Novetus/Novetus.Bootstrapper/Novetus.Bootstrapper.csproj index c750839..9280b34 100644 --- a/Novetus/Novetus.Bootstrapper/Novetus.Bootstrapper.csproj +++ b/Novetus/Novetus.Bootstrapper/Novetus.Bootstrapper.csproj @@ -79,7 +79,6 @@ Settings.settings True - diff --git a/Novetus/Novetus.Bootstrapper/NovetusLaunchForm.cs b/Novetus/Novetus.Bootstrapper/NovetusLaunchForm.cs index 8a83d16..a2a5bfc 100644 --- a/Novetus/Novetus.Bootstrapper/NovetusLaunchForm.cs +++ b/Novetus/Novetus.Bootstrapper/NovetusLaunchForm.cs @@ -1,7 +1,6 @@ using System; using System.Drawing; using System.Drawing.Text; -using System.Runtime.InteropServices; using System.Windows.Forms; namespace Novetus.Bootstrapper @@ -16,22 +15,26 @@ namespace Novetus.Bootstrapper private void NovetusLaunchForm_Load(object sender, EventArgs e) { //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; - IntPtr data = Marshal.AllocCoTaskMem(fontLength); - Marshal.Copy(fontdata, 0, data, fontLength); - pfc.AddMemoryFont(data, fontLength); + try + { + PrivateFontCollection pfc = new PrivateFontCollection(); + string fontPath = LocalPaths.FixedDataDir + "\\BootstrapperFont.ttf"; + pfc.AddFontFile(fontPath); + + foreach (var fam in pfc.Families) + { + VersionLabel.Font = new Font(fam, VersionLabel.Font.Size); + LaunchNovetusButton.Font = new Font(fam, VersionLabel.Font.Size); + } + } + catch (Exception) + { + } - VersionLabel.Font = new Font(pfc.Families[0], VersionLabel.Font.Size); VersionLabel.Text = GlobalVars.ProgramInformation.Version.ToUpper(); - - LaunchNovetusButton.Font = new Font(pfc.Families[0], VersionLabel.Font.Size); - CenterToScreen(); } diff --git a/Novetus/Novetus.Bootstrapper/Properties/Resources.Designer.cs b/Novetus/Novetus.Bootstrapper/Properties/Resources.Designer.cs index f1aca5d..adeffeb 100644 --- a/Novetus/Novetus.Bootstrapper/Properties/Resources.Designer.cs +++ b/Novetus/Novetus.Bootstrapper/Properties/Resources.Designer.cs @@ -60,16 +60,6 @@ namespace Novetus.Bootstrapper.Properties { } } - /// - /// Looks up a localized resource of type System.Byte[]. - /// - internal static byte[] Montserrat_SemiBold { - get { - object obj = ResourceManager.GetObject("Montserrat_SemiBold", resourceCulture); - return ((byte[])(obj)); - } - } - /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/Novetus/Novetus.Bootstrapper/Properties/Resources.resx b/Novetus/Novetus.Bootstrapper/Properties/Resources.resx index b160fce..eba071f 100644 --- a/Novetus/Novetus.Bootstrapper/Properties/Resources.resx +++ b/Novetus/Novetus.Bootstrapper/Properties/Resources.resx @@ -118,9 +118,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - ..\Resources\Montserrat-SemiBold.ttf;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - ..\Resources\NOVETUS_new_final_smol.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a diff --git a/Novetus/Novetus.Bootstrapper/Resources/Montserrat-SemiBold.ttf b/Novetus/Novetus.Bootstrapper/Resources/Montserrat-SemiBold.ttf deleted file mode 100644 index f8a43f2..0000000 Binary files a/Novetus/Novetus.Bootstrapper/Resources/Montserrat-SemiBold.ttf and /dev/null differ diff --git a/Novetus/NovetusCMD/NovetusCMD.cs b/Novetus/NovetusCMD/NovetusCMD.cs index 9727a4e..79cb1ac 100644 --- a/Novetus/NovetusCMD/NovetusCMD.cs +++ b/Novetus/NovetusCMD/NovetusCMD.cs @@ -6,6 +6,7 @@ using System.IO; using System.Windows.Forms; using NLog; using System.Threading; +using System.Runtime.InteropServices; #endregion namespace NovetusCMD @@ -13,6 +14,24 @@ namespace NovetusCMD #region Novetus CMD Main Class public static class NovetusCMD { + //https://stackoverflow.com/questions/474679/capture-console-exit-c-sharp + #region Trap application termination + [DllImport("Kernel32")] + private static extern bool SetConsoleCtrlHandler(EventHandler handler, bool add); + + private delegate bool EventHandler(CtrlType sig); + static EventHandler _handler; + + enum CtrlType + { + CTRL_C_EVENT = 0, + CTRL_BREAK_EVENT = 1, + CTRL_CLOSE_EVENT = 2, + CTRL_LOGOFF_EVENT = 5, + CTRL_SHUTDOWN_EVENT = 6 + } + #endregion + #region UPnP public static void InitUPnP() { @@ -121,6 +140,9 @@ namespace NovetusCMD #region Main Program Function public static void Main(string[] args) { + _handler += new EventHandler(CloseHandler); + SetConsoleCtrlHandler(_handler, true); + var config = new NLog.Config.LoggingConfiguration(); var logfile = new NLog.Targets.FileTarget("logfile") { FileName = GlobalPaths.ConfigDir + "\\CMD-log-" + DateTime.Today.ToString("MM-dd-yyyy") + ".log" }; config.AddRule(LogLevel.Info, LogLevel.Fatal, logfile); @@ -149,8 +171,6 @@ namespace NovetusCMD LoadOverrideINIArgs(args); InitUPnP(); - AppDomain.CurrentDomain.ProcessExit += new EventHandler(ProgramClose); - GlobalFuncs.ConsolePrint("Launching a " + GlobalVars.UserConfiguration.SelectedClient + " server on " + GlobalVars.UserConfiguration.Map + " with " + GlobalVars.UserConfiguration.PlayerLimit + " players.", 1); switch (LocalVars.DebugMode) @@ -172,28 +192,37 @@ namespace NovetusCMD Console.ReadKey(); } - static void ProgramClose(object sender, EventArgs e) + private static bool CloseHandler(CtrlType sig) { - if (GlobalVars.ProcessID != 0) + CloseHandlerInternal(); + return true; + } + + private static void CloseHandlerInternal() + { + if (!LocalVars.PrintHelp) { - if (LocalFuncs.ProcessExists(GlobalVars.ProcessID)) + if (GlobalVars.ProcessID != 0) { - Process proc = Process.GetProcessById(GlobalVars.ProcessID); - proc.Kill(); + if (LocalFuncs.ProcessExists(GlobalVars.ProcessID)) + { + Process proc = Process.GetProcessById(GlobalVars.ProcessID); + proc.Kill(); + } + } + + if (!LocalVars.OverrideINI) + { + WriteConfigValues(); + } + + if (GlobalVars.RequestToOutputInfo) + { + GlobalFuncs.FixedFileDelete(GlobalPaths.BasePath + "\\" + GlobalVars.ServerInfoFileName); } } - if (!LocalVars.OverrideINI) - { - WriteConfigValues(); - } - - if (GlobalVars.RequestToOutputInfo) - { - GlobalFuncs.FixedFileDelete(GlobalPaths.BasePath + "\\" + GlobalVars.ServerInfoFileName); - } - - Application.Exit(); + Environment.Exit(-1); } static void LoadCMDArgs(string[] args) @@ -318,15 +347,16 @@ namespace NovetusCMD #region Client Loading static void StartServer(bool no3d) { - GlobalFuncs.LaunchRBXClient(ScriptType.Server, no3d, false, new EventHandler(ServerExited)); + GlobalFuncs.LaunchRBXClient(ScriptType.Server, no3d, false, new System.EventHandler(ServerExited)); } static void ServerExited(object sender, EventArgs e) { GlobalVars.GameOpened = ScriptType.None; GlobalFuncs.PingMasterServer(0, "The server has removed itself from the master server list."); - Environment.Exit(0); - } + CloseHandlerInternal(); + + } #endregion } #endregion diff --git a/Novetus/NovetusCore/StorageAndFunctions/GlobalFuncs.cs b/Novetus/NovetusCore/StorageAndFunctions/GlobalFuncs.cs index 4a4586a..1f684d8 100644 --- a/Novetus/NovetusCore/StorageAndFunctions/GlobalFuncs.cs +++ b/Novetus/NovetusCore/StorageAndFunctions/GlobalFuncs.cs @@ -468,7 +468,7 @@ public class GlobalFuncs if (!File.Exists(fulldllpath)) { - FixedFileCopy(GlobalPaths.ConfigDirData + "\\" + dllfilename, fulldllpath, false); + FixedFileCopy(GlobalPaths.DataDir + "\\" + dllfilename, fulldllpath, false); } } else @@ -644,8 +644,16 @@ public class GlobalFuncs string name = ClientName; if (string.IsNullOrWhiteSpace(name)) { - name = GlobalVars.ProgramInformation.DefaultClient; + if (!string.IsNullOrWhiteSpace(GlobalVars.ProgramInformation.DefaultClient)) + { + name = GlobalVars.ProgramInformation.DefaultClient; + } + else + { + return; + } } + string clientpath = GlobalPaths.ClientDir + @"\\" + name + @"\\clientinfo.nov"; if (!File.Exists(clientpath)) @@ -1893,7 +1901,7 @@ public class GlobalFuncs string luafile = GetLuaFileName(ClientName, type); string rbxexe = GetClientEXEDir(ClientName, type); - string mapfile = type.Equals(ScriptType.EasterEgg) ? GlobalPaths.ConfigDirData + "\\Appreciation.rbxl" : (nomap ? "" : GlobalVars.UserConfiguration.MapPath); + string mapfile = type.Equals(ScriptType.EasterEgg) ? GlobalPaths.DataDir + "\\Appreciation.rbxl" : (nomap ? "" : GlobalVars.UserConfiguration.MapPath); string mapname = type.Equals(ScriptType.EasterEgg) ? "" : (nomap ? "" : GlobalVars.UserConfiguration.Map); FileFormat.ClientInfo info = GetClientInfoValues(ClientName); string quote = "\""; diff --git a/Novetus/NovetusCore/StorageAndFunctions/GlobalPaths.cs b/Novetus/NovetusCore/StorageAndFunctions/GlobalPaths.cs index 6fcf025..1f21498 100644 --- a/Novetus/NovetusCore/StorageAndFunctions/GlobalPaths.cs +++ b/Novetus/NovetusCore/StorageAndFunctions/GlobalPaths.cs @@ -17,7 +17,7 @@ public class GlobalPaths public static readonly string ConfigDir = BasePath + @"\\config"; public static readonly string ConfigDirClients = ConfigDir + @"\\clients"; public static readonly string ConfigDirTemplates = ConfigDir + @"\\itemtemplates"; - public static readonly string ConfigDirData = BasePathLauncher + @"\\data"; + public static readonly string DataDir = BinDir + @"\\data"; public static readonly string ClientDir = BasePath + @"\\clients"; public static readonly string MapsDir = BasePath + @"\\maps"; public static readonly string MapsDirCustom = MapsDir + @"\\Custom"; diff --git a/Novetus/NovetusLauncher/Forms/SDK/AssetSDK.cs b/Novetus/NovetusLauncher/Forms/SDK/AssetSDK.cs index 8633f13..aadf940 100644 --- a/Novetus/NovetusLauncher/Forms/SDK/AssetSDK.cs +++ b/Novetus/NovetusLauncher/Forms/SDK/AssetSDK.cs @@ -1218,7 +1218,7 @@ public partial class AssetSDK : Form { if (MeshConverter_OpenOBJDialog.ShowDialog() == DialogResult.OK) { - MeshConverter_ProcessOBJ(GlobalPaths.ConfigDirData + "\\ObjToRBXMesh.exe", MeshConverter_OpenOBJDialog.FileName); + MeshConverter_ProcessOBJ(GlobalPaths.DataDir + "\\ObjToRBXMesh.exe", MeshConverter_OpenOBJDialog.FileName); } } diff --git a/Novetus/NovetusLauncher/Forms/SDK/NovetusSDK.cs b/Novetus/NovetusLauncher/Forms/SDK/NovetusSDK.cs index 523073e..e7c506f 100644 --- a/Novetus/NovetusLauncher/Forms/SDK/NovetusSDK.cs +++ b/Novetus/NovetusLauncher/Forms/SDK/NovetusSDK.cs @@ -88,14 +88,14 @@ public partial class NovetusSDK : Form break; case SDKApps.ScriptGenerator: Process proc = new Process(); - proc.StartInfo.FileName = GlobalPaths.ConfigDirData + "\\RSG.exe"; + proc.StartInfo.FileName = GlobalPaths.DataDir + "\\RSG.exe"; proc.StartInfo.CreateNoWindow = false; proc.StartInfo.UseShellExecute = false; proc.Start(); break; case SDKApps.LegacyPlaceConverter: Process proc2 = new Process(); - proc2.StartInfo.FileName = GlobalPaths.ConfigDirData + "\\Roblox_Legacy_Place_Converter.exe"; + proc2.StartInfo.FileName = GlobalPaths.DataDir + "\\Roblox_Legacy_Place_Converter.exe"; proc2.StartInfo.CreateNoWindow = false; proc2.StartInfo.UseShellExecute = false; proc2.Start();