Added back tools build support and editor docs.

This commit is contained in:
Relintai 2023-12-17 00:57:16 +01:00
parent c74948a3fd
commit 7773f9cf80
46 changed files with 1556 additions and 4222 deletions

View File

@ -615,11 +615,6 @@ if selected_platform in platform_list:
sys.path.remove(path)
sys.modules.pop("config")
#TODO hack, the editor should be a module as well
if env["tools"] and not env["module_freetype_enabled"]:
print("The editor (tools=yes) can't be built if freetype is disabled! Stopping.")
sys.exit(255)
env.module_list = modules_enabled
methods.sort_module_list(env)
@ -643,6 +638,9 @@ if selected_platform in platform_list:
if env.use_ptrcall:
env.Append(CPPDEFINES=["PTRCALL_ENABLED"])
if env["tools"]:
env.Append(CPPDEFINES=["TOOLS_ENABLED"])
if env["disable_advanced_gui"]:
env.Append(CPPDEFINES=["ADVANCED_GUI_DISABLED"])
@ -688,6 +686,9 @@ if selected_platform in platform_list:
SConscript("servers/SCsub")
SConscript("scene/SCsub")
if env["tools"]:
SConscript("editor/SCsub")
SConscript("drivers/SCsub")
SConscript("platform/SCsub")

View File

