| 322 | } |
| 323 | |
| 324 | void 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 | |
| 357 | void ScriptCreateDialog::ok_pressed() { |
| 358 | if (is_new_script_created) { |
nothing calls this directly
no test coverage detected