|
@@ -52,7 +52,8 @@ namespace AtomicEditor
|
|
|
|
|
|
|
|
AEPlayerApplication::AEPlayerApplication(Context* context) :
|
|
AEPlayerApplication::AEPlayerApplication(Context* context) :
|
|
|
AEEditorCommon(context),
|
|
AEEditorCommon(context),
|
|
|
- debugPlayer_(false)
|
|
|
|
|
|
|
+ debugPlayer_(false),
|
|
|
|
|
+ launchedByEditor_(false)
|
|
|
{
|
|
{
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -60,44 +61,98 @@ void AEPlayerApplication::Setup()
|
|
|
{
|
|
{
|
|
|
AEEditorCommon::Setup();
|
|
AEEditorCommon::Setup();
|
|
|
|
|
|
|
|
- // Read the engine configuration
|
|
|
|
|
|
|
+ // Read the project engine configuration
|
|
|
ReadEngineConfig();
|
|
ReadEngineConfig();
|
|
|
|
|
|
|
|
engine_->SetAutoExit(false);
|
|
engine_->SetAutoExit(false);
|
|
|
|
|
|
|
|
engineParameters_.InsertNew("WindowTitle", "AtomicPlayer");
|
|
engineParameters_.InsertNew("WindowTitle", "AtomicPlayer");
|
|
|
|
|
|
|
|
|
|
+ // Set defaults not already set from config
|
|
|
#if (ATOMIC_PLATFORM_ANDROID)
|
|
#if (ATOMIC_PLATFORM_ANDROID)
|
|
|
- engineParameters_["FullScreen"] = true;
|
|
|
|
|
- engineParameters_["ResourcePaths"] = "CoreData;AtomicResources";
|
|
|
|
|
|
|
+ engineParameters_.InsertNew("FullScreen", true);
|
|
|
|
|
+ engineParameters_.InsertNew("ResourcePaths", "CoreData;AtomicResources");
|
|
|
#elif ATOMIC_PLATFORM_WEB
|
|
#elif ATOMIC_PLATFORM_WEB
|
|
|
- engineParameters_["FullScreen"] = false;
|
|
|
|
|
- engineParameters_["ResourcePaths"] = "AtomicResources";
|
|
|
|
|
- // engineParameters_["WindowWidth"] = 1280;
|
|
|
|
|
- // engineParameters_["WindowHeight"] = 720;
|
|
|
|
|
|
|
+ engineParameters_.InsertNew("FullScreen", false);
|
|
|
|
|
+ engineParameters_.InsertNew("ResourcePaths", "AtomicResources");
|
|
|
|
|
+ // engineParameters_.InsertNew("WindowWidth", 1280);
|
|
|
|
|
+ // engineParameters_.InsertNew("WindowHeight", 720);
|
|
|
#elif ATOMIC_PLATFORM_IOS
|
|
#elif ATOMIC_PLATFORM_IOS
|
|
|
- engineParameters_["FullScreen"] = false;
|
|
|
|
|
- engineParameters_["ResourcePaths"] = "AtomicResources";
|
|
|
|
|
|
|
+ engineParameters_.InsertNew("FullScreen", false);
|
|
|
|
|
+ engineParameters_.InsertNew("ResourcePaths", "AtomicResources)";
|
|
|
#else
|
|
#else
|
|
|
- engineParameters_["FullScreen"] = false;
|
|
|
|
|
- engineParameters_["WindowWidth"] = 1280;
|
|
|
|
|
- engineParameters_["WindowHeight"] = 720;
|
|
|
|
|
|
|
+ engineParameters_.InsertNew("FullScreen", false);
|
|
|
|
|
+ engineParameters_.InsertNew("WindowWidth", 1280);
|
|
|
|
|
+ engineParameters_.InsertNew("WindowHeight", 720);
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
engineParameters_.InsertNew("LogLevel", LOG_DEBUG);
|
|
engineParameters_.InsertNew("LogLevel", LOG_DEBUG);
|
|
|
|
|
|
|
|
#if ATOMIC_PLATFORM_WINDOWS || ATOMIC_PLATFORM_LINUX
|
|
#if ATOMIC_PLATFORM_WINDOWS || ATOMIC_PLATFORM_LINUX
|
|
|
- engineParameters_["WindowIcon"] = "Images/AtomicLogo32.png";
|
|
|
|
|
- engineParameters_["ResourcePrefixPath"] = "AtomicPlayer_Resources";
|
|
|
|
|
|
|
+ engineParameters_.InsertNew("WindowIcon", "Images/AtomicLogo32.png");
|
|
|
|
|
+ engineParameters_.InsertNew("ResourcePrefixPath", "AtomicPlayer_Resources");
|
|
|
#elif ATOMIC_PLATFORM_ANDROID
|
|
#elif ATOMIC_PLATFORM_ANDROID
|
|
|
- //engineParameters_["ResourcePrefixPath"] = "assets";
|
|
|
|
|
|
|
+ //engineParameters_.InsertNew("ResourcePrefixPath", "assets");
|
|
|
#elif ATOMIC_PLATFORM_OSX
|
|
#elif ATOMIC_PLATFORM_OSX
|
|
|
- engineParameters_["ResourcePrefixPath"] = "../Resources";
|
|
|
|
|
|
|
+ engineParameters_.InsertNew("ResourcePrefixPath", "../Resources");
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
- FileSystem* filesystem = GetSubsystem<FileSystem>();
|
|
|
|
|
|
|
+ // Read command line arguments, potentially overwriting project settings
|
|
|
|
|
+ ReadCommandLineArguments();
|
|
|
|
|
|
|
|
|
|
+ // Re-apply project settings if running from editor play button
|
|
|
|
|
+ if (launchedByEditor_)
|
|
|
|
|
+ {
|
|
|
|
|
+ EngineConfig::ApplyConfig(engineParameters_, true);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Use the script file name as the base name for the log file
|
|
|
|
|
+ engineParameters_["LogName"] = GetSubsystem<FileSystem>()->GetAppPreferencesDir("AtomicPlayer", "Logs") + "AtomicPlayer.log";
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void AEPlayerApplication::ReadEngineConfig()
|
|
|
|
|
+{
|
|
|
|
|
+ // find the project path from the command line args
|
|
|
|
|
+
|
|
|
|
|
+ String projectPath;
|
|
|
|
|
+ const Vector<String>& arguments = GetArguments();
|
|
|
|
|
+
|
|
|
|
|
+ for (unsigned i = 0; i < arguments.Size(); ++i)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (arguments[i].Length() > 1)
|
|
|
|
|
+ {
|
|
|
|
|
+ String argument = arguments[i].ToLower();
|
|
|
|
|
+ String value = i + 1 < arguments.Size() ? arguments[i + 1] : String::EMPTY;
|
|
|
|
|
+
|
|
|
|
|
+ if (argument == "--project" && value.Length())
|
|
|
|
|
+ {
|
|
|
|
|
+ projectPath = AddTrailingSlash(value);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!projectPath.Length())
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ String filename = projectPath + "Settings/Engine.json";
|
|
|
|
|
+
|
|
|
|
|
+ FileSystem* fileSystem = GetSubsystem<FileSystem>();
|
|
|
|
|
+ if (!fileSystem->FileExists(filename))
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ if (EngineConfig::LoadFromFile(context_, filename))
|
|
|
|
|
+ {
|
|
|
|
|
+ EngineConfig::ApplyConfig(engineParameters_);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void AEPlayerApplication::ReadCommandLineArguments()
|
|
|
|
|
+{
|
|
|
const Vector<String>& arguments = GetArguments();
|
|
const Vector<String>& arguments = GetArguments();
|
|
|
|
|
+ FileSystem* fileSystem = GetSubsystem<FileSystem>();
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < arguments.Size(); ++i)
|
|
for (unsigned i = 0; i < arguments.Size(); ++i)
|
|
|
{
|
|
{
|
|
@@ -110,6 +165,12 @@ void AEPlayerApplication::Setup()
|
|
|
{
|
|
{
|
|
|
SubscribeToEvent(E_LOGMESSAGE, HANDLER(AEPlayerApplication, HandleLogMessage));
|
|
SubscribeToEvent(E_LOGMESSAGE, HANDLER(AEPlayerApplication, HandleLogMessage));
|
|
|
}
|
|
}
|
|
|
|
|
+ else if (argument.StartsWith("--ipc-server=") || argument.StartsWith("--ipc-client="))
|
|
|
|
|
+ {
|
|
|
|
|
+ // If we have IPC server/client we're being launched from the Editor
|
|
|
|
|
+ // TODO: Unify this with AEPlayerMode handling
|
|
|
|
|
+ launchedByEditor_ = true;
|
|
|
|
|
+ }
|
|
|
else if (argument == "--debug")
|
|
else if (argument == "--debug")
|
|
|
{
|
|
{
|
|
|
debugPlayer_ = true;
|
|
debugPlayer_ = true;
|
|
@@ -121,7 +182,7 @@ void AEPlayerApplication::Setup()
|
|
|
value = AddTrailingSlash(value);
|
|
value = AddTrailingSlash(value);
|
|
|
|
|
|
|
|
// check that cache exists
|
|
// check that cache exists
|
|
|
- if (!filesystem->DirExists(value + "Cache"))
|
|
|
|
|
|
|
+ if (!fileSystem->DirExists(value + "Cache"))
|
|
|
{
|
|
{
|
|
|
ErrorExit("Project cache folder does not exist, projects must be loaded into the Atomic Editor at least once before using the --player command line mode");
|
|
ErrorExit("Project cache folder does not exist, projects must be loaded into the Atomic Editor at least once before using the --player command line mode");
|
|
|
return;
|
|
return;
|
|
@@ -130,18 +191,18 @@ void AEPlayerApplication::Setup()
|
|
|
#ifdef ATOMIC_DEV_BUILD
|
|
#ifdef ATOMIC_DEV_BUILD
|
|
|
|
|
|
|
|
String resourcePaths = ToString("%s/Resources/CoreData;%s/Resources/PlayerData;%sResources;%s;%sCache",
|
|
String resourcePaths = ToString("%s/Resources/CoreData;%s/Resources/PlayerData;%sResources;%s;%sCache",
|
|
|
- ATOMIC_ROOT_SOURCE_DIR, ATOMIC_ROOT_SOURCE_DIR, value.CString(), value.CString(), value.CString());
|
|
|
|
|
|
|
+ ATOMIC_ROOT_SOURCE_DIR, ATOMIC_ROOT_SOURCE_DIR, value.CString(), value.CString(), value.CString());
|
|
|
|
|
|
|
|
#else
|
|
#else
|
|
|
|
|
|
|
|
#ifdef __APPLE__
|
|
#ifdef __APPLE__
|
|
|
engineParameters_["ResourcePrefixPath"] = "../Resources";
|
|
engineParameters_["ResourcePrefixPath"] = "../Resources";
|
|
|
#else
|
|
#else
|
|
|
- engineParameters_["ResourcePrefixPath"] = filesystem->GetProgramDir() + "Resources";
|
|
|
|
|
|
|
+ engineParameters_["ResourcePrefixPath"] = fileSystem->GetProgramDir() + "Resources";
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
String resourcePaths = ToString("CoreData;PlayerData;%s/;%s/Resources;%s;%sCache",
|
|
String resourcePaths = ToString("CoreData;PlayerData;%s/;%s/Resources;%s;%sCache",
|
|
|
- value.CString(), value.CString(), value.CString(), value.CString());
|
|
|
|
|
|
|
+ value.CString(), value.CString(), value.CString(), value.CString());
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
LOGINFOF("Adding ResourcePaths: %s", resourcePaths.CString());
|
|
LOGINFOF("Adding ResourcePaths: %s", resourcePaths.CString());
|
|
@@ -155,7 +216,7 @@ void AEPlayerApplication::Setup()
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
- else if (argument == "--windowposx" && value.Length())
|
|
|
|
|
|
|
+ else if (argument == "--windowposx" && value.Length())
|
|
|
{
|
|
{
|
|
|
engineParameters_["WindowPositionX"] = atoi(value.CString());
|
|
engineParameters_["WindowPositionX"] = atoi(value.CString());
|
|
|
}
|
|
}
|
|
@@ -171,58 +232,16 @@ void AEPlayerApplication::Setup()
|
|
|
{
|
|
{
|
|
|
engineParameters_["WindowHeight"] = atoi(value.CString());
|
|
engineParameters_["WindowHeight"] = atoi(value.CString());
|
|
|
}
|
|
}
|
|
|
- else if (argument == "--resizable")
|
|
|
|
|
|
|
+ else if (argument == "--resizable")
|
|
|
{
|
|
{
|
|
|
engineParameters_["WindowResizable"] = true;
|
|
engineParameters_["WindowResizable"] = true;
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
else if (argument == "--maximize")
|
|
else if (argument == "--maximize")
|
|
|
{
|
|
{
|
|
|
engineParameters_["WindowMaximized"] = true;
|
|
engineParameters_["WindowMaximized"] = true;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- // Use the script file name as the base name for the log file
|
|
|
|
|
- engineParameters_["LogName"] = filesystem->GetAppPreferencesDir("AtomicPlayer", "Logs") + "AtomicPlayer.log";
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-void AEPlayerApplication::ReadEngineConfig()
|
|
|
|
|
-{
|
|
|
|
|
- // find the project path from the command line args
|
|
|
|
|
-
|
|
|
|
|
- String projectPath;
|
|
|
|
|
- const Vector<String>& arguments = GetArguments();
|
|
|
|
|
-
|
|
|
|
|
- for (unsigned i = 0; i < arguments.Size(); ++i)
|
|
|
|
|
- {
|
|
|
|
|
- if (arguments[i].Length() > 1)
|
|
|
|
|
- {
|
|
|
|
|
- String argument = arguments[i].ToLower();
|
|
|
|
|
- String value = i + 1 < arguments.Size() ? arguments[i + 1] : String::EMPTY;
|
|
|
|
|
-
|
|
|
|
|
- if (argument == "--project" && value.Length())
|
|
|
|
|
- {
|
|
|
|
|
- projectPath = AddTrailingSlash(value);
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (!projectPath.Length())
|
|
|
|
|
- return;
|
|
|
|
|
-
|
|
|
|
|
- FileSystem* filesystem = GetSubsystem<FileSystem>();
|
|
|
|
|
- String filename = projectPath + "Settings/Engine.json";
|
|
|
|
|
-
|
|
|
|
|
- if (!filesystem->FileExists(filename))
|
|
|
|
|
- return;
|
|
|
|
|
-
|
|
|
|
|
- if (EngineConfig::LoadFromFile(context_, filename))
|
|
|
|
|
- {
|
|
|
|
|
- EngineConfig::ApplyConfig(engineParameters_);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void AEPlayerApplication::Start()
|
|
void AEPlayerApplication::Start()
|