@ -34,10 +34,6 @@
#include "core/os/os.h"
#include "core/config/project_settings.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_settings.h"
#endif
Input *Input::singleton = nullptr;
Input *Input::get_singleton() {

77
editor/SCsub Normal file
View File

@ -0,0 +1,77 @@
#!/usr/bin/env python
Import("env")
env.editor_sources = []
import os
import glob
from platform_methods import run_in_subprocess
from compat import open_utf8
import editor_builders
def _make_doc_data_class_path(to_path):
# NOTE: It is safe to generate this file here, since this is still executed serially
g = open_utf8(os.path.join(to_path, "doc_data_class_path.gen.h"), "w")
g.write("static const int _doc_data_class_path_count = " + str(len(env.doc_class_path)) + ";\n")
g.write("struct _DocDataClassPath { const char* name; const char* path; };\n")
g.write("static const _DocDataClassPath _doc_data_class_paths[" + str(len(env.doc_class_path) + 1) + "] = {\n")
for c in sorted(env.doc_class_path):
g.write('\t{"' + c + '", "' + env.doc_class_path[c] + '"},\n')
g.write("\t{NULL, NULL}\n")
g.write("};\n")
g.close()
if env["tools"]:
# Register exporters
reg_exporters_inc = '#include "register_exporters.h"\n'
reg_exporters = "void register_exporters() {\n"
for e in env.platform_exporters:
# Glob all .cpp files in export folder
files = Glob("#platform/" + e + "/export/" + "*.cpp")
env.add_source_files(env.editor_sources, files)
reg_exporters += "\tregister_" + e + "_exporter();\n"
reg_exporters_inc += '#include "platform/' + e + '/export/export.h"\n'
reg_exporters += "}\n"
# NOTE: It is safe to generate this file here, since this is still executed serially
with open_utf8("register_exporters.gen.cpp", "w") as f:
f.write(reg_exporters_inc)
f.write(reg_exporters)
# Core API documentation.
docs = []
if env["editor_docs"]:
docs += Glob("#doc/classes/*.xml")
# Module API documentation.
module_dirs = []
for d in env.doc_class_path.values():
if d not in module_dirs:
module_dirs.append(d)
for d in module_dirs:
if not os.path.isabs(d):
docs += Glob("#" + d + "/*.xml") # Built-in.
else:
docs += Glob(d + "/*.xml") # Custom.
_make_doc_data_class_path(env.Dir("#editor/doc").abspath)
docs = sorted(docs)
env.Depends("#editor/doc_data_compressed.gen.h", docs)
env.CommandNoCache("#editor/doc_data_compressed.gen.h", docs, run_in_subprocess(editor_builders.make_doc_header))
#env.add_source_files(env.editor_sources, "*.cpp")
SConscript("doc/SCsub")
lib = env.add_library("editor", env.editor_sources)
env.Prepend(LIBS=[lib])

5
editor/doc/SCsub Normal file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env python
Import("env")
env.add_source_files(env.editor_sources, "*.cpp")

1274
editor/doc/doc_data.cpp Normal file

File diff suppressed because it is too large Load Diff

136
editor/doc/doc_data.h Normal file
View File

@ -0,0 +1,136 @@
#ifndef DOC_DATA_H
#define DOC_DATA_H
/*************************************************************************/
/* doc_data.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "core/containers/rb_map.h"
#include "core/variant/variant.h"
#include "core/object/reference.h"
#include "core/error/error_list.h"
#include "core/string/ustring.h"
#include "core/containers/vector.h"
class XMLParser;
class DocData {
public:
struct ArgumentDoc {
String name;
String type;
String enumeration;
String default_value;
};
struct MethodDoc {
String name;
String return_type;
String return_enum;
String qualifiers;
String description;
Vector<ArgumentDoc> arguments;
bool operator<(const MethodDoc &p_md) const {
return name < p_md.name;
}
};
struct ConstantDoc {
String name;
String value;
bool is_value_valid;
String enumeration;
String description;
};
struct PropertyDoc {
String name;
String type;
String enumeration;
String description;
String setter, getter;
String default_value;
bool overridden;
String overrides;
bool operator<(const PropertyDoc &p_prop) const {
return name < p_prop.name;
}
PropertyDoc() {
overridden = false;
}
};
struct ThemeItemDoc {
String name;
String type;
String data_type;
String description;
String default_value;
bool operator<(const ThemeItemDoc &p_theme_item) const {
// First sort by the data type, then by name.
if (data_type == p_theme_item.data_type) {
return name < p_theme_item.name;
}
return data_type < p_theme_item.data_type;
}
};
struct TutorialDoc {
String link;
String title;
};
struct ClassDoc {
String name;
String inherits;
String category;
String brief_description;
String description;
Vector<TutorialDoc> tutorials;
Vector<MethodDoc> methods;
Vector<MethodDoc> signals;
Vector<ConstantDoc> constants;
Vector<PropertyDoc> properties;
Vector<ThemeItemDoc> theme_properties;
};
String version;
RBMap<String, ClassDoc> class_list;
Error _load(Ref<XMLParser> parser);
public:
void merge_from(const DocData &p_data);
void remove_from(const DocData &p_data);
void generate(bool p_basic_types = false);
Error load_classes(const String &p_dir);
static Error erase_classes(const String &p_dir);
Error save_classes(const String &p_default_path, const RBMap<String, String> &p_class_path);
};
#endif // DOC_DATA_H

51
editor/editor_builders.py Normal file
View File

@ -0,0 +1,51 @@
"""Functions used to generate source files during build time
All such functions are invoked in a subprocess on Windows to prevent build flakiness.
"""
import os
import os.path
import shutil
import subprocess
import tempfile
import uuid
from platform_methods import subprocess_main
from compat import encode_utf8, byte_to_str, open_utf8
def make_doc_header(target, source, env):
dst = target[0]
g = open_utf8(dst, "w")
buf = ""
docbegin = ""
docend = ""
for src in source:
if not src.endswith(".xml"):
continue
with open_utf8(src, "r") as f:
content = f.read()
buf += content
buf = encode_utf8(docbegin + buf + docend)
decomp_size = len(buf)
import zlib
buf = zlib.compress(buf)
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
g.write("#ifndef _DOC_DATA_RAW_H\n")
g.write("#define _DOC_DATA_RAW_H\n")
g.write("static const int _doc_data_compressed_size = " + str(len(buf)) + ";\n")
g.write("static const int _doc_data_uncompressed_size = " + str(decomp_size) + ";\n")
g.write("static const unsigned char _doc_data_compressed[] = {\n")
for i in range(len(buf)):
g.write("\t" + byte_to_str(buf[i]) + ",\n")
g.write("};\n")
g.write("#endif")
g.close()
if __name__ == "__main__":
subprocess_main(globals())

View File

@ -63,20 +63,10 @@
#ifdef TOOLS_ENABLED
#include "editor/doc/doc_data.h"
#include "editor/doc/doc_data_class_path.gen.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor/editor_translation.h"
#include "editor/progress_dialog.h"
#include "editor/project_manager.h"
#include "editor/script_editor_debugger.h"
#endif
#include "modules/modules_enabled.gen.h"
#ifdef MODULE_EDITOR_CODE_EDITOR_ENABLED
#include "editor_code_editor/editor_script_editor.h"
#endif
/* Static members */
// Singletons
@ -113,9 +103,6 @@ static bool show_help = false;
static bool auto_quit = false;
static OS::ProcessID allow_focus_steal_pid = 0;
static bool delta_sync_after_draw = false;
#ifdef TOOLS_ENABLED
static String debug_server_uri;
#endif
// Display
@ -208,19 +195,11 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print("General options:\n");
OS::get_singleton()->print(" -h, --help Display this help message.\n");
OS::get_singleton()->print(" --version Display the version string.\n");
#ifdef TOOLS_ENABLED
OS::get_singleton()->print(" --version-full-config Display the full config version string (used by the export templates manager).\n");
#endif
OS::get_singleton()->print(" -v, --verbose Use verbose stdout mode.\n");
OS::get_singleton()->print(" --quiet Quiet mode, silences stdout messages. Errors are still displayed.\n");
OS::get_singleton()->print("\n");
OS::get_singleton()->print("Run options:\n");
#ifdef TOOLS_ENABLED
OS::get_singleton()->print(" -e, --editor Start the editor instead of running the scene.\n");
OS::get_singleton()->print(" -p, --project-manager Start the project manager, even if a project is auto-detected.\n");
OS::get_singleton()->print(" --debug-server <address> Start the editor debug server (<IP>:<port>, e.g. 127.0.0.1:6007)\n");
#endif
OS::get_singleton()->print(" -q, --quit Quit after the first iteration.\n");
OS::get_singleton()->print(" -l, --language <locale> Use a specific locale (<locale> being a two-letter code).\n");
OS::get_singleton()->print(" --path <directory> Path to a project (<directory> must contain a 'project.pandemonium' file).\n");
@ -296,14 +275,8 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print(" -s, --script <script> Run a script.\n");
OS::get_singleton()->print(" --check-only Only parse for errors and quit (use with --script).\n");
#ifdef TOOLS_ENABLED
OS::get_singleton()->print(" --export <preset> <path> Export the project using the given preset and matching release template. The preset name should match one defined in export_presets.cfg.\n");
OS::get_singleton()->print(" <path> should be absolute or relative to the project directory, and include the filename for the binary (e.g. 'builds/game.exe'). The target directory should exist.\n");
OS::get_singleton()->print(" --export-debug <preset> <path> Same as --export, but using the debug template.\n");
OS::get_singleton()->print(" --export-pack <preset> <path> Same as --export, but only export the game pack for the given preset. The <path> extension determines whether it will be in PCK or ZIP format.\n");
OS::get_singleton()->print(" --doctool [<path>] Dump the engine API reference to the given <path> (defaults to current dir) in XML format, merging if existing files are found.\n");
OS::get_singleton()->print(" --no-docbase Disallow dumping the base types (used with --doctool).\n");
OS::get_singleton()->print(" --benchmark Benchmark the run time and print it to console.\n");
OS::get_singleton()->print(" --benchmark-file <path> Benchmark the run time and save it to a given file in JSON format. The path should be absolute.\n");
#endif
}
@ -411,9 +384,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
bool force_res = false;
bool saw_vsync_via_compositor_override = false;
bool delta_smoothing_override = false;
#ifdef TOOLS_ENABLED
bool found_project = false;
#endif
// Default exit code, can be modified for certain errors.
Error exit_code = ERR_INVALID_PARAMETER;
@ -442,13 +412,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
exit_code = ERR_HELP; // Hack to force an early exit in `main()` with a success code.
goto error;
#ifdef TOOLS_ENABLED
} else if (I->get() == "--version-full-config") {
print_line(String(VERSION_FULL_CONFIG));
exit_code = ERR_HELP; // Hack to force an early exit in `main()` with a success code.
goto error;
#endif
} else if (I->get() == "-v" || I->get() == "--verbose") { // verbose output
OS::get_singleton()->_verbose_stdout = true;
@ -681,29 +644,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
OS::get_singleton()->print("Missing render thread mode argument, aborting.\n");
goto error;
}
#ifdef TOOLS_ENABLED
} else if (I->get() == "-e" || I->get() == "--editor") { // starts editor
editor = true;
} else if (I->get() == "-p" || I->get() == "--project-manager") { // starts project manager
project_manager = true;
} else if (I->get() == "--debug-server") {
if (I->next()) {
debug_server_uri = I->next()->get();
if (debug_server_uri.find(":") == -1) { // wrong address
OS::get_singleton()->print("Invalid debug server address. It should be of the form <bind_address>:<port>.\n");
goto error;
}
N = I->next()->next();
} else {
OS::get_singleton()->print("Missing remote debug server server, aborting.\n");
goto error;
}
} else if (I->get() == "--export" || I->get() == "--export-debug" || I->get() == "--export-pack") { // Export project
editor = true;
main_args.push_back(I->get());
#endif
} else if (I->get() == "--path") { // set path of project to start or edit
if (I->next()) {
@ -736,9 +676,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} else {
project_path = path;
}
#ifdef TOOLS_ENABLED
editor = true;
#endif
} else if (I->get() == "-b" || I->get() == "--breakpoints") { // add breakpoints
if (I->next()) {
@ -849,13 +786,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
I = N;
}
#ifdef TOOLS_ENABLED
if (editor && project_manager) {
OS::get_singleton()->print("Error: Command line arguments implied opening both editor and project manager, which is not possible. Aborting.\n");
goto error;
}
#endif
// Network file system needs to be configured before globals, since globals are based on the
// 'project.pandemonium' file which will only be available through the network if this is enabled
FileAccessNetwork::configure();
@ -879,19 +809,12 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
}
if (globals->setup(project_path, main_pack, upwards, editor) == OK) {
#ifdef TOOLS_ENABLED
found_project = true;
#endif
} else {
#ifdef TOOLS_ENABLED
editor = false;
#else
const String error_msg = "Error: Couldn't load project data at path \"" + project_path + "\". Is the .pck file missing?\nIf you've renamed the executable, the associated .pck file should also be renamed to match the executable's name (without the extension).\n";
OS::get_singleton()->print("%s", error_msg.utf8().get_data());
OS::get_singleton()->alert(error_msg);
goto error;
#endif
}
// Initialize user data dir.
@ -925,22 +848,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
}
}
#ifdef TOOLS_ENABLED
if (editor) {
Engine::get_singleton()->set_editor_hint(true);
main_args.push_back("--editor");
if (!init_windowed) {
init_maximized = true;
video_mode.maximized = true;
}
}
if (!project_manager && !editor) {
// Determine if the project manager should be requested
project_manager = main_args.size() == 0 && !found_project;
}
#endif
// Only flush stdout in debug builds by default, as spamming `print()` will
// decrease performance if this is enabled.
GLOBAL_DEF_RST("application/run/flush_stdout_on_print", false);
@ -964,16 +871,10 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
}
if (main_args.size() == 0 && String(GLOBAL_DEF("application/run/main_scene", "")) == "") {
#ifdef TOOLS_ENABLED
if (!editor && !project_manager) {
#endif
const String error_msg = "Error: Can't run project: no main scene defined in the project.\n";
OS::get_singleton()->print("%s", error_msg.utf8().get_data());
OS::get_singleton()->alert(error_msg);
goto error;
#ifdef TOOLS_ENABLED
}
#endif
}
if (editor || project_manager) {
@ -1370,14 +1271,6 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
register_scene_types();
#ifdef TOOLS_ENABLED
ClassDB::set_current_api(ClassDB::API_EDITOR);
EditorNode::register_editor_types();
ClassDB::set_current_api(ClassDB::API_CORE);
#endif
MAIN_PRINT("Main: Load Modules, Physics, Drivers, Scripts");
register_platform_apis();
@ -1452,9 +1345,6 @@ bool Main::start() {
#ifdef TOOLS_ENABLED
bool doc_base = true;
String _export_preset;
bool export_debug = false;
bool export_pack_only = false;
#endif
main_timer_sync.init(OS::get_singleton()->get_ticks_usec());
@ -1467,10 +1357,6 @@ bool Main::start() {
#ifdef TOOLS_ENABLED
} else if (args[i] == "--no-docbase") {
doc_base = false;
} else if (args[i] == "-e" || args[i] == "--editor") {
editor = true;
} else if (args[i] == "-p" || args[i] == "--project-manager") {
project_manager = true;
#endif
} else if (args[i].length() && args[i][0] != '-' && positional_arg == "") {
positional_arg = args[i];
@ -1502,17 +1388,6 @@ bool Main::start() {
doc_tool_path = ".";
parsed_pair = false;
}
} else if (args[i] == "--export") {
editor = true; //needs editor
_export_preset = args[i + 1];
} else if (args[i] == "--export-debug") {
editor = true; //needs editor
_export_preset = args[i + 1];
export_debug = true;
} else if (args[i] == "--export-pack") {
editor = true;
_export_preset = args[i + 1];
export_pack_only = true;
#endif
} else {
// The parameter does not match anything known, don't skip the next argument
@ -1538,11 +1413,6 @@ bool Main::start() {
if (doc_tool_path != "") {
Engine::get_singleton()->set_editor_hint(true); // Needed to instance editor-only classes for their default values
// Translate the class reference only when `-l LOCALE` parameter is given.
if (!locale.empty() && locale != "en") {
load_doc_translations(locale);
}
{
DirAccessRef da = DirAccess::open(doc_tool_path);
ERR_FAIL_COND_V_MSG(!da, false, "Argument supplied to --doctool must be a valid directory path.");
@ -1776,19 +1646,6 @@ bool Main::start() {
}
}
#ifdef TOOLS_ENABLED
EditorNode *editor_node = nullptr;
if (editor) {
editor_node = memnew(EditorNode);
sml->get_root()->add_child(editor_node);
if (_export_preset != "") {
editor_node->export_preset(_export_preset, positional_arg, export_debug, export_pack_only);
game_path = ""; // Do not load anything.
}
}
#endif
if (!editor && !project_manager) {
//standard helpers that can be changed from main config
@ -1888,27 +1745,6 @@ bool Main::start() {
local_game_path = ProjectSettings::get_singleton()->localize_path(local_game_path);
#ifdef TOOLS_ENABLED
if (editor) {
if (game_path != GLOBAL_GET("application/run/main_scene") || !editor_node->has_scenes_in_session()) {
Error serr = editor_node->load_scene(local_game_path);
if (serr != OK)
ERR_PRINT("Failed to load scene");
}
OS::get_singleton()->set_context(OS::CONTEXT_EDITOR);
#ifdef MODULE_EDITOR_CODE_EDITOR_ENABLED
// Start debug server.
if (!debug_server_uri.empty()) {
int idx = debug_server_uri.rfind(":");
IP_Address addr = debug_server_uri.substr(0, idx);
int port = debug_server_uri.substr(idx + 1).to_int();
EditorScriptEditor::get_singleton()->get_debugger()->start(port, addr);
}
#endif
}
#endif
if (!editor) {
OS::get_singleton()->set_context(OS::CONTEXT_ENGINE);
}
@ -1957,22 +1793,6 @@ bool Main::start() {
}
}
#ifdef TOOLS_ENABLED
if (project_manager || (script == "" && game_path == "" && !editor)) {
Engine::get_singleton()->set_editor_hint(true);
ProjectManager *pmanager = memnew(ProjectManager);
ProgressDialog *progress_dialog = memnew(ProgressDialog);
pmanager->add_child(progress_dialog);
sml->get_root()->add_child(pmanager);
OS::get_singleton()->set_context(OS::CONTEXT_PROJECTMAN);
project_manager = true;
}
if (project_manager || editor) {
// Load SSL Certificates from Editor Settings (or builtin)
Crypto::load_default_certificates(EditorSettings::get_singleton()->get_setting("network/ssl/editor_ssl_certificates").operator String());
}
#endif
}
OS::get_singleton()->set_main_loop(main_loop);
@ -2288,10 +2108,6 @@ void Main::cleanup(bool p_force) {
// Sync pending commands that may have been queued from a different thread during ScriptServer finalization
RenderingServer::get_singleton()->sync();
#ifdef TOOLS_ENABLED
EditorNode::unregister_editor_types();
#endif
ImageLoader::cleanup();
unregister_driver_types();

View File

@ -484,9 +484,7 @@ public:
virtual int find_function(const String &p_function, const String &p_code) const;
virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const;
virtual Error complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptCodeCompletionOption> *r_options, bool &r_forced, String &r_call_hint);
#ifdef TOOLS_ENABLED
virtual Error lookup_code(const String &p_code, const String &p_symbol, const String &p_path, Object *p_owner, LookupResult &r_result);
#endif
virtual String _get_indentation() const;
virtual void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const;
virtual void add_global_constant(const StringName &p_variable, const Variant &p_value);

File diff suppressed because it is too large Load Diff

View File

@ -37,106 +37,10 @@
#include "gdscript.h"
#include "gdscript_tokenizer.h"
#include "modules/modules_enabled.gen.h"
GDScriptLanguage *script_language_gd = nullptr;
Ref<ResourceFormatLoaderGDScript> resource_loader_gd;
Ref<ResourceFormatSaverGDScript> resource_saver_gd;
#ifdef TOOLS_ENABLED
#include "editor/editor_export.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
class EditorExportGDScript : public EditorExportPlugin {
GDCLASS(EditorExportGDScript, EditorExportPlugin);
public:
virtual void _export_file(const String &p_path, const String &p_type, const RBSet<String> &p_features) {
int script_mode = EditorExportPreset::MODE_SCRIPT_COMPILED;
String script_key;
const Ref<EditorExportPreset> &preset = get_export_preset();
if (preset.is_valid()) {
script_mode = preset->get_script_export_mode();
script_key = preset->get_script_encryption_key().to_lower();
}
if (!p_path.ends_with(".gd") || script_mode == EditorExportPreset::MODE_SCRIPT_TEXT) {
return;
}
Vector<uint8_t> file = FileAccess::get_file_as_array(p_path);
if (file.empty()) {
return;
}
String txt;
txt.parse_utf8((const char *)file.ptr(), file.size());
file = GDScriptTokenizerBuffer::parse_code_string(txt);
if (!file.empty()) {
if (script_mode == EditorExportPreset::MODE_SCRIPT_ENCRYPTED) {
String tmp_path = EditorSettings::get_singleton()->get_cache_dir().plus_file("script.gde");
FileAccess *fa = FileAccess::open(tmp_path, FileAccess::WRITE);
Vector<uint8_t> key;
key.resize(32);
for (int i = 0; i < 32; i++) {
int v = 0;
if (i * 2 < script_key.length()) {
CharType ct = script_key[i * 2];
if (ct >= '0' && ct <= '9') {
ct = ct - '0';
} else if (ct >= 'a' && ct <= 'f') {
ct = 10 + ct - 'a';
}
v |= ct << 4;
}
if (i * 2 + 1 < script_key.length()) {
CharType ct = script_key[i * 2 + 1];
if (ct >= '0' && ct <= '9') {
ct = ct - '0';
} else if (ct >= 'a' && ct <= 'f') {
ct = 10 + ct - 'a';
}
v |= ct;
}
key.write[i] = v;
}
FileAccessEncrypted *fae = memnew(FileAccessEncrypted);
Error err = fae->open_and_parse(fa, key, FileAccessEncrypted::MODE_WRITE_AES256);
if (err == OK) {
fae->store_buffer(file.ptr(), file.size());
}
memdelete(fae);
file = FileAccess::get_file_as_array(tmp_path);
add_file(p_path.get_basename() + ".gde", file, true);
// Clean up temporary file.
DirAccess::remove_file_or_error(tmp_path);
} else {
add_file(p_path.get_basename() + ".gdc", file, true);
}
}
}
};
static void _editor_init() {
Ref<EditorExportGDScript> gd_export;
gd_export.instance();
EditorExport::get_singleton()->add_export_plugin(gd_export);
}
#endif // TOOLS_ENABLED
void register_gdscript_types(ModuleRegistrationLevel p_level) {
if (p_level == MODULE_REGISTRATION_LEVEL_SINGLETON) {
script_language_gd = memnew(GDScriptLanguage);
@ -153,12 +57,6 @@ void register_gdscript_types(ModuleRegistrationLevel p_level) {
ClassDB::register_class<GDScript>();
ClassDB::register_virtual_class<GDScriptFunctionState>();
}
#ifdef TOOLS_ENABLED
if (p_level == MODULE_REGISTRATION_LEVEL_EDITOR) {
EditorNode::add_init_callback(_editor_init);
}
#endif // TOOLS_ENABLED
}
void unregister_gdscript_types(ModuleRegistrationLevel p_level) {

View File

@ -34,53 +34,8 @@
#include "scene/resources/texture.h"
#include "scene/main/scene_string_names.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_settings.h"
#endif
#define NORMAL_SUFFIX "_normal"
#ifdef TOOLS_ENABLED
Dictionary AnimatedSprite::_edit_get_state() const {
Dictionary state = Node2D::_edit_get_state();
state["offset"] = offset;
return state;
}
void AnimatedSprite::_edit_set_state(const Dictionary &p_state) {
Node2D::_edit_set_state(p_state);
set_offset(p_state["offset"]);
}
void AnimatedSprite::_edit_set_pivot(const Point2 &p_pivot) {
set_offset(get_offset() - p_pivot);
set_position(get_transform().xform(p_pivot));
}
Point2 AnimatedSprite::_edit_get_pivot() const {
return Vector2();
}
bool AnimatedSprite::_edit_use_pivot() const {
return true;
}
Rect2 AnimatedSprite::_edit_get_rect() const {
return _get_rect();
}
bool AnimatedSprite::_edit_use_rect() const {
if (!frames.is_valid() || !frames->has_animation(animation) || frame < 0 || frame >= frames->get_frame_count(animation)) {
return false;
}
Ref<Texture> t;
if (animation) {
t = frames->get_frame(animation, frame);
}
return t.is_valid();
}
#endif
Rect2 AnimatedSprite::get_anchorable_rect() const {
return _get_rect();
}

View File

@ -150,17 +150,6 @@ protected:
virtual void _validate_property(PropertyInfo &property) const;
public:
#ifdef TOOLS_ENABLED
virtual Dictionary _edit_get_state() const;
virtual void _edit_set_state(const Dictionary &p_state);
virtual void _edit_set_pivot(const Point2 &p_pivot);
virtual Point2 _edit_get_pivot() const;
virtual bool _edit_use_pivot() const;
virtual Rect2 _edit_get_rect() const;
virtual bool _edit_use_rect() const;
#endif
virtual Rect2 get_anchorable_rect() const;
void set_sprite_frames(const Ref<SpriteFrames> &p_frames);

View File

@ -89,20 +89,5 @@ Ref<Texture> MeshInstance2D::get_texture() const {
return texture;
}
#ifdef TOOLS_ENABLED
Rect2 MeshInstance2D::_edit_get_rect() const {
if (mesh.is_valid()) {
AABB aabb = mesh->get_aabb();
return Rect2(aabb.position.x, aabb.position.y, aabb.size.x, aabb.size.y);
}
return Node2D::_edit_get_rect();
}
bool MeshInstance2D::_edit_use_rect() const {
return mesh.is_valid();
}
#endif
MeshInstance2D::MeshInstance2D() {
}

View File

@ -45,11 +45,6 @@ protected:
static void _bind_methods();
public:
#ifdef TOOLS_ENABLED
virtual Rect2 _edit_get_rect() const;
virtual bool _edit_use_rect() const;
#endif
void set_mesh(const Ref<Mesh> &p_mesh);
Ref<Mesh> get_mesh() const;

View File

@ -99,17 +99,6 @@ Ref<Texture> MultiMeshInstance2D::get_normal_map() const {
return normal_map;
}
#ifdef TOOLS_ENABLED
Rect2 MultiMeshInstance2D::_edit_get_rect() const {
if (multimesh.is_valid()) {
AABB aabb = multimesh->get_aabb();
return Rect2(aabb.position.x, aabb.position.y, aabb.size.x, aabb.size.y);
}
return Node2D::_edit_get_rect();
}
#endif
MultiMeshInstance2D::MultiMeshInstance2D() {
}

View File

@ -47,10 +47,6 @@ protected:
static void _bind_methods();
public:
#ifdef TOOLS_ENABLED
virtual Rect2 _edit_get_rect() const;
#endif
void set_multimesh(const Ref<MultiMesh> &p_multimesh);
Ref<MultiMesh> get_multimesh() const;

View File

@ -34,58 +34,6 @@
#include "scene/resources/curve.h"
#include "scene/main/scene_string_names.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_scale.h"
#endif
#ifdef TOOLS_ENABLED
Rect2 Path2D::_edit_get_rect() const {
if (!curve.is_valid() || curve->get_point_count() == 0) {
return Rect2(0, 0, 0, 0);
}
Rect2 aabb = Rect2(curve->get_point_position(0), Vector2(0, 0));
for (int i = 0; i < curve->get_point_count(); i++) {
for (int j = 0; j <= 8; j++) {
real_t frac = j / 8.0;
Vector2 p = curve->interpolate(i, frac);
aabb.expand_to(p);
}
}
return aabb;
}
bool Path2D::_edit_use_rect() const {
return curve.is_valid() && curve->get_point_count() != 0;
}
bool Path2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
if (curve.is_null()) {
return false;
}
for (int i = 0; i < curve->get_point_count(); i++) {
Vector2 s[2];
s[0] = curve->get_point_position(i);
for (int j = 1; j <= 8; j++) {
real_t frac = j / 8.0;
s[1] = curve->interpolate(i, frac);
Vector2 p = Geometry::get_closest_point_to_segment_2d(p_point, s);
if (p.distance_to(p_point) <= p_tolerance) {
return true;
}
s[0] = s[1];
}
}
return false;
}
#endif
void Path2D::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW && curve.is_valid()) {
@ -99,11 +47,7 @@ void Path2D::_notification(int p_what) {
return;
}
#ifdef TOOLS_ENABLED
const float line_width = get_tree()->get_debug_paths_width() * EDSCALE;
#else
const float line_width = get_tree()->get_debug_paths_width();
#endif
_cached_draw_pts.resize(curve->get_point_count() * 8);
int count = 0;

View File

@ -47,12 +47,6 @@ protected:
static void _bind_methods();
public:
#ifdef TOOLS_ENABLED
virtual Rect2 _edit_get_rect() const;
virtual bool _edit_use_rect() const;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
#endif
void set_curve(const Ref<Curve2D> &p_curve);
Ref<Curve2D> get_curve() const;

View File

@ -38,63 +38,6 @@
#include "modules/skeleton_2d/nodes/skeleton_2d.h"
#endif
#ifdef TOOLS_ENABLED
Dictionary Polygon2D::_edit_get_state() const {
Dictionary state = Node2D::_edit_get_state();
state["offset"] = offset;
return state;
}
void Polygon2D::_edit_set_state(const Dictionary &p_state) {
Node2D::_edit_set_state(p_state);
set_offset(p_state["offset"]);
}
void Polygon2D::_edit_set_pivot(const Point2 &p_pivot) {
set_position(get_transform().xform(p_pivot));
set_offset(get_offset() - p_pivot);
}
Point2 Polygon2D::_edit_get_pivot() const {
return Vector2();
}
bool Polygon2D::_edit_use_pivot() const {
return true;
}
Rect2 Polygon2D::_edit_get_rect() const {
if (rect_cache_dirty) {
int l = polygon.size();
PoolVector<Vector2>::Read r = polygon.read();
item_rect = Rect2();
for (int i = 0; i < l; i++) {
Vector2 pos = r[i] + offset;
if (i == 0) {
item_rect.position = pos;
} else {
item_rect.expand_to(pos);
}
}
rect_cache_dirty = false;
}
return item_rect;
}
bool Polygon2D::_edit_use_rect() const {
return polygon.size() > 0;
}
bool Polygon2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
Vector<Vector2> polygon2d = Variant(polygon);
if (internal_vertices > 0) {
polygon2d.resize(polygon2d.size() - internal_vertices);
}
return Geometry::is_point_in_polygon(p_point - get_offset(), polygon2d);
}
#endif
void Polygon2D::_skeleton_bone_setup_changed() {
update();
}

View File

@ -76,18 +76,6 @@ protected:
static void _bind_methods();
public:
#ifdef TOOLS_ENABLED
virtual Dictionary _edit_get_state() const;
virtual void _edit_set_state(const Dictionary &p_state);
virtual void _edit_set_pivot(const Point2 &p_pivot);
virtual Point2 _edit_get_pivot() const;
virtual bool _edit_use_pivot() const;
virtual Rect2 _edit_get_rect() const;
virtual bool _edit_use_rect() const;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
#endif
void set_polygon(const PoolVector<Vector2> &p_polygon);
PoolVector<Vector2> get_polygon() const;

View File

@ -35,44 +35,6 @@
#include "scene/resources/texture.h"
#include "scene/main/scene_string_names.h"
#ifdef TOOLS_ENABLED
Dictionary Sprite::_edit_get_state() const {
Dictionary state = Node2D::_edit_get_state();
state["offset"] = offset;
return state;
}
void Sprite::_edit_set_state(const Dictionary &p_state) {
Node2D::_edit_set_state(p_state);
set_offset(p_state["offset"]);
}
void Sprite::_edit_set_pivot(const Point2 &p_pivot) {
set_offset(get_offset() - p_pivot);
set_position(get_transform().xform(p_pivot));
}
Point2 Sprite::_edit_get_pivot() const {
return Vector2();
}
bool Sprite::_edit_use_pivot() const {
return true;
}
bool Sprite::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
return is_pixel_opaque(p_point);
}
Rect2 Sprite::_edit_get_rect() const {
return get_rect();
}
bool Sprite::_edit_use_rect() const {
return texture.is_valid();
}
#endif
Rect2 Sprite::get_anchorable_rect() const {
return get_rect();
}

View File

@ -65,19 +65,6 @@ protected:
virtual void _validate_property(PropertyInfo &property) const;
public:
#ifdef TOOLS_ENABLED
virtual Dictionary _edit_get_state() const;
virtual void _edit_set_state(const Dictionary &p_state);
virtual void _edit_set_pivot(const Point2 &p_pivot);
virtual Point2 _edit_get_pivot() const;
virtual bool _edit_use_pivot() const;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
virtual Rect2 _edit_get_rect() const;
virtual bool _edit_use_rect() const;
#endif
bool is_pixel_opaque(const Point2 &p_point) const;
void set_texture(const Ref<Texture> &p_texture);

View File

@ -331,20 +331,6 @@ void TouchScreenButton::_release(bool p_exiting_tree) {
}
}
#ifdef TOOLS_ENABLED
Rect2 TouchScreenButton::_edit_get_rect() const {
if (texture.is_null()) {
return CanvasItem::_edit_get_rect();
}
return Rect2(Size2(), texture->get_size());
}
bool TouchScreenButton::_edit_use_rect() const {
return !texture.is_null();
}
#endif
Rect2 TouchScreenButton::get_anchorable_rect() const {
if (texture.is_null()) {
return CanvasItem::get_anchorable_rect();

View File

@ -75,11 +75,6 @@ protected:
static void _bind_methods();
public:
#ifdef TOOLS_ENABLED
virtual Rect2 _edit_get_rect() const;
virtual bool _edit_use_rect() const;
#endif
void set_texture(const Ref<Texture> &p_texture);
Ref<Texture> get_texture() const;

View File

@ -319,14 +319,7 @@ void VisibilityEnabler2D::_node_removed(Node *p_node) {
String VisibilityEnabler2D::get_configuration_warning() const {
String warning = VisibilityNotifier2D::get_configuration_warning();
#ifdef TOOLS_ENABLED
if (is_inside_tree() && get_parent() && (get_parent()->get_filename() == String() && get_parent() != get_tree()->get_edited_scene_root())) {
if (warning != String()) {
warning += "\n\n";
}
warning += TTR("VisibilityEnabler2D works best when used with the edited scene root directly as parent.");
}
#endif
return warning;
}

View File

@ -348,12 +348,6 @@ public:
void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options, const String &quote_style) const;
#ifdef TOOLS_ENABLED
Ref<AnimatedValuesBackup> backup_animated_values(Node *p_root_override = NULL);
Ref<AnimatedValuesBackup> apply_reset(bool p_user_initiated = false);
bool can_apply_reset() const;
#endif
AnimationPlayer();
~AnimationPlayer();
};

View File

@ -47,10 +47,6 @@
#include "scene/gui/texture_rect.h"
#include "scene/gui/tool_button.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#endif
#include "scene/main/viewport.h"
List<Color> ColorPicker::preset_cache;
@ -69,21 +65,6 @@ void ColorPicker::_notification(int p_what) {
_update_controls();
_update_color();
#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint()) {
if (preset_cache.empty()) {
PoolColorArray saved_presets = EditorSettings::get_singleton()->get_project_metadata("color_picker", "presets", PoolColorArray());
for (int i = 0; i < saved_presets.size(); i++) {
preset_cache.push_back(saved_presets[i]);
}
}
for (int i = 0; i < preset_cache.size(); i++) {
presets.push_back(preset_cache[i]);
}
}
#endif
} break;
case NOTIFICATION_PARENTED: {
for (int i = 0; i < 4; i++) {
@ -334,12 +315,6 @@ void ColorPicker::add_preset(const Color &p_color) {
_notification(NOTIFICATION_VISIBILITY_CHANGED);
}
#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint()) {
PoolColorArray arr_to_save = get_presets();
EditorSettings::get_singleton()->set_project_metadata("color_picker", "presets", arr_to_save);
}
#endif
}
void ColorPicker::erase_preset(const Color &p_color) {
@ -355,13 +330,6 @@ void ColorPicker::erase_preset(const Color &p_color) {
break;
}
}
#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint()) {
PoolColorArray arr_to_save = get_presets();
EditorSettings::get_singleton()->set_project_metadata("color_picker", "presets", arr_to_save);
}
#endif
}
}
@ -911,9 +879,6 @@ ColorPicker::ColorPicker() :
text_type->set_text("#");
text_type->set_tooltip(TTR("Switch between hexadecimal and code values."));
if (Engine::get_singleton()->is_editor_hint()) {
#ifdef TOOLS_ENABLED
text_type->set_custom_minimum_size(Size2(28 * EDSCALE, 0)); // Adjust for the width of the "Script" icon.
#endif
text_type->connect("pressed", this, "_text_type_toggled");
} else {
text_type->set_flat(true);

View File

@ -40,12 +40,6 @@
#include "core/input/shortcut.h"
#include "scene/gui/texture_button.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
#include "scene/main/viewport.h" // Only used to check for more modals when dimming the editor.
#endif
// WindowDialog
void WindowDialog::_post_popup() {
@ -240,22 +234,6 @@ void WindowDialog::_notification(int p_what) {
}
}
} break;
#ifdef TOOLS_ENABLED
case NOTIFICATION_POST_POPUP: {
if (get_tree() && Engine::get_singleton()->is_editor_hint() && EditorNode::get_singleton()) {
was_editor_dimmed = EditorNode::get_singleton()->is_editor_dimmed();
EditorNode::get_singleton()->dim_editor(true);
}
} break;
case NOTIFICATION_POPUP_HIDE: {
if (get_tree() && Engine::get_singleton()->is_editor_hint() && EditorNode::get_singleton() && !was_editor_dimmed) {
EditorNode::get_singleton()->dim_editor(false);
set_pass_on_modal_close_click(false);
}
} break;
#endif
}
}
@ -349,10 +327,6 @@ WindowDialog::WindowDialog() {
close_button = memnew(TextureButton);
add_child(close_button);
close_button->connect("pressed", this, "_closed");
#ifdef TOOLS_ENABLED
was_editor_dimmed = false;
#endif
}
WindowDialog::~WindowDialog() {
@ -631,8 +605,5 @@ Button *ConfirmationDialog::get_cancel() {
ConfirmationDialog::ConfirmationDialog() {
set_title(RTR("Please Confirm..."));
#ifdef TOOLS_ENABLED
set_custom_minimum_size(Size2(200, 70) * EDSCALE);
#endif
cancel = add_cancel();
}

View File

@ -35,14 +35,8 @@
#include "scene/gui/popup.h"
#include "scene/resources/default_theme/theme_data.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_scale.h"
#define SPACING (3 * EDSCALE)
#define POINT_WIDTH (8 * EDSCALE)
#else
#define SPACING 3
#define POINT_WIDTH 8
#endif
GradientEdit::GradientEdit() {
grabbed = -1;

View File

@ -43,10 +43,6 @@
#include "scene/gui/texture_rect.h"
#include "scene/gui/tool_button.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_scale.h"
#endif
constexpr int MINIMAP_OFFSET = 12;
constexpr int MINIMAP_PADDING = 5;
@ -888,11 +884,7 @@ void GraphEdit::_draw_cos_line(CanvasItem *p_where, const Vector2 &p_from, const
points.push_back(p_to);
colors.push_back(p_to_color);
#ifdef TOOLS_ENABLED
p_where->draw_polyline_colors(points, colors, Math::floor(p_width * EDSCALE), true);
#else
p_where->draw_polyline_colors(points, colors, p_width, true);
#endif
}
void GraphEdit::_connections_layer_draw() {
@ -1822,11 +1814,7 @@ GraphEdit::GraphEdit() {
zoom_label->set_visible(false);
zoom_label->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
zoom_label->set_align(Label::ALIGN_CENTER);
#ifdef TOOLS_ENABLED
zoom_label->set_custom_minimum_size(Size2(48, 0) * EDSCALE);
#else
zoom_label->set_custom_minimum_size(Size2(48, 0));
#endif
_update_zoom_label();
zoom_minus = memnew(ToolButton);

View File

@ -42,11 +42,6 @@
#include "scene/main/timer.h"
#include "scene/main/viewport.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#endif
bool LineEdit::_is_text_char(CharType c) {
return !is_symbol(c);
}
@ -930,11 +925,7 @@ void LineEdit::_notification(int p_what) {
if (char_ofs == cursor_pos && draw_caret && !using_placeholder) {
if (ime_text.length() == 0) {
#ifdef TOOLS_ENABLED
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs), Size2(Math::round(EDSCALE), caret_height)), cursor_color);
#else
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs), Size2(1, caret_height)), cursor_color);
#endif
}
}
@ -990,11 +981,7 @@ void LineEdit::_notification(int p_what) {
} break;
}
}
#ifdef TOOLS_ENABLED
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(caret_x_ofs, y_ofs), Size2(Math::round(EDSCALE), caret_height)), cursor_color);
#else
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(caret_x_ofs, y_ofs), Size2(1, caret_height)), cursor_color);
#endif
}
}
@ -1769,11 +1756,6 @@ PopupMenu *LineEdit::get_menu() const {
}
void LineEdit::_editor_settings_changed() {
#ifdef TOOLS_ENABLED
EDITOR_DEF("text_editor/cursor/caret_blink", false);
cursor_set_blink_enabled(EditorSettings::get_singleton()->is_caret_blink_active());
cursor_set_blink_speed(EDITOR_DEF("text_editor/cursor/caret_blink_speed", 0.65));
#endif
}
void LineEdit::set_expand_to_text_length(bool p_enabled) {

View File

@ -56,14 +56,7 @@ void Popup::_notification(int p_what) {
}
if (p_what == NOTIFICATION_ENTER_TREE) {
//small helper to make editing of these easier in editor
#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) {
//edited on editor
set_as_toplevel(false);
} else
#endif
if (is_visible()) {
if (is_visible()) {
hide();
}
}

View File

@ -37,10 +37,6 @@
#include "scene/gui/scroll_bar.h"
#include "scene/main/scene_string_names.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_scale.h"
#endif
#include "modules/modules_enabled.gen.h" // For regex.
#ifdef MODULE_REGEX_ENABLED
#include "modules/regex/regex.h"
@ -643,11 +639,8 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
}
}
#ifdef TOOLS_ENABLED
const float line_width = EDSCALE;
#else
const float line_width = 1.0f;
#endif
if (underline) {
Color uc = color;
uc.a *= 0.5;

View File

@ -43,10 +43,6 @@
#include "scene/main/timer.h"
#include "scene/main/viewport.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_scale.h"
#endif
#define TAB_PIXELS
inline bool _is_symbol(CharType c) {
@ -1139,11 +1135,7 @@ void TextEdit::_notification(int p_what) {
cache_entry.y_offset = ofs_y;
if (text.is_breakpoint(line) && !draw_breakpoint_gutter) {
#ifdef TOOLS_ENABLED
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y + get_row_height() - EDSCALE, xmargin_end - xmargin_beg, EDSCALE), cache.breakpoint_color);
#else
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, xmargin_end - xmargin_beg, get_row_height()), cache.breakpoint_color);
#endif
}
// Draw bookmark marker.
@ -1203,11 +1195,7 @@ void TextEdit::_notification(int p_what) {
int marker_width = cache.breakpoint_gutter_width - (horizontal_gap * 2) + icon_extra_size;
cache.executing_icon->draw_rect(ci, Rect2(cache.style_normal->get_margin(MARGIN_LEFT) + horizontal_gap - 2 - icon_extra_size / 2, ofs_y + vertical_gap - icon_extra_size / 2, marker_width, marker_height), false, Color(cache.executing_line_color.r, cache.executing_line_color.g, cache.executing_line_color.b));
} else {
#ifdef TOOLS_ENABLED
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y + get_row_height() - EDSCALE, xmargin_end - xmargin_beg, EDSCALE), cache.executing_line_color);
#else
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, xmargin_end - xmargin_beg, get_row_height()), cache.executing_line_color);
#endif
}
}
@ -1416,18 +1404,11 @@ void TextEdit::_notification(int p_what) {
if (ime_text.length() == 0) {
if (draw_caret || drag_caret_force_displayed) {
if (insert_mode) {
#ifdef TOOLS_ENABLED
int caret_h = (block_caret) ? 4 : 2 * EDSCALE;
#else
int caret_h = (block_caret) ? 4 : 2;
#endif
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(cursor_pos, Size2i(caret_w, caret_h)), cache.caret_color);
} else {
#ifdef TOOLS_ENABLED
caret_w = (block_caret) ? caret_w : 2 * EDSCALE;
#else
caret_w = (block_caret) ? caret_w : 2;
#endif
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(cursor_pos, Size2i(caret_w, cache.font->get_height())), cache.caret_color);
}
@ -1447,9 +1428,6 @@ void TextEdit::_notification(int p_what) {
int w = drawer.draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, yofs + ascent), str[j], str[j + 1], in_selection && override_selected_font_color ? cache.font_color_selected : color);
if (underlined) {
float line_width = 1.0;
#ifdef TOOLS_ENABLED
line_width *= EDSCALE;
#endif
draw_rect(Rect2(char_ofs + char_margin + ofs_x, yofs + ascent + 2, w, line_width), in_selection && override_selected_font_color ? cache.font_color_selected : color);
}
@ -1523,19 +1501,12 @@ void TextEdit::_notification(int p_what) {
if (draw_caret || drag_caret_force_displayed) {
if (insert_mode) {
int char_w = cache.font->get_char_size(' ').width;
#ifdef TOOLS_ENABLED
int caret_h = (block_caret) ? 4 : 2 * EDSCALE;
#else
int caret_h = (block_caret) ? 4 : 2;
#endif
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(cursor_pos, Size2i(char_w, caret_h)), cache.caret_color);
} else {
int char_w = cache.font->get_char_size(' ').width;
#ifdef TOOLS_ENABLED
int caret_w = (block_caret) ? char_w : 2 * EDSCALE;
#else
int caret_w = (block_caret) ? char_w : 2;
#endif
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(cursor_pos, Size2i(caret_w, cache.font->get_height())), cache.caret_color);
}
@ -5334,11 +5305,7 @@ void TextEdit::_update_caches() {
cache.search_result_color = get_theme_color("search_result_color");
cache.search_result_border_color = get_theme_color("search_result_border_color");
cache.background_color = get_theme_color("background_color");
#ifdef TOOLS_ENABLED
cache.line_spacing = get_theme_constant("line_spacing") * EDSCALE;
#else
cache.line_spacing = get_theme_constant("line_spacing");
#endif
cache.row_height = cache.font->get_height() + cache.line_spacing;
cache.tab_icon = get_theme_icon("tab");
cache.space_icon = get_theme_icon("space");

View File

@ -44,10 +44,6 @@
#include "scene/main/timer.h"
#include "scene/main/viewport.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_scale.h"
#endif
#include <limits.h>
void TreeItem::move_to_top() {
@ -1446,9 +1442,6 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
}
float line_width = 1.0;
#ifdef TOOLS_ENABLED
line_width *= EDSCALE;
#endif
Point2i parent_pos = Point2i(parent_ofs - cache.arrow->get_width() / 2, p_pos.y + label_h / 2 + cache.arrow->get_height() / 2) - cache.offset + p_draw_ofs;

View File

@ -342,19 +342,6 @@ CanvasItemMaterial::~CanvasItemMaterial() {
}
///////////////////////////////////////////////////////////////////
#ifdef TOOLS_ENABLED
bool CanvasItem::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
if (_edit_use_rect()) {
return _edit_get_rect().has_point(p_point);
} else {
return p_point.length() < p_tolerance;
}
}
Transform2D CanvasItem::_edit_get_transform() const {
return Transform2D(_edit_get_rotation(), _edit_get_position() + _edit_get_pivot());
}
#endif
bool CanvasItem::is_visible_in_tree() const {
if (!is_inside_tree()) {
@ -1130,25 +1117,6 @@ void CanvasItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("_toplevel_raise_self"), &CanvasItem::_toplevel_raise_self);
ClassDB::bind_method(D_METHOD("_update_callback"), &CanvasItem::_update_callback);
#ifdef TOOLS_ENABLED
ClassDB::bind_method(D_METHOD("_edit_set_state", "state"), &CanvasItem::_edit_set_state);
ClassDB::bind_method(D_METHOD("_edit_get_state"), &CanvasItem::_edit_get_state);
ClassDB::bind_method(D_METHOD("_edit_set_position", "position"), &CanvasItem::_edit_set_position);
ClassDB::bind_method(D_METHOD("_edit_get_position"), &CanvasItem::_edit_get_position);
ClassDB::bind_method(D_METHOD("_edit_set_scale", "scale"), &CanvasItem::_edit_set_scale);
ClassDB::bind_method(D_METHOD("_edit_get_scale"), &CanvasItem::_edit_get_scale);
ClassDB::bind_method(D_METHOD("_edit_set_rect", "rect"), &CanvasItem::_edit_set_rect);
ClassDB::bind_method(D_METHOD("_edit_get_rect"), &CanvasItem::_edit_get_rect);
ClassDB::bind_method(D_METHOD("_edit_use_rect"), &CanvasItem::_edit_use_rect);
ClassDB::bind_method(D_METHOD("_edit_set_rotation", "degrees"), &CanvasItem::_edit_set_rotation);
ClassDB::bind_method(D_METHOD("_edit_get_rotation"), &CanvasItem::_edit_get_rotation);
ClassDB::bind_method(D_METHOD("_edit_use_rotation"), &CanvasItem::_edit_use_rotation);
ClassDB::bind_method(D_METHOD("_edit_set_pivot", "pivot"), &CanvasItem::_edit_set_pivot);
ClassDB::bind_method(D_METHOD("_edit_get_pivot"), &CanvasItem::_edit_get_pivot);
ClassDB::bind_method(D_METHOD("_edit_use_pivot"), &CanvasItem::_edit_use_pivot);
ClassDB::bind_method(D_METHOD("_edit_get_transform"), &CanvasItem::_edit_get_transform);
#endif
ClassDB::bind_method(D_METHOD("get_canvas_item"), &CanvasItem::get_canvas_item);
ClassDB::bind_method(D_METHOD("set_visible", "visible"), &CanvasItem::set_visible);

View File

@ -251,42 +251,6 @@ public:
};
/* EDITOR */
#ifdef TOOLS_ENABLED
// Select the node
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
// Save and restore a CanvasItem state
virtual void _edit_set_state(const Dictionary &p_state){};
virtual Dictionary _edit_get_state() const { return Dictionary(); };
// Used to move the node
virtual void _edit_set_position(const Point2 &p_position) = 0;
virtual Point2 _edit_get_position() const = 0;
// Used to scale the node
virtual void _edit_set_scale(const Size2 &p_scale) = 0;
virtual Size2 _edit_get_scale() const = 0;
// Used to rotate the node
virtual bool _edit_use_rotation() const { return false; };
virtual void _edit_set_rotation(float p_rotation){};
virtual float _edit_get_rotation() const { return 0.0; };
// Used to resize/move the node
virtual bool _edit_use_rect() const { return false; }; // MAYBE REPLACE BY A _edit_get_editmode()
virtual void _edit_set_rect(const Rect2 &p_rect){};
virtual Rect2 _edit_get_rect() const { return Rect2(0, 0, 0, 0); };
virtual Size2 _edit_get_minimum_size() const { return Size2(-1, -1); }; // LOOKS WEIRD
// Used to set a pivot
virtual bool _edit_use_pivot() const { return false; };
virtual void _edit_set_pivot(const Point2 &p_pivot){};
virtual Point2 _edit_get_pivot() const { return Point2(); };
virtual Transform2D _edit_get_transform() const;
#endif
void update_draw_order();
/* VISIBILITY */

