Compare commits
419 Commits
3.2
...
2.1.2-stab
| Author | SHA1 | Date | |
|---|---|---|---|
| c508b5b2e1 | |||
| b65e553440 | |||
| 7c47769aa2 | |||
| 0669c9816e | |||
| 23789f49dd | |||
| 8e380677cb | |||
| e4bbc1067a | |||
| 5aac8eeb0f | |||
| b351d4cbc1 | |||
| 1f2293d5cc | |||
| 8322c1aa64 | |||
| 8fca6870c4 | |||
| 9f3c594f9e | |||
| b3d0596c4b | |||
| 6b5a852bd8 | |||
| 25a62a3e32 | |||
| b61d7e6261 | |||
| 9c8ecb45f8 | |||
| 8a5596322d | |||
| 93a83c81f0 | |||
| af7fd899f4 | |||
| d66740175e | |||
| 5672852351 | |||
| 349e62835b | |||
| ff490e42da | |||
| b1fc41a301 | |||
| 3cd976366e | |||
| 6e9584e0c5 | |||
| c24c2ca17b | |||
| d2240404e3 | |||
| 01b8beb023 | |||
| 4f35fdd1e3 | |||
| 0b6d4e92b5 | |||
| d8223ffa75 | |||
| b5bdc60f58 | |||
| ba50bb9cb1 | |||
| 2a60bf1cd9 | |||
| 1bb1b6986c | |||
| 4c9c43735a | |||
| 6940830627 | |||
| 27a801df99 | |||
| f520e7788e | |||
| 580031e6f5 | |||
| d5e4011bc3 | |||
| 1397019424 | |||
| eea6c43676 | |||
| 3a4c412153 | |||
| 9b0be3753b | |||
| 5698571235 | |||
| 0701e7c2d8 | |||
| 2fbae72d14 | |||
| dbeb1ca114 | |||
| 0aebdb346a | |||
| 71b35c527f | |||
| a282579f5c | |||
| f08aa02688 | |||
| a8bc2f64ad | |||
| 85585c7fc5 | |||
| c5bff5073e | |||
| f10a78e5c0 | |||
| 5354d7ddcc | |||
| ff3891f88e | |||
| 5bfd0bbe5e | |||
| fa816730c0 | |||
| 01f3399ed0 | |||
| 1e34e8d5e1 | |||
| f184455187 | |||
| c07fe5e8de | |||
| 5b27f05e7e | |||
| 2e74bdab35 | |||
| 916e79a5bf | |||
| f95694ee86 | |||
| 6227e8f343 | |||
| 608e3f3097 | |||
| ef009a8b91 | |||
| 1a41d3351a | |||
| 17399de0e1 | |||
| fe81402257 | |||
| b56c00cc56 | |||
| 13cdc2a6f5 | |||
| fd5e01d1cd | |||
| b328d2eb00 | |||
| fde651ebf8 | |||
| 39ce4a49fa | |||
| 6ad84850ab | |||
| c0743f898a | |||
| 8589a1b117 | |||
| 40de567297 | |||
| 1e646e2797 | |||
| 4a7d5f7b0e | |||
| a86dae5761 | |||
| 7a77fd1cd5 | |||
| ac9f0aea1a | |||
| 3bb1709fd7 | |||
| 00fdcf3cd0 | |||
| 7ef71b9013 | |||
| e8a6cbc897 | |||
| 47ae6c6507 | |||
| 5e79ac72b7 | |||
| a46a643f90 | |||
| c030e602e5 | |||
| 19b31297ec | |||
| 4635671de5 | |||
| 8f23be8752 | |||
| 490f51a202 | |||
| 1a7f14b206 | |||
| e1dfaaf786 | |||
| 3f6fe2f3f1 | |||
| 2fff8e8cde | |||
| 754e9aa60a | |||
| a2048efd72 | |||
| 70a6791150 | |||
| 6e0de0cce8 | |||
| 04def2161e | |||
| b3443fd848 | |||
| 5546929712 | |||
| d8b0070b8c | |||
| 904285f4b4 | |||
| 53fea7f196 | |||
| fd1022fd29 | |||
| 24a440a34f | |||
| 5ede1a1226 | |||
| 17422f1f86 | |||
| 49e22aa83f | |||
| 6d86a63648 | |||
| a3582fa3cb | |||
| 326978dcce | |||
| 76233a3022 | |||
| ed2c369785 | |||
| 220bcbf7c0 | |||
| 3e2247ca53 | |||
| bf3cf5505e | |||
| bcc887bbe5 | |||
| 9b32df9cab | |||
| 601f056b6f | |||
| 14b46c4263 | |||
| 8a813e2a1e | |||
| 679e9f413c | |||
| 19ce11b908 | |||
| 28944e95e7 | |||
| 2d6dabc68e | |||
| 9219ac7e44 | |||
| e3dc319f78 | |||
| 221346521c | |||
| f1c2d70f1a | |||
| 3e127ce3fd | |||
| 0413d85add | |||
| 7d09222b37 | |||
| dd8b87f58e | |||
| 36a4c54593 | |||
| 51fe9fc132 | |||
| 9e1e5daddf | |||
| bc8dabf3d2 | |||
| fada9d7a8e | |||
| 82b458f160 | |||
| 64f38490df | |||
| c282ac8ec7 | |||
| 210618c5e2 | |||
| 2b00fdc679 | |||
| d7ec768805 | |||
| 86c6aabf27 | |||
| e5f210693c | |||
| 7e3360ae01 | |||
| 67f65f6639 | |||
| dbca4ee3fe | |||
| cd828bd5fc | |||
| da4a870bc4 | |||
| ce54b6ea8b | |||
| 5ee9a9962f | |||
| f629b1fd3e | |||
| eaf803f71e | |||
| a7389217f8 | |||
| e259bf8bbb | |||
| 561c1f17a1 | |||
| 7c92b401f1 | |||
| d44e6ea268 | |||
| 1185da656f | |||
| c78aef5812 | |||
| 91af714d39 | |||
| 5033fc92f4 | |||
| 1038c1f856 | |||
| 8087be05c7 | |||
| a20da0c048 | |||
| d67bbd183e | |||
| 647b287a1e | |||
| 91df1ebff6 | |||
| 62d1e39113 | |||
| b492dd78bd | |||
| a27aee241c | |||
| e3be51f87c | |||
| 68b6b50d28 | |||
| 06c47e6f8a | |||
| e56961f58b | |||
| b0013f32bf | |||
| 58daf901f9 | |||
| 887b1de1db | |||
| caf42f77d2 | |||
| 9f9d1eed7b | |||
| 0af331d1c0 | |||
| 7a17d72e84 | |||
| 52bf8bd168 | |||
| f3b42e049d | |||
| a130520a7c | |||
| 85a7105345 | |||
| dcd4b80c13 | |||
| 5a49e45d21 | |||
| 7143401e25 | |||
| f4414e3e03 | |||
| aa1367595e | |||
| d96842b80e | |||
| 8bf3bc3449 | |||
| f1bd2f6f56 | |||
| e04ec9565b | |||
| 8263fca121 | |||
| 1022705707 | |||
| 4ff4177acc | |||
| c8a97c3678 | |||
| 82e8721715 | |||
| bfea3f1d9a | |||
| 4cd640f684 | |||
| 995dcb610c | |||
| 55414bc573 | |||
| 819ccdd340 | |||
| ea1e180e4a | |||
| 575e986bde | |||
| 846db09038 | |||
| fae2863a5e | |||
| 56b03e7208 | |||
| c9d7f77c6f | |||
| 14e45a55d4 | |||
| 7d25d20861 | |||
| e88a540b91 | |||
| 2287bac8f7 | |||
| 00b0f3dfde | |||
| 64b083b496 | |||
| 9b71cae50f | |||
| 8a8ace8fa0 | |||
| 2261c65f19 | |||
| a418304def | |||
| ea48675ffa | |||
| d5ee98bb2c | |||
| 728ac94313 | |||
| a8502ae6f6 | |||
| 04255541a0 | |||
| 17edff2f84 | |||
| b4edaa892d | |||
| 81bc271619 | |||
| 5f540a17cc | |||
| 4b6809a2b3 | |||
| 280728c0c7 | |||
| 35cdb1a49b | |||
| 3df8f79c9f | |||
| 99d82f3033 | |||
| f250c0cf50 | |||
| 55a5631986 | |||
| 8cb09bf9d0 | |||
| 58e2652f94 | |||
| 3f941faf4d | |||
| b3bf3c392a | |||
| c757787fed | |||
| 1ae1deabfa | |||
| 22680a30f1 | |||
| ce1138cb02 | |||
| a139c7afe6 | |||
| e51cd3d454 | |||
| a7d6894a9f | |||
| 6775cce469 | |||
| 9e20b39b3d | |||
| 0462bf01a2 | |||
| cf427eeb7a | |||
| cd03f8cce2 | |||
| d0ff75c91c | |||
| 82dfaf7af6 | |||
| c0ba08b8d5 | |||
| ba095b8dcc | |||
| 9593863a92 | |||
| 97ebfddaaf | |||
| 342b1408d5 | |||
| 359b5f3b25 | |||
| 5b942f056a | |||
| 44ba542de6 | |||
| f63b338e0f | |||
| 13108317ae | |||
| 12d4d65668 | |||
| 56dc7aa568 | |||
| f315d352ec | |||
| ef0bcc7e20 | |||
| b2a58da321 | |||
| de13e52b9b | |||
| 73e7ccabf5 | |||
| 721599c797 | |||
| ab231cd3fb | |||
| 268b3446c6 | |||
| d7925ca09d | |||
| d613952300 | |||
| a3c58999e2 | |||
| 4b2243f82e | |||
| 6fc894d652 | |||
| 5adb75c2e7 | |||
| a827734e03 | |||
| f4f5855168 | |||
| f4da1e9ed2 | |||
| a5fe7ffbcd | |||
| 02487a4be1 | |||
| 228ee4363e | |||
| 36b1521cdc | |||
| d1ad94acf0 | |||
| 63b5a80088 | |||
| 45a5769162 | |||
| b9399e93ad | |||
| 33223e7a8a | |||
| 12edde80f2 | |||
| c8299249e4 | |||
| 1d175be921 | |||
| 94e5c48004 | |||
| 4084ec4869 | |||
| d3b549f2a3 | |||
| 4ca83c635f | |||
| e788ffff65 | |||
| 6a0d47f34c | |||
| e6d49fb54c | |||
| eed5d878e8 | |||
| 521b5bd90f | |||
| 8dca3f3f42 | |||
| d2aa006ddb | |||
| ec32c33799 | |||
| 9b9870ed9f | |||
| a72945f4e3 | |||
| 3ff8dea5f9 | |||
| 2b43d0a028 | |||
| ee23649813 | |||
| 75f51aece9 | |||
| 5653ac41f9 | |||
| 6c22cab856 | |||
| 71dc733ad2 | |||
| 04ade4d639 | |||
| 20c3b35dd5 | |||
| 323dec7dd5 | |||
| 3b691907e9 | |||
| 85eca7bc93 | |||
| 2e6ce4b362 | |||
| a1df4f138c | |||
| 0aad82e921 | |||
| aae720e488 | |||
| 772a590261 | |||
| f90370886f | |||
| c44757c2b7 | |||
| ffe5ecd67d | |||
| e0ddef3164 | |||
| 7178399548 | |||
| c007d31e52 | |||
| 3f30a22cb0 | |||
| d6dc8f4644 | |||
| c4f79716d3 | |||
| 4a9461fded | |||
| 49dd7b38bc | |||
| bfcfb58efc | |||
| ed96689d8c | |||
| 125a9f0b06 | |||
| fd58f8dce8 | |||
| adcf45b627 | |||
| 48d1e8bd4e | |||
| 73b40d1457 | |||
| e7772e43d3 | |||
| de5f49aac5 | |||
| 2ab7e6daab | |||
| 68c7da5a35 | |||
| a3a065b458 | |||
| 9ea76ff46d | |||
| cd6afd5f1d | |||
| 265715f5b2 | |||
| cd8beea3bf | |||
| 0657d43960 | |||
| a21b9caa2a | |||
| 83864514f9 | |||
| b1ea299edf | |||
| 103b04e529 | |||
| 07caf4438d | |||
| 6df46803a7 | |||
| cccc35e427 | |||
| fa1f5e55de | |||
| 6a563949c7 | |||
| f9aeb91850 | |||
| 71a9efe604 | |||
| 5f9e6d2b48 | |||
| 6327fc47c8 | |||
| 3cbd6b8701 | |||
| 4890db7fef | |||
| df3d2b25d8 | |||
| 743c63670e | |||
| e26acc39da | |||
| 1a53c4d3c2 | |||
| 37fc61f986 | |||
| 16fc229e5d | |||
| 4f07998552 | |||
| 3b7ab73cab | |||
| bbb543735c | |||
| ed931d3b59 | |||
| 720305d98e | |||
| 676b60a8b5 | |||
| 0c76ba32cc | |||
| c5e2c83dcd | |||
| 9cc700a0ab | |||
| 569966f3bb | |||
| 58556f5f95 | |||
| 229b172977 | |||
| c56ea7cf91 | |||
| 1913e4a040 | |||
| 2b35ba4815 | |||
| d853eb2fb7 | |||
| 36eeedb357 | |||
| 5f18c5cb46 | |||
| f25e9a08e1 | |||
| 4f8f9a4dbf | |||
| dd97502788 | |||
| d55304c56f | |||
| 03a4b8cbc8 | |||
| 2f0df52fe7 | |||
| fd6f62fd9a |
@ -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
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
************************************************************************
|
||||
|
||||
Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur.
|
||||
Copyright (c) 2007-2017 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
|
||||
|
||||
66
README.md
66
README.md
@ -1,30 +1,66 @@
|
||||

