From 8ad12525a90d90d77dc08b3d6decae33be5675c4 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 2 Dec 2014 17:26:56 -0300 Subject: -fixes to vmethod for button --- scene/gui/base_button.cpp | 27 ++++++++++++++++++++++++++- scene/scene_string_names.cpp | 3 +++ scene/scene_string_names.h | 3 +++ tools/editor/editor_import_export.cpp | 2 +- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index cf3bef73ea..0167687621 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -30,7 +30,7 @@ #include "os/keyboard.h" #include "print_string.h" #include "button_group.h" - +#include "scene/scene_string_names.h" void BaseButton::_input_event(InputEvent p_event) { @@ -60,12 +60,21 @@ void BaseButton::_input_event(InputEvent p_event) { status.pressing_inside=true; pressed(); + if (get_script_instance()) { + Variant::CallError ce; + get_script_instance()->call(SceneStringNames::get_singleton()->_pressed,NULL,0,ce); + } + emit_signal("pressed"); } else { status.pressed=!status.pressed; pressed(); + if (get_script_instance()) { + Variant::CallError ce; + get_script_instance()->call(SceneStringNames::get_singleton()->_pressed,NULL,0,ce); + } emit_signal("pressed"); toggled(status.pressed); @@ -99,6 +108,11 @@ void BaseButton::_input_event(InputEvent p_event) { if (!toggle_mode) { //mouse press attempt pressed(); + if (get_script_instance()) { + Variant::CallError ce; + get_script_instance()->call(SceneStringNames::get_singleton()->_pressed,NULL,0,ce); + } + emit_signal("pressed"); } else { @@ -110,6 +124,10 @@ void BaseButton::_input_event(InputEvent p_event) { toggled(status.pressed); emit_signal("toggled",status.pressed); + if (get_script_instance()) { + get_script_instance()->call(SceneStringNames::get_singleton()->_toggled,status.pressed); + } + } @@ -177,6 +195,9 @@ void BaseButton::_input_event(InputEvent p_event) { emit_signal("pressed"); toggled(status.pressed); + if (get_script_instance()) { + get_script_instance()->call(SceneStringNames::get_singleton()->_toggled,status.pressed); + } emit_signal("toggled",status.pressed); } } @@ -362,6 +383,9 @@ void BaseButton::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_click_on_press"),&BaseButton::get_click_on_press); ObjectTypeDB::bind_method(_MD("get_draw_mode"),&BaseButton::get_draw_mode); + BIND_VMETHOD(MethodInfo("_pressed")); + BIND_VMETHOD(MethodInfo("_toggled",PropertyInfo(Variant::BOOL,"pressed"))); + ADD_SIGNAL( MethodInfo("pressed" ) ); ADD_SIGNAL( MethodInfo("released" ) ); ADD_SIGNAL( MethodInfo("toggled", PropertyInfo( Variant::BOOL,"pressed") ) ); @@ -369,6 +393,7 @@ void BaseButton::_bind_methods() { ADD_PROPERTY( PropertyInfo( Variant::BOOL, "toggle_mode"), _SCS("set_toggle_mode"), _SCS("is_toggle_mode")); ADD_PROPERTY( PropertyInfo( Variant::BOOL, "click_on_press"), _SCS("set_click_on_press"), _SCS("get_click_on_press")); + BIND_CONSTANT( DRAW_NORMAL ); BIND_CONSTANT( DRAW_PRESSED ); BIND_CONSTANT( DRAW_HOVER ); diff --git a/scene/scene_string_names.cpp b/scene/scene_string_names.cpp index df9b02ea3f..8ad7e06c0f 100644 --- a/scene/scene_string_names.cpp +++ b/scene/scene_string_names.cpp @@ -147,4 +147,7 @@ SceneStringNames::SceneStringNames() { _mouse_enter=StaticCString::create("_mouse_enter"); _mouse_exit=StaticCString::create("_mouse_exit"); + _pressed=StaticCString::create("_pressed"); + _toggled=StaticCString::create("_toggled"); + } diff --git a/scene/scene_string_names.h b/scene/scene_string_names.h index 11799b9e86..512674f648 100644 --- a/scene/scene_string_names.h +++ b/scene/scene_string_names.h @@ -95,6 +95,9 @@ public: StringName _input; StringName _ready; + StringName _pressed; + StringName _toggled; + StringName _update_scroll; StringName _update_xform; diff --git a/tools/editor/editor_import_export.cpp b/tools/editor/editor_import_export.cpp index 6e8cb987e9..a511e78863 100644 --- a/tools/editor/editor_import_export.cpp +++ b/tools/editor/editor_import_export.cpp @@ -938,7 +938,7 @@ Error EditorExportPlatform::save_pack(FileAccess *dst,bool p_make_bundles) { dst->store_32(0); //pack version dst->store_32(VERSION_MAJOR); dst->store_32(VERSION_MINOR); - dst->store_32(VERSION_REVISION); + dst->store_32(0); //hmph for(int i=0;i<16;i++) { //reserved dst->store_32(0); -- cgit v1.2.3