From f8db8a3faa30b71dca33ced38be16d3f93f43e8a Mon Sep 17 00:00:00 2001 From: Rémi Verschelde Date: Sun, 19 Mar 2017 00:36:26 +0100 Subject: Bring that Whole New World to the Old Continent too Applies the clang-format style to the 2.1 branch as done for master in 5dbf1809c6e3e905b94b8764e99491e608122261. --- editor/script_create_dialog.cpp | 209 ++++++++++++++++++---------------------- 1 file changed, 92 insertions(+), 117 deletions(-) (limited to 'editor/script_create_dialog.cpp') diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index 30cce9af0..25b0e2607 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -27,70 +27,68 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "script_create_dialog.h" -#include "script_language.h" +#include "editor_file_system.h" #include "globals.h" #include "io/resource_saver.h" #include "os/file_access.h" -#include "editor_file_system.h" +#include "script_language.h" -void ScriptCreateDialog::config(const String& p_base_name,const String&p_base_path) { +void ScriptCreateDialog::config(const String &p_base_name, const String &p_base_path) { class_name->set_text(""); parent_name->set_text(p_base_name); - if (p_base_path!="") { - initial_bp=p_base_path.basename(); - file_path->set_text(initial_bp+"."+ScriptServer::get_language( language_menu->get_selected() )->get_extension()); + if (p_base_path != "") { + initial_bp = p_base_path.basename(); + file_path->set_text(initial_bp + "." + ScriptServer::get_language(language_menu->get_selected())->get_extension()); } else { - initial_bp=""; + initial_bp = ""; file_path->set_text(""); } _class_name_changed(""); _path_changed(file_path->get_text()); } -bool ScriptCreateDialog::_validate(const String& p_string) { +bool ScriptCreateDialog::_validate(const String &p_string) { - if (p_string.length()==0) + if (p_string.length() == 0) return false; + for (int i = 0; i < p_string.length(); i++) { - for(int i=0;i='0' && p_string[0]<='9') + if (i == 0) { + if (p_string[0] >= '0' && p_string[0] <= '9') return false; // no start with number plz } - bool valid_char = (p_string[i]>='0' && p_string[i]<='9') || (p_string[i]>='a' && p_string[i]<='z') || (p_string[i]>='A' && p_string[i]<='Z') || p_string[i]=='_'; + bool valid_char = (p_string[i] >= '0' && p_string[i] <= '9') || (p_string[i] >= 'a' && p_string[i] <= 'z') || (p_string[i] >= 'A' && p_string[i] <= 'Z') || p_string[i] == '_'; if (!valid_char) return false; - } return true; } -void ScriptCreateDialog::_class_name_changed(const String& p_name) { +void ScriptCreateDialog::_class_name_changed(const String &p_name) { if (!_validate(parent_name->get_text())) { error_label->set_text(TTR("Invalid parent class name")); - error_label->add_color_override("font_color",Color(1,0.4,0.0,0.8)); + error_label->add_color_override("font_color", Color(1, 0.4, 0.0, 0.8)); } else if (class_name->is_editable()) { - if (class_name->get_text()=="") { - error_label->set_text(TTR("Valid chars:")+" a-z A-Z 0-9 _"); - error_label->add_color_override("font_color",Color(1,1,1,0.6)); + if (class_name->get_text() == "") { + error_label->set_text(TTR("Valid chars:") + " a-z A-Z 0-9 _"); + error_label->add_color_override("font_color", Color(1, 1, 1, 0.6)); } else if (!_validate(class_name->get_text())) { error_label->set_text(TTR("Invalid class name")); - error_label->add_color_override("font_color",Color(1,0.2,0.2,0.8)); + error_label->add_color_override("font_color", Color(1, 0.2, 0.2, 0.8)); } else { error_label->set_text(TTR("Valid name")); - error_label->add_color_override("font_color",Color(0,1.0,0.8,0.8)); + error_label->add_color_override("font_color", Color(0, 1.0, 0.8, 0.8)); } } else { error_label->set_text(TTR("N/A")); - error_label->add_color_override("font_color",Color(0,1.0,0.8,0.8)); + error_label->add_color_override("font_color", Color(0, 1.0, 0.8, 0.8)); } } @@ -107,28 +105,22 @@ void ScriptCreateDialog::ok_pressed() { alert->popup_centered_minsize(); return; - } - String cname; if (class_name->is_editable()) - cname=class_name->get_text(); + cname = class_name->get_text(); - - - String text = ScriptServer::get_language( language_menu->get_selected() )->get_template(cname,parent_name->get_text()); - Script *script = ScriptServer::get_language( language_menu->get_selected() )->create_script(); + String text = ScriptServer::get_language(language_menu->get_selected())->get_template(cname, parent_name->get_text()); + Script *script = ScriptServer::get_language(language_menu->get_selected())->create_script(); script->set_source_code(text); - if (cname!="") + if (cname != "") script->set_name(cname); - Ref