Renamed WebEditor* to WebNodeEditor*.

This commit is contained in:
Relintai 2022-08-23 13:27:59 +02:00
parent 5e64462049
commit 285fe5cd82
9 changed files with 82 additions and 82 deletions

View File

@ -31,13 +31,13 @@ SOFTWARE.
#include "web_node_editor_web_server.h"
#include "web_node_editor_web_server_request.h"
void WebEditor::edit(WebNode *web_node) {
void WebNodeEditor::edit(WebNode *web_node) {
_edited_node = web_node;
refresh();
}
void WebEditor::refresh() {
void WebNodeEditor::refresh() {
if (_edited_node && !ObjectDB::instance_validate(_edited_node)) {
_edited_node = nullptr;
}
@ -49,7 +49,7 @@ void WebEditor::refresh() {
return;
}
Ref<WebEditorWebServerRequest> request;
Ref<WebNodeEditorWebServerRequest> request;
request.instance();
_web_server->web_editor_request(_edited_node, request);
@ -58,16 +58,16 @@ void WebEditor::refresh() {
request_info += "Response type: ";
switch (request->_response_type) {
case WebEditorWebServerRequest::RESPONSE_TYPE_NONE: {
case WebNodeEditorWebServerRequest::RESPONSE_TYPE_NONE: {
request_info += "NONE";
} break;
case WebEditorWebServerRequest::RESPONSE_TYPE_NORMAL: {
case WebNodeEditorWebServerRequest::RESPONSE_TYPE_NORMAL: {
request_info += "NORMAL";
} break;
case WebEditorWebServerRequest::RESPONSE_TYPE_FILE: {
case WebNodeEditorWebServerRequest::RESPONSE_TYPE_FILE: {
request_info += "FILE";
} break;
case WebEditorWebServerRequest::RESPONSE_TYPE_REDIRECT: {
case WebNodeEditorWebServerRequest::RESPONSE_TYPE_REDIRECT: {
request_info += "REDIRECT";
} break;
default: {
@ -115,10 +115,10 @@ void WebEditor::refresh() {
}
switch (request->_response_type) {
case WebEditorWebServerRequest::RESPONSE_TYPE_NONE: {
case WebNodeEditorWebServerRequest::RESPONSE_TYPE_NONE: {
body += request->_sent_message;
} break;
case WebEditorWebServerRequest::RESPONSE_TYPE_NORMAL: {
case WebNodeEditorWebServerRequest::RESPONSE_TYPE_NORMAL: {
if (_prettify_html) {
HTMLParser p;
p.parse(request->_sent_message);
@ -127,11 +127,11 @@ void WebEditor::refresh() {
body += request->_sent_message;
}
} break;
case WebEditorWebServerRequest::RESPONSE_TYPE_FILE: {
case WebNodeEditorWebServerRequest::RESPONSE_TYPE_FILE: {
body += "Sent file:\n";
body += request->_sent_message;
} break;
case WebEditorWebServerRequest::RESPONSE_TYPE_REDIRECT: {
case WebNodeEditorWebServerRequest::RESPONSE_TYPE_REDIRECT: {
if (_prettify_html) {
HTMLParser p;
p.parse(request->_sent_message);
@ -148,12 +148,12 @@ void WebEditor::refresh() {
_results_label->set_text(body);
}
void WebEditor::clear() {
void WebNodeEditor::clear() {
_result_info_label->clear();
_results_label->clear();
}
void WebEditor::_notification(int p_what) {
void WebNodeEditor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
} break;
@ -171,10 +171,10 @@ void WebEditor::_notification(int p_what) {
}
}
WebEditor::WebEditor() {
WebNodeEditor::WebNodeEditor() {
_prettify_html = true;
_web_server = memnew(WebEditorWebServer);
_web_server = memnew(WebNodeEditorWebServer);
add_child(_web_server);
set_h_size_flags(SIZE_EXPAND_FILL);
@ -220,9 +220,9 @@ WebEditor::WebEditor() {
_results_label->add_color_region("<right>", "</right>", Color::color8(135, 206, 235, 255), false);
}
WebEditor::~WebEditor() {
WebNodeEditor::~WebNodeEditor() {
}
void WebEditor::_bind_methods() {
//ClassDB::bind_method(D_METHOD("_input", "event"), &WebEditor::_input);
void WebNodeEditor::_bind_methods() {
//ClassDB::bind_method(D_METHOD("_input", "event"), &WebNodeEditor::_input);
}

View File

@ -28,20 +28,20 @@ SOFTWARE.
#include "scene/gui/box_container.h"
class WebNode;
class WebEditorWebServer;
class WebNodeEditorWebServer;
class RichTextLabel;
class TextEdit;
class WebEditor : public VBoxContainer {
GDCLASS(WebEditor, VBoxContainer);
class WebNodeEditor : public VBoxContainer {
GDCLASS(WebNodeEditor, VBoxContainer);
public:
void edit(WebNode *web_node);
void refresh();
void clear();
WebEditor();
~WebEditor();
WebNodeEditor();
~WebNodeEditor();
protected:
void _notification(int p_what);
@ -50,7 +50,7 @@ protected:
bool _prettify_html;
WebNode *_edited_node;
WebEditorWebServer *_web_server;
WebNodeEditorWebServer *_web_server;
HBoxContainer *_toolbar;
RichTextLabel *_result_info_label;

View File

@ -28,7 +28,7 @@ SOFTWARE.
#include "editor/editor_node.h"
void WebEditorPlugin::make_visible(bool visible) {
void WebNodeEditorPlugin::make_visible(bool visible) {
if (visible) {
if (is_inside_tree()) {
_scene_has_webnode = true;
@ -39,19 +39,19 @@ void WebEditorPlugin::make_visible(bool visible) {
window->set_visible(visible);
}
String WebEditorPlugin::get_name() const {
String WebNodeEditorPlugin::get_name() const {
return "Web";
}
const Ref<Texture> WebEditorPlugin::get_icon() const {
const Ref<Texture> WebNodeEditorPlugin::get_icon() const {
return _icon;
}
bool WebEditorPlugin::has_main_screen() const {
bool WebNodeEditorPlugin::has_main_screen() const {
return true;
}
void WebEditorPlugin::edit(Object *p_object) {
void WebNodeEditorPlugin::edit(Object *p_object) {
WebNode *wn = Object::cast_to<WebNode>(p_object);
if (wn) {
@ -61,18 +61,18 @@ void WebEditorPlugin::edit(Object *p_object) {
}
}
bool WebEditorPlugin::handles(Object *p_object) const {
bool WebNodeEditorPlugin::handles(Object *p_object) const {
return p_object->is_class("WebNode");
}
void WebEditorPlugin::edited_scene_changed() {
void WebNodeEditorPlugin::edited_scene_changed() {
Node *edited_scene = editor->get_edited_scene();
_scene_has_webnode = scene_has_webnode(edited_scene);
editor->editor_set_visible_by_name("Web", _scene_has_webnode);
}
bool WebEditorPlugin::scene_has_webnode(Node *p_node) {
bool WebNodeEditorPlugin::scene_has_webnode(Node *p_node) {
if (!p_node) {
return false;
}
@ -92,7 +92,7 @@ bool WebEditorPlugin::scene_has_webnode(Node *p_node) {
return false;
}
bool WebEditorPlugin::scene_has_webnode_skip(Node *p_node, Node *skip) {
bool WebNodeEditorPlugin::scene_has_webnode_skip(Node *p_node, Node *skip) {
if (!p_node) {
return false;
}
@ -116,7 +116,7 @@ bool WebEditorPlugin::scene_has_webnode_skip(Node *p_node, Node *skip) {
return false;
}
void WebEditorPlugin::on_node_removed(Node *p_node) {
void WebNodeEditorPlugin::on_node_removed(Node *p_node) {
if (!_scene_has_webnode) {
return;
}
@ -129,10 +129,10 @@ void WebEditorPlugin::on_node_removed(Node *p_node) {
}
}
WebEditorPlugin::WebEditorPlugin(EditorNode *p_node) {
WebNodeEditorPlugin::WebNodeEditorPlugin(EditorNode *p_node) {
editor = p_node;
window = memnew(WebEditor);
window = memnew(WebNodeEditor);
editor->get_viewport()->add_child(window);
_icon = get_editor_interface()->get_base_control()->get_theme_icon("WebNodeEditor", "EditorIcons");
@ -144,11 +144,11 @@ WebEditorPlugin::WebEditorPlugin(EditorNode *p_node) {
Engine::get_singleton()->add_global("WebNodeEditor", window);
}
WebEditorPlugin::~WebEditorPlugin() {
WebNodeEditorPlugin::~WebNodeEditorPlugin() {
Engine::get_singleton()->remove_global("WebNodeEditor");
}
void WebEditorPlugin::_notification(int p_what) {
void WebNodeEditorPlugin::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_POST_ENTER_TREE: {
editor->editor_set_visible_by_name("Web", false);
@ -160,6 +160,6 @@ void WebEditorPlugin::_notification(int p_what) {
}
}
void WebEditorPlugin::_bind_methods() {
ClassDB::bind_method(D_METHOD("on_node_removed", "node"), &WebEditorPlugin::on_node_removed);
void WebNodeEditorPlugin::_bind_methods() {
ClassDB::bind_method(D_METHOD("on_node_removed", "node"), &WebNodeEditorPlugin::on_node_removed);
}

View File

@ -27,11 +27,11 @@ SOFTWARE.
#include "editor/editor_plugin.h"
class WebEditor;
class WebNodeEditor;
class Texture;
class WebEditorPlugin : public EditorPlugin {
GDCLASS(WebEditorPlugin, EditorPlugin);
class WebNodeEditorPlugin : public EditorPlugin {
GDCLASS(WebNodeEditorPlugin, EditorPlugin);
public:
void make_visible(bool visible);
@ -45,12 +45,12 @@ public:
bool scene_has_webnode(Node *p_node);
bool scene_has_webnode_skip(Node *p_node, Node *skip);
WebEditorPlugin(EditorNode *p_node);
~WebEditorPlugin();
WebNodeEditorPlugin(EditorNode *p_node);
~WebNodeEditorPlugin();
EditorNode *editor;
WebEditor *window;
WebNodeEditor *window;
protected:
void on_node_removed(Node *p_child);

View File

@ -4,7 +4,7 @@
#include "web_node_editor_web_server_request.h"
void WebEditorWebServer::web_editor_request(WebNode *node, Ref<WebEditorWebServerRequest> request) {
void WebNodeEditorWebServer::web_editor_request(WebNode *node, Ref<WebNodeEditorWebServerRequest> request) {
_web_root = node;
_last_request = request;
@ -16,12 +16,12 @@ void WebEditorWebServer::web_editor_request(WebNode *node, Ref<WebEditorWebServe
node->handle_request(request);
}
WebEditorWebServer::WebEditorWebServer() {
WebNodeEditorWebServer::WebNodeEditorWebServer() {
_is_running = true;
}
WebEditorWebServer::~WebEditorWebServer() {
WebNodeEditorWebServer::~WebNodeEditorWebServer() {
}
void WebEditorWebServer::_bind_methods() {
void WebNodeEditorWebServer::_bind_methods() {
}

View File

@ -6,18 +6,18 @@
#include "../http/web_server.h"
class WebNode;
class WebEditorWebServerRequest;
class WebNodeEditorWebServerRequest;
class WebEditorWebServer : public WebServer {
GDCLASS(WebEditorWebServer, WebServer);
class WebNodeEditorWebServer : public WebServer {
GDCLASS(WebNodeEditorWebServer, WebServer);
public:
void web_editor_request(WebNode *node, Ref<WebEditorWebServerRequest> request);
void web_editor_request(WebNode *node, Ref<WebNodeEditorWebServerRequest> request);
WebEditorWebServer();
~WebEditorWebServer();
WebNodeEditorWebServer();
~WebNodeEditorWebServer();
Ref<WebEditorWebServerRequest> _last_request;
Ref<WebNodeEditorWebServerRequest> _last_request;
protected:
static void _bind_methods();

View File

@ -6,79 +6,79 @@
#include "../http/web_server.h"
#include "../http/web_node.h"
String WebEditorWebServerRequest::get_cookie(const String &key) {
String WebNodeEditorWebServerRequest::get_cookie(const String &key) {
return "";
}
HTTPServerEnums::HTTPMethod WebEditorWebServerRequest::get_method() const {
HTTPServerEnums::HTTPMethod WebNodeEditorWebServerRequest::get_method() const {
return HTTPServerEnums::HTTP_METHOD_GET;
}
void WebEditorWebServerRequest::parse_files() {
void WebNodeEditorWebServerRequest::parse_files() {
}
int WebEditorWebServerRequest::get_file_count() const {
int WebNodeEditorWebServerRequest::get_file_count() const {
return 0;
}
String WebEditorWebServerRequest::get_file_file_name(const int index) const {
String WebNodeEditorWebServerRequest::get_file_file_name(const int index) const {
return "";
}
String WebEditorWebServerRequest::get_file_key(const int index) const {
String WebNodeEditorWebServerRequest::get_file_key(const int index) const {
return "";
}
int WebEditorWebServerRequest::get_file_length(const int index) const {
int WebNodeEditorWebServerRequest::get_file_length(const int index) const {
return 0;
}
PoolByteArray WebEditorWebServerRequest::get_file_data(const int index) const {
PoolByteArray WebNodeEditorWebServerRequest::get_file_data(const int index) const {
return PoolByteArray();
}
String WebEditorWebServerRequest::get_file_data_str(const int index) const {
String WebNodeEditorWebServerRequest::get_file_data_str(const int index) const {
return "";
}
String WebEditorWebServerRequest::get_parameter(const String &key) const {
String WebNodeEditorWebServerRequest::get_parameter(const String &key) const {
return "";
}
void WebEditorWebServerRequest::send_redirect(const String &location, const HTTPServerEnums::HTTPStatusCode status_code) {
void WebNodeEditorWebServerRequest::send_redirect(const String &location, const HTTPServerEnums::HTTPStatusCode status_code) {
_response_type = RESPONSE_TYPE_REDIRECT;
_status_code = status_code;
_sent_message = location;
}
void WebEditorWebServerRequest::send() {
void WebNodeEditorWebServerRequest::send() {
_response_type = RESPONSE_TYPE_NORMAL;
_sent_message = get_compiled_body();
}
void WebEditorWebServerRequest::send_file(const String &p_file_path) {
void WebNodeEditorWebServerRequest::send_file(const String &p_file_path) {
_response_type = RESPONSE_TYPE_FILE;
_sent_message = p_file_path;
}
void WebEditorWebServerRequest::send_error(int error_code) {
void WebNodeEditorWebServerRequest::send_error(int error_code) {
_error_handler_called = true;
_server->get_web_root()->handle_error_send_request(this, error_code);
}
String WebEditorWebServerRequest::parser_get_path() {
String WebNodeEditorWebServerRequest::parser_get_path() {
return "";
}
String WebEditorWebServerRequest::get_host() const {
String WebNodeEditorWebServerRequest::get_host() const {
return "";
}
void WebEditorWebServerRequest::update() {
void WebNodeEditorWebServerRequest::update() {
}
WebEditorWebServerRequest::WebEditorWebServerRequest() {
WebNodeEditorWebServerRequest::WebNodeEditorWebServerRequest() {
_response_type = RESPONSE_TYPE_NONE;
_error_handler_called = false;
}
WebEditorWebServerRequest::~WebEditorWebServerRequest() {
WebNodeEditorWebServerRequest::~WebNodeEditorWebServerRequest() {
}
void WebEditorWebServerRequest::_bind_methods() {
void WebNodeEditorWebServerRequest::_bind_methods() {
}

View File

@ -15,8 +15,8 @@ class HTTPSession;
class WebPermission;
class WebNode;
class WebEditorWebServerRequest : public WebServerRequest {
GDCLASS(WebEditorWebServerRequest, WebServerRequest);
class WebNodeEditorWebServerRequest : public WebServerRequest {
GDCLASS(WebNodeEditorWebServerRequest, WebServerRequest);
public:
enum ResponseType {
@ -49,8 +49,8 @@ public:
void update();
WebEditorWebServerRequest();
~WebEditorWebServerRequest();
WebNodeEditorWebServerRequest();
~WebNodeEditorWebServerRequest();
ResponseType _response_type;
String _sent_message;

View File

@ -130,7 +130,7 @@ void register_web_types() {
ClassDB::register_class<AliasWebPage>();
#if TOOLS_ENABLED
EditorPlugins::add_by_type<WebEditorPlugin>();
EditorPlugins::add_by_type<WebNodeEditorPlugin>();
#endif
}