fixed various bugs

This commit is contained in:
Bitl 2021-11-07 07:29:26 -07:00
parent 7706658f9c
commit cb60ed7773
11 changed files with 82 additions and 54 deletions

View File

@ -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";

View File

@ -79,7 +79,6 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<None Include="Resources\Montserrat-SemiBold.ttf" />
</ItemGroup>
<ItemGroup>
<Content Include="NovetusIcon.ico" />

View File

@ -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();
}

View File

@ -60,16 +60,6 @@ namespace Novetus.Bootstrapper.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
internal static byte[] Montserrat_SemiBold {
get {
object obj = ResourceManager.GetObject("Montserrat_SemiBold", resourceCulture);
return ((byte[])(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>

View File

@ -118,9 +118,6 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="Montserrat_SemiBold" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Montserrat-SemiBold.ttf;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="NOVETUS_new_final_smol" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\NOVETUS_new_final_smol.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>

View File

@ -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

View File

@ -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 = "\"";

View File

@ -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";

View File

@ -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);
}
}

View File

@ -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();