Compare commits

...

3 Commits

Author SHA1 Message Date
Serhii Snitsaruk 2973590533
Flip split offset setting if editor layout changed 2024-07-05 17:53:35 +02:00
Serhii Snitsaruk b74f664da6
Fix compilation issue with GDExtension 2024-07-05 17:24:32 +02:00
Serhii Snitsaruk 7baa395d3f
Rename to editor_layout 2024-07-05 17:02:29 +02:00
2 changed files with 26 additions and 9 deletions

View File

@ -1294,7 +1294,12 @@ void LimboAIEditor::_notification(int p_what) {
cf.instantiate();
String conf_path = PROJECT_CONFIG_FILE();
cf->load(conf_path);
cf->set_value("bt_editor", "bteditor_hsplit", hsc->get_split_offset());
int split_offset = hsc->get_split_offset();
if (editor_layout != (int)EDITOR_GET("limbo_ai/editor/layout")) {
// Editor layout settings changed - flip split offset.
split_offset *= -1;
}
cf->set_value("bt_editor", "bteditor_hsplit", split_offset);
cf->save(conf_path);
if (task_tree->get_bt().is_valid() &&
@ -1377,6 +1382,20 @@ LimboAIEditor::LimboAIEditor() {
plugin = nullptr;
idx_history = 0;
#ifdef LIMBOAI_MODULE
EDITOR_DEF("limbo_ai/editor/layout", 0);
EDITOR_SETTINGS()->add_property_hint(PropertyInfo(Variant::INT, "limbo_ai/editor/layout", PROPERTY_HINT_ENUM, "Classic:0,Widescreen Optimized:1"));
EDITOR_SETTINGS()->set_restart_if_changed("limbo_ai/editor/layout", true);
#elif LIMBOAI_GDEXTENSION
EDITOR_SETTINGS()->set_initial_value("limbo_ai/editor/layout", 0, false);
Dictionary pinfo;
pinfo["name"] = "limbo_ai/editor/layout";
pinfo["type"] = Variant::INT;
pinfo["hint"] = PROPERTY_HINT_ENUM;
pinfo["hint_string"] = "Classic:0,Widescreen Optimized:1";
EDITOR_SETTINGS()->add_property_info(pinfo);
#endif
LW_SHORTCUT("limbo_ai/rename_task", TTR("Rename"), LW_KEY(F2));
// Todo: Add override support for shortcuts.
// LW_SHORTCUT_OVERRIDE("limbo_ai/rename_task", "macos", Key::ENTER);
@ -1546,8 +1565,8 @@ LimboAIEditor::LimboAIEditor() {
task_palette = memnew(TaskPalette());
task_palette->hide();
hsc->add_child(task_palette);
TaskPalettePlacement palette_placement = (TaskPalettePlacement)(int)EDITOR_GET("limbo_ai/editor/task_palette_placement");
if (palette_placement == TaskPalettePlacement::LEFT_SIDE) {
editor_layout = (EditorLayout)(int)EDITOR_GET("limbo_ai/editor/layout");
if (editor_layout == EditorLayout::WIDESCREEN_OPTIMIZED) {
VBoxContainer *editor_vbox = memnew(VBoxContainer);
hsc->add_child(editor_vbox);
toolbar->reparent(editor_vbox);
@ -1665,9 +1684,6 @@ LimboAIEditor::LimboAIEditor() {
GLOBAL_DEF(PropertyInfo(Variant::STRING, "limbo_ai/behavior_tree/user_task_dir_2", PROPERTY_HINT_DIR), "");
GLOBAL_DEF(PropertyInfo(Variant::STRING, "limbo_ai/behavior_tree/user_task_dir_3", PROPERTY_HINT_DIR), "");
EDITOR_DEF("limbo_ai/editor/task_palette_placement", 0);
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "limbo_ai/editor/task_palette_placement", PROPERTY_HINT_ENUM, "Right Side:0,Left Side:1"));
String bt_default_dir = GLOBAL_GET("limbo_ai/behavior_tree/behavior_tree_default_dir");
save_dialog->set_current_dir(bt_default_dir);
load_dialog->set_current_dir(bt_default_dir);

View File

@ -111,9 +111,9 @@ private:
TAB_CLOSE_ALL,
};
enum TaskPalettePlacement {
RIGHT_SIDE,
LEFT_SIDE,
enum EditorLayout {
CLASSIC,
WIDESCREEN_OPTIMIZED,
};
struct ThemeCache {
@ -137,6 +137,7 @@ private:
} theme_cache;
EditorPlugin *plugin;
EditorLayout editor_layout;
Vector<Ref<BehaviorTree>> history;
int idx_history;
bool updating_tabs = false;