Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hack #52

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -399,3 +399,4 @@ fomod/ShowStats/gui
fomod/ShowStats/main
cmake-build-debug
cmake-build-release
venv/
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
[submodule "extern/stb"]
path = extern/stb
url = https://github.com/nothings/stb.git
[submodule "extern/CommonLibSSE-NG"]
path = extern/CommonLibSSE-NG
url = https://github.com/mlthelama/CommonLibSSE.git
branch = ng
14 changes: 8 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.20)

set(NAME "LamasTinyHUD")
set(VERSION 1.5.0.0)
set(VERSION 1.5.1.0)

# ---- Options ----

Expand Down Expand Up @@ -92,16 +92,16 @@ set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_DEBUG OFF)
set(Boost_USE_STATIC_LIBS ON)

# ---- Dependencies ----
find_package(CommonLibSSE CONFIG REQUIRED)

#find_package(CommonLibSSE CONFIG REQUIRED)
find_package(spdlog REQUIRED CONFIG)

include_directories(extern/stb)

find_package(imgui REQUIRED)

find_package(unofficial-nanosvg CONFIG REQUIRED)

set(CommonLibPath "extern/CommonLibSSE-NG")
set(CommonLibName "CommonLibSSE")
set(GameVersion "Skyrim")

# ---- Add source files ----

include(cmake/sourcelist.cmake)
Expand Down Expand Up @@ -140,6 +140,8 @@ target_compile_features(
cxx_std_23
)

add_subdirectory(${CommonLibPath} ${CommonLibName} EXCLUDE_FROM_ALL)

target_include_directories(
${PROJECT_NAME}
PRIVATE
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# LamasTinyHUD
![Platform](https://img.shields.io/static/v1?label=platform&message=windows&color=dimgray&style=for-the-badge&logo=windows)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/mlthelama/LamasTinyHUD?style=for-the-badge)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/mlthelama/LamasTinyHUD?style=for-the-badge&include_prereleases)
![GitHub](https://img.shields.io/github/license/mlthelama/LamasTinyHUD?style=for-the-badge)
![GitHub top language](https://img.shields.io/github/languages/top/mlthelama/LamasTinyHUD?style=for-the-badge)
![GitHub language count](https://img.shields.io/github/languages/count/mlthelama/LamasTinyHUD?style=for-the-badge)
Expand Down
3 changes: 2 additions & 1 deletion cmake/Version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ namespace Version
inline constexpr auto NAME = "@PROJECT_VERSION@"sv;
inline constexpr auto PROJECT = "@PROJECT_NAME@"sv;
inline constexpr auto AUTHOR = "mlthelama"sv;
inline constexpr auto EMAIL = "mlthelama [at] gmail [dot] com";

inline constexpr std::uint32_t ASINT =
(static_cast<std::uint32_t>((MAJOR * 1000000) + (MINOR * 10000) + (PATCH * 100) + (BETA)));
}
}
1 change: 1 addition & 0 deletions extern/CommonLibSSE-NG
Submodule CommonLibSSE-NG added at 4119d0
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
4 changes: 2 additions & 2 deletions src/control/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ namespace control {
break;
case RE::INPUT_DEVICE::kNone:
case RE::INPUT_DEVICE::kVirtualKeyboard:
case RE::INPUT_DEVICE::kVRRight:
case RE::INPUT_DEVICE::kVRLeft:
//case RE::INPUT_DEVICE::kVRRight:
//case RE::INPUT_DEVICE::kVRLeft:
case RE::INPUT_DEVICE::kTotal:
break;
}
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
28 changes: 17 additions & 11 deletions src/equip/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,18 @@ namespace equip {
auto simple_extra_data_list = entry->extraLists;
if (simple_extra_data_list) {
for (auto* extra_data : *simple_extra_data_list) {
extra = extra_data;
//extra = extra_data;
auto worn_right = extra_data->HasType(RE::ExtraDataType::kWorn);
auto worn_left = extra_data->HasType(RE::ExtraDataType::kWornLeft);
logger::trace("extra data {}, worn right {}, worn left {}"sv,
extra_data->GetCount(),
worn_right,
worn_left);
if (!worn_right && !worn_left) {
extra_vector.push_back(extra_data);
if (worn_right || worn_left) {
continue;
}

extra_vector.push_back(extra_data);
}
}
break;
Expand All @@ -75,6 +77,7 @@ namespace equip {
return;
}

logger::debug("extra vector is {}"sv, extra_vector.size());
auto* extra_handler = handle::extra_data_holder::get_singleton();
if (extra_handler->is_form_set(a_form)) {
auto extra_list = extra_handler->get_extra_list_for_form(a_form);
Expand All @@ -84,9 +87,12 @@ 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

extra_handler->init_extra_data(a_form, extra_vector);
logger::trace("set {} extra data for form {}"sv, extra_vector.size(), a_form->GetName());
}
Expand All @@ -107,12 +113,12 @@ namespace equip {
auto equipped_count = 0;
if (obj_right && obj_right->formID == obj->formID) {
equipped_count++;
logger::debug("Object {} already equipped."sv, obj->GetName());
logger::debug("Object {} already equipped (right)."sv, obj->GetName());
}

if (obj_left && obj_left->formID == obj->formID) {
equipped_count++;
logger::debug("Object {} already equipped."sv, obj->GetName());
logger::debug("Object {} already equipped (left)."sv, obj->GetName());
}

logger::trace("Got a count of {} in the Inventory {}, Equipped {}"sv,
Expand Down Expand Up @@ -177,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 @@ -273,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 @@ -297,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 @@ -342,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
11 changes: 7 additions & 4 deletions src/equip/magic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "setting/mcm_setting.h"
#include "util/offset.h"
#include "util/player/player.h"
#include <util/helper.h>
#include <util/string_util.h>

namespace equip {
//add toggle mcm if equip or cast
Expand Down Expand Up @@ -32,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 @@ -51,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 @@ -86,6 +88,7 @@ namespace equip {
//might need to set some things
//TODO make an animation to play here
//a_player->NotifyAnimationGraph("IdleMagic_01"); //works

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 @@ -198,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
9 changes: 5 additions & 4 deletions 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 Expand Up @@ -52,7 +52,7 @@ namespace event {
return event_result::kContinue;
}

handle::extra_data_holder::get_singleton()->reset_data();
//handle::extra_data_holder::get_singleton()->reset_data();

for (auto* event = *a_event; event; event = event->next) {
if (event->eventType != RE::INPUT_EVENT_TYPE::kButton) {
Expand Down Expand Up @@ -85,8 +85,8 @@ namespace event {
}

const auto* control_map = RE::ControlMap::GetSingleton();
if (!control_map || !control_map->IsMovementControlsEnabled() ||
control_map->contextPriorityStack.back() != RE::UserEvents::INPUT_CONTEXT_ID::kGameplay) {
if (!control_map || !control_map->IsMovementControlsEnabled()) { /*||
control_map->contextPriorityStack.back() != RE::UserEvents::INPUT_CONTEXT_ID::kGameplay) {*/
continue;
}

Expand Down Expand Up @@ -188,6 +188,7 @@ namespace event {
}
}
}

return event_result::kContinue;
}

Expand Down
9 changes: 9 additions & 0 deletions src/event/menu_manager.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "menu_manager.h"
#include "control/binding.h"
#include "handle/extra_data_holder.h"

namespace event {
menu_manager* menu_manager::get_singleton() {
Expand Down Expand Up @@ -28,6 +29,14 @@ namespace event {
binding->set_is_remove_down(false);
}
}

if (a_event->menuName == RE::InventoryMenu::MENU_NAME || a_event->menuName == RE::MagicMenu::MENU_NAME ||
a_event->menuName == RE::FavoritesMenu::MENU_NAME || a_event->menuName == RE::BarterMenu::MENU_NAME ||
a_event->menuName == RE::GiftMenu::MENU_NAME || a_event->menuName == RE::BookMenu::MENU_NAME ||
a_event->menuName == RE::FaderMenu::MENU_NAME || a_event->menuName == RE::CraftingMenu::MENU_NAME) {
handle::extra_data_holder::get_singleton()->reset_data();
}

return event_result::kContinue;
}
} // event
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
Loading