|
@@ -49,6 +49,9 @@ void Urho3DPlayer::Setup()
|
|
|
{
|
|
{
|
|
|
FileSystem* filesystem = GetSubsystem<FileSystem>();
|
|
FileSystem* filesystem = GetSubsystem<FileSystem>();
|
|
|
|
|
|
|
|
|
|
+ // Web platform depends on the resource system to read any data files. Skip parsing the command line now
|
|
|
|
|
+ // and try later when the resource system is live
|
|
|
|
|
+#ifndef EMSCRIPTEN
|
|
|
// Read command line from a file if no arguments given. This is primarily intended for mobile platforms.
|
|
// Read command line from a file if no arguments given. This is primarily intended for mobile platforms.
|
|
|
// Note that the command file name uses a hardcoded path that does not utilize the resource system
|
|
// Note that the command file name uses a hardcoded path that does not utilize the resource system
|
|
|
// properly (including resource path prefix), as the resource system is not yet initialized at this point
|
|
// properly (including resource path prefix), as the resource system is not yet initialized at this point
|
|
@@ -63,17 +66,8 @@ void Urho3DPlayer::Setup()
|
|
|
engineParameters_ = Engine::ParseParameters(GetArguments());
|
|
engineParameters_ = Engine::ParseParameters(GetArguments());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // Check for script file name
|
|
|
|
|
- const Vector<String>& arguments = GetArguments();
|
|
|
|
|
- String scriptFileName;
|
|
|
|
|
- if (arguments.Size() && arguments[0][0] != '-')
|
|
|
|
|
- scriptFileName_ = GetInternalPath(arguments[0]);
|
|
|
|
|
-
|
|
|
|
|
- // On Emscripten CommandLine.txt can only be read through the resource system, but it is not yet possible,
|
|
|
|
|
- // so hardcode the script name for now. NinjaSnowWar cannot be used as the Network subsystem doesn't exist
|
|
|
|
|
-#ifdef EMSCRIPTEN
|
|
|
|
|
- scriptFileName_ = "Scripts/18_CharacterDemo.as";
|
|
|
|
|
-#endif
|
|
|
|
|
|
|
+ // Check for script file name from the arguments
|
|
|
|
|
+ GetScriptFileName();
|
|
|
|
|
|
|
|
// Show usage if not found
|
|
// Show usage if not found
|
|
|
if (scriptFileName_.Empty())
|
|
if (scriptFileName_.Empty())
|
|
@@ -126,6 +120,10 @@ void Urho3DPlayer::Setup()
|
|
|
// Use the script file name as the base name for the log file
|
|
// Use the script file name as the base name for the log file
|
|
|
engineParameters_["LogName"] = filesystem->GetAppPreferencesDir("urho3d", "logs") + GetFileNameAndExtension(scriptFileName_) + ".log";
|
|
engineParameters_["LogName"] = filesystem->GetAppPreferencesDir("urho3d", "logs") + GetFileNameAndExtension(scriptFileName_) + ".log";
|
|
|
}
|
|
}
|
|
|
|
|
+#else
|
|
|
|
|
+ // On Web platform setup a default windowed resolution similar to the executable samples
|
|
|
|
|
+ engineParameters_["FullScreen"] = false;
|
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
// Construct a search path to find the resource prefix with two entries:
|
|
// Construct a search path to find the resource prefix with two entries:
|
|
|
// The first entry is an empty path which will be substituted with program/bin directory -- this entry is for binary when it is still in build tree
|
|
// The first entry is an empty path which will be substituted with program/bin directory -- this entry is for binary when it is still in build tree
|
|
@@ -136,6 +134,27 @@ void Urho3DPlayer::Setup()
|
|
|
|
|
|
|
|
void Urho3DPlayer::Start()
|
|
void Urho3DPlayer::Start()
|
|
|
{
|
|
{
|
|
|
|
|
+ // Reattempt reading the command line now on Web platform
|
|
|
|
|
+#ifdef EMSCRIPTEN
|
|
|
|
|
+ if (GetArguments().Empty())
|
|
|
|
|
+ {
|
|
|
|
|
+ SharedPtr<File> commandFile = GetSubsystem<ResourceCache>()->GetFile("CommandLine.txt", false);
|
|
|
|
|
+ if (commandFile)
|
|
|
|
|
+ {
|
|
|
|
|
+ String commandLine = commandFile->ReadLine();
|
|
|
|
|
+ commandFile->Close();
|
|
|
|
|
+ ParseArguments(commandLine, false);
|
|
|
|
|
+ GetScriptFileName();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (scriptFileName_.Empty())
|
|
|
|
|
+ {
|
|
|
|
|
+ ErrorExit("Script file name not specified; cannot proceed");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
String extension = GetExtension(scriptFileName_);
|
|
String extension = GetExtension(scriptFileName_);
|
|
|
if (extension != ".lua" && extension != ".luc")
|
|
if (extension != ".lua" && extension != ".luc")
|
|
|
{
|
|
{
|
|
@@ -240,3 +259,10 @@ void Urho3DPlayer::HandleScriptReloadFailed(StringHash eventType, VariantMap& ev
|
|
|
ErrorExit();
|
|
ErrorExit();
|
|
|
#endif
|
|
#endif
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+void Urho3DPlayer::GetScriptFileName()
|
|
|
|
|
+{
|
|
|
|
|
+ const Vector<String>& arguments = GetArguments();
|
|
|
|
|
+ if (arguments.Size() && arguments[0][0] != '-')
|
|
|
|
|
+ scriptFileName_ = GetInternalPath(arguments[0]);
|
|
|
|
|
+}
|