Files
godot-docs-l10n/sphinx/templates/development/cpp/custom_modules_in_cpp.pot
2019-01-09 10:58:46 +01:00

271 lines
13 KiB
Plaintext

# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2014-2019, Juan Linietsky, Ariel Manzur and the Godot community (CC-BY 3.0)
# This file is distributed under the same license as the Godot Engine package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Godot Engine latest\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-01-09 10:56+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:4
msgid "Custom modules in C++"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:7
msgid "Modules"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:9
msgid "Godot allows extending the engine in a modular way. New modules can be created and then enabled/disabled. This allows for adding new engine functionality at every level without modifying the core, which can be split for use and reuse in different modules."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:14
msgid "Modules are located in the ``modules/`` subdirectory of the build system. By default, many different modules exist, such as GDScript (which, yes, is not part of the base engine), the Mono runtime, a regular expressions module, and others. As many new modules as desired can be created and combined, and the SCons build system will take care of it transparently."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:22
msgid "What for?"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:24
msgid "While it's recommended that most of a game is written in scripting (as it is an enormous time saver), it's perfectly possible to use C++ instead. Adding C++ modules can be useful in the following scenarios:"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:28
msgid "Binding an external library to Godot (like PhysX, FMOD, etc)."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:29
msgid "Optimize critical parts of a game."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:30
msgid "Adding new functionality to the engine and/or editor."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:31
msgid "Porting an existing game."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:32
msgid "Write a whole, new game in C++ because you can't live without C++."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:35
msgid "Creating a new module"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:37
msgid "Before creating a module, make sure to download the source code of Godot and manage to compile it. There are tutorials in the documentation for this."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:40
msgid "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."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:44
msgid "The example module will be called \"summator\", and is placed inside the Godot source tree (``C:\\godot`` refers to wherever the Godot sources are located):"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:55
msgid "Inside we will create a simple summator class:"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:83
msgid "And then the cpp file."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:117
msgid "Then, the new class needs to be registered somehow, so two more files need to be created:"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:125
msgid "With the following contents:"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:153
msgid "Next, we need to create a ``SCsub`` file so the build system compiles this module:"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:163
msgid "With multiple sources, you can also add each file individually to a Python string list:"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:171
msgid "This allows for powerful possibilities using Python to construct the file list using loops and logic statements. Look at some of the other modules that ship with Godot by default for examples."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:175
msgid "To add include directories for the compiler to look at you can append it to the environment's paths:"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:183
msgid "If you want to add custom compiler flags when building your module, you need to clone `env` first, so it won't add those flags to whole Godot build (which can cause errors). Example `SCsub` with custom flags:"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:196
msgid "And finally, the configuration file for the module, this is a simple python script that must be named ``config.py``:"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:209
msgid "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)."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:212
msgid "And that's it. Hope it was not too complex! Your module should look like this:"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:224
msgid "You can then zip it and share the module with everyone else. When building for every platform (instructions in the previous sections), your module will be included."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:229
msgid "Using the module"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:231
msgid "You can now use your newly created module from any script:"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:242
msgid "And the output will be ``60``."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:244
msgid "The previous Summator example is great for small, custom modules, but what if you want to use a larger, external library? Refer to :ref:`doc_binding_to_external_libraries` for details about binding to external libraries."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:250
msgid "Improving the build system for development"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:252
msgid "So far we defined a clean and simple SCsub that allows us to add the sources of our new module as part of the Godot binary."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:255
msgid "This static approach is fine when we want to build a release version of our game given we want all the modules in a single binary."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:258
msgid "However the trade-of is every single change means a full recompilation of the game. Even if SCons is able to detect and recompile only the file that have changed, finding such files and eventually linking the final binary is a long and costly part."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:263
msgid "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."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:295
msgid "Once compiled, we should end up with a ``bin`` directory containing both the ``godot*`` binary and our ``libsummator*.so``. However given the .so is not in a standard directory (like ``/usr/lib``), we have to help our binary find it during runtime with the ``LD_LIBRARY_PATH`` environ variable:"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:305
msgid "**note**: Pay attention you have to ``export`` the environ variable otherwise you won't be able to play you project from within the editor."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:308
msgid "On top of that, it would be nice to be able to select whether to compile our module as shared library (for development) or as a part of the Godot binary (for release). To do that we can define a custom flag to be passed to SCons using the `ARGUMENT` command:"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:338
msgid "Now by default ``scons`` command will build our module as part of godot's binary and as a shared library when passing ``summator_shared=yes``."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:341
msgid "Finally you can even speedup build further by explicitly specifying your shared module as target in the scons command:"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:349
msgid "Writing custom documentation"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:351
msgid "Writing documentation may seem like a boring task, but it is highly recommended to document your newly created module in order to make it easier for users to benefit from it. Not to mention that the code you've written one year ago may become indistinguishable from the code that was written by someone else, so be kind to your future self!"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:357
msgid "There are several steps in order to setup custom docs for the module:"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:359
msgid "Make a new directory in the root of the module. The directory name can be anything, but we'll be using the ``doc_classes`` name throughout this section."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:362
msgid "Append the following code snippet to ``config.py``:"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:374
msgid "The ``get_doc_classes()`` method is necessary for the build system to know which documentation classes of the module must be merged, since the module may contain several classes. Replace ``ClassName`` with the name of the class you want to write documentation for. If you need docs for more than one class, append those as well."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:380
msgid "The ``get_doc_path()`` method is used by the build system to determine the location of the docs. In our case, they will be located in the ``doc_classes`` directory."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:384
msgid "Run command:"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:390
msgid "This will dump the engine API reference to the given ``<path>`` in XML format. Notice that you'll need to configure your ``PATH`` to locate Godot's executable, and make sure that you have write access rights. If not, you might encounter an error similar to the following:"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:400
msgid "Get generated doc file from ``godot/doc/classes/ClassName.xml``"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:402
msgid "Copy this file to ``doc_classes``, optionally edit it, then compile the engine."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:404
msgid "The build system will fetch the documentation files from the ``doc_classes`` directory and merge them with the base types. Once the compilation process is finished, the docs will become accessible within the engine's built-in documentation system."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:408
msgid "In order to keep documentation up-to-date, all you'll have to do is simply modify one of the ``ClassName.xml`` files and recompile the engine from now on."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:412
msgid "Summing up"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:414
msgid "Remember to:"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:416
msgid "use ``GDCLASS`` macro for inheritance, so Godot can wrap it"
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:417
msgid "use ``_bind_methods`` to bind your functions to scripting, and to allow them to work as callbacks for signals."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:420
msgid "But this is not all, depending what you do, you will be greeted with some (hopefully positive) surprises."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:423
msgid "If you inherit from :ref:`class_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."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:426
msgid "If you inherit from :ref:`class_Resource`, it will appear in the resource list, and all the exposed properties can be serialized when saved/loaded."
msgstr ""
#: ../../docs/development/cpp/custom_modules_in_cpp.rst:429
msgid "By this same logic, you can extend the Editor and almost any area of the engine."
msgstr ""