diff --git a/advanced_topics/binary_serialization_api.rst b/advanced_topics/binary_serialization_api.rst index b815dd63f..1a7a11b05 100644 --- a/advanced_topics/binary_serialization_api.rst +++ b/advanced_topics/binary_serialization_api.rst @@ -307,21 +307,21 @@ This field is padded to 4 bytes. 15: image ~~~~~~~~~ -+---------------------+-------+-----------+------------------------------------------------------+ -| Offset | Len | Type | Description | -+=====================+=======+===========+======================================================+ -| 4 | 4 | Integer | Format (see FORMAT\_\* in \\"Image\\":class\_image | -+---------------------+-------+-----------+------------------------------------------------------+ -| 8 | 4 | Integer | Mip-Maps (0 means no mip-maps). | -+---------------------+-------+-----------+------------------------------------------------------+ -| 12 | 4 | Integer | Width (Pixels) | -+---------------------+-------+-----------+------------------------------------------------------+ -| 16 | 4 | Integer | Height (Pixels) | -+---------------------+-------+-----------+------------------------------------------------------+ -| 20 | 4 | Integer | Data Length | -+---------------------+-------+-----------+------------------------------------------------------+ -| 24..24+DataLength | 1 | Byte | Image Data | -+---------------------+-------+-----------+------------------------------------------------------+ ++---------------------+-------+-----------+--------------------------------------------------+ +| Offset | Len | Type | Description | ++=====================+=======+===========+==================================================+ +| 4 | 4 | Integer | Format (see FORMAT\_\* in "Image":class\_image | ++---------------------+-------+-----------+--------------------------------------------------+ +| 8 | 4 | Integer | Mip-Maps (0 means no mip-maps). | ++---------------------+-------+-----------+--------------------------------------------------+ +| 12 | 4 | Integer | Width (Pixels) | ++---------------------+-------+-----------+--------------------------------------------------+ +| 16 | 4 | Integer | Height (Pixels) | ++---------------------+-------+-----------+--------------------------------------------------+ +| 20 | 4 | Integer | Data Length | ++---------------------+-------+-----------+--------------------------------------------------+ +| 24..24+DataLength | 1 | Byte | Image Data | ++---------------------+-------+-----------+--------------------------------------------------+ This field is padded to 4 bytes. @@ -386,7 +386,7 @@ Every name string is is padded to 4 bytes. | 4 | 4 | Integer | val&0x7FFFFFFF = elements, val&0x80000000 = shared (bool) | +----------+-------+-----------+---------------------------------------------------------------------+ -| Then what follows is, for amount of \\"elements\\", pairs of key and +| Then what follows is, for amount of "elements", pairs of key and value, one after the other, using | this same format. @@ -399,8 +399,8 @@ Every name string is is padded to 4 bytes. | 4 | 4 | Integer | val&0x7FFFFFFF = elements, val&0x80000000 = shared (bool) | +----------+-------+-----------+---------------------------------------------------------------------+ -| Then what follows is, for amount of \\"elements\\", values one after - the other, using +| Then what follows is, for amount of "elements", values one after the + other, using | this same format. 22: byte array diff --git a/advanced_topics/command_line_tutorial.rst b/advanced_topics/command_line_tutorial.rst index 319eae0bb..24cf6ef3f 100644 --- a/advanced_topics/command_line_tutorial.rst +++ b/advanced_topics/command_line_tutorial.rst @@ -100,7 +100,7 @@ that is headless (server build, no video) is ideal for this. :: - user@host:~/newgame$ godot -export \"Linux X11\" /var/builds/project + user@host:~/newgame$ godot -export "Linux X11" /var/builds/project user@host:~/newgame$ godot -export Android /var/builds/project.apk The platform names recognized by the ``-export`` switch are the same as @@ -122,17 +122,14 @@ Running a script Here is a simple example of how it works: -|
-| #sayhello.gd
-| extends SceneTree
+.. code:: python
 
-| func \_init():
-| print(\\"Hello!\\")
-| quit()
+    #sayhello.gd
+    extends SceneTree
 
-.. raw:: html
-
-   
+ func _init(): + print("Hello!") + quit() And how to run it: diff --git a/advanced_topics/compiling_for_android.rst b/advanced_topics/compiling_for_android.rst index 423d470ba..e07e73b9b 100644 --- a/advanced_topics/compiling_for_android.rst +++ b/advanced_topics/compiling_for_android.rst @@ -30,8 +30,8 @@ Setting Up SCons Android NDK. To set those environment variables on Windows, press Windows+R, type -\\"control system\\", then click on **Advanced system settings** in the -left pane, then click on **Environment variables** on the window that +"control system", then click on **Advanced system settings** in the left +pane, then click on **Environment variables** on the window that appears. To set those environment variables on Linux, use @@ -78,8 +78,8 @@ platform, for each build type (release, debug, etc), it must be replaced. **Note**: The file inside libs/armeabi must be renamed to -**\\"libgodot\_android.so\\"**, or else unsatisfied link error will -happen at runtime. +**"libgodot\_android.so"**, or else unsatisfied link error will happen +at runtime. If you also want to include support for x86 Android, add the following compile flag: ``x86=yes`` , then copy/symlink the resulting folder to @@ -102,8 +102,8 @@ the current numbers, then set the following environment variables: :: - NDK_TOOLCHAIN (by default set to \"arm-eabi-4.4.0\") - NDK_TARGET (by default set to \"arm-linux-androideabi-4.8\") + NDK_TOOLCHAIN (by default set to "arm-eabi-4.4.0") + NDK_TARGET (by default set to "arm-linux-androideabi-4.8") Building the APK ---------------- diff --git a/advanced_topics/compiling_for_ios.rst b/advanced_topics/compiling_for_ios.rst index 9de156943..cdad7f4e5 100644 --- a/advanced_topics/compiling_for_ios.rst +++ b/advanced_topics/compiling_for_ios.rst @@ -40,5 +40,5 @@ Run | To run on a device or simulator, follow these instructions: [[Exporting for iOS]]. | Replace or add your executable to the Xcode project, and change the - \\"executable name\\" property on Info.plist accordingly if you use an + "executable name" property on Info.plist accordingly if you use an alternative build. diff --git a/advanced_topics/compiling_for_linux.rst b/advanced_topics/compiling_for_linux.rst index 89512ffcf..546f6996d 100644 --- a/advanced_topics/compiling_for_linux.rst +++ b/advanced_topics/compiling_for_linux.rst @@ -41,9 +41,9 @@ Start a terminal, go to the root dir of the engine source code and type: user@host:~/godot$ scons platform=x11 If all goes well, the resulting binary executable will be placed in the -\\"bin\\" subdirectory. This executable file contains the whole engine -and runs without any dependencies. Executing it will bring up the -project manager. +"bin" subdirectory. This executable file contains the whole engine and +runs without any dependencies. Executing it will bring up the project +manager. Building export templates ------------------------- diff --git a/advanced_topics/compiling_for_osx.rst b/advanced_topics/compiling_for_osx.rst index 1a5f307aa..affde9a70 100644 --- a/advanced_topics/compiling_for_osx.rst +++ b/advanced_topics/compiling_for_osx.rst @@ -21,9 +21,9 @@ Start a terminal, go to the root dir of the engine source code and type: user@host:~/godot$ scons platform=osx If all goes well, the resulting binary executable will be placed in the -\\"bin\\" subdirectory. This executable file contains the whole engine -and runs without any dependencies. Executing it will bring up the -project manager. There is a .app template to put the binary into in +"bin" subdirectory. This executable file contains the whole engine and +runs without any dependencies. Executing it will bring up the project +manager. There is a .app template to put the binary into in tools/Godot.app. Cross-compiling @@ -31,9 +31,8 @@ Cross-compiling It is possible to compile for OS X in a Linux environment (and maybe also in Windows with Cygwin). For that you will need -\\\ `OSXCross\\ `__ for being -able to use OS X as target. First, follow the instructions to install -it: +`OSXCross `__ for being able +to use OS X as target. First, follow the instructions to install it: # Clone the OSXCross repository (https://github.com/tpoechtrager/osxcross) somewhere in your machine (or diff --git a/advanced_topics/compiling_for_universal_windows_apps.rst b/advanced_topics/compiling_for_universal_windows_apps.rst index 687ed0b50..cd1f4a2b5 100644 --- a/advanced_topics/compiling_for_universal_windows_apps.rst +++ b/advanced_topics/compiling_for_universal_windows_apps.rst @@ -1,32 +1,31 @@ Compiling for Universal Windows Apps ==================================== -This page documents the current state of the \\"winrt\\" platform, used -to support \\"Windows Store Apps\\" for Windows 8.1, and Windows Phone -8.1 apps using Microsoft's new \\"Universal\\" APIs. +This page documents the current state of the "winrt" platform, used to +support "Windows Store Apps" for Windows 8.1, and Windows Phone 8.1 apps +using Microsoft's new "Universal" APIs. Requirements ------------ - Windows 8 - SCons (see [[Compiling for Windows]] for more details) -- Visual Studio 2013 for Windows (but *not* \\"for Windows Desktop\\"). - Tested on \\"Microsoft Visual Studio Express 2013 for Windows Version - 12.0.31101.00 Update 4\\". +- Visual Studio 2013 for Windows (but *not* "for Windows Desktop"). + Tested on "Microsoft Visual Studio Express 2013 for Windows Version + 12.0.31101.00 Update 4". Compiling --------- The platform can compile binaries for both Windows 8.1 and Windows Phone -8.1. The architecture is decided by the environment variable -\\"PLATFORM\\". +8.1. The architecture is decided by the environment variable "PLATFORM". Windows 8.1 ~~~~~~~~~~~ -\* Open a \\"VS 2013 x64 Cross Tools Command Prompt\\" +\* Open a "VS 2013 x64 Cross Tools Command Prompt" -\* The value of environment variable \\"PLATFORM\\" should be \\"x64\\" +\* The value of environment variable "PLATFORM" should be "x64" \* Run scons with platform=winrt from the root of the source tree @@ -35,15 +34,15 @@ Windows 8.1 C:\\godot_source> scons platform=winrt - You should get an executable file inside bin/ named according to your - build options, for the architecture \\"x64\\", for example - \\"godot.winrt.tools.x64.exe\\". + build options, for the architecture "x64", for example + "godot.winrt.tools.x64.exe". Windows Phone 8.1 ~~~~~~~~~~~~~~~~~ -\* Open a \\"Visual Studio 2012 ARM Phone Tools Command Prompt\\" +\* Open a "Visual Studio 2012 ARM Phone Tools Command Prompt" -\* The value of environment variable \\"PLATFORM\\" should be \\"arm\\" +\* The value of environment variable "PLATFORM" should be "arm" \* Run scons with platform=winrt from the root of the source tree @@ -52,26 +51,26 @@ Windows Phone 8.1 C:\\godot_source> scons platform=winrt - You should get an executable file inside bin/ named according to your - build options, for the architecture \\"arm\\", for example - \\"godot.winrt.tools.arm.exe\\". + build options, for the architecture "arm", for example + "godot.winrt.tools.arm.exe". Running ------- -On Visual studio, create a new project using any of the \\"Unversal -App\\" templates found under Visual C++ -> Store Apps -> Universal Apps. -\\"Blank App\\" should be fine. +On Visual studio, create a new project using any of the "Unversal App" +templates found under Visual C++ -> Store Apps -> Universal Apps. "Blank +App" should be fine. -On the \\"Solution Explorer\\" box, you should have 3 sections, -\\"App.Windows (Windows 8.1)\\", \\"App.WindowsPhone (Windows Phone -8.1)\\" and \\"App.Shared\\". You need to add files to each section: +On the "Solution Explorer" box, you should have 3 sections, "App.Windows +(Windows 8.1)", "App.WindowsPhone (Windows Phone 8.1)" and "App.Shared". +You need to add files to each section: App.Shared ~~~~~~~~~~ -- Add a folder named \\"game\\" containing your game content (can be - individual files or your data.pck). Remember to set the \\"Content\\" - property of each file to \\"True\\", otherwise your files won't get +- Add a folder named "game" containing your game content (can be + individual files or your data.pck). Remember to set the "Content" + property of each file to "True", otherwise your files won't get included in the package. App.Windows @@ -79,13 +78,13 @@ App.Windows \* Add your windows executable, and all the .dll files found on platform/winrt/x64/bin on the godot source. Remember to also set the -\\"Content\\" property. +"Content" property. -\* Find the file \\"Package.appxmanifest\\". Right click on it and -select \\"Open with...\\" then \\"XML (Text) Editor\\" from the list. +\* Find the file "Package.appxmanifest". Right click on it and select +"Open with..." then "XML (Text) Editor" from the list. -\* Find the \\"Application\\" section, and add (or modify) the -\\"Executable\\" property with the name of your .exe. Example: +\* Find the "Application" section, and add (or modify) the "Executable" +property with the name of your .exe. Example: :: @@ -94,23 +93,21 @@ App.WindowsPhone - Repeat all the steps from App.Windows, using your arm executable and the dlls found in platform/winrt/arm/bin. Remember to set the - \\"Content\\" property for all the files. + "Content" property for all the files. -Use the green \\"Play\\" button on the top to run. The drop down menu -next to it should let you choose the project (App.Windows or -App.WindowsPhone) and the device (\\"Local Machine\\", \\"Device\\" for -an attached phone, etc). +Use the green "Play" button on the top to run. The drop down menu next +to it should let you choose the project (App.Windows or +App.WindowsPhone) and the device ("Local Machine", "Device" for an +attached phone, etc). Angle ----- ANGLE precompiled binaries are provided on platform/winrt/x64 and -platform/winrt/arm. They are built from MSOpenTech's \\"future-dev\\" -branch, found here: -\\\ `https://github.com/MSOpenTech/angle\\ `__. -The visual studio 'solutions' used are found on -\\"projects/winrt/windows/angle.sln\\" and -\\"projects/winrt/windowsphone/angle.sln\\". +platform/winrt/arm. They are built from MSOpenTech's "future-dev" +branch, found here: https://github.com/MSOpenTech/angle. The visual +studio 'solutions' used are found on "projects/winrt/windows/angle.sln" +and "projects/winrt/windowsphone/angle.sln". What's missing -------------- @@ -131,18 +128,17 @@ Packages This is what we know: - App packages are documented here: - \\\ `http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh464929.aspx\\ `__ -- There are 2 command line tools that might be useful, \\\ `App - Packager\\ `__ + http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh464929.aspx +- There are 2 command line tools that might be useful, `App + Packager `__ and - \\\ `SignTool\\ `__. -- There are a bunch of tools on \\"powershell\\" that deal with - packages that might be relevant: - \\\ `http://technet.microsoft.com/library/dn448373.aspx\\ `__ -- When running a Windows 8.1 app on \\"Local Machine\\" from Visual - studio, the app seems to run from an uncompressed directory on the - filesystem in an arbitrary location (ie. outside of the proper - directory where Apps are installed), but there is some special - registry entry made for it, so we know it's possible to skip the - packaging step to run locally (in the case of very big games this can - be useful). + `SignTool `__. +- There are a bunch of tools on "powershell" that deal with packages + that might be relevant: + http://technet.microsoft.com/library/dn448373.aspx +- When running a Windows 8.1 app on "Local Machine" from Visual studio, + the app seems to run from an uncompressed directory on the filesystem + in an arbitrary location (ie. outside of the proper directory where + Apps are installed), but there is some special registry entry made + for it, so we know it's possible to skip the packaging step to run + locally (in the case of very big games this can be useful). diff --git a/advanced_topics/compiling_for_windows.rst b/advanced_topics/compiling_for_windows.rst index e24fa89a7..f07a8256f 100644 --- a/advanced_topics/compiling_for_windows.rst +++ b/advanced_topics/compiling_for_windows.rst @@ -6,27 +6,25 @@ Requirements For compiling under Windows, the following is required: -- \\\ `Visual C++\\ `__, Visual - C++ Express compiler or Visual Studio Community (recommended) at - least the 2010 version (10.0) up to 2015 (14.0). **Make sure you get - a version that can compile for C++, Desktop**. -- \\\ `Python 2.7+\\ `__ - (3.0 is untested as of now). Using the 32-bits installer is - recommended. -- \\\ `Pywin32 Python - Extension\\ `__ for parallel +- `Visual C++ `__, Visual C++ + Express compiler or Visual Studio Community (recommended) at least + the 2010 version (10.0) up to 2015 (14.0). **Make sure you get a + version that can compile for C++, Desktop**. +- `Python 2.7+ `__ (3.0 is + untested as of now). Using the 32-bits installer is recommended. +- `Pywin32 Python + Extension `__ for parallel builds (which increase the build speed by a great factor). -- \\\ `SCons\\ `__ build system. +- `SCons `__ build system. Setting up SCons ---------------- Python adds the interpreter (python.exe) to the path. It usually installs in C:\\\\Python (or C:\\\\Python[Version]). SCons installs -inside the python install and provides a .bat file called -\\"scons.bat\\". The location of this file can be added to the path or -it can simply be copied to C:\\\\Python together with the interpreter -executable. +inside the python install and provides a .bat file called "scons.bat". +The location of this file can be added to the path or it can simply be +copied to C:\\\\Python together with the interpreter executable. Compiling --------- @@ -64,7 +62,7 @@ build it seems to be by running: :: - \"C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\vcvarsall.bat\" && c:\\python27\\scons p=windows + "C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\vcvarsall.bat" && c:\\python27\\scons p=windows (or however your VS and Scons are installed) @@ -91,8 +89,8 @@ following env variables: :: - export MINGW32_PREFIX=\"/path/to/i586-mingw32msvc-\" - export MINGW64_PREFIX=\"/path/to/i686-w64-mingw32-\" + export MINGW32_PREFIX="/path/to/i586-mingw32msvc-" + export MINGW64_PREFIX="/path/to/i686-w64-mingw32-" To make sure you are doing things correctly, executing the following in the shell should result in a working compiler: diff --git a/advanced_topics/core_types.rst b/advanced_topics/core_types.rst index 2091e6d65..f0964d420 100644 --- a/advanced_topics/core_types.rst +++ b/advanced_topics/core_types.rst @@ -31,7 +31,7 @@ directly to wchar\_t. References: ~~~~~~~~~~~ -- \\\ `core/typedefs.h\\ `__ +- `core/typedefs.h `__ Memory model ------------ @@ -128,8 +128,8 @@ locked until they go out of scope. References: ~~~~~~~~~~~ -- \\\ `core/os/memory.h\\ `__ -- \\\ `core/dvector.h\\ `__ +- `core/os/memory.h `__ +- `core/dvector.h `__ Containers ---------- @@ -162,10 +162,10 @@ The Vector<> class also has a few nice features: References: ~~~~~~~~~~~ -- \\\ `core/vector.h\\ `__ -- \\\ `core/list.h\\ `__ -- \\\ `core/set.h\\ `__ -- \\\ `core/map.h\\ `__ +- `core/vector.h `__ +- `core/list.h `__ +- `core/set.h `__ +- `core/map.h `__ String ------ @@ -178,7 +178,7 @@ conversion and visualization. References: ~~~~~~~~~~~ -- \\\ `core/ustring.h\\ `__ +- `core/ustring.h `__ StringName ---------- @@ -193,7 +193,7 @@ StringName References: ~~~~~~~~~~~ -- \\\ `core/string\_db.h\\ `__ +- `core/string\_db.h `__ Math types ---------- @@ -204,7 +204,7 @@ directory, they are basically just that. References: ~~~~~~~~~~~ -- \\\ `core/math\\ `__ +- `core/math `__ NodePath -------- @@ -215,7 +215,7 @@ referencing them fast. References: ~~~~~~~~~~~ -- \\\ `core/path\_db.h\\ `__ +- `core/path\_db.h `__ RID --- @@ -228,4 +228,4 @@ referenced data. References: ~~~~~~~~~~~ -- \\\ `core/rid.h\\ `__ +- `core/rid.h `__ diff --git a/advanced_topics/creating_android_modules.rst b/advanced_topics/creating_android_modules.rst index e4b7549d4..a6df42026 100644 --- a/advanced_topics/creating_android_modules.rst +++ b/advanced_topics/creating_android_modules.rst @@ -64,29 +64,23 @@ In the config.py for the module, some extra functions are provided for convenience. First, it's often wise to detect if android is being built and only enable building in this case: -|
-| def can\_build(plat):
-| return plat==\\"android\\"
+.. code:: python
 
-.. raw:: html
-
-   
+ def can_build(plat): + return plat=="android" If more than one platform can be built (typical if implementing the module also for iOS), check manually for Android in the configure functions: -|
-| def can\_build(plat):
-| return plat\\"android\\" or plat\\"iphone\\"
+.. code:: python
 
-| def configure(env):
-| if env['platform'] == 'android':
-| #androd specific code
+    def can_build(plat):
+        return plat=="android" or plat=="iphone"
 
-.. raw:: html
-
-   
+ def configure(env): + if env['platform'] == 'android': + #androd specific code Java singleton -------------- @@ -95,56 +89,51 @@ An android module will usually have a singleton class that will load it, this class inherits from ``Godot.SingletonBase``. A singleton object template follows: -|
-| //namespace is wrong, will eventually change
-| package com.android.godot;
+.. code:: java
 
-public class MySingleton extends Godot.SingletonBase {
+    //namespace is wrong, will eventually change
+    package com.android.godot;
 
-| public int myFunction(String p\_str) {
-| // a function to bind
-| }
+    public class MySingleton extends Godot.SingletonBase {
 
-static public Godot.SingletonBase initialize(Activity p\_activity) {
 
-| return new MySingleton(p\_activity);
-| }
+        public int myFunction(String p_str) {
+              // a function to bind
+        }
 
-| public MySingleton(Activity p\_activity) {
-| //register class name and functions to bind
-| registerClass(\\"MySingleton\\", new String[]{\\"myFunction\\"});
+        static public Godot.SingletonBase initialize(Activity p_activity) {
 
-| // you might want to try initializing your singleton here, but android
-| // threads are weird and this runs in another thread, so you usually
-  have to do
-| activity.runOnUiThread(new Runnable() {
-| public void run() {
-| //useful way to get config info from engine.cfg
-| String key = GodotLib.getGlobal(\\"plugin/api\_key\\");
-| SDK.initializeHere();
-| }
-| });
+                    return new MySingleton(p_activity);
+        } 
 
-}
+        public MySingleton(Activity p_activity) {
+              //register class name and functions to bind
+              registerClass("MySingleton", new String[]{"myFunction"});
 
-// forwarded callbacks you can reimplement, as SDKs often need them
+              // you might want to try initializing your singleton here, but android
+              // threads are weird and this runs in another thread, so you usually have to do
+              activity.runOnUiThread(new Runnable() {
+                   public void run() {
+                        //useful way to get config info from engine.cfg
+                        String key = GodotLib.getGlobal("plugin/api_key");
+                        SDK.initializeHere();
+                   }
+              });
 
-protected void onMainActivityResult(int requestCode, int resultCode,
-Intent data) {}
+        }
 
-| protected void onMainPause() {}
-| protected void onMainResume() {}
-| protected void onMainDestroy() {}
+         // forwarded callbacks you can reimplement, as SDKs often need them
 
-| protected void onGLDrawFrame(GL10 gl) {}
-| protected void onGLSurfaceChanged(GL10 gl, int width, int height) {}
-  // singletons will always miss first onGLSurfaceChanged call
+         protected void onMainActivityResult(int requestCode, int resultCode, Intent data) {}
 
-}
+         protected void onMainPause() {}
+         protected void onMainResume() {}
+         protected void onMainDestroy() {}
 
-.. raw:: html
+         protected void onGLDrawFrame(GL10 gl) {}
+         protected void onGLSurfaceChanged(GL10 gl, int width, int height) {} // singletons will always miss first onGLSurfaceChanged call
 
-   
+ } Calling back to Godot from Java is a little more difficult. The instance ID of the script must be known first, this is obtained by calling @@ -154,30 +143,23 @@ passed to Java. From Java, use the calldeferred function to communicate back with Godot. Java will most likely run in a separate thread, so calls are deferred: -
GodotLib.calldeferred(, \\"\\", new
-Object[]{param1,param2,etc});
+.. code:: java
 
-.. raw:: html
-
-   
+ GodotLib.calldeferred(, "", new Object[]{param1,param2,etc}); Add this singleton to the build of the project by adding the following to config.py: -|
-| def can\_build(plat):
-| return plat\\"android\\" or plat\\"iphone\\"
+.. code:: python
 
-| def configure(env):
-| if env['platform'] == 'android':
-| # will copy this to the java folder
-| env.android\_module\_file(\\"MySingleton.java\\")
-| #env.android\_module\_file(\\"MySingleton2.java\\") call again for
-  more files
+    def can_build(plat):
+        return plat=="android" or plat=="iphone"
 
-.. raw:: html
-
-   
+ def configure(env): + if env['platform'] == 'android': + # will copy this to the java folder + env.android_module_file("MySingleton.java") + #env.android_module_file("MySingleton2.java") call again for more files AndroidManifest --------------- @@ -189,19 +171,16 @@ maybe other functionalities are needed. Create the custom chunk of android manifest and put it inside the module, add it like this: -|
-| def can\_build(plat):
-| return plat\\"android\\" or plat\\"iphone\\"
+.. code:: python
 
-| def configure(env):
-| if env['platform'] == 'android':
-| # will copy this to the java folder
-| env.android\_module\_file(\\"MySingleton.java\\")
-| env.android\_module\_manifest(\\"AndroidManifestChunk.xml\\")
+    def can_build(plat):
+        return plat=="android" or plat=="iphone"
 
-.. raw:: html
-
-   
+ def configure(env): + if env['platform'] == 'android': + # will copy this to the java folder + env.android_module_file("MySingleton.java") + env.android_module_manifest("AndroidManifestChunk.xml") SDK library ----------- @@ -210,20 +189,17 @@ So, finally it's time to add the SDK library. The library can come in two flavors, a JAR file or an Android project for ant. JAR is the easiest to integrate, just put it in the module directory and add it: -|
-| def can\_build(plat):
-| return plat\\"android\\" or plat\\"iphone\\"
+.. code:: python
 
-| def configure(env):
-| if env['platform'] == 'android':
-| # will copy this to the java folder
-| env.android\_module\_file(\\"MySingleton.java\\")
-| env.android\_module\_manifest(\\"AndroidManifestChunk.xml\\")
-| env.android\_module\_library(\\"MyLibrary-3.1.jar\\")
+    def can_build(plat):
+        return plat=="android" or plat=="iphone"
 
-.. raw:: html
-
-   
+ def configure(env): + if env['platform'] == 'android': + # will copy this to the java folder + env.android_module_file("MySingleton.java") + env.android_module_manifest("AndroidManifestChunk.xml") + env.android_module_library("MyLibrary-3.1.jar") SDK project ----------- @@ -238,24 +214,21 @@ the project folder inside the module directory and configure it: As of this writing, godot uses minsdk 10 and target sdk 15. If this ever changes, should be reflected in the manifest template: -\\\ `https://github.com/okamstudio/godot/blob/master/platform/android/AndroidManifest.xml.template\\ `__ +https://github.com/okamstudio/godot/blob/master/platform/android/AndroidManifest.xml.template Then, add the module folder to the project: -|
-| def can\_build(plat):
-| return plat\\"android\\" or plat\\"iphone\\"
+.. code:: python
 
-| def configure(env):
-| if env['platform'] == 'android':
-| # will copy this to the java folder
-| env.android\_module\_file(\\"MySingleton.java\\")
-| env.android\_module\_manifest(\\"AndroidManifestChunk.xml\\")
-| env.android\_module\_source(\\"sdk-1.2\\",\\"\\")
+    def can_build(plat):
+        return plat=="android" or plat=="iphone"
 
-.. raw:: html
-
-   
+ def configure(env): + if env['platform'] == 'android': + # will copy this to the java folder + env.android_module_file("MySingleton.java") + env.android_module_manifest("AndroidManifestChunk.xml") + env.android_module_source("sdk-1.2","") Building -------- @@ -299,7 +272,7 @@ the following line to engine.cfg: [android] - modules=\"com/android/godot/MySingleton\" + modules="com/android/godot/MySingleton" More than one singleton module can be enable by separating with comma: @@ -307,22 +280,19 @@ More than one singleton module can be enable by separating with comma: [android] - modules=\"com/android/godot/MySingleton,com/android/godot/MyOtherSingleton\" + modules="com/android/godot/MySingleton,com/android/godot/MyOtherSingleton" Then just request the singleton Java object from Globals like this: -|
-| #in any file
+.. code:: python
 
-var singleton=null
+    #in any file
 
-| func \_init():
-| singleton = Globals.get\_singleton(\\"MySingleton\\")
-| print( singleton.myFunction(\\"Hello\\") )
+    var singleton=null
 
-.. raw:: html
-
-   
+ func _init(): + singleton = Globals.get_singleton("MySingleton") + print( singleton.myFunction("Hello") ) Troubleshooting --------------- @@ -350,5 +320,5 @@ Future class = JavaClassWrapper.wrap() This is most likely not functional yet, if you want to test it and help -us make it work, contact us through the \\\ `developer mailing -list\\ `__. +us make it work, contact us through the `developer mailing +list `__. diff --git a/advanced_topics/cross-compiling_for_ios_on_linux.rst b/advanced_topics/cross-compiling_for_ios_on_linux.rst index 3be1d2cbd..fb58a835a 100644 --- a/advanced_topics/cross-compiling_for_ios_on_linux.rst +++ b/advanced_topics/cross-compiling_for_ios_on_linux.rst @@ -11,10 +11,10 @@ Disclaimer While it is possible to compile for iOS on a Linux environment, Apple is very restrictive about the tools to be used (specially hardware-wise), allowing pretty much only their products to be used for development. So -this is **not official**. However, a \\\ `statement from Apple in -2010\\ `__ -says they relaxed some of the \\\ `App Store review -guidelines\\ `__ +this is **not official**. However, a `statement from Apple in +2010 `__ +says they relaxed some of the `App Store review +guidelines `__ to allow any tool to be used, as long as the resulting binary do not download any code, which means it should be OK to use the procedure described here and cross-compiling the binary. @@ -22,21 +22,21 @@ described here and cross-compiling the binary. Requirements ------------ -- \\\ `**XCode with the iOS - SDK**\\ `__ (a dmg image) -- \\\ `**Clang >=3.5**\\ `__ for your - development machine installed and in the ``PATH``. It needs to be - version >= 3.5 to target ``arm64`` architecture. -- \\\ `**Fuse**\\ `__ for mounting and - umounting the dmg image. -- \\\ `**darling-dmg**\\ `__, - which needs to be built from source. The procedure for that is - explained below. +- `**XCode with the iOS + SDK** `__ (a dmg image) +- `**Clang >=3.5** `__ for your development + machine installed and in the ``PATH``. It needs to be version >= 3.5 + to target ``arm64`` architecture. +- `**Fuse** `__ for mounting and umounting + the dmg image. +- `**darling-dmg** `__, which + needs to be built from source. The procedure for that is explained + below. - For building darling-dmg, you'll need the development packages of the following libraries: **fuse, icu, openssl, zlib, bzip2**. -- \\\ `**cctools-port**\\ `__ +- `**cctools-port** `__ for the needed build tools. The procedure for building is quite peculiar and is described below. @@ -138,8 +138,8 @@ way, with some additional arguments to provide the correct paths: :: - $ scons -j 4 platform=iphone bits=32 target=release_debug IPHONESDK=\"/path/to/iPhoneSDK\" IPHONEPATH=\"/path/to/iostoolchain\" ios_triple=\"arm-apple-darwin11-\" - $ scons -j 4 platform=iphone bits=64 target=release_debug IPHONESDK=\"/path/to/iPhoneSDK\" IPHONEPATH=\"/path/to/iostoolchain\" ios_triple=\"arm-apple-darwin11-\" + $ scons -j 4 platform=iphone bits=32 target=release_debug IPHONESDK="/path/to/iPhoneSDK" IPHONEPATH="/path/to/iostoolchain" ios_triple="arm-apple-darwin11-" + $ scons -j 4 platform=iphone bits=64 target=release_debug IPHONESDK="/path/to/iPhoneSDK" IPHONEPATH="/path/to/iostoolchain" ios_triple="arm-apple-darwin11-" Producing fat binaries ~~~~~~~~~~~~~~~~~~~~~~ diff --git a/advanced_topics/custom_modules_in_c++.rst b/advanced_topics/custom_modules_in_c++.rst index b0190a54a..9b47166f0 100644 --- a/advanced_topics/custom_modules_in_c++.rst +++ b/advanced_topics/custom_modules_in_c++.rst @@ -38,9 +38,9 @@ To create a new module, the first step is creating a directory inside modules. If you want to maintain the module separately, you can checkout a different VCS into modules and use it. -The example module will be called \\"sumator\\", and is placed inside -the Godot source tree (C:\\\\godot refers to wherever the Godot sources -are located): +The example module will be called "sumator", and is placed inside the +Godot source tree (C:\\\\godot refers to wherever the Godot sources are +located): :: @@ -51,71 +51,65 @@ are located): Inside we will create a simple sumator class: -|
-| /\* sumator.h \*/
-| #ifndef SUMATOR\_H
-| #define SUMATOR\_H
+.. code:: cpp
 
-#include "reference.h"
+    /* sumator.h */
+    #ifndef SUMATOR_H
+    #define SUMATOR_H
 
-| class Sumator : public Reference {
-| OBJ\_TYPE(Sumator,Reference);
+    #include "reference.h"
 
-int count;
+    class Sumator : public Reference {
+        OBJ_TYPE(Sumator,Reference);
 
-| protected:
-| static void \_bind\_methods();
-| public:
+        int count;
 
-| void add(int value);
-| void reset();
-| int get\_total() const;
+    protected:
+        static void _bind_methods();
+    public:
 
-| Sumator();
-| };
+        void add(int value);
+        void reset();
+        int get_total() const;
 
-#endif
+        Sumator();
+    };
 
-.. raw:: html
-
-   
+ #endif And then the cpp file. -|
-| /\* sumator.cpp \*/
+.. code:: cpp
 
-#include "sumator.h"
+    /* sumator.cpp */
 
-void Sumator::add(int value) {
+    #include "sumator.h"
 
-| count+=value;
-| }
+    void Sumator::add(int value) {
 
-void Sumator::reset() {
+        count+=value;
+    }
 
-| count=0;
-| }
+    void Sumator::reset() {
 
-int Sumator::get\_total() const {
+        count=0;
+    }
 
-| return count;
-| }
+    int Sumator::get_total() const {
 
-void Sumator::\_bind\_methods() {
+        return count;
+    }
 
-| ObjectTypeDB::bind\_method("add",&Sumator::add);
-| ObjectTypeDB::bind\_method("reset",&Sumator::reset);
-| ObjectTypeDB::bind\_method("get\_total",&Sumator::get\_total);
-| }
+    void Sumator::_bind_methods() {
 
-| Sumator::Sumator() {
-| count=0;
-| }
+        ObjectTypeDB::bind_method("add",&Sumator::add);
+        ObjectTypeDB::bind_method("reset",&Sumator::reset);
+        ObjectTypeDB::bind_method("get_total",&Sumator::get_total);
+    }
 
-.. raw:: html
-
-   
+ Sumator::Sumator() { + count=0; + } Then, the new class needs to be registered somehow, so two more files need to be created: @@ -127,69 +121,53 @@ need to be created: With the following contents -|
-| /\* register\_types.h \*/
+.. code:: cpp
 
-| void register\_sumator\_types();
-| void unregister\_sumator\_types();
-| /\* yes, the word in the middle must be the same as the module folder
-  name \*/
+    /* register_types.h */
 
-.. raw:: html
+    void register_sumator_types();
+    void unregister_sumator_types();
+    /* yes, the word in the middle must be the same as the module folder name */
 
-   
+.. code:: cpp -|
-| /\* register\_types.cpp \*/
+    /* register_types.cpp */
 
-| #include "register\_types.h"
-| #include "object\_type\_db.h"
-| #include "sumator.h"
+    #include "register_types.h"
+    #include "object_type_db.h"
+    #include "sumator.h"
 
-void register\_sumator\_types() {
+    void register_sumator_types() {
 
-| ObjectTypeDB::register\_type<Sumator>();
-| }
+            ObjectTypeDB::register_type();
+    }
 
-| void unregister\_sumator\_types() {
-| //nothing to do here
-| }
-
-.. raw:: html
-
-   
+ void unregister_sumator_types() { + //nothing to do here + } Next, we need to create a SCsub so the build system compiles this module: -
+.. code:: python
 
-#. SCsub
-   Import('env')
+    # SCsub
+    Import('env')
 
-env.add\_source\_files(env.modules\_sources,"\*.cpp") # just add
-all cpp files to the build
-
-.. raw:: html
-
-   
+ env.add_source_files(env.modules_sources,"*.cpp") # just add all cpp files to the build And finally, the configuration file for the module, this is a simple python script that must be named 'config.py' -
+.. code:: python
 
-#. config.py
+    # config.py
 
-| def can\_build(platform):
-| return True
+    def can_build(platform):
+        return True  
 
-| def configure(env):
-| pass
-
-.. raw:: html
-
-   
+ def configure(env): + pass The module is asked if it's ok to build for the specific platform (in this case, True means it will build for every platform). @@ -221,17 +199,14 @@ Using the module Using your newly created module is very easy, from any script you can do: -|
-| var s = Sumator.new()
-| s.add(10)
-| s.add(20)
-| s.add(30)
-| print( s.get\_total() )
-| s.reset()
+.. code:: python
 
-.. raw:: html
-
-   
+ var s = Sumator.new() + s.add(10) + s.add(20) + s.add(30) + print( s.get_total() ) + s.reset() And the output will be ``60``. @@ -250,7 +225,7 @@ some surprises. - If you inherit from [[API:Node]] (or any derived node type, such as Sprite), your new class will appear in the editor, in the inheritance - tree in the \\"Add Node\\" dialog. + tree in the "Add Node" dialog. - If you inherit from [[API:Resource]], it will appear int the resource list, and all the exposed properties can be serialized when saved/loaded. diff --git a/advanced_topics/introduction_to_the_buildsystem.rst b/advanced_topics/introduction_to_the_buildsystem.rst index 1252dd3a5..4813c52ef 100644 --- a/advanced_topics/introduction_to_the_buildsystem.rst +++ b/advanced_topics/introduction_to_the_buildsystem.rst @@ -4,12 +4,12 @@ Introduction to the buildsystem Scons ----- -Godot uses \\\ `Scons\\ `__ to build. We love it, -we are not changing it for anything else. We are not even sure other -build systems are up to the task of building Godot. We constantly get -requests to move the build system to CMake, or Visual Studio, but this -is not going to happen. There are many reasons why we have chosen SCons -over other alternatives and are listed as follows: +Godot uses `Scons `__ to build. We love it, we are +not changing it for anything else. We are not even sure other build +systems are up to the task of building Godot. We constantly get requests +to move the build system to CMake, or Visual Studio, but this is not +going to happen. There are many reasons why we have chosen SCons over +other alternatives and are listed as follows: - Godot can be compiled for a dozen different platforms. All PC platforms, all mobile platforms, many consoles, and many web-based @@ -149,9 +149,9 @@ Target controls optimization and debug flags. Each mode means: scons platform= target=debug/release_debug/release -This flag appends \\".debug\\" suffix (for debug), or \\".tools\\" (for -debug with tools enables). When optimization is enabled (release) it -appends the \\".opt\\" suffix. +This flag appends ".debug" suffix (for debug), or ".tools" (for debug +with tools enables). When optimization is enabled (release) it appends +the ".opt" suffix. Bits ---- @@ -171,8 +171,8 @@ else. scons platform= bits=default/32/64 -This flag appends \\".32\\" or \\".64\\" suffixes to resulting binaries -when relevant. +This flag appends ".32" or ".64" suffixes to resulting binaries when +relevant. Export templates ---------------- diff --git a/advanced_topics/object_class.rst b/advanced_topics/object_class.rst index ac84e3410..18d9ed0ad 100644 --- a/advanced_topics/object_class.rst +++ b/advanced_topics/object_class.rst @@ -6,33 +6,26 @@ inherit directly or indirectly from it. Objects provide reflection and editable properties, and declaring them is a matter of using a single macro like this. -|
-| class CustomObject : public Object {
+.. code:: cpp
 
-| OBJ\_TYPE(CustomObject,Object); // this required to inherit
-| };
+    class CustomObject : public Object {
 
-.. raw:: html
-
-   
+ OBJ_TYPE(CustomObject,Object); // this required to inherit + }; This makes objects gain a lot of functionality, like for example -|
-| obj = memnew(CustomObject);
-| print\_line("Object Type: ",obj->get\_type()); //print object type
+.. code:: cpp
 
-obj2 = obj->cast\_to<OtherType>(); // converting between types,
-this also works without RTTI enabled.
+    obj = memnew(CustomObject);
+    print_line("Object Type: ",obj->get_type()); //print object type
 
-.. raw:: html
-
-   
+ obj2 = obj->cast_to(); // converting between types, this also works without RTTI enabled. References: ~~~~~~~~~~~ -- \\\ `core/object.h\\ `__ +- `core/object.h `__ Registering an Object --------------------- @@ -43,22 +36,18 @@ their methods properties and integer constants. Classes are registered by calling: -
ObjectTypeDB::register\_type()
+.. code:: cpp
 
-.. raw:: html
-
-   
+ ObjectTypeDB::register_type() Registering it will allow the type to be instanced by scripts, code, or creating them again when deserializing. Registering as virtual is the same but it can't be instanced. -
ObjectTypeDB::register\_virtual\_type()
+.. code:: cpp
 
-.. raw:: html
-
-   
+ ObjectTypeDB::register_virtual_type() Object derived classes can override a static function ``static void _bind_methods()``, when one class is registered, this @@ -70,25 +59,18 @@ virtual automatically. Inside ``_bind_methods``, there are a couple of things that can be done. Registering functions is one: -
ObjectTypeDB::register\_method(\_MD (\\"methodname\\",\\"arg1name\\",\\"arg2name\\"),&MyCustethod);
+.. code:: cpp
 
-.. raw:: html
-
-   
+ ObjectTypeDB::register_method(_MD("methodname","arg1name","arg2name"),&MyCustethod); Default values for arguments can be passed in reverse order: -
ObjectTypeDB::register\_method(\_MD (\\"methodname\\",\\"arg1name\\",\\"arg2name\\"),&MyCustomType::method,DEFVAL (-1));
-//default argument for arg2name
+.. code:: cpp
 
-.. raw:: html
+    ObjectTypeDB::register_method(_MD("methodname","arg1name","arg2name"),&MyCustomType::method,DEFVAL(-1)); //default argument for arg2name
 
-   
- -``_MD`` is a macro that convers \\"methodname\\" to a stringname for -more efficiency. Argument names are used for instrospection, but when +``_MD`` is a macro that convers "methodname" to a stringname for more +efficiency. Argument names are used for instrospection, but when compiling on release, the macro ignores them, so the strings are unused and optimized away. @@ -101,42 +83,33 @@ string passing the name can be passed for brevity. References: ~~~~~~~~~~~ -- \\\ `core/object\_type\_db.h\\ `__ +- `core/object\_type\_db.h `__ Constants --------- Classes often have enums such as: -|
-| enum SomeMode {
-| MODE\_FIRST,
-| MODE\_SECOND
-| };
+.. code:: cpp
 
-.. raw:: html
-
-   
+ enum SomeMode { + MODE_FIRST, + MODE_SECOND + }; For these to work when binding to methods, the enum must be declared convertible to int, for this a macro is provided: -
VARIANT\_ENUM\_CAST( MyClass::SomeMode); // now
-functions that take SomeMode can be bound.
+.. code:: cpp
 
-.. raw:: html
-
-   
+ VARIANT_ENUM_CAST( MyClass::SomeMode); // now functions that take SomeMode can be bound. The constants can also be bound inside ``_bind_methods``, by using: -|
-| BIND\_CONSTANT( MODE\_FIRST );
-| BIND\_CONSTANT( MODE\_SECOND );
+.. code:: cpp
 
-.. raw:: html
-
-   
+ BIND_CONSTANT( MODE_FIRST ); + BIND_CONSTANT( MODE_SECOND ); Properties (set/get) -------------------- @@ -149,34 +122,25 @@ Objects export properties, properties are useful for the following: Properties are usually defined by the PropertyInfo() class. Usually constructed as: -
PropertyInfo(type,name,hint,hint\_string,usage\_flags)
+.. code:: cpp
 
-.. raw:: html
-
-   
+ PropertyInfo(type,name,hint,hint_string,usage_flags) For example: -
PropertyInfo(Variant::INT,\\"amount\\",PROPERTY\_HINT\_RANGE,\\"0,49,1\\",PROPERTY\_USAGE\_EDITOR)
+.. code:: cpp
 
-.. raw:: html
+    PropertyInfo(Variant::INT,"amount",PROPERTY_HINT_RANGE,"0,49,1",PROPERTY_USAGE_EDITOR)
 
-   
- -This is an integer property, named \\"amount\\", hint is a range, range -goes from 0 to 49 in steps of 1 (integers). It is only usable for the -editor (edit value visually) but wont be serialized. +This is an integer property, named "amount", hint is a range, range goes +from 0 to 49 in steps of 1 (integers). It is only usable for the editor +(edit value visually) but wont be serialized. or -
PropertyInfo(Variant::STRING,\\"modes\\",PROPERTY\_HINT\_ENUM,\\"Enabled,Disabled,Turbo\\")
+.. code:: cpp
 
-.. raw:: html
-
-   
+ PropertyInfo(Variant::STRING,"modes",PROPERTY_HINT_ENUM,"Enabled,Disabled,Turbo") This is a string property, can take any string but the editor will only allow the defined hint ones. Since no hint flags were specified, the @@ -188,19 +152,15 @@ check. Properties can also work like C# properties and be accessed from script using indexing, but ths usage is generally discouraged, as using functions is preferred for legibility. Many properties are also bound -with categories, such as \\"animation/frame\\" which also make indexing +with categories, such as "animation/frame" which also make indexing imposssible unless using operator []. From ``_bind_methods()``, properties can be created and bound as long as a set/get functions exist. Example: -
ADD\_PROPERTY(
-PropertyInfo(Variant::INT,\\"amount\\"), \_SCS (\\"set\_amount\\"),
-\_SCS (\\"get\_amount\\") )
+.. code:: cpp
 
-.. raw:: html
-
-   
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"amount"), _SCS("set_amount"), _SCS("get_amount") ) This creates the property using the setter and the getter. ``_SCS`` is a macro that creates a StringName efficiently. @@ -216,17 +176,11 @@ they are NOT virtual, DO NOT make them virtual, they are called for every override and the previous ones are not invalidated (multilevel call). -|
-| void \_get\_property\_info(List \*r\_props); //return list of
-  propertes
-| bool \_get(const StringName& p\_property, Variany& r\_value) const;
-  //return true if property was found
-| bool \_set(const StringName& p\_property, const Variany& p\_value);
-  //return true if property was found
+.. code:: cpp
 
-.. raw:: html
-
-   
+ void _get_property_info(List *r_props); //return list of propertes + bool _get(const StringName& p_property, Variany& r_value) const; //return true if property was found + bool _set(const StringName& p_property, const Variany& p_value); //return true if property was found This is also a little less efficient since ``p_property`` must be compared against the desired names in serial order. @@ -237,15 +191,12 @@ Dynamic casting Godot provides dynamic casting between Object Derived classes, for example: -|
-| void somefunc(Object \*some\_obj) {
+.. code:: cpp
 
-| Button \* button = some\_obj->cast\_to<Button>();
-| }
+    void somefunc(Object *some_obj) {
 
-.. raw:: html
-
-   
+ Button * button = some_obj->cast_to