Compare commits

...

289 Commits

Author SHA1 Message Date
Rémi Verschelde
3e2247ca53 Release 2.1.1-stable 2016-11-15 09:14:21 +01:00
Rémi Verschelde
bf3cf5505e classref: Sync with current source 2016-11-15 09:14:02 +01:00
Rémi Verschelde
bcc887bbe5 i18n: Sync translations with Weblate and update template 2016-11-15 09:10:37 +01:00
Rémi Verschelde
9b32df9cab i18n: Remove translations below 20% completion
They are of course kept in master to be synced in Weblate.
2016-11-15 09:07:53 +01:00
Ben Hickling
601f056b6f Added snapping to 3D path handles to bring it in line with its 2D counterpart
(cherry picked from commit 4d1acab79b)
2016-11-15 08:44:53 +01:00
volzhs
14b46c4263 Check entered and trimmed path when create, import, install project
(cherry picked from commit 2d9e89ea2a)
2016-11-15 08:44:53 +01:00
khairul169
8a813e2a1e Uncomment debug properties of HTTP Request
(cherry picked from commit 6a7aebdf6c)
2016-11-15 08:44:53 +01:00
volzhs
679e9f413c Fix crash when select target path on import 3d scene window
(cherry picked from commit b0cf201ea3)
2016-11-15 08:44:53 +01:00
Pedro J. Estébanez
19ce11b908 Update/fix Android build
Fix wrong path for 32-bit Windows, which fixes #7084
Exclude 32-bit Windows from multi-threaded linking because it's not supported by the NDK
Remove 32-bit Linux as there is no NDK variant for it
(cherry picked from commit 5a26459c06)
2016-11-15 08:44:53 +01:00
eska
28944e95e7 Clarify a NULL comparison
'TreeItem::get_children()' does not return the child count, but rather
a pointer to the children.

This comparison caused an error during WebAssembly builds using the
LLVM backend path.

(cherry picked from commit 31f929caa2)
2016-11-15 08:37:53 +01:00
volzhs
2d6dabc68e Prevent to select children if selection lock or instanced scene
Fix #7086

(cherry picked from commit c3f4d676c0)
2016-11-15 08:37:48 +01:00
volzhs
9219ac7e44 Fix resetting to default value in EditorSettings
(cherry picked from commit 70cce6152d)
2016-11-15 08:36:53 +01:00
Elia Argentieri
e3dc319f78 Make the step property useful for sliders as described in #5773
(cherry picked from commit 0955371447)
2016-11-15 08:36:18 +01:00
Pedro J. Estébanez
221346521c Make Android export quicker (especially on Windows)
(cherry picked from commit 56721e5d9d)
2016-11-15 08:35:15 +01:00
Pawel Kowal
f1c2d70f1a Export immediately if only one device present
(cherry picked from commit 938f9388dd)
2016-11-15 08:35:01 +01:00
volzhs
3e127ce3fd Fix Directory.dir_exist/get_current_dir for 'res://' on Android
Fix #7014

(cherry picked from commit 8d454ed9a7)
2016-11-15 08:34:51 +01:00
ISylvox
0413d85add vsnc --> vsync
(cherry picked from commit b5c383fd61)
2016-11-15 08:34:43 +01:00
volzhs
7d09222b37 Set project name as directory name instead of '.'
(cherry picked from commit 571f33f863)
2016-11-15 08:34:38 +01:00
volzhs
dd8b87f58e Select newly created or imported project automatically
(cherry picked from commit b8f80e9450)
2016-11-15 08:34:32 +01:00
volzhs
36a4c54593 Fix Label valign position
Fix #7055

(cherry picked from commit c0e87f2a24)
2016-11-15 08:34:26 +01:00
SPTelur
51fe9fc132 Some missing License notice has been added
(cherry picked from commit df737ebb46)
2016-11-15 08:34:16 +01:00
Paulb23
9e1e5daddf Caret blink will no longer cause redraw without focus, issue 6167
(cherry picked from commit 7b036a94bf)
2016-11-15 08:34:01 +01:00
DTV96Calibre
bc8dabf3d2 Fixed minor typo
(cherry picked from commit 37098419c5)
2016-11-15 08:30:35 +01:00
Pedro J. Estébanez
fada9d7a8e Clean/fix triangulation internals
Drop unused variable
Remove commented-out code
Fix leak by using Vector instead of raw memory

(cherry picked from commit 0e1972aa51)
2016-11-15 08:30:09 +01:00
volzhs
82b458f160 Fix updating value of SpinBox with prefix
(cherry picked from commit 80b6507071)
2016-11-15 08:30:02 +01:00
volzhs
64f38490df Prevent to make UndoRedo for duplicate if no selected node
(cherry picked from commit d82928eb49)
2016-11-15 08:29:56 +01:00
ScotFlux
c282ac8ec7 fix a tiny typo
(cherry picked from commit 8639d6e806)
2016-11-15 08:29:30 +01:00
Rémi Verschelde
210618c5e2 Rewrite the README to be more descriptive
(cherry picked from commit ab9fa604d1)
2016-11-15 08:29:23 +01:00
volzhs
2b00fdc679 Fix wrong number for ERR_* on comment
(cherry picked from commit 42f2380190)
2016-11-15 08:29:09 +01:00
Tim Roes
d7ec768805 Fix typos and missing newlines in --help
(cherry picked from commit c34aa331ec)
2016-11-15 08:28:58 +01:00
Keetz
86c6aabf27 Fix scene tree drag & drop places node as child (#6912)
(cherry picked from commit 2afcbc4b1f)
2016-11-15 08:28:52 +01:00
Saracen
e5f210693c Fixed flag for importing animation and skipping value tracks.
(cherry picked from commit 0063471edd)
2016-11-15 08:28:26 +01:00
Ignacio Etcheverry
7e3360ae01 Keep groups when replacing nodes
(cherry picked from commit 305956bf70)
2016-11-15 08:28:11 +01:00
Ariel Manzur
67f65f6639 memory ops implemented as OS functions by default 2016-11-08 19:04:56 -03:00
Ariel Manzur
dbca4ee3fe adding get_stored_values method
changed order name
2016-11-08 18:14:10 -03:00
Rémi Verschelde
cd828bd5fc server: Allow building against system libraries
(cherry picked from commit 5e360fe178)
2016-11-03 22:55:24 +01:00
Rémi Verschelde
da4a870bc4 opus: Move public headers to match system install
(cherry picked from commit 611a94e3a6)
2016-11-03 21:22:56 +01:00
Rémi Verschelde
ce54b6ea8b scons: Reorder options for clarity
Also prefix all thirdparty-related toggles with `builtin`.

(cherry picked from commit cc95d4448c)
2016-11-03 08:41:10 +01:00
Rémi Verschelde
5ee9a9962f libpng: Update to upstream 1.6.26
(cherry picked from commit 7504a85e5a)
2016-11-03 08:34:19 +01:00
Pedro J. Estébanez
f629b1fd3e Improve Android build (Clang + tidyness)
(cherry picked from commit b18ff942be)
2016-11-02 22:34:17 +01:00
Rémi Verschelde
eaf803f71e style: Various other PEP8 fixes in Python files
Done with `autopep8 --select=E7`, fixes:

- E701 - Put colon-separated compound statement on separate lines.
- E702 - Put semicolon-separated compound statement on separate lines.
- E703 - Put semicolon-separated compound statement on separate lines.
- E711 - Fix comparison with None.
- E712 - Fix (trivial case of) comparison with boolean.
- E713 - Fix (trivial case of) non-membership check.
- E721 - Fix various deprecated code (via lib2to3).
2016-11-02 22:30:34 +01:00
Rémi Verschelde
a7389217f8 style: Fix PEP8 blank lines issues in Python files
Done with `autopep8 --select=E3,W3`, fixes:

- E301 - Add missing blank line.
- E302 - Add missing 2 blank lines.
- E303 - Remove extra blank lines.
- E304 - Remove blank line following function decorator.
- E309 - Add missing blank line.
- W391 - Remove trailing blank lines.
2016-11-02 22:29:36 +01:00
Rémi Verschelde
e259bf8bbb style: Fix PEP8 whitespace issues in Python files
Done with `autopep8 --select=E2,W2`, fixes:

- E201 - Remove extraneous whitespace.
- E202 - Remove extraneous whitespace.
- E203 - Remove extraneous whitespace.
- E211 - Remove extraneous whitespace.
- E221 - Fix extraneous whitespace around keywords.
- E222 - Fix extraneous whitespace around keywords.
- E223 - Fix extraneous whitespace around keywords.
- E224 - Remove extraneous whitespace around operator.
- E225 - Fix missing whitespace around operator.
- E226 - Fix missing whitespace around operator.
- E227 - Fix missing whitespace around operator.
- E228 - Fix missing whitespace around operator.
- E231 - Add missing whitespace.
- E231 - Fix various deprecated code (via lib2to3).
- E241 - Fix extraneous whitespace around keywords.
- E242 - Remove extraneous whitespace around operator.
- E251 - Remove whitespace around parameter '=' sign.
- E261 - Fix spacing after comment hash.
- E262 - Fix spacing after comment hash.
- E265 - Format block comments.
- E271 - Fix extraneous whitespace around keywords.
- E272 - Fix extraneous whitespace around keywords.
- E273 - Fix extraneous whitespace around keywords.
- E274 - Fix extraneous whitespace around keywords.
- W291 - Remove trailing whitespace.
- W293 - Remove trailing whitespace.
2016-11-02 22:28:28 +01:00
Rémi Verschelde
561c1f17a1 style: Start applying PEP8 to Python files, indentation issues
Done with `autopep8 --select=E1`, fixes:

- E101 - Reindent all lines.
- E112 - Fix under-indented comments.
- E113 - Fix over-indented comments.
- E115 - Fix under-indented comments.
- E116 - Fix over-indented comments.
- E121 - Fix a badly indented line.
- E122 - Fix a badly indented line.
- E123 - Fix a badly indented line.
- E124 - Fix a badly indented line.
- E125 - Fix indentation undistinguish from the next logical line.
- E126 - Fix a badly indented line.
- E127 - Fix a badly indented line.
- E128 - Fix a badly indented line.
- E129 - Fix a badly indented line.
2016-11-02 22:26:55 +01:00
volzhs
7c92b401f1 Fix to fit stylebox with ItemList
(cherry picked from commit 4c9b00b508)
2016-11-02 22:18:34 +01:00
m4nu3lf
d44e6ea268 Fixed Mix nodes in Animation Tree Player
(cherry picked from commit 40ba6d328b)
2016-11-02 22:18:28 +01:00
Rémi Verschelde
1185da656f Merge pull request #6988 from RandomShaper/2.1
Fix shader tokenizer/compiler reporting wrong error location (2.1)
2016-11-02 22:10:00 +01:00
Rémi Verschelde
c78aef5812 Fix usage of 3.0 naming API in 1038c1f8 2016-10-31 08:39:45 +01:00
volzhs
91af714d39 Fix memory leak with drag & drop on 2D viewport
(cherry picked from commit a7d492eb53)
2016-10-31 07:55:23 +01:00
Andreas Haas
5033fc92f4 Ability to drag script files from Filesystem dock to SceneTree dock.
Allows to attach scripts by dragging them onto the target Node.

(cherry picked from commit a3944e66da)
2016-10-31 07:55:03 +01:00
volzhs
1038c1f856 Improve drag and drop on 2D viewport
(cherry picked from commit eed9179ea3)
2016-10-31 07:53:31 +01:00
Rémi Verschelde
8087be05c7 scons: msvc_is_detected not available in 2.1 2016-10-31 07:52:40 +01:00
Rémi Verschelde
a20da0c048 classref: Sync with current sources 2016-10-31 00:15:54 +01:00
volzhs
d67bbd183e Fix p_index out of size error when closing script
(cherry picked from commit 707185d9d8)
2016-10-31 00:07:56 +01:00
volzhs
647b287a1e Fix Accept/ConfirmationDialog UI broken
(cherry picked from commit 8d5644c4b2)
2016-10-31 00:07:47 +01:00
volzhs
91df1ebff6 Revert "Place child control under label in AcceptDialog."
This reverts commit 3ef2722904.

(cherry picked from commit 3f15a65307)
2016-10-31 00:07:40 +01:00
Rémi Verschelde
62d1e39113 scons: Move lib splitting method to methods.py
Apparently it might still be necessary for some console ports.

(cherry picked from commit e34a5324c8)
2016-10-31 00:07:29 +01:00
Pedro J. Estébanez
b492dd78bd Adopt simpler strategy for big libs on Windows
(cherry picked from commit 51ad1c1668)
2016-10-31 00:05:42 +01:00
rdb
a27aee241c Add "Never" underline mode to LinkButton
(cherry picked from commit d517bc908f)
2016-10-31 00:05:32 +01:00
Damon
e3be51f87c Fix locale for macOS-style locales
(cherry picked from commit 1e7f078ce9)
2016-10-31 00:04:39 +01:00
Damon Myers
68b6b50d28 Change set_locale to fallback to the global language (#6910)
(cherry picked from commit 470ead74db)
2016-10-31 00:04:26 +01:00
volzhs
06c47e6f8a Remove dead code in FileSystemDock
(cherry picked from commit 9605a1d0da)
2016-10-31 00:02:12 +01:00
volzhs
e56961f58b Fix comparison bug with InputEvent
(cherry picked from commit b76a0ca40c)
2016-10-31 00:02:04 +01:00
Błażej Szczygieł
b0013f32bf "CCFLAGS" are for C and C++ compiler
(cherry picked from commit ace18d28d2)
2016-10-31 00:01:41 +01:00
Henrique Lacreta Alves
58daf901f9 Prevent unwanted script editor input on game crash
Fixes #6530.
(cherry picked from commit 853d1ce9f3)
2016-10-31 00:01:11 +01:00
Pedro J. Estébanez
887b1de1db Add/expose VisualServer::get_default_clear_color()
(cherry picked from commit 753ba67d65)
2016-10-31 00:00:55 +01:00
yg2f
caf42f77d2 Fixes #6487, GDscript compiler ignores OPCODE_LINE and OPCODE_BREAKPOINT in Release mode
When godot is in release mode, GDscript compiler does not generate
bytecodes for OPCODE_LINE and OPCODE_BREAKPOINT anymore.

This optimizes GDscript execution speed when the script contains a lot
of comments in blocs executed in loops.

Fixes #6487

(cherry picked from commit 217e09c79d)
2016-10-31 00:00:46 +01:00
Karol Walasek
9f9d1eed7b Added general notes on RayCast[2D] updating behaviour and force_raycast_update()
(cherry picked from commit 8d57640d37)
2016-10-31 00:00:34 +01:00
Karol Walasek
0af331d1c0 Added force_raycast_update GDScript method for RayCast[2D]
(cherry picked from commit 7494a8c3c6)
2016-10-31 00:00:23 +01:00
George Marques
7a17d72e84 Fix extraneous NULL character on HTML export
Fix #2801

(cherry picked from commit 604ddd691c)
2016-10-30 23:58:41 +01:00
George Marques
52bf8bd168 Fix the hiding of mouse cursor before interaction
Fix part of #6633

(cherry picked from commit 414d58e6c0)
2016-10-30 23:58:32 +01:00
George Marques
f3b42e049d Fix output binary paths for VS project generation
(cherry picked from commit c8093678a0)
2016-10-30 23:57:54 +01:00
Pedro J. Estébanez
a130520a7c Fix shader tokenizer/compiler reporting wrong error location
Raname shader tokenizer methods for clarity
2016-10-30 22:09:23 +01:00
Błażej Szczygieł
85a7105345 SCons: Use colored output if available, change "colored"->"verbose"
(cherry picked from commit 2bf4553fe0)
2016-10-30 14:51:34 +01:00
Błażej Szczygieł
dcd4b80c13 Disable asserts in release mode
(cherry picked from commit 639ea563e0)
2016-10-30 14:51:34 +01:00
Rémi Verschelde
5a49e45d21 SCsub: Add python shebang as a hint for syntax highlighting
Also switch existing shebangs to "better" /usr/bin/env python.

(cherry picked from commit fc8ccd5b8c)
2016-10-30 14:51:34 +01:00
Błażej Szczygieł
7143401e25 Theora: Don't compile unnecessary files, rename "x86_opt_*"
(cherry picked from commit 4ffa8f224d)
2016-10-30 14:51:34 +01:00
Rémi Verschelde
f4414e3e03 png: Try to fix neon issue on iphone armv7
(cherry picked from commit e57042e8a9)
2016-10-30 14:51:34 +01:00
Rémi Verschelde
aa1367595e drivers: Refactor SCsub and drop redundant env_drivers clone
The reordering of the SConscript includes allows to ensure that
stuff like the builtin zlib headers will be available for libpng.

Also moved glew back into global env, otherwise windows seems
not to find it... Kind of shooting in the dark with this multi-env
setup.

(cherry picked from commit 248bc9159c)
2016-10-30 14:51:34 +01:00
Rémi Verschelde
d96842b80e freetype: Make it a module and split thirdparty library
Comment out the weird workaround for building on Windows at it might
not be needed anymore. Testing needed to confirm.

(cherry picked from commit edbc0c0d0b)
2016-10-30 14:51:33 +01:00
Rémi Verschelde
8bf3bc3449 chibi: Move to a module
(cherry picked from commit e6dc51a0f7)
2016-10-30 14:51:33 +01:00
Rémi Verschelde
f1bd2f6f56 zlib: Split thirdparty files, simplify scons option
(cherry picked from commit cbf52606f4)
2016-10-30 14:51:33 +01:00
Rémi Verschelde
e04ec9565b glew: Split thirdparty files and isolate env
Not fully happy about the way this one interacts with the various
platforms. Maybe the platform_config.h should be generated by the
SCsub instead of passing a define just to know where is the header.

(cherry picked from commit 36738ddda4)
2016-10-30 14:51:33 +01:00
Rémi Verschelde
8263fca121 squish: Update to upstream 1.14
Sources are untouched, tarball from https://sourceforge.net/projects/libsquish

(cherry picked from commit 249836e530)
2016-10-30 14:51:33 +01:00
Rémi Verschelde
1022705707 squish: Move to a module and split thirdparty lib
(cherry picked from commit 8311a78df5)
2016-10-30 14:51:33 +01:00
Rémi Verschelde
4ff4177acc rtaudio: Split thirdparty files
(cherry picked from commit 8981ff8a84)
2016-10-30 14:51:33 +01:00
Rémi Verschelde
c8a97c3678 mpc: Move to a module and split thirdparty libmpcdec
(cherry picked from commit 5c12c9e69b)
2016-10-30 14:51:33 +01:00
Rémi Verschelde
82e8721715 theora: Move to a module and split thirdparty lib
Same rationale as the previous commits.

(cherry picked from commit cfcc8a20e8)
2016-10-30 14:51:32 +01:00
Rémi Verschelde
bfea3f1d9a modules: Clone env in each module
This allows to pass include paths and flags only to a given thirdparty
library, thus preventing conflicts between their files (e.g. between
opus and openssl which both provide modes.h.

This also has the nice effect of making the compilation command smaller
for each module as it no longer related to all other modules, only the
final linking brings them together.

This however requires adding manually the ogg include path in opus
and vorbis when building against the builtin ogg, since it is no longer
in the global env.

Also simplified template 'thirdparty_<module>_sources' to
'thirdparty_sources'.

"Core" modules like cscript, gdscript, gridmap, ik and virtual_script
still use the main env_modules, but it could be changed if need be.

(cherry picked from commit da09c6131b)

Obviously removed the parts about enet and visual_script.
2016-10-30 14:51:32 +01:00
Rémi Verschelde
4cd640f684 openssl: Move to a module and split thirdparty lib
Same rationale as the previous commits.

(cherry picked from commit 422196759f)

Removed the winrt-specific parts.
2016-10-30 14:51:32 +01:00
Rémi Verschelde
995dcb610c ogg/vorbis/opus/speex: Make them modules and unbundle thirdparty libs
Took the opportunity to undo the Godot changed made to the
opus source. The opus module should eventually be built in its
own environment to avoid polluting others with too many include
dirs and defines.

TODO: Fix the platform/ stuff for opus.
(cherry picked from commit d9a291f641)

speex module was only added while cherry-picking, as speex is removed
in the master branch but we don't want to break compatibility in 2.1.x.
Unbundling wasn't done as the module uses the internal speex_free,
so it would require some more work.
2016-10-30 14:51:31 +01:00
Rémi Verschelde
55414bc573 webp: Make it a module and unbundle libwebp thirdparty files
Note that there are two Godot-specific changes made to libwebp
for the javascript/HTML5 platform. They are documented in the
README.md.

(cherry picked from commit ee3cf211c6)
2016-10-30 14:51:30 +01:00
Rémi Verschelde
819ccdd340 dds/etc1/pbm/pvr: Make those modules and split thirdparty files
They are not particularly packaged in Linux distros so we do not
facilitate unbundling via SCons. There could be done if/when there
is interest.

Also s/pnm/pbm/, long-lived typo :)

(cherry picked from commit b1e8889d96)
2016-10-30 14:51:30 +01:00
Rémi Verschelde
ea1e180e4a jpg: Make it a module and split jpgd thirdparty files
Similar rationale as in previous commit.

(cherry picked from commit 16ba665db6)
2016-10-30 14:51:30 +01:00
Rémi Verschelde
575e986bde png: Split library to thirdparty dir and allow unbundling
Uses the new structure agreed upon in #6157, but the thirdparty/ folder
does not behave following a logic similar to that of modules/ yet.

The png driver can't be moved to a module as discussed in #6157, as it's
required by core together with a few other ImageLoader implementations
(see drivers/register_driver_types.cpp:register_core_driver_types())

Dropped the possibility to disable PNG support, it's a core component
of Godot.

(cherry picked from commit 5fef84a135)
2016-10-30 14:51:30 +01:00
Rémi Verschelde
846db09038 Drop nedmalloc which is apparently not used anymore
(cherry picked from commit f63bf12193)
2016-10-30 14:51:30 +01:00
Zher Huei Lee
fae2863a5e Added support for tooltips in ButtonArray. Fixes #6597
(cherry picked from commit 38caa4ef91)
2016-10-30 14:51:30 +01:00
Rémi Verschelde
56b03e7208 Merge pull request #6877 from ranmaru90/2.1
Fixed tiny error in detect.py causing compilation for Android to fail.
2016-10-22 13:03:35 +02:00
Randy Tan Shaoxian
c9d7f77c6f Fixed tiny error in detect.py causing compilation for Android to fail. 2016-10-20 21:17:21 +08:00
Rémi Verschelde
14e45a55d4 Revert "Tween reset/stop/resume/remove for all object properties at once"
This reverts commit 6fc894d652.
It caused a regression, cf. #6863.
2016-10-18 21:43:46 +02:00
Juan Linietsky
7d25d20861 Added a generic AStar implementation to Godot.
It's pretty fast, use it for games where Navigation does not cut it.

(cherry picked from commit 827a9aa829)
2016-10-18 18:35:44 +02:00
Andreas Haas
e88a540b91 osx: Support gamepad input.
Fixes #3881

Vibration support is not optimal yet as it doesn't try to emulate the "weak" and "strong" motor strength,
but just takes the parameter with the highest value for the vibration gain.

(cherry picked from commit 8c886b9d7a)
2016-10-18 18:34:16 +02:00
Rémi Verschelde
2287bac8f7 classref: Sync with current source 2016-10-17 21:07:01 +02:00
volzhs
00b0f3dfde Fix crash when using Directory.dir_exists(path) on Android
(cherry picked from commit 4a57821349)
2016-10-17 20:50:57 +02:00
Andreas Haas
64b083b496 Allow whitespace in Gamepad mappings.
Previously, mappings that contained whitespace (most likely after a comma seperator) would not parse
correctly.
Consider the following mapping as an example:

"_test_guid_, test controller, a:b0, b:b1, leftx:a0 ,"

(cherry picked from commit fa502b7ccc)
2016-10-17 20:50:43 +02:00
volzhs
9b71cae50f Add option for root node name on Import 3D scene window
(cherry picked from commit dd04ac7ba9)
2016-10-17 20:50:20 +02:00
Karol Walasek
8a8ace8fa0 Fixed Particle2D docs - radians to degrees for some params
(cherry picked from commit 5687fa4709)
2016-10-17 20:49:52 +02:00
Pedro J. Estébanez
2261c65f19 Adapt overlooked instances of zero-based column numbers
(cherry picked from commit 1b3dcac281)
2016-10-17 20:49:28 +02:00
Andreas Haas
a418304def Only show AnimationEditor automatically when an Animplayer is selected.
Previous behaviour was to show it when an AnimationPlayer has been detected in the scene, now you actually have to select it.
Fixes #6213

(cherry picked from commit 86fd40b06c)
2016-10-17 20:49:18 +02:00
Fabio Alessandrelli
ea48675ffa Properly handle absolute paths in Globals::localize_path
This give a proper fix for #4280 - #3106 , allowing absolute paths
that starts from the file system, not the resource folder

(cherry picked from commit 2f2cea070e)
2016-10-17 20:49:12 +02:00
Fabio Alessandrelli
d5ee98bb2c Revert "Add warning when (pre)loading paths with leading / (#4280 - #3106)"
Also closes: #6801

This reverts commit e59820ac94.

(cherry picked from commit 11349a786b)
2016-10-17 20:48:52 +02:00
volzhs
728ac94313 Add "button_selected" signal to ButtonGroup
(cherry picked from commit 870ed6f2fa)
2016-10-17 20:48:36 +02:00
Zher Huei Lee
a8502ae6f6 Fixes for ButtonArray
Fixed hover sometimes not resetting when mouse leaves widget.
Fixed text position not taking into account stylebox's content margins.

(cherry picked from commit f5830e0973)
2016-10-17 20:48:25 +02:00
Răzvan Cosmin Rădulescu
04255541a0 Fixes hash float negative 0 problem
Before this was giving an error:

var a = {Vector2(1, 0): 5, Vector2(-1, 0): 7}
    print(a)
    print(a[Vector2(1, 0)])
    print(a[-Vector2(1, 0)])

This simple commit fixes the issue.

(cherry picked from commit 9ad0850301)
2016-10-17 20:48:15 +02:00
Mateusz Adamczyk
17edff2f84 Possibility to write node path by hand in exported NodePath variable (#3486)
(cherry picked from commit cf4f3815b3)
2016-10-17 20:48:10 +02:00
Anthony Fieroni
b4edaa892d Correct OS architecture detection
Signed-off-by: Anthony Fieroni <bvbfan@abv.bg>
(cherry picked from commit f87e32696d)
2016-10-17 20:48:05 +02:00
volzhs
81bc271619 Replace a node with saved branch scene instance
(cherry picked from commit cc33c528eb)
2016-10-17 20:47:49 +02:00
Andreas Haas
5f540a17cc Sprite: Fix inspector not showing changes on "frame" property.
Fixes #6562

(cherry picked from commit 9d67895c7c)
2016-10-17 20:47:27 +02:00
Andreas Haas
4b6809a2b3 Refresh TextureRegionEditor when region has been changed externally.
Now the TextureRegionEditor updates when you change the region_rect either via the inspector or via
undo/redo.

Fixes #6772

(cherry picked from commit 094073e4b2)
2016-10-17 20:47:14 +02:00
Pawel Kowal
280728c0c7 New load icon, removed unused open icon
(cherry picked from commit ed1e71a77e)
2016-10-17 20:46:34 +02:00
Pawel Kowal
35cdb1a49b Fix #5959, contrasting texture for toggled button
(cherry picked from commit d3a8087659)
2016-10-17 20:46:10 +02:00
Pedro J. Estébanez
3df8f79c9f Allow step for integer properties
Small readability improvement

(cherry picked from commit 7b293aa4d4)
2016-10-17 20:44:54 +02:00
Pedro J. Estébanez
99d82f3033 Make text column numbers one-based
Make one-based the column number on the code editor

Make one-based the column number for GDScript error messages

Make one-based the column number for shader code error messages

(cherry picked from commit 2f80965845)
2016-10-17 20:44:47 +02:00
Anthony Fieroni
f250c0cf50 Button focus hovering
Signed-off-by: Anthony Fieroni bvbfan@abv.bg
(cherry picked from commit 6d21fd42d3)
2016-10-17 20:43:36 +02:00
Ignacio Etcheverry
55a5631986 Bindings: Fix missing default value
(cherry picked from commit 068b58b3ce)
2016-10-17 20:43:25 +02:00
George Marques
8cb09bf9d0 Fix Android build detection on Windows
(cherry picked from commit 4bdbafabce)
2016-10-17 20:43:03 +02:00
Mateusz Adamczyk
58e2652f94 Place child control under label in AcceptDialog.
Fixes #6199.

(cherry picked from commit 3ef2722904)
2016-10-17 20:42:51 +02:00
Rémi Verschelde
3f941faf4d i18n: Sync translations from Weblate and merge with current code 2016-10-09 18:23:26 +02:00
Rémi Verschelde
b3bf3c392a i18n: Fix string that broke msgmerge
(cherry picked from commit 2fb5a00305)
2016-10-09 18:21:59 +02:00
Rémi Verschelde
c757787fed classref: Sync with current 2.1 branch 2016-10-09 17:50:09 +02:00
J08nY
1ae1deabfa editor_node: add an option to stop the update spinner from spinning, fixes #6653
(cherry picked from commit 4527fbcfa1)
2016-10-09 17:41:04 +02:00
Pedro J. Estébanez
22680a30f1 Fix reparent undo not renaming back
(cherry picked from commit 88a32c11f1)
2016-10-09 17:40:49 +02:00
Mateusz Adamczyk
ce1138cb02 Added simple check to viewport, if matrix32 is invesile (https://github.com/godotengine/godot/issues/6296).
(cherry picked from commit 8671836b76)
2016-10-09 17:40:37 +02:00
Bojidar Marinov
a139c7afe6 Attempt to fix travis builds for android
Using travis_wait command
(cherry picked from commit f73f554cc0)
2016-10-09 17:40:25 +02:00
Fabio Alessandrelli
e51cd3d454 Throw an error when exporting a resource class
"export var tex = Texture"
will now throw an error to avoid crashing the editor:
"Exported constant not a type or resource"

Fixes #6719 . Closes #6729

(cherry picked from commit ee7df2c89a)
2016-10-09 17:40:19 +02:00
Andreas Haas
a7d6894a9f Project manager: grab focus on ok button after path selection.
Slight usability improvement: grabs focus on the Import/Create button after engine.cfg/path selection.
So then I can just press enter to create the project ^^

(cherry picked from commit 36d2dd5318)
2016-10-09 17:40:10 +02:00
Răzvan Cosmin Rădulescu
6775cce469 fixes #6695 - MultiNodeEdit edit path in exported NodePath
(cherry picked from commit ced8fb4806)
2016-10-09 17:40:03 +02:00
Andreas Haas
9e20b39b3d Fix code completion drawing under other gui elements.
Raises the z-index of the Script editor when the completion is shown.

fixes #1257
fixes #6690

(cherry picked from commit 6dfa405eac)
2016-10-09 17:39:56 +02:00
Andreas Haas
0462bf01a2 Prevent crash on focus change when no valid next control has been found.
Fixes the crash discussed in #6714.

(cherry picked from commit 8dd026e4f9)
2016-10-09 17:39:39 +02:00
Ariel Manzur
cf427eeb7a bind method canvas_item_set_sort_children_by_y
(cherry picked from commit 1f9e16119f)
2016-10-09 17:39:17 +02:00
Adham Zahran
cd03f8cce2 fix #6012 exposed setters and getters of Camera H/V offset to GDScript
(cherry picked from commit cbb0ea315b)
2016-10-09 17:39:06 +02:00
Fabio Alessandrelli
d0ff75c91c Add shortcut to reset cursor position in 3D Editor ( #166 )
The shortcut will focus the origin after you moved around with shift + mouse3.
The default shortcut is the letter "O", like "F" for focus.
This can be customized in the editor shortcuts menu.

Closes #166

(cherry picked from commit 63abe3dcd0)
2016-10-09 17:39:00 +02:00
Pedro J. Estébanez
82dfaf7af6 Fix compile flags not getting to the Android build
(cherry picked from commit 7f51bb7b1c)
2016-10-09 17:34:36 +02:00
Pedro J. Estébanez
c0ba08b8d5 Add editor_only param to Light2D
(cherry picked from commit 34c02fad5a)
2016-10-09 17:34:29 +02:00
Fabio Alessandrelli
ba095b8dcc Add warning when (pre)loading paths with leading / (#4280 - #3106)
(cherry picked from commit e59820ac94)
2016-10-09 17:34:23 +02:00
Andreas Haas
9593863a92 ConnectionDialog: Don't allow connecting to a Node without a script if target method is invalid.
Shows a warning now.
Fixes #6656

(cherry picked from commit 5b7021434f)
2016-10-09 17:34:12 +02:00
Răzvan Cosmin Rădulescu
97ebfddaaf fixes #6331, Variant::can_convert
(cherry picked from commit f2af5ab949)
2016-10-09 17:34:00 +02:00
J08nY
342b1408d5 light: respect editor_only setting in release build and dont show the light
(cherry picked from commit af35130b50)
2016-10-09 17:33:54 +02:00
Fabio Alessandrelli
359b5f3b25 Expose more 2D/3D physics options in project settings
(cherry picked from commit 1d09c27ba4)
2016-10-09 17:33:47 +02:00
J08nY
5b942f056a Vector3: added angle_to(Vector3 other)
(cherry picked from commit deb36b44d1)
2016-10-09 17:33:36 +02:00
J08nY
44ba542de6 Vector3: format properly, fix indents
(cherry picked from commit f468cfc379)
2016-10-09 17:33:30 +02:00
mookiexl
f63b338e0f Limit directional shadow draw distance, fixes #559, optimization (#1991)
* Shadow fadeout exponent hardcoded for now, should be user configurable.
* optimization - skip shadows outside visible range
(cherry picked from commit 0b12ebba11)
2016-10-09 17:33:20 +02:00
Błażej Szczygieł
13108317ae Fixes in Theora SCsub
- properly pass x86 assembly define to the compiler,
- don't compile unnecessary/encoder files.

(cherry picked from commit 75299cf334)
2016-10-09 17:33:12 +02:00
Pedro J. Estébanez
12d4d65668 Improve debug focus behavior
Fix focusing debugged game on Windows
Add re-focusing editor on continue

(cherry picked from commit 66dac878ac)
2016-10-09 17:29:59 +02:00
Fabio Alessandrelli
56dc7aa568 Properly encode InputEvent of type NONE. Fix #5987
In the editor settings you can disable default editor shortcuts.
When a default shortcut is disabled an InputEvent of type NONE must
be stored in the config file to allow the editor to remember that setting.
variant_parser.cpp was not properly encoding InputEvent of type NONE causing
the "corruption" of the editor settings file.

(cherry picked from commit 941f460384)
2016-10-09 17:29:27 +02:00
J08nY
f315d352ec PCKPacker: moved from tools into core, fixes #4129
(cherry picked from commit b1fba2e013)
2016-10-09 17:28:11 +02:00
J08nY
ef0bcc7e20 PopupMenu: added toggle_item_checked and exposed set_item_tooltip and get_item_tooltip
(cherry picked from commit 6b283ae293)
2016-10-09 17:26:14 +02:00
Karol Walasek
b2a58da321 Filled blanks and normalized documentation on RayCast[2D]
(cherry picked from commit db0a46d7f7)
2016-10-09 17:25:07 +02:00
Pedro J. Estébanez
de13e52b9b Respect texture .flags files on export
(cherry picked from commit 11cbbeb17e)
2016-10-09 17:24:10 +02:00
volzhs
73e7ccabf5 Fix typo for word_wrap
(cherry picked from commit c333659ebc)
2016-10-09 17:23:58 +02:00
volzhs
721599c797 Fix error when using 2 or more slashes on resource path
(cherry picked from commit 0866f49f4e)
2016-10-09 17:23:53 +02:00
Pawel Kowal
ab231cd3fb Fix #6480, area duplicated param
(cherry picked from commit f9a21baa26)
2016-10-09 17:23:43 +02:00
Marc Gilleron
268b3446c6 Windows: prevent huge prints from crashing the engine
(cherry picked from commit 0c09de3ef1)
2016-10-09 17:23:08 +02:00
Pawel Kowal
d7925ca09d LineEdit long indicator, fix #6624
(cherry picked from commit 3edc0a4832)
2016-10-09 17:23:02 +02:00
Błażej Szczygieł
d613952300 Don't crash when video is stopped and played again
(cherry picked from commit 5585bc1c38)
2016-10-09 17:22:54 +02:00
Victor Seiji Hariki
a3c58999e2 Now ignoring remaining collision shapes.
(cherry picked from commit e5edd50d62)
2016-10-09 17:22:48 +02:00
syskrank
4b2243f82e removed confusing "if(true)" statement with empty "else" block
(cherry picked from commit af4b0db1e4)
2016-10-09 17:22:36 +02:00
Pawel Kowal
6fc894d652 Tween reset/stop/resume/remove for all object properties at once
(cherry picked from commit acc242fd6a)
2016-10-09 17:22:16 +02:00
Andreas Haas
5adb75c2e7 Throw error when trying to emit a non-existing signal.
closes #6017

(cherry picked from commit 276087e92d)
2016-10-09 17:22:08 +02:00
Błażej Szczygieł
a827734e03 Don't crash in "_process_hdr()" if "framebuffer.luminance" is empty
If "glFramebufferTexture2D()" fails on old drivers the Vector is empty.
Don't allow to read from empty Vector (NULL pointer).

(cherry picked from commit 7b8fe97888)
2016-10-09 17:22:01 +02:00
Błażej Szczygieł
f4f5855168 Don't crach when OpenGL version is unsupported
(cherry picked from commit ca3b8deb78)
2016-10-09 17:21:48 +02:00
Błażej Szczygieł
f4da1e9ed2 Add compatibility with old OpenGL 2.1 drivers
If ARB_framebuffer_object is not supported, try to fall-back to
EXT_framebuffer_object if present.

In current version of godot, the way framebuffers are used is backward
compatible with the older EXT_framebuffer_object extension.

Fixes #6591
Done with SuperUserNameMan

(cherry picked from commit a27fafb273)
2016-10-09 17:21:41 +02:00
Emmanuel Leblond
a5fe7ffbcd Add CC parameter to allow use of custom C compiler
(cherry picked from commit cfd17de230)
2016-10-09 17:21:33 +02:00
Andreas Haas
02487a4be1 AnimationEditor: zoom using ctrl+wheel
closes #6585

(cherry picked from commit 3cce39c2d3)
2016-10-09 17:21:26 +02:00
romeojulietthotel
228ee4363e Use pkgconfig to locate ALSA libs (#6119)
* This allows building when ALSA libs are in a non-standard location. PKG_CONFIG_PATH alone is not enough as the final link fails. Adding this makes the final link succeed.

* The extra LIBS flag for alsa is not needed so removing.

(cherry picked from commit 94d6757a0d)
2016-10-09 17:21:17 +02:00
yg2f
36b1521cdc expose GeometryInstance.get_aabb() etc fixes #6587
expose ``GeometryInstance.get_aabb();`` to gdscript
expose ``VisualInstance.get_transformed_aabb();`` to gdscript
and debug ``ImmediateGeometry::add_vertex()``;

(cherry picked from commit c1e2358914)
2016-10-09 17:21:07 +02:00
Andreas Haas
d1ad94acf0 x11: Fix event.is_action() for release of modifier keys
The bug was that the release events for these also had the modifier state set, so the event comparison
failed.

Fixes #5901

(cherry picked from commit 6fcf2b2bd8)
2016-10-09 17:20:57 +02:00
George Marques
63b5a80088 Fix crash when disabling main screen plugin
(cherry picked from commit 0ec2b7baea)
2016-10-09 17:20:38 +02:00
Pedro J. Estébanez
45a5769162 Fix manifest generation bug in Android export
(cherry picked from commit 2c9d98bb48)
2016-10-09 17:20:27 +02:00
knd
b9399e93ad removed redundant assign operation in mesh_add_surface: elem_count is reassigned a value before the old one has been used.
(cherry picked from commit 708a028ce8)
2016-10-09 17:20:20 +02:00
Andreas Haas
33223e7a8a Add function to get readable names for joystick events
Closes #6476

(cherry picked from commit e0fcd9331a)
2016-10-09 17:19:57 +02:00
anneomcl
12edde80f2 Fix for #6158. Converting Vector2 to Size2 for scaling functions.
(cherry picked from commit aa5ade834c)
2016-10-09 17:18:54 +02:00
Pawel Kowal
c8299249e4 Show True/False tooltip in property editor for bool values
(cherry picked from commit 623c483eba)
2016-10-09 17:18:43 +02:00
George Marques
1d175be921 Add docs for XMLparser, VideoPlayer and most of Tree
(cherry picked from commit 7cd64c3c8d)
2016-10-09 17:18:36 +02:00
Andreas Haas
94e5c48004 Expose Vector2::clamped() to scripts
Needed this and wondered that there's no built-in function for it.
So I wanted to implement it and saw that it's actually already there, just wasn't bound ^^

(cherry picked from commit c21412fa7e)
2016-10-09 17:18:29 +02:00
Andreas Haas
4084ec4869 Make the choosable default editor layout the same as the actual default one.
Fixes #6266

(cherry picked from commit a2bff72eee)
2016-10-09 17:18:02 +02:00
Andreas Haas
d3b549f2a3 Fix ability to cut/paste text in LineEdit/TextEdit in readonly mode.
Fixes #6466

(cherry picked from commit 9c71e5a9df)
2016-10-09 17:17:54 +02:00
Pawel Kowal
4ca83c635f Add scrolling to Tree control in Drag and Drop mode
(cherry picked from commit 9e5aaa27bc)
2016-10-09 17:17:04 +02:00
Andreas Haas
e788ffff65 Fix input action pressed state not changing for quick joystick movements.
fixes #6488
Also removes a bunch of dead code related to checking if a joystick axis is pressed.

(cherry picked from commit 84783fe77b)
2016-10-09 17:16:19 +02:00
George Marques
6a0d47f34c Add a function to plugin get the main screen parent
- Fix a bug where the main screen button did not disappear when the plugin
  was deactivated.

(cherry picked from commit 98e7c1edba)
2016-10-09 17:12:15 +02:00
Brickcaster
e6d49fb54c Fix for issue #6496
Canged order of NOTIFICATION_DRAW to update scrollbar before scrollbar
is checked to see which list elements to display.

(cherry picked from commit cc7bc07e33)
2016-10-09 17:11:54 +02:00
Rémi Verschelde
eed5d878e8 classref: Sync with current source 2016-09-19 09:08:12 +02:00
Andreas Haas
521b5bd90f Update documentation on joystick vibration.
Added a note that long vibration durations are not recommended because of hardware limitations.
For example, my ps4 controller can only vibrate for ~3s on linux.

(cherry picked from commit cef70a5f8b)
2016-09-18 23:22:14 +02:00
Paulb23
8dca3f3f42 Fix highlight current script when script temputure is disabled
(cherry picked from commit fbd0b6f995)
2016-09-18 23:21:48 +02:00
Błażej Szczygieł
d2aa006ddb Vorbis: Don't compile unnecessary encoder files
(cherry picked from commit 222bc07874)
2016-09-18 23:21:36 +02:00
sanikoyes
ec32c33799 fix ScrollContainer cannot scroll when scroll bar is hidden
(cherry picked from commit b548ef0009)
2016-09-18 23:20:37 +02:00
Paulb23
9b9870ed9f Update current script color on change
(cherry picked from commit a0136838b3)
2016-09-18 23:19:58 +02:00
Juan Linietsky
a72945f4e3 Added constants from types in code completion, somehow this was never added.
Stuff like Label.ALIGN_CENTER or Mesh.PRIMITIVE_TRIANGLES did not complete..

(cherry picked from commit b83350f4b2)
2016-09-18 23:19:04 +02:00
Juan Linietsky
3ff8dea5f9 Fix Viewport.get_mouse_pos() for specific situations, closes #1885
(cherry picked from commit b16f41a10a)
2016-09-18 23:17:07 +02:00
Pawel Kowal
2b43d0a028 ScrollContainer expand children bug fix
(cherry picked from commit 853161a000)
2016-09-18 23:16:33 +02:00
George Marques
ee23649813 Fix the Windows environment in SCons spawn function
Properly fix #2974 as discussed there.

(cherry picked from commit aad87ab1b6)
2016-09-18 23:15:56 +02:00
sanikoyes
75f51aece9 Tween: fix non-repeat interpolate_callback does not delete after call triggered
(cherry picked from commit cccea7e0b4)
2016-09-18 23:15:43 +02:00
Ovnuniarchos
5653ac41f9 Mouse hotspot is not honored.
(cherry picked from commit 8fcd92c38a)
2016-09-18 23:15:32 +02:00
Ralf Hölzemer
6c22cab856 Move hardcoded theme colors from editor_node into editor_themes
(cherry picked from commit 991a433cb3)
2016-09-18 23:13:46 +02:00
Paulb23
71dc733ad2 Added ItemList get_v_scroll to docs
(cherry picked from commit 7d455fca71)
2016-09-18 23:13:40 +02:00
Paulb23
04ade4d639 Added get_v_scroll to item list, issue 5343
(cherry picked from commit 63fd8f863b)
2016-09-18 23:13:34 +02:00
Paulb23
20c3b35dd5 Added customisable grid color, issue 3781
(cherry picked from commit a82ecf6d80)
2016-09-18 23:13:13 +02:00
Andreas Haas
323dec7dd5 x11: fix x360 wireless gamepad mapping.
Uses hat values instead of buttons for the dpad now.
Fixes #6419

(cherry picked from commit 20bad652ef)
2016-09-18 23:13:06 +02:00
Gastronok
3b691907e9 Change the documentation to reflect that Directory.list_dir_begin()
returns true (not false) when a stream could not be initialized. (See, for
example,
https://github.com/godotengine/godot/blob/master/drivers/windows/dir_access_windows.cpp#L76
)

(cherry picked from commit cd82fafd58)
2016-09-18 23:12:55 +02:00
MarianoGNU
85eca7bc93 Explicitly initialize TextureProgress's initial angle value.
(Hopefully)
Fixes #3856
Fixes #6426
Fixes #6344

(cherry picked from commit ae4f7cbc2c)
2016-09-18 23:12:48 +02:00
bebae
2e6ce4b362 fixed wrong placement of AcceptDialog Buttons issue-6143
(cherry picked from commit dd9189aac4)
2016-09-18 23:12:39 +02:00
Paulb23
a1df4f138c Document itemlist disable tooltip
(cherry picked from commit 607d602493)
2016-09-18 23:12:30 +02:00
Paulb23
0aad82e921 Ability to disable item list tooltip, issue 6240
(cherry picked from commit 62a968b1c6)
2016-09-18 23:12:23 +02:00
Paulb23
aae720e488 Added setting to change current script background color, issue 5450
(cherry picked from commit 9e92fcaef9)
2016-09-18 23:12:15 +02:00
Geequlim
772a590261 Fix dialogs in ProjectManage don't with editor theme issue
(cherry picked from commit c1f23bb6af)
2016-09-18 23:11:50 +02:00
Pedro J. Estébanez
f90370886f Fix (potentially) Android libs packaging issue (#5645)
(cherry picked from commit e9065632c6)
2016-09-18 23:11:18 +02:00
Pedro J. Estébanez
c44757c2b7 Expose light shadow color to canvas item shaders
(cherry picked from commit 0960887625)
2016-09-18 23:11:08 +02:00
Pedro J. Estébanez
ffe5ecd67d Rename misleading define
The macro USE_LIGHT_SHADOW_COLOR actually was being defined when the shader used SHADOW (the output shadow color), not the shadow color set for the light so it's better named USE_OUTPUT_SHADOW_COLOR. In 3D there's not that difference but renaming as well for consistency.

(cherry picked from commit b69e422af9)
2016-09-18 23:10:26 +02:00
Juan Linietsky
e0ddef3164 Do not expose resource/ properties in sectioned property editor, closes #6396
(cherry picked from commit 0094c30938)
2016-09-18 23:10:14 +02:00
Juan Linietsky
7178399548 Added option for UVs (and tangents) in adding sphere for ImmediateGeometry, closes #6398
(cherry picked from commit f31400c04d)
2016-09-18 23:09:41 +02:00
supaiku
c007d31e52 Always show output panel when debugging
(cherry picked from commit 8514eaf34b)
2016-09-18 23:07:06 +02:00
supaiku
3f30a22cb0 Show object string cast instead of object id in debugger
(cherry picked from commit 0108e7c33a)
2016-09-18 23:06:51 +02:00
volzhs
d6dc8f4644 Select newly created folder on Directory dialog
(cherry picked from commit 28a0ed75ba)
2016-09-18 23:06:46 +02:00
Răzvan Cosmin Rădulescu
c4f79716d3 Clean up GDScript template
(cherry picked from commit 00e743b76a)
2016-09-18 23:05:45 +02:00
Kazuo256
4a9461fded Add http method and request data parameters
For HTTPRequest::request

(cherry picked from commit c53e5c555a)
2016-09-18 23:05:40 +02:00
Rémi Verschelde
49dd7b38bc Remove tools/script_plugins, demos of the old plugin API
They are superseded by the official demos in
https://github.com/godotengine/godot-demo-projects/tree/master/plugins

(cherry picked from commit 3b3502b758)
2016-09-18 23:05:16 +02:00
Rémi Verschelde
bfcfb58efc Merge tools/docdump in tools/doc
Reduces clutter in the tools folder.

(cherry picked from commit 6a4ba76836)
2016-09-18 23:05:07 +02:00
Rémi Verschelde
ed96689d8c Move various scripts to the "scripts" folder
Thus cleaning up the "tools" folder a bit.

(cherry picked from commit ae9729b6df)
2016-09-18 23:05:00 +02:00
Rémi Verschelde
125a9f0b06 Remove obsolete Win32 libraries that everyone had forgotten about
(cherry picked from commit 08e5e8794a)
2016-09-18 23:04:52 +02:00
Rémi Verschelde
fd58f8dce8 Move templates and distribution stuff to tools/dist
Also removed the obsolete iOS xcode template.

(cherry picked from commit 3efe1231f0)
2016-09-18 23:04:26 +02:00
Andreas Haas
adcf45b627 Update gamepad mappings from community db.
(cherry picked from commit 808bd53934)
2016-09-18 23:03:22 +02:00
Rémi Verschelde
48d1e8bd4e InputEvent: Fix event comparisons when type is NONE
Was a regression from 2e5a4cb5ca.
Fixes #6376.

(cherry picked from commit eff6519aaf)
2016-09-18 23:03:10 +02:00
Waldson Patrício
73b40d1457 Fixes LineEdit text selection with mouse selecting more than intended
(cherry picked from commit 3d84973184)
2016-09-18 23:02:57 +02:00
Joscha
e7772e43d3 Tilemap editor: Bucket tool - allow deleting and replacing of tiles
(cherry picked from commit acd41d964a)
2016-09-18 23:02:46 +02:00
Rémi Verschelde
de5f49aac5 i18n: Update list of supported locales based off glibc
Fixes #5733, fixes #6214.

(cherry picked from commit 54e97e5ee6)
2016-09-18 23:02:14 +02:00
Rémi Verschelde
2ab7e6daab i18n: Sync translations from Weblate
Translator credits added manually based on Weblate git log.
Adds Catalan, Danish and Norwegian Bokmål initial translations.

Those were initially translations for the master branch, merged
against the 2.1 template.
2016-09-01 19:33:28 +02:00
Rémi Verschelde
68c7da5a35 classref: Sync with current source 2016-09-01 18:56:48 +02:00
Mark Nokalt
a3a065b458 editor: Add mouse position information in TileMap
(cherry picked from commit cd71fcb097)
2016-09-01 08:46:23 +02:00
Mario Schlack
9ea76ff46d Hide the mouse cursor when MOUSE_MODE_CAPTURED is activated.
(cherry picked from commit f0b6a242cc)
2016-09-01 08:46:03 +02:00
Andreas Haas
cd6afd5f1d Fix crash when trying to access the guid of an unavailable Gamepad.
Throws an error now.

(cherry picked from commit 02a8604906)
2016-09-01 08:45:51 +02:00
volzhs
265715f5b2 Show last added action on Input Map and implement InputEvent "=="
(cherry picked from commit 2e5a4cb5ca)
2016-09-01 08:45:37 +02:00
volzhs
cd8beea3bf Prevent to add node to selection when node is not inside tree
(cherry picked from commit 4857eabddb)
2016-09-01 08:45:15 +02:00
George Marques
0657d43960 Better document the BaseButton signals
(cherry picked from commit 141360ed82)
2016-09-01 08:44:52 +02:00
George Marques
a21b9caa2a Add button_down and button_up signals
(cherry picked from commit 8a1b1ab6d6)
2016-09-01 08:44:45 +02:00
caryoscelus
83864514f9 fix string iterator
Since strings are null-terminated, size() returns incorrect length,
so use length() instead.

fixes #6287

(cherry picked from commit 810fbb70ae)
2016-09-01 08:44:30 +02:00
Ignacio Etcheverry
b1ea299edf Matrix32: Add constructor that takes six real_t params
(cherry picked from commit 3578800230)
2016-09-01 08:44:22 +02:00
Ignacio Etcheverry
103b04e529 DocData: Fix null reference not detected correctly
(cherry picked from commit b81725b203)
2016-09-01 08:44:08 +02:00
Mason Ashbridge
07caf4438d Slider value accounts for grabber offset
(cherry picked from commit fb54ba6397)
2016-09-01 08:43:59 +02:00
volzhs
6df46803a7 Make LineEdit not to cover whole line when rename node
(cherry picked from commit ff22db3b21)
2016-09-01 08:42:49 +02:00
Pedro J. Estébanez
cccc35e427 Improve/fix GridMap editor
Fix cursor/palette update on tile eyedropping
Fix editor not cleaning its state when becoming inactive, which leaves indicators behind among other issues
Fix/improve menu/keyboard shortcuts
Merge 'Gridmap Editor' and 'Grid Map' settings into the latter

(cherry picked from commit 7d35973486)
2016-09-01 08:41:31 +02:00
Gau o fthe Veldt
fa1f5e55de Documentation for most of ItemList control.
The icon stuff is incomplete since I haven't used icons.

(cherry picked from commit f9e931bf12)
2016-09-01 08:41:18 +02:00
Ignacio Etcheverry
6a563949c7 DocData: Fix duplicated parenthesis for default values
(cherry picked from commit 9e6b53c8dd)
2016-09-01 08:41:12 +02:00
Franklin Sobrinho
f9aeb91850 Implemented UndoRedo mergeable modes
(cherry picked from commit debf574df3)
2016-09-01 08:41:04 +02:00
Franklin Sobrinho
71a9efe604 Update Globals and EditorSettings docs
(cherry picked from commit 038e99e107)
2016-09-01 08:40:54 +02:00
Franklin Sobrinho
5f9e6d2b48 Added add_property_info function to Globals and EditorSettings classes
(cherry picked from commit 9f242ed6e5)
2016-09-01 08:40:49 +02:00
Franklin Sobrinho
6327fc47c8 Better editor settings for the FileSystem dock
* Save the current display mode when changing it from the dock

(cherry picked from commit f6b39827b1)
2016-09-01 08:40:23 +02:00
Franklin Sobrinho
3cbd6b8701 Fix editor glitches when the mesh/material preview is shown
(cherry picked from commit a4c3d2dc89)
2016-09-01 08:40:16 +02:00
Franklin Sobrinho
4890db7fef Small usability improvements on the TileMap editor tile palette.
* The column width changes with the zoom, now the icons don't overlap.
  * Added a tile hsepation setting.
  * Added a setting to show/hide tile names.

(cherry picked from commit 0fa26cd850)
2016-09-01 08:40:08 +02:00
Franklin Sobrinho
df3d2b25d8 Update EditorPlugin doc
(cherry picked from commit a27d2e4c29)
2016-09-01 08:39:58 +02:00
Franklin Sobrinho
743c63670e Expose additional functions for the EditorPlugin class
(cherry picked from commit 104653f9eb)
2016-09-01 08:39:52 +02:00
Daniel J. Ramirez
e26acc39da 2d collision shape icons now uses the color for shape icons
(cherry picked from commit cbad6b3fae)
2016-09-01 08:39:09 +02:00
Ignacio Etcheverry
1a53c4d3c2 Confirm code completion with numpad key ENTER
(cherry picked from commit e9f9e00bd9)
2016-09-01 08:38:34 +02:00
Andreas Haas
37fc61f986 x11: Use proper sonames for loading libXrandr.
(cherry picked from commit f59860f464)
2016-09-01 08:38:24 +02:00
Daniel J. Ramirez
16fc229e5d Zoom texture region via mouse wheel
(cherry picked from commit 1e7d0c6ac1)
2016-09-01 08:37:55 +02:00
Ignacio Etcheverry
4f07998552 Device Input dialog now uses containers
(cherry picked from commit 9483d3cbf9)
2016-09-01 08:34:05 +02:00
Rémi Verschelde
3b7ab73cab i18n: Merge PO files with current template 2016-08-10 21:31:06 +02:00
Rémi Verschelde
bbb543735c i18n: Sync template with current source 2016-08-10 21:30:57 +02:00
Rémi Verschelde
ed931d3b59 i18n: Sync translations from Weblate
Translator credits added manually based on Weblate git log.

(cherry picked from commit 221d81a26d)
2016-08-10 21:28:05 +02:00
Rémi Verschelde
720305d98e classref: Sync with current source 2016-08-10 21:28:01 +02:00
Rémi Verschelde
676b60a8b5 i18n: Add a README file to point to the Weblate repo
(cherry picked from commit 807c615148)
2016-08-10 21:27:45 +02:00
marcelofg55
0c76ba32cc Crashfix for OSX on Sierra beta
(cherry picked from commit bf320fd4ea)
2016-08-09 18:47:13 +02:00
Rémi Verschelde
c5e2c83dcd Release 2.1-stable
\o/
2016-08-09 09:52:15 +02:00
Rémi Verschelde
9cc700a0ab OSX Info.plist: no longer dev version
This should really be dehardcoded somehow.
2016-08-09 09:51:58 +02:00
Juan Linietsky
569966f3bb prevent bug due to scripts not working in editor and notifier sending signals to it.
(cherry picked from commit 37b5e99bc2)
2016-08-09 00:13:31 +02:00
Juan Linietsky
58556f5f95 Fixed bug in make_dir_recursive, closes #6016
(cherry picked from commit df6dbadc3e)
2016-08-08 23:45:39 +02:00
Rémi Verschelde
229b172977 Merge pull request #6078 from eska014/2.1-fix-call_func
Revert documentation of return type for FuncRef::call_func from b80c42e
2016-08-08 18:23:43 +02:00
Skyfrit
c56ea7cf91 Android: Rename values-zh to values-zh-rCN (#6063)
(cherry picked from commit 4f6a21b0df)
2016-08-08 18:15:55 +02:00
Skyfrit
1913e4a040 Android: Add support for Traditional Chinese (HK) (#6061)
(cherry picked from commit 664b5b5137)
2016-08-08 18:15:49 +02:00
Skyfrit
2b35ba4815 Android: Add support for Traditional Chinese (TW) (#6061)
(cherry picked from commit 8ab4acd17f)
2016-08-08 18:15:43 +02:00
Ignacio Etcheverry
d853eb2fb7 Project Manager: Fix and improve unhandled input
(cherry picked from commit f3a75a42dd)
2016-08-08 18:15:03 +02:00
Andreas Haas
36eeedb357 Remove unused function in Project Manager.
This has been deprecated by #5993

(cherry picked from commit 0df40cc29b)
2016-08-08 18:14:57 +02:00
Andreas Haas
5f18c5cb46 Fix steam controller gamepad mapping
The left stick click was missing

(cherry picked from commit e52567bd29)
2016-08-08 18:14:51 +02:00
Bojidar Marinov
f25e9a08e1 Fix #5891 by not expecting the script instance to be a GDInstance
It could be a placeholder instance as well

(cherry picked from commit 76ea995228)
2016-08-08 18:14:44 +02:00
MSC
4f8f9a4dbf Some additions to the OS documentation (#6037)
(cherry picked from commit 7b05b4c83c)
2016-08-08 18:14:35 +02:00
Saracen
dd97502788 TextureRegionEditor snap_mode fix.
(cherry picked from commit b578cf4da8)
2016-08-08 18:14:29 +02:00
Hubert Jarosz
d55304c56f [ci skip] update Raycast documentation
clarification that set_cast_to needs LOCAL point
and get_collision_point gives GLOBAL point

(cherry picked from commit 1445553fea)
2016-08-08 18:14:14 +02:00
eska
03a4b8cbc8 Revert documentation of return type for FuncRef::call_func from b80c42e
bind_native_method doesn't support this style of return type documentation.
2016-08-08 17:49:30 +02:00
Rémi Verschelde
2f0df52fe7 Bump version to 2.1-rc2 2016-08-03 17:53:53 +02:00
marcelofg55
fd6f62fd9a Fix set_window_size not setting the correct size on OSX
(cherry picked from commit 38de4d24ef)
2016-08-03 17:52:10 +02:00
2894 changed files with 39181 additions and 64427 deletions

View File

@@ -69,8 +69,8 @@ addons:
before_script:
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew update; brew install scons; fi
- if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$GODOT_TARGET" = "android" ]; then
brew update; brew install -v android-sdk;
brew install -v android-ndk | grep -v "inflating:" | grep -v "creating:";
brew update; travis_wait 20 brew install -v android-sdk;
travis_wait 20 brew install -v android-ndk | grep -v "inflating:" | grep -v "creating:";
export ANDROID_HOME=/usr/local/opt/android-sdk; export ANDROID_NDK_ROOT=/usr/local/opt/android-ndk;
fi

View File

@@ -1,30 +1,66 @@
![GODOT](/logo.png)
[![GODOT](/logo.png)](https://godotengine.org)
https://godotengine.org
## Godot Engine
### The Engine
Homepage: https://godotengine.org
Godot is a fully featured, open source, MIT licensed, game engine. It focuses on having great tools, and a visual oriented workflow that can export to PC, Mobile and Web platforms with no hassle.
The editor, language and APIs are feature rich, yet simple to learn, allowing you to become productive in a matter of hours.
#### 2D and 3D cross-platform game engine
### About
Godot Engine is a feature-packed, cross-platform game engine to create 2D and
3D games from a unified interface. It provides a comprehensive set of common
tools, so that users can focus on making games without having to reinvent the
wheel. Games can be exported in one click to a number of platforms, including
the major desktop platforms (Linux, Mac OSX, Windows) as well as mobile
(Android, iOS) and web-based (HTML5) platforms.
Godot has been developed by Juan Linietsky and Ariel Manzur for several years, and was born as an in-house engine, used to publish several work-for-hire titles. Godot is a member project of the [Software Freedom Conservancy](https://sfconservancy.org)
#### Free, open source and community-driven
### Documentation
Godot is completely free and open source under the very permissive MIT license.
No strings attached, no royalties, nothing. The users' games are theirs, down
to the last line of engine code. Godot's development is fully independent and
community-driven, empowering users to help shape their engine to match their
expectations. It is supported by the Software Freedom Conservancy
not-for-profit.
Documentation is hosted on [ReadTheDocs](http://docs.godotengine.org).
Before being open sourced in February 2014, Godot had been developed by Juan
Linietsky and Ariel Manzur (both still maintaining the project) for several
years as an in-house engine, used to publish several work-for-hire titles.
### Binary Downloads, Community, etc.
### Getting the engine
Binary downloads, community, etc. can be found in Godot homepage:
#### Binary downloads
https://godotengine.org
Official binaries for the Godot editor and the export templates can be found
[on the homepage](https://godotengine.org/download).
### Compiling from Source
#### Compiling from source
See docs for compilation instructions for every platform:
http://docs.godotengine.org/en/latest/reference/_compiling.html
[See the official docs](http://docs.godotengine.org/en/latest/reference/_compiling.html)
for compilation instructions for every supported platform.
### Community
Godot is not only an engine but an ever-growing community of users and engine
developers. The main community channels are listed [on the homepage](https://godotengine.org/community).
To get in touch with the developers, the best way is to join the
[#godotengine IRC channel](https://webchat.freenode.net/?channels=godotengine)
on Freenode.
### Documentation and demos
The official documentation is hosted on [ReadTheDocs](http://docs.godotengine.org).
It is maintained by the Godot community in its own [GitHub repository](https://github.com/godotengine/godot-docs).
The [class reference](http://docs.godotengine.org/en/latest/classes/_classes.html)
is also accessible from within the engine.
The official demos are maintained in their own [GitHub repository](https://github.com/godotengine/godot-demo-projects)
as well.
There are also a number of other learning resources provided by the community,
such as text and video tutorials, demos, etc. Consult the [community channels](https://godotengine.org/community)
for more info.
[![Build Status](https://travis-ci.org/godotengine/godot.svg?branch=master)](https://travis-ci.org/godotengine/godot)
[![Code Triagers Badge](http://www.codetriage.com/godotengine/godot/badges/users.svg)](http://www.codetriage.com/godotengine/godot)

View File

@@ -1,4 +1,6 @@
EnsureSConsVersion(0,14);
#!/usr/bin/env python
EnsureSConsVersion(0, 14)
import string
@@ -12,84 +14,85 @@ methods.update_version()
# scan possible build platforms
platform_list = [] # list of platforms
platform_opts = {} # options for each platform
platform_flags = {} # flags for each platform
platform_list = [] # list of platforms
platform_opts = {} # options for each platform
platform_flags = {} # flags for each platform
active_platforms=[]
active_platform_ids=[]
platform_exporters=[]
global_defaults=[]
active_platforms = []
active_platform_ids = []
platform_exporters = []
global_defaults = []
for x in glob.glob("platform/*"):
if (not os.path.isdir(x) or not os.path.exists(x+"/detect.py")):
continue
tmppath="./"+x
if (not os.path.isdir(x) or not os.path.exists(x + "/detect.py")):
continue
tmppath = "./" + x
sys.path.append(tmppath)
import detect
sys.path.append(tmppath)
import detect
if (os.path.exists(x+"/export/export.cpp")):
platform_exporters.append(x[9:])
if (os.path.exists(x+"/globals/global_defaults.cpp")):
global_defaults.append(x[9:])
if (detect.is_active()):
active_platforms.append( detect.get_name() )
active_platform_ids.append(x);
if (detect.can_build()):
x=x.replace("platform/","") # rest of world
x=x.replace("platform\\","") # win32
platform_list+=[x]
platform_opts[x]=detect.get_opts()
platform_flags[x]=detect.get_flags()
sys.path.remove(tmppath)
sys.modules.pop('detect')
if (os.path.exists(x + "/export/export.cpp")):
platform_exporters.append(x[9:])
if (os.path.exists(x + "/globals/global_defaults.cpp")):
global_defaults.append(x[9:])
if (detect.is_active()):
active_platforms.append(detect.get_name())
active_platform_ids.append(x)
if (detect.can_build()):
x = x.replace("platform/", "") # rest of world
x = x.replace("platform\\", "") # win32
platform_list += [x]
platform_opts[x] = detect.get_opts()
platform_flags[x] = detect.get_flags()
sys.path.remove(tmppath)
sys.modules.pop('detect')
module_list=methods.detect_modules()
module_list = methods.detect_modules()
#print "Detected Platforms: "+str(platform_list)
# print "Detected Platforms: "+str(platform_list)
methods.save_active_platforms(active_platforms,active_platform_ids)
methods.save_active_platforms(active_platforms, active_platform_ids)
custom_tools=['default']
custom_tools = ['default']
platform_arg = ARGUMENTS.get("platform", False)
platform_arg = ARGUMENTS.get("platform", ARGUMENTS.get("p", False))
if (os.name=="posix"):
pass
elif (os.name=="nt"):
if (os.getenv("VSINSTALLDIR")==None or platform_arg=="android"):
custom_tools=['mingw']
if (os.name == "posix"):
pass
elif (os.name == "nt"):
if (os.getenv("VSINSTALLDIR") == None or platform_arg == "android"):
custom_tools = ['mingw']
env_base=Environment(tools=custom_tools);
env_base = Environment(tools=custom_tools)
if 'TERM' in os.environ:
env_base['ENV']['TERM'] = os.environ['TERM']
env_base.AppendENVPath('PATH', os.getenv('PATH'))
env_base.AppendENVPath('PKG_CONFIG_PATH', os.getenv('PKG_CONFIG_PATH'))
env_base.global_defaults=global_defaults
env_base.android_maven_repos=[]
env_base.android_dependencies=[]
env_base.android_java_dirs=[]
env_base.android_res_dirs=[]
env_base.android_aidl_dirs=[]
env_base.android_jni_dirs=[]
env_base.android_default_config=[]
env_base.android_manifest_chunk=""
env_base.android_permission_chunk=""
env_base.android_appattributes_chunk=""
env_base.disabled_modules=[]
env_base.use_ptrcall=False
env_base.split_drivers=False
env_base.global_defaults = global_defaults
env_base.android_maven_repos = []
env_base.android_dependencies = []
env_base.android_java_dirs = []
env_base.android_res_dirs = []
env_base.android_aidl_dirs = []
env_base.android_jni_dirs = []
env_base.android_default_config = []
env_base.android_manifest_chunk = ""
env_base.android_permission_chunk = ""
env_base.android_appattributes_chunk = ""
env_base.disabled_modules = []
env_base.use_ptrcall = False
env_base.split_drivers = False
env_base.__class__.android_add_maven_repository=methods.android_add_maven_repository
env_base.__class__.android_add_dependency=methods.android_add_dependency
env_base.__class__.android_add_java_dir=methods.android_add_java_dir
env_base.__class__.android_add_res_dir=methods.android_add_res_dir
env_base.__class__.android_add_aidl_dir=methods.android_add_aidl_dir
env_base.__class__.android_add_jni_dir=methods.android_add_jni_dir
env_base.__class__.android_add_default_config=methods.android_add_default_config
env_base.__class__.android_add_maven_repository = methods.android_add_maven_repository
env_base.__class__.android_add_dependency = methods.android_add_dependency
env_base.__class__.android_add_java_dir = methods.android_add_java_dir
env_base.__class__.android_add_res_dir = methods.android_add_res_dir
env_base.__class__.android_add_aidl_dir = methods.android_add_aidl_dir
env_base.__class__.android_add_jni_dir = methods.android_add_jni_dir
env_base.__class__.android_add_default_config = methods.android_add_default_config
env_base.__class__.android_add_to_manifest = methods.android_add_to_manifest
env_base.__class__.android_add_to_permissions = methods.android_add_to_permissions
env_base.__class__.android_add_to_attributes = methods.android_add_to_attributes
@@ -97,78 +100,92 @@ env_base.__class__.disable_module = methods.disable_module
env_base.__class__.add_source_files = methods.add_source_files
env_base.__class__.use_windows_spawn_fix = methods.use_windows_spawn_fix
env_base.__class__.split_lib = methods.split_lib
env_base["x86_opt_gcc"]=False
env_base["x86_opt_vc"]=False
env_base["armv7_opt_gcc"]=False
env_base["x86_libtheora_opt_gcc"] = False
env_base["x86_libtheora_opt_vc"] = False
# Build options
customs = ['custom.py']
profile = ARGUMENTS.get("profile", False)
if profile:
import os.path
if os.path.isfile(profile):
customs.append(profile)
elif os.path.isfile(profile+".py"):
customs.append(profile+".py")
import os.path
if os.path.isfile(profile):
customs.append(profile)
elif os.path.isfile(profile + ".py"):
customs.append(profile + ".py")
opts = Variables(customs, ARGUMENTS)
# Target build options
opts.Add('arch', "Platform-dependent architecture (arm/arm64/x86/x64/mips/etc)", '')
opts.Add('bits', "Target platform bits (default/32/64/fat)", 'default')
opts.Add('p', "Platform (alias for 'platform')", '')
opts.Add('platform', "Target platform: any in " + str(platform_list), '')
opts.Add('target', "Compilation target (debug/release_debug/release)", 'debug')
opts.Add('tools', "Build the tools a.k.a. the Godot editor (yes/no)", 'yes')
# Components
opts.Add('deprecated', "Enable deprecated features (yes/no)", 'yes')
opts.Add('gdscript', "Build GDSCript support (yes/no)", 'yes')
opts.Add('minizip', "Build minizip archive support (yes/no)", 'yes')
opts.Add('xml', "XML format support for resources (yes/no)", 'yes')
# Advanced options
opts.Add('disable_3d', "Disable 3D nodes for smaller executable (yes/no)", 'no')
opts.Add('disable_advanced_gui', "Disable advance 3D gui nodes and behaviors (yes/no)", 'no')
opts.Add('extra_suffix', "Custom extra suffix added to the base filename of all generated binary files", '')
opts.Add('unix_global_settings_path', "UNIX-specific path to system-wide settings. Currently only used for templates", '')
opts.Add('verbose', "Enable verbose output for the compilation (yes/no)", 'yes')
opts.Add('vsproj', "Generate Visual Studio Project. (yes/no)", 'no')
# Thirdparty libraries
opts.Add('builtin_freetype', "Use the builtin freetype library (yes/no)", 'yes')
opts.Add('builtin_glew', "Use the builtin glew library (yes/no)", 'yes')
opts.Add('builtin_libmpcdec', "Use the builtin libmpcdec library (yes/no)", 'yes')
opts.Add('builtin_libogg', "Use the builtin libogg library (yes/no)", 'yes')
opts.Add('builtin_libpng', "Use the builtin libpng library (yes/no)", 'yes')
opts.Add('builtin_libtheora', "Use the builtin libtheora library (yes/no)", 'yes')
opts.Add('builtin_libvorbis', "Use the builtin libvorbis library (yes/no)", 'yes')
opts.Add('builtin_libwebp', "Use the builtin libwebp library (yes/no)", 'yes')
opts.Add('builtin_openssl', "Use the builtin openssl library (yes/no)", 'yes')
opts.Add('builtin_opus', "Use the builtin opus library (yes/no)", 'yes')
# (akien) Unbundling would require work in audio_stream_speex.{cpp,h}, but since speex was
# removed in 3.0+ and this is only to preserve compatibility in 2.1, I haven't worked on it.
# Patches welcome if anyone cares :)
opts.Add('builtin_speex', "Use the builtin speex library (yes/no)", 'yes')
opts.Add('builtin_squish', "Use the builtin squish library (yes/no)", 'yes')
opts.Add('builtin_zlib', "Use the builtin zlib library (yes/no)", 'yes')
# Environment setup
opts.Add("CXX", "C++ compiler")
opts.Add("CC", "C compiler")
opts.Add("CCFLAGS", "Custom flags for the C and C++ compilers")
opts.Add("CFLAGS", "Custom flags for the C compiler")
opts.Add("LINKFLAGS", "Custom flags for the linker")
opts=Variables(customs, ARGUMENTS)
opts.Add('target', 'Compile Target (debug/release_debug/release).', "debug")
opts.Add('arch', 'Platform dependent architecture (arm/arm64/x86/x64/mips/etc)', "")
opts.Add('bits', 'Compile Target Bits (default/32/64/fat).', "default")
opts.Add('platform','Platform: '+str(platform_list)+'.',"")
opts.Add('p','Platform (same as platform=).',"")
opts.Add('tools','Build Tools (Including Editor): (yes/no)','yes')
opts.Add('gdscript','Build GDSCript support: (yes/no)','yes')
opts.Add('vorbis','Build Ogg Vorbis Support: (yes/no)','yes')
opts.Add('opus','Build Opus Audio Format Support: (yes/no)','yes')
opts.Add('minizip','Build Minizip Archive Support: (yes/no)','yes')
opts.Add('squish','Squish BC Texture Compression in editor (yes/no)','yes')
opts.Add('theora','Theora Video (yes/no)','yes')
opts.Add('theoralib','Theora Video (yes/no)','no')
opts.Add('freetype','Freetype support in editor','builtin')
opts.Add('speex','Speex Audio (yes/no)','yes')
opts.Add('xml','XML Save/Load support (yes/no)','yes')
opts.Add('png','PNG Image loader support (yes/no)','yes')
opts.Add('jpg','JPG Image loader support (yes/no)','yes')
opts.Add('webp','WEBP Image loader support (yes/no)','yes')
opts.Add('dds','DDS Texture loader support (yes/no)','yes')
opts.Add('pvr','PVR (PowerVR) Texture loader support (yes/no)','yes')
opts.Add('etc1','etc1 Texture compression support (yes/no)','yes')
opts.Add('builtin_zlib','Use built-in zlib (yes/no)','yes')
opts.Add('openssl','Use OpenSSL (yes/no/builtin)','no')
opts.Add('musepack','Musepack Audio (yes/no)','yes')
opts.Add("CXX", "Compiler");
opts.Add("CCFLAGS", "Custom flags for the C++ compiler");
opts.Add("CFLAGS", "Custom flags for the C compiler");
opts.Add("LINKFLAGS", "Custom flags for the linker");
opts.Add('unix_global_settings_path', 'unix-specific path to system-wide settings. Currently only used by templates.','')
opts.Add('disable_3d', 'Disable 3D nodes for smaller executable (yes/no)', "no")
opts.Add('disable_advanced_gui', 'Disable advance 3D gui nodes and behaviors (yes/no)', "no")
opts.Add('colored', 'Enable colored output for the compilation (yes/no)', 'no')
opts.Add('deprecated','Enable deprecated features (yes/no)','yes')
opts.Add('extra_suffix', 'Custom extra suffix added to the base filename of all generated binary files.', '')
opts.Add('vsproj', 'Generate Visual Studio Project. (yes/no)', 'no')
# add platform specific options
for k in platform_opts.keys():
opt_list = platform_opts[k]
for o in opt_list:
opts.Add(o[0],o[1],o[2])
opt_list = platform_opts[k]
for o in opt_list:
opts.Add(o[0], o[1], o[2])
for x in module_list:
opts.Add('module_'+x+'_enabled', "Enable module '"+x+"'.", "yes")
opts.Add('module_' + x + '_enabled', "Enable module '" + x + "' (yes/no)", "yes")
opts.Update(env_base) # update environment
Help(opts.GenerateHelpText(env_base)) # generate help
opts.Update(env_base) # update environment
Help(opts.GenerateHelpText(env_base)) # generate help
# add default include paths
env_base.Append(CPPPATH=['#core','#core/math','#tools','#drivers','#'])
env_base.Append(CPPPATH=['#core', '#core/math', '#tools', '#drivers', '#'])
# configure ENV for platform
env_base.platform_exporters=platform_exporters
env_base.platform_exporters = platform_exporters
"""
sys.path.append("./platform/"+env_base["platform"])
@@ -178,276 +195,223 @@ sys.path.remove("./platform/"+env_base["platform"])
sys.modules.pop('detect')
"""
if (env_base['target']=='debug'):
env_base.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC']);
env_base.Append(CPPFLAGS=['-DSCI_NAMESPACE'])
if (env_base['target'] == 'debug'):
env_base.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC'])
env_base.Append(CPPFLAGS=['-DSCI_NAMESPACE'])
if (env_base['deprecated']!='no'):
env_base.Append(CPPFLAGS=['-DENABLE_DEPRECATED']);
if (env_base['deprecated'] != 'no'):
env_base.Append(CPPFLAGS=['-DENABLE_DEPRECATED'])
env_base.platforms = {}
selected_platform =""
selected_platform = ""
if env_base['platform'] != "":
selected_platform=env_base['platform']
selected_platform = env_base['platform']
elif env_base['p'] != "":
selected_platform=env_base['p']
env_base["platform"]=selected_platform
selected_platform = env_base['p']
env_base["platform"] = selected_platform
if selected_platform in platform_list:
sys.path.append("./platform/"+selected_platform)
import detect
if "create" in dir(detect):
env = detect.create(env_base)
else:
env = env_base.Clone()
sys.path.append("./platform/" + selected_platform)
import detect
if "create" in dir(detect):
env = detect.create(env_base)
else:
env = env_base.Clone()
if env['vsproj']=="yes":
env.vs_incs = []
env.vs_srcs = []
if env['vsproj'] == "yes":
env.vs_incs = []
env.vs_srcs = []
def AddToVSProject( sources ):
for x in sources:
if type(x) == type(""):
fname = env.File(x).path
else:
fname = env.File(x)[0].path
pieces = fname.split(".")
if len(pieces)>0:
basename = pieces[0]
basename = basename.replace('\\\\','/')
env.vs_srcs = env.vs_srcs + [basename + ".cpp"]
env.vs_incs = env.vs_incs + [basename + ".h"]
#print basename
env.AddToVSProject = AddToVSProject
def AddToVSProject(sources):
for x in sources:
if type(x) == type(""):
fname = env.File(x).path
else:
fname = env.File(x)[0].path
pieces = fname.split(".")
if len(pieces) > 0:
basename = pieces[0]
basename = basename.replace('\\\\', '/')
env.vs_srcs = env.vs_srcs + [basename + ".cpp"]
env.vs_incs = env.vs_incs + [basename + ".h"]
# print basename
env.AddToVSProject = AddToVSProject
env.extra_suffix=""
env.extra_suffix = ""
if env["extra_suffix"] != '' :
env.extra_suffix += '.'+env["extra_suffix"]
if env["extra_suffix"] != '':
env.extra_suffix += '.' + env["extra_suffix"]
CCFLAGS = env.get('CCFLAGS', '')
env['CCFLAGS'] = ''
CCFLAGS = env.get('CCFLAGS', '')
env['CCFLAGS'] = ''
env.Append(CCFLAGS=string.split(str(CCFLAGS)))
env.Append(CCFLAGS=string.split(str(CCFLAGS)))
CFLAGS = env.get('CFLAGS', '')
env['CFLAGS'] = ''
CFLAGS = env.get('CFLAGS', '')
env['CFLAGS'] = ''
env.Append(CFLAGS=string.split(str(CFLAGS)))
env.Append(CFLAGS=string.split(str(CFLAGS)))
LINKFLAGS = env.get('LINKFLAGS', '')
env['LINKFLAGS'] = ''
LINKFLAGS = env.get('LINKFLAGS', '')
env['LINKFLAGS'] = ''
env.Append(LINKFLAGS=string.split(str(LINKFLAGS)))
env.Append(LINKFLAGS=string.split(str(LINKFLAGS)))
flag_list = platform_flags[selected_platform]
for f in flag_list:
if not (f[0] in ARGUMENTS): # allow command line to override platform flags
env[f[0]] = f[1]
flag_list = platform_flags[selected_platform]
for f in flag_list:
if not (f[0] in ARGUMENTS): # allow command line to override platform flags
env[f[0]] = f[1]
#must happen after the flags, so when flags are used by configure, stuff happens (ie, ssl on x11)
detect.configure(env)
# must happen after the flags, so when flags are used by configure, stuff happens (ie, ssl on x11)
detect.configure(env)
#env['platform_libsuffix'] = env['LIBSUFFIX']
if (env["freetype"]!="no"):
env.Append(CCFLAGS=['-DFREETYPE_ENABLED'])
if (env["freetype"]=="builtin"):
env.Append(CPPPATH=['#drivers/freetype'])
env.Append(CPPPATH=['#drivers/freetype/freetype/include'])
suffix = "." + selected_platform
if (env["target"] == "release"):
if (env["tools"] == "yes"):
print("Tools can only be built with targets 'debug' and 'release_debug'.")
sys.exit(255)
suffix += ".opt"
#env['platform_libsuffix'] = env['LIBSUFFIX']
env.Append(CCFLAGS=['-DNDEBUG'])
suffix="."+selected_platform
elif (env["target"] == "release_debug"):
if (env["tools"] == "yes"):
suffix += ".opt.tools"
else:
suffix += ".opt.debug"
else:
if (env["tools"] == "yes"):
suffix += ".tools"
else:
suffix += ".debug"
if (env["target"]=="release"):
if (env["tools"]=="yes"):
print("Tools can only be built with targets 'debug' and 'release_debug'.")
sys.exit(255)
suffix+=".opt"
if env["arch"] != "":
suffix += "." + env["arch"]
elif (env["bits"] == "32"):
suffix += ".32"
elif (env["bits"] == "64"):
suffix += ".64"
elif (env["bits"] == "fat"):
suffix += ".fat"
elif (env["target"]=="release_debug"):
if (env["tools"]=="yes"):
suffix+=".opt.tools"
else:
suffix+=".opt.debug"
else:
if (env["tools"]=="yes"):
suffix+=".tools"
else:
suffix+=".debug"
suffix += env.extra_suffix
if env["arch"] != "":
suffix += "."+env["arch"]
elif (env["bits"]=="32"):
suffix+=".32"
elif (env["bits"]=="64"):
suffix+=".64"
elif (env["bits"]=="fat"):
suffix+=".fat"
env["PROGSUFFIX"] = suffix + env["PROGSUFFIX"]
env["OBJSUFFIX"] = suffix + env["OBJSUFFIX"]
env["LIBSUFFIX"] = suffix + env["LIBSUFFIX"]
env["SHLIBSUFFIX"] = suffix + env["SHLIBSUFFIX"]
suffix+=env.extra_suffix
sys.path.remove("./platform/" + selected_platform)
sys.modules.pop('detect')
env["PROGSUFFIX"]=suffix+env["PROGSUFFIX"]
env["OBJSUFFIX"]=suffix+env["OBJSUFFIX"]
env["LIBSUFFIX"]=suffix+env["LIBSUFFIX"]
env["SHLIBSUFFIX"]=suffix+env["SHLIBSUFFIX"]
env.module_list = []
sys.path.remove("./platform/"+selected_platform)
sys.modules.pop('detect')
for x in module_list:
if env['module_' + x + '_enabled'] != "yes":
continue
tmppath = "./modules/" + x
sys.path.append(tmppath)
env.current_module = x
import config
if (config.can_build(selected_platform)):
config.configure(env)
env.module_list.append(x)
sys.path.remove(tmppath)
sys.modules.pop('config')
if (env.use_ptrcall):
env.Append(CPPFLAGS=['-DPTRCALL_ENABLED'])
env.module_list=[]
# to test 64 bits compiltion
# env.Append(CPPFLAGS=['-m64'])
for x in module_list:
if env['module_'+x+'_enabled'] != "yes":
continue
tmppath="./modules/"+x
sys.path.append(tmppath)
env.current_module=x
import config
if (config.can_build(selected_platform)):
config.configure(env)
env.module_list.append(x)
sys.path.remove(tmppath)
sys.modules.pop('config')
if (env['tools'] == 'yes'):
env.Append(CPPFLAGS=['-DTOOLS_ENABLED'])
if (env['disable_3d'] == 'yes'):
env.Append(CPPFLAGS=['-D_3D_DISABLED'])
if (env['gdscript'] == 'yes'):
env.Append(CPPFLAGS=['-DGDSCRIPT_ENABLED'])
if (env['disable_advanced_gui'] == 'yes'):
env.Append(CPPFLAGS=['-DADVANCED_GUI_DISABLED'])
if (env['minizip'] == 'yes'):
env.Append(CPPFLAGS=['-DMINIZIP_ENABLED'])
if (env.use_ptrcall):
env.Append(CPPFLAGS=['-DPTRCALL_ENABLED']);
if (env['xml'] == 'yes'):
env.Append(CPPFLAGS=['-DXML_ENABLED'])
if (env['musepack']=='yes'):
env.Append(CPPFLAGS=['-DMUSEPACK_ENABLED']);
if (env['verbose'] == 'no'):
methods.no_verbose(sys, env)
#if (env['openssl']!='no'):
# env.Append(CPPFLAGS=['-DOPENSSL_ENABLED']);
# if (env['openssl']=="builtin"):
# env.Append(CPPPATH=['#drivers/builtin_openssl2'])
Export('env')
if (env["builtin_zlib"]=='yes'):
env.Append(CPPPATH=['#drivers/builtin_zlib/zlib'])
# build subdirs, the build order is dependent on link order.
# to test 64 bits compiltion
# env.Append(CPPFLAGS=['-m64'])
SConscript("core/SCsub")
SConscript("servers/SCsub")
SConscript("scene/SCsub")
SConscript("tools/SCsub")
SConscript("drivers/SCsub")
SConscript("bin/SCsub")
if (env_base['squish']=='yes'):
env.Append(CPPFLAGS=['-DSQUISH_ENABLED']);
SConscript("modules/SCsub")
SConscript("main/SCsub")
if (env['vorbis']=='yes'):
env.Append(CPPFLAGS=['-DVORBIS_ENABLED']);
if (env['opus']=='yes'):
env.Append(CPPFLAGS=['-DOPUS_ENABLED']);
SConscript("platform/" + selected_platform + "/SCsub") # build selected platform
# Microsoft Visual Studio Project Generation
if (env['vsproj']) == "yes":
if (env['theora']=='yes'):
env['theoralib']='yes'
env.Append(CPPFLAGS=['-DTHEORA_ENABLED']);
if (env['theoralib']=='yes'):
env.Append(CPPFLAGS=['-DTHEORALIB_ENABLED']);
AddToVSProject(env.core_sources)
AddToVSProject(env.main_sources)
AddToVSProject(env.modules_sources)
AddToVSProject(env.scene_sources)
AddToVSProject(env.servers_sources)
AddToVSProject(env.tool_sources)
if (env['png']=='yes'):
env.Append(CPPFLAGS=['-DPNG_ENABLED']);
if (env['dds']=='yes'):
env.Append(CPPFLAGS=['-DDDS_ENABLED']);
if (env['pvr']=='yes'):
env.Append(CPPFLAGS=['-DPVR_ENABLED']);
if (env['jpg']=='yes'):
env.Append(CPPFLAGS=['-DJPG_ENABLED']);
if (env['webp']=='yes'):
env.Append(CPPFLAGS=['-DWEBP_ENABLED']);
# this env flag won't work, it needs to be set in env_base=Environment(MSVC_VERSION='9.0')
# Even then, SCons still seems to ignore it and builds with the latest MSVC...
# That said, it's not needed to be set so far but I'm leaving it here so that this comment
# has a purpose.
# env['MSVS_VERSION']='9.0'
if (env['speex']=='yes'):
env.Append(CPPFLAGS=['-DSPEEX_ENABLED']);
# Calls a CMD with /C(lose) and /V(delayed environment variable expansion) options.
# And runs vcvarsall bat for the propper arhitecture and scons for propper configuration
env['MSVSBUILDCOM'] = 'cmd /V /C set "plat=$(PlatformTarget)" ^& (if "$(PlatformTarget)"=="x64" (set "plat=x86_amd64")) ^& set "tools=yes" ^& (if "$(Configuration)"=="release" (set "tools=no")) ^& call "$(VCInstallDir)vcvarsall.bat" !plat! ^& scons platform=windows target=$(Configuration) tools=!tools! -j2'
env['MSVSREBUILDCOM'] = 'cmd /V /C set "plat=$(PlatformTarget)" ^& (if "$(PlatformTarget)"=="x64" (set "plat=x86_amd64")) ^& set "tools=yes" ^& (if "$(Configuration)"=="release" (set "tools=no")) & call "$(VCInstallDir)vcvarsall.bat" !plat! ^& scons platform=windows target=$(Configuration) tools=!tools! vsproj=yes -j2'
env['MSVSCLEANCOM'] = 'cmd /V /C set "plat=$(PlatformTarget)" ^& (if "$(PlatformTarget)"=="x64" (set "plat=x86_amd64")) ^& set "tools=yes" ^& (if "$(Configuration)"=="release" (set "tools=no")) ^& call "$(VCInstallDir)vcvarsall.bat" !plat! ^& scons --clean platform=windows target=$(Configuration) tools=!tools! -j2'
if (env['tools']=='yes'):
env.Append(CPPFLAGS=['-DTOOLS_ENABLED'])
if (env['disable_3d']=='yes'):
env.Append(CPPFLAGS=['-D_3D_DISABLED'])
if (env['gdscript']=='yes'):
env.Append(CPPFLAGS=['-DGDSCRIPT_ENABLED'])
if (env['disable_advanced_gui']=='yes'):
env.Append(CPPFLAGS=['-DADVANCED_GUI_DISABLED'])
if (env['minizip'] == 'yes'):
env.Append(CPPFLAGS=['-DMINIZIP_ENABLED'])
if (env['xml']=='yes'):
env.Append(CPPFLAGS=['-DXML_ENABLED'])
if (env['colored']=='yes'):
methods.colored(sys,env)
if (env['etc1']=='yes'):
env.Append(CPPFLAGS=['-DETC1_ENABLED'])
Export('env')
#build subdirs, the build order is dependent on link order.
SConscript("core/SCsub")
SConscript("servers/SCsub")
SConscript("scene/SCsub")
SConscript("tools/SCsub")
SConscript("drivers/SCsub")
SConscript("bin/SCsub")
SConscript("modules/SCsub")
SConscript("main/SCsub")
SConscript("platform/"+selected_platform+"/SCsub"); # build selected platform
# Microsoft Visual Studio Project Generation
if (env['vsproj'])=="yes":
AddToVSProject(env.core_sources)
AddToVSProject(env.main_sources)
AddToVSProject(env.modules_sources)
AddToVSProject(env.scene_sources)
AddToVSProject(env.servers_sources)
AddToVSProject(env.tool_sources)
# this env flag won't work, it needs to be set in env_base=Environment(MSVC_VERSION='9.0')
# Even then, SCons still seems to ignore it and builds with the latest MSVC...
# That said, it's not needed to be set so far but I'm leaving it here so that this comment
# has a purpose.
#env['MSVS_VERSION']='9.0'
# Calls a CMD with /C(lose) and /V(delayed environment variable expansion) options.
# And runs vcvarsall bat for the propper arhitecture and scons for propper configuration
env['MSVSBUILDCOM'] = 'cmd /V /C set "plat=$(PlatformTarget)" ^& (if "$(PlatformTarget)"=="x64" (set "plat=x86_amd64")) ^& set "tools=yes" ^& (if "$(Configuration)"=="release" (set "tools=no")) ^& call "$(VCInstallDir)vcvarsall.bat" !plat! ^& scons platform=windows target=$(Configuration) tools=!tools! -j2'
env['MSVSREBUILDCOM'] = 'cmd /V /C set "plat=$(PlatformTarget)" ^& (if "$(PlatformTarget)"=="x64" (set "plat=x86_amd64")) ^& set "tools=yes" ^& (if "$(Configuration)"=="release" (set "tools=no")) & call "$(VCInstallDir)vcvarsall.bat" !plat! ^& scons platform=windows target=$(Configuration) tools=!tools! vsproj=yes -j2'
env['MSVSCLEANCOM'] = 'cmd /V /C set "plat=$(PlatformTarget)" ^& (if "$(PlatformTarget)"=="x64" (set "plat=x86_amd64")) ^& set "tools=yes" ^& (if "$(Configuration)"=="release" (set "tools=no")) ^& call "$(VCInstallDir)vcvarsall.bat" !plat! ^& scons --clean platform=windows target=$(Configuration) tools=!tools! -j2'
# This version information (Win32, x64, Debug, Release, Release_Debug seems to be
# required for Visual Studio to understand that it needs to generate an NMAKE
# project. Do not modify without knowing what you are doing.
debug_variants = ['debug|Win32']+['debug|x64']
release_variants = ['release|Win32']+['release|x64']
release_debug_variants = ['release_debug|Win32']+['release_debug|x64']
variants = debug_variants + release_variants + release_debug_variants
debug_targets = ['Debug']+['Debug']
release_targets = ['Release']+['Release']
release_debug_targets = ['ReleaseDebug']+['ReleaseDebug']
targets = debug_targets + release_targets + release_debug_targets
msvproj = env.MSVSProject(target = ['#godot' + env['MSVSPROJECTSUFFIX'] ],
incs = env.vs_incs,
srcs = env.vs_srcs,
runfile = targets,
buildtarget = targets,
auto_build_solution=1,
variant = variants)
# This version information (Win32, x64, Debug, Release, Release_Debug seems to be
# required for Visual Studio to understand that it needs to generate an NMAKE
# project. Do not modify without knowing what you are doing.
debug_variants = ['debug|Win32'] + ['debug|x64']
release_variants = ['release|Win32'] + ['release|x64']
release_debug_variants = ['release_debug|Win32'] + ['release_debug|x64']
variants = debug_variants + release_variants + release_debug_variants
debug_targets = ['bin\\godot.windows.tools.32.exe'] + ['bin\\godot.windows.tools.64.exe']
release_targets = ['bin\\godot.windows.opt.32.exe'] + ['bin\\godot.windows.opt.64.exe']
release_debug_targets = ['bin\\godot.windows.opt.tools.32.exe'] + ['bin\\godot.windows.opt.tools.64.exe']
targets = debug_targets + release_targets + release_debug_targets
msvproj = env.MSVSProject(target=['#godot' + env['MSVSPROJECTSUFFIX']],
incs=env.vs_incs,
srcs=env.vs_srcs,
runfile=targets,
buildtarget=targets,
auto_build_solution=1,
variant=variants)
else:
print("No valid target platform selected.")
print("The following were detected:")
for x in platform_list:
print("\t"+x)
print("\nPlease run scons again with argument: platform=<string>")
print("No valid target platform selected.")
print("The following were detected:")
for x in platform_list:
print("\t" + x)
print("\nPlease run scons again with argument: platform=<string>")

View File

@@ -1,4 +1,6 @@
#!/usr/bin/python
Import('env')
Export('env')
SConscript('tests/SCsub');
SConscript('tests/SCsub')

View File

@@ -1,12 +1,14 @@
#!/usr/bin/python
Import('env')
env.tests_sources=[]
env.add_source_files(env.tests_sources,"*.cpp")
env.tests_sources = []
env.add_source_files(env.tests_sources, "*.cpp")
Export('env')
#SConscript('math/SCsub');
# SConscript('math/SCsub');
lib = env.Library("tests",env.tests_sources)
lib = env.Library("tests", env.tests_sources)
env.Prepend(LIBS=[lib])

View File

@@ -1,65 +1,67 @@
#!/usr/bin/env python
Import('env')
env.core_sources=[]
env.core_sources = []
gd_call=""
gd_inc=""
gd_call = ""
gd_inc = ""
for x in env.global_defaults:
env.core_sources.append("#platform/"+x+"/globals/global_defaults.cpp")
gd_inc+='#include "platform/'+x+'/globals/global_defaults.h"\n'
gd_call+="\tregister_"+x+"_global_defaults();\n"
env.core_sources.append("#platform/" + x + "/globals/global_defaults.cpp")
gd_inc += '#include "platform/' + x + '/globals/global_defaults.h"\n'
gd_call += "\tregister_" + x + "_global_defaults();\n"
gd_cpp='#include "globals.h"\n'
gd_cpp+=gd_inc
gd_cpp+="void Globals::register_global_defaults() {\n"+gd_call+"\n}\n"
gd_cpp = '#include "globals.h"\n'
gd_cpp += gd_inc
gd_cpp += "void Globals::register_global_defaults() {\n" + gd_call + "\n}\n"
f = open("global_defaults.cpp","wb")
f = open("global_defaults.cpp", "wb")
f.write(gd_cpp)
f.close()
import os
txt = "0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0"
if ("SCRIPT_AES256_ENCRYPTION_KEY" in os.environ):
e=os.environ["SCRIPT_AES256_ENCRYPTION_KEY"]
txt = ""
ec_valid=True
if (len(e)!=64):
ec_valid=False
else:
e = os.environ["SCRIPT_AES256_ENCRYPTION_KEY"]
txt = ""
ec_valid = True
if (len(e) != 64):
ec_valid = False
else:
for i in range(len(e)>>1):
if (i>0):
txt+=","
txts="0x"+e[i*2:i*2+2]
try:
int(txts,16)
except:
ec_valid=False
txt+=txts
if (not ec_valid):
txt = "0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0"
print("Invalid AES256 encryption key, not 64 bits hex: "+e)
for i in range(len(e) >> 1):
if (i > 0):
txt += ","
txts = "0x" + e[i * 2:i * 2 + 2]
try:
int(txts, 16)
except:
ec_valid = False
txt += txts
if (not ec_valid):
txt = "0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0"
print("Invalid AES256 encryption key, not 64 bits hex: " + e)
f = open("script_encryption_key.cpp", "wb")
f.write("#include \"globals.h\"\nuint8_t script_encryption_key[32]={" + txt + "};\n")
f.close()
env.add_source_files(env.core_sources,"*.cpp")
env.add_source_files(env.core_sources, "*.cpp")
Export('env')
import make_binders
env.Command(['method_bind.inc','method_bind_ext.inc'], 'make_binders.py', make_binders.run)
env.Command(['method_bind.inc', 'method_bind_ext.inc'], 'make_binders.py', make_binders.run)
SConscript('os/SCsub');
SConscript('math/SCsub');
SConscript('io/SCsub');
SConscript('bind/SCsub');
SConscript('os/SCsub')
SConscript('math/SCsub')
SConscript('io/SCsub')
SConscript('bind/SCsub')
lib = env.Library("core",env.core_sources)
lib = env.Library("core", env.core_sources)
env.Prepend(LIBS=[lib])

View File

@@ -1,5 +1,7 @@
#!/usr/bin/env python
Import('env')
env.add_source_files(env.core_sources,"*.cpp")
env.add_source_files(env.core_sources, "*.cpp")
Export('env')

View File

@@ -480,9 +480,9 @@ void _OS::set_use_vsync(bool p_enable) {
OS::get_singleton()->set_use_vsync(p_enable);
}
bool _OS::is_vsnc_enabled() const {
bool _OS::is_vsync_enabled() const {
return OS::get_singleton()->is_vsnc_enabled();
return OS::get_singleton()->is_vsync_enabled();
}
@@ -1172,7 +1172,7 @@ void _OS::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_thread_name","name"),&_OS::set_thread_name);
ObjectTypeDB::bind_method(_MD("set_use_vsync","enable"),&_OS::set_use_vsync);
ObjectTypeDB::bind_method(_MD("is_vsnc_enabled"),&_OS::is_vsnc_enabled);
ObjectTypeDB::bind_method(_MD("is_vsync_enabled"),&_OS::is_vsync_enabled);
ObjectTypeDB::bind_method(_MD("get_engine_version"),&_OS::get_engine_version);
@@ -1936,6 +1936,13 @@ Error _Directory::make_dir(String p_dir){
Error _Directory::make_dir_recursive(String p_dir){
ERR_FAIL_COND_V(!d,ERR_UNCONFIGURED);
if (!p_dir.is_rel_path()) {
DirAccess *d = DirAccess::create_for_path(p_dir);
Error err = d->make_dir_recursive(p_dir);
memdelete(d);
return err;
}
return d->make_dir_recursive(p_dir);
}

View File

@@ -318,7 +318,7 @@ public:
Error set_thread_name(const String& p_name);
void set_use_vsync(bool p_enable);
bool is_vsnc_enabled() const;
bool is_vsync_enabled() const;
Dictionary get_engine_version() const;

View File

@@ -57,33 +57,33 @@ enum Error {
ERR_FILE_MISSING_DEPENDENCIES,
ERR_FILE_EOF,
ERR_CANT_OPEN, ///< Can't open a resource/socket/file
ERR_CANT_CREATE,
ERROR_QUERY_FAILED, // (20)
ERR_CANT_CREATE, // (20)
ERROR_QUERY_FAILED,
ERR_ALREADY_IN_USE,
ERR_LOCKED, ///< resource is locked
ERR_TIMEOUT,
ERR_CANT_CONNECT,
ERR_CANT_RESOLVE, // (25)
ERR_CANT_CONNECT, // (25)
ERR_CANT_RESOLVE,
ERR_CONNECTION_ERROR,
ERR_CANT_AQUIRE_RESOURCE,
ERR_CANT_FORK,
ERR_INVALID_DATA, ///< Data passed is invalid
ERR_INVALID_PARAMETER, ///< Parameter passed is invalid (30)
ERR_INVALID_DATA, ///< Data passed is invalid (30)
ERR_INVALID_PARAMETER, ///< Parameter passed is invalid
ERR_ALREADY_EXISTS, ///< When adding, item already exists
ERR_DOES_NOT_EXIST, ///< When retrieving/erasing, it item does not exist
ERR_DATABASE_CANT_READ, ///< database is full
ERR_DATABASE_CANT_WRITE, ///< database is full
ERR_COMPILATION_FAILED, // (35)
ERR_DATABASE_CANT_WRITE, ///< database is full (35)
ERR_COMPILATION_FAILED,
ERR_METHOD_NOT_FOUND,
ERR_LINK_FAILED,
ERR_SCRIPT_FAILED,
ERR_CYCLIC_LINK,
ERR_INVALID_DECLARATION, // (40)
ERR_CYCLIC_LINK, // (40)
ERR_INVALID_DECLARATION,
ERR_DUPLICATE_SYMBOL,
ERR_PARSE_ERROR,
ERR_BUSY,
ERR_SKIP,
ERR_HELP, ///< user requested help!! (45)
ERR_SKIP, // (45)
ERR_HELP, ///< user requested help!!
ERR_BUG, ///< a bug in the software certainly happened, due to a double check failing or unexpected behavior.
ERR_PRINTER_ON_FIRE, /// the parallel port printer is engulfed in flames
ERR_OMFG_THIS_IS_VERY_VERY_BAD, ///< shit happens, has never been used, though

View File

@@ -65,7 +65,7 @@ void FuncRef::_bind_methods() {
mi.arguments.push_back( PropertyInfo( Variant::NIL, "arg"+itos(i)));
defargs.push_back(Variant());
}
ObjectTypeDB::bind_native_method(METHOD_FLAGS_DEFAULT,"call_func:Variant",&FuncRef::call_func,mi,defargs);
ObjectTypeDB::bind_native_method(METHOD_FLAGS_DEFAULT,"call_func",&FuncRef::call_func,mi,defargs);
}

View File

@@ -54,7 +54,7 @@ String Globals::localize_path(const String& p_path) const {
if (resource_path=="")
return p_path; //not initialied yet
if (p_path.begins_with("res://") || p_path.begins_with("user://"))
if (p_path.begins_with("res://") || p_path.begins_with("user://") || p_path.is_abs_path())
return p_path.simplify_path();
@@ -1375,6 +1375,25 @@ Vector<String> Globals::get_optimizer_presets() const {
}
void Globals::_add_property_info_bind(const Dictionary& p_info) {
ERR_FAIL_COND(!p_info.has("name"));
ERR_FAIL_COND(!p_info.has("type"));
PropertyInfo pinfo;
pinfo.name = p_info["name"];
ERR_FAIL_COND(!props.has(pinfo.name));
pinfo.type = Variant::Type(p_info["type"].operator int());
ERR_FAIL_INDEX(pinfo.type, Variant::VARIANT_MAX);
if (p_info.has("hint"))
pinfo.hint = PropertyHint(p_info["hint"].operator int());
if (p_info.has("hint_string"))
pinfo.hint_string = p_info["hint_string"];
set_custom_property_info(pinfo.name, pinfo);
}
void Globals::set_custom_property_info(const String& p_prop,const PropertyInfo& p_info) {
ERR_FAIL_COND(!props.has(p_prop));
@@ -1399,6 +1418,7 @@ void Globals::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_order","name"),&Globals::get_order);
ObjectTypeDB::bind_method(_MD("set_persisting","name","enable"),&Globals::set_persisting);
ObjectTypeDB::bind_method(_MD("is_persisting","name"),&Globals::is_persisting);
ObjectTypeDB::bind_method(_MD("add_property_info", "hint"),&Globals::_add_property_info_bind);
ObjectTypeDB::bind_method(_MD("clear","name"),&Globals::clear);
ObjectTypeDB::bind_method(_MD("localize_path","path"),&Globals::localize_path);
ObjectTypeDB::bind_method(_MD("globalize_path","path"),&Globals::globalize_path);

View File

@@ -96,6 +96,8 @@ protected:
bool _load_resource_pack(const String& p_pack);
void _add_property_info_bind(const Dictionary& p_info);
protected:
static void _bind_methods();

View File

@@ -74,7 +74,10 @@ static inline uint32_t hash_djb2_one_float(float p_in,uint32_t p_prev=5381) {
float f;
uint32_t i;
} u;
u.f=p_in;
// handle -0 case
if (p_in==0.0f) u.f=0.0f;
else u.f=p_in;
return ((p_prev<<5)+p_prev)+u.i;
}

View File

@@ -232,64 +232,6 @@ bool InputMap::event_is_action(const InputEvent& p_event, const StringName& p_ac
return _find_event(E->get().inputs,p_event)!=NULL;
}
bool InputMap::event_is_joy_motion_action_pressed(const InputEvent& p_event) const {
ERR_FAIL_COND_V(p_event.type!=InputEvent::JOYSTICK_MOTION,false);
bool pressed=false;
//this could be optimized by having a separate list of joymotions?
for (Map<StringName, Action>::Element *A=input_map.front();A;A=A->next()) {
for (List<InputEvent>::Element *E=A->get().inputs.front();E;E=E->next()) {
const InputEvent& e=E->get();
if(e.type!=p_event.type)
continue;
if (e.type!=InputEvent::KEY && e.device!=p_event.device)
continue;
switch(p_event.type) {
case InputEvent::KEY: {
if (e.key.scancode==p_event.key.scancode && e.key.mod == p_event.key.mod)
return e.key.pressed;
} break;
case InputEvent::JOYSTICK_BUTTON: {
if (e.joy_button.button_index==p_event.joy_button.button_index) {
return e.joy_button.pressed;
}
} break;
case InputEvent::MOUSE_BUTTON: {
if (e.mouse_button.button_index==p_event.mouse_button.button_index) {
return e.mouse_button.pressed;
}
} break;
case InputEvent::JOYSTICK_MOTION: {
if (e.joy_motion.axis==p_event.joy_motion.axis) {
if (
(e.joy_motion.axis_value * p_event.joy_motion.axis_value >0) && //same axis
ABS(e.joy_motion.axis_value)>0.5 && ABS(p_event.joy_motion.axis_value)>0.5 )
pressed=true;
}
} break;
}
}
}
return pressed;
}
void InputMap::load_from_globals() {
input_map.clear();;

View File

@@ -70,7 +70,6 @@ public:
const List<InputEvent> *get_action_list(const StringName& p_action);
bool event_is_action(const InputEvent& p_event, const StringName& p_action) const;
bool event_is_joy_motion_action_pressed(const InputEvent& p_event) const;
void load_from_globals();

View File

@@ -1,7 +1,9 @@
#!/usr/bin/env python
Import('env')
env.add_source_files(env.core_sources,"*.cpp")
env.add_source_files(env.core_sources,"*.c")
#env.core_sources.append("io/fastlz.c")
env.add_source_files(env.core_sources, "*.cpp")
env.add_source_files(env.core_sources, "*.c")
# env.core_sources.append("io/fastlz.c")
Export('env')

View File

@@ -1,7 +1,7 @@
# -*- coding: ibm850 -*-
template_typed="""
template_typed = """
#ifdef TYPED_METHOD_BIND
template<class T $ifret ,class R$ $ifargs ,$ $arg, class P@$>
class MethodBind$argc$$ifret R$$ifconst C$ : public MethodBind {
@@ -75,7 +75,7 @@ MethodBind* create_method_bind($ifret R$ $ifnoret void$ (T::*p_method)($arg, P@$
#endif
"""
template="""
template = """
#ifndef TYPED_METHOD_BIND
$iftempl template<$ $ifret class R$ $ifretargs ,$ $arg, class P@$ $iftempl >$
class MethodBind$argc$$ifret R$$ifconst C$ : public MethodBind {
@@ -161,96 +161,95 @@ MethodBind* create_method_bind($ifret R$ $ifnoret void$ (T::*p_method)($arg, P@$
"""
def make_version(template,nargs,argmax,const,ret):
def make_version(template, nargs, argmax, const, ret):
intext=template
from_pos=0
outtext=""
intext = template
from_pos = 0
outtext = ""
while(True):
to_pos=intext.find("$",from_pos)
if (to_pos==-1):
outtext+=intext[from_pos:]
break
else:
outtext+=intext[from_pos:to_pos]
end=intext.find("$",to_pos+1)
if (end==-1):
break # ignore
macro=intext[to_pos+1:end]
cmd=""
data=""
while(True):
to_pos = intext.find("$", from_pos)
if (to_pos == -1):
outtext += intext[from_pos:]
break
else:
outtext += intext[from_pos:to_pos]
end = intext.find("$", to_pos + 1)
if (end == -1):
break # ignore
macro = intext[to_pos + 1:end]
cmd = ""
data = ""
if (macro.find(" ")!=-1):
cmd=macro[0:macro.find(" ")]
data=macro[macro.find(" ")+1:]
else:
cmd=macro
if (macro.find(" ") != -1):
cmd = macro[0:macro.find(" ")]
data = macro[macro.find(" ") + 1:]
else:
cmd = macro
if (cmd=="argc"):
outtext+=str(nargs)
if (cmd=="ifret" and ret):
outtext+=data
if (cmd=="ifargs" and nargs):
outtext+=data
if (cmd=="ifretargs" and nargs and ret):
outtext+=data
if (cmd=="ifconst" and const):
outtext+=data
elif (cmd=="ifnoconst" and not const):
outtext+=data
elif (cmd=="ifnoret" and not ret):
outtext+=data
elif (cmd=="iftempl" and (nargs>0 or ret)):
outtext+=data
elif (cmd=="arg,"):
for i in range(1,nargs+1):
if (i>1):
outtext+=", "
outtext+=data.replace("@",str(i))
elif (cmd=="arg"):
for i in range(1,nargs+1):
outtext+=data.replace("@",str(i))
elif (cmd=="noarg"):
for i in range(nargs+1,argmax+1):
outtext+=data.replace("@",str(i))
elif (cmd=="noarg"):
for i in range(nargs+1,argmax+1):
outtext+=data.replace("@",str(i))
if (cmd == "argc"):
outtext += str(nargs)
if (cmd == "ifret" and ret):
outtext += data
if (cmd == "ifargs" and nargs):
outtext += data
if (cmd == "ifretargs" and nargs and ret):
outtext += data
if (cmd == "ifconst" and const):
outtext += data
elif (cmd == "ifnoconst" and not const):
outtext += data
elif (cmd == "ifnoret" and not ret):
outtext += data
elif (cmd == "iftempl" and (nargs > 0 or ret)):
outtext += data
elif (cmd == "arg,"):
for i in range(1, nargs + 1):
if (i > 1):
outtext += ", "
outtext += data.replace("@", str(i))
elif (cmd == "arg"):
for i in range(1, nargs + 1):
outtext += data.replace("@", str(i))
elif (cmd == "noarg"):
for i in range(nargs + 1, argmax + 1):
outtext += data.replace("@", str(i))
elif (cmd == "noarg"):
for i in range(nargs + 1, argmax + 1):
outtext += data.replace("@", str(i))
from_pos=end+1
from_pos = end + 1
return outtext
return outtext
def run(target, source, env):
versions=10
versions_ext=6
text=""
text_ext=""
versions = 10
versions_ext = 6
text = ""
text_ext = ""
for i in range(0,versions+1):
for i in range(0, versions + 1):
t=""
t+=make_version(template,i,versions,False,False)
t+=make_version(template_typed,i,versions,False,False)
t+=make_version(template,i,versions,False,True)
t+=make_version(template_typed,i,versions,False,True)
t+=make_version(template,i,versions,True,False)
t+=make_version(template_typed,i,versions,True,False)
t+=make_version(template,i,versions,True,True)
t+=make_version(template_typed,i,versions,True,True)
if (i>=versions_ext):
text_ext+=t
else:
text+=t
t = ""
t += make_version(template, i, versions, False, False)
t += make_version(template_typed, i, versions, False, False)
t += make_version(template, i, versions, False, True)
t += make_version(template_typed, i, versions, False, True)
t += make_version(template, i, versions, True, False)
t += make_version(template_typed, i, versions, True, False)
t += make_version(template, i, versions, True, True)
t += make_version(template_typed, i, versions, True, True)
if (i >= versions_ext):
text_ext += t
else:
text += t
f = open(target[0].path, "w")
f.write(text)
f.close()
f=open(target[0].path,"w")
f.write(text)
f.close()
f=open(target[1].path,"w")
f.write(text_ext)
f.close()
f = open(target[1].path, "w")
f.write(text_ext)
f.close()

View File

@@ -1,5 +1,7 @@
#!/usr/bin/env python
Import('env')
env.add_source_files(env.core_sources,"*.cpp")
env.add_source_files(env.core_sources, "*.cpp")
Export('env')

440
core/math/a_star.cpp Normal file
View File

@@ -0,0 +1,440 @@
/*************************************************************************/
/* a_star.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "a_star.h"
#include "geometry.h"
int AStar::get_available_point_id() const {
if (points.empty()) {
return 1;
}
return points.back()->key()+1;
}
void AStar::add_point(int p_id, const Vector3 &p_pos, float p_weight_scale) {
ERR_FAIL_COND(p_id<0);
if (!points.has(p_id)) {
Point *pt = memnew( Point );
pt->id=p_id;
pt->pos=p_pos;
pt->weight_scale=p_weight_scale;
pt->prev_point=NULL;
pt->last_pass=0;
points[p_id]=pt;
} else {
points[p_id]->pos=p_pos;
points[p_id]->weight_scale=p_weight_scale;
}
}
Vector3 AStar::get_point_pos(int p_id) const{
ERR_FAIL_COND_V(!points.has(p_id),Vector3());
return points[p_id]->pos;
}
float AStar::get_point_weight_scale(int p_id) const{
ERR_FAIL_COND_V(!points.has(p_id),0);
return points[p_id]->weight_scale;
}
void AStar::remove_point(int p_id){
ERR_FAIL_COND(!points.has(p_id));
Point* p = points[p_id];
for(int i=0;i<p->neighbours.size();i++) {
Segment s(p_id,p->neighbours[i]->id);
segments.erase(s);
p->neighbours[i]->neighbours.erase(p);
}
memdelete(p);
points.erase(p_id);
}
void AStar::connect_points(int p_id,int p_with_id){
ERR_FAIL_COND(!points.has(p_id));
ERR_FAIL_COND(!points.has(p_with_id));
ERR_FAIL_COND(p_id==p_with_id);
Point* a = points[p_id];
Point* b = points[p_with_id];
a->neighbours.push_back(b);
b->neighbours.push_back(a);
Segment s(p_id,p_with_id);
if (s.from==p_id) {
s.from_point=a;
s.to_point=b;
} else {
s.from_point=b;
s.to_point=a;
}
segments.insert(s);
}
void AStar::disconnect_points(int p_id,int p_with_id){
Segment s(p_id,p_with_id);
ERR_FAIL_COND(!segments.has(s));
segments.erase(s);
Point *a = points[p_id];
Point *b = points[p_with_id];
a->neighbours.erase(b);
b->neighbours.erase(a);
}
bool AStar::are_points_connected(int p_id,int p_with_id) const{
Segment s(p_id,p_with_id);
return segments.has(s);
}
void AStar::clear(){
for (const Map<int,Point*>::Element *E=points.front();E;E=E->next()) {
memdelete(E->get());
}
segments.clear();
points.clear();
}
int AStar::get_closest_point(const Vector3& p_point) const{
int closest_id=-1;
float closest_dist=1e20;
for (const Map<int,Point*>::Element *E=points.front();E;E=E->next()) {
float d = p_point.distance_squared_to(E->get()->pos);
if (closest_id<0 || d<closest_dist) {
closest_dist=d;
closest_id=E->key();
}
}
return closest_id;
}
Vector3 AStar::get_closest_pos_in_segment(const Vector3& p_point) const {
float closest_dist = 1e20;
bool found=false;
Vector3 closest_point;
for (const Set<Segment>::Element *E=segments.front();E;E=E->next()) {
Vector3 segment[2]={
E->get().from_point->pos,
E->get().to_point->pos,
};
Vector3 p = Geometry::get_closest_point_to_segment(p_point,segment);
float d = p_point.distance_squared_to(p);
if (!found || d<closest_dist) {
closest_point=p;
closest_dist=d;
found=true;
}
}
return closest_point;
}
bool AStar::_solve(Point* begin_point, Point* end_point) {
pass++;
SelfList<Point>::List open_list;
bool found_route=false;
for(int i=0;i<begin_point->neighbours.size();i++) {
Point *n = begin_point->neighbours[i];
n->prev_point=begin_point;
n->distance=n->pos.distance_to(begin_point->pos);
n->distance*=n->weight_scale;
n->last_pass=pass;
open_list.add(&n->list);
if (end_point==n) {
found_route=true;
break;
}
}
while(!found_route) {
if (open_list.first()==NULL) {
//could not find path sadly
break;
}
//check open list
SelfList<Point> *least_cost_point=NULL;
float least_cost=1e30;
//this could be faster (cache previous results)
for (SelfList<Point> *E=open_list.first();E;E=E->next()) {
Point *p=E->self();
float cost=p->distance;
cost+=p->pos.distance_to(end_point->pos);
cost*=p->weight_scale;
if (cost<least_cost) {
least_cost_point=E;
least_cost=cost;
}
}
Point *p=least_cost_point->self();
//open the neighbours for search
int es = p->neighbours.size();
for(int i=0;i<es;i++) {
Point* e=p->neighbours[i];
float distance = p->pos.distance_to(e->pos) + p->distance;
distance*=e->weight_scale;
if (e->last_pass==pass) {
//oh this was visited already, can we win the cost?
if (e->distance>distance) {
e->prev_point=p;
e->distance=distance;
}
} else {
//add to open neighbours
e->prev_point=p;
e->distance=distance;
e->last_pass=pass; //mark as used
open_list.add(&e->list);
if (e==end_point) {
//oh my reached end! stop algorithm
found_route=true;
break;
}
}
}
if (found_route)
break;
open_list.remove(least_cost_point);
}
//clear the openf list
while(open_list.first()) {
open_list.remove( open_list.first() );
}
return found_route;
}
DVector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
ERR_FAIL_COND_V(!points.has(p_from_id),DVector<Vector3>());
ERR_FAIL_COND_V(!points.has(p_to_id),DVector<Vector3>());
pass++;
Point* a = points[p_from_id];
Point* b = points[p_to_id];
if (a==b) {
DVector<Vector3> ret;
ret.push_back(a->pos);
return ret;
}
Point *begin_point=a;
Point *end_point=b;
bool found_route=_solve(begin_point,end_point);
if (!found_route)
return DVector<Vector3>();
//midpoints
Point *p=end_point;
int pc=1; //begin point
while(p!=begin_point) {
pc++;
p=p->prev_point;
}
DVector<Vector3> path;
path.resize(pc);
{
DVector<Vector3>::Write w = path.write();
Point *p=end_point;
int idx=pc-1;
while(p!=begin_point) {
w[idx--]=p->pos;
p=p->prev_point;
}
w[0]=p->pos; //assign first
}
return path;
}
DVector<int> AStar::get_id_path(int p_from_id, int p_to_id) {
ERR_FAIL_COND_V(!points.has(p_from_id),DVector<int>());
ERR_FAIL_COND_V(!points.has(p_to_id),DVector<int>());
pass++;
Point* a = points[p_from_id];
Point* b = points[p_to_id];
if (a==b) {
DVector<int> ret;
ret.push_back(a->id);
return ret;
}
Point *begin_point=a;
Point *end_point=b;
bool found_route=_solve(begin_point,end_point);
if (!found_route)
return DVector<int>();
//midpoints
Point *p=end_point;
int pc=1; //begin point
while(p!=begin_point) {
pc++;
p=p->prev_point;
}
DVector<int> path;
path.resize(pc);
{
DVector<int>::Write w = path.write();
p=end_point;
int idx=pc-1;
while(p!=begin_point) {
w[idx--]=p->id;
p=p->prev_point;
}
w[0]=p->id; //assign first
}
return path;
}
void AStar::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_available_point_id"),&AStar::get_available_point_id);
ObjectTypeDB::bind_method(_MD("add_point","id","pos","weight_scale"),&AStar::add_point,DEFVAL(1.0));
ObjectTypeDB::bind_method(_MD("get_point_pos","id"),&AStar::get_point_pos);
ObjectTypeDB::bind_method(_MD("get_point_weight_scale","id"),&AStar::get_point_weight_scale);
ObjectTypeDB::bind_method(_MD("remove_point","id"),&AStar::remove_point);
ObjectTypeDB::bind_method(_MD("connect_points","id","to_id"),&AStar::connect_points);
ObjectTypeDB::bind_method(_MD("disconnect_points","id","to_id"),&AStar::disconnect_points);
ObjectTypeDB::bind_method(_MD("are_points_connected","id","to_id"),&AStar::are_points_connected);
ObjectTypeDB::bind_method(_MD("clear"),&AStar::clear);
ObjectTypeDB::bind_method(_MD("get_closest_point","to_pos"),&AStar::get_closest_point);
ObjectTypeDB::bind_method(_MD("get_closest_pos_in_segment","to_pos"),&AStar::get_closest_pos_in_segment);
ObjectTypeDB::bind_method(_MD("get_point_path","from_id","to_id"),&AStar::get_point_path);
ObjectTypeDB::bind_method(_MD("get_id_path","from_id","to_id"),&AStar::get_id_path);
}
AStar::AStar() {
pass=1;
}
AStar::~AStar() {
pass=1;
}

View File

@@ -1,5 +1,5 @@
/*************************************************************************/
/* memory_pool_static_nedmalloc.h */
/* a_star.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -26,52 +26,98 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifdef NEDMALLOC_ENABLED
#ifndef ASTAR_H
#define ASTAR_H
//
// C++ Interface: memory_static_malloc
//
// Description:
//
//
// Author: Juan Linietsky <red@lunatea>, (C) 2006
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef MEMORY_POOL_STATIC_NEDMALLOC_H
#define MEMORY_POOL_STATIC_NEDMALLOC_H
#include "os/memory_pool_static.h"
#include "os/mutex.h"
#include "reference.h"
#include "self_list.h"
/**
@author Juan Linietsky <red@lunatea>
@author Juan Linietsky <reduzio@gmail.com>
*/
class MemoryPoolStaticNedMalloc : public MemoryPoolStatic {
Mutex *mutex;
class AStar: public Reference {
OBJ_TYPE(AStar,Reference)
uint64_t pass;
struct Point {
SelfList<Point> list;
int id;
Vector3 pos;
float weight_scale;
uint64_t last_pass;
Vector<Point*> neighbours;
//used for pathfinding
Point *prev_point;
float distance;
Point() : list(this) {}
};
Map<int,Point*> points;
struct Segment {
union {
struct {
int32_t from;
int32_t to;
};
uint64_t key;
};
Point *from_point;
Point *to_point;
bool operator<(const Segment& p_s) const { return key<p_s.key; }
Segment() { key=0; }
Segment(int p_from,int p_to) {
if (p_from > p_to) {
SWAP(p_from,p_to);
}
from=p_from;
to=p_to;
}
};
Set<Segment> segments;
bool _solve(Point *begin_point, Point *end_point);
protected:
static void _bind_methods();
public:
void* alloc(size_t p_bytes,const char *p_description=""); ///< Pointer in p_description shold be to a const char const like "hello"
void* realloc(void *p_memory,size_t p_bytes); ///< Pointer in
void free(void *p_ptr); ///< Pointer in p_description shold be to a const char const
virtual size_t get_available_mem() const;
virtual size_t get_total_usage();
/* Most likely available only if memory debugger was compiled in */
virtual int get_alloc_count();
virtual void * get_alloc_ptr(int p_alloc_idx);
virtual const char* get_alloc_description(int p_alloc_idx);
virtual size_t get_alloc_size(int p_alloc_idx);
virtual void debug_print_all_memory();
MemoryPoolStaticNedMalloc();
~MemoryPoolStaticNedMalloc();
int get_available_point_id() const;
void add_point(int p_id,const Vector3& p_pos,float p_weight_scale=1);
Vector3 get_point_pos(int p_id) const;
float get_point_weight_scale(int p_id) const;
void remove_point(int p_id);
void connect_points(int p_id,int p_with_id);
void disconnect_points(int p_id,int p_with_id);
bool are_points_connected(int p_id,int p_with_id) const;
void clear();
int get_closest_point(const Vector3& p_point) const;
Vector3 get_closest_pos_in_segment(const Vector3& p_point) const;
DVector<Vector3> get_point_path(int p_from_id, int p_to_id);
DVector<int> get_id_path(int p_from_id, int p_to_id);
AStar();
~AStar();
};
#endif
#endif
#endif // ASTAR_H

View File

@@ -424,7 +424,7 @@ Matrix32 Matrix32::inverse() const {
void Matrix32::affine_invert() {
float det = elements[0][0]*elements[1][1] - elements[1][0]*elements[0][1];
float det = basis_determinant();
ERR_FAIL_COND(det==0);
float idet = 1.0 / det;
@@ -475,18 +475,18 @@ Matrix32::Matrix32(real_t p_rot, const Vector2& p_pos) {
elements[2]=p_pos;
}
Vector2 Matrix32::get_scale() const {
Size2 Matrix32::get_scale() const {
return Vector2( elements[0].length(), elements[1].length() );
return Size2( elements[0].length(), elements[1].length() );
}
void Matrix32::scale(const Vector2& p_scale) {
void Matrix32::scale(const Size2& p_scale) {
elements[0]*=p_scale;
elements[1]*=p_scale;
elements[2]*=p_scale;
}
void Matrix32::scale_basis(const Vector2& p_scale) {
void Matrix32::scale_basis(const Size2& p_scale) {
elements[0]*=p_scale;
elements[1]*=p_scale;
@@ -501,7 +501,6 @@ void Matrix32::translate( const Vector2& p_translation ) {
elements[2]+=basis_xform(p_translation);
}
void Matrix32::orthonormalize() {
// Gram-Schmidt Process
@@ -550,11 +549,6 @@ void Matrix32::operator*=(const Matrix32& p_transform) {
elements[2] = xform(p_transform.elements[2]);
float x0,x1,y0,y1;
/*
x0 = p_transform.tdotx(elements[0]);
x1 = p_transform.tdoty(elements[0]);
y0 = p_transform.tdotx(elements[1]);
y1 = p_transform.tdoty(elements[1]);*/
x0 = tdotx(p_transform.elements[0]);
x1 = tdoty(p_transform.elements[0]);
@@ -576,7 +570,7 @@ Matrix32 Matrix32::operator*(const Matrix32& p_transform) const {
}
Matrix32 Matrix32::scaled(const Vector2& p_scale) const {
Matrix32 Matrix32::scaled(const Size2& p_scale) const {
Matrix32 copy=*this;
copy.scale(p_scale);
@@ -584,7 +578,7 @@ Matrix32 Matrix32::scaled(const Vector2& p_scale) const {
}
Matrix32 Matrix32::basis_scaled(const Vector2& p_scale) const {
Matrix32 Matrix32::basis_scaled(const Size2& p_scale) const {
Matrix32 copy=*this;
copy.scale_basis(p_scale);
@@ -629,8 +623,8 @@ Matrix32 Matrix32::interpolate_with(const Matrix32& p_transform, float p_c) cons
real_t r1 = get_rotation();
real_t r2 = p_transform.get_rotation();
Vector2 s1 = get_scale();
Vector2 s2 = p_transform.get_scale();
Size2 s1 = get_scale();
Size2 s2 = p_transform.get_scale();
//slerp rotation
Vector2 v1(Math::cos(r1), Math::sin(r1));

View File

@@ -553,10 +553,8 @@ struct Rect2i {
struct Matrix32 {
Vector2 elements[3];
_FORCE_INLINE_ float tdotx(const Vector2& v) const { return elements[0][0] * v.x + elements[1][0] * v.y; }
_FORCE_INLINE_ float tdoty(const Vector2& v) const { return elements[0][1] * v.x + elements[1][1] * v.y; }
@@ -577,26 +575,25 @@ struct Matrix32 {
_FORCE_INLINE_ void set_rotation_and_scale(real_t p_phi,const Size2& p_scale);
void rotate(real_t p_phi);
void scale(const Vector2& p_scale);
void scale_basis(const Vector2& p_scale);
void scale(const Size2& p_scale);
void scale_basis(const Size2& p_scale);
void translate( real_t p_tx, real_t p_ty);
void translate( const Vector2& p_translation );
float basis_determinant() const;
Vector2 get_scale() const;
Size2 get_scale() const;
_FORCE_INLINE_ const Vector2& get_origin() const { return elements[2]; }
_FORCE_INLINE_ void set_origin(const Vector2& p_origin) { elements[2]=p_origin; }
Matrix32 scaled(const Vector2& p_scale) const;
Matrix32 basis_scaled(const Vector2& p_scale) const;
Matrix32 scaled(const Size2& p_scale) const;
Matrix32 basis_scaled(const Size2& p_scale) const;
Matrix32 translated(const Vector2& p_offset) const;
Matrix32 rotated(float p_phi) const;
Matrix32 untranslated() const;
void orthonormalize();
Matrix32 orthonormalized() const;
@@ -615,13 +612,20 @@ struct Matrix32 {
_FORCE_INLINE_ Rect2 xform(const Rect2& p_vec) const;
_FORCE_INLINE_ Rect2 xform_inv(const Rect2& p_vec) const;
operator String() const;
Matrix32(real_t xx, real_t xy, real_t yx, real_t yy, real_t ox, real_t oy) {
elements[0][0] = xx;
elements[0][1] = xy;
elements[1][0] = yx;
elements[1][1] = yy;
elements[2][0] = ox;
elements[2][1] = oy;
}
Matrix32(real_t p_rot, const Vector2& p_pos);
Matrix32() { elements[0][0]=1.0; elements[1][1]=1.0; }
};
bool Rect2::intersects_transformed(const Matrix32& p_xform, const Rect2& p_rect) const {

View File

@@ -71,7 +71,7 @@ bool Triangulate::is_inside_triangle(float Ax, float Ay,
return ((aCROSSbp >= 0.0f) && (bCROSScp >= 0.0f) && (cCROSSap >= 0.0f));
};
bool Triangulate::snip(const Vector<Vector2> &p_contour,int u,int v,int w,int n,int *V)
bool Triangulate::snip(const Vector<Vector2> &p_contour,int u,int v,int w,int n,const Vector<int>& V)
{
int p;
float Ax, Ay, Bx, By, Cx, Cy, Px, Py;
@@ -107,8 +107,8 @@ bool Triangulate::triangulate(const Vector<Vector2> &contour,Vector<int> &result
if ( n < 3 ) return false;
int *V = (int*)alloca(sizeof(int)*n);
Vector<int> V;
V.resize(n);
/* we want a counter-clockwise polygon in V */
@@ -122,7 +122,7 @@ bool Triangulate::triangulate(const Vector<Vector2> &contour,Vector<int> &result
/* remove nv-2 Vertices, creating 1 triangle every time */
int count = 2*nv; /* error detection */
for(int m=0, v=nv-1; nv>2; )
for(int v=nv-1; nv>2; )
{
/* if we loop, it is probably a non-simple polygon */
if (0 >= (count--))
@@ -144,18 +144,10 @@ bool Triangulate::triangulate(const Vector<Vector2> &contour,Vector<int> &result
a = V[u]; b = V[v]; c = V[w];
/* output Triangle */
/*
result.push_back( contour[a] );
result.push_back( contour[b] );
result.push_back( contour[c] );
*/
result.push_back( a );
result.push_back( b );
result.push_back( c );
m++;
/* remove v from remaining polygon */
for(s=v,t=v+1;t<nv;s++,t++) V[s] = V[t]; nv--;

View File

@@ -56,7 +56,7 @@ public:
private:
static bool snip(const Vector<Vector2> &p_contour,int u,int v,int w,int n,int *V);
static bool snip(const Vector<Vector2> &p_contour,int u,int v,int w,int n,const Vector<int>& V);
};

View File

@@ -49,13 +49,13 @@ void Vector3::set_axis(int p_axis,real_t p_value) {
}
real_t Vector3::get_axis(int p_axis) const {
ERR_FAIL_INDEX_V(p_axis,3,0);
return operator[](p_axis);
ERR_FAIL_INDEX_V(p_axis,3,0);
return operator[](p_axis);
}
int Vector3::min_axis() const {
return x < y ? (x < z ? 0 : 2) : (y < z ? 1 : 2);
return x < y ? (x < z ? 0 : 2) : (y < z ? 1 : 2);
}
int Vector3::max_axis() const {
@@ -75,9 +75,9 @@ void Vector3::snap(float p_val) {
}
Vector3 Vector3::snapped(float p_val) const {
Vector3 v=*this;
v.snap(p_val);
return v;
Vector3 v=*this;
v.snap(p_val);
return v;
}

View File

@@ -63,77 +63,78 @@ struct Vector3 {
return coord[p_axis];
}
void set_axis(int p_axis,real_t p_value);
real_t get_axis(int p_axis) const;
void set_axis(int p_axis,real_t p_value);
real_t get_axis(int p_axis) const;
int min_axis() const;
int max_axis() const;
int min_axis() const;
int max_axis() const;
_FORCE_INLINE_ real_t length() const;
_FORCE_INLINE_ real_t length_squared() const;
_FORCE_INLINE_ real_t length() const;
_FORCE_INLINE_ real_t length_squared() const;
_FORCE_INLINE_ void normalize();
_FORCE_INLINE_ Vector3 normalized() const;
_FORCE_INLINE_ Vector3 inverse() const;
_FORCE_INLINE_ void normalize();
_FORCE_INLINE_ Vector3 normalized() const;
_FORCE_INLINE_ Vector3 inverse() const;
_FORCE_INLINE_ void zero();
void snap(float p_val);
Vector3 snapped(float p_val) const;
void snap(float p_val);
Vector3 snapped(float p_val) const;
void rotate(const Vector3& p_axis,float p_phi);
Vector3 rotated(const Vector3& p_axis,float p_phi) const;
/* Static Methods between 2 vector3s */
/* Static Methods between 2 vector3s */
_FORCE_INLINE_ Vector3 linear_interpolate(const Vector3& p_b,float p_t) const;
_FORCE_INLINE_ Vector3 linear_interpolate(const Vector3& p_b,float p_t) const;
Vector3 cubic_interpolate(const Vector3& p_b,const Vector3& p_pre_a, const Vector3& p_post_b,float p_t) const;
Vector3 cubic_interpolaten(const Vector3& p_b,const Vector3& p_pre_a, const Vector3& p_post_b,float p_t) const;
_FORCE_INLINE_ Vector3 cross(const Vector3& p_b) const;
_FORCE_INLINE_ real_t dot(const Vector3& p_b) const;
_FORCE_INLINE_ Vector3 cross(const Vector3& p_b) const;
_FORCE_INLINE_ real_t dot(const Vector3& p_b) const;
_FORCE_INLINE_ Vector3 abs() const;
_FORCE_INLINE_ Vector3 floor() const;
_FORCE_INLINE_ Vector3 ceil() const;
_FORCE_INLINE_ Vector3 abs() const;
_FORCE_INLINE_ Vector3 floor() const;
_FORCE_INLINE_ Vector3 ceil() const;
_FORCE_INLINE_ real_t distance_to(const Vector3& p_b) const;
_FORCE_INLINE_ real_t distance_squared_to(const Vector3& p_b) const;
_FORCE_INLINE_ real_t distance_to(const Vector3& p_b) const;
_FORCE_INLINE_ real_t distance_squared_to(const Vector3& p_b) const;
_FORCE_INLINE_ real_t angle_to(const Vector3& p_b) const;
_FORCE_INLINE_ Vector3 slide(const Vector3& p_vec) const;
_FORCE_INLINE_ Vector3 reflect(const Vector3& p_vec) const;
/* Operators */
/* Operators */
_FORCE_INLINE_ Vector3& operator+=(const Vector3& p_v);
_FORCE_INLINE_ Vector3 operator+(const Vector3& p_v) const;
_FORCE_INLINE_ Vector3& operator-=(const Vector3& p_v);
_FORCE_INLINE_ Vector3 operator-(const Vector3& p_v) const;
_FORCE_INLINE_ Vector3& operator*=(const Vector3& p_v);
_FORCE_INLINE_ Vector3 operator*(const Vector3& p_v) const;
_FORCE_INLINE_ Vector3& operator/=(const Vector3& p_v);
_FORCE_INLINE_ Vector3 operator/(const Vector3& p_v) const;
_FORCE_INLINE_ Vector3& operator+=(const Vector3& p_v);
_FORCE_INLINE_ Vector3 operator+(const Vector3& p_v) const;
_FORCE_INLINE_ Vector3& operator-=(const Vector3& p_v);
_FORCE_INLINE_ Vector3 operator-(const Vector3& p_v) const;
_FORCE_INLINE_ Vector3& operator*=(const Vector3& p_v);
_FORCE_INLINE_ Vector3 operator*(const Vector3& p_v) const;
_FORCE_INLINE_ Vector3& operator/=(const Vector3& p_v);
_FORCE_INLINE_ Vector3 operator/(const Vector3& p_v) const;
_FORCE_INLINE_ Vector3& operator*=(real_t p_scalar);
_FORCE_INLINE_ Vector3 operator*(real_t p_scalar) const;
_FORCE_INLINE_ Vector3& operator/=(real_t p_scalar);
_FORCE_INLINE_ Vector3 operator/(real_t p_scalar) const;
_FORCE_INLINE_ Vector3& operator*=(real_t p_scalar);
_FORCE_INLINE_ Vector3 operator*(real_t p_scalar) const;
_FORCE_INLINE_ Vector3& operator/=(real_t p_scalar);
_FORCE_INLINE_ Vector3 operator/(real_t p_scalar) const;
_FORCE_INLINE_ Vector3 operator-() const;
_FORCE_INLINE_ Vector3 operator-() const;
_FORCE_INLINE_ bool operator==(const Vector3& p_v) const;
_FORCE_INLINE_ bool operator!=(const Vector3& p_v) const;
_FORCE_INLINE_ bool operator<(const Vector3& p_v) const;
_FORCE_INLINE_ bool operator==(const Vector3& p_v) const;
_FORCE_INLINE_ bool operator!=(const Vector3& p_v) const;
_FORCE_INLINE_ bool operator<(const Vector3& p_v) const;
_FORCE_INLINE_ bool operator<=(const Vector3& p_v) const;
operator String() const;
_FORCE_INLINE_ Vector3() { x=y=z=0; }
_FORCE_INLINE_ Vector3(real_t p_x,real_t p_y,real_t p_z) { x=p_x; y=p_y; z=p_z; }
_FORCE_INLINE_ Vector3() { x=y=z=0; }
_FORCE_INLINE_ Vector3(real_t p_x,real_t p_y,real_t p_z) { x=p_x; y=p_y; z=p_z; }
};
@@ -151,11 +152,12 @@ Vector3 Vector3::cross(const Vector3& p_b) const {
(x * p_b.y) - (y * p_b.x)
);
return ret;
return ret;
}
real_t Vector3::dot(const Vector3& p_b) const {
return x*p_b.x + y*p_b.y + z*p_b.z;
return x*p_b.x + y*p_b.y + z*p_b.z;
}
Vector3 Vector3::abs() const {
@@ -180,115 +182,119 @@ Vector3 Vector3::linear_interpolate(const Vector3& p_b,float p_t) const {
y+(p_t * (p_b.y-y)),
z+(p_t * (p_b.z-z))
);
}
real_t Vector3::distance_to(const Vector3& p_b) const {
return (p_b-*this).length();
}
real_t Vector3::distance_squared_to(const Vector3& p_b) const {
return (p_b-*this).length_squared();
return (p_b-*this).length_squared();
}
real_t Vector3::angle_to(const Vector3& p_b) const {
return Math::acos(this->dot(p_b) / Math::sqrt(this->length_squared() * p_b.length_squared()));
}
/* Operators */
Vector3& Vector3::operator+=(const Vector3& p_v) {
x+=p_v.x;
y+=p_v.y;
z+=p_v.z;
return *this;
x+=p_v.x;
y+=p_v.y;
z+=p_v.z;
return *this;
}
Vector3 Vector3::operator+(const Vector3& p_v) const {
return Vector3(x+p_v.x, y+p_v.y, z+ p_v.z);
return Vector3(x+p_v.x, y+p_v.y, z+ p_v.z);
}
Vector3& Vector3::operator-=(const Vector3& p_v) {
x-=p_v.x;
y-=p_v.y;
z-=p_v.z;
return *this;
x-=p_v.x;
y-=p_v.y;
z-=p_v.z;
return *this;
}
Vector3 Vector3::operator-(const Vector3& p_v) const {
return Vector3(x-p_v.x, y-p_v.y, z- p_v.z);
return Vector3(x-p_v.x, y-p_v.y, z- p_v.z);
}
Vector3& Vector3::operator*=(const Vector3& p_v) {
x*=p_v.x;
y*=p_v.y;
z*=p_v.z;
return *this;
x*=p_v.x;
y*=p_v.y;
z*=p_v.z;
return *this;
}
Vector3 Vector3::operator*(const Vector3& p_v) const {
return Vector3(x*p_v.x, y*p_v.y, z* p_v.z);
return Vector3(x*p_v.x, y*p_v.y, z* p_v.z);
}
Vector3& Vector3::operator/=(const Vector3& p_v) {
x/=p_v.x;
y/=p_v.y;
z/=p_v.z;
return *this;
x/=p_v.x;
y/=p_v.y;
z/=p_v.z;
return *this;
}
Vector3 Vector3::operator/(const Vector3& p_v) const {
return Vector3(x/p_v.x, y/p_v.y, z/ p_v.z);
return Vector3(x/p_v.x, y/p_v.y, z/ p_v.z);
}
Vector3& Vector3::operator*=(real_t p_scalar) {
x*=p_scalar;
y*=p_scalar;
z*=p_scalar;
return *this;
x*=p_scalar;
y*=p_scalar;
z*=p_scalar;
return *this;
}
_FORCE_INLINE_ Vector3 operator*(real_t p_scalar, const Vector3& p_vec) {
return p_vec * p_scalar;
}
Vector3 Vector3::operator*(real_t p_scalar) const {
return Vector3( x*p_scalar, y*p_scalar, z*p_scalar);
return Vector3( x*p_scalar, y*p_scalar, z*p_scalar);
}
Vector3& Vector3::operator/=(real_t p_scalar) {
x/=p_scalar;
y/=p_scalar;
z/=p_scalar;
return *this;
x/=p_scalar;
y/=p_scalar;
z/=p_scalar;
return *this;
}
Vector3 Vector3::operator/(real_t p_scalar) const {
return Vector3( x/p_scalar, y/p_scalar, z/p_scalar);
return Vector3( x/p_scalar, y/p_scalar, z/p_scalar);
}
Vector3 Vector3::operator-() const {
return Vector3( -x, -y, -z );
return Vector3( -x, -y, -z );
}
bool Vector3::operator==(const Vector3& p_v) const {
return (x==p_v.x && y==p_v.y && z==p_v.z);
return (x==p_v.x && y==p_v.y && z==p_v.z);
}
bool Vector3::operator!=(const Vector3& p_v) const {
return (x!=p_v.x || y!=p_v.y || z!=p_v.z);
return (x!=p_v.x || y!=p_v.y || z!=p_v.z);
}
bool Vector3::operator<(const Vector3& p_v) const {
@@ -298,9 +304,9 @@ bool Vector3::operator<(const Vector3& p_v) const {
return z<p_v.z;
else
return y<p_v.y;
} else
} else {
return x<p_v.x;
}
}
bool Vector3::operator<=(const Vector3& p_v) const {
@@ -310,9 +316,9 @@ bool Vector3::operator<=(const Vector3& p_v) const {
return z<=p_v.z;
else
return y<p_v.y;
} else
} else {
return x<p_v.x;
}
}
_FORCE_INLINE_ Vector3 vec3_cross(const Vector3& p_a, const Vector3& p_b) {
@@ -333,6 +339,7 @@ real_t Vector3::length() const {
return Math::sqrt(x2+y2+z2);
}
real_t Vector3::length_squared() const {
real_t x2=x*x;
@@ -340,27 +347,25 @@ real_t Vector3::length_squared() const {
real_t z2=z*z;
return x2+y2+z2;
}
void Vector3::normalize() {
real_t l=length();
if (l==0) {
real_t l=length();
if (l==0) {
x=y=z=0;
} else {
} else {
x/=l;
y/=l;
z/=l;
}
}
}
Vector3 Vector3::normalized() const {
Vector3 v=*this;
v.normalize();
return v;
Vector3 v=*this;
v.normalize();
return v;
}
Vector3 Vector3::inverse() const {
@@ -377,10 +382,10 @@ Vector3 Vector3::slide(const Vector3& p_vec) const {
return p_vec - *this * this->dot(p_vec);
}
Vector3 Vector3::reflect(const Vector3& p_vec) const {
return p_vec - *this * this->dot(p_vec) * 2.0;
}
#endif

View File

@@ -1152,6 +1152,15 @@ void Object::emit_signal(const StringName& p_name,const Variant** p_args,int p_a
Signal *s = signal_map.getptr(p_name);
if (!s) {
#ifdef DEBUG_ENABLED
bool signal_is_valid = ObjectTypeDB::has_signal(get_type_name(),p_name);
//check in script
if (!signal_is_valid && !script.is_null() && !Ref<Script>(script)->has_script_signal(p_name)) {
ERR_EXPLAIN("Can't emit non-existing signal " + String("\"")+p_name+"\".");
ERR_FAIL();
}
#endif
//not connected? just return
return;
}

View File

@@ -1,5 +1,7 @@
#!/usr/bin/env python
Import('env')
env.add_source_files(env.core_sources,"*.cpp")
env.add_source_files(env.core_sources, "*.cpp")
Export('env')

View File

@@ -31,89 +31,18 @@
#include "typedefs.h"
///@TODO use optimized routines for this, depending on platform. these are just the standard ones
#ifdef PLATFORM_COPYMEM
#define copymem(m_to,m_from,m_count) \
do { \
unsigned char * _from=(unsigned char*)m_from; \
unsigned char * _to=(unsigned char*)m_to; \
int _count=m_count; \
for (int _i=0;_i<_count;_i++) \
_to[_i]=_from[_i]; \
} while (0);
/*
case 0: *_dto++ = *_dfrom++; \
case 7: *_dto++ = *_dfrom++; \
case 6: *_dto++ = *_dfrom++; \
case 5: *_dto++ = *_dfrom++; \
case 4: *_dto++ = *_dfrom++; \
case 3: *_dto++ = *_dfrom++; \
case 2: *_dto++ = *_dfrom++; \
case 1: *_dto++ = *_dfrom++; \
*/
#define movemem_duff(m_to, m_from, m_count) \
do { \
if (m_to<m_from) { \
unsigned char* _dto = (unsigned char*)m_to; \
unsigned char* _dfrom = (unsigned char*)m_from; \
int n = (m_count + 7) / 8; \
switch (m_count % 8) { \
do { \
case 0: *_dto++ = *_dfrom++; \
case 7: *_dto++ = *_dfrom++; \
case 6: *_dto++ = *_dfrom++; \
case 5: *_dto++ = *_dfrom++; \
case 4: *_dto++ = *_dfrom++; \
case 3: *_dto++ = *_dfrom++; \
case 2: *_dto++ = *_dfrom++; \
case 1: *_dto++ = *_dfrom++; \
} while (--n > 0); \
}; \
} else if (m_to>m_from) { \
unsigned char* _dto = &((unsigned char*)m_to)[m_count-1]; \
unsigned char* _dfrom = &((unsigned char*)m_from)[m_count-1]; \
int n = (m_count + 7) / 8; \
switch (m_count % 8) { \
do { \
case 0: *_dto-- = *_dfrom--; \
case 7: *_dto-- = *_dfrom--; \
case 6: *_dto-- = *_dfrom--; \
case 5: *_dto-- = *_dfrom--; \
case 4: *_dto-- = *_dfrom--; \
case 3: *_dto-- = *_dfrom--; \
case 2: *_dto-- = *_dfrom--; \
case 1: *_dto-- = *_dfrom--; \
} while (--n > 0); \
}; \
} \
} while(0) \
#include "platform_copymem.h" // included from platform/<current_platform>/platform_copymem.h"
#define movemem_conventional(m_to,m_from,m_count) \
do { \
if (m_to<m_from) { \
unsigned char * _from=(unsigned char*)m_from; \
unsigned char * _to=(unsigned char*)m_to; \
int _count=m_count; \
for (int _i=0;_i<_count;_i++) \
_to[_i]=_from[_i]; \
\
} else if (m_to>m_from) { \
unsigned char * _from=(unsigned char*)m_from; \
unsigned char * _to=(unsigned char*)m_to; \
int _count=m_count; \
while (_count--) \
_to[_count]=_from[_count]; \
\
\
} \
} while (0); \
#else
void movemem_system(void*,void*,int);
#include <string.h>
#define movemem movemem_system
void zeromem(void* p_mem,size_t p_bytes);
#define copymem(to,from,count) memcpy(to,from,count)
#define zeromem(to, count) memset(to, 0, count)
#define movemem(to, from, count) memmove(to, from, count)
#endif
#endif

View File

@@ -62,6 +62,10 @@ void Input::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_connected_joysticks"),&Input::get_connected_joysticks);
ObjectTypeDB::bind_method(_MD("get_joy_vibration_strength", "device"), &Input::get_joy_vibration_strength);
ObjectTypeDB::bind_method(_MD("get_joy_vibration_duration", "device"), &Input::get_joy_vibration_duration);
ObjectTypeDB::bind_method(_MD("get_joy_button_string", "button_index"), &Input::get_joy_button_string);
ObjectTypeDB::bind_method(_MD("get_joy_button_index_from_string", "button"), &Input::get_joy_button_index_from_string);
ObjectTypeDB::bind_method(_MD("get_joy_axis_string", "axis_index"), &Input::get_joy_axis_string);
ObjectTypeDB::bind_method(_MD("get_joy_axis_index_from_string", "axis"), &Input::get_joy_axis_index_from_string);
ObjectTypeDB::bind_method(_MD("start_joy_vibration", "device", "weak_magnitude", "strong_magnitude", "duration"), &Input::start_joy_vibration, DEFVAL(0));
ObjectTypeDB::bind_method(_MD("stop_joy_vibration", "device"), &Input::stop_joy_vibration);
ObjectTypeDB::bind_method(_MD("get_accelerometer"),&Input::get_accelerometer);

View File

@@ -94,6 +94,11 @@ public:
virtual void set_custom_mouse_cursor(const RES& p_cursor,const Vector2& p_hotspot=Vector2())=0;
virtual void set_mouse_in_window(bool p_in_window)=0;
virtual String get_joy_button_string(int p_button)=0;
virtual String get_joy_axis_string(int p_axis)=0;
virtual int get_joy_button_index_from_string(String p_button)=0;
virtual int get_joy_axis_index_from_string(String p_axis)=0;
Input();
};

View File

@@ -34,8 +34,57 @@
*/
bool InputEvent::operator==(const InputEvent &p_event) const {
if (type != p_event.type){
return false;
}
return true;
switch(type) {
case NONE:
return true;
case KEY:
return key.unicode == p_event.key.unicode
&& key.scancode == p_event.key.scancode
&& key.echo == p_event.key.echo
&& key.pressed == p_event.key.pressed
&& key.mod == p_event.key.mod;
case MOUSE_MOTION:
return mouse_motion.x == p_event.mouse_motion.x
&& mouse_motion.y == p_event.mouse_motion.y
&& mouse_motion.relative_x == p_event.mouse_motion.relative_x
&& mouse_motion.relative_y == p_event.mouse_motion.relative_y
&& mouse_motion.button_mask == p_event.mouse_motion.button_mask
&& key.mod == p_event.key.mod;
case MOUSE_BUTTON:
return mouse_button.pressed == p_event.mouse_button.pressed
&& mouse_button.x == p_event.mouse_button.x
&& mouse_button.y == p_event.mouse_button.y
&& mouse_button.button_index == p_event.mouse_button.button_index
&& mouse_button.button_mask == p_event.mouse_button.button_mask
&& key.mod == p_event.key.mod;
case JOYSTICK_MOTION:
return joy_motion.axis == p_event.joy_motion.axis
&& joy_motion.axis_value == p_event.joy_motion.axis_value;
case JOYSTICK_BUTTON:
return joy_button.pressed == p_event.joy_button.pressed
&& joy_button.button_index == p_event.joy_button.button_index
&& joy_button.pressure == p_event.joy_button.pressure;
case SCREEN_TOUCH:
return screen_touch.pressed == p_event.screen_touch.pressed
&& screen_touch.index == p_event.screen_touch.index
&& screen_touch.x == p_event.screen_touch.x
&& screen_touch.y == p_event.screen_touch.y;
case SCREEN_DRAG:
return screen_drag.index == p_event.screen_drag.index
&& screen_drag.x == p_event.screen_drag.x
&& screen_drag.y == p_event.screen_drag.y;
case ACTION:
return action.action == p_event.action.action
&& action.pressed == p_event.action.pressed;
default:
ERR_PRINT("No logic to compare InputEvents of this type, this shouldn't happen.");
}
return false;
}
InputEvent::operator String() const {
@@ -156,7 +205,7 @@ bool InputEvent::is_pressed() const {
case MOUSE_BUTTON: return mouse_button.pressed;
case JOYSTICK_BUTTON: return joy_button.pressed;
case SCREEN_TOUCH: return screen_touch.pressed;
case JOYSTICK_MOTION: return InputMap::get_singleton()->event_is_joy_motion_action_pressed(*this);
case JOYSTICK_MOTION: return ABS(joy_motion.axis_value) > 0.5;
case ACTION: return action.pressed;
default: {}
}

View File

@@ -542,7 +542,7 @@ void OS::set_use_vsync(bool p_enable) {
}
bool OS::is_vsnc_enabled() const{
bool OS::is_vsync_enabled() const{
return true;
}

View File

@@ -364,6 +364,7 @@ public:
virtual void set_screen_orientation(ScreenOrientation p_orientation);
ScreenOrientation get_screen_orientation() const;
virtual void enable_for_stealing_focus(ProcessID pid) {}
virtual void move_window_to_foreground() {}
virtual void debug_break();
@@ -422,7 +423,7 @@ public:
virtual void set_context(int p_context);
virtual void set_use_vsync(bool p_enable);
virtual bool is_vsnc_enabled() const;
virtual bool is_vsync_enabled() const;
Dictionary get_engine_version() const;

View File

@@ -33,6 +33,7 @@
#include "io/config_file.h"
#include "os/main_loop.h"
#include "io/packet_peer.h"
#include "math/a_star.h"
#include "globals.h"
#include "object_type_db.h"
#include "geometry.h"
@@ -48,6 +49,7 @@
#include "os/input.h"
#include "core/io/xml_parser.h"
#include "io/http_client.h"
#include "io/pck_packer.h"
#include "packed_data_container.h"
#include "func_ref.h"
#include "input_map.h"
@@ -144,8 +146,11 @@ void register_core_types() {
ObjectTypeDB::register_type<ConfigFile>();
ObjectTypeDB::register_type<PCKPacker>();
ObjectTypeDB::register_type<PackedDataContainer>();
ObjectTypeDB::register_virtual_type<PackedDataContainerRef>();
ObjectTypeDB::register_type<AStar>();
ip = IP::create();

View File

@@ -134,6 +134,8 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script,bool p_can_continue) {
ERR_FAIL();
}
OS::get_singleton()->enable_for_stealing_focus(Globals::get_singleton()->get("editor_pid"));
packet_peer_stream->put_var("debug_enter");
packet_peer_stream->put_var(2);
packet_peer_stream->put_var(p_can_continue);
@@ -219,7 +221,8 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script,bool p_can_continue) {
if (F->get().get_type()==Variant::OBJECT) {
packet_peer_stream->put_var("*"+E->get());
packet_peer_stream->put_var(safe_get_instance_id(F->get()));
String pretty_print = F->get().operator String();
packet_peer_stream->put_var(pretty_print.ascii().get_data());
} else {
packet_peer_stream->put_var(E->get());
packet_peer_stream->put_var(F->get());
@@ -242,7 +245,8 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script,bool p_can_continue) {
if (F->get().get_type()==Variant::OBJECT) {
packet_peer_stream->put_var("*"+E->get());
packet_peer_stream->put_var(safe_get_instance_id(F->get()));
String pretty_print = F->get().operator String();
packet_peer_stream->put_var(pretty_print.ascii().get_data());
} else {
packet_peer_stream->put_var(E->get());
packet_peer_stream->put_var(F->get());
@@ -271,6 +275,7 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script,bool p_can_continue) {
set_depth(-1);
set_lines_left(-1);
OS::get_singleton()->move_window_to_foreground();
break;
} else if (command=="break") {
ERR_PRINT("Got break when already broke!");

View File

@@ -32,11 +32,23 @@
#include "os/os.h"
static const char* locale_list[]={
"aa", // Afar
"aa_DJ", // Afar (Djibouti)
"aa_ER", // Afar (Eritrea)
"aa_ET", // Afar (Ethiopia)
"af", // Afrikaans
"af_ZA", // Afrikaans (South Africa)
"agr_PE", // Aguaruna (Peru)
"ak_GH", // Akan (Ghana)
"am_ET", // Amharic (Ethiopia)
"an_ES", // Aragonese (Spain)
"anp_IN", // Angika (India)
"ar", // Arabic
"ar_AE", // Arabic (United Arab Emirates)
"ar_BH", // Arabic (Bahrain)
"ar_DZ", // Arabic (Algeria)
"ar_EG", // Arabic (Egypt)
"ar_IN", // Arabic (India)
"ar_IQ", // Arabic (Iraq)
"ar_JO", // Arabic (Jordan)
"ar_KW", // Arabic (Kuwait)
@@ -47,48 +59,91 @@ static const char* locale_list[]={
"ar_QA", // Arabic (Qatar)
"ar_SA", // Arabic (Saudi Arabia)
"ar_SD", // Arabic (Sudan)
"ar_SS", // Arabic (South Soudan)
"ar_SY", // Arabic (Syria)
"ar_TN", // Arabic (Tunisia)
"ar_YE", // Arabic (Yemen)
"as_IN", // Assamese (India)
"ast_ES", // Asturian (Spain)
"ayc_PE", // Southern Aymara (Peru)
"ay_PE", // Aymara (Peru)
"az_AZ", // Azerbaijani (Azerbaijan)
"be", // Belarusian
"be_BY", // Belarusian (Belarus)
"bem_ZM", // Bemba (Zambia)
"ber_DZ", // Berber languages (Algeria)
"ber_MA", // Berber languages (Morocco)
"bg", // Bulgarian
"bg_BG", // Bulgarian (Bulgaria)
"bhb_IN", // Bhili (India)
"bho_IN", // Bhojpuri (India)
"bi_TV", // Bislama (Tuvalu)
"bn", // Bengali
"bn_BD", // Bengali (Bangladesh)
"bn_IN", // Bengali (India)
"bo", // Tibetan
"bo_CN", // Tibetan (China)
"bo_IN", // Tibetan (India)
"br_FR", // Breton (France)
"brx_IN", // Bodo (India)
"bs_BA", // Bosnian (Bosnia and Herzegovina)
"byn_ER", // Bilin (Eritrea)
"ca", // Catalan
"ca_AD", // Catalan (Andorra)
"ca_ES", // Catalan (Spain)
"ca_FR", // Catalan (France)
"ca_IT", // Catalan (Italy)
"ce_RU", // Chechen (Russia)
"chr_US", // Cherokee (United States)
"cmn_TW", // Mandarin Chinese (Taiwan)
"crh_UA", // Crimean Tatar (Ukraine)
"csb_PL", // Kashubian (Poland)
"cs", // Czech
"cs_CZ", // Czech (Czech Republic)
"cv_RU", // Chuvash (Russia)
"cy_GB", // Welsh (United Kingdom)
"da", // Danish
"da_DK", // Danish (Denmark)
"de", // German
"de_AT", // German (Austria)
"de_BE", // German (Belgium)
"de_CH", // German (Switzerland)
"de_DE", // German (Germany)
"de_IT", // German (Italy)
"de_LU", // German (Luxembourg)
"doi_IN", // Dogri (India)
"dv_MV", // Dhivehi (Maldives)
"dz_BT", // Dzongkha (Bhutan)
"el", // Greek
"el_CY", // Greek (Cyprus)
"el_GR", // Greek (Greece)
"en", // English
"en_AG", // English (Antigua and Barbuda)
"en_AU", // English (Australia)
"en_BW", // English (Botswana)
"en_CA", // English (Canada)
"en_DK", // English (Denmark)
"en_GB", // English (United Kingdom)
"en_HK", // English (Hong Kong)
"en_IE", // English (Ireland)
"en_IL", // English (Israel)
"en_IN", // English (India)
"en_MT", // English (Malta)
"en_NG", // English (Nigeria)
"en_NZ", // English (New Zealand)
"en_PH", // English (Philippines)
"en_SG", // English (Singapore)
"en_US", // English (United States)
"en_ZA", // English (South Africa)
"en_ZM", // English (Zambia)
"en_ZW", // English (Zimbabwe)
"eo", // Esperanto
"es", // Spanish
"es_AR", // Spanish (Argentina)
"es_BO", // Spanish (Bolivia)
"es_CL", // Spanish (Chile)
"es_CO", // Spanish (Colombia)
"es_CR", // Spanish (Costa Rica)
"es_CU", // Spanish (Cuba)
"es_DO", // Spanish (Dominican Republic)
"es_EC", // Spanish (Ecuador)
"es_ES", // Spanish (Spain)
@@ -106,100 +161,252 @@ static const char* locale_list[]={
"es_VE", // Spanish (Venezuela)
"et", // Estonian
"et_EE", // Estonian (Estonia)
"eu", // Basque
"eu_ES", // Basque (Spain)
"fa", // Persian
"fa_IR", // Persian (Iran)
"ff_SN", // Fulah (Senegal)
"fi", // Finnish
"fi_FI", // Finnish (Finland)
"fil_PH", // Filipino (Philippines)
"fo_FO", // Faroese (Faroe Islands)
"fr", // French
"fr_BE", // French (Belgium)
"fr_CA", // French (Canada)
"fr_CH", // French (Switzerland)
"fr_FR", // French (France)
"fr_LU", // French (Luxembourg)
"fur_IT", // Friulian (Italy)
"fy_DE", // Western Frisian (Germany)
"fy_NL", // Western Frisian (Netherlands)
"ga", // Irish
"ga_IE", // Irish (Ireland)
"hi", // Hindi (India)
"gd_GB", // Scottish Gaelic (United Kingdom)
"gez_ER", // Geez (Eritrea)
"gez_ET", // Geez (Ethiopia)
"gl_ES", // Galician (Spain)
"gu_IN", // Gujarati (India)
"gv_GB", // Manx (United Kingdom)
"hak_TW", // Hakka Chinese (Taiwan)
"ha_NG", // Hausa (Nigeria)
"he", // Hebrew
"he_IL", // Hebrew (Israel)
"hi", // Hindi
"hi_IN", // Hindi (India)
"hne_IN", // Chhattisgarhi (India)
"hr", // Croatian
"hr_HR", // Croatian (Croatia)
"hsb_DE", // Upper Sorbian (Germany)
"ht_HT", // Haitian (Haiti)
"hu", // Hungarian
"hu_HU", // Hungarian (Hungary)
"in", // Indonesian
"in_ID", // Indonesian (Indonesia)
"hus_MX", // Huastec (Mexico)
"hy_AM", // Armenian (Armenia)
"ia_FR", // Interlingua (France)
"id", // Indonesian
"id_ID", // Indonesian (Indonesia)
"ig_NG", // Igbo (Nigeria)
"ik_CA", // Inupiaq (Canada)
"is", // Icelandic
"is_IS", // Icelandic (Iceland)
"it", // Italian
"it_CH", // Italian (Switzerland)
"it_IT", // Italian (Italy)
"iw", // Hebrew
"iw_IL", // Hebrew (Israel)
"iu_CA", // Inuktitut (Canada)
"ja", // Japanese
"ja_JP", // Japanese (Japan)
"ja_JP_JP", // Japanese (Japan,JP)
"kab_DZ", // Kabyle (Algeria)
"ka_GE", // Georgian (Georgia)
"kk_KZ", // Kazakh (Kazakhstan)
"kl_GL", // Kalaallisut (Greenland)
"km_KH", // Central Khmer (Cambodia)
"kn_IN", // Kannada (India)
"kok_IN", // Konkani (India)
"ko", // Korean
"ko_KR", // Korean (South Korea)
"ks_IN", // Kashmiri (India)
"ku", // Kurdish
"ku_TR", // Kurdish (Turkey)
"kw_GB", // Cornish (United Kingdom)
"ky_KG", // Kirghiz (Kyrgyzstan)
"lb_LU", // Luxembourgish (Luxembourg)
"lg_UG", // Ganda (Uganda)
"li_BE", // Limburgan (Belgium)
"li_NL", // Limburgan (Netherlands)
"lij_IT", // Ligurian (Italy)
"ln_CD", // Lingala (Congo)
"lo_LA", // Lao (Laos)
"lt", // Lithuanian
"lt_LT", // Lithuanian (Lithuania)
"lv", // Latvian
"lv_LV", // Latvian (Latvia)
"lzh_TW", // Literary Chinese (Taiwan)
"mag_IN", // Magahi (India)
"mai_IN", // Maithili (India)
"mg_MG", // Malagasy (Madagascar)
"mh_MH", // Marshallese (Marshall Islands)
"mhr_RU", // Eastern Mari (Russia)
"mi_NZ", // Maori (New Zealand)
"miq_NI", // Mískito (Nicaragua)
"mk", // Macedonian
"mk_MK", // Macedonian (Macedonia)
"ml_IN", // Malayalam (India)
"mni_IN", // Manipuri (India)
"mn_MN", // Mongolian (Mongolia)
"mr_IN", // Marathi (India)
"ms", // Malay
"ms_MY", // Malay (Malaysia)
"mt", // Maltese
"mt_MT", // Maltese (Malta)
"my_MM", // Burmese (Myanmar)
"myv_RU", // Erzya (Russia)
"nah_MX", // Nahuatl languages (Mexico)
"nan_TW", // Min Nan Chinese (Taiwan)
"nb", // Norwegian Bokmål
"nb_NO", // Norwegian Bokmål (Norway)
"nds_DE", // Low German (Germany)
"nds_NL", // Low German (Netherlands)
"ne_NP", // Nepali (Nepal)
"nhn_MX", // Central Nahuatl (Mexico)
"niu_NU", // Niuean (Niue)
"niu_NZ", // Niuean (New Zealand)
"nl", // Dutch
"nl_AW", // Dutch (Aruba)
"nl_BE", // Dutch (Belgium)
"nl_NL", // Dutch (Netherlands)
"no", // Norwegian
"no_NO", // Norwegian (Norway)
"no_NO_NY", // Norwegian (Norway,Nynorsk)
"nn", // Norwegian Nynorsk
"nn_NO", // Norwegian Nynorsk (Norway)
"nr_ZA", // South Ndebele (South Africa)
"nso_ZA", // Pedi (South Africa)
"oc_FR", // Occitan (France)
"om", // Oromo
"om_ET", // Oromo (Ethiopia)
"om_KE", // Oromo (Kenya)
"or_IN", // Oriya (India)
"os_RU", // Ossetian (Russia)
"pa_IN", // Panjabi (India)
"pap", // Papiamento
"pap_AN", // Papiamento (Netherlands Antilles)
"pap_AW", // Papiamento (Aruba)
"pap_CW", // Papiamento (Curaçao)
"pa_PK", // Panjabi (Pakistan)
"pl", // Polish
"pl_PL", // Polish (Poland)
"ps_AF", // Pushto (Afghanistan)
"pt", // Portuguese
"pt_BR", // Portuguese (Brazil)
"pt_PT", // Portuguese (Portugal)
"quy_PE", // Ayacucho Quechua (Peru)
"quz_PE", // Cusco Quechua (Peru)
"raj_IN", // Rajasthani (India)
"ro", // Romanian
"ro_RO", // Romanian (Romania)
"ru", // Russian
"ru_RU", // Russian (Russia)
"ru_UA", // Russian (Ukraine)
"rw_RW", // Kinyarwanda (Rwanda)
"sa_IN", // Sanskrit (India)
"sat_IN", // Santali (India)
"sc_IT", // Sardinian (Italy)
"sd_IN", // Sindhi (India)
"se_NO", // Northern Sami (Norway)
"sgs_LT", // Samogitian (Lithuania)
"shs_CA", // Shuswap (Canada)
"sid_ET", // Sidamo (Ethiopia)
"si_LK", // Sinhala (Sri Lanka)
"sk", // Slovak
"sk_SK", // Slovak (Slovakia)
"sl", // Slovenian
"sl_SI", // Slovenian (Slovenia)
"so", // Somali
"so_DJ", // Somali (Djibouti)
"so_ET", // Somali (Ethiopia)
"so_KE", // Somali (Kenya)
"so_SO", // Somali (Somalia)
"son_ML", // Songhai languages (Mali)
"sq", // Albanian
"sq_AL", // Albanian (Albania)
"sq_KV", // Albanian (Kosovo)
"sq_MK", // Albanian (Macedonia)
"sr", // Serbian
"sr_BA", // Serbian (Bosnia and Herzegovina)
"sr_CS", // Serbian (Serbia and Montenegro)
"sr_ME", // Serbian (Montenegro)
"sr_RS", // Serbian (Serbia)
"ss_ZA", // Swati (South Africa)
"st_ZA", // Southern Sotho (South Africa)
"sv", // Swedish
"sv_FI", // Swedish (Finland)
"sv_SE", // Swedish (Sweden)
"sw_KE", // Swahili (Kenya)
"sw_TZ", // Swahili (Tanzania)
"szl_PL", // Silesian (Poland)
"ta", // Tamil
"ta_IN", // Tamil (India)
"ta_LK", // Tamil (Sri Lanka)
"tcy_IN", // Tulu (India)
"te_IN", // Telugu (India)
"tg_TJ", // Tajik (Tajikistan)
"the_NP", // Chitwania Tharu (Nepal)
"th", // Thai
"th_TH", // Thai (Thailand)
"th_TH_TH", // Thai (Thailand,TH)
"ti", // Tigrinya
"ti_ER", // Tigrinya (Eritrea)
"ti_ET", // Tigrinya (Ethiopia)
"tig_ER", // Tigre (Eritrea)
"tk_TM", // Turkmen (Turkmenistan)
"tl_PH", // Tagalog (Philippines)
"tn_ZA", // Tswana (South Africa)
"tr", // Turkish
"tr_CY", // Turkish (Cyprus)
"tr_TR", // Turkish (Turkey)
"ts_ZA", // Tsonga (South Africa)
"tt_RU", // Tatar (Russia)
"ug_CN", // Uighur (China)
"uk", // Ukrainian
"uk_UA", // Ukrainian (Ukraine)
"unm_US", // Unami (United States)
"ur", // Urdu
"ur_IN", // Urdu (India)
"ur_PK", // Urdu (Pakistan)
"uz", // Uzbek
"uz_UZ", // Uzbek (Uzbekistan)
"ve_ZA", // Venda (South Africa)
"vi", // Vietnamese
"vi_VN", // Vietnamese (Vietnam)
"wa_BE", // Walloon (Belgium)
"wae_CH", // Walser (Switzerland)
"wal_ET", // Wolaytta (Ethiopia)
"wo_SN", // Wolof (Senegal)
"xh_ZA", // Xhosa (South Africa)
"yi_US", // Yiddish (United States)
"yo_NG", // Yoruba (Nigeria)
"yue_HK", // Yue Chinese (Hong Kong)
"zh", // Chinese
"zh_CN", // Chinese (China)
"zh_HK", // Chinese (Hong Kong)
"zh_SG", // Chinese (Singapore)
"zh_TW", // Chinese (Taiwan)
"zu_ZA", // Zulu (South Africa)
0
};
static const char* locale_names[]={
"Afar",
"Afar (Djibouti)",
"Afar (Eritrea)",
"Afar (Ethiopia)",
"Afrikaans",
"Afrikaans (South Africa)",
"Aguaruna (Peru)",
"Akan (Ghana)",
"Amharic (Ethiopia)",
"Aragonese (Spain)",
"Angika (India)",
"Arabic",
"Arabic (United Arab Emirates)",
"Arabic (Bahrain)",
"Arabic (Algeria)",
"Arabic (Egypt)",
"Arabic (India)",
"Arabic (Iraq)",
"Arabic (Jordan)",
"Arabic (Kuwait)",
@@ -210,48 +417,91 @@ static const char* locale_names[]={
"Arabic (Qatar)",
"Arabic (Saudi Arabia)",
"Arabic (Sudan)",
"Arabic (South Soudan)",
"Arabic (Syria)",
"Arabic (Tunisia)",
"Arabic (Yemen)",
"Assamese (India)",
"Asturian (Spain)",
"Southern Aymara (Peru)",
"Aymara (Peru)",
"Azerbaijani (Azerbaijan)",
"Belarusian",
"Belarusian (Belarus)",
"Bemba (Zambia)",
"Berber languages (Algeria)",
"Berber languages (Morocco)",
"Bulgarian",
"Bulgarian (Bulgaria)",
"Bhili (India)",
"Bhojpuri (India)",
"Bislama (Tuvalu)",
"Bengali",
"Bengali (Bangladesh)",
"Bengali (India)",
"Tibetan",
"Tibetan (China)",
"Tibetan (India)",
"Breton (France)",
"Bodo (India)",
"Bosnian (Bosnia and Herzegovina)",
"Bilin (Eritrea)",
"Catalan",
"Catalan (Andorra)",
"Catalan (Spain)",
"Catalan (France)",
"Catalan (Italy)",
"Chechen (Russia)",
"Cherokee (United States)",
"Mandarin Chinese (Taiwan)",
"Crimean Tatar (Ukraine)",
"Kashubian (Poland)",
"Czech",
"Czech (Czech Republic)",
"Chuvash (Russia)",
"Welsh (United Kingdom)",
"Danish",
"Danish (Denmark)",
"German",
"German (Austria)",
"German (Belgium)",
"German (Switzerland)",
"German (Germany)",
"German (Italy)",
"German (Luxembourg)",
"Dogri (India)",
"Dhivehi (Maldives)",
"Dzongkha (Bhutan)",
"Greek",
"Greek (Cyprus)",
"Greek (Greece)",
"English",
"English (Antigua and Barbuda)",
"English (Australia)",
"English (Botswana)",
"English (Canada)",
"English (Denmark)",
"English (United Kingdom)",
"English (Hong Kong)",
"English (Ireland)",
"English (Israel)",
"English (India)",
"English (Malta)",
"English (Nigeria)",
"English (New Zealand)",
"English (Philippines)",
"English (Singapore)",
"English (United States)",
"English (South Africa)",
"English (Zambia)",
"English (Zimbabwe)",
"Esperanto",
"Spanish",
"Spanish (Argentina)",
"Spanish (Bolivia)",
"Spanish (Chile)",
"Spanish (Colombia)",
"Spanish (Costa Rica)",
"Spanish (Cuba)",
"Spanish (Dominican Republic)",
"Spanish (Ecuador)",
"Spanish (Spain)",
@@ -269,91 +519,231 @@ static const char* locale_names[]={
"Spanish (Venezuela)",
"Estonian",
"Estonian (Estonia)",
"Basque",
"Basque (Spain)",
"Persian",
"Persian (Iran)",
"Fulah (Senegal)",
"Finnish",
"Finnish (Finland)",
"Filipino (Philippines)",
"Faroese (Faroe Islands)",
"French",
"French (Belgium)",
"French (Canada)",
"French (Switzerland)",
"French (France)",
"French (Luxembourg)",
"Friulian (Italy)",
"Western Frisian (Germany)",
"Western Frisian (Netherlands)",
"Irish",
"Irish (Ireland)",
"Scottish Gaelic (United Kingdom)",
"Geez (Eritrea)",
"Geez (Ethiopia)",
"Galician (Spain)",
"Gujarati (India)",
"Manx (United Kingdom)",
"Hakka Chinese (Taiwan)",
"Hausa (Nigeria)",
"Hebrew",
"Hebrew (Israel)",
"Hindi",
"Hindi (India)",
"Hindi (India)",
"Chhattisgarhi (India)",
"Croatian",
"Croatian (Croatia)",
"Upper Sorbian (Germany)",
"Haitian (Haiti)",
"Hungarian",
"Hungarian (Hungary)",
"Huastec (Mexico)",
"Armenian (Armenia)",
"Interlingua (France)",
"Indonesian",
"Indonesian (Indonesia)",
"Igbo (Nigeria)",
"Inupiaq (Canada)",
"Icelandic",
"Icelandic (Iceland)",
"Italian",
"Italian (Switzerland)",
"Italian (Italy)",
"Hebrew",
"Hebrew (Israel)",
"Inuktitut (Canada)",
"Japanese",
"Japanese (Japan)",
"Japanese (Japan JP)",
"Kabyle (Algeria)",
"Georgian (Georgia)",
"Kazakh (Kazakhstan)",
"Kalaallisut (Greenland)",
"Central Khmer (Cambodia)",
"Kannada (India)",
"Konkani (India)",
"Korean",
"Korean (South Korea)",
"Kashmiri (India)",
"Kurdish",
"Kurdish (Turkey)",
"Cornish (United Kingdom)",
"Kirghiz (Kyrgyzstan)",
"Luxembourgish (Luxembourg)",
"Ganda (Uganda)",
"Limburgan (Belgium)",
"Limburgan (Netherlands)",
"Ligurian (Italy)",
"Lingala (Congo)",
"Lao (Laos)",
"Lithuanian",
"Lithuanian (Lithuania)",
"Latvian",
"Latvian (Latvia)",
"Literary Chinese (Taiwan)",
"Magahi (India)",
"Maithili (India)",
"Malagasy (Madagascar)",
"Marshallese (Marshall Islands)",
"Eastern Mari (Russia)",
"Maori (New Zealand)",
"Mískito (Nicaragua)",
"Macedonian",
"Macedonian (Macedonia)",
"Malayalam (India)",
"Manipuri (India)",
"Mongolian (Mongolia)",
"Marathi (India)",
"Malay",
"Malay (Malaysia)",
"Maltese",
"Maltese (Malta)",
"Burmese (Myanmar)",
"Erzya (Russia)",
"Nahuatl languages (Mexico)",
"Min Nan Chinese (Taiwan)",
"Norwegian Bokmål",
"Norwegian Bokmål (Norway)",
"Low German (Germany)",
"Low German (Netherlands)",
"Nepali (Nepal)",
"Central Nahuatl (Mexico)",
"Niuean (Niue)",
"Niuean (New Zealand)",
"Dutch",
"Dutch (Aruba)",
"Dutch (Belgium)",
"Dutch (Netherlands)",
"Norwegian",
"Norwegian (Norway)",
"Norwegian (Norway Nynorsk)",
"Norwegian Nynorsk",
"Norwegian Nynorsk (Norway)",
"South Ndebele (South Africa)",
"Pedi (South Africa)",
"Occitan (France)",
"Oromo",
"Oromo (Ethiopia)",
"Oromo (Kenya)",
"Oriya (India)",
"Ossetian (Russia)",
"Panjabi (India)",
"Papiamento",
"Papiamento (Netherlands Antilles)",
"Papiamento (Aruba)",
"Papiamento (Curaçao)",
"Panjabi (Pakistan)",
"Polish",
"Polish (Poland)",
"Pushto (Afghanistan)",
"Portuguese",
"Portuguese (Brazil)",
"Portuguese (Portugal)",
"Ayacucho Quechua (Peru)",
"Cusco Quechua (Peru)",
"Rajasthani (India)",
"Romanian",
"Romanian (Romania)",
"Russian",
"Russian (Russia)",
"Russian (Ukraine)",
"Kinyarwanda (Rwanda)",
"Sanskrit (India)",
"Santali (India)",
"Sardinian (Italy)",
"Sindhi (India)",
"Northern Sami (Norway)",
"Samogitian (Lithuania)",
"Shuswap (Canada)",
"Sidamo (Ethiopia)",
"Sinhala (Sri Lanka)",
"Slovak",
"Slovak (Slovakia)",
"Slovenian",
"Slovenian (Slovenia)",
"Somali",
"Somali (Djibouti)",
"Somali (Ethiopia)",
"Somali (Kenya)",
"Somali (Somalia)",
"Songhai languages (Mali)",
"Albanian",
"Albanian (Albania)",
"Albanian (Kosovo)",
"Albanian (Macedonia)",
"Serbian",
"Serbian (Bosnia and Herzegovina)",
"Serbian (Serbia and Montenegro)",
"Serbian (Montenegro)",
"Serbian (Serbia)",
"Swati (South Africa)",
"Southern Sotho (South Africa)",
"Swedish",
"Swedish (Finland)",
"Swedish (Sweden)",
"Swahili (Kenya)",
"Swahili (Tanzania)",
"Silesian (Poland)",
"Tamil",
"Tamil (India)",
"Tamil (Sri Lanka)",
"Tulu (India)",
"Telugu (India)",
"Tajik (Tajikistan)",
"Chitwania Tharu (Nepal)",
"Thai",
"Thai (Thailand)",
"Thai (Thailand TH)",
"Tigrinya",
"Tigrinya (Eritrea)",
"Tigrinya (Ethiopia)",
"Tigre (Eritrea)",
"Turkmen (Turkmenistan)",
"Tagalog (Philippines)",
"Tswana (South Africa)",
"Turkish",
"Turkish (Cyprus)",
"Turkish (Turkey)",
"Tsonga (South Africa)",
"Tatar (Russia)",
"Uighur (China)",
"Ukrainian",
"Ukrainian (Ukraine)",
"Unami (United States)",
"Urdu",
"Urdu (India)",
"Urdu (Pakistan)",
"Uzbek",
"Uzbek (Uzbekistan)",
"Venda (South Africa)",
"Vietnamese",
"Vietnamese (Vietnam)",
"Walloon (Belgium)",
"Walser (Switzerland)",
"Wolaytta (Ethiopia)",
"Wolof (Senegal)",
"Xhosa (South Africa)",
"Yiddish (United States)",
"Yoruba (Nigeria)",
"Yue Chinese (Hong Kong)",
"Chinese",
"Chinese (China)",
"Chinese (Hong Kong)",
"Chinese (Singapore)",
"Chinese (Taiwan)",
"Zulu (South Africa)",
0
};
@@ -389,6 +779,11 @@ Vector<String> TranslationServer::get_all_locale_names(){
}
static String get_trimmed_locale(const String& p_locale) {
return p_locale.substr(0,2);
}
static bool is_valid_locale(const String& p_locale) {
const char **ptr=locale_list;
@@ -449,9 +844,20 @@ void Translation::_set_messages(const DVector<String>& p_messages){
void Translation::set_locale(const String& p_locale) {
ERR_EXPLAIN("Invalid Locale: "+p_locale);
ERR_FAIL_COND(!is_valid_locale(p_locale));
locale=p_locale;
// replaces '-' with '_' for macOS Sierra-style locales
String univ_locale = p_locale.replace("-", "_");
if(!is_valid_locale(univ_locale)) {
String trimmed_locale = get_trimmed_locale(univ_locale);
ERR_EXPLAIN("Invalid Locale: "+trimmed_locale);
ERR_FAIL_COND(!is_valid_locale(trimmed_locale));
locale=trimmed_locale;
}
else {
locale=univ_locale;
}
}
void Translation::add_message( const StringName& p_src_text, const StringName& p_xlated_text ) {
@@ -516,9 +922,20 @@ Translation::Translation() {
void TranslationServer::set_locale(const String& p_locale) {
ERR_EXPLAIN("Invalid Locale: "+p_locale);
ERR_FAIL_COND(!is_valid_locale(p_locale));
locale=p_locale;
// replaces '-' with '_' for macOS Sierra-style locales
String univ_locale = p_locale.replace("-", "_");
if(!is_valid_locale(univ_locale)) {
String trimmed_locale = get_trimmed_locale(univ_locale);
ERR_EXPLAIN("Invalid Locale: "+trimmed_locale);
ERR_FAIL_COND(!is_valid_locale(trimmed_locale));
locale=trimmed_locale;
}
else {
locale=univ_locale;
}
}
String TranslationServer::get_locale() const {

View File

@@ -52,26 +52,46 @@ void UndoRedo::_discard_redo() {
}
void UndoRedo::create_action(const String& p_name,bool p_mergeable) {
void UndoRedo::create_action(const String& p_name,MergeMode p_mode) {
if (action_level==0) {
_discard_redo();
if (p_mergeable && actions.size() && actions[actions.size()-1].name==p_name) {
//old will replace new (it's mergeable after all)
// should check references though!
// Check if the merge operation is valid
if (p_mode!=MERGE_DISABLE && actions.size() && actions[actions.size()-1].name==p_name) {
current_action=actions.size()-2;
actions[current_action+1].do_ops.clear();
//actions[current_action+1].undo_ops.clear(); - no, this is kept
merging=true;
if (p_mode==MERGE_ENDS) {
// Clear all do ops from last action, and delete all object references
List<Operation>::Element *E=actions[current_action+1].do_ops.front();
while (E) {
if (E->get().type==Operation::TYPE_REFERENCE) {
Object *obj=ObjectDB::get_instance(E->get().object);
if (obj)
memdelete(obj);
}
E=E->next();
actions[current_action+1].do_ops.pop_front();
}
}
merge_mode=p_mode;
} else {
Action new_action;
new_action.name=p_name;
actions.push_back(new_action);
merging=false;
merge_mode=MERGE_DISABLE;
}
}
@@ -102,8 +122,10 @@ void UndoRedo::add_undo_method(Object *p_object,const String& p_method,VARIANT_A
VARIANT_ARGPTRS
ERR_FAIL_COND(action_level<=0);
ERR_FAIL_COND((current_action+1)>=actions.size());
if (merging)
return; //- no undo if merging
// No undo if the merge mode is MERGE_ENDS
if (merge_mode==MERGE_ENDS)
return;
Operation undo_op;
undo_op.object=p_object->get_instance_ID();
@@ -139,6 +161,10 @@ void UndoRedo::add_undo_property(Object *p_object,const String& p_property,const
ERR_FAIL_COND(action_level<=0);
ERR_FAIL_COND((current_action+1)>=actions.size());
// No undo if the merge mode is MERGE_ENDS
if (merge_mode==MERGE_ENDS)
return;
Operation undo_op;
undo_op.object=p_object->get_instance_ID();
if (p_object->cast_to<Resource>())
@@ -167,6 +193,11 @@ void UndoRedo::add_undo_reference(Object *p_object) {
ERR_FAIL_COND(action_level<=0);
ERR_FAIL_COND((current_action+1)>=actions.size());
// No undo if the merge mode is MERGE_ENDS
if (merge_mode==MERGE_ENDS)
return;
Operation undo_op;
undo_op.object=p_object->get_instance_ID();
if (p_object->cast_to<Resource>())
@@ -352,7 +383,7 @@ UndoRedo::UndoRedo() {
action_level=0;
current_action=-1;
max_steps=-1;
merging=true;
merge_mode=MERGE_DISABLE;
callback=NULL;
callback_ud=NULL;
@@ -448,7 +479,7 @@ Variant UndoRedo::_add_undo_method(const Variant** p_args, int p_argcount, Varia
void UndoRedo::_bind_methods() {
ObjectTypeDB::bind_method(_MD("create_action","name","mergeable"),&UndoRedo::create_action, DEFVAL(false) );
ObjectTypeDB::bind_method(_MD("create_action","name","merge_mode"),&UndoRedo::create_action, DEFVAL(MERGE_DISABLE) );
ObjectTypeDB::bind_method(_MD("commit_action"),&UndoRedo::commit_action);
//ObjectTypeDB::bind_method(_MD("add_do_method","p_object", "p_method", "VARIANT_ARG_LIST"),&UndoRedo::add_do_method);
@@ -489,4 +520,8 @@ void UndoRedo::_bind_methods() {
ObjectTypeDB::bind_method(_MD("clear_history"),&UndoRedo::clear_history);
ObjectTypeDB::bind_method(_MD("get_current_action_name"),&UndoRedo::get_current_action_name);
ObjectTypeDB::bind_method(_MD("get_version"),&UndoRedo::get_version);
BIND_CONSTANT(MERGE_DISABLE);
BIND_CONSTANT(MERGE_ENDS);
BIND_CONSTANT(MERGE_ALL);
}

View File

@@ -41,6 +41,12 @@ class UndoRedo : public Object {
OBJ_SAVE_TYPE( UndoRedo );
public:
enum MergeMode {
MERGE_DISABLE,
MERGE_ENDS,
MERGE_ALL
};
typedef void (*CommitNotifyCallback)(void *p_ud,const String& p_name);
Variant _add_do_method(const Variant** p_args, int p_argcount, Variant::CallError& r_error);
Variant _add_undo_method(const Variant** p_args, int p_argcount, Variant::CallError& r_error);
@@ -76,7 +82,7 @@ private:
int current_action;
int action_level;
int max_steps;
bool merging;
MergeMode merge_mode;
uint64_t version;
void _pop_history_tail();
@@ -98,7 +104,7 @@ protected:
public:
void create_action(const String& p_name="",bool p_mergeable=false);
void create_action(const String& p_name="",MergeMode p_mode=MERGE_DISABLE);
void add_do_method(Object *p_object,const String& p_method,VARIANT_ARG_LIST);
void add_undo_method(Object *p_object,const String& p_method,VARIANT_ARG_LIST);
@@ -128,4 +134,6 @@ public:
~UndoRedo();
};
VARIANT_ENUM_CAST( UndoRedo::MergeMode );
#endif // UNDO_REDO_H

View File

@@ -3073,6 +3073,11 @@ String String::simplify_path() const {
}
s =s.replace("\\","/");
while(true){ // in case of using 2 or more slash
String compare = s.replace("//","/");
if (s==compare) break;
else s=compare;
}
Vector<String> dirs = s.split("/",false);
for(int i=0;i<dirs.size();i++) {
@@ -3173,7 +3178,7 @@ bool String::is_valid_identifier() const {
//kind of poor should be rewritten properly
String String::world_wrap(int p_chars_per_line) const {
String String::word_wrap(int p_chars_per_line) const {
int from=0;
int last_space=0;

View File

@@ -218,7 +218,7 @@ public:
String c_escape() const;
String c_unescape() const;
String json_escape() const;
String world_wrap(int p_chars_per_line) const;
String word_wrap(int p_chars_per_line) const;
String percent_encode() const;
String percent_decode() const;

View File

@@ -429,6 +429,7 @@ bool Variant::can_convert(Variant::Type p_type_from,Variant::Type p_type_to) {
return true;
i++;
}
} else if (invalid_types) {
@@ -439,6 +440,8 @@ bool Variant::can_convert(Variant::Type p_type_from,Variant::Type p_type_to) {
return false;
i++;
}
return true;
}
return false;
@@ -457,7 +460,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from,Variant::Type p_type_
};
const Type *valid_types=NULL;
const Type *invalid_types=NULL;
switch(p_type_to) {
case BOOL: {
@@ -679,16 +681,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from,Variant::Type p_type_
return true;
i++;
}
} else if (invalid_types) {
int i=0;
while(invalid_types[i]!=NIL) {
if (p_type_from==invalid_types[i])
return false;
i++;
}
}
return false;

View File

@@ -346,6 +346,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM0R(Vector2,angle);
// VCALL_LOCALMEM1R(Vector2,cross);
VCALL_LOCALMEM0R(Vector2,abs);
VCALL_LOCALMEM1R(Vector2,clamped);
VCALL_LOCALMEM0R(Rect2,get_area);
VCALL_LOCALMEM1R(Rect2,intersects);
@@ -374,6 +375,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM0R(Vector3, ceil);
VCALL_LOCALMEM1R(Vector3, distance_to);
VCALL_LOCALMEM1R(Vector3, distance_squared_to);
VCALL_LOCALMEM1R(Vector3, angle_to);
VCALL_LOCALMEM1R(Vector3, slide);
VCALL_LOCALMEM1R(Vector3, reflect);
@@ -1398,6 +1400,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC1(VECTOR2,VECTOR2,Vector2,reflect,VECTOR2,"vec",varray());
//ADDFUNC1(VECTOR2,REAL,Vector2,cross,VECTOR2,"with",varray());
ADDFUNC0(VECTOR2,VECTOR2,Vector2,abs,varray());
ADDFUNC1(VECTOR2,VECTOR2,Vector2,clamped,REAL,"length",varray());
ADDFUNC0(RECT2,REAL,Rect2,get_area,varray());
ADDFUNC1(RECT2,BOOL,Rect2,intersects,RECT2,"b",varray());
@@ -1426,6 +1429,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC0(VECTOR3,VECTOR3,Vector3,ceil,varray());
ADDFUNC1(VECTOR3,REAL,Vector3,distance_to,VECTOR3,"b",varray());
ADDFUNC1(VECTOR3,REAL,Vector3,distance_squared_to,VECTOR3,"b",varray());
ADDFUNC1(VECTOR3,REAL,Vector3,angle_to,VECTOR3,"to",varray());
ADDFUNC1(VECTOR3,VECTOR3,Vector3,slide,VECTOR3,"by",varray());
ADDFUNC1(VECTOR3,VECTOR3,Vector3,reflect,VECTOR3,"by",varray());

View File

@@ -3046,7 +3046,7 @@ bool Variant::iter_next(Variant& r_iter,bool &valid) const {
const String *str=reinterpret_cast<const String*>(_data._mem);
int idx = r_iter;
idx++;
if (idx >= str->size())
if (idx >= str->length())
return false;
r_iter = idx;
return true;

View File

@@ -986,7 +986,18 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in
InputEvent ie;
if (id=="KEY") {
if (id=="NONE") {
ie.type=InputEvent::NONE;
get_token(p_stream,token,line,r_err_str);
if (token.type!=TK_PARENTHESIS_CLOSE) {
r_err_str="Expected ')'";
return ERR_PARSE_ERROR;
}
} else if (id=="KEY") {
get_token(p_stream,token,line,r_err_str);
if (token.type!=TK_COMMA) {
@@ -2093,6 +2104,9 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
case InputEvent::JOYSTICK_MOTION: {
str+="JAXIS,"+itos(ev.joy_motion.axis)+","+itos(ev.joy_motion.axis_value);
} break;
case InputEvent::NONE: {
str+="NONE";
} break;
default: {}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
@@ -6,206 +6,210 @@ import xml.etree.ElementTree as ET
tree = ET.parse(sys.argv[1])
old_doc=tree.getroot()
old_doc = tree.getroot()
tree = ET.parse(sys.argv[2])
new_doc=tree.getroot()
new_doc = tree.getroot()
f = file(sys.argv[3],"wb")
tab=0
f = file(sys.argv[3], "wb")
tab = 0
old_classes={}
old_classes = {}
def write_string(_f, text, newline=True):
for t in range(tab):
_f.write("\t")
_f.write(text)
if (newline):
_f.write("\n")
def write_string(_f, text,newline=True):
for t in range(tab):
_f.write("\t")
_f.write(text)
if (newline):
_f.write("\n")
def escape(ret):
ret=ret.replace("&","&amp;");
ret=ret.replace("<","&gt;");
ret=ret.replace(">","&lt;");
ret=ret.replace("'","&apos;");
ret=ret.replace("\"","&quot;");
return ret
ret = ret.replace("&", "&amp;")
ret = ret.replace("<", "&gt;")
ret = ret.replace(">", "&lt;")
ret = ret.replace("'", "&apos;")
ret = ret.replace("\"", "&quot;")
return ret
def inc_tab():
global tab
tab+=1
global tab
tab += 1
def dec_tab():
global tab
tab-=1
global tab
tab -= 1
write_string(f,'<?xml version="1.0" encoding="UTF-8" ?>')
write_string(f,'<doc version="'+new_doc.attrib["version"]+'">')
write_string(f, '<?xml version="1.0" encoding="UTF-8" ?>')
write_string(f, '<doc version="' + new_doc.attrib["version"] + '">')
def get_tag(node,name):
tag=""
if (name in node.attrib):
tag=' '+name+'="'+escape(node.attrib[name])+'" '
return tag
def find_method_descr(old_class,name):
def get_tag(node, name):
tag = ""
if (name in node.attrib):
tag = ' ' + name + '="' + escape(node.attrib[name]) + '" '
return tag
methods = old_class.find("methods")
if(methods!=None and len(list(methods))>0):
for m in list(methods):
if (m.attrib["name"]==name):
description=m.find("description")
if (description!=None and description.text.strip()!=""):
return description.text
return None
def find_method_descr(old_class, name):
def find_signal_descr(old_class,name):
methods = old_class.find("methods")
if(methods != None and len(list(methods)) > 0):
for m in list(methods):
if (m.attrib["name"] == name):
description = m.find("description")
if (description != None and description.text.strip() != ""):
return description.text
signals = old_class.find("signals")
if(signals!=None and len(list(signals))>0):
for m in list(signals):
if (m.attrib["name"]==name):
description=m.find("description")
if (description!=None and description.text.strip()!=""):
return description.text
return None
return None
def find_constant_descr(old_class,name):
def find_signal_descr(old_class, name):
signals = old_class.find("signals")
if(signals != None and len(list(signals)) > 0):
for m in list(signals):
if (m.attrib["name"] == name):
description = m.find("description")
if (description != None and description.text.strip() != ""):
return description.text
return None
def find_constant_descr(old_class, name):
if (old_class == None):
return None
constants = old_class.find("constants")
if(constants != None and len(list(constants)) > 0):
for m in list(constants):
if (m.attrib["name"] == name):
if (m.text.strip() != ""):
return m.text
return None
if (old_class==None):
return None
constants = old_class.find("constants")
if(constants!=None and len(list(constants))>0):
for m in list(constants):
if (m.attrib["name"]==name):
if (m.text.strip()!=""):
return m.text
return None
def write_class(c):
class_name = c.attrib["name"]
print("Parsing Class: "+class_name)
if (class_name in old_classes):
old_class=old_classes[class_name]
else:
old_class=None
class_name = c.attrib["name"]
print("Parsing Class: " + class_name)
if (class_name in old_classes):
old_class = old_classes[class_name]
else:
old_class = None
category = get_tag(c, "category")
inherits = get_tag(c, "inherits")
write_string(f, '<class name="' + class_name + '" ' + category + inherits + '>')
inc_tab()
category=get_tag(c,"category")
inherits=get_tag(c,"inherits")
write_string(f,'<class name="'+class_name+'" '+category+inherits+'>')
inc_tab()
write_string(f, "<brief_description>")
write_string(f,"<brief_description>")
if (old_class != None):
old_brief_descr = old_class.find("brief_description")
if (old_brief_descr != None):
write_string(f, escape(old_brief_descr.text.strip()))
if (old_class!=None):
old_brief_descr=old_class.find("brief_description")
if (old_brief_descr!=None):
write_string(f,escape(old_brief_descr.text.strip()))
write_string(f, "</brief_description>")
write_string(f, "<description>")
if (old_class != None):
old_descr = old_class.find("description")
if (old_descr != None):
write_string(f, escape(old_descr.text.strip()))
write_string(f,"</brief_description>")
write_string(f, "</description>")
write_string(f,"<description>")
if (old_class!=None):
old_descr=old_class.find("description")
if (old_descr!=None):
write_string(f,escape(old_descr.text.strip()))
methods = c.find("methods")
if(methods != None and len(list(methods)) > 0):
write_string(f,"</description>")
write_string(f, "<methods>")
inc_tab()
methods = c.find("methods")
if(methods!=None and len(list(methods))>0):
for m in list(methods):
qualifiers = get_tag(m, "qualifiers")
write_string(f,"<methods>")
inc_tab()
write_string(f, '<method name="' + escape(m.attrib["name"]) + '" ' + qualifiers + '>')
inc_tab()
for m in list(methods):
qualifiers=get_tag(m,"qualifiers")
for a in list(m):
if (a.tag == "return"):
typ = get_tag(a, "type")
write_string(f, '<return' + typ + '>')
write_string(f, '</return>')
elif (a.tag == "argument"):
write_string(f,'<method name="'+escape(m.attrib["name"])+'" ' +qualifiers+'>')
inc_tab()
default = get_tag(a, "default")
for a in list(m):
if (a.tag=="return"):
typ=get_tag(a,"type")
write_string(f,'<return'+typ+'>');
write_string(f,'</return>');
elif (a.tag=="argument"):
write_string(f, '<argument index="' + a.attrib["index"] + '" name="' + escape(a.attrib["name"]) + '" type="' + a.attrib["type"] + '"' + default + '>')
write_string(f, '</argument>')
default=get_tag(a,"default")
write_string(f, '<description>')
if (old_class != None):
old_method_descr = find_method_descr(old_class, m.attrib["name"])
if (old_method_descr):
write_string(f, escape(escape(old_method_descr.strip())))
write_string(f,'<argument index="'+a.attrib["index"]+'" name="'+escape(a.attrib["name"])+'" type="'+a.attrib["type"]+'"' +default+'>');
write_string(f,'</argument>');
write_string(f, '</description>')
dec_tab()
write_string(f, "</method>")
dec_tab()
write_string(f, "</methods>")
write_string(f,'<description>');
if (old_class!=None):
old_method_descr=find_method_descr(old_class,m.attrib["name"])
if (old_method_descr):
write_string(f,escape(escape(old_method_descr.strip())))
signals = c.find("signals")
if(signals != None and len(list(signals)) > 0):
write_string(f,'</description>');
dec_tab()
write_string(f,"</method>")
dec_tab()
write_string(f,"</methods>")
write_string(f, "<signals>")
inc_tab()
signals = c.find("signals")
if(signals!=None and len(list(signals))>0):
for m in list(signals):
write_string(f,"<signals>")
inc_tab()
write_string(f, '<signal name="' + escape(m.attrib["name"]) + '">')
inc_tab()
for m in list(signals):
for a in list(m):
if (a.tag == "argument"):
write_string(f,'<signal name="'+escape(m.attrib["name"])+'">')
inc_tab()
write_string(f, '<argument index="' + a.attrib["index"] + '" name="' + escape(a.attrib["name"]) + '" type="' + a.attrib["type"] + '">')
write_string(f, '</argument>')
for a in list(m):
if (a.tag=="argument"):
write_string(f, '<description>')
if (old_class != None):
old_signal_descr = find_signal_descr(old_class, m.attrib["name"])
if (old_signal_descr):
write_string(f, escape(old_signal_descr.strip()))
write_string(f, '</description>')
dec_tab()
write_string(f, "</signal>")
dec_tab()
write_string(f, "</signals>")
write_string(f,'<argument index="'+a.attrib["index"]+'" name="'+escape(a.attrib["name"])+'" type="'+a.attrib["type"]+'">');
write_string(f,'</argument>');
constants = c.find("constants")
if(constants != None and len(list(constants)) > 0):
write_string(f,'<description>');
if (old_class!=None):
old_signal_descr=find_signal_descr(old_class,m.attrib["name"])
if (old_signal_descr):
write_string(f,escape(old_signal_descr.strip()))
write_string(f,'</description>');
dec_tab()
write_string(f,"</signal>")
dec_tab()
write_string(f,"</signals>")
write_string(f, "<constants>")
inc_tab()
constants = c.find("constants")
if(constants!=None and len(list(constants))>0):
for m in list(constants):
write_string(f,"<constants>")
inc_tab()
write_string(f, '<constant name="' + escape(m.attrib["name"]) + '" value="' + m.attrib["value"] + '">')
old_constant_descr = find_constant_descr(old_class, m.attrib["name"])
if (old_constant_descr):
write_string(f, escape(old_constant_descr.strip()))
write_string(f, "</constant>")
for m in list(constants):
dec_tab()
write_string(f, "</constants>")
write_string(f,'<constant name="'+escape(m.attrib["name"])+'" value="'+m.attrib["value"]+'">')
old_constant_descr=find_constant_descr(old_class,m.attrib["name"])
if (old_constant_descr):
write_string(f,escape(old_constant_descr.strip()))
write_string(f,"</constant>")
dec_tab()
write_string(f,"</constants>")
dec_tab()
write_string(f,"</class>")
dec_tab()
write_string(f, "</class>")
for c in list(old_doc):
old_classes[c.attrib["name"]]=c
old_classes[c.attrib["name"]] = c
for c in list(new_doc):
write_class(c)
write_string(f,'</doc>\n')
write_class(c)
write_string(f, '</doc>\n')

View File

@@ -1,4 +1,4 @@
#!/usr/bin/python3
#!/usr/bin/env python3
import sys
import re
@@ -11,233 +11,235 @@ import xml.etree.ElementTree as ET
################################################################################
flags = {
'c': platform.platform() != 'Windows', # Disable by default on windows, since we use ANSI escape codes
'b': False,
'g': False,
's': False,
'u': False,
'h': False,
'p': False,
'o': True,
'i': False,
'c': platform.platform() != 'Windows', # Disable by default on windows, since we use ANSI escape codes
'b': False,
'g': False,
's': False,
'u': False,
'h': False,
'p': False,
'o': True,
'i': False,
}
flag_descriptions = {
'c': 'Toggle colors when outputting.',
'b': 'Toggle showing only not fully described classes.',
'g': 'Toggle showing only completed classes.',
's': 'Toggle showing comments about the status.',
'u': 'Toggle URLs to docs.',
'h': 'Show help and exit.',
'p': 'Toggle showing percentage as well as counts.',
'o': 'Toggle overall column.',
'i': 'Toggle collapse of class items columns.',
'c': 'Toggle colors when outputting.',
'b': 'Toggle showing only not fully described classes.',
'g': 'Toggle showing only completed classes.',
's': 'Toggle showing comments about the status.',
'u': 'Toggle URLs to docs.',
'h': 'Show help and exit.',
'p': 'Toggle showing percentage as well as counts.',
'o': 'Toggle overall column.',
'i': 'Toggle collapse of class items columns.',
}
long_flags = {
'colors': 'c',
'use-colors': 'c',
'colors': 'c',
'use-colors': 'c',
'bad': 'b',
'only-bad': 'b',
'bad': 'b',
'only-bad': 'b',
'good': 'g',
'only-good': 'g',
'good': 'g',
'only-good': 'g',
'comments': 's',
'status': 's',
'comments': 's',
'status': 's',
'urls': 'u',
'gen-url': 'u',
'urls': 'u',
'gen-url': 'u',
'help': 'h',
'help': 'h',
'percent': 'p',
'use-percentages': 'p',
'percent': 'p',
'use-percentages': 'p',
'overall': 'o',
'use-overall': 'o',
'overall': 'o',
'use-overall': 'o',
'items': 'i',
'collapse': 'i',
'items': 'i',
'collapse': 'i',
}
table_columns = ['name', 'brief_description', 'description', 'methods', 'constants', 'members', 'signals']
table_column_names = ['Name', 'Brief Desc.', 'Desc.', 'Methods', 'Constants', 'Members', 'Signals']
colors = {
'name': [36], # cyan
'part_big_problem': [4, 31], # underline, red
'part_problem': [31], # red
'part_mostly_good': [33], # yellow
'part_good': [32], # green
'url': [4, 34], # underline, blue
'section': [1, 4], # bold, underline
'state_off': [36], # cyan
'state_on': [1, 35], # bold, magenta/plum
'name': [36], # cyan
'part_big_problem': [4, 31], # underline, red
'part_problem': [31], # red
'part_mostly_good': [33], # yellow
'part_good': [32], # green
'url': [4, 34], # underline, blue
'section': [1, 4], # bold, underline
'state_off': [36], # cyan
'state_on': [1, 35], # bold, magenta/plum
}
overall_progress_description_weigth = 10
################################################################################
# Utils #
################################################################################
def validate_tag(elem, tag):
if elem.tag != tag:
print('Tag mismatch, expected "' + tag + '", got ' + elem.tag)
sys.exit(255)
if elem.tag != tag:
print('Tag mismatch, expected "' + tag + '", got ' + elem.tag)
sys.exit(255)
def color(color, string):
if flags['c']:
color_format = ''
for code in colors[color]:
color_format += '\033[' + str(code) + 'm'
return color_format + string + '\033[0m'
else:
return string
if flags['c']:
color_format = ''
for code in colors[color]:
color_format += '\033[' + str(code) + 'm'
return color_format + string + '\033[0m'
else:
return string
ansi_escape = re.compile(r'\x1b[^m]*m')
def nonescape_len(s):
return len(ansi_escape.sub('', s))
def nonescape_len(s):
return len(ansi_escape.sub('', s))
################################################################################
# Classes #
################################################################################
class ClassStatusProgress:
def __init__(self, described = 0, total = 0):
self.described = described
self.total = total
def __add__(self, other):
return ClassStatusProgress(self.described + other.described, self.total + other.total)
def __init__(self, described=0, total=0):
self.described = described
self.total = total
def increment(self, described):
if described:
self.described += 1
self.total += 1
def __add__(self, other):
return ClassStatusProgress(self.described + other.described, self.total + other.total)
def is_ok(self):
return self.described >= self.total
def increment(self, described):
if described:
self.described += 1
self.total += 1
def to_configured_colored_string(self):
if flags['p']:
return self.to_colored_string('{percent}% ({has}/{total})', '{pad_percent}{pad_described}{s}{pad_total}')
else:
return self.to_colored_string()
def is_ok(self):
return self.described >= self.total
def to_colored_string(self, format='{has}/{total}', pad_format='{pad_described}{s}{pad_total}'):
ratio = self.described/self.total if self.total != 0 else 1
percent = round(100*ratio)
s = format.format(has = str(self.described), total = str(self.total), percent = str(percent))
if self.described >= self.total:
s = color('part_good', s)
elif self.described >= self.total/4*3:
s = color('part_mostly_good', s)
elif self.described > 0:
s = color('part_problem', s)
else:
s = color('part_big_problem', s)
pad_size = max(len(str(self.described)), len(str(self.total)))
pad_described = ''.ljust(pad_size - len(str(self.described)))
pad_percent = ''.ljust(3 - len(str(percent)))
pad_total = ''.ljust(pad_size - len(str(self.total)))
return pad_format.format(pad_described = pad_described, pad_total = pad_total, pad_percent = pad_percent, s = s)
def to_configured_colored_string(self):
if flags['p']:
return self.to_colored_string('{percent}% ({has}/{total})', '{pad_percent}{pad_described}{s}{pad_total}')
else:
return self.to_colored_string()
def to_colored_string(self, format='{has}/{total}', pad_format='{pad_described}{s}{pad_total}'):
ratio = self.described / self.total if self.total != 0 else 1
percent = round(100 * ratio)
s = format.format(has=str(self.described), total=str(self.total), percent=str(percent))
if self.described >= self.total:
s = color('part_good', s)
elif self.described >= self.total / 4 * 3:
s = color('part_mostly_good', s)
elif self.described > 0:
s = color('part_problem', s)
else:
s = color('part_big_problem', s)
pad_size = max(len(str(self.described)), len(str(self.total)))
pad_described = ''.ljust(pad_size - len(str(self.described)))
pad_percent = ''.ljust(3 - len(str(percent)))
pad_total = ''.ljust(pad_size - len(str(self.total)))
return pad_format.format(pad_described=pad_described, pad_total=pad_total, pad_percent=pad_percent, s=s)
class ClassStatus:
def __init__(self, name=''):
self.name = name
self.has_brief_description = True
self.has_description = True
self.progresses = {
'methods': ClassStatusProgress(),
'constants': ClassStatusProgress(),
'members': ClassStatusProgress(),
'signals': ClassStatusProgress()
}
def __add__(self, other):
new_status = ClassStatus()
new_status.name = self.name
new_status.has_brief_description = self.has_brief_description and other.has_brief_description
new_status.has_description = self.has_description and other.has_description
for k in self.progresses:
new_status.progresses[k] = self.progresses[k] + other.progresses[k]
return new_status
def __init__(self, name=''):
self.name = name
self.has_brief_description = True
self.has_description = True
self.progresses = {
'methods': ClassStatusProgress(),
'constants': ClassStatusProgress(),
'members': ClassStatusProgress(),
'signals': ClassStatusProgress()
}
def is_ok(self):
ok = True
ok = ok and self.has_brief_description
ok = ok and self.has_description
for k in self.progresses:
ok = ok and self.progresses[k].is_ok()
return ok
def __add__(self, other):
new_status = ClassStatus()
new_status.name = self.name
new_status.has_brief_description = self.has_brief_description and other.has_brief_description
new_status.has_description = self.has_description and other.has_description
for k in self.progresses:
new_status.progresses[k] = self.progresses[k] + other.progresses[k]
return new_status
def make_output(self):
output = {}
output['name'] = color('name', self.name)
def is_ok(self):
ok = True
ok = ok and self.has_brief_description
ok = ok and self.has_description
for k in self.progresses:
ok = ok and self.progresses[k].is_ok()
return ok
ok_string = color('part_good', 'OK')
missing_string = color('part_big_problem', 'MISSING')
def make_output(self):
output = {}
output['name'] = color('name', self.name)
output['brief_description'] = ok_string if self.has_brief_description else missing_string
output['description'] = ok_string if self.has_description else missing_string
ok_string = color('part_good', 'OK')
missing_string = color('part_big_problem', 'MISSING')
description_progress = ClassStatusProgress(
(self.has_brief_description + self.has_description) * overall_progress_description_weigth,
2 * overall_progress_description_weigth
)
items_progress = ClassStatusProgress()
output['brief_description'] = ok_string if self.has_brief_description else missing_string
output['description'] = ok_string if self.has_description else missing_string
for k in ['methods', 'constants', 'members', 'signals']:
items_progress += self.progresses[k]
output[k] = self.progresses[k].to_configured_colored_string()
description_progress = ClassStatusProgress(
(self.has_brief_description + self.has_description) * overall_progress_description_weigth,
2 * overall_progress_description_weigth
)
items_progress = ClassStatusProgress()
output['items'] = items_progress.to_configured_colored_string()
for k in ['methods', 'constants', 'members', 'signals']:
items_progress += self.progresses[k]
output[k] = self.progresses[k].to_configured_colored_string()
output['overall'] = (description_progress + items_progress).to_colored_string('{percent}%', '{pad_percent}{s}')
output['items'] = items_progress.to_configured_colored_string()
if self.name.startswith('Total'):
output['url'] = color('url', 'http://docs.godotengine.org/en/latest/classes/_classes.html')
if flags['s']:
output['comment'] = color('part_good', 'ALL OK')
else:
output['url'] = color('url', 'http://docs.godotengine.org/en/latest/classes/class_{name}.html'.format(name=self.name.lower()))
output['overall'] = (description_progress + items_progress).to_colored_string('{percent}%', '{pad_percent}{s}')
if flags['s'] and not flags['g'] and self.is_ok():
output['comment'] = color('part_good', 'ALL OK')
if self.name.startswith('Total'):
output['url'] = color('url', 'http://docs.godotengine.org/en/latest/classes/_classes.html')
if flags['s']:
output['comment'] = color('part_good', 'ALL OK')
else:
output['url'] = color('url', 'http://docs.godotengine.org/en/latest/classes/class_{name}.html'.format(name=self.name.lower()))
return output
if flags['s'] and not flags['g'] and self.is_ok():
output['comment'] = color('part_good', 'ALL OK')
def generate_for_class(c):
status = ClassStatus()
status.name = c.attrib['name']
for tag in list(c):
return output
if tag.tag == 'brief_description':
status.has_brief_description = len(tag.text.strip()) > 0
def generate_for_class(c):
status = ClassStatus()
status.name = c.attrib['name']
for tag in list(c):
elif tag.tag == 'description':
status.has_description = len(tag.text.strip()) > 0
if tag.tag == 'brief_description':
status.has_brief_description = len(tag.text.strip()) > 0
elif tag.tag in ['methods', 'signals']:
for sub_tag in list(tag):
descr = sub_tag.find('description')
status.progresses[tag.tag].increment(len(descr.text.strip()) > 0)
elif tag.tag == 'description':
status.has_description = len(tag.text.strip()) > 0
elif tag.tag in ['constants', 'members']:
for sub_tag in list(tag):
status.progresses[tag.tag].increment(len(sub_tag.text.strip()) > 0)
elif tag.tag in ['methods', 'signals']:
for sub_tag in list(tag):
descr = sub_tag.find('description')
status.progresses[tag.tag].increment(len(descr.text.strip()) > 0)
elif tag.tag in ['theme_items']:
pass #Ignore those tags, since they seem to lack description at all
elif tag.tag in ['constants', 'members']:
for sub_tag in list(tag):
status.progresses[tag.tag].increment(len(sub_tag.text.strip()) > 0)
else:
print(tag.tag, tag.attrib)
elif tag.tag in ['theme_items']:
pass # Ignore those tags, since they seem to lack description at all
return status
else:
print(tag.tag, tag.attrib)
return status
################################################################################
@@ -248,31 +250,31 @@ input_file_list = []
input_class_list = []
for arg in sys.argv[1:]:
if arg.startswith('--'):
flags[long_flags[arg[2:]]] = not flags[long_flags[arg[2:]]]
elif arg.startswith('-'):
for f in arg[1:]:
flags[f] = not flags[f]
elif arg.endswith('.xml'):
input_file_list.append(arg)
else:
input_class_list.append(arg)
if arg.startswith('--'):
flags[long_flags[arg[2:]]] = not flags[long_flags[arg[2:]]]
elif arg.startswith('-'):
for f in arg[1:]:
flags[f] = not flags[f]
elif arg.endswith('.xml'):
input_file_list.append(arg)
else:
input_class_list.append(arg)
if flags['i']:
for r in ['methods', 'constants', 'members', 'signals']:
index = table_columns.index(r)
del table_column_names[index]
del table_columns[index]
table_column_names.append('Items')
table_columns.append('items')
for r in ['methods', 'constants', 'members', 'signals']:
index = table_columns.index(r)
del table_column_names[index]
del table_columns[index]
table_column_names.append('Items')
table_columns.append('items')
if flags['o'] == (not flags['i']):
table_column_names.append('Overall')
table_columns.append('overall')
table_column_names.append('Overall')
table_columns.append('overall')
if flags['u']:
table_column_names.append('Docs URL')
table_columns.append('url')
table_column_names.append('Docs URL')
table_columns.append('url')
################################################################################
@@ -280,29 +282,28 @@ if flags['u']:
################################################################################
if len(input_file_list) < 1 or flags['h']:
if not flags['h']:
print(color('section', 'Invalid usage') + ': At least one classes.xml file is required')
print(color('section', 'Usage') + ': doc_status.py [flags] <classes.xml> [class names]')
print('\t< and > signify required parameters, while [ and ] signify optional parameters.')
print('\tNote that you can give more than one classes file, in which case they will be merged on-the-fly.')
print(color('section', 'Available flags') + ':')
possible_synonym_list = list(long_flags)
possible_synonym_list.sort()
flag_list = list(flags)
flag_list.sort()
for flag in flag_list:
synonyms = [color('name', '-' + flag)]
for synonym in possible_synonym_list:
if long_flags[synonym] == flag:
synonyms.append(color('name', '--' + synonym))
print(('{synonyms} (Currently '+color('state_'+('on' if flags[flag] else 'off'), '{value}')+')\n\t{description}').format(
synonyms = ', '.join(synonyms),
value = ('on' if flags[flag] else 'off'),
description = flag_descriptions[flag]
))
sys.exit(0)
if not flags['h']:
print(color('section', 'Invalid usage') + ': At least one classes.xml file is required')
print(color('section', 'Usage') + ': doc_status.py [flags] <classes.xml> [class names]')
print('\t< and > signify required parameters, while [ and ] signify optional parameters.')
print('\tNote that you can give more than one classes file, in which case they will be merged on-the-fly.')
print(color('section', 'Available flags') + ':')
possible_synonym_list = list(long_flags)
possible_synonym_list.sort()
flag_list = list(flags)
flag_list.sort()
for flag in flag_list:
synonyms = [color('name', '-' + flag)]
for synonym in possible_synonym_list:
if long_flags[synonym] == flag:
synonyms.append(color('name', '--' + synonym))
print(('{synonyms} (Currently ' + color('state_' + ('on' if flags[flag] else 'off'), '{value}') + ')\n\t{description}').format(
synonyms=', '.join(synonyms),
value=('on' if flags[flag] else 'off'),
description=flag_descriptions[flag]
))
sys.exit(0)
################################################################################
@@ -313,26 +314,25 @@ class_names = []
classes = {}
for file in input_file_list:
tree = ET.parse(file)
doc = tree.getroot()
tree = ET.parse(file)
doc = tree.getroot()
if 'version' not in doc.attrib:
print('Version missing from "doc"')
sys.exit(255)
if 'version' not in doc.attrib:
print('Version missing from "doc"')
sys.exit(255)
version = doc.attrib['version']
version = doc.attrib['version']
for c in list(doc):
if c.attrib['name'] in class_names:
continue
class_names.append(c.attrib['name'])
classes[c.attrib['name']] = c
for c in list(doc):
if c.attrib['name'] in class_names:
continue
class_names.append(c.attrib['name'])
classes[c.attrib['name']] = c
class_names.sort()
if len(input_class_list) < 1:
input_class_list = class_names
input_class_list = class_names
################################################################################
@@ -346,34 +346,32 @@ table_column_chars = '|'
total_status = ClassStatus('Total')
for cn in input_class_list:
if not cn in classes:
print('Cannot find class ' + cn + '!')
sys.exit(255)
if not cn in classes:
print('Cannot find class ' + cn + '!')
sys.exit(255)
c = classes[cn]
validate_tag(c, 'class')
status = ClassStatus.generate_for_class(c)
c = classes[cn]
validate_tag(c, 'class')
status = ClassStatus.generate_for_class(c)
if flags['b'] and status.is_ok():
continue
if flags['g'] and not status.is_ok():
continue
if flags['b'] and status.is_ok():
continue
if flags['g'] and not status.is_ok():
continue
total_status = total_status + status
out = status.make_output()
row = []
for column in table_columns:
if column in out:
row.append(out[column])
else:
row.append('')
if 'comment' in out and out['comment'] != '':
row.append(out['comment'])
table.append(row)
total_status = total_status + status
out = status.make_output()
row = []
for column in table_columns:
if column in out:
row.append(out[column])
else:
row.append('')
if 'comment' in out and out['comment'] != '':
row.append(out['comment'])
table.append(row)
################################################################################
@@ -381,50 +379,49 @@ for cn in input_class_list:
################################################################################
if len(table) == 1:
print(color('part_big_problem', 'No classes suitable for printing!'))
sys.exit(0)
print(color('part_big_problem', 'No classes suitable for printing!'))
sys.exit(0)
if len(table) > 2:
total_status.name = 'Total = {0}'.format(len(table) - 1)
out = total_status.make_output()
row = []
for column in table_columns:
if column in out:
row.append(out[column])
else:
row.append('')
table.append(row)
total_status.name = 'Total = {0}'.format(len(table) - 1)
out = total_status.make_output()
row = []
for column in table_columns:
if column in out:
row.append(out[column])
else:
row.append('')
table.append(row)
table_column_sizes = []
for row in table:
for cell_i, cell in enumerate(row):
if cell_i >= len(table_column_sizes):
table_column_sizes.append(0)
for cell_i, cell in enumerate(row):
if cell_i >= len(table_column_sizes):
table_column_sizes.append(0)
table_column_sizes[cell_i] = max(nonescape_len(cell), table_column_sizes[cell_i])
table_column_sizes[cell_i] = max(nonescape_len(cell), table_column_sizes[cell_i])
divider_string = table_row_chars[0]
for cell_i in range(len(table[0])):
divider_string += table_row_chars[1] * (table_column_sizes[cell_i] + 2) + table_row_chars[0]
divider_string += table_row_chars[1] * (table_column_sizes[cell_i] + 2) + table_row_chars[0]
print(divider_string)
for row_i, row in enumerate(table):
row_string = table_column_chars
for cell_i, cell in enumerate(row):
padding_needed = table_column_sizes[cell_i] - nonescape_len(cell) + 2
if cell_i == 0:
row_string += table_row_chars[2] + cell + table_row_chars[2]*(padding_needed-1)
else:
row_string += table_row_chars[2]*math.floor(padding_needed/2) + cell + table_row_chars[2]*math.ceil((padding_needed/2))
row_string += table_column_chars
row_string = table_column_chars
for cell_i, cell in enumerate(row):
padding_needed = table_column_sizes[cell_i] - nonescape_len(cell) + 2
if cell_i == 0:
row_string += table_row_chars[2] + cell + table_row_chars[2] * (padding_needed - 1)
else:
row_string += table_row_chars[2] * math.floor(padding_needed / 2) + cell + table_row_chars[2] * math.ceil((padding_needed / 2))
row_string += table_column_chars
print(row_string)
print(row_string)
if row_i == 0 or row_i == len(table) - 2:
print(divider_string)
if row_i == 0 or row_i == len(table) - 2:
print(divider_string)
print(divider_string)
if total_status.is_ok() and not flags['g']:
print('All listed classes are ' + color('part_good', 'OK') + '!')
print('All listed classes are ' + color('part_good', 'OK') + '!')

View File

@@ -1,4 +1,4 @@
#!/usr/bin/python3
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#

View File

@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
@@ -8,308 +8,295 @@ input_list = []
for arg in sys.argv[1:]:
input_list.append(arg)
input_list.append(arg)
if len(input_list) < 1:
print("usage: makedoku.py <classes.xml>")
sys.exit(0)
print("usage: makedoku.py <classes.xml>")
sys.exit(0)
def validate_tag(elem,tag):
if (elem.tag != tag):
print("Tag mismatch, expected '"+tag+"', got "+elem.tag);
sys.exit(255)
def validate_tag(elem, tag):
if (elem.tag != tag):
print("Tag mismatch, expected '" + tag + "', got " + elem.tag)
sys.exit(255)
class_names=[]
classes={}
class_names = []
classes = {}
def make_class_list(class_list,columns):
def make_class_list(class_list, columns):
f=open("class_list.txt","wb")
prev=0
col_max = len(class_list) / columns + 1
print("col max is ", col_max)
col_count = 0
row_count = 0
last_initial = ""
fit_columns=[]
f = open("class_list.txt", "wb")
prev = 0
col_max = len(class_list) / columns + 1
print("col max is ", col_max)
col_count = 0
row_count = 0
last_initial = ""
fit_columns = []
for n in range(0,columns):
fit_columns+=[[]]
for n in range(0, columns):
fit_columns += [[]]
indexers=[]
last_initial=""
indexers = []
last_initial = ""
idx=0
for n in class_list:
col = idx/col_max
if (col>=columns):
col=columns-1
fit_columns[col]+=[n]
idx+=1
if (n[:1]!=last_initial):
indexers+=[n]
last_initial=n[:1]
idx = 0
for n in class_list:
col = idx / col_max
if (col >= columns):
col = columns - 1
fit_columns[col] += [n]
idx += 1
if (n[:1] != last_initial):
indexers += [n]
last_initial = n[:1]
row_max = 0
row_max=0
for n in range(0, columns):
if (len(fit_columns[n]) > row_max):
row_max = len(fit_columns[n])
for n in range(0,columns):
if (len(fit_columns[n])>row_max):
row_max=len(fit_columns[n])
for r in range(0, row_max):
s = "|"
for c in range(0, columns):
if (r >= len(fit_columns[c])):
continue
classname = fit_columns[c][r]
initial = classname[0]
if (classname in indexers):
s += "**" + initial + "**|"
else:
s += " |"
for r in range(0,row_max):
s="|"
for c in range(0,columns):
if (r>=len(fit_columns[c])):
continue
s += "[[" + classname.lower() + "|" + classname + "]]|"
classname = fit_columns[c][r]
initial=classname[0]
if (classname in indexers):
s+="**"+initial+"**|"
else:
s+=" |"
s+="[["+classname.lower()+"|"+classname+"]]|"
s+="\n"
f.write(s)
s += "\n"
f.write(s)
def dokuize_text(txt):
return txt
return txt
def dokuize_text(text):
pos=0
while(True):
pos = text.find("[",pos)
if (pos==-1):
break
pos = 0
while(True):
pos = text.find("[", pos)
if (pos == -1):
break
endq_pos=text.find("]",pos+1)
if (endq_pos==-1):
break
endq_pos = text.find("]", pos + 1)
if (endq_pos == -1):
break
pre_text=text[:pos]
post_text=text[endq_pos+1:]
tag_text=text[pos+1:endq_pos]
pre_text = text[:pos]
post_text = text[endq_pos + 1:]
tag_text = text[pos + 1:endq_pos]
if (tag_text in class_names):
tag_text="[["+tag_text.lower()+"|"+tag_text+"]]"
else: #command
cmd=tag_text
space_pos=tag_text.find(" ")
if (cmd.find("html")==0):
cmd=tag_text[:space_pos]
param=tag_text[space_pos+1:]
tag_text="<"+param+">"
elif(cmd.find("method")==0):
cmd=tag_text[:space_pos]
param=tag_text[space_pos+1:]
if (tag_text in class_names):
tag_text = "[[" + tag_text.lower() + "|" + tag_text + "]]"
else: # command
cmd = tag_text
space_pos = tag_text.find(" ")
if (cmd.find("html") == 0):
cmd = tag_text[:space_pos]
param = tag_text[space_pos + 1:]
tag_text = "<" + param + ">"
elif(cmd.find("method") == 0):
cmd = tag_text[:space_pos]
param = tag_text[space_pos + 1:]
if (param.find(".")!=-1):
class_param,method_param=param.split(".")
tag_text="[["+class_param.lower()+"#"+method_param+"|"+class_param+'.'+method_param+"]]"
else:
tag_text="[[#"+param+"|"+param+"]]"
elif (cmd.find("image=")==0):
tag_text="{{"+cmd[6:]+"}}"
elif (cmd.find("url=")==0):
tag_text="[["+cmd[4:]+"|"
elif (cmd=="/url"):
tag_text="]]>"
elif (cmd=="center"):
tag_text=""
elif (cmd=="/center"):
tag_text=""
elif (cmd=="br"):
tag_text="\\\\\n"
elif (cmd=="i" or cmd=="/i"):
tag_text="//"
elif (cmd=="b" or cmd=="/b"):
tag_text="**"
elif (cmd=="u" or cmd=="/u"):
tag_text="__"
else:
tag_text="["+tag_text+"]"
if (param.find(".") != -1):
class_param, method_param = param.split(".")
tag_text = "[[" + class_param.lower() + "#" + method_param + "|" + class_param + '.' + method_param + "]]"
else:
tag_text = "[[#" + param + "|" + param + "]]"
elif (cmd.find("image=") == 0):
tag_text = "{{" + cmd[6:] + "}}"
elif (cmd.find("url=") == 0):
tag_text = "[[" + cmd[4:] + "|"
elif (cmd == "/url"):
tag_text = "]]>"
elif (cmd == "center"):
tag_text = ""
elif (cmd == "/center"):
tag_text = ""
elif (cmd == "br"):
tag_text = "\\\\\n"
elif (cmd == "i" or cmd == "/i"):
tag_text = "//"
elif (cmd == "b" or cmd == "/b"):
tag_text = "**"
elif (cmd == "u" or cmd == "/u"):
tag_text = "__"
else:
tag_text = "[" + tag_text + "]"
text = pre_text + tag_text + post_text
pos = len(pre_text) + len(tag_text)
text=pre_text+tag_text+post_text
pos=len(pre_text)+len(tag_text)
#tnode = ET.SubElement(parent,"div")
#tnode.text=text
return text
#tnode = ET.SubElement(parent,"div")
# tnode.text=text
return text
def make_type(t):
global class_names
if (t in class_names):
return "[["+t.lower()+"|"+t+"]]"
return t
global class_names
if (t in class_names):
return "[[" + t.lower() + "|" + t + "]]"
return t
def make_method(f,name,m,declare,event=False):
def make_method(f, name, m, declare, event=False):
s=" * "
ret_type="void"
args=list(m)
mdata={}
mdata["argidx"]=[]
for a in args:
if (a.tag=="return"):
idx=-1
elif (a.tag=="argument"):
idx=int(a.attrib["index"])
else:
continue
s = " * "
ret_type = "void"
args = list(m)
mdata = {}
mdata["argidx"] = []
for a in args:
if (a.tag == "return"):
idx = -1
elif (a.tag == "argument"):
idx = int(a.attrib["index"])
else:
continue
mdata["argidx"].append(idx)
mdata[idx]=a
mdata["argidx"].append(idx)
mdata[idx] = a
if (not event):
if (-1 in mdata["argidx"]):
s += make_type(mdata[-1].attrib["type"])
else:
s += "void"
s += " "
if (declare):
if (not event):
if (-1 in mdata["argidx"]):
s+=make_type(mdata[-1].attrib["type"])
else:
s+="void"
s+=" "
# span.attrib["class"]="funcdecl"
# a=ET.SubElement(span,"a")
# a.attrib["name"]=name+"_"+m.attrib["name"]
# a.text=name+"::"+m.attrib["name"]
s += "**" + m.attrib["name"] + "**"
else:
s += "[[#" + m.attrib["name"] + "|" + m.attrib["name"] + "]]"
if (declare):
s += "**(**"
argfound = False
for a in mdata["argidx"]:
arg = mdata[a]
if (a < 0):
continue
if (a > 0):
s += ", "
else:
s += " "
#span.attrib["class"]="funcdecl"
#a=ET.SubElement(span,"a")
#a.attrib["name"]=name+"_"+m.attrib["name"]
#a.text=name+"::"+m.attrib["name"]
s+="**"+m.attrib["name"]+"**"
else:
s+="[[#"+m.attrib["name"]+"|"+m.attrib["name"]+"]]"
s += make_type(arg.attrib["type"])
if ("name" in arg.attrib):
s += " " + arg.attrib["name"]
else:
s += " arg" + str(a)
s+="**(**"
argfound=False
for a in mdata["argidx"]:
arg=mdata[a]
if (a<0):
continue
if (a>0):
s+=", "
else:
s+=" "
if ("default" in arg.attrib):
s += "=" + arg.attrib["default"]
s+=make_type(arg.attrib["type"])
if ("name" in arg.attrib):
s+=" "+arg.attrib["name"]
else:
s+=" arg"+str(a)
argfound = True
if ("default" in arg.attrib):
s+="="+arg.attrib["default"]
if (argfound):
s += " "
s += "**)**"
if ("qualifiers" in m.attrib):
s += " " + m.attrib["qualifiers"]
argfound=True
if (argfound):
s+=" "
s+="**)**"
if ("qualifiers" in m.attrib):
s+=" "+m.attrib["qualifiers"]
f.write(s+"\n")
f.write(s + "\n")
def make_doku_class(node):
name = node.attrib["name"]
name = node.attrib["name"]
f=open(name.lower()+".txt","wb")
f = open(name.lower() + ".txt", "wb")
f.write("====== "+name+" ======\n")
f.write("====== " + name + " ======\n")
if ("inherits" in node.attrib):
inh=node.attrib["inherits"].strip()
f.write("**Inherits:** [["+inh.lower()+"|"+inh+"]]\\\\\n")
if ("category" in node.attrib):
f.write("**Category:** "+node.attrib["category"].strip()+"\\\\\n")
if ("inherits" in node.attrib):
inh = node.attrib["inherits"].strip()
f.write("**Inherits:** [[" + inh.lower() + "|" + inh + "]]\\\\\n")
if ("category" in node.attrib):
f.write("**Category:** " + node.attrib["category"].strip() + "\\\\\n")
briefd = node.find("brief_description")
if (briefd!=None):
f.write("===== Brief Description ======\n")
f.write( dokuize_text(briefd.text.strip())+"\n" )
briefd = node.find("brief_description")
if (briefd != None):
f.write("===== Brief Description ======\n")
f.write(dokuize_text(briefd.text.strip()) + "\n")
methods = node.find("methods")
methods = node.find("methods")
if(methods!=None and len(list(methods))>0):
f.write("===== Member Functions ======\n")
for m in list(methods):
make_method(f,node.attrib["name"],m,False)
if(methods != None and len(list(methods)) > 0):
f.write("===== Member Functions ======\n")
for m in list(methods):
make_method(f, node.attrib["name"], m, False)
events = node.find("signals")
if(events!=None and len(list(events))>0):
f.write("===== Signals ======\n")
for m in list(events):
make_method(f,node.attrib["name"],m,True,True)
events = node.find("signals")
if(events != None and len(list(events)) > 0):
f.write("===== Signals ======\n")
for m in list(events):
make_method(f, node.attrib["name"], m, True, True)
members = node.find("members")
members = node.find("members")
if(members!=None and len(list(members))>0):
f.write("===== Member Variables ======\n")
if(members != None and len(list(members)) > 0):
f.write("===== Member Variables ======\n")
for c in list(members):
s = " * "
s+=make_type(c.attrib["type"])+" "
s+="**"+c.attrib["name"]+"**"
if (c.text.strip()!=""):
s+=" - "+c.text.strip()
f.write(s+"\n")
for c in list(members):
s = " * "
s += make_type(c.attrib["type"]) + " "
s += "**" + c.attrib["name"] + "**"
if (c.text.strip() != ""):
s += " - " + c.text.strip()
f.write(s + "\n")
constants = node.find("constants")
if(constants != None and len(list(constants)) > 0):
f.write("===== Numeric Constants ======\n")
for c in list(constants):
s = " * "
s += "**" + c.attrib["name"] + "**"
if ("value" in c.attrib):
s += " = **" + c.attrib["value"] + "**"
if (c.text.strip() != ""):
s += " - " + c.text.strip()
f.write(s + "\n")
descr = node.find("description")
if (descr != None and descr.text.strip() != ""):
f.write("===== Description ======\n")
f.write(dokuize_text(descr.text.strip()) + "\n")
constants = node.find("constants")
if(constants!=None and len(list(constants))>0):
f.write("===== Numeric Constants ======\n")
for c in list(constants):
s = " * "
s+="**"+c.attrib["name"]+"**"
if ("value" in c.attrib):
s+=" = **"+c.attrib["value"]+"**"
if (c.text.strip()!=""):
s+=" - "+c.text.strip()
f.write(s+"\n")
methods = node.find("methods")
if(methods != None and len(list(methods)) > 0):
f.write("===== Member Function Description ======\n")
for m in list(methods):
descr=node.find("description")
if (descr!=None and descr.text.strip()!=""):
f.write("===== Description ======\n")
f.write(dokuize_text(descr.text.strip())+"\n")
d = m.find("description")
if (d == None or d.text.strip() == ""):
continue
f.write("== " + m.attrib["name"] + " ==\n")
make_method(f, node.attrib["name"], m, False)
f.write("\\\\\n")
f.write(dokuize_text(d.text.strip()))
f.write("\n")
methods = node.find("methods")
if(methods!=None and len(list(methods))>0):
f.write("===== Member Function Description ======\n")
for m in list(methods):
d=m.find("description")
if (d==None or d.text.strip()==""):
continue
f.write("== "+m.attrib["name"]+" ==\n")
make_method(f,node.attrib["name"],m,False)
f.write("\\\\\n")
f.write(dokuize_text(d.text.strip()))
f.write("\n")
"""
"""
div=ET.Element("div")
div.attrib["class"]="class";
@@ -487,28 +474,26 @@ def make_doku_class(node):
return div
"""
for file in input_list:
tree = ET.parse(file)
doc=tree.getroot()
tree = ET.parse(file)
doc = tree.getroot()
if ("version" not in doc.attrib):
print("Version missing from 'doc'")
sys.exit(255)
if ("version" not in doc.attrib):
print("Version missing from 'doc'")
sys.exit(255)
version=doc.attrib["version"]
version = doc.attrib["version"]
for c in list(doc):
if (c.attrib["name"] in class_names):
continue
class_names.append(c.attrib["name"])
classes[c.attrib["name"]]=c
for c in list(doc):
if (c.attrib["name"] in class_names):
continue
class_names.append(c.attrib["name"])
classes[c.attrib["name"]] = c
class_names.sort()
make_class_list(class_names,4)
make_class_list(class_names, 4)
for cn in class_names:
c=classes[cn]
make_doku_class(c)
c = classes[cn]
make_doku_class(c)

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
@@ -7,17 +7,17 @@ import xml.etree.ElementTree as ET
input_list = []
for arg in sys.argv[1:]:
input_list.append(arg)
input_list.append(arg)
if len(input_list) < 1:
print 'usage: makemd.py <classes.xml>'
sys.exit(0)
print 'usage: makemd.py <classes.xml>'
sys.exit(0)
def validate_tag(elem, tag):
if elem.tag != tag:
print "Tag mismatch, expected '" + tag + "', got " + elem.tag
sys.exit(255)
if elem.tag != tag:
print "Tag mismatch, expected '" + tag + "', got " + elem.tag
sys.exit(255)
class_names = []
@@ -26,321 +26,320 @@ classes = {}
def make_class_list(class_list, columns):
f = open('class_list.md', 'wb')
prev = 0
col_max = len(class_list) / columns + 1
print ('col max is ', col_max)
col_count = 0
row_count = 0
last_initial = ''
fit_columns = []
f = open('class_list.md', 'wb')
prev = 0
col_max = len(class_list) / columns + 1
print ('col max is ', col_max)
col_count = 0
row_count = 0
last_initial = ''
fit_columns = []
for n in range(0, columns):
fit_columns += [[]]
for n in range(0, columns):
fit_columns += [[]]
indexers = []
last_initial = ''
indexers = []
last_initial = ''
idx = 0
for n in class_list:
col = idx / col_max
if col >= columns:
col = columns - 1
fit_columns[col] += [n]
idx += 1
if n[:1] != last_initial:
indexers += [n]
last_initial = n[:1]
idx = 0
for n in class_list:
col = idx / col_max
if col >= columns:
col = columns - 1
fit_columns[col] += [n]
idx += 1
if n[:1] != last_initial:
indexers += [n]
last_initial = n[:1]
row_max = 0
f.write("\n")
row_max = 0
f.write("\n")
for n in range(0, columns):
if len(fit_columns[n]) > row_max:
row_max = len(fit_columns[n])
for n in range(0, columns):
if len(fit_columns[n]) > row_max:
row_max = len(fit_columns[n])
f.write("| ")
for n in range(0, columns):
f.write(" | |")
f.write("| ")
for n in range(0, columns):
f.write(" | |")
f.write("\n")
f.write("| ")
for n in range(0, columns):
f.write(" --- | ------- |")
f.write("\n")
f.write("\n")
f.write("| ")
for n in range(0, columns):
f.write(" --- | ------- |")
f.write("\n")
for r in range(0, row_max):
s = '| '
for c in range(0, columns):
if r >= len(fit_columns[c]):
continue
for r in range(0, row_max):
s = '| '
for c in range(0, columns):
if r >= len(fit_columns[c]):
continue
classname = fit_columns[c][r]
initial = classname[0]
if classname in indexers:
s += '**' + initial + '** | '
else:
s += ' | '
classname = fit_columns[c][r]
initial = classname[0]
if classname in indexers:
s += '**' + initial + '** | '
else:
s += ' | '
s += '[' + classname + '](class_'+ classname.lower()+') | '
s += '[' + classname + '](class_' + classname.lower() + ') | '
s += '\n'
f.write(s)
s += '\n'
f.write(s)
def dokuize_text(txt):
return txt
return txt
def dokuize_text(text):
pos = 0
while True:
pos = text.find('[', pos)
if pos == -1:
break
pos = 0
while True:
pos = text.find('[', pos)
if pos == -1:
break
endq_pos = text.find(']', pos + 1)
if endq_pos == -1:
break
endq_pos = text.find(']', pos + 1)
if endq_pos == -1:
break
pre_text = text[:pos]
post_text = text[endq_pos + 1:]
tag_text = text[pos + 1:endq_pos]
pre_text = text[:pos]
post_text = text[endq_pos + 1:]
tag_text = text[pos + 1:endq_pos]
if tag_text in class_names:
tag_text = make_type(tag_text)
else:
if tag_text in class_names:
tag_text = make_type(tag_text)
else:
# command
# command
cmd = tag_text
space_pos = tag_text.find(' ')
if cmd.find('html') == 0:
cmd = tag_text[:space_pos]
param = tag_text[space_pos + 1:]
tag_text = '<' + param + '>'
elif cmd.find('method') == 0:
cmd = tag_text[:space_pos]
param = tag_text[space_pos + 1:]
cmd = tag_text
space_pos = tag_text.find(' ')
if cmd.find('html') == 0:
cmd = tag_text[:space_pos]
param = tag_text[space_pos + 1:]
tag_text = '<' + param + '>'
elif cmd.find('method') == 0:
cmd = tag_text[:space_pos]
param = tag_text[space_pos + 1:]
if param.find('.') != -1:
(class_param, method_param) = param.split('.')
tag_text = '['+class_param+'.'+method_param.replace("_","&#95;")+'](' + class_param.lower() + '#' \
+ method_param + ')'
else:
tag_text = '[' + param.replace("_","&#95;") + '](#' + param + ')'
elif cmd.find('image=') == 0:
tag_text = '![](' + cmd[6:] + ')'
elif cmd.find('url=') == 0:
tag_text = '[' + cmd[4:] + ']('+cmd[4:]
elif cmd == '/url':
tag_text = ')'
elif cmd == 'center':
tag_text = ''
elif cmd == '/center':
tag_text = ''
elif cmd == 'br':
tag_text = '\n'
elif cmd == 'i' or cmd == '/i':
tag_text = '_'
elif cmd == 'b' or cmd == '/b':
tag_text = '**'
elif cmd == 'u' or cmd == '/u':
tag_text = '__'
else:
tag_text = '[' + tag_text + ']'
if param.find('.') != -1:
(class_param, method_param) = param.split('.')
tag_text = '[' + class_param + '.' + method_param.replace("_", "&#95;") + '](' + class_param.lower() + '#' \
+ method_param + ')'
else:
tag_text = '[' + param.replace("_", "&#95;") + '](#' + param + ')'
elif cmd.find('image=') == 0:
tag_text = '![](' + cmd[6:] + ')'
elif cmd.find('url=') == 0:
tag_text = '[' + cmd[4:] + '](' + cmd[4:]
elif cmd == '/url':
tag_text = ')'
elif cmd == 'center':
tag_text = ''
elif cmd == '/center':
tag_text = ''
elif cmd == 'br':
tag_text = '\n'
elif cmd == 'i' or cmd == '/i':
tag_text = '_'
elif cmd == 'b' or cmd == '/b':
tag_text = '**'
elif cmd == 'u' or cmd == '/u':
tag_text = '__'
else:
tag_text = '[' + tag_text + ']'
text = pre_text + tag_text + post_text
pos = len(pre_text) + len(tag_text)
text = pre_text + tag_text + post_text
pos = len(pre_text) + len(tag_text)
# tnode = ET.SubElement(parent,"div")
# tnode.text=text
return text
return text
def make_type(t):
global class_names
if t in class_names:
return '[' + t + '](class_' + t.lower() + ')'
return t
global class_names
if t in class_names:
return '[' + t + '](class_' + t.lower() + ')'
return t
def make_method(
f,
name,
m,
declare,
event=False,
):
f,
name,
m,
declare,
event=False,
):
s = ' * '
ret_type = 'void'
args = list(m)
mdata = {}
mdata['argidx'] = []
for a in args:
if a.tag == 'return':
idx = -1
elif a.tag == 'argument':
idx = int(a.attrib['index'])
else:
continue
s = ' * '
ret_type = 'void'
args = list(m)
mdata = {}
mdata['argidx'] = []
for a in args:
if a.tag == 'return':
idx = -1
elif a.tag == 'argument':
idx = int(a.attrib['index'])
else:
continue
mdata['argidx'].append(idx)
mdata[idx] = a
mdata['argidx'].append(idx)
mdata[idx] = a
if not event:
if -1 in mdata['argidx']:
s += make_type(mdata[-1].attrib['type'])
else:
s += 'void'
s += ' '
if not event:
if -1 in mdata['argidx']:
s += make_type(mdata[-1].attrib['type'])
else:
s += 'void'
s += ' '
if declare:
if declare:
# span.attrib["class"]="funcdecl"
# a=ET.SubElement(span,"a")
# a.attrib["name"]=name+"_"+m.attrib["name"]
# a.text=name+"::"+m.attrib["name"]
# span.attrib["class"]="funcdecl"
# a=ET.SubElement(span,"a")
# a.attrib["name"]=name+"_"+m.attrib["name"]
# a.text=name+"::"+m.attrib["name"]
s += ' **'+m.attrib['name'].replace("_","&#95;")+'** '
else:
s += ' **['+ m.attrib['name'].replace("_","&#95;")+'](#' + m.attrib['name'] + ')** '
s += ' **' + m.attrib['name'].replace("_", "&#95;") + '** '
else:
s += ' **[' + m.attrib['name'].replace("_", "&#95;") + '](#' + m.attrib['name'] + ')** '
s += ' **(**'
argfound = False
for a in mdata['argidx']:
arg = mdata[a]
if a < 0:
continue
if a > 0:
s += ', '
else:
s += ' '
s += ' **(**'
argfound = False
for a in mdata['argidx']:
arg = mdata[a]
if a < 0:
continue
if a > 0:
s += ', '
else:
s += ' '
s += make_type(arg.attrib['type'])
if 'name' in arg.attrib:
s += ' ' + arg.attrib['name']
else:
s += ' arg' + str(a)
s += make_type(arg.attrib['type'])
if 'name' in arg.attrib:
s += ' ' + arg.attrib['name']
else:
s += ' arg' + str(a)
if 'default' in arg.attrib:
s += '=' + arg.attrib['default']
if 'default' in arg.attrib:
s += '=' + arg.attrib['default']
argfound = True
argfound = True
if argfound:
s += ' '
s += ' **)**'
if argfound:
s += ' '
s += ' **)**'
if 'qualifiers' in m.attrib:
s += ' ' + m.attrib['qualifiers']
if 'qualifiers' in m.attrib:
s += ' ' + m.attrib['qualifiers']
f.write(s + '\n')
f.write(s + '\n')
def make_doku_class(node):
name = node.attrib['name']
name = node.attrib['name']
f = open("class_"+name.lower() + '.md', 'wb')
f = open("class_" + name.lower() + '.md', 'wb')
f.write('# ' + name + ' \n')
f.write('# ' + name + ' \n')
if 'inherits' in node.attrib:
inh = node.attrib['inherits'].strip()
f.write('####**Inherits:** '+make_type(inh)+'\n')
if 'category' in node.attrib:
f.write('####**Category:** ' + node.attrib['category'].strip()
+ '\n')
if 'inherits' in node.attrib:
inh = node.attrib['inherits'].strip()
f.write('####**Inherits:** ' + make_type(inh) + '\n')
if 'category' in node.attrib:
f.write('####**Category:** ' + node.attrib['category'].strip()
+ '\n')
briefd = node.find('brief_description')
if briefd != None:
f.write('\n### Brief Description \n')
f.write(dokuize_text(briefd.text.strip()) + '\n')
briefd = node.find('brief_description')
if briefd != None:
f.write('\n### Brief Description \n')
f.write(dokuize_text(briefd.text.strip()) + '\n')
methods = node.find('methods')
methods = node.find('methods')
if methods != None and len(list(methods)) > 0:
f.write('\n### Member Functions \n')
for m in list(methods):
make_method(f, node.attrib['name'], m, False)
if methods != None and len(list(methods)) > 0:
f.write('\n### Member Functions \n')
for m in list(methods):
make_method(f, node.attrib['name'], m, False)
events = node.find('signals')
if events != None and len(list(events)) > 0:
f.write('\n### Signals \n')
for m in list(events):
make_method(f, node.attrib['name'], m, True, True)
events = node.find('signals')
if events != None and len(list(events)) > 0:
f.write('\n### Signals \n')
for m in list(events):
make_method(f, node.attrib['name'], m, True, True)
members = node.find('members')
members = node.find('members')
if members != None and len(list(members)) > 0:
f.write('\n### Member Variables \n')
if members != None and len(list(members)) > 0:
f.write('\n### Member Variables \n')
for c in list(members):
s = ' * '
s += make_type(c.attrib['type']) + ' '
s += '**' + c.attrib['name'] + '**'
if c.text.strip() != '':
s += ' - ' + c.text.strip()
f.write(s + '\n')
for c in list(members):
s = ' * '
s += make_type(c.attrib['type']) + ' '
s += '**' + c.attrib['name'] + '**'
if c.text.strip() != '':
s += ' - ' + c.text.strip()
f.write(s + '\n')
constants = node.find('constants')
if constants != None and len(list(constants)) > 0:
f.write('\n### Numeric Constants \n')
for c in list(constants):
s = ' * '
s += '**' + c.attrib['name'] + '**'
if 'value' in c.attrib:
s += ' = **' + c.attrib['value'] + '**'
if c.text.strip() != '':
s += ' - ' + c.text.strip()
f.write(s + '\n')
constants = node.find('constants')
if constants != None and len(list(constants)) > 0:
f.write('\n### Numeric Constants \n')
for c in list(constants):
s = ' * '
s += '**' + c.attrib['name'] + '**'
if 'value' in c.attrib:
s += ' = **' + c.attrib['value'] + '**'
if c.text.strip() != '':
s += ' - ' + c.text.strip()
f.write(s + '\n')
descr = node.find('description')
if descr != None and descr.text.strip() != '':
f.write('\n### Description \n')
f.write(dokuize_text(descr.text.strip()) + '\n')
descr = node.find('description')
if descr != None and descr.text.strip() != '':
f.write('\n### Description \n')
f.write(dokuize_text(descr.text.strip()) + '\n')
methods = node.find('methods')
methods = node.find('methods')
if methods != None and len(list(methods)) > 0:
f.write('\n### Member Function Description \n')
for m in list(methods):
if methods != None and len(list(methods)) > 0:
f.write('\n### Member Function Description \n')
for m in list(methods):
d = m.find('description')
if d == None or d.text.strip() == '':
continue
f.write('\n#### <a name="'+m.attrib['name']+'">' + m.attrib['name'] + '</a>\n')
make_method(f, node.attrib['name'], m, True)
f.write('\n')
f.write(dokuize_text(d.text.strip()))
f.write('\n')
d = m.find('description')
if d == None or d.text.strip() == '':
continue
f.write('\n#### <a name="' + m.attrib['name'] + '">' + m.attrib['name'] + '</a>\n')
make_method(f, node.attrib['name'], m, True)
f.write('\n')
f.write(dokuize_text(d.text.strip()))
f.write('\n')
for file in input_list:
tree = ET.parse(file)
doc = tree.getroot()
tree = ET.parse(file)
doc = tree.getroot()
if 'version' not in doc.attrib:
print "Version missing from 'doc'"
sys.exit(255)
if 'version' not in doc.attrib:
print "Version missing from 'doc'"
sys.exit(255)
version = doc.attrib['version']
version = doc.attrib['version']
for c in list(doc):
if c.attrib['name'] in class_names:
continue
class_names.append(c.attrib['name'])
classes[c.attrib['name']] = c
for c in list(doc):
if c.attrib['name'] in class_names:
continue
class_names.append(c.attrib['name'])
classes[c.attrib['name']] = c
class_names.sort()
make_class_list(class_names, 2)
for cn in class_names:
c = classes[cn]
make_doku_class(c)
c = classes[cn]
make_doku_class(c)

View File

@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import codecs
@@ -8,512 +8,510 @@ import xml.etree.ElementTree as ET
input_list = []
for arg in sys.argv[1:]:
input_list.append(arg)
input_list.append(arg)
if len(input_list) < 1:
print 'usage: makerst.py <classes.xml>'
sys.exit(0)
print 'usage: makerst.py <classes.xml>'
sys.exit(0)
def validate_tag(elem, tag):
if elem.tag != tag:
print "Tag mismatch, expected '" + tag + "', got " + elem.tag
sys.exit(255)
if elem.tag != tag:
print "Tag mismatch, expected '" + tag + "', got " + elem.tag
sys.exit(255)
class_names = []
classes = {}
def ul_string(str,ul):
str+="\n"
for i in range(len(str)-1):
str+=ul
str+="\n"
return str
def ul_string(str, ul):
str += "\n"
for i in range(len(str) - 1):
str += ul
str += "\n"
return str
def make_class_list(class_list, columns):
f = codecs.open('class_list.rst', 'wb', 'utf-8')
prev = 0
col_max = len(class_list) / columns + 1
print ('col max is ', col_max)
col_count = 0
row_count = 0
last_initial = ''
fit_columns = []
f = codecs.open('class_list.rst', 'wb', 'utf-8')
prev = 0
col_max = len(class_list) / columns + 1
print ('col max is ', col_max)
col_count = 0
row_count = 0
last_initial = ''
fit_columns = []
for n in range(0, columns):
fit_columns += [[]]
for n in range(0, columns):
fit_columns += [[]]
indexers = []
last_initial = ''
indexers = []
last_initial = ''
idx = 0
for n in class_list:
col = idx / col_max
if col >= columns:
col = columns - 1
fit_columns[col] += [n]
idx += 1
if n[:1] != last_initial:
indexers += [n]
last_initial = n[:1]
idx = 0
for n in class_list:
col = idx / col_max
if col >= columns:
col = columns - 1
fit_columns[col] += [n]
idx += 1
if n[:1] != last_initial:
indexers += [n]
last_initial = n[:1]
row_max = 0
f.write("\n")
row_max = 0
f.write("\n")
for n in range(0, columns):
if len(fit_columns[n]) > row_max:
row_max = len(fit_columns[n])
for n in range(0, columns):
if len(fit_columns[n]) > row_max:
row_max = len(fit_columns[n])
f.write("| ")
for n in range(0, columns):
f.write(" | |")
f.write("| ")
for n in range(0, columns):
f.write(" | |")
f.write("\n")
f.write("+")
for n in range(0, columns):
f.write("--+-------+")
f.write("\n")
f.write("\n")
f.write("+")
for n in range(0, columns):
f.write("--+-------+")
f.write("\n")
for r in range(0, row_max):
s = '+ '
for c in range(0, columns):
if r >= len(fit_columns[c]):
continue
for r in range(0, row_max):
s = '+ '
for c in range(0, columns):
if r >= len(fit_columns[c]):
continue
classname = fit_columns[c][r]
initial = classname[0]
if classname in indexers:
s += '**' + initial + '** | '
else:
s += ' | '
classname = fit_columns[c][r]
initial = classname[0]
if classname in indexers:
s += '**' + initial + '** | '
else:
s += ' | '
s += '[' + classname + '](class_'+ classname.lower()+') | '
s += '[' + classname + '](class_' + classname.lower() + ') | '
s += '\n'
f.write(s)
s += '\n'
f.write(s)
for n in range(0, columns):
f.write("--+-------+")
f.write("\n")
for n in range(0, columns):
f.write("--+-------+")
f.write("\n")
def rstize_text(text,cclass):
def rstize_text(text, cclass):
# Linebreak + tabs in the XML should become two line breaks unless in a "codeblock"
pos = 0
while True:
pos = text.find('\n', pos)
if pos == -1:
break
# Linebreak + tabs in the XML should become two line breaks unless in a "codeblock"
pos = 0
while True:
pos = text.find('\n', pos)
if pos == -1:
break
pre_text = text[:pos]
while text[pos+1] == '\t':
pos += 1
post_text = text[pos+1:]
pre_text = text[:pos]
while text[pos + 1] == '\t':
pos += 1
post_text = text[pos + 1:]
# Handle codeblocks
if post_text.startswith("[codeblock]"):
end_pos = post_text.find("[/codeblock]")
if end_pos == -1:
sys.exit("ERROR! [codeblock] without a closing tag!")
# Handle codeblocks
if post_text.startswith("[codeblock]"):
end_pos = post_text.find("[/codeblock]")
if end_pos == -1:
sys.exit("ERROR! [codeblock] without a closing tag!")
code_text = post_text[len("[codeblock]"):end_pos]
post_text = post_text[end_pos:]
code_text = post_text[len("[codeblock]"):end_pos]
post_text = post_text[end_pos:]
# Remove extraneous tabs
code_pos = 0
while True:
code_pos = code_text.find('\n', code_pos)
if code_pos == -1:
break
# Remove extraneous tabs
code_pos = 0
while True:
code_pos = code_text.find('\n', code_pos)
if code_pos == -1:
break
to_skip = 0
while code_pos+to_skip+1 < len(code_text) and code_text[code_pos+to_skip+1] == '\t':
to_skip += 1
to_skip = 0
while code_pos + to_skip + 1 < len(code_text) and code_text[code_pos + to_skip + 1] == '\t':
to_skip += 1
if len(code_text[code_pos+to_skip+1:])==0:
code_text = code_text[:code_pos] + "\n"
code_pos += 1
else:
code_text = code_text[:code_pos] + "\n " + code_text[code_pos+to_skip+1:]
code_pos += 5 - to_skip
if len(code_text[code_pos + to_skip + 1:]) == 0:
code_text = code_text[:code_pos] + "\n"
code_pos += 1
else:
code_text = code_text[:code_pos] + "\n " + code_text[code_pos + to_skip + 1:]
code_pos += 5 - to_skip
text = pre_text + "\n[codeblock]" + code_text + post_text
pos += len("\n[codeblock]" + code_text)
text = pre_text + "\n[codeblock]" + code_text + post_text
pos += len("\n[codeblock]" + code_text)
# Handle normal text
else:
text = pre_text + "\n\n" + post_text
pos += 2
# Handle normal text
else:
text = pre_text + "\n\n" + post_text
pos += 2
# Escape * character to avoid interpreting it as emphasis
pos = 0
while True:
pos = text.find('*', pos)
if pos == -1:
break
text = text[:pos] + "\*" + text[pos + 1:]
pos += 2
# Escape * character to avoid interpreting it as emphasis
pos = 0
while True:
pos = text.find('*', pos)
if pos == -1:
break
text = text[:pos] + "\*" + text[pos + 1:]
pos += 2
# Escape _ character at the end of a word to avoid interpreting it as an inline hyperlink
pos = 0
while True:
pos = text.find('_', pos)
if pos == -1:
break
if not text[pos + 1].isalnum(): # don't escape within a snake_case word
text = text[:pos] + "\_" + text[pos + 1:]
pos += 2
else:
pos += 1
# Escape _ character at the end of a word to avoid interpreting it as an inline hyperlink
pos = 0
while True:
pos = text.find('_', pos)
if pos == -1:
break
if not text[pos + 1].isalnum(): # don't escape within a snake_case word
text = text[:pos] + "\_" + text[pos + 1:]
pos += 2
else:
pos += 1
# Handle [tags]
pos = 0
while True:
pos = text.find('[', pos)
if pos == -1:
break
# Handle [tags]
pos = 0
while True:
pos = text.find('[', pos)
if pos == -1:
break
endq_pos = text.find(']', pos + 1)
if endq_pos == -1:
break
endq_pos = text.find(']', pos + 1)
if endq_pos == -1:
break
pre_text = text[:pos]
post_text = text[endq_pos + 1:]
tag_text = text[pos + 1:endq_pos]
pre_text = text[:pos]
post_text = text[endq_pos + 1:]
tag_text = text[pos + 1:endq_pos]
if tag_text in class_names:
tag_text = make_type(tag_text)
else: # command
cmd = tag_text
space_pos = tag_text.find(' ')
if cmd.find('html') == 0:
cmd = tag_text[:space_pos]
param = tag_text[space_pos + 1:]
tag_text = param
elif cmd.find('method') == 0:
cmd = tag_text[:space_pos]
param = tag_text[space_pos + 1:]
if tag_text in class_names:
tag_text = make_type(tag_text)
else: # command
cmd = tag_text
space_pos = tag_text.find(' ')
if cmd.find('html') == 0:
cmd = tag_text[:space_pos]
param = tag_text[space_pos + 1:]
tag_text = param
elif cmd.find('method') == 0:
cmd = tag_text[:space_pos]
param = tag_text[space_pos + 1:]
if param.find('.') != -1:
(class_param, method_param) = param.split('.')
tag_text = ':ref:`'+class_param+'.'+method_param+'<class_' + class_param + '_' + method_param + '>`'
else:
tag_text = ':ref:`' + param + '<class_' + cclass +"_"+ param + '>`'
elif cmd.find('image=') == 0:
tag_text = "" #'![](' + cmd[6:] + ')'
elif cmd.find('url=') == 0:
tag_text = ':ref:`' + cmd[4:] + '<'+cmd[4:]+">`"
elif cmd == '/url':
tag_text = ')'
elif cmd == 'center':
tag_text = ''
elif cmd == '/center':
tag_text = ''
elif cmd == 'codeblock':
tag_text = '\n::\n'
elif cmd == '/codeblock':
tag_text = ''
# Strip newline if the tag was alone on one
if pre_text[-1] == '\n':
pre_text = pre_text[:-1]
elif cmd == 'br':
# Make a new paragraph instead of a linebreak, rst is not so linebreak friendly
tag_text = '\n\n'
# Strip potential leading spaces
while post_text[0] == ' ':
post_text = post_text[1:]
elif cmd == 'i' or cmd == '/i':
tag_text = '*'
elif cmd == 'b' or cmd == '/b':
tag_text = '**'
elif cmd == 'u' or cmd == '/u':
tag_text = ''
elif cmd == 'code' or cmd == '/code':
tag_text = '``'
else:
tag_text = ':ref:`' + tag_text + '<class_'+tag_text.lower()+'>`'
if param.find('.') != -1:
(class_param, method_param) = param.split('.')
tag_text = ':ref:`' + class_param + '.' + method_param + '<class_' + class_param + '_' + method_param + '>`'
else:
tag_text = ':ref:`' + param + '<class_' + cclass + "_" + param + '>`'
elif cmd.find('image=') == 0:
tag_text = "" # '![](' + cmd[6:] + ')'
elif cmd.find('url=') == 0:
tag_text = ':ref:`' + cmd[4:] + '<' + cmd[4:] + ">`"
elif cmd == '/url':
tag_text = ')'
elif cmd == 'center':
tag_text = ''
elif cmd == '/center':
tag_text = ''
elif cmd == 'codeblock':
tag_text = '\n::\n'
elif cmd == '/codeblock':
tag_text = ''
# Strip newline if the tag was alone on one
if pre_text[-1] == '\n':
pre_text = pre_text[:-1]
elif cmd == 'br':
# Make a new paragraph instead of a linebreak, rst is not so linebreak friendly
tag_text = '\n\n'
# Strip potential leading spaces
while post_text[0] == ' ':
post_text = post_text[1:]
elif cmd == 'i' or cmd == '/i':
tag_text = '*'
elif cmd == 'b' or cmd == '/b':
tag_text = '**'
elif cmd == 'u' or cmd == '/u':
tag_text = ''
elif cmd == 'code' or cmd == '/code':
tag_text = '``'
else:
tag_text = ':ref:`' + tag_text + '<class_' + tag_text.lower() + '>`'
text = pre_text + tag_text + post_text
pos = len(pre_text) + len(tag_text)
text = pre_text + tag_text + post_text
pos = len(pre_text) + len(tag_text)
# tnode = ET.SubElement(parent,"div")
# tnode.text=text
return text
return text
def make_type(t):
global class_names
if t in class_names:
return ':ref:`'+t+'<class_' + t.lower()+'>`'
return t
global class_names
if t in class_names:
return ':ref:`' + t + '<class_' + t.lower() + '>`'
return t
def make_method(
f,
name,
m,
declare,
cname,
event=False,
pp=None
):
f,
name,
m,
declare,
cname,
event=False,
pp=None
):
if (declare or pp==None):
t = '- '
else:
t = ""
if (declare or pp == None):
t = '- '
else:
t = ""
ret_type = 'void'
args = list(m)
mdata = {}
mdata['argidx'] = []
for a in args:
if a.tag == 'return':
idx = -1
elif a.tag == 'argument':
idx = int(a.attrib['index'])
else:
continue
ret_type = 'void'
args = list(m)
mdata = {}
mdata['argidx'] = []
for a in args:
if a.tag == 'return':
idx = -1
elif a.tag == 'argument':
idx = int(a.attrib['index'])
else:
continue
mdata['argidx'].append(idx)
mdata[idx] = a
mdata['argidx'].append(idx)
mdata[idx] = a
if not event:
if -1 in mdata['argidx']:
t += make_type(mdata[-1].attrib['type'])
else:
t += 'void'
t += ' '
if not event:
if -1 in mdata['argidx']:
t += make_type(mdata[-1].attrib['type'])
else:
t += 'void'
t += ' '
if declare or pp==None:
if declare or pp == None:
# span.attrib["class"]="funcdecl"
# a=ET.SubElement(span,"a")
# a.attrib["name"]=name+"_"+m.attrib["name"]
# a.text=name+"::"+m.attrib["name"]
# span.attrib["class"]="funcdecl"
# a=ET.SubElement(span,"a")
# a.attrib["name"]=name+"_"+m.attrib["name"]
# a.text=name+"::"+m.attrib["name"]
s = ' **'+m.attrib['name']+'** '
else:
s = ':ref:`'+ m.attrib['name']+'<class_' + cname+"_"+m.attrib['name'] + '>` '
s = ' **' + m.attrib['name'] + '** '
else:
s = ':ref:`' + m.attrib['name'] + '<class_' + cname + "_" + m.attrib['name'] + '>` '
s += ' **(**'
argfound = False
for a in mdata['argidx']:
arg = mdata[a]
if a < 0:
continue
if a > 0:
s += ', '
else:
s += ' '
s += ' **(**'
argfound = False
for a in mdata['argidx']:
arg = mdata[a]
if a < 0:
continue
if a > 0:
s += ', '
else:
s += ' '
s += make_type(arg.attrib['type'])
if 'name' in arg.attrib:
s += ' ' + arg.attrib['name']
else:
s += ' arg' + str(a)
s += make_type(arg.attrib['type'])
if 'name' in arg.attrib:
s += ' ' + arg.attrib['name']
else:
s += ' arg' + str(a)
if 'default' in arg.attrib:
s += '=' + arg.attrib['default']
if 'default' in arg.attrib:
s += '=' + arg.attrib['default']
argfound = True
argfound = True
if argfound:
s += ' '
s += ' **)**'
if argfound:
s += ' '
s += ' **)**'
if 'qualifiers' in m.attrib:
s += ' ' + m.attrib['qualifiers']
if 'qualifiers' in m.attrib:
s += ' ' + m.attrib['qualifiers']
# f.write(s)
if (not declare):
if (pp!=None):
pp.append( (t,s) )
else:
f.write("- "+t+" "+s+"\n")
else:
f.write(t+s+"\n")
if (not declare):
if (pp != None):
pp.append((t, s))
else:
f.write("- " + t + " " + s + "\n")
else:
f.write(t + s + "\n")
def make_heading(title, underline):
return title + '\n' + underline*len(title) + "\n\n"
return title + '\n' + underline * len(title) + "\n\n"
def make_rst_class(node):
name = node.attrib['name']
name = node.attrib['name']
f = codecs.open("class_"+name.lower() + '.rst', 'wb', 'utf-8')
f = codecs.open("class_" + name.lower() + '.rst', 'wb', 'utf-8')
# Warn contributors not to edit this file directly
f.write(".. Generated automatically by doc/tools/makerst.py in Godot's source tree.\n")
f.write(".. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.\n\n")
# Warn contributors not to edit this file directly
f.write(".. Generated automatically by doc/tools/makerst.py in Godot's source tree.\n")
f.write(".. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.\n\n")
f.write(".. _class_"+name+":\n\n")
f.write(make_heading(name, '='))
f.write(".. _class_" + name + ":\n\n")
f.write(make_heading(name, '='))
if 'inherits' in node.attrib:
inh = node.attrib['inherits'].strip()
if 'inherits' in node.attrib:
inh = node.attrib['inherits'].strip()
# whle inh in classes[cn]
f.write('**Inherits:** ')
first=True
while(inh in classes):
if (not first):
f.write(" **<** ")
else:
first=False
f.write('**Inherits:** ')
first = True
while(inh in classes):
if (not first):
f.write(" **<** ")
else:
first = False
f.write(make_type(inh))
inode = classes[inh]
if ('inherits' in inode.attrib):
inh=inode.attrib['inherits'].strip()
else:
inh=None
f.write(make_type(inh))
inode = classes[inh]
if ('inherits' in inode.attrib):
inh = inode.attrib['inherits'].strip()
else:
inh = None
f.write("\n\n")
f.write("\n\n")
inherited = []
for cn in classes:
c = classes[cn]
if 'inherits' in c.attrib:
if (c.attrib['inherits'].strip() == name):
inherited.append(c.attrib['name'])
inherited=[]
for cn in classes:
c=classes[cn]
if 'inherits' in c.attrib:
if (c.attrib['inherits'].strip()==name):
inherited.append(c.attrib['name'])
if (len(inherited)):
f.write('**Inherited By:** ')
for i in range(len(inherited)):
if (i > 0):
f.write(", ")
f.write(make_type(inherited[i]))
f.write("\n\n")
if 'category' in node.attrib:
f.write('**Category:** ' + node.attrib['category'].strip() + "\n\n")
if (len(inherited)):
f.write('**Inherited By:** ')
for i in range(len(inherited)):
if (i>0):
f.write(", ")
f.write(make_type(inherited[i]))
f.write("\n\n")
if 'category' in node.attrib:
f.write('**Category:** ' + node.attrib['category'].strip() + "\n\n")
f.write(make_heading('Brief Description', '-'))
briefd = node.find('brief_description')
if briefd != None:
f.write(rstize_text(briefd.text.strip(), name) + "\n\n")
f.write(make_heading('Brief Description', '-'))
briefd = node.find('brief_description')
if briefd != None:
f.write(rstize_text(briefd.text.strip(),name) + "\n\n")
methods = node.find('methods')
methods = node.find('methods')
if methods != None and len(list(methods)) > 0:
f.write(make_heading('Member Functions', '-'))
ml = []
for m in list(methods):
make_method(f, node.attrib['name'], m, False, name, False, ml)
longest_t = 0
longest_s = 0
for s in ml:
sl = len(s[0])
if (sl > longest_s):
longest_s = sl
tl = len(s[1])
if (tl > longest_t):
longest_t = tl
if methods != None and len(list(methods)) > 0:
f.write(make_heading('Member Functions', '-'))
ml=[]
for m in list(methods):
make_method(f, node.attrib['name'], m, False,name,False,ml)
longest_t = 0
longest_s = 0
for s in ml:
sl = len(s[0])
if (sl>longest_s):
longest_s=sl
tl = len(s[1])
if (tl>longest_t):
longest_t=tl
sep = "+"
for i in range(longest_s + 2):
sep += "-"
sep += "+"
for i in range(longest_t + 2):
sep += "-"
sep += "+\n"
f.write(sep)
for s in ml:
rt = s[0]
while(len(rt) < longest_s):
rt += " "
st = s[1]
while(len(st) < longest_t):
st += " "
f.write("| " + rt + " | " + st + " |\n")
f.write(sep)
f.write('\n')
sep="+"
for i in range(longest_s+2):
sep+="-"
sep+="+"
for i in range(longest_t+2):
sep+="-"
sep+="+\n"
f.write(sep)
for s in ml:
rt = s[0]
while( len(rt) < longest_s ):
rt+=" "
st = s[1]
while( len(st) < longest_t ):
st+=" "
f.write("| "+rt+" | "+st+" |\n")
f.write(sep)
f.write('\n')
events = node.find('signals')
if events != None and len(list(events)) > 0:
f.write(make_heading('Signals', '-'))
for m in list(events):
make_method(f, node.attrib['name'], m, True, name, True)
f.write('\n')
members = node.find('members')
if members != None and len(list(members)) > 0:
f.write(make_heading('Member Variables', '-'))
events = node.find('signals')
if events != None and len(list(events)) > 0:
f.write(make_heading('Signals', '-'))
for m in list(events):
make_method(f, node.attrib['name'], m, True,name, True)
f.write('\n')
for c in list(members):
s = '- '
s += make_type(c.attrib['type']) + ' '
s += '**' + c.attrib['name'] + '**'
if c.text.strip() != '':
s += ' - ' + c.text.strip()
f.write(s + '\n')
f.write('\n')
members = node.find('members')
if members != None and len(list(members)) > 0:
f.write(make_heading('Member Variables', '-'))
constants = node.find('constants')
if constants != None and len(list(constants)) > 0:
f.write(make_heading('Numeric Constants', '-'))
for c in list(constants):
s = '- '
s += '**' + c.attrib['name'] + '**'
if 'value' in c.attrib:
s += ' = **' + c.attrib['value'] + '**'
if c.text.strip() != '':
s += ' --- ' + rstize_text(c.text.strip(), name)
f.write(s + '\n')
f.write('\n')
for c in list(members):
s = '- '
s += make_type(c.attrib['type']) + ' '
s += '**' + c.attrib['name'] + '**'
if c.text.strip() != '':
s += ' - ' + c.text.strip()
f.write(s + '\n')
f.write('\n')
descr = node.find('description')
if descr != None and descr.text.strip() != '':
f.write(make_heading('Description', '-'))
f.write(rstize_text(descr.text.strip(), name) + "\n\n")
constants = node.find('constants')
if constants != None and len(list(constants)) > 0:
f.write(make_heading('Numeric Constants', '-'))
for c in list(constants):
s = '- '
s += '**' + c.attrib['name'] + '**'
if 'value' in c.attrib:
s += ' = **' + c.attrib['value'] + '**'
if c.text.strip() != '':
s += ' --- ' + rstize_text(c.text.strip(),name)
f.write(s + '\n')
f.write('\n')
descr = node.find('description')
if descr != None and descr.text.strip() != '':
f.write(make_heading('Description', '-'))
f.write(rstize_text(descr.text.strip(),name) + "\n\n")
methods = node.find('methods')
if methods != None and len(list(methods)) > 0:
f.write(make_heading('Member Function Description', '-'))
for m in list(methods):
f.write(".. _class_"+name+"_"+m.attrib['name']+":\n\n")
methods = node.find('methods')
if methods != None and len(list(methods)) > 0:
f.write(make_heading('Member Function Description', '-'))
for m in list(methods):
f.write(".. _class_" + name + "_" + m.attrib['name'] + ":\n\n")
# f.write(ul_string(m.attrib['name'],"^"))
#f.write('\n<a name="'+m.attrib['name']+'">' + m.attrib['name'] + '</a>\n------\n')
make_method(f, node.attrib['name'], m, True,name)
f.write('\n')
d = m.find('description')
if d == None or d.text.strip() == '':
continue
f.write(rstize_text(d.text.strip(),name))
f.write("\n\n")
f.write('\n')
#f.write('\n<a name="'+m.attrib['name']+'">' + m.attrib['name'] + '</a>\n------\n')
make_method(f, node.attrib['name'], m, True, name)
f.write('\n')
d = m.find('description')
if d == None or d.text.strip() == '':
continue
f.write(rstize_text(d.text.strip(), name))
f.write("\n\n")
f.write('\n')
for file in input_list:
tree = ET.parse(file)
doc = tree.getroot()
tree = ET.parse(file)
doc = tree.getroot()
if 'version' not in doc.attrib:
print "Version missing from 'doc'"
sys.exit(255)
if 'version' not in doc.attrib:
print "Version missing from 'doc'"
sys.exit(255)
version = doc.attrib['version']
version = doc.attrib['version']
for c in list(doc):
if c.attrib['name'] in class_names:
continue
class_names.append(c.attrib['name'])
classes[c.attrib['name']] = c
for c in list(doc):
if c.attrib['name'] in class_names:
continue
class_names.append(c.attrib['name'])
classes[c.attrib['name']] = c
class_names.sort()
#Don't make class list for Sphinx, :toctree: handles it
# Don't make class list for Sphinx, :toctree: handles it
#make_class_list(class_names, 2)
for cn in class_names:
c = classes[cn]
make_rst_class(c)
c = classes[cn]
make_rst_class(c)

134
drivers/SCsub vendored
View File

@@ -1,115 +1,41 @@
#!/usr/bin/env python
Import('env')
env_drivers = env.Clone()
env.drivers_sources = []
env.drivers_sources=[]
#env.add_source_files(env.drivers_sources,"*.cpp")
env_drivers.Append(CPPPATH=["vorbis"])
if ("builtin_zlib" in env and env["builtin_zlib"] == "yes"):
SConscript("zlib/SCsub")
Export('env_drivers')
# OS drivers
SConscript('unix/SCsub')
SConscript('windows/SCsub')
SConscript('unix/SCsub');
SConscript('alsa/SCsub');
SConscript('pulseaudio/SCsub');
SConscript('windows/SCsub');
SConscript('gles2/SCsub');
SConscript('gl_context/SCsub');
SConscript('pnm/SCsub');
# Sounds drivers
SConscript('alsa/SCsub')
SConscript('pulseaudio/SCsub')
if (env["platform"] == "windows"):
SConscript("rtaudio/SCsub")
if (env['openssl']!='no'):
env_drivers.Append(CPPFLAGS=['-DOPENSSL_ENABLED']);
if (env['openssl']=="builtin"):
env_drivers.Append(CPPPATH=['#drivers/builtin_openssl2'])
SConscript("builtin_openssl2/SCsub");
# Graphics drivers
SConscript('gles2/SCsub')
SConscript('gl_context/SCsub')
SConscript('openssl/SCsub')
# Core dependencies
SConscript("png/SCsub")
SConscript("nrex/SCsub")
# Tools override
# FIXME: Should likely be integrated in the tools/ codebase
if (env["tools"] == "yes"):
SConscript("convex_decomp/SCsub")
if (env["png"]=="yes"):
SConscript("png/SCsub");
if (env["jpg"]=="yes"):
#SConscript("jpg/SCsub");
SConscript("jpegd/SCsub");
if (env["webp"]=="yes"):
SConscript("webp/SCsub");
SConscript("dds/SCsub");
SConscript("pvr/SCsub");
SConscript("etc1/SCsub")
if (env["builtin_zlib"]=="yes"):
SConscript("builtin_zlib/SCsub");
if env['vsproj'] == "yes":
env.AddToVSProject(env.drivers_sources)
SConscript("rtaudio/SCsub");
SConscript("nedmalloc/SCsub");
SConscript("nrex/SCsub");
SConscript("chibi/SCsub");
if (env["vorbis"]=="yes" or env["speex"]=="yes" or env["theoralib"]=="yes" or env["opus"]=="yes"):
SConscript("ogg/SCsub");
if (env["vorbis"]=="yes"):
SConscript("vorbis/SCsub");
if (env["opus"]=="yes"):
SConscript('opus/SCsub');
if (env["tools"]=="yes"):
SConscript("convex_decomp/SCsub");
if (env["theoralib"]=="yes"):
SConscript("theora/SCsub");
if (env['speex']=='yes'):
SConscript("speex/SCsub");
if (env['musepack']=='yes'):
SConscript("mpc/SCsub");
if (env["squish"]=="yes" and env["tools"]=="yes"):
SConscript("squish/SCsub");
if (env["freetype"]!="no"):
SConscript("freetype/SCsub");
num = 0
cur_base = ""
total = len(env.drivers_sources)
max_src = 64
list = []
lib_list = []
import string
if env['vsproj']=="yes":
env.AddToVSProject(env.drivers_sources)
if (env.split_drivers): #split drivers, this used to be needed for windows until separate builders for windows were created
for f in env.drivers_sources:
fname = ""
if type(f) == type(""):
fname = env.File(f).path
else:
fname = env.File(f)[0].path
fname = fname.replace("\\", "/")
base = string.join(fname.split("/")[:2], "/")
if base != cur_base and len(list) > max_src:
if num > 0:
lib = env_drivers.Library("drivers"+str(num), list)
lib_list.append(lib)
list = []
num = num+1
cur_base = base
list.append(f)
lib = env_drivers.Library("drivers"+str(num), list)
lib_list.append(lib)
if len(lib_list) > 0:
import os, sys
if os.name=='posix' and sys.platform=='msys':
env.Replace(ARFLAGS=['rcsT'])
lib = env_drivers.Library("drivers_collated", lib_list)
lib_list = [lib]
drivers_base=[]
env_drivers.add_source_files(drivers_base,"*.cpp")
lib_list.insert(0, env_drivers.Library("drivers", drivers_base))
env.Prepend(LIBS=lib_list)
if env.split_drivers:
env.split_lib("drivers")
else:
env_drivers.add_source_files(env.drivers_sources,"*.cpp")
lib = env_drivers.Library("drivers",env.drivers_sources)
env.Prepend(LIBS=[lib])
env.add_source_files(env.drivers_sources, "*.cpp")
lib = env.Library("drivers", env.drivers_sources)
env.Prepend(LIBS=[lib])

View File

@@ -1,5 +1,7 @@
#!/usr/bin/env python
Import('env')
env.add_source_files(env.drivers_sources,"*.cpp")
env.add_source_files(env.drivers_sources, "*.cpp")
Export('env')

File diff suppressed because it is too large Load Diff

View File

@@ -1,22 +0,0 @@
Import('env')
zlib_sources = [
"builtin_zlib/zlib/adler32.c",
"builtin_zlib/zlib/compress.c",
"builtin_zlib/zlib/crc32.c",
"builtin_zlib/zlib/deflate.c",
"builtin_zlib/zlib/infback.c",
"builtin_zlib/zlib/inffast.c",
"builtin_zlib/zlib/inflate.c",
"builtin_zlib/zlib/inftrees.c",
"builtin_zlib/zlib/trees.c",
"builtin_zlib/zlib/uncompr.c",
"builtin_zlib/zlib/zutil.c",
]
env.drivers_sources+=zlib_sources
#env.add_source_files("core", png_sources)
Export('env')

View File

@@ -1,5 +0,0 @@
Import('env')
env.add_source_files(env.drivers_sources,"*.cpp")
Export('env')

View File

@@ -1,4 +1,7 @@
Import('env')
Export('env');
#!/usr/bin/env python
env.add_source_files(env.drivers_sources,"*.cpp")
Import('env')
env.add_source_files(env.drivers_sources, "*.cpp")
Export('env')

View File

@@ -1,10 +0,0 @@
Import('env')
dds_sources = [
"dds/texture_loader_dds.cpp"
]
env.drivers_sources+=dds_sources
#env.add_source_files(env.drivers_sources, dds_sources)

View File

@@ -1,15 +0,0 @@
Import('env')
etc_sources = [
"etc1/image_etc.cpp",
"etc1/rg_etc1.cpp",
"etc1/texture_loader_pkm.cpp"
]
if (env["etc1"] != "no"):
env.drivers_sources+=etc_sources
#env.add_source_files(env.drivers_sources, etc_sources)
Export('env')

View File

@@ -1,68 +0,0 @@
Import('env')
ft_sources=[\
"src/autofit/autofit.c",\
"src/base/ftapi.c",\
"src/base/ftbase.c",\
"src/base/ftbbox.c",\
"src/base/ftbdf.c",\
"src/base/ftbitmap.c",\
"src/base/ftcid.c",\
"src/base/ftdebug.c",\
"src/base/ftfntfmt.c",\
"src/base/ftfstype.c",\
"src/base/ftgasp.c",\
"src/base/ftglyph.c",\
"src/base/ftgxval.c",\
"src/base/ftinit.c",\
"src/base/ftlcdfil.c",\
"src/base/ftmm.c",\
"src/base/ftotval.c",\
"src/base/ftpatent.c",\
"src/base/ftpfr.c",\
"src/base/ftpic.c",\
"src/base/ftstroke.c",\
"src/base/ftsynth.c",\
"src/base/ftsystem.c",\
"src/base/fttype1.c",\
"src/base/ftwinfnt.c",\
"src/bdf/bdf.c",\
"src/cache/ftcache.c",\
"src/cff/cff.c",\
"src/cid/type1cid.c",\
"src/gxvalid/gxvalid.c",\
"src/otvalid/otvalid.c",\
"src/pcf/pcf.c",\
"src/pfr/pfr.c",\
"src/psaux/psaux.c",\
"src/pshinter/pshinter.c",\
"src/psnames/psnames.c",\
"src/raster/raster.c",\
"src/sfnt/sfnt.c",\
"src/smooth/smooth.c",\
"src/truetype/truetype.c",\
"src/type1/type1.c",\
"src/type42/type42.c",\
"src/winfonts/winfnt.c",\
]
if (env["freetype"]=="builtin"):
# fix for Windows' shell miserably failing on long lines, split in two libraries
half1=[]
half2=[]
for x in ft_sources:
if (x.find("src/base")==0 or x.find("src/sfnt")==0):
half2.append(x)
else:
half1.append(x)
lib = env.Library("freetype_builtin1",half2)
env.Append(LIBS=[lib])
lib = env.Library("freetype_builtin2",half1)
env.Append(LIBS=[lib])
env.Append(CPPPATH=["#drivers/freetype/include"])
Export('env')

View File

@@ -1,19 +0,0 @@
# FreeType 2 src Jamfile
#
# Copyright 2001-2016 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
# and distributed under the terms of the FreeType project license,
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
# indicate that you have read the license and understand and accept it
# fully.
SubDir FT2_TOP $(FT2_SRC_DIR) ;
for xx in $(FT2_COMPONENTS)
{
SubInclude FT2_TOP $(FT2_SRC_DIR) $(xx) ;
}
# end of src Jamfile

View File

@@ -1,53 +0,0 @@
# FreeType 2 src/autofit Jamfile
#
# Copyright 2003-2016 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
# and distributed under the terms of the FreeType project license,
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
# indicate that you have read the license and understand and accept it
# fully.
SubDir FT2_TOP src autofit ;
{
local _sources ;
# define FT2_AUTOFIT2 to enable experimental latin hinter replacement
if $(FT2_AUTOFIT2)
{
CCFLAGS += FT_OPTION_AUTOFIT2 ;
}
if $(FT2_MULTI)
{
_sources = afangles
afblue
afcjk
afdummy
afglobal
afhints
afindic
aflatin
afloader
afmodule
afpic
afranges
afshaper
afwarp
;
if $(FT2_AUTOFIT2)
{
_sources += aflatin2 ;
}
}
else
{
_sources = autofit ;
}
Library $(FT2_LIB) : $(_sources).c ;
}
# end of src/autofit Jamfile

View File

@@ -1,88 +0,0 @@
# FreeType 2 src/base Jamfile
#
# Copyright 2001-2016 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
# and distributed under the terms of the FreeType project license,
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
# indicate that you have read the license and understand and accept it
# fully.
SubDir FT2_TOP $(FT2_SRC_DIR) base ;
{
local _sources ;
if $(FT2_MULTI)
{
_sources = basepic
ftadvanc
ftcalc
ftdbgmem
ftgloadr
fthash
ftobjs
ftoutln
ftpic
ftrfork
ftsnames
ftstream
fttrigon
ftutil
;
}
else
{
_sources = ftbase ;
}
Library $(FT2_LIB) : $(_sources).c ;
}
# Add the optional/replaceable files.
#
{
local _sources = ftapi
ftbbox
ftbdf
ftbitmap
ftcid
ftdebug
ftfntfmt
ftfstype
ftgasp
ftglyph
ftgxval
ftinit
ftlcdfil
ftmm
ftotval
ftpatent
ftpfr
ftstroke
ftsynth
ftsystem
fttype1
ftwinfnt
;
Library $(FT2_LIB) : $(_sources).c ;
}
# Add Macintosh-specific file to the library when necessary.
#
if $(MAC)
{
Library $(FT2_LIB) : ftmac.c ;
}
else if $(OS) = MACOSX
{
if $(FT2_MULTI)
{
Library $(FT2_LIB) : ftmac.c ;
}
}
# end of src/base Jamfile

View File

@@ -1,31 +0,0 @@
# FreeType 2 src/bdf Jamfile
#
# Copyright 2002-2016 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
# and distributed under the terms of the FreeType project license,
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
# indicate that you have read the license and understand and accept it
# fully.
SubDir FT2_TOP $(FT2_SRC_DIR) bdf ;
{
local _sources ;
if $(FT2_MULTI)
{
_sources = bdfdrivr
bdflib
;
}
else
{
_sources = bdf ;
}
Library $(FT2_LIB) : $(_sources).c ;
}
# end of src/bdf Jamfile

View File

@@ -1,37 +0,0 @@
# FreeType 2 src/cache Jamfile
#
# Copyright 2001-2016 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
# and distributed under the terms of the FreeType project license,
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
# indicate that you have read the license and understand and accept it
# fully.
SubDir FT2_TOP $(FT2_SRC_DIR) cache ;
{
local _sources ;
if $(FT2_MULTI)
{
_sources = ftcbasic
ftccache
ftcglyph
ftcimage
ftcmanag
ftccmap
ftcmru
ftcsbits
;
}
else
{
_sources = ftcache ;
}
Library $(FT2_LIB) : $(_sources).c ;
}
# end of src/cache Jamfile

View File

@@ -1,45 +0,0 @@
# FreeType 2 src/cff Jamfile
#
# Copyright 2001-2016 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
# and distributed under the terms of the FreeType project license,
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
# indicate that you have read the license and understand and accept it
# fully.
SubDir FT2_TOP $(FT2_SRC_DIR) cff ;
{
local _sources ;
if $(FT2_MULTI)
{
_sources = cffcmap
cffdrivr
cffgload
cffload
cffobjs
cffparse
cffpic
cf2arrst
cf2blues
cf2error
cf2font
cf2ft
cf2hints
cf2intrp
cf2read
cf2stack
;
}
else
{
_sources = cff ;
}
Library $(FT2_LIB) : $(_sources).c ;
}
# end of src/cff Jamfile

View File

@@ -1,34 +0,0 @@
# FreeType 2 src/cid Jamfile
#
# Copyright 2001-2016 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
# and distributed under the terms of the FreeType project license,
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
# indicate that you have read the license and understand and accept it
# fully.
SubDir FT2_TOP $(FT2_SRC_DIR) cid ;
{
local _sources ;
if $(FT2_MULTI)
{
_sources = cidgload
cidload
cidobjs
cidparse
cidriver
;
}
else
{
_sources = type1cid ;
}
Library $(FT2_LIB) : $(_sources).c ;
}
# end of src/cid Jamfile

View File

@@ -1,52 +0,0 @@
# FreeType 2 src/gxvalid Jamfile
#
# Copyright 2005-2016 by
# suzuki toshiya, Masatake YAMATO and Red Hat K.K.
#
# This file is part of the FreeType project, and may only be used, modified,
# and distributed under the terms of the FreeType project license,
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
# indicate that you have read the license and understand and accept it
# fully.
SubDir FT2_TOP $(FT2_SRC_DIR) gxvalid ;
{
local _sources ;
if $(FT2_MULTI)
{
_sources = gxvbsln
gxvcommn
gxvfeat
gxvjust
gxvkern
gxvlcar
gxvmod
gxvmort
gxvmort0
gxvmort1
gxvmort2
gxvmort4
gxvmort5
gxvmorx
gxvmorx0
gxvmorx1
gxvmorx2
gxvmorx4
gxvmorx5
gxvopbd
gxvprop
gxvtrak
;
}
else
{
_sources = gxvalid ;
}
Library $(FT2_LIB) : $(_sources).c ;
}
# end of src/gxvalid Jamfile

View File

@@ -1,37 +0,0 @@
# FreeType 2 src/otvalid Jamfile
#
# Copyright 2004-2016 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
# and distributed under the terms of the FreeType project license,
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
# indicate that you have read the license and understand and accept it
# fully.
SubDir FT2_TOP $(FT2_SRC_DIR) otvalid ;
{
local _sources ;
if $(FT2_MULTI)
{
_sources = otvbase
otvcommn
otvgdef
otvgpos
otvgsub
otvjstf
otvmath
otvmod
;
}
else
{
_sources = otvalid ;
}
Library $(FT2_LIB) : $(_sources).c ;
}
# end of src/otvalid Jamfile

View File

@@ -1,32 +0,0 @@
# FreeType 2 src/pcf Jamfile
#
# Copyright 2001-2016 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
# and distributed under the terms of the FreeType project license,
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
# indicate that you have read the license and understand and accept it
# fully.
SubDir FT2_TOP $(FT2_SRC_DIR) pcf ;
{
local _sources ;
if $(FT2_MULTI)
{
_sources = pcfdrivr
pcfread
pcfutil
;
}
else
{
_sources = pcf ;
}
Library $(FT2_LIB) : $(_sources).c ;
}
# end of src/pcf Jamfile

View File

@@ -1,35 +0,0 @@
# FreeType 2 src/pfr Jamfile
#
# Copyright 2002-2016 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
# and distributed under the terms of the FreeType project license,
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
# indicate that you have read the license and understand and accept it
# fully.
SubDir FT2_TOP $(FT2_SRC_DIR) pfr ;
{
local _sources ;
if $(FT2_MULTI)
{
_sources = pfrcmap
pfrdrivr
pfrgload
pfrload
pfrobjs
pfrsbit
;
}
else
{
_sources = pfr ;
}
Library $(FT2_LIB) : $(_sources).c ;
}
# end of src/pfr Jamfile

View File

@@ -1,35 +0,0 @@
# FreeType 2 src/psaux Jamfile
#
# Copyright 2001-2016 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
# and distributed under the terms of the FreeType project license,
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
# indicate that you have read the license and understand and accept it
# fully.
SubDir FT2_TOP $(FT2_SRC_DIR) psaux ;
{
local _sources ;
if $(FT2_MULTI)
{
_sources = afmparse
psauxmod
psconv
psobjs
t1cmap
t1decode
;
}
else
{
_sources = psaux ;
}
Library $(FT2_LIB) : $(_sources).c ;
}
# end of src/psaux Jamfile

View File

@@ -1,34 +0,0 @@
# FreeType 2 src/pshinter Jamfile
#
# Copyright 2001-2016 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
# and distributed under the terms of the FreeType project license,
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
# indicate that you have read the license and understand and accept it
# fully.
SubDir FT2_TOP $(FT2_SRC_DIR) pshinter ;
{
local _sources ;
if $(FT2_MULTI)
{
_sources = pshalgo
pshglob
pshmod
pshpic
pshrec
;
}
else
{
_sources = pshinter ;
}
Library $(FT2_LIB) : $(_sources).c ;
}
# end of src/pshinter Jamfile

View File

@@ -1,31 +0,0 @@
# FreeType 2 src/psnames Jamfile
#
# Copyright 2001-2016 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
# and distributed under the terms of the FreeType project license,
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
# indicate that you have read the license and understand and accept it
# fully.
SubDir FT2_TOP $(FT2_SRC_DIR) psnames ;
{
local _sources ;
if $(FT2_MULTI)
{
_sources = psmodule
pspic
;
}
else
{
_sources = psnames ;
}
Library $(FT2_LIB) : $(_sources).c ;
}
# end of src/psnames Jamfile

View File

@@ -1,32 +0,0 @@
# FreeType 2 src/raster Jamfile
#
# Copyright 2001-2016 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
# and distributed under the terms of the FreeType project license,
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
# indicate that you have read the license and understand and accept it
# fully.
SubDir FT2_TOP $(FT2_SRC_DIR) raster ;
{
local _sources ;
if $(FT2_MULTI)
{
_sources = ftraster
ftrend1
rastpic
;
}
else
{
_sources = raster ;
}
Library $(FT2_LIB) : $(_sources).c ;
}
# end of src/raster Jamfile

View File

@@ -1,40 +0,0 @@
# FreeType 2 src/sfnt Jamfile
#
# Copyright 2001-2016 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
# and distributed under the terms of the FreeType project license,
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
# indicate that you have read the license and understand and accept it
# fully.
SubDir FT2_TOP $(FT2_SRC_DIR) sfnt ;
{
local _sources ;
if $(FT2_MULTI)
{
_sources = pngshim
sfdriver
sfntpic
sfobjs
ttbdf
ttcmap
ttkern
ttload
ttmtx
ttpost
ttsbit
;
}
else
{
_sources = sfnt ;
}
Library $(FT2_LIB) : $(_sources).c ;
}
# end of src/sfnt Jamfile

View File

@@ -1,32 +0,0 @@
# FreeType 2 src/smooth Jamfile
#
# Copyright 2001-2016 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
# and distributed under the terms of the FreeType project license,
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
# indicate that you have read the license and understand and accept it
# fully.
SubDir FT2_TOP $(FT2_SRC_DIR) smooth ;
{
local _sources ;
if $(FT2_MULTI)
{
_sources = ftgrays
ftsmooth
ftspic
;
}
else
{
_sources = smooth ;
}
Library $(FT2_LIB) : $(_sources).c ;
}
# end of src/smooth Jamfile

View File

@@ -1,37 +0,0 @@
# FreeType 2 src/truetype Jamfile
#
# Copyright 2001-2016 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
# and distributed under the terms of the FreeType project license,
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
# indicate that you have read the license and understand and accept it
# fully.
SubDir FT2_TOP $(FT2_SRC_DIR) truetype ;
{
local _sources ;
if $(FT2_MULTI)
{
_sources = ttdriver
ttgload
ttgxvar
ttinterp
ttobjs
ttpic
ttpload
ttsubpix
;
}
else
{
_sources = truetype ;
}
Library $(FT2_LIB) : $(_sources).c ;
}
# end of src/truetype Jamfile

View File

@@ -1,35 +0,0 @@
# FreeType 2 src/type1 Jamfile
#
# Copyright 2001-2016 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
# and distributed under the terms of the FreeType project license,
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
# indicate that you have read the license and understand and accept it
# fully.
SubDir FT2_TOP $(FT2_SRC_DIR) type1 ;
{
local _sources ;
if $(FT2_MULTI)
{
_sources = t1afm
t1driver
t1gload
t1load
t1objs
t1parse
;
}
else
{
_sources = type1 ;
}
Library $(FT2_LIB) : $(_sources).c ;
}
# end of src/type1 Jamfile

View File

@@ -1,32 +0,0 @@
# FreeType 2 src/type42 Jamfile
#
# Copyright 2002-2016 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
# and distributed under the terms of the FreeType project license,
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
# indicate that you have read the license and understand and accept it
# fully.
SubDir FT2_TOP $(FT2_SRC_DIR) type42 ;
{
local _sources ;
if $(FT2_MULTI)
{
_sources = t42drivr
t42objs
t42parse
;
}
else
{
_sources = type42 ;
}
Library $(FT2_LIB) : $(_sources).c ;
}
# end of src/type42 Jamfile

View File

@@ -1,16 +0,0 @@
# FreeType 2 src/winfonts Jamfile
#
# Copyright 2001-2016 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
# and distributed under the terms of the FreeType project license,
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
# indicate that you have read the license and understand and accept it
# fully.
SubDir FT2_TOP $(FT2_SRC_DIR) winfonts ;
Library $(FT2_LIB) : winfnt.c ;
# end of src/winfonts Jamfile

View File

@@ -1,11 +1,23 @@
#!/usr/bin/env python
Import('env')
env.add_source_files(env.drivers_sources,"*.cpp")
if (env["platform"] in ["haiku", "osx", "windows", "x11"]):
# Thirdparty source files
if (env['builtin_glew'] != 'no'): # builtin
thirdparty_dir = "#thirdparty/glew/"
thirdparty_sources = [
"glew.c",
]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
if (env.get('glew') == 'yes'):
env.add_source_files(env.drivers_sources,"glew.c")
env.Append(CPPFLAGS = ['-DGLEW_ENABLED'])
env.Append(CPPFLAGS = ['-DGLEW_STATIC'])
env.Append(CPPPATH = ['.'])
env.add_source_files(env.drivers_sources, thirdparty_sources)
env.Append(CPPFLAGS=['-DGLEW_STATIC'])
env.Append(CPPPATH=[thirdparty_dir])
env.Append(CPPFLAGS=['-DGLEW_ENABLED'])
# Godot source files
env.add_source_files(env.drivers_sources, "*.cpp")
Export('env')

View File

@@ -1,5 +1,9 @@
#!/usr/bin/env python
Import('env')
env.add_source_files(env.drivers_sources,"*.cpp")
env.add_source_files(env.drivers_sources, "*.cpp")
SConscript("shaders/SCsub")
Export('env')

View File

@@ -36,6 +36,7 @@
#include "servers/visual/particle_system_sw.h"
#include "gl_context/context_gl.h"
#include <string.h>
#include <stdlib.h>
#ifdef GLEW_ENABLED
#define _GL_HALF_FLOAT_OES 0x140B
@@ -1998,7 +1999,6 @@ void RasterizerGLES2::mesh_add_surface(RID p_mesh,VS::PrimitiveType p_primitive,
if (use_VBO) {
elem_size=VS::ARRAY_WEIGHTS_SIZE*sizeof(GLushort);
elem_count=VS::ARRAY_WEIGHTS_SIZE;
valid_local=false;
bind=true;
normalize=true;
@@ -2007,7 +2007,6 @@ void RasterizerGLES2::mesh_add_surface(RID p_mesh,VS::PrimitiveType p_primitive,
} else {
elem_size=VS::ARRAY_WEIGHTS_SIZE*sizeof(GLfloat);
elem_count=VS::ARRAY_WEIGHTS_SIZE;
valid_local=false;
bind=false;
datatype=GL_FLOAT;
@@ -2019,7 +2018,6 @@ void RasterizerGLES2::mesh_add_surface(RID p_mesh,VS::PrimitiveType p_primitive,
if (use_VBO) {
elem_size=VS::ARRAY_WEIGHTS_SIZE*sizeof(GLubyte);
elem_count=VS::ARRAY_WEIGHTS_SIZE;
valid_local=false;
bind=true;
datatype=GL_UNSIGNED_BYTE;
@@ -2027,7 +2025,6 @@ void RasterizerGLES2::mesh_add_surface(RID p_mesh,VS::PrimitiveType p_primitive,
} else {
elem_size=VS::ARRAY_WEIGHTS_SIZE*sizeof(GLushort);
elem_count=VS::ARRAY_WEIGHTS_SIZE;
valid_local=false;
bind=false;
datatype=GL_UNSIGNED_SHORT;
@@ -4666,7 +4663,7 @@ void RasterizerGLES2::_update_shader( Shader* p_shader) const {
enablers.push_back("#define USE_LIGHT_SHADER_CODE\n");
}
if (light_flags.uses_shadow_color) {
enablers.push_back("#define USE_LIGHT_SHADOW_COLOR\n");
enablers.push_back("#define USE_OUTPUT_SHADOW_COLOR\n");
}
if (light_flags.uses_time || fragment_flags.uses_time || vertex_flags.uses_time) {
enablers.push_back("#define USE_TIME\n");
@@ -4709,7 +4706,7 @@ void RasterizerGLES2::_update_shader( Shader* p_shader) const {
enablers.push_back("#define USE_TEXPIXEL_SIZE\n");
}
if (light_flags.uses_shadow_color) {
enablers.push_back("#define USE_LIGHT_SHADOW_COLOR\n");
enablers.push_back("#define USE_OUTPUT_SHADOW_COLOR\n");
}
if (vertex_flags.uses_worldvec) {
@@ -5460,9 +5457,16 @@ void RasterizerGLES2::_setup_light(uint16_t p_light) {
}
light_data[VL_LIGHT_ATTENUATION][0]=l->vars[VS::LIGHT_PARAM_ENERGY];
light_data[VL_LIGHT_ATTENUATION][1]=l->vars[VS::LIGHT_PARAM_RADIUS];
light_data[VL_LIGHT_ATTENUATION][2]=l->vars[VS::LIGHT_PARAM_ATTENUATION];
light_data[VL_LIGHT_ATTENUATION][0] = l->vars[VS::LIGHT_PARAM_ENERGY];
if (l->type == VS::LIGHT_DIRECTIONAL) {
light_data[VL_LIGHT_ATTENUATION][1] = l->directional_shadow_param[VS::LIGHT_DIRECTIONAL_SHADOW_PARAM_MAX_DISTANCE];
}
else{
light_data[VL_LIGHT_ATTENUATION][1] = l->vars[VS::LIGHT_PARAM_RADIUS];
}
light_data[VL_LIGHT_ATTENUATION][2] = l->vars[VS::LIGHT_PARAM_ATTENUATION];
light_data[VL_LIGHT_SPOT_ATTENUATION][0]=Math::cos(Math::deg2rad(l->vars[VS::LIGHT_PARAM_SPOT_ANGLE]));
light_data[VL_LIGHT_SPOT_ATTENUATION][1]=l->vars[VS::LIGHT_PARAM_SPOT_ATTENUATION];
@@ -7008,6 +7012,10 @@ void RasterizerGLES2::_process_glow_bloom() {
void RasterizerGLES2::_process_hdr() {
if (framebuffer.luminance.empty()) {
return;
}
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.luminance[0].fbo);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, framebuffer.color );
@@ -10789,14 +10797,52 @@ void RasterizerGLES2::init() {
print_line(String("GLES2: Using GLEW ") + (const char*) glewGetString(GLEW_VERSION));
}
// Godot makes use of functions from ARB_framebuffer_object extension which is not implemented by all drivers.
// On the other hand, these drivers might implement the older EXT_framebuffer_object extension
// with which current source code is backward compatible.
bool framebuffer_object_is_supported = glewIsSupported("GL_ARB_framebuffer_object");
if ( !framebuffer_object_is_supported ) {
WARN_PRINT("GL_ARB_framebuffer_object not supported by your graphics card.");
if ( glewIsSupported("GL_EXT_framebuffer_object") ) {
// falling-back to the older EXT function if present
WARN_PRINT("Falling-back to GL_EXT_framebuffer_object.");
glIsRenderbuffer = glIsRenderbufferEXT;
glBindRenderbuffer = glBindRenderbufferEXT;
glDeleteRenderbuffers = glDeleteRenderbuffersEXT;
glGenRenderbuffers = glGenRenderbuffersEXT;
glRenderbufferStorage = glRenderbufferStorageEXT;
glGetRenderbufferParameteriv = glGetRenderbufferParameterivEXT;
glIsFramebuffer = glIsFramebufferEXT;
glBindFramebuffer = glBindFramebufferEXT;
glDeleteFramebuffers = glDeleteFramebuffersEXT;
glGenFramebuffers = glGenFramebuffersEXT;
glCheckFramebufferStatus = glCheckFramebufferStatusEXT;
glFramebufferTexture1D = glFramebufferTexture1DEXT;
glFramebufferTexture2D = glFramebufferTexture2DEXT;
glFramebufferTexture3D = glFramebufferTexture3DEXT;
glFramebufferRenderbuffer = glFramebufferRenderbufferEXT;
glGetFramebufferAttachmentParameteriv = glGetFramebufferAttachmentParameterivEXT;
glGenerateMipmap = glGenerateMipmapEXT;
framebuffer_object_is_supported = true;
}
else {
ERR_PRINT("Framebuffer Object is not supported by your graphics card.");
}
}
// Check for GL 2.1 compatibility, if not bail out
if (!glewIsSupported("GL_VERSION_2_1")) {
if (!(glewIsSupported("GL_VERSION_2_1") && framebuffer_object_is_supported)) {
ERR_PRINT("Your system's graphic drivers seem not to support OpenGL 2.1 / GLES 2.0, sorry :(\n"
"Try a drivers update, buy a new GPU or try software rendering on Linux; Godot will now crash with a segmentation fault.");
"Try a drivers update, buy a new GPU or try software rendering on Linux; Godot is now going to terminate.");
OS::get_singleton()->alert("Your system's graphic drivers seem not to support OpenGL 2.1 / GLES 2.0, sorry :(\n"
"Godot Engine will self-destruct as soon as you acknowledge this error message.",
"Fatal error: Insufficient OpenGL / GLES drivers");
// TODO: If it's even possible, we should stop the execution without segfault and memory leaks :)
exit(1);
}
#endif

View File

@@ -904,6 +904,7 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() {
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_VEC"]="light_vec";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_HEIGHT"]="light_height";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_COLOR"]="light";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_SHADOW"]="light_shadow_color";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_UV"]="light_uv";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT"]="light_out";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["SHADOW"]="shadow_color";

View File

@@ -1,8 +1,12 @@
#!/usr/bin/env python
Import('env')
if env['BUILDERS'].has_key('GLSL120GLES'):
env.GLSL120GLES('material.glsl');
env.GLSL120GLES('canvas.glsl');
env.GLSL120GLES('canvas_shadow.glsl');
env.GLSL120GLES('blur.glsl');
env.GLSL120GLES('copy.glsl');
env.GLSL120GLES('material.glsl')
env.GLSL120GLES('canvas.glsl')
env.GLSL120GLES('canvas_shadow.glsl')
env.GLSL120GLES('blur.glsl')
env.GLSL120GLES('copy.glsl')
Export('env')

View File

@@ -244,7 +244,7 @@ FRAGMENT_SHADER_CODE
vec2 light_uv = light_uv_interp.xy;
vec4 light = texture2D(light_texture,light_uv) * light_color;
#if defined(USE_LIGHT_SHADOW_COLOR)
#if defined(USE_OUTPUT_SHADOW_COLOR)
vec4 shadow_color=vec4(0.0,0.0,0.0,0.0);
#endif
@@ -380,7 +380,7 @@ LIGHT_SHADER_CODE
#endif
#if defined(USE_LIGHT_SHADOW_COLOR)
#if defined(USE_OUTPUT_SHADOW_COLOR)
color=mix(shadow_color,color,shadow_attenuation);
#else
//color*=shadow_attenuation;

View File

@@ -976,6 +976,12 @@ FRAGMENT_SHADER_CODE
#ifdef LIGHT_USE_SHADOW
#ifdef LIGHT_TYPE_DIRECTIONAL
float shadow_fade_exponent=5.0; //hardcoded for now
float shadow_fade=pow(length(vertex_interp)/light_attenuation.g,shadow_fade_exponent);
// optimization - skip shadows outside visible range
if(shadow_fade<1.0){
#ifdef LIGHT_USE_PSSM
@@ -1101,6 +1107,12 @@ FRAGMENT_SHADER_CODE
shadow_attenuation=SAMPLE_SHADOW_TEX(shadow_coord.xy,shadow_coord.z);
#endif
shadow_attenuation=mix(shadow_attenuation,1.0,shadow_fade);
}else{
shadow_attenuation=1.0;
};
#endif
#ifdef LIGHT_TYPE_OMNI
@@ -1181,7 +1193,7 @@ FRAGMENT_SHADER_CODE
vec3 mdiffuse = diffuse.rgb;
vec3 light;
#if defined(USE_LIGHT_SHADOW_COLOR)
#if defined(USE_OUTPUT_SHADOW_COLOR)
vec3 shadow_color=vec3(0.0,0.0,0.0);
#endif
@@ -1205,7 +1217,7 @@ LIGHT_SHADER_CODE
#endif
diffuse.rgb = const_light_mult * ambient_light *diffuse.rgb + light * attenuation * shadow_attenuation;
#if defined(USE_LIGHT_SHADOW_COLOR)
#if defined(USE_OUTPUT_SHADOW_COLOR)
diffuse.rgb += light * shadow_color * attenuation * (1.0 - shadow_attenuation);
#endif

View File

@@ -1,11 +0,0 @@
Import('env')
jpg_sources = [
"jpegd/jpgd.cpp",
"jpegd/image_loader_jpegd.cpp"
]
env.drivers_sources+=jpg_sources
#env.add_source_files(env.drivers_sources, jpg_sources)

View File

@@ -1,21 +0,0 @@
Import('env')
mpc_sources = [
"mpc/huffman.c",
"mpc/mpc_bits_reader.c",
"mpc/mpc_decoder.c",
"mpc/mpc_demux.c",
"mpc/mpc_reader.c",
"mpc/requant.c",
"mpc/streaminfo.c",
"mpc/synth_filter.c",
]
env.drivers_sources+=mpc_sources
env.add_source_files(env.drivers_sources,"*.cpp")
#env.add_source_files(env.drivers_sources, mpc_sources)
Export('env')

View File

@@ -1,23 +0,0 @@
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

View File

@@ -1,136 +0,0 @@
nedalloc v1.05 15th June 2008:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
by Niall Douglas (http://www.nedprod.com/programs/portable/nedmalloc/)
Enclosed is nedalloc, an alternative malloc implementation for multiple
threads without lock contention based on dlmalloc v2.8.4. It is more
or less a newer implementation of ptmalloc2, the standard allocator in
Linux (which is based on dlmalloc v2.7.0) but also contains a per-thread
cache for maximum CPU scalability.
It is licensed under the Boost Software License which basically means
you can do anything you like with it. This does not apply to the malloc.c.h
file which remains copyright to others.
It has been tested on win32 (x86), win64 (x64), Linux (x64), FreeBSD (x64)
and Apple MacOS X (x86). It works very well on all of these and is very
significantly faster than the system allocator on all of these platforms.
By literally dropping in this allocator as a replacement for your system
allocator, you can see real world improvements of up to three times in normal
code!
To use:
-=-=-=-
Drop in nedmalloc.h, nedmalloc.c and malloc.c.h into your project.
Configure using the instructions in nedmalloc.h. Run and enjoy.
To test, compile test.c. It will run a comparison between your system
allocator and nedalloc and tell you how much faster nedalloc is. It also
serves as an example of usage.
Notes:
-=-=-=
If you want the very latest version of this allocator, get it from the
TnFOX SVN repository at svn://svn.berlios.de/viewcvs/tnfox/trunk/src/nedmalloc
Because of how nedalloc allocates an mspace per thread, it can cause
severe bloating of memory usage under certain allocation patterns.
You can substantially reduce this wastage by setting MAXTHREADSINPOOL
or the threads parameter to nedcreatepool() to a fraction of the number of
threads which would normally be in a pool at once. This will reduce
bloating at the cost of an increase in lock contention. If allocated size
is less than THREADCACHEMAX, locking is avoided 90-99% of the time and
if most of your allocations are below this value, you can safely set
MAXTHREADSINPOOL to one.
You will suffer memory leakage unless you call neddisablethreadcache()
per pool for every thread which exits. This is because nedalloc cannot
portably know when a thread exits and thus when its thread cache can
be returned for use by other code. Don't forget pool zero, the system pool.
For C++ type allocation patterns (where the same sizes of memory are
regularly allocated and deallocated as objects are created and destroyed),
the threadcache always benefits performance. If however your allocation
patterns are different, searching the threadcache may significantly slow
down your code - as a rule of thumb, if cache utilisation is below 80%
(see the source for neddisablethreadcache() for how to enable debug
printing in release mode) then you should disable the thread cache for
that thread. You can compile out the threadcache code by setting
THREADCACHEMAX to zero.
Speed comparisons:
-=-=-=-=-=-=-=-=-=
See Benchmarks.xls for details.
The enclosed test.c can do two things: it can be a torture test or a speed
test. The speed test is designed to be a representative synthetic
memory allocator test. It works by randomly mixing allocations with frees
with half of the allocation sizes being a two power multiple less than
512 bytes (to mimic C++ stack instantiated objects) and the other half
being a simple random value less than 16Kb.
The real world code results are from Tn's TestIO benchmark. This is a
heavily multithreaded and memory intensive benchmark with a lot of branching
and other stuff modern processors don't like so much. As you'll note, the
test doesn't show the benefits of the threadcache mostly due to the saturation
of the memory bus being the limiting factor.
ChangeLog:
-=-=-=-=-=
v1.05 15th June 2008:
* { 1042 } Added error check for TLSSET() and TLSFREE() macros. Thanks to
Markus Elfring for reporting this.
* { 1043 } Fixed a segfault when freeing memory allocated using
nedindependent_comalloc(). Thanks to Pavel Vozenilek for reporting this.
v1.04 14th July 2007:
* Fixed a bug with the new optimised implementation that failed to lock
on a realloc under certain conditions.
* Fixed lack of thread synchronisation in InitPool() causing pool corruption
* Fixed a memory leak of thread cache contents on disabling. Thanks to Earl
Chew for reporting this.
* Added a sanity check for freed blocks being valid.
* Reworked test.c into being a torture test.
* Fixed GCC assembler optimisation misspecification
v1.04alpha_svn915 7th October 2006:
* Fixed failure to unlock thread cache list if allocating a new list failed.
Thanks to Dmitry Chichkov for reporting this. Futher thanks to Aleksey Sanin.
* Fixed realloc(0, <size>) segfaulting. Thanks to Dmitry Chichkov for
reporting this.
* Made config defines #ifndef so they can be overriden by the build system.
Thanks to Aleksey Sanin for suggesting this.
* Fixed deadlock in nedprealloc() due to unnecessary locking of preferred
thread mspace when mspace_realloc() always uses the original block's mspace
anyway. Thanks to Aleksey Sanin for reporting this.
* Made some speed improvements by hacking mspace_malloc() to no longer lock
its mspace, thus allowing the recursive mutex implementation to be removed
with an associated speed increase. Thanks to Aleksey Sanin for suggesting this.
* Fixed a bug where allocating mspaces overran its max limit. Thanks to
Aleksey Sanin for reporting this.
v1.03 10th July 2006:
* Fixed memory corruption bug in threadcache code which only appeared with >4
threads and in heavy use of the threadcache.
v1.02 15th May 2006:
* Integrated dlmalloc v2.8.4, fixing the win32 memory release problem and
improving performance still further. Speed is now up to twice the speed of v1.01
(average is 67% faster).
* Fixed win32 critical section implementation. Thanks to Pavel Kuznetsov
for reporting this.
* Wasn't locking mspace if all mspaces were locked. Thanks to Pavel Kuznetsov
for reporting this.
* Added Apple Mac OS X support.
v1.01 24th February 2006:
* Fixed multiprocessor scaling problems by removing sources of cache sloshing
* Earl Chew <earl_chew <at> agilent <dot> com> sent patches for the following:
1. size2binidx() wasn't working for default code path (non x86)
2. Fixed failure to release mspace lock under certain circumstances which
caused a deadlock
v1.00 1st January 2006:
* First release

View File

@@ -1,4 +0,0 @@
Import('env')
Export('env');
env.add_source_files(env.drivers_sources,"*.cpp")

File diff suppressed because it is too large Load Diff

View File

@@ -1,163 +0,0 @@
/*************************************************************************/
/* memory_pool_static_nedmalloc.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifdef NEDMALLOC_ENABLED
//
// C++ Implementation: memory_static_malloc
//
// Description:
//
//
// Author: Juan Linietsky <red@lunatea>, (C) 2006
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "memory_pool_static_nedmalloc.h"
#include "error_macros.h"
#include "os/memory.h"
#include <stdlib.h>
#include <stdio.h>
#include "os/copymem.h"
#include "os/os.h"
#include "nedmalloc.h"
/**
* NOTE NOTE NOTE NOTE
* in debug mode, this appends the memory size before the allocated, returned pointer
* so BE CAREFUL!
*/
void* MemoryPoolStaticNedMalloc::alloc(size_t p_bytes,const char *p_description) {
ERR_FAIL_COND_V(p_bytes==0,0);
MutexLock lock(mutex);
void *mem=nedalloc::nedmalloc(p_bytes);
ERR_FAIL_COND_V(!mem,0); //out of memory, or unreasonable request
return mem;
}
void* MemoryPoolStaticNedMalloc::realloc(void *p_memory,size_t p_bytes) {
if (p_memory==NULL) {
return alloc( p_bytes );
}
if (p_bytes<=0) {
this->free(p_memory);
ERR_FAIL_COND_V( p_bytes < 0 , NULL );
return NULL;
}
MutexLock lock(mutex);
return nedalloc::nedrealloc( p_memory, p_bytes );
}
void MemoryPoolStaticNedMalloc::free(void *p_ptr) {
MutexLock lock(mutex);
ERR_FAIL_COND(p_ptr==0);
nedalloc::nedfree(p_ptr);
}
size_t MemoryPoolStaticNedMalloc::get_available_mem() const {
return 0xffffffff;
}
size_t MemoryPoolStaticNedMalloc::get_total_usage() {
return nedalloc::nedmalloc_footprint();
}
/* Most likely available only if memory debugger was compiled in */
int MemoryPoolStaticNedMalloc::get_alloc_count() {
return 0;
}
void * MemoryPoolStaticNedMalloc::get_alloc_ptr(int p_alloc_idx) {
return 0;
}
const char* MemoryPoolStaticNedMalloc::get_alloc_description(int p_alloc_idx) {
return "";
}
size_t MemoryPoolStaticNedMalloc::get_alloc_size(int p_alloc_idx) {
return 0;
}
void MemoryPoolStaticNedMalloc::debug_print_all_memory() {
nedalloc::nedmalloc_stats();
}
MemoryPoolStaticNedMalloc::MemoryPoolStaticNedMalloc() {
mutex=NULL;
#ifndef NO_THREADS
mutex=Mutex::create(); // at this point, this should work
#endif
}
MemoryPoolStaticNedMalloc::~MemoryPoolStaticNedMalloc() {
Mutex *old_mutex=mutex;
mutex=NULL;
if (old_mutex)
memdelete(old_mutex);
#ifdef DEBUG_ENABLED
if (OS::get_singleton()->is_stdout_verbose())
nedalloc::nedmalloc_stats();
#endif
}
#endif

Some files were not shown because too many files have changed in this diff Show More