void EditorFileDialog::_item_dc_selected(int p_item) { int current = p_item; if (current<0 || current>=item_list->get_item_count()) return; Dictionary d=item_list->get_item_metadata(current); if (d["dir"]) { //print_line("change dir: "+String(d["name"])); dir_access->change_dir(d["name"]); if (mode==MODE_OPEN_FILE || mode==MODE_OPEN_FILES || mode==MODE_OPEN_DIR || MODE_OPEN_ANY) file->set_text(""); call_deferred("_update_file_list"); call_deferred("_update_dir"); _push_history(); } else { _action_pressed(); } }
void EditorFileSystem::update_file(const String& p_file) { EditorFileSystemDirectory *fs=NULL; int cpos=-1; if (!_find_file(p_file,&fs,cpos)) { if (!fs) return; } if (!FileAccess::exists(p_file)) { //was removed memdelete( fs->files[cpos] ); fs->files.remove(cpos); call_deferred("emit_signal","filesystem_changed"); //update later return; } String type = ResourceLoader::get_resource_type(p_file); if (cpos==-1) { int idx=0; for(int i=0;i<fs->files.size();i++) { if (p_file<fs->files[i]->file) break; idx++; } EditorFileSystemDirectory::FileInfo *fi = memnew( EditorFileSystemDirectory::FileInfo ); fi->file=p_file.get_file(); if (idx==fs->files.size()) { fs->files.push_back(fi); } else { fs->files.insert(idx,fi); } cpos=idx; } //print_line("UPDATING: "+p_file); fs->files[cpos]->type=type; fs->files[cpos]->modified_time=FileAccess::get_modified_time(p_file); fs->files[cpos]->meta=_get_meta(p_file); EditorResourcePreview::get_singleton()->call_deferred("check_for_invalidation",p_file); call_deferred("emit_signal","filesystem_changed"); //update later }
void StreamPlayer::sp_update() { //_THREAD_SAFE_METHOD_ if (!paused && resampler.is_ready() && playback.is_valid()) { if (!playback->is_playing()) { //stream depleted data, but there's still audio in the ringbuffer //check that all this audio has been flushed before stopping the stream int to_mix = resampler.get_total() - resampler.get_todo(); if (to_mix==0) { if (!stop_request) { stop_request=true; call_deferred("stop"); } return; } return; } int todo =resampler.get_todo(); int wrote = playback->mix(resampler.get_write_buffer(),todo); resampler.write(wrote); } }
Variant Object::_call_deferred_bind(const Variant** p_args, int p_argcount, Variant::CallError& r_error) { if (p_argcount<1) { r_error.error=Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; r_error.argument=0; return Variant(); } if (p_args[0]->get_type()!=Variant::STRING) { r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument=0; r_error.expected=Variant::STRING; return Variant(); } r_error.error=Variant::CallError::CALL_OK; StringName signal = *p_args[0]; Variant v[VARIANT_ARG_MAX]; for(int i=0;i<MIN(5,p_argcount-1);i++) { v[i]=*p_args[i+1]; } call_deferred(signal,v[0],v[1],v[2],v[3],v[4]); return Variant(); }
Error HTTPRequest::request(const String &p_url, const Vector<String> &p_custom_headers, bool p_ssl_validate_domain, HTTPClient::Method p_method, const String &p_request_data) { ERR_FAIL_COND_V(!is_inside_tree(), ERR_UNCONFIGURED); if (requesting) { ERR_EXPLAIN("HTTPRequest is processing a request. Wait for completion or cancel it before attempting a new one."); ERR_FAIL_V(ERR_BUSY); } method = p_method; Error err = _parse_url(p_url); if (err) return err; validate_ssl = p_ssl_validate_domain; bool has_user_agent = false; bool has_accept = false; headers = p_custom_headers; request_data = p_request_data; for (int i = 0; i < headers.size(); i++) { if (headers[i].findn("user-agent:") == 0) has_user_agent = true; if (headers[i].findn("Accept:") == 0) has_accept = true; } if (!has_user_agent) { headers.push_back("User-Agent: GodotEngine/" + String(VERSION_MKSTRING) + " (" + OS::get_singleton()->get_name() + ")"); } if (!has_accept) { headers.push_back("Accept: */*"); } requesting = true; if (use_threads) { thread_done = false; thread_request_quit = false; client->set_blocking_mode(true); thread = Thread::create(_thread_func, this); } else { client->set_blocking_mode(false); err = _request(); if (err != OK) { call_deferred("_request_done", RESULT_CANT_CONNECT, 0, PoolStringArray(), PoolByteArray()); return ERR_CANT_CONNECT; } set_process_internal(true); } return OK; }
void AnimationTree::_tree_changed() { if (properties_dirty) { return; } call_deferred("_update_properties"); properties_dirty = true; }
void SpriteBase3D::_queue_update(){ if (pending_update) return; pending_update=true; call_deferred(SceneStringNames::get_singleton()->_im_update); }
void ProceduralSky::_queue_update() { if (update_queued) return; update_queued = true; call_deferred("_update_sky"); }
void SpatialIndexer::_request_update() { if (pending_update) return; pending_update=true; call_deferred(SceneStringNames::get_singleton()->_update_pairs); }
void ProjectSettings::_translation_res_select() { if (updating_translations) return; call_deferred("_update_translations"); }
void NoiseTexture::_queue_update() { if (update_queued) return; update_queued = true; call_deferred("_update_texture"); }
void ResourcesDock::_delete(Object* p_item, int p_column, int p_id) { TreeItem *ti = p_item->cast_to<TreeItem>(); ERR_FAIL_COND(!ti); call_deferred("remove_resource",ti->get_metadata(0)); }
void FileDialog::_tree_item_activated() { TreeItem *ti = tree->get_selected(); if (!ti) return; Dictionary d = ti->get_metadata(0); if (d["dir"]) { dir_access->change_dir(d["name"]); if (mode == MODE_OPEN_FILE || mode == MODE_OPEN_FILES || mode == MODE_OPEN_DIR || mode == MODE_OPEN_ANY) file->set_text(""); call_deferred("_update_file_list"); call_deferred("_update_dir"); } else { _action_pressed(); } }
void SpriteBase3D::_queue_update() { if (pending_update) return; triangle_mesh.unref(); update_gizmo(); pending_update = true; call_deferred(SceneStringNames::get_singleton()->_im_update); }
void SoftBody::_draw_soft_mesh() { if (get_mesh().is_null()) return; if (!visual_server_handler.is_ready()) { visual_server_handler.prepare(get_mesh()->get_rid(), 0); /// Necessary in order to render the mesh correctly (Soft body nodes are in global space) simulation_started = true; call_deferred("set_as_toplevel", true); call_deferred("set_transform", Transform()); } visual_server_handler.open(); PhysicsServer::get_singleton()->soft_body_update_visual_server(physics_rid, &visual_server_handler); visual_server_handler.close(); visual_server_handler.commit_changes(); }
bool Tween::remove_all() { if(pending_update != 0) { call_deferred("remove_all"); return true; } set_active(false); _set_process(false); interpolates.clear(); return true; }
void EditorSelection::update() { _update_nl(); if (!changed) return; changed = false; if (!emitted) { emitted = true; call_deferred("_emit_change"); } }
void EditorFileDialog::_item_dc_selected(int p_item) { int current = p_item; if (current < 0 || current >= item_list->get_item_count()) return; Dictionary d = item_list->get_item_metadata(current); if (d["dir"]) { dir_access->change_dir(d["name"]); call_deferred("_update_file_list"); call_deferred("_update_dir"); _push_history(); } else { _action_pressed(); } }
bool GodotSharpEditor::_create_project_solution() { EditorProgress pr("create_csharp_solution", "Generating solution...", 2); pr.step("Generating C# project..."); String path = OS::get_singleton()->get_resource_dir(); String name = ProjectSettings::get_singleton()->get("application/config/name"); if (name.empty()) { name = "UnnamedProject"; } String guid = CSharpProject::generate_game_project(path, name); if (guid.length()) { NETSolution solution(name); if (!solution.set_path(path)) { show_error_dialog("Failed to create solution."); return false; } Vector<String> extra_configs; extra_configs.push_back("Tools"); solution.add_new_project(name, guid, extra_configs); Error sln_error = solution.save(); if (sln_error != OK) { show_error_dialog("Failed to save solution."); return false; } if (!GodotSharpBuilds::make_api_sln(GodotSharpBuilds::API_CORE)) return false; if (!GodotSharpBuilds::make_api_sln(GodotSharpBuilds::API_EDITOR)) return false; pr.step("Done"); // Here, after all calls to progress_task_step call_deferred("_remove_create_sln_menu_option"); } else { show_error_dialog("Failed to create C# project."); } return true; }
void GraphEdit::_scroll_moved(double) { if (!awaiting_scroll_offset_update) { call_deferred("_update_scroll_offset"); awaiting_scroll_offset_update = true; } top_layer->update(); update(); if (!setting_scroll_ofs) { //in godot, signals on change value are avoided as a convention emit_signal("scroll_offset_changed", get_scroll_ofs()); } }
void TileMap::_make_quadrant_dirty(Map<PosKey,Quadrant>::Element *Q) { Quadrant &q=Q->get(); if (!q.dirty_list.in_list()) dirty_quadrant_list.add(&q.dirty_list); if (pending_update) return; pending_update=true; if (!is_inside_scene()) return; call_deferred("_update_dirty_quadrants"); }
void GraphEdit::_update_scroll() { if (updating) return; updating = true; set_block_minimum_size_adjust(true); Rect2 screen; for (int i = 0; i < get_child_count(); i++) { GraphNode *gn = Object::cast_to<GraphNode>(get_child(i)); if (!gn) continue; Rect2 r; r.position = gn->get_offset() * zoom; r.size = gn->get_size() * zoom; screen = screen.merge(r); } screen.position -= get_size(); screen.size += get_size() * 2.0; h_scroll->set_min(screen.position.x); h_scroll->set_max(screen.position.x + screen.size.x); h_scroll->set_page(get_size().x); if (h_scroll->get_max() - h_scroll->get_min() <= h_scroll->get_page()) h_scroll->hide(); else h_scroll->show(); v_scroll->set_min(screen.position.y); v_scroll->set_max(screen.position.y + screen.size.y); v_scroll->set_page(get_size().y); if (v_scroll->get_max() - v_scroll->get_min() <= v_scroll->get_page()) v_scroll->hide(); else v_scroll->show(); set_block_minimum_size_adjust(false); if (!awaiting_scroll_offset_update) { call_deferred("_update_scroll_offset"); awaiting_scroll_offset_update = true; } updating = false; }
void EditorAudioBuses::_file_dialog_callback(const String &p_string) { if (file_dialog->get_mode() == EditorFileDialog::MODE_OPEN_FILE) { Ref<AudioBusLayout> state = ResourceLoader::load(p_string); if (state.is_null()) { EditorNode::get_singleton()->show_warning(TTR("Invalid file, not an audio bus layout.")); return; } edited_path = p_string; file->set_text(p_string.get_file()); AudioServer::get_singleton()->set_bus_layout(state); _update_buses(); EditorNode::get_singleton()->get_undo_redo()->clear_history(); call_deferred("_select_layout"); } else if (file_dialog->get_mode() == EditorFileDialog::MODE_SAVE_FILE) { if (new_layout) { Ref<AudioBusLayout> empty_state; empty_state.instance(); AudioServer::get_singleton()->set_bus_layout(empty_state); } Error err = ResourceSaver::save(p_string, AudioServer::get_singleton()->generate_bus_layout()); if (err != OK) { EditorNode::get_singleton()->show_warning("Error saving file: " + p_string); return; } edited_path = p_string; file->set_text(p_string.get_file()); _update_buses(); EditorNode::get_singleton()->get_undo_redo()->clear_history(); call_deferred("_select_layout"); } }
void ProjectManager::_favorite_pressed(Node *p_hb) { String clicked = p_hb->get_meta("name"); bool favorite = !p_hb->get_meta("favorite"); String proj=clicked.replace(":::",":/"); proj=proj.replace("::","/"); if (favorite) { EditorSettings::get_singleton()->set("favorite_projects/"+clicked,proj); } else { EditorSettings::get_singleton()->erase("favorite_projects/"+clicked); } EditorSettings::get_singleton()->save(); call_deferred("_load_recent_projects"); }
void EditorAudioBuses::_load_default_layout() { Ref<AudioBusLayout> state = ResourceLoader::load("res://default_bus_layout.tres"); if (state.is_null()) { EditorNode::get_singleton()->show_warning(TTR("There is no 'res://default_bus_layout.tres' file.")); return; } edited_path = "res://default_bus_layout.tres"; file->set_text(edited_path.get_file()); AudioServer::get_singleton()->set_bus_layout(state); _update_buses(); EditorNode::get_singleton()->get_undo_redo()->clear_history(); call_deferred("_select_layout"); }
void FindReplaceBar::_show_search() { show(); search_text->call_deferred("grab_focus"); if (text_edit->is_selection_active() && !selection_only->is_pressed()) { search_text->set_text(text_edit->get_selection_text()); } if (!get_search_text().empty()) { search_text->select_all(); search_text->set_cursor_position(search_text->get_text().length()); search_current(); } call_deferred("_update_size"); }
void TabContainer::remove_child_notify(Node *p_child) { int tc = get_tab_count(); // bool set_curent=false; if (current==tc-1) { current--; if (current<0) current=0; else { call_deferred("set_current_tab",current); } } p_child->disconnect("renamed", this,"_child_renamed_callback"); update(); }
void EditorFileSystem::update_file(const String& p_file) { EditorFileSystemDirectory *fs=NULL; int cpos=-1; if (!_find_file(p_file,&fs,cpos)) { if (!fs) return; } String type = ResourceLoader::get_resource_type(p_file); if (cpos==-1) { int idx=0; for(int i=0;i<fs->files.size();i++) { if (p_file<fs->files[i].file) break; idx++; } EditorFileSystemDirectory::FileInfo fi; fi.file=p_file.get_file(); if (idx==fs->files.size()) { fs->files.push_back(fi); } else { fs->files.insert(idx,fi); } cpos=idx; } print_line("UPDATING: "+p_file); fs->files[cpos].type=type; fs->files[cpos].modified_time=FileAccess::get_modified_time(p_file); fs->files[cpos].meta=_get_meta(p_file); call_deferred("emit_signal","filesystem_changed"); //update later }
void EditorAudioBuses::open_layout(const String &p_path) { EditorNode::get_singleton()->make_bottom_panel_item_visible(this); Ref<AudioBusLayout> state = ResourceLoader::load(p_path); if (state.is_null()) { EditorNode::get_singleton()->show_warning(TTR("Invalid file, not an audio bus layout.")); return; } edited_path = p_path; file->set_text(p_path.get_file()); AudioServer::get_singleton()->set_bus_layout(state); _update_buses(); EditorNode::get_singleton()->get_undo_redo()->clear_history(); call_deferred("_select_layout"); }
bool Tween::remove(Object *p_object, String p_key) { if(pending_update != 0) { call_deferred("remove", p_object, p_key); return true; } for(List<InterpolateData>::Element *E=interpolates.front();E;E=E->next()) { InterpolateData& data = E->get(); Object *object = ObjectDB::get_instance(data.id); if(object == NULL) continue; if(object == p_object && data.key == p_key) { interpolates.erase(E); return true; } } return true; }