summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.clang-format5
-rw-r--r--AUTHORS.md10
-rw-r--r--DONORS.md42
-rw-r--r--core/class_db.cpp19
-rw-r--r--core/class_db.h2
-rw-r--r--core/io/json.cpp6
-rw-r--r--core/io/json.h4
-rw-r--r--doc/classes/Animation.xml28
-rw-r--r--doc/classes/AnimationPlayer.xml38
-rw-r--r--doc/classes/AnimationTreePlayer.xml60
-rw-r--r--doc/classes/CanvasItem.xml28
-rw-r--r--doc/classes/EditorPlugin.xml22
-rw-r--r--doc/classes/EditorSceneImporter.xml95
-rw-r--r--doc/classes/KinematicBody.xml6
-rw-r--r--doc/classes/Mesh.xml4
-rw-r--r--doc/classes/MeshInstance.xml2
-rw-r--r--doc/classes/PhysicsServer.xml19
-rw-r--r--doc/classes/Rect2.xml6
-rw-r--r--doc/classes/RigidBody.xml15
-rw-r--r--doc/classes/SurfaceTool.xml2
-rw-r--r--doc/classes/TextEdit.xml11
-rw-r--r--doc/classes/Texture.xml2
-rw-r--r--doc/classes/VisualServer.xml8
-rw-r--r--drivers/gles3/shader_compiler_gles3.cpp1
-rw-r--r--editor/editor_help.cpp5
-rw-r--r--editor/editor_node.cpp1
-rw-r--r--editor/editor_plugin.h2
-rw-r--r--editor/import/editor_import_collada.cpp2
-rw-r--r--editor/import/editor_import_collada.h2
-rw-r--r--editor/import/editor_scene_importer_gltf.cpp5
-rw-r--r--editor/import/editor_scene_importer_gltf.h2
-rw-r--r--editor/import/resource_importer_obj.h2
-rw-r--r--editor/plugins/asset_library_editor_plugin.cpp8
-rw-r--r--editor/plugins/asset_library_editor_plugin.h1
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp2
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp2
-rw-r--r--editor/property_editor.cpp53
-rw-r--r--editor/property_selector.cpp18
-rwxr-xr-xmisc/hooks/pre-commit-clang-format2
-rwxr-xr-xmisc/travis/clang-format.sh2
-rw-r--r--modules/gdnative/register_types.cpp7
-rw-r--r--modules/gdscript/gdscript_function.cpp4
-rw-r--r--platform/android/export/export.cpp11
-rw-r--r--platform/android/java/src/org/godotengine/godot/Dictionary.java7
-rw-r--r--platform/android/java/src/org/godotengine/godot/Godot.java812
-rw-r--r--platform/android/java/src/org/godotengine/godot/GodotDownloaderAlarmReceiver.java18
-rw-r--r--platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java55
-rw-r--r--platform/android/java/src/org/godotengine/godot/GodotIO.java273
-rw-r--r--platform/android/java/src/org/godotengine/godot/GodotLib.java56
-rw-r--r--platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java25
-rw-r--r--platform/android/java/src/org/godotengine/godot/GodotView.java261
-rw-r--r--platform/android/java/src/org/godotengine/godot/input/GodotEditText.java61
-rw-r--r--platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java3
-rw-r--r--platform/android/java/src/org/godotengine/godot/input/InputManagerCompat.java204
-rw-r--r--platform/android/java/src/org/godotengine/godot/input/InputManagerV16.java144
-rw-r--r--platform/android/java/src/org/godotengine/godot/input/InputManagerV9.java352
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java38
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java20
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/HandlePurchaseTask.java30
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/PaymentsCache.java45
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java87
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java38
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java46
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java36
-rw-r--r--platform/android/java/src/org/godotengine/godot/utils/Crypt.java46
-rw-r--r--platform/android/java/src/org/godotengine/godot/utils/CustomSSLSocketFactory.java31
-rw-r--r--platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java207
-rw-r--r--platform/android/java/src/org/godotengine/godot/utils/RequestParams.java34
-rw-r--r--platform/x11/os_x11.cpp44
-rw-r--r--platform/x11/os_x11.h1
-rw-r--r--scene/3d/gi_probe.cpp2
-rw-r--r--scene/3d/particles.cpp4
-rw-r--r--scene/animation/animation_player.cpp4
-rw-r--r--scene/main/viewport.cpp7
-rw-r--r--scene/resources/surface_tool.cpp2
75 files changed, 1796 insertions, 1763 deletions
diff --git a/.clang-format b/.clang-format
index bc69a6a3a6..212bc25109 100644
--- a/.clang-format
+++ b/.clang-format
@@ -44,7 +44,6 @@ AllowShortIfStatementsOnASingleLine: true
BreakBeforeTernaryOperators: false
# BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: AfterColon
-# BreakAfterJavaFieldAnnotations: false
# BreakStringLiterals: true
ColumnLimit: 0
# CommentPragmas: '^ IWYU pragma:'
@@ -113,4 +112,8 @@ Language: ObjC
ObjCBlockIndentWidth: 4
# ObjCSpaceAfterProperty: false
# ObjCSpaceBeforeProtocolList: true
+---
+### Java specific config ###
+Language: Java
+# BreakAfterJavaFieldAnnotations: false
...
diff --git a/AUTHORS.md b/AUTHORS.md
index 73712bbfc4..9a373896f8 100644
--- a/AUTHORS.md
+++ b/AUTHORS.md
@@ -32,6 +32,7 @@ name is available.
Alket Rexhepi (alketii)
Andrea Catania (AndreaCatania)
Andreas Haas (Hinsbart)
+ Andy Moss (MillionOstrich)
Anton Yabchinskiy (a12n)
Aren Villanueva (kurikaesu)
Ariel Manzur (punto-)
@@ -43,6 +44,7 @@ name is available.
Carl Olsson (not-surt)
Dana Olson (adolson)
Daniel J. Ramirez (djrm)
+ Dmitry Koteroff (Krakean)
Дмитрий Сальников (DmitriySalnikov)
Emmanuel Leblond (touilleMan)
Fabio Alessandrelli (Faless)
@@ -53,7 +55,7 @@ name is available.
George Marques (vnen)
Gerrit Großkopf (Grosskopf)
Gilles Roudiere (groud)
- Guilherme Felipe (guilhermefelipecgs)
+ Guilherme Felipe de C. G. da Silva (guilhermefelipecgs)
Hein-Pieter van Braam (hpvb)
Hiroshi Ogawa (hi-ogawa)
Hubert Jarosz (Marqin)
@@ -76,6 +78,7 @@ name is available.
Masoud BH (masoudbh3)
Matthias Hölzl (hoelzl)
Max Hilbrunner (mhilbrunner)
+ Michael Alexsander Silva Dias (YeldhamDev)
Nathan Warden (NathanWarden)
Nuno Donato (nunodonato)
Ovnuniarchos
@@ -97,13 +100,18 @@ name is available.
Timo (toger5)
V. Vamsi Krishna (vkbsb)
Vinzenz Feenstra (vinzenz)
+ Will Nations (willnationsdev)
Wilson E. Alvarez (Rubonnek)
+ Yuri Roubinski (Chaosus)
Zher Huei Lee (leezh)
ZuBsPaCe
박한얼 (volzhs)
bruvzg
est31
+ m4nu3lf
marynate
mrezai
+ rraallvv
romulox-x
+ sersoong
yg2f (SuperUserNameMan)
diff --git a/DONORS.md b/DONORS.md
index 3891a708ce..aea2ef5ae8 100644
--- a/DONORS.md
+++ b/DONORS.md
@@ -12,7 +12,7 @@ generous deed immortalized in the next stable release of Godot Engine.
## Platinum sponsors
-None so far, but your company could be the first! :)
+ Enjin Coin <https://enjincoin.io>
## Gold sponsors
@@ -22,15 +22,16 @@ None so far, but your company could be the first! :)
## Mini sponsors
Andreas
- Andreas Hirschauer
+ Brandon Lamb
Christian Uldall Pedersen
Christoph Woinke
E Hewert
Hein-Pieter van Braam
+ Jamal Alyafei
+ Jordan M Lucas
Matthieu Huvé
Nathan Warden
Neal Gompa (Conan Kudo)
- Olimpiu Metiu
Pascal Julien
Ruslan Mustakov
Slobodan Milnovic
@@ -48,15 +49,19 @@ None so far, but your company could be the first! :)
Officine Pixel S.n.c.
Rémi Verschelde
Stephan Lanfermann
+ Zaven Muradyan
Andreas Schüle
Austen McRae
Bernhard Liebl
+ Cody Brocious
Gerald E Butler
Jahn Johansen
- Jordan M Lucas
+ Johannes Wuensch
Kris Michael
+ Libre-Dépanne
Ranoller
+ Svenne Krap
BanjoNode2D
Chris Serino
@@ -80,40 +85,49 @@ None so far, but your company could be the first! :)
Amanda Haldy
Andreas Haas
- Andres Cuevas
Arnaud Verstuyf
- Bryanna M
Chris Brown
Cody Parker
D
+ Daniel Eliasinski
+ Daniel Langegger
+ Eric Monson
Ezra Theunissen
flesk
François Cantin
Giovanni Solimeno
- Hendrik Mans
Jeppe Zapp
Justin Arnold
Justo Delgado Baudí
Leandro Voltolino
Lucien Boudy
Noah
+ Patrick Schnorbus
+ Pete Goodwin
Ryan Estes
+ Ted
+ Travis Womack
Trent McPheron
## Silver donors
1D_Inc
+ Abe Pazos
+ Alder Stefano
Alessandro Senese
Alex Barsukov
+ Andres Cuevas
Anthony Bongiovanni
Avencherus
Bastian Böhm
Ben Vercammen
Blair Allen
Bryan Stevenson
+ Casey Foote
Christian Baune
Christian Winter
Collin Shooltz
+ Daniel Egger
Daniel Kaplan
David Cravens
David May
@@ -122,11 +136,13 @@ None so far, but your company could be the first! :)
Eric Martini
Fabian Becker
fengjiongmax
+ Francesco Lisi
Frank C. Simmons
+ Fredy Romero Sam
+ G3Dev sàrl
Geequlim
Gerrit Großkopf
Guldoman
- Gustav Dahlström
HardRound
hatniX
HeartBeast
@@ -134,6 +150,7 @@ None so far, but your company could be the first! :)
Hunter Jones
Jaime Ruiz-Borau Vizárraga
Jeff Hungerford
+ Jerry Chen
Jesse Liles
joe513
Jonathon
@@ -146,15 +163,15 @@ None so far, but your company could be the first! :)
Kevin Boyer
Kevin Kamper Meejach Petersen
Klavdij Voncina
- Kobi Malul
Linus Lind Lundgren
Lisandro Lorea
magodev
+ Markus Wiesner
Martin Novák
Matthew Fitzpatrick
- Matthew Valancy
Matthias Hölzl
Max R.R. Collada
+ memoryruins
mhilbrunner
Michael Gringauz
Michael Tintiuc
@@ -172,17 +189,18 @@ None so far, but your company could be the first! :)
Patrick Nafarrete
Paul Mason
Paweł Kowal
- Pete Goodwin
+ Pierre-Igor Berthet
Pietro Vertechi
rayos
Richman Stewart
+ Rodolfo Baeza
+ Roger Burgess
Roger Smith
Roman Tinkov
Sam Van Campenhout
Sasori Olkof
Scott D. Yelich
Sootstone
- TheHappieCat
Theo Cranmore
Thomas Norman
Tom Larrow
diff --git a/core/class_db.cpp b/core/class_db.cpp
index 57e88044b5..edd49fe95f 100644
--- a/core/class_db.cpp
+++ b/core/class_db.cpp
@@ -1036,7 +1036,6 @@ bool ClassDB::get_property(Object *p_object, const StringName &p_property, Varia
r_value = *c;
return true;
}
- //if (check->constant_map.fin)
check = check->inherits_ptr;
}
@@ -1163,24 +1162,6 @@ bool ClassDB::has_method(StringName p_class, StringName p_method, bool p_no_inhe
return false;
}
-bool ClassDB::get_setter_and_type_for_property(const StringName &p_class, const StringName &p_prop, StringName &r_class, StringName &r_setter) {
-
- ClassInfo *type = classes.getptr(p_class);
- ClassInfo *check = type;
- while (check) {
-
- if (check->property_setget.has(p_prop)) {
- r_class = check->name;
- r_setter = check->property_setget[p_prop].setter;
- return true;
- }
-
- check = check->inherits_ptr;
- }
-
- return false;
-}
-
#ifdef DEBUG_METHODS_ENABLED
MethodBind *ClassDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind, const MethodDefinition &method_name, const Variant **p_defs, int p_defcount) {
StringName mdname = method_name.name;
diff --git a/core/class_db.h b/core/class_db.h
index b8b681301d..55fe01ec6d 100644
--- a/core/class_db.h
+++ b/core/class_db.h
@@ -349,8 +349,6 @@ public:
static StringName get_category(const StringName &p_node);
- static bool get_setter_and_type_for_property(const StringName &p_class, const StringName &p_prop, StringName &r_class, StringName &r_setter);
-
static void set_class_enabled(StringName p_class, bool p_enable);
static bool is_class_enabled(StringName p_class);
diff --git a/core/io/json.cpp b/core/io/json.cpp
index ddfc792cc7..82e938d2db 100644
--- a/core/io/json.cpp
+++ b/core/io/json.cpp
@@ -43,7 +43,7 @@ const char *JSON::tk_name[TK_MAX] = {
"EOF",
};
-static String _make_indent(const String& p_indent, int p_size) {
+static String _make_indent(const String &p_indent, int p_size) {
String indent_text = "";
if (!p_indent.empty()) {
@@ -53,7 +53,7 @@ static String _make_indent(const String& p_indent, int p_size) {
return indent_text;
}
-String JSON::_print_var(const Variant &p_var, const String& p_indent, int p_cur_indent, bool p_sort_keys) {
+String JSON::_print_var(const Variant &p_var, const String &p_indent, int p_cur_indent, bool p_sort_keys) {
String colon = ":";
String end_statement = "";
@@ -116,7 +116,7 @@ String JSON::_print_var(const Variant &p_var, const String& p_indent, int p_cur_
}
}
-String JSON::print(const Variant &p_var, const String& p_indent, bool p_sort_keys) {
+String JSON::print(const Variant &p_var, const String &p_indent, bool p_sort_keys) {
return _print_var(p_var, p_indent, 0, p_sort_keys);
}
diff --git a/core/io/json.h b/core/io/json.h
index 5e1a89f069..fbb7875c7c 100644
--- a/core/io/json.h
+++ b/core/io/json.h
@@ -64,7 +64,7 @@ class JSON {
static const char *tk_name[TK_MAX];
- static String _print_var(const Variant &p_var, const String& p_indent, int p_cur_indent, bool p_sort_keys);
+ static String _print_var(const Variant &p_var, const String &p_indent, int p_cur_indent, bool p_sort_keys);
static Error _get_token(const CharType *p_str, int &index, int p_len, Token &r_token, int &line, String &r_err_str);
static Error _parse_value(Variant &value, Token &token, const CharType *p_str, int &index, int p_len, int &line, String &r_err_str);
@@ -72,7 +72,7 @@ class JSON {
static Error _parse_object(Dictionary &object, const CharType *p_str, int &index, int p_len, int &line, String &r_err_str);
public:
- static String print(const Variant &p_var, const String& p_indent = "", bool p_sort_keys = true);
+ static String print(const Variant &p_var, const String &p_indent = "", bool p_sort_keys = true);
static Error parse(const String &p_json, Variant &r_ret, String &r_err_str, int &r_err_line);
};
diff --git a/doc/classes/Animation.xml b/doc/classes/Animation.xml
index c3933443a0..93b01a466b 100644
--- a/doc/classes/Animation.xml
+++ b/doc/classes/Animation.xml
@@ -30,6 +30,16 @@
Clear the animation (clear all tracks and reset all).
</description>
</method>
+ <method name="copy_track">
+ <return type="void">
+ </return>
+ <argument index="0" name="track" type="int">
+ </argument>
+ <argument index="1" name="to_animation" type="Animation">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="find_track" qualifiers="const">
<return type="int">
</return>
@@ -244,6 +254,14 @@
Insert a generic key in a given track.
</description>
</method>
+ <method name="track_is_enabled" qualifiers="const">
+ <return type="bool">
+ </return>
+ <argument index="0" name="idx" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="track_is_imported" qualifiers="const">
<return type="bool">
</return>
@@ -293,6 +311,16 @@
Remove a key by position (seconds) in a given track.
</description>
</method>
+ <method name="track_set_enabled">
+ <return type="void">
+ </return>
+ <argument index="0" name="idx" type="int">
+ </argument>
+ <argument index="1" name="enabled" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="track_set_imported">
<return type="void">
</return>
diff --git a/doc/classes/AnimationPlayer.xml b/doc/classes/AnimationPlayer.xml
index 6ae0debc3a..d61211bb6b 100644
--- a/doc/classes/AnimationPlayer.xml
+++ b/doc/classes/AnimationPlayer.xml
@@ -74,20 +74,6 @@
Returns the name of [code]animation[/code] or empty string if not found.
</description>
</method>
- <method name="get_anim_length" qualifiers="const">
- <return type="float">
- </return>
- <description>
- Get the length (in seconds) of the currently playing animation.
- </description>
- </method>
- <method name="get_anim_position" qualifiers="const">
- <return type="float">
- </return>
- <description>
- Get the position (in seconds) of the currently playing animation.
- </description>
- </method>
<method name="get_animation" qualifiers="const">
<return type="Animation">
</return>
@@ -115,11 +101,18 @@
Get the blend time (in seconds) between two animations, referenced by their names.
</description>
</method>
- <method name="get_current_animation" qualifiers="const">
- <return type="String">
+ <method name="get_current_animation_length" qualifiers="const">
+ <return type="float">
</return>
<description>
- Returns the name of the currently playing animation.
+ Get the length (in seconds) of the currently playing animation.
+ </description>
+ </method>
+ <method name="get_current_animation_position" qualifiers="const">
+ <return type="float">
+ </return>
+ <description>
+ Get the position (in seconds) of the currently playing animation.
</description>
</method>
<method name="has_animation" qualifiers="const">
@@ -217,15 +210,6 @@
Specify a blend time (in seconds) between two animations, referenced by their names.
</description>
</method>
- <method name="set_current_animation">
- <return type="void">
- </return>
- <argument index="0" name="anim" type="String">
- </argument>
- <description>
- Set the current animation (even if no playback occurs). Using set_current_animation() and set_active() are similar to calling play().
- </description>
- </method>
<method name="stop">
<return type="void">
</return>
@@ -253,6 +237,8 @@
<member name="current_animation" type="String" setter="set_current_animation" getter="get_current_animation">
The name of the current animation. Default value: [code]""[/code].
</member>
+ <member name="playback_default_blend_time" type="float" setter="set_default_blend_time" getter="get_default_blend_time">
+ </member>
<member name="playback_process_mode" type="int" setter="set_animation_process_mode" getter="get_animation_process_mode" enum="AnimationPlayer.AnimationProcessMode">
The process notification in which to update animations. Default value: [enum ANIMATION_PROCESS_IDLE].
</member>
diff --git a/doc/classes/AnimationTreePlayer.xml b/doc/classes/AnimationTreePlayer.xml
index 37005c3bd3..ecd1f81951 100644
--- a/doc/classes/AnimationTreePlayer.xml
+++ b/doc/classes/AnimationTreePlayer.xml
@@ -194,19 +194,6 @@
Disconnects nodes connected to [code]id[/code] at the specified input slot.
</description>
</method>
- <method name="get_base_path" qualifiers="const">
- <return type="NodePath">
- </return>
- <description>
- </description>
- </method>
- <method name="get_master_player" qualifiers="const">
- <return type="NodePath">
- </return>
- <description>
- Returns the path to the [AnimationPlayer] from which this [code]AnimationTreePlayer[/code] binds animations to animation nodes.
- </description>
- </method>
<method name="get_node_list">
<return type="PoolStringArray">
</return>
@@ -214,13 +201,6 @@
Returns a PoolStringArray containing the name of all nodes.
</description>
</method>
- <method name="is_active" qualifiers="const">
- <return type="bool">
- </return>
- <description>
- Returns whether this AnimationTreePlayer is active.
- </description>
- </method>
<method name="mix_node_get_amount" qualifiers="const">
<return type="float">
</return>
@@ -473,32 +453,6 @@
Resets this AnimationTreePlayer.
</description>
</method>
- <method name="set_active">
- <return type="void">
- </return>
- <argument index="0" name="enabled" type="bool">
- </argument>
- <description>
- Sets whether this AnimationTreePlayer is active. AnimationTreePlayer will start processing if set to active.
- </description>
- </method>
- <method name="set_base_path">
- <return type="void">
- </return>
- <argument index="0" name="path" type="NodePath">
- </argument>
- <description>
- Sets base path of this AnimationTreePlayer.
- </description>
- </method>
- <method name="set_master_player">
- <return type="void">
- </return>
- <argument index="0" name="nodepath" type="NodePath">
- </argument>
- <description>
- </description>
- </method>
<method name="timescale_node_get_scale" qualifiers="const">
<return type="float">
</return>
@@ -627,17 +581,17 @@
</method>
</methods>
<members>
- <member name="playback_process_mode" type="int" setter="set_animation_process_mode" getter="get_animation_process_mode" enum="AnimationTreePlayer.AnimationProcessMode">
- The thread in which to update animations. Default value: [enum ANIMATION_PROCESS_IDLE].
- </member>
- <member name="master_player" type="NodePath" setter="set_master_player" getter="get_master_player">
- The path to the [AnimationPlayer] from which this [code]AnimationTreePlayer[/code] binds animations to animation nodes.
+ <member name="active" type="bool" setter="set_active" getter="is_active">
+ If [code]true[/code] the [code]AnimationTreePlayer[/code] is able to play animations. Default value: [code]false[/code].
</member>
<member name="base_path" type="NodePath" setter="set_base_path" getter="get_base_path">
The node from which to relatively access other nodes. Default value: [code]".."[/code].
</member>
- <member name="active" type="bool" setter="set_active" getter="is_active">
- If [code]true[/code] the [code]AnimationTreePlayer[/code] is able to play animations. Default value: [code]false[/code].
+ <member name="master_player" type="NodePath" setter="set_master_player" getter="get_master_player">
+ The path to the [AnimationPlayer] from which this [code]AnimationTreePlayer[/code] binds animations to animation nodes.
+ </member>
+ <member name="playback_process_mode" type="int" setter="set_animation_process_mode" getter="get_animation_process_mode" enum="AnimationTreePlayer.AnimationProcessMode">
+ The thread in which to update animations. Default value: [enum ANIMATION_PROCESS_IDLE].
</member>
</members>
<constants>
diff --git a/doc/classes/CanvasItem.xml b/doc/classes/CanvasItem.xml
index 4a567981e6..cf0b482b07 100644
--- a/doc/classes/CanvasItem.xml
+++ b/doc/classes/CanvasItem.xml
@@ -88,6 +88,34 @@
Draw a line from a 2D point to another, with a given color and width. It can be optionally antialiased.
</description>
</method>
+ <method name="draw_multiline">
+ <return type="void">
+ </return>
+ <argument index="0" name="points" type="PoolVector2Array">
+ </argument>
+ <argument index="1" name="color" type="Color">
+ </argument>
+ <argument index="2" name="width" type="float" default="1.0">
+ </argument>
+ <argument index="3" name="antialiased" type="bool" default="false">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="draw_multiline_colors">
+ <return type="void">
+ </return>
+ <argument index="0" name="points" type="PoolVector2Array">
+ </argument>
+ <argument index="1" name="colors" type="PoolColorArray">
+ </argument>
+ <argument index="2" name="width" type="float" default="1.0">
+ </argument>
+ <argument index="3" name="antialiased" type="bool" default="false">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="draw_polygon">
<return type="void">
</return>
diff --git a/doc/classes/EditorPlugin.xml b/doc/classes/EditorPlugin.xml
index edd1f721b5..ada0ee56a8 100644
--- a/doc/classes/EditorPlugin.xml
+++ b/doc/classes/EditorPlugin.xml
@@ -82,6 +82,14 @@
<description>
</description>
</method>
+ <method name="add_scene_import_plugin">
+ <return type="void">
+ </return>
+ <argument index="0" name="scene_importer" type="EditorSceneImporter">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="add_tool_submenu_item">
<return type="void">
</return>
@@ -176,6 +184,12 @@
<description>
</description>
</method>
+ <method name="get_plugin_icon" qualifiers="virtual">
+ <return type="Object">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="get_plugin_name" qualifiers="virtual">
<return type="String">
</return>
@@ -295,6 +309,14 @@
<description>
</description>
</method>
+ <method name="remove_scene_import_plugin">
+ <return type="void">
+ </return>
+ <argument index="0" name="scene_importer" type="EditorSceneImporter">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="save_external_data" qualifiers="virtual">
<return type="void">
</return>
diff --git a/doc/classes/EditorSceneImporter.xml b/doc/classes/EditorSceneImporter.xml
new file mode 100644
index 0000000000..69fe4050f4
--- /dev/null
+++ b/doc/classes/EditorSceneImporter.xml
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="EditorSceneImporter" inherits="Reference" category="Core" version="3.0-beta">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <tutorials>
+ </tutorials>
+ <demos>
+ </demos>
+ <methods>
+ <method name="_get_extensions" qualifiers="virtual">
+ <return type="Array">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="_get_import_flags" qualifiers="virtual">
+ <return type="int">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="_import_animation" qualifiers="virtual">
+ <return type="Animation">
+ </return>
+ <argument index="0" name="path" type="String">
+ </argument>
+ <argument index="1" name="flags" type="int">
+ </argument>
+ <argument index="2" name="bake_fps" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="_import_scene" qualifiers="virtual">
+ <return type="Node">
+ </return>
+ <argument index="0" name="path" type="String">
+ </argument>
+ <argument index="1" name="flags" type="int">
+ </argument>
+ <argument index="2" name="bake_fps" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="import_animation_from_other_importer">
+ <return type="Animation">
+ </return>
+ <argument index="0" name="path" type="String">
+ </argument>
+ <argument index="1" name="flags" type="int">
+ </argument>
+ <argument index="2" name="bake_fps" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="import_scene_from_other_importer">
+ <return type="Node">
+ </return>
+ <argument index="0" name="path" type="String">
+ </argument>
+ <argument index="1" name="flags" type="int">
+ </argument>
+ <argument index="2" name="bake_fps" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ </methods>
+ <constants>
+ <constant name="IMPORT_SCENE" value="1">
+ </constant>
+ <constant name="IMPORT_ANIMATION" value="2">
+ </constant>
+ <constant name="IMPORT_ANIMATION_DETECT_LOOP" value="4">
+ </constant>
+ <constant name="IMPORT_ANIMATION_OPTIMIZE" value="8">
+ </constant>
+ <constant name="IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS" value="16">
+ </constant>
+ <constant name="IMPORT_ANIMATION_KEEP_VALUE_TRACKS" value="32">
+ </constant>
+ <constant name="IMPORT_GENERATE_TANGENT_ARRAYS" value="256">
+ </constant>
+ <constant name="IMPORT_FAIL_ON_MISSING_DEPENDENCIES" value="512">
+ </constant>
+ <constant name="IMPORT_MATERIALS_IN_INSTANCES" value="1024">
+ </constant>
+ <constant name="IMPORT_USE_COMPRESSION" value="2048">
+ </constant>
+ </constants>
+</class>
diff --git a/doc/classes/KinematicBody.xml b/doc/classes/KinematicBody.xml
index c5204fd0bf..43db8ed43a 100644
--- a/doc/classes/KinematicBody.xml
+++ b/doc/classes/KinematicBody.xml
@@ -102,6 +102,12 @@
</method>
</methods>
<members>
+ <member name="axis_lock_x" type="bool" setter="set_axis_lock_x" getter="get_axis_lock_x">
+ </member>
+ <member name="axis_lock_y" type="bool" setter="set_axis_lock_y" getter="get_axis_lock_y">
+ </member>
+ <member name="axis_lock_z" type="bool" setter="set_axis_lock_z" getter="get_axis_lock_z">
+ </member>
<member name="collision/safe_margin" type="float" setter="set_safe_margin" getter="get_safe_margin">
If the body is at least this close to another body, this body will consider them to be colliding.
</member>
diff --git a/doc/classes/Mesh.xml b/doc/classes/Mesh.xml
index c681886546..465b68171e 100644
--- a/doc/classes/Mesh.xml
+++ b/doc/classes/Mesh.xml
@@ -49,6 +49,10 @@
</description>
</method>
</methods>
+ <members>
+ <member name="lightmap_size_hint" type="Vector2" setter="set_lightmap_size_hint" getter="get_lightmap_size_hint">
+ </member>
+ </members>
<constants>
<constant name="PRIMITIVE_POINTS" value="0" enum="PrimitiveType">
Render array as points (one vertex equals one point).
diff --git a/doc/classes/MeshInstance.xml b/doc/classes/MeshInstance.xml
index ac26c2946f..9273e87430 100644
--- a/doc/classes/MeshInstance.xml
+++ b/doc/classes/MeshInstance.xml
@@ -22,7 +22,7 @@
<return type="void">
</return>
<description>
- This helper creates a [MeshInstance] child node with gizmos at every vertex calculated from the mesh geometry. It's mainly used for testing.
+ This helper creates a [MeshInstance] child node with gizmos at every vertex calculated from the mesh geometry. It's mainly used for testing.
</description>
</method>
<method name="create_trimesh_collision">
diff --git a/doc/classes/PhysicsServer.xml b/doc/classes/PhysicsServer.xml
index eb7c735277..8f3d77d841 100644
--- a/doc/classes/PhysicsServer.xml
+++ b/doc/classes/PhysicsServer.xml
@@ -352,7 +352,7 @@
</description>
</method>
<method name="body_get_axis_lock" qualifiers="const">
- <return type="int" enum="PhysicsServer.BodyAxisLock">
+ <return type="bool">
</return>
<argument index="0" name="body" type="RID">
</argument>
@@ -540,10 +540,11 @@
</return>
<argument index="0" name="body" type="RID">
</argument>
- <argument index="1" name="axis" type="int" enum="PhysicsServer.BodyAxisLock">
+ <argument index="1" name="axis" type="int">
+ </argument>
+ <argument index="2" name="lock" type="bool">
</argument>
<description>
- Locks velocity along one axis to 0 and only allows rotation along this axis, can also be set to disabled which disables this functionality.
</description>
</method>
<method name="body_set_axis_velocity">
@@ -1519,17 +1520,5 @@
<constant name="SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS" value="7" enum="SpaceParameter">
Constant to set/get the default solver bias for all physics constraints. A solver bias is a factor controlling how much two objects "rebound", after violating a constraint, to avoid leaving them in that state because of numerical imprecision.
</constant>
- <constant name="BODY_AXIS_LOCK_DISABLED" value="0" enum="BodyAxisLock">
- The [Body] can rotate and move freely.
- </constant>
- <constant name="BODY_AXIS_LOCK_X" value="1" enum="BodyAxisLock">
- The [Body] cannot move across x axis can only rotate across x axis.
- </constant>
- <constant name="BODY_AXIS_LOCK_Y" value="2" enum="BodyAxisLock">
- The [Body] cannot move across y axis can only rotate across y axis.
- </constant>
- <constant name="BODY_AXIS_LOCK_Z" value="3" enum="BodyAxisLock">
- The [Body] cannot move across z axis can only rotate across z axis.
- </constant>
</constants>
</class>
diff --git a/doc/classes/Rect2.xml b/doc/classes/Rect2.xml
index 1bd2e812e6..4fc9e5bd71 100644
--- a/doc/classes/Rect2.xml
+++ b/doc/classes/Rect2.xml
@@ -37,6 +37,12 @@
Constructs a [code]Rect2[/code] by x, y, width, and height.
</description>
</method>
+ <method name="abs">
+ <return type="Rect2">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="clip">
<return type="Rect2">
</return>
diff --git a/doc/classes/RigidBody.xml b/doc/classes/RigidBody.xml
index cfcd0258e7..77e27cefcc 100644
--- a/doc/classes/RigidBody.xml
+++ b/doc/classes/RigidBody.xml
@@ -59,8 +59,11 @@
<member name="angular_velocity" type="Vector3" setter="set_angular_velocity" getter="get_angular_velocity">
RigidBody's rotational velocity.
</member>
- <member name="axis_lock" type="int" setter="set_axis_lock" getter="get_axis_lock" enum="RigidBody.AxisLock">
- Locks the rotational forces to a particular axis, preventing rotations on other axes.
+ <member name="axis_lock_x" type="bool" setter="set_axis_lock_x" getter="get_axis_lock_x">
+ </member>
+ <member name="axis_lock_y" type="bool" setter="set_axis_lock_y" getter="get_axis_lock_y">
+ </member>
+ <member name="axis_lock_z" type="bool" setter="set_axis_lock_z" getter="get_axis_lock_z">
</member>
<member name="bounce" type="float" setter="set_bounce" getter="get_bounce">
RigidBody's bounciness.
@@ -168,13 +171,5 @@
<constant name="MODE_KINEMATIC" value="3" enum="Mode">
Kinematic body. The body behaves like a [KinematicBody], and can only move by user code.
</constant>
- <constant name="AXIS_LOCK_DISABLED" value="0" enum="AxisLock">
- </constant>
- <constant name="AXIS_LOCK_X" value="1" enum="AxisLock">
- </constant>
- <constant name="AXIS_LOCK_Y" value="2" enum="AxisLock">
- </constant>
- <constant name="AXIS_LOCK_Z" value="3" enum="AxisLock">
- </constant>
</constants>
</class>
diff --git a/doc/classes/SurfaceTool.xml b/doc/classes/SurfaceTool.xml
index 22099a930c..0916d0b928 100644
--- a/doc/classes/SurfaceTool.xml
+++ b/doc/classes/SurfaceTool.xml
@@ -170,6 +170,8 @@
</return>
<argument index="0" name="existing" type="ArrayMesh" default="null">
</argument>
+ <argument index="1" name="flags" type="int" default="97792">
+ </argument>
<description>
Returns a constructed [ArrayMesh] from current information passed in. If an existing [ArrayMesh] is passed in as an argument, will add an extra surface to the existing [ArrayMesh].
</description>
diff --git a/doc/classes/TextEdit.xml b/doc/classes/TextEdit.xml
index df48ba3e23..da30c4c7bd 100644
--- a/doc/classes/TextEdit.xml
+++ b/doc/classes/TextEdit.xml
@@ -305,6 +305,15 @@
Enable text wrapping when it goes beyond he edge of what is visible.
</description>
</method>
+ <method name="toggle_fold_line">
+ <return type="void">
+ </return>
+ <argument index="0" name="line" type="int">
+ </argument>
+ <description>
+ Toggle the folding of the code block at the given line.
+ </description>
+ </method>
<method name="undo">
<return type="void">
</return>
@@ -428,6 +437,8 @@
</theme_item>
<theme_item name="caret_color" type="Color">
</theme_item>
+ <theme_item name="code_folding_color" type="Color">
+ </theme_item>
<theme_item name="completion" type="StyleBox">
</theme_item>
<theme_item name="completion_background_color" type="Color">
diff --git a/doc/classes/Texture.xml b/doc/classes/Texture.xml
index 52972177bf..bf27bc4768 100644
--- a/doc/classes/Texture.xml
+++ b/doc/classes/Texture.xml
@@ -133,7 +133,7 @@
More effective on planes often shown going to the horrizon as those textures (Walls or Ground for example) get squashed in the viewport to different aspect ratios and regular mipmaps keep the aspect ratio so they don't optimize storage that well in those cases.
</constant>
<constant name="FLAG_CONVERT_TO_LINEAR" value="16" enum="Flags">
- Converts texture to SRGB color space.
+ Converts texture to SRGB color space.
</constant>
<constant name="FLAG_MIRRORED_REPEAT" value="32" enum="Flags">
Repeats texture with alternate sections mirrored.
diff --git a/doc/classes/VisualServer.xml b/doc/classes/VisualServer.xml
index 6627ba15d5..1a9dc3a669 100644
--- a/doc/classes/VisualServer.xml
+++ b/doc/classes/VisualServer.xml
@@ -647,7 +647,7 @@
<argument index="1" name="height" type="float">
</argument>
<description>
- Sets a canvas light's height.
+ Sets a canvas light's height.
</description>
</method>
<method name="canvas_light_set_item_cull_mask">
@@ -1495,7 +1495,7 @@
<return type="Array">
</return>
<description>
- Returns a list of all the textures and their information.
+ Returns a list of all the textures and their information.
</description>
</method>
<method name="texture_get_data" qualifiers="const">
@@ -2022,7 +2022,7 @@
More effective on planes often shown going to the horrizon as those textures (Walls or Ground for example) get squashed in the viewport to different aspect ratios and regular mipmaps keep the aspect ratio so they don't optimize storage that well in those cases.
</constant>
<constant name="TEXTURE_FLAG_CONVERT_TO_LINEAR" value="16" enum="TextureFlags">
- Converts texture to SRGB color space.
+ Converts texture to SRGB color space.
</constant>
<constant name="TEXTURE_FLAG_MIRRORED_REPEAT" value="32" enum="TextureFlags">
Repeat texture with alternate sections mirrored.
@@ -2397,4 +2397,4 @@
<constant name="FEATURE_MULTITHREADED" value="1" enum="Features">
</constant>
</constants>
-</class> \ No newline at end of file
+</class>
diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp
index 05381da9b9..21102e8c25 100644
--- a/drivers/gles3/shader_compiler_gles3.cpp
+++ b/drivers/gles3/shader_compiler_gles3.cpp
@@ -230,7 +230,6 @@ void ShaderCompilerGLES3::_dump_function_deps(SL::ShaderNode *p_node, const Stri
for (Set<StringName>::Element *E = p_node->functions[fidx].uses_function.front(); E; E = E->next()) {
- print_line(String(p_node->functions[fidx].name) + " uses function: " + String(E->get()));
if (added.has(E->get())) {
continue; //was added already
}
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 8f427582ae..676b168371 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -202,8 +202,9 @@ class EditorHelpSearch::IncrementalSearch : public Reference {
}
public:
- IncrementalSearch(EditorHelpSearch *p_search, Tree *p_search_options, const String &p_term)
- : search(p_search), search_options(p_search_options) {
+ IncrementalSearch(EditorHelpSearch *p_search, Tree *p_search_options, const String &p_term) :
+ search(p_search),
+ search_options(p_search_options) {
def_icon = search->get_icon("Node", "EditorIcons");
doc = EditorHelp::get_doc_data();
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 0252358a27..908bc468a0 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -3366,7 +3366,6 @@ void EditorNode::register_editor_types() {
ClassDB::register_class<EditorResourceConversionPlugin>();
ClassDB::register_class<EditorSceneImporter>();
-
// FIXME: Is this stuff obsolete, or should it be ported to new APIs?
ClassDB::register_class<EditorScenePostImport>();
//ClassDB::register_type<EditorImportExport>();
diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h
index 89a6d3d250..f45d1c1ecc 100644
--- a/editor/editor_plugin.h
+++ b/editor/editor_plugin.h
@@ -31,11 +31,11 @@
#define EDITOR_PLUGIN_H
#include "editor/import/editor_import_plugin.h"
+#include "editor/import/resource_importer_scene.h"
#include "io/config_file.h"
#include "scene/gui/tool_button.h"
#include "scene/main/node.h"
#include "scene/resources/texture.h"
-#include "editor/import/resource_importer_scene.h"
#include "undo_redo.h"
/**
diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp
index c38391c71b..c4315f1b83 100644
--- a/editor/import/editor_import_collada.cpp
+++ b/editor/import/editor_import_collada.cpp
@@ -1979,7 +1979,7 @@ Node *EditorSceneImporterCollada::import_scene(const String &p_path, uint32_t p_
return state.scene;
}
-Ref<Animation> EditorSceneImporterCollada::import_animation(const String &p_path, uint32_t p_flags,int p_bake_fps) {
+Ref<Animation> EditorSceneImporterCollada::import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) {
ColladaImport state;
diff --git a/editor/import/editor_import_collada.h b/editor/import/editor_import_collada.h
index 986b5b766f..904080c19b 100644
--- a/editor/import/editor_import_collada.h
+++ b/editor/import/editor_import_collada.h
@@ -40,7 +40,7 @@ public:
virtual uint32_t get_import_flags() const;
virtual void get_extensions(List<String> *r_extensions) const;
virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps = NULL, Error *r_err = NULL);
- virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags,int p_bake_fps);
+ virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps);
EditorSceneImporterCollada();
};
diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp
index e801f3e7c3..00eb69a568 100644
--- a/editor/import/editor_scene_importer_gltf.cpp
+++ b/editor/import/editor_scene_importer_gltf.cpp
@@ -1597,8 +1597,11 @@ void EditorSceneImporterGLTF::_generate_node(GLTFState &state, int p_node, Node
if (n->mesh >= 0) {
ERR_FAIL_INDEX(n->mesh, state.meshes.size());
MeshInstance *mi = memnew(MeshInstance);
- const GLTFMesh &mesh = state.meshes[n->mesh];
+ GLTFMesh &mesh = state.meshes[n->mesh];
mi->set_mesh(mesh.mesh);
+ if (mesh.mesh->get_name() == "") {
+ mesh.mesh->set_name(n->name);
+ }
for (int i = 0; i < mesh.blend_weights.size(); i++) {
mi->set("blend_shapes/" + mesh.mesh->get_blend_shape_name(i), mesh.blend_weights[i]);
}
diff --git a/editor/import/editor_scene_importer_gltf.h b/editor/import/editor_scene_importer_gltf.h
index 0c8000427e..91c584a05a 100644
--- a/editor/import/editor_scene_importer_gltf.h
+++ b/editor/import/editor_scene_importer_gltf.h
@@ -296,7 +296,7 @@ public:
virtual uint32_t get_import_flags() const;
virtual void get_extensions(List<String> *r_extensions) const;
virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps = NULL, Error *r_err = NULL);
- virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags,int p_bake_fps);
+ virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps);
EditorSceneImporterGLTF();
};
diff --git a/editor/import/resource_importer_obj.h b/editor/import/resource_importer_obj.h
index 09dc8ac8a1..e66ea47b69 100644
--- a/editor/import/resource_importer_obj.h
+++ b/editor/import/resource_importer_obj.h
@@ -40,7 +40,7 @@ public:
virtual uint32_t get_import_flags() const;
virtual void get_extensions(List<String> *r_extensions) const;
virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = NULL);
- virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags,int p_bake_fps);
+ virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps);
EditorOBJImporter();
};
diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp
index eee54f3cd2..3ab8f318a7 100644
--- a/editor/plugins/asset_library_editor_plugin.cpp
+++ b/editor/plugins/asset_library_editor_plugin.cpp
@@ -915,6 +915,11 @@ void EditorAssetLibrary::_search(int p_page) {
_api_request("asset", REQUESTING_SEARCH, args);
}
+void EditorAssetLibrary::_search_text_entered(const String &p_text) {
+
+ _search();
+}
+
HBoxContainer *EditorAssetLibrary::_make_pages(int p_page, int p_page_count, int p_page_len, int p_total_items, int p_current_items) {
HBoxContainer *hbc = memnew(HBoxContainer);
@@ -1280,6 +1285,7 @@ void EditorAssetLibrary::_bind_methods() {
ClassDB::bind_method("_select_category", &EditorAssetLibrary::_select_category);
ClassDB::bind_method("_image_request_completed", &EditorAssetLibrary::_image_request_completed);
ClassDB::bind_method("_search", &EditorAssetLibrary::_search, DEFVAL(0));
+ ClassDB::bind_method("_search_text_entered", &EditorAssetLibrary::_search_text_entered);
ClassDB::bind_method("_install_asset", &EditorAssetLibrary::_install_asset);
ClassDB::bind_method("_manage_plugins", &EditorAssetLibrary::_manage_plugins);
ClassDB::bind_method("_asset_open", &EditorAssetLibrary::_asset_open);
@@ -1309,7 +1315,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
filter = memnew(LineEdit);
search_hb->add_child(filter);
filter->set_h_size_flags(SIZE_EXPAND_FILL);
- filter->connect("text_entered", this, "_search");
+ filter->connect("text_entered", this, "_search_text_entered");
search = memnew(Button(TTR("Search")));
search->connect("pressed", this, "_search");
search_hb->add_child(search);
diff --git a/editor/plugins/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h
index 90d597e70a..5536fbb2ec 100644
--- a/editor/plugins/asset_library_editor_plugin.h
+++ b/editor/plugins/asset_library_editor_plugin.h
@@ -284,6 +284,7 @@ class EditorAssetLibrary : public PanelContainer {
void _search(int p_page = 0);
void _rerun_search(int p_ignore);
+ void _search_text_entered(const String &p_text = "");
void _api_request(const String &p_request, RequestType p_request_type, const String &p_arguments = "");
void _http_request_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data);
void _http_download_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data);
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index e63bc3ad9f..150c184e90 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -4344,7 +4344,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
additive_selection = false;
// Update the menus checkboxes
- set_state(get_state());
+ call_deferred("set_state", get_state());
}
CanvasItemEditor *CanvasItemEditor::singleton = NULL;
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index eb2faa1ab1..b8c57fd959 100644
--- a/editor/plugins/tile_set_editor_plugin.cpp
+++ b/editor/plugins/tile_set_editor_plugin.cpp
@@ -343,7 +343,7 @@ AutotileEditor::AutotileEditor(EditorNode *p_editor) {
split->add_child(property_editor);
helper = memnew(AutotileEditorHelper(this));
- property_editor->edit(helper);
+ property_editor->call_deferred("edit", helper);
// Editor
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index 446a0ea35d..14e3b7cfb7 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -647,7 +647,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
}
}
- if (type)
+ if (type != Variant::NIL)
property_select->select_property_from_basic_type(type, v);
updating = false;
@@ -2802,13 +2802,12 @@ void PropertyEditor::update_tree() {
TreeItem *sep = tree->create_item(root);
current_category = sep;
String type = p.name;
- //*
+
if (has_icon(type, "EditorIcons"))
sep->set_icon(0, get_icon(type, "EditorIcons"));
else
sep->set_icon(0, get_icon("Object", "EditorIcons"));
- //*/
sep->set_text(0, type);
sep->set_expand_right(0, true);
sep->set_selectable(0, false);
@@ -2934,38 +2933,36 @@ void PropertyEditor::update_tree() {
}
if (use_doc_hints) {
- StringName setter;
- StringName type;
- if (ClassDB::get_setter_and_type_for_property(obj->get_class_name(), p.name, type, setter)) {
- String descr;
- bool found = false;
- Map<StringName, Map<StringName, String> >::Element *E = descr_cache.find(type);
- if (E) {
+ StringName classname = obj->get_class_name();
+ StringName propname = p.name;
+ String descr;
+ bool found = false;
- Map<StringName, String>::Element *F = E->get().find(setter);
- if (F) {
- found = true;
- descr = F->get();
- }
+ Map<StringName, Map<StringName, String> >::Element *E = descr_cache.find(classname);
+ if (E) {
+ Map<StringName, String>::Element *F = E->get().find(propname);
+ if (F) {
+ found = true;
+ descr = F->get();
}
- if (!found) {
+ }
- DocData *dd = EditorHelp::get_doc_data();
- Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(type);
- if (E) {
- for (int i = 0; i < E->get().methods.size(); i++) {
- if (E->get().methods[i].name == setter.operator String()) {
- descr = E->get().methods[i].description.strip_edges().word_wrap(80);
- }
+ if (!found) {
+ DocData *dd = EditorHelp::get_doc_data();
+ Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(classname);
+ if (E) {
+ for (int i = 0; i < E->get().properties.size(); i++) {
+ if (E->get().properties[i].name == propname.operator String()) {
+ descr = E->get().properties[i].description.strip_edges().word_wrap(80);
}
}
-
- descr_cache[type][setter] = descr;
}
- item->set_tooltip(0, TTR("Property:") + " " + p.name + "\n\n" + descr);
+ descr_cache[classname][propname] = descr;
}
+
+ item->set_tooltip(0, TTR("Property:") + " " + p.name + "\n\n" + descr);
}
Dictionary d;
@@ -4365,7 +4362,7 @@ class SectionedPropertyEditorFilter : public Object {
PropertyInfo pi = E->get();
int sp = pi.name.find("/");
- if (pi.name == "resource_path" || pi.name == "resource_name" || pi.name.begins_with("script/")) //skip resource stuff
+ if (pi.name == "resource_path" || pi.name == "resource_name" || pi.name == "resource_local_to_scene" || pi.name.begins_with("script/")) //skip resource stuff
continue;
if (sp == -1) {
@@ -4515,7 +4512,7 @@ void SectionedPropertyEditor::update_category_list() {
else if (!(pi.usage & PROPERTY_USAGE_EDITOR))
continue;
- if (pi.name.find(":") != -1 || pi.name == "script" || pi.name == "resource_name" || pi.name == "resource_path")
+ if (pi.name.find(":") != -1 || pi.name == "script" || pi.name == "resource_name" || pi.name == "resource_path" || pi.name == "resource_local_to_scene")
continue;
if (search_box && search_box->get_text() != String() && pi.name.findn(search_box->get_text()) == -1)
diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp
index 86de7c56e1..77b73e4635 100644
--- a/editor/property_selector.cpp
+++ b/editor/property_selector.cpp
@@ -363,23 +363,6 @@ void PropertySelector::_item_selected() {
at_class = ClassDB::get_parent_class(at_class);
}
-
- if (text == String()) {
-
- StringName setter;
- StringName type;
- if (ClassDB::get_setter_and_type_for_property(class_type, name, type, setter)) {
- Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(type);
- if (E) {
- for (int i = 0; i < E->get().methods.size(); i++) {
- if (E->get().methods[i].name == setter.operator String()) {
- text = E->get().methods[i].description;
- }
- }
- }
- }
- }
-
} else {
String at_class = class_type;
@@ -516,6 +499,7 @@ void PropertySelector::select_property_from_script(const Ref<Script> &p_script,
search_box->grab_focus();
_update_search();
}
+
void PropertySelector::select_property_from_basic_type(Variant::Type p_type, const String &p_current) {
ERR_FAIL_COND(p_type == Variant::NIL);
diff --git a/misc/hooks/pre-commit-clang-format b/misc/hooks/pre-commit-clang-format
index d2d65a7428..8ef4e27748 100755
--- a/misc/hooks/pre-commit-clang-format
+++ b/misc/hooks/pre-commit-clang-format
@@ -31,7 +31,7 @@ PARSE_EXTS=true
# File types to parse. Only effective when PARSE_EXTS is true.
# FILE_EXTS=".c .h .cpp .hpp"
-FILE_EXTS=".c .h .cpp .hpp .cc .hh .cxx .m .mm .inc"
+FILE_EXTS=".c .h .cpp .hpp .cc .hh .cxx .m .mm .inc *.java"
# Use pygmentize instead of cat to parse diff with highlighting.
# Install it with `pip install pygments` (Linux) or `easy_install Pygments` (Mac)
diff --git a/misc/travis/clang-format.sh b/misc/travis/clang-format.sh
index 2b30cf5ada..d1e37cc10e 100755
--- a/misc/travis/clang-format.sh
+++ b/misc/travis/clang-format.sh
@@ -11,7 +11,7 @@ else
RANGE=HEAD
fi
-FILES=$(git diff-tree --no-commit-id --name-only -r $RANGE | grep -v thirdparty/ | grep -E "\.(c|h|cpp|hpp|cc|hh|cxx|m|mm|inc)$")
+FILES=$(git diff-tree --no-commit-id --name-only -r $RANGE | grep -v thirdparty/ | grep -E "\.(c|h|cpp|hpp|cc|hh|cxx|m|mm|inc|java)$")
echo "Checking files:\n$FILES"
# create a random filename to store our generated patch
diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp
index 365def75bc..1cb35ec006 100644
--- a/modules/gdnative/register_types.cpp
+++ b/modules/gdnative/register_types.cpp
@@ -99,12 +99,16 @@ static Set<String> get_gdnative_singletons(EditorFileSystemDirectory *p_dir) {
}
static void actual_discoverer_handler() {
+
EditorFileSystemDirectory *dir = EditorFileSystem::get_singleton()->get_filesystem();
Set<String> file_paths = get_gdnative_singletons(dir);
bool changed = false;
- Array current_files = ProjectSettings::get_singleton()->get("gdnative/singletons");
+ Array current_files;
+ if (ProjectSettings::get_singleton()->has_setting("gdnative/singletons")) {
+ current_files = ProjectSettings::get_singleton()->get("gdnative/singletons");
+ }
Array files;
files.resize(file_paths.size());
int i = 0;
@@ -128,7 +132,6 @@ static void actual_discoverer_handler() {
if (changed) {
ProjectSettings::get_singleton()->set("gdnative/singletons", files);
-
ProjectSettings::get_singleton()->save();
}
}
diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp
index d2ce318f82..ee23f0ea0f 100644
--- a/modules/gdscript/gdscript_function.cpp
+++ b/modules/gdscript/gdscript_function.cpp
@@ -515,7 +515,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
} else {
v = "of type '" + _get_var_type(index) + "'";
}
- err_text = "Invalid set index " + v + " (on base: '" + _get_var_type(dst) + "') with value of type '"+_get_var_type(value)+"'";
+ err_text = "Invalid set index " + v + " (on base: '" + _get_var_type(dst) + "') with value of type '" + _get_var_type(value) + "'";
OPCODE_BREAK;
}
#endif
@@ -574,7 +574,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
#ifdef DEBUG_ENABLED
if (!valid) {
String err_type;
- err_text = "Invalid set index '" + String(*index) + "' (on base: '" + _get_var_type(dst) + "') with value of type '"+_get_var_type(value)+"'.";
+ err_text = "Invalid set index '" + String(*index) + "' (on base: '" + _get_var_type(dst) + "') with value of type '" + _get_var_type(value) + "'.";
OPCODE_BREAK;
}
#endif
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp
index 67e00f4952..255413bf2c 100644
--- a/platform/android/export/export.cpp
+++ b/platform/android/export/export.cpp
@@ -1557,12 +1557,15 @@ public:
encode_uint32(cl.size(), &clf[0]);
for (int i = 0; i < cl.size(); i++) {
+ print_line(itos(i) + " param: " + cl[i]);
CharString txt = cl[i].utf8();
int base = clf.size();
- clf.resize(base + 4 + txt.length());
- encode_uint32(txt.length(), &clf[base]);
- copymem(&clf[base + 4], txt.ptr(), txt.length());
- print_line(itos(i) + " param: " + cl[i]);
+ int length = txt.length();
+ if (!length)
+ continue;
+ clf.resize(base + 4 + length);
+ encode_uint32(length, &clf[base]);
+ copymem(&clf[base + 4], txt.ptr(), length);
}
zip_fileinfo zipfi = get_zip_fileinfo();
diff --git a/platform/android/java/src/org/godotengine/godot/Dictionary.java b/platform/android/java/src/org/godotengine/godot/Dictionary.java
index ed91fedd85..2bc9c083aa 100644
--- a/platform/android/java/src/org/godotengine/godot/Dictionary.java
+++ b/platform/android/java/src/org/godotengine/godot/Dictionary.java
@@ -32,7 +32,6 @@ package org.godotengine.godot;
import java.util.HashMap;
import java.util.Set;
-
public class Dictionary extends HashMap<String, Object> {
protected String[] keys_cache;
@@ -40,7 +39,7 @@ public class Dictionary extends HashMap<String, Object> {
public String[] get_keys() {
String[] ret = new String[size()];
- int i=0;
+ int i = 0;
Set<String> keys = keySet();
for (String key : keys) {
@@ -54,7 +53,7 @@ public class Dictionary extends HashMap<String, Object> {
public Object[] get_values() {
Object[] ret = new Object[size()];
- int i=0;
+ int i = 0;
Set<String> keys = keySet();
for (String key : keys) {
@@ -71,7 +70,7 @@ public class Dictionary extends HashMap<String, Object> {
public void set_values(Object[] vals) {
- int i=0;
+ int i = 0;
for (String key : keys_cache) {
put(key, vals[i]);
i++;
diff --git a/platform/android/java/src/org/godotengine/godot/Godot.java b/platform/android/java/src/org/godotengine/godot/Godot.java
index 4daf06142d..3939ceb2e7 100644
--- a/platform/android/java/src/org/godotengine/godot/Godot.java
+++ b/platform/android/java/src/org/godotengine/godot/Godot.java
@@ -90,35 +90,34 @@ import android.os.Bundle;
import android.os.Messenger;
import android.os.SystemClock;
-
-public class Godot extends Activity implements SensorEventListener, IDownloaderClient
-{
+public class Godot extends Activity implements SensorEventListener, IDownloaderClient {
static final int MAX_SINGLETONS = 64;
private IStub mDownloaderClientStub;
- private IDownloaderService mRemoteService;
- private TextView mStatusText;
- private TextView mProgressFraction;
- private TextView mProgressPercent;
- private TextView mAverageSpeed;
- private TextView mTimeRemaining;
- private ProgressBar mPB;
-
- private View mDashboard;
- private View mCellMessage;
-
- private Button mPauseButton;
- private Button mWiFiSettingsButton;
-
- private boolean use_32_bits=false;
- private boolean use_immersive=false;
- private boolean mStatePaused;
- private int mState;
- private boolean keep_screen_on=true;
+ private IDownloaderService mRemoteService;
+ private TextView mStatusText;
+ private TextView mProgressFraction;
+ private TextView mProgressPercent;
+ private TextView mAverageSpeed;
+ private TextView mTimeRemaining;
+ private ProgressBar mPB;
+
+ private View mDashboard;
+ private View mCellMessage;
+
+ private Button mPauseButton;
+ private Button mWiFiSettingsButton;
+
+ private boolean use_32_bits = false;
+ private boolean use_immersive = false;
+ private boolean mStatePaused;
+ private int mState;
+ private boolean keep_screen_on = true;
static private Intent mCurrentIntent;
- @Override public void onNewIntent(Intent intent) {
+ @Override
+ public void onNewIntent(Intent intent) {
mCurrentIntent = intent;
}
@@ -127,43 +126,43 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
}
private void setState(int newState) {
- if (mState != newState) {
- mState = newState;
- mStatusText.setText(Helpers.getDownloaderStringResourceIDFromState(newState));
- }
- }
-
- private void setButtonPausedState(boolean paused) {
- mStatePaused = paused;
- int stringResourceID = paused ? com.godot.game.R.string.text_button_resume :
- com.godot.game.R.string.text_button_pause;
- mPauseButton.setText(stringResourceID);
- }
+ if (mState != newState) {
+ mState = newState;
+ mStatusText.setText(Helpers.getDownloaderStringResourceIDFromState(newState));
+ }
+ }
+
+ private void setButtonPausedState(boolean paused) {
+ mStatePaused = paused;
+ int stringResourceID = paused ? com.godot.game.R.string.text_button_resume :
+ com.godot.game.R.string.text_button_pause;
+ mPauseButton.setText(stringResourceID);
+ }
static public class SingletonBase {
protected void registerClass(String p_name, String[] p_methods) {
- GodotLib.singleton(p_name,this);
+ GodotLib.singleton(p_name, this);
Class clazz = getClass();
Method[] methods = clazz.getDeclaredMethods();
for (Method method : methods) {
- boolean found=false;
- Log.d("XXX","METHOD: %s\n" + method.getName());
+ boolean found = false;
+ Log.d("XXX", "METHOD: %s\n" + method.getName());
for (String s : p_methods) {
- Log.d("XXX", "METHOD CMP WITH: %s\n" + s);
+ Log.d("XXX", "METHOD CMP WITH: %s\n" + s);
if (s.equals(method.getName())) {
- found=true;
- Log.d("XXX","METHOD CMP VALID");
+ found = true;
+ Log.d("XXX", "METHOD CMP VALID");
break;
}
}
if (!found)
continue;
- Log.d("XXX","METHOD FOUND: %s\n" + method.getName());
+ Log.d("XXX", "METHOD FOUND: %s\n" + method.getName());
List<String> ptr = new ArrayList<String>();
@@ -175,17 +174,13 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
String[] pt = new String[ptr.size()];
ptr.toArray(pt);
- GodotLib.method(p_name,method.getName(),method.getReturnType().getName(),pt);
-
-
+ GodotLib.method(p_name, method.getName(), method.getReturnType().getName(), pt);
}
- Godot.singletons[Godot.singleton_count++]=this;
+ Godot.singletons[Godot.singleton_count++] = this;
}
protected void onMainActivityResult(int requestCode, int resultCode, Intent data) {
-
-
}
protected void onMainPause() {}
@@ -200,22 +195,20 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
public void registerMethods() {}
}
-/*
+ /*
protected List<SingletonBase> singletons = new ArrayList<SingletonBase>();
protected void instanceSingleton(SingletonBase s) {
s.registerMethods();
singletons.add(s);
}
-
-*/
+ */
private String[] command_line;
private boolean use_apk_expansion;
public GodotView mView;
- private boolean godot_initialized=false;
-
+ private boolean godot_initialized = false;
private SensorManager mSensorManager;
private Sensor mAccelerometer;
@@ -226,36 +219,34 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
public FrameLayout layout;
public RelativeLayout adLayout;
-
static public GodotIO io;
public static void setWindowTitle(String title) {
//setTitle(title);
}
-
static SingletonBase singletons[] = new SingletonBase[MAX_SINGLETONS];
- static int singleton_count=0;
-
+ static int singleton_count = 0;
public interface ResultCallback {
public void callback(int requestCode, int resultCode, Intent data);
- };
+ }
public ResultCallback result_callback;
private PaymentsManager mPaymentsManager = null;
- @Override protected void onActivityResult (int requestCode, int resultCode, Intent data) {
- if(requestCode == PaymentsManager.REQUEST_CODE_FOR_PURCHASE){
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (requestCode == PaymentsManager.REQUEST_CODE_FOR_PURCHASE) {
mPaymentsManager.processPurchaseResponse(resultCode, data);
- }else if (result_callback != null) {
+ } else if (result_callback != null) {
result_callback.callback(requestCode, resultCode, data);
result_callback = null;
};
- for(int i=0;i<singleton_count;i++) {
+ for (int i = 0; i < singleton_count; i++) {
- singletons[i].onMainActivityResult(requestCode,resultCode,data);
+ singletons[i].onMainActivityResult(requestCode, resultCode, data);
}
};
@@ -265,38 +256,38 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
//setContentView(mView);
layout = new FrameLayout(this);
- layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
+ layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
setContentView(layout);
// GodotEditText layout
GodotEditText edittext = new GodotEditText(this);
- edittext.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
- // ...add to FrameLayout
- layout.addView(edittext);
+ edittext.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
+ // ...add to FrameLayout
+ layout.addView(edittext);
- mView = new GodotView(getApplication(),io,use_gl2,use_32_bits, this);
- layout.addView(mView,new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
+ mView = new GodotView(getApplication(), io, use_gl2, use_32_bits, this);
+ layout.addView(mView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
edittext.setView(mView);
io.setEdit(edittext);
final Godot godot = this;
mView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
- @Override
- public void onGlobalLayout() {
- Point fullSize = new Point();
- godot.getWindowManager().getDefaultDisplay().getSize(fullSize);
- Rect gameSize = new Rect();
- godot.mView.getWindowVisibleDisplayFrame(gameSize);
-
- final int keyboardHeight = fullSize.y - gameSize.bottom;
- Log.d("GODOT", "setVirtualKeyboardHeight: " + keyboardHeight);
- GodotLib.setVirtualKeyboardHeight(keyboardHeight);
- }
+ @Override
+ public void onGlobalLayout() {
+ Point fullSize = new Point();
+ godot.getWindowManager().getDefaultDisplay().getSize(fullSize);
+ Rect gameSize = new Rect();
+ godot.mView.getWindowVisibleDisplayFrame(gameSize);
+
+ final int keyboardHeight = fullSize.y - gameSize.bottom;
+ Log.d("GODOT", "setVirtualKeyboardHeight: " + keyboardHeight);
+ GodotLib.setVirtualKeyboardHeight(keyboardHeight);
+ }
});
// Ad layout
adLayout = new RelativeLayout(this);
- adLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
+ adLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
layout.addView(adLayout);
final String[] current_command_line = command_line;
@@ -313,12 +304,11 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
});
}
});
-
}
public void setKeepScreenOn(final boolean p_enabled) {
keep_screen_on = p_enabled;
- if (mView != null){
+ if (mView != null) {
runOnUiThread(new Runnable() {
@Override
public void run() {
@@ -335,12 +325,12 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
AlertDialog.Builder builder = new AlertDialog.Builder(getInstance());
builder.setMessage(message).setTitle(title);
builder.setPositiveButton(
- "OK",
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- dialog.cancel();
- }
- });
+ "OK",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ dialog.cancel();
+ }
+ });
AlertDialog dialog = builder.create();
dialog.show();
}
@@ -349,91 +339,86 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
private static Godot _self;
- public static Godot getInstance(){
+ public static Godot getInstance() {
return Godot._self;
}
-
private String[] getCommandLine() {
- InputStream is;
- try {
- is = getAssets().open("_cl_");
- byte[] len = new byte[4];
- int r = is.read(len);
- if (r<4) {
- Log.d("XXX","**ERROR** Wrong cmdline length.\n");
- Log.d("GODOT", "**ERROR** Wrong cmdline length.\n");
- return new String[0];
- }
- int argc=((int)(len[3]&0xFF)<<24) | ((int)(len[2]&0xFF)<<16) | ((int)(len[1]&0xFF)<<8) | ((int)(len[0]&0xFF));
- String[] cmdline = new String[argc];
-
- for(int i=0;i<argc;i++) {
- r = is.read(len);
- if (r<4) {
-
- Log.d("GODOT", "**ERROR** Wrong cmdline param length.\n");
- return new String[0];
- }
- int strlen=((int)(len[3]&0xFF)<<24) | ((int)(len[2]&0xFF)<<16) | ((int)(len[1]&0xFF)<<8) | ((int)(len[0]&0xFF));
- if (strlen>65535) {
- Log.d("GODOT", "**ERROR** Wrong command len\n");
- return new String[0];
- }
- byte[] arg = new byte[strlen];
- r = is.read(arg);
- if (r==strlen) {
- cmdline[i]=new String(arg,"UTF-8");
- }
+ InputStream is;
+ try {
+ is = getAssets().open("_cl_");
+ byte[] len = new byte[4];
+ int r = is.read(len);
+ if (r < 4) {
+ Log.d("XXX", "**ERROR** Wrong cmdline length.\n");
+ Log.d("GODOT", "**ERROR** Wrong cmdline length.\n");
+ return new String[0];
+ }
+ int argc = ((int)(len[3] & 0xFF) << 24) | ((int)(len[2] & 0xFF) << 16) | ((int)(len[1] & 0xFF) << 8) | ((int)(len[0] & 0xFF));
+ String[] cmdline = new String[argc];
+
+ for (int i = 0; i < argc; i++) {
+ r = is.read(len);
+ if (r < 4) {
+
+ Log.d("GODOT", "**ERROR** Wrong cmdline param length.\n");
+ return new String[0];
+ }
+ int strlen = ((int)(len[3] & 0xFF) << 24) | ((int)(len[2] & 0xFF) << 16) | ((int)(len[1] & 0xFF) << 8) | ((int)(len[0] & 0xFF));
+ if (strlen > 65535) {
+ Log.d("GODOT", "**ERROR** Wrong command len\n");
+ return new String[0];
+ }
+ byte[] arg = new byte[strlen];
+ r = is.read(arg);
+ if (r == strlen) {
+ cmdline[i] = new String(arg, "UTF-8");
+ }
}
return cmdline;
} catch (Exception e) {
- e.printStackTrace();
- Log.d("GODOT", "**ERROR** Exception " + e.getClass().getName() + ":" + e.getMessage());
+ e.printStackTrace();
+ Log.d("GODOT", "**ERROR** Exception " + e.getClass().getName() + ":" + e.getMessage());
return new String[0];
}
-
-
}
-
String expansion_pack_path;
-
private void initializeGodot() {
- if (expansion_pack_path!=null) {
+ if (expansion_pack_path != null) {
String[] new_cmdline;
- int cll=0;
- if (command_line!=null) {
- Log.d("GODOT", "initializeGodot: command_line: is not null" );
- new_cmdline = new String[ command_line.length + 2 ];
- cll=command_line.length;
- for(int i=0;i<command_line.length;i++) {
- new_cmdline[i]=command_line[i];
+ int cll = 0;
+ if (command_line != null) {
+ Log.d("GODOT", "initializeGodot: command_line: is not null");
+ new_cmdline = new String[command_line.length + 2];
+ cll = command_line.length;
+ for (int i = 0; i < command_line.length; i++) {
+ new_cmdline[i] = command_line[i];
}
} else {
- Log.d("GODOT", "initializeGodot: command_line: is null" );
- new_cmdline = new String[ 2 ];
+ Log.d("GODOT", "initializeGodot: command_line: is null");
+ new_cmdline = new String[2];
}
- new_cmdline[cll]="--main_pack";
- new_cmdline[cll+1]=expansion_pack_path;
- command_line=new_cmdline;
+ new_cmdline[cll] = "--main_pack";
+ new_cmdline[cll + 1] = expansion_pack_path;
+ command_line = new_cmdline;
}
io = new GodotIO(this);
io.unique_id = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
- GodotLib.io=io;
- Log.d("GODOT", "command_line is null? " + ((command_line == null)?"yes":"no"));
+ GodotLib.io = io;
+ Log.d("GODOT", "command_line is null? " + ((command_line == null) ? "yes" : "no"));
/*if(command_line != null){
Log.d("GODOT", "Command Line:");
for(int w=0;w <command_line.length;w++){
Log.d("GODOT"," " + command_line[w]);
}
}*/
- mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
+ mSensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_GAME);
mGravity = mSensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY);
@@ -449,18 +434,15 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
mPaymentsManager = PaymentsManager.createManager(this).initService();
- godot_initialized=true;
-
+ godot_initialized = true;
}
@Override
public void onServiceConnected(Messenger m) {
- mRemoteService = DownloaderServiceMarshaller.CreateProxy(m);
- mRemoteService.onClientUpdated(mDownloaderClientStub.getMessenger());
+ mRemoteService = DownloaderServiceMarshaller.CreateProxy(m);
+ mRemoteService.onClientUpdated(mDownloaderClientStub.getMessenger());
}
-
-
@Override
protected void onCreate(Bundle icicle) {
@@ -474,59 +456,58 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
//check for apk expansion API
if (true) {
- boolean md5mismatch = false;
+ boolean md5mismatch = false;
command_line = getCommandLine();
- String main_pack_md5=null;
- String main_pack_key=null;
+ String main_pack_md5 = null;
+ String main_pack_key = null;
List<String> new_args = new LinkedList<String>();
+ for (int i = 0; i < command_line.length; i++) {
- for(int i=0;i<command_line.length;i++) {
-
- boolean has_extra = i< command_line.length -1;
+ boolean has_extra = i < command_line.length - 1;
if (command_line[i].equals("--use_depth_32")) {
- use_32_bits=true;
+ use_32_bits = true;
} else if (command_line[i].equals("--use_immersive")) {
- use_immersive=true;
- if(Build.VERSION.SDK_INT >= 19.0){ // check if the application runs on an android 4.4+
+ use_immersive = true;
+ if (Build.VERSION.SDK_INT >= 19.0) { // check if the application runs on an android 4.4+
window.getDecorView().setSystemUiVisibility(
- View.SYSTEM_UI_FLAG_LAYOUT_STABLE
- | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
- | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
- | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
- | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
- | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
+ View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
+ View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
+ View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
+ View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | // hide nav bar
+ View.SYSTEM_UI_FLAG_FULLSCREEN | // hide status bar
+ View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
UiChangeListener();
}
} else if (command_line[i].equals("--use_apk_expansion")) {
- use_apk_expansion=true;
+ use_apk_expansion = true;
} else if (has_extra && command_line[i].equals("--apk_expansion_md5")) {
- main_pack_md5=command_line[i+1];
+ main_pack_md5 = command_line[i + 1];
i++;
} else if (has_extra && command_line[i].equals("--apk_expansion_key")) {
- main_pack_key=command_line[i+1];
+ main_pack_key = command_line[i + 1];
SharedPreferences prefs = getSharedPreferences("app_data_keys", MODE_PRIVATE);
Editor editor = prefs.edit();
editor.putString("store_public_key", main_pack_key);
editor.commit();
i++;
- } else if (command_line[i].trim().length()!=0){
+ } else if (command_line[i].trim().length() != 0) {
new_args.add(command_line[i]);
}
}
- if (new_args.isEmpty()){
- command_line=null;
- }else{
+ if (new_args.isEmpty()) {
+ command_line = null;
+ } else {
command_line = new_args.toArray(new String[new_args.size()]);
- }
- if (use_apk_expansion && main_pack_md5!=null && main_pack_key!=null) {
+ }
+ if (use_apk_expansion && main_pack_md5 != null && main_pack_key != null) {
//check that environment is ok!
- if (!Environment.getExternalStorageState().equals( Environment.MEDIA_MOUNTED )) {
+ if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
Log.d("GODOT", "**ERROR! No media mounted!");
//show popup and die
}
@@ -534,7 +515,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
// Build the full path to the app's expansion files
try {
expansion_pack_path = Helpers.getSaveFilePath(getApplicationContext());
- expansion_pack_path+="/"+"main."+getPackageManager().getPackageInfo(getPackageName(), 0).versionCode+"."+this.getPackageName()+".obb";
+ expansion_pack_path += "/main." + getPackageManager().getPackageInfo(getPackageName(), 0).versionCode + "." + this.getPackageName() + ".obb";
} catch (Exception e) {
e.printStackTrace();
}
@@ -542,20 +523,20 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
File f = new File(expansion_pack_path);
boolean pack_valid = true;
- Log.d("GODOT","**PACK** - Path "+expansion_pack_path);
+ Log.d("GODOT", "**PACK** - Path " + expansion_pack_path);
if (!f.exists()) {
- pack_valid=false;
- Log.d("GODOT","**PACK** - File does not exist");
+ pack_valid = false;
+ Log.d("GODOT", "**PACK** - File does not exist");
- } else if( obbIsCorrupted(expansion_pack_path, main_pack_md5)){
+ } else if (obbIsCorrupted(expansion_pack_path, main_pack_md5)) {
Log.d("GODOT", "**PACK** - Expansion pack (obb) is corrupted");
pack_valid = false;
- try{
- f.delete();
- }catch(Exception e){
- Log.d("GODOT", "**PACK** - Error deleting corrupted expansion pack (obb)");
+ try {
+ f.delete();
+ } catch (Exception e) {
+ Log.d("GODOT", "**PACK** - Error deleting corrupted expansion pack (obb)");
}
}
@@ -564,12 +545,12 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
Intent notifierIntent = new Intent(this, this.getClass());
notifierIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
- Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ Intent.FLAG_ACTIVITY_CLEAR_TOP);
- PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
- notifierIntent, PendingIntent.FLAG_UPDATE_CURRENT);
+ PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
+ notifierIntent, PendingIntent.FLAG_UPDATE_CURRENT);
- int startResult;
+ int startResult;
try {
Log.d("GODOT", "INITIALIZING DOWNLOAD");
startResult = DownloaderClientMarshaller.startDownloadServiceIfRequired(
@@ -578,36 +559,34 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
GodotDownloaderService.class);
Log.d("GODOT", "DOWNLOAD SERVICE FINISHED:" + startResult);
- if (startResult != DownloaderClientMarshaller.NO_DOWNLOAD_REQUIRED) {
- Log.d("GODOT", "DOWNLOAD REQUIRED");
- // This is where you do set up to display the download
- // progress (next step)
- mDownloaderClientStub = DownloaderClientMarshaller.CreateStub(this,
- GodotDownloaderService.class);
-
- setContentView(com.godot.game.R.layout.downloading_expansion);
- mPB = (ProgressBar) findViewById(com.godot.game.R.id.progressBar);
- mStatusText = (TextView) findViewById(com.godot.game.R.id.statusText);
- mProgressFraction = (TextView) findViewById(com.godot.game.R.id.progressAsFraction);
- mProgressPercent = (TextView) findViewById(com.godot.game.R.id.progressAsPercentage);
- mAverageSpeed = (TextView) findViewById(com.godot.game.R.id.progressAverageSpeed);
- mTimeRemaining = (TextView) findViewById(com.godot.game.R.id.progressTimeRemaining);
- mDashboard = findViewById(com.godot.game.R.id.downloaderDashboard);
- mCellMessage = findViewById(com.godot.game.R.id.approveCellular);
- mPauseButton = (Button) findViewById(com.godot.game.R.id.pauseButton);
- mWiFiSettingsButton = (Button) findViewById(com.godot.game.R.id.wifiSettingsButton);
-
- return;
- } else{
- Log.d("GODOT", "NO DOWNLOAD REQUIRED");
- }
+ if (startResult != DownloaderClientMarshaller.NO_DOWNLOAD_REQUIRED) {
+ Log.d("GODOT", "DOWNLOAD REQUIRED");
+ // This is where you do set up to display the download
+ // progress (next step)
+ mDownloaderClientStub = DownloaderClientMarshaller.CreateStub(this,
+ GodotDownloaderService.class);
+
+ setContentView(com.godot.game.R.layout.downloading_expansion);
+ mPB = (ProgressBar)findViewById(com.godot.game.R.id.progressBar);
+ mStatusText = (TextView)findViewById(com.godot.game.R.id.statusText);
+ mProgressFraction = (TextView)findViewById(com.godot.game.R.id.progressAsFraction);
+ mProgressPercent = (TextView)findViewById(com.godot.game.R.id.progressAsPercentage);
+ mAverageSpeed = (TextView)findViewById(com.godot.game.R.id.progressAverageSpeed);
+ mTimeRemaining = (TextView)findViewById(com.godot.game.R.id.progressTimeRemaining);
+ mDashboard = findViewById(com.godot.game.R.id.downloaderDashboard);
+ mCellMessage = findViewById(com.godot.game.R.id.approveCellular);
+ mPauseButton = (Button)findViewById(com.godot.game.R.id.pauseButton);
+ mWiFiSettingsButton = (Button)findViewById(com.godot.game.R.id.wifiSettingsButton);
+
+ return;
+ } else {
+ Log.d("GODOT", "NO DOWNLOAD REQUIRED");
+ }
} catch (NameNotFoundException e) {
// TODO Auto-generated catch block
Log.d("GODOT", "Error downloading expansion package:" + e.getMessage());
}
-
}
-
}
}
@@ -615,28 +594,26 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
initializeGodot();
-
//instanceSingleton( new GodotFacebook(this) );
-
-
}
+ @Override
+ protected void onDestroy() {
- @Override protected void onDestroy(){
-
- if(mPaymentsManager != null ) mPaymentsManager.destroy();
- for(int i=0;i<singleton_count;i++) {
+ if (mPaymentsManager != null) mPaymentsManager.destroy();
+ for (int i = 0; i < singleton_count; i++) {
singletons[i].onMainDestroy();
}
super.onDestroy();
}
- @Override protected void onPause() {
+ @Override
+ protected void onPause() {
super.onPause();
- if (!godot_initialized){
+ if (!godot_initialized) {
if (null != mDownloaderClientStub) {
- mDownloaderClientStub.disconnect(this);
- }
+ mDownloaderClientStub.disconnect(this);
+ }
return;
}
mView.onPause();
@@ -648,17 +625,18 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
});
mSensorManager.unregisterListener(this);
- for(int i=0;i<singleton_count;i++) {
+ for (int i = 0; i < singleton_count; i++) {
singletons[i].onMainPause();
}
}
- @Override protected void onResume() {
+ @Override
+ protected void onResume() {
super.onResume();
- if (!godot_initialized){
+ if (!godot_initialized) {
if (null != mDownloaderClientStub) {
- mDownloaderClientStub.connect(this);
- }
+ mDownloaderClientStub.connect(this);
+ }
return;
}
@@ -674,59 +652,58 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
mSensorManager.registerListener(this, mMagnetometer, SensorManager.SENSOR_DELAY_GAME);
mSensorManager.registerListener(this, mGyroscope, SensorManager.SENSOR_DELAY_GAME);
- if(use_immersive && Build.VERSION.SDK_INT >= 19.0){ // check if the application runs on an android 4.4+
+ if (use_immersive && Build.VERSION.SDK_INT >= 19.0) { // check if the application runs on an android 4.4+
Window window = getWindow();
window.getDecorView().setSystemUiVisibility(
- View.SYSTEM_UI_FLAG_LAYOUT_STABLE
- | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
- | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
- | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
- | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
- | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
+ View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
+ View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
+ View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
+ View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | // hide nav bar
+ View.SYSTEM_UI_FLAG_FULLSCREEN | // hide status bar
+ View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
- for(int i=0;i<singleton_count;i++) {
+ for (int i = 0; i < singleton_count; i++) {
singletons[i].onMainResume();
}
-
-
-
}
public void UiChangeListener() {
final View decorView = getWindow().getDecorView();
- decorView.setOnSystemUiVisibilityChangeListener (new View.OnSystemUiVisibilityChangeListener() {
+ decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
@Override
public void onSystemUiVisibilityChange(int visibility) {
if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
decorView.setSystemUiVisibility(
- View.SYSTEM_UI_FLAG_LAYOUT_STABLE
- | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
- | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
- | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
- | View.SYSTEM_UI_FLAG_FULLSCREEN
- | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
+ View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
+ View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
+ View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
+ View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
+ View.SYSTEM_UI_FLAG_FULLSCREEN |
+ View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
}
});
}
- @Override public void onSensorChanged(SensorEvent event) {
- Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
+ @Override
+ public void onSensorChanged(SensorEvent event) {
+ Display display = ((WindowManager)getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
int displayRotation = display.getRotation();
float[] adjustedValues = new float[3];
final int axisSwap[][] = {
- { 1, -1, 0, 1 }, // ROTATION_0
- {-1, -1, 1, 0 }, // ROTATION_90
- {-1, 1, 0, 1 }, // ROTATION_180
- { 1, 1, 1, 0 } }; // ROTATION_270
+ { 1, -1, 0, 1 }, // ROTATION_0
+ { -1, -1, 1, 0 }, // ROTATION_90
+ { -1, 1, 0, 1 }, // ROTATION_180
+ { 1, 1, 1, 0 }
+ }; // ROTATION_270
final int[] as = axisSwap[displayRotation];
- adjustedValues[0] = (float)as[0] * event.values[ as[2] ];
- adjustedValues[1] = (float)as[1] * event.values[ as[3] ];
- adjustedValues[2] = event.values[2];
+ adjustedValues[0] = (float)as[0] * event.values[as[2]];
+ adjustedValues[1] = (float)as[1] * event.values[as[3]];
+ adjustedValues[2] = event.values[2];
final float x = adjustedValues[0];
final float y = adjustedValues[1];
@@ -738,27 +715,28 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
@Override
public void run() {
if (typeOfSensor == Sensor.TYPE_ACCELEROMETER) {
- GodotLib.accelerometer(-x,y,-z);
+ GodotLib.accelerometer(-x, y, -z);
}
if (typeOfSensor == Sensor.TYPE_GRAVITY) {
- GodotLib.gravity(-x,y,-z);
+ GodotLib.gravity(-x, y, -z);
}
if (typeOfSensor == Sensor.TYPE_MAGNETIC_FIELD) {
- GodotLib.magnetometer(-x,y,-z);
+ GodotLib.magnetometer(-x, y, -z);
}
if (typeOfSensor == Sensor.TYPE_GYROSCOPE) {
- GodotLib.gyroscope(x,-y,z);
+ GodotLib.gyroscope(x, -y, z);
}
}
});
}
}
- @Override public final void onAccuracyChanged(Sensor sensor, int accuracy) {
+ @Override
+ public final void onAccuracyChanged(Sensor sensor, int accuracy) {
// Do something here if sensor accuracy changes.
}
-/*
+ /*
@Override public boolean dispatchKeyEvent(KeyEvent event) {
if (event.getKeyCode()==KeyEvent.KEYCODE_BACK) {
@@ -772,12 +750,13 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
return false;
}
-*/
+ */
- @Override public void onBackPressed() {
+ @Override
+ public void onBackPressed() {
boolean shouldQuit = true;
- for(int i=0;i<singleton_count;i++) {
+ for (int i = 0; i < singleton_count; i++) {
if (singletons[i].onMainBackPressed()) {
shouldQuit = false;
}
@@ -799,71 +778,68 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
System.exit(0);
}
+ private boolean obbIsCorrupted(String f, String main_pack_md5) {
+ try {
- private boolean obbIsCorrupted(String f, String main_pack_md5){
-
- try {
-
- InputStream fis = new FileInputStream(f);
+ InputStream fis = new FileInputStream(f);
- // Create MD5 Hash
- byte[] buffer = new byte[16384];
-
- MessageDigest complete = MessageDigest.getInstance("MD5");
- int numRead;
- do {
- numRead = fis.read(buffer);
- if (numRead > 0) {
- complete.update(buffer, 0, numRead);
- }
- } while (numRead != -1);
+ // Create MD5 Hash
+ byte[] buffer = new byte[16384];
+ MessageDigest complete = MessageDigest.getInstance("MD5");
+ int numRead;
+ do {
+ numRead = fis.read(buffer);
+ if (numRead > 0) {
+ complete.update(buffer, 0, numRead);
+ }
+ } while (numRead != -1);
- fis.close();
- byte[] messageDigest = complete.digest();
+ fis.close();
+ byte[] messageDigest = complete.digest();
- // Create Hex String
- StringBuffer hexString = new StringBuffer();
- for (int i=0; i<messageDigest.length; i++) {
- String s = Integer.toHexString(0xFF & messageDigest[i]);
+ // Create Hex String
+ StringBuffer hexString = new StringBuffer();
+ for (int i = 0; i < messageDigest.length; i++) {
+ String s = Integer.toHexString(0xFF & messageDigest[i]);
- if (s.length()==1) {
- s="0"+s;
- }
- hexString.append(s);
- }
- String md5str = hexString.toString();
+ if (s.length() == 1) {
+ s = "0" + s;
+ }
+ hexString.append(s);
+ }
+ String md5str = hexString.toString();
- //Log.d("GODOT","**PACK** - My MD5: "+hexString+" - APK md5: "+main_pack_md5);
- if (!md5str.equals(main_pack_md5)) {
- Log.d("GODOT","**PACK MD5 MISMATCH???** - MD5 Found: "+md5str+" "+Integer.toString(md5str.length())+" - MD5 Expected: "+main_pack_md5+" "+Integer.toString(main_pack_md5.length()));
- return true;
- }
- return false;
- } catch (Exception e) {
- e.printStackTrace();
- Log.d("GODOT","**PACK FAIL**");
- return true;
- }
+ //Log.d("GODOT","**PACK** - My MD5: "+hexString+" - APK md5: "+main_pack_md5);
+ if (!md5str.equals(main_pack_md5)) {
+ Log.d("GODOT", "**PACK MD5 MISMATCH???** - MD5 Found: " + md5str + " " + Integer.toString(md5str.length()) + " - MD5 Expected: " + main_pack_md5 + " " + Integer.toString(main_pack_md5.length()));
+ return true;
+ }
+ return false;
+ } catch (Exception e) {
+ e.printStackTrace();
+ Log.d("GODOT", "**PACK FAIL**");
+ return true;
+ }
}
//@Override public boolean dispatchTouchEvent (MotionEvent event) {
public boolean gotTouchEvent(final MotionEvent event) {
super.onTouchEvent(event);
- final int evcount=event.getPointerCount();
- if (evcount==0)
+ final int evcount = event.getPointerCount();
+ if (evcount == 0)
return true;
if (mView != null) {
- final int[] arr = new int[event.getPointerCount()*3];
+ final int[] arr = new int[event.getPointerCount() * 3];
- for(int i=0;i<event.getPointerCount();i++) {
+ for (int i = 0; i < event.getPointerCount(); i++) {
- arr[i*3+0]=(int)event.getPointerId(i);
- arr[i*3+1]=(int)event.getX(i);
- arr[i*3+2]=(int)event.getY(i);
+ arr[i * 3 + 0] = (int)event.getPointerId(i);
+ arr[i * 3 + 1] = (int)event.getX(i);
+ arr[i * 3 + 2] = (int)event.getY(i);
}
//System.out.printf("gaction: %d\n",event.getAction());
@@ -871,13 +847,13 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
mView.queueEvent(new Runnable() {
@Override
public void run() {
- switch(action) {
+ switch (action) {
case MotionEvent.ACTION_DOWN: {
- GodotLib.touch(0,0,evcount,arr);
+ GodotLib.touch(0, 0, evcount, arr);
//System.out.printf("action down at: %f,%f\n", event.getX(),event.getY());
} break;
case MotionEvent.ACTION_MOVE: {
- GodotLib.touch(1,0,evcount,arr);
+ GodotLib.touch(1, 0, evcount, arr);
/*
for(int i=0;i<event.getPointerCount();i++) {
System.out.printf("%d - moved to: %f,%f\n",i, event.getX(i),event.getY(i));
@@ -887,17 +863,17 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
case MotionEvent.ACTION_POINTER_UP: {
final int indexPointUp = event.getActionIndex();
final int pointer_idx = event.getPointerId(indexPointUp);
- GodotLib.touch(4,pointer_idx,evcount,arr);
+ GodotLib.touch(4, pointer_idx, evcount, arr);
//System.out.printf("%d - s.up at: %f,%f\n",pointer_idx, event.getX(pointer_idx),event.getY(pointer_idx));
} break;
case MotionEvent.ACTION_POINTER_DOWN: {
int pointer_idx = event.getActionIndex();
- GodotLib.touch(3,pointer_idx,evcount,arr);
+ GodotLib.touch(3, pointer_idx, evcount, arr);
//System.out.printf("%d - s.down at: %f,%f\n",pointer_idx, event.getX(pointer_idx),event.getY(pointer_idx));
} break;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP: {
- GodotLib.touch(2,0,evcount,arr);
+ GodotLib.touch(2, 0, evcount, arr);
/*
for(int i=0;i<event.getPointerCount();i++) {
System.out.printf("%d - up! %f,%f\n",i, event.getX(i),event.getY(i));
@@ -911,14 +887,16 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
return true;
}
- @Override public boolean onKeyMultiple(final int inKeyCode, int repeatCount, KeyEvent event) {
+ @Override
+ public boolean onKeyMultiple(final int inKeyCode, int repeatCount, KeyEvent event) {
String s = event.getCharacters();
if (s == null || s.length() == 0)
return super.onKeyMultiple(inKeyCode, repeatCount, event);
final char[] cc = s.toCharArray();
int cnt = 0;
- for (int i = cc.length; --i >= 0; cnt += cc[i] != 0 ? 1 : 0);
+ for (int i = cc.length; --i >= 0; cnt += cc[i] != 0 ? 1 : 0)
+ ;
if (cnt == 0) return super.onKeyMultiple(inKeyCode, repeatCount, event);
final Activity me = this;
queueEvent(new Runnable() {
@@ -939,7 +917,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
private void queueEvent(Runnable runnable) {
// TODO Auto-generated method stub
-
}
public PaymentsManager getPaymentsManager() {
@@ -952,7 +929,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
}
*/
-
// Audio
/**
@@ -960,110 +936,106 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
* to show the state as being indeterminate at times. This sample can be
* considered a guideline.
*/
- @Override
- public void onDownloadStateChanged(int newState) {
- Log.d("GODOT", "onDownloadStateChanged:" + newState);
- setState(newState);
- boolean showDashboard = true;
- boolean showCellMessage = false;
- boolean paused;
- boolean indeterminate;
- switch (newState) {
- case IDownloaderClient.STATE_IDLE:
- Log.d("GODOT", "DOWNLOAD STATE IDLE");
- // STATE_IDLE means the service is listening, so it's
- // safe to start making calls via mRemoteService.
- paused = false;
- indeterminate = true;
- break;
- case IDownloaderClient.STATE_CONNECTING:
- case IDownloaderClient.STATE_FETCHING_URL:
- Log.d("GODOT", "DOWNLOAD STATE CONNECTION / FETCHING URL");
- showDashboard = true;
- paused = false;
- indeterminate = true;
- break;
- case IDownloaderClient.STATE_DOWNLOADING:
- Log.d("GODOT", "DOWNLOAD STATE DOWNLOADING");
- paused = false;
- showDashboard = true;
- indeterminate = false;
- break;
-
- case IDownloaderClient.STATE_FAILED_CANCELED:
- case IDownloaderClient.STATE_FAILED:
- case IDownloaderClient.STATE_FAILED_FETCHING_URL:
- case IDownloaderClient.STATE_FAILED_UNLICENSED:
- Log.d("GODOT", "DOWNLOAD STATE: FAILED, CANCELLED, UNLICENSED OR FAILED TO FETCH URL");
- paused = true;
- showDashboard = false;
- indeterminate = false;
- break;
- case IDownloaderClient.STATE_PAUSED_NEED_CELLULAR_PERMISSION:
- case IDownloaderClient.STATE_PAUSED_WIFI_DISABLED_NEED_CELLULAR_PERMISSION:
- Log.d("GODOT", "DOWNLOAD STATE: PAUSED BY MISSING CELLULAR PERMISSION");
- showDashboard = false;
- paused = true;
- indeterminate = false;
- showCellMessage = true;
- break;
-
- case IDownloaderClient.STATE_PAUSED_BY_REQUEST:
- Log.d("GODOT", "DOWNLOAD STATE: PAUSED BY USER");
- paused = true;
- indeterminate = false;
- break;
- case IDownloaderClient.STATE_PAUSED_ROAMING:
- case IDownloaderClient.STATE_PAUSED_SDCARD_UNAVAILABLE:
- Log.d("GODOT", "DOWNLOAD STATE: PAUSED BY ROAMING OR SDCARD UNAVAILABLE");
- paused = true;
- indeterminate = false;
- break;
- case IDownloaderClient.STATE_COMPLETED:
- Log.d("GODOT", "DOWNLOAD STATE: COMPLETED");
- showDashboard = false;
- paused = false;
- indeterminate = false;
-// validateXAPKZipFiles();
- initializeGodot();
- return;
- default:
- Log.d("GODOT", "DOWNLOAD STATE: DEFAULT");
- paused = true;
- indeterminate = true;
- showDashboard = true;
- }
- int newDashboardVisibility = showDashboard ? View.VISIBLE : View.GONE;
- if (mDashboard.getVisibility() != newDashboardVisibility) {
- mDashboard.setVisibility(newDashboardVisibility);
- }
- int cellMessageVisibility = showCellMessage ? View.VISIBLE : View.GONE;
- if (mCellMessage.getVisibility() != cellMessageVisibility) {
- mCellMessage.setVisibility(cellMessageVisibility);
- }
-
- mPB.setIndeterminate(indeterminate);
- setButtonPausedState(paused);
- }
+ @Override
+ public void onDownloadStateChanged(int newState) {
+ Log.d("GODOT", "onDownloadStateChanged:" + newState);
+ setState(newState);
+ boolean showDashboard = true;
+ boolean showCellMessage = false;
+ boolean paused;
+ boolean indeterminate;
+ switch (newState) {
+ case IDownloaderClient.STATE_IDLE:
+ Log.d("GODOT", "DOWNLOAD STATE IDLE");
+ // STATE_IDLE means the service is listening, so it's
+ // safe to start making calls via mRemoteService.
+ paused = false;
+ indeterminate = true;
+ break;
+ case IDownloaderClient.STATE_CONNECTING:
+ case IDownloaderClient.STATE_FETCHING_URL:
+ Log.d("GODOT", "DOWNLOAD STATE CONNECTION / FETCHING URL");
+ showDashboard = true;
+ paused = false;
+ indeterminate = true;
+ break;
+ case IDownloaderClient.STATE_DOWNLOADING:
+ Log.d("GODOT", "DOWNLOAD STATE DOWNLOADING");
+ paused = false;
+ showDashboard = true;
+ indeterminate = false;
+ break;
+
+ case IDownloaderClient.STATE_FAILED_CANCELED:
+ case IDownloaderClient.STATE_FAILED:
+ case IDownloaderClient.STATE_FAILED_FETCHING_URL:
+ case IDownloaderClient.STATE_FAILED_UNLICENSED:
+ Log.d("GODOT", "DOWNLOAD STATE: FAILED, CANCELLED, UNLICENSED OR FAILED TO FETCH URL");
+ paused = true;
+ showDashboard = false;
+ indeterminate = false;
+ break;
+ case IDownloaderClient.STATE_PAUSED_NEED_CELLULAR_PERMISSION:
+ case IDownloaderClient.STATE_PAUSED_WIFI_DISABLED_NEED_CELLULAR_PERMISSION:
+ Log.d("GODOT", "DOWNLOAD STATE: PAUSED BY MISSING CELLULAR PERMISSION");
+ showDashboard = false;
+ paused = true;
+ indeterminate = false;
+ showCellMessage = true;
+ break;
+
+ case IDownloaderClient.STATE_PAUSED_BY_REQUEST:
+ Log.d("GODOT", "DOWNLOAD STATE: PAUSED BY USER");
+ paused = true;
+ indeterminate = false;
+ break;
+ case IDownloaderClient.STATE_PAUSED_ROAMING:
+ case IDownloaderClient.STATE_PAUSED_SDCARD_UNAVAILABLE:
+ Log.d("GODOT", "DOWNLOAD STATE: PAUSED BY ROAMING OR SDCARD UNAVAILABLE");
+ paused = true;
+ indeterminate = false;
+ break;
+ case IDownloaderClient.STATE_COMPLETED:
+ Log.d("GODOT", "DOWNLOAD STATE: COMPLETED");
+ showDashboard = false;
+ paused = false;
+ indeterminate = false;
+ // validateXAPKZipFiles();
+ initializeGodot();
+ return;
+ default:
+ Log.d("GODOT", "DOWNLOAD STATE: DEFAULT");
+ paused = true;
+ indeterminate = true;
+ showDashboard = true;
+ }
+ int newDashboardVisibility = showDashboard ? View.VISIBLE : View.GONE;
+ if (mDashboard.getVisibility() != newDashboardVisibility) {
+ mDashboard.setVisibility(newDashboardVisibility);
+ }
+ int cellMessageVisibility = showCellMessage ? View.VISIBLE : View.GONE;
+ if (mCellMessage.getVisibility() != cellMessageVisibility) {
+ mCellMessage.setVisibility(cellMessageVisibility);
+ }
+ mPB.setIndeterminate(indeterminate);
+ setButtonPausedState(paused);
+ }
@Override
public void onDownloadProgress(DownloadProgressInfo progress) {
mAverageSpeed.setText(getString(com.godot.game.R.string.kilobytes_per_second,
- Helpers.getSpeedString(progress.mCurrentSpeed)));
- mTimeRemaining.setText(getString(com.godot.game.R.string.time_remaining,
- Helpers.getTimeRemaining(progress.mTimeRemaining)));
-
- progress.mOverallTotal = progress.mOverallTotal;
- mPB.setMax((int) (progress.mOverallTotal >> 8));
- mPB.setProgress((int) (progress.mOverallProgress >> 8));
- mProgressPercent.setText(Long.toString(progress.mOverallProgress
- * 100 /
- progress.mOverallTotal) + "%");
- mProgressFraction.setText(Helpers.getDownloadProgressString
- (progress.mOverallProgress,
- progress.mOverallTotal));
-
+ Helpers.getSpeedString(progress.mCurrentSpeed)));
+ mTimeRemaining.setText(getString(com.godot.game.R.string.time_remaining,
+ Helpers.getTimeRemaining(progress.mTimeRemaining)));
+
+ progress.mOverallTotal = progress.mOverallTotal;
+ mPB.setMax((int)(progress.mOverallTotal >> 8));
+ mPB.setProgress((int)(progress.mOverallProgress >> 8));
+ mProgressPercent.setText(Long.toString(progress.mOverallProgress * 100 /
+ progress.mOverallTotal) +
+ "%");
+ mProgressFraction.setText(Helpers.getDownloadProgressString(progress.mOverallProgress,
+ progress.mOverallTotal));
}
-
}
diff --git a/platform/android/java/src/org/godotengine/godot/GodotDownloaderAlarmReceiver.java b/platform/android/java/src/org/godotengine/godot/GodotDownloaderAlarmReceiver.java
index 2c668dd586..568c7a4140 100644
--- a/platform/android/java/src/org/godotengine/godot/GodotDownloaderAlarmReceiver.java
+++ b/platform/android/java/src/org/godotengine/godot/GodotDownloaderAlarmReceiver.java
@@ -46,14 +46,14 @@ import android.util.Log;
*/
public class GodotDownloaderAlarmReceiver extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- Log.d("GODOT", "Alarma recivida");
- try {
- DownloaderClientMarshaller.startDownloadServiceIfRequired(context, intent, GodotDownloaderService.class);
- } catch (NameNotFoundException e) {
- e.printStackTrace();
- Log.d("GODOT", "Exception: " + e.getClass().getName() + ":" + e.getMessage());
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Log.d("GODOT", "Alarma recivida");
+ try {
+ DownloaderClientMarshaller.startDownloadServiceIfRequired(context, intent, GodotDownloaderService.class);
+ } catch (NameNotFoundException e) {
+ e.printStackTrace();
+ Log.d("GODOT", "Exception: " + e.getClass().getName() + ":" + e.getMessage());
+ }
}
- }
}
diff --git a/platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java b/platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java
index 97ba7826fb..b8b3b925c5 100644
--- a/platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java
+++ b/platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java
@@ -40,46 +40,45 @@ import com.google.android.vending.expansion.downloader.impl.DownloaderService;
* DownloaderService from the Downloader library.
*/
public class GodotDownloaderService extends DownloaderService {
- // stuff for LVL -- MODIFY FOR YOUR APPLICATION!
- private static final String BASE64_PUBLIC_KEY = "REPLACE THIS WITH YOUR PUBLIC KEY";
- // used by the preference obfuscater
- private static final byte[] SALT = new byte[] {
- 1, 43, -12, -1, 54, 98,
- -100, -12, 43, 2, -8, -4, 9, 5, -106, -108, -33, 45, -1, 84
- };
+ // stuff for LVL -- MODIFY FOR YOUR APPLICATION!
+ private static final String BASE64_PUBLIC_KEY = "REPLACE THIS WITH YOUR PUBLIC KEY";
+ // used by the preference obfuscater
+ private static final byte[] SALT = new byte[] {
+ 1, 43, -12, -1, 54, 98,
+ -100, -12, 43, 2, -8, -4, 9, 5, -106, -108, -33, 45, -1, 84
+ };
- /**
+ /**
* This public key comes from your Android Market publisher account, and it
* used by the LVL to validate responses from Market on your behalf.
*/
- @Override
- public String getPublicKey() {
- SharedPreferences prefs = getApplicationContext().getSharedPreferences("app_data_keys", Context.MODE_PRIVATE);
- Log.d("GODOT", "getting public key:" + prefs.getString("store_public_key", null));
- return prefs.getString("store_public_key", null);
-
- //return BASE64_PUBLIC_KEY;
- }
+ @Override
+ public String getPublicKey() {
+ SharedPreferences prefs = getApplicationContext().getSharedPreferences("app_data_keys", Context.MODE_PRIVATE);
+ Log.d("GODOT", "getting public key:" + prefs.getString("store_public_key", null));
+ return prefs.getString("store_public_key", null);
- /**
+ //return BASE64_PUBLIC_KEY;
+ }
+
+ /**
* This is used by the preference obfuscater to make sure that your
* obfuscated preferences are different than the ones used by other
* applications.
*/
- @Override
- public byte[] getSALT() {
- return SALT;
- }
+ @Override
+ public byte[] getSALT() {
+ return SALT;
+ }
- /**
+ /**
* Fill this in with the class name for your alarm receiver. We do this
* because receivers must be unique across all of Android (it's a good idea
* to make sure that your receiver is in your unique package)
*/
- @Override
- public String getAlarmReceiverClassName() {
- Log.d("GODOT", "getAlarmReceiverClassName()");
- return GodotDownloaderAlarmReceiver.class.getName();
- }
-
+ @Override
+ public String getAlarmReceiverClassName() {
+ Log.d("GODOT", "getAlarmReceiverClassName()");
+ return GodotDownloaderAlarmReceiver.class.getName();
+ }
}
diff --git a/platform/android/java/src/org/godotengine/godot/GodotIO.java b/platform/android/java/src/org/godotengine/godot/GodotIO.java
index 989fd2b609..12a2467a29 100644
--- a/platform/android/java/src/org/godotengine/godot/GodotIO.java
+++ b/platform/android/java/src/org/godotengine/godot/GodotIO.java
@@ -56,7 +56,6 @@ import org.godotengine.godot.input.*;
public class GodotIO {
-
AssetManager am;
Godot activity;
GodotEditText edit;
@@ -64,35 +63,32 @@ public class GodotIO {
Context applicationContext;
MediaPlayer mediaPlayer;
- final int SCREEN_LANDSCAPE=0;
- final int SCREEN_PORTRAIT=1;
- final int SCREEN_REVERSE_LANDSCAPE=2;
- final int SCREEN_REVERSE_PORTRAIT=3;
- final int SCREEN_SENSOR_LANDSCAPE=4;
- final int SCREEN_SENSOR_PORTRAIT=5;
- final int SCREEN_SENSOR=6;
+ final int SCREEN_LANDSCAPE = 0;
+ final int SCREEN_PORTRAIT = 1;
+ final int SCREEN_REVERSE_LANDSCAPE = 2;
+ final int SCREEN_REVERSE_PORTRAIT = 3;
+ final int SCREEN_SENSOR_LANDSCAPE = 4;
+ final int SCREEN_SENSOR_PORTRAIT = 5;
+ final int SCREEN_SENSOR = 6;
/////////////////////////
/// FILES
/////////////////////////
- public int last_file_id=1;
+ public int last_file_id = 1;
class AssetData {
-
- public boolean eof=false;
+ public boolean eof = false;
public String path;
public InputStream is;
public int len;
public int pos;
}
+ HashMap<Integer, AssetData> streams;
- HashMap<Integer,AssetData> streams;
-
-
- public int file_open(String path,boolean write) {
+ public int file_open(String path, boolean write) {
//System.out.printf("file_open: Attempt to Open %s\n",path);
@@ -100,7 +96,6 @@ public class GodotIO {
if (write)
return -1;
-
AssetData ad = new AssetData();
try {
@@ -113,76 +108,73 @@ public class GodotIO {
}
try {
- ad.len=ad.is.available();
+ ad.len = ad.is.available();
} catch (Exception e) {
- System.out.printf("Exception availabling on file_open: %s\n",path);
+ System.out.printf("Exception availabling on file_open: %s\n", path);
return -1;
}
- ad.path=path;
- ad.pos=0;
+ ad.path = path;
+ ad.pos = 0;
++last_file_id;
- streams.put(last_file_id,ad);
+ streams.put(last_file_id, ad);
return last_file_id;
}
public int file_get_size(int id) {
if (!streams.containsKey(id)) {
- System.out.printf("file_get_size: Invalid file id: %d\n",id);
+ System.out.printf("file_get_size: Invalid file id: %d\n", id);
return -1;
}
return streams.get(id).len;
-
}
- public void file_seek(int id,int bytes) {
+ public void file_seek(int id, int bytes) {
if (!streams.containsKey(id)) {
- System.out.printf("file_get_size: Invalid file id: %d\n",id);
+ System.out.printf("file_get_size: Invalid file id: %d\n", id);
return;
}
//seek sucks
AssetData ad = streams.get(id);
- if (bytes>ad.len)
- bytes=ad.len;
- if (bytes<0)
- bytes=0;
+ if (bytes > ad.len)
+ bytes = ad.len;
+ if (bytes < 0)
+ bytes = 0;
try {
- if (bytes > (int)ad.pos) {
- int todo=bytes-(int)ad.pos;
- while(todo>0) {
- todo-=ad.is.skip(todo);
- }
- ad.pos=bytes;
- } else if (bytes<(int)ad.pos) {
+ if (bytes > (int)ad.pos) {
+ int todo = bytes - (int)ad.pos;
+ while (todo > 0) {
+ todo -= ad.is.skip(todo);
+ }
+ ad.pos = bytes;
+ } else if (bytes < (int)ad.pos) {
- ad.is=am.open(ad.path);
+ ad.is = am.open(ad.path);
- ad.pos=bytes;
- int todo=bytes;
- while(todo>0) {
- todo-=ad.is.skip(todo);
+ ad.pos = bytes;
+ int todo = bytes;
+ while (todo > 0) {
+ todo -= ad.is.skip(todo);
+ }
}
- }
- ad.eof=false;
+ ad.eof = false;
} catch (IOException e) {
- System.out.printf("Exception on file_seek: %s\n",e);
+ System.out.printf("Exception on file_seek: %s\n", e);
return;
}
-
-
}
public int file_tell(int id) {
if (!streams.containsKey(id)) {
- System.out.printf("file_read: Can't tell eof for invalid file id: %d\n",id);
+ System.out.printf("file_read: Can't tell eof for invalid file id: %d\n", id);
return 0;
}
@@ -192,7 +184,7 @@ public class GodotIO {
public boolean file_eof(int id) {
if (!streams.containsKey(id)) {
- System.out.printf("file_read: Can't check eof for invalid file id: %d\n",id);
+ System.out.printf("file_read: Can't check eof for invalid file id: %d\n", id);
return false;
}
@@ -203,73 +195,65 @@ public class GodotIO {
public byte[] file_read(int id, int bytes) {
if (!streams.containsKey(id)) {
- System.out.printf("file_read: Can't read invalid file id: %d\n",id);
+ System.out.printf("file_read: Can't read invalid file id: %d\n", id);
return new byte[0];
}
-
AssetData ad = streams.get(id);
if (ad.pos + bytes > ad.len) {
- bytes=ad.len-ad.pos;
- ad.eof=true;
+ bytes = ad.len - ad.pos;
+ ad.eof = true;
}
-
- if (bytes==0) {
+ if (bytes == 0) {
return new byte[0];
}
-
-
- byte[] buf1=new byte[bytes];
- int r=0;
+ byte[] buf1 = new byte[bytes];
+ int r = 0;
try {
r = ad.is.read(buf1);
} catch (IOException e) {
- System.out.printf("Exception on file_read: %s\n",e);
+ System.out.printf("Exception on file_read: %s\n", e);
return new byte[bytes];
}
- if (r==0) {
+ if (r == 0) {
return new byte[0];
}
- ad.pos+=r;
+ ad.pos += r;
- if (r<bytes) {
+ if (r < bytes) {
- byte[] buf2=new byte[r];
- for(int i=0;i<r;i++)
- buf2[i]=buf1[i];
+ byte[] buf2 = new byte[r];
+ for (int i = 0; i < r; i++)
+ buf2[i] = buf1[i];
return buf2;
} else {
return buf1;
}
-
}
public void file_close(int id) {
if (!streams.containsKey(id)) {
- System.out.printf("file_close: Can't close invalid file id: %d\n",id);
+ System.out.printf("file_close: Can't close invalid file id: %d\n", id);
return;
}
streams.remove(id);
-
}
-
/////////////////////////
/// DIRECTORIES
/////////////////////////
-
class AssetDir {
public String[] files;
@@ -277,49 +261,48 @@ public class GodotIO {
public String path;
}
- public int last_dir_id=1;
+ public int last_dir_id = 1;
- HashMap<Integer,AssetDir> dirs;
+ HashMap<Integer, AssetDir> dirs;
public int dir_open(String path) {
AssetDir ad = new AssetDir();
- ad.current=0;
- ad.path=path;
+ ad.current = 0;
+ ad.path = path;
try {
ad.files = am.list(path);
// no way to find path is directory or file exactly.
// but if ad.files.length==0, then it's an empty directory or file.
- if (ad.files.length==0) {
+ if (ad.files.length == 0) {
return -1;
}
} catch (IOException e) {
- System.out.printf("Exception on dir_open: %s\n",e);
+ System.out.printf("Exception on dir_open: %s\n", e);
return -1;
}
//System.out.printf("Opened dir: %s\n",path);
++last_dir_id;
- dirs.put(last_dir_id,ad);
+ dirs.put(last_dir_id, ad);
return last_dir_id;
-
}
public boolean dir_is_dir(int id) {
if (!dirs.containsKey(id)) {
- System.out.printf("dir_next: invalid dir id: %d\n",id);
+ System.out.printf("dir_next: invalid dir id: %d\n", id);
return false;
}
AssetDir ad = dirs.get(id);
//System.out.printf("go next: %d,%d\n",ad.current,ad.files.length);
int idx = ad.current;
- if (idx>0)
+ if (idx > 0)
idx--;
- if (idx>=ad.files.length)
+ if (idx >= ad.files.length)
return false;
String fname = ad.files[idx];
@@ -327,7 +310,7 @@ public class GodotIO {
if (ad.path.equals(""))
am.open(fname);
else
- am.open(ad.path+"/"+fname);
+ am.open(ad.path + "/" + fname);
return false;
} catch (Exception e) {
return true;
@@ -337,46 +320,41 @@ public class GodotIO {
public String dir_next(int id) {
if (!dirs.containsKey(id)) {
- System.out.printf("dir_next: invalid dir id: %d\n",id);
+ System.out.printf("dir_next: invalid dir id: %d\n", id);
return "";
}
AssetDir ad = dirs.get(id);
//System.out.printf("go next: %d,%d\n",ad.current,ad.files.length);
- if (ad.current>=ad.files.length) {
+ if (ad.current >= ad.files.length) {
ad.current++;
return "";
}
String r = ad.files[ad.current];
ad.current++;
return r;
-
}
public void dir_close(int id) {
if (!dirs.containsKey(id)) {
- System.out.printf("dir_close: invalid dir id: %d\n",id);
+ System.out.printf("dir_close: invalid dir id: %d\n", id);
return;
}
dirs.remove(id);
}
-
-
GodotIO(Godot p_activity) {
- am=p_activity.getAssets();
- activity=p_activity;
- streams=new HashMap<Integer,AssetData>();
- dirs=new HashMap<Integer,AssetDir>();
+ am = p_activity.getAssets();
+ activity = p_activity;
+ streams = new HashMap<Integer, AssetData>();
+ dirs = new HashMap<Integer, AssetDir>();
applicationContext = activity.getApplicationContext();
-
}
-
/////////////////////////
// AUDIO
/////////////////////////
@@ -400,7 +378,7 @@ public class GodotIO {
desiredFrames = Math.max(desiredFrames, (AudioTrack.getMinBufferSize(sampleRate, channelConfig, audioFormat) + frameSize - 1) / frameSize);
mAudioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, sampleRate,
- channelConfig, audioFormat, desiredFrames * frameSize, AudioTrack.MODE_STREAM);
+ channelConfig, audioFormat, desiredFrames * frameSize, AudioTrack.MODE_STREAM);
audioStartThread();
@@ -412,10 +390,10 @@ public class GodotIO {
public void audioStartThread() {
mAudioThread = new Thread(new Runnable() {
- public void run() {
- mAudioTrack.play();
- GodotLib.audio();
- }
+ public void run() {
+ mAudioTrack.play();
+ GodotLib.audio();
+ }
});
// I'd take REALTIME if I could get it!
@@ -424,15 +402,15 @@ public class GodotIO {
}
public void audioWriteShortBuffer(short[] buffer) {
- for (int i = 0; i < buffer.length; ) {
+ for (int i = 0; i < buffer.length;) {
int result = mAudioTrack.write(buffer, i, buffer.length - i);
if (result > 0) {
i += result;
} else if (result == 0) {
try {
- Thread.sleep(1);
- } catch(InterruptedException e) {
- // Nom nom
+ Thread.sleep(1);
+ } catch (InterruptedException e) {
+ // Nom nom
}
} else {
Log.w("Godot", "Godot audio: error return from write(short)");
@@ -441,18 +419,16 @@ public class GodotIO {
}
}
-
-
public void audioQuit() {
if (mAudioThread != null) {
try {
mAudioThread.join();
- } catch(Exception e) {
+ } catch (Exception e) {
Log.v("Godot", "Problem stopping audio thread: " + e);
}
mAudioThread = null;
- //Log.v("Godot", "Finished waiting for audio thread");
+ //Log.v("Godot", "Finished waiting for audio thread");
}
if (mAudioTrack != null) {
@@ -473,20 +449,18 @@ public class GodotIO {
// MISCELLANEOUS OS IO
/////////////////////////
-
-
public int openURI(String p_uri) {
try {
Log.v("MyApp", "TRYING TO OPEN URI: " + p_uri);
String path = p_uri;
- String type="";
+ String type = "";
if (path.startsWith("/")) {
//absolute path to filesystem, prepend file://
- path="file://"+path;
+ path = "file://" + path;
if (p_uri.endsWith(".png") || p_uri.endsWith(".jpg") || p_uri.endsWith(".gif") || p_uri.endsWith(".webp")) {
- type="image/*";
+ type = "image/*";
}
}
@@ -531,7 +505,7 @@ public class GodotIO {
}
public void showKeyboard(String p_existing_text) {
- if(edit != null)
+ if (edit != null)
edit.showKeyboard(p_existing_text);
//InputMethodManager inputMgr = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
@@ -539,21 +513,21 @@ public class GodotIO {
};
public void hideKeyboard() {
- if(edit != null)
+ if (edit != null)
edit.hideKeyboard();
- InputMethodManager inputMgr = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
- View v = activity.getCurrentFocus();
- if (v != null) {
- inputMgr.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
- } else {
- inputMgr.hideSoftInputFromWindow(new View(activity).getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
- }
+ InputMethodManager inputMgr = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
+ View v = activity.getCurrentFocus();
+ if (v != null) {
+ inputMgr.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
+ } else {
+ inputMgr.hideSoftInputFromWindow(new View(activity).getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
+ }
};
public void setScreenOrientation(int p_orientation) {
- switch(p_orientation) {
+ switch (p_orientation) {
case SCREEN_LANDSCAPE: {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
@@ -576,16 +550,14 @@ public class GodotIO {
case SCREEN_SENSOR: {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);
} break;
-
}
};
-
+
public void setEdit(GodotEditText _edit) {
edit = _edit;
}
- public void playVideo(String p_path)
- {
+ public void playVideo(String p_path) {
Uri filePath = Uri.parse(p_path);
mediaPlayer = new MediaPlayer();
@@ -594,11 +566,9 @@ public class GodotIO {
mediaPlayer.setDataSource(applicationContext, filePath);
mediaPlayer.prepare();
mediaPlayer.start();
+ } catch (IOException e) {
+ System.out.println("IOError while playing video");
}
- catch(IOException e)
- {
- System.out.println("IOError while playing video");
- }
}
public boolean isVideoPlaying() {
@@ -621,49 +591,47 @@ public class GodotIO {
}
}
-
- public static final int SYSTEM_DIR_DESKTOP=0;
- public static final int SYSTEM_DIR_DCIM=1;
- public static final int SYSTEM_DIR_DOCUMENTS=2;
- public static final int SYSTEM_DIR_DOWNLOADS=3;
- public static final int SYSTEM_DIR_MOVIES=4;
- public static final int SYSTEM_DIR_MUSIC=5;
- public static final int SYSTEM_DIR_PICTURES=6;
- public static final int SYSTEM_DIR_RINGTONES=7;
-
+ public static final int SYSTEM_DIR_DESKTOP = 0;
+ public static final int SYSTEM_DIR_DCIM = 1;
+ public static final int SYSTEM_DIR_DOCUMENTS = 2;
+ public static final int SYSTEM_DIR_DOWNLOADS = 3;
+ public static final int SYSTEM_DIR_MOVIES = 4;
+ public static final int SYSTEM_DIR_MUSIC = 5;
+ public static final int SYSTEM_DIR_PICTURES = 6;
+ public static final int SYSTEM_DIR_RINGTONES = 7;
public String getSystemDir(int idx) {
- String what="";
- switch(idx) {
+ String what = "";
+ switch (idx) {
case SYSTEM_DIR_DESKTOP: {
//what=Environment.DIRECTORY_DOCUMENTS;
- what=Environment.DIRECTORY_DOWNLOADS;
+ what = Environment.DIRECTORY_DOWNLOADS;
} break;
case SYSTEM_DIR_DCIM: {
- what=Environment.DIRECTORY_DCIM;
+ what = Environment.DIRECTORY_DCIM;
} break;
case SYSTEM_DIR_DOCUMENTS: {
- what=Environment.DIRECTORY_DOWNLOADS;
+ what = Environment.DIRECTORY_DOWNLOADS;
//what=Environment.DIRECTORY_DOCUMENTS;
} break;
case SYSTEM_DIR_DOWNLOADS: {
- what=Environment.DIRECTORY_DOWNLOADS;
+ what = Environment.DIRECTORY_DOWNLOADS;
} break;
case SYSTEM_DIR_MOVIES: {
- what=Environment.DIRECTORY_MOVIES;
+ what = Environment.DIRECTORY_MOVIES;
} break;
case SYSTEM_DIR_MUSIC: {
- what=Environment.DIRECTORY_MUSIC;
+ what = Environment.DIRECTORY_MUSIC;
} break;
case SYSTEM_DIR_PICTURES: {
- what=Environment.DIRECTORY_PICTURES;
+ what = Environment.DIRECTORY_PICTURES;
} break;
case SYSTEM_DIR_RINGTONES: {
- what=Environment.DIRECTORY_RINGTONES;
+ what = Environment.DIRECTORY_RINGTONES;
} break;
}
@@ -676,10 +644,9 @@ public class GodotIO {
protected static final String PREFS_FILE = "device_id.xml";
protected static final String PREFS_DEVICE_ID = "device_id";
- public static String unique_id="";
+ public static String unique_id = "";
public String getUniqueID() {
- return unique_id;
+ return unique_id;
}
-
}
diff --git a/platform/android/java/src/org/godotengine/godot/GodotLib.java b/platform/android/java/src/org/godotengine/godot/GodotLib.java
index 6b84ad6555..873d30eb34 100644
--- a/platform/android/java/src/org/godotengine/godot/GodotLib.java
+++ b/platform/android/java/src/org/godotengine/godot/GodotLib.java
@@ -33,43 +33,41 @@ package org.godotengine.godot;
public class GodotLib {
+ public static GodotIO io;
- public static GodotIO io;
+ static {
+ System.loadLibrary("godot_android");
+ }
- static {
- System.loadLibrary("godot_android");
- }
-
- /**
+ /**
* @param width the current view width
* @param height the current view height
*/
- public static native void initialize(Godot p_instance,boolean need_reload_hook,Object p_asset_manager, boolean use_apk_expansion);
- public static native void setup(String[] p_cmdline);
- public static native void resize(int width, int height,boolean reload);
- public static native void newcontext(boolean p_32_bits);
- public static native void back();
- public static native void step();
- public static native void touch(int what,int pointer,int howmany, int[] arr);
- public static native void accelerometer(float x, float y, float z);
- public static native void gravity(float x, float y, float z);
- public static native void magnetometer(float x, float y, float z);
- public static native void gyroscope(float x, float y, float z);
- public static native void key(int p_scancode, int p_unicode_char, boolean p_pressed);
- public static native void joybutton(int p_device, int p_but, boolean p_pressed);
- public static native void joyaxis(int p_device, int p_axis, float p_value);
- public static native void joyhat(int p_device, int p_hat_x, int p_hat_y);
- public static native void joyconnectionchanged(int p_device, boolean p_connected, String p_name);
- public static native void focusin();
- public static native void focusout();
- public static native void audio();
- public static native void singleton(String p_name,Object p_object);
- public static native void method(String p_sname,String p_name,String p_ret,String[] p_params);
- public static native String getGlobal(String p_key);
+ public static native void initialize(Godot p_instance, boolean need_reload_hook, Object p_asset_manager, boolean use_apk_expansion);
+ public static native void setup(String[] p_cmdline);
+ public static native void resize(int width, int height, boolean reload);
+ public static native void newcontext(boolean p_32_bits);
+ public static native void back();
+ public static native void step();
+ public static native void touch(int what, int pointer, int howmany, int[] arr);
+ public static native void accelerometer(float x, float y, float z);
+ public static native void gravity(float x, float y, float z);
+ public static native void magnetometer(float x, float y, float z);
+ public static native void gyroscope(float x, float y, float z);
+ public static native void key(int p_scancode, int p_unicode_char, boolean p_pressed);
+ public static native void joybutton(int p_device, int p_but, boolean p_pressed);
+ public static native void joyaxis(int p_device, int p_axis, float p_value);
+ public static native void joyhat(int p_device, int p_hat_x, int p_hat_y);
+ public static native void joyconnectionchanged(int p_device, boolean p_connected, String p_name);
+ public static native void focusin();
+ public static native void focusout();
+ public static native void audio();
+ public static native void singleton(String p_name, Object p_object);
+ public static native void method(String p_sname, String p_name, String p_ret, String[] p_params);
+ public static native String getGlobal(String p_key);
public static native void callobject(int p_ID, String p_method, Object[] p_params);
public static native void calldeferred(int p_ID, String p_method, Object[] p_params);
public static native void setVirtualKeyboardHeight(int p_height);
-
}
diff --git a/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java b/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java
index 8fe79fdfc7..61d10ed9e4 100644
--- a/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java
+++ b/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java
@@ -40,7 +40,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-
public class GodotPaymentV3 extends Godot.SingletonBase {
private Godot activity;
@@ -67,8 +66,8 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
public GodotPaymentV3(Activity p_activity) {
- registerClass("GodotPayments", new String[]{"purchase", "setPurchaseCallbackId", "setPurchaseValidationUrlPrefix", "setTransactionId", "getSignature", "consumeUnconsumedPurchases", "requestPurchased", "setAutoConsume", "consume", "querySkuDetails"});
- activity = (Godot) p_activity;
+ registerClass("GodotPayments", new String[] { "purchase", "setPurchaseCallbackId", "setPurchaseValidationUrlPrefix", "setTransactionId", "getSignature", "consumeUnconsumedPurchases", "requestPurchased", "setAutoConsume", "consume", "querySkuDetails" });
+ activity = (Godot)p_activity;
mPaymentManager = activity.getPaymentsManager();
mPaymentManager.setBaseSingleton(this);
}
@@ -89,32 +88,32 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
}
public void callbackSuccess(String ticket, String signature, String sku) {
- GodotLib.calldeferred(purchaseCallbackId, "purchase_success", new Object[]{ticket, signature, sku});
+ GodotLib.calldeferred(purchaseCallbackId, "purchase_success", new Object[] { ticket, signature, sku });
}
public void callbackSuccessProductMassConsumed(String ticket, String signature, String sku) {
Log.d(this.getClass().getName(), "callbackSuccessProductMassConsumed > " + ticket + "," + signature + "," + sku);
- GodotLib.calldeferred(purchaseCallbackId, "consume_success", new Object[]{ticket, signature, sku});
+ GodotLib.calldeferred(purchaseCallbackId, "consume_success", new Object[] { ticket, signature, sku });
}
public void callbackSuccessNoUnconsumedPurchases() {
- GodotLib.calldeferred(purchaseCallbackId, "consume_not_required", new Object[]{});
+ GodotLib.calldeferred(purchaseCallbackId, "consume_not_required", new Object[] {});
}
public void callbackFailConsume() {
- GodotLib.calldeferred(purchaseCallbackId, "consume_fail", new Object[]{});
+ GodotLib.calldeferred(purchaseCallbackId, "consume_fail", new Object[] {});
}
public void callbackFail() {
- GodotLib.calldeferred(purchaseCallbackId, "purchase_fail", new Object[]{});
+ GodotLib.calldeferred(purchaseCallbackId, "purchase_fail", new Object[] {});
}
public void callbackCancel() {
- GodotLib.calldeferred(purchaseCallbackId, "purchase_cancel", new Object[]{});
+ GodotLib.calldeferred(purchaseCallbackId, "purchase_cancel", new Object[] {});
}
public void callbackAlreadyOwned(String sku) {
- GodotLib.calldeferred(purchaseCallbackId, "purchase_owned", new Object[]{sku});
+ GodotLib.calldeferred(purchaseCallbackId, "purchase_owned", new Object[] { sku });
}
public int getPurchaseCallbackId() {
@@ -161,7 +160,7 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
// callback for requestPurchased()
public void callbackPurchased(String receipt, String signature, String sku) {
- GodotLib.calldeferred(purchaseCallbackId, "has_purchased", new Object[]{receipt, signature, sku});
+ GodotLib.calldeferred(purchaseCallbackId, "has_purchased", new Object[] { receipt, signature, sku });
}
// consume item automatically after purchase. default is true.
@@ -210,10 +209,10 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
}
public void completeSkuDetail() {
- GodotLib.calldeferred(purchaseCallbackId, "sku_details_complete", new Object[]{mSkuDetails});
+ GodotLib.calldeferred(purchaseCallbackId, "sku_details_complete", new Object[] { mSkuDetails });
}
public void errorSkuDetail(String errorMessage) {
- GodotLib.calldeferred(purchaseCallbackId, "sku_details_error", new Object[]{errorMessage});
+ GodotLib.calldeferred(purchaseCallbackId, "sku_details_error", new Object[] { errorMessage });
}
}
diff --git a/platform/android/java/src/org/godotengine/godot/GodotView.java b/platform/android/java/src/org/godotengine/godot/GodotView.java
index b807b952d4..b762aa021a 100644
--- a/platform/android/java/src/org/godotengine/godot/GodotView.java
+++ b/platform/android/java/src/org/godotengine/godot/GodotView.java
@@ -77,20 +77,19 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener {
private static Context ctx;
private static GodotIO io;
- private static boolean firsttime=true;
- private static boolean use_gl3=false;
- private static boolean use_32=false;
+ private static boolean firsttime = true;
+ private static boolean use_gl3 = false;
+ private static boolean use_32 = false;
private Godot activity;
-
private InputManagerCompat mInputManager;
- public GodotView(Context context,GodotIO p_io,boolean p_use_gl3, boolean p_use_32_bits, Godot p_activity) {
+ public GodotView(Context context, GodotIO p_io, boolean p_use_gl3, boolean p_use_32_bits, Godot p_activity) {
super(context);
- ctx=context;
- io=p_io;
- use_gl3=p_use_gl3;
- use_32=p_use_32_bits;
+ ctx = context;
+ io = p_io;
+ use_gl3 = p_use_gl3;
+ use_32 = p_use_32_bits;
activity = p_activity;
@@ -101,14 +100,15 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener {
mInputManager = InputManagerCompat.Factory.getInputManager(this.getContext());
mInputManager.registerInputDeviceListener(this, null);
init(false, 16, 0);
- }
+ }
- public GodotView(Context context, boolean translucent, int depth, int stencil) {
+ public GodotView(Context context, boolean translucent, int depth, int stencil) {
super(context);
init(translucent, depth, stencil);
- }
+ }
- @Override public boolean onTouchEvent (MotionEvent event) {
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
return activity.gotTouchEvent(event);
};
@@ -196,16 +196,17 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener {
ArrayList<joystick> joy_devices = new ArrayList<joystick>();
private int find_joy_device(int device_id) {
- for (int i=0; i<joy_devices.size(); i++) {
+ for (int i = 0; i < joy_devices.size(); i++) {
if (joy_devices.get(i).device_id == device_id) {
- return i;
+ return i;
}
}
onInputDeviceAdded(device_id);
return joy_devices.size() - 1;
}
- @Override public void onInputDeviceAdded(int deviceId) {
+ @Override
+ public void onInputDeviceAdded(int deviceId) {
joystick joy = new joystick();
joy.device_id = deviceId;
final int id = joy_devices.size();
@@ -219,8 +220,7 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener {
for (InputDevice.MotionRange range : ranges) {
if (range.getAxis() == MotionEvent.AXIS_HAT_X || range.getAxis() == MotionEvent.AXIS_HAT_Y) {
joy.hats.add(range);
- }
- else {
+ } else {
joy.axes.add(range);
}
}
@@ -231,9 +231,10 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener {
GodotLib.joyconnectionchanged(id, true, name);
}
});
- }
+ }
- @Override public void onInputDeviceRemoved(int deviceId) {
+ @Override
+ public void onInputDeviceRemoved(int deviceId) {
final int id = find_joy_device(deviceId);
joy_devices.remove(id);
queueEvent(new Runnable() {
@@ -244,10 +245,11 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener {
});
}
- @Override public void onInputDeviceChanged(int deviceId) {
-
+ @Override
+ public void onInputDeviceChanged(int deviceId) {
}
- @Override public boolean onKeyUp(final int keyCode, KeyEvent event) {
+ @Override
+ public boolean onKeyUp(final int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
return true;
@@ -282,7 +284,8 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener {
return super.onKeyUp(keyCode, event);
};
- @Override public boolean onKeyDown(final int keyCode, KeyEvent event) {
+ @Override
+ public boolean onKeyDown(final int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
activity.onBackPressed();
@@ -326,7 +329,8 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener {
return super.onKeyDown(keyCode, event);
}
- @Override public boolean onGenericMotionEvent(MotionEvent event) {
+ @Override
+ public boolean onGenericMotionEvent(MotionEvent event) {
if ((event.getSource() & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK && event.getAction() == MotionEvent.ACTION_MOVE) {
@@ -335,7 +339,7 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener {
for (int i = 0; i < joy.axes.size(); i++) {
InputDevice.MotionRange range = joy.axes.get(i);
- final float value = (event.getAxisValue(range.getAxis()) - range.getMin() ) / range.getRange() * 2.0f - 1.0f;
+ final float value = (event.getAxisValue(range.getAxis()) - range.getMin()) / range.getRange() * 2.0f - 1.0f;
//Log.e(TAG, String.format("axis event: %d, value %f", i, value));
final int idx = i;
queueEvent(new Runnable() {
@@ -346,9 +350,9 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener {
});
}
- for (int i = 0; i < joy.hats.size(); i+=2) {
+ for (int i = 0; i < joy.hats.size(); i += 2) {
final int hatX = Math.round(event.getAxisValue(joy.hats.get(i).getAxis()));
- final int hatY = Math.round(event.getAxisValue(joy.hats.get(i+1).getAxis()));
+ final int hatY = Math.round(event.getAxisValue(joy.hats.get(i + 1).getAxis()));
//Log.e(TAG, String.format("HAT EVENT %d, %d", hatX, hatY));
queueEvent(new Runnable() {
@Override
@@ -363,8 +367,7 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener {
return super.onGenericMotionEvent(event);
};
-
- private void init(boolean translucent, int depth, int stencil) {
+ private void init(boolean translucent, int depth, int stencil) {
this.setFocusableInTouchMode(true);
/* By default, GLSurfaceView() creates a RGB_565 opaque surface.
@@ -388,14 +391,14 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener {
*/
if (use_32) {
- setEGLConfigChooser( translucent ?
- new FallbackConfigChooser(8, 8, 8, 8, 24, stencil, new ConfigChooser(8, 8, 8, 8, 16, stencil)) :
- new FallbackConfigChooser(8, 8, 8, 8, 24, stencil, new ConfigChooser(5, 6, 5, 0, 16, stencil)) );
+ setEGLConfigChooser(translucent ?
+ new FallbackConfigChooser(8, 8, 8, 8, 24, stencil, new ConfigChooser(8, 8, 8, 8, 16, stencil)) :
+ new FallbackConfigChooser(8, 8, 8, 8, 24, stencil, new ConfigChooser(5, 6, 5, 0, 16, stencil)));
} else {
- setEGLConfigChooser( translucent ?
- new ConfigChooser(8, 8, 8, 8, 16, stencil) :
- new ConfigChooser(5, 6, 5, 0, 16, stencil) );
+ setEGLConfigChooser(translucent ?
+ new ConfigChooser(8, 8, 8, 8, 16, stencil) :
+ new ConfigChooser(5, 6, 5, 0, 16, stencil));
}
/* Set the renderer responsible for frame rendering */
@@ -403,33 +406,33 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener {
}
private static class ContextFactory implements GLSurfaceView.EGLContextFactory {
- private static int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
- public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig) {
- if (use_gl3)
- Log.w(TAG, "creating OpenGL ES 3.0 context :");
- else
- Log.w(TAG, "creating OpenGL ES 2.0 context :");
-
- checkEglError("Before eglCreateContext", egl);
- int[] attrib_list2 = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE };
- int[] attrib_list3 = {EGL_CONTEXT_CLIENT_VERSION, 3, EGL10.EGL_NONE };
- EGLContext context = egl.eglCreateContext(display, eglConfig, EGL10.EGL_NO_CONTEXT, use_gl3?attrib_list3:attrib_list2);
- checkEglError("After eglCreateContext", egl);
- return context;
- }
+ private static int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
+ public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig) {
+ if (use_gl3)
+ Log.w(TAG, "creating OpenGL ES 3.0 context :");
+ else
+ Log.w(TAG, "creating OpenGL ES 2.0 context :");
+
+ checkEglError("Before eglCreateContext", egl);
+ int[] attrib_list2 = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE };
+ int[] attrib_list3 = { EGL_CONTEXT_CLIENT_VERSION, 3, EGL10.EGL_NONE };
+ EGLContext context = egl.eglCreateContext(display, eglConfig, EGL10.EGL_NO_CONTEXT, use_gl3 ? attrib_list3 : attrib_list2);
+ checkEglError("After eglCreateContext", egl);
+ return context;
+ }
- public void destroyContext(EGL10 egl, EGLDisplay display, EGLContext context) {
- egl.eglDestroyContext(display, context);
+ public void destroyContext(EGL10 egl, EGLDisplay display, EGLContext context) {
+ egl.eglDestroyContext(display, context);
+ }
}
- }
- private static void checkEglError(String prompt, EGL10 egl) {
- int error;
- while ((error = egl.eglGetError()) != EGL10.EGL_SUCCESS) {
- Log.e(TAG, String.format("%s: EGL error: 0x%x", prompt, error));
+ private static void checkEglError(String prompt, EGL10 egl) {
+ int error;
+ while ((error = egl.eglGetError()) != EGL10.EGL_SUCCESS) {
+ Log.e(TAG, String.format("%s: EGL error: 0x%x", prompt, error));
+ }
}
- }
- /* Fallback if 32bit View is not supported*/
+ /* Fallback if 32bit View is not supported*/
private static class FallbackConfigChooser extends ConfigChooser {
private ConfigChooser fallback;
@@ -438,17 +441,17 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener {
this.fallback = fallback;
}
- @Override
+ @Override
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display, EGLConfig[] configs) {
EGLConfig ec = super.chooseConfig(egl, display, configs);
if (ec == null) {
- Log.w(TAG, "Trying ConfigChooser fallback");
- ec = fallback.chooseConfig(egl, display, configs);
- use_32=false;
+ Log.w(TAG, "Trying ConfigChooser fallback");
+ ec = fallback.chooseConfig(egl, display, configs);
+ use_32 = false;
}
return ec;
- }
- }
+ }
+ }
private static class ConfigChooser implements GLSurfaceView.EGLConfigChooser {
@@ -467,46 +470,46 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener {
*/
private static int EGL_OPENGL_ES2_BIT = 4;
private static int[] s_configAttribs2 =
- {
- EGL10.EGL_RED_SIZE, 4,
- EGL10.EGL_GREEN_SIZE, 4,
- EGL10.EGL_BLUE_SIZE, 4,
- // EGL10.EGL_DEPTH_SIZE, 16,
- // EGL10.EGL_STENCIL_SIZE, EGL10.EGL_DONT_CARE,
- EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
- EGL10.EGL_NONE
- };
+ {
+ EGL10.EGL_RED_SIZE, 4,
+ EGL10.EGL_GREEN_SIZE, 4,
+ EGL10.EGL_BLUE_SIZE, 4,
+ // EGL10.EGL_DEPTH_SIZE, 16,
+ // EGL10.EGL_STENCIL_SIZE, EGL10.EGL_DONT_CARE,
+ EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
+ EGL10.EGL_NONE
+ };
private static int[] s_configAttribs3 =
- {
- EGL10.EGL_RED_SIZE, 4,
- EGL10.EGL_GREEN_SIZE, 4,
- EGL10.EGL_BLUE_SIZE, 4,
- // EGL10.EGL_DEPTH_SIZE, 16,
- // EGL10.EGL_STENCIL_SIZE, EGL10.EGL_DONT_CARE,
- EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, //apparently there is no EGL_OPENGL_ES3_BIT
- EGL10.EGL_NONE
- };
+ {
+ EGL10.EGL_RED_SIZE, 4,
+ EGL10.EGL_GREEN_SIZE, 4,
+ EGL10.EGL_BLUE_SIZE, 4,
+ // EGL10.EGL_DEPTH_SIZE, 16,
+ // EGL10.EGL_STENCIL_SIZE, EGL10.EGL_DONT_CARE,
+ EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, //apparently there is no EGL_OPENGL_ES3_BIT
+ EGL10.EGL_NONE
+ };
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
/* Get the number of minimally matching EGL configurations
*/
int[] num_config = new int[1];
- egl.eglChooseConfig(display, use_gl3?s_configAttribs3:s_configAttribs2, null, 0, num_config);
+ egl.eglChooseConfig(display, use_gl3 ? s_configAttribs3 : s_configAttribs2, null, 0, num_config);
int numConfigs = num_config[0];
if (numConfigs <= 0) {
- throw new IllegalArgumentException("No configs match configSpec");
+ throw new IllegalArgumentException("No configs match configSpec");
}
/* Allocate then read the array of minimally matching EGL configs
*/
EGLConfig[] configs = new EGLConfig[numConfigs];
- egl.eglChooseConfig(display, use_gl3?s_configAttribs3:s_configAttribs2, configs, numConfigs, num_config);
+ egl.eglChooseConfig(display, use_gl3 ? s_configAttribs3 : s_configAttribs2, configs, numConfigs, num_config);
if (DEBUG) {
- printConfigs(egl, display, configs);
+ printConfigs(egl, display, configs);
}
/* Now return the "best" one
*/
@@ -514,54 +517,54 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener {
}
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display,
- EGLConfig[] configs) {
- for(EGLConfig config : configs) {
- int d = findConfigAttrib(egl, display, config,
- EGL10.EGL_DEPTH_SIZE, 0);
- int s = findConfigAttrib(egl, display, config,
- EGL10.EGL_STENCIL_SIZE, 0);
-
- // We need at least mDepthSize and mStencilSize bits
- if (d < mDepthSize || s < mStencilSize)
- continue;
-
- // We want an *exact* match for red/green/blue/alpha
- int r = findConfigAttrib(egl, display, config,
- EGL10.EGL_RED_SIZE, 0);
- int g = findConfigAttrib(egl, display, config,
- EGL10.EGL_GREEN_SIZE, 0);
- int b = findConfigAttrib(egl, display, config,
- EGL10.EGL_BLUE_SIZE, 0);
- int a = findConfigAttrib(egl, display, config,
- EGL10.EGL_ALPHA_SIZE, 0);
-
- if (r == mRedSize && g == mGreenSize && b == mBlueSize && a == mAlphaSize)
- return config;
+ EGLConfig[] configs) {
+ for (EGLConfig config : configs) {
+ int d = findConfigAttrib(egl, display, config,
+ EGL10.EGL_DEPTH_SIZE, 0);
+ int s = findConfigAttrib(egl, display, config,
+ EGL10.EGL_STENCIL_SIZE, 0);
+
+ // We need at least mDepthSize and mStencilSize bits
+ if (d < mDepthSize || s < mStencilSize)
+ continue;
+
+ // We want an *exact* match for red/green/blue/alpha
+ int r = findConfigAttrib(egl, display, config,
+ EGL10.EGL_RED_SIZE, 0);
+ int g = findConfigAttrib(egl, display, config,
+ EGL10.EGL_GREEN_SIZE, 0);
+ int b = findConfigAttrib(egl, display, config,
+ EGL10.EGL_BLUE_SIZE, 0);
+ int a = findConfigAttrib(egl, display, config,
+ EGL10.EGL_ALPHA_SIZE, 0);
+
+ if (r == mRedSize && g == mGreenSize && b == mBlueSize && a == mAlphaSize)
+ return config;
}
return null;
}
private int findConfigAttrib(EGL10 egl, EGLDisplay display,
- EGLConfig config, int attribute, int defaultValue) {
+ EGLConfig config, int attribute, int defaultValue) {
if (egl.eglGetConfigAttrib(display, config, attribute, mValue)) {
- return mValue[0];
+ return mValue[0];
}
return defaultValue;
}
private void printConfigs(EGL10 egl, EGLDisplay display,
- EGLConfig[] configs) {
+ EGLConfig[] configs) {
int numConfigs = configs.length;
Log.w(TAG, String.format("%d configurations", numConfigs));
for (int i = 0; i < numConfigs; i++) {
- Log.w(TAG, String.format("Configuration %d:\n", i));
- printConfig(egl, display, configs[i]);
+ Log.w(TAG, String.format("Configuration %d:\n", i));
+ printConfig(egl, display, configs[i]);
}
}
private void printConfig(EGL10 egl, EGLDisplay display,
- EGLConfig config) {
+ EGLConfig config) {
int[] attributes = {
EGL10.EGL_BUFFER_SIZE,
EGL10.EGL_ALPHA_SIZE,
@@ -634,14 +637,15 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener {
};
int[] value = new int[1];
for (int i = 0; i < attributes.length; i++) {
- int attribute = attributes[i];
- String name = names[i];
- if ( egl.eglGetConfigAttrib(display, config, attribute, value)) {
- Log.w(TAG, String.format(" %s: %d\n", name, value[0]));
- } else {
- // Log.w(TAG, String.format(" %s: failed\n", name));
- while (egl.eglGetError() != EGL10.EGL_SUCCESS);
- }
+ int attribute = attributes[i];
+ String name = names[i];
+ if (egl.eglGetConfigAttrib(display, config, attribute, value)) {
+ Log.w(TAG, String.format(" %s: %d\n", name, value[0]));
+ } else {
+ // Log.w(TAG, String.format(" %s: failed\n", name));
+ while (egl.eglGetError() != EGL10.EGL_SUCCESS)
+ ;
+ }
}
}
@@ -657,19 +661,18 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener {
private static class Renderer implements GLSurfaceView.Renderer {
-
public void onDrawFrame(GL10 gl) {
GodotLib.step();
- for(int i=0;i<Godot.singleton_count;i++) {
+ for (int i = 0; i < Godot.singleton_count; i++) {
Godot.singletons[i].onGLDrawFrame(gl);
}
}
public void onSurfaceChanged(GL10 gl, int width, int height) {
- GodotLib.resize(width, height,!firsttime);
- firsttime=false;
- for(int i=0;i<Godot.singleton_count;i++) {
+ GodotLib.resize(width, height, !firsttime);
+ firsttime = false;
+ for (int i = 0; i < Godot.singleton_count; i++) {
Godot.singletons[i].onGLSurfaceChanged(gl, width, height);
}
}
diff --git a/platform/android/java/src/org/godotengine/godot/input/GodotEditText.java b/platform/android/java/src/org/godotengine/godot/input/GodotEditText.java
index d8a3ac5591..9e062d89c6 100644
--- a/platform/android/java/src/org/godotengine/godot/input/GodotEditText.java
+++ b/platform/android/java/src/org/godotengine/godot/input/GodotEditText.java
@@ -70,42 +70,37 @@ public class GodotEditText extends EditText {
super(context, attrs, defStyle);
this.initView();
}
-
+
protected void initView() {
- this.setPadding(0, 0, 0, 0);
+ this.setPadding(0, 0, 0, 0);
this.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
-
+
sHandler = new Handler() {
@Override
public void handleMessage(final Message msg) {
switch (msg.what) {
- case HANDLER_OPEN_IME_KEYBOARD:
- {
- GodotEditText edit = (GodotEditText) msg.obj;
- String text = edit.mOriginText;
- if (edit.requestFocus())
- {
- edit.removeTextChangedListener(edit.mInputWrapper);
- edit.setText("");
- edit.append(text);
- edit.mInputWrapper.setOriginText(text);
- edit.addTextChangedListener(edit.mInputWrapper);
- final InputMethodManager imm = (InputMethodManager) mView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.showSoftInput(edit, 0);
- }
+ case HANDLER_OPEN_IME_KEYBOARD: {
+ GodotEditText edit = (GodotEditText)msg.obj;
+ String text = edit.mOriginText;
+ if (edit.requestFocus()) {
+ edit.removeTextChangedListener(edit.mInputWrapper);
+ edit.setText("");
+ edit.append(text);
+ edit.mInputWrapper.setOriginText(text);
+ edit.addTextChangedListener(edit.mInputWrapper);
+ final InputMethodManager imm = (InputMethodManager)mView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
+ imm.showSoftInput(edit, 0);
}
- break;
-
- case HANDLER_CLOSE_IME_KEYBOARD:
- {
- GodotEditText edit = (GodotEditText) msg.obj;
-
- edit.removeTextChangedListener(mInputWrapper);
- final InputMethodManager imm = (InputMethodManager) mView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.hideSoftInputFromWindow(edit.getWindowToken(), 0);
- edit.mView.requestFocus();
- }
- break;
+ } break;
+
+ case HANDLER_CLOSE_IME_KEYBOARD: {
+ GodotEditText edit = (GodotEditText)msg.obj;
+
+ edit.removeTextChangedListener(mInputWrapper);
+ final InputMethodManager imm = (InputMethodManager)mView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
+ imm.hideSoftInputFromWindow(edit.getWindowToken(), 0);
+ edit.mView.requestFocus();
+ } break;
}
}
};
@@ -116,7 +111,7 @@ public class GodotEditText extends EditText {
// ===========================================================
public void setView(final GodotView view) {
this.mView = view;
- if(mInputWrapper == null)
+ if (mInputWrapper == null)
mInputWrapper = new GodotTextInputWrapper(mView, this);
this.setOnEditorActionListener(mInputWrapper);
view.requestFocus();
@@ -125,7 +120,7 @@ public class GodotEditText extends EditText {
// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================
- @Override
+ @Override
public boolean onKeyDown(final int keyCode, final KeyEvent keyEvent) {
super.onKeyDown(keyCode, keyEvent);
@@ -142,7 +137,7 @@ public class GodotEditText extends EditText {
// ===========================================================
public void showKeyboard(String p_existing_text) {
this.mOriginText = p_existing_text;
-
+
final Message msg = new Message();
msg.what = HANDLER_OPEN_IME_KEYBOARD;
msg.obj = this;
@@ -155,7 +150,7 @@ public class GodotEditText extends EditText {
msg.obj = this;
sHandler.sendMessage(msg);
}
-
+
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
diff --git a/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java b/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java
index ac424ab9f8..8e34d9e9e7 100644
--- a/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java
+++ b/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java
@@ -67,7 +67,7 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene
private boolean isFullScreenEdit() {
final TextView textField = this.mEdit;
- final InputMethodManager imm = (InputMethodManager) textField.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
+ final InputMethodManager imm = (InputMethodManager)textField.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
return imm.isFullscreenMode();
}
@@ -81,7 +81,6 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene
@Override
public void afterTextChanged(final Editable s) {
-
}
@Override
diff --git a/platform/android/java/src/org/godotengine/godot/input/InputManagerCompat.java b/platform/android/java/src/org/godotengine/godot/input/InputManagerCompat.java
index 4615d2fbb5..0a876d2b7f 100644
--- a/platform/android/java/src/org/godotengine/godot/input/InputManagerCompat.java
+++ b/platform/android/java/src/org/godotengine/godot/input/InputManagerCompat.java
@@ -23,118 +23,118 @@ import android.view.InputDevice;
import android.view.MotionEvent;
public interface InputManagerCompat {
- /**
- * Gets information about the input device with the specified id.
- *
- * @param id The device id
- * @return The input device or null if not found
- */
- public InputDevice getInputDevice(int id);
+ /**
+ * Gets information about the input device with the specified id.
+ *
+ * @param id The device id
+ * @return The input device or null if not found
+ */
+ public InputDevice getInputDevice(int id);
- /**
- * Gets the ids of all input devices in the system.
- *
- * @return The input device ids.
- */
- public int[] getInputDeviceIds();
+ /**
+ * Gets the ids of all input devices in the system.
+ *
+ * @return The input device ids.
+ */
+ public int[] getInputDeviceIds();
- /**
- * Registers an input device listener to receive notifications about when
- * input devices are added, removed or changed.
- *
- * @param listener The listener to register.
- * @param handler The handler on which the listener should be invoked, or
- * null if the listener should be invoked on the calling thread's
- * looper.
- */
- public void registerInputDeviceListener(InputManagerCompat.InputDeviceListener listener,
- Handler handler);
+ /**
+ * Registers an input device listener to receive notifications about when
+ * input devices are added, removed or changed.
+ *
+ * @param listener The listener to register.
+ * @param handler The handler on which the listener should be invoked, or
+ * null if the listener should be invoked on the calling thread's
+ * looper.
+ */
+ public void registerInputDeviceListener(InputManagerCompat.InputDeviceListener listener,
+ Handler handler);
- /**
- * Unregisters an input device listener.
- *
- * @param listener The listener to unregister.
- */
- public void unregisterInputDeviceListener(InputManagerCompat.InputDeviceListener listener);
+ /**
+ * Unregisters an input device listener.
+ *
+ * @param listener The listener to unregister.
+ */
+ public void unregisterInputDeviceListener(InputManagerCompat.InputDeviceListener listener);
- /*
- * The following three calls are to simulate V16 behavior on pre-Jellybean
- * devices. If you don't call them, your callback will never be called
- * pre-API 16.
- */
+ /*
+ * The following three calls are to simulate V16 behavior on pre-Jellybean
+ * devices. If you don't call them, your callback will never be called
+ * pre-API 16.
+ */
- /**
- * Pass the motion events to the InputManagerCompat. This is used to
- * optimize for polling for controllers. If you do not pass these events in,
- * polling will cause regular object creation.
- *
- * @param event the motion event from the app
- */
- public void onGenericMotionEvent(MotionEvent event);
+ /**
+ * Pass the motion events to the InputManagerCompat. This is used to
+ * optimize for polling for controllers. If you do not pass these events in,
+ * polling will cause regular object creation.
+ *
+ * @param event the motion event from the app
+ */
+ public void onGenericMotionEvent(MotionEvent event);
- /**
- * Tell the V9 input manager that it should stop polling for disconnected
- * devices. You can call this during onPause in your activity, although you
- * might want to call it whenever your game is not active (or whenever you
- * don't care about being notified of new input devices)
- */
- public void onPause();
+ /**
+ * Tell the V9 input manager that it should stop polling for disconnected
+ * devices. You can call this during onPause in your activity, although you
+ * might want to call it whenever your game is not active (or whenever you
+ * don't care about being notified of new input devices)
+ */
+ public void onPause();
- /**
- * Tell the V9 input manager that it should start polling for disconnected
- * devices. You can call this during onResume in your activity, although you
- * might want to call it less often (only when the gameplay is actually
- * active)
- */
- public void onResume();
+ /**
+ * Tell the V9 input manager that it should start polling for disconnected
+ * devices. You can call this during onResume in your activity, although you
+ * might want to call it less often (only when the gameplay is actually
+ * active)
+ */
+ public void onResume();
- public interface InputDeviceListener {
- /**
- * Called whenever the input manager detects that a device has been
- * added. This will only be called in the V9 version when a motion event
- * is detected.
- *
- * @param deviceId The id of the input device that was added.
- */
- void onInputDeviceAdded(int deviceId);
+ public interface InputDeviceListener {
+ /**
+ * Called whenever the input manager detects that a device has been
+ * added. This will only be called in the V9 version when a motion event
+ * is detected.
+ *
+ * @param deviceId The id of the input device that was added.
+ */
+ void onInputDeviceAdded(int deviceId);
- /**
- * Called whenever the properties of an input device have changed since
- * they were last queried. This will not be called for the V9 version of
- * the API.
- *
- * @param deviceId The id of the input device that changed.
- */
- void onInputDeviceChanged(int deviceId);
+ /**
+ * Called whenever the properties of an input device have changed since
+ * they were last queried. This will not be called for the V9 version of
+ * the API.
+ *
+ * @param deviceId The id of the input device that changed.
+ */
+ void onInputDeviceChanged(int deviceId);
- /**
- * Called whenever the input manager detects that a device has been
- * removed. For the V9 version, this can take some time depending on the
- * poll rate.
- *
- * @param deviceId The id of the input device that was removed.
- */
- void onInputDeviceRemoved(int deviceId);
- }
+ /**
+ * Called whenever the input manager detects that a device has been
+ * removed. For the V9 version, this can take some time depending on the
+ * poll rate.
+ *
+ * @param deviceId The id of the input device that was removed.
+ */
+ void onInputDeviceRemoved(int deviceId);
+ }
- /**
- * Use this to construct a compatible InputManager.
- */
- public static class Factory {
+ /**
+ * Use this to construct a compatible InputManager.
+ */
+ public static class Factory {
- /**
- * Constructs and returns a compatible InputManger
- *
- * @param context the Context that will be used to get the system
- * service from
- * @return a compatible implementation of InputManager
- */
- public static InputManagerCompat getInputManager(Context context) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
- return new InputManagerV16(context);
- } else {
- return new InputManagerV9();
- }
- }
- }
+ /**
+ * Constructs and returns a compatible InputManger
+ *
+ * @param context the Context that will be used to get the system
+ * service from
+ * @return a compatible implementation of InputManager
+ */
+ public static InputManagerCompat getInputManager(Context context) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
+ return new InputManagerV16(context);
+ } else {
+ return new InputManagerV9();
+ }
+ }
+ }
}
diff --git a/platform/android/java/src/org/godotengine/godot/input/InputManagerV16.java b/platform/android/java/src/org/godotengine/godot/input/InputManagerV16.java
index f05701f455..3b88609cc9 100644
--- a/platform/android/java/src/org/godotengine/godot/input/InputManagerV16.java
+++ b/platform/android/java/src/org/godotengine/godot/input/InputManagerV16.java
@@ -30,78 +30,74 @@ import java.util.Map;
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public class InputManagerV16 implements InputManagerCompat {
- private final InputManager mInputManager;
- private final Map<InputManagerCompat.InputDeviceListener, V16InputDeviceListener> mListeners;
-
- public InputManagerV16(Context context) {
- mInputManager = (InputManager) context.getSystemService(Context.INPUT_SERVICE);
- mListeners = new HashMap<InputManagerCompat.InputDeviceListener, V16InputDeviceListener>();
- }
-
- @Override
- public InputDevice getInputDevice(int id) {
- return mInputManager.getInputDevice(id);
- }
-
- @Override
- public int[] getInputDeviceIds() {
- return mInputManager.getInputDeviceIds();
- }
-
- static class V16InputDeviceListener implements InputManager.InputDeviceListener {
- final InputManagerCompat.InputDeviceListener mIDL;
-
- public V16InputDeviceListener(InputDeviceListener idl) {
- mIDL = idl;
- }
-
- @Override
- public void onInputDeviceAdded(int deviceId) {
- mIDL.onInputDeviceAdded(deviceId);
- }
-
- @Override
- public void onInputDeviceChanged(int deviceId) {
- mIDL.onInputDeviceChanged(deviceId);
- }
-
- @Override
- public void onInputDeviceRemoved(int deviceId) {
- mIDL.onInputDeviceRemoved(deviceId);
- }
-
- }
-
- @Override
- public void registerInputDeviceListener(InputDeviceListener listener, Handler handler) {
- V16InputDeviceListener v16Listener = new V16InputDeviceListener(listener);
- mInputManager.registerInputDeviceListener(v16Listener, handler);
- mListeners.put(listener, v16Listener);
- }
-
- @Override
- public void unregisterInputDeviceListener(InputDeviceListener listener) {
- V16InputDeviceListener curListener = mListeners.remove(listener);
- if (null != curListener)
- {
- mInputManager.unregisterInputDeviceListener(curListener);
- }
-
- }
-
- @Override
- public void onGenericMotionEvent(MotionEvent event) {
- // unused in V16
- }
-
- @Override
- public void onPause() {
- // unused in V16
- }
-
- @Override
- public void onResume() {
- // unused in V16
- }
-
+ private final InputManager mInputManager;
+ private final Map<InputManagerCompat.InputDeviceListener, V16InputDeviceListener> mListeners;
+
+ public InputManagerV16(Context context) {
+ mInputManager = (InputManager)context.getSystemService(Context.INPUT_SERVICE);
+ mListeners = new HashMap<InputManagerCompat.InputDeviceListener, V16InputDeviceListener>();
+ }
+
+ @Override
+ public InputDevice getInputDevice(int id) {
+ return mInputManager.getInputDevice(id);
+ }
+
+ @Override
+ public int[] getInputDeviceIds() {
+ return mInputManager.getInputDeviceIds();
+ }
+
+ static class V16InputDeviceListener implements InputManager.InputDeviceListener {
+ final InputManagerCompat.InputDeviceListener mIDL;
+
+ public V16InputDeviceListener(InputDeviceListener idl) {
+ mIDL = idl;
+ }
+
+ @Override
+ public void onInputDeviceAdded(int deviceId) {
+ mIDL.onInputDeviceAdded(deviceId);
+ }
+
+ @Override
+ public void onInputDeviceChanged(int deviceId) {
+ mIDL.onInputDeviceChanged(deviceId);
+ }
+
+ @Override
+ public void onInputDeviceRemoved(int deviceId) {
+ mIDL.onInputDeviceRemoved(deviceId);
+ }
+ }
+
+ @Override
+ public void registerInputDeviceListener(InputDeviceListener listener, Handler handler) {
+ V16InputDeviceListener v16Listener = new V16InputDeviceListener(listener);
+ mInputManager.registerInputDeviceListener(v16Listener, handler);
+ mListeners.put(listener, v16Listener);
+ }
+
+ @Override
+ public void unregisterInputDeviceListener(InputDeviceListener listener) {
+ V16InputDeviceListener curListener = mListeners.remove(listener);
+ if (null != curListener) {
+ mInputManager.unregisterInputDeviceListener(curListener);
+ }
+ }
+
+ @Override
+ public void onGenericMotionEvent(MotionEvent event) {
+ // unused in V16
+ }
+
+ @Override
+ public void onPause() {
+ // unused in V16
+ }
+
+ @Override
+ public void onResume() {
+ // unused in V16
+ }
}
diff --git a/platform/android/java/src/org/godotengine/godot/input/InputManagerV9.java b/platform/android/java/src/org/godotengine/godot/input/InputManagerV9.java
index 0334c00997..a1418c5899 100644
--- a/platform/android/java/src/org/godotengine/godot/input/InputManagerV9.java
+++ b/platform/android/java/src/org/godotengine/godot/input/InputManagerV9.java
@@ -31,181 +31,179 @@ import java.util.Map;
import java.util.Queue;
public class InputManagerV9 implements InputManagerCompat {
- private static final String LOG_TAG = "InputManagerV9";
- private static final int MESSAGE_TEST_FOR_DISCONNECT = 101;
- private static final long CHECK_ELAPSED_TIME = 3000L;
-
- private static final int ON_DEVICE_ADDED = 0;
- private static final int ON_DEVICE_CHANGED = 1;
- private static final int ON_DEVICE_REMOVED = 2;
-
- private final SparseArray<long[]> mDevices;
- private final Map<InputDeviceListener, Handler> mListeners;
- private final Handler mDefaultHandler;
-
- private static class PollingMessageHandler extends Handler {
- private final WeakReference<InputManagerV9> mInputManager;
-
- PollingMessageHandler(InputManagerV9 im) {
- mInputManager = new WeakReference<InputManagerV9>(im);
- }
-
- @Override
- public void handleMessage(Message msg) {
- super.handleMessage(msg);
- switch (msg.what) {
- case MESSAGE_TEST_FOR_DISCONNECT:
- InputManagerV9 imv = mInputManager.get();
- if (null != imv) {
- long time = SystemClock.elapsedRealtime();
- int size = imv.mDevices.size();
- for (int i = 0; i < size; i++) {
- long[] lastContact = imv.mDevices.valueAt(i);
- if (null != lastContact) {
- if (time - lastContact[0] > CHECK_ELAPSED_TIME) {
- // check to see if the device has been
- // disconnected
- int id = imv.mDevices.keyAt(i);
- if (null == InputDevice.getDevice(id)) {
- // disconnected!
- imv.notifyListeners(ON_DEVICE_REMOVED, id);
- imv.mDevices.remove(id);
- } else {
- lastContact[0] = time;
- }
- }
- }
- }
- sendEmptyMessageDelayed(MESSAGE_TEST_FOR_DISCONNECT,
- CHECK_ELAPSED_TIME);
- }
- break;
- }
- }
-
- }
-
- public InputManagerV9() {
- mDevices = new SparseArray<long[]>();
- mListeners = new HashMap<InputDeviceListener, Handler>();
- mDefaultHandler = new PollingMessageHandler(this);
- // as a side-effect, populates our collection of watched
- // input devices
- getInputDeviceIds();
- }
-
- @Override
- public InputDevice getInputDevice(int id) {
- return InputDevice.getDevice(id);
- }
-
- @Override
- public int[] getInputDeviceIds() {
- // add any hitherto unknown devices to our
- // collection of watched input devices
- int[] activeDevices = InputDevice.getDeviceIds();
- long time = SystemClock.elapsedRealtime();
- for ( int id : activeDevices ) {
- long[] lastContact = mDevices.get(id);
- if ( null == lastContact ) {
- // we have a new device
- mDevices.put(id, new long[] { time });
- }
- }
- return activeDevices;
- }
-
- @Override
- public void registerInputDeviceListener(InputDeviceListener listener, Handler handler) {
- mListeners.remove(listener);
- if (handler == null) {
- handler = mDefaultHandler;
- }
- mListeners.put(listener, handler);
- }
-
- @Override
- public void unregisterInputDeviceListener(InputDeviceListener listener) {
- mListeners.remove(listener);
- }
-
- private void notifyListeners(int why, int deviceId) {
- // the state of some device has changed
- if (!mListeners.isEmpty()) {
- // yes... this will cause an object to get created... hopefully
- // it won't happen very often
- for (InputDeviceListener listener : mListeners.keySet()) {
- Handler handler = mListeners.get(listener);
- DeviceEvent odc = DeviceEvent.getDeviceEvent(why, deviceId, listener);
- handler.post(odc);
- }
- }
- }
-
- private static class DeviceEvent implements Runnable {
- private int mMessageType;
- private int mId;
- private InputDeviceListener mListener;
- private static Queue<DeviceEvent> sEventQueue = new ArrayDeque<DeviceEvent>();
-
- private DeviceEvent() {
- }
-
- static DeviceEvent getDeviceEvent(int messageType, int id,
- InputDeviceListener listener) {
- DeviceEvent curChanged = sEventQueue.poll();
- if (null == curChanged) {
- curChanged = new DeviceEvent();
- }
- curChanged.mMessageType = messageType;
- curChanged.mId = id;
- curChanged.mListener = listener;
- return curChanged;
- }
-
- @Override
- public void run() {
- switch (mMessageType) {
- case ON_DEVICE_ADDED:
- mListener.onInputDeviceAdded(mId);
- break;
- case ON_DEVICE_CHANGED:
- mListener.onInputDeviceChanged(mId);
- break;
- case ON_DEVICE_REMOVED:
- mListener.onInputDeviceRemoved(mId);
- break;
- default:
- Log.e(LOG_TAG, "Unknown Message Type");
- break;
- }
- // dump this runnable back in the queue
- sEventQueue.offer(this);
- }
- }
-
- @Override
- public void onGenericMotionEvent(MotionEvent event) {
- // detect new devices
- int id = event.getDeviceId();
- long[] timeArray = mDevices.get(id);
- if (null == timeArray) {
- notifyListeners(ON_DEVICE_ADDED, id);
- timeArray = new long[1];
- mDevices.put(id, timeArray);
- }
- long time = SystemClock.elapsedRealtime();
- timeArray[0] = time;
- }
-
- @Override
- public void onPause() {
- mDefaultHandler.removeMessages(MESSAGE_TEST_FOR_DISCONNECT);
- }
-
- @Override
- public void onResume() {
- mDefaultHandler.sendEmptyMessage(MESSAGE_TEST_FOR_DISCONNECT);
- }
-
+ private static final String LOG_TAG = "InputManagerV9";
+ private static final int MESSAGE_TEST_FOR_DISCONNECT = 101;
+ private static final long CHECK_ELAPSED_TIME = 3000L;
+
+ private static final int ON_DEVICE_ADDED = 0;
+ private static final int ON_DEVICE_CHANGED = 1;
+ private static final int ON_DEVICE_REMOVED = 2;
+
+ private final SparseArray<long[]> mDevices;
+ private final Map<InputDeviceListener, Handler> mListeners;
+ private final Handler mDefaultHandler;
+
+ private static class PollingMessageHandler extends Handler {
+ private final WeakReference<InputManagerV9> mInputManager;
+
+ PollingMessageHandler(InputManagerV9 im) {
+ mInputManager = new WeakReference<InputManagerV9>(im);
+ }
+
+ @Override
+ public void handleMessage(Message msg) {
+ super.handleMessage(msg);
+ switch (msg.what) {
+ case MESSAGE_TEST_FOR_DISCONNECT:
+ InputManagerV9 imv = mInputManager.get();
+ if (null != imv) {
+ long time = SystemClock.elapsedRealtime();
+ int size = imv.mDevices.size();
+ for (int i = 0; i < size; i++) {
+ long[] lastContact = imv.mDevices.valueAt(i);
+ if (null != lastContact) {
+ if (time - lastContact[0] > CHECK_ELAPSED_TIME) {
+ // check to see if the device has been
+ // disconnected
+ int id = imv.mDevices.keyAt(i);
+ if (null == InputDevice.getDevice(id)) {
+ // disconnected!
+ imv.notifyListeners(ON_DEVICE_REMOVED, id);
+ imv.mDevices.remove(id);
+ } else {
+ lastContact[0] = time;
+ }
+ }
+ }
+ }
+ sendEmptyMessageDelayed(MESSAGE_TEST_FOR_DISCONNECT,
+ CHECK_ELAPSED_TIME);
+ }
+ break;
+ }
+ }
+ }
+
+ public InputManagerV9() {
+ mDevices = new SparseArray<long[]>();
+ mListeners = new HashMap<InputDeviceListener, Handler>();
+ mDefaultHandler = new PollingMessageHandler(this);
+ // as a side-effect, populates our collection of watched
+ // input devices
+ getInputDeviceIds();
+ }
+
+ @Override
+ public InputDevice getInputDevice(int id) {
+ return InputDevice.getDevice(id);
+ }
+
+ @Override
+ public int[] getInputDeviceIds() {
+ // add any hitherto unknown devices to our
+ // collection of watched input devices
+ int[] activeDevices = InputDevice.getDeviceIds();
+ long time = SystemClock.elapsedRealtime();
+ for (int id : activeDevices) {
+ long[] lastContact = mDevices.get(id);
+ if (null == lastContact) {
+ // we have a new device
+ mDevices.put(id, new long[] { time });
+ }
+ }
+ return activeDevices;
+ }
+
+ @Override
+ public void registerInputDeviceListener(InputDeviceListener listener, Handler handler) {
+ mListeners.remove(listener);
+ if (handler == null) {
+ handler = mDefaultHandler;
+ }
+ mListeners.put(listener, handler);
+ }
+
+ @Override
+ public void unregisterInputDeviceListener(InputDeviceListener listener) {
+ mListeners.remove(listener);
+ }
+
+ private void notifyListeners(int why, int deviceId) {
+ // the state of some device has changed
+ if (!mListeners.isEmpty()) {
+ // yes... this will cause an object to get created... hopefully
+ // it won't happen very often
+ for (InputDeviceListener listener : mListeners.keySet()) {
+ Handler handler = mListeners.get(listener);
+ DeviceEvent odc = DeviceEvent.getDeviceEvent(why, deviceId, listener);
+ handler.post(odc);
+ }
+ }
+ }
+
+ private static class DeviceEvent implements Runnable {
+ private int mMessageType;
+ private int mId;
+ private InputDeviceListener mListener;
+ private static Queue<DeviceEvent> sEventQueue = new ArrayDeque<DeviceEvent>();
+
+ private DeviceEvent() {
+ }
+
+ static DeviceEvent getDeviceEvent(int messageType, int id,
+ InputDeviceListener listener) {
+ DeviceEvent curChanged = sEventQueue.poll();
+ if (null == curChanged) {
+ curChanged = new DeviceEvent();
+ }
+ curChanged.mMessageType = messageType;
+ curChanged.mId = id;
+ curChanged.mListener = listener;
+ return curChanged;
+ }
+
+ @Override
+ public void run() {
+ switch (mMessageType) {
+ case ON_DEVICE_ADDED:
+ mListener.onInputDeviceAdded(mId);
+ break;
+ case ON_DEVICE_CHANGED:
+ mListener.onInputDeviceChanged(mId);
+ break;
+ case ON_DEVICE_REMOVED:
+ mListener.onInputDeviceRemoved(mId);
+ break;
+ default:
+ Log.e(LOG_TAG, "Unknown Message Type");
+ break;
+ }
+ // dump this runnable back in the queue
+ sEventQueue.offer(this);
+ }
+ }
+
+ @Override
+ public void onGenericMotionEvent(MotionEvent event) {
+ // detect new devices
+ int id = event.getDeviceId();
+ long[] timeArray = mDevices.get(id);
+ if (null == timeArray) {
+ notifyListeners(ON_DEVICE_ADDED, id);
+ timeArray = new long[1];
+ mDevices.put(id, timeArray);
+ }
+ long time = SystemClock.elapsedRealtime();
+ timeArray[0] = time;
+ }
+
+ @Override
+ public void onPause() {
+ mDefaultHandler.removeMessages(MESSAGE_TEST_FOR_DISCONNECT);
+ }
+
+ @Override
+ public void onResume() {
+ mDefaultHandler.sendEmptyMessage(MESSAGE_TEST_FOR_DISCONNECT);
+ }
}
diff --git a/platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java b/platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java
index 8622f4ccff..d6f26e19b2 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java
@@ -39,33 +39,32 @@ import android.util.Log;
abstract public class ConsumeTask {
private Context context;
-
+
private IInAppBillingService mService;
- public ConsumeTask(IInAppBillingService mService, Context context ){
+ public ConsumeTask(IInAppBillingService mService, Context context) {
this.context = context;
this.mService = mService;
}
-
- public void consume(final String sku){
+ public void consume(final String sku) {
//Log.d("XXX", "Consuming product " + sku);
PaymentsCache pc = new PaymentsCache(context);
Boolean isBlocked = pc.getConsumableFlag("block", sku);
String _token = pc.getConsumableValue("token", sku);
- //Log.d("XXX", "token " + _token);
- if(!isBlocked && _token == null){
+ //Log.d("XXX", "token " + _token);
+ if (!isBlocked && _token == null) {
//_token = "inapp:"+context.getPackageName()+":android.test.purchased";
//Log.d("XXX", "Consuming product " + sku + " with token " + _token);
- }else if(!isBlocked){
+ } else if (!isBlocked) {
//Log.d("XXX", "It is not blocked ¿?");
return;
- }else if(_token == null){
+ } else if (_token == null) {
//Log.d("XXX", "No token available");
this.error("No token for sku:" + sku);
return;
}
final String token = _token;
- new AsyncTask<String, String, String>(){
+ new AsyncTask<String, String, String>() {
@Override
protected String doInBackground(String... params) {
@@ -73,28 +72,27 @@ abstract public class ConsumeTask {
//Log.d("XXX", "Requesting to release item.");
int response = mService.consumePurchase(3, context.getPackageName(), token);
//Log.d("XXX", "release response code: " + response);
- if(response == 0 || response == 8){
+ if (response == 0 || response == 8) {
return null;
}
} catch (RemoteException e) {
return e.getMessage();
-
}
return "Some error";
}
-
- protected void onPostExecute(String param){
- if(param == null){
- success( new PaymentsCache(context).getConsumableValue("ticket", sku) );
- }else{
+
+ protected void onPostExecute(String param) {
+ if (param == null) {
+ success(new PaymentsCache(context).getConsumableValue("ticket", sku));
+ } else {
error(param);
}
}
-
- }.execute();
+
+ }
+ .execute();
}
-
+
abstract protected void success(String ticket);
abstract protected void error(String message);
-
}
diff --git a/platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java b/platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java
index 0afe35510c..31f6396738 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java
@@ -36,15 +36,12 @@ import android.os.AsyncTask;
import android.os.RemoteException;
import android.util.Log;
-abstract public class GenericConsumeTask extends AsyncTask<String, String, String>{
+abstract public class GenericConsumeTask extends AsyncTask<String, String, String> {
private Context context;
private IInAppBillingService mService;
-
-
-
- public GenericConsumeTask(Context context, IInAppBillingService mService, String sku, String receipt, String signature, String token){
+ public GenericConsumeTask(Context context, IInAppBillingService mService, String sku, String receipt, String signature, String token) {
this.context = context;
this.mService = mService;
this.sku = sku;
@@ -52,19 +49,19 @@ abstract public class GenericConsumeTask extends AsyncTask<String, String, Strin
this.signature = signature;
this.token = token;
}
-
+
private String sku;
private String receipt;
private String signature;
private String token;
-
+
@Override
protected String doInBackground(String... params) {
try {
//Log.d("godot", "Requesting to consume an item with token ." + token);
int response = mService.consumePurchase(3, context.getPackageName(), token);
//Log.d("godot", "consumePurchase response: " + response);
- if(response == 0 || response == 8){
+ if (response == 0 || response == 8) {
return null;
}
} catch (Exception e) {
@@ -72,11 +69,10 @@ abstract public class GenericConsumeTask extends AsyncTask<String, String, Strin
}
return null;
}
-
- protected void onPostExecute(String sarasa){
+
+ protected void onPostExecute(String sarasa) {
onSuccess(sku, receipt, signature, token);
}
-
- abstract public void onSuccess(String sku, String receipt, String signature, String token);
+ abstract public void onSuccess(String sku, String receipt, String signature, String token);
}
diff --git a/platform/android/java/src/org/godotengine/godot/payments/HandlePurchaseTask.java b/platform/android/java/src/org/godotengine/godot/payments/HandlePurchaseTask.java
index 7318ae2fc6..80f53d16c8 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/HandlePurchaseTask.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/HandlePurchaseTask.java
@@ -50,28 +50,26 @@ import android.util.Log;
abstract public class HandlePurchaseTask {
private Activity context;
-
- public HandlePurchaseTask(Activity context ){
+
+ public HandlePurchaseTask(Activity context) {
this.context = context;
}
-
-
- public void handlePurchaseRequest(int resultCode, Intent data){
+
+ public void handlePurchaseRequest(int resultCode, Intent data) {
//Log.d("XXX", "Handling purchase response");
//int responseCode = data.getIntExtra("RESPONSE_CODE", 0);
PaymentsCache pc = new PaymentsCache(context);
-
+
String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA");
//Log.d("XXX", "Purchase data:" + purchaseData);
String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE");
//Log.d("XXX", "Purchase signature:" + dataSignature);
-
+
if (resultCode == Activity.RESULT_OK) {
-
+
try {
//Log.d("SARLANGA", purchaseData);
-
-
+
JSONObject jo = new JSONObject(purchaseData);
//String sku = jo.getString("productId");
//alert("You have bought the " + sku + ". Excellent choice, aventurer!");
@@ -82,8 +80,8 @@ abstract public class HandlePurchaseTask {
//Integer state = jo.getInt("purchaseState");
String developerPayload = jo.getString("developerPayload");
String purchaseToken = jo.getString("purchaseToken");
-
- if(! pc.getConsumableValue("validation_hash", productId).equals(developerPayload) ) {
+
+ if (!pc.getConsumableValue("validation_hash", productId).equals(developerPayload)) {
error("Untrusted callback");
return;
}
@@ -92,13 +90,13 @@ abstract public class HandlePurchaseTask {
pc.setConsumableValue("ticket", productId, purchaseData);
pc.setConsumableFlag("block", productId, true);
pc.setConsumableValue("token", productId, purchaseToken);
-
+
success(productId, dataSignature, purchaseData);
return;
- } catch (JSONException e) {
+ } catch (JSONException e) {
error(e.getMessage());
}
- }else if( resultCode == Activity.RESULT_CANCELED){
+ } else if (resultCode == Activity.RESULT_CANCELED) {
canceled();
}
}
@@ -106,6 +104,4 @@ abstract public class HandlePurchaseTask {
abstract protected void success(String sku, String signature, String ticket);
abstract protected void error(String message);
abstract protected void canceled();
-
-
}
diff --git a/platform/android/java/src/org/godotengine/godot/payments/PaymentsCache.java b/platform/android/java/src/org/godotengine/godot/payments/PaymentsCache.java
index 69ac02e902..f9828ef77d 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/PaymentsCache.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/PaymentsCache.java
@@ -34,41 +34,38 @@ import android.content.SharedPreferences;
import android.util.Log;
public class PaymentsCache {
-
+
public Context context;
- public PaymentsCache(Context context){
+ public PaymentsCache(Context context) {
this.context = context;
}
-
-
- public void setConsumableFlag(String set, String sku, Boolean flag){
- SharedPreferences sharedPref = context.getSharedPreferences("consumables_" + set, Context.MODE_PRIVATE);
- SharedPreferences.Editor editor = sharedPref.edit();
- editor.putBoolean(sku, flag);
- editor.commit();
-}
- public boolean getConsumableFlag(String set, String sku){
- SharedPreferences sharedPref = context.getSharedPreferences(
- "consumables_" + set, Context.MODE_PRIVATE);
- return sharedPref.getBoolean(sku, false);
+ public void setConsumableFlag(String set, String sku, Boolean flag) {
+ SharedPreferences sharedPref = context.getSharedPreferences("consumables_" + set, Context.MODE_PRIVATE);
+ SharedPreferences.Editor editor = sharedPref.edit();
+ editor.putBoolean(sku, flag);
+ editor.commit();
}
+ public boolean getConsumableFlag(String set, String sku) {
+ SharedPreferences sharedPref = context.getSharedPreferences(
+ "consumables_" + set, Context.MODE_PRIVATE);
+ return sharedPref.getBoolean(sku, false);
+ }
- public void setConsumableValue(String set, String sku, String value){
- SharedPreferences sharedPref = context.getSharedPreferences("consumables_" + set, Context.MODE_PRIVATE);
- SharedPreferences.Editor editor = sharedPref.edit();
- editor.putString(sku, value);
+ public void setConsumableValue(String set, String sku, String value) {
+ SharedPreferences sharedPref = context.getSharedPreferences("consumables_" + set, Context.MODE_PRIVATE);
+ SharedPreferences.Editor editor = sharedPref.edit();
+ editor.putString(sku, value);
//Log.d("XXX", "Setting asset: consumables_" + set + ":" + sku);
- editor.commit();
+ editor.commit();
}
- public String getConsumableValue(String set, String sku){
- SharedPreferences sharedPref = context.getSharedPreferences(
- "consumables_" + set, Context.MODE_PRIVATE);
+ public String getConsumableValue(String set, String sku) {
+ SharedPreferences sharedPref = context.getSharedPreferences(
+ "consumables_" + set, Context.MODE_PRIVATE);
//Log.d("XXX", "Getting asset: consumables_" + set + ":" + sku);
- return sharedPref.getString(sku, null);
+ return sharedPref.getString(sku, null);
}
-
}
diff --git a/platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java b/platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java
index b327265abb..71407566e2 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java
@@ -106,7 +106,6 @@ public class PaymentsManager {
@Override
protected void error(String message) {
godotPaymentV3.callbackFail();
-
}
@Override
@@ -119,8 +118,8 @@ public class PaymentsManager {
godotPaymentV3.callbackAlreadyOwned(sku);
}
- }.purchase(sku, transactionId);
-
+ }
+ .purchase(sku, transactionId);
}
public void consumeUnconsumedPurchases() {
@@ -135,16 +134,15 @@ public class PaymentsManager {
protected void error(String message) {
Log.d("godot", "consumeUnconsumedPurchases :" + message);
godotPaymentV3.callbackFailConsume();
-
}
@Override
protected void notRequired() {
Log.d("godot", "callbackSuccessNoUnconsumedPurchases :");
godotPaymentV3.callbackSuccessNoUnconsumedPurchases();
-
}
- }.consumeItAll();
+ }
+ .consumeItAll();
}
public void requestPurchased() {
@@ -210,9 +208,9 @@ public class PaymentsManager {
@Override
protected void error(String message) {
godotPaymentV3.callbackFail();
-
}
- }.consume(sku);
+ }
+ .consume(sku);
}
}
@@ -225,7 +223,8 @@ public class PaymentsManager {
protected void canceled() {
godotPaymentV3.callbackCancel();
}
- }.handlePurchaseRequest(resultCode, data);
+ }
+ .handlePurchaseRequest(resultCode, data);
}
public void validatePurchase(String purchaseToken, final String sku) {
@@ -246,8 +245,8 @@ public class PaymentsManager {
protected void error(String message) {
godotPaymentV3.callbackFail();
}
- }.consume(sku);
-
+ }
+ .consume(sku);
}
@Override
@@ -259,7 +258,8 @@ public class PaymentsManager {
protected void canceled() {
godotPaymentV3.callbackCancel();
}
- }.validatePurchase(sku);
+ }
+ .validatePurchase(sku);
}
public void setAutoConsume(boolean autoConsume) {
@@ -278,7 +278,8 @@ public class PaymentsManager {
protected void error(String message) {
godotPaymentV3.callbackFailConsume();
}
- }.consume(sku);
+ }
+ .consume(sku);
}
// Workaround to bug where sometimes response codes come as Long instead of Integer
@@ -287,8 +288,10 @@ public class PaymentsManager {
if (o == null) {
//logDebug("Bundle with null response code, assuming OK (known issue)");
return BILLING_RESPONSE_RESULT_OK;
- } else if (o instanceof Integer) return ((Integer) o).intValue();
- else if (o instanceof Long) return (int) ((Long) o).longValue();
+ } else if (o instanceof Integer)
+ return ((Integer)o).intValue();
+ else if (o instanceof Long)
+ return (int)((Long)o).longValue();
else {
//logError("Unexpected type for bundle response code.");
//logError(o.getClass().getName());
@@ -304,25 +307,41 @@ public class PaymentsManager {
* It also includes the result code numerically.
*/
public static String getResponseDesc(int code) {
- String[] iab_msgs = ("0:OK/1:User Canceled/2:Unknown/" +
- "3:Billing Unavailable/4:Item unavailable/" +
- "5:Developer Error/6:Error/7:Item Already Owned/" +
- "8:Item not owned").split("/");
- String[] iabhelper_msgs = ("0:OK/-1001:Remote exception during initialization/" +
- "-1002:Bad response received/" +
- "-1003:Purchase signature verification failed/" +
- "-1004:Send intent failed/" +
- "-1005:User cancelled/" +
- "-1006:Unknown purchase response/" +
- "-1007:Missing token/" +
- "-1008:Unknown error/" +
- "-1009:Subscriptions not available/" +
- "-1010:Invalid consumption attempt").split("/");
+ String[] iab_msgs = ("0:OK/1:User Canceled/2:Unknown/"
+ +
+ "3:Billing Unavailable/4:Item unavailable/"
+ +
+ "5:Developer Error/6:Error/7:Item Already Owned/"
+ +
+ "8:Item not owned")
+ .split("/");
+ String[] iabhelper_msgs = ("0:OK/-1001:Remote exception during initialization/"
+ +
+ "-1002:Bad response received/"
+ +
+ "-1003:Purchase signature verification failed/"
+ +
+ "-1004:Send intent failed/"
+ +
+ "-1005:User cancelled/"
+ +
+ "-1006:Unknown purchase response/"
+ +
+ "-1007:Missing token/"
+ +
+ "-1008:Unknown error/"
+ +
+ "-1009:Subscriptions not available/"
+ +
+ "-1010:Invalid consumption attempt")
+ .split("/");
if (code <= -1000) {
int index = -1000 - code;
- if (index >= 0 && index < iabhelper_msgs.length) return iabhelper_msgs[index];
- else return String.valueOf(code) + ":Unknown IAB Helper Error";
+ if (index >= 0 && index < iabhelper_msgs.length)
+ return iabhelper_msgs[index];
+ else
+ return String.valueOf(code) + ":Unknown IAB Helper Error";
} else if (code < 0 || code >= iab_msgs.length)
return String.valueOf(code) + ":Unknown";
else
@@ -375,7 +394,7 @@ public class PaymentsManager {
ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST");
for (String thisResponse : responseList) {
- Log.d("godot", "response = "+thisResponse);
+ Log.d("godot", "response = " + thisResponse);
godotPaymentV3.addSkuDetail(thisResponse);
}
} catch (RemoteException e) {
@@ -385,7 +404,8 @@ public class PaymentsManager {
}
godotPaymentV3.completeSkuDetail();
}
- })).start();
+ }))
+ .start();
}
private GodotPaymentV3 godotPaymentV3;
@@ -393,5 +413,4 @@ public class PaymentsManager {
public void setBaseSingleton(GodotPaymentV3 godotPaymentV3) {
this.godotPaymentV3 = godotPaymentV3;
}
-
}
diff --git a/platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java b/platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java
index 6ecea0106c..e2f08345ad 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java
@@ -50,17 +50,16 @@ import android.util.Log;
abstract public class PurchaseTask {
private Activity context;
-
+
private IInAppBillingService mService;
- public PurchaseTask(IInAppBillingService mService, Activity context ){
+ public PurchaseTask(IInAppBillingService mService, Activity context) {
this.context = context;
this.mService = mService;
}
-
private boolean isLooping = false;
-
- public void purchase(final String sku, final String transactionId){
+
+ public void purchase(final String sku, final String transactionId) {
Log.d("XXX", "Starting purchase for: " + sku);
PaymentsCache pc = new PaymentsCache(context);
Boolean isBlocked = pc.getConsumableFlag("block", sku);
@@ -75,7 +74,7 @@ abstract public class PurchaseTask {
Bundle buyIntentBundle;
try {
- buyIntentBundle = mService.getBuyIntent(3, context.getApplicationContext().getPackageName(), sku, "inapp", hash );
+ buyIntentBundle = mService.getBuyIntent(3, context.getApplicationContext().getPackageName(), sku, "inapp", hash);
} catch (RemoteException e) {
//Log.d("XXX", "Error: " + e.getMessage());
error(e.getMessage());
@@ -83,50 +82,45 @@ abstract public class PurchaseTask {
}
Object rc = buyIntentBundle.get("RESPONSE_CODE");
int responseCode = 0;
- if(rc == null){
+ if (rc == null) {
responseCode = PaymentsManager.BILLING_RESPONSE_RESULT_OK;
- }else if( rc instanceof Integer){
+ } else if (rc instanceof Integer) {
responseCode = ((Integer)rc).intValue();
- }else if( rc instanceof Long){
+ } else if (rc instanceof Long) {
responseCode = (int)((Long)rc).longValue();
}
//Log.d("XXX", "Buy intent response code: " + responseCode);
- if(responseCode == 1 || responseCode == 3 || responseCode == 4){
+ if (responseCode == 1 || responseCode == 3 || responseCode == 4) {
canceled();
return;
}
- if(responseCode == 7){
+ if (responseCode == 7) {
alreadyOwned();
return;
}
-
-
+
PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
pc.setConsumableValue("validation_hash", sku, hash);
try {
- if(context == null){
+ if (context == null) {
//Log.d("XXX", "No context!");
}
- if(pendingIntent == null){
+ if (pendingIntent == null) {
//Log.d("XXX", "No pending intent");
}
//Log.d("XXX", "Starting activity for purchase!");
context.startIntentSenderForResult(
pendingIntent.getIntentSender(),
- PaymentsManager.REQUEST_CODE_FOR_PURCHASE,
- new Intent(),
+ PaymentsManager.REQUEST_CODE_FOR_PURCHASE,
+ new Intent(),
Integer.valueOf(0), Integer.valueOf(0),
- Integer.valueOf(0));
+ Integer.valueOf(0));
} catch (SendIntentException e) {
error(e.getMessage());
}
-
-
-
}
abstract protected void error(String message);
abstract protected void canceled();
abstract protected void alreadyOwned();
-
}
diff --git a/platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java b/platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java
index d831e45694..765906d0bb 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java
@@ -48,69 +48,63 @@ abstract public class ReleaseAllConsumablesTask {
private Context context;
private IInAppBillingService mService;
-
- public ReleaseAllConsumablesTask(IInAppBillingService mService, Context context ){
+
+ public ReleaseAllConsumablesTask(IInAppBillingService mService, Context context) {
this.context = context;
this.mService = mService;
}
-
- public void consumeItAll(){
- try{
+ public void consumeItAll() {
+ try {
//Log.d("godot", "consumeItall for " + context.getPackageName());
- Bundle bundle = mService.getPurchases(3, context.getPackageName(), "inapp",null);
-
+ Bundle bundle = mService.getPurchases(3, context.getPackageName(), "inapp", null);
+
for (String key : bundle.keySet()) {
Object value = bundle.get(key);
//Log.d("godot", String.format("%s %s (%s)", key,
//value.toString(), value.getClass().getName()));
}
-
-
- if (bundle.getInt("RESPONSE_CODE") == 0){
+
+ if (bundle.getInt("RESPONSE_CODE") == 0) {
final ArrayList<String> myPurchases = bundle.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
final ArrayList<String> mySignatures = bundle.getStringArrayList("INAPP_DATA_SIGNATURE_LIST");
-
- if (myPurchases == null || myPurchases.size() == 0){
+ if (myPurchases == null || myPurchases.size() == 0) {
//Log.d("godot", "No purchases!");
notRequired();
return;
}
-
-
+
//Log.d("godot", "# products to be consumed:" + myPurchases.size());
- for (int i=0;i<myPurchases.size();i++)
- {
-
- try{
+ for (int i = 0; i < myPurchases.size(); i++) {
+
+ try {
String receipt = myPurchases.get(i);
JSONObject inappPurchaseData = new JSONObject(receipt);
String sku = inappPurchaseData.getString("productId");
String token = inappPurchaseData.getString("purchaseToken");
String signature = mySignatures.get(i);
//Log.d("godot", "A punto de consumir un item con token:" + token + "\n" + receipt);
- new GenericConsumeTask(context, mService, sku, receipt,signature, token) {
-
+ new GenericConsumeTask(context, mService, sku, receipt, signature, token) {
+
@Override
public void onSuccess(String sku, String receipt, String signature, String token) {
ReleaseAllConsumablesTask.this.success(sku, receipt, signature, token);
}
- }.execute();
-
+ }
+ .execute();
+
} catch (JSONException e) {
}
}
-
}
- }catch(Exception e){
+ } catch (Exception e) {
Log.d("godot", "Error releasing products:" + e.getClass().getName() + ":" + e.getMessage());
}
}
-
+
abstract protected void success(String sku, String receipt, String signature, String token);
abstract protected void error(String message);
abstract protected void notRequired();
-
}
diff --git a/platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java b/platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java
index 6e058c140c..3e62ef282a 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java
@@ -55,22 +55,21 @@ abstract public class ValidateTask {
private Activity context;
private GodotPaymentV3 godotPaymentsV3;
- public ValidateTask(Activity context, GodotPaymentV3 godotPaymentsV3){
+ public ValidateTask(Activity context, GodotPaymentV3 godotPaymentsV3) {
this.context = context;
this.godotPaymentsV3 = godotPaymentsV3;
}
-
- public void validatePurchase(final String sku){
- new AsyncTask<String, String, String>(){
-
+ public void validatePurchase(final String sku) {
+ new AsyncTask<String, String, String>() {
+
private ProgressDialog dialog;
@Override
- protected void onPreExecute(){
+ protected void onPreExecute() {
dialog = ProgressDialog.show(context, null, "Please wait...");
}
-
+
@Override
protected String doInBackground(String... params) {
PaymentsCache pc = new PaymentsCache(context);
@@ -90,37 +89,34 @@ abstract public class ValidateTask {
//Log.d("XXX", "Validation response:\n"+jsonResponse);
return jsonResponse;
}
-
+
@Override
- protected void onPostExecute(String response){
- if(dialog != null){
+ protected void onPostExecute(String response) {
+ if (dialog != null) {
dialog.dismiss();
}
JSONObject j;
try {
j = new JSONObject(response);
- if(j.getString("status").equals("OK")){
+ if (j.getString("status").equals("OK")) {
success();
return;
- }else if(j.getString("status") != null){
+ } else if (j.getString("status") != null) {
error(j.getString("message"));
- }else{
+ } else {
error("Connection error");
}
} catch (JSONException e) {
error(e.getMessage());
- }catch (Exception e){
+ } catch (Exception e) {
error(e.getMessage());
}
-
-
}
-
- }.execute();
+
+ }
+ .execute();
}
abstract protected void success();
abstract protected void error(String message);
abstract protected void canceled();
-
-
}
diff --git a/platform/android/java/src/org/godotengine/godot/utils/Crypt.java b/platform/android/java/src/org/godotengine/godot/utils/Crypt.java
index 2fd66553f6..35e4e430a4 100644
--- a/platform/android/java/src/org/godotengine/godot/utils/Crypt.java
+++ b/platform/android/java/src/org/godotengine/godot/utils/Crypt.java
@@ -34,34 +34,34 @@ import java.util.Random;
public class Crypt {
- public static String md5(String input){
- try {
- // Create MD5 Hash
- MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
- digest.update(input.getBytes());
- byte messageDigest[] = digest.digest();
-
- // Create Hex String
- StringBuffer hexString = new StringBuffer();
- for (int i=0; i<messageDigest.length; i++)
- hexString.append(Integer.toHexString(0xFF & messageDigest[i]));
- return hexString.toString();
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- return "";
+ public static String md5(String input) {
+ try {
+ // Create MD5 Hash
+ MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
+ digest.update(input.getBytes());
+ byte messageDigest[] = digest.digest();
+
+ // Create Hex String
+ StringBuffer hexString = new StringBuffer();
+ for (int i = 0; i < messageDigest.length; i++)
+ hexString.append(Integer.toHexString(0xFF & messageDigest[i]));
+ return hexString.toString();
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return "";
}
-
- public static String createRandomHash(){
+
+ public static String createRandomHash() {
return md5(Long.toString(createRandomLong()));
}
-
- public static long createAbsRandomLong(){
+
+ public static long createAbsRandomLong() {
return Math.abs(createRandomLong());
}
-
- public static long createRandomLong(){
+
+ public static long createRandomLong() {
Random r = new Random();
return r.nextLong();
}
diff --git a/platform/android/java/src/org/godotengine/godot/utils/CustomSSLSocketFactory.java b/platform/android/java/src/org/godotengine/godot/utils/CustomSSLSocketFactory.java
index 3fc8c48397..bfcf7e3b2a 100644
--- a/platform/android/java/src/org/godotengine/godot/utils/CustomSSLSocketFactory.java
+++ b/platform/android/java/src/org/godotengine/godot/utils/CustomSSLSocketFactory.java
@@ -42,30 +42,29 @@ import javax.net.ssl.TrustManagerFactory;
import org.apache.http.conn.ssl.SSLSocketFactory;
-
/**
*
* @author Luis Linietsky <luis.linietsky@gmail.com>
*/
public class CustomSSLSocketFactory extends SSLSocketFactory {
- SSLContext sslContext = SSLContext.getInstance("TLS");
+ SSLContext sslContext = SSLContext.getInstance("TLS");
- public CustomSSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
- super(truststore);
+ public CustomSSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
+ super(truststore);
- TrustManagerFactory tmf = TrustManagerFactory.getInstance("X509");
- tmf.init(truststore);
+ TrustManagerFactory tmf = TrustManagerFactory.getInstance("X509");
+ tmf.init(truststore);
- sslContext.init(null, tmf.getTrustManagers(), null);
- }
+ sslContext.init(null, tmf.getTrustManagers(), null);
+ }
- @Override
- public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException, UnknownHostException {
- return sslContext.getSocketFactory().createSocket(socket, host, port, autoClose);
- }
+ @Override
+ public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException, UnknownHostException {
+ return sslContext.getSocketFactory().createSocket(socket, host, port, autoClose);
+ }
- @Override
- public Socket createSocket() throws IOException {
- return sslContext.getSocketFactory().createSocket();
- }
+ @Override
+ public Socket createSocket() throws IOException {
+ return sslContext.getSocketFactory().createSocket();
+ }
}
diff --git a/platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java b/platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java
index 0711f30b8b..81a642af9f 100644
--- a/platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java
+++ b/platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java
@@ -63,7 +63,6 @@ import org.apache.http.params.HttpProtocolParams;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
-
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
@@ -73,155 +72,154 @@ import android.util.Log;
* @author Luis Linietsky <luis.linietsky@gmail.com>
*/
public class HttpRequester {
-
+
private Context context;
- private static final int TTL = 600000; // 10 minutos
- private long cttl=0;
-
- public HttpRequester(){
+ private static final int TTL = 600000; // 10 minutos
+ private long cttl = 0;
+
+ public HttpRequester() {
//Log.d("XXX", "Creando http request sin contexto");
}
-
- public HttpRequester(Context context){
- this.context=context;
+
+ public HttpRequester(Context context) {
+ this.context = context;
//Log.d("XXX", "Creando http request con contexto");
}
-
- public String post(RequestParams params){
- HttpPost httppost = new HttpPost(params.getUrl());
- try {
+
+ public String post(RequestParams params) {
+ HttpPost httppost = new HttpPost(params.getUrl());
+ try {
httppost.setEntity(new UrlEncodedFormEntity(params.toPairsList()));
return request(httppost);
} catch (UnsupportedEncodingException e) {
return null;
}
}
-
- public String get(RequestParams params){
+
+ public String get(RequestParams params) {
String response = getResponseFromCache(params.getUrl());
- if(response == null){
+ if (response == null) {
//Log.d("XXX", "Cache miss!");
- HttpGet httpget = new HttpGet(params.getUrl());
- long timeInit = new Date().getTime();
- response = request(httpget);
- long delay = new Date().getTime() - timeInit;
- Log.d("com.app11tt.android.utils.HttpRequest::get(url)", "Url: " + params.getUrl() + " downloaded in " + String.format("%.03f", delay/1000.0f) + " seconds");
- if(response == null || response.length() == 0){
- response = "";
- }else{
- saveResponseIntoCache(params.getUrl(), response);
- }
+ HttpGet httpget = new HttpGet(params.getUrl());
+ long timeInit = new Date().getTime();
+ response = request(httpget);
+ long delay = new Date().getTime() - timeInit;
+ Log.d("com.app11tt.android.utils.HttpRequest::get(url)", "Url: " + params.getUrl() + " downloaded in " + String.format("%.03f", delay / 1000.0f) + " seconds");
+ if (response == null || response.length() == 0) {
+ response = "";
+ } else {
+ saveResponseIntoCache(params.getUrl(), response);
+ }
}
Log.d("XXX", "Req: " + params.getUrl());
Log.d("XXX", "Resp: " + response);
- return response;
+ return response;
}
-
- private String request(HttpUriRequest request){
+
+ private String request(HttpUriRequest request) {
//Log.d("XXX", "Haciendo request a: " + request.getURI() );
- Log.d("PPP", "Haciendo request a: " + request.getURI() );
+ Log.d("PPP", "Haciendo request a: " + request.getURI());
long init = new Date().getTime();
HttpClient httpclient = getNewHttpClient();
HttpParams httpParameters = httpclient.getParams();
HttpConnectionParams.setConnectionTimeout(httpParameters, 0);
HttpConnectionParams.setSoTimeout(httpParameters, 0);
HttpConnectionParams.setTcpNoDelay(httpParameters, true);
- try {
- HttpResponse response = httpclient.execute(request);
- Log.d("PPP", "Fin de request (" + (new Date().getTime() - init) + ") a: " + request.getURI() );
+ try {
+ HttpResponse response = httpclient.execute(request);
+ Log.d("PPP", "Fin de request (" + (new Date().getTime() - init) + ") a: " + request.getURI());
//Log.d("XXX1", "Status:" + response.getStatusLine().toString());
- if(response.getStatusLine().getStatusCode() == 200){
- String strResponse = EntityUtils.toString(response.getEntity());
+ if (response.getStatusLine().getStatusCode() == 200) {
+ String strResponse = EntityUtils.toString(response.getEntity());
//Log.d("XXX2", strResponse);
- return strResponse;
- }else{
- Log.d("XXX3", "Response status code:" + response.getStatusLine().getStatusCode() + "\n" + EntityUtils.toString(response.getEntity()));
- return null;
- }
-
- } catch (ClientProtocolException e) {
- Log.d("XXX3", e.getMessage());
- } catch (IOException e) {
- Log.d("XXX4", e.getMessage());
- }
+ return strResponse;
+ } else {
+ Log.d("XXX3", "Response status code:" + response.getStatusLine().getStatusCode() + "\n" + EntityUtils.toString(response.getEntity()));
+ return null;
+ }
+
+ } catch (ClientProtocolException e) {
+ Log.d("XXX3", e.getMessage());
+ } catch (IOException e) {
+ Log.d("XXX4", e.getMessage());
+ }
return null;
}
-
+
private HttpClient getNewHttpClient() {
- try {
- KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
- trustStore.load(null, null);
+ try {
+ KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
+ trustStore.load(null, null);
- SSLSocketFactory sf = new CustomSSLSocketFactory(trustStore);
- sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+ SSLSocketFactory sf = new CustomSSLSocketFactory(trustStore);
+ sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
- HttpParams params = new BasicHttpParams();
- HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
- HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
+ HttpParams params = new BasicHttpParams();
+ HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
+ HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
- SchemeRegistry registry = new SchemeRegistry();
- registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
- registry.register(new Scheme("https", sf, 443));
+ SchemeRegistry registry = new SchemeRegistry();
+ registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
+ registry.register(new Scheme("https", sf, 443));
- ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry);
+ ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry);
- return new DefaultHttpClient(ccm, params);
- } catch (Exception e) {
- return new DefaultHttpClient();
- }
+ return new DefaultHttpClient(ccm, params);
+ } catch (Exception e) {
+ return new DefaultHttpClient();
+ }
}
-
+
private static String convertStreamToString(InputStream is) {
- BufferedReader reader = new BufferedReader(new InputStreamReader(is));
- StringBuilder sb = new StringBuilder();
- String line = null;
- try {
- while ((line = reader.readLine()) != null) {
- sb.append((line + "\n"));
- }
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- try {
- is.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- return sb.toString();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+ StringBuilder sb = new StringBuilder();
+ String line = null;
+ try {
+ while ((line = reader.readLine()) != null) {
+ sb.append((line + "\n"));
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ is.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ return sb.toString();
}
- public void saveResponseIntoCache(String request, String response){
- if(context == null){
+ public void saveResponseIntoCache(String request, String response) {
+ if (context == null) {
//Log.d("XXX", "No context, cache failed!");
return;
}
- SharedPreferences sharedPref = context.getSharedPreferences("http_get_cache", Context.MODE_PRIVATE);
- SharedPreferences.Editor editor = sharedPref.edit();
- editor.putString("request_" + Crypt.md5(request), response);
- editor.putLong("request_" + Crypt.md5(request) + "_ttl", new Date().getTime() + getTtl());
- editor.commit();
+ SharedPreferences sharedPref = context.getSharedPreferences("http_get_cache", Context.MODE_PRIVATE);
+ SharedPreferences.Editor editor = sharedPref.edit();
+ editor.putString("request_" + Crypt.md5(request), response);
+ editor.putLong("request_" + Crypt.md5(request) + "_ttl", new Date().getTime() + getTtl());
+ editor.commit();
}
-
-
- public String getResponseFromCache(String request){
- if(context == null){
+
+ public String getResponseFromCache(String request) {
+ if (context == null) {
Log.d("XXX", "No context, cache miss");
return null;
}
- SharedPreferences sharedPref = context.getSharedPreferences( "http_get_cache", Context.MODE_PRIVATE);
- long ttl = getResponseTtl(request);
- if(ttl == 0l || (new Date().getTime() - ttl) > 0l){
- Log.d("XXX", "Cache invalid ttl:" + ttl + " vs now:" + new Date().getTime());
- return null;
- }
- return sharedPref.getString("request_" + Crypt.md5(request), null);
+ SharedPreferences sharedPref = context.getSharedPreferences("http_get_cache", Context.MODE_PRIVATE);
+ long ttl = getResponseTtl(request);
+ if (ttl == 0l || (new Date().getTime() - ttl) > 0l) {
+ Log.d("XXX", "Cache invalid ttl:" + ttl + " vs now:" + new Date().getTime());
+ return null;
+ }
+ return sharedPref.getString("request_" + Crypt.md5(request), null);
}
- public long getResponseTtl(String request){
- SharedPreferences sharedPref = context.getSharedPreferences(
- "http_get_cache", Context.MODE_PRIVATE);
- return sharedPref.getLong("request_" + Crypt.md5(request) + "_ttl", 0l);
+ public long getResponseTtl(String request) {
+ SharedPreferences sharedPref = context.getSharedPreferences(
+ "http_get_cache", Context.MODE_PRIVATE);
+ return sharedPref.getLong("request_" + Crypt.md5(request) + "_ttl", 0l);
}
public long getTtl() {
@@ -229,7 +227,6 @@ public class HttpRequester {
}
public void setTtl(long ttl) {
- this.cttl = (ttl*1000) + new Date().getTime();
+ this.cttl = (ttl * 1000) + new Date().getTime();
}
-
}
diff --git a/platform/android/java/src/org/godotengine/godot/utils/RequestParams.java b/platform/android/java/src/org/godotengine/godot/utils/RequestParams.java
index ded11550bb..051fed5500 100644
--- a/platform/android/java/src/org/godotengine/godot/utils/RequestParams.java
+++ b/platform/android/java/src/org/godotengine/godot/utils/RequestParams.java
@@ -43,33 +43,33 @@ import org.apache.http.message.BasicNameValuePair;
*/
public class RequestParams {
- private HashMap<String,String> params;
+ private HashMap<String, String> params;
private String url;
-
- public RequestParams(){
- params = new HashMap<String,String>();
+
+ public RequestParams() {
+ params = new HashMap<String, String>();
}
-
- public void put(String key, String value){
+
+ public void put(String key, String value) {
params.put(key, value);
}
-
- public String get(String key){
+
+ public String get(String key) {
return params.get(key);
}
-
- public void remove(Object key){
+
+ public void remove(Object key) {
params.remove(key);
}
-
- public boolean has(String key){
+
+ public boolean has(String key) {
return params.containsKey(key);
}
-
- public List<NameValuePair> toPairsList(){
- List<NameValuePair> fields = new ArrayList<NameValuePair>();
- for(String key : params.keySet()){
+ public List<NameValuePair> toPairsList() {
+ List<NameValuePair> fields = new ArrayList<NameValuePair>();
+
+ for (String key : params.keySet()) {
fields.add(new BasicNameValuePair(key, this.get(key)));
}
return fields;
@@ -82,6 +82,4 @@ public class RequestParams {
public void setUrl(String url) {
this.url = url;
}
-
-
}
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index 263ff012d4..b59fab7088 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -195,14 +195,13 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
XIDeviceInfo *dev = &info[i];
if (!dev->enabled)
continue;
- /*if (dev->use != XIMasterPointer)
- continue;*/
+ if (!(dev->use == XIMasterPointer || dev->use == XIFloatingSlave))
+ continue;
bool direct_touch = false;
for (int j = 0; j < dev->num_classes; j++) {
if (dev->classes[j]->type == XITouchClass && ((XITouchClassInfo *)dev->classes[j])->mode == XIDirectTouch) {
direct_touch = true;
- printf("%d) %d %s\n", i, dev->attachment, dev->name);
break;
}
}
@@ -215,7 +214,7 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
XIFreeDeviceInfo(info);
if (!touch.devices.size()) {
- fprintf(stderr, "No suitable touch device found\n");
+ fprintf(stderr, "No touch devices found\n");
}
}
}
@@ -359,7 +358,7 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
// Must be alive after this block
static unsigned char mask_data[XIMaskLen(XI_LASTEVENT)] = {};
- touch.event_mask.deviceid = XIAllMasterDevices;
+ touch.event_mask.deviceid = XIAllDevices;
touch.event_mask.mask_len = sizeof(mask_data);
touch.event_mask.mask = mask_data;
@@ -370,12 +369,14 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
XISelectEvents(x11_display, x11_window, &touch.event_mask, 1);
- XIClearMask(touch.event_mask.mask, XI_TouchOwnership);
+ // Disabled by now since grabbing also blocks mouse events
+ // (they are received as extended events instead of standard events)
+ /*XIClearMask(touch.event_mask.mask, XI_TouchOwnership);
// Grab touch devices to avoid OS gesture interference
for (int i = 0; i < touch.devices.size(); ++i) {
XIGrabDevice(x11_display, touch.devices[i], x11_window, CurrentTime, None, XIGrabModeAsync, XIGrabModeAsync, False, &touch.event_mask);
- }
+ }*/
}
#endif
@@ -512,15 +513,14 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
power_manager = memnew(PowerX11);
XEvent xevent;
- while (XCheckIfEvent(x11_display, &xevent, _check_window_events, NULL)) {
- _window_changed(&xevent);
+ while (XPending(x11_display) > 0) {
+ XNextEvent(x11_display, &xevent);
+ if (xevent.type == ConfigureNotify) {
+ _window_changed(&xevent);
+ }
}
}
-int OS_X11::_check_window_events(Display *display, XEvent *event, char *arg) {
- if (event->type == ConfigureNotify) return 1;
- return 0;
-}
void OS_X11::xim_destroy_callback(::XIM im, ::XPointer client_data,
::XPointer call_data) {
@@ -1513,7 +1513,7 @@ void OS_X11::process_xevents() {
#ifdef TOUCH_ENABLED
if (XGetEventData(x11_display, &event.xcookie)) {
- if (event.xcookie.extension == touch.opcode) {
+ if (event.xcookie.type == GenericEvent && event.xcookie.extension == touch.opcode) {
XIDeviceEvent *event_data = (XIDeviceEvent *)event.xcookie.data;
int index = event_data->detail;
@@ -1522,7 +1522,8 @@ void OS_X11::process_xevents() {
switch (event_data->evtype) {
case XI_TouchBegin: // Fall-through
- XIAllowTouchEvents(x11_display, event_data->deviceid, event_data->detail, x11_window, XIAcceptTouch);
+ // Disabled hand-in-hand with the grabbing
+ //XIAllowTouchEvents(x11_display, event_data->deviceid, event_data->detail, x11_window, XIAcceptTouch);
case XI_TouchEnd: {
@@ -1568,9 +1569,8 @@ void OS_X11::process_xevents() {
} break;
}
}
-
- XFreeEventData(x11_display, &event.xcookie);
}
+ XFreeEventData(x11_display, &event.xcookie);
#endif
switch (event.type) {
@@ -1616,10 +1616,10 @@ void OS_X11::process_xevents() {
GrabModeAsync, GrabModeAsync, x11_window, None, CurrentTime);
}
#ifdef TOUCH_ENABLED
- // Grab touch devices to avoid OS gesture interference
- for (int i = 0; i < touch.devices.size(); ++i) {
+ // Grab touch devices to avoid OS gesture interference
+ /*for (int i = 0; i < touch.devices.size(); ++i) {
XIGrabDevice(x11_display, touch.devices[i], x11_window, CurrentTime, None, XIGrabModeAsync, XIGrabModeAsync, False, &touch.event_mask);
- }
+ }*/
#endif
if (xic) {
XSetICFocus(xic);
@@ -1639,9 +1639,9 @@ void OS_X11::process_xevents() {
}
#ifdef TOUCH_ENABLED
// Ungrab touch devices so input works as usual while we are unfocused
- for (int i = 0; i < touch.devices.size(); ++i) {
+ /*for (int i = 0; i < touch.devices.size(); ++i) {
XIUngrabDevice(x11_display, touch.devices[i], CurrentTime);
- }
+ }*/
// Release every pointer to avoid sticky points
for (Map<int, Vector2>::Element *E = touch.state.front(); E; E = E->next()) {
diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h
index 84dff2e089..244c69ee2b 100644
--- a/platform/x11/os_x11.h
+++ b/platform/x11/os_x11.h
@@ -199,7 +199,6 @@ protected:
virtual void set_main_loop(MainLoop *p_main_loop);
void _window_changed(XEvent *xevent);
- static int _check_window_events(Display *display, XEvent *xevent, char *arg);
public:
virtual String get_name();
diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp
index ff5cb41135..1f2b43165e 100644
--- a/scene/3d/gi_probe.cpp
+++ b/scene/3d/gi_probe.cpp
@@ -1286,7 +1286,7 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) {
Ref<GIProbeData> probe_data = get_probe_data();
- if(probe_data.is_null())
+ if (probe_data.is_null())
probe_data.instance();
probe_data->set_bounds(AABB(-extents, extents * 2.0));
diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp
index c137b7e8ff..821f1a5a78 100644
--- a/scene/3d/particles.cpp
+++ b/scene/3d/particles.cpp
@@ -1189,7 +1189,7 @@ void ParticlesMaterial::set_flag(Flags p_flag, bool p_enable) {
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
flags[p_flag] = p_enable;
_queue_shader_change();
- if (p_flag==FLAG_DISABLE_Z) {
+ if (p_flag == FLAG_DISABLE_Z) {
_change_notify();
}
}
@@ -1379,7 +1379,7 @@ void ParticlesMaterial::_validate_property(PropertyInfo &property) const {
}
if (property.name.begins_with("orbit_") && !flags[FLAG_DISABLE_Z]) {
- property.usage=0;
+ property.usage = 0;
}
}
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index 91aa069060..e866e665d8 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -1327,7 +1327,7 @@ void AnimationPlayer::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_root"), &AnimationPlayer::get_root);
ClassDB::bind_method(D_METHOD("seek", "seconds", "update"), &AnimationPlayer::seek, DEFVAL(false));
- ClassDB::bind_method(D_METHOD("get_position"), &AnimationPlayer::get_current_animation_position);
+ ClassDB::bind_method(D_METHOD("advance", "delta"), &AnimationPlayer::advance);
ClassDB::bind_method(D_METHOD("find_animation", "animation"), &AnimationPlayer::find_animation);
@@ -1339,8 +1339,6 @@ void AnimationPlayer::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_current_animation_position"), &AnimationPlayer::get_current_animation_position);
ClassDB::bind_method(D_METHOD("get_current_animation_length"), &AnimationPlayer::get_current_animation_length);
- ClassDB::bind_method(D_METHOD("advance", "delta"), &AnimationPlayer::advance);
-
ADD_GROUP("Playback Options", "playback_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "playback_process_mode", PROPERTY_HINT_ENUM, "Physics,Idle"), "set_animation_process_mode", "get_animation_process_mode");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "playback_default_blend_time", PROPERTY_HINT_RANGE, "0,4096,0.01"), "set_default_blend_time", "get_default_blend_time");
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index a785abbc65..ea8adc58cd 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -1269,12 +1269,9 @@ Transform2D Viewport::_get_input_pre_xform() const {
Vector2 Viewport::_get_window_offset() const {
- /*
- if (parent_control) {
- return (parent_control->get_viewport()->get_final_transform() * parent_control->get_global_transform_with_canvas()).get_origin();
+ if (get_parent() && get_parent()->has_method("get_global_position")) {
+ return get_parent()->call("get_global_position");
}
- */
-
return Vector2();
}
diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp
index 352418e65c..d8600e041d 100644
--- a/scene/resources/surface_tool.cpp
+++ b/scene/resources/surface_tool.cpp
@@ -990,7 +990,7 @@ void SurfaceTool::_bind_methods() {
ClassDB::bind_method(D_METHOD("create_from", "existing", "surface"), &SurfaceTool::create_from);
ClassDB::bind_method(D_METHOD("append_from", "existing", "surface", "transform"), &SurfaceTool::append_from);
- ClassDB::bind_method(D_METHOD("commit", "existing"), &SurfaceTool::commit, DEFVAL(Variant()), DEFVAL(Mesh::ARRAY_COMPRESS_DEFAULT));
+ ClassDB::bind_method(D_METHOD("commit", "existing", "flags"), &SurfaceTool::commit, DEFVAL(Variant()), DEFVAL(Mesh::ARRAY_COMPRESS_DEFAULT));
}
SurfaceTool::SurfaceTool() {