diff --git a/Editor/ComponentsWindow.cpp b/Editor/ComponentsWindow.cpp index aac03340f..729827cb0 100644 --- a/Editor/ComponentsWindow.cpp +++ b/Editor/ComponentsWindow.cpp @@ -590,16 +590,6 @@ void ComponentsWindow::Update(float dt) { animWnd.Update(); weatherWnd.Update(); - - if (nameWnd.nameInput.GetState() == wi::gui::WIDGETSTATE::DEACTIVATING) - { - editor->renaming_mode = false; - } - if (nameWnd.nameInput.GetState() == wi::gui::WIDGETSTATE::ACTIVE) - { - editor->renaming_mode = true; - - } } void ComponentsWindow::ResizeLayout() diff --git a/Editor/Editor.cpp b/Editor/Editor.cpp index dcde9f9bd..28f63ad39 100644 --- a/Editor/Editor.cpp +++ b/Editor/Editor.cpp @@ -127,7 +127,7 @@ HotkeyInfo hotkeyActions[size_t(EditorActions::COUNT)] = { {wi::input::BUTTON('A'), /*press=*/ true, /*control=*/ true, /*shift=*/ false}, //SELECT_ALL_ENTITIES, {wi::input::BUTTON::KEYBOARD_BUTTON_ESCAPE, /*press=*/ true, /*control=*/ false, /*shift=*/ false}, //DESELECT_ALL_ENTITIES, {wi::input::BUTTON('F'), /*press=*/ false, /*control=*/ false, /*shift=*/ false}, //FOCUS_ON_SELECTION, - {wi::input::BUTTON('R'), /*press=*/ true, /*control=*/ false, /*shift=*/ false}, //RENAME_SELECTED, + {wi::input::BUTTON::KEYBOARD_BUTTON_F2, /*press=*/ true, /*control=*/ false, /*shift=*/ false}, //RENAME_SELECTED, {wi::input::BUTTON('Z'), /*press=*/ true, /*control=*/ true, /*shift=*/ false}, //UNDO_ACTION, {wi::input::BUTTON('Y'), /*press=*/ true, /*control=*/ true, /*shift=*/ false}, //REDO_ACTION, {wi::input::BUTTON('C'), /*press=*/ true, /*control=*/ true, /*shift=*/ false}, //COPY_ACTION, @@ -137,7 +137,7 @@ HotkeyInfo hotkeyActions[size_t(EditorActions::COUNT)] = { {wi::input::BUTTON('1'), /*press=*/ true, /*control=*/ false, /*shift=*/ false}, //MOVE_TOGGLE_ACTION, {wi::input::BUTTON('2'), /*press=*/ true, /*control=*/ false, /*shift=*/ false}, //ROTATE_TOGGLE_ACTION, {wi::input::BUTTON('3'), /*press=*/ true, /*control=*/ false, /*shift=*/ false}, //SCALE_TOGGLE_ACTION, - {wi::input::BUTTON::KEYBOARD_BUTTON_F2, /*press=*/ true, /*control=*/ false, /*shift=*/ false}, //MAKE_NEW_SCREENSHOT, + {wi::input::BUTTON::KEYBOARD_BUTTON_F3, /*press=*/ true, /*control=*/ false, /*shift=*/ false}, //MAKE_NEW_SCREENSHOT, {wi::input::BUTTON('I'), /*press=*/ false, /*control=*/ false, /*shift=*/ false}, //INSPECTOR_MODE, {wi::input::BUTTON::MOUSE_BUTTON_LEFT, /*press=*/ true, /*control=*/ true, /*shift=*/ true}, //PLACE_INSTANCES, {wi::input::BUTTON('S'), /*press=*/ true, /*control=*/ true, /*shift=*/ true}, //SAVE_SCENE_AS, @@ -1615,8 +1615,22 @@ void EditorComponent::Update(float dt) drive_orbit_horizontal = lerp(drive_orbit_horizontal, 0.0f, dt); } + if (!GetGUI().IsTyping() && !translator.selected.empty() && CheckInput(EditorActions::RENAME_SELECTED)) + { + for (auto& x : translator.selected) + { + if (!scene.names.Contains(x.entity)) + { + scene.names.Create(x.entity); + } + } + componentsWnd.nameWnd.SetEntity(translator.selected.back().entity); + componentsWnd.nameWnd.SetCollapsed(false); + componentsWnd.nameWnd.nameInput.SetAsActive(true); + } + // Camera control: - if (!drive_mode && !wi::backlog::isActive() && !GetGUI().HasFocus() && !renaming_mode) + if (!drive_mode && !wi::backlog::isActive() && !GetGUI().HasFocus()) { deleting = CheckInput(EditorActions::DELETE_ACTION); currentMouse = wi::input::GetPointer(); @@ -1805,19 +1819,6 @@ void EditorComponent::Update(float dt) FocusCameraOnSelected(); } - if (!translator.selected.empty() && CheckInput(EditorActions::RENAME_SELECTED)) - { - for (auto& x : translator.selected) - { - const auto& picked = translator.selected.back(); - if (NameComponent* name_comp = scene.names.GetComponent(translator.selected.back().entity)) - { - componentsWnd.nameWnd.nameInput.SetAsActive(); - componentsWnd.nameWnd.SetCollapsed(false); - } - } - } - inspector_mode = CheckInput(EditorActions::INSPECTOR_MODE); // Begin picking: diff --git a/Editor/Editor.h b/Editor/Editor.h index 911dbb7cb..bdb1dfa94 100644 --- a/Editor/Editor.h +++ b/Editor/Editor.h @@ -40,8 +40,6 @@ public: float drive_orbit_horizontal = 0; float drive_steering_smoothed = 0; - bool renaming_mode = false; - wi::gui::Button navtestButton; bool navtest_enabled = false; wi::scene::PickResult navtest_start_pick; diff --git a/Editor/NameWindow.cpp b/Editor/NameWindow.cpp index efdecb086..c4c5eba92 100644 --- a/Editor/NameWindow.cpp +++ b/Editor/NameWindow.cpp @@ -46,7 +46,6 @@ void NameWindow::Create(EditorComponent* _editor) name->name = args.sValue; } editor->componentsWnd.RefreshEntityTree(); - editor->renaming_mode = false; }); AddWidget(&nameInput); diff --git a/Editor/config.ini b/Editor/config.ini index 21ffee131..0f1b94f2d 100644 --- a/Editor/config.ini +++ b/Editor/config.ini @@ -48,7 +48,7 @@ move_toggle_action = 1 #Switch to move action rotate_toggle_action = 2 #Switch to rotate action scale_toggle_action = 3 #Switch to scale action #Engine Actions -make_new_screenshot = F2 +make_new_screenshot = F3 inspector_mode = I place_instances = CTRL+SHIFT+MOUSELEFT #<- This key, Requirement CTRL+SHIFT #Scene @@ -139,3 +139,4 @@ options.width = 338.000000 options.height = 500.000000 components.width = 338.000000 components.height = 500.000000 +entities.height = 300.000000 diff --git a/WickedEngine/wiGUI.cpp b/WickedEngine/wiGUI.cpp index a0b0eab83..085a11a13 100644 --- a/WickedEngine/wiGUI.cpp +++ b/WickedEngine/wiGUI.cpp @@ -1709,7 +1709,6 @@ namespace wi::gui { // activate SetAsActive(); - typing_active = true; // do NOT set this inside SetAsActive() because that can be called from outside, but this bool cannot, and it could stuck } } @@ -1991,13 +1990,14 @@ namespace wi::gui Widget::SetTheme(theme, id); theme.font.Apply(font_description.params); } - void TextInputField::SetAsActive() + void TextInputField::SetAsActive(bool selectall) { Activate(); font_input.SetText(font.GetText()); caret_pos = (int)font_input.GetText().size(); - caret_begin = caret_pos; + caret_begin = selectall ? 0 : caret_pos; caret_delay = 0; + typing_active = true; } diff --git a/WickedEngine/wiGUI.h b/WickedEngine/wiGUI.h index 9a32944a3..100843001 100644 --- a/WickedEngine/wiGUI.h +++ b/WickedEngine/wiGUI.h @@ -515,7 +515,10 @@ namespace wi::gui static void AddInput(const wchar_t inputChar); static void AddInput(const char inputChar); static void DeleteFromInput(int direction = -1); - void SetAsActive(); + + // Sets this text input as currently active in typing state + // selectall params: selects the current input, so typing will immediately overwrite it + void SetAsActive(bool selectall = false); void Update(const wi::Canvas& canvas, float dt) override; void Render(const wi::Canvas& canvas, wi::graphics::CommandList cmd) const override;