summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorryburnj <jordanryburn@gmail.com>2022-09-09 10:29:59 +1000
committerryburnj <jordanryburn@gmail.com>2022-09-18 11:17:22 +1000
commit9d6af9323aa856bd1e23453838fd2f6c0c0c92ef (patch)
tree3d5fddb3bc980cfc11eaa9e5176dd2950570ede7
parent57bdddce02370af3d13e6edc583afdc17264147d (diff)
Fix inconsistent scene file name casing by moving existing Name_Casing code to separate function in editor_node, and adding a call from both editor_node and scene_tree_dock.
-rw-r--r--core/config/project_settings.h3
-rw-r--r--editor/editor_node.cpp26
-rw-r--r--editor/editor_node.h14
-rw-r--r--editor/scene_tree_dock.cpp1
4 files changed, 25 insertions, 19 deletions
diff --git a/core/config/project_settings.h b/core/config/project_settings.h
index a9af63ee39..960dfe0395 100644
--- a/core/config/project_settings.h
+++ b/core/config/project_settings.h
@@ -45,9 +45,10 @@ public:
static const String PROJECT_DATA_DIR_NAME_SUFFIX;
enum {
- //properties that are not for built in values begin from this value, so builtin ones are displayed first
+ // Properties that are not for built in values begin from this value, so builtin ones are displayed first.
NO_BUILTIN_ORDER_BASE = 1 << 16
};
+
#ifdef TOOLS_ENABLED
const static PackedStringArray get_required_features();
const static PackedStringArray get_unsupported_features(const PackedStringArray &p_project_features);
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 8eaddcb7e1..26dd3b616c 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -2763,18 +2763,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
}
} else if (extensions.size()) {
String root_name = scene->get_name();
- // Very similar to node naming logic.
- switch (ProjectSettings::get_singleton()->get("editor/scene/scene_naming").operator int()) {
- case SCENE_NAME_CASING_AUTO:
- // Use casing of the root node.
- break;
- case SCENE_NAME_CASING_PASCAL_CASE: {
- root_name = root_name.to_pascal_case();
- } break;
- case SCENE_NAME_CASING_SNAKE_CASE:
- root_name = root_name.replace("-", "_").to_snake_case();
- break;
- }
+ root_name = EditorNode::adjust_scene_name_casing(root_name);
file->set_current_path(root_name + "." + extensions.front()->get().to_lower());
}
file->popup_file_dialog();
@@ -3090,6 +3079,19 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
}
}
+String EditorNode::adjust_scene_name_casing(const String &root_name) {
+ switch (ProjectSettings::get_singleton()->get("editor/scene/scene_naming").operator int()) {
+ case SCENE_NAME_CASING_AUTO:
+ // Use casing of the root node.
+ break;
+ case SCENE_NAME_CASING_PASCAL_CASE:
+ return root_name.to_pascal_case();
+ case SCENE_NAME_CASING_SNAKE_CASE:
+ return root_name.replace("-", "_").to_snake_case();
+ }
+ return root_name;
+}
+
void EditorNode::_request_screenshot() {
_screenshot();
}
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 200d68908c..a7a8120f49 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -125,6 +125,12 @@ public:
EDITOR_ASSETLIB
};
+ enum SceneNameCasing {
+ SCENE_NAME_CASING_AUTO,
+ SCENE_NAME_CASING_PASCAL_CASE,
+ SCENE_NAME_CASING_SNAKE_CASE
+ };
+
struct ExecuteThreadArgs {
String path;
List<String> args;
@@ -233,12 +239,6 @@ private:
MAX_BUILD_CALLBACKS = 128
};
- enum ScriptNameCasing {
- SCENE_NAME_CASING_AUTO,
- SCENE_NAME_CASING_PASCAL_CASE,
- SCENE_NAME_CASING_SNAKE_CASE
- };
-
struct BottomPanelItem {
String name;
Control *control = nullptr;
@@ -720,6 +720,8 @@ public:
static HBoxContainer *get_menu_hb() { return singleton->menu_hb; }
static VSplitContainer *get_top_split() { return singleton->top_split; }
+ static String adjust_scene_name_casing(const String &root_name);
+
static bool has_unsaved_changes() { return singleton->unsaved_cache; }
static void disambiguate_filenames(const Vector<String> p_full_paths, Vector<String> &r_filenames);
static void add_io_error(const String &p_error);
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index a437245c57..7714df9c4e 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -916,6 +916,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
String existing;
if (extensions.size()) {
String root_name(tocopy->get_name());
+ root_name = EditorNode::adjust_scene_name_casing(root_name);
existing = root_name + "." + extensions.front()->get().to_lower();
}
new_scene_from_dialog->set_current_path(existing);