View File

@ -45,131 +45,6 @@
#include "scene/main/scene_string_names.h"
#include "servers/rendering_server.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_settings.h"
#include "editor/plugins/canvas_item_editor_plugin.h"
#endif
#ifdef TOOLS_ENABLED
Dictionary Control::_edit_get_state() const {
Dictionary s;
s["rotation"] = get_rotation();
s["scale"] = get_scale();
s["pivot"] = get_pivot_offset();
Array anchors;
anchors.push_back(get_anchor(MARGIN_LEFT));
anchors.push_back(get_anchor(MARGIN_TOP));
anchors.push_back(get_anchor(MARGIN_RIGHT));
anchors.push_back(get_anchor(MARGIN_BOTTOM));
s["anchors"] = anchors;
Array margins;
margins.push_back(get_margin(MARGIN_LEFT));
margins.push_back(get_margin(MARGIN_TOP));
margins.push_back(get_margin(MARGIN_RIGHT));
margins.push_back(get_margin(MARGIN_BOTTOM));
s["margins"] = margins;
return s;
}
void Control::_edit_set_state(const Dictionary &p_state) {
ERR_FAIL_COND((p_state.size() <= 0) ||
!p_state.has("rotation") || !p_state.has("scale") ||
!p_state.has("pivot") || !p_state.has("anchors") || !p_state.has("margins"));
Dictionary state = p_state;
set_rotation(state["rotation"]);
set_scale(state["scale"]);
set_pivot_offset(state["pivot"]);
Array anchors = state["anchors"];
data.anchor[MARGIN_LEFT] = anchors[0];
data.anchor[MARGIN_TOP] = anchors[1];
data.anchor[MARGIN_RIGHT] = anchors[2];
data.anchor[MARGIN_BOTTOM] = anchors[3];
Array margins = state["margins"];
data.margin[MARGIN_LEFT] = margins[0];
data.margin[MARGIN_TOP] = margins[1];
data.margin[MARGIN_RIGHT] = margins[2];
data.margin[MARGIN_BOTTOM] = margins[3];
_size_changed();
_change_notify("anchor_left");
_change_notify("anchor_right");
_change_notify("anchor_top");
_change_notify("anchor_bottom");
}
void Control::_edit_set_position(const Point2 &p_position) {
#ifdef TOOLS_ENABLED
ERR_FAIL_COND_MSG(!Engine::get_singleton()->is_editor_hint(), "This function can only be used from editor plugins.");
set_position(p_position, CanvasItemEditor::get_singleton()->is_anchors_mode_enabled() && Object::cast_to<Control>(data.parent));
#else
// Unlikely to happen. TODO: enclose all _edit_ functions into TOOLS_ENABLED
set_position(p_position);
#endif
}
Point2 Control::_edit_get_position() const {
return get_position();
}
void Control::_edit_set_scale(const Size2 &p_scale) {
set_scale(p_scale);
}
Size2 Control::_edit_get_scale() const {
return data.scale;
}
void Control::_edit_set_rect(const Rect2 &p_edit_rect) {
#ifdef TOOLS_ENABLED
ERR_FAIL_COND_MSG(!Engine::get_singleton()->is_editor_hint(), "This function can only be used from editor plugins.");
set_position((get_position() + get_transform().basis_xform(p_edit_rect.position)).snapped(Vector2(1, 1)), CanvasItemEditor::get_singleton()->is_anchors_mode_enabled());
set_size(p_edit_rect.size.snapped(Vector2(1, 1)), CanvasItemEditor::get_singleton()->is_anchors_mode_enabled());
#else
// Unlikely to happen. TODO: enclose all _edit_ functions into TOOLS_ENABLED
set_position((get_position() + get_transform().basis_xform(p_edit_rect.position)).snapped(Vector2(1, 1)));
set_size(p_edit_rect.size.snapped(Vector2(1, 1)));
#endif
}
Rect2 Control::_edit_get_rect() const {
return Rect2(Point2(), get_size());
}
bool Control::_edit_use_rect() const {
return true;
}
void Control::_edit_set_rotation(float p_rotation) {
set_rotation(p_rotation);
}
float Control::_edit_get_rotation() const {
return get_rotation();
}
bool Control::_edit_use_rotation() const {
return true;
}
void Control::_edit_set_pivot(const Point2 &p_pivot) {
Vector2 delta_pivot = p_pivot - get_pivot_offset();
Vector2 move = Vector2((cos(data.rotation) - 1.0) * delta_pivot.x - sin(data.rotation) * delta_pivot.y, sin(data.rotation) * delta_pivot.x + (cos(data.rotation) - 1.0) * delta_pivot.y);
set_position(get_position() + move);
set_pivot_offset(p_pivot);
}
Point2 Control::_edit_get_pivot() const {
return get_pivot_offset();
}
bool Control::_edit_use_pivot() const {
return true;
}
Size2 Control::_edit_get_minimum_size() const {
return get_combined_minimum_size();
}
#endif
void Control::set_custom_minimum_size(const Size2 &p_custom) {
if (p_custom == data.custom_minimum_size) {

View File

@ -292,32 +292,6 @@ public:
};
/* EDITOR */
#ifdef TOOLS_ENABLED
virtual Dictionary _edit_get_state() const;
virtual void _edit_set_state(const Dictionary &p_state);
virtual void _edit_set_position(const Point2 &p_position);
virtual Point2 _edit_get_position() const;
virtual void _edit_set_scale(const Size2 &p_scale);
virtual Size2 _edit_get_scale() const;
virtual void _edit_set_rect(const Rect2 &p_edit_rect);
virtual Rect2 _edit_get_rect() const;
virtual bool _edit_use_rect() const;
virtual void _edit_set_rotation(float p_rotation);
virtual float _edit_get_rotation() const;
virtual bool _edit_use_rotation() const;
virtual void _edit_set_pivot(const Point2 &p_pivot);
virtual Point2 _edit_get_pivot() const;
virtual bool _edit_use_pivot() const;
virtual Size2 _edit_get_minimum_size() const;
#endif
void accept_event();
virtual Size2 get_minimum_size() const;

View File

@ -46,10 +46,6 @@
#include "core/object/class_db.h"
#include "core/object/script_language.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_settings.h"
#endif
VARIANT_ENUM_CAST(Node::PauseMode);
VARIANT_ENUM_CAST(Node::PhysicsInterpolationMode);
@ -3267,11 +3263,7 @@ NodePath Node::get_import_path() const {
}
static void _add_nodes_to_options(const Node *p_base, const Node *p_node, List<String> *r_options) {
#ifdef TOOLS_ENABLED
const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", 0) ? "'" : "\"";
#else
const String quote_style = "\"";
#endif
if (p_node != p_base && !p_node->get_owner()) {
return;
@ -3308,14 +3300,6 @@ String Node::get_configuration_warning() const {
}
void Node::update_configuration_warning() {
#ifdef TOOLS_ENABLED
if (!is_inside_tree()) {
return;
}
if (get_tree()->get_edited_scene_root() && (get_tree()->get_edited_scene_root() == this || get_tree()->get_edited_scene_root()->is_a_parent_of(this))) {
get_tree()->emit_signal(SceneStringNames::get_singleton()->node_configuration_warning_changed, this);
}
#endif
}
bool Node::is_owned_by_parent() const {

View File

@ -36,96 +36,6 @@
#include "scene/main/scene_string_names.h"
#include "servers/rendering_server.h"
#ifdef TOOLS_ENABLED
Dictionary Node2D::_edit_get_state() const {
Dictionary state;
state["position"] = get_position();
state["rotation"] = get_rotation();
state["scale"] = get_scale();
return state;
}
void Node2D::_edit_set_state(const Dictionary &p_state) {
pos = p_state["position"];
angle = p_state["rotation"];
_scale = p_state["scale"];
_update_transform();
_change_notify("rotation");
_change_notify("rotation_degrees");
_change_notify("scale");
_change_notify("position");
}
void Node2D::_edit_set_position(const Point2 &p_position) {
set_position(p_position);
}
Point2 Node2D::_edit_get_position() const {
return pos;
}
void Node2D::_edit_set_scale(const Size2 &p_scale) {
set_scale(p_scale);
}
Size2 Node2D::_edit_get_scale() const {
return _scale;
}
void Node2D::_edit_set_rotation(float p_rotation) {
angle = p_rotation;
_update_transform();
_change_notify("rotation");
_change_notify("rotation_degrees");
}
float Node2D::_edit_get_rotation() const {
return angle;
}
bool Node2D::_edit_use_rotation() const {
return true;
}
void Node2D::_edit_set_rect(const Rect2 &p_edit_rect) {
ERR_FAIL_COND(!_edit_use_rect());
Rect2 r = _edit_get_rect();
Vector2 zero_offset;
if (r.size.x != 0) {
zero_offset.x = -r.position.x / r.size.x;
}
if (r.size.y != 0) {
zero_offset.y = -r.position.y / r.size.y;
}
Size2 new_scale(1, 1);
if (r.size.x != 0) {
new_scale.x = p_edit_rect.size.x / r.size.x;
}
if (r.size.y != 0) {
new_scale.y = p_edit_rect.size.y / r.size.y;
}
Point2 new_pos = p_edit_rect.position + p_edit_rect.size * zero_offset;
Transform2D postxf;
postxf.set_rotation_and_scale(angle, _scale);
new_pos = postxf.xform(new_pos);
pos += new_pos;
_scale *= new_scale;
_update_transform();
_change_notify("scale");
_change_notify("position");
}
#endif
void Node2D::_update_xform_values() {
pos = _mat.columns[2];
angle = _mat.get_rotation();

View File

@ -54,23 +54,6 @@ protected:
static void _bind_methods();
public:
#ifdef TOOLS_ENABLED
virtual Dictionary _edit_get_state() const;
virtual void _edit_set_state(const Dictionary &p_state);
virtual void _edit_set_position(const Point2 &p_position);
virtual Point2 _edit_get_position() const;
virtual void _edit_set_scale(const Size2 &p_scale);
virtual Size2 _edit_get_scale() const;
virtual void _edit_set_rotation(float p_rotation);
virtual float _edit_get_rotation() const;
virtual bool _edit_use_rotation() const;
virtual void _edit_set_rect(const Rect2 &p_edit_rect);
#endif
void set_position(const Point2 &p_pos);
void set_rotation(float p_radians);
void set_rotation_degrees(float p_degrees);

View File

@ -687,33 +687,6 @@ bool SceneTree::idle(float p_time) {
ProjectSettings::get_singleton()->update();
#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint()) {
//simple hack to reload fallback environment if it changed from editor
String env_path = ProjectSettings::get_singleton()->get("rendering/environment/default_environment");
env_path = env_path.strip_edges(); //user may have added a space or two
String cpath;
Ref<Environment3D> fallback = get_root()->get_world_3d()->get_fallback_environment();
if (fallback.is_valid()) {
cpath = fallback->get_path();
}
if (cpath != env_path) {
if (env_path != String()) {
fallback = ResourceLoader::load(env_path);
if (fallback.is_null()) {
//could not load fallback, set as empty
ProjectSettings::get_singleton()->set("rendering/environment/default_environment", "");
}
} else {
fallback.unref();
}
get_root()->get_world_3d()->set_fallback_environment(fallback);
}
}
#endif
return _quit;
}

View File

@ -36,11 +36,6 @@ void Timer::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_READY: {
if (autostart) {
#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && (get_tree()->get_edited_scene_root() == this || get_tree()->get_edited_scene_root()->is_a_parent_of(this))) {
break;
}
#endif
start();
autostart = false;
}

View File

@ -931,12 +931,6 @@ void Viewport::_vp_input(const Ref<InputEvent> &p_ev) {
return;
}
#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) {
return;
}
#endif
if (to_screen_rect == Rect2()) {
return; //if render target, can't get input events
}
@ -952,11 +946,6 @@ void Viewport::_vp_unhandled_input(const Ref<InputEvent> &p_ev) {
if (disable_input) {
return;
}
#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) {
return;
}
#endif
/*
if (parent_control && !parent_control->is_visible_in_tree())