Skip to content

Commit

Permalink
Merge pull request #1 from okamstudio/master
Browse files Browse the repository at this point in the history
improved animation editor
  • Loading branch information
choikwa committed May 25, 2015
2 parents b210f52 + f36e7dc commit ec93668
Show file tree
Hide file tree
Showing 30 changed files with 840 additions and 106 deletions.
33 changes: 33 additions & 0 deletions core/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -995,12 +995,44 @@ Variant Object::get_meta(const String& p_name) const {
return metadata[p_name];
}


Array Object::_get_property_list_bind() const {

List<PropertyInfo> lpi;
get_property_list(&lpi);
return convert_property_list(&lpi);
}

Array Object::_get_method_list_bind() const {

List<MethodInfo> ml;
get_method_list(&ml);
Array ret;

for(List<MethodInfo>::Element *E=ml.front();E;E=E->next()) {

Dictionary d;
d["name"]=E->get().name;
d["args"]=convert_property_list(&E->get().arguments);
Array da;
for(int i=0;i<E->get().default_arguments.size();i++)
da.push_back(E->get().default_arguments[i]);
d["default_args"]=da;
d["flags"]=E->get().flags;
d["id"]=E->get().id;
Dictionary r;
r["type"]=E->get().return_val.type;
r["hint"]=E->get().return_val.hint;
r["hint_string"]=E->get().return_val.hint_string;
d["return_type"]=r;
//va.push_back(d);
ret.push_back(d);
}

return ret;

}

