Skip to content

Commit

Permalink
quick fix
Browse files Browse the repository at this point in the history
* maybe
  • Loading branch information
mlthelama committed Feb 8, 2024
1 parent 0574d5b commit 26e9e1b
Show file tree
Hide file tree
Showing 27 changed files with 226 additions and 189 deletions.
2 changes: 2 additions & 0 deletions cmake/sourcelist.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions src/control/binding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
7 changes: 6 additions & 1 deletion src/equip/equip_slot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "util/offset.h"
#include "util/player/player.h"
#include "util/string_util.h"
#include <util/constant.h>

namespace equip {
RE::BGSEquipSlot* equip_slot::get_right_hand_slot() {
Expand Down Expand Up @@ -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<RE::TESForm>(0x00020163)->As<RE::TESObjectWEAP>();
//auto* dummy = RE::TESForm::LookupByID<RE::TESForm>(0x00020163)->As<RE::TESObjectWEAP>();
auto* dummy =
RE::TESForm::LookupByID(RE::TESDataHandler::GetSingleton()->LookupFormID(0x00020163, util::skyrim_esm))
->As<RE::TESObjectWEAP>();

//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);
Expand Down
14 changes: 8 additions & 6 deletions src/equip/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand All @@ -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,
Expand Down Expand Up @@ -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<float>(potion_doses));
Expand Down
20 changes: 4 additions & 16 deletions src/equip/magic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace equip {
auto casting_type = spell->GetCastingType();
logger::trace("spell {} is type {}"sv, spell->GetName(), static_cast<uint32_t>(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(
Expand All @@ -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,
Expand Down Expand Up @@ -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<RE::TESIdleForm, RE::TESIdleForm>) {
for (const auto& form : RE::TESDataHandler::GetSingleton()->GetFormArray<T>()) {
//AddForm(EditorID::GetEditorID(form), form);
}*/
/*for (const auto& form : RE::TESDataHandler::GetSingleton()->GetFormArray<RE::TESIdleForm>()){
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<RE::TESIdleForm>("RightCastSelf");
}

auto is_self_target = spell->GetDelivery() == RE::MagicSystem::Delivery::kSelf;
auto* target = is_self_target ? actor : actor->GetActorRuntimeData().currentCombatTarget.get().get();
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions src/event/equip_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ 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(
RE::PlayerCharacter::GetSingleton()->GetActorRuntimeData().selectedPower);
}

//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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/event/key_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/handle/key_position_handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
18 changes: 9 additions & 9 deletions src/handle/page_handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -240,7 +240,7 @@ namespace handle {
}

std::map<position_type, position_setting*> page_handle::get_active_page() const {
if (config::mcm_setting::get_elden_demon_souls()) {
if (setting::mcm_setting::get_elden_demon_souls()) {
std::map<position_type, position_setting*> a_active;
for (auto i = 0; i < static_cast<int>(position_type::total); ++i) {
const auto pos = static_cast<position_type>(i);
Expand All @@ -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) {
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/hook/menu_hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace hook {
RE::BSTEventSource<RE::InputEvent*>* 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();

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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());
Expand Down
10 changes: 5 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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<uint32_t>(msg->type));
break;
default:
Expand Down
Loading

0 comments on commit 26e9e1b

Please sign in to comment.