You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-12 13:20:55 +00:00
A Whole New World (clang-format edition)
I can show you the code Pretty, with proper whitespace Tell me, coder, now when did You last write readable code? I can open your eyes Make you see your bad indent Force you to respect the style The core devs agreed upon A whole new world A new fantastic code format A de facto standard With some sugar Enforced with clang-format A whole new world A dazzling style we all dreamed of And when we read it through It's crystal clear That now we're in a whole new world of code
This commit is contained in:
@@ -28,39 +28,35 @@
|
||||
/*************************************************************************/
|
||||
#include "rich_text_editor_plugin.h"
|
||||
|
||||
#include "os/file_access.h"
|
||||
#include "canvas_item_editor_plugin.h"
|
||||
#include "os/file_access.h"
|
||||
|
||||
void RichTextEditor::_notification(int p_what) {
|
||||
|
||||
switch(p_what) {
|
||||
switch (p_what) {
|
||||
|
||||
case NOTIFICATION_FIXED_PROCESS: {
|
||||
|
||||
|
||||
} break;
|
||||
}
|
||||
|
||||
}
|
||||
void RichTextEditor::_node_removed(Node *p_node) {
|
||||
|
||||
if(p_node==node) {
|
||||
node=NULL;
|
||||
if (p_node == node) {
|
||||
node = NULL;
|
||||
hide();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void RichTextEditor::_file_selected(const String& p_path) {
|
||||
void RichTextEditor::_file_selected(const String &p_path) {
|
||||
|
||||
CharString cs;
|
||||
FileAccess *fa = FileAccess::open(p_path,FileAccess::READ);
|
||||
FileAccess *fa = FileAccess::open(p_path, FileAccess::READ);
|
||||
if (!fa) {
|
||||
ERR_FAIL();
|
||||
}
|
||||
|
||||
while(!fa->eof_reached())
|
||||
while (!fa->eof_reached())
|
||||
cs.push_back(fa->get_8());
|
||||
cs.push_back(0);
|
||||
memdelete(fa);
|
||||
@@ -68,12 +64,11 @@ void RichTextEditor::_file_selected(const String& p_path) {
|
||||
String bbcode;
|
||||
bbcode.parse_utf8(&cs[0]);
|
||||
node->parse_bbcode(bbcode);
|
||||
|
||||
}
|
||||
|
||||
void RichTextEditor::_menu_option(int p_option) {
|
||||
|
||||
switch(p_option) {
|
||||
switch (p_option) {
|
||||
|
||||
case PARSE_BBCODE: {
|
||||
|
||||
@@ -84,42 +79,38 @@ void RichTextEditor::_menu_option(int p_option) {
|
||||
node->clear();
|
||||
|
||||
} break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void RichTextEditor::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_menu_option"),&RichTextEditor::_menu_option);
|
||||
ClassDB::bind_method(D_METHOD("_file_selected"),&RichTextEditor::_file_selected);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_menu_option"), &RichTextEditor::_menu_option);
|
||||
ClassDB::bind_method(D_METHOD("_file_selected"), &RichTextEditor::_file_selected);
|
||||
}
|
||||
|
||||
void RichTextEditor::edit(Node *p_rich_text) {
|
||||
|
||||
node=p_rich_text->cast_to<RichTextLabel>();
|
||||
|
||||
node = p_rich_text->cast_to<RichTextLabel>();
|
||||
}
|
||||
RichTextEditor::RichTextEditor() {
|
||||
|
||||
options = memnew( MenuButton );
|
||||
options = memnew(MenuButton);
|
||||
//add_child(options);
|
||||
CanvasItemEditor::get_singleton()->add_control_to_menu_panel(options);
|
||||
options->set_area_as_parent_rect();
|
||||
|
||||
options->set_text("RichText");
|
||||
options->get_popup()->add_item(TTR("Parse BBCode"),PARSE_BBCODE);
|
||||
options->get_popup()->add_item(TTR("Clear"),CLEAR);
|
||||
options->get_popup()->add_item(TTR("Parse BBCode"), PARSE_BBCODE);
|
||||
options->get_popup()->add_item(TTR("Clear"), CLEAR);
|
||||
|
||||
options->get_popup()->connect("id_pressed", this,"_menu_option");
|
||||
file_dialog = memnew( EditorFileDialog );
|
||||
options->get_popup()->connect("id_pressed", this, "_menu_option");
|
||||
file_dialog = memnew(EditorFileDialog);
|
||||
add_child(file_dialog);
|
||||
file_dialog->add_filter("*.txt");
|
||||
file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE);
|
||||
file_dialog->connect("file_selected",this,"_file_selected");
|
||||
file_dialog->connect("file_selected", this, "_file_selected");
|
||||
}
|
||||
|
||||
|
||||
void RichTextEditorPlugin::edit(Object *p_object) {
|
||||
|
||||
rich_text_editor->edit(p_object->cast_to<Node>());
|
||||
@@ -139,26 +130,21 @@ void RichTextEditorPlugin::make_visible(bool p_visible) {
|
||||
rich_text_editor->options->hide();
|
||||
rich_text_editor->edit(NULL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
RichTextEditorPlugin::RichTextEditorPlugin(EditorNode *p_node) {
|
||||
|
||||
editor=p_node;
|
||||
rich_text_editor = memnew( RichTextEditor );
|
||||
editor = p_node;
|
||||
rich_text_editor = memnew(RichTextEditor);
|
||||
editor->get_viewport()->add_child(rich_text_editor);
|
||||
|
||||
rich_text_editor->set_margin(MARGIN_LEFT,184);
|
||||
rich_text_editor->set_margin(MARGIN_RIGHT,230);
|
||||
rich_text_editor->set_margin(MARGIN_TOP,0);
|
||||
rich_text_editor->set_margin(MARGIN_BOTTOM,10);
|
||||
rich_text_editor->set_margin(MARGIN_LEFT, 184);
|
||||
rich_text_editor->set_margin(MARGIN_RIGHT, 230);
|
||||
rich_text_editor->set_margin(MARGIN_TOP, 0);
|
||||
rich_text_editor->set_margin(MARGIN_BOTTOM, 10);
|
||||
|
||||
rich_text_editor->options->hide();
|
||||
|
||||
}
|
||||
|
||||
|
||||
RichTextEditorPlugin::~RichTextEditorPlugin()
|
||||
{
|
||||
RichTextEditorPlugin::~RichTextEditorPlugin() {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user