Browse Source

Fix Editor argument parsing to load startup scene correctly.

Yao Wei Tjong 姚伟忠 12 years ago
parent
commit
e52bc6e45d
3 changed files with 15 additions and 6 deletions
  1. 7 4
      Bin/Data/Scripts/Editor.as
  2. 6 0
      Docs/GettingStarted.dox
  3. 2 2
      Source/Engine/CMakeLists.txt

+ 7 - 4
Bin/Data/Scripts/Editor.as

@@ -67,13 +67,16 @@ void ParseArguments()
     Array<String> arguments = GetArguments();
     bool loaded = false;
 
-    // The first argument should be the editor script name. Scan for a scene to load
+    // Scan for a scene to load
     for (uint i = 1; i < arguments.length; ++i)
     {
-        if (arguments[i][0] != '-')
+        if (arguments[i].ToLower() == "-scene")
         {
-            loaded = LoadScene(arguments[i]);
-            break;
+            if (++i < arguments.length)
+            {
+                loaded = LoadScene(arguments[i]);
+                break;
+            }
         }
     }
 

+ 6 - 0
Docs/GettingStarted.dox

@@ -452,6 +452,12 @@ For more details related to the C++ coding style, see also \ref CodingConvention
 
 The Urho3D editor is a script application that can be run with the Urho3D player application. To start, execute any of these commands: (in the Bin directory) Editor.bat, Editor.sh or Urho3DPlayer Scripts/Editor.as
 
+All the \ref Running_Commandline "command line options" supported by Urho3D player application are available for Editor as well. Additionally, Editor also supports the following command line options:
+
+\verbatim
+-scene </path/to/scene.xml>     Load a scene after starting up
+\endverbatim
+
 Hint: to get some content to look at, run the Physics sample application (Bin/Data/Scripts/11_Physics.as), and press F5. This saves a scene file called Physics.xml into the Data/Scenes subdirectory, which can be loaded in the editor. The NinjaSnowWar scene also exists in the Data/Scenes subdirectory, and the NinjaSnowWar object "prefabs" are in the Data/Objects subdirectory.
 
 \section EditorInstructions_Controls Controls

+ 2 - 2
Source/Engine/CMakeLists.txt

@@ -181,7 +181,7 @@ endif ()
 # \todo This is a deprecated property in CMake version 2.8.12 - Remove below macros when CMake minimum version is 2.8.12
 set_target_properties (${TARGET_NAME} PROPERTIES LINK_INTERFACE_LIBRARIES "")
 if (URHO3D_LIB_TYPE STREQUAL SHARED)
-    if (CMAKE_VERSION VERSION_LESS 2.8.11)
+    if (NOT MSVC AND CMAKE_VERSION VERSION_LESS 2.8.11)
         get_target_property (LINK_LIBRARIES ${TARGET_NAME} LINK_LIBRARIES)
         target_link_libraries (${TARGET_NAME} LINK_PRIVATE ${LINK_LIBRARIES})
     endif ()
@@ -228,7 +228,7 @@ if (URHO3D_LIB_TYPE STREQUAL SHARED)
     add_compiler_export_flags ()
     # Use PIC on platforms that support it (shared library type has this property set to true by default, so we only have to deal with those static ones that the shared library links against)
     set_target_properties (${STATIC_LIBRARY_TARGETS} PROPERTIES POSITION_INDEPENDENT_CODE true)
-    if (CMAKE_VERSION VERSION_LESS 2.8.9)  # \todo Remove this when CMake minimum version is 2.8.9
+    if (NOT MSVC AND CMAKE_VERSION VERSION_LESS 2.8.9)  # \todo Remove this when CMake minimum version is 2.8.9
         set_property (TARGET ${STATIC_LIBRARY_TARGETS} APPEND PROPERTY COMPILE_FLAGS -fPIC)
     endif ()
 endif ()