summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-05-01 21:13:20 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-05-01 21:13:20 -0300
commit1e422941c88105852cc376569b7aa92e7784f4cd (patch)
treef54ff75e18805ff6c1d0ebee7104a9bdf325551b
parent88d078df1e72bcf7caf82761d9a86cb920527cb7 (diff)
-Fixed android export options (screen sizes, orientation should work)
-added functions to get mouse position in CanvasItem
-rw-r--r--core/os/input.cpp2
-rw-r--r--platform/android/AndroidManifest.xml.template4
-rw-r--r--platform/android/export/export.cpp20
-rw-r--r--scene/2d/canvas_item.cpp14
-rw-r--r--scene/2d/canvas_item.h3
5 files changed, 28 insertions, 15 deletions
diff --git a/core/os/input.cpp b/core/os/input.cpp
index 4a8718e2d6..2b939ede46 100644
--- a/core/os/input.cpp
+++ b/core/os/input.cpp
@@ -56,7 +56,7 @@ void Input::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_joy_axis","device","axis"),&Input::get_joy_axis);
ObjectTypeDB::bind_method(_MD("get_joy_name","device"),&Input::get_joy_name);
ObjectTypeDB::bind_method(_MD("get_accelerometer"),&Input::get_accelerometer);
- //ObjectTypeDB::bind_method(_MD("get_mouse_pos"),&Input::get_mouse_pos);
+ //ObjectTypeDB::bind_method(_MD("get_mouse_pos"),&Input::get_mouse_pos); - this is not the function you want
ObjectTypeDB::bind_method(_MD("get_mouse_speed"),&Input::get_mouse_speed);
ObjectTypeDB::bind_method(_MD("get_mouse_button_mask"),&Input::get_mouse_button_mask);
ObjectTypeDB::bind_method(_MD("set_mouse_mode","mode"),&Input::set_mouse_mode);
diff --git a/platform/android/AndroidManifest.xml.template b/platform/android/AndroidManifest.xml.template
index 71e8b866dc..c95c86c060 100644
--- a/platform/android/AndroidManifest.xml.template
+++ b/platform/android/AndroidManifest.xml.template
@@ -7,7 +7,7 @@
>
<supports-screens android:smallScreens="true"
android:normalScreens="true"
- android:largeScreens="true"
+ android:largeScreens="false"
android:xlargeScreens="true"/>
<application android:label="@string/godot_project_name_string" android:icon="@drawable/icon" android:allowBackup="false" $$ADD_APPATTRIBUTE_CHUNKS$$ >
@@ -15,7 +15,7 @@
android:label="@string/godot_project_name_string"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:launchMode="singleTask"
- android:screenOrientation="portrait"
+ android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize">
<intent-filter>
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp
index 35ea7f15f8..e11a2c09cd 100644
--- a/platform/android/export/export.cpp
+++ b/platform/android/export/export.cpp
@@ -768,19 +768,21 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest) {
if (tname=="activity" && /*nspace=="android" &&*/ attrname=="screenOrientation") {
+ encode_uint32(orientation==0?0:1,&p_manifest[iofs+16]);
+ /*
print_line("FOUND screen orientation");
if (attr_value==0xFFFFFFFF) {
WARN_PRINT("Version name in a resource, should be plaintext")
} else {
string_table[attr_value]=(orientation==0?"landscape":"portrait");
- }
+ }*/
}
if (tname=="application" && /*nspace=="android" &&*/ attrname=="label") {
print_line("FOUND application");
if (attr_value==0xFFFFFFFF) {
- WARN_PRINT("Application name in a resource, should be plaintext.")
+ WARN_PRINT("Application name in a resource, should be plaintext (but you can ignore this).")
} else {
String aname = get_project_name();
@@ -791,7 +793,7 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest) {
print_line("FOUND activity name");
if (attr_value==0xFFFFFFFF) {
- WARN_PRINT("Activity name in a resource, should be plaintext")
+ WARN_PRINT("Activity name in a resource, should be plaintext (but you can ignore this)")
} else {
String aname;
if (this->name!="") {
@@ -835,23 +837,19 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest) {
WARN_PRINT("Screen res name in a resource, should be plaintext")
} else if (attrname=="smallScreens") {
- print_line("SMALLSCREEN");
- string_table[attr_value]=screen_support[SCREEN_SMALL]?"true":"false";
+ encode_uint32(screen_support[SCREEN_SMALL]?0xFFFFFFFF:0,&p_manifest[iofs+16]);
} else if (attrname=="mediumScreens") {
- print_line("MEDSCREEN");
- string_table[attr_value]=screen_support[SCREEN_NORMAL]?"true":"false";
+ encode_uint32(screen_support[SCREEN_NORMAL]?0xFFFFFFFF:0,&p_manifest[iofs+16]);
} else if (attrname=="largeScreens") {
- print_line("LARGECREEN");
- string_table[attr_value]=screen_support[SCREEN_LARGE]?"true":"false";
+ encode_uint32(screen_support[SCREEN_LARGE]?0xFFFFFFFF:0,&p_manifest[iofs+16]);
} else if (attrname=="xlargeScreens") {
- print_line("XLARGECREEN");
- string_table[attr_value]=screen_support[SCREEN_XLARGE]?"true":"false";
+ encode_uint32(screen_support[SCREEN_XLARGE]?0xFFFFFFFF:0,&p_manifest[iofs+16]);
}
}
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index 09c5a2a2bb..9b2cdf4ea2 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -35,7 +35,7 @@
#include "scene/resources/font.h"
#include "scene/resources/texture.h"
#include "scene/resources/style_box.h"
-
+#include "os/input.h"
bool CanvasItemMaterial::_set(const StringName& p_name, const Variant& p_value) {
@@ -1010,6 +1010,16 @@ InputEvent CanvasItem::make_input_local(const InputEvent& p_event) const {
}
+Vector2 CanvasItem::get_global_mouse_pos() const {
+
+ return get_viewport_transform().affine_inverse().xform(Input::get_singleton()->get_mouse_pos());
+}
+Vector2 CanvasItem::get_local_mouse_pos() const{
+
+ return (get_viewport_transform() * get_global_transform()).affine_inverse().xform(Input::get_singleton()->get_mouse_pos());
+}
+
+
void CanvasItem::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_sort_children"),&CanvasItem::_sort_children);
@@ -1075,6 +1085,8 @@ void CanvasItem::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_viewport_transform"),&CanvasItem::get_viewport_transform);
ObjectTypeDB::bind_method(_MD("get_viewport_rect"),&CanvasItem::get_viewport_rect);
ObjectTypeDB::bind_method(_MD("get_canvas_transform"),&CanvasItem::get_canvas_transform);
+ ObjectTypeDB::bind_method(_MD("get_local_mouse_pos"),&CanvasItem::get_local_mouse_pos);
+ ObjectTypeDB::bind_method(_MD("get_global_mouse_pos"),&CanvasItem::get_global_mouse_pos);
ObjectTypeDB::bind_method(_MD("get_canvas"),&CanvasItem::get_canvas);
ObjectTypeDB::bind_method(_MD("get_world_2d"),&CanvasItem::get_world_2d);
//ObjectTypeDB::bind_method(_MD("get_viewport"),&CanvasItem::get_viewport);
diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h
index 0755638047..6d8308dbe4 100644
--- a/scene/2d/canvas_item.h
+++ b/scene/2d/canvas_item.h
@@ -260,6 +260,9 @@ public:
InputEvent make_input_local(const InputEvent& pevent) const;
+ Vector2 get_global_mouse_pos() const;
+ Vector2 get_local_mouse_pos() const;
+
CanvasItem();
~CanvasItem();
};