diff --git a/assets/alice.csv b/assets/alice.csv index 68440469a..7ded7a978 100644 --- a/assets/alice.csv +++ b/assets/alice.csv @@ -19,6 +19,7 @@ zoom_mode_centered;Centered;;;Centrado;;;;;;;;;x zoom_speed_label;Zoom Acceleration river_label;Rivers;;;Rios;;;;;;;;;x mute_on_focus_lost_label;Mute On Focus Lost +wasd_for_map_movement_label;WASD for map movement vassal_color_label;Vassal coloring vassal_color_inherit;Inherit vassal_color_same;Same diff --git a/assets/alice.gui b/assets/alice.gui index 16329edb2..001dd35cd 100644 --- a/assets/alice.gui +++ b/assets/alice.gui @@ -527,6 +527,22 @@ guiTypes = { position = { 51 300 } quadTextureSprite = "GFX_checkbox_default" } + # WASD for map movement + instantTextBoxType = { + name = "wasd_for_map_movement_label" + position = { 78 320 } + text = "wasd_for_map_movement_label" + font = "Arial16" + borderSize = { 0 0 } + maxsize = { 236 18 } + orientation = "UPPER_LEFT" + format = left + } + guiButtonType = { + name = "wasd_for_map_movement_checkbox" + position = { 51 320 } + quadTextureSprite = "GFX_checkbox_default" + } # Zoom style instantTextBoxType = { name = "zoom_mode_label" diff --git a/src/gamestate/system_state.cpp b/src/gamestate/system_state.cpp index f70d8453f..e4b48a07f 100644 --- a/src/gamestate/system_state.cpp +++ b/src/gamestate/system_state.cpp @@ -457,17 +457,14 @@ void state::on_key_down(virtual_key keycode, key_modifiers mod) { keycode = sys::virtual_key::SUBTRACT; else if(keycode == sys::virtual_key::PLUS) keycode = sys::virtual_key::ADD; - if(cheat_data.wasd_move_cam) { + if(user_settings.wasd_for_map_movement) { if(keycode == sys::virtual_key::W) keycode = sys::virtual_key::UP; - else - if(keycode == sys::virtual_key::A) + else if(keycode == sys::virtual_key::A) keycode = sys::virtual_key::LEFT; - else - if(keycode == sys::virtual_key::S) + else if(keycode == sys::virtual_key::S) keycode = sys::virtual_key::DOWN; - else - if(keycode == sys::virtual_key::D) + else if(keycode == sys::virtual_key::D) keycode = sys::virtual_key::RIGHT; } if(ui_state.root->impl_on_key_down(*this, keycode, mod) != ui::message_result::consumed) { @@ -558,17 +555,14 @@ void state::on_key_up(virtual_key keycode, key_modifiers mod) { if(keycode == virtual_key::CONTROL) ui_state.ctrl_held_down = false; - if(cheat_data.wasd_move_cam) { + if(user_settings.wasd_for_map_movement) { if(keycode == sys::virtual_key::W) keycode = sys::virtual_key::UP; - else - if(keycode == sys::virtual_key::A) + else if(keycode == sys::virtual_key::A) keycode = sys::virtual_key::LEFT; - else - if(keycode == sys::virtual_key::S) + else if(keycode == sys::virtual_key::S) keycode = sys::virtual_key::DOWN; - else - if(keycode == sys::virtual_key::D) + else if(keycode == sys::virtual_key::D) keycode = sys::virtual_key::RIGHT; } @@ -2236,6 +2230,7 @@ void state::save_user_settings() const { US_SAVE(zoom_speed); US_SAVE(mute_on_focus_lost); US_SAVE(diplomatic_message_popup); + US_SAVE(wasd_for_map_movement); #undef US_SAVE simple_fs::write_file(settings_location, NATIVE("user_settings.dat"), &buffer[0], uint32_t(ptr - buffer)); @@ -2299,6 +2294,7 @@ void state::load_user_settings() { US_LOAD(zoom_speed); US_LOAD(mute_on_focus_lost); US_LOAD(diplomatic_message_popup); + US_LOAD(wasd_for_map_movement); #undef US_LOAD } while(false); diff --git a/src/gamestate/system_state.hpp b/src/gamestate/system_state.hpp index f3d15ed5c..d546b6506 100644 --- a/src/gamestate/system_state.hpp +++ b/src/gamestate/system_state.hpp @@ -378,6 +378,7 @@ struct user_settings_s { float zoom_speed = 20.f; bool mute_on_focus_lost = true; bool diplomatic_message_popup = false; + bool wasd_for_map_movement = false; }; struct global_scenario_data_s { // this struct holds miscellaneous global properties of the scenario @@ -388,7 +389,6 @@ struct cheat_data_s { bool always_allow_reforms = false; bool always_accept_deals = false; bool show_province_id_tooltip = false; - bool wasd_move_cam = false; bool instant_army = false; bool instant_industry = false; std::vector instant_research_nations; diff --git a/src/gui/gui_console.cpp b/src/gui/gui_console.cpp index dd80bd452..df28dc94d 100644 --- a/src/gui/gui_console.cpp +++ b/src/gui/gui_console.cpp @@ -1569,8 +1569,9 @@ void ui::console_edit::edit_box_enter(sys::state& state, std::string_view s) noe } case command_info::type::wasd: { - state.cheat_data.wasd_move_cam = not state.cheat_data.wasd_move_cam; - log_to_console(state, parent, state.cheat_data.wasd_move_cam ? "\x02" : "\x01"); + state.user_settings.wasd_for_map_movement = not state.user_settings.wasd_for_map_movement; + log_to_console(state, parent, state.user_settings.wasd_for_map_movement ? "\x02" : "\x01"); + state.save_user_settings(); break; } case command_info::type::next_song: diff --git a/src/gui/gui_main_menu.cpp b/src/gui/gui_main_menu.cpp index b0e337251..c0f046561 100644 --- a/src/gui/gui_main_menu.cpp +++ b/src/gui/gui_main_menu.cpp @@ -162,6 +162,13 @@ void spoilers_checkbox::button_action(sys::state& state) noexcept { bool spoilers_checkbox::is_active(sys::state& state) noexcept { return state.user_settings.spoilers; } +void wasd_for_map_movement_checkbox::button_action(sys::state& state) noexcept { + state.user_settings.wasd_for_map_movement = !state.user_settings.wasd_for_map_movement; + send(state, parent, notify_setting_update{}); +} +bool wasd_for_map_movement_checkbox::is_active(sys::state& state) noexcept { + return state.user_settings.wasd_for_map_movement; +} void dm_popup_checkbox::button_action(sys::state& state) noexcept { state.user_settings.diplomatic_message_popup = !state.user_settings.diplomatic_message_popup; send(state, parent, notify_setting_update{}); diff --git a/src/gui/gui_main_menu.hpp b/src/gui/gui_main_menu.hpp index b1619e198..2cb52f599 100644 --- a/src/gui/gui_main_menu.hpp +++ b/src/gui/gui_main_menu.hpp @@ -125,6 +125,11 @@ class spoilers_checkbox : public checkbox_button { void button_action(sys::state& state) noexcept override; bool is_active(sys::state& state) noexcept override; }; +class wasd_for_map_movement_checkbox : public checkbox_button { +public: + void button_action(sys::state& state) noexcept override; + bool is_active(sys::state& state) noexcept override; +}; class dm_popup_checkbox : public checkbox_button { public: void button_action(sys::state& state) noexcept override; @@ -278,6 +283,8 @@ class controls_menu_window : public window_element_base { return make_element_by_type(state, id); } else if(name == "mouse_edge_scrolling_checkbox") { return make_element_by_type(state, id); + } else if(name == "wasd_for_map_movement_checkbox") { + return make_element_by_type(state, id); } else { return nullptr; }