summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/animation_track_editor_plugins.cpp33
-rw-r--r--editor/editor_node.cpp61
-rw-r--r--editor/editor_node.h2
-rw-r--r--editor/editor_run_native.cpp12
-rw-r--r--editor/editor_run_native.h5
-rw-r--r--editor/editor_settings.cpp2
6 files changed, 72 insertions, 43 deletions
diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp
index baf417fed7..07dbc1fd81 100644
--- a/editor/animation_track_editor_plugins.cpp
+++ b/editor/animation_track_editor_plugins.cpp
@@ -48,7 +48,7 @@ int AnimationTrackEditBool::get_key_height() const {
Rect2 AnimationTrackEditBool::get_key_rect(int p_index, float p_pixels_sec) {
Ref<Texture> checked = get_icon("checked", "CheckBox");
- return Rect2(0, 0, checked->get_width(), get_size().height);
+ return Rect2(-checked->get_width() / 2, 0, checked->get_width(), get_size().height);
}
bool AnimationTrackEditBool::is_key_selectable_by_distance() const {
@@ -57,17 +57,18 @@ bool AnimationTrackEditBool::is_key_selectable_by_distance() const {
}
void AnimationTrackEditBool::draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) {
- Ref<Texture> icon;
bool checked = get_animation()->track_get_key_value(get_track(), p_index);
+ Ref<Texture> icon = get_icon(checked ? "checked" : "unchecked", "CheckBox");
- if (checked)
- icon = get_icon("checked", "CheckBox");
- else
- icon = get_icon("unchecked", "CheckBox");
+ Vector2 ofs(p_x - icon->get_width() / 2, int(get_size().height - icon->get_height()) / 2);
- Vector2 ofs(p_x, int(get_size().height - icon->get_height()) / 2);
+ if (ofs.x + icon->get_width() / 2 < p_clip_left)
+ return;
+
+ if (ofs.x + icon->get_width() / 2 > p_clip_right)
+ return;
- draw_texture_clipped(icon, ofs);
+ draw_texture(icon, ofs);
if (p_selected) {
Color color = get_color("accent_color", "Editor");
@@ -86,7 +87,7 @@ Rect2 AnimationTrackEditColor::get_key_rect(int p_index, float p_pixels_sec) {
Ref<Font> font = get_font("font", "Label");
int fh = font->get_height() * 0.8;
- return Rect2(0, 0, fh, get_size().height);
+ return Rect2(-fh / 2, 0, fh, get_size().height);
}
bool AnimationTrackEditColor::is_key_selectable_by_distance() const {
@@ -96,20 +97,14 @@ bool AnimationTrackEditColor::is_key_selectable_by_distance() const {
void AnimationTrackEditColor::draw_key_link(int p_index, float p_pixels_sec, int p_x, int p_next_x, int p_clip_left, int p_clip_right) {
- int x_from = p_x;
- int x_to = p_next_x;
-
Ref<Font> font = get_font("font", "Label");
int fh = (font->get_height() * 0.8);
- x_from += fh - 1;
- x_to += 1;
+ int x_from = p_x + fh / 2 - 1;
+ int x_to = p_next_x - fh / 2 + 1;
fh /= 3;
- if (x_from > p_clip_right)
- return;
-
- if (x_to < p_clip_left)
+ if (x_from > p_clip_right || x_to < p_clip_left)
return;
Color color = get_animation()->track_get_key_value(get_track(), p_index);
@@ -154,7 +149,7 @@ void AnimationTrackEditColor::draw_key(int p_index, float p_pixels_sec, int p_x,
Ref<Font> font = get_font("font", "Label");
int fh = font->get_height() * 0.8;
- Rect2 rect(Vector2(p_x, int(get_size().height - fh) / 2), Size2(fh, fh));
+ Rect2 rect(Vector2(p_x - fh / 2, int(get_size().height - fh) / 2), Size2(fh, fh));
draw_rect_clipped(Rect2(rect.position, rect.size / 2), Color(0.4, 0.4, 0.4));
draw_rect_clipped(Rect2(rect.position + rect.size / 2, rect.size / 2), Color(0.4, 0.4, 0.4));
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index b8f3ee23f0..43c8ef60aa 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -1296,7 +1296,12 @@ void EditorNode::_dialog_action(String p_file) {
ProjectSettings::get_singleton()->set("application/run/main_scene", p_file);
ProjectSettings::get_singleton()->save();
//would be nice to show the project manager opened with the highlighted field..
- _run(false, ""); // automatically run the project
+
+ if (pick_main_scene->has_meta("from_native") && (bool)pick_main_scene->get_meta("from_native")) {
+ run_native->resume_run_native();
+ } else {
+ _run(false, ""); // automatically run the project
+ }
} break;
case FILE_CLOSE:
case FILE_CLOSE_ALL_AND_QUIT:
@@ -1809,28 +1814,7 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
if (run_filename == "") {
//evidently, run the scene
- main_scene = GLOBAL_DEF("application/run/main_scene", "");
- if (main_scene == "") {
-
- current_option = -1;
- pick_main_scene->set_text(TTR("No main scene has ever been defined, select one?\nYou can change it later in \"Project Settings\" under the 'application' category."));
- pick_main_scene->popup_centered_minsize();
- return;
- }
-
- if (!FileAccess::exists(main_scene)) {
-
- current_option = -1;
- pick_main_scene->set_text(vformat(TTR("Selected scene '%s' does not exist, select a valid one?\nYou can change it later in \"Project Settings\" under the 'application' category."), main_scene));
- pick_main_scene->popup_centered_minsize();
- return;
- }
-
- if (ResourceLoader::get_resource_type(main_scene) != "PackedScene") {
-
- current_option = -1;
- pick_main_scene->set_text(vformat(TTR("Selected scene '%s' is not a scene file, select a valid one?\nYou can change it later in \"Project Settings\" under the 'application' category."), main_scene));
- pick_main_scene->popup_centered_minsize();
+ if (!ensure_main_scene(false)) {
return;
}
}
@@ -4167,6 +4151,37 @@ bool EditorNode::has_scenes_in_session() {
return !scenes.empty();
}
+bool EditorNode::ensure_main_scene(bool p_from_native) {
+ pick_main_scene->set_meta("from_native", p_from_native); //whether from play button or native run
+ String main_scene = GLOBAL_DEF("application/run/main_scene", "");
+
+ if (main_scene == "") {
+
+ current_option = -1;
+ pick_main_scene->set_text(TTR("No main scene has ever been defined, select one?\nYou can change it later in \"Project Settings\" under the 'application' category."));
+ pick_main_scene->popup_centered_minsize();
+ return false;
+ }
+
+ if (!FileAccess::exists(main_scene)) {
+
+ current_option = -1;
+ pick_main_scene->set_text(vformat(TTR("Selected scene '%s' does not exist, select a valid one?\nYou can change it later in \"Project Settings\" under the 'application' category."), main_scene));
+ pick_main_scene->popup_centered_minsize();
+ return false;
+ }
+
+ if (ResourceLoader::get_resource_type(main_scene) != "PackedScene") {
+
+ current_option = -1;
+ pick_main_scene->set_text(vformat(TTR("Selected scene '%s' is not a scene file, select a valid one?\nYou can change it later in \"Project Settings\" under the 'application' category."), main_scene));
+ pick_main_scene->popup_centered_minsize();
+ return false;
+ }
+
+ return true;
+}
+
void EditorNode::_update_layouts_menu() {
editor_layouts->clear();
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 6e7b2b2443..ea988cb134 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -836,6 +836,8 @@ public:
static void add_init_callback(EditorNodeInitCallback p_callback) { _init_callbacks.push_back(p_callback); }
static void add_build_callback(EditorBuildCallback p_callback);
+
+ bool ensure_main_scene(bool p_from_native);
};
struct EditorProgress {
diff --git a/editor/editor_run_native.cpp b/editor/editor_run_native.cpp
index b73cda6008..585ea0ec69 100644
--- a/editor/editor_run_native.cpp
+++ b/editor/editor_run_native.cpp
@@ -101,6 +101,12 @@ void EditorRunNative::_notification(int p_what) {
void EditorRunNative::_run_native(int p_idx, int p_platform) {
+ if (!EditorNode::get_singleton()->ensure_main_scene(true)) {
+ resume_idx = p_idx;
+ resume_platform = p_platform;
+ return;
+ }
+
Ref<EditorExportPlatform> eep = EditorExport::get_singleton()->get_export_platform(p_platform);
ERR_FAIL_COND(eep.is_null());
@@ -144,6 +150,10 @@ void EditorRunNative::_run_native(int p_idx, int p_platform) {
eep->run(preset, p_idx, flags);
}
+void EditorRunNative::resume_run_native() {
+ _run_native(resume_idx, resume_platform);
+}
+
void EditorRunNative::_bind_methods() {
ClassDB::bind_method("_run_native", &EditorRunNative::_run_native);
@@ -198,4 +208,6 @@ EditorRunNative::EditorRunNative() {
deploy_debug_remote = false;
debug_collisions = false;
debug_navigation = false;
+ resume_idx = 0;
+ resume_platform = 0;
}
diff --git a/editor/editor_run_native.h b/editor/editor_run_native.h
index 10cca014cf..d62c982725 100644
--- a/editor/editor_run_native.h
+++ b/editor/editor_run_native.h
@@ -45,6 +45,9 @@ class EditorRunNative : public HBoxContainer {
bool debug_collisions;
bool debug_navigation;
+ int resume_idx;
+ int resume_platform;
+
void _run_native(int p_idx, int p_platform);
protected:
@@ -64,6 +67,8 @@ public:
void set_debug_navigation(bool p_debug);
bool get_debug_navigation() const;
+ void resume_run_native();
+
EditorRunNative();
};
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 2c0b3a350f..ef8456549a 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -318,7 +318,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("interface/editor/display_scale", 0);
hints["interface/editor/display_scale"] = PropertyInfo(Variant::INT, "interface/editor/display_scale", PROPERTY_HINT_ENUM, "Auto,75%,100%,125%,150%,175%,200%,Custom", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
_initial_set("interface/editor/custom_display_scale", 1.0f);
- hints["interface/editor/custom_display_scale"] = PropertyInfo(Variant::REAL, "interface/editor/custom_display_scale", PROPERTY_HINT_RANGE, "0.75,3,0.01", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+ hints["interface/editor/custom_display_scale"] = PropertyInfo(Variant::REAL, "interface/editor/custom_display_scale", PROPERTY_HINT_RANGE, "0.5,3,0.01", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
_initial_set("interface/editor/main_font_size", 14);
hints["interface/editor/main_font_size"] = PropertyInfo(Variant::INT, "interface/editor/main_font_size", PROPERTY_HINT_RANGE, "10,40,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
_initial_set("interface/editor/code_font_size", 14);