MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / _template_changed

Method _template_changed

editor/script/script_create_dialog.cpp:324–355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

322}
323
324void ScriptCreateDialog::_template_changed(int p_template) {
325 const ScriptLanguage::ScriptTemplate &sinfo = _get_current_template();
326 // Update last used dictionaries
327 if (is_using_templates && !parent_name->get_text().begins_with("\"res:")) {
328 if (sinfo.origin == ScriptLanguage::TemplateLocation::TEMPLATE_PROJECT) {
329 // Save the last used template for this node into the project dictionary.
330 Dictionary dic_templates_project = EditorSettings::get_singleton()->get_project_metadata("script_setup", "templates_dictionary", Dictionary());
331 dic_templates_project[parent_name->get_text()] = sinfo.get_hash();
332 EditorSettings::get_singleton()->set_project_metadata("script_setup", "templates_dictionary", dic_templates_project);
333 } else {
334 // Save template info to editor dictionary (not a project template).
335 Dictionary dic_templates = EDITOR_GET("_script_setup_templates_dictionary");
336 dic_templates[parent_name->get_text()] = sinfo.get_hash();
337 EditorSettings::get_singleton()->set("_script_setup_templates_dictionary", dic_templates);
338 // Remove template from project dictionary as we last used an editor level template.
339 Dictionary dic_templates_project = EditorSettings::get_singleton()->get_project_metadata("script_setup", "templates_dictionary", Dictionary());
340 if (dic_templates_project.has(parent_name->get_text())) {
341 dic_templates_project.erase(parent_name->get_text());
342 EditorSettings::get_singleton()->set_project_metadata("script_setup", "templates_dictionary", dic_templates_project);
343 }
344 }
345 }
346
347 // Update template label information.
348 String template_info = U"• ";
349 template_info += TTR("Template:");
350 template_info += " " + sinfo.name;
351 if (!sinfo.description.is_empty()) {
352 template_info += " - " + sinfo.description;
353 }
354 validation_panel->set_message(MSG_ID_TEMPLATE, template_info, EditorValidationPanel::MSG_INFO, false);
355}
356
357void ScriptCreateDialog::ok_pressed() {
358 if (is_new_script_created) {

Callers

nothing calls this directly

Calls 12

TTRFunction · 0.85
begins_withMethod · 0.80
get_project_metadataMethod · 0.80
set_project_metadataMethod · 0.80
DictionaryClass · 0.50
get_textMethod · 0.45
get_hashMethod · 0.45
setMethod · 0.45
hasMethod · 0.45
eraseMethod · 0.45
is_emptyMethod · 0.45
set_messageMethod · 0.45

Tested by

no test coverage detected