From 26e9e1b3dd8a05017d082dbf6857a1f60d9accaa Mon Sep 17 00:00:00 2001 From: mlthelama <47679057+mlthelama@users.noreply.github.com> Date: Thu, 8 Feb 2024 19:48:28 +0100 Subject: [PATCH] `quick fix` * maybe --- cmake/sourcelist.cmake | 2 + src/control/binding.cpp | 18 +++---- src/equip/equip_slot.cpp | 7 ++- src/equip/item.cpp | 14 ++--- src/equip/magic.cpp | 20 ++----- src/event/equip_event.cpp | 6 +-- src/event/key_manager.cpp | 2 +- src/handle/key_position_handle.cpp | 2 +- src/handle/page_handle.cpp | 18 +++---- src/hook/menu_hook.cpp | 6 +-- src/main.cpp | 10 ++-- src/papyrus/papyrus.cpp | 78 +++++++++++++++------------- src/processing/game_menu_setting.cpp | 9 ++-- src/processing/set_setting_data.cpp | 51 +++++++++--------- src/processing/setting_execute.cpp | 2 +- src/setting/custom_setting.cpp | 14 ++--- src/setting/custom_setting.h | 2 +- src/setting/display_tweaks.cpp | 31 +++++++++++ src/setting/display_tweaks.h | 11 ++++ src/setting/file_setting.cpp | 2 +- src/setting/file_setting.h | 2 +- src/setting/mcm_setting.cpp | 2 +- src/setting/mcm_setting.h | 2 +- src/ui/ui_renderer.cpp | 60 ++++++++------------- src/util/constant.h | 2 + src/util/helper.cpp | 40 +++++++------- src/util/player/player.cpp | 2 +- 27 files changed, 226 insertions(+), 189 deletions(-) create mode 100644 src/setting/display_tweaks.cpp create mode 100644 src/setting/display_tweaks.h diff --git a/cmake/sourcelist.cmake b/cmake/sourcelist.cmake index 7502eaa..8c7e1ec 100644 --- a/cmake/sourcelist.cmake +++ b/cmake/sourcelist.cmake @@ -50,6 +50,8 @@ set(sources ${sources} src/processing/setting_execute.h src/setting/custom_setting.cpp src/setting/custom_setting.h + src/setting/display_tweaks.cpp + src/setting/display_tweaks.h src/setting/file_setting.cpp src/setting/file_setting.h src/setting/mcm_setting.cpp diff --git a/src/control/binding.cpp b/src/control/binding.cpp index a5e1fec..ac1dff6 100644 --- a/src/control/binding.cpp +++ b/src/control/binding.cpp @@ -23,15 +23,15 @@ namespace control { uint32_t binding::get_remove_key() const { return key_remove_key_; } void binding::set_all_keys() { - key_top_action_ = config::mcm_setting::get_top_action_key(); - key_right_action_ = config::mcm_setting::get_right_action_key(); - key_bottom_action_ = config::mcm_setting::get_bottom_action_key(); - key_left_action_ = config::mcm_setting::get_left_action_key(); - key_bottom_execute_or_toggle_ = config::mcm_setting::get_toggle_key(); - key_hide_show_ = config::mcm_setting::get_show_hide_key(); - key_edit_key_ = config::mcm_setting::get_edit_key(); - key_edit_left_or_overwrite_ = config::mcm_setting::get_left_or_overwrite_edit_key(); - key_remove_key_ = config::mcm_setting::get_remove_key(); + key_top_action_ = setting::mcm_setting::get_top_action_key(); + key_right_action_ = setting::mcm_setting::get_right_action_key(); + key_bottom_action_ = setting::mcm_setting::get_bottom_action_key(); + key_left_action_ = setting::mcm_setting::get_left_action_key(); + key_bottom_execute_or_toggle_ = setting::mcm_setting::get_toggle_key(); + key_hide_show_ = setting::mcm_setting::get_show_hide_key(); + key_edit_key_ = setting::mcm_setting::get_edit_key(); + key_edit_left_or_overwrite_ = setting::mcm_setting::get_left_or_overwrite_edit_key(); + key_remove_key_ = setting::mcm_setting::get_remove_key(); } void binding::set_top_execute(uint32_t a_key) { key_top_execute_ = a_key; } diff --git a/src/equip/equip_slot.cpp b/src/equip/equip_slot.cpp index 691c128..2c8c9b6 100644 --- a/src/equip/equip_slot.cpp +++ b/src/equip/equip_slot.cpp @@ -2,6 +2,7 @@ #include "util/offset.h" #include "util/player/player.h" #include "util/string_util.h" +#include namespace equip { RE::BGSEquipSlot* equip_slot::get_right_hand_slot() { @@ -88,7 +89,11 @@ namespace equip { void equip_slot::un_equip_object_ft_dummy_dagger(RE::BGSEquipSlot*& a_slot, RE::PlayerCharacter*& a_player, RE::ActorEquipManager*& a_actor_equip_manager) { - auto* dummy = RE::TESForm::LookupByID(0x00020163)->As(); + //auto* dummy = RE::TESForm::LookupByID(0x00020163)->As(); + auto* dummy = + RE::TESForm::LookupByID(RE::TESDataHandler::GetSingleton()->LookupFormID(0x00020163, util::skyrim_esm)) + ->As(); + //sound false, queue false, force true a_actor_equip_manager->EquipObject(a_player, dummy, nullptr, 1, a_slot, false, true, false); a_actor_equip_manager->UnequipObject(a_player, dummy, nullptr, 1, a_slot, false, true, false); diff --git a/src/equip/item.cpp b/src/equip/item.cpp index d4f469a..5525209 100644 --- a/src/equip/item.cpp +++ b/src/equip/item.cpp @@ -87,6 +87,8 @@ namespace equip { extra_handler->overwrite_extra_data_for_form(a_form, extra_list); } } else { + //if the data is not set, something else might be, but we might not care about that anymore + extra_handler->reset_data(); if (!extra_vector.empty()) { extra = extra_vector.back(); extra_vector.pop_back(); //remove last item, because we already use that @@ -181,7 +183,7 @@ namespace equip { } } - if (config::mcm_setting::get_prevent_consumption_of_last_dynamic_potion() && obj && obj->IsDynamicForm() && + if (setting::mcm_setting::get_prevent_consumption_of_last_dynamic_potion() && obj && obj->IsDynamicForm() && left == 1) { logger::warn( "Somehow the game crashes on potions with dynamic id if the count is 0 (happens with or without the mod). So I am not consuming it. Form {}, Name {}"sv, @@ -277,8 +279,8 @@ namespace equip { fmt::format(FMT_STRING("{:.2f}"), missing)); //min heal, max heal - auto min_perfect = config::mcm_setting::get_potion_min_perfect(); - auto max_perfect = config::mcm_setting::get_potion_max_perfect(); + auto min_perfect = setting::mcm_setting::get_potion_min_perfect(); + auto max_perfect = setting::mcm_setting::get_potion_max_perfect(); logger::trace("min perfect {}, max perfect {}, missing {}"sv, fmt::format(FMT_STRING("{:.2f}"), missing * min_perfect), fmt::format(FMT_STRING("{:.2f}"), missing * max_perfect), @@ -301,7 +303,7 @@ namespace equip { if (actor_value == a_actor_value) { //set obj here, because if we do not have a perfect hit, we still need to consume something - if (config::mcm_setting::get_prevent_consumption_of_last_dynamic_potion() && + if (setting::mcm_setting::get_prevent_consumption_of_last_dynamic_potion() && alchemy_item->IsDynamicForm() && num_items == 1) { logger::warn( "Somehow the game crashes on potions with dynamic id if the count is 0 (happens with or without the mod). So I am not consuming it. Form {}, Name {}"sv, @@ -346,8 +348,8 @@ namespace equip { * vokrii should be fine as well * other add av multiply implementations need to be handled by getting the data from the game * the MCM setting will be left for overwrite handling */ - if (config::mcm_setting::get_overwrite_poison_dose()) { - potion_doses = config::mcm_setting::get_apply_poison_dose(); + if (setting::mcm_setting::get_overwrite_poison_dose()) { + potion_doses = setting::mcm_setting::get_apply_poison_dose(); } else { if (a_player->HasPerkEntries(RE::BGSEntryPoint::ENTRY_POINTS::kModPoisonDoseCount)) { auto perk_visit = util::perk_visitor(a_player, static_cast(potion_doses)); diff --git a/src/equip/magic.cpp b/src/equip/magic.cpp index 8c9b523..02c7914 100644 --- a/src/equip/magic.cpp +++ b/src/equip/magic.cpp @@ -34,7 +34,7 @@ namespace equip { auto casting_type = spell->GetCastingType(); logger::trace("spell {} is type {}"sv, spell->GetName(), static_cast(casting_type)); if (a_action == action_type::instant && casting_type != RE::MagicSystem::CastingType::kConcentration) { - if (config::mcm_setting::get_elden_demon_souls()) { + if (setting::mcm_setting::get_elden_demon_souls()) { auto selected_power = a_player->GetActorRuntimeData().selectedPower; if (selected_power) { logger::warn( @@ -53,8 +53,8 @@ namespace equip { auto current_magicka = actor->AsActorValueOwner()->GetActorValue(RE::ActorValue::kMagicka); auto dual_cast = false; - if (!spell->IsTwoHanded() && config::mcm_setting::get_try_dual_cast_top_spell() && - config::mcm_setting::get_elden_demon_souls()) { + if (!spell->IsTwoHanded() && setting::mcm_setting::get_try_dual_cast_top_spell() && + setting::mcm_setting::get_elden_demon_souls()) { auto* game_setting = RE::GameSettingCollection::GetSingleton(); auto dual_cast_cost_multiplier = game_setting->GetSetting("fMagicDualCastingCostMult")->GetFloat(); logger::trace("dual cast, multiplier {}"sv, @@ -88,18 +88,6 @@ namespace equip { //might need to set some things //TODO make an animation to play here //a_player->NotifyAnimationGraph("IdleMagic_01"); //works - /*if constexpr (!std::is_same_v) { - for (const auto& form : RE::TESDataHandler::GetSingleton()->GetFormArray()) { - //AddForm(EditorID::GetEditorID(form), form); - - }*/ - /*for (const auto& form : RE::TESDataHandler::GetSingleton()->GetFormArray()){ - logger::debug("formid {}, form name {}"sv, util::string_util::int_to_hex(form->formID), form->GetName()); - }*/ - if (const auto* current = a_player->GetActorRuntimeData().currentProcess; current) { - //if (current) - //auto* idle = RE::TESForm::LookupByEditorID("RightCastSelf"); - } auto is_self_target = spell->GetDelivery() == RE::MagicSystem::Delivery::kSelf; auto* target = is_self_target ? actor : actor->GetActorRuntimeData().currentCombatTarget.get().get(); @@ -213,7 +201,7 @@ namespace equip { } if (a_action == handle::slot_setting::action_type::instant) { - if (config::mcm_setting::get_elden_demon_souls()) { + if (setting::mcm_setting::get_elden_demon_souls()) { logger::warn("form {}, will only not instant cast power in elden mode. return."sv, spell->GetName()); return; } diff --git a/src/event/equip_event.cpp b/src/event/equip_event.cpp index 30ab06b..9a58b10 100644 --- a/src/event/equip_event.cpp +++ b/src/event/equip_event.cpp @@ -24,12 +24,12 @@ namespace event { return event_result::kContinue; } - if (config::mcm_setting::get_draw_current_items_text() && + if (setting::mcm_setting::get_draw_current_items_text() && (form->IsWeapon() || form->Is(RE::FormType::Spell) || form->IsAmmo() || form->Is(RE::FormType::Light))) { handle::name_handle::get_singleton()->init_names(util::player::get_hand_assignment()); } - if (config::mcm_setting::get_draw_current_shout_text() && form->Is(RE::FormType::Shout) || + if (setting::mcm_setting::get_draw_current_shout_text() && form->Is(RE::FormType::Shout) || form->Is(RE::FormType::Spell)) { // call function there and check selected power, spell trigger and spells as well but that is ok for now handle::name_handle::get_singleton()->init_voice_name( @@ -37,7 +37,7 @@ namespace event { } //add check if we need to block left - if (!RE::UI::GetSingleton()->GameIsPaused() && config::mcm_setting::get_elden_demon_souls() && + if (!RE::UI::GetSingleton()->GameIsPaused() && setting::mcm_setting::get_elden_demon_souls() && util::helper::is_two_handed(form)) { processing::set_setting_data::check_if_location_needs_block(form, a_event->equipped); } diff --git a/src/event/key_manager.cpp b/src/event/key_manager.cpp index 01ca7cb..6dc7fe6 100644 --- a/src/event/key_manager.cpp +++ b/src/event/key_manager.cpp @@ -11,7 +11,7 @@ namespace event { using event_result = RE::BSEventNotifyControl; using position_type = handle::position_setting::position_type; using common = control::common; - using mcm = config::mcm_setting; + using mcm = setting::mcm_setting; using setting_execute = processing::setting_execute; key_manager* key_manager::get_singleton() { diff --git a/src/handle/key_position_handle.cpp b/src/handle/key_position_handle.cpp index 26fccb0..d09bee0 100644 --- a/src/handle/key_position_handle.cpp +++ b/src/handle/key_position_handle.cpp @@ -2,7 +2,7 @@ #include "setting/mcm_setting.h" namespace handle { - using mcm = config::mcm_setting; + using mcm = setting::mcm_setting; using position_type = position_setting::position_type; key_position_handle* key_position_handle::get_singleton() { diff --git a/src/handle/page_handle.cpp b/src/handle/page_handle.cpp index e9111f9..e70ba65 100644 --- a/src/handle/page_handle.cpp +++ b/src/handle/page_handle.cpp @@ -10,7 +10,7 @@ #include "util/string_util.h" namespace handle { - using mcm = config::mcm_setting; + using mcm = setting::mcm_setting; using position_type = position_setting::position_type; page_handle* page_handle::get_singleton() { @@ -130,8 +130,8 @@ namespace handle { draw->offset_key_y = offset_y; //same for now - draw->offset_text_x = config::mcm_setting::get_slot_count_text_offset(); - draw->offset_text_y = config::mcm_setting::get_slot_count_text_offset(); + draw->offset_text_x = setting::mcm_setting::get_slot_count_text_offset(); + draw->offset_text_y = setting::mcm_setting::get_slot_count_text_offset(); if ((elden || mcm::get_draw_item_name_text()) && (a_position == position_type::bottom || a_position == position_type::top)) { @@ -163,14 +163,14 @@ namespace handle { if (first_slot->item_count == 0 && ((first_slot->type == slot_type::consumable) || (first_slot->form && first_slot->form->IsInventoryObject() && first_slot->form->formID != util::unarmed))) { - draw->icon_transparency = config::mcm_setting::get_icon_transparency_blocked(); + draw->icon_transparency = setting::mcm_setting::get_icon_transparency_blocked(); } page->draw_setting = draw; page->key = a_key_pos->get_key_for_position(a_position); - page->item_name_font_size = config::mcm_setting::get_item_name_font_size(); - page->count_font_size = config::mcm_setting::get_slot_count_text_font_size(); + page->item_name_font_size = setting::mcm_setting::get_item_name_font_size(); + page->count_font_size = setting::mcm_setting::get_slot_count_text_font_size(); if (elden) { if (first_slot->type != slot_type::empty || slots->size() == 2 && slots->at(1)->type != slot_type::empty) { @@ -240,7 +240,7 @@ namespace handle { } std::map page_handle::get_active_page() const { - if (config::mcm_setting::get_elden_demon_souls()) { + if (setting::mcm_setting::get_elden_demon_souls()) { std::map a_active; for (auto i = 0; i < static_cast(position_type::total); ++i) { const auto pos = static_cast(i); @@ -260,7 +260,7 @@ namespace handle { } uint32_t page_handle::get_active_page_id() const { - if (config::mcm_setting::get_elden_demon_souls()) { + if (setting::mcm_setting::get_elden_demon_souls()) { return 0; } if (const page_handle_data* data = this->data_; data) { @@ -273,7 +273,7 @@ namespace handle { if (const page_handle_data* data = this->data_; data) { //let's make it easy for now //we start at 0, so it is max count -1 - if (data->active_page < config::mcm_setting::get_max_page_count() - 1) { + if (data->active_page < setting::mcm_setting::get_max_page_count() - 1) { return data->active_page + 1; } return 0; diff --git a/src/hook/menu_hook.cpp b/src/hook/menu_hook.cpp index c483d74..eef73a8 100644 --- a/src/hook/menu_hook.cpp +++ b/src/hook/menu_hook.cpp @@ -19,7 +19,7 @@ namespace hook { RE::BSTEventSource* a_source) { auto* ui = RE::UI::GetSingleton(); auto* binding = control::binding::get_singleton(); - auto edit_key = config::mcm_setting::get_key_press_to_enter_edit(); + auto edit_key = setting::mcm_setting::get_key_press_to_enter_edit(); auto* user_event = RE::UserEvents::GetSingleton(); auto* control_map = RE::ControlMap::GetSingleton(); @@ -60,7 +60,7 @@ namespace hook { if (button->IsDown()) { if (common::is_key_valid_and_matches(key_, binding->get_bottom_execute_or_toggle_action()) || - (config::mcm_setting::get_key_press_to_enter_edit() && + (setting::mcm_setting::get_key_press_to_enter_edit() && common::is_key_valid_and_matches(key_, binding->get_edit_key()))) { binding->set_is_edit_down(true); } @@ -101,7 +101,7 @@ namespace hook { processing::set_setting_data::default_remove(tes_form_menu); } else { logger::trace("doing add or place for form."sv); - if (config::mcm_setting::get_elden_demon_souls()) { + if (setting::mcm_setting::get_elden_demon_souls()) { processing::game_menu_setting::elden_souls_config(tes_form_menu, key_position, binding->get_is_edit_left_down()); diff --git a/src/main.cpp b/src/main.cpp index 36d7ff5..b0c6248 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,14 +34,14 @@ void init_logger() { logger::info("{} v{}"sv, Version::PROJECT, Version::NAME); try { - config::file_setting::load_setting(); - config::mcm_setting::read_setting(); - config::custom_setting::read_setting(); + setting::file_setting::load_setting(); + setting::mcm_setting::read_setting(); + setting::custom_setting::read_setting(); } catch (const std::exception& e) { logger::warn("failed to load setting {}"sv, e.what()); } - if (config::file_setting::get_is_debug()) { + if (setting::file_setting::get_is_debug()) { spdlog::set_level(spdlog::level::trace); spdlog::flush_on(spdlog::level::trace); } @@ -72,7 +72,7 @@ void message_callback(SKSE::MessagingInterface::Message* msg) { processing::set_setting_data::read_and_set_data(); processing::set_setting_data::get_actives_and_equip(); processing::set_setting_data::check_config_data(); - ui::ui_renderer::set_show_ui(config::file_setting::get_show_ui()); + ui::ui_renderer::set_show_ui(setting::file_setting::get_show_ui()); logger::info("Done running after {}"sv, static_cast(msg->type)); break; default: diff --git a/src/papyrus/papyrus.cpp b/src/papyrus/papyrus.cpp index 7705c02..76a7147 100644 --- a/src/papyrus/papyrus.cpp +++ b/src/papyrus/papyrus.cpp @@ -12,9 +12,9 @@ namespace papyrus { static const char* mcm_name = "LamasTinyHUD_MCM"; void hud_mcm::on_config_close(RE::TESQuest*) { - logger::info("on config close"sv); - config::mcm_setting::read_setting(); - if (config::mcm_setting::get_elden_demon_souls()) { + logger::info("on setting close"sv); + setting::mcm_setting::read_setting(); + if (setting::mcm_setting::get_elden_demon_souls()) { util::helper::rewrite_settings(); } processing::set_setting_data::read_and_set_data(); @@ -23,7 +23,7 @@ namespace papyrus { //In case the setting was changed ui::ui_renderer::set_fade(true, 1.f); - logger::debug("on config close done. return."sv); + logger::debug("on setting close done. return."sv); } RE::BSFixedString hud_mcm::get_resolution_width(RE::TESQuest*) { @@ -48,7 +48,7 @@ namespace papyrus { RE::BSFixedString hud_mcm::get_page(RE::TESQuest*, const uint32_t a_index, uint32_t a_position) { logger::trace("page was requested for index {}"sv, a_index); if (const auto section = get_section_by_index(a_index, a_position); !section.empty()) { - return std::to_string(config::custom_setting::get_page_by_section(section)); + return std::to_string(setting::custom_setting::get_page_by_section(section)); } return ""; } @@ -56,7 +56,7 @@ namespace papyrus { RE::BSFixedString hud_mcm::get_position(RE::TESQuest*, const uint32_t a_index, uint32_t a_position) { logger::trace("position was requested for index {}"sv, a_index); if (const auto section = get_section_by_index(a_index, a_position); !section.empty()) { - return std::to_string(config::custom_setting::get_position_by_section(section)); + return std::to_string(setting::custom_setting::get_position_by_section(section)); } return ""; } @@ -66,9 +66,9 @@ namespace papyrus { uint32_t type = 0; if (const auto section = get_section_by_index(a_index, a_position); !section.empty()) { if (a_left) { - type = config::custom_setting::get_type_left_by_section(section); + type = setting::custom_setting::get_type_left_by_section(section); } else { - type = config::custom_setting::get_type_by_section(section); + type = setting::custom_setting::get_type_by_section(section); } } logger::trace("return type {} index {}"sv, type, a_index); @@ -80,9 +80,9 @@ namespace papyrus { std::string form_string; if (const auto section = get_section_by_index(a_index, a_position); !section.empty()) { if (a_left) { - form_string = config::custom_setting::get_item_form_left_by_section(section); + form_string = setting::custom_setting::get_item_form_left_by_section(section); } else { - form_string = config::custom_setting::get_item_form_by_section(section); + form_string = setting::custom_setting::get_item_form_by_section(section); } } return form_string; @@ -92,9 +92,9 @@ namespace papyrus { uint32_t action = 0; if (const auto section = get_section_by_index(a_index, a_position); !section.empty()) { if (a_left) { - action = config::custom_setting::get_slot_action_left_by_section(section); + action = setting::custom_setting::get_slot_action_left_by_section(section); } else { - action = config::custom_setting::get_slot_action_by_section(section); + action = setting::custom_setting::get_slot_action_by_section(section); } } logger::trace("return action {} index {}"sv, action, a_index); @@ -104,7 +104,7 @@ namespace papyrus { uint32_t hud_mcm::get_hand_selection(RE::TESQuest*, const uint32_t a_index, uint32_t a_position) { uint32_t hand = 0; if (const auto section = get_section_by_index(a_index, a_position); !section.empty()) { - hand = config::custom_setting::get_hand_selection_by_section(section); + hand = setting::custom_setting::get_hand_selection_by_section(section); } logger::trace("return hand {} index {}"sv, hand, a_index); return hand; @@ -115,9 +115,9 @@ namespace papyrus { std::string form_string; if (const auto section = get_section_by_index(a_index, a_position); !section.empty()) { if (a_left) { - form_string = config::custom_setting::get_item_form_left_by_section(section); + form_string = setting::custom_setting::get_item_form_left_by_section(section); } else { - form_string = config::custom_setting::get_item_form_by_section(section); + form_string = setting::custom_setting::get_item_form_by_section(section); } } @@ -136,7 +136,7 @@ namespace papyrus { void hud_mcm::reset_section(RE::TESQuest*, const uint32_t a_index, uint32_t a_position) { logger::trace("reset section was called for index {}"sv, a_index); if (const auto section = get_section_by_index(a_index, a_position); !section.empty()) { - config::custom_setting::reset_section(section); + setting::custom_setting::reset_section(section); } } @@ -148,15 +148,15 @@ namespace papyrus { logger::trace("set action was called for index {}, left {}, value {}"sv, a_index, a_left, a_value); if (const auto section = get_section_by_index(a_index, a_position); !section.empty()) { if (a_left) { - config::custom_setting::write_slot_action_left_by_section(section, a_value); + setting::custom_setting::write_slot_action_left_by_section(section, a_value); } else { - config::custom_setting::write_slot_action_by_section(section, a_value); + setting::custom_setting::write_slot_action_by_section(section, a_value); } } } std::vector hud_mcm::get_config_files(RE::TESQuest*, bool a_elden) { - logger::trace("getting config files for elden {}"sv, a_elden); + logger::trace("getting setting files for elden {}"sv, a_elden); auto files = search_for_config_files(a_elden); std::vector file_list; file_list.reserve(files.size()); @@ -168,7 +168,7 @@ namespace papyrus { } RE::BSFixedString hud_mcm::get_active_config(RE::TESQuest*, bool a_elden) { - auto file = a_elden ? config::file_setting::get_config_elden() : config::file_setting::get_config_default(); + auto file = a_elden ? setting::file_setting::get_config_elden() : setting::file_setting::get_config_default(); logger::trace("getting active Config File, Elden {}, File {}"sv, a_elden, file); return file; } @@ -180,19 +180,19 @@ namespace papyrus { if (a_elden) { name = util::ini_elden_name + "_" + a_name.data() + util::ini_ending; if (check_name(name)) { - config::file_setting::set_config_elden(name); + setting::file_setting::set_config_elden(name); } else { logger::warn("Did not set new file, already exists, name {}"sv, name); } } else { name = util::ini_default_name + "_" + a_name.data() + util::ini_ending; if (check_name(name)) { - config::file_setting::set_config_default(name); + setting::file_setting::set_config_default(name); } else { logger::warn("Did not set new file, already exists, name {}"sv, name); } } - logger::trace("set config elden {}, file {}"sv, a_elden, name); + logger::trace("set setting elden {}, file {}"sv, a_elden, name); } void hud_mcm::set_active_config(RE::TESQuest*, bool a_elden, uint32_t a_index) { @@ -203,23 +203,25 @@ namespace papyrus { } if (a_elden) { - config::file_setting::set_config_elden(file); + setting::file_setting::set_config_elden(file); } else { - config::file_setting::set_config_default(file); + setting::file_setting::set_config_default(file); } } void hud_mcm::add_unarmed_setting(RE::TESQuest*, uint32_t a_position) { - auto elden = config::mcm_setting::get_elden_demon_souls(); + auto elden = setting::mcm_setting::get_elden_demon_souls(); logger::trace("Try to add Unarmed for Position {}, Elden {}"sv, a_position, elden); auto* page_handle = handle::page_handle::get_singleton(); auto position = static_cast(a_position); std::vector data; auto next_page = 0; + const auto data_handler = RE::TESDataHandler::GetSingleton(); + if (elden && (a_position == static_cast(handle::position_setting::position_type::right) || a_position == static_cast(handle::position_setting::position_type::left))) { auto left = a_position == static_cast(handle::position_setting::position_type::left); - auto max_pages = config::mcm_setting::get_max_page_count(); + auto max_pages = setting::mcm_setting::get_max_page_count(); auto highest_page = page_handle->get_highest_page_id_position(position); if (static_cast(max_pages) == highest_page) { @@ -241,7 +243,8 @@ namespace papyrus { const auto item = new data_helper(); item->type = handle::slot_setting::slot_type::weapon; item->left = left; - item->form = RE::TESForm::LookupByID(util::unarmed); //unarmed + //item->form = RE::TESForm::LookupByID(util::unarmed); //unarmed + item->form = data_handler->LookupForm(util::unarmed, util::skyrim_esm); item->two_handed = false; item->action_type = handle::slot_setting::action_type::default_action; data.push_back(item); @@ -250,14 +253,16 @@ namespace papyrus { next_page = static_cast(page_handle->get_active_page_id()); const auto item = new data_helper(); - item->form = RE::TESForm::LookupByID(util::unarmed); + //item->form = RE::TESForm::LookupByID(util::unarmed); + item->form = data_handler->LookupForm(util::unarmed, util::skyrim_esm); item->left = false; item->type = handle::slot_setting::slot_type::weapon; item->action_type = handle::slot_setting::action_type::default_action; data.push_back(item); const auto item2 = new data_helper(); - item2->form = RE::TESForm::LookupByID(util::unarmed); + //item2->form = RE::TESForm::LookupByID(util::unarmed); + item2->form = data_handler->LookupForm(util::unarmed, util::skyrim_esm); item2->left = true; item2->type = handle::slot_setting::slot_type::weapon; item2->action_type = handle::slot_setting::action_type::default_action; @@ -273,7 +278,7 @@ namespace papyrus { RE::BSFixedString hud_mcm::get_actor_value(RE::TESQuest*, uint32_t a_index, uint32_t a_position) { std::string form_string; if (const auto section = get_section_by_index(a_index, a_position); !section.empty()) { - form_string = std::to_string(config::custom_setting::get_effect_actor_value(section)); + form_string = std::to_string(setting::custom_setting::get_effect_actor_value(section)); } return form_string; } @@ -366,8 +371,8 @@ namespace papyrus { std::string hud_mcm::get_form_name_string_for_section(const std::string& a_str) { std::string display_string; - auto form_string = config::custom_setting::get_item_form_by_section(a_str); - auto form_string_left = config::custom_setting::get_item_form_left_by_section(a_str); + auto form_string = setting::custom_setting::get_item_form_by_section(a_str); + auto form_string_left = setting::custom_setting::get_item_form_left_by_section(a_str); RE::TESForm* form = nullptr; if (!form_string.empty()) { @@ -398,9 +403,12 @@ namespace papyrus { } if (display_string.empty()) { - auto actor_value = static_cast(config::custom_setting::get_effect_actor_value(a_str)); + auto actor_value = static_cast(setting::custom_setting::get_effect_actor_value(a_str)); + const auto data_handler = RE::TESDataHandler::GetSingleton(); if (util::actor_value_to_base_potion_map_.contains(actor_value)) { - auto* potion_form = RE::TESForm::LookupByID(util::actor_value_to_base_potion_map_[actor_value]); + //auto* potion_form = RE::TESForm::LookupByID(util::actor_value_to_base_potion_map_[actor_value]); + auto* potion_form = + data_handler->LookupForm(util::actor_value_to_base_potion_map_[actor_value], util::skyrim_esm); display_string = potion_form ? potion_form->GetName() : ""; } } diff --git a/src/processing/game_menu_setting.cpp b/src/processing/game_menu_setting.cpp index 8319232..bd9db69 100644 --- a/src/processing/game_menu_setting.cpp +++ b/src/processing/game_menu_setting.cpp @@ -20,13 +20,13 @@ namespace processing { static_cast(a_position), static_cast(a_overwrite))); const auto pos_max = handle::page_handle::get_singleton()->get_highest_page_id_position(a_position); - auto max = config::mcm_setting::get_max_page_count() - 1; //we start at 0 so count -1 + auto max = setting::mcm_setting::get_max_page_count() - 1; //we start at 0 so count -1 logger::trace("Max for Position {} is {}, already set before edit {}"sv, static_cast(a_position), max, pos_max); if (pos_max != -1) { - max = config::mcm_setting::get_max_page_count() - 1 - pos_max; + max = setting::mcm_setting::get_max_page_count() - 1 - pos_max; } if (!a_overwrite && (data.size() == max || max == 0)) { @@ -35,7 +35,7 @@ namespace processing { return; } - const auto check_duplicates = config::mcm_setting::get_check_duplicate_items(); + const auto check_duplicates = setting::mcm_setting::get_check_duplicate_items(); auto* item = is_suitable_for_position(a_form, a_position); if (item->form || (a_form && item->actor_value != RE::ActorValue::kNone)) { @@ -202,7 +202,8 @@ namespace processing { if (current_data.size() == 1 && !current_two_handed) { new_data[0] = data[0]; const auto item2 = new data_helper(); - item2->form = RE::TESForm::LookupByID(util::unarmed); + //item2->form = RE::TESForm::LookupByID(util::unarmed); + item2->form = RE::TESDataHandler::GetSingleton()->LookupForm(util::unarmed, util::skyrim_esm); item2->left = !a_left; //need the opposite item2->type = slot_type::weapon; item2->action_type = handle::slot_setting::action_type::default_action; diff --git a/src/processing/set_setting_data.cpp b/src/processing/set_setting_data.cpp index 95f7f4c..6cc0c3f 100644 --- a/src/processing/set_setting_data.cpp +++ b/src/processing/set_setting_data.cpp @@ -14,8 +14,8 @@ #include "util/string_util.h" namespace processing { - using mcm = config::mcm_setting; - using custom = config::custom_setting; + using mcm = setting::mcm_setting; + using custom = setting::custom_setting; void set_setting_data::read_and_set_data() { logger::trace("Setting handlers, elden demon souls {} ..."sv, mcm::get_elden_demon_souls()); @@ -114,7 +114,7 @@ namespace processing { } void set_setting_data::set_empty_slot(const int a_page, int a_pos, handle::key_position_handle*& a_key_pos) { - logger::trace("setting empty config for page {}, position {}"sv, a_page, a_pos); + logger::trace("setting empty setting for page {}, position {}"sv, a_page, a_pos); std::vector data; auto* const item = new data_helper(); item->form = nullptr; @@ -158,7 +158,7 @@ namespace processing { auto hand = static_cast(a_hand); std::vector data; - auto action_check = config::mcm_setting::get_action_check(); + auto action_check = setting::mcm_setting::get_action_check(); logger::trace("page {}, pos {}, start working data hands {}, action_check {} ..."sv, a_page, static_cast(a_position), @@ -339,11 +339,11 @@ namespace processing { section); } - //do not trigger reequip if config a config is set + //do not trigger reequip if setting a setting is set if (mcm::get_elden_demon_souls()) { set_active_and_equip(handler); } - logger::trace("processed config data"sv); + logger::trace("processed setting data"sv); } void set_setting_data::write_empty_config_and_init_active() { //we start at 0, so it is max count -1 @@ -357,7 +357,7 @@ namespace processing { auto* key_position = handle::key_position_handle::get_singleton(); //set empty for each position, it will be overwritten if it is configured - const auto max = static_cast(config::mcm_setting::get_max_page_count()); + const auto max = static_cast(setting::mcm_setting::get_max_page_count()); for (auto i = 0; i < max; ++i) { for (auto j = 0; j < static_cast(position_type::total); ++j) { set_empty_slot(i, j, key_position); @@ -445,7 +445,7 @@ namespace processing { } else { handle::ammo_handle::get_singleton()->clear_ammo(); //un equip armor here - if (config::mcm_setting::get_un_equip_ammo()) { + if (setting::mcm_setting::get_un_equip_ammo()) { equip::item::un_equip_ammo(); } } @@ -474,18 +474,20 @@ namespace processing { return; } if (a_condition) { - a_position_setting->draw_setting->icon_transparency = config::mcm_setting::get_icon_transparency_blocked(); + a_position_setting->draw_setting->icon_transparency = setting::mcm_setting::get_icon_transparency_blocked(); } else { - a_position_setting->draw_setting->icon_transparency = config::mcm_setting::get_icon_transparency(); + a_position_setting->draw_setting->icon_transparency = setting::mcm_setting::get_icon_transparency(); } } void set_setting_data::look_for_ammo(const bool a_crossbow) { - bool only_favorite = config::mcm_setting::get_only_favorite_ammo(); - bool sort_by_quantity = config::mcm_setting::get_sort_arrow_by_quantity(); - const auto max_items = config::mcm_setting::get_max_ammunition_type(); + bool only_favorite = setting::mcm_setting::get_only_favorite_ammo(); + bool sort_by_quantity = setting::mcm_setting::get_sort_arrow_by_quantity(); + const auto max_items = setting::mcm_setting::get_max_ammunition_type(); auto* player = RE::PlayerCharacter::GetSingleton(); const auto inv = util::player::get_inventory(player, RE::FormType::Ammo); + const auto data_handler = RE::TESDataHandler::GetSingleton(); + std::multimap> ammo_list; for (const auto& [item, inv_data] : inv) { const auto& [num_items, entry] = inv_data; @@ -495,7 +497,8 @@ namespace processing { continue; } - if (ammo->formID == util::bound_arrow) { + //if (ammo->formID == util::bound_arrow) { + if (ammo->formID == data_handler->LookupFormID(util::bound_arrow, util::skyrim_esm)) { continue; } @@ -561,7 +564,7 @@ namespace processing { logger::trace("{}"sv, log_string); if (mcm::get_elden_demon_souls()) { - config::custom_setting::reset_section( + setting::custom_setting::reset_section( util::helper::get_section_name_for_page_position(a_position_setting->page, static_cast(a_position_setting->position))); } else { @@ -651,7 +654,7 @@ namespace processing { (setting->actor_value != RE::ActorValue::kNone && util::helper::get_actor_value_effect_from_potion(a_form) != RE::ActorValue::kNone)) { do_cleanup(page_setting, setting); - if (config::mcm_setting::get_elden_demon_souls()) { + if (setting::mcm_setting::get_elden_demon_souls()) { util::helper::rewrite_settings(); } write_empty_config_and_init_active(); @@ -664,35 +667,35 @@ namespace processing { } bool set_setting_data::clean_type_allowed(slot_type a_type) { - if (!config::mcm_setting::get_auto_cleanup()) { + if (!setting::mcm_setting::get_auto_cleanup()) { return false; } auto allowed = false; switch (a_type) { case slot_type::weapon: - allowed = config::mcm_setting::get_clean_weapon(); + allowed = setting::mcm_setting::get_clean_weapon(); break; case slot_type::magic: case slot_type::power: - allowed = config::mcm_setting::get_clean_spell(); + allowed = setting::mcm_setting::get_clean_spell(); break; case slot_type::shield: case slot_type::armor: case slot_type::lantern: case slot_type::mask: - allowed = config::mcm_setting::get_clean_armor(); + allowed = setting::mcm_setting::get_clean_armor(); break; case slot_type::shout: - allowed = config::mcm_setting::get_clean_shout(); + allowed = setting::mcm_setting::get_clean_shout(); break; case slot_type::consumable: - allowed = config::mcm_setting::get_clean_alchemy_item(); + allowed = setting::mcm_setting::get_clean_alchemy_item(); break; case slot_type::scroll: - allowed = config::mcm_setting::get_clean_scroll(); + allowed = setting::mcm_setting::get_clean_scroll(); break; case slot_type::light: - allowed = config::mcm_setting::get_clean_light(); + allowed = setting::mcm_setting::get_clean_light(); break; case slot_type::empty: case slot_type::misc: diff --git a/src/processing/setting_execute.cpp b/src/processing/setting_execute.cpp index 3c0438e..1b4b311 100644 --- a/src/processing/setting_execute.cpp +++ b/src/processing/setting_execute.cpp @@ -10,7 +10,7 @@ #include "util/string_util.h" namespace processing { - using mcm = config::mcm_setting; + using mcm = setting::mcm_setting; void setting_execute::execute_settings(const std::vector& a_slots, bool a_only_equip, diff --git a/src/setting/custom_setting.cpp b/src/setting/custom_setting.cpp index 61d14fb..c3fd21e 100644 --- a/src/setting/custom_setting.cpp +++ b/src/setting/custom_setting.cpp @@ -3,16 +3,16 @@ #include "mcm_setting.h" #include "util/constant.h" -namespace config { +namespace setting { CSimpleIniA custom_ini; void custom_setting::read_setting() { custom_ini.Reset(); custom_ini.SetUnicode(); - if (config::mcm_setting::get_elden_demon_souls()) { - custom_ini.LoadFile((util::ini_path + config::file_setting::get_config_elden()).c_str()); + if (setting::mcm_setting::get_elden_demon_souls()) { + custom_ini.LoadFile((util::ini_path + setting::file_setting::get_config_elden()).c_str()); } else { - custom_ini.LoadFile((util::ini_path + config::file_setting::get_config_default()).c_str()); + custom_ini.LoadFile((util::ini_path + setting::file_setting::get_config_default()).c_str()); } } @@ -131,10 +131,10 @@ namespace config { } void custom_setting::save_setting() { - if (config::mcm_setting::get_elden_demon_souls()) { - (void)custom_ini.SaveFile((util::ini_path + config::file_setting::get_config_elden()).c_str()); + if (setting::mcm_setting::get_elden_demon_souls()) { + (void)custom_ini.SaveFile((util::ini_path + setting::file_setting::get_config_elden()).c_str()); } else { - (void)custom_ini.SaveFile((util::ini_path + config::file_setting::get_config_default()).c_str()); + (void)custom_ini.SaveFile((util::ini_path + setting::file_setting::get_config_default()).c_str()); } read_setting(); } diff --git a/src/setting/custom_setting.h b/src/setting/custom_setting.h index 566de0d..060eba3 100644 --- a/src/setting/custom_setting.h +++ b/src/setting/custom_setting.h @@ -1,6 +1,6 @@ #pragma once -namespace config { +namespace setting { class custom_setting { public: static void read_setting(); diff --git a/src/setting/display_tweaks.cpp b/src/setting/display_tweaks.cpp new file mode 100644 index 0000000..a6d023f --- /dev/null +++ b/src/setting/display_tweaks.cpp @@ -0,0 +1,31 @@ +#include "display_tweaks.h" + +namespace setting { + static const char* default_ini_path = R"(.\Data\SKSE\Plugins\SSEDisplayTweaks.ini)"; + static const char* user_ini_path = R"(.\Data\SKSE\Plugins\SSEDisplayTweaks_Custom.ini)"; + + static float resolution_scale; + static bool borderless_upscale; + + void display_tweaks::load_setting() { + logger::info("reading ini files"); + const auto read_config = [&](const std::filesystem::path& path) { + CSimpleIniA ini; + ini.SetUnicode(); + ini.LoadFile(path.string().c_str()); + + resolution_scale = static_cast(ini.GetDoubleValue("Render", "ResolutionScale", 1.0f)); + borderless_upscale = ini.GetBoolValue("Render", "BorderlessUpscale", false); + }; + + read_config(default_ini_path); + read_config(user_ini_path); + + logger::info("finished reading ini files. return."); + } + + float display_tweaks::get_resolution_scale() { return resolution_scale; } + + bool display_tweaks::get_borderless_upscale() { return borderless_upscale; } + +} // config diff --git a/src/setting/display_tweaks.h b/src/setting/display_tweaks.h new file mode 100644 index 0000000..36b6abf --- /dev/null +++ b/src/setting/display_tweaks.h @@ -0,0 +1,11 @@ +#pragma once + +namespace setting { + class display_tweaks { + public: + static void load_setting(); + + static float get_resolution_scale(); + static bool get_borderless_upscale(); + }; +} // config diff --git a/src/setting/file_setting.cpp b/src/setting/file_setting.cpp index c96c746..61b0beb 100644 --- a/src/setting/file_setting.cpp +++ b/src/setting/file_setting.cpp @@ -1,7 +1,7 @@ #include "file_setting.h" #include "util/constant.h" -namespace config { +namespace setting { static const char* ini_path = R"(.\Data\SKSE\Plugins\LamasTinyHUD.ini)"; CSimpleIniA ini; diff --git a/src/setting/file_setting.h b/src/setting/file_setting.h index 38baf66..bc127e7 100644 --- a/src/setting/file_setting.h +++ b/src/setting/file_setting.h @@ -1,6 +1,6 @@ #pragma once -namespace config { +namespace setting { class file_setting { public: static void load_setting(); diff --git a/src/setting/mcm_setting.cpp b/src/setting/mcm_setting.cpp index 14b970b..70da490 100644 --- a/src/setting/mcm_setting.cpp +++ b/src/setting/mcm_setting.cpp @@ -1,6 +1,6 @@ #include "mcm_setting.h" -namespace config { +namespace setting { static const char* mcm_default_setting = R"(.\Data\MCM\Config\LamasTinyHUD\settings.ini)"; static const char* mcm_config_setting = R"(.\Data\MCM\Settings\LamasTinyHUD.ini)"; diff --git a/src/setting/mcm_setting.h b/src/setting/mcm_setting.h index 98afe1d..4ca01c3 100644 --- a/src/setting/mcm_setting.h +++ b/src/setting/mcm_setting.h @@ -1,6 +1,6 @@ #pragma once -namespace config { +namespace setting { class mcm_setting { public: static void read_setting(); diff --git a/src/ui/ui_renderer.cpp b/src/ui/ui_renderer.cpp index 96ee222..f5e29dc 100644 --- a/src/ui/ui_renderer.cpp +++ b/src/ui/ui_renderer.cpp @@ -20,7 +20,7 @@ #include namespace ui { - using mcm = config::mcm_setting; + using mcm = setting::mcm_setting; static std::map> animation_frame_map = {}; static std::vector>> animation_list; @@ -622,7 +622,7 @@ namespace ui { continue; } const auto* draw_setting = page_setting->draw_setting; - if (config::file_setting::get_draw_key_background()) { + if (setting::file_setting::get_draw_key_background()) { draw_key(a_x, a_y, draw_setting->key_icon_scale_width, @@ -704,21 +704,10 @@ namespace ui { } void ui_renderer::draw_main() { - if (fade == 0.0f) { + if (!show_ui_ || fade == 0.0f || !should_show_ui()) { return; } - if (!show_ui_) { - return; - } - - if (!should_show_ui()) { - return; - } - /*if (!show_ui_ || fade == 0.0f || !should_show_ui()) { - return; - }*/ - if (mcm::get_hide_outside_combat()) { if (!RE::PlayerCharacter::GetSingleton()->IsInCombat()) { fade_in = false; @@ -865,41 +854,41 @@ namespace ui { bool ui_renderer::get_fade() { return fade_in; } void ui_renderer::load_font() { - std::string path = R"(Data\SKSE\Plugins\resources\font\)" + config::file_setting::get_font_file_name(); + std::string path = R"(Data\SKSE\Plugins\resources\font\)" + setting::file_setting::get_font_file_name(); auto file_path = std::filesystem::path(path); - logger::trace("Need to load font {} from file {}"sv, config::file_setting::get_font_load(), path); + logger::trace("Need to load font {} from file {}"sv, setting::file_setting::get_font_load(), path); tried_font_load = true; - if (config::file_setting::get_font_load() && std::filesystem::is_regular_file(file_path) && + if (setting::file_setting::get_font_load() && std::filesystem::is_regular_file(file_path) && ((file_path.extension() == ".ttf") || (file_path.extension() == ".otf"))) { ImGuiIO& io = ImGui::GetIO(); ImVector ranges; ImFontGlyphRangesBuilder builder; builder.AddRanges(io.Fonts->GetGlyphRangesDefault()); - if (config::file_setting::get_font_chinese_full()) { + if (setting::file_setting::get_font_chinese_full()) { builder.AddRanges(io.Fonts->GetGlyphRangesChineseFull()); } - if (config::file_setting::get_font_chinese_simplified_common()) { + if (setting::file_setting::get_font_chinese_simplified_common()) { builder.AddRanges(io.Fonts->GetGlyphRangesChineseSimplifiedCommon()); } - if (config::file_setting::get_font_cyrillic()) { + if (setting::file_setting::get_font_cyrillic()) { builder.AddRanges(io.Fonts->GetGlyphRangesCyrillic()); } - if (config::file_setting::get_font_japanese()) { + if (setting::file_setting::get_font_japanese()) { builder.AddRanges(io.Fonts->GetGlyphRangesJapanese()); } - if (config::file_setting::get_font_korean()) { + if (setting::file_setting::get_font_korean()) { builder.AddRanges(io.Fonts->GetGlyphRangesKorean()); } - if (config::file_setting::get_font_thai()) { + if (setting::file_setting::get_font_thai()) { builder.AddRanges(io.Fonts->GetGlyphRangesThai()); } - if (config::file_setting::get_font_vietnamese()) { + if (setting::file_setting::get_font_vietnamese()) { builder.AddRanges(io.Fonts->GetGlyphRangesVietnamese()); } builder.BuildRanges(&ranges); loaded_font = io.Fonts->AddFontFromFileTTF(file_path.string().c_str(), - config::file_setting::get_font_size(), + setting::file_setting::get_font_size(), nullptr, ranges.Data); if (io.Fonts->Build()) { @@ -916,32 +905,32 @@ namespace ui { } else { show_ui_ = true; } - config::file_setting::set_show_ui(show_ui_); + setting::file_setting::set_show_ui(show_ui_); logger::trace("Show UI is now {}"sv, show_ui_); } void ui_renderer::set_show_ui(bool a_show) { show_ui_ = a_show; } void ui_renderer::load_all_images() { - load_images(image_type_name_map, image_struct, img_directory, config::file_setting::get_image_file_ending()); - load_images(icon_type_name_map, icon_struct, icon_directory, config::file_setting::get_image_file_ending()); - load_images(key_icon_name_map, key_struct, key_directory, config::file_setting::get_key_file_ending()); + load_images(image_type_name_map, image_struct, img_directory, setting::file_setting::get_image_file_ending()); + load_images(icon_type_name_map, icon_struct, icon_directory, setting::file_setting::get_image_file_ending()); + load_images(key_icon_name_map, key_struct, key_directory, setting::file_setting::get_key_file_ending()); load_images(default_key_icon_name_map, default_key_struct, key_directory, - config::file_setting::get_key_file_ending()); + setting::file_setting::get_key_file_ending()); load_images(gamepad_ps_icon_name_map, ps_key_struct, key_directory, - config::file_setting::get_key_file_ending()); + setting::file_setting::get_key_file_ending()); load_images(gamepad_xbox_icon_name_map, xbox_key_struct, key_directory, - config::file_setting::get_key_file_ending()); + setting::file_setting::get_key_file_ending()); load_animation_frames(highlight_animation_directory, animation_frame_map[animation_type::highlight], - config::file_setting::get_image_file_ending()); + setting::file_setting::get_image_file_ending()); logger::trace("frame length is {}"sv, animation_frame_map[animation_type::highlight].size()); } @@ -1004,11 +993,6 @@ namespace ui { if (auto* control_map = RE::ControlMap::GetSingleton(); !control_map->IsMovementControlsEnabled()) { return false; } - /*if (const auto* control_map = RE::ControlMap::GetSingleton(); - !control_map || !control_map->IsMovementControlsEnabled() || - control_map->contextPriorityStack.back() != RE::UserEvents::INPUT_CONTEXT_ID::kGameplay) { - return false; - }*/ return true; } diff --git a/src/util/constant.h b/src/util/constant.h index ac81ac3..234dc3e 100644 --- a/src/util/constant.h +++ b/src/util/constant.h @@ -19,4 +19,6 @@ namespace util { { RE::ActorValue::kMagicka, 0x0003EAE1 } }; constexpr RE::FormID bound_arrow = 0x0010b0a7; + + constexpr std::string skyrim_esm = "Skyrim.esm"; } diff --git a/src/util/helper.cpp b/src/util/helper.cpp index ff805f2..af1af1d 100644 --- a/src/util/helper.cpp +++ b/src/util/helper.cpp @@ -42,11 +42,11 @@ namespace util { std::vector helper::get_configured_section_page_names(uint32_t a_position) { //4 is all std::vector names; - for (const auto entries = config::custom_setting::get_sections(); const auto& entry : entries) { + for (const auto entries = setting::custom_setting::get_sections(); const auto& entry : entries) { if (a_position == static_cast(handle::position_setting::position_type::total)) { names.emplace_back(entry.pItem); } else { - auto section_position = config::custom_setting::get_position_by_section(entry.pItem); + auto section_position = setting::custom_setting::get_position_by_section(entry.pItem); if (section_position == a_position) { names.emplace_back(entry.pItem); } @@ -178,7 +178,7 @@ namespace util { } void helper::rewrite_settings() { - logger::trace("rewriting config ..."sv); + logger::trace("rewriting setting ..."sv); std::map next_page_for_position; for (auto i = 0; i < static_cast(handle::position_setting::position_type::total); ++i) { @@ -188,33 +188,33 @@ namespace util { const auto sections = get_configured_section_page_names(); logger::trace("got {} sections, rewrite that they are in consecutive pages"sv, sections.size()); for (const auto& section : sections) { - auto position = config::custom_setting::get_position_by_section(section); + auto position = setting::custom_setting::get_position_by_section(section); const auto next_page = next_page_for_position[position]; auto* config = new config_writer_helper(); config->section = section; config->page = next_page; config->position = position; - config->form = config::custom_setting::get_item_form_by_section(section); - config->type = config::custom_setting::get_type_by_section(section); - config->hand = config::custom_setting::get_hand_selection_by_section(section); - config->action = config::custom_setting::get_slot_action_by_section(section); - config->form_left = config::custom_setting::get_item_form_left_by_section(section); - config->type_left = config::custom_setting::get_type_left_by_section(section); - config->action_left = config::custom_setting::get_slot_action_left_by_section(section); - config->actor_value = config::custom_setting::get_effect_actor_value(section); + config->form = setting::custom_setting::get_item_form_by_section(section); + config->type = setting::custom_setting::get_type_by_section(section); + config->hand = setting::custom_setting::get_hand_selection_by_section(section); + config->action = setting::custom_setting::get_slot_action_by_section(section); + config->form_left = setting::custom_setting::get_item_form_left_by_section(section); + config->type_left = setting::custom_setting::get_type_left_by_section(section); + config->action_left = setting::custom_setting::get_slot_action_left_by_section(section); + config->actor_value = setting::custom_setting::get_effect_actor_value(section); configs.push_back(config); next_page_for_position[position] = next_page + 1; } - logger::trace("start writing config, got {} items"sv, configs.size()); + logger::trace("start writing setting, got {} items"sv, configs.size()); for (const auto config : configs) { - config::custom_setting::reset_section(config->section); + setting::custom_setting::reset_section(config->section); const auto section = get_section_name_for_page_position(config->page, config->position); - config::custom_setting::write_section_setting(section, + setting::custom_setting::write_section_setting(section, config->page, config->position, config->type, @@ -238,7 +238,7 @@ namespace util { } RE::ActorValue helper::get_actor_value_effect_from_potion(RE::TESForm* a_form, bool a_check) { - if (!a_form->Is(RE::FormType::AlchemyItem) || (!config::mcm_setting::get_group_potions() && a_check)) { + if (!a_form->Is(RE::FormType::AlchemyItem) || (!setting::mcm_setting::get_group_potions() && a_check)) { return RE::ActorValue::kNone; } @@ -284,7 +284,7 @@ namespace util { return; } - if (config::mcm_setting::get_elden_demon_souls()) { + if (setting::mcm_setting::get_elden_demon_souls()) { if (!a_data.empty()) { if (a_data[0]->left) { type_left = static_cast(a_data[0]->type); @@ -329,9 +329,9 @@ namespace util { actor_value = a_data[1]->actor_value; } } - config::mcm_setting::read_setting(); + setting::mcm_setting::read_setting(); - config::custom_setting::write_section_setting(section, + setting::custom_setting::write_section_setting(section, a_page, a_position, type, @@ -342,7 +342,7 @@ namespace util { form_string_left, action_left, static_cast(actor_value)); - config::custom_setting::read_setting(); + setting::custom_setting::read_setting(); } bool helper::can_instant_cast(RE::TESForm* a_form, const slot_type a_type) { diff --git a/src/util/player/player.cpp b/src/util/player/player.cpp index b54351b..a90c53b 100644 --- a/src/util/player/player.cpp +++ b/src/util/player/player.cpp @@ -38,7 +38,7 @@ namespace util { auto right_obj = player->GetActorRuntimeData().currentProcess->GetEquippedRightHand(); auto left_obj = player->GetActorRuntimeData().currentProcess->GetEquippedLeftHand(); - const auto empty_handle = config::mcm_setting::get_empty_hand_setting(); + const auto empty_handle = setting::mcm_setting::get_empty_hand_setting(); const auto item = new data_helper(); item->form = nullptr;