DVector<String> Object::_get_meta_list_bind() const {

DVector<String> _metaret;
Expand Down Expand Up @@ -1439,6 +1471,7 @@ void Object::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set","property","value"),&Object::_set_bind);
ObjectTypeDB::bind_method(_MD("get","property"),&Object::_get_bind);
ObjectTypeDB::bind_method(_MD("get_property_list"),&Object::_get_property_list_bind);
ObjectTypeDB::bind_method(_MD("get_method_list"),&Object::_get_method_list_bind);
ObjectTypeDB::bind_method(_MD("notification","what"),&Object::notification,DEFVAL(false));
ObjectTypeDB::bind_method(_MD("get_instance_ID"),&Object::get_instance_ID);

Expand Down
2 changes: 2 additions & 0 deletions core/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ enum PropertyHint {
PROPERTY_HINT_ENUM, ///< hint_text= "val1,val2,val3,etc"
PROPERTY_HINT_EXP_EASING, /// exponential easing funciton (Math::ease)
PROPERTY_HINT_LENGTH, ///< hint_text= "length" (as integer)
PROPERTY_HINT_SPRITE_FRAME,
PROPERTY_HINT_KEY_ACCEL, ///< hint_text= "length" (as integer)
PROPERTY_HINT_FLAGS, ///< hint_text= "flag1,flag2,etc" (as bit flags)
PROPERTY_HINT_ALL_FLAGS,
Expand Down Expand Up @@ -448,6 +449,7 @@ friend void postinitialize_handler(Object*);

DVector<String> _get_meta_list_bind() const;
Array _get_property_list_bind() const;
Array _get_method_list_bind() const;

public: //should be protected, but bug in clang++
static void initialize_type();
Expand Down
27 changes: 21 additions & 6 deletions core/os/main_loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,20 @@

void MainLoop::_bind_methods() {

ObjectTypeDB::bind_method("input_event",&MainLoop::input_event);
ObjectTypeDB::bind_method(_MD("input_event","ev"),&MainLoop::input_event);
ObjectTypeDB::bind_method(_MD("input_text","text"),&MainLoop::input_text);
ObjectTypeDB::bind_method(_MD("init"),&MainLoop::init);
ObjectTypeDB::bind_method(_MD("iteration","delta"),&MainLoop::iteration);
ObjectTypeDB::bind_method(_MD("idle","delta"),&MainLoop::idle);
ObjectTypeDB::bind_method(_MD("finish"),&MainLoop::finish);

BIND_VMETHOD( MethodInfo("_input_event",PropertyInfo(Variant::INPUT_EVENT,"ev")) );
BIND_VMETHOD( MethodInfo("_input_text",PropertyInfo(Variant::STRING,"text")) );
BIND_VMETHOD( MethodInfo("_initialize") );
BIND_VMETHOD( MethodInfo("_iteration",PropertyInfo(Variant::REAL,"delta")) );
BIND_VMETHOD( MethodInfo("_idle",PropertyInfo(Variant::REAL,"delta")) );
BIND_VMETHOD( MethodInfo("_finalize") );


BIND_CONSTANT(NOTIFICATION_WM_FOCUS_IN);
BIND_CONSTANT(NOTIFICATION_WM_FOCUS_OUT);
Expand All @@ -58,13 +71,15 @@ MainLoop::~MainLoop()

void MainLoop::input_text( const String& p_text ) {

if (get_script_instance())
get_script_instance()->call("_input_text",p_text);

}

void MainLoop::input_event( const InputEvent& p_event ) {

if (get_script_instance())
get_script_instance()->call("input_event",p_event);
get_script_instance()->call("_input_event",p_event);

}

Expand All @@ -74,28 +89,28 @@ void MainLoop::init() {
set_script(init_script.get_ref_ptr());

if (get_script_instance())
get_script_instance()->call("init");
get_script_instance()->call("_initialize");

}
bool MainLoop::iteration(float p_time) {

if (get_script_instance())
return get_script_instance()->call("iteration",p_time);
return get_script_instance()->call("_iteration",p_time);

return false;

}
bool MainLoop::idle(float p_time) {

if (get_script_instance())
return get_script_instance()->call("idle",p_time);
return get_script_instance()->call("_idle",p_time);

return false;
}
void MainLoop::finish() {

if (get_script_instance()) {
get_script_instance()->call("finish");
get_script_instance()->call("_finalize");
set_script(RefPtr()); //clear script
}

Expand Down
2 changes: 1 addition & 1 deletion scene/2d/animated_sprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ void AnimatedSprite::_bind_methods() {
ADD_SIGNAL(MethodInfo("frame_changed"));

ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "frames",PROPERTY_HINT_RESOURCE_TYPE,"SpriteFrames"), _SCS("set_sprite_frames"),_SCS("get_sprite_frames"));
ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "frame"), _SCS("set_frame"),_SCS("get_frame"));
ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "frame",PROPERTY_HINT_SPRITE_FRAME), _SCS("set_frame"),_SCS("get_frame"));
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "centered"), _SCS("set_centered"),_SCS("is_centered"));
ADD_PROPERTYNZ( PropertyInfo( Variant::VECTOR2, "offset"), _SCS("set_offset"),_SCS("get_offset"));
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "flip_h"), _SCS("set_flip_h"),_SCS("is_flipped_h"));
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/sprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ void Sprite::_bind_methods() {
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "flip_v"), _SCS("set_flip_v"),_SCS("is_flipped_v"));
ADD_PROPERTY( PropertyInfo( Variant::INT, "vframes"), _SCS("set_vframes"),_SCS("get_vframes"));
ADD_PROPERTY( PropertyInfo( Variant::INT, "hframes"), _SCS("set_hframes"),_SCS("get_hframes"));
ADD_PROPERTY( PropertyInfo( Variant::INT, "frame"), _SCS("set_frame"),_SCS("get_frame"));
ADD_PROPERTY( PropertyInfo( Variant::INT, "frame",PROPERTY_HINT_SPRITE_FRAME), _SCS("set_frame"),_SCS("get_frame"));
ADD_PROPERTY( PropertyInfo( Variant::COLOR, "modulate"), _SCS("set_modulate"),_SCS("get_modulate"));
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "region"), _SCS("set_region"),_SCS("is_region"));
ADD_PROPERTY( PropertyInfo( Variant::RECT2, "region_rect"), _SCS("set_region_rect"),_SCS("get_region_rect"));
Expand Down
4 changes: 2 additions & 2 deletions scene/3d/sprite_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ void Sprite3D::_bind_methods() {
ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_texture"),_SCS("get_texture"));
ADD_PROPERTY( PropertyInfo( Variant::INT, "vframes"), _SCS("set_vframes"),_SCS("get_vframes"));
ADD_PROPERTY( PropertyInfo( Variant::INT, "hframes"), _SCS("set_hframes"),_SCS("get_hframes"));
ADD_PROPERTY( PropertyInfo( Variant::INT, "frame"), _SCS("set_frame"),_SCS("get_frame"));
ADD_PROPERTY( PropertyInfo( Variant::INT, "frame",PROPERTY_HINT_SPRITE_FRAME), _SCS("set_frame"),_SCS("get_frame"));
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "region"), _SCS("set_region"),_SCS("is_region"));
ADD_PROPERTY( PropertyInfo( Variant::RECT2, "region_rect"), _SCS("set_region_rect"),_SCS("get_region_rect"));

