Fix MSVC warnings, rename shadowed variables, fix uninitialized values, change warnings=all to use /W4.
This commit is contained in:
parent
5b7f62af55
commit
0103af1ddd
|
@ -6,7 +6,7 @@ on: [push, pull_request]
|
|||
env:
|
||||
# Only used for the cache key. Increment version to force clean build.
|
||||
GODOT_BASE_BRANCH: master
|
||||
SCONSFLAGS: verbose=yes warnings=all werror=yes module_text_server_fb_enabled=yes
|
||||
SCONSFLAGS: verbose=yes warnings=extra werror=yes module_text_server_fb_enabled=yes
|
||||
SCONS_CACHE_MSVC_CONFIG: true
|
||||
|
||||
concurrency:
|
||||
|
|
34
SConstruct
34
SConstruct
|
@ -651,16 +651,32 @@ if selected_platform in platform_list:
|
|||
|
||||
# Configure compiler warnings
|
||||
if env.msvc: # MSVC
|
||||
# Truncations, narrowing conversions, signed/unsigned comparisons...
|
||||
disable_nonessential_warnings = ["/wd4267", "/wd4244", "/wd4305", "/wd4018", "/wd4800"]
|
||||
if env["warnings"] == "extra":
|
||||
env.Append(CCFLAGS=["/Wall"]) # Implies /W4
|
||||
elif env["warnings"] == "all":
|
||||
env.Append(CCFLAGS=["/W3"] + disable_nonessential_warnings)
|
||||
elif env["warnings"] == "moderate":
|
||||
env.Append(CCFLAGS=["/W2"] + disable_nonessential_warnings)
|
||||
else: # 'no'
|
||||
if env["warnings"] == "no":
|
||||
env.Append(CCFLAGS=["/w"])
|
||||
else:
|
||||
if env["warnings"] == "extra":
|
||||
env.Append(CCFLAGS=["/W4"])
|
||||
elif env["warnings"] == "all":
|
||||
env.Append(CCFLAGS=["/W3"])
|
||||
elif env["warnings"] == "moderate":
|
||||
env.Append(CCFLAGS=["/W2"])
|
||||
# Disable warnings which we don't plan to fix.
|
||||
|
||||
env.Append(
|
||||
CCFLAGS=[
|
||||
"/wd4100", # C4100 (unreferenced formal parameter): Doesn't play nice with polymorphism.
|
||||
"/wd4127", # C4127 (conditional expression is constant)
|
||||
"/wd4201", # C4201 (non-standard nameless struct/union): Only relevant for C89.
|
||||
"/wd4244", # C4244 C4245 C4267 (narrowing conversions): Unavoidable at this scale.
|
||||
"/wd4245",
|
||||
"/wd4267",
|
||||
"/wd4305", # C4305 (truncation): double to float or real_t, too hard to avoid.
|
||||
"/wd4514", # C4514 (unreferenced inline function has been removed)
|
||||
"/wd4714", # C4714 (function marked as __forceinline not inlined)
|
||||
"/wd4820", # C4820 (padding added after construct)
|
||||
]
|
||||
)
|
||||
|
||||
# Set exception handling model to avoid warnings caused by Windows system headers.
|
||||
env.Append(CCFLAGS=["/EHsc"])
|
||||
|
||||
|
|
|
@ -785,7 +785,7 @@ Error ProjectSettings::save() {
|
|||
return error;
|
||||
}
|
||||
|
||||
Error ProjectSettings::_save_settings_binary(const String &p_file, const RBMap<String, List<String>> &props, const CustomMap &p_custom, const String &p_custom_features) {
|
||||
Error ProjectSettings::_save_settings_binary(const String &p_file, const RBMap<String, List<String>> &p_props, const CustomMap &p_custom, const String &p_custom_features) {
|
||||
Error err;
|
||||
Ref<FileAccess> file = FileAccess::open(p_file, FileAccess::WRITE, &err);
|
||||
ERR_FAIL_COND_V_MSG(err != OK, err, "Couldn't save project.binary at " + p_file + ".");
|
||||
|
@ -795,7 +795,7 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const RBMap<S
|
|||
|
||||
int count = 0;
|
||||
|
||||
for (const KeyValue<String, List<String>> &E : props) {
|
||||
for (const KeyValue<String, List<String>> &E : p_props) {
|
||||
count += E.value.size();
|
||||
}
|
||||
|
||||
|
@ -821,7 +821,7 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const RBMap<S
|
|||
file->store_32(count); //store how many properties are saved
|
||||
}
|
||||
|
||||
for (const KeyValue<String, List<String>> &E : props) {
|
||||
for (const KeyValue<String, List<String>> &E : p_props) {
|
||||
for (const String &key : E.value) {
|
||||
String k = key;
|
||||
if (!E.key.is_empty()) {
|
||||
|
@ -853,7 +853,7 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const RBMap<S
|
|||
return OK;
|
||||
}
|
||||
|
||||
Error ProjectSettings::_save_settings_text(const String &p_file, const RBMap<String, List<String>> &props, const CustomMap &p_custom, const String &p_custom_features) {
|
||||
Error ProjectSettings::_save_settings_text(const String &p_file, const RBMap<String, List<String>> &p_props, const CustomMap &p_custom, const String &p_custom_features) {
|
||||
Error err;
|
||||
Ref<FileAccess> file = FileAccess::open(p_file, FileAccess::WRITE, &err);
|
||||
|
||||
|
@ -874,8 +874,8 @@ Error ProjectSettings::_save_settings_text(const String &p_file, const RBMap<Str
|
|||
}
|
||||
file->store_string("\n");
|
||||
|
||||
for (const KeyValue<String, List<String>> &E : props) {
|
||||
if (E.key != props.begin()->key) {
|
||||
for (const KeyValue<String, List<String>> &E : p_props) {
|
||||
if (E.key != p_props.begin()->key) {
|
||||
file->store_string("\n");
|
||||
}
|
||||
|
||||
|
@ -980,7 +980,7 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust
|
|||
vclist.insert(vc);
|
||||
}
|
||||
|
||||
RBMap<String, List<String>> props;
|
||||
RBMap<String, List<String>> save_props;
|
||||
|
||||
for (const _VCSort &E : vclist) {
|
||||
String category = E.name;
|
||||
|
@ -994,24 +994,24 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust
|
|||
category = category.substr(0, div);
|
||||
name = name.substr(div + 1, name.size());
|
||||
}
|
||||
props[category].push_back(name);
|
||||
save_props[category].push_back(name);
|
||||
}
|
||||
|
||||
String custom_features;
|
||||
String save_features;
|
||||
|
||||
for (int i = 0; i < p_custom_features.size(); i++) {
|
||||
if (i > 0) {
|
||||
custom_features += ",";
|
||||
save_features += ",";
|
||||
}
|
||||
|
||||
String f = p_custom_features[i].strip_edges().replace("\"", "");
|
||||
custom_features += f;
|
||||
save_features += f;
|
||||
}
|
||||
|
||||
if (p_path.ends_with(".godot") || p_path.ends_with("override.cfg")) {
|
||||
return _save_settings_text(p_path, props, p_custom, custom_features);
|
||||
return _save_settings_text(p_path, save_props, p_custom, save_features);
|
||||
} else if (p_path.ends_with(".binary")) {
|
||||
return _save_settings_binary(p_path, props, p_custom, custom_features);
|
||||
return _save_settings_binary(p_path, save_props, p_custom, save_features);
|
||||
} else {
|
||||
ERR_FAIL_V_MSG(ERR_FILE_UNRECOGNIZED, "Unknown config file format: " + p_path + ".");
|
||||
}
|
||||
|
|
|
@ -365,7 +365,6 @@ Vector2 Input::get_vector(const StringName &p_negative_x, const StringName &p_po
|
|||
// Inverse lerp length to map (p_deadzone, 1) to (0, 1).
|
||||
return vector * (Math::inverse_lerp(p_deadzone, 1.0f, length) / length);
|
||||
}
|
||||
return vector;
|
||||
}
|
||||
|
||||
float Input::get_joy_axis(int p_device, JoyAxis p_axis) const {
|
||||
|
|
|
@ -449,11 +449,11 @@ bool InputEventKey::action_match(const Ref<InputEvent> &p_event, bool p_exact_ma
|
|||
match &= action_mask == key_mask;
|
||||
}
|
||||
if (match) {
|
||||
bool pressed = key->is_pressed();
|
||||
bool key_pressed = key->is_pressed();
|
||||
if (r_pressed != nullptr) {
|
||||
*r_pressed = pressed;
|
||||
*r_pressed = key_pressed;
|
||||
}
|
||||
float strength = pressed ? 1.0f : 0.0f;
|
||||
float strength = key_pressed ? 1.0f : 0.0f;
|
||||
if (r_strength != nullptr) {
|
||||
*r_strength = strength;
|
||||
}
|
||||
|
@ -610,20 +610,20 @@ bool InputEventMouseButton::action_match(const Ref<InputEvent> &p_event, bool p_
|
|||
}
|
||||
|
||||
bool match = button_index == mb->button_index;
|
||||
Key action_mask = get_modifiers_mask();
|
||||
Key button_mask = mb->get_modifiers_mask();
|
||||
Key action_modifiers_mask = get_modifiers_mask();
|
||||
Key button_modifiers_mask = mb->get_modifiers_mask();
|
||||
if (mb->is_pressed()) {
|
||||
match &= (action_mask & button_mask) == action_mask;
|
||||
match &= (action_modifiers_mask & button_modifiers_mask) == action_modifiers_mask;
|
||||
}
|
||||
if (p_exact_match) {
|
||||
match &= action_mask == button_mask;
|
||||
match &= action_modifiers_mask == button_modifiers_mask;
|
||||
}
|
||||
if (match) {
|
||||
bool pressed = mb->is_pressed();
|
||||
bool mb_pressed = mb->is_pressed();
|
||||
if (r_pressed != nullptr) {
|
||||
*r_pressed = pressed;
|
||||
*r_pressed = mb_pressed;
|
||||
}
|
||||
float strength = pressed ? 1.0f : 0.0f;
|
||||
float strength = mb_pressed ? 1.0f : 0.0f;
|
||||
if (r_strength != nullptr) {
|
||||
*r_strength = strength;
|
||||
}
|
||||
|
@ -808,9 +808,9 @@ String InputEventMouseMotion::as_text() const {
|
|||
}
|
||||
|
||||
String InputEventMouseMotion::to_string() {
|
||||
MouseButton button_mask = get_button_mask();
|
||||
String button_mask_string = itos((int64_t)button_mask);
|
||||
switch (button_mask) {
|
||||
MouseButton mouse_button_mask = get_button_mask();
|
||||
String button_mask_string = itos((int64_t)mouse_button_mask);
|
||||
switch (mouse_button_mask) {
|
||||
case MouseButton::MASK_LEFT:
|
||||
button_mask_string += vformat(" (%s)", TTRGET(_mouse_button_descriptions[(size_t)MouseButton::LEFT - 1]));
|
||||
break;
|
||||
|
@ -1045,11 +1045,11 @@ bool InputEventJoypadButton::action_match(const Ref<InputEvent> &p_event, bool p
|
|||
|
||||
bool match = button_index == jb->button_index;
|
||||
if (match) {
|
||||
bool pressed = jb->is_pressed();
|
||||
bool jb_pressed = jb->is_pressed();
|
||||
if (r_pressed != nullptr) {
|
||||
*r_pressed = pressed;
|
||||
*r_pressed = jb_pressed;
|
||||
}
|
||||
float strength = pressed ? 1.0f : 0.0f;
|
||||
float strength = jb_pressed ? 1.0f : 0.0f;
|
||||
if (r_strength != nullptr) {
|
||||
*r_strength = strength;
|
||||
}
|
||||
|
@ -1340,16 +1340,16 @@ bool InputEventAction::action_match(const Ref<InputEvent> &p_event, bool p_exact
|
|||
|
||||
bool match = action == act->action;
|
||||
if (match) {
|
||||
bool pressed = act->pressed;
|
||||
bool act_pressed = act->pressed;
|
||||
if (r_pressed != nullptr) {
|
||||
*r_pressed = pressed;
|
||||
*r_pressed = act_pressed;
|
||||
}
|
||||
float strength = pressed ? 1.0f : 0.0f;
|
||||
float act_strength = act_pressed ? 1.0f : 0.0f;
|
||||
if (r_strength != nullptr) {
|
||||
*r_strength = strength;
|
||||
*r_strength = act_strength;
|
||||
}
|
||||
if (r_raw_strength != nullptr) {
|
||||
*r_raw_strength = strength;
|
||||
*r_raw_strength = act_strength;
|
||||
}
|
||||
}
|
||||
return match;
|
||||
|
|
|
@ -102,13 +102,13 @@ Error FileAccessEncrypted::open_and_parse(Ref<FileAccess> p_base, const Vector<u
|
|||
Error FileAccessEncrypted::open_and_parse_password(Ref<FileAccess> p_base, const String &p_key, Mode p_mode) {
|
||||
String cs = p_key.md5_text();
|
||||
ERR_FAIL_COND_V(cs.length() != 32, ERR_INVALID_PARAMETER);
|
||||
Vector<uint8_t> key;
|
||||
key.resize(32);
|
||||
Vector<uint8_t> key_md5;
|
||||
key_md5.resize(32);
|
||||
for (int i = 0; i < 32; i++) {
|
||||
key.write[i] = cs[i];
|
||||
key_md5.write[i] = cs[i];
|
||||
}
|
||||
|
||||
return open_and_parse(p_base, key, p_mode);
|
||||
return open_and_parse(p_base, key_md5, p_mode);
|
||||
}
|
||||
|
||||
Error FileAccessEncrypted::open_internal(const String &p_path, int p_mode_flags) {
|
||||
|
|
|
@ -137,12 +137,12 @@ void FileAccessNetworkClient::_thread_func() {
|
|||
int64_t offset = get_64();
|
||||
int32_t len = get_32();
|
||||
|
||||
Vector<uint8_t> block;
|
||||
block.resize(len);
|
||||
client->get_data(block.ptrw(), len);
|
||||
Vector<uint8_t> resp_block;
|
||||
resp_block.resize(len);
|
||||
client->get_data(resp_block.ptrw(), len);
|
||||
|
||||
if (fa) { //may have been queued
|
||||
fa->_set_block(offset, block);
|
||||
fa->_set_block(offset, resp_block);
|
||||
}
|
||||
|
||||
} break;
|
||||
|
|
|
@ -358,38 +358,38 @@ Error HTTPClientTCP::poll() {
|
|||
} break;
|
||||
}
|
||||
} else if (tls) {
|
||||
Ref<StreamPeerTLS> tls;
|
||||
Ref<StreamPeerTLS> tls_conn;
|
||||
if (!handshaking) {
|
||||
// Connect the StreamPeerTLS and start handshaking.
|
||||
tls = Ref<StreamPeerTLS>(StreamPeerTLS::create());
|
||||
tls->set_blocking_handshake_enabled(false);
|
||||
Error err = tls->connect_to_stream(tcp_connection, tls_verify_host, conn_host);
|
||||
tls_conn = Ref<StreamPeerTLS>(StreamPeerTLS::create());
|
||||
tls_conn->set_blocking_handshake_enabled(false);
|
||||
Error err = tls_conn->connect_to_stream(tcp_connection, tls_verify_host, conn_host);
|
||||
if (err != OK) {
|
||||
close();
|
||||
status = STATUS_TLS_HANDSHAKE_ERROR;
|
||||
return ERR_CANT_CONNECT;
|
||||
}
|
||||
connection = tls;
|
||||
connection = tls_conn;
|
||||
handshaking = true;
|
||||
} else {
|
||||
// We are already handshaking, which means we can use your already active TLS connection.
|
||||
tls = static_cast<Ref<StreamPeerTLS>>(connection);
|
||||
if (tls.is_null()) {
|
||||
tls_conn = static_cast<Ref<StreamPeerTLS>>(connection);
|
||||
if (tls_conn.is_null()) {
|
||||
close();
|
||||
status = STATUS_TLS_HANDSHAKE_ERROR;
|
||||
return ERR_CANT_CONNECT;
|
||||
}
|
||||
|
||||
tls->poll(); // Try to finish the handshake.
|
||||
tls_conn->poll(); // Try to finish the handshake.
|
||||
}
|
||||
|
||||
if (tls->get_status() == StreamPeerTLS::STATUS_CONNECTED) {
|
||||
if (tls_conn->get_status() == StreamPeerTLS::STATUS_CONNECTED) {
|
||||
// Handshake has been successful.
|
||||
handshaking = false;
|
||||
ip_candidates.clear();
|
||||
status = STATUS_CONNECTED;
|
||||
return OK;
|
||||
} else if (tls->get_status() != StreamPeerTLS::STATUS_HANDSHAKING) {
|
||||
} else if (tls_conn->get_status() != StreamPeerTLS::STATUS_HANDSHAKING) {
|
||||
// Handshake has failed.
|
||||
close();
|
||||
status = STATUS_TLS_HANDSHAKE_ERROR;
|
||||
|
|
|
@ -3869,15 +3869,15 @@ Dictionary Image::compute_image_metrics(const Ref<Image> p_compared_image, bool
|
|||
double image_metric_max, image_metric_mean, image_metric_mean_squared, image_metric_root_mean_squared, image_metric_peak_snr = 0.0;
|
||||
const bool average_component_error = true;
|
||||
|
||||
const uint32_t width = MIN(compared_image->get_width(), source_image->get_width());
|
||||
const uint32_t height = MIN(compared_image->get_height(), source_image->get_height());
|
||||
const uint32_t w = MIN(compared_image->get_width(), source_image->get_width());
|
||||
const uint32_t h = MIN(compared_image->get_height(), source_image->get_height());
|
||||
|
||||
// Histogram approach originally due to Charles Bloom.
|
||||
double hist[256];
|
||||
memset(hist, 0, sizeof(hist));
|
||||
|
||||
for (uint32_t y = 0; y < height; y++) {
|
||||
for (uint32_t x = 0; x < width; x++) {
|
||||
for (uint32_t y = 0; y < h; y++) {
|
||||
for (uint32_t x = 0; x < w; x++) {
|
||||
const Color color_a = compared_image->get_pixel(x, y);
|
||||
|
||||
const Color color_b = source_image->get_pixel(x, y);
|
||||
|
@ -3922,7 +3922,7 @@ Dictionary Image::compute_image_metrics(const Ref<Image> p_compared_image, bool
|
|||
}
|
||||
|
||||
// See http://richg42.blogspot.com/2016/09/how-to-compute-psnr-from-old-berkeley.html
|
||||
double total_values = width * height;
|
||||
double total_values = w * h;
|
||||
|
||||
if (average_component_error) {
|
||||
total_values *= 4;
|
||||
|
|
|
@ -51,7 +51,7 @@ bool ImageFormatLoader::recognize(const String &p_extension) const {
|
|||
}
|
||||
|
||||
Error ImageFormatLoaderExtension::load_image(Ref<Image> p_image, Ref<FileAccess> p_fileaccess, BitField<ImageFormatLoader::LoaderFlags> p_flags, float p_scale) {
|
||||
Error err;
|
||||
Error err = ERR_UNAVAILABLE;
|
||||
if (GDVIRTUAL_CALL(_load_image, p_image, p_fileaccess, p_flags, p_scale, err)) {
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -169,10 +169,10 @@ StringName ResourceLoaderBinary::_get_string() {
|
|||
}
|
||||
|
||||
Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
|
||||
uint32_t type = f->get_32();
|
||||
print_bl("find property of type: " + itos(type));
|
||||
uint32_t prop_type = f->get_32();
|
||||
print_bl("find property of type: " + itos(prop_type));
|
||||
|
||||
switch (type) {
|
||||
switch (prop_type) {
|
||||
case VARIANT_NIL: {
|
||||
r_v = Variant();
|
||||
} break;
|
||||
|
@ -1100,16 +1100,14 @@ String ResourceLoaderBinary::recognize(Ref<FileAccess> p_f) {
|
|||
|
||||
uint32_t ver_major = f->get_32();
|
||||
f->get_32(); // ver_minor
|
||||
uint32_t ver_format = f->get_32();
|
||||
uint32_t ver_fmt = f->get_32();
|
||||
|
||||
if (ver_format > FORMAT_VERSION || ver_major > VERSION_MAJOR) {
|
||||
if (ver_fmt > FORMAT_VERSION || ver_major > VERSION_MAJOR) {
|
||||
f.unref();
|
||||
return "";
|
||||
}
|
||||
|
||||
String type = get_unicode_string();
|
||||
|
||||
return type;
|
||||
return get_unicode_string();
|
||||
}
|
||||
|
||||
Ref<Resource> ResourceFormatLoaderBinary::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) {
|
||||
|
@ -2118,9 +2116,9 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const Ref<Re
|
|||
|
||||
for (int i = 0; i < save_order.size(); i++) {
|
||||
save_unicode_string(f, save_order[i]->get_save_class());
|
||||
String path = save_order[i]->get_path();
|
||||
path = relative_paths ? local_path.path_to_file(path) : path;
|
||||
save_unicode_string(f, path);
|
||||
String res_path = save_order[i]->get_path();
|
||||
res_path = relative_paths ? local_path.path_to_file(res_path) : res_path;
|
||||
save_unicode_string(f, res_path);
|
||||
ResourceUID::ID ruid = ResourceSaver::get_resource_id_for_path(save_order[i]->get_path(), false);
|
||||
f->store_64(ruid);
|
||||
}
|
||||
|
|
|
@ -110,8 +110,8 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy
|
|||
|
||||
#ifdef TOOLS_ENABLED
|
||||
if (r_path_and_type.metadata && !r_path_and_type.path.is_empty()) {
|
||||
Dictionary metadata = r_path_and_type.metadata;
|
||||
if (metadata.has("has_editor_variant")) {
|
||||
Dictionary meta = r_path_and_type.metadata;
|
||||
if (meta.has("has_editor_variant")) {
|
||||
r_path_and_type.path = r_path_and_type.path.get_basename() + ".editor." + r_path_and_type.path.get_extension();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ bool ResourceFormatLoader::recognize_path(const String &p_path, const String &p_
|
|||
}
|
||||
|
||||
bool ResourceFormatLoader::handles_type(const String &p_type) const {
|
||||
bool success;
|
||||
bool success = false;
|
||||
if (GDVIRTUAL_CALL(_handles_type, p_type, success)) {
|
||||
return success;
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ String ResourceFormatLoader::get_resource_type(const String &p_path) const {
|
|||
}
|
||||
|
||||
ResourceUID::ID ResourceFormatLoader::get_resource_uid(const String &p_path) const {
|
||||
int64_t uid;
|
||||
int64_t uid = ResourceUID::INVALID_ID;
|
||||
if (GDVIRTUAL_CALL(_get_resource_uid, p_path, uid)) {
|
||||
return uid;
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ void ResourceLoader::get_recognized_extensions_for_type(const String &p_type, Li
|
|||
}
|
||||
|
||||
bool ResourceFormatLoader::exists(const String &p_path) const {
|
||||
bool success;
|
||||
bool success = false;
|
||||
if (GDVIRTUAL_CALL(_exists, p_path, success)) {
|
||||
return success;
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ Error ResourceFormatLoader::rename_dependencies(const String &p_path, const Hash
|
|||
deps_dict[E.key] = E.value;
|
||||
}
|
||||
|
||||
int64_t err;
|
||||
int64_t err = OK;
|
||||
if (GDVIRTUAL_CALL(_rename_dependencies, p_path, deps_dict, err)) {
|
||||
return (Error)err;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ ResourceSavedCallback ResourceSaver::save_callback = nullptr;
|
|||
ResourceSaverGetResourceIDForPath ResourceSaver::save_get_id_for_path = nullptr;
|
||||
|
||||
Error ResourceFormatSaver::save(const Ref<Resource> &p_resource, const String &p_path, uint32_t p_flags) {
|
||||
int64_t res;
|
||||
int64_t res = ERR_METHOD_NOT_FOUND;
|
||||
if (GDVIRTUAL_CALL(_save, p_resource, p_path, p_flags, res)) {
|
||||
return (Error)res;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ Error ResourceFormatSaver::save(const Ref<Resource> &p_resource, const String &p
|
|||
}
|
||||
|
||||
bool ResourceFormatSaver::recognize(const Ref<Resource> &p_resource) const {
|
||||
bool success;
|
||||
bool success = false;
|
||||
if (GDVIRTUAL_CALL(_recognize, p_resource, success)) {
|
||||
return success;
|
||||
}
|
||||
|
|
|
@ -256,9 +256,9 @@ void StreamPeerTCP::disconnect_from_host() {
|
|||
peer_port = 0;
|
||||
}
|
||||
|
||||
Error StreamPeerTCP::wait(NetSocket::PollType p_type, int timeout) {
|
||||
Error StreamPeerTCP::wait(NetSocket::PollType p_type, int p_timeout) {
|
||||
ERR_FAIL_COND_V(_sock.is_null() || !_sock->is_open(), ERR_UNAVAILABLE);
|
||||
return _sock->poll(p_type, timeout);
|
||||
return _sock->poll(p_type, p_timeout);
|
||||
}
|
||||
|
||||
Error StreamPeerTCP::put_data(const uint8_t *p_data, int p_bytes) {
|
||||
|
|
|
@ -79,7 +79,7 @@ public:
|
|||
Error poll();
|
||||
|
||||
// Wait or check for writable, readable.
|
||||
Error wait(NetSocket::PollType p_type, int timeout = 0);
|
||||
Error wait(NetSocket::PollType p_type, int p_timeout = 0);
|
||||
|
||||
// Read/Write from StreamPeer
|
||||
Error put_data(const uint8_t *p_data, int p_bytes) override;
|
||||
|
|
|
@ -560,7 +560,7 @@ const char *Expression::token_name[TK_MAX] = {
|
|||
};
|
||||
|
||||
Expression::ENode *Expression::_parse_expression() {
|
||||
Vector<ExpressionNode> expression;
|
||||
Vector<ExpressionNode> expression_nodes;
|
||||
|
||||
while (true) {
|
||||
//keep appending stuff to expression
|
||||
|
@ -838,14 +838,14 @@ Expression::ENode *Expression::_parse_expression() {
|
|||
ExpressionNode e;
|
||||
e.is_op = true;
|
||||
e.op = Variant::OP_NEGATE;
|
||||
expression.push_back(e);
|
||||
expression_nodes.push_back(e);
|
||||
continue;
|
||||
} break;
|
||||
case TK_OP_NOT: {
|
||||
ExpressionNode e;
|
||||
e.is_op = true;
|
||||
e.op = Variant::OP_NOT;
|
||||
expression.push_back(e);
|
||||
expression_nodes.push_back(e);
|
||||
continue;
|
||||
} break;
|
||||
|
||||
|
@ -960,7 +960,7 @@ Expression::ENode *Expression::_parse_expression() {
|
|||
ExpressionNode e;
|
||||
e.is_op = false;
|
||||
e.node = expr;
|
||||
expression.push_back(e);
|
||||
expression_nodes.push_back(e);
|
||||
}
|
||||
|
||||
//ok finally look for an operator
|
||||
|
@ -1054,19 +1054,19 @@ Expression::ENode *Expression::_parse_expression() {
|
|||
ExpressionNode e;
|
||||
e.is_op = true;
|
||||
e.op = op;
|
||||
expression.push_back(e);
|
||||
expression_nodes.push_back(e);
|
||||
}
|
||||
}
|
||||
|
||||
/* Reduce the set of expressions and place them in an operator tree, respecting precedence */
|
||||
|
||||
while (expression.size() > 1) {
|
||||
while (expression_nodes.size() > 1) {
|
||||
int next_op = -1;
|
||||
int min_priority = 0xFFFFF;
|
||||
bool is_unary = false;
|
||||
|
||||
for (int i = 0; i < expression.size(); i++) {
|
||||
if (!expression[i].is_op) {
|
||||
for (int i = 0; i < expression_nodes.size(); i++) {
|
||||
if (!expression_nodes[i].is_op) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1074,7 +1074,7 @@ Expression::ENode *Expression::_parse_expression() {
|
|||
|
||||
bool unary = false;
|
||||
|
||||
switch (expression[i].op) {
|
||||
switch (expression_nodes[i].op) {
|
||||
case Variant::OP_POWER:
|
||||
priority = 0;
|
||||
break;
|
||||
|
@ -1130,7 +1130,7 @@ Expression::ENode *Expression::_parse_expression() {
|
|||
priority = 14;
|
||||
break;
|
||||
default: {
|
||||
_set_error("Parser bug, invalid operator in expression: " + itos(expression[i].op));
|
||||
_set_error("Parser bug, invalid operator in expression: " + itos(expression_nodes[i].op));
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -1153,9 +1153,9 @@ Expression::ENode *Expression::_parse_expression() {
|
|||
// OK! create operator..
|
||||
if (is_unary) {
|
||||
int expr_pos = next_op;
|
||||
while (expression[expr_pos].is_op) {
|
||||
while (expression_nodes[expr_pos].is_op) {
|
||||
expr_pos++;
|
||||
if (expr_pos == expression.size()) {
|
||||
if (expr_pos == expression_nodes.size()) {
|
||||
//can happen..
|
||||
_set_error("Unexpected end of expression...");
|
||||
return nullptr;
|
||||
|
@ -1165,29 +1165,29 @@ Expression::ENode *Expression::_parse_expression() {
|
|||
//consecutively do unary operators
|
||||
for (int i = expr_pos - 1; i >= next_op; i--) {
|
||||
OperatorNode *op = alloc_node<OperatorNode>();
|
||||
op->op = expression[i].op;
|
||||
op->nodes[0] = expression[i + 1].node;
|
||||
op->op = expression_nodes[i].op;
|
||||
op->nodes[0] = expression_nodes[i + 1].node;
|
||||
op->nodes[1] = nullptr;
|
||||
expression.write[i].is_op = false;
|
||||
expression.write[i].node = op;
|
||||
expression.remove_at(i + 1);
|
||||
expression_nodes.write[i].is_op = false;
|
||||
expression_nodes.write[i].node = op;
|
||||
expression_nodes.remove_at(i + 1);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (next_op < 1 || next_op >= (expression.size() - 1)) {
|
||||
if (next_op < 1 || next_op >= (expression_nodes.size() - 1)) {
|
||||
_set_error("Parser bug...");
|
||||
ERR_FAIL_V(nullptr);
|
||||
}
|
||||
|
||||
OperatorNode *op = alloc_node<OperatorNode>();
|
||||
op->op = expression[next_op].op;
|
||||
op->op = expression_nodes[next_op].op;
|
||||
|
||||
if (expression[next_op - 1].is_op) {
|
||||
if (expression_nodes[next_op - 1].is_op) {
|
||||
_set_error("Parser bug...");
|
||||
ERR_FAIL_V(nullptr);
|
||||
}
|
||||
|
||||
if (expression[next_op + 1].is_op) {
|
||||
if (expression_nodes[next_op + 1].is_op) {
|
||||
// this is not invalid and can really appear
|
||||
// but it becomes invalid anyway because no binary op
|
||||
// can be followed by a unary op in a valid combination,
|
||||
|
@ -1197,17 +1197,17 @@ Expression::ENode *Expression::_parse_expression() {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
op->nodes[0] = expression[next_op - 1].node; //expression goes as left
|
||||
op->nodes[1] = expression[next_op + 1].node; //next expression goes as right
|
||||
op->nodes[0] = expression_nodes[next_op - 1].node; //expression goes as left
|
||||
op->nodes[1] = expression_nodes[next_op + 1].node; //next expression goes as right
|
||||
|
||||
//replace all 3 nodes by this operator and make it an expression
|
||||
expression.write[next_op - 1].node = op;
|
||||
expression.remove_at(next_op);
|
||||
expression.remove_at(next_op);
|
||||
expression_nodes.write[next_op - 1].node = op;
|
||||
expression_nodes.remove_at(next_op);
|
||||
expression_nodes.remove_at(next_op);
|
||||
}
|
||||
}
|
||||
|
||||
return expression[0].node;
|
||||
return expression_nodes[0].node;
|
||||
}
|
||||
|
||||
bool Expression::_compile_expression() {
|
||||
|
|
|
@ -169,7 +169,7 @@ Projection Projection::perspective_znear_adjusted(real_t p_new_znear) const {
|
|||
}
|
||||
|
||||
Plane Projection::get_projection_plane(Planes p_plane) const {
|
||||
const real_t *matrix = (const real_t *)this->columns;
|
||||
const real_t *matrix = (const real_t *)columns;
|
||||
|
||||
switch (p_plane) {
|
||||
case PLANE_NEAR: {
|
||||
|
@ -402,7 +402,7 @@ void Projection::set_frustum(real_t p_size, real_t p_aspect, Vector2 p_offset, r
|
|||
}
|
||||
|
||||
real_t Projection::get_z_far() const {
|
||||
const real_t *matrix = (const real_t *)this->columns;
|
||||
const real_t *matrix = (const real_t *)columns;
|
||||
Plane new_plane = Plane(matrix[3] - matrix[2],
|
||||
matrix[7] - matrix[6],
|
||||
matrix[11] - matrix[10],
|
||||
|
@ -415,7 +415,7 @@ real_t Projection::get_z_far() const {
|
|||
}
|
||||
|
||||
real_t Projection::get_z_near() const {
|
||||
const real_t *matrix = (const real_t *)this->columns;
|
||||
const real_t *matrix = (const real_t *)columns;
|
||||
Plane new_plane = Plane(matrix[3] + matrix[2],
|
||||
matrix[7] + matrix[6],
|
||||
matrix[11] + matrix[10],
|
||||
|
@ -426,7 +426,7 @@ real_t Projection::get_z_near() const {
|
|||
}
|
||||
|
||||
Vector2 Projection::get_viewport_half_extents() const {
|
||||
const real_t *matrix = (const real_t *)this->columns;
|
||||
const real_t *matrix = (const real_t *)columns;
|
||||
///////--- Near Plane ---///////
|
||||
Plane near_plane = Plane(matrix[3] + matrix[2],
|
||||
matrix[7] + matrix[6],
|
||||
|
@ -454,7 +454,7 @@ Vector2 Projection::get_viewport_half_extents() const {
|
|||
}
|
||||
|
||||
Vector2 Projection::get_far_plane_half_extents() const {
|
||||
const real_t *matrix = (const real_t *)this->columns;
|
||||
const real_t *matrix = (const real_t *)columns;
|
||||
///////--- Far Plane ---///////
|
||||
Plane far_plane = Plane(matrix[3] - matrix[2],
|
||||
matrix[7] - matrix[6],
|
||||
|
@ -514,7 +514,7 @@ Vector<Plane> Projection::get_projection_planes(const Transform3D &p_transform)
|
|||
Vector<Plane> planes;
|
||||
planes.resize(6);
|
||||
|
||||
const real_t *matrix = (const real_t *)this->columns;
|
||||
const real_t *matrix = (const real_t *)columns;
|
||||
|
||||
Plane new_plane;
|
||||
|
||||
|
@ -807,7 +807,7 @@ bool Projection::is_orthogonal() const {
|
|||
}
|
||||
|
||||
real_t Projection::get_fov() const {
|
||||
const real_t *matrix = (const real_t *)this->columns;
|
||||
const real_t *matrix = (const real_t *)columns;
|
||||
|
||||
Plane right_plane = Plane(matrix[3] - matrix[0],
|
||||
matrix[7] - matrix[4],
|
||||
|
|
|
@ -215,10 +215,8 @@ Vector3 TriangleMesh::get_area_normal(const AABB &p_aabb) const {
|
|||
|
||||
switch (stack[level] >> VISITED_BIT_SHIFT) {
|
||||
case TEST_AABB_BIT: {
|
||||
bool valid = b.aabb.intersects(p_aabb);
|
||||
if (!valid) {
|
||||
if (!b.aabb.intersects(p_aabb)) {
|
||||
stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node;
|
||||
|
||||
} else {
|
||||
if (b.face_index >= 0) {
|
||||
const Triangle &s = triangleptr[b.face_index];
|
||||
|
@ -302,12 +300,8 @@ bool TriangleMesh::intersect_segment(const Vector3 &p_begin, const Vector3 &p_en
|
|||
|
||||
switch (stack[level] >> VISITED_BIT_SHIFT) {
|
||||
case TEST_AABB_BIT: {
|
||||
bool valid = b.aabb.intersects_segment(p_begin, p_end);
|
||||
//bool valid = b.aabb.intersects(ray_aabb);
|
||||
|
||||
if (!valid) {
|
||||
if (!b.aabb.intersects_segment(p_begin, p_end)) {
|
||||
stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node;
|
||||
|
||||
} else {
|
||||
if (b.face_index >= 0) {
|
||||
const Triangle &s = triangleptr[b.face_index];
|
||||
|
@ -407,10 +401,8 @@ bool TriangleMesh::intersect_ray(const Vector3 &p_begin, const Vector3 &p_dir, V
|
|||
|
||||
switch (stack[level] >> VISITED_BIT_SHIFT) {
|
||||
case TEST_AABB_BIT: {
|
||||
bool valid = b.aabb.intersects_ray(p_begin, p_dir);
|
||||
if (!valid) {
|
||||
if (!b.aabb.intersects_ray(p_begin, p_dir)) {
|
||||
stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node;
|
||||
|
||||
} else {
|
||||
if (b.face_index >= 0) {
|
||||
const Triangle &s = triangleptr[b.face_index];
|
||||
|
@ -508,10 +500,8 @@ bool TriangleMesh::intersect_convex_shape(const Plane *p_planes, int p_plane_cou
|
|||
|
||||
switch (stack[level] >> VISITED_BIT_SHIFT) {
|
||||
case TEST_AABB_BIT: {
|
||||
bool valid = b.aabb.intersects_convex_shape(p_planes, p_plane_count, p_points, p_point_count);
|
||||
if (!valid) {
|
||||
if (!b.aabb.intersects_convex_shape(p_planes, p_plane_count, p_points, p_point_count)) {
|
||||
stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node;
|
||||
|
||||
} else {
|
||||
if (b.face_index >= 0) {
|
||||
const Triangle &s = triangleptr[b.face_index];
|
||||
|
|
|
@ -106,23 +106,23 @@ Dictionary Script::_get_script_constant_map() {
|
|||
|
||||
PropertyInfo Script::get_class_category() const {
|
||||
String path = get_path();
|
||||
String name;
|
||||
String scr_name;
|
||||
|
||||
if (is_built_in()) {
|
||||
if (get_name().is_empty()) {
|
||||
name = TTR("Built-in script");
|
||||
scr_name = TTR("Built-in script");
|
||||
} else {
|
||||
name = vformat("%s (%s)", get_name(), TTR("Built-in"));
|
||||
scr_name = vformat("%s (%s)", get_name(), TTR("Built-in"));
|
||||
}
|
||||
} else {
|
||||
if (get_name().is_empty()) {
|
||||
name = path.get_file();
|
||||
scr_name = path.get_file();
|
||||
} else {
|
||||
name = get_name();
|
||||
scr_name = get_name();
|
||||
}
|
||||
}
|
||||
|
||||
return PropertyInfo(Variant::NIL, name, PROPERTY_HINT_NONE, path, PROPERTY_USAGE_CATEGORY);
|
||||
return PropertyInfo(Variant::NIL, scr_name, PROPERTY_HINT_NONE, path, PROPERTY_USAGE_CATEGORY);
|
||||
}
|
||||
|
||||
#endif // TOOLS_ENABLED
|
||||
|
|
|
@ -179,14 +179,14 @@ void OptimizedTranslation::generate(const Ref<Translation> &p_from) {
|
|||
}
|
||||
|
||||
bool OptimizedTranslation::_set(const StringName &p_name, const Variant &p_value) {
|
||||
String name = p_name.operator String();
|
||||
if (name == "hash_table") {
|
||||
String prop_name = p_name.operator String();
|
||||
if (prop_name == "hash_table") {
|
||||
hash_table = p_value;
|
||||
} else if (name == "bucket_table") {
|
||||
} else if (prop_name == "bucket_table") {
|
||||
bucket_table = p_value;
|
||||
} else if (name == "strings") {
|
||||
} else if (prop_name == "strings") {
|
||||
strings = p_value;
|
||||
} else if (name == "load_from") {
|
||||
} else if (prop_name == "load_from") {
|
||||
generate(p_value);
|
||||
} else {
|
||||
return false;
|
||||
|
@ -196,12 +196,12 @@ bool OptimizedTranslation::_set(const StringName &p_name, const Variant &p_value
|
|||
}
|
||||
|
||||
bool OptimizedTranslation::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
String name = p_name.operator String();
|
||||
if (name == "hash_table") {
|
||||
String prop_name = p_name.operator String();
|
||||
if (prop_name == "hash_table") {
|
||||
r_ret = hash_table;
|
||||
} else if (name == "bucket_table") {
|
||||
} else if (prop_name == "bucket_table") {
|
||||
r_ret = bucket_table;
|
||||
} else if (name == "strings") {
|
||||
} else if (prop_name == "strings") {
|
||||
r_ret = strings;
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
@ -297,27 +297,27 @@ String TranslationServer::standardize_locale(const String &p_locale) const {
|
|||
String univ_locale = p_locale.replace("-", "_");
|
||||
|
||||
// Extract locale elements.
|
||||
String lang, script, country, variant;
|
||||
String lang_name, script_name, country_name, variant_name;
|
||||
Vector<String> locale_elements = univ_locale.get_slice("@", 0).split("_");
|
||||
lang = locale_elements[0];
|
||||
lang_name = locale_elements[0];
|
||||
if (locale_elements.size() >= 2) {
|
||||
if (locale_elements[1].length() == 4 && is_ascii_upper_case(locale_elements[1][0]) && is_ascii_lower_case(locale_elements[1][1]) && is_ascii_lower_case(locale_elements[1][2]) && is_ascii_lower_case(locale_elements[1][3])) {
|
||||
script = locale_elements[1];
|
||||
script_name = locale_elements[1];
|
||||
}
|
||||
if (locale_elements[1].length() == 2 && is_ascii_upper_case(locale_elements[1][0]) && is_ascii_upper_case(locale_elements[1][1])) {
|
||||
country = locale_elements[1];
|
||||
country_name = locale_elements[1];
|
||||
}
|
||||
}
|
||||
if (locale_elements.size() >= 3) {
|
||||
if (locale_elements[2].length() == 2 && is_ascii_upper_case(locale_elements[2][0]) && is_ascii_upper_case(locale_elements[2][1])) {
|
||||
country = locale_elements[2];
|
||||
} else if (variant_map.has(locale_elements[2].to_lower()) && variant_map[locale_elements[2].to_lower()] == lang) {
|
||||
variant = locale_elements[2].to_lower();
|
||||
country_name = locale_elements[2];
|
||||
} else if (variant_map.has(locale_elements[2].to_lower()) && variant_map[locale_elements[2].to_lower()] == lang_name) {
|
||||
variant_name = locale_elements[2].to_lower();
|
||||
}
|
||||
}
|
||||
if (locale_elements.size() >= 4) {
|
||||
if (variant_map.has(locale_elements[3].to_lower()) && variant_map[locale_elements[3].to_lower()] == lang) {
|
||||
variant = locale_elements[3].to_lower();
|
||||
if (variant_map.has(locale_elements[3].to_lower()) && variant_map[locale_elements[3].to_lower()] == lang_name) {
|
||||
variant_name = locale_elements[3].to_lower();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -325,69 +325,69 @@ String TranslationServer::standardize_locale(const String &p_locale) const {
|
|||
Vector<String> script_extra = univ_locale.get_slice("@", 1).split(";");
|
||||
for (int i = 0; i < script_extra.size(); i++) {
|
||||
if (script_extra[i].to_lower() == "cyrillic") {
|
||||
script = "Cyrl";
|
||||
script_name = "Cyrl";
|
||||
break;
|
||||
} else if (script_extra[i].to_lower() == "latin") {
|
||||
script = "Latn";
|
||||
script_name = "Latn";
|
||||
break;
|
||||
} else if (script_extra[i].to_lower() == "devanagari") {
|
||||
script = "Deva";
|
||||
script_name = "Deva";
|
||||
break;
|
||||
} else if (variant_map.has(script_extra[i].to_lower()) && variant_map[script_extra[i].to_lower()] == lang) {
|
||||
variant = script_extra[i].to_lower();
|
||||
} else if (variant_map.has(script_extra[i].to_lower()) && variant_map[script_extra[i].to_lower()] == lang_name) {
|
||||
variant_name = script_extra[i].to_lower();
|
||||
}
|
||||
}
|
||||
|
||||
// Handles known non-ISO language names used e.g. on Windows.
|
||||
if (locale_rename_map.has(lang)) {
|
||||
lang = locale_rename_map[lang];
|
||||
if (locale_rename_map.has(lang_name)) {
|
||||
lang_name = locale_rename_map[lang_name];
|
||||
}
|
||||
|
||||
// Handle country renames.
|
||||
if (country_rename_map.has(country)) {
|
||||
country = country_rename_map[country];
|
||||
if (country_rename_map.has(country_name)) {
|
||||
country_name = country_rename_map[country_name];
|
||||
}
|
||||
|
||||
// Remove unsupported script codes.
|
||||
if (!script_map.has(script)) {
|
||||
script = "";
|
||||
if (!script_map.has(script_name)) {
|
||||
script_name = "";
|
||||
}
|
||||
|
||||
// Add script code base on language and country codes for some ambiguous cases.
|
||||
if (script.is_empty()) {
|
||||
if (script_name.is_empty()) {
|
||||
for (int i = 0; i < locale_script_info.size(); i++) {
|
||||
const LocaleScriptInfo &info = locale_script_info[i];
|
||||
if (info.name == lang) {
|
||||
if (country.is_empty() || info.supported_countries.has(country)) {
|
||||
script = info.script;
|
||||
if (info.name == lang_name) {
|
||||
if (country_name.is_empty() || info.supported_countries.has(country_name)) {
|
||||
script_name = info.script;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!script.is_empty() && country.is_empty()) {
|
||||
if (!script_name.is_empty() && country_name.is_empty()) {
|
||||
// Add conntry code based on script for some ambiguous cases.
|
||||
for (int i = 0; i < locale_script_info.size(); i++) {
|
||||
const LocaleScriptInfo &info = locale_script_info[i];
|
||||
if (info.name == lang && info.script == script) {
|
||||
country = info.default_country;
|
||||
if (info.name == lang_name && info.script == script_name) {
|
||||
country_name = info.default_country;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Combine results.
|
||||
String locale = lang;
|
||||
if (!script.is_empty()) {
|
||||
locale = locale + "_" + script;
|
||||
String out = lang_name;
|
||||
if (!script_name.is_empty()) {
|
||||
out = out + "_" + script_name;
|
||||
}
|
||||
if (!country.is_empty()) {
|
||||
locale = locale + "_" + country;
|
||||
if (!country_name.is_empty()) {
|
||||
out = out + "_" + country_name;
|
||||
}
|
||||
if (!variant.is_empty()) {
|
||||
locale = locale + "_" + variant;
|
||||
if (!variant_name.is_empty()) {
|
||||
out = out + "_" + variant_name;
|
||||
}
|
||||
return locale;
|
||||
return out;
|
||||
}
|
||||
|
||||
int TranslationServer::compare_locales(const String &p_locale_a, const String &p_locale_b) const {
|
||||
|
@ -420,31 +420,29 @@ int TranslationServer::compare_locales(const String &p_locale_a, const String &p
|
|||
}
|
||||
|
||||
String TranslationServer::get_locale_name(const String &p_locale) const {
|
||||
String locale = standardize_locale(p_locale);
|
||||
|
||||
String lang, script, country;
|
||||
Vector<String> locale_elements = locale.split("_");
|
||||
lang = locale_elements[0];
|
||||
String lang_name, script_name, country_name;
|
||||
Vector<String> locale_elements = standardize_locale(p_locale).split("_");
|
||||
lang_name = locale_elements[0];
|
||||
if (locale_elements.size() >= 2) {
|
||||
if (locale_elements[1].length() == 4 && is_ascii_upper_case(locale_elements[1][0]) && is_ascii_lower_case(locale_elements[1][1]) && is_ascii_lower_case(locale_elements[1][2]) && is_ascii_lower_case(locale_elements[1][3])) {
|
||||
script = locale_elements[1];
|
||||
script_name = locale_elements[1];
|
||||
}
|
||||
if (locale_elements[1].length() == 2 && is_ascii_upper_case(locale_elements[1][0]) && is_ascii_upper_case(locale_elements[1][1])) {
|
||||
country = locale_elements[1];
|
||||
country_name = locale_elements[1];
|
||||
}
|
||||
}
|
||||
if (locale_elements.size() >= 3) {
|
||||
if (locale_elements[2].length() == 2 && is_ascii_upper_case(locale_elements[2][0]) && is_ascii_upper_case(locale_elements[2][1])) {
|
||||
country = locale_elements[2];
|
||||
country_name = locale_elements[2];
|
||||
}
|
||||
}
|
||||
|
||||
String name = language_map[lang];
|
||||
if (!script.is_empty()) {
|
||||
name = name + " (" + script_map[script] + ")";
|
||||
String name = language_map[lang_name];
|
||||
if (!script_name.is_empty()) {
|
||||
name = name + " (" + script_map[script_name] + ")";
|
||||
}
|
||||
if (!country.is_empty()) {
|
||||
name = name + ", " + country_name_map[country];
|
||||
if (!country_name.is_empty()) {
|
||||
name = name + ", " + country_name_map[country_name];
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
@ -630,12 +628,12 @@ TranslationServer *TranslationServer::singleton = nullptr;
|
|||
|
||||
bool TranslationServer::_load_translations(const String &p_from) {
|
||||
if (ProjectSettings::get_singleton()->has_setting(p_from)) {
|
||||
Vector<String> translations = ProjectSettings::get_singleton()->get(p_from);
|
||||
const Vector<String> &translation_names = ProjectSettings::get_singleton()->get(p_from);
|
||||
|
||||
int tcount = translations.size();
|
||||
int tcount = translation_names.size();
|
||||
|
||||
if (tcount) {
|
||||
const String *r = translations.ptr();
|
||||
const String *r = translation_names.ptr();
|
||||
|
||||
for (int i = 0; i < tcount; i++) {
|
||||
Ref<Translation> tr = ResourceLoader::load(r[i]);
|
||||
|
@ -964,7 +962,6 @@ void TranslationServer::_bind_methods() {
|
|||
}
|
||||
|
||||
void TranslationServer::load_translations() {
|
||||
String locale = get_locale();
|
||||
_load_translations("internationalization/locale/translations"); //all
|
||||
_load_translations("internationalization/locale/translations_" + locale.substr(0, 2));
|
||||
|
||||
|
|
|
@ -402,33 +402,33 @@ Error Signal::emit(const Variant **p_arguments, int p_argcount) const {
|
|||
}
|
||||
|
||||
Error Signal::connect(const Callable &p_callable, uint32_t p_flags) {
|
||||
Object *object = get_object();
|
||||
ERR_FAIL_COND_V(!object, ERR_UNCONFIGURED);
|
||||
Object *obj = get_object();
|
||||
ERR_FAIL_COND_V(!obj, ERR_UNCONFIGURED);
|
||||
|
||||
return object->connect(name, p_callable, p_flags);
|
||||
return obj->connect(name, p_callable, p_flags);
|
||||
}
|
||||
|
||||
void Signal::disconnect(const Callable &p_callable) {
|
||||
Object *object = get_object();
|
||||
ERR_FAIL_COND(!object);
|
||||
object->disconnect(name, p_callable);
|
||||
Object *obj = get_object();
|
||||
ERR_FAIL_COND(!obj);
|
||||
obj->disconnect(name, p_callable);
|
||||
}
|
||||
|
||||
bool Signal::is_connected(const Callable &p_callable) const {
|
||||
Object *object = get_object();
|
||||
ERR_FAIL_COND_V(!object, false);
|
||||
Object *obj = get_object();
|
||||
ERR_FAIL_COND_V(!obj, false);
|
||||
|
||||
return object->is_connected(name, p_callable);
|
||||
return obj->is_connected(name, p_callable);
|
||||
}
|
||||
|
||||
Array Signal::get_connections() const {
|
||||
Object *object = get_object();
|
||||
if (!object) {
|
||||
Object *obj = get_object();
|
||||
if (!obj) {
|
||||
return Array();
|
||||
}
|
||||
|
||||
List<Object::Connection> connections;
|
||||
object->get_signal_connection_list(name, &connections);
|
||||
obj->get_signal_connection_list(name, &connections);
|
||||
|
||||
Array arr;
|
||||
for (const Object::Connection &E : connections) {
|
||||
|
|
|
@ -1101,8 +1101,6 @@ bool Variant::is_one() const {
|
|||
return !is_zero();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Variant::is_null() const {
|
||||
|
@ -3573,8 +3571,6 @@ bool Variant::hash_compare(const Variant &p_variant, int recursion_count) const
|
|||
evaluate(OP_EQUAL, *this, p_variant, r, v);
|
||||
return r;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Variant::is_ref_counted() const {
|
||||
|
|
|
@ -100,9 +100,9 @@ void RasterizerGLES3::begin_frame(double frame_step) {
|
|||
canvas->set_time(time_total);
|
||||
scene->set_time(time_total, frame_step);
|
||||
|
||||
GLES3::Utilities *utilities = GLES3::Utilities::get_singleton();
|
||||
utilities->info.render_final = utilities->info.render;
|
||||
utilities->info.render.reset();
|
||||
GLES3::Utilities *utils = GLES3::Utilities::get_singleton();
|
||||
utils->info.render_final = utils->info.render;
|
||||
utils->info.render.reset();
|
||||
|
||||
//scene->iteration();
|
||||
}
|
||||
|
@ -275,9 +275,7 @@ void RasterizerGLES3::prepare_for_blitting_render_targets() {
|
|||
}
|
||||
|
||||
void RasterizerGLES3::_blit_render_target_to_screen(RID p_render_target, DisplayServer::WindowID p_screen, const Rect2 &p_screen_rect) {
|
||||
GLES3::TextureStorage *texture_storage = GLES3::TextureStorage::get_singleton();
|
||||
|
||||
GLES3::RenderTarget *rt = texture_storage->get_render_target(p_render_target);
|
||||
GLES3::RenderTarget *rt = GLES3::TextureStorage::get_singleton()->get_render_target(p_render_target);
|
||||
ERR_FAIL_COND(!rt);
|
||||
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, rt->fbo);
|
||||
|
|
|
@ -7262,12 +7262,12 @@ Error RenderingDeviceVulkan::_draw_list_render_pass_begin(Framebuffer *framebuff
|
|||
return OK;
|
||||
}
|
||||
|
||||
void RenderingDeviceVulkan::_draw_list_insert_clear_region(DrawList *draw_list, Framebuffer *framebuffer, Point2i viewport_offset, Point2i viewport_size, bool p_clear_color, const Vector<Color> &p_clear_colors, bool p_clear_depth, float p_depth, uint32_t p_stencil) {
|
||||
void RenderingDeviceVulkan::_draw_list_insert_clear_region(DrawList *p_draw_list, Framebuffer *p_framebuffer, Point2i p_viewport_offset, Point2i p_viewport_size, bool p_clear_color, const Vector<Color> &p_clear_colors, bool p_clear_depth, float p_depth, uint32_t p_stencil) {
|
||||
Vector<VkClearAttachment> clear_attachments;
|
||||
int color_index = 0;
|
||||
int texture_index = 0;
|
||||
for (int i = 0; i < framebuffer->texture_ids.size(); i++) {
|
||||
Texture *texture = texture_owner.get_or_null(framebuffer->texture_ids[i]);
|
||||
for (int i = 0; i < p_framebuffer->texture_ids.size(); i++) {
|
||||
Texture *texture = texture_owner.get_or_null(p_framebuffer->texture_ids[i]);
|
||||
|
||||
if (!texture) {
|
||||
texture_index++;
|
||||
|
@ -7300,12 +7300,12 @@ void RenderingDeviceVulkan::_draw_list_insert_clear_region(DrawList *draw_list,
|
|||
VkClearRect cr;
|
||||
cr.baseArrayLayer = 0;
|
||||
cr.layerCount = 1;
|
||||
cr.rect.offset.x = viewport_offset.x;
|
||||
cr.rect.offset.y = viewport_offset.y;
|
||||
cr.rect.extent.width = viewport_size.width;
|
||||
cr.rect.extent.height = viewport_size.height;
|
||||
cr.rect.offset.x = p_viewport_offset.x;
|
||||
cr.rect.offset.y = p_viewport_offset.y;
|
||||
cr.rect.extent.width = p_viewport_size.width;
|
||||
cr.rect.extent.height = p_viewport_size.height;
|
||||
|
||||
vkCmdClearAttachments(draw_list->command_buffer, clear_attachments.size(), clear_attachments.ptr(), 1, &cr);
|
||||
vkCmdClearAttachments(p_draw_list->command_buffer, clear_attachments.size(), clear_attachments.ptr(), 1, &cr);
|
||||
}
|
||||
|
||||
RenderingDevice::DrawListID RenderingDeviceVulkan::draw_list_begin(RID p_framebuffer, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, const Vector<Color> &p_clear_color_values, float p_clear_depth, uint32_t p_clear_stencil, const Rect2 &p_region, const Vector<RID> &p_storage_textures) {
|
||||
|
|
|
@ -905,7 +905,7 @@ class RenderingDeviceVulkan : public RenderingDevice {
|
|||
bool draw_list_unbind_color_textures = false;
|
||||
bool draw_list_unbind_depth_textures = false;
|
||||
|
||||
void _draw_list_insert_clear_region(DrawList *draw_list, Framebuffer *framebuffer, Point2i viewport_offset, Point2i viewport_size, bool p_clear_color, const Vector<Color> &p_clear_colors, bool p_clear_depth, float p_depth, uint32_t p_stencil);
|
||||
void _draw_list_insert_clear_region(DrawList *p_draw_list, Framebuffer *p_framebuffer, Point2i p_viewport_offset, Point2i p_viewport_size, bool p_clear_color, const Vector<Color> &p_clear_colors, bool p_clear_depth, float p_depth, uint32_t p_stencil);
|
||||
Error _draw_list_setup_framebuffer(Framebuffer *p_framebuffer, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, VkFramebuffer *r_framebuffer, VkRenderPass *r_render_pass, uint32_t *r_subpass_count);
|
||||
Error _draw_list_render_pass_begin(Framebuffer *framebuffer, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, const Vector<Color> &p_clear_colors, float p_clear_depth, uint32_t p_clear_stencil, Point2i viewport_offset, Point2i viewport_size, VkFramebuffer vkframebuffer, VkRenderPass render_pass, VkCommandBuffer command_buffer, VkSubpassContents subpass_contents, const Vector<RID> &p_storage_textures);
|
||||
_FORCE_INLINE_ DrawList *_get_draw_list_ptr(DrawListID p_id);
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
|
||||
VulkanHooks *VulkanContext::vulkan_hooks = nullptr;
|
||||
|
||||
VkResult VulkanContext::vkCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass) {
|
||||
VkResult VulkanContext::vkCreateRenderPass2KHR(VkDevice p_device, const VkRenderPassCreateInfo2 *p_create_info, const VkAllocationCallbacks *p_allocator, VkRenderPass *p_render_pass) {
|
||||
if (fpCreateRenderPass2KHR == nullptr) {
|
||||
fpCreateRenderPass2KHR = (PFN_vkCreateRenderPass2KHR)vkGetInstanceProcAddr(inst, "vkCreateRenderPass2KHR");
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ VkResult VulkanContext::vkCreateRenderPass2KHR(VkDevice device, const VkRenderPa
|
|||
if (fpCreateRenderPass2KHR == nullptr) {
|
||||
return VK_ERROR_EXTENSION_NOT_PRESENT;
|
||||
} else {
|
||||
return (fpCreateRenderPass2KHR)(device, pCreateInfo, pAllocator, pRenderPass);
|
||||
return (fpCreateRenderPass2KHR)(p_device, p_create_info, p_allocator, p_render_pass);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -270,7 +270,7 @@ protected:
|
|||
|
||||
public:
|
||||
// Extension calls.
|
||||
VkResult vkCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass);
|
||||
VkResult vkCreateRenderPass2KHR(VkDevice p_device, const VkRenderPassCreateInfo2 *p_create_info, const VkAllocationCallbacks *p_allocator, VkRenderPass *p_render_pass);
|
||||
|
||||
uint32_t get_vulkan_major() const { return vulkan_major; };
|
||||
uint32_t get_vulkan_minor() const { return vulkan_minor; };
|
||||
|
|
|
@ -200,9 +200,9 @@ String DirAccessWindows::get_current_dir(bool p_include_drive) const {
|
|||
return current_dir;
|
||||
} else {
|
||||
if (_get_root_string().is_empty()) {
|
||||
int p = current_dir.find(":");
|
||||
if (p != -1) {
|
||||
return current_dir.substr(p + 1);
|
||||
int pos = current_dir.find(":");
|
||||
if (pos != -1) {
|
||||
return current_dir.substr(pos + 1);
|
||||
}
|
||||
}
|
||||
return current_dir;
|
||||
|
|
|
@ -95,8 +95,8 @@ Error FileAccessWindows::open_internal(const String &p_path, int p_mode_flags) {
|
|||
// platforms).
|
||||
if (p_mode_flags == READ) {
|
||||
WIN32_FIND_DATAW d;
|
||||
HANDLE f = FindFirstFileW((LPCWSTR)(path.utf16().get_data()), &d);
|
||||
if (f != INVALID_HANDLE_VALUE) {
|
||||
HANDLE fnd = FindFirstFileW((LPCWSTR)(path.utf16().get_data()), &d);
|
||||
if (fnd != INVALID_HANDLE_VALUE) {
|
||||
String fname = String::utf16((const char16_t *)(d.cFileName));
|
||||
if (!fname.is_empty()) {
|
||||
String base_file = path.get_file();
|
||||
|
@ -104,7 +104,7 @@ Error FileAccessWindows::open_internal(const String &p_path, int p_mode_flags) {
|
|||
WARN_PRINT("Case mismatch opening requested file '" + base_file + "', stored as '" + fname + "' in the filesystem. This file will not open when exported to other case-sensitive platforms.");
|
||||
}
|
||||
}
|
||||
FindClose(f);
|
||||
FindClose(fnd);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -338,14 +338,14 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
|
|||
Ref<Texture2D> unlock = get_theme_icon(SNAME("Unlock"), SNAME("EditorIcons"));
|
||||
float lock_hpos = remove_hpos - hsep - lock->get_width();
|
||||
|
||||
Ref<Texture2D> visible = get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons"));
|
||||
Ref<Texture2D> hidden = get_theme_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons"));
|
||||
float visibility_hpos = lock_hpos - hsep - visible->get_width();
|
||||
Ref<Texture2D> visibility_visible = get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons"));
|
||||
Ref<Texture2D> visibility_hidden = get_theme_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons"));
|
||||
float visibility_hpos = lock_hpos - hsep - visibility_visible->get_width();
|
||||
|
||||
Ref<Texture2D> solo = get_theme_icon(SNAME("AudioBusSolo"), SNAME("EditorIcons"));
|
||||
float solo_hpos = visibility_hpos - hsep - solo->get_width();
|
||||
|
||||
float buttons_width = remove->get_width() + lock->get_width() + visible->get_width() + solo->get_width() + hsep * 3;
|
||||
float buttons_width = remove->get_width() + lock->get_width() + visibility_visible->get_width() + solo->get_width() + hsep * 3;
|
||||
|
||||
for (int i = 0; i < tracks.size(); ++i) {
|
||||
// RELATED TRACKS TITLES
|
||||
|
@ -418,11 +418,11 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
|
|||
draw_texture(unlock, lock_rect.position);
|
||||
}
|
||||
|
||||
Rect2 visible_rect = Rect2(visibility_hpos, icon_start_height - visible->get_height() / 2.0, visible->get_width(), visible->get_height());
|
||||
Rect2 visible_rect = Rect2(visibility_hpos, icon_start_height - visibility_visible->get_height() / 2.0, visibility_visible->get_width(), visibility_visible->get_height());
|
||||
if (hidden_tracks.has(current_track)) {
|
||||
draw_texture(hidden, visible_rect.position);
|
||||
draw_texture(visibility_hidden, visible_rect.position);
|
||||
} else {
|
||||
draw_texture(visible, visible_rect.position);
|
||||
draw_texture(visibility_visible, visible_rect.position);
|
||||
}
|
||||
|
||||
Rect2 solo_rect = Rect2(solo_hpos, icon_start_height - solo->get_height() / 2.0, solo->get_width(), solo->get_height());
|
||||
|
|
|
@ -2029,14 +2029,14 @@ void AnimationTrackEdit::_notification(int p_what) {
|
|||
draw_texture(check, check_rect.position);
|
||||
ofs += check->get_width() + hsep;
|
||||
|
||||
Ref<Texture2D> type_icon = _get_key_type_icon();
|
||||
draw_texture(type_icon, Point2(ofs, int(get_size().height - type_icon->get_height()) / 2));
|
||||
ofs += type_icon->get_width() + hsep;
|
||||
Ref<Texture2D> key_type_icon = _get_key_type_icon();
|
||||
draw_texture(key_type_icon, Point2(ofs, int(get_size().height - key_type_icon->get_height()) / 2));
|
||||
ofs += key_type_icon->get_width() + hsep;
|
||||
|
||||
NodePath path = animation->track_get_path(track);
|
||||
NodePath anim_path = animation->track_get_path(track);
|
||||
Node *node = nullptr;
|
||||
if (root && root->has_node(path)) {
|
||||
node = root->get_node(path);
|
||||
if (root && root->has_node(anim_path)) {
|
||||
node = root->get_node(anim_path);
|
||||
}
|
||||
|
||||
String text;
|
||||
|
@ -2053,7 +2053,7 @@ void AnimationTrackEdit::_notification(int p_what) {
|
|||
} else if (animation->track_get_type(track) == Animation::TYPE_ANIMATION) {
|
||||
text = TTR("Anim Clips:");
|
||||
} else {
|
||||
text += path.get_concatenated_subnames();
|
||||
text += anim_path.get_concatenated_subnames();
|
||||
}
|
||||
text_color.a *= 0.7;
|
||||
} else if (node) {
|
||||
|
@ -2062,14 +2062,14 @@ void AnimationTrackEdit::_notification(int p_what) {
|
|||
draw_texture(icon, Point2(ofs, int(get_size().height - icon->get_height()) / 2));
|
||||
icon_cache = icon;
|
||||
|
||||
text = String() + node->get_name() + ":" + path.get_concatenated_subnames();
|
||||
text = String() + node->get_name() + ":" + anim_path.get_concatenated_subnames();
|
||||
ofs += hsep;
|
||||
ofs += icon->get_width();
|
||||
|
||||
} else {
|
||||
icon_cache = type_icon;
|
||||
icon_cache = key_type_icon;
|
||||
|
||||
text = path;
|
||||
text = anim_path;
|
||||
}
|
||||
|
||||
path_cache = text;
|
||||
|
@ -2853,9 +2853,9 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
|
|||
if (ape) {
|
||||
AnimationPlayer *ap = ape->get_player();
|
||||
if (ap) {
|
||||
NodePath path = animation->track_get_path(track);
|
||||
Node *nd = ap->get_node(ap->get_root())->get_node(NodePath(path.get_concatenated_names()));
|
||||
StringName prop = path.get_concatenated_subnames();
|
||||
NodePath npath = animation->track_get_path(track);
|
||||
Node *nd = ap->get_node(ap->get_root())->get_node(NodePath(npath.get_concatenated_names()));
|
||||
StringName prop = npath.get_concatenated_subnames();
|
||||
PropertyInfo prop_info;
|
||||
ClassDB::get_property_info(nd->get_class(), prop, &prop_info);
|
||||
bool is_angle = prop_info.type == Variant::FLOAT && prop_info.hint_string.find("radians") != -1;
|
||||
|
@ -4463,24 +4463,24 @@ void AnimationTrackEditor::_update_tracks() {
|
|||
return;
|
||||
}
|
||||
|
||||
bool read_only = false;
|
||||
bool file_read_only = false;
|
||||
if (!animation->get_path().is_resource_file()) {
|
||||
int srpos = animation->get_path().find("::");
|
||||
if (srpos != -1) {
|
||||
String base = animation->get_path().substr(0, srpos);
|
||||
if (ResourceLoader::get_resource_type(base) == "PackedScene") {
|
||||
if (!get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->get_scene_file_path() != base) {
|
||||
read_only = true;
|
||||
file_read_only = true;
|
||||
}
|
||||
} else {
|
||||
if (FileAccess::exists(base + ".import")) {
|
||||
read_only = true;
|
||||
file_read_only = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (FileAccess::exists(animation->get_path() + ".import")) {
|
||||
read_only = true;
|
||||
file_read_only = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4612,7 +4612,7 @@ void AnimationTrackEditor::_update_tracks() {
|
|||
track_edit->set_undo_redo(undo_redo);
|
||||
track_edit->set_timeline(timeline);
|
||||
track_edit->set_root(root);
|
||||
track_edit->set_animation_and_track(animation, i, read_only);
|
||||
track_edit->set_animation_and_track(animation, i, file_read_only);
|
||||
track_edit->set_play_position(timeline->get_play_position());
|
||||
track_edit->set_editor(this);
|
||||
|
||||
|
@ -5072,10 +5072,8 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) {
|
|||
return;
|
||||
}
|
||||
|
||||
Vector3 scale = base->get_scale();
|
||||
|
||||
undo_redo->create_action(TTR("Add Scale Key"));
|
||||
undo_redo->add_do_method(animation.ptr(), "scale_track_insert_key", p_track, p_ofs, scale);
|
||||
undo_redo->add_do_method(animation.ptr(), "scale_track_insert_key", p_track, p_ofs, base->get_scale());
|
||||
undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", p_track, p_ofs);
|
||||
undo_redo->commit_action();
|
||||
|
||||
|
@ -5671,18 +5669,18 @@ void AnimationTrackEditor::goto_prev_step(bool p_from_mouse_event) {
|
|||
if (animation.is_null()) {
|
||||
return;
|
||||
}
|
||||
float step = animation->get_step();
|
||||
if (step == 0) {
|
||||
step = 1;
|
||||
float anim_step = animation->get_step();
|
||||
if (anim_step == 0) {
|
||||
anim_step = 1;
|
||||
}
|
||||
if (p_from_mouse_event && Input::get_singleton()->is_key_pressed(Key::SHIFT)) {
|
||||
// Use more precise snapping when holding Shift.
|
||||
// This is used when scrobbling the timeline using Alt + Mouse wheel.
|
||||
step *= 0.25;
|
||||
anim_step *= 0.25;
|
||||
}
|
||||
|
||||
float pos = timeline->get_play_position();
|
||||
pos = Math::snapped(pos - step, step);
|
||||
pos = Math::snapped(pos - anim_step, anim_step);
|
||||
if (pos < 0) {
|
||||
pos = 0;
|
||||
}
|
||||
|
@ -5694,21 +5692,21 @@ void AnimationTrackEditor::goto_next_step(bool p_from_mouse_event, bool p_timeli
|
|||
if (animation.is_null()) {
|
||||
return;
|
||||
}
|
||||
float step = animation->get_step();
|
||||
if (step == 0) {
|
||||
step = 1;
|
||||
float anim_step = animation->get_step();
|
||||
if (anim_step == 0) {
|
||||
anim_step = 1;
|
||||
}
|
||||
if (p_from_mouse_event && Input::get_singleton()->is_key_pressed(Key::SHIFT)) {
|
||||
// Use more precise snapping when holding Shift.
|
||||
// This is used when scrobbling the timeline using Alt + Mouse wheel.
|
||||
// Do not use precise snapping when using the menu action or keyboard shortcut,
|
||||
// as the default keyboard shortcut requires pressing Shift.
|
||||
step *= 0.25;
|
||||
anim_step *= 0.25;
|
||||
}
|
||||
|
||||
float pos = timeline->get_play_position();
|
||||
|
||||
pos = Math::snapped(pos + step, step);
|
||||
pos = Math::snapped(pos + anim_step, anim_step);
|
||||
if (pos > animation->get_length()) {
|
||||
pos = animation->get_length();
|
||||
}
|
||||
|
@ -5801,9 +5799,9 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
|
|||
} break;
|
||||
case EDIT_COPY_TRACKS_CONFIRM: {
|
||||
track_clipboard.clear();
|
||||
TreeItem *root = track_copy_select->get_root();
|
||||
if (root) {
|
||||
TreeItem *it = root->get_first_child();
|
||||
TreeItem *tree_root = track_copy_select->get_root();
|
||||
if (tree_root) {
|
||||
TreeItem *it = tree_root->get_first_child();
|
||||
while (it) {
|
||||
Dictionary md = it->get_metadata(0);
|
||||
int idx = md["track_idx"];
|
||||
|
@ -6037,7 +6035,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
|
|||
bool is_using_angle = animation->track_get_interpolation_type(track) == Animation::INTERPOLATION_LINEAR_ANGLE || animation->track_get_interpolation_type(track) == Animation::INTERPOLATION_CUBIC_ANGLE;
|
||||
|
||||
// Make insert queue.
|
||||
Vector<Pair<real_t, Variant>> insert_queue;
|
||||
Vector<Pair<real_t, Variant>> insert_queue_new;
|
||||
for (int i = 0; i < len; i++) {
|
||||
// Check neighboring keys.
|
||||
if (keys[i] + 1 == keys[i + 1]) {
|
||||
|
@ -6058,15 +6056,15 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
|
|||
Pair<real_t, Variant> keydata;
|
||||
keydata.first = from_t + delta_t;
|
||||
keydata.second = Tween::interpolate_variant(from_v, delta_v, delta_t, duration, transition_type, ease_type);
|
||||
insert_queue.append(keydata);
|
||||
insert_queue_new.append(keydata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Do insertion.
|
||||
for (int i = 0; i < insert_queue.size(); i++) {
|
||||
undo_redo->add_do_method(animation.ptr(), "track_insert_key", track, insert_queue[i].first, insert_queue[i].second);
|
||||
undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", track, insert_queue[i].first);
|
||||
for (int i = 0; i < insert_queue_new.size(); i++) {
|
||||
undo_redo->add_do_method(animation.ptr(), "track_insert_key", track, insert_queue_new[i].first, insert_queue_new[i].second);
|
||||
undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", track, insert_queue_new[i].first);
|
||||
}
|
||||
|
||||
++E;
|
||||
|
@ -6213,7 +6211,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
|
|||
bool is_using_angle = it == Animation::INTERPOLATION_LINEAR_ANGLE || it == Animation::INTERPOLATION_CUBIC_ANGLE;
|
||||
|
||||
// Make insert queue.
|
||||
Vector<Pair<real_t, Variant>> insert_queue;
|
||||
Vector<Pair<real_t, Variant>> insert_queue_new;
|
||||
|
||||
switch (type) {
|
||||
case Animation::TYPE_POSITION_3D: {
|
||||
|
@ -6223,7 +6221,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
|
|||
Vector3 v;
|
||||
animation->position_track_interpolate(i, delta_t, &v);
|
||||
keydata.second = v;
|
||||
insert_queue.append(keydata);
|
||||
insert_queue_new.append(keydata);
|
||||
}
|
||||
} break;
|
||||
case Animation::TYPE_ROTATION_3D: {
|
||||
|
@ -6233,7 +6231,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
|
|||
Quaternion v;
|
||||
animation->rotation_track_interpolate(i, delta_t, &v);
|
||||
keydata.second = v;
|
||||
insert_queue.append(keydata);
|
||||
insert_queue_new.append(keydata);
|
||||
}
|
||||
} break;
|
||||
case Animation::TYPE_SCALE_3D: {
|
||||
|
@ -6243,7 +6241,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
|
|||
Vector3 v;
|
||||
animation->scale_track_interpolate(i, delta_t, &v);
|
||||
keydata.second = v;
|
||||
insert_queue.append(keydata);
|
||||
insert_queue_new.append(keydata);
|
||||
}
|
||||
} break;
|
||||
case Animation::TYPE_BLEND_SHAPE: {
|
||||
|
@ -6253,7 +6251,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
|
|||
float v;
|
||||
animation->blend_shape_track_interpolate(i, delta_t, &v);
|
||||
keydata.second = v;
|
||||
insert_queue.append(keydata);
|
||||
insert_queue_new.append(keydata);
|
||||
}
|
||||
} break;
|
||||
case Animation::TYPE_VALUE: {
|
||||
|
@ -6261,7 +6259,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
|
|||
Pair<real_t, Variant> keydata;
|
||||
keydata.first = delta_t;
|
||||
keydata.second = animation->value_track_interpolate(i, delta_t);
|
||||
insert_queue.append(keydata);
|
||||
insert_queue_new.append(keydata);
|
||||
}
|
||||
} break;
|
||||
default: {
|
||||
|
@ -6276,9 +6274,9 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
|
|||
|
||||
// Insert keys.
|
||||
undo_redo->add_do_method(animation.ptr(), "track_set_interpolation_type", i, is_using_angle ? Animation::INTERPOLATION_LINEAR_ANGLE : Animation::INTERPOLATION_LINEAR);
|
||||
for (int j = insert_queue.size() - 1; j >= 0; j--) {
|
||||
undo_redo->add_do_method(animation.ptr(), "track_insert_key", i, insert_queue[j].first, insert_queue[j].second);
|
||||
undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", i, insert_queue[j].first);
|
||||
for (int j = insert_queue_new.size() - 1; j >= 0; j--) {
|
||||
undo_redo->add_do_method(animation.ptr(), "track_insert_key", i, insert_queue_new[j].first, insert_queue_new[j].second);
|
||||
undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", i, insert_queue_new[j].first);
|
||||
}
|
||||
|
||||
// Undo methods.
|
||||
|
@ -6925,19 +6923,19 @@ AnimationTrackEditor::AnimationTrackEditor() {
|
|||
track_copy_dialog->set_title(TTR("Select Tracks to Copy"));
|
||||
track_copy_dialog->set_ok_button_text(TTR("Copy"));
|
||||
|
||||
VBoxContainer *track_vbox = memnew(VBoxContainer);
|
||||
track_copy_dialog->add_child(track_vbox);
|
||||
VBoxContainer *track_copy_vbox = memnew(VBoxContainer);
|
||||
track_copy_dialog->add_child(track_copy_vbox);
|
||||
|
||||
Button *select_all_button = memnew(Button);
|
||||
select_all_button->set_text(TTR("Select All/None"));
|
||||
select_all_button->connect("pressed", callable_mp(this, &AnimationTrackEditor::_select_all_tracks_for_copy));
|
||||
track_vbox->add_child(select_all_button);
|
||||
track_copy_vbox->add_child(select_all_button);
|
||||
|
||||
track_copy_select = memnew(Tree);
|
||||
track_copy_select->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
track_copy_select->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
track_copy_select->set_hide_root(true);
|
||||
track_vbox->add_child(track_copy_select);
|
||||
track_copy_vbox->add_child(track_copy_select);
|
||||
track_copy_dialog->connect("confirmed", callable_mp(this, &AnimationTrackEditor::_edit_menu_pressed).bind(EDIT_COPY_TRACKS_CONFIRM));
|
||||
}
|
||||
|
||||
|
|
|
@ -412,9 +412,9 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se
|
|||
sf->get_animation_list(&animations);
|
||||
|
||||
int frame = get_animation()->track_get_key_value(get_track(), p_index);
|
||||
String animation;
|
||||
String animation_name;
|
||||
if (animations.size() == 1) {
|
||||
animation = animations.front()->get();
|
||||
animation_name = animations.front()->get();
|
||||
} else {
|
||||
// Go through other track to find if animation is set
|
||||
String animation_path = get_animation()->track_get_path(get_track());
|
||||
|
@ -422,10 +422,10 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se
|
|||
int animation_track = get_animation()->find_track(animation_path, get_animation()->track_get_type(get_track()));
|
||||
float track_time = get_animation()->track_get_key_time(get_track(), p_index);
|
||||
int animaiton_index = get_animation()->track_find_key(animation_track, track_time);
|
||||
animation = get_animation()->track_get_key_value(animation_track, animaiton_index);
|
||||
animation_name = get_animation()->track_get_key_value(animation_track, animaiton_index);
|
||||
}
|
||||
|
||||
Ref<Texture2D> texture = sf->get_frame(animation, frame);
|
||||
Ref<Texture2D> texture = sf->get_frame(animation_name, frame);
|
||||
if (!texture.is_valid()) {
|
||||
return AnimationTrackEdit::get_key_rect(p_index, p_pixels_sec);
|
||||
}
|
||||
|
@ -504,9 +504,9 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in
|
|||
sf->get_animation_list(&animations);
|
||||
|
||||
int frame = get_animation()->track_get_key_value(get_track(), p_index);
|
||||
String animation;
|
||||
String animation_name;
|
||||
if (animations.size() == 1) {
|
||||
animation = animations.front()->get();
|
||||
animation_name = animations.front()->get();
|
||||
} else {
|
||||
// Go through other track to find if animation is set
|
||||
String animation_path = get_animation()->track_get_path(get_track());
|
||||
|
@ -514,10 +514,10 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in
|
|||
int animation_track = get_animation()->find_track(animation_path, get_animation()->track_get_type(get_track()));
|
||||
float track_time = get_animation()->track_get_key_time(get_track(), p_index);
|
||||
int animaiton_index = get_animation()->track_find_key(animation_track, track_time);
|
||||
animation = get_animation()->track_get_key_value(animation_track, animaiton_index);
|
||||
animation_name = get_animation()->track_get_key_value(animation_track, animaiton_index);
|
||||
}
|
||||
|
||||
texture = sf->get_frame(animation, frame);
|
||||
texture = sf->get_frame(animation_name, frame);
|
||||
if (!texture.is_valid()) {
|
||||
AnimationTrackEdit::draw_key(p_index, p_pixels_sec, p_x, p_selected, p_clip_left, p_clip_right);
|
||||
return;
|
||||
|
@ -670,15 +670,15 @@ void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_
|
|||
Vector<Vector2> lines;
|
||||
Vector<Color> colorv;
|
||||
{
|
||||
Ref<Animation> animation = ap->get_animation(anim);
|
||||
Ref<Animation> ap_anim = ap->get_animation(anim);
|
||||
|
||||
for (int i = 0; i < animation->get_track_count(); i++) {
|
||||
float h = (rect.size.height - 2) / animation->get_track_count();
|
||||
for (int i = 0; i < ap_anim->get_track_count(); i++) {
|
||||
float h = (rect.size.height - 2) / ap_anim->get_track_count();
|
||||
|
||||
int y = 2 + h * i + h / 2;
|
||||
|
||||
for (int j = 0; j < animation->track_get_key_count(i); j++) {
|
||||
float ofs = animation->track_get_key_time(i, j);
|
||||
for (int j = 0; j < ap_anim->track_get_key_count(i); j++) {
|
||||
float ofs = ap_anim->track_get_key_time(i, j);
|
||||
int x = p_x + ofs * p_pixels_sec + 2;
|
||||
|
||||
if (x < from_x || x >= (to_x - 4)) {
|
||||
|
@ -1244,15 +1244,15 @@ void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec,
|
|||
Vector<Vector2> lines;
|
||||
Vector<Color> colorv;
|
||||
{
|
||||
Ref<Animation> animation = ap->get_animation(anim);
|
||||
Ref<Animation> ap_anim = ap->get_animation(anim);
|
||||
|
||||
for (int i = 0; i < animation->get_track_count(); i++) {
|
||||
float h = (rect.size.height - 2) / animation->get_track_count();
|
||||
for (int i = 0; i < ap_anim->get_track_count(); i++) {
|
||||
float h = (rect.size.height - 2) / ap_anim->get_track_count();
|
||||
|
||||
int y = 2 + h * i + h / 2;
|
||||
|
||||
for (int j = 0; j < animation->track_get_key_count(i); j++) {
|
||||
float ofs = animation->track_get_key_time(i, j);
|
||||
for (int j = 0; j < ap_anim->track_get_key_count(i); j++) {
|
||||
float ofs = ap_anim->track_get_key_time(i, j);
|
||||
int x = p_x + ofs * p_pixels_sec + 2;
|
||||
|
||||
if (x < from_x || x >= (to_x - 4)) {
|
||||
|
|
|
@ -184,7 +184,7 @@ void FindReplaceBar::_replace() {
|
|||
selection_end = Point2i(text_editor->get_selection_to_line(0), text_editor->get_selection_to_column(0));
|
||||
}
|
||||
|
||||
String replace_text = get_replace_text();
|
||||
String repl_text = get_replace_text();
|
||||
int search_text_len = get_search_text().length();
|
||||
|
||||
text_editor->begin_complex_operation();
|
||||
|
@ -201,13 +201,13 @@ void FindReplaceBar::_replace() {
|
|||
Point2i match_from(result_line, result_col);
|
||||
Point2i match_to(result_line, result_col + search_text_len);
|
||||
if (!(match_from < selection_begin || match_to > selection_end)) {
|
||||
text_editor->insert_text_at_caret(replace_text, 0);
|
||||
text_editor->insert_text_at_caret(repl_text, 0);
|
||||
if (match_to.x == selection_end.x) { // Adjust selection bounds if necessary
|
||||
selection_end.y += replace_text.length() - search_text_len;
|
||||
selection_end.y += repl_text.length() - search_text_len;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
text_editor->insert_text_at_caret(replace_text, 0);
|
||||
text_editor->insert_text_at_caret(repl_text, 0);
|
||||
}
|
||||
}
|
||||
text_editor->end_complex_operation();
|
||||
|
@ -241,7 +241,7 @@ void FindReplaceBar::_replace_all() {
|
|||
text_editor->set_caret_line(0, false, true, 0, 0);
|
||||
text_editor->set_caret_column(0, true, 0);
|
||||
|
||||
String replace_text = get_replace_text();
|
||||
String repl_text = get_replace_text();
|
||||
int search_text_len = get_search_text().length();
|
||||
|
||||
int rc = 0;
|
||||
|
@ -264,7 +264,7 @@ void FindReplaceBar::_replace_all() {
|
|||
break; // Done.
|
||||
}
|
||||
|
||||
prev_match = Point2i(result_line, result_col + replace_text.length());
|
||||
prev_match = Point2i(result_line, result_col + repl_text.length());
|
||||
|
||||
text_editor->unfold_line(result_line);
|
||||
text_editor->select(result_line, result_col, result_line, match_to.y, 0);
|
||||
|
@ -275,14 +275,14 @@ void FindReplaceBar::_replace_all() {
|
|||
}
|
||||
|
||||
// Replace but adjust selection bounds.
|
||||
text_editor->insert_text_at_caret(replace_text, 0);
|
||||
text_editor->insert_text_at_caret(repl_text, 0);
|
||||
if (match_to.x == selection_end.x) {
|
||||
selection_end.y += replace_text.length() - search_text_len;
|
||||
selection_end.y += repl_text.length() - search_text_len;
|
||||
}
|
||||
|
||||
} else {
|
||||
// Just replace.
|
||||
text_editor->insert_text_at_caret(replace_text, 0);
|
||||
text_editor->insert_text_at_caret(repl_text, 0);
|
||||
}
|
||||
|
||||
rc++;
|
||||
|
|
|
@ -184,8 +184,8 @@ void ConnectDialog::_add_bind() {
|
|||
Variant::Type type = (Variant::Type)type_list->get_item_id(type_list->get_selected());
|
||||
|
||||
Variant value;
|
||||
Callable::CallError error;
|
||||
Variant::construct(type, value, nullptr, 0, error);
|
||||
Callable::CallError err;
|
||||
Variant::construct(type, value, nullptr, 0, err);
|
||||
|
||||
cdbinds->params.push_back(value);
|
||||
cdbinds->notify_changed();
|
||||
|
@ -583,19 +583,19 @@ void ConnectionsDock::_make_or_edit_connection() {
|
|||
// Conditions to add function: must have a script and must not have the method already
|
||||
// (in the class, the script itself, or inherited).
|
||||
bool add_script_function = false;
|
||||
Ref<Script> script = target->get_script();
|
||||
if (!target->get_script().is_null() && !ClassDB::has_method(target->get_class(), cd.method)) {
|
||||
Ref<Script> scr = target->get_script();
|
||||
if (!scr.is_null() && !ClassDB::has_method(target->get_class(), cd.method)) {
|
||||
// There is a chance that the method is inherited from another script.
|
||||
bool found_inherited_function = false;
|
||||
Ref<Script> inherited_script = script->get_base_script();
|
||||
while (!inherited_script.is_null()) {
|
||||
int line = inherited_script->get_language()->find_function(cd.method, inherited_script->get_source_code());
|
||||
Ref<Script> inherited_scr = scr->get_base_script();
|
||||
while (!inherited_scr.is_null()) {
|
||||
int line = inherited_scr->get_language()->find_function(cd.method, inherited_scr->get_source_code());
|
||||
if (line != -1) {
|
||||
found_inherited_function = true;
|
||||
break;
|
||||
}
|
||||
|
||||
inherited_script = inherited_script->get_base_script();
|
||||
inherited_scr = inherited_scr->get_base_script();
|
||||
}
|
||||
|
||||
add_script_function = !found_inherited_function;
|
||||
|
@ -816,13 +816,13 @@ void ConnectionsDock::_go_to_script(TreeItem &p_item) {
|
|||
return;
|
||||
}
|
||||
|
||||
Ref<Script> script = cd.target->get_script();
|
||||
Ref<Script> scr = cd.target->get_script();
|
||||
|
||||
if (script.is_null()) {
|
||||
if (scr.is_null()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (script.is_valid() && ScriptEditor::get_singleton()->script_goto_method(script, cd.method)) {
|
||||
if (scr.is_valid() && ScriptEditor::get_singleton()->script_goto_method(scr, cd.method)) {
|
||||
EditorNode::get_singleton()->editor_select(EditorNode::EDITOR_SCRIPT);
|
||||
}
|
||||
}
|
||||
|
@ -1077,10 +1077,10 @@ void ConnectionsDock::update_tree() {
|
|||
}
|
||||
|
||||
// List existing connections.
|
||||
List<Object::Connection> connections;
|
||||
selected_node->get_signal_connection_list(signal_name, &connections);
|
||||
List<Object::Connection> existing_connections;
|
||||
selected_node->get_signal_connection_list(signal_name, &existing_connections);
|
||||
|
||||
for (const Object::Connection &F : connections) {
|
||||
for (const Object::Connection &F : existing_connections) {
|
||||
Connection connection = F;
|
||||
if (!(connection.flags & CONNECT_PERSIST)) {
|
||||
continue;
|
||||
|
|
|
@ -213,18 +213,18 @@ void CreateDialog::_add_type(const String &p_type, const TypeCategory p_type_cat
|
|||
inherited_type = TypeCategory::CPP_TYPE;
|
||||
} else if (p_type_category == TypeCategory::PATH_TYPE) {
|
||||
ERR_FAIL_COND(!ResourceLoader::exists(p_type, "Script"));
|
||||
Ref<Script> script = ResourceLoader::load(p_type, "Script");
|
||||
ERR_FAIL_COND(script.is_null());
|
||||
Ref<Script> scr = ResourceLoader::load(p_type, "Script");
|
||||
ERR_FAIL_COND(scr.is_null());
|
||||
|
||||
Ref<Script> base = script->get_base_script();
|
||||
Ref<Script> base = scr->get_base_script();
|
||||
if (base.is_null()) {
|
||||
String extends;
|
||||
script->get_language()->get_global_class_name(script->get_path(), &extends);
|
||||
scr->get_language()->get_global_class_name(scr->get_path(), &extends);
|
||||
|
||||
inherits = extends;
|
||||
inherited_type = TypeCategory::CPP_TYPE;
|
||||
} else {
|
||||
inherits = script->get_language()->get_global_class_name(base->get_path());
|
||||
inherits = scr->get_language()->get_global_class_name(base->get_path());
|
||||
if (inherits.is_empty()) {
|
||||
inherits = base->get_path();
|
||||
inherited_type = TypeCategory::PATH_TYPE;
|
||||
|
@ -232,18 +232,18 @@ void CreateDialog::_add_type(const String &p_type, const TypeCategory p_type_cat
|
|||
}
|
||||
} else {
|
||||
if (ScriptServer::is_global_class(p_type)) {
|
||||
Ref<Script> script = EditorNode::get_editor_data().script_class_load_script(p_type);
|
||||
ERR_FAIL_COND(script.is_null());
|
||||
Ref<Script> scr = EditorNode::get_editor_data().script_class_load_script(p_type);
|
||||
ERR_FAIL_COND(scr.is_null());
|
||||
|
||||
Ref<Script> base = script->get_base_script();
|
||||
Ref<Script> base = scr->get_base_script();
|
||||
if (base.is_null()) {
|
||||
String extends;
|
||||
script->get_language()->get_global_class_name(script->get_path(), &extends);
|
||||
scr->get_language()->get_global_class_name(scr->get_path(), &extends);
|
||||
|
||||
inherits = extends;
|
||||
inherited_type = TypeCategory::CPP_TYPE;
|
||||
} else {
|
||||
inherits = script->get_language()->get_global_class_name(base->get_path());
|
||||
inherits = scr->get_language()->get_global_class_name(base->get_path());
|
||||
if (inherits.is_empty()) {
|
||||
inherits = base->get_path();
|
||||
inherited_type = TypeCategory::PATH_TYPE;
|
||||
|
|
|
@ -921,11 +921,11 @@ void DebugAdapterProtocol::on_debug_stack_frame_vars(const int &p_size) {
|
|||
ERR_FAIL_COND(!stackframe_list.has(frame));
|
||||
List<int> scope_ids = stackframe_list.find(frame)->value;
|
||||
for (List<int>::Element *E = scope_ids.front(); E; E = E->next()) {
|
||||
int variable_id = E->get();
|
||||
if (variable_list.has(variable_id)) {
|
||||
variable_list.find(variable_id)->value.clear();
|
||||
int var_id = E->get();
|
||||
if (variable_list.has(var_id)) {
|
||||
variable_list.find(var_id)->value.clear();
|
||||
} else {
|
||||
variable_list.insert(variable_id, Array());
|
||||
variable_list.insert(var_id, Array());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -941,7 +941,7 @@ void DebugAdapterProtocol::on_debug_stack_frame_var(const Array &p_data) {
|
|||
List<int> scope_ids = stackframe_list.find(frame)->value;
|
||||
ERR_FAIL_COND(scope_ids.size() != 3);
|
||||
ERR_FAIL_INDEX(stack_var.type, 3);
|
||||
int variable_id = scope_ids[stack_var.type];
|
||||
int var_id = scope_ids[stack_var.type];
|
||||
|
||||
DAP::Variable variable;
|
||||
|
||||
|
@ -950,7 +950,7 @@ void DebugAdapterProtocol::on_debug_stack_frame_var(const Array &p_data) {
|
|||
variable.type = Variant::get_type_name(stack_var.value.get_type());
|
||||
variable.variablesReference = parse_variant(stack_var.value);
|
||||
|
||||
variable_list.find(variable_id)->value.push_back(variable.to_json());
|
||||
variable_list.find(var_id)->value.push_back(variable.to_json());
|
||||
_remaining_vars--;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,10 +64,10 @@ void DebugAdapterServer::_notification(int p_what) {
|
|||
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
|
||||
protocol._request_timeout = EditorSettings::get_singleton()->get("network/debug_adapter/request_timeout");
|
||||
protocol._sync_breakpoints = EditorSettings::get_singleton()->get("network/debug_adapter/sync_breakpoints");
|
||||
int remote_port = (int)_EDITOR_GET("network/debug_adapter/remote_port");
|
||||
if (remote_port != this->remote_port) {
|
||||
this->stop();
|
||||
this->start();
|
||||
int port = (int)_EDITOR_GET("network/debug_adapter/remote_port");
|
||||
if (port != remote_port) {
|
||||
stop();
|
||||
start();
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
|
|
@ -166,11 +166,11 @@ ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) {
|
|||
if (pinfo.hint_string == "Script") {
|
||||
if (debug_obj->get_script() != var) {
|
||||
debug_obj->set_script(Ref<RefCounted>());
|
||||
Ref<Script> script(var);
|
||||
if (!script.is_null()) {
|
||||
ScriptInstance *script_instance = script->placeholder_instance_create(debug_obj);
|
||||
if (script_instance) {
|
||||
debug_obj->set_script_and_instance(var, script_instance);
|
||||
Ref<Script> scr(var);
|
||||
if (!scr.is_null()) {
|
||||
ScriptInstance *scr_instance = scr->placeholder_instance_create(debug_obj);
|
||||
if (scr_instance) {
|
||||
debug_obj->set_script_and_instance(var, scr_instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -477,13 +477,10 @@ void EditorDebuggerNode::_menu_option(int p_id) {
|
|||
}
|
||||
|
||||
void EditorDebuggerNode::_update_debug_options() {
|
||||
bool keep_debugger_open = EditorSettings::get_singleton()->get_project_metadata("debug_options", "keep_debugger_open", false);
|
||||
bool debug_with_external_editor = EditorSettings::get_singleton()->get_project_metadata("debug_options", "debug_with_external_editor", false);
|
||||
|
||||
if (keep_debugger_open) {
|
||||
if (EditorSettings::get_singleton()->get_project_metadata("debug_options", "keep_debugger_open", false).operator bool()) {
|
||||
_menu_option(DEBUG_KEEP_DEBUGGER_OPEN);
|
||||
}
|
||||
if (debug_with_external_editor) {
|
||||
if (EditorSettings::get_singleton()->get_project_metadata("debug_options", "debug_with_external_editor", false).operator bool()) {
|
||||
_menu_option(DEBUG_WITH_EXTERNAL_EDITOR);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -349,12 +349,12 @@ void EditorPerformanceProfiler::update_monitors(const Vector<StringName> &p_name
|
|||
|
||||
void EditorPerformanceProfiler::add_profile_frame(const Vector<float> &p_values) {
|
||||
for (KeyValue<StringName, Monitor> &E : monitors) {
|
||||
float data = 0.0f;
|
||||
float value = 0.0f;
|
||||
if (E.value.frame_index >= 0 && E.value.frame_index < p_values.size()) {
|
||||
data = p_values[E.value.frame_index];
|
||||
value = p_values[E.value.frame_index];
|
||||
}
|
||||
E.value.history.push_front(data);
|
||||
E.value.update_value(data);
|
||||
E.value.history.push_front(value);
|
||||
E.value.update_value(value);
|
||||
}
|
||||
marker_frame++;
|
||||
monitor_draw->queue_redraw();
|
||||
|
|
|
@ -747,8 +747,8 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
|
|||
if (element) {
|
||||
Callable &c = element->value;
|
||||
ERR_FAIL_COND_MSG(c.is_null(), "Invalid callable registered: " + cap);
|
||||
Variant cmd = p_msg.substr(colon_index + 1), data = p_data;
|
||||
const Variant *args[2] = { &cmd, &data };
|
||||
Variant cmd = p_msg.substr(colon_index + 1), cmd_data = p_data;
|
||||
const Variant *args[2] = { &cmd, &cmd_data };
|
||||
Variant retval;
|
||||
Callable::CallError err;
|
||||
c.callp(args, 2, retval, err);
|
||||
|
@ -895,9 +895,9 @@ void ScriptEditorDebugger::_clear_execution() {
|
|||
}
|
||||
|
||||
void ScriptEditorDebugger::_set_breakpoint(const String &p_file, const int &p_line, const bool &p_enabled) {
|
||||
Ref<Script> script = ResourceLoader::load(p_file);
|
||||
emit_signal(SNAME("set_breakpoint"), script, p_line - 1, p_enabled);
|
||||
script.unref();
|
||||
Ref<Script> scr = ResourceLoader::load(p_file);
|
||||
emit_signal(SNAME("set_breakpoint"), scr, p_line - 1, p_enabled);
|
||||
scr.unref();
|
||||
}
|
||||
|
||||
void ScriptEditorDebugger::_clear_breakpoints() {
|
||||
|
@ -979,15 +979,15 @@ void ScriptEditorDebugger::stop() {
|
|||
}
|
||||
|
||||
void ScriptEditorDebugger::_profiler_activate(bool p_enable, int p_type) {
|
||||
Array data;
|
||||
data.push_back(p_enable);
|
||||
Array msg_data;
|
||||
msg_data.push_back(p_enable);
|
||||
switch (p_type) {
|
||||
case PROFILER_NETWORK:
|
||||
_put_msg("profiler:multiplayer", data);
|
||||
_put_msg("profiler:rpc", data);
|
||||
_put_msg("profiler:multiplayer", msg_data);
|
||||
_put_msg("profiler:rpc", msg_data);
|
||||
break;
|
||||
case PROFILER_VISUAL:
|
||||
_put_msg("profiler:visual", data);
|
||||
_put_msg("profiler:visual", msg_data);
|
||||
break;
|
||||
case PROFILER_SCRIPTS_SERVERS:
|
||||
if (p_enable) {
|
||||
|
@ -997,9 +997,9 @@ void ScriptEditorDebugger::_profiler_activate(bool p_enable, int p_type) {
|
|||
Array opts;
|
||||
int max_funcs = EditorSettings::get_singleton()->get("debugger/profiler_frame_max_functions");
|
||||
opts.push_back(CLAMP(max_funcs, 16, 512));
|
||||
data.push_back(opts);
|
||||
msg_data.push_back(opts);
|
||||
}
|
||||
_put_msg("profiler:servers", data);
|
||||
_put_msg("profiler:servers", msg_data);
|
||||
break;
|
||||
default:
|
||||
ERR_FAIL_MSG("Invalid profiler type");
|
||||
|
|
|
@ -792,14 +792,14 @@ void OrphanResourcesDialog::show() {
|
|||
popup_centered_ratio(0.4);
|
||||
}
|
||||
|
||||
void OrphanResourcesDialog::_find_to_delete(TreeItem *p_item, List<String> &paths) {
|
||||
void OrphanResourcesDialog::_find_to_delete(TreeItem *p_item, List<String> &r_paths) {
|
||||
while (p_item) {
|
||||
if (p_item->get_cell_mode(0) == TreeItem::CELL_MODE_CHECK && p_item->is_checked(0)) {
|
||||
paths.push_back(p_item->get_metadata(0));
|
||||
r_paths.push_back(p_item->get_metadata(0));
|
||||
}
|
||||
|
||||
if (p_item->get_first_child()) {
|
||||
_find_to_delete(p_item->get_first_child(), paths);
|
||||
_find_to_delete(p_item->get_first_child(), r_paths);
|
||||
}
|
||||
|
||||
p_item = p_item->get_next();
|
||||
|
|
|
@ -165,7 +165,7 @@ class OrphanResourcesDialog : public ConfirmationDialog {
|
|||
bool _fill_owners(EditorFileSystemDirectory *efsd, HashMap<String, int> &refs, TreeItem *p_parent);
|
||||
|
||||
List<String> paths;
|
||||
void _find_to_delete(TreeItem *p_item, List<String> &paths);
|
||||
void _find_to_delete(TreeItem *p_item, List<String> &r_paths);
|
||||
void _delete_confirm();
|
||||
void _button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button);
|
||||
|
||||
|
|
|
@ -183,16 +183,16 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) {
|
|||
|
||||
int pp = path.rfind("/");
|
||||
|
||||
TreeItem *parent;
|
||||
TreeItem *parent_item;
|
||||
if (pp == -1) {
|
||||
parent = root;
|
||||
parent_item = root;
|
||||
} else {
|
||||
String ppath = path.substr(0, pp);
|
||||
ERR_CONTINUE(!dir_map.has(ppath));
|
||||
parent = dir_map[ppath];
|
||||
parent_item = dir_map[ppath];
|
||||
}
|
||||
|
||||
TreeItem *ti = tree->create_item(parent);
|
||||
TreeItem *ti = tree->create_item(parent_item);
|
||||
ti->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
|
||||
ti->set_checked(0, true);
|
||||
ti->set_editable(0, true);
|
||||
|
@ -284,17 +284,17 @@ void EditorAssetInstaller::ok_pressed() {
|
|||
Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
||||
da->make_dir(dirpath);
|
||||
} else {
|
||||
Vector<uint8_t> data;
|
||||
data.resize(info.uncompressed_size);
|
||||
Vector<uint8_t> uncomp_data;
|
||||
uncomp_data.resize(info.uncompressed_size);
|
||||
|
||||
//read
|
||||
unzOpenCurrentFile(pkg);
|
||||
unzReadCurrentFile(pkg, data.ptrw(), data.size());
|
||||
unzReadCurrentFile(pkg, uncomp_data.ptrw(), uncomp_data.size());
|
||||
unzCloseCurrentFile(pkg);
|
||||
|
||||
Ref<FileAccess> f = FileAccess::open(path, FileAccess::WRITE);
|
||||
if (f.is_valid()) {
|
||||
f->store_buffer(data.ptr(), data.size());
|
||||
f->store_buffer(uncomp_data.ptr(), uncomp_data.size());
|
||||
} else {
|
||||
failed_files.push_back(path);
|
||||
}
|
||||
|
|
|
@ -919,10 +919,10 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) {
|
|||
effect_options = memnew(PopupMenu);
|
||||
effect_options->connect("index_pressed", callable_mp(this, &EditorAudioBus::_effect_add));
|
||||
add_child(effect_options);
|
||||
List<StringName> effects;
|
||||
ClassDB::get_inheriters_from_class("AudioEffect", &effects);
|
||||
effects.sort_custom<StringName::AlphCompare>();
|
||||
for (const StringName &E : effects) {
|
||||
List<StringName> effect_list;
|
||||
ClassDB::get_inheriters_from_class("AudioEffect", &effect_list);
|
||||
effect_list.sort_custom<StringName::AlphCompare>();
|
||||
for (const StringName &E : effect_list) {
|
||||
if (!ClassDB::can_instantiate(E) || ClassDB::is_virtual(E)) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -222,15 +222,15 @@ void EditorAutoloadSettings::_autoload_edited() {
|
|||
name = "autoload/" + name;
|
||||
|
||||
int order = ProjectSettings::get_singleton()->get_order(selected_autoload);
|
||||
String path = ProjectSettings::get_singleton()->get(selected_autoload);
|
||||
String scr_path = ProjectSettings::get_singleton()->get(selected_autoload);
|
||||
|
||||
undo_redo->create_action(TTR("Rename Autoload"));
|
||||
|
||||
undo_redo->add_do_property(ProjectSettings::get_singleton(), name, path);
|
||||
undo_redo->add_do_property(ProjectSettings::get_singleton(), name, scr_path);
|
||||
undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", name, order);
|
||||
undo_redo->add_do_method(ProjectSettings::get_singleton(), "clear", selected_autoload);
|
||||
|
||||
undo_redo->add_undo_property(ProjectSettings::get_singleton(), selected_autoload, path);
|
||||
undo_redo->add_undo_property(ProjectSettings::get_singleton(), selected_autoload, scr_path);
|
||||
undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", selected_autoload, order);
|
||||
undo_redo->add_undo_method(ProjectSettings::get_singleton(), "clear", name);
|
||||
|
||||
|
@ -250,20 +250,20 @@ void EditorAutoloadSettings::_autoload_edited() {
|
|||
String base = "autoload/" + ti->get_text(0);
|
||||
|
||||
int order = ProjectSettings::get_singleton()->get_order(base);
|
||||
String path = ProjectSettings::get_singleton()->get(base);
|
||||
String scr_path = ProjectSettings::get_singleton()->get(base);
|
||||
|
||||
if (path.begins_with("*")) {
|
||||
path = path.substr(1, path.length());
|
||||
if (scr_path.begins_with("*")) {
|
||||
scr_path = scr_path.substr(1, scr_path.length());
|
||||
}
|
||||
|
||||
// Singleton autoloads are represented with a leading "*" in their path.
|
||||
if (checked) {
|
||||
path = "*" + path;
|
||||
scr_path = "*" + scr_path;
|
||||
}
|
||||
|
||||
undo_redo->create_action(TTR("Toggle Autoload Globals"));
|
||||
|
||||
undo_redo->add_do_property(ProjectSettings::get_singleton(), base, path);
|
||||
undo_redo->add_do_property(ProjectSettings::get_singleton(), base, scr_path);
|
||||
undo_redo->add_undo_property(ProjectSettings::get_singleton(), base, ProjectSettings::get_singleton()->get(base));
|
||||
|
||||
undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", base, order);
|
||||
|
@ -404,11 +404,11 @@ Node *EditorAutoloadSettings::_create_autoload(const String &p_path) {
|
|||
ERR_FAIL_COND_V_MSG(res.is_null(), nullptr, "Can't autoload: " + p_path + ".");
|
||||
Node *n = nullptr;
|
||||
Ref<PackedScene> scn = res;
|
||||
Ref<Script> script = res;
|
||||
Ref<Script> scr = res;
|
||||
if (scn.is_valid()) {
|
||||
n = scn->instantiate();
|
||||
} else if (script.is_valid()) {
|
||||
StringName ibt = script->get_instance_base_type();
|
||||
} else if (scr.is_valid()) {
|
||||
StringName ibt = scr->get_instance_base_type();
|
||||
bool valid_type = ClassDB::is_parent_class(ibt, "Node");
|
||||
ERR_FAIL_COND_V_MSG(!valid_type, nullptr, "Script does not inherit from Node: " + p_path + ".");
|
||||
|
||||
|
@ -417,7 +417,7 @@ Node *EditorAutoloadSettings::_create_autoload(const String &p_path) {
|
|||
ERR_FAIL_COND_V_MSG(!obj, nullptr, "Cannot instance script for Autoload, expected 'Node' inheritance, got: " + String(ibt) + ".");
|
||||
|
||||
n = Object::cast_to<Node>(obj);
|
||||
n->set_script(script);
|
||||
n->set_script(scr);
|
||||
}
|
||||
|
||||
ERR_FAIL_COND_V_MSG(!n, nullptr, "Path in Autoload not a node or script: " + p_path + ".");
|
||||
|
@ -453,21 +453,21 @@ void EditorAutoloadSettings::update_autoload() {
|
|||
}
|
||||
|
||||
String name = pi.name.get_slice("/", 1);
|
||||
String path = ProjectSettings::get_singleton()->get(pi.name);
|
||||
String scr_path = ProjectSettings::get_singleton()->get(pi.name);
|
||||
|
||||
if (name.is_empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
AutoloadInfo info;
|
||||
info.is_singleton = path.begins_with("*");
|
||||
info.is_singleton = scr_path.begins_with("*");
|
||||
|
||||
if (info.is_singleton) {
|
||||
path = path.substr(1, path.length());
|
||||
scr_path = scr_path.substr(1, scr_path.length());
|
||||
}
|
||||
|
||||
info.name = name;
|
||||
info.path = path;
|
||||
info.path = scr_path;
|
||||
info.order = ProjectSettings::get_singleton()->get_order(pi.name);
|
||||
|
||||
bool need_to_add = true;
|
||||
|
@ -499,7 +499,7 @@ void EditorAutoloadSettings::update_autoload() {
|
|||
item->set_text(0, name);
|
||||
item->set_editable(0, true);
|
||||
|
||||
item->set_text(1, path);
|
||||
item->set_text(1, scr_path);
|
||||
item->set_selectable(1, true);
|
||||
|
||||
item->set_cell_mode(2, TreeItem::CELL_MODE_CHECK);
|
||||
|
@ -745,13 +745,12 @@ bool EditorAutoloadSettings::autoload_add(const String &p_name, const String &p_
|
|||
return false;
|
||||
}
|
||||
|
||||
const String &path = p_path;
|
||||
if (!FileAccess::exists(path)) {
|
||||
if (!FileAccess::exists(p_path)) {
|
||||
EditorNode::get_singleton()->show_warning(TTR("Can't add Autoload:") + "\n" + vformat(TTR("%s is an invalid path. File does not exist."), path));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!path.begins_with("res://")) {
|
||||
if (!p_path.begins_with("res://")) {
|
||||
EditorNode::get_singleton()->show_warning(TTR("Can't add Autoload:") + "\n" + vformat(TTR("%s is an invalid path. Not in resource path (res://)."), path));
|
||||
return false;
|
||||
}
|
||||
|
@ -762,7 +761,7 @@ bool EditorAutoloadSettings::autoload_add(const String &p_name, const String &p_
|
|||
|
||||
undo_redo->create_action(TTR("Add Autoload"));
|
||||
// Singleton autoloads are represented with a leading "*" in their path.
|
||||
undo_redo->add_do_property(ProjectSettings::get_singleton(), name, "*" + path);
|
||||
undo_redo->add_do_property(ProjectSettings::get_singleton(), name, "*" + p_path);
|
||||
|
||||
if (ProjectSettings::get_singleton()->has_setting(name)) {
|
||||
undo_redo->add_undo_property(ProjectSettings::get_singleton(), name, ProjectSettings::get_singleton()->get(name));
|
||||
|
@ -829,21 +828,21 @@ EditorAutoloadSettings::EditorAutoloadSettings() {
|
|||
}
|
||||
|
||||
String name = pi.name.get_slice("/", 1);
|
||||
String path = ProjectSettings::get_singleton()->get(pi.name);
|
||||
String scr_path = ProjectSettings::get_singleton()->get(pi.name);
|
||||
|
||||
if (name.is_empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
AutoloadInfo info;
|
||||
info.is_singleton = path.begins_with("*");
|
||||
info.is_singleton = scr_path.begins_with("*");
|
||||
|
||||
if (info.is_singleton) {
|
||||
path = path.substr(1, path.length());
|
||||
scr_path = scr_path.substr(1, scr_path.length());
|
||||
}
|
||||
|
||||
info.name = name;
|
||||
info.path = path;
|
||||
info.path = scr_path;
|
||||
info.order = ProjectSettings::get_singleton()->get_order(pi.name);
|
||||
|
||||
if (info.is_singleton) {
|
||||
|
|
|
@ -1023,10 +1023,10 @@ void EditorFileDialog::set_current_path(const String &p_path) {
|
|||
if (pos == -1) {
|
||||
set_current_file(p_path);
|
||||
} else {
|
||||
String dir = p_path.substr(0, pos);
|
||||
String file = p_path.substr(pos + 1, p_path.length());
|
||||
set_current_dir(dir);
|
||||
set_current_file(file);
|
||||
String path_dir = p_path.substr(0, pos);
|
||||
String path_file = p_path.substr(pos + 1, p_path.length());
|
||||
set_current_dir(path_dir);
|
||||
set_current_file(path_file);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1614,26 +1614,26 @@ void EditorFileDialog::set_default_display_mode(DisplayMode p_mode) {
|
|||
}
|
||||
|
||||
void EditorFileDialog::_save_to_recent() {
|
||||
String dir = get_current_dir();
|
||||
Vector<String> recent = EditorSettings::get_singleton()->get_recent_dirs();
|
||||
String cur_dir = get_current_dir();
|
||||
Vector<String> recent_new = EditorSettings::get_singleton()->get_recent_dirs();
|
||||
|
||||
const int max = 20;
|
||||
int count = 0;
|
||||
bool res = dir.begins_with("res://");
|
||||
bool res = cur_dir.begins_with("res://");
|
||||
|
||||
for (int i = 0; i < recent.size(); i++) {
|
||||
bool cres = recent[i].begins_with("res://");
|
||||
if (recent[i] == dir || (res == cres && count > max)) {
|
||||
recent.remove_at(i);
|
||||
for (int i = 0; i < recent_new.size(); i++) {
|
||||
bool cres = recent_new[i].begins_with("res://");
|
||||
if (recent_new[i] == cur_dir || (res == cres && count > max)) {
|
||||
recent_new.remove_at(i);
|
||||
i--;
|
||||
} else {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
recent.insert(0, dir);
|
||||
recent_new.insert(0, cur_dir);
|
||||
|
||||
EditorSettings::get_singleton()->set_recent_dirs(recent);
|
||||
EditorSettings::get_singleton()->set_recent_dirs(recent_new);
|
||||
}
|
||||
|
||||
void EditorFileDialog::set_disable_overwrite_warning(bool p_disable) {
|
||||
|
|
|
@ -919,11 +919,11 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, Ref<DirAc
|
|||
for (int i = 0; i < ScriptServer::get_language_count(); i++) {
|
||||
ScriptLanguage *lang = ScriptServer::get_language(i);
|
||||
if (lang->supports_documentation() && fi->type == lang->get_type()) {
|
||||
Ref<Script> script = ResourceLoader::load(path);
|
||||
if (script == nullptr) {
|
||||
Ref<Script> scr = ResourceLoader::load(path);
|
||||
if (scr == nullptr) {
|
||||
continue;
|
||||
}
|
||||
Vector<DocData::ClassDoc> docs = script->get_documentation();
|
||||
Vector<DocData::ClassDoc> docs = scr->get_documentation();
|
||||
for (int j = 0; j < docs.size(); j++) {
|
||||
EditorHelp::get_doc_data()->add_doc(docs[j]);
|
||||
}
|
||||
|
@ -1902,8 +1902,8 @@ void EditorFileSystem::_reimport_file(const String &p_file, const HashMap<String
|
|||
|
||||
List<String> import_variants;
|
||||
List<String> gen_files;
|
||||
Variant metadata;
|
||||
Error err = importer->import(p_file, base_path, params, &import_variants, &gen_files, &metadata);
|
||||
Variant meta;
|
||||
Error err = importer->import(p_file, base_path, params, &import_variants, &gen_files, &meta);
|
||||
|
||||
if (err != OK) {
|
||||
ERR_PRINT("Error importing '" + p_file + "'.");
|
||||
|
@ -1955,8 +1955,8 @@ void EditorFileSystem::_reimport_file(const String &p_file, const HashMap<String
|
|||
f->store_line("valid=false");
|
||||
}
|
||||
|
||||
if (metadata != Variant()) {
|
||||
f->store_line("metadata=" + metadata.get_construct_string());
|
||||
if (meta != Variant()) {
|
||||
f->store_line("metadata=" + meta.get_construct_string());
|
||||
}
|
||||
|
||||
f->store_line("");
|
||||
|
@ -2108,11 +2108,11 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) {
|
|||
|
||||
reimport_files.sort();
|
||||
|
||||
bool use_threads = GLOBAL_GET("editor/import/use_multiple_threads");
|
||||
bool use_multiple_threads = GLOBAL_GET("editor/import/use_multiple_threads");
|
||||
|
||||
int from = 0;
|
||||
for (int i = 0; i < reimport_files.size(); i++) {
|
||||
if (use_threads && reimport_files[i].threaded) {
|
||||
if (use_multiple_threads && reimport_files[i].threaded) {
|
||||
if (i + 1 == reimport_files.size() || reimport_files[i + 1].importer != reimport_files[from].importer) {
|
||||
if (from - i == 0) {
|
||||
//single file, do not use threads
|
||||
|
@ -2124,16 +2124,16 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) {
|
|||
|
||||
importer->import_threaded_begin();
|
||||
|
||||
ImportThreadData data;
|
||||
data.max_index = from;
|
||||
data.reimport_from = from;
|
||||
data.reimport_files = reimport_files.ptr();
|
||||
ImportThreadData tdata;
|
||||
tdata.max_index = from;
|
||||
tdata.reimport_from = from;
|
||||
tdata.reimport_files = reimport_files.ptr();
|
||||
|
||||
WorkerThreadPool::GroupID group_task = WorkerThreadPool::get_singleton()->add_template_group_task(this, &EditorFileSystem::_reimport_thread, &data, i - from + 1, -1, false, vformat(TTR("Import resources of type: %s"), reimport_files[from].importer));
|
||||
WorkerThreadPool::GroupID group_task = WorkerThreadPool::get_singleton()->add_template_group_task(this, &EditorFileSystem::_reimport_thread, &tdata, i - from + 1, -1, false, vformat(TTR("Import resources of type: %s"), reimport_files[from].importer));
|
||||
int current_index = from - 1;
|
||||
do {
|
||||
if (current_index < data.max_index) {
|
||||
current_index = data.max_index;
|
||||
if (current_index < tdata.max_index) {
|
||||
current_index = tdata.max_index;
|
||||
pr.step(reimport_files[current_index].path.get_file(), current_index);
|
||||
}
|
||||
OS::get_singleton()->delay_usec(1);
|
||||
|
|
|
@ -184,9 +184,9 @@ void EditorHelp::_class_desc_input(const Ref<InputEvent> &p_input) {
|
|||
void EditorHelp::_class_desc_resized(bool p_force_update_theme) {
|
||||
// Add extra horizontal margins for better readability.
|
||||
// The margins increase as the width of the editor help container increases.
|
||||
Ref<Font> doc_code_font = get_theme_font(SNAME("doc_source"), SNAME("EditorFonts"));
|
||||
Ref<Font> font = get_theme_font(SNAME("doc_source"), SNAME("EditorFonts"));
|
||||
int font_size = get_theme_font_size(SNAME("doc_source_size"), SNAME("EditorFonts"));
|
||||
real_t char_width = doc_code_font->get_char_size('x', font_size).width;
|
||||
real_t char_width = font->get_char_size('x', font_size).width;
|
||||
const int new_display_margin = MAX(30 * EDSCALE, get_parent_anchorable_rect().size.width - char_width * 120 * EDSCALE) * 0.5;
|
||||
if (display_margin != new_display_margin || p_force_update_theme) {
|
||||
display_margin = new_display_margin;
|
||||
|
@ -412,13 +412,13 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) {
|
|||
}
|
||||
|
||||
void EditorHelp::_update_method_list(const Vector<DocData::MethodDoc> p_methods, bool &r_method_descrpitons) {
|
||||
Ref<Font> doc_code_font = get_theme_font(SNAME("doc_source"), SNAME("EditorFonts"));
|
||||
Ref<Font> font = get_theme_font(SNAME("doc_source"), SNAME("EditorFonts"));
|
||||
class_desc->pop(); // title font size
|
||||
class_desc->pop(); // title font
|
||||
class_desc->pop(); // title color
|
||||
|
||||
class_desc->add_newline();
|
||||
class_desc->push_font(doc_code_font);
|
||||
class_desc->push_font(font);
|
||||
class_desc->push_indent(1);
|
||||
class_desc->push_table(2);
|
||||
class_desc->set_table_column_expand(1, true);
|
||||
|
@ -479,9 +479,8 @@ void EditorHelp::_update_method_list(const Vector<DocData::MethodDoc> p_methods,
|
|||
}
|
||||
|
||||
void EditorHelp::_update_method_descriptions(const DocData::ClassDoc p_classdoc, const Vector<DocData::MethodDoc> p_methods, const String &p_method_type) {
|
||||
Ref<Font> doc_font = get_theme_font(SNAME("doc"), SNAME("EditorFonts"));
|
||||
Ref<Font> doc_bold_font = get_theme_font(SNAME("doc_bold"), SNAME("EditorFonts"));
|
||||
Ref<Font> doc_code_font = get_theme_font(SNAME("doc_source"), SNAME("EditorFonts"));
|
||||
Ref<Font> font = get_theme_font(SNAME("doc"), SNAME("EditorFonts"));
|
||||
Ref<Font> code_font = get_theme_font(SNAME("doc_source"), SNAME("EditorFonts"));
|
||||
String link_color_text = title_color.to_html(false);
|
||||
class_desc->pop(); // title font size
|
||||
class_desc->pop(); // title font
|
||||
|
@ -501,7 +500,7 @@ void EditorHelp::_update_method_descriptions(const DocData::ClassDoc p_classdoc,
|
|||
}
|
||||
|
||||
for (int i = 0; i < methods_filtered.size(); i++) {
|
||||
class_desc->push_font(doc_code_font);
|
||||
class_desc->push_font(code_font);
|
||||
_add_method(methods_filtered[i], false);
|
||||
class_desc->pop();
|
||||
|
||||
|
@ -509,7 +508,7 @@ void EditorHelp::_update_method_descriptions(const DocData::ClassDoc p_classdoc,
|
|||
class_desc->add_newline();
|
||||
|
||||
class_desc->push_color(text_color);
|
||||
class_desc->push_font(doc_font);
|
||||
class_desc->push_font(font);
|
||||
class_desc->push_indent(1);
|
||||
if (methods_filtered[i].errors_returned.size()) {
|
||||
class_desc->append_text(TTR("Error codes returned:"));
|
||||
|
|
|
@ -450,7 +450,7 @@ bool EditorHelpSearch::Runner::_phase_member_items() {
|
|||
return false;
|
||||
}
|
||||
|
||||
TreeItem *parent = (search_flags & SEARCH_SHOW_HIERARCHY) ? class_items[match.doc->name] : root_item;
|
||||
TreeItem *parent_item = (search_flags & SEARCH_SHOW_HIERARCHY) ? class_items[match.doc->name] : root_item;
|
||||
bool constructor_created = false;
|
||||
for (int i = 0; i < match.methods.size(); i++) {
|
||||
String text = match.methods[i]->name;
|
||||
|
@ -464,23 +464,23 @@ bool EditorHelpSearch::Runner::_phase_member_items() {
|
|||
continue;
|
||||
}
|
||||
}
|
||||
_create_method_item(parent, match.doc, text, match.methods[i]);
|
||||
_create_method_item(parent_item, match.doc, text, match.methods[i]);
|
||||
}
|
||||
for (int i = 0; i < match.signals.size(); i++) {
|
||||
_create_signal_item(parent, match.doc, match.signals[i]);
|
||||
_create_signal_item(parent_item, match.doc, match.signals[i]);
|
||||
}
|
||||
for (int i = 0; i < match.constants.size(); i++) {
|
||||
_create_constant_item(parent, match.doc, match.constants[i]);
|
||||
_create_constant_item(parent_item, match.doc, match.constants[i]);
|
||||
}
|
||||
for (int i = 0; i < match.properties.size(); i++) {
|
||||
_create_property_item(parent, match.doc, match.properties[i]);
|
||||
_create_property_item(parent_item, match.doc, match.properties[i]);
|
||||
}
|
||||
for (int i = 0; i < match.theme_properties.size(); i++) {
|
||||
_create_theme_property_item(parent, match.doc, match.theme_properties[i]);
|
||||
_create_theme_property_item(parent_item, match.doc, match.theme_properties[i]);
|
||||
}
|
||||
for (int i = 0; i < match.annotations.size(); i++) {
|
||||
// Hide the redundant leading @ symbol.
|
||||
_create_annotation_item(parent, match.doc, match.annotations[i]->name.substr(1), match.annotations[i]);
|
||||
_create_annotation_item(parent_item, match.doc, match.annotations[i]->name.substr(1), match.annotations[i]);
|
||||
}
|
||||
|
||||
++iterator_match;
|
||||
|
@ -567,19 +567,19 @@ TreeItem *EditorHelpSearch::Runner::_create_class_hierarchy(const ClassMatch &p_
|
|||
}
|
||||
|
||||
// Ensure parent nodes are created first.
|
||||
TreeItem *parent = root_item;
|
||||
TreeItem *parent_item = root_item;
|
||||
if (!p_match.doc->inherits.is_empty()) {
|
||||
if (class_items.has(p_match.doc->inherits)) {
|
||||
parent = class_items[p_match.doc->inherits];
|
||||
parent_item = class_items[p_match.doc->inherits];
|
||||
} else {
|
||||
ClassMatch &base_match = matches[p_match.doc->inherits];
|
||||
if (base_match.doc) {
|
||||
parent = _create_class_hierarchy(base_match);
|
||||
parent_item = _create_class_hierarchy(base_match);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TreeItem *class_item = _create_class_item(parent, p_match.doc, !p_match.name);
|
||||
TreeItem *class_item = _create_class_item(parent_item, p_match.doc, !p_match.name);
|
||||
class_items[p_match.doc->name] = class_item;
|
||||
return class_item;
|
||||
}
|
||||
|
|
|
@ -783,9 +783,9 @@ Variant EditorProperty::get_drag_data(const Point2 &p_point) {
|
|||
dp["property"] = property;
|
||||
dp["value"] = object->get(property);
|
||||
|
||||
Label *label = memnew(Label);
|
||||
label->set_text(property);
|
||||
set_drag_preview(label);
|
||||
Label *drag_label = memnew(Label);
|
||||
drag_label->set_text(property);
|
||||
set_drag_preview(drag_label);
|
||||
return dp;
|
||||
}
|
||||
|
||||
|
@ -1061,7 +1061,7 @@ void EditorInspectorPlugin::add_property_editor_for_multiple_properties(const St
|
|||
}
|
||||
|
||||
bool EditorInspectorPlugin::can_handle(Object *p_object) {
|
||||
bool success;
|
||||
bool success = false;
|
||||
if (GDVIRTUAL_CALL(_can_handle, p_object, success)) {
|
||||
return success;
|
||||
}
|
||||
|
@ -1081,7 +1081,7 @@ void EditorInspectorPlugin::parse_group(Object *p_object, const String &p_group)
|
|||
}
|
||||
|
||||
bool EditorInspectorPlugin::parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide) {
|
||||
bool ret;
|
||||
bool ret = false;
|
||||
if (GDVIRTUAL_CALL(_parse_property, p_object, p_type, p_path, p_hint, p_hint_text, p_usage, p_wide, ret)) {
|
||||
return ret;
|
||||
}
|
||||
|
@ -1575,9 +1575,9 @@ int EditorInspectorArray::_get_array_count() {
|
|||
return _extract_properties_as_array(object_property_list).size();
|
||||
} else if (mode == MODE_USE_COUNT_PROPERTY) {
|
||||
bool valid;
|
||||
int count = object->get(count_property, &valid);
|
||||
int count_val = object->get(count_property, &valid);
|
||||
ERR_FAIL_COND_V_MSG(!valid, 0, vformat("%s is not a valid property to be used as array count.", count_property));
|
||||
return count;
|
||||
return count_val;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -2768,13 +2768,13 @@ void EditorInspector::update_tree() {
|
|||
// Set the category icon.
|
||||
if (!EditorNode::get_editor_data().is_type_recognized(type) && p.hint_string.length() && FileAccess::exists(p.hint_string)) {
|
||||
// If we have a category inside a script, search for the first script with a valid icon.
|
||||
Ref<Script> script = ResourceLoader::load(p.hint_string, "Script");
|
||||
Ref<Script> scr = ResourceLoader::load(p.hint_string, "Script");
|
||||
StringName base_type;
|
||||
StringName name;
|
||||
if (script.is_valid()) {
|
||||
base_type = script->get_instance_base_type();
|
||||
name = EditorNode::get_editor_data().script_class_get_name(script->get_path());
|
||||
Vector<DocData::ClassDoc> docs = script->get_documentation();
|
||||
if (scr.is_valid()) {
|
||||
base_type = scr->get_instance_base_type();
|
||||
name = EditorNode::get_editor_data().script_class_get_name(scr->get_path());
|
||||
Vector<DocData::ClassDoc> docs = scr->get_documentation();
|
||||
if (!docs.is_empty()) {
|
||||
doc_name = docs[0].name;
|
||||
}
|
||||
|
@ -2782,20 +2782,20 @@ void EditorInspector::update_tree() {
|
|||
label = name;
|
||||
}
|
||||
}
|
||||
while (script.is_valid()) {
|
||||
name = EditorNode::get_editor_data().script_class_get_name(script->get_path());
|
||||
while (scr.is_valid()) {
|
||||
name = EditorNode::get_editor_data().script_class_get_name(scr->get_path());
|
||||
String icon_path = EditorNode::get_editor_data().script_class_get_icon_path(name);
|
||||
if (name != StringName() && !icon_path.is_empty()) {
|
||||
category->icon = ResourceLoader::load(icon_path, "Texture");
|
||||
break;
|
||||
}
|
||||
|
||||
const EditorData::CustomType *ctype = EditorNode::get_editor_data().get_custom_type_by_path(script->get_path());
|
||||
const EditorData::CustomType *ctype = EditorNode::get_editor_data().get_custom_type_by_path(scr->get_path());
|
||||
if (ctype) {
|
||||
category->icon = ctype->icon;
|
||||
break;
|
||||
}
|
||||
script = script->get_base_script();
|
||||
scr = scr->get_base_script();
|
||||
}
|
||||
if (category->icon.is_null() && has_theme_icon(base_type, SNAME("EditorIcons"))) {
|
||||
category->icon = get_theme_icon(base_type, SNAME("EditorIcons"));
|
||||
|
|
|
@ -149,7 +149,7 @@ void EditorLocaleDialog::_filter_lang_option_changed() {
|
|||
|
||||
void EditorLocaleDialog::_filter_script_option_changed() {
|
||||
TreeItem *t = script_list->get_edited();
|
||||
String script = t->get_metadata(0);
|
||||
String scr_code = t->get_metadata(0);
|
||||
bool checked = t->is_checked(0);
|
||||
|
||||
Variant prev;
|
||||
|
@ -160,11 +160,11 @@ void EditorLocaleDialog::_filter_script_option_changed() {
|
|||
prev = f_script_all;
|
||||
}
|
||||
|
||||
int l_idx = f_script_all.find(script);
|
||||
int l_idx = f_script_all.find(scr_code);
|
||||
|
||||
if (checked) {
|
||||
if (l_idx == -1) {
|
||||
f_script_all.append(script);
|
||||
f_script_all.append(scr_code);
|
||||
}
|
||||
} else {
|
||||
if (l_idx != -1) {
|
||||
|
@ -298,7 +298,7 @@ void EditorLocaleDialog::_update_tree() {
|
|||
Vector<String> scripts = TranslationServer::get_singleton()->get_all_scripts();
|
||||
for (const String &E : scripts) {
|
||||
if (is_edit_mode || (filter == SHOW_ALL_LOCALES) || f_script_all.has(E) || f_script_all.is_empty()) {
|
||||
const String &script = TranslationServer::get_singleton()->get_script_name(E);
|
||||
const String &scr_code = TranslationServer::get_singleton()->get_script_name(E);
|
||||
TreeItem *t = script_list->create_item(s_root);
|
||||
if (is_edit_mode) {
|
||||
t->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
|
||||
|
@ -307,7 +307,7 @@ void EditorLocaleDialog::_update_tree() {
|
|||
} else if (script_code->get_text() == E) {
|
||||
t->select(0);
|
||||
}
|
||||
t->set_text(0, vformat("%s [%s]", script, E));
|
||||
t->set_text(0, vformat("%s [%s]", scr_code, E));
|
||||
t->set_metadata(0, E);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -892,8 +892,8 @@ void EditorNode::_update_update_spinner() {
|
|||
}
|
||||
|
||||
void EditorNode::_on_plugin_ready(Object *p_script, const String &p_activate_name) {
|
||||
Ref<Script> script = Object::cast_to<Script>(p_script);
|
||||
if (script.is_null()) {
|
||||
Ref<Script> scr = Object::cast_to<Script>(p_script);
|
||||
if (scr.is_null()) {
|
||||
return;
|
||||
}
|
||||
if (p_activate_name.length()) {
|
||||
|
@ -901,7 +901,7 @@ void EditorNode::_on_plugin_ready(Object *p_script, const String &p_activate_nam
|
|||
}
|
||||
project_settings_editor->update_plugins();
|
||||
project_settings_editor->hide();
|
||||
push_item(script.operator->());
|
||||
push_item(scr.operator->());
|
||||
}
|
||||
|
||||
void EditorNode::_remove_plugin_from_enabled(const String &p_name) {
|
||||
|
@ -1665,10 +1665,8 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) {
|
|||
cache_base = temp_path.path_join("resthumb-" + cache_base);
|
||||
|
||||
// Does not have it, try to load a cached thumbnail.
|
||||
String file = cache_base + ".png";
|
||||
|
||||
post_process_preview(img);
|
||||
img->save_png(file);
|
||||
img->save_png(cache_base + ".png");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2038,8 +2036,8 @@ void EditorNode::_dialog_action(String p_file) {
|
|||
ERR_FAIL_COND(saving_resource.is_null());
|
||||
save_resource_in_path(saving_resource, p_file);
|
||||
saving_resource = Ref<Resource>();
|
||||
ObjectID current = editor_history.get_current();
|
||||
Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : nullptr;
|
||||
ObjectID current_id = editor_history.get_current();
|
||||
Object *current_obj = current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr;
|
||||
ERR_FAIL_COND(!current_obj);
|
||||
current_obj->notify_property_list_changed();
|
||||
} break;
|
||||
|
@ -2240,8 +2238,8 @@ static bool overrides_external_editor(Object *p_object) {
|
|||
}
|
||||
|
||||
void EditorNode::_edit_current(bool p_skip_foreign) {
|
||||
ObjectID current = editor_history.get_current();
|
||||
Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : nullptr;
|
||||
ObjectID current_id = editor_history.get_current();
|
||||
Object *current_obj = current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr;
|
||||
|
||||
Ref<Resource> res = Object::cast_to<Resource>(current_obj);
|
||||
if (p_skip_foreign && res.is_valid()) {
|
||||
|
@ -2691,9 +2689,9 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
|
|||
save_confirmation->set_text(TTR("Save modified resources before closing?"));
|
||||
}
|
||||
} else {
|
||||
Node *scene_root = editor_data.get_edited_scene_root(tab_closing_idx);
|
||||
if (scene_root) {
|
||||
String scene_filename = scene_root->get_scene_file_path();
|
||||
Node *ed_scene_root = editor_data.get_edited_scene_root(tab_closing_idx);
|
||||
if (ed_scene_root) {
|
||||
String scene_filename = ed_scene_root->get_scene_file_path();
|
||||
if (p_option == FILE_CLOSE_ALL_AND_RELOAD_CURRENT_PROJECT) {
|
||||
save_confirmation->set_ok_button_text(TTR("Save & Reload"));
|
||||
save_confirmation->set_text(vformat(TTR("Save changes to '%s' before reloading?"), !scene_filename.is_empty() ? scene_filename : "unsaved scene"));
|
||||
|
@ -3511,39 +3509,39 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled,
|
|||
}
|
||||
|
||||
String script_path = cf->get_value("plugin", "script");
|
||||
Ref<Script> script; // We need to save it for creating "ep" below.
|
||||
Ref<Script> scr; // We need to save it for creating "ep" below.
|
||||
|
||||
// Only try to load the script if it has a name. Else, the plugin has no init script.
|
||||
if (script_path.length() > 0) {
|
||||
script_path = addon_path.get_base_dir().path_join(script_path);
|
||||
script = ResourceLoader::load(script_path);
|
||||
scr = ResourceLoader::load(script_path);
|
||||
|
||||
if (script.is_null()) {
|
||||
if (scr.is_null()) {
|
||||
show_warning(vformat(TTR("Unable to load addon script from path: '%s'."), script_path));
|
||||
return;
|
||||
}
|
||||
|
||||
// Errors in the script cause the base_type to be an empty StringName.
|
||||
if (script->get_instance_base_type() == StringName()) {
|
||||
if (scr->get_instance_base_type() == StringName()) {
|
||||
show_warning(vformat(TTR("Unable to load addon script from path: '%s'. This might be due to a code error in that script.\nDisabling the addon at '%s' to prevent further errors."), script_path, addon_path));
|
||||
_remove_plugin_from_enabled(addon_path);
|
||||
return;
|
||||
}
|
||||
|
||||
// Plugin init scripts must inherit from EditorPlugin and be tools.
|
||||
if (String(script->get_instance_base_type()) != "EditorPlugin") {
|
||||
if (String(scr->get_instance_base_type()) != "EditorPlugin") {
|
||||
show_warning(vformat(TTR("Unable to load addon script from path: '%s' Base type is not EditorPlugin."), script_path));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!script->is_tool()) {
|
||||
if (!scr->is_tool()) {
|
||||
show_warning(vformat(TTR("Unable to load addon script from path: '%s' Script is not in tool mode."), script_path));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
EditorPlugin *ep = memnew(EditorPlugin);
|
||||
ep->set_script(script);
|
||||
ep->set_script(scr);
|
||||
addon_name_to_plugin[addon_path] = ep;
|
||||
add_editor_plugin(ep, p_config_changed);
|
||||
|
||||
|
@ -3641,17 +3639,17 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) {
|
|||
|
||||
changing_scene = false;
|
||||
|
||||
int current = -1;
|
||||
int current_tab = -1;
|
||||
for (int i = 0; i < editor_table.size(); i++) {
|
||||
if (editor_plugin_screen == editor_table[i]) {
|
||||
current = i;
|
||||
current_tab = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (p_state.has("editor_index")) {
|
||||
int index = p_state["editor_index"];
|
||||
if (current < 2) { // If currently in spatial/2d, only switch to spatial/2d. If currently in script, stay there.
|
||||
if (current_tab < 2) { // If currently in spatial/2d, only switch to spatial/2d. If currently in script, stay there.
|
||||
if (index < 2 || !get_edited_scene()) {
|
||||
editor_select(index);
|
||||
}
|
||||
|
@ -3659,7 +3657,7 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) {
|
|||
}
|
||||
|
||||
if (get_edited_scene()) {
|
||||
if (current < 2) {
|
||||
if (current_tab < 2) {
|
||||
// Use heuristic instead.
|
||||
int n2d = 0, n3d = 0;
|
||||
_find_node_types(get_edited_scene(), n2d, n3d);
|
||||
|
@ -3939,9 +3937,9 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
|
|||
|
||||
void EditorNode::open_request(const String &p_path) {
|
||||
if (!opening_prev) {
|
||||
List<String>::Element *prev_scene = previous_scenes.find(p_path);
|
||||
if (prev_scene != nullptr) {
|
||||
prev_scene->erase();
|
||||
List<String>::Element *prev_scene_item = previous_scenes.find(p_path);
|
||||
if (prev_scene_item != nullptr) {
|
||||
prev_scene_item->erase();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4192,9 +4190,9 @@ void EditorNode::stop_child_process(OS::ProcessID p_pid) {
|
|||
Ref<Script> EditorNode::get_object_custom_type_base(const Object *p_object) const {
|
||||
ERR_FAIL_COND_V(!p_object, nullptr);
|
||||
|
||||
Ref<Script> script = p_object->get_script();
|
||||
Ref<Script> scr = p_object->get_script();
|
||||
|
||||
if (script.is_valid()) {
|
||||
if (scr.is_valid()) {
|
||||
// Uncommenting would break things! Consider adding a parameter if you need it.
|
||||
// StringName name = EditorNode::get_editor_data().script_class_get_name(base_script->get_path());
|
||||
// if (name != StringName()) {
|
||||
|
@ -4202,18 +4200,18 @@ Ref<Script> EditorNode::get_object_custom_type_base(const Object *p_object) cons
|
|||
// }
|
||||
|
||||
// TODO: Should probably be deprecated in 4.x
|
||||
StringName base = script->get_instance_base_type();
|
||||
StringName base = scr->get_instance_base_type();
|
||||
if (base != StringName() && EditorNode::get_editor_data().get_custom_types().has(base)) {
|
||||
const Vector<EditorData::CustomType> &types = EditorNode::get_editor_data().get_custom_types()[base];
|
||||
|
||||
Ref<Script> base_script = script;
|
||||
while (base_script.is_valid()) {
|
||||
Ref<Script> base_scr = scr;
|
||||
while (base_scr.is_valid()) {
|
||||
for (int i = 0; i < types.size(); ++i) {
|
||||
if (types[i].script == base_script) {
|
||||
if (types[i].script == base_scr) {
|
||||
return types[i].script;
|
||||
}
|
||||
}
|
||||
base_script = base_script->get_base_script();
|
||||
base_scr = base_scr->get_base_script();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4224,30 +4222,30 @@ Ref<Script> EditorNode::get_object_custom_type_base(const Object *p_object) cons
|
|||
StringName EditorNode::get_object_custom_type_name(const Object *p_object) const {
|
||||
ERR_FAIL_COND_V(!p_object, StringName());
|
||||
|
||||
Ref<Script> script = p_object->get_script();
|
||||
if (script.is_null() && Object::cast_to<Script>(p_object)) {
|
||||
script = p_object;
|
||||
Ref<Script> scr = p_object->get_script();
|
||||
if (scr.is_null() && Object::cast_to<Script>(p_object)) {
|
||||
scr = p_object;
|
||||
}
|
||||
|
||||
if (script.is_valid()) {
|
||||
Ref<Script> base_script = script;
|
||||
while (base_script.is_valid()) {
|
||||
StringName name = EditorNode::get_editor_data().script_class_get_name(base_script->get_path());
|
||||
if (scr.is_valid()) {
|
||||
Ref<Script> base_scr = scr;
|
||||
while (base_scr.is_valid()) {
|
||||
StringName name = EditorNode::get_editor_data().script_class_get_name(base_scr->get_path());
|
||||
if (name != StringName()) {
|
||||
return name;
|
||||
}
|
||||
|
||||
// TODO: Should probably be deprecated in 4.x.
|
||||
StringName base = base_script->get_instance_base_type();
|
||||
StringName base = base_scr->get_instance_base_type();
|
||||
if (base != StringName() && EditorNode::get_editor_data().get_custom_types().has(base)) {
|
||||
const Vector<EditorData::CustomType> &types = EditorNode::get_editor_data().get_custom_types()[base];
|
||||
for (int i = 0; i < types.size(); ++i) {
|
||||
if (types[i].script == base_script) {
|
||||
if (types[i].script == base_scr) {
|
||||
return types[i].name;
|
||||
}
|
||||
}
|
||||
}
|
||||
base_script = base_script->get_base_script();
|
||||
base_scr = base_scr->get_base_script();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4291,40 +4289,40 @@ void EditorNode::_pick_main_scene_custom_action(const String &p_custom_action_na
|
|||
Ref<Texture2D> EditorNode::get_object_icon(const Object *p_object, const String &p_fallback) {
|
||||
ERR_FAIL_COND_V(!p_object || !gui_base, nullptr);
|
||||
|
||||
Ref<Script> script = p_object->get_script();
|
||||
if (script.is_null() && p_object->is_class("Script")) {
|
||||
script = p_object;
|
||||
Ref<Script> scr = p_object->get_script();
|
||||
if (scr.is_null() && p_object->is_class("Script")) {
|
||||
scr = p_object;
|
||||
}
|
||||
|
||||
if (script.is_valid() && !script_icon_cache.has(script)) {
|
||||
Ref<Script> base_script = script;
|
||||
while (base_script.is_valid()) {
|
||||
StringName name = EditorNode::get_editor_data().script_class_get_name(base_script->get_path());
|
||||
if (scr.is_valid() && !script_icon_cache.has(scr)) {
|
||||
Ref<Script> base_scr = scr;
|
||||
while (base_scr.is_valid()) {
|
||||
StringName name = EditorNode::get_editor_data().script_class_get_name(base_scr->get_path());
|
||||
String icon_path = EditorNode::get_editor_data().script_class_get_icon_path(name);
|
||||
Ref<ImageTexture> icon = _load_custom_class_icon(icon_path);
|
||||
if (icon.is_valid()) {
|
||||
script_icon_cache[script] = icon;
|
||||
script_icon_cache[scr] = icon;
|
||||
return icon;
|
||||
}
|
||||
|
||||
// TODO: should probably be deprecated in 4.x
|
||||
StringName base = base_script->get_instance_base_type();
|
||||
StringName base = base_scr->get_instance_base_type();
|
||||
if (base != StringName() && EditorNode::get_editor_data().get_custom_types().has(base)) {
|
||||
const Vector<EditorData::CustomType> &types = EditorNode::get_editor_data().get_custom_types()[base];
|
||||
for (int i = 0; i < types.size(); ++i) {
|
||||
if (types[i].script == base_script && types[i].icon.is_valid()) {
|
||||
script_icon_cache[script] = types[i].icon;
|
||||
if (types[i].script == base_scr && types[i].icon.is_valid()) {
|
||||
script_icon_cache[scr] = types[i].icon;
|
||||
return types[i].icon;
|
||||
}
|
||||
}
|
||||
}
|
||||
base_script = base_script->get_base_script();
|
||||
base_scr = base_scr->get_base_script();
|
||||
}
|
||||
|
||||
// If no icon found, cache it as null.
|
||||
script_icon_cache[script] = Ref<Texture>();
|
||||
} else if (script.is_valid() && script_icon_cache.has(script) && script_icon_cache[script].is_valid()) {
|
||||
return script_icon_cache[script];
|
||||
script_icon_cache[scr] = Ref<Texture>();
|
||||
} else if (scr.is_valid() && script_icon_cache.has(scr) && script_icon_cache[scr].is_valid()) {
|
||||
return script_icon_cache[scr];
|
||||
}
|
||||
|
||||
// TODO: Should probably be deprecated in 4.x.
|
||||
|
@ -4348,7 +4346,7 @@ Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p
|
|||
|
||||
if (ScriptServer::is_global_class(p_class)) {
|
||||
String class_name = p_class;
|
||||
Ref<Script> script = EditorNode::get_editor_data().script_class_load_script(class_name);
|
||||
Ref<Script> scr = EditorNode::get_editor_data().script_class_load_script(class_name);
|
||||
|
||||
while (true) {
|
||||
String icon_path = EditorNode::get_editor_data().script_class_get_icon_path(class_name);
|
||||
|
@ -4359,18 +4357,18 @@ Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p
|
|||
|
||||
// Find next global class along the inheritance chain.
|
||||
do {
|
||||
Ref<Script> base_script = script->get_base_script();
|
||||
if (base_script.is_null()) {
|
||||
Ref<Script> base_scr = scr->get_base_script();
|
||||
if (base_scr.is_null()) {
|
||||
// We've reached a native class, use its icon.
|
||||
String base_type;
|
||||
script->get_language()->get_global_class_name(script->get_path(), &base_type);
|
||||
scr->get_language()->get_global_class_name(scr->get_path(), &base_type);
|
||||
if (gui_base->has_theme_icon(base_type, "EditorIcons")) {
|
||||
return gui_base->get_theme_icon(base_type, "EditorIcons");
|
||||
}
|
||||
return gui_base->get_theme_icon(p_fallback, "EditorIcons");
|
||||
}
|
||||
script = base_script;
|
||||
class_name = EditorNode::get_editor_data().script_class_get_name(script->get_path());
|
||||
scr = base_scr;
|
||||
class_name = EditorNode::get_editor_data().script_class_get_name(scr->get_path());
|
||||
} while (class_name.is_empty());
|
||||
}
|
||||
}
|
||||
|
@ -4675,12 +4673,12 @@ void EditorNode::_dock_move_left() {
|
|||
if (dock_popup_selected_idx < 0 || dock_popup_selected_idx >= DOCK_SLOT_MAX) {
|
||||
return;
|
||||
}
|
||||
Control *current = dock_slot[dock_popup_selected_idx]->get_tab_control(dock_slot[dock_popup_selected_idx]->get_current_tab());
|
||||
Control *prev = dock_slot[dock_popup_selected_idx]->get_tab_control(dock_slot[dock_popup_selected_idx]->get_current_tab() - 1);
|
||||
if (!current || !prev) {
|
||||
Control *current_ctl = dock_slot[dock_popup_selected_idx]->get_tab_control(dock_slot[dock_popup_selected_idx]->get_current_tab());
|
||||
Control *prev_ctl = dock_slot[dock_popup_selected_idx]->get_tab_control(dock_slot[dock_popup_selected_idx]->get_current_tab() - 1);
|
||||
if (!current_ctl || !prev_ctl) {
|
||||
return;
|
||||
}
|
||||
dock_slot[dock_popup_selected_idx]->move_child(current, prev->get_index());
|
||||
dock_slot[dock_popup_selected_idx]->move_child(current_ctl, prev_ctl->get_index());
|
||||
dock_slot[dock_popup_selected_idx]->set_current_tab(dock_slot[dock_popup_selected_idx]->get_current_tab() - 1);
|
||||
dock_select->queue_redraw();
|
||||
_edit_current();
|
||||
|
@ -4688,12 +4686,12 @@ void EditorNode::_dock_move_left() {
|
|||
}
|
||||
|
||||
void EditorNode::_dock_move_right() {
|
||||
Control *current = dock_slot[dock_popup_selected_idx]->get_tab_control(dock_slot[dock_popup_selected_idx]->get_current_tab());
|
||||
Control *next = dock_slot[dock_popup_selected_idx]->get_tab_control(dock_slot[dock_popup_selected_idx]->get_current_tab() + 1);
|
||||
if (!current || !next) {
|
||||
Control *current_ctl = dock_slot[dock_popup_selected_idx]->get_tab_control(dock_slot[dock_popup_selected_idx]->get_current_tab());
|
||||
Control *next_ctl = dock_slot[dock_popup_selected_idx]->get_tab_control(dock_slot[dock_popup_selected_idx]->get_current_tab() + 1);
|
||||
if (!current_ctl || !next_ctl) {
|
||||
return;
|
||||
}
|
||||
dock_slot[dock_popup_selected_idx]->move_child(next, current->get_index());
|
||||
dock_slot[dock_popup_selected_idx]->move_child(next_ctl, current_ctl->get_index());
|
||||
dock_slot[dock_popup_selected_idx]->set_current_tab(dock_slot[dock_popup_selected_idx]->get_current_tab() + 1);
|
||||
dock_select->queue_redraw();
|
||||
_edit_current();
|
||||
|
@ -5283,9 +5281,9 @@ void EditorNode::_layout_menu_option(int p_id) {
|
|||
}
|
||||
|
||||
void EditorNode::_scene_tab_script_edited(int p_tab) {
|
||||
Ref<Script> script = editor_data.get_scene_root_script(p_tab);
|
||||
if (script.is_valid()) {
|
||||
InspectorDock::get_singleton()->edit_resource(script);
|
||||
Ref<Script> scr = editor_data.get_scene_root_script(p_tab);
|
||||
if (scr.is_valid()) {
|
||||
InspectorDock::get_singleton()->edit_resource(scr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ void EditorPath::_add_children_to_popup(Object *p_obj, int p_depth) {
|
|||
continue;
|
||||
}
|
||||
|
||||
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(obj);
|
||||
Ref<Texture2D> obj_icon = EditorNode::get_singleton()->get_object_icon(obj);
|
||||
|
||||
String proper_name = "";
|
||||
Vector<String> name_parts = E.name.split("/");
|
||||
|
@ -72,7 +72,7 @@ void EditorPath::_add_children_to_popup(Object *p_obj, int p_depth) {
|
|||
}
|
||||
|
||||
int index = sub_objects_menu->get_item_count();
|
||||
sub_objects_menu->add_icon_item(icon, proper_name, objects.size());
|
||||
sub_objects_menu->add_icon_item(obj_icon, proper_name, objects.size());
|
||||
sub_objects_menu->set_item_indent(index, p_depth);
|
||||
objects.push_back(obj->get_instance_id());
|
||||
|
||||
|
@ -122,15 +122,15 @@ void EditorPath::update_path() {
|
|||
continue;
|
||||
}
|
||||
|
||||
Ref<Texture2D> icon;
|
||||
Ref<Texture2D> obj_icon;
|
||||
if (Object::cast_to<MultiNodeEdit>(obj)) {
|
||||
icon = EditorNode::get_singleton()->get_class_icon(Object::cast_to<MultiNodeEdit>(obj)->get_edited_class_name());
|
||||
obj_icon = EditorNode::get_singleton()->get_class_icon(Object::cast_to<MultiNodeEdit>(obj)->get_edited_class_name());
|
||||
} else {
|
||||
icon = EditorNode::get_singleton()->get_object_icon(obj);
|
||||
obj_icon = EditorNode::get_singleton()->get_object_icon(obj);
|
||||
}
|
||||
|
||||
if (icon.is_valid()) {
|
||||
current_object_icon->set_texture(icon);
|
||||
if (obj_icon.is_valid()) {
|
||||
current_object_icon->set_texture(obj_icon);
|
||||
}
|
||||
|
||||
if (i == history->get_path_size() - 1) {
|
||||
|
|
|
@ -570,7 +570,7 @@ void EditorPlugin::notify_resource_saved(const Ref<Resource> &p_resource) {
|
|||
}
|
||||
|
||||
bool EditorPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p_event) {
|
||||
bool success;
|
||||
bool success = false;
|
||||
if (GDVIRTUAL_CALL(_forward_canvas_gui_input, p_event, success)) {
|
||||
return success;
|
||||
}
|
||||
|
@ -605,7 +605,7 @@ int EditorPlugin::update_overlays() const {
|
|||
}
|
||||
|
||||
EditorPlugin::AfterGUIInput EditorPlugin::forward_3d_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) {
|
||||
int success;
|
||||
int success = EditorPlugin::AFTER_GUI_INPUT_PASS;
|
||||
|
||||
if (GDVIRTUAL_CALL(_forward_3d_gui_input, p_camera, p_event, success)) {
|
||||
return static_cast<EditorPlugin::AfterGUIInput>(success);
|
||||
|
@ -662,7 +662,7 @@ void EditorPlugin::edit(Object *p_object) {
|
|||
}
|
||||
|
||||
bool EditorPlugin::handles(Object *p_object) const {
|
||||
bool success;
|
||||
bool success = false;
|
||||
if (GDVIRTUAL_CALL(_handles, p_object, success)) {
|
||||
return success;
|
||||
}
|
||||
|
|
|
@ -98,14 +98,14 @@ void EditorPluginSettings::update_plugins() {
|
|||
String author = cf->get_value("plugin", "author");
|
||||
String version = cf->get_value("plugin", "version");
|
||||
String description = cf->get_value("plugin", "description");
|
||||
String script = cf->get_value("plugin", "script");
|
||||
String scr = cf->get_value("plugin", "script");
|
||||
|
||||
TreeItem *item = plugin_list->create_item(root);
|
||||
item->set_text(0, name);
|
||||
item->set_tooltip_text(0, TTR("Name:") + " " + name + "\n" + TTR("Path:") + " " + path + "\n" + TTR("Main Script:") + " " + script + "\n" + TTR("Description:") + " " + description);
|
||||
item->set_tooltip_text(0, TTR("Name:") + " " + name + "\n" + TTR("Path:") + " " + path + "\n" + TTR("Main Script:") + " " + scr + "\n" + TTR("Description:") + " " + description);
|
||||
item->set_metadata(0, path);
|
||||
item->set_text(1, version);
|
||||
item->set_metadata(1, script);
|
||||
item->set_metadata(1, scr);
|
||||
item->set_text(2, author);
|
||||
item->set_metadata(2, description);
|
||||
item->set_cell_mode(3, TreeItem::CELL_MODE_CHECK);
|
||||
|
|
|
@ -51,9 +51,9 @@ void EditorPropertyNil::update_property() {
|
|||
}
|
||||
|
||||
EditorPropertyNil::EditorPropertyNil() {
|
||||
Label *label = memnew(Label);
|
||||
label->set_text("<null>");
|
||||
add_child(label);
|
||||
Label *prop_label = memnew(Label);
|
||||
prop_label->set_text("<null>");
|
||||
add_child(prop_label);
|
||||
}
|
||||
|
||||
///////////////////// TEXT /////////////////////////
|
||||
|
@ -3644,8 +3644,8 @@ bool EditorPropertyNodePath::can_drop_data_fw(const Point2 &p_point, const Varia
|
|||
|
||||
void EditorPropertyNodePath::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
|
||||
ERR_FAIL_COND(!is_drop_valid(p_data));
|
||||
Dictionary data = p_data;
|
||||
Array nodes = data["nodes"];
|
||||
Dictionary data_dict = p_data;
|
||||
Array nodes = data_dict["nodes"];
|
||||
Node *node = get_tree()->get_edited_scene_root()->get_node(nodes[0]);
|
||||
|
||||
if (node) {
|
||||
|
@ -3973,19 +3973,19 @@ void EditorPropertyResource::_update_preferred_shader() {
|
|||
|
||||
if (parent_property) {
|
||||
EditorShaderPicker *shader_picker = Object::cast_to<EditorShaderPicker>(resource_picker);
|
||||
Object *object = parent_property->get_edited_object();
|
||||
const StringName &property = parent_property->get_edited_property();
|
||||
Object *ed_object = parent_property->get_edited_object();
|
||||
const StringName &ed_property = parent_property->get_edited_property();
|
||||
|
||||
// Set preferred shader based on edited parent type.
|
||||
if ((Object::cast_to<GPUParticles2D>(object) || Object::cast_to<GPUParticles3D>(object)) && property == SNAME("process_material")) {
|
||||
if ((Object::cast_to<GPUParticles2D>(ed_object) || Object::cast_to<GPUParticles3D>(ed_object)) && ed_property == SNAME("process_material")) {
|
||||
shader_picker->set_preferred_mode(Shader::MODE_PARTICLES);
|
||||
} else if (Object::cast_to<FogVolume>(object)) {
|
||||
} else if (Object::cast_to<FogVolume>(ed_object)) {
|
||||
shader_picker->set_preferred_mode(Shader::MODE_FOG);
|
||||
} else if (Object::cast_to<CanvasItem>(object)) {
|
||||
} else if (Object::cast_to<CanvasItem>(ed_object)) {
|
||||
shader_picker->set_preferred_mode(Shader::MODE_CANVAS_ITEM);
|
||||
} else if (Object::cast_to<Node3D>(object) || Object::cast_to<Mesh>(object)) {
|
||||
} else if (Object::cast_to<Node3D>(ed_object) || Object::cast_to<Mesh>(ed_object)) {
|
||||
shader_picker->set_preferred_mode(Shader::MODE_SPATIAL);
|
||||
} else if (Object::cast_to<Sky>(object)) {
|
||||
} else if (Object::cast_to<Sky>(ed_object)) {
|
||||
shader_picker->set_preferred_mode(Shader::MODE_SKY);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -260,9 +260,9 @@ void EditorPropertyArray::update_property() {
|
|||
HBoxContainer *hbox = memnew(HBoxContainer);
|
||||
vbox->add_child(hbox);
|
||||
|
||||
Label *label = memnew(Label(TTR("Size:")));
|
||||
label->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
hbox->add_child(label);
|
||||
Label *size_label = memnew(Label(TTR("Size:")));
|
||||
size_label->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
hbox->add_child(size_label);
|
||||
|
||||
size_slider = memnew(EditorSpinSlider);
|
||||
size_slider->set_step(1);
|
||||
|
@ -367,17 +367,17 @@ void EditorPropertyArray::update_property() {
|
|||
bool is_untyped_array = array.get_type() == Variant::ARRAY && subtype == Variant::NIL;
|
||||
|
||||
if (is_untyped_array) {
|
||||
Button *edit = memnew(Button);
|
||||
edit->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")));
|
||||
hbox->add_child(edit);
|
||||
edit->set_disabled(is_read_only());
|
||||
edit->connect("pressed", callable_mp(this, &EditorPropertyArray::_change_type).bind(edit, i + offset));
|
||||
Button *edit_btn = memnew(Button);
|
||||
edit_btn->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")));
|
||||
hbox->add_child(edit_btn);
|
||||
edit_btn->set_disabled(is_read_only());
|
||||
edit_btn->connect("pressed", callable_mp(this, &EditorPropertyArray::_change_type).bind(edit_btn, i + offset));
|
||||
} else {
|
||||
Button *remove = memnew(Button);
|
||||
remove->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
|
||||
remove->set_disabled(is_read_only());
|
||||
remove->connect("pressed", callable_mp(this, &EditorPropertyArray::_remove_pressed).bind(i + offset));
|
||||
hbox->add_child(remove);
|
||||
Button *remove_btn = memnew(Button);
|
||||
remove_btn->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
|
||||
remove_btn->set_disabled(is_read_only());
|
||||
remove_btn->connect("pressed", callable_mp(this, &EditorPropertyArray::_remove_pressed).bind(i + offset));
|
||||
hbox->add_child(remove_btn);
|
||||
}
|
||||
|
||||
prop->update_property();
|
||||
|
@ -1155,11 +1155,11 @@ void EditorPropertyDictionary::update_property() {
|
|||
}
|
||||
hbox->add_child(prop);
|
||||
prop->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
Button *edit = memnew(Button);
|
||||
edit->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")));
|
||||
edit->set_disabled(is_read_only());
|
||||
hbox->add_child(edit);
|
||||
edit->connect("pressed", callable_mp(this, &EditorPropertyDictionary::_change_type).bind(edit, change_index));
|
||||
Button *edit_btn = memnew(Button);
|
||||
edit_btn->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")));
|
||||
edit_btn->set_disabled(is_read_only());
|
||||
hbox->add_child(edit_btn);
|
||||
edit_btn->connect("pressed", callable_mp(this, &EditorPropertyDictionary::_change_type).bind(edit_btn, change_index));
|
||||
|
||||
prop->update_property();
|
||||
|
||||
|
@ -1396,10 +1396,10 @@ void EditorPropertyLocalizableString::update_property() {
|
|||
property_vbox->add_child(hbox);
|
||||
hbox->add_child(prop);
|
||||
prop->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
Button *edit = memnew(Button);
|
||||
edit->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
|
||||
hbox->add_child(edit);
|
||||
edit->connect("pressed", callable_mp(this, &EditorPropertyLocalizableString::_remove_item).bind(edit, remove_index));
|
||||
Button *edit_btn = memnew(Button);
|
||||
edit_btn->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
|
||||
hbox->add_child(edit_btn);
|
||||
edit_btn->connect("pressed", callable_mp(this, &EditorPropertyLocalizableString::_remove_item).bind(edit_btn, remove_index));
|
||||
|
||||
prop->update_property();
|
||||
}
|
||||
|
|
|
@ -96,9 +96,9 @@ void EditorResourcePicker::_update_resource_preview(const String &p_path, const
|
|||
}
|
||||
|
||||
if (preview_rect) {
|
||||
Ref<Script> script = edited_resource;
|
||||
if (script.is_valid()) {
|
||||
assign_button->set_text(script->get_path().get_file());
|
||||
Ref<Script> scr = edited_resource;
|
||||
if (scr.is_valid()) {
|
||||
assign_button->set_text(scr->get_path().get_file());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -981,8 +981,8 @@ void EditorScriptPicker::set_create_options(Object *p_menu_node) {
|
|||
|
||||
menu_node->add_icon_item(get_theme_icon(SNAME("ScriptCreate"), SNAME("EditorIcons")), TTR("New Script"), OBJ_MENU_NEW_SCRIPT);
|
||||
if (script_owner) {
|
||||
Ref<Script> script = script_owner->get_script();
|
||||
if (script.is_valid()) {
|
||||
Ref<Script> scr = script_owner->get_script();
|
||||
if (scr.is_valid()) {
|
||||
menu_node->add_icon_item(get_theme_icon(SNAME("ScriptExtend"), SNAME("EditorIcons")), TTR("Extend Script"), OBJ_MENU_EXTEND_SCRIPT);
|
||||
}
|
||||
}
|
||||
|
@ -1040,12 +1040,12 @@ void EditorShaderPicker::set_create_options(Object *p_menu_node) {
|
|||
}
|
||||
|
||||
bool EditorShaderPicker::handle_menu_selected(int p_which) {
|
||||
Ref<ShaderMaterial> material = Ref<ShaderMaterial>(get_edited_material());
|
||||
Ref<ShaderMaterial> ed_material = Ref<ShaderMaterial>(get_edited_material());
|
||||
|
||||
switch (p_which) {
|
||||
case OBJ_MENU_NEW_SHADER: {
|
||||
if (material.is_valid()) {
|
||||
SceneTreeDock::get_singleton()->open_shader_dialog(material, preferred_mode);
|
||||
if (ed_material.is_valid()) {
|
||||
SceneTreeDock::get_singleton()->open_shader_dialog(ed_material, preferred_mode);
|
||||
return true;
|
||||
}
|
||||
} break;
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "editor/editor_settings.h"
|
||||
|
||||
bool EditorResourcePreviewGenerator::handles(const String &p_type) const {
|
||||
bool success;
|
||||
bool success = false;
|
||||
if (GDVIRTUAL_CALL(_handles, p_type, success)) {
|
||||
return success;
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ Ref<Texture2D> EditorResourcePreviewGenerator::generate_from_path(const String &
|
|||
}
|
||||
|
||||
bool EditorResourcePreviewGenerator::generate_small_preview_automatically() const {
|
||||
bool success;
|
||||
bool success = false;
|
||||
if (GDVIRTUAL_CALL(_generate_small_preview_automatically, success)) {
|
||||
return success;
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ bool EditorResourcePreviewGenerator::generate_small_preview_automatically() cons
|
|||
}
|
||||
|
||||
bool EditorResourcePreviewGenerator::can_generate_small_preview() const {
|
||||
bool success;
|
||||
bool success = false;
|
||||
if (GDVIRTUAL_CALL(_can_generate_small_preview, success)) {
|
||||
return success;
|
||||
}
|
||||
|
|
|
@ -226,9 +226,9 @@ void SectionedInspector::update_category_list() {
|
|||
TreeItem *root = sections->create_item();
|
||||
section_map[""] = root;
|
||||
|
||||
String filter;
|
||||
String filter_text;
|
||||
if (search_box) {
|
||||
filter = search_box->get_text();
|
||||
filter_text = search_box->get_text();
|
||||
}
|
||||
|
||||
const EditorPropertyNameProcessor::Style name_style = EditorPropertyNameProcessor::get_settings_style();
|
||||
|
@ -245,7 +245,7 @@ void SectionedInspector::update_category_list() {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!filter.is_empty() && !_property_path_matches(pi.name, filter, name_style)) {
|
||||
if (!filter_text.is_empty() && !_property_path_matches(pi.name, filter_text, name_style)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -76,14 +76,14 @@ bool EditorSettings::_set_only(const StringName &p_name, const Variant &p_value)
|
|||
Array arr = p_value;
|
||||
for (int i = 0; i < arr.size(); i++) {
|
||||
Dictionary dict = arr[i];
|
||||
String name = dict["name"];
|
||||
String shortcut_name = dict["name"];
|
||||
|
||||
Array shortcut_events = dict["shortcuts"];
|
||||
|
||||
Ref<Shortcut> sc;
|
||||
sc.instantiate();
|
||||
sc->set_events(shortcut_events);
|
||||
add_shortcut(name, sc);
|
||||
add_shortcut(shortcut_name, sc);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -92,16 +92,16 @@ bool EditorSettings::_set_only(const StringName &p_name, const Variant &p_value)
|
|||
for (int i = 0; i < actions_arr.size(); i++) {
|
||||
Dictionary action_dict = actions_arr[i];
|
||||
|
||||
String name = action_dict["name"];
|
||||
String action_name = action_dict["name"];
|
||||
Array events = action_dict["events"];
|
||||
|
||||
InputMap *im = InputMap::get_singleton();
|
||||
im->action_erase_events(name);
|
||||
im->action_erase_events(action_name);
|
||||
|
||||
builtin_action_overrides[name].clear();
|
||||
builtin_action_overrides[action_name].clear();
|
||||
for (int ev_idx = 0; ev_idx < events.size(); ev_idx++) {
|
||||
im->action_add_event(name, events[ev_idx]);
|
||||
builtin_action_overrides[name].push_back(events[ev_idx]);
|
||||
im->action_add_event(action_name, events[ev_idx]);
|
||||
builtin_action_overrides[action_name].push_back(events[ev_idx]);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -735,8 +735,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
|
|||
if (p_extra_config->has_section("init_projects") && p_extra_config->has_section_key("init_projects", "list")) {
|
||||
Vector<String> list = p_extra_config->get_value("init_projects", "list");
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
String name = list[i].replace("/", "::");
|
||||
set("projects/" + name, list[i]);
|
||||
String proj_name = list[i].replace("/", "::");
|
||||
set("projects/" + proj_name, list[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -78,19 +78,19 @@ void EditorToaster::_notification(int p_what) {
|
|||
// Change alpha over time.
|
||||
bool needs_update = false;
|
||||
for (const KeyValue<Control *, Toast> &element : toasts) {
|
||||
Color modulate = element.key->get_modulate();
|
||||
Color modulate_fade = element.key->get_modulate();
|
||||
|
||||
// Change alpha over time.
|
||||
if (element.value.popped && modulate.a < 1.0) {
|
||||
modulate.a += delta * 3;
|
||||
element.key->set_modulate(modulate);
|
||||
} else if (!element.value.popped && modulate.a > 0.0) {
|
||||
modulate.a -= delta * 2;
|
||||
element.key->set_modulate(modulate);
|
||||
if (element.value.popped && modulate_fade.a < 1.0) {
|
||||
modulate_fade.a += delta * 3;
|
||||
element.key->set_modulate(modulate_fade);
|
||||
} else if (!element.value.popped && modulate_fade.a > 0.0) {
|
||||
modulate_fade.a -= delta * 2;
|
||||
element.key->set_modulate(modulate_fade);
|
||||
}
|
||||
|
||||
// Hide element if it is not visible anymore.
|
||||
if (modulate.a <= 0) {
|
||||
if (modulate_fade.a <= 0) {
|
||||
if (element.key->is_visible()) {
|
||||
element.key->hide();
|
||||
needs_update = true;
|
||||
|
@ -317,7 +317,7 @@ void EditorToaster::_set_notifications_enabled(bool p_enabled) {
|
|||
void EditorToaster::_repop_old() {
|
||||
// Repop olds, up to max_temporary_count
|
||||
bool needs_update = false;
|
||||
int visible = 0;
|
||||
int visible_count = 0;
|
||||
for (int i = vbox_container->get_child_count() - 1; i >= 0; i--) {
|
||||
Control *control = Object::cast_to<Control>(vbox_container->get_child(i));
|
||||
if (!control->is_visible()) {
|
||||
|
@ -326,8 +326,8 @@ void EditorToaster::_repop_old() {
|
|||
toasts[control].popped = true;
|
||||
needs_update = true;
|
||||
}
|
||||
visible++;
|
||||
if (visible >= max_temporary_count) {
|
||||
visible_count++;
|
||||
if (visible_count >= max_temporary_count) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -265,9 +265,9 @@ void ExportTemplateManager::_refresh_mirrors_completed(int p_status, int p_code,
|
|||
|
||||
mirrors_available = false;
|
||||
|
||||
Dictionary data = json.get_data();
|
||||
if (data.has("mirrors")) {
|
||||
Array mirrors = data["mirrors"];
|
||||
Dictionary mirror_data = json.get_data();
|
||||
if (mirror_data.has("mirrors")) {
|
||||
Array mirrors = mirror_data["mirrors"];
|
||||
|
||||
for (int i = 0; i < mirrors.size(); i++) {
|
||||
Dictionary m = mirrors[i];
|
||||
|
@ -401,17 +401,17 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_
|
|||
|
||||
String file = String::utf8(fname);
|
||||
if (file.ends_with("version.txt")) {
|
||||
Vector<uint8_t> data;
|
||||
data.resize(info.uncompressed_size);
|
||||
Vector<uint8_t> uncomp_data;
|
||||
uncomp_data.resize(info.uncompressed_size);
|
||||
|
||||
// Read.
|
||||
unzOpenCurrentFile(pkg);
|
||||
ret = unzReadCurrentFile(pkg, data.ptrw(), data.size());
|
||||
ret = unzReadCurrentFile(pkg, uncomp_data.ptrw(), uncomp_data.size());
|
||||
ERR_BREAK_MSG(ret < 0, vformat("An error occurred while attempting to read from file: %s. This file will not be used.", file));
|
||||
unzCloseCurrentFile(pkg);
|
||||
|
||||
String data_str;
|
||||
data_str.parse_utf8((const char *)data.ptr(), data.size());
|
||||
data_str.parse_utf8((const char *)uncomp_data.ptr(), uncomp_data.size());
|
||||
data_str = data_str.strip_edges();
|
||||
|
||||
// Version number should be of the form major.minor[.patch].status[.module_config]
|
||||
|
@ -473,12 +473,12 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_
|
|||
continue;
|
||||
}
|
||||
|
||||
Vector<uint8_t> data;
|
||||
data.resize(info.uncompressed_size);
|
||||
Vector<uint8_t> uncomp_data;
|
||||
uncomp_data.resize(info.uncompressed_size);
|
||||
|
||||
// Read
|
||||
unzOpenCurrentFile(pkg);
|
||||
ret = unzReadCurrentFile(pkg, data.ptrw(), data.size());
|
||||
ret = unzReadCurrentFile(pkg, uncomp_data.ptrw(), uncomp_data.size());
|
||||
ERR_BREAK_MSG(ret < 0, vformat("An error occurred while attempting to read from file: %s. This file will not be used.", file));
|
||||
unzCloseCurrentFile(pkg);
|
||||
|
||||
|
@ -512,7 +512,7 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_
|
|||
ERR_CONTINUE_MSG(true, "Can't open file from path '" + String(to_write) + "'.");
|
||||
}
|
||||
|
||||
f->store_buffer(data.ptr(), data.size());
|
||||
f->store_buffer(uncomp_data.ptr(), uncomp_data.size());
|
||||
f.unref(); // close file.
|
||||
#ifndef WINDOWS_ENABLED
|
||||
FileAccess::set_unix_permissions(to_write, (info.external_fa >> 16) & 0x01FF);
|
||||
|
@ -714,12 +714,12 @@ Error ExportTemplateManager::install_android_template_from_file(const String &p_
|
|||
String base_dir = path.get_base_dir();
|
||||
|
||||
if (!path.ends_with("/")) {
|
||||
Vector<uint8_t> data;
|
||||
data.resize(info.uncompressed_size);
|
||||
Vector<uint8_t> uncomp_data;
|
||||
uncomp_data.resize(info.uncompressed_size);
|
||||
|
||||
// Read.
|
||||
unzOpenCurrentFile(pkg);
|
||||
unzReadCurrentFile(pkg, data.ptrw(), data.size());
|
||||
unzReadCurrentFile(pkg, uncomp_data.ptrw(), uncomp_data.size());
|
||||
unzCloseCurrentFile(pkg);
|
||||
|
||||
if (!dirs_tested.has(base_dir)) {
|
||||
|
@ -730,7 +730,7 @@ Error ExportTemplateManager::install_android_template_from_file(const String &p_
|
|||
String to_write = String("res://android/build").path_join(path);
|
||||
Ref<FileAccess> f = FileAccess::open(to_write, FileAccess::WRITE);
|
||||
if (f.is_valid()) {
|
||||
f->store_buffer(data.ptr(), data.size());
|
||||
f->store_buffer(uncomp_data.ptr(), uncomp_data.size());
|
||||
f.unref(); // close file.
|
||||
#ifndef WINDOWS_ENABLED
|
||||
FileAccess::set_unix_permissions(to_write, (info.external_fa >> 16) & 0x01FF);
|
||||
|
|
|
@ -94,7 +94,7 @@ void ProjectExportDialog::_add_preset(int p_platform) {
|
|||
Ref<EditorExportPreset> preset = EditorExport::get_singleton()->get_export_platform(p_platform)->create_preset();
|
||||
ERR_FAIL_COND(!preset.is_valid());
|
||||
|
||||
String name = EditorExport::get_singleton()->get_export_platform(p_platform)->get_name();
|
||||
String preset_name = EditorExport::get_singleton()->get_export_platform(p_platform)->get_name();
|
||||
bool make_runnable = true;
|
||||
int attempt = 1;
|
||||
while (true) {
|
||||
|
@ -105,7 +105,7 @@ void ProjectExportDialog::_add_preset(int p_platform) {
|
|||
if (p->get_platform() == preset->get_platform() && p->is_runnable()) {
|
||||
make_runnable = false;
|
||||
}
|
||||
if (p->get_name() == name) {
|
||||
if (p->get_name() == preset_name) {
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
|
@ -116,10 +116,10 @@ void ProjectExportDialog::_add_preset(int p_platform) {
|
|||
}
|
||||
|
||||
attempt++;
|
||||
name = EditorExport::get_singleton()->get_export_platform(p_platform)->get_name() + " " + itos(attempt);
|
||||
preset_name = EditorExport::get_singleton()->get_export_platform(p_platform)->get_name() + " " + itos(attempt);
|
||||
}
|
||||
|
||||
preset->set_name(name);
|
||||
preset->set_name(preset_name);
|
||||
if (make_runnable) {
|
||||
preset->set_runnable(make_runnable);
|
||||
}
|
||||
|
@ -154,12 +154,12 @@ void ProjectExportDialog::_update_presets() {
|
|||
current_idx = i;
|
||||
}
|
||||
|
||||
String name = preset->get_name();
|
||||
String preset_name = preset->get_name();
|
||||
if (preset->is_runnable()) {
|
||||
name += " (" + TTR("Runnable") + ")";
|
||||
preset_name += " (" + TTR("Runnable") + ")";
|
||||
}
|
||||
preset->update_files_to_export();
|
||||
presets->add_item(name, preset->get_platform()->get_logo());
|
||||
presets->add_item(preset_name, preset->get_platform()->get_logo());
|
||||
}
|
||||
|
||||
if (current_idx != -1) {
|
||||
|
@ -552,7 +552,7 @@ void ProjectExportDialog::_duplicate_preset() {
|
|||
Ref<EditorExportPreset> preset = current->get_platform()->create_preset();
|
||||
ERR_FAIL_COND(!preset.is_valid());
|
||||
|
||||
String name = current->get_name() + " (copy)";
|
||||
String preset_name = current->get_name() + " (copy)";
|
||||
bool make_runnable = true;
|
||||
while (true) {
|
||||
bool valid = true;
|
||||
|
@ -562,7 +562,7 @@ void ProjectExportDialog::_duplicate_preset() {
|
|||
if (p->get_platform() == preset->get_platform() && p->is_runnable()) {
|
||||
make_runnable = false;
|
||||
}
|
||||
if (p->get_name() == name) {
|
||||
if (p->get_name() == preset_name) {
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
|
@ -572,10 +572,10 @@ void ProjectExportDialog::_duplicate_preset() {
|
|||
break;
|
||||
}
|
||||
|
||||
name += " (copy)";
|
||||
preset_name += " (copy)";
|
||||
}
|
||||
|
||||
preset->set_name(name);
|
||||
preset->set_name(preset_name);
|
||||
if (make_runnable) {
|
||||
preset->set_runnable(make_runnable);
|
||||
}
|
||||
|
@ -945,8 +945,8 @@ void ProjectExportDialog::_export_all_dialog_action(const String &p_str) {
|
|||
}
|
||||
|
||||
void ProjectExportDialog::_export_all(bool p_debug) {
|
||||
String mode = p_debug ? TTR("Debug") : TTR("Release");
|
||||
EditorProgress ep("exportall", TTR("Exporting All") + " " + mode, EditorExport::get_singleton()->get_export_preset_count(), true);
|
||||
String export_target = p_debug ? TTR("Debug") : TTR("Release");
|
||||
EditorProgress ep("exportall", TTR("Exporting All") + " " + export_target, EditorExport::get_singleton()->get_export_preset_count(), true);
|
||||
|
||||
bool show_dialog = false;
|
||||
result_dialog_log->clear();
|
||||
|
|
|
@ -218,11 +218,11 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo
|
|||
TreeItem *root = tree->create_item();
|
||||
|
||||
// Handles the favorites.
|
||||
TreeItem *favorites = tree->create_item(root);
|
||||
favorites->set_icon(0, get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons")));
|
||||
favorites->set_text(0, TTR("Favorites:"));
|
||||
favorites->set_metadata(0, "Favorites");
|
||||
favorites->set_collapsed(p_uncollapsed_paths.find("Favorites") < 0);
|
||||
TreeItem *favorites_item = tree->create_item(root);
|
||||
favorites_item->set_icon(0, get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons")));
|
||||
favorites_item->set_text(0, TTR("Favorites:"));
|
||||
favorites_item->set_metadata(0, "Favorites");
|
||||
favorites_item->set_collapsed(p_uncollapsed_paths.find("Favorites") < 0);
|
||||
|
||||
Vector<String> favorite_paths = EditorSettings::get_singleton()->get_favorites();
|
||||
|
||||
|
@ -272,7 +272,7 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo
|
|||
}
|
||||
|
||||
if (searched_string.length() == 0 || text.to_lower().find(searched_string) >= 0) {
|
||||
TreeItem *ti = tree->create_item(favorites);
|
||||
TreeItem *ti = tree->create_item(favorites_item);
|
||||
ti->set_text(0, text);
|
||||
ti->set_icon(0, icon);
|
||||
ti->set_icon_modulate(0, color);
|
||||
|
@ -784,9 +784,8 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) {
|
|||
List<FileInfo> file_list;
|
||||
if (path == "Favorites") {
|
||||
// Display the favorites.
|
||||
Vector<String> favorites = EditorSettings::get_singleton()->get_favorites();
|
||||
for (int i = 0; i < favorites.size(); i++) {
|
||||
String favorite = favorites[i];
|
||||
Vector<String> favorites_list = EditorSettings::get_singleton()->get_favorites();
|
||||
for (const String &favorite : favorites_list) {
|
||||
String text;
|
||||
Ref<Texture2D> icon;
|
||||
if (favorite == "res://") {
|
||||
|
@ -1056,15 +1055,15 @@ void FileSystemDock::_select_file(const String &p_path, bool p_select_in_favorit
|
|||
void FileSystemDock::_tree_activate_file() {
|
||||
TreeItem *selected = tree->get_selected();
|
||||
if (selected) {
|
||||
String path = selected->get_metadata(0);
|
||||
String file_path = selected->get_metadata(0);
|
||||
TreeItem *parent = selected->get_parent();
|
||||
bool is_favorite = parent != nullptr && parent->get_metadata(0) == "Favorites";
|
||||
|
||||
if ((!is_favorite && path.ends_with("/")) || path == "Favorites") {
|
||||
if ((!is_favorite && file_path.ends_with("/")) || file_path == "Favorites") {
|
||||
bool collapsed = selected->is_collapsed();
|
||||
selected->set_collapsed(!collapsed);
|
||||
} else {
|
||||
_select_file(path, is_favorite && !path.ends_with("/"));
|
||||
_select_file(file_path, is_favorite && !file_path.ends_with("/"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1169,29 +1168,29 @@ void FileSystemDock::_push_to_history() {
|
|||
button_hist_next->set_disabled(history_pos == history.size() - 1);
|
||||
}
|
||||
|
||||
void FileSystemDock::_get_all_items_in_dir(EditorFileSystemDirectory *efsd, Vector<String> &files, Vector<String> &folders) const {
|
||||
if (efsd == nullptr) {
|
||||
void FileSystemDock::_get_all_items_in_dir(EditorFileSystemDirectory *p_efsd, Vector<String> &r_files, Vector<String> &r_folders) const {
|
||||
if (p_efsd == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < efsd->get_subdir_count(); i++) {
|
||||
folders.push_back(efsd->get_subdir(i)->get_path());
|
||||
_get_all_items_in_dir(efsd->get_subdir(i), files, folders);
|
||||
for (int i = 0; i < p_efsd->get_subdir_count(); i++) {
|
||||
r_folders.push_back(p_efsd->get_subdir(i)->get_path());
|
||||
_get_all_items_in_dir(p_efsd->get_subdir(i), r_files, r_folders);
|
||||
}
|
||||
for (int i = 0; i < efsd->get_file_count(); i++) {
|
||||
files.push_back(efsd->get_file_path(i));
|
||||
for (int i = 0; i < p_efsd->get_file_count(); i++) {
|
||||
r_files.push_back(p_efsd->get_file_path(i));
|
||||
}
|
||||
}
|
||||
|
||||
void FileSystemDock::_find_remaps(EditorFileSystemDirectory *efsd, const HashMap<String, String> &renames, Vector<String> &to_remaps) const {
|
||||
for (int i = 0; i < efsd->get_subdir_count(); i++) {
|
||||
_find_remaps(efsd->get_subdir(i), renames, to_remaps);
|
||||
void FileSystemDock::_find_remaps(EditorFileSystemDirectory *p_efsd, const HashMap<String, String> &r_renames, Vector<String> &r_to_remaps) const {
|
||||
for (int i = 0; i < p_efsd->get_subdir_count(); i++) {
|
||||
_find_remaps(p_efsd->get_subdir(i), r_renames, r_to_remaps);
|
||||
}
|
||||
for (int i = 0; i < efsd->get_file_count(); i++) {
|
||||
Vector<String> deps = efsd->get_file_deps(i);
|
||||
for (int i = 0; i < p_efsd->get_file_count(); i++) {
|
||||
Vector<String> deps = p_efsd->get_file_deps(i);
|
||||
for (int j = 0; j < deps.size(); j++) {
|
||||
if (renames.has(deps[j])) {
|
||||
to_remaps.push_back(efsd->get_file_path(i));
|
||||
if (r_renames.has(deps[j])) {
|
||||
r_to_remaps.push_back(p_efsd->get_file_path(i));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1345,25 +1344,25 @@ void FileSystemDock::_update_resource_paths_after_move(const HashMap<String, Str
|
|||
}
|
||||
|
||||
for (int i = 0; i < EditorNode::get_editor_data().get_edited_scene_count(); i++) {
|
||||
String path;
|
||||
String file_path;
|
||||
if (i == EditorNode::get_editor_data().get_edited_scene()) {
|
||||
if (!get_tree()->get_edited_scene_root()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
path = get_tree()->get_edited_scene_root()->get_scene_file_path();
|
||||
file_path = get_tree()->get_edited_scene_root()->get_scene_file_path();
|
||||
} else {
|
||||
path = EditorNode::get_editor_data().get_scene_path(i);
|
||||
file_path = EditorNode::get_editor_data().get_scene_path(i);
|
||||
}
|
||||
|
||||
if (p_renames.has(path)) {
|
||||
path = p_renames[path];
|
||||
if (p_renames.has(file_path)) {
|
||||
file_path = p_renames[file_path];
|
||||
}
|
||||
|
||||
if (i == EditorNode::get_editor_data().get_edited_scene()) {
|
||||
get_tree()->get_edited_scene_root()->set_scene_file_path(path);
|
||||
get_tree()->get_edited_scene_root()->set_scene_file_path(file_path);
|
||||
} else {
|
||||
EditorNode::get_editor_data().set_scene_path(i, path);
|
||||
EditorNode::get_editor_data().set_scene_path(i, file_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1421,11 +1420,10 @@ void FileSystemDock::_update_project_settings_after_move(const HashMap<String, S
|
|||
}
|
||||
|
||||
void FileSystemDock::_update_favorites_list_after_move(const HashMap<String, String> &p_files_renames, const HashMap<String, String> &p_folders_renames) const {
|
||||
Vector<String> favorites = EditorSettings::get_singleton()->get_favorites();
|
||||
Vector<String> favorites_list = EditorSettings::get_singleton()->get_favorites();
|
||||
Vector<String> new_favorites;
|
||||
|
||||
for (int i = 0; i < favorites.size(); i++) {
|
||||
String old_path = favorites[i];
|
||||
for (const String &old_path : favorites_list) {
|
||||
if (p_folders_renames.has(old_path)) {
|
||||
new_favorites.push_back(p_folders_renames[old_path]);
|
||||
} else if (p_files_renames.has(old_path)) {
|
||||
|
@ -1836,23 +1834,23 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
|
|||
|
||||
case FILE_ADD_FAVORITE: {
|
||||
// Add the files from favorites.
|
||||
Vector<String> favorites = EditorSettings::get_singleton()->get_favorites();
|
||||
Vector<String> favorites_list = EditorSettings::get_singleton()->get_favorites();
|
||||
for (int i = 0; i < p_selected.size(); i++) {
|
||||
if (!favorites.has(p_selected[i])) {
|
||||
favorites.push_back(p_selected[i]);
|
||||
if (!favorites_list.has(p_selected[i])) {
|
||||
favorites_list.push_back(p_selected[i]);
|
||||
}
|
||||
}
|
||||
EditorSettings::get_singleton()->set_favorites(favorites);
|
||||
EditorSettings::get_singleton()->set_favorites(favorites_list);
|
||||
_update_tree(_compute_uncollapsed_paths());
|
||||
} break;
|
||||
|
||||
case FILE_REMOVE_FAVORITE: {
|
||||
// Remove the files from favorites.
|
||||
Vector<String> favorites = EditorSettings::get_singleton()->get_favorites();
|
||||
Vector<String> favorites_list = EditorSettings::get_singleton()->get_favorites();
|
||||
for (int i = 0; i < p_selected.size(); i++) {
|
||||
favorites.erase(p_selected[i]);
|
||||
favorites_list.erase(p_selected[i]);
|
||||
}
|
||||
EditorSettings::get_singleton()->set_favorites(favorites);
|
||||
EditorSettings::get_singleton()->set_favorites(favorites_list);
|
||||
_update_tree(_compute_uncollapsed_paths());
|
||||
if (path == "Favorites") {
|
||||
_update_file_list(true);
|
||||
|
@ -2274,7 +2272,7 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data,
|
|||
int drop_section = tree->get_drop_section_at_position(p_point);
|
||||
|
||||
int drop_position;
|
||||
Vector<String> files = drag_data["files"];
|
||||
Vector<String> drag_files = drag_data["files"];
|
||||
TreeItem *favorites_item = tree->get_root()->get_first_child();
|
||||
TreeItem *resources_item = favorites_item->get_next();
|
||||
|
||||
|
@ -2295,8 +2293,8 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data,
|
|||
// Remove dragged favorites.
|
||||
Vector<int> to_remove;
|
||||
int offset = 0;
|
||||
for (int i = 0; i < files.size(); i++) {
|
||||
int to_remove_pos = dirs.find(files[i]);
|
||||
for (int i = 0; i < drag_files.size(); i++) {
|
||||
int to_remove_pos = dirs.find(drag_files[i]);
|
||||
to_remove.push_back(to_remove_pos);
|
||||
if (to_remove_pos < drop_position) {
|
||||
offset++;
|
||||
|
@ -2309,8 +2307,8 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data,
|
|||
}
|
||||
|
||||
// Re-add them at the right position.
|
||||
for (int i = 0; i < files.size(); i++) {
|
||||
dirs.insert(drop_position, files[i]);
|
||||
for (int i = 0; i < drag_files.size(); i++) {
|
||||
dirs.insert(drop_position, drag_files[i]);
|
||||
drop_position++;
|
||||
}
|
||||
|
||||
|
@ -2379,13 +2377,13 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data,
|
|||
} else if (favorite) {
|
||||
// Add the files from favorites.
|
||||
Vector<String> fnames = drag_data["files"];
|
||||
Vector<String> favorites = EditorSettings::get_singleton()->get_favorites();
|
||||
Vector<String> favorites_list = EditorSettings::get_singleton()->get_favorites();
|
||||
for (int i = 0; i < fnames.size(); i++) {
|
||||
if (!favorites.has(fnames[i])) {
|
||||
favorites.push_back(fnames[i]);
|
||||
if (!favorites_list.has(fnames[i])) {
|
||||
favorites_list.push_back(fnames[i]);
|
||||
}
|
||||
}
|
||||
EditorSettings::get_singleton()->set_favorites(favorites);
|
||||
EditorSettings::get_singleton()->set_favorites(favorites_list);
|
||||
_update_tree(_compute_uncollapsed_paths());
|
||||
}
|
||||
}
|
||||
|
@ -2463,7 +2461,7 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<Str
|
|||
Vector<String> filenames;
|
||||
Vector<String> foldernames;
|
||||
|
||||
Vector<String> favorites = EditorSettings::get_singleton()->get_favorites();
|
||||
Vector<String> favorites_list = EditorSettings::get_singleton()->get_favorites();
|
||||
|
||||
bool all_files = true;
|
||||
bool all_files_scenes = true;
|
||||
|
@ -2484,8 +2482,8 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<Str
|
|||
|
||||
// Check if in favorites.
|
||||
bool found = false;
|
||||
for (int j = 0; j < favorites.size(); j++) {
|
||||
if (favorites[j] == fpath) {
|
||||
for (int j = 0; j < favorites_list.size(); j++) {
|
||||
if (favorites_list[j] == fpath) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
@ -2852,10 +2850,10 @@ void FileSystemDock::_file_list_gui_input(Ref<InputEvent> p_event) {
|
|||
}
|
||||
}
|
||||
|
||||
void FileSystemDock::_get_imported_files(const String &p_path, Vector<String> &files) const {
|
||||
void FileSystemDock::_get_imported_files(const String &p_path, Vector<String> &r_files) const {
|
||||
if (!p_path.ends_with("/")) {
|
||||
if (FileAccess::exists(p_path + ".import")) {
|
||||
files.push_back(p_path);
|
||||
r_files.push_back(p_path);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -2866,7 +2864,7 @@ void FileSystemDock::_get_imported_files(const String &p_path, Vector<String> &f
|
|||
while (!n.is_empty()) {
|
||||
if (n != "." && n != ".." && !n.ends_with(".import")) {
|
||||
String npath = p_path + n + (da->current_is_dir() ? "/" : "");
|
||||
_get_imported_files(npath, files);
|
||||
_get_imported_files(npath, r_files);
|
||||
}
|
||||
n = da->get_next();
|
||||
}
|
||||
|
|
|
@ -213,11 +213,11 @@ private:
|
|||
void _file_multi_selected(int p_index, bool p_selected);
|
||||
void _tree_multi_selected(Object *p_item, int p_column, bool p_selected);
|
||||
|
||||
void _get_imported_files(const String &p_path, Vector<String> &files) const;
|
||||
void _get_imported_files(const String &p_path, Vector<String> &r_files) const;
|
||||
void _update_import_dock();
|
||||
|
||||
void _get_all_items_in_dir(EditorFileSystemDirectory *efsd, Vector<String> &files, Vector<String> &folders) const;
|
||||
void _find_remaps(EditorFileSystemDirectory *efsd, const HashMap<String, String> &renames, Vector<String> &to_remaps) const;
|
||||
void _get_all_items_in_dir(EditorFileSystemDirectory *p_efsd, Vector<String> &r_files, Vector<String> &r_folders) const;
|
||||
void _find_remaps(EditorFileSystemDirectory *p_efsd, const HashMap<String, String> &r_renames, Vector<String> &r_to_remaps) const;
|
||||
void _try_move_item(const FileOrFolder &p_item, const String &p_new_path, HashMap<String, String> &p_file_renames, HashMap<String, String> &p_folder_renames);
|
||||
void _try_duplicate_item(const FileOrFolder &p_item, const String &p_new_path) const;
|
||||
void _update_dependencies_after_move(const HashMap<String, String> &p_renames) const;
|
||||
|
|
|
@ -968,8 +968,8 @@ void FindInFilesPanel::update_replace_buttons() {
|
|||
_replace_all_button->set_disabled(disabled);
|
||||
}
|
||||
|
||||
void FindInFilesPanel::set_progress_visible(bool visible) {
|
||||
_progress_bar->set_self_modulate(Color(1, 1, 1, visible ? 1 : 0));
|
||||
void FindInFilesPanel::set_progress_visible(bool p_visible) {
|
||||
_progress_bar->set_self_modulate(Color(1, 1, 1, p_visible ? 1 : 0));
|
||||
}
|
||||
|
||||
void FindInFilesPanel::_bind_methods() {
|
||||
|
|
|
@ -198,7 +198,7 @@ private:
|
|||
|
||||
void draw_result_text(Object *item_obj, Rect2 rect);
|
||||
|
||||
void set_progress_visible(bool visible);
|
||||
void set_progress_visible(bool p_visible);
|
||||
void clear();
|
||||
|
||||
FindInFiles *_finder = nullptr;
|
||||
|
|
|
@ -76,7 +76,7 @@ void AudioStreamImportSettings::_notification(int p_what) {
|
|||
|
||||
void AudioStreamImportSettings::_draw_preview() {
|
||||
Rect2 rect = _preview->get_rect();
|
||||
Size2 size = rect.size;
|
||||
Size2 rect_size = rect.size;
|
||||
|
||||
Ref<AudioStreamPreview> preview = AudioStreamPreviewGenerator::get_singleton()->generate_preview(stream);
|
||||
float preview_offset = zoom_bar->get_value();
|
||||
|
@ -85,7 +85,7 @@ void AudioStreamImportSettings::_draw_preview() {
|
|||
Ref<Font> beat_font = get_theme_font(SNAME("main"), SNAME("EditorFonts"));
|
||||
int main_size = get_theme_font_size(SNAME("main_size"), SNAME("EditorFonts"));
|
||||
Vector<Vector2> lines;
|
||||
lines.resize(size.width * 2);
|
||||
lines.resize(rect_size.width * 2);
|
||||
Color color_active = get_theme_color(SNAME("contrast_color_2"), SNAME("Editor"));
|
||||
Color color_inactive = color_active;
|
||||
color_inactive.a *= 0.5;
|
||||
|
@ -107,9 +107,9 @@ void AudioStreamImportSettings::_draw_preview() {
|
|||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < size.width; i++) {
|
||||
float ofs = preview_offset + i * preview_len / size.width;
|
||||
float ofs_n = preview_offset + (i + 1) * preview_len / size.width;
|
||||
for (int i = 0; i < rect_size.width; i++) {
|
||||
float ofs = preview_offset + i * preview_len / rect_size.width;
|
||||
float ofs_n = preview_offset + (i + 1) * preview_len / rect_size.width;
|
||||
float max = preview->get_max(ofs, ofs_n) * 0.5 + 0.5;
|
||||
float min = preview->get_min(ofs, ofs_n) * 0.5 + 0.5;
|
||||
|
||||
|
@ -139,8 +139,8 @@ void AudioStreamImportSettings::_draw_preview() {
|
|||
int bar_beats = stream->get_bar_beats();
|
||||
|
||||
int last_text_end_x = 0;
|
||||
for (int i = 0; i < size.width; i++) {
|
||||
float ofs = preview_offset + i * preview_len / size.width;
|
||||
for (int i = 0; i < rect_size.width; i++) {
|
||||
float ofs = preview_offset + i * preview_len / rect_size.width;
|
||||
int beat = int(ofs / beat_size);
|
||||
if (beat != prev_beat) {
|
||||
String text = itos(beat);
|
||||
|
|
|
@ -949,11 +949,11 @@ void DynamicFontImportSettings::_re_import() {
|
|||
|
||||
void DynamicFontImportSettings::open_settings(const String &p_path) {
|
||||
// Load base font data.
|
||||
Vector<uint8_t> data = FileAccess::get_file_as_array(p_path);
|
||||
Vector<uint8_t> font_data = FileAccess::get_file_as_array(p_path);
|
||||
|
||||
// Load font for preview.
|
||||
font_preview.instantiate();
|
||||
font_preview->set_data(data);
|
||||
font_preview->set_data(font_data);
|
||||
|
||||
String font_name = vformat("%s (%s)", font_preview->get_font_name(), font_preview->get_font_style_name());
|
||||
String sample;
|
||||
|
@ -976,7 +976,7 @@ void DynamicFontImportSettings::open_settings(const String &p_path) {
|
|||
|
||||
// Load second copy of font with MSDF disabled for the glyph table and metadata extraction.
|
||||
font_main.instantiate();
|
||||
font_main->set_data(data);
|
||||
font_main->set_data(font_data);
|
||||
font_main->set_multichannel_signed_distance_field(false);
|
||||
|
||||
text_edit->add_theme_font_override("font", font_main);
|
||||
|
@ -1036,7 +1036,7 @@ void DynamicFontImportSettings::open_settings(const String &p_path) {
|
|||
double embolden = preload_config.has("variation_embolden") ? preload_config["variation_embolden"].operator double() : 0;
|
||||
int face_index = preload_config.has("variation_face_index") ? preload_config["variation_face_index"].operator int() : 0;
|
||||
Transform2D transform = preload_config.has("variation_transform") ? preload_config["variation_transform"].operator Transform2D() : Transform2D();
|
||||
Vector2i size = preload_config.has("size") ? preload_config["size"].operator Vector2i() : Vector2i(16, 0);
|
||||
Vector2i font_size = preload_config.has("size") ? preload_config["size"].operator Vector2i() : Vector2i(16, 0);
|
||||
String cfg_name = preload_config.has("name") ? preload_config["name"].operator String() : vformat("Configuration %d", i);
|
||||
|
||||
TreeItem *vars_item = vars_list->create_item(vars_list_root);
|
||||
|
@ -1061,8 +1061,8 @@ void DynamicFontImportSettings::open_settings(const String &p_path) {
|
|||
import_variation_data_custom->options = options_variations;
|
||||
vars_item->set_metadata(0, import_variation_data_custom);
|
||||
|
||||
import_variation_data_custom->set("size", size.x);
|
||||
import_variation_data_custom->set("outline_size", size.y);
|
||||
import_variation_data_custom->set("size", font_size.x);
|
||||
import_variation_data_custom->set("outline_size", font_size.y);
|
||||
import_variation_data_custom->set("variation_opentype", variation);
|
||||
import_variation_data_custom->set("variation_embolden", embolden);
|
||||
import_variation_data_custom->set("variation_face_index", face_index);
|
||||
|
|
|
@ -154,7 +154,7 @@ bool EditorImportPlugin::get_option_visibility(const String &p_path, const Strin
|
|||
d[E->key] = E->value;
|
||||
++E;
|
||||
}
|
||||
bool visible;
|
||||
bool visible = false;
|
||||
if (GDVIRTUAL_CALL(_get_option_visibility, p_path, p_option, d, visible)) {
|
||||
return visible;
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ Error EditorImportPlugin::import(const String &p_source_file, const String &p_sa
|
|||
++E;
|
||||
}
|
||||
|
||||
int err;
|
||||
int err = 0;
|
||||
if (GDVIRTUAL_CALL(_import, p_source_file, p_save_path, options, platform_variants, gen_files, err)) {
|
||||
Error ret_err = Error(err);
|
||||
|
||||
|
|
|
@ -396,12 +396,12 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const
|
|||
texture_import->used_channels = used_channels;
|
||||
_check_compress_ctex(p_source_file, texture_import);
|
||||
if (r_metadata) {
|
||||
Dictionary metadata;
|
||||
metadata["vram_texture"] = compress_mode == COMPRESS_VRAM_COMPRESSED;
|
||||
Dictionary meta;
|
||||
meta["vram_texture"] = compress_mode == COMPRESS_VRAM_COMPRESSED;
|
||||
if (formats_imported.size()) {
|
||||
metadata["imported_formats"] = formats_imported;
|
||||
meta["imported_formats"] = formats_imported;
|
||||
}
|
||||
*r_metadata = metadata;
|
||||
*r_metadata = meta;
|
||||
}
|
||||
|
||||
return OK;
|
||||
|
@ -432,20 +432,20 @@ String ResourceImporterLayeredTexture::get_import_settings_string() const {
|
|||
|
||||
bool ResourceImporterLayeredTexture::are_import_settings_valid(const String &p_path) const {
|
||||
//will become invalid if formats are missing to import
|
||||
Dictionary metadata = ResourceFormatImporter::get_singleton()->get_resource_metadata(p_path);
|
||||
Dictionary meta = ResourceFormatImporter::get_singleton()->get_resource_metadata(p_path);
|
||||
|
||||
if (!metadata.has("vram_texture")) {
|
||||
if (!meta.has("vram_texture")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool vram = metadata["vram_texture"];
|
||||
bool vram = meta["vram_texture"];
|
||||
if (!vram) {
|
||||
return true; //do not care about non vram
|
||||
}
|
||||
|
||||
Vector<String> formats_imported;
|
||||
if (metadata.has("imported_formats")) {
|
||||
formats_imported = metadata["imported_formats"];
|
||||
if (meta.has("imported_formats")) {
|
||||
formats_imported = meta["imported_formats"];
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
|
|
|
@ -669,23 +669,23 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
|
|||
}
|
||||
|
||||
if (r_metadata) {
|
||||
Dictionary metadata;
|
||||
metadata["vram_texture"] = compress_mode == COMPRESS_VRAM_COMPRESSED;
|
||||
Dictionary meta;
|
||||
meta["vram_texture"] = compress_mode == COMPRESS_VRAM_COMPRESSED;
|
||||
if (formats_imported.size()) {
|
||||
metadata["imported_formats"] = formats_imported;
|
||||
meta["imported_formats"] = formats_imported;
|
||||
}
|
||||
|
||||
if (editor_image.is_valid()) {
|
||||
metadata["has_editor_variant"] = true;
|
||||
meta["has_editor_variant"] = true;
|
||||
if (use_editor_scale) {
|
||||
metadata["editor_scale"] = EDSCALE;
|
||||
meta["editor_scale"] = EDSCALE;
|
||||
}
|
||||
if (convert_editor_colors) {
|
||||
metadata["editor_dark_theme"] = EditorSettings::get_singleton()->is_dark_theme();
|
||||
meta["editor_dark_theme"] = EditorSettings::get_singleton()->is_dark_theme();
|
||||
}
|
||||
}
|
||||
|
||||
*r_metadata = metadata;
|
||||
*r_metadata = meta;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
@ -715,29 +715,29 @@ String ResourceImporterTexture::get_import_settings_string() const {
|
|||
|
||||
bool ResourceImporterTexture::are_import_settings_valid(const String &p_path) const {
|
||||
//will become invalid if formats are missing to import
|
||||
Dictionary metadata = ResourceFormatImporter::get_singleton()->get_resource_metadata(p_path);
|
||||
Dictionary meta = ResourceFormatImporter::get_singleton()->get_resource_metadata(p_path);
|
||||
|
||||
if (metadata.has("has_editor_variant")) {
|
||||
if (metadata.has("editor_scale") && (float)metadata["editor_scale"] != EDSCALE) {
|
||||
if (meta.has("has_editor_variant")) {
|
||||
if (meta.has("editor_scale") && (float)meta["editor_scale"] != EDSCALE) {
|
||||
return false;
|
||||
}
|
||||
if (metadata.has("editor_dark_theme") && (bool)metadata["editor_dark_theme"] != EditorSettings::get_singleton()->is_dark_theme()) {
|
||||
if (meta.has("editor_dark_theme") && (bool)meta["editor_dark_theme"] != EditorSettings::get_singleton()->is_dark_theme()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!metadata.has("vram_texture")) {
|
||||
if (!meta.has("vram_texture")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool vram = metadata["vram_texture"];
|
||||
bool vram = meta["vram_texture"];
|
||||
if (!vram) {
|
||||
return true; // Do not care about non-VRAM.
|
||||
}
|
||||
|
||||
Vector<String> formats_imported;
|
||||
if (metadata.has("imported_formats")) {
|
||||
formats_imported = metadata["imported_formats"];
|
||||
if (meta.has("imported_formats")) {
|
||||
formats_imported = meta["imported_formats"];
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
|
|
|
@ -255,8 +255,8 @@ void InspectorDock::_resource_file_selected(String p_file) {
|
|||
}
|
||||
|
||||
void InspectorDock::_save_resource(bool save_as) {
|
||||
ObjectID current = EditorNode::get_singleton()->get_editor_selection_history()->get_current();
|
||||
Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : nullptr;
|
||||
ObjectID current_id = EditorNode::get_singleton()->get_editor_selection_history()->get_current();
|
||||
Object *current_obj = current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr;
|
||||
|
||||
ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj));
|
||||
|
||||
|
@ -270,8 +270,8 @@ void InspectorDock::_save_resource(bool save_as) {
|
|||
}
|
||||
|
||||
void InspectorDock::_unref_resource() {
|
||||
ObjectID current = EditorNode::get_singleton()->get_editor_selection_history()->get_current();
|
||||
Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : nullptr;
|
||||
ObjectID current_id = EditorNode::get_singleton()->get_editor_selection_history()->get_current();
|
||||
Object *current_obj = current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr;
|
||||
|
||||
ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj));
|
||||
|
||||
|
@ -281,8 +281,8 @@ void InspectorDock::_unref_resource() {
|
|||
}
|
||||
|
||||
void InspectorDock::_copy_resource() {
|
||||
ObjectID current = EditorNode::get_singleton()->get_editor_selection_history()->get_current();
|
||||
Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : nullptr;
|
||||
ObjectID current_id = EditorNode::get_singleton()->get_editor_selection_history()->get_current();
|
||||
Object *current_obj = current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr;
|
||||
|
||||
ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj));
|
||||
|
||||
|
@ -610,8 +610,8 @@ void InspectorDock::apply_script_properties(Object *p_object) {
|
|||
}
|
||||
|
||||
for (const Pair<StringName, Variant> &E : stored_properties) {
|
||||
Variant current;
|
||||
if (si->get(E.first, current) && current.get_type() == E.second.get_type()) {
|
||||
Variant current_prop;
|
||||
if (si->get(E.first, current_prop) && current_prop.get_type() == E.second.get_type()) {
|
||||
si->set(E.first, E.second);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,11 +80,11 @@ void PluginConfigDialog::_on_confirmed() {
|
|||
if (!templates.is_empty()) {
|
||||
template_content = templates[0].content;
|
||||
}
|
||||
Ref<Script> script = ScriptServer::get_language(lang_idx)->make_template(template_content, class_name, "EditorPlugin");
|
||||
script->set_path(script_path, true);
|
||||
ResourceSaver::save(script);
|
||||
Ref<Script> scr = ScriptServer::get_language(lang_idx)->make_template(template_content, class_name, "EditorPlugin");
|
||||
scr->set_path(script_path, true);
|
||||
ResourceSaver::save(scr);
|
||||
|
||||
emit_signal(SNAME("plugin_ready"), script.ptr(), active_edit->is_pressed() ? _to_absolute_plugin_path(_get_subfolder()) : "");
|
||||
emit_signal(SNAME("plugin_ready"), scr.ptr(), active_edit->is_pressed() ? _to_absolute_plugin_path(_get_subfolder()) : "");
|
||||
} else {
|
||||
EditorNode::get_singleton()->get_project_settings()->update_plugins();
|
||||
}
|
||||
|
|
|
@ -561,8 +561,8 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl
|
|||
const Vector2 p = (vertex == edited_point) ? edited_point.pos : (points[i] + offset);
|
||||
const Vector2 point = xform.xform(p);
|
||||
|
||||
const Color modulate = vertex == active_point ? Color(0.5, 1, 2) : Color(1, 1, 1);
|
||||
p_overlay->draw_texture(handle, point - handle->get_size() * 0.5, modulate);
|
||||
const Color overlay_modulate = vertex == active_point ? Color(0.5, 1, 2) : Color(1, 1, 1);
|
||||
p_overlay->draw_texture(handle, point - handle->get_size() * 0.5, overlay_modulate);
|
||||
|
||||
if (vertex == hover_point) {
|
||||
Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label"));
|
||||
|
|
|
@ -406,11 +406,11 @@ void AnimationNodeBlendSpace2DEditor::_tool_switch(int p_tool) {
|
|||
making_triangle.clear();
|
||||
|
||||
if (p_tool == 2) {
|
||||
Vector<Vector2> points;
|
||||
Vector<Vector2> bl_points;
|
||||
for (int i = 0; i < blend_space->get_blend_point_count(); i++) {
|
||||
points.push_back(blend_space->get_blend_point_position(i));
|
||||
bl_points.push_back(blend_space->get_blend_point_position(i));
|
||||
}
|
||||
Vector<Delaunay2D::Triangle> tr = Delaunay2D::triangulate(points);
|
||||
Vector<Delaunay2D::Triangle> tr = Delaunay2D::triangulate(bl_points);
|
||||
for (int i = 0; i < tr.size(); i++) {
|
||||
blend_space->add_triangle(tr[i].points[0], tr[i].points[1], tr[i].points[2]);
|
||||
}
|
||||
|
@ -494,8 +494,8 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
|
|||
|
||||
//triangles first
|
||||
for (int i = 0; i < blend_space->get_triangle_count(); i++) {
|
||||
Vector<Vector2> points;
|
||||
points.resize(3);
|
||||
Vector<Vector2> bl_points;
|
||||
bl_points.resize(3);
|
||||
|
||||
for (int j = 0; j < 3; j++) {
|
||||
int point_idx = blend_space->get_triangle_point(i, j);
|
||||
|
@ -509,11 +509,11 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
|
|||
point = (point - blend_space->get_min_space()) / (blend_space->get_max_space() - blend_space->get_min_space());
|
||||
point *= s;
|
||||
point.y = s.height - point.y;
|
||||
points.write[j] = point;
|
||||
bl_points.write[j] = point;
|
||||
}
|
||||
|
||||
for (int j = 0; j < 3; j++) {
|
||||
blend_space_draw->draw_line(points[j], points[(j + 1) % 3], linecolor, Math::round(EDSCALE), true);
|
||||
blend_space_draw->draw_line(bl_points[j], bl_points[(j + 1) % 3], linecolor, Math::round(EDSCALE), true);
|
||||
}
|
||||
|
||||
Color color;
|
||||
|
@ -530,7 +530,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
|
|||
color,
|
||||
color
|
||||
};
|
||||
blend_space_draw->draw_primitive(points, colors, Vector<Vector2>());
|
||||
blend_space_draw->draw_primitive(bl_points, colors, Vector<Vector2>());
|
||||
}
|
||||
|
||||
points.clear();
|
||||
|
@ -560,19 +560,19 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
|
|||
}
|
||||
|
||||
if (making_triangle.size()) {
|
||||
Vector<Vector2> points;
|
||||
Vector<Vector2> bl_points;
|
||||
for (int i = 0; i < making_triangle.size(); i++) {
|
||||
Vector2 point = blend_space->get_blend_point_position(making_triangle[i]);
|
||||
point = (point - blend_space->get_min_space()) / (blend_space->get_max_space() - blend_space->get_min_space());
|
||||
point *= s;
|
||||
point.y = s.height - point.y;
|
||||
points.push_back(point);
|
||||
bl_points.push_back(point);
|
||||
}
|
||||
|
||||
for (int i = 0; i < points.size() - 1; i++) {
|
||||
blend_space_draw->draw_line(points[i], points[i + 1], linecolor, Math::round(2 * EDSCALE), true);
|
||||
for (int i = 0; i < bl_points.size() - 1; i++) {
|
||||
blend_space_draw->draw_line(bl_points[i], bl_points[i + 1], linecolor, Math::round(2 * EDSCALE), true);
|
||||
}
|
||||
blend_space_draw->draw_line(points[points.size() - 1], blend_space_draw->get_local_mouse_position(), linecolor, Math::round(2 * EDSCALE), true);
|
||||
blend_space_draw->draw_line(bl_points[bl_points.size() - 1], blend_space_draw->get_local_mouse_position(), linecolor, Math::round(2 * EDSCALE), true);
|
||||
}
|
||||
|
||||
///draw cursor position
|
||||
|
|
|
@ -262,10 +262,10 @@ void AnimationNodeBlendTreeEditor::update_graph() {
|
|||
node->add_theme_color_override("resizer_color", c);
|
||||
}
|
||||
|
||||
List<AnimationNodeBlendTree::NodeConnection> connections;
|
||||
blend_tree->get_node_connections(&connections);
|
||||
List<AnimationNodeBlendTree::NodeConnection> node_connections;
|
||||
blend_tree->get_node_connections(&node_connections);
|
||||
|
||||
for (const AnimationNodeBlendTree::NodeConnection &E : connections) {
|
||||
for (const AnimationNodeBlendTree::NodeConnection &E : node_connections) {
|
||||
StringName from = E.output_node;
|
||||
StringName to = E.input_node;
|
||||
int to_idx = E.input_index;
|
||||
|
@ -293,9 +293,9 @@ void AnimationNodeBlendTreeEditor::_add_node(int p_idx) {
|
|||
|
||||
if (p_idx == MENU_LOAD_FILE) {
|
||||
open_file->clear_filters();
|
||||
List<String> filters;
|
||||
ResourceLoader::get_recognized_extensions_for_type("AnimationNode", &filters);
|
||||
for (const String &E : filters) {
|
||||
List<String> ext_filters;
|
||||
ResourceLoader::get_recognized_extensions_for_type("AnimationNode", &ext_filters);
|
||||
for (const String &E : ext_filters) {
|
||||
open_file->add_filter("*." + E);
|
||||
}
|
||||
open_file->popup_file_dialog();
|
||||
|
@ -611,10 +611,10 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano
|
|||
HashSet<String> paths;
|
||||
HashMap<String, RBSet<String>> types;
|
||||
{
|
||||
List<StringName> animations;
|
||||
player->get_animation_list(&animations);
|
||||
List<StringName> animation_list;
|
||||
player->get_animation_list(&animation_list);
|
||||
|
||||
for (const StringName &E : animations) {
|
||||
for (const StringName &E : animation_list) {
|
||||
Ref<Animation> anim = player->get_animation(E);
|
||||
for (int i = 0; i < anim->get_track_count(); i++) {
|
||||
String track_path = anim->track_get_path(i);
|
||||
|
@ -970,10 +970,10 @@ void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<Anima
|
|||
//recreate connections
|
||||
graph->clear_connections();
|
||||
|
||||
List<AnimationNodeBlendTree::NodeConnection> connections;
|
||||
blend_tree->get_node_connections(&connections);
|
||||
List<AnimationNodeBlendTree::NodeConnection> node_connections;
|
||||
blend_tree->get_node_connections(&node_connections);
|
||||
|
||||
for (const AnimationNodeBlendTree::NodeConnection &E : connections) {
|
||||
for (const AnimationNodeBlendTree::NodeConnection &E : node_connections) {
|
||||
StringName from = E.output_node;
|
||||
StringName to = E.input_node;
|
||||
int to_idx = E.input_index;
|
||||
|
|
|
@ -826,13 +826,13 @@ void AnimationPlayerEditor::_update_player() {
|
|||
}
|
||||
|
||||
// Check if the global library is foreign since we want to disable options for adding/remove/renaming animations if it is.
|
||||
Ref<AnimationLibrary> library = player->get_animation_library(K);
|
||||
Ref<AnimationLibrary> anim_library = player->get_animation_library(K);
|
||||
if (K == "") {
|
||||
foreign_global_anim_lib = EditorNode::get_singleton()->is_resource_read_only(library);
|
||||
foreign_global_anim_lib = EditorNode::get_singleton()->is_resource_read_only(anim_library);
|
||||
}
|
||||
|
||||
List<StringName> animlist;
|
||||
library->get_animation_list(&animlist);
|
||||
anim_library->get_animation_list(&animlist);
|
||||
|
||||
for (const StringName &E : animlist) {
|
||||
String path = K;
|
||||
|
@ -913,19 +913,19 @@ void AnimationPlayerEditor::_update_player() {
|
|||
|
||||
void AnimationPlayerEditor::_update_animation_list_icons() {
|
||||
for (int i = 0; i < animation->get_item_count(); i++) {
|
||||
String name = animation->get_item_text(i);
|
||||
String anim_name = animation->get_item_text(i);
|
||||
if (animation->is_item_disabled(i) || animation->is_item_separator(i)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Ref<Texture2D> icon;
|
||||
if (name == player->get_autoplay()) {
|
||||
if (name == SceneStringNames::get_singleton()->RESET) {
|
||||
if (anim_name == player->get_autoplay()) {
|
||||
if (anim_name == SceneStringNames::get_singleton()->RESET) {
|
||||
icon = autoplay_reset_icon;
|
||||
} else {
|
||||
icon = autoplay_icon;
|
||||
}
|
||||
} else if (name == SceneStringNames::get_singleton()->RESET) {
|
||||
} else if (anim_name == SceneStringNames::get_singleton()->RESET) {
|
||||
icon = reset_icon;
|
||||
}
|
||||
|
||||
|
@ -1356,8 +1356,8 @@ void AnimationPlayerEditor::_free_onion_layers() {
|
|||
|
||||
void AnimationPlayerEditor::_prepare_onion_layers_1() {
|
||||
// This would be called per viewport and we want to act once only.
|
||||
int64_t frame = get_tree()->get_frame();
|
||||
if (frame == onion.last_frame) {
|
||||
int64_t cur_frame = get_tree()->get_frame();
|
||||
if (cur_frame == onion.last_frame) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1366,7 +1366,7 @@ void AnimationPlayerEditor::_prepare_onion_layers_1() {
|
|||
return;
|
||||
}
|
||||
|
||||
onion.last_frame = frame;
|
||||
onion.last_frame = cur_frame;
|
||||
|
||||
// Refresh viewports with no onion layers overlaid.
|
||||
onion.can_overlay = false;
|
||||
|
|
|
@ -243,19 +243,19 @@ void EditorAssetLibraryItemDescription::configure(const String &p_title, int p_a
|
|||
}
|
||||
|
||||
void EditorAssetLibraryItemDescription::add_preview(int p_id, bool p_video, const String &p_url) {
|
||||
Preview preview;
|
||||
preview.id = p_id;
|
||||
preview.video_link = p_url;
|
||||
preview.is_video = p_video;
|
||||
preview.button = memnew(Button);
|
||||
preview.button->set_icon(previews->get_theme_icon(SNAME("ThumbnailWait"), SNAME("EditorIcons")));
|
||||
preview.button->set_toggle_mode(true);
|
||||
preview.button->connect("pressed", callable_mp(this, &EditorAssetLibraryItemDescription::_preview_click).bind(p_id));
|
||||
preview_hb->add_child(preview.button);
|
||||
Preview new_preview;
|
||||
new_preview.id = p_id;
|
||||
new_preview.video_link = p_url;
|
||||
new_preview.is_video = p_video;
|
||||
new_preview.button = memnew(Button);
|
||||
new_preview.button->set_icon(previews->get_theme_icon(SNAME("ThumbnailWait"), SNAME("EditorIcons")));
|
||||
new_preview.button->set_toggle_mode(true);
|
||||
new_preview.button->connect("pressed", callable_mp(this, &EditorAssetLibraryItemDescription::_preview_click).bind(p_id));
|
||||
preview_hb->add_child(new_preview.button);
|
||||
if (!p_video) {
|
||||
preview.image = previews->get_theme_icon(SNAME("ThumbnailWait"), SNAME("EditorIcons"));
|
||||
new_preview.image = previews->get_theme_icon(SNAME("ThumbnailWait"), SNAME("EditorIcons"));
|
||||
}
|
||||
preview_images.push_back(preview);
|
||||
preview_images.push_back(new_preview);
|
||||
if (preview_images.size() == 1 && !p_video) {
|
||||
_preview_click(p_id);
|
||||
}
|
||||
|
|
|
@ -44,8 +44,8 @@ void AudioStreamRandomizerEditorPlugin::make_visible(bool p_visible) {
|
|||
}
|
||||
|
||||
void AudioStreamRandomizerEditorPlugin::_move_stream_array_element(Object *p_undo_redo, Object *p_edited, String p_array_prefix, int p_from_index, int p_to_pos) {
|
||||
Ref<EditorUndoRedoManager> undo_redo = Object::cast_to<EditorUndoRedoManager>(p_undo_redo);
|
||||
ERR_FAIL_COND(undo_redo.is_null());
|
||||
Ref<EditorUndoRedoManager> undo_redo_man = Object::cast_to<EditorUndoRedoManager>(p_undo_redo);
|
||||
ERR_FAIL_COND(undo_redo_man.is_null());
|
||||
|
||||
AudioStreamRandomizer *randomizer = Object::cast_to<AudioStreamRandomizer>(p_edited);
|
||||
if (!randomizer) {
|
||||
|
@ -76,12 +76,12 @@ void AudioStreamRandomizerEditorPlugin::_move_stream_array_element(Object *p_und
|
|||
end = MIN(MAX(p_from_index, p_to_pos) + 1, end);
|
||||
}
|
||||
|
||||
#define ADD_UNDO(obj, property) undo_redo->add_undo_property(obj, property, obj->get(property));
|
||||
#define ADD_UNDO(obj, property) undo_redo_man->add_undo_property(obj, property, obj->get(property));
|
||||
// Save layers' properties.
|
||||
if (p_from_index < 0) {
|
||||
undo_redo->add_undo_method(randomizer, "remove_stream", p_to_pos < 0 ? randomizer->get_streams_count() : p_to_pos);
|
||||
undo_redo_man->add_undo_method(randomizer, "remove_stream", p_to_pos < 0 ? randomizer->get_streams_count() : p_to_pos);
|
||||
} else if (p_to_pos < 0) {
|
||||
undo_redo->add_undo_method(randomizer, "add_stream", p_from_index);
|
||||
undo_redo_man->add_undo_method(randomizer, "add_stream", p_from_index);
|
||||
}
|
||||
|
||||
List<PropertyInfo> properties;
|
||||
|
@ -107,11 +107,11 @@ void AudioStreamRandomizerEditorPlugin::_move_stream_array_element(Object *p_und
|
|||
#undef ADD_UNDO
|
||||
|
||||
if (p_from_index < 0) {
|
||||
undo_redo->add_do_method(randomizer, "add_stream", p_to_pos);
|
||||
undo_redo_man->add_do_method(randomizer, "add_stream", p_to_pos);
|
||||
} else if (p_to_pos < 0) {
|
||||
undo_redo->add_do_method(randomizer, "remove_stream", p_from_index);
|
||||
undo_redo_man->add_do_method(randomizer, "remove_stream", p_from_index);
|
||||
} else {
|
||||
undo_redo->add_do_method(randomizer, "move_stream", p_from_index, p_to_pos);
|
||||
undo_redo_man->add_do_method(randomizer, "move_stream", p_from_index, p_to_pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -110,8 +110,8 @@ void CPUParticles2DEditorPlugin::_generate_emission_mask() {
|
|||
int vpc = 0;
|
||||
|
||||
{
|
||||
Vector<uint8_t> data = img->get_data();
|
||||
const uint8_t *r = data.ptr();
|
||||
Vector<uint8_t> img_data = img->get_data();
|
||||
const uint8_t *r = img_data.ptr();
|
||||
|
||||
for (int i = 0; i < s.width; i++) {
|
||||
for (int j = 0; j < s.height; j++) {
|
||||
|
|
|
@ -46,7 +46,7 @@ String EditorResourceConversionPlugin::converts_to() const {
|
|||
}
|
||||
|
||||
bool EditorResourceConversionPlugin::handles(const Ref<Resource> &p_resource) const {
|
||||
bool ret;
|
||||
bool ret = false;
|
||||
if (GDVIRTUAL_CALL(_handles, p_resource, ret)) {
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -207,8 +207,8 @@ void GPUParticles2DEditorPlugin::_generate_emission_mask() {
|
|||
int vpc = 0;
|
||||
|
||||
{
|
||||
Vector<uint8_t> data = img->get_data();
|
||||
const uint8_t *r = data.ptr();
|
||||
Vector<uint8_t> img_data = img->get_data();
|
||||
const uint8_t *r = img_data.ptr();
|
||||
|
||||
for (int i = 0; i < s.width; i++) {
|
||||
for (int j = 0; j < s.height; j++) {
|
||||
|
|
|
@ -255,8 +255,8 @@ void GPUParticles3DEditor::_menu_option(int p_option) {
|
|||
}
|
||||
} break;
|
||||
case MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE: {
|
||||
Ref<ParticleProcessMaterial> material = node->get_process_material();
|
||||
if (material.is_null()) {
|
||||
Ref<ParticleProcessMaterial> mat = node->get_process_material();
|
||||
if (mat.is_null()) {
|
||||
EditorNode::get_singleton()->show_warning(TTR("A processor material of type 'ParticleProcessMaterial' is required."));
|
||||
return;
|
||||
}
|
||||
|
@ -366,13 +366,13 @@ void GPUParticles3DEditor::_generate_emission_points() {
|
|||
Ref<Image> image = memnew(Image(w, h, false, Image::FORMAT_RGBF, point_img));
|
||||
Ref<ImageTexture> tex = ImageTexture::create_from_image(image);
|
||||
|
||||
Ref<ParticleProcessMaterial> material = node->get_process_material();
|
||||
ERR_FAIL_COND(material.is_null());
|
||||
Ref<ParticleProcessMaterial> mat = node->get_process_material();
|
||||
ERR_FAIL_COND(mat.is_null());
|
||||
|
||||
if (normals.size() > 0) {
|
||||
material->set_emission_shape(ParticleProcessMaterial::EMISSION_SHAPE_DIRECTED_POINTS);
|
||||
material->set_emission_point_count(point_count);
|
||||
material->set_emission_point_texture(tex);
|
||||
mat->set_emission_shape(ParticleProcessMaterial::EMISSION_SHAPE_DIRECTED_POINTS);
|
||||
mat->set_emission_point_count(point_count);
|
||||
mat->set_emission_point_texture(tex);
|
||||
|
||||
Vector<uint8_t> point_img2;
|
||||
point_img2.resize(w * h * 3 * sizeof(float));
|
||||
|
@ -390,11 +390,11 @@ void GPUParticles3DEditor::_generate_emission_points() {
|
|||
}
|
||||
|
||||
Ref<Image> image2 = memnew(Image(w, h, false, Image::FORMAT_RGBF, point_img2));
|
||||
material->set_emission_normal_texture(ImageTexture::create_from_image(image2));
|
||||
mat->set_emission_normal_texture(ImageTexture::create_from_image(image2));
|
||||
} else {
|
||||
material->set_emission_shape(ParticleProcessMaterial::EMISSION_SHAPE_POINTS);
|
||||
material->set_emission_point_count(point_count);
|
||||
material->set_emission_point_texture(tex);
|
||||
mat->set_emission_shape(ParticleProcessMaterial::EMISSION_SHAPE_POINTS);
|
||||
mat->set_emission_point_count(point_count);
|
||||
mat->set_emission_point_texture(tex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -90,8 +90,8 @@ void GradientEditor::_gradient_changed() {
|
|||
}
|
||||
|
||||
editing = true;
|
||||
Vector<Gradient::Point> points = gradient->get_points();
|
||||
set_points(points);
|
||||
Vector<Gradient::Point> grad_points = gradient->get_points();
|
||||
set_points(grad_points);
|
||||
set_interpolation_mode(gradient->get_interpolation_mode());
|
||||
queue_redraw();
|
||||
editing = false;
|
||||
|
|
|
@ -51,9 +51,9 @@ void Line2DEditor::_set_polygon(int p_idx, const Variant &p_polygon) const {
|
|||
}
|
||||
|
||||
void Line2DEditor::_action_set_polygon(int p_idx, const Variant &p_previous, const Variant &p_polygon) {
|
||||
Node2D *node = _get_node();
|
||||
undo_redo->add_do_method(node, "set_points", p_polygon);
|
||||
undo_redo->add_undo_method(node, "set_points", p_previous);
|
||||
Node2D *_node = _get_node();
|
||||
undo_redo->add_do_method(_node, "set_points", p_polygon);
|
||||
undo_redo->add_undo_method(_node, "set_points", p_previous);
|
||||
}
|
||||
|
||||
Line2DEditor::Line2DEditor() {}
|
||||
|
|
|
@ -1119,7 +1119,7 @@ void EditorNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
|||
}
|
||||
|
||||
bool EditorNode3DGizmoPlugin::is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
|
||||
bool ret;
|
||||
bool ret = false;
|
||||
if (GDVIRTUAL_CALL(_is_handle_highlighted, Ref<EditorNode3DGizmo>(p_gizmo), p_id, p_secondary, ret)) {
|
||||
return ret;
|
||||
}
|
||||
|
@ -1151,7 +1151,7 @@ void EditorNode3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, in
|
|||
}
|
||||
|
||||
int EditorNode3DGizmoPlugin::subgizmos_intersect_ray(const EditorNode3DGizmo *p_gizmo, Camera3D *p_camera, const Vector2 &p_point) const {
|
||||
int ret;
|
||||
int ret = -1;
|
||||
if (GDVIRTUAL_CALL(_subgizmos_intersect_ray, Ref<EditorNode3DGizmo>(p_gizmo), p_camera, p_point, ret)) {
|
||||
return ret;
|
||||
}
|
||||
|
@ -4167,9 +4167,9 @@ void CollisionObject3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
|||
|
||||
p_gizmo->clear();
|
||||
|
||||
List<uint32_t> owners;
|
||||
co->get_shape_owners(&owners);
|
||||
for (uint32_t &owner_id : owners) {
|
||||
List<uint32_t> owner_ids;
|
||||
co->get_shape_owners(&owner_ids);
|
||||
for (uint32_t &owner_id : owner_ids) {
|
||||
Transform3D xform = co->shape_owner_get_transform(owner_id);
|
||||
Object *owner = co->shape_owner_get_owner(owner_id);
|
||||
// Exclude CollisionShape3D and CollisionPolygon3D as they have their gizmo.
|
||||
|
|
|
@ -2429,11 +2429,11 @@ void Node3DEditorViewport::_notification(int p_what) {
|
|||
} break;
|
||||
|
||||
case NOTIFICATION_VISIBILITY_CHANGED: {
|
||||
bool visible = is_visible_in_tree();
|
||||
bool vp_visible = is_visible_in_tree();
|
||||
|
||||
set_process(visible);
|
||||
set_process(vp_visible);
|
||||
|
||||
if (visible) {
|
||||
if (vp_visible) {
|
||||
orthogonal = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_ORTHOGONAL));
|
||||
_update_name();
|
||||
_update_camera(0);
|
||||
|
@ -3880,8 +3880,8 @@ bool Node3DEditorViewport::_apply_preview_material(ObjectID p_target, const Poin
|
|||
Vector3 xform_ray = ai.basis.xform(world_ray).normalized();
|
||||
Vector3 xform_pos = ai.xform(world_pos);
|
||||
|
||||
for (int surface = 0; surface < surface_count; surface++) {
|
||||
Ref<TriangleMesh> surface_mesh = mesh->generate_surface_triangle_mesh(surface);
|
||||
for (int surface_idx = 0; surface_idx < surface_count; surface_idx++) {
|
||||
Ref<TriangleMesh> surface_mesh = mesh->generate_surface_triangle_mesh(surface_idx);
|
||||
|
||||
Vector3 rpos, rnorm;
|
||||
if (surface_mesh->intersect_ray(xform_pos, xform_ray, rpos, rnorm)) {
|
||||
|
@ -3894,7 +3894,7 @@ bool Node3DEditorViewport::_apply_preview_material(ObjectID p_target, const Poin
|
|||
}
|
||||
|
||||
if (dist < closest_dist) {
|
||||
closest_surface = surface;
|
||||
closest_surface = surface_idx;
|
||||
closest_dist = dist;
|
||||
}
|
||||
}
|
||||
|
@ -4020,16 +4020,16 @@ bool Node3DEditorViewport::_create_instance(Node *parent, String &path, const Po
|
|||
|
||||
Node3D *node3d = Object::cast_to<Node3D>(instantiated_scene);
|
||||
if (node3d) {
|
||||
Transform3D global_transform;
|
||||
Transform3D gl_transform;
|
||||
Node3D *parent_node3d = Object::cast_to<Node3D>(parent);
|
||||
if (parent_node3d) {
|
||||
global_transform = parent_node3d->get_global_gizmo_transform();
|
||||
gl_transform = parent_node3d->get_global_gizmo_transform();
|
||||
}
|
||||
|
||||
global_transform.origin = spatial_editor->snap_point(_get_instance_position(p_point));
|
||||
global_transform.basis *= node3d->get_transform().basis;
|
||||
gl_transform.origin = spatial_editor->snap_point(_get_instance_position(p_point));
|
||||
gl_transform.basis *= node3d->get_transform().basis;
|
||||
|
||||
editor_data->get_undo_redo()->add_do_method(instantiated_scene, "set_global_transform", global_transform);
|
||||
editor_data->get_undo_redo()->add_do_method(instantiated_scene, "set_global_transform", gl_transform);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -4163,8 +4163,8 @@ bool Node3DEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variant
|
|||
}
|
||||
|
||||
if (can_instantiate) {
|
||||
Transform3D global_transform = Transform3D(Basis(), _get_instance_position(p_point));
|
||||
preview_node->set_global_transform(global_transform);
|
||||
Transform3D gl_transform = Transform3D(Basis(), _get_instance_position(p_point));
|
||||
preview_node->set_global_transform(gl_transform);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -264,33 +264,33 @@ void Path3DGizmo::redraw() {
|
|||
|
||||
if (Path3DEditorPlugin::singleton->get_edited_path() == path) {
|
||||
v3p.clear();
|
||||
Vector<Vector3> handles;
|
||||
Vector<Vector3> sec_handles;
|
||||
Vector<Vector3> handle_points;
|
||||
Vector<Vector3> sec_handle_points;
|
||||
|
||||
for (int i = 0; i < c->get_point_count(); i++) {
|
||||
Vector3 p = c->get_point_position(i);
|
||||
handles.push_back(p);
|
||||
handle_points.push_back(p);
|
||||
// push Out points first so they get selected if the In and Out points are on top of each other.
|
||||
if (i < c->get_point_count() - 1) {
|
||||
v3p.push_back(p);
|
||||
v3p.push_back(p + c->get_point_out(i));
|
||||
sec_handles.push_back(p + c->get_point_out(i));
|
||||
sec_handle_points.push_back(p + c->get_point_out(i));
|
||||
}
|
||||
if (i > 0) {
|
||||
v3p.push_back(p);
|
||||
v3p.push_back(p + c->get_point_in(i));
|
||||
sec_handles.push_back(p + c->get_point_in(i));
|
||||
sec_handle_points.push_back(p + c->get_point_in(i));
|
||||
}
|
||||
}
|
||||
|
||||
if (v3p.size() > 1) {
|
||||
add_lines(v3p, path_thin_material);
|
||||
}
|
||||
if (handles.size()) {
|
||||
add_handles(handles, handles_material);
|
||||
if (handle_points.size()) {
|
||||
add_handles(handle_points, handles_material);
|
||||
}
|
||||
if (sec_handles.size()) {
|
||||
add_handles(sec_handles, sec_handles_material, Vector<int>(), false, true);
|
||||
if (sec_handle_points.size()) {
|
||||
add_handles(sec_handle_points, sec_handles_material, Vector<int>(), false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,12 +128,12 @@ void EditorStandardSyntaxHighlighter::_update_cache() {
|
|||
}
|
||||
}
|
||||
|
||||
const Ref<Script> script = _get_edited_resource();
|
||||
if (script.is_valid()) {
|
||||
const Ref<Script> scr = _get_edited_resource();
|
||||
if (scr.is_valid()) {
|
||||
/* Core types. */
|
||||
const Color basetype_color = EDITOR_GET("text_editor/theme/highlighting/base_type_color");
|
||||
List<String> core_types;
|
||||
script->get_language()->get_core_type_words(&core_types);
|
||||
scr->get_language()->get_core_type_words(&core_types);
|
||||
for (const String &E : core_types) {
|
||||
highlighter->add_keyword_color(E, basetype_color);
|
||||
}
|
||||
|
@ -142,9 +142,9 @@ void EditorStandardSyntaxHighlighter::_update_cache() {
|
|||
const Color keyword_color = EDITOR_GET("text_editor/theme/highlighting/keyword_color");
|
||||
const Color control_flow_keyword_color = EDITOR_GET("text_editor/theme/highlighting/control_flow_keyword_color");
|
||||
List<String> keywords;
|
||||
script->get_language()->get_reserved_words(&keywords);
|
||||
scr->get_language()->get_reserved_words(&keywords);
|
||||
for (const String &E : keywords) {
|
||||
if (script->get_language()->is_control_flow_keyword(E)) {
|
||||
if (scr->get_language()->is_control_flow_keyword(E)) {
|
||||
highlighter->add_keyword_color(E, control_flow_keyword_color);
|
||||
} else {
|
||||
highlighter->add_keyword_color(E, keyword_color);
|
||||
|
@ -153,19 +153,19 @@ void EditorStandardSyntaxHighlighter::_update_cache() {
|
|||
|
||||
/* Member types. */
|
||||
const Color member_variable_color = EDITOR_GET("text_editor/theme/highlighting/member_variable_color");
|
||||
StringName instance_base = script->get_instance_base_type();
|
||||
StringName instance_base = scr->get_instance_base_type();
|
||||
if (instance_base != StringName()) {
|
||||
List<PropertyInfo> plist;
|
||||
ClassDB::get_property_list(instance_base, &plist);
|
||||
for (const PropertyInfo &E : plist) {
|
||||
String name = E.name;
|
||||
String prop_name = E.name;
|
||||
if (E.usage & PROPERTY_USAGE_CATEGORY || E.usage & PROPERTY_USAGE_GROUP || E.usage & PROPERTY_USAGE_SUBGROUP) {
|
||||
continue;
|
||||
}
|
||||
if (name.contains("/")) {
|
||||
if (prop_name.contains("/")) {
|
||||
continue;
|
||||
}
|
||||
highlighter->add_member_keyword_color(name, member_variable_color);
|
||||
highlighter->add_member_keyword_color(prop_name, member_variable_color);
|
||||
}
|
||||
|
||||
List<String> clist;
|
||||
|
@ -178,7 +178,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() {
|
|||
/* Comments */
|
||||
const Color comment_color = EDITOR_GET("text_editor/theme/highlighting/comment_color");
|
||||
List<String> comments;
|
||||
script->get_language()->get_comment_delimiters(&comments);
|
||||
scr->get_language()->get_comment_delimiters(&comments);
|
||||
for (const String &comment : comments) {
|
||||
String beg = comment.get_slice(" ", 0);
|
||||
String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String();
|
||||
|
@ -188,7 +188,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() {
|
|||
/* Strings */
|
||||
const Color string_color = EDITOR_GET("text_editor/theme/highlighting/string_color");
|
||||
List<String> strings;
|
||||
script->get_language()->get_string_delimiters(&strings);
|
||||
scr->get_language()->get_string_delimiters(&strings);
|
||||
for (const String &string : strings) {
|
||||
String beg = string.get_slice(" ", 0);
|
||||
String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String();
|
||||
|
@ -431,8 +431,8 @@ void ScriptEditor::_goto_script_line2(int p_line) {
|
|||
}
|
||||
|
||||
void ScriptEditor::_goto_script_line(Ref<RefCounted> p_script, int p_line) {
|
||||
Ref<Script> script = Object::cast_to<Script>(*p_script);
|
||||
if (script.is_valid() && (script->has_source_code() || script->get_path().is_resource_file())) {
|
||||
Ref<Script> scr = Object::cast_to<Script>(*p_script);
|
||||
if (scr.is_valid() && (scr->has_source_code() || scr->get_path().is_resource_file())) {
|
||||
if (edit(p_script, p_line, 0)) {
|
||||
EditorNode::get_singleton()->push_item(p_script.ptr());
|
||||
|
||||
|
@ -447,15 +447,15 @@ void ScriptEditor::_goto_script_line(Ref<RefCounted> p_script, int p_line) {
|
|||
}
|
||||
|
||||
void ScriptEditor::_set_execution(Ref<RefCounted> p_script, int p_line) {
|
||||
Ref<Script> script = Object::cast_to<Script>(*p_script);
|
||||
if (script.is_valid() && (script->has_source_code() || script->get_path().is_resource_file())) {
|
||||
Ref<Script> scr = Object::cast_to<Script>(*p_script);
|
||||
if (scr.is_valid() && (scr->has_source_code() || scr->get_path().is_resource_file())) {
|
||||
for (int i = 0; i < tab_container->get_tab_count(); i++) {
|
||||
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i));
|
||||
if (!se) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((script != nullptr && se->get_edited_resource() == p_script) || se->get_edited_resource()->get_path() == script->get_path()) {
|
||||
if ((scr != nullptr && se->get_edited_resource() == p_script) || se->get_edited_resource()->get_path() == scr->get_path()) {
|
||||
se->set_executing_line(p_line);
|
||||
}
|
||||
}
|
||||
|
@ -463,15 +463,15 @@ void ScriptEditor::_set_execution(Ref<RefCounted> p_script, int p_line) {
|
|||
}
|
||||
|
||||
void ScriptEditor::_clear_execution(Ref<RefCounted> p_script) {
|
||||
Ref<Script> script = Object::cast_to<Script>(*p_script);
|
||||
if (script.is_valid() && (script->has_source_code() || script->get_path().is_resource_file())) {
|
||||
Ref<Script> scr = Object::cast_to<Script>(*p_script);
|
||||
if (scr.is_valid() && (scr->has_source_code() || scr->get_path().is_resource_file())) {
|
||||
for (int i = 0; i < tab_container->get_tab_count(); i++) {
|
||||
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i));
|
||||
if (!se) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((script != nullptr && se->get_edited_resource() == p_script) || se->get_edited_resource()->get_path() == script->get_path()) {
|
||||
if ((scr != nullptr && se->get_edited_resource() == p_script) || se->get_edited_resource()->get_path() == scr->get_path()) {
|
||||
se->clear_executing_line();
|
||||
}
|
||||
}
|
||||
|
@ -479,19 +479,19 @@ void ScriptEditor::_clear_execution(Ref<RefCounted> p_script) {
|
|||
}
|
||||
|
||||
void ScriptEditor::_set_breakpoint(Ref<RefCounted> p_script, int p_line, bool p_enabled) {
|
||||
Ref<Script> script = Object::cast_to<Script>(*p_script);
|
||||
if (script.is_valid() && (script->has_source_code() || script->get_path().is_resource_file())) {
|
||||
Ref<Script> scr = Object::cast_to<Script>(*p_script);
|
||||
if (scr.is_valid() && (scr->has_source_code() || scr->get_path().is_resource_file())) {
|
||||
// Update if open.
|
||||
for (int i = 0; i < tab_container->get_tab_count(); i++) {
|
||||
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i));
|
||||
if (se && se->get_edited_resource()->get_path() == script->get_path()) {
|
||||
if (se && se->get_edited_resource()->get_path() == scr->get_path()) {
|
||||
se->set_breakpoint(p_line, p_enabled);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle closed.
|
||||
Dictionary state = script_editor_cache->get_value(script->get_path(), "state");
|
||||
Dictionary state = script_editor_cache->get_value(scr->get_path(), "state");
|
||||
Array breakpoints;
|
||||
if (state.has("breakpoints")) {
|
||||
breakpoints = state["breakpoints"];
|
||||
|
@ -505,8 +505,8 @@ void ScriptEditor::_set_breakpoint(Ref<RefCounted> p_script, int p_line, bool p_
|
|||
breakpoints.push_back(p_line);
|
||||
}
|
||||
state["breakpoints"] = breakpoints;
|
||||
script_editor_cache->set_value(script->get_path(), "state", state);
|
||||
EditorDebuggerNode::get_singleton()->set_breakpoint(script->get_path(), p_line + 1, false);
|
||||
script_editor_cache->set_value(scr->get_path(), "state", state);
|
||||
EditorDebuggerNode::get_singleton()->set_breakpoint(scr->get_path(), p_line + 1, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -627,9 +627,9 @@ void ScriptEditor::_go_to_tab(int p_idx) {
|
|||
Object::cast_to<ScriptEditorBase>(c)->ensure_focus();
|
||||
}
|
||||
|
||||
Ref<Script> script = Object::cast_to<ScriptEditorBase>(c)->get_edited_resource();
|
||||
if (script != nullptr) {
|
||||
notify_script_changed(script);
|
||||
Ref<Script> scr = Object::cast_to<ScriptEditorBase>(c)->get_edited_resource();
|
||||
if (scr != nullptr) {
|
||||
notify_script_changed(scr);
|
||||
}
|
||||
|
||||
Object::cast_to<ScriptEditorBase>(c)->validate();
|
||||
|
@ -705,9 +705,9 @@ void ScriptEditor::_open_recent_script(int p_idx) {
|
|||
ResourceLoader::get_recognized_extensions_for_type("Script", &extensions);
|
||||
|
||||
if (extensions.find(path.get_extension())) {
|
||||
Ref<Script> script = ResourceLoader::load(path);
|
||||
if (script.is_valid()) {
|
||||
edit(script, true);
|
||||
Ref<Script> scr = ResourceLoader::load(path);
|
||||
if (scr.is_valid()) {
|
||||
edit(scr, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -729,9 +729,9 @@ void ScriptEditor::_open_recent_script(int p_idx) {
|
|||
} else {
|
||||
EditorNode::get_singleton()->load_resource(res_path);
|
||||
}
|
||||
Ref<Script> script = ResourceLoader::load(path);
|
||||
if (script.is_valid()) {
|
||||
edit(script, true);
|
||||
Ref<Script> scr = ResourceLoader::load(path);
|
||||
if (scr.is_valid()) {
|
||||
edit(scr, true);
|
||||
return;
|
||||
}
|
||||
} else if (!path.is_resource_file()) {
|
||||
|
@ -774,9 +774,9 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) {
|
|||
previous_scripts.push_back(file->get_path());
|
||||
}
|
||||
|
||||
Ref<Script> script = file;
|
||||
if (script.is_valid()) {
|
||||
notify_script_close(script);
|
||||
Ref<Script> scr = file;
|
||||
if (scr.is_valid()) {
|
||||
notify_script_close(scr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -851,8 +851,8 @@ void ScriptEditor::_close_docs_tab() {
|
|||
void ScriptEditor::_copy_script_path() {
|
||||
ScriptEditorBase *se = _get_current_editor();
|
||||
if (se) {
|
||||
Ref<Resource> script = se->get_edited_resource();
|
||||
DisplayServer::get_singleton()->clipboard_set(script->get_path());
|
||||
Ref<Resource> scr = se->get_edited_resource();
|
||||
DisplayServer::get_singleton()->clipboard_set(scr->get_path());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -908,9 +908,9 @@ void ScriptEditor::_resave_scripts(const String &p_str) {
|
|||
continue;
|
||||
}
|
||||
|
||||
Ref<Resource> script = se->get_edited_resource();
|
||||
Ref<Resource> scr = se->get_edited_resource();
|
||||
|
||||
if (script->is_built_in()) {
|
||||
if (scr->is_built_in()) {
|
||||
continue; //internal script, who cares
|
||||
}
|
||||
|
||||
|
@ -928,13 +928,13 @@ void ScriptEditor::_resave_scripts(const String &p_str) {
|
|||
}
|
||||
}
|
||||
|
||||
Ref<TextFile> text_file = script;
|
||||
Ref<TextFile> text_file = scr;
|
||||
if (text_file != nullptr) {
|
||||
se->apply_code();
|
||||
_save_text_file(text_file, text_file->get_path());
|
||||
break;
|
||||
} else {
|
||||
EditorNode::get_singleton()->save_resource(script);
|
||||
EditorNode::get_singleton()->save_resource(scr);
|
||||
}
|
||||
se->tag_saved_version();
|
||||
}
|
||||
|
@ -949,9 +949,9 @@ void ScriptEditor::_res_saved_callback(const Ref<Resource> &p_res) {
|
|||
continue;
|
||||
}
|
||||
|
||||
Ref<Resource> script = se->get_edited_resource();
|
||||
Ref<Resource> scr = se->get_edited_resource();
|
||||
|
||||
if (script == p_res) {
|
||||
if (scr == p_res) {
|
||||
se->tag_saved_version();
|
||||
}
|
||||
}
|
||||
|
@ -1106,8 +1106,8 @@ Ref<Script> ScriptEditor::_get_current_script() {
|
|||
ScriptEditorBase *current = _get_current_editor();
|
||||
|
||||
if (current) {
|
||||
Ref<Script> script = current->get_edited_resource();
|
||||
return script != nullptr ? script : nullptr;
|
||||
Ref<Script> scr = current->get_edited_resource();
|
||||
return scr != nullptr ? scr : nullptr;
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -1284,7 +1284,7 @@ void ScriptEditor::_menu_option(int p_option) {
|
|||
|
||||
Ref<Resource> resource = current->get_edited_resource();
|
||||
Ref<TextFile> text_file = resource;
|
||||
Ref<Script> script = resource;
|
||||
Ref<Script> scr = resource;
|
||||
|
||||
if (text_file != nullptr) {
|
||||
file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
|
||||
|
@ -1301,15 +1301,15 @@ void ScriptEditor::_menu_option(int p_option) {
|
|||
break;
|
||||
}
|
||||
|
||||
if (script.is_valid()) {
|
||||
clear_docs_from_script(script);
|
||||
if (scr.is_valid()) {
|
||||
clear_docs_from_script(scr);
|
||||
}
|
||||
|
||||
EditorNode::get_singleton()->push_item(resource.ptr());
|
||||
EditorNode::get_singleton()->save_resource_as(resource);
|
||||
|
||||
if (script.is_valid()) {
|
||||
update_docs_from_script(script);
|
||||
if (scr.is_valid()) {
|
||||
update_docs_from_script(scr);
|
||||
}
|
||||
} break;
|
||||
|
||||
|
@ -1367,18 +1367,18 @@ void ScriptEditor::_menu_option(int p_option) {
|
|||
_copy_script_path();
|
||||
} break;
|
||||
case SHOW_IN_FILE_SYSTEM: {
|
||||
const Ref<Resource> script = current->get_edited_resource();
|
||||
String path = script->get_path();
|
||||
const Ref<Resource> scr = current->get_edited_resource();
|
||||
String path = scr->get_path();
|
||||
if (!path.is_empty()) {
|
||||
if (script->is_built_in()) {
|
||||
if (scr->is_built_in()) {
|
||||
path = path.get_slice("::", 0); // Show the scene instead.
|
||||
}
|
||||
|
||||
FileSystemDock *file_system_dock = FileSystemDock::get_singleton();
|
||||
file_system_dock->navigate_to_path(path);
|
||||
// Ensure that the FileSystem dock is visible.
|
||||
TabContainer *tab_container = (TabContainer *)file_system_dock->get_parent_control();
|
||||
tab_container->set_current_tab(tab_container->get_tab_idx_from_control(file_system_dock));
|
||||
TabContainer *dock_tab_container = (TabContainer *)file_system_dock->get_parent_control();
|
||||
dock_tab_container->set_current_tab(dock_tab_container->get_tab_idx_from_control(file_system_dock));
|
||||
}
|
||||
} break;
|
||||
case CLOSE_DOCS: {
|
||||
|
@ -1635,12 +1635,12 @@ void ScriptEditor::close_builtin_scripts_from_scene(const String &p_scene) {
|
|||
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i));
|
||||
|
||||
if (se) {
|
||||
Ref<Script> script = se->get_edited_resource();
|
||||
if (script == nullptr || !script.is_valid()) {
|
||||
Ref<Script> scr = se->get_edited_resource();
|
||||
if (scr == nullptr || !scr.is_valid()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (script->is_built_in() && script->get_path().begins_with(p_scene)) { //is an internal script and belongs to scene being closed
|
||||
if (scr->is_built_in() && scr->get_path().begins_with(p_scene)) { //is an internal script and belongs to scene being closed
|
||||
_close_tab(i, false);
|
||||
i--;
|
||||
}
|
||||
|
@ -1668,12 +1668,12 @@ void ScriptEditor::get_breakpoints(List<String> *p_breakpoints) {
|
|||
continue;
|
||||
}
|
||||
|
||||
Ref<Script> script = se->get_edited_resource();
|
||||
if (script == nullptr) {
|
||||
Ref<Script> scr = se->get_edited_resource();
|
||||
if (scr == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String base = script->get_path();
|
||||
String base = scr->get_path();
|
||||
loaded_scripts.insert(base);
|
||||
if (base.begins_with("local://") || base.is_empty()) {
|
||||
continue;
|
||||
|
@ -2184,20 +2184,20 @@ bool ScriptEditor::edit(const Ref<Resource> &p_resource, int p_line, int p_col,
|
|||
return false;
|
||||
}
|
||||
|
||||
Ref<Script> script = p_resource;
|
||||
Ref<Script> scr = p_resource;
|
||||
|
||||
// Don't open dominant script if using an external editor.
|
||||
bool use_external_editor =
|
||||
EditorSettings::get_singleton()->get("text_editor/external/use_external_editor") ||
|
||||
(script.is_valid() && script->get_language()->overrides_external_editor());
|
||||
use_external_editor = use_external_editor && !(script.is_valid() && script->is_built_in()); // Ignore external editor for built-in scripts.
|
||||
(scr.is_valid() && scr->get_language()->overrides_external_editor());
|
||||
use_external_editor = use_external_editor && !(scr.is_valid() && scr->is_built_in()); // Ignore external editor for built-in scripts.
|
||||
const bool open_dominant = EditorSettings::get_singleton()->get("text_editor/behavior/files/open_dominant_script_on_scene_change");
|
||||
|
||||
const bool should_open = (open_dominant && !use_external_editor) || !EditorNode::get_singleton()->is_changing_scene();
|
||||
|
||||
if (script.is_valid() && script->get_language()->overrides_external_editor()) {
|
||||
if (scr.is_valid() && scr->get_language()->overrides_external_editor()) {
|
||||
if (should_open) {
|
||||
Error err = script->get_language()->open_in_external_editor(script, p_line >= 0 ? p_line : 0, p_col);
|
||||
Error err = scr->get_language()->open_in_external_editor(scr, p_line >= 0 ? p_line : 0, p_col);
|
||||
if (err != OK) {
|
||||
ERR_PRINT("Couldn't open script in the overridden external text editor");
|
||||
}
|
||||
|
@ -2271,7 +2271,7 @@ bool ScriptEditor::edit(const Ref<Resource> &p_resource, int p_line, int p_col,
|
|||
continue;
|
||||
}
|
||||
|
||||
if ((script != nullptr && se->get_edited_resource() == p_resource) || se->get_edited_resource()->get_path() == p_resource->get_path()) {
|
||||
if ((scr != nullptr && se->get_edited_resource() == p_resource) || se->get_edited_resource()->get_path() == p_resource->get_path()) {
|
||||
if (should_open) {
|
||||
se->enable_editor();
|
||||
|
||||
|
@ -2316,9 +2316,9 @@ bool ScriptEditor::edit(const Ref<Resource> &p_resource, int p_line, int p_col,
|
|||
}
|
||||
se->add_syntax_highlighter(highlighter);
|
||||
|
||||
if (script != nullptr && !highlighter_set) {
|
||||
if (scr != nullptr && !highlighter_set) {
|
||||
PackedStringArray languages = highlighter->_get_supported_languages();
|
||||
if (languages.has(script->get_language()->get_name())) {
|
||||
if (languages.has(scr->get_language()->get_name())) {
|
||||
se->set_syntax_highlighter(highlighter);
|
||||
highlighter_set = true;
|
||||
}
|
||||
|
@ -2399,7 +2399,7 @@ void ScriptEditor::save_current_script() {
|
|||
|
||||
Ref<Resource> resource = current->get_edited_resource();
|
||||
Ref<TextFile> text_file = resource;
|
||||
Ref<Script> script = resource;
|
||||
Ref<Script> scr = resource;
|
||||
|
||||
if (text_file != nullptr) {
|
||||
current->apply_code();
|
||||
|
@ -2407,8 +2407,8 @@ void ScriptEditor::save_current_script() {
|
|||
return;
|
||||
}
|
||||
|
||||
if (script.is_valid()) {
|
||||
clear_docs_from_script(script);
|
||||
if (scr.is_valid()) {
|
||||
clear_docs_from_script(scr);
|
||||
}
|
||||
|
||||
if (resource->is_built_in()) {
|
||||
|
@ -2423,8 +2423,8 @@ void ScriptEditor::save_current_script() {
|
|||
EditorNode::get_singleton()->save_resource(resource);
|
||||
}
|
||||
|
||||
if (script.is_valid()) {
|
||||
update_docs_from_script(script);
|
||||
if (scr.is_valid()) {
|
||||
update_docs_from_script(scr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2462,21 +2462,21 @@ void ScriptEditor::save_all_scripts() {
|
|||
|
||||
if (!edited_res->is_built_in()) {
|
||||
Ref<TextFile> text_file = edited_res;
|
||||
Ref<Script> script = edited_res;
|
||||
Ref<Script> scr = edited_res;
|
||||
|
||||
if (text_file != nullptr) {
|
||||
_save_text_file(text_file, text_file->get_path());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (script.is_valid()) {
|
||||
clear_docs_from_script(script);
|
||||
if (scr.is_valid()) {
|
||||
clear_docs_from_script(scr);
|
||||
}
|
||||
|
||||
EditorNode::get_singleton()->save_resource(edited_res); //external script, save it
|
||||
|
||||
if (script.is_valid()) {
|
||||
update_docs_from_script(script);
|
||||
if (scr.is_valid()) {
|
||||
update_docs_from_script(scr);
|
||||
}
|
||||
} else {
|
||||
// For built-in scripts, save their scenes instead.
|
||||
|
@ -2526,13 +2526,13 @@ void ScriptEditor::reload_scripts(bool p_refresh_only) {
|
|||
continue;
|
||||
}
|
||||
|
||||
Ref<Script> script = edited_res;
|
||||
if (script != nullptr) {
|
||||
Ref<Script> rel_script = ResourceLoader::load(script->get_path(), script->get_class(), ResourceFormatLoader::CACHE_MODE_IGNORE);
|
||||
ERR_CONTINUE(!rel_script.is_valid());
|
||||
script->set_source_code(rel_script->get_source_code());
|
||||
script->set_last_modified_time(rel_script->get_last_modified_time());
|
||||
script->reload(true);
|
||||
Ref<Script> scr = edited_res;
|
||||
if (scr != nullptr) {
|
||||
Ref<Script> rel_scr = ResourceLoader::load(scr->get_path(), scr->get_class(), ResourceFormatLoader::CACHE_MODE_IGNORE);
|
||||
ERR_CONTINUE(!rel_scr.is_valid());
|
||||
scr->set_source_code(rel_scr->get_source_code());
|
||||
scr->set_last_modified_time(rel_scr->get_last_modified_time());
|
||||
scr->reload(true);
|
||||
}
|
||||
|
||||
Ref<TextFile> text_file = edited_res;
|
||||
|
@ -2605,17 +2605,17 @@ void ScriptEditor::_editor_stop() {
|
|||
|
||||
void ScriptEditor::_add_callback(Object *p_obj, const String &p_function, const PackedStringArray &p_args) {
|
||||
ERR_FAIL_COND(!p_obj);
|
||||
Ref<Script> script = p_obj->get_script();
|
||||
ERR_FAIL_COND(!script.is_valid());
|
||||
Ref<Script> scr = p_obj->get_script();
|
||||
ERR_FAIL_COND(!scr.is_valid());
|
||||
|
||||
EditorNode::get_singleton()->push_item(script.ptr());
|
||||
EditorNode::get_singleton()->push_item(scr.ptr());
|
||||
|
||||
for (int i = 0; i < tab_container->get_tab_count(); i++) {
|
||||
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i));
|
||||
if (!se) {
|
||||
continue;
|
||||
}
|
||||
if (se->get_edited_resource() != script) {
|
||||
if (se->get_edited_resource() != scr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -2626,7 +2626,7 @@ void ScriptEditor::_add_callback(Object *p_obj, const String &p_function, const
|
|||
script_list->select(script_list->find_metadata(i));
|
||||
|
||||
// Save the current script so the changes can be picked up by an external editor.
|
||||
if (!script.ptr()->is_built_in()) { // But only if it's not built-in script.
|
||||
if (!scr.ptr()->is_built_in()) { // But only if it's not built-in script.
|
||||
save_current_script();
|
||||
}
|
||||
|
||||
|
@ -3376,9 +3376,9 @@ void ScriptEditor::_update_history_pos(int p_new_pos) {
|
|||
seb->set_edit_state(history[history_pos].state);
|
||||
seb->ensure_focus();
|
||||
|
||||
Ref<Script> script = seb->get_edited_resource();
|
||||
if (script != nullptr) {
|
||||
notify_script_changed(script);
|
||||
Ref<Script> scr = seb->get_edited_resource();
|
||||
if (scr != nullptr) {
|
||||
notify_script_changed(scr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3414,9 +3414,9 @@ Vector<Ref<Script>> ScriptEditor::get_open_scripts() const {
|
|||
continue;
|
||||
}
|
||||
|
||||
Ref<Script> script = se->get_edited_resource();
|
||||
if (script != nullptr) {
|
||||
out_scripts.push_back(script);
|
||||
Ref<Script> scr = se->get_edited_resource();
|
||||
if (scr != nullptr) {
|
||||
out_scripts.push_back(scr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3467,9 +3467,9 @@ void ScriptEditor::_help_search(String p_text) {
|
|||
}
|
||||
|
||||
void ScriptEditor::_open_script_request(const String &p_path) {
|
||||
Ref<Script> script = ResourceLoader::load(p_path);
|
||||
if (script.is_valid()) {
|
||||
script_editor->edit(script, false);
|
||||
Ref<Script> scr = ResourceLoader::load(p_path);
|
||||
if (scr.is_valid()) {
|
||||
script_editor->edit(scr, false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3534,9 +3534,9 @@ void ScriptEditor::_on_find_in_files_result_selected(String fpath, int line_numb
|
|||
EditorNode::get_singleton()->load_scene(fpath);
|
||||
return;
|
||||
} else {
|
||||
Ref<Script> script = res;
|
||||
if (script.is_valid()) {
|
||||
edit(script);
|
||||
Ref<Script> scr = res;
|
||||
if (scr.is_valid()) {
|
||||
edit(scr);
|
||||
|
||||
ScriptTextEditor *ste = Object::cast_to<ScriptTextEditor>(_get_current_editor());
|
||||
if (ste) {
|
||||
|
@ -3806,12 +3806,12 @@ ScriptEditor::ScriptEditor() {
|
|||
script_search_menu->get_popup()->connect("id_pressed", callable_mp(this, &ScriptEditor::_menu_option));
|
||||
menu_hb->add_child(script_search_menu);
|
||||
|
||||
MenuButton *debug_menu = memnew(MenuButton);
|
||||
menu_hb->add_child(debug_menu);
|
||||
debug_menu->hide(); // Handled by EditorDebuggerNode below.
|
||||
MenuButton *debug_menu_btn = memnew(MenuButton);
|
||||
menu_hb->add_child(debug_menu_btn);
|
||||
debug_menu_btn->hide(); // Handled by EditorDebuggerNode below.
|
||||
|
||||
EditorDebuggerNode *debugger = EditorDebuggerNode::get_singleton();
|
||||
debugger->set_script_debug_button(debug_menu);
|
||||
debugger->set_script_debug_button(debug_menu_btn);
|
||||
debugger->connect("goto_script_line", callable_mp(this, &ScriptEditor::_goto_script_line));
|
||||
debugger->connect("set_execution", callable_mp(this, &ScriptEditor::_set_execution));
|
||||
debugger->connect("clear_execution", callable_mp(this, &ScriptEditor::_clear_execution));
|
||||
|
|
|
@ -703,25 +703,25 @@ void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_fo
|
|||
}
|
||||
|
||||
for (const Ref<Script> &E : scripts) {
|
||||
Ref<Script> script = E;
|
||||
Ref<Script> scr = E;
|
||||
|
||||
if (p_for_script.is_valid() && p_for_script != script) {
|
||||
if (p_for_script.is_valid() && p_for_script != scr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (script->is_built_in()) {
|
||||
if (scr->is_built_in()) {
|
||||
continue; //internal script, who cares, though weird
|
||||
}
|
||||
|
||||
uint64_t last_date = script->get_last_modified_time();
|
||||
uint64_t date = FileAccess::get_modified_time(script->get_path());
|
||||
uint64_t last_date = scr->get_last_modified_time();
|
||||
uint64_t date = FileAccess::get_modified_time(scr->get_path());
|
||||
|
||||
if (last_date != date) {
|
||||
Ref<Script> rel_script = ResourceLoader::load(script->get_path(), script->get_class(), ResourceFormatLoader::CACHE_MODE_IGNORE);
|
||||
ERR_CONTINUE(!rel_script.is_valid());
|
||||
script->set_source_code(rel_script->get_source_code());
|
||||
script->set_last_modified_time(rel_script->get_last_modified_time());
|
||||
script->update_exports();
|
||||
Ref<Script> rel_scr = ResourceLoader::load(scr->get_path(), scr->get_class(), ResourceFormatLoader::CACHE_MODE_IGNORE);
|
||||
ERR_CONTINUE(!rel_scr.is_valid());
|
||||
scr->set_source_code(rel_scr->get_source_code());
|
||||
scr->set_last_modified_time(rel_scr->get_last_modified_time());
|
||||
scr->update_exports();
|
||||
|
||||
_trigger_live_script_reload();
|
||||
}
|
||||
|
@ -982,10 +982,10 @@ void ScriptTextEditor::_update_connected_methods() {
|
|||
Vector<Node *> nodes = _find_all_node_for_script(base, base, script);
|
||||
HashSet<StringName> methods_found;
|
||||
for (int i = 0; i < nodes.size(); i++) {
|
||||
List<Connection> connections;
|
||||
nodes[i]->get_signals_connected_to_this(&connections);
|
||||
List<Connection> signal_connections;
|
||||
nodes[i]->get_signals_connected_to_this(&signal_connections);
|
||||
|
||||
for (const Connection &connection : connections) {
|
||||
for (const Connection &connection : signal_connections) {
|
||||
if (!(connection.flags & CONNECT_PERSIST)) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -587,25 +587,25 @@ void Skeleton3DEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
|
|||
|
||||
void Skeleton3DEditor::move_skeleton_bone(NodePath p_skeleton_path, int32_t p_selected_boneidx, int32_t p_target_boneidx) {
|
||||
Node *node = get_node_or_null(p_skeleton_path);
|
||||
Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(node);
|
||||
ERR_FAIL_NULL(skeleton);
|
||||
Skeleton3D *skeleton_node = Object::cast_to<Skeleton3D>(node);
|
||||
ERR_FAIL_NULL(skeleton_node);
|
||||
Ref<EditorUndoRedoManager> &ur = EditorNode::get_undo_redo();
|
||||
ur->create_action(TTR("Set Bone Parentage"));
|
||||
// If the target is a child of ourselves, we move only *us* and not our children.
|
||||
if (skeleton->is_bone_parent_of(p_target_boneidx, p_selected_boneidx)) {
|
||||
const BoneId parent_idx = skeleton->get_bone_parent(p_selected_boneidx);
|
||||
const int bone_count = skeleton->get_bone_count();
|
||||
if (skeleton_node->is_bone_parent_of(p_target_boneidx, p_selected_boneidx)) {
|
||||
const BoneId parent_idx = skeleton_node->get_bone_parent(p_selected_boneidx);
|
||||
const int bone_count = skeleton_node->get_bone_count();
|
||||
for (BoneId i = 0; i < bone_count; ++i) {
|
||||
if (skeleton->get_bone_parent(i) == p_selected_boneidx) {
|
||||
ur->add_undo_method(skeleton, "set_bone_parent", i, skeleton->get_bone_parent(i));
|
||||
ur->add_do_method(skeleton, "set_bone_parent", i, parent_idx);
|
||||
skeleton->set_bone_parent(i, parent_idx);
|
||||
if (skeleton_node->get_bone_parent(i) == p_selected_boneidx) {
|
||||
ur->add_undo_method(skeleton_node, "set_bone_parent", i, skeleton_node->get_bone_parent(i));
|
||||
ur->add_do_method(skeleton_node, "set_bone_parent", i, parent_idx);
|
||||
skeleton_node->set_bone_parent(i, parent_idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
ur->add_undo_method(skeleton, "set_bone_parent", p_selected_boneidx, skeleton->get_bone_parent(p_selected_boneidx));
|
||||
ur->add_do_method(skeleton, "set_bone_parent", p_selected_boneidx, p_target_boneidx);
|
||||
skeleton->set_bone_parent(p_selected_boneidx, p_target_boneidx);
|
||||
ur->add_undo_method(skeleton_node, "set_bone_parent", p_selected_boneidx, skeleton_node->get_bone_parent(p_selected_boneidx));
|
||||
ur->add_do_method(skeleton_node, "set_bone_parent", p_selected_boneidx, p_target_boneidx);
|
||||
skeleton_node->set_bone_parent(p_selected_boneidx, p_target_boneidx);
|
||||
|
||||
update_joint_tree();
|
||||
ur->commit_action();
|
||||
|
|
|
@ -1095,8 +1095,8 @@ bool SpriteFramesEditor::can_drop_data_fw(const Point2 &p_point, const Variant &
|
|||
}
|
||||
|
||||
for (int i = 0; i < files.size(); i++) {
|
||||
String file = files[i];
|
||||
String ftype = EditorFileSystem::get_singleton()->get_file_type(file);
|
||||
String f = files[i];
|
||||
String ftype = EditorFileSystem::get_singleton()->get_file_type(f);
|
||||
|
||||
if (!ClassDB::is_parent_class(ftype, "Texture2D")) {
|
||||
return false;
|
||||
|
|
|
@ -202,12 +202,12 @@ void ShaderTextEditor::set_warnings_panel(RichTextLabel *p_warnings_panel) {
|
|||
}
|
||||
|
||||
void ShaderTextEditor::_load_theme_settings() {
|
||||
CodeEdit *text_editor = get_text_editor();
|
||||
CodeEdit *te = get_text_editor();
|
||||
Color updated_marked_line_color = EDITOR_GET("text_editor/theme/highlighting/mark_color");
|
||||
if (updated_marked_line_color != marked_line_color) {
|
||||
for (int i = 0; i < text_editor->get_line_count(); i++) {
|
||||
if (text_editor->get_line_background_color(i) == marked_line_color) {
|
||||
text_editor->set_line_background_color(i, updated_marked_line_color);
|
||||
for (int i = 0; i < te->get_line_count(); i++) {
|
||||
if (te->get_line_background_color(i) == marked_line_color) {
|
||||
te->set_line_background_color(i, updated_marked_line_color);
|
||||
}
|
||||
}
|
||||
marked_line_color = updated_marked_line_color;
|
||||
|
@ -257,14 +257,14 @@ void ShaderTextEditor::_load_theme_settings() {
|
|||
const Vector<ShaderLanguage::ModeInfo> &modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(i));
|
||||
|
||||
for (int j = 0; j < modes.size(); j++) {
|
||||
const ShaderLanguage::ModeInfo &info = modes[j];
|
||||
const ShaderLanguage::ModeInfo &mode_info = modes[j];
|
||||
|
||||
if (!info.options.is_empty()) {
|
||||
for (int k = 0; k < info.options.size(); k++) {
|
||||
built_ins.push_back(String(info.name) + "_" + String(info.options[k]));
|
||||
if (!mode_info.options.is_empty()) {
|
||||
for (int k = 0; k < mode_info.options.size(); k++) {
|
||||
built_ins.push_back(String(mode_info.name) + "_" + String(mode_info.options[k]));
|
||||
}
|
||||
} else {
|
||||
built_ins.push_back(String(info.name));
|
||||
built_ins.push_back(String(mode_info.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -278,14 +278,14 @@ void ShaderTextEditor::_load_theme_settings() {
|
|||
const Vector<ShaderLanguage::ModeInfo> &modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode()));
|
||||
|
||||
for (int i = 0; i < modes.size(); i++) {
|
||||
const ShaderLanguage::ModeInfo &info = modes[i];
|
||||
const ShaderLanguage::ModeInfo &mode_info = modes[i];
|
||||
|
||||
if (!info.options.is_empty()) {
|
||||
for (int j = 0; j < info.options.size(); j++) {
|
||||
built_ins.push_back(String(info.name) + "_" + String(info.options[j]));
|
||||
if (!mode_info.options.is_empty()) {
|
||||
for (int j = 0; j < mode_info.options.size(); j++) {
|
||||
built_ins.push_back(String(mode_info.name) + "_" + String(mode_info.options[j]));
|
||||
}
|
||||
} else {
|
||||
built_ins.push_back(String(info.name));
|
||||
built_ins.push_back(String(mode_info.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -303,12 +303,12 @@ void ShaderTextEditor::_load_theme_settings() {
|
|||
syntax_highlighter->add_color_region("//", "", comment_color, true);
|
||||
syntax_highlighter->set_disabled_branch_color(comment_color);
|
||||
|
||||
text_editor->clear_comment_delimiters();
|
||||
text_editor->add_comment_delimiter("/*", "*/", false);
|
||||
text_editor->add_comment_delimiter("//", "", true);
|
||||
te->clear_comment_delimiters();
|
||||
te->add_comment_delimiter("/*", "*/", false);
|
||||
te->add_comment_delimiter("//", "", true);
|
||||
|
||||
if (!text_editor->has_auto_brace_completion_open_key("/*")) {
|
||||
text_editor->add_auto_brace_completion_pair("/*", "*/");
|
||||
if (!te->has_auto_brace_completion_open_key("/*")) {
|
||||
te->add_auto_brace_completion_pair("/*", "*/");
|
||||
}
|
||||
|
||||
// Colorize preprocessor include strings.
|
||||
|
@ -399,22 +399,22 @@ void ShaderTextEditor::_code_complete_script(const String &p_code, List<ScriptLa
|
|||
|
||||
ShaderLanguage sl;
|
||||
String calltip;
|
||||
ShaderLanguage::ShaderCompileInfo info;
|
||||
info.global_shader_uniform_type_func = _get_global_shader_uniform_type;
|
||||
ShaderLanguage::ShaderCompileInfo comp_info;
|
||||
comp_info.global_shader_uniform_type_func = _get_global_shader_uniform_type;
|
||||
|
||||
if (shader.is_null()) {
|
||||
info.is_include = true;
|
||||
comp_info.is_include = true;
|
||||
|
||||
sl.complete(code, info, r_options, calltip);
|
||||
sl.complete(code, comp_info, r_options, calltip);
|
||||
get_text_editor()->set_code_hint(calltip);
|
||||
return;
|
||||
}
|
||||
_check_shader_mode();
|
||||
info.functions = ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode()));
|
||||
info.render_modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode()));
|
||||
info.shader_types = ShaderTypes::get_singleton()->get_types();
|
||||
comp_info.functions = ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode()));
|
||||
comp_info.render_modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode()));
|
||||
comp_info.shader_types = ShaderTypes::get_singleton()->get_types();
|
||||
|
||||
sl.complete(code, info, r_options, calltip);
|
||||
sl.complete(code, comp_info, r_options, calltip);
|
||||
get_text_editor()->set_code_hint(calltip);
|
||||
}
|
||||
|
||||
|
@ -464,22 +464,22 @@ void ShaderTextEditor::_validate_script() {
|
|||
//preprocessor error
|
||||
ERR_FAIL_COND(err_positions.size() == 0);
|
||||
|
||||
String error_text = error_pp;
|
||||
int error_line = err_positions.front()->get().line;
|
||||
String err_text = error_pp;
|
||||
int err_line = err_positions.front()->get().line;
|
||||
if (err_positions.size() == 1) {
|
||||
// Error in main file
|
||||
error_text = "error(" + itos(error_line) + "): " + error_text;
|
||||
err_text = "error(" + itos(err_line) + "): " + err_text;
|
||||
} else {
|
||||
error_text = "error(" + itos(error_line) + ") in include " + err_positions.back()->get().file.get_file() + ":" + itos(err_positions.back()->get().line) + ": " + error_text;
|
||||
err_text = "error(" + itos(err_line) + ") in include " + err_positions.back()->get().file.get_file() + ":" + itos(err_positions.back()->get().line) + ": " + err_text;
|
||||
set_error_count(err_positions.size() - 1);
|
||||
}
|
||||
|
||||
set_error(error_text);
|
||||
set_error_pos(error_line - 1, 0);
|
||||
set_error(err_text);
|
||||
set_error_pos(err_line - 1, 0);
|
||||
for (int i = 0; i < get_text_editor()->get_line_count(); i++) {
|
||||
get_text_editor()->set_line_background_color(i, Color(0, 0, 0, 0));
|
||||
}
|
||||
get_text_editor()->set_line_background_color(error_line - 1, marked_line_color);
|
||||
get_text_editor()->set_line_background_color(err_line - 1, marked_line_color);
|
||||
|
||||
set_warning_count(0);
|
||||
|
||||
|
@ -507,39 +507,39 @@ void ShaderTextEditor::_validate_script() {
|
|||
}
|
||||
sl.set_warning_flags(flags);
|
||||
|
||||
ShaderLanguage::ShaderCompileInfo info;
|
||||
info.global_shader_uniform_type_func = _get_global_shader_uniform_type;
|
||||
ShaderLanguage::ShaderCompileInfo comp_info;
|
||||
comp_info.global_shader_uniform_type_func = _get_global_shader_uniform_type;
|
||||
|
||||
if (shader.is_null()) {
|
||||
info.is_include = true;
|
||||
comp_info.is_include = true;
|
||||
} else {
|
||||
Shader::Mode mode = shader->get_mode();
|
||||
info.functions = ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(mode));
|
||||
info.render_modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(mode));
|
||||
info.shader_types = ShaderTypes::get_singleton()->get_types();
|
||||
comp_info.functions = ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(mode));
|
||||
comp_info.render_modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(mode));
|
||||
comp_info.shader_types = ShaderTypes::get_singleton()->get_types();
|
||||
}
|
||||
|
||||
code = code_pp;
|
||||
//compiler error
|
||||
last_compile_result = sl.compile(code, info);
|
||||
last_compile_result = sl.compile(code, comp_info);
|
||||
|
||||
if (last_compile_result != OK) {
|
||||
String error_text;
|
||||
int error_line;
|
||||
String err_text;
|
||||
int err_line;
|
||||
Vector<ShaderLanguage::FilePosition> include_positions = sl.get_include_positions();
|
||||
if (include_positions.size() > 1) {
|
||||
//error is in an include
|
||||
error_line = include_positions[0].line;
|
||||
error_text = "error(" + itos(error_line) + ") in include " + include_positions[include_positions.size() - 1].file + ":" + itos(include_positions[include_positions.size() - 1].line) + ": " + sl.get_error_text();
|
||||
err_line = include_positions[0].line;
|
||||
err_text = "error(" + itos(err_line) + ") in include " + include_positions[include_positions.size() - 1].file + ":" + itos(include_positions[include_positions.size() - 1].line) + ": " + sl.get_error_text();
|
||||
set_error_count(include_positions.size() - 1);
|
||||
} else {
|
||||
error_line = sl.get_error_line();
|
||||
error_text = "error(" + itos(error_line) + "): " + sl.get_error_text();
|
||||
err_line = sl.get_error_line();
|
||||
err_text = "error(" + itos(err_line) + "): " + sl.get_error_text();
|
||||
set_error_count(0);
|
||||
}
|
||||
set_error(error_text);
|
||||
set_error_pos(error_line - 1, 0);
|
||||
get_text_editor()->set_line_background_color(error_line - 1, marked_line_color);
|
||||
set_error(err_text);
|
||||
set_error_pos(err_line - 1, 0);
|
||||
get_text_editor()->set_line_background_color(err_line - 1, marked_line_color);
|
||||
} else {
|
||||
set_error("");
|
||||
}
|
||||
|
|
|
@ -212,8 +212,8 @@ void GenericTilePolygonEditor::_base_control_draw() {
|
|||
for (int i = 0; i < (int)polygons.size(); i++) {
|
||||
const Vector<Vector2> &polygon = polygons[i];
|
||||
for (int j = 0; j < polygon.size(); j++) {
|
||||
const Color modulate = (tinted_polygon_index == i && tinted_point_index == j) ? Color(0.5, 1, 2) : Color(1, 1, 1);
|
||||
base_control->draw_texture(handle, xform.xform(polygon[j]) - handle->get_size() / 2, modulate);
|
||||
const Color poly_modulate = (tinted_polygon_index == i && tinted_point_index == j) ? Color(0.5, 1, 2) : Color(1, 1, 1);
|
||||
base_control->draw_texture(handle, xform.xform(polygon[j]) - handle->get_size() / 2, poly_modulate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2662,27 +2662,27 @@ TileDataTerrainsEditor::~TileDataTerrainsEditor() {
|
|||
}
|
||||
|
||||
Variant TileDataNavigationEditor::_get_painted_value() {
|
||||
Ref<NavigationPolygon> navigation_polygon;
|
||||
navigation_polygon.instantiate();
|
||||
Ref<NavigationPolygon> nav_polygon;
|
||||
nav_polygon.instantiate();
|
||||
|
||||
for (int i = 0; i < polygon_editor->get_polygon_count(); i++) {
|
||||
Vector<Vector2> polygon = polygon_editor->get_polygon(i);
|
||||
navigation_polygon->add_outline(polygon);
|
||||
nav_polygon->add_outline(polygon);
|
||||
}
|
||||
|
||||
navigation_polygon->make_polygons_from_outlines();
|
||||
return navigation_polygon;
|
||||
nav_polygon->make_polygons_from_outlines();
|
||||
return nav_polygon;
|
||||
}
|
||||
|
||||
void TileDataNavigationEditor::_set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) {
|
||||
TileData *tile_data = p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile);
|
||||
ERR_FAIL_COND(!tile_data);
|
||||
|
||||
Ref<NavigationPolygon> navigation_polygon = tile_data->get_navigation_polygon(navigation_layer);
|
||||
Ref<NavigationPolygon> nav_polygon = tile_data->get_navigation_polygon(navigation_layer);
|
||||
polygon_editor->clear_polygons();
|
||||
if (navigation_polygon.is_valid()) {
|
||||
for (int i = 0; i < navigation_polygon->get_outline_count(); i++) {
|
||||
polygon_editor->add_polygon(navigation_polygon->get_outline(i));
|
||||
if (nav_polygon.is_valid()) {
|
||||
for (int i = 0; i < nav_polygon->get_outline_count(); i++) {
|
||||
polygon_editor->add_polygon(nav_polygon->get_outline(i));
|
||||
}
|
||||
}
|
||||
polygon_editor->set_background(p_tile_set_atlas_source->get_texture(), p_tile_set_atlas_source->get_tile_texture_region(p_coords), p_tile_set_atlas_source->get_tile_effective_texture_offset(p_coords, p_alternative_tile), tile_data->get_flip_h(), tile_data->get_flip_v(), tile_data->get_transpose(), tile_data->get_modulate());
|
||||
|
@ -2691,8 +2691,8 @@ void TileDataNavigationEditor::_set_painted_value(TileSetAtlasSource *p_tile_set
|
|||
void TileDataNavigationEditor::_set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) {
|
||||
TileData *tile_data = p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile);
|
||||
ERR_FAIL_COND(!tile_data);
|
||||
Ref<NavigationPolygon> navigation_polygon = p_value;
|
||||
tile_data->set_navigation_polygon(navigation_layer, navigation_polygon);
|
||||
Ref<NavigationPolygon> nav_polygon = p_value;
|
||||
tile_data->set_navigation_polygon(navigation_layer, nav_polygon);
|
||||
|
||||
polygon_editor->set_background(p_tile_set_atlas_source->get_texture(), p_tile_set_atlas_source->get_tile_texture_region(p_coords), p_tile_set_atlas_source->get_tile_effective_texture_offset(p_coords, p_alternative_tile), tile_data->get_flip_h(), tile_data->get_flip_v(), tile_data->get_transpose(), tile_data->get_modulate());
|
||||
}
|
||||
|
@ -2740,9 +2740,9 @@ void TileDataNavigationEditor::draw_over_tile(CanvasItem *p_canvas_item, Transfo
|
|||
// Draw all shapes.
|
||||
RenderingServer::get_singleton()->canvas_item_add_set_transform(p_canvas_item->get_canvas_item(), p_transform);
|
||||
|
||||
Ref<NavigationPolygon> navigation_polygon = tile_data->get_navigation_polygon(navigation_layer);
|
||||
if (navigation_polygon.is_valid()) {
|
||||
Vector<Vector2> verts = navigation_polygon->get_vertices();
|
||||
Ref<NavigationPolygon> nav_polygon = tile_data->get_navigation_polygon(navigation_layer);
|
||||
if (nav_polygon.is_valid()) {
|
||||
Vector<Vector2> verts = nav_polygon->get_vertices();
|
||||
if (verts.size() < 3) {
|
||||
return;
|
||||
}
|
||||
|
@ -2759,9 +2759,9 @@ void TileDataNavigationEditor::draw_over_tile(CanvasItem *p_canvas_item, Transfo
|
|||
}
|
||||
|
||||
RandomPCG rand;
|
||||
for (int i = 0; i < navigation_polygon->get_polygon_count(); i++) {
|
||||
for (int i = 0; i < nav_polygon->get_polygon_count(); i++) {
|
||||
// An array of vertices for this polygon.
|
||||
Vector<int> polygon = navigation_polygon->get_polygon(i);
|
||||
Vector<int> polygon = nav_polygon->get_polygon(i);
|
||||
Vector<Vector2> vertices;
|
||||
vertices.resize(polygon.size());
|
||||
for (int j = 0; j < polygon.size(); j++) {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue