mirror of
https://github.com/Facepunch/sbox-public.git
synced 2025-12-23 22:48:07 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
54 lines
1.2 KiB
C#
54 lines
1.2 KiB
C#
namespace Sandbox;
|
|
|
|
/// <summary>
|
|
/// Used for sbox-dev editor
|
|
/// </summary>
|
|
public class EditorAppSystem : AppSystem
|
|
{
|
|
public override void Init()
|
|
{
|
|
LoadSteamDll();
|
|
|
|
base.Init();
|
|
|
|
// Error as early as possible if invalid project
|
|
if ( !CheckProject() )
|
|
return;
|
|
|
|
CreateMenu();
|
|
CreateGame();
|
|
CreateEditor();
|
|
|
|
var createInfo = new AppSystemCreateInfo()
|
|
{
|
|
WindowTitle = "s&box editor",
|
|
Flags = AppSystemFlags.IsGameApp | AppSystemFlags.IsEditor
|
|
};
|
|
|
|
if ( Utility.CommandLine.HasSwitch( "-test" ) )
|
|
createInfo.Flags |= AppSystemFlags.IsUnitTest;
|
|
|
|
InitGame( createInfo );
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Checks if a valid -project parameter was passed
|
|
/// </summary>
|
|
protected bool CheckProject()
|
|
{
|
|
// -test special case
|
|
if ( !Utility.CommandLine.HasSwitch( "-project" ) && Utility.CommandLine.HasSwitch( "-test" ) )
|
|
return true;
|
|
|
|
var path = Utility.CommandLine.GetSwitch( "-project", "" ).TrimQuoted();
|
|
|
|
Project project = new() { ConfigFilePath = path };
|
|
if ( project.LoadMinimal() )
|
|
return true;
|
|
|
|
NativeEngine.EngineGlobal.Plat_MessageBox( "Couldn't open project", $"Couldn't open project file: {path}" );
|
|
return false;
|
|
}
|
|
}
|