Expand Down Expand Up @@ -727,7 +727,7 @@ void AnimatedSprite3D::_bind_methods(){
ObjectTypeDB::bind_method(_MD("get_frame"),&AnimatedSprite3D::get_frame);

ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "frames", PROPERTY_HINT_RESOURCE_TYPE,"SpriteFrames"), _SCS("set_sprite_frames"),_SCS("get_sprite_frames"));
ADD_PROPERTY( PropertyInfo( Variant::INT, "frame"), _SCS("set_frame"),_SCS("get_frame"));
ADD_PROPERTY( PropertyInfo( Variant::INT, "frame",PROPERTY_HINT_SPRITE_FRAME), _SCS("set_frame"),_SCS("get_frame"));

ADD_SIGNAL(MethodInfo("frame_changed"));

Expand Down
10 changes: 6 additions & 4 deletions scene/animation/animation_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -967,14 +967,16 @@ String AnimationPlayer::get_current_animation() const {

}

void AnimationPlayer::stop() {
void AnimationPlayer::stop(bool p_reset) {

Playback &c=playback;
c.blend.clear();
c.current.from=NULL;
if (p_reset) {
c.current.from=NULL;
}
_set_process(false);
queued.clear();
playing = false;
playing = false;
}

void AnimationPlayer::stop_all() {
Expand Down Expand Up @@ -1211,7 +1213,7 @@ void AnimationPlayer::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_default_blend_time"),&AnimationPlayer::get_default_blend_time);

ObjectTypeDB::bind_method(_MD("play","name","custom_blend","custom_speed","from_end"),&AnimationPlayer::play,DEFVAL(""),DEFVAL(-1),DEFVAL(1.0),DEFVAL(false));
ObjectTypeDB::bind_method(_MD("stop"),&AnimationPlayer::stop);
ObjectTypeDB::bind_method(_MD("stop","reset"),&AnimationPlayer::stop,DEFVAL(true));
ObjectTypeDB::bind_method(_MD("stop_all"),&AnimationPlayer::stop_all);
ObjectTypeDB::bind_method(_MD("is_playing"),&AnimationPlayer::is_playing);
ObjectTypeDB::bind_method(_MD("set_current_animation","anim"),&AnimationPlayer::set_current_animation);
Expand Down
2 changes: 1 addition & 1 deletion scene/animation/animation_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ class AnimationPlayer : public Node {
void play(const StringName& p_name=StringName(),float p_custom_blend=-1,float p_custom_scale=1.0,bool p_from_end=false);
void queue(const StringName& p_name);
void clear_queue();
void stop();
void stop(bool p_reset=true);
bool is_playing() const;
String get_current_animation() const;
void set_current_animation(const String& p_anim);
Expand Down
Loading

0 comments on commit ec93668

Please sign in to comment.