|
@@ -45,8 +45,7 @@ The example module will be called "summator" (``godot/modules/summator``).
|
|
Inside we will create a summator class:
|
|
Inside we will create a summator class:
|
|
|
|
|
|
.. code-block:: cpp
|
|
.. code-block:: cpp
|
|
-
|
|
|
|
- /* summator.h */
|
|
|
|
|
|
+ :caption: godot/modules/summator/summator.h
|
|
|
|
|
|
#ifndef SUMMATOR_H
|
|
#ifndef SUMMATOR_H
|
|
#define SUMMATOR_H
|
|
#define SUMMATOR_H
|
|
@@ -74,8 +73,7 @@ Inside we will create a summator class:
|
|
And then the cpp file.
|
|
And then the cpp file.
|
|
|
|
|
|
.. code-block:: cpp
|
|
.. code-block:: cpp
|
|
-
|
|
|
|
- /* summator.cpp */
|
|
|
|
|
|
+ :caption: godot/modules/summator/summator.cpp
|
|
|
|
|
|
#include "summator.h"
|
|
#include "summator.h"
|
|
|
|
|
|
@@ -116,8 +114,7 @@ need to be created:
|
|
These files should contain the following:
|
|
These files should contain the following:
|
|
|
|
|
|
.. code-block:: cpp
|
|
.. code-block:: cpp
|
|
-
|
|
|
|
- /* register_types.h */
|
|
|
|
|
|
+ :caption: godot/modules/summator/register_types.h
|
|
|
|
|
|
#include "modules/register_module_types.h"
|
|
#include "modules/register_module_types.h"
|
|
|
|
|
|
@@ -126,8 +123,7 @@ These files should contain the following:
|
|
/* yes, the word in the middle must be the same as the module folder name */
|
|
/* yes, the word in the middle must be the same as the module folder name */
|
|
|
|
|
|
.. code-block:: cpp
|
|
.. code-block:: cpp
|
|
-
|
|
|
|
- /* register_types.cpp */
|
|
|
|
|
|
+ :caption: godot/modules/summator/register_types.cpp
|
|
|
|
|
|
#include "register_types.h"
|
|
#include "register_types.h"
|
|
|
|
|
|
@@ -152,6 +148,7 @@ Next, we need to create an ``SCsub`` file so the build system compiles
|
|
this module:
|
|
this module:
|
|
|
|
|
|
.. code-block:: python
|
|
.. code-block:: python
|
|
|
|
+ :caption: godot/modules/summator/SCsub
|
|
|
|
|
|
# SCsub
|
|
# SCsub
|
|
|
|
|
|
@@ -184,8 +181,7 @@ If you want to add custom compiler flags when building your module, you need to
|
|
Example ``SCsub`` with custom flags:
|
|
Example ``SCsub`` with custom flags:
|
|
|
|
|
|
.. code-block:: python
|
|
.. code-block:: python
|
|
-
|
|
|
|
- # SCsub
|
|
|
|
|
|
+ :caption: godot/modules/summator/SCsub
|
|
|
|
|
|
Import('env')
|
|
Import('env')
|
|
|
|
|
|
@@ -201,6 +197,7 @@ And finally, the configuration file for the module, this is a
|
|
Python script that must be named ``config.py``:
|
|
Python script that must be named ``config.py``:
|
|
|
|
|
|
.. code-block:: python
|
|
.. code-block:: python
|
|
|
|
+ :caption: godot/modules/summator/config.py
|
|
|
|
|
|
# config.py
|
|
# config.py
|
|
|
|
|
|
@@ -354,8 +351,7 @@ method which will be called before anything else during the
|
|
We now need to add this method to ``register_types`` header and source files:
|
|
We now need to add this method to ``register_types`` header and source files:
|
|
|
|
|
|
.. code-block:: cpp
|
|
.. code-block:: cpp
|
|
-
|
|
|
|
- /* register_types.h */
|
|
|
|
|
|
+ :caption: godot/modules/summator/register_types.h
|
|
|
|
|
|
#define MODULE_SUMMATOR_HAS_PREREGISTER
|
|
#define MODULE_SUMMATOR_HAS_PREREGISTER
|
|
void preregister_summator_types();
|
|
void preregister_summator_types();
|
|
@@ -369,8 +365,7 @@ We now need to add this method to ``register_types`` header and source files:
|
|
has to be converted to uppercase as well.
|
|
has to be converted to uppercase as well.
|
|
|
|
|
|
.. code-block:: cpp
|
|
.. code-block:: cpp
|
|
-
|
|
|
|
- /* register_types.cpp */
|
|
|
|
|
|
+ :caption: godot/modules/summator/register_types.cpp
|
|
|
|
|
|
#include "register_types.h"
|
|
#include "register_types.h"
|
|
|
|
|
|
@@ -413,8 +408,7 @@ The solution to avoid such a cost is to build our own module as a shared
|
|
library that will be dynamically loaded when starting our game's binary.
|
|
library that will be dynamically loaded when starting our game's binary.
|
|
|
|
|
|
.. code-block:: python
|
|
.. code-block:: python
|
|
-
|
|
|
|
- # SCsub
|
|
|
|
|
|
+ :caption: godot/modules/summator/SCsub
|
|
|
|
|
|
Import('env')
|
|
Import('env')
|
|
|
|
|
|
@@ -470,8 +464,7 @@ module as shared library (for development) or as a part of the Godot binary
|
|
using the ``ARGUMENT`` command:
|
|
using the ``ARGUMENT`` command:
|
|
|
|
|
|
.. code-block:: python
|
|
.. code-block:: python
|
|
-
|
|
|
|
- # SCsub
|
|
|
|
|
|
+ :caption: godot/modules/summator/SCsub
|
|
|
|
|
|
Import('env')
|
|
Import('env')
|
|
|
|
|
|
@@ -626,8 +619,8 @@ The procedure is the following:
|
|
3. Write some test cases. Here's an example:
|
|
3. Write some test cases. Here's an example:
|
|
|
|
|
|
.. code-block:: cpp
|
|
.. code-block:: cpp
|
|
|
|
+ :caption: godot/modules/summator/tests/test_summator.h
|
|
|
|
|
|
- // test_summator.h
|
|
|
|
#ifndef TEST_SUMMATOR_H
|
|
#ifndef TEST_SUMMATOR_H
|
|
#define TEST_SUMMATOR_H
|
|
#define TEST_SUMMATOR_H
|
|
|
|
|