|
||||
[](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.
|
||||
|
||||
[](https://travis-ci.org/godotengine/godot)
|
||||
[](http://www.codetriage.com/godotengine/godot)
|
||||
|
||||
630
SConstruct
630
SConstruct
@ -1,4 +1,7 @@
|
||||
EnsureSConsVersion(0,14);
|
||||
|
||||
#!/usr/bin/env python
|
||||
|
||||
EnsureSConsVersion(0, 14)
|
||||
|
||||
|
||||
import string
|
||||
@ -12,84 +15,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 +101,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 +196,222 @@ 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")
|
||||
|
||||
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>")
|
||||
|
||||
@ -1,12 +0,0 @@
|
||||
Import('env')
|
||||
|
||||
env.tests_sources=[]
|
||||
env.add_source_files(env.tests_sources,"*.cpp")
|
||||
|
||||
Export('env')
|
||||
|
||||
#SConscript('math/SCsub');
|
||||
|
||||
lib = env.Library("tests",env.tests_sources)
|
||||
|
||||
env.Prepend(LIBS=[lib])
|
||||
72
core/SCsub
72
core/SCsub
@ -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])
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
@ -150,6 +150,16 @@ void Array::erase(const Variant& p_value) {
|
||||
_p->array.erase(p_value);
|
||||
}
|
||||
|
||||
Variant Array::front() const {
|
||||
ERR_FAIL_COND_V(_p->array.size() == 0, Variant());
|
||||
return operator[](0);
|
||||
}
|
||||
|
||||
Variant Array::back() const {
|
||||
ERR_FAIL_COND_V(_p->array.size() == 0, Variant());
|
||||
return operator[](_p->array.size() - 1);
|
||||
}
|
||||
|
||||
int Array::find(const Variant& p_value, int p_from) const {
|
||||
|
||||
return _p->array.find(p_value, p_from);
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
@ -67,6 +67,9 @@ public:
|
||||
void insert(int p_pos, const Variant& p_value);
|
||||
void remove(int p_pos);
|
||||
|
||||
Variant front() const;
|
||||
Variant back() const;
|
||||
|
||||
void sort();
|
||||
void sort_custom(Object *p_obj,const StringName& p_function);
|
||||
void invert();
|
||||
|
||||
@ -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')
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
@ -553,6 +553,16 @@ void _OS::set_icon(const Image& p_icon) {
|
||||
OS::get_singleton()->set_icon(p_icon);
|
||||
}
|
||||
|
||||
int _OS::get_exit_code() const {
|
||||
|
||||
return OS::get_singleton()->get_exit_code();
|
||||
}
|
||||
|
||||
void _OS::set_exit_code(int p_code) {
|
||||
|
||||
OS::get_singleton()->set_exit_code(p_code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current datetime with consideration for utc and
|
||||
* dst
|
||||
@ -1112,6 +1122,9 @@ void _OS::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_icon","icon"),&_OS::set_icon);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("get_exit_code"),&_OS::get_exit_code);
|
||||
ObjectTypeDB::bind_method(_MD("set_exit_code","code"),&_OS::set_exit_code);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("delay_usec","usec"),&_OS::delay_usec);
|
||||
ObjectTypeDB::bind_method(_MD("delay_msec","msec"),&_OS::delay_msec);
|
||||
ObjectTypeDB::bind_method(_MD("get_ticks_msec"),&_OS::get_ticks_msec);
|
||||
@ -1172,7 +1185,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 +1949,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);
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
@ -246,6 +246,9 @@ public:
|
||||
void set_use_file_access_save_and_swap(bool p_enable);
|
||||
|
||||
void set_icon(const Image& p_icon);
|
||||
|
||||
int get_exit_code() const;
|
||||
void set_exit_code(int p_code);
|
||||
Dictionary get_date(bool utc) const;
|
||||
Dictionary get_time(bool utc) const;
|
||||
Dictionary get_datetime(bool utc) const;
|
||||
@ -318,7 +321,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;
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
@ -29,6 +29,8 @@
|
||||
#include "color.h"
|
||||
#include "math_funcs.h"
|
||||
#include "print_string.h"
|
||||
#include "map.h"
|
||||
#include "color_names.inc"
|
||||
|
||||
uint32_t Color::to_ARGB32() const {
|
||||
|
||||
@ -327,7 +329,25 @@ bool Color::html_is_valid(const String& p_color) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
Color Color::named(const String &p_name) {
|
||||
if (_named_colors.empty()) _populate_named_colors(); // from color_names.inc
|
||||
String name = p_name;
|
||||
// Normalize name
|
||||
name = name.replace(" ", "");
|
||||
name = name.replace("-", "");
|
||||
name = name.replace("_", "");
|
||||
name = name.replace("'", "");
|
||||
name = name.replace(".", "");
|
||||
name = name.to_lower();
|
||||
|
||||
const Map<String, Color>::Element* color = _named_colors.find(name);
|
||||
if(color) {
|
||||
return color->value();
|
||||
} else {
|
||||
ERR_EXPLAIN("Invalid Color Name: "+p_name);
|
||||
ERR_FAIL_V(Color());
|
||||
}
|
||||
}
|
||||
|
||||
String _to_hex(float p_val) {
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
@ -111,6 +111,7 @@ struct Color {
|
||||
static Color hex(uint32_t p_hex);
|
||||
static Color html(const String& p_color);
|
||||
static bool html_is_valid(const String& p_color);
|
||||
static Color named(const String& p_name);
|
||||
String to_html(bool p_alpha=true) const;
|
||||
|
||||
_FORCE_INLINE_ bool operator<(const Color& p_color) const; //used in set keys
|
||||
|
||||
150
core/color_names.inc
Normal file
150
core/color_names.inc
Normal file
@ -0,0 +1,150 @@
|
||||
// Names from https://en.wikipedia.org/wiki/List_of_colors (through https://raw.githubusercontent.com/SuperUserNameMan/color_to_name/616a7cddafefda91478b7bc26167de97fb5badb1/godot_version.gd), slightly edited and normalized
|
||||
static Map<String, Color> _named_colors;
|
||||
static void _populate_named_colors() {
|
||||
if(!_named_colors.empty()) return;
|
||||
_named_colors.insert("aliceblue", Color(0.94, 0.97, 1.00));
|
||||
_named_colors.insert("antiquewhite", Color(0.98, 0.92, 0.84));
|
||||
_named_colors.insert("aqua", Color(0.00, 1.00, 1.00));
|
||||
_named_colors.insert("aquamarine", Color(0.50, 1.00, 0.83));
|
||||
_named_colors.insert("azure", Color(0.94, 1.00, 1.00));
|
||||
_named_colors.insert("beige", Color(0.96, 0.96, 0.86));
|
||||
_named_colors.insert("bisque", Color(1.00, 0.89, 0.77));
|
||||
_named_colors.insert("black", Color(0.00, 0.00, 0.00));
|
||||
_named_colors.insert("blanchedalmond", Color(1.00, 0.92, 0.80));
|
||||
_named_colors.insert("blue", Color(0.00, 0.00, 1.00));
|
||||
_named_colors.insert("blueviolet", Color(0.54, 0.17, 0.89));
|
||||
_named_colors.insert("brown", Color(0.65, 0.16, 0.16));
|
||||
_named_colors.insert("burlywood", Color(0.87, 0.72, 0.53));
|
||||
_named_colors.insert("cadetblue", Color(0.37, 0.62, 0.63));
|
||||
_named_colors.insert("chartreuse", Color(0.50, 1.00, 0.00));
|
||||
_named_colors.insert("chocolate", Color(0.82, 0.41, 0.12));
|
||||
_named_colors.insert("coral", Color(1.00, 0.50, 0.31));
|
||||
_named_colors.insert("cornflower", Color(0.39, 0.58, 0.93));
|
||||
_named_colors.insert("cornsilk", Color(1.00, 0.97, 0.86));
|
||||
_named_colors.insert("crimson", Color(0.86, 0.08, 0.24));
|
||||
_named_colors.insert("cyan", Color(0.00, 1.00, 1.00));
|
||||
_named_colors.insert("darkblue", Color(0.00, 0.00, 0.55));
|
||||
_named_colors.insert("darkcyan", Color(0.00, 0.55, 0.55));
|
||||
_named_colors.insert("darkgoldenrod", Color(0.72, 0.53, 0.04));
|
||||
_named_colors.insert("darkgray", Color(0.66, 0.66, 0.66));
|
||||
_named_colors.insert("darkgreen", Color(0.00, 0.39, 0.00));
|
||||
_named_colors.insert("darkkhaki", Color(0.74, 0.72, 0.42));
|
||||
_named_colors.insert("darkmagenta", Color(0.55, 0.00, 0.55));
|
||||
_named_colors.insert("darkolivegreen", Color(0.33, 0.42, 0.18));
|
||||
_named_colors.insert("darkorange", Color(1.00, 0.55, 0.00));
|
||||
_named_colors.insert("darkorchid", Color(0.60, 0.20, 0.80));
|
||||
_named_colors.insert("darkred", Color(0.55, 0.00, 0.00));
|
||||
_named_colors.insert("darksalmon", Color(0.91, 0.59, 0.48));
|
||||
_named_colors.insert("darkseagreen", Color(0.56, 0.74, 0.56));
|
||||
_named_colors.insert("darkslateblue", Color(0.28, 0.24, 0.55));
|
||||
_named_colors.insert("darkslategray", Color(0.18, 0.31, 0.31));
|
||||
_named_colors.insert("darkturquoise", Color(0.00, 0.81, 0.82));
|
||||
_named_colors.insert("darkviolet", Color(0.58, 0.00, 0.83));
|
||||
_named_colors.insert("deeppink", Color(1.00, 0.08, 0.58));
|
||||
_named_colors.insert("deepskyblue", Color(0.00, 0.75, 1.00));
|
||||
_named_colors.insert("dimgray", Color(0.41, 0.41, 0.41));
|
||||
_named_colors.insert("dodgerblue", Color(0.12, 0.56, 1.00));
|
||||
_named_colors.insert("firebrick", Color(0.70, 0.13, 0.13));
|
||||
_named_colors.insert("floralwhite", Color(1.00, 0.98, 0.94));
|
||||
_named_colors.insert("forestgreen", Color(0.13, 0.55, 0.13));
|
||||
_named_colors.insert("fuchsia", Color(1.00, 0.00, 1.00));
|
||||
_named_colors.insert("gainsboro", Color(0.86, 0.86, 0.86));
|
||||
_named_colors.insert("ghostwhite", Color(0.97, 0.97, 1.00));
|
||||
_named_colors.insert("gold", Color(1.00, 0.84, 0.00));
|
||||
_named_colors.insert("goldenrod", Color(0.85, 0.65, 0.13));
|
||||
_named_colors.insert("gray", Color(0.75, 0.75, 0.75));
|
||||
_named_colors.insert("webgray", Color(0.50, 0.50, 0.50));
|
||||
_named_colors.insert("green", Color(0.00, 1.00, 0.00));
|
||||
_named_colors.insert("webgreen", Color(0.00, 0.50, 0.00));
|
||||
_named_colors.insert("greenyellow", Color(0.68, 1.00, 0.18));
|
||||
_named_colors.insert("honeydew", Color(0.94, 1.00, 0.94));
|
||||
_named_colors.insert("hotpink", Color(1.00, 0.41, 0.71));
|
||||
_named_colors.insert("indianred", Color(0.80, 0.36, 0.36));
|
||||
_named_colors.insert("indigo", Color(0.29, 0.00, 0.51));
|
||||
_named_colors.insert("ivory", Color(1.00, 1.00, 0.94));
|
||||
_named_colors.insert("khaki", Color(0.94, 0.90, 0.55));
|
||||
_named_colors.insert("lavender", Color(0.90, 0.90, 0.98));
|
||||
_named_colors.insert("lavenderblush", Color(1.00, 0.94, 0.96));
|
||||
_named_colors.insert("lawngreen", Color(0.49, 0.99, 0.00));
|
||||
_named_colors.insert("lemonchiffon", Color(1.00, 0.98, 0.80));
|
||||
_named_colors.insert("lightblue", Color(0.68, 0.85, 0.90));
|
||||
_named_colors.insert("lightcoral", Color(0.94, 0.50, 0.50));
|
||||
_named_colors.insert("lightcyan", Color(0.88, 1.00, 1.00));
|
||||
_named_colors.insert("lightgoldenrod", Color(0.98, 0.98, 0.82));
|
||||
_named_colors.insert("lightgray", Color(0.83, 0.83, 0.83));
|
||||
_named_colors.insert("lightgreen", Color(0.56, 0.93, 0.56));
|
||||
_named_colors.insert("lightpink", Color(1.00, 0.71, 0.76));
|
||||
_named_colors.insert("lightsalmon", Color(1.00, 0.63, 0.48));
|
||||
_named_colors.insert("lightseagreen", Color(0.13, 0.70, 0.67));
|
||||
_named_colors.insert("lightskyblue", Color(0.53, 0.81, 0.98));
|
||||
_named_colors.insert("lightslategray", Color(0.47, 0.53, 0.60));
|
||||
_named_colors.insert("lightsteelblue", Color(0.69, 0.77, 0.87));
|
||||
_named_colors.insert("lightyellow", Color(1.00, 1.00, 0.88));
|
||||
_named_colors.insert("lime", Color(0.00, 1.00, 0.00));
|
||||
_named_colors.insert("limegreen", Color(0.20, 0.80, 0.20));
|
||||
_named_colors.insert("linen", Color(0.98, 0.94, 0.90));
|
||||
_named_colors.insert("magenta", Color(1.00, 0.00, 1.00));
|
||||
_named_colors.insert("maroon", Color(0.69, 0.19, 0.38));
|
||||
_named_colors.insert("webmaroon", Color(0.50, 0.00, 0.00));
|
||||
_named_colors.insert("mediumaquamarine", Color(0.40, 0.80, 0.67));
|
||||
_named_colors.insert("mediumblue", Color(0.00, 0.00, 0.80));
|
||||
_named_colors.insert("mediumorchid", Color(0.73, 0.33, 0.83));
|
||||
_named_colors.insert("mediumpurple", Color(0.58, 0.44, 0.86));
|
||||
_named_colors.insert("mediumseagreen", Color(0.24, 0.70, 0.44));
|
||||
_named_colors.insert("mediumslateblue", Color(0.48, 0.41, 0.93));
|
||||
_named_colors.insert("mediumspringgreen", Color(0.00, 0.98, 0.60));
|
||||
_named_colors.insert("mediumturquoise", Color(0.28, 0.82, 0.80));
|
||||
_named_colors.insert("mediumvioletred", Color(0.78, 0.08, 0.52));
|
||||
_named_colors.insert("midnightblue", Color(0.10, 0.10, 0.44));
|
||||
_named_colors.insert("mintcream", Color(0.96, 1.00, 0.98));
|
||||
_named_colors.insert("mistyrose", Color(1.00, 0.89, 0.88));
|
||||
_named_colors.insert("moccasin", Color(1.00, 0.89, 0.71));
|
||||
_named_colors.insert("navajowhite", Color(1.00, 0.87, 0.68));
|
||||
_named_colors.insert("navyblue", Color(0.00, 0.00, 0.50));
|
||||
_named_colors.insert("oldlace", Color(0.99, 0.96, 0.90));
|
||||
_named_colors.insert("olive", Color(0.50, 0.50, 0.00));
|
||||
_named_colors.insert("olivedrab", Color(0.42, 0.56, 0.14));
|
||||
_named_colors.insert("orange", Color(1.00, 0.65, 0.00));
|
||||
_named_colors.insert("orangered", Color(1.00, 0.27, 0.00));
|
||||
_named_colors.insert("orchid", Color(0.85, 0.44, 0.84));
|
||||
_named_colors.insert("palegoldenrod", Color(0.93, 0.91, 0.67));
|
||||
_named_colors.insert("palegreen", Color(0.60, 0.98, 0.60));
|
||||
_named_colors.insert("paleturquoise", Color(0.69, 0.93, 0.93));
|
||||
_named_colors.insert("palevioletred", Color(0.86, 0.44, 0.58));
|
||||
_named_colors.insert("papayawhip", Color(1.00, 0.94, 0.84));
|
||||
_named_colors.insert("peachpuff", Color(1.00, 0.85, 0.73));
|
||||
_named_colors.insert("peru", Color(0.80, 0.52, 0.25));
|
||||
_named_colors.insert("pink", Color(1.00, 0.75, 0.80));
|
||||
_named_colors.insert("plum", Color(0.87, 0.63, 0.87));
|
||||
_named_colors.insert("powderblue", Color(0.69, 0.88, 0.90));
|
||||
_named_colors.insert("purple", Color(0.63, 0.13, 0.94));
|
||||
_named_colors.insert("webpurple", Color(0.50, 0.00, 0.50));
|
||||
_named_colors.insert("rebeccapurple", Color(0.40, 0.20, 0.60));
|
||||
_named_colors.insert("red", Color(1.00, 0.00, 0.00));
|
||||
_named_colors.insert("rosybrown", Color(0.74, 0.56, 0.56));
|
||||
_named_colors.insert("royalblue", Color(0.25, 0.41, 0.88));
|
||||
_named_colors.insert("saddlebrown", Color(0.55, 0.27, 0.07));
|
||||
_named_colors.insert("salmon", Color(0.98, 0.50, 0.45));
|
||||
_named_colors.insert("sandybrown", Color(0.96, 0.64, 0.38));
|
||||
_named_colors.insert("seagreen", Color(0.18, 0.55, 0.34));
|
||||
_named_colors.insert("seashell", Color(1.00, 0.96, 0.93));
|
||||
_named_colors.insert("sienna", Color(0.63, 0.32, 0.18));
|
||||
_named_colors.insert("silver", Color(0.75, 0.75, 0.75));
|
||||
_named_colors.insert("skyblue", Color(0.53, 0.81, 0.92));
|
||||
_named_colors.insert("slateblue", Color(0.42, 0.35, 0.80));
|
||||
_named_colors.insert("slategray", Color(0.44, 0.50, 0.56));
|
||||
_named_colors.insert("snow", Color(1.00, 0.98, 0.98));
|
||||
_named_colors.insert("springgreen", Color(0.00, 1.00, 0.50));
|
||||
_named_colors.insert("steelblue", Color(0.27, 0.51, 0.71));
|
||||
_named_colors.insert("tan", Color(0.82, 0.71, 0.55));
|
||||
_named_colors.insert("teal", Color(0.00, 0.50, 0.50));
|
||||
_named_colors.insert("thistle", Color(0.85, 0.75, 0.85));
|
||||
_named_colors.insert("tomato", Color(1.00, 0.39, 0.28));
|
||||
_named_colors.insert("turquoise", Color(0.25, 0.88, 0.82));
|
||||
_named_colors.insert("violet", Color(0.93, 0.51, 0.93));
|
||||
_named_colors.insert("wheat", Color(0.96, 0.87, 0.70));
|
||||
_named_colors.insert("white", Color(1.00, 1.00, 1.00));
|
||||
_named_colors.insert("whitesmoke", Color(0.96, 0.96, 0.96));
|
||||
_named_colors.insert("yellow", Color(1.00, 1.00, 0.00));
|
||||
_named_colors.insert("yellowgreen", Color(0.60, 0.80, 0.20));
|
||||
}
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
@ -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
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
@ -54,7 +54,8 @@ 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() && !p_path.begins_with(resource_path)))
|
||||
return p_path.simplify_path();
|
||||
|
||||
|
||||
@ -1375,6 +1376,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 +1419,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);
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
@ -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();
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
@ -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();;
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
@ -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();
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -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')
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
@ -29,10 +29,14 @@
|
||||
#include "http_client.h"
|
||||
#include "io/stream_peer_ssl.h"
|
||||
|
||||
void HTTPClient::set_ip_type(IP::Type p_type) {
|
||||
ip_type = p_type;
|
||||
}
|
||||
|
||||
Error HTTPClient::connect(const String &p_host, int p_port, bool p_ssl,bool p_verify_host){
|
||||
|
||||
close();
|
||||
tcp_connection->set_ip_type(ip_type);
|
||||
conn_port=p_port;
|
||||
conn_host=p_host;
|
||||
|
||||
@ -62,7 +66,7 @@ Error HTTPClient::connect(const String &p_host, int p_port, bool p_ssl,bool p_ve
|
||||
status=STATUS_CONNECTING;
|
||||
} else {
|
||||
//is hostname
|
||||
resolving=IP::get_singleton()->resolve_hostname_queue_item(conn_host);
|
||||
resolving=IP::get_singleton()->resolve_hostname_queue_item(conn_host, ip_type);
|
||||
status=STATUS_RESOLVING;
|
||||
|
||||
}
|
||||
@ -635,6 +639,7 @@ Error HTTPClient::_get_http_data(uint8_t* p_buffer, int p_bytes,int &r_received)
|
||||
|
||||
void HTTPClient::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_ip_type","ip_type"),&HTTPClient::set_ip_type);
|
||||
ObjectTypeDB::bind_method(_MD("connect:Error","host","port","use_ssl","verify_host"),&HTTPClient::connect,DEFVAL(false),DEFVAL(true));
|
||||
ObjectTypeDB::bind_method(_MD("set_connection","connection:StreamPeer"),&HTTPClient::set_connection);
|
||||
ObjectTypeDB::bind_method(_MD("get_connection:StreamPeer"),&HTTPClient::get_connection);
|
||||
@ -761,6 +766,7 @@ String HTTPClient::query_string_from_dict(const Dictionary& p_dict) {
|
||||
|
||||
HTTPClient::HTTPClient(){
|
||||
|
||||
ip_type = IP::TYPE_ANY;
|
||||
tcp_connection = StreamPeerTCP::create_ref();
|
||||
resolving = IP::RESOLVER_INVALID_ID;
|
||||
status=STATUS_DISCONNECTED;
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
@ -132,6 +132,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
IP::Type ip_type;
|
||||
Status status;
|
||||
IP::ResolverID resolving;
|
||||
int conn_port;
|
||||
@ -164,6 +165,7 @@ private:
|
||||
public:
|
||||
|
||||
|
||||
void set_ip_type(IP::Type p_type);
|
||||
//Error connect_and_get(const String& p_url,bool p_verify_host=true); //connects to a full url and perform request
|
||||
Error connect(const String &p_host,int p_port,bool p_ssl=false,bool p_verify_host=true);
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
@ -43,10 +43,12 @@ struct _IP_ResolverPrivate {
|
||||
volatile IP::ResolverStatus status;
|
||||
IP_Address response;
|
||||
String hostname;
|
||||
IP::Type type;
|
||||
|
||||
void clear() {
|
||||
status = IP::RESOLVER_STATUS_NONE;
|
||||
response = IP_Address();
|
||||
type = IP::TYPE_NONE;
|
||||
hostname="";
|
||||
};
|
||||
|
||||
@ -78,9 +80,9 @@ struct _IP_ResolverPrivate {
|
||||
|
||||
if (queue[i].status!=IP::RESOLVER_STATUS_WAITING)
|
||||
continue;
|
||||
queue[i].response=IP::get_singleton()->resolve_hostname(queue[i].hostname);
|
||||
queue[i].response=IP::get_singleton()->resolve_hostname(queue[i].hostname, queue[i].type);
|
||||
|
||||
if (queue[i].response.host==0)
|
||||
if (queue[i].response==IP_Address())
|
||||
queue[i].status=IP::RESOLVER_STATUS_ERROR;
|
||||
else
|
||||
queue[i].status=IP::RESOLVER_STATUS_DONE;
|
||||
@ -105,25 +107,30 @@ struct _IP_ResolverPrivate {
|
||||
|
||||
HashMap<String, IP_Address> cache;
|
||||
|
||||
static String get_cache_key(String p_hostname, IP::Type p_type) {
|
||||
return itos(p_type) + p_hostname;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
IP_Address IP::resolve_hostname(const String& p_hostname) {
|
||||
IP_Address IP::resolve_hostname(const String& p_hostname, IP::Type p_type) {
|
||||
|
||||
GLOBAL_LOCK_FUNCTION
|
||||
GLOBAL_LOCK_FUNCTION;
|
||||
|
||||
if (resolver->cache.has(p_hostname))
|
||||
return resolver->cache[p_hostname];
|
||||
String key = _IP_ResolverPrivate::get_cache_key(p_hostname, p_type);
|
||||
if (resolver->cache.has(key))
|
||||
return resolver->cache[key];
|
||||
|
||||
IP_Address res = _resolve_hostname(p_hostname);
|
||||
resolver->cache[p_hostname]=res;
|
||||
IP_Address res = _resolve_hostname(p_hostname, p_type);
|
||||
resolver->cache[key]=res;
|
||||
return res;
|
||||
|
||||
}
|
||||
IP::ResolverID IP::resolve_hostname_queue_item(const String& p_hostname) {
|
||||
IP::ResolverID IP::resolve_hostname_queue_item(const String& p_hostname, IP::Type p_type) {
|
||||
|
||||
GLOBAL_LOCK_FUNCTION
|
||||
GLOBAL_LOCK_FUNCTION;
|
||||
|
||||
ResolverID id = resolver->find_empty_id();
|
||||
|
||||
@ -132,9 +139,11 @@ IP::ResolverID IP::resolve_hostname_queue_item(const String& p_hostname) {
|
||||
return id;
|
||||
}
|
||||
|
||||
String key = _IP_ResolverPrivate::get_cache_key(p_hostname, p_type);
|
||||
resolver->queue[id].hostname=p_hostname;
|
||||
if (resolver->cache.has(p_hostname)) {
|
||||
resolver->queue[id].response=resolver->cache[p_hostname];
|
||||
resolver->queue[id].type = p_type;
|
||||
if (resolver->cache.has(key)) {
|
||||
resolver->queue[id].response=resolver->cache[key];
|
||||
resolver->queue[id].status=IP::RESOLVER_STATUS_DONE;
|
||||
} else {
|
||||
resolver->queue[id].response=IP_Address();
|
||||
@ -145,10 +154,6 @@ IP::ResolverID IP::resolve_hostname_queue_item(const String& p_hostname) {
|
||||
resolver->resolve_queues();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
@ -187,6 +192,17 @@ void IP::erase_resolve_item(ResolverID p_id) {
|
||||
|
||||
}
|
||||
|
||||
void IP::clear_cache(const String &p_hostname) {
|
||||
|
||||
if (p_hostname.empty()) {
|
||||
resolver->cache.clear();
|
||||
} else {
|
||||
resolver->cache.erase(_IP_ResolverPrivate::get_cache_key(p_hostname, IP::TYPE_NONE));
|
||||
resolver->cache.erase(_IP_ResolverPrivate::get_cache_key(p_hostname, IP::TYPE_IPV4));
|
||||
resolver->cache.erase(_IP_ResolverPrivate::get_cache_key(p_hostname, IP::TYPE_IPV6));
|
||||
resolver->cache.erase(_IP_ResolverPrivate::get_cache_key(p_hostname, IP::TYPE_ANY));
|
||||
}
|
||||
};
|
||||
|
||||
Array IP::_get_local_addresses() const {
|
||||
|
||||
@ -202,12 +218,13 @@ Array IP::_get_local_addresses() const {
|
||||
|
||||
void IP::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("resolve_hostname","host"),&IP::resolve_hostname);
|
||||
ObjectTypeDB::bind_method(_MD("resolve_hostname_queue_item","host"),&IP::resolve_hostname_queue_item);
|
||||
ObjectTypeDB::bind_method(_MD("resolve_hostname","host","ip_type"),&IP::resolve_hostname,DEFVAL(IP::TYPE_ANY));
|
||||
ObjectTypeDB::bind_method(_MD("resolve_hostname_queue_item","host","ip_type"),&IP::resolve_hostname_queue_item,DEFVAL(IP::TYPE_ANY));
|
||||
ObjectTypeDB::bind_method(_MD("get_resolve_item_status","id"),&IP::get_resolve_item_status);
|
||||
ObjectTypeDB::bind_method(_MD("get_resolve_item_address","id"),&IP::get_resolve_item_address);
|
||||
ObjectTypeDB::bind_method(_MD("erase_resolve_item","id"),&IP::erase_resolve_item);
|
||||
ObjectTypeDB::bind_method(_MD("get_local_addresses"),&IP::_get_local_addresses);
|
||||
ObjectTypeDB::bind_method(_MD("clear_cache"),&IP::clear_cache, DEFVAL(""));
|
||||
|
||||
BIND_CONSTANT( RESOLVER_STATUS_NONE );
|
||||
BIND_CONSTANT( RESOLVER_STATUS_WAITING );
|
||||
@ -217,6 +234,10 @@ void IP::_bind_methods() {
|
||||
BIND_CONSTANT( RESOLVER_MAX_QUERIES );
|
||||
BIND_CONSTANT( RESOLVER_INVALID_ID );
|
||||
|
||||
BIND_CONSTANT( TYPE_NONE );
|
||||
BIND_CONSTANT( TYPE_IPV4 );
|
||||
BIND_CONSTANT( TYPE_IPV6 );
|
||||
BIND_CONSTANT( TYPE_ANY );
|
||||
}
|
||||
|
||||
|
||||
|
||||
20
core/io/ip.h
20
core/io/ip.h
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
@ -48,6 +48,14 @@ public:
|
||||
RESOLVER_STATUS_ERROR,
|
||||
};
|
||||
|
||||
enum Type {
|
||||
|
||||
TYPE_NONE = 0,
|
||||
TYPE_IPV4 = 1,
|
||||
TYPE_IPV6 = 2,
|
||||
TYPE_ANY = 3,
|
||||
};
|
||||
|
||||
enum {
|
||||
RESOLVER_MAX_QUERIES = 32,
|
||||
RESOLVER_INVALID_ID=-1
|
||||
@ -65,7 +73,7 @@ protected:
|
||||
static IP*singleton;
|
||||
static void _bind_methods();
|
||||
|
||||
virtual IP_Address _resolve_hostname(const String& p_hostname)=0;
|
||||
virtual IP_Address _resolve_hostname(const String& p_hostname, Type p_type = TYPE_ANY)=0;
|
||||
Array _get_local_addresses() const;
|
||||
|
||||
static IP* (*_create)();
|
||||
@ -73,14 +81,16 @@ public:
|
||||
|
||||
|
||||
|
||||
IP_Address resolve_hostname(const String& p_hostname);
|
||||
IP_Address resolve_hostname(const String& p_hostname, Type p_type = TYPE_ANY);
|
||||
// async resolver hostname
|
||||
ResolverID resolve_hostname_queue_item(const String& p_hostname);
|
||||
ResolverID resolve_hostname_queue_item(const String& p_hostname, Type p_type = TYPE_ANY);
|
||||
ResolverStatus get_resolve_item_status(ResolverID p_id) const;
|
||||
IP_Address get_resolve_item_address(ResolverID p_id) const;
|
||||
virtual void get_local_addresses(List<IP_Address> *r_addresses) const=0;
|
||||
void erase_resolve_item(ResolverID p_id);
|
||||
|
||||
void clear_cache(const String& p_hostname = "");
|
||||
|
||||
static IP* get_singleton();
|
||||
|
||||
static IP* create();
|
||||
@ -91,4 +101,6 @@ public:
|
||||
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(IP::Type);
|
||||
|
||||
#endif // IP_H
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
@ -32,29 +32,209 @@ IP_Address::operator Variant() const {
|
||||
|
||||
return operator String();
|
||||
}*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
IP_Address::operator String() const {
|
||||
|
||||
return itos(field[0])+"."+itos(field[1])+"."+itos(field[2])+"."+itos(field[3]);
|
||||
if(is_ipv4())
|
||||
// IPv4 address mapped to IPv6
|
||||
return itos(field8[12])+"."+itos(field8[13])+"."+itos(field8[14])+"."+itos(field8[15]);
|
||||
String ret;
|
||||
for (int i=0; i<8; i++) {
|
||||
if (i > 0)
|
||||
ret = ret + ":";
|
||||
uint16_t num = (field8[i*2] << 8) + field8[i*2+1];
|
||||
ret = ret + String::num_int64(num, 16);
|
||||
};
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void _parse_hex(const String& p_string, int p_start, uint8_t* p_dst) {
|
||||
|
||||
uint16_t ret = 0;
|
||||
for (int i=p_start; i<p_start + 4; i++) {
|
||||
|
||||
if (i >= p_string.length()) {
|
||||
break;
|
||||
};
|
||||
|
||||
int n = 0;
|
||||
CharType c = p_string[i];
|
||||
if (c >= '0' && c <= '9') {
|
||||
|
||||
n = c - '0';
|
||||
} else if (c >= 'a' && c <= 'f') {
|
||||
n = 10 + (c - 'a');
|
||||
} else if (c >= 'A' && c <= 'F') {
|
||||
n = 10 + (c - 'A');
|
||||
} else if (c == ':') {
|
||||
break;
|
||||
} else {
|
||||
ERR_EXPLAIN("Invalid character in ipv6 address: " + p_string);
|
||||
ERR_FAIL();
|
||||
};
|
||||
ret = ret << 4;
|
||||
ret += n;
|
||||
};
|
||||
|
||||
p_dst[0] = ret >> 8;
|
||||
p_dst[1] = ret & 0xff;
|
||||
};
|
||||
|
||||
void IP_Address::_parse_ipv6(const String& p_string) {
|
||||
|
||||
static const int parts_total = 8;
|
||||
int parts[parts_total] = {0};
|
||||
int parts_count = 0;
|
||||
bool part_found = false;
|
||||
bool part_skip = false;
|
||||
bool part_ipv4 = false;
|
||||
int parts_idx = 0;
|
||||
|
||||
for (int i=0; i<p_string.length(); i++) {
|
||||
|
||||
CharType c = p_string[i];
|
||||
if (c == ':') {
|
||||
|
||||
if (i == 0) {
|
||||
continue; // next must be a ":"
|
||||
};
|
||||
if (!part_found) {
|
||||
part_skip = true;
|
||||
parts[parts_idx++] = -1;
|
||||
};
|
||||
part_found = false;
|
||||
} else if (c == '.') {
|
||||
|
||||
part_ipv4 = true;
|
||||
|
||||
} else if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')) {
|
||||
if (!part_found) {
|
||||
parts[parts_idx++] = i;
|
||||
part_found = true;
|
||||
++parts_count;
|
||||
};
|
||||
} else {
|
||||
|
||||
ERR_EXPLAIN("Invalid character in IPv6 address: " + p_string);
|
||||
ERR_FAIL();
|
||||
};
|
||||
};
|
||||
|
||||
int parts_extra = 0;
|
||||
if (part_skip) {
|
||||
parts_extra = parts_total - parts_count;
|
||||
};
|
||||
|
||||
int idx = 0;
|
||||
for (int i=0; i<parts_idx; i++) {
|
||||
|
||||
if (parts[i] == -1) {
|
||||
|
||||
for (int j=0; j<parts_extra; j++) {
|
||||
field16[idx++] = 0;
|
||||
};
|
||||
continue;
|
||||
};
|
||||
|
||||
if (part_ipv4 && i == parts_idx - 1) {
|
||||
_parse_ipv4(p_string, parts[i], (uint8_t*)&field16[idx]); // should be the last one
|
||||
} else {
|
||||
_parse_hex(p_string, parts[i], (uint8_t*)&(field16[idx++]));
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
void IP_Address::_parse_ipv4(const String& p_string, int p_start, uint8_t* p_ret) {
|
||||
|
||||
String ip;
|
||||
if (p_start != 0) {
|
||||
ip = p_string.substr(p_start, p_string.length() - p_start);
|
||||
} else {
|
||||
ip = p_string;
|
||||
};
|
||||
|
||||
int slices = ip.get_slice_count(".");
|
||||
if (slices!=4) {
|
||||
ERR_EXPLAIN("Invalid IP Address String: "+ip);
|
||||
ERR_FAIL();
|
||||
}
|
||||
for(int i=0;i<4;i++) {
|
||||
p_ret[i]=ip.get_slicec('.',i).to_int();
|
||||
}
|
||||
};
|
||||
|
||||
void IP_Address::clear() {
|
||||
|
||||
memset(&field8[0], 0, sizeof(field8));
|
||||
};
|
||||
|
||||
bool IP_Address::is_ipv4() const{
|
||||
return (field32[0]==0 && field32[1]==0 && field16[4]==0 && field16[5]==0xffff);
|
||||
}
|
||||
|
||||
const uint8_t *IP_Address::get_ipv4() const{
|
||||
ERR_FAIL_COND_V(!is_ipv4(),0);
|
||||
return &(field8[12]);
|
||||
}
|
||||
|
||||
void IP_Address::set_ipv4(const uint8_t *p_ip) {
|
||||
clear();
|
||||
field16[5]=0xffff;
|
||||
field32[3]=*((const uint32_t *)p_ip);
|
||||
}
|
||||
|
||||
const uint8_t *IP_Address::get_ipv6() const{
|
||||
return field8;
|
||||
}
|
||||
|
||||
void IP_Address::set_ipv6(const uint8_t *p_buf) {
|
||||
clear();
|
||||
for (int i=0; i<16; i++)
|
||||
field8[i] = p_buf[i];
|
||||
}
|
||||
|
||||
IP_Address::IP_Address(const String& p_string) {
|
||||
|
||||
host=0;
|
||||
int slices = p_string.get_slice_count(".");
|
||||
if (slices!=4) {
|
||||
ERR_EXPLAIN("Invalid IP Address String: "+p_string);
|
||||
ERR_FAIL();
|
||||
}
|
||||
for(int i=0;i<4;i++) {
|
||||
clear();
|
||||
if (p_string.find(":") >= 0) {
|
||||
|
||||
field[i]=p_string.get_slicec('.',i).to_int();
|
||||
}
|
||||
_parse_ipv6(p_string);
|
||||
} else {
|
||||
// Mapped to IPv6
|
||||
field16[5] = 0xffff;
|
||||
_parse_ipv4(p_string, 0, &field8[12]);
|
||||
};
|
||||
}
|
||||
|
||||
IP_Address::IP_Address(uint8_t p_a,uint8_t p_b,uint8_t p_c,uint8_t p_d) {
|
||||
_FORCE_INLINE_ static void _32_to_buf(uint8_t* p_dst, uint32_t p_n) {
|
||||
|
||||
p_dst[0] = (p_n >> 24) & 0xff;
|
||||
p_dst[1] = (p_n >> 16) & 0xff;
|
||||
p_dst[2] = (p_n >> 8) & 0xff;
|
||||
p_dst[3] = (p_n >> 0) & 0xff;
|
||||
};
|
||||
|
||||
IP_Address::IP_Address(uint32_t p_a,uint32_t p_b,uint32_t p_c,uint32_t p_d, bool is_v6) {
|
||||
|
||||
clear();
|
||||
if (!is_v6) {
|
||||
// Mapped to IPv6
|
||||
field16[5]=0xffff;
|
||||
field8[12]=p_a;
|
||||
field8[13]=p_b;
|
||||
field8[14]=p_c;
|
||||
field8[15]=p_d;
|
||||
} else {
|
||||
|
||||
_32_to_buf(&field8[0], p_a);
|
||||
_32_to_buf(&field8[4], p_b);
|
||||
_32_to_buf(&field8[8], p_c);
|
||||
_32_to_buf(&field8[12], p_d);
|
||||
}
|
||||
|
||||
field[0]=p_a;
|
||||
field[1]=p_b;
|
||||
field[2]=p_c;
|
||||
field[3]=p_d;
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
@ -33,22 +33,45 @@
|
||||
|
||||
struct IP_Address {
|
||||
|
||||
private:
|
||||
|
||||
union {
|
||||
uint8_t field[4];
|
||||
uint32_t host;
|
||||
uint8_t field8[16];
|
||||
uint16_t field16[8];
|
||||
uint32_t field32[4];
|
||||
};
|
||||
|
||||
protected:
|
||||
void _parse_ipv6(const String& p_string);
|
||||
void _parse_ipv4(const String& p_string, int p_start, uint8_t* p_ret);
|
||||
|
||||
public:
|
||||
//operator Variant() const;
|
||||
bool operator==(const IP_Address& p_ip) const {
|
||||
return host==p_ip.host;
|
||||
for (int i=0; i<4; i++)
|
||||
if (field32[i] != p_ip.field32[i])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
bool operator!=(const IP_Address& p_ip) const {
|
||||
return host!=p_ip.host;
|
||||
for (int i=0; i<4; i++)
|
||||
if (field32[i] != p_ip.field32[i])
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void clear();
|
||||
bool is_ipv4() const;
|
||||
const uint8_t *get_ipv4() const;
|
||||
void set_ipv4(const uint8_t *p_ip);
|
||||
|
||||
const uint8_t *get_ipv6() const;
|
||||
void set_ipv6(const uint8_t *buf);
|
||||
|
||||
operator String() const;
|
||||
IP_Address(const String& p_string);
|
||||
IP_Address(uint8_t p_a,uint8_t p_b,uint8_t p_c,uint8_t p_d);
|
||||
IP_Address() { host=0; }
|
||||
IP_Address(uint32_t p_a,uint32_t p_b,uint32_t p_c,uint32_t p_d, bool is_v6=false);
|
||||
IP_Address() { clear(); }
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
@ -29,27 +29,20 @@
|
||||
#include "packet_peer_udp.h"
|
||||
#include "io/ip.h"
|
||||
|
||||
|
||||
PacketPeerUDP* (*PacketPeerUDP::_create)()=NULL;
|
||||
|
||||
int PacketPeerUDP::_get_packet_address() const {
|
||||
|
||||
IP_Address ip = get_packet_address();
|
||||
return ip.host;
|
||||
}
|
||||
|
||||
String PacketPeerUDP::_get_packet_ip() const {
|
||||
|
||||
return get_packet_address();
|
||||
}
|
||||
|
||||
Error PacketPeerUDP::_set_send_address(const String& p_address,int p_port) {
|
||||
Error PacketPeerUDP::_set_send_address(const String& p_address, int p_port) {
|
||||
|
||||
IP_Address ip;
|
||||
if (p_address.is_valid_ip_address()) {
|
||||
ip=p_address;
|
||||
} else {
|
||||
ip=IP::get_singleton()->resolve_hostname(p_address);
|
||||
ip=IP::get_singleton()->resolve_hostname(p_address, ip_type);
|
||||
if (ip==IP_Address())
|
||||
return ERR_CANT_RESOLVE;
|
||||
}
|
||||
@ -58,14 +51,20 @@ Error PacketPeerUDP::_set_send_address(const String& p_address,int p_port) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
void PacketPeerUDP::set_ip_type(IP::Type p_type) {
|
||||
close();
|
||||
ip_type = p_type;
|
||||
}
|
||||
|
||||
void PacketPeerUDP::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("listen:Error","port","recv_buf_size"),&PacketPeerUDP::listen,DEFVAL(65536));
|
||||
ObjectTypeDB::bind_method(_MD("set_ip_type","ip_type"),&PacketPeerUDP::set_ip_type);
|
||||
ObjectTypeDB::bind_method(_MD("listen:Error","port", "recv_buf_size"),&PacketPeerUDP::listen,DEFVAL(65536));
|
||||
ObjectTypeDB::bind_method(_MD("close"),&PacketPeerUDP::close);
|
||||
ObjectTypeDB::bind_method(_MD("wait:Error"),&PacketPeerUDP::wait);
|
||||
ObjectTypeDB::bind_method(_MD("is_listening"),&PacketPeerUDP::is_listening);
|
||||
ObjectTypeDB::bind_method(_MD("get_packet_ip"),&PacketPeerUDP::_get_packet_ip);
|
||||
ObjectTypeDB::bind_method(_MD("get_packet_address"),&PacketPeerUDP::_get_packet_address);
|
||||
//ObjectTypeDB::bind_method(_MD("get_packet_address"),&PacketPeerUDP::_get_packet_address);
|
||||
ObjectTypeDB::bind_method(_MD("get_packet_port"),&PacketPeerUDP::get_packet_port);
|
||||
ObjectTypeDB::bind_method(_MD("set_send_address","host","port"),&PacketPeerUDP::_set_send_address);
|
||||
|
||||
@ -88,4 +87,5 @@ PacketPeerUDP* PacketPeerUDP::create() {
|
||||
|
||||
PacketPeerUDP::PacketPeerUDP()
|
||||
{
|
||||
ip_type = IP::TYPE_ANY;
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
@ -30,6 +30,7 @@
|
||||
#define PACKET_PEER_UDP_H
|
||||
|
||||
|
||||
#include "io/ip.h"
|
||||
#include "io/packet_peer.h"
|
||||
|
||||
class PacketPeerUDP : public PacketPeer {
|
||||
@ -37,17 +38,19 @@ class PacketPeerUDP : public PacketPeer {
|
||||
|
||||
protected:
|
||||
|
||||
IP::Type ip_type;
|
||||
|
||||
static PacketPeerUDP* (*_create)();
|
||||
static void _bind_methods();
|
||||
|
||||
int _get_packet_address() const;
|
||||
String _get_packet_ip() const;
|
||||
|
||||
virtual Error _set_send_address(const String& p_address,int p_port);
|
||||
|
||||
public:
|
||||
|
||||
virtual Error listen(int p_port,int p_recv_buffer_size=65536)=0;
|
||||
virtual void set_ip_type(IP::Type p_type);
|
||||
virtual Error listen(int p_port, int p_recv_buffer_size=65536)=0;
|
||||
virtual void close()=0;
|
||||
virtual Error wait()=0;
|
||||
virtual bool is_listening() const=0;
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
@ -30,9 +30,30 @@
|
||||
|
||||
StreamPeerTCP* (*StreamPeerTCP::_create)()=NULL;
|
||||
|
||||
Error StreamPeerTCP::_connect(const String& p_address,int p_port) {
|
||||
|
||||
IP_Address ip;
|
||||
if (p_address.is_valid_ip_address()) {
|
||||
ip=p_address;
|
||||
} else {
|
||||
ip=IP::get_singleton()->resolve_hostname(p_address, ip_type);
|
||||
if (ip==IP_Address())
|
||||
return ERR_CANT_RESOLVE;
|
||||
}
|
||||
|
||||
connect(ip,p_port);
|
||||
return OK;
|
||||
}
|
||||
|
||||
void StreamPeerTCP::set_ip_type(IP::Type p_type) {
|
||||
disconnect();
|
||||
ip_type = p_type;
|
||||
}
|
||||
|
||||
void StreamPeerTCP::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("connect","host","port"),&StreamPeerTCP::connect);
|
||||
ObjectTypeDB::bind_method(_MD("set_ip_type","ip_type"),&StreamPeerTCP::set_ip_type);
|
||||
ObjectTypeDB::bind_method(_MD("connect","host","port"),&StreamPeerTCP::_connect);
|
||||
ObjectTypeDB::bind_method(_MD("is_connected"),&StreamPeerTCP::is_connected);
|
||||
ObjectTypeDB::bind_method(_MD("get_status"),&StreamPeerTCP::get_status);
|
||||
ObjectTypeDB::bind_method(_MD("get_connected_host"),&StreamPeerTCP::get_connected_host);
|
||||
@ -62,6 +83,7 @@ StreamPeerTCP* StreamPeerTCP::create() {
|
||||
|
||||
StreamPeerTCP::StreamPeerTCP() {
|
||||
|
||||
ip_type = IP::TYPE_ANY;
|
||||
}
|
||||
|
||||
StreamPeerTCP::~StreamPeerTCP() {
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
@ -32,6 +32,7 @@
|
||||
#include "stream_peer.h"
|
||||
|
||||
#include "ip_address.h"
|
||||
#include "io/ip.h"
|
||||
|
||||
class StreamPeerTCP : public StreamPeer {
|
||||
|
||||
@ -50,11 +51,15 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
IP::Type ip_type;
|
||||
|
||||
virtual Error _connect(const String& p_address, int p_port);
|
||||
static StreamPeerTCP* (*_create)();
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
|
||||
virtual void set_ip_type(IP::Type p_type);
|
||||
virtual Error connect(const IP_Address& p_host, uint16_t p_port)=0;
|
||||
|
||||
//read/write from streampeer
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
@ -44,18 +44,24 @@ TCP_Server* TCP_Server::create() {
|
||||
return _create();
|
||||
}
|
||||
|
||||
Error TCP_Server::_listen(uint16_t p_port,DVector<String> p_accepted_hosts) {
|
||||
Error TCP_Server::_listen(uint16_t p_port, DVector<String> p_accepted_hosts) {
|
||||
|
||||
List<String> hosts;
|
||||
for(int i=0;i<p_accepted_hosts.size();i++)
|
||||
hosts.push_back(p_accepted_hosts.get(i));
|
||||
|
||||
return listen(p_port,hosts.size()?&hosts:NULL);
|
||||
return listen(p_port, hosts.size()?&hosts:NULL);
|
||||
|
||||
}
|
||||
|
||||
void TCP_Server::set_ip_type(IP::Type p_type) {
|
||||
stop();
|
||||
ip_type = p_type;
|
||||
}
|
||||
|
||||
void TCP_Server::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_ip_type","ip_type"),&TCP_Server::set_ip_type);
|
||||
ObjectTypeDB::bind_method(_MD("listen","port","accepted_hosts"),&TCP_Server::_listen,DEFVAL(DVector<String>()));
|
||||
ObjectTypeDB::bind_method(_MD("is_connection_available"),&TCP_Server::is_connection_available);
|
||||
ObjectTypeDB::bind_method(_MD("take_connection"),&TCP_Server::take_connection);
|
||||
@ -66,4 +72,5 @@ void TCP_Server::_bind_methods() {
|
||||
|
||||
TCP_Server::TCP_Server()
|
||||
{
|
||||
ip_type = IP::TYPE_ANY;
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2017 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 */
|
||||
@ -38,14 +38,17 @@ class TCP_Server : public Reference {
|
||||
OBJ_TYPE( TCP_Server, Reference );
|
||||
protected:
|
||||
|
||||
IP::Type ip_type;
|
||||
|
||||
static TCP_Server* (*_create)();
|
||||
|
||||
//bind helper
|
||||
Error _listen(uint16_t p_port,DVector<String> p_accepted_hosts=DVector<String>());
|
||||
Error _listen(uint16_t p_port, DVector<String> p_accepted_hosts=DVector<String>());
|
||||
static void _bind_methods();
|
||||
public:
|
||||
|
||||
virtual Error listen(uint16_t p_port,const List<String> *p_accepted_hosts=NULL)=0;
|
||||
virtual void set_ip_type(IP::Type p_type);
|
||||
virtual Error listen(uint16_t p_port, const List<String> *p_accepted_hosts=NULL)=0;
|
||||
virtual bool is_connection_available() const=0;
|
||||
virtual Ref<StreamPeerTCP> take_connection()=0;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user