void TextureRegionEditor::_changed_callback(Object *p_changed, const char *p_prop) { if (!is_visible()) return; if (p_prop == StringName("atlas") || p_prop == StringName("texture")) _edit_region(); }
Error _Thread::start(Object *p_instance,const StringName& p_method,const Variant& p_userdata,int p_priority) { ERR_FAIL_COND_V(active,ERR_ALREADY_IN_USE); ERR_FAIL_COND_V(!p_instance,ERR_INVALID_PARAMETER); ERR_FAIL_COND_V(p_method==StringName(),ERR_INVALID_PARAMETER); ERR_FAIL_INDEX_V(p_priority,3,ERR_INVALID_PARAMETER); ret=Variant(); target_method=p_method; target_instance=p_instance; userdata=p_userdata; active=true; Thread::Settings s; s.priority=(Thread::Priority)p_priority; thread = Thread::create(_start_func,this,s); if (!thread) { active=false; target_method=StringName(); target_instance=NULL; userdata=Variant(); return ERR_CANT_CREATE; } return OK; }
StringName AnimationTreePlayer::node_get_input_source(const StringName& p_node,int p_input) const { ERR_FAIL_COND_V(!node_map.has(p_node),StringName()); ERR_FAIL_INDEX_V( p_input,node_map[p_node]->inputs.size(),StringName() ); return node_map[p_node]->inputs[p_input].node; }
StringName StringName::search(const String &p_name) { ERR_FAIL_COND_V(p_name == "", StringName()); lock->lock(); uint32_t hash = p_name.hash(); uint32_t idx = hash & STRING_TABLE_MASK; _Data *_data = _table[idx]; while (_data) { // compare hash first if (_data->hash == hash && p_name == _data->get_name()) break; _data = _data->next; } if (_data && _data->refcount.ref()) { lock->unlock(); return StringName(_data); } lock->unlock(); return StringName(); //does not exist }
BehaviorNode::Status StatusBNode::_step(const Variant &target, Dictionary &env) { if (!get_behavior_enable() || get_child_count() == 0) return STATUS_FAILURE; if ((bool)call(StringName("pre_behavior"),target, Variant(env)) && get_child_count() > 0) { if (_selected < 0) { _selected = 0; }else if (_selected >= get_child_count()) { _selected = get_child_count() - 1; } BehaviorNode *b_node = get_child(_selected)->cast_to<BehaviorNode>(); Status childrenStatus = STATUS_FAILURE; if (b_node) { if (_selected != _old_selected) b_node->reset(target); childrenStatus = b_node->step(target, env); } _old_selected = _selected; Status status = (Status)((int)call(StringName("behavior"),target, Variant(env))); if (status == STATUS_DEPEND_ON_CHILDREN) return childrenStatus; else return status; }else { return STATUS_FAILURE; } }
Ref<TimerObject> NewTimer::wait(float p_time) { const String timer_key = "new_timer"; MainLoop *main_loop = OS::get_singleton()->get_main_loop(); SceneTree *tree = main_loop->cast_to<SceneTree>(); ERR_FAIL_COND_V(tree == NULL, NULL); Viewport *viewport = tree->get_root(); ERR_FAIL_COND_V(viewport == NULL, NULL); if (timerNode==NULL) { timerNode = memnew(TimerNode); timerNode->set_name(timer_key); Vector<Variant> vector; vector.push_back(Variant(timerNode)); tree->connect(StringName("idle_frame"), this, StringName("_add_node"), vector, 0); } Ref<TimerObject> obj = memnew(TimerObject); obj->time = p_time; timerNode->timer_objs.push_back(obj); timerNode->check_queue(); return obj; }
StringName StringName::search(const CharType *p_name) { ERR_FAIL_COND_V(!configured, StringName()); ERR_FAIL_COND_V(!p_name, StringName()); if (!p_name[0]) return StringName(); lock->lock(); uint32_t hash = String::hash(p_name); uint32_t idx = hash & STRING_TABLE_MASK; _Data *_data = _table[idx]; while (_data) { // compare hash first if (_data->hash == hash && _data->get_name() == p_name) break; _data = _data->next; } if (_data && _data->refcount.ref()) { lock->unlock(); return StringName(_data); } lock->unlock(); return StringName(); //does not exist }
StringName SceneState::get_node_type(int p_idx) const { ERR_FAIL_INDEX_V(p_idx,nodes.size(),StringName()); if (nodes[p_idx].type==TYPE_INSTANCED) return StringName(); return names[nodes[p_idx].type]; }
void AnimController::add_child_notify(Node *p_child) { if (p_child->is_type("AnimationPlayer")) { anim_nodes[p_child->get_name()] = p_child; Vector<Variant> binds; binds.push_back(p_child); p_child->connect(StringName("finished"), this, StringName("_animation_finished"), binds); } }
StringName NetworkedMultiplayerENet::get_packet_peer() const{ ERR_FAIL_COND_V(!active,StringName()); ERR_FAIL_COND_V(incoming_packets.size()==0,StringName()); return incoming_packets.front()->get().from; }
StringName ClassDB::get_category(const StringName &p_node) { ERR_FAIL_COND_V(!classes.has(p_node), StringName()); #ifdef DEBUG_ENABLED return classes[p_node].category; #else return StringName(); #endif }
StringName GDTokenizerText::get_token_identifier(int p_offset) const { ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, StringName()); ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, StringName()); int ofs = (TK_RB_SIZE + tk_rb_pos + p_offset - MAX_LOOKAHEAD - 1) % TK_RB_SIZE; ERR_FAIL_COND_V(tk_rb[ofs].type != TK_IDENTIFIER, StringName()); return tk_rb[ofs].identifier; }
StringName ObjectTypeDB::get_category(const StringName& p_node) { ERR_FAIL_COND_V(!types.has(p_node),StringName()); #ifdef DEBUG_ENABLED return types[p_node].category; #else return StringName(); #endif }
StringName GDTokenizerBuffer::get_token_identifier(int p_offset) const{ int offset = token+p_offset; ERR_FAIL_INDEX_V(offset,tokens.size(),StringName()); uint32_t identifier = tokens[offset]>>TOKEN_BITS; ERR_FAIL_INDEX_V(identifier,identifiers.size(),StringName()); return identifiers[identifier]; }
void AnimationNodeStateMachineEditor::_update_mode() { if (tool_select->is_pressed()) { tool_erase_hb->show(); tool_erase->set_disabled(selected_node == StringName() && selected_transition_from == StringName() && selected_transition_to == StringName()); tool_autoplay->set_disabled(selected_node == StringName()); tool_end->set_disabled(selected_node == StringName()); } else { tool_erase_hb->hide(); } }
StringName AnimationPlayer::animation_get_next(const StringName& p_animation) const{ if (!animation_set.has(p_animation)) return StringName(); return animation_set[p_animation].next; }
Error AnimationTreePlayer::node_rename(const StringName& p_node,const StringName& p_new_name) { if (p_new_name==p_node) return OK; ERR_FAIL_COND_V(!node_map.has(p_node),ERR_ALREADY_EXISTS); ERR_FAIL_COND_V(node_map.has(p_new_name),ERR_ALREADY_EXISTS); ERR_FAIL_COND_V(p_new_name==StringName(),ERR_INVALID_DATA); ERR_FAIL_COND_V(p_node==out_name,ERR_INVALID_DATA); ERR_FAIL_COND_V(p_new_name==out_name,ERR_INVALID_DATA); for(Map<StringName,NodeBase*>::Element *E=node_map.front();E;E=E->next()) { NodeBase *nb = E->get(); for(int i=0;i<nb->inputs.size();i++) { if (nb->inputs[i].node==p_node) { nb->inputs[i].node=p_new_name; } } } node_map[p_new_name]=node_map[p_node]; node_map.erase(p_node); return OK; }
StringName ClassDB::get_integer_constant_enum(const StringName &p_class, const StringName &p_name, bool p_no_inheritance) { OBJTYPE_RLOCK; ClassInfo *type = classes.getptr(p_class); while (type) { const StringName *k = NULL; while ((k = type->enum_map.next(k))) { List<StringName> &constants_list = type->enum_map.get(*k); const List<StringName>::Element *found = constants_list.find(p_name); if (found) return *k; } if (p_no_inheritance) break; type = type->inherits_ptr; } return StringName(); }
void AnimatedSprite3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_sprite_frames", "sprite_frames"), &AnimatedSprite3D::set_sprite_frames); ClassDB::bind_method(D_METHOD("get_sprite_frames"), &AnimatedSprite3D::get_sprite_frames); ClassDB::bind_method(D_METHOD("set_animation", "animation"), &AnimatedSprite3D::set_animation); ClassDB::bind_method(D_METHOD("get_animation"), &AnimatedSprite3D::get_animation); ClassDB::bind_method(D_METHOD("_set_playing", "playing"), &AnimatedSprite3D::_set_playing); ClassDB::bind_method(D_METHOD("_is_playing"), &AnimatedSprite3D::_is_playing); ClassDB::bind_method(D_METHOD("play", "anim"), &AnimatedSprite3D::play, DEFVAL(StringName())); ClassDB::bind_method(D_METHOD("stop"), &AnimatedSprite3D::stop); ClassDB::bind_method(D_METHOD("is_playing"), &AnimatedSprite3D::is_playing); ClassDB::bind_method(D_METHOD("set_frame", "frame"), &AnimatedSprite3D::set_frame); ClassDB::bind_method(D_METHOD("get_frame"), &AnimatedSprite3D::get_frame); ClassDB::bind_method(D_METHOD("_res_changed"), &AnimatedSprite3D::_res_changed); ADD_SIGNAL(MethodInfo("frame_changed")); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "frames", PROPERTY_HINT_RESOURCE_TYPE, "SpriteFrames"), "set_sprite_frames", "get_sprite_frames"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "animation"), "set_animation", "get_animation"); ADD_PROPERTY(PropertyInfo(Variant::INT, "frame", PROPERTY_HINT_SPRITE_FRAME), "set_frame", "get_frame"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playing"), "_set_playing", "_is_playing"); }
Variant::operator StringName() const { if (type==NODE_PATH) { return reinterpret_cast<const NodePath*>(_data._mem)->get_sname(); } return StringName(operator String()); }
void RigidBodyBullet::dispatch_callbacks() { /// The check isTransformChanged is necessary in order to call integrated forces only when the first transform is sent if ((btBody->isActive() || previousActiveState != btBody->isActive()) && force_integration_callback && isTransformChanged) { if (omit_forces_integration) btBody->clearForces(); BulletPhysicsDirectBodyState *bodyDirect = BulletPhysicsDirectBodyState::get_singleton(this); Variant variantBodyDirect = bodyDirect; Object *obj = ObjectDB::get_instance(force_integration_callback->id); if (!obj) { // Remove integration callback set_force_integration_callback(0, StringName()); } else { const Variant *vp[2] = { &variantBodyDirect, &force_integration_callback->udata }; Variant::CallError responseCallError; int argc = (force_integration_callback->udata.get_type() == Variant::NIL) ? 1 : 2; obj->call(force_integration_callback->method, vp, argc, responseCallError); } } if (isScratchedSpaceOverrideModificator || 0 < countGravityPointSpaces) { isScratchedSpaceOverrideModificator = false; reload_space_override_modificator(); } /// Lock axis btBody->setLinearVelocity(btBody->getLinearVelocity() * btBody->getLinearFactor()); btBody->setAngularVelocity(btBody->getAngularVelocity() * btBody->getAngularFactor()); previousActiveState = btBody->isActive(); }
void Body2DSW::call_queries() { if (fi_callback) { Physics2DDirectBodyStateSW *dbs = Physics2DDirectBodyStateSW::singleton; dbs->body=this; Variant v=dbs; const Variant *vp[2]={&v,&fi_callback->callback_udata}; Object *obj = ObjectDB::get_instance(fi_callback->id); if (!obj) { set_force_integration_callback(0,StringName()); } else { Variant::CallError ce; if (fi_callback->callback_udata.get_type()) { obj->call(fi_callback->method,vp,2,ce); } else { obj->call(fi_callback->method,vp,1,ce); } } } }
void SpriteFramesEditor::edit(SpriteFrames *p_frames) { if (frames == p_frames) return; frames = p_frames; if (p_frames) { if (!p_frames->has_animation(edited_anim)) { List<StringName> anim_names; frames->get_animation_list(&anim_names); anim_names.sort_custom<StringName::AlphCompare>(); if (anim_names.size()) { edited_anim = anim_names.front()->get(); } else { edited_anim = StringName(); } } _update_library(); } else { hide(); //set_fixed_process(false); } }
void EditorSceneImportDialog::_choose_file(const String& p_path) { #if 0 StringName sn = EditorImportDB::get_singleton()->find_source_path(p_path); if (sn!=StringName()) { EditorImportDB::ImportScene isc; if (EditorImportDB::get_singleton()->get_scene(sn,isc)==OK) { save_path->set_text(String(sn).get_base_dir()); texture_options->set_flags( isc.image_flags ); texture_options->set_quality( isc.image_quality ); texture_options->set_format( isc.image_format ); animation_options->set_flags( isc.anim_flags ); script_path->set_text( isc.import_script ); uint32_t f = isc.flags; for(int i=0;i<scene_flags.size();i++) { scene_flags[i]->set_checked(0,f&(1<<i)); } } } else { #endif save_path->set_text(""); //save_path->set_text(p_path.get_file().basename()+".scn"); #if 0 } #endif import_path->set_text(p_path); }
/* Open connection dialog with TreeItem data to CREATE a brand-new connection. */ void ConnectionsDock::_open_connection_dialog(TreeItem &item) { String signal = item.get_metadata(0).operator Dictionary()["name"]; String signalname = signal; String midname = selectedNode->get_name(); for (int i = 0; i < midname.length(); i++) { //TODO: Regex filter may be cleaner. CharType c = midname[i]; if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_')) { if (c == ' ') { //Replace spaces with underlines. c = '_'; } else { //Remove any other characters. midname.remove(i); i--; continue; } } midname[i] = c; } Node *dst_node = selectedNode->get_owner() ? selectedNode->get_owner() : selectedNode; StringName dst_method = "_on_" + midname + "_" + signal; Connection c; c.source = selectedNode; c.signal = StringName(signalname); c.target = dst_node; c.method = dst_method; connect_dialog->init(c); connect_dialog->set_title(TTR("Connect Signal: ") + signalname); connect_dialog->popup_centered_ratio(); }
StringName Translation::get_message(const StringName& p_src_text) const { const Map<StringName, StringName>::Element *E=translation_map.find(p_src_text); if (!E) return StringName(); return E->get(); }
StringName ClassDB::get_parent_class(const StringName &p_class) { OBJTYPE_RLOCK; ClassInfo *ti = classes.getptr(p_class); ERR_FAIL_COND_V(!ti, StringName()); return ti->inherits; }
StringName ClassDB::get_parent_class_nocheck(const StringName &p_class) { OBJTYPE_RLOCK; ClassInfo *ti = classes.getptr(p_class); if (!ti) return StringName(); return ti->inherits; }
MonoObject *unmanaged_get_managed(Object *unmanaged) { if (unmanaged) { if (unmanaged->get_script_instance()) { CSharpInstance *cs_instance = CAST_CSHARP_INSTANCE(unmanaged->get_script_instance()); if (cs_instance) { return cs_instance->get_mono_object(); } } // If the owner does not have a CSharpInstance... void *data = unmanaged->get_script_instance_binding(CSharpLanguage::get_singleton()->get_language_index()); if (data) { CSharpScriptBinding &script_binding = ((Map<Object *, CSharpScriptBinding>::Element *)data)->value(); Ref<MonoGCHandle> &gchandle = script_binding.gchandle; ERR_FAIL_COND_V(gchandle.is_null(), NULL); MonoObject *target = gchandle->get_target(); if (target) return target; CSharpLanguage::get_singleton()->release_script_gchandle(gchandle); // Create a new one #ifdef DEBUG_ENABLED CRASH_COND(script_binding.type_name == StringName()); CRASH_COND(script_binding.wrapper_class == NULL); #endif MonoObject *mono_object = GDMonoUtils::create_managed_for_godot_object(script_binding.wrapper_class, script_binding.type_name, unmanaged); ERR_FAIL_NULL_V(mono_object, NULL); gchandle->set_handle(MonoGCHandle::new_strong_handle(mono_object), MonoGCHandle::STRONG_HANDLE); // Tie managed to unmanaged Reference *ref = Object::cast_to<Reference>(unmanaged); if (ref) { // Unsafe refcount increment. The managed instance also counts as a reference. // This way if the unmanaged world has no references to our owner // but the managed instance is alive, the refcount will be 1 instead of 0. // See: godot_icall_Reference_Dtor(MonoObject *p_obj, Object *p_ptr) ref->reference(); } return mono_object; } } return NULL; }
void NetworkedMultiplayerENet::_pop_current_packet() const { if (current_packet.packet) { enet_packet_destroy(current_packet.packet); current_packet.packet=NULL; current_packet.from=StringName(); } }