Skip to content

Commit

Permalink
[wip]
Browse files Browse the repository at this point in the history
* added mcm setting for scale and location of hud
* removed dependencies and took over a imgui hooking
  • Loading branch information
mlthelama committed Dec 30, 2022
1 parent 938b938 commit aeeb0e5
Show file tree
Hide file tree
Showing 31 changed files with 527 additions and 269 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "extern/stb"]
path = extern/stb
url = https://github.com/nothings/stb.git
[submodule "extern/dkutil"]
path = extern/dkutil
url = https://github.com/mlthelama/DKUtil
9 changes: 3 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ find_package(CommonLibSSE CONFIG REQUIRED)

find_package(spdlog REQUIRED CONFIG)

add_subdirectory(extern/dkutil DKUtil)

include_directories(extern/stb)

find_package(imgui REQUIRED)
Expand Down Expand Up @@ -119,8 +117,8 @@ add_library(
${CMAKE_CURRENT_BINARY_DIR}/include/Version.h
${CMAKE_CURRENT_BINARY_DIR}/version.rc
.clang-format
.editorconfig
LamasTinyHUD.ini
.editorconfig
LamasTinyHUD.ini
)

target_compile_features(
Expand All @@ -141,8 +139,7 @@ target_link_libraries(
PRIVATE
CommonLibSSE::CommonLibSSE
spdlog::spdlog
DKUtil::DKUtil
imgui::imgui
imgui::imgui
)

link_directories(extern/stb)
Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ A small UI Element
* [CommonLibSSE NG](https://github.com/CharmedBaryon/CommonLibSSE-NG)
* [spdlog](https://github.com/gabime/spdlog)
* [simpleini](https://github.com/brofield/simpleini)
* [DKUtil](https://github.com/gottyduke/DKUtil) (for easier imgui handling)
* [tomlplusplus](https://github.com/marzer/tomlplusplus) (to satisfy dkutil dependency)
* [nlohmann-json](https://github.com/nlohmann/json) (to satisfy dkutil dependency)
* [stb](https://github.com/nothings/stb) (for file reading into dx11 texture)
* [imgui](https://github.com/ocornut/imgui) (for displaying ui elements)

Expand Down
10 changes: 4 additions & 6 deletions cmake/sourcelist.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ set(sources ${sources}
src/event/key_manager.h
src/event/sink_event.cpp
src/event/sink_event.h
src/handle/read_data.cpp
src/handle/read_data.h
src/handle/set_data.cpp
src/handle/set_data.h
src/handle/slot_setting_handle.cpp
src/handle/slot_setting_handle.h
src/item/inventory.cpp
Expand All @@ -27,10 +27,8 @@ set(sources ${sources}
src/setting/file_setting.h
src/setting/mcm_setting.cpp
src/setting/mcm_setting.h
src/ui/hud.cpp
src/ui/hud.h
src/ui/renderer.cpp
src/ui/renderer.h
src/ui/ui_renderer.cpp
src/ui/ui_renderer.h
src/util/constant.h
src/util/string_util.h
)
1 change: 0 additions & 1 deletion extern/dkutil
Submodule dkutil deleted from e4c5a0
114 changes: 93 additions & 21 deletions mcm/Config/LamasTinyHUD/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
"displayName": "Lamas Tiny HUD",
"minMcmVersion": 11,
"cursorFillMode": "topToBottom",
"pages": [
{
"pages": [{
"pageDisplayName": "$LamasTinyHUD_ControlsPage",
"cursorFillMode": "topToBottom",
"content": [
{
"content": [{
"text": "$LamasTinyHUD_Controls_HeaderText",
"type": "header"
},
Expand Down Expand Up @@ -57,8 +55,7 @@
{
"pageDisplayName": "$LamasTinyHUD_TopPage",
"cursorFillMode": "topToBottom",
"content": [
{
"content": [{
"text": "$LamasTinyHUD_Top_HeaderText",
"type": "header"
},
Expand Down Expand Up @@ -114,30 +111,105 @@
{
"pageDisplayName": "$LamasTinyHUD_RightPage",
"cursorFillMode": "topToBottom",
"content": [
{
"text": "$LamasTinyHUD_Right_HeaderText",
"type": "header"
}
]
"content": [{
"text": "$LamasTinyHUD_Right_HeaderText",
"type": "header"
}]
},
{
"pageDisplayName": "$LamasTinyHUD_BottomPage",
"cursorFillMode": "topToBottom",
"content": [
{
"text": "$LamasTinyHUD_Bottom_HeaderText",
"type": "header"
}
]
"content": [{
"text": "$LamasTinyHUD_Bottom_HeaderText",
"type": "header"
}]
},
{
"pageDisplayName": "$LamasTinyHUD_LeftPage",
"cursorFillMode": "topToBottom",
"content": [
{
"text": "$LamasTinyHUD_Left_HeaderText",
"content": [{
"text": "$LamasTinyHUD_Left_HeaderText",
"type": "header"
}]
},
{
"pageDisplayName": "$LamasTinyHUD_HudSetting",
"cursorFillMode": "topToBottom",
"content": [{
"text": "$LamasTinyHUD_HudSetting_HeaderText",
"type": "header"
},
{
"id": "fHudImageScaleWidth:HudSetting",
"text": "$LamasTinyHUD_HudSetting_HudImageScaleWidth_OptionText",
"type": "slider",
"help": "$LamasTinyHUD_HudSetting_HudImageScaleWidth_InfoText",
"valueOptions": {
"min": 0.1,
"max": 5.0,
"step": 0.05,
"formatString": "{2}",
"sourceType": "ModSettingFloat"
}
},
{
"id": "fHudImageScaleHeight:HudSetting",
"text": "$LamasTinyHUD_HudSetting_HudImageScaleHeight_OptionText",
"type": "slider",
"help": "$LamasTinyHUD_HudSetting_HudImageScaleHeight_InfoText",
"valueOptions": {
"min": 0.1,
"max": 5.0,
"step": 0.05,
"formatString": "{2}",
"sourceType": "ModSettingFloat"
}
},
{
"id": "sDisplayResolutionWidth:HudSetting",
"valueOptions": {
"value": "",
"sourceType": "ModSettingString"
},
"type": "text",
"text": "$LamasTinyHUD_DisplayResolutionWidth",
"help": "$LamasTinyHUD_DisplayResolutionWidth_Help"
},
{
"id": "fHudImagePositionWidth:HudSetting",
"text": "$LamasTinyHUD_HudSetting_ImagePositionWidth_OptionText",
"type": "slider",
"help": "$LamasTinyHUD_HudSetting_ImagePositionWidth_InfoText",
"valueOptions": {
"min": 0.0,
"max": 4000.0,
"step": 1.0,
"formatString": "{1}",
"sourceType": "ModSettingFloat"
}
},
{
"id": "sDisplayResolutionHeight:HudSetting",
"valueOptions": {
"value": "",
"sourceType": "ModSettingString"
},
"type": "text",
"text": "$LamasTinyHUD_DisplayResolutionHeight",
"help": "$LamasTinyHUD_DisplayResolutionHeight_Help"
},
{
"id": "fHudImagePositionHeight:HudSetting",
"text": "$LamasTinyHUD_HudSetting_ImagePositionHeight_OptionText",
"type": "slider",
"help": "$LamasTinyHUD_HudSetting_ImagePositionHeight_InfoText",
"valueOptions": {
"min": 0.0,
"max": 4000.0,
"step": 1.0,
"formatString": "{1}",
"sourceType": "ModSettingFloat"
}
}
]
}
Expand Down
10 changes: 9 additions & 1 deletion mcm/Config/LamasTinyHUD/settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,12 @@ uLeftActionKey = 48
uTopType = 1
uTopSelectedItem = 0
sRefreshTopItems =
sSelectedTopItemForm =
sSelectedTopItemForm = 0

[HudSetting]
fHudImageScaleWidth = 1.0
fHudImageScaleHeight = 1.0
sDisplayResolutionWidth =
fHudImagePositionWidth = 0.0
sDisplayResolutionHeight =
fHudImagePositionHeight = 0.0
Binary file modified mcm/Interface/Translations/LamasTinyHUD_english.txt
Binary file not shown.
Binary file modified mcm/scripts/LamasTinyHUD_MCM.pex
Binary file not shown.
19 changes: 13 additions & 6 deletions mcm/source/Scripts/LamasTinyHUD_MCM.psc
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ ScriptName LamasTinyHUD_MCM Extends MCM_ConfigBase
Event OnConfigClose() native

function RefreshItems()
RefreshMenu()
;RefreshMenu()
SetMenuOptions("uTopSelectedItem:TopPage", GetSelectedOptions(GetModSettingInt("uTopType:TopPage")))
RefreshMenu()
;RefreshMenu()
endfunction

string[] function GetSelectedOptions(int a_id) native
Expand All @@ -25,11 +25,18 @@ EndEvent
; RefreshItems()
;EndEvent

string function GetResolutionWidth() native
string function GetResolutionHeight() native

;Event OnPageSelect(string a_page)
; RefreshMenu()
;EndEvent
Event OnPageSelect(string a_page)
if (a_page == "$LamasTinyHUD_TopPage")
SetMenuOptions("uTopSelectedItem:TopPage", GetSelectedOptions(GetModSettingInt("uTopType:TopPage")))
elseif ( a_page == "$LamasTinyHUD_HudSetting" )
SetModSettingString("sDisplayResolutionWidth:HudSetting",GetResolutionWidth())
SetModSettingString("sDisplayResolutionHeight:HudSetting",GetResolutionHeight())
endIf
EndEvent

Event OnConfigInit()
RefreshItems()
;RefreshItems()
EndEvent
7 changes: 7 additions & 0 deletions src/PCH.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ namespace stl {
using namespace SKSE::stl;

constexpr std::string_view safe_string(const char* a_str) { return a_str ? a_str : ""sv; }

template <class T>
void write_thunk_call() {
auto& trampoline = SKSE::GetTrampoline();
const REL::Relocation<std::uintptr_t> hook{ T::id, T::offset };
T::func = trampoline.write_call<5>(hook.address(), T::thunk);
}
}

namespace logger = SKSE::log;
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 @@ -117,7 +117,7 @@ namespace event {
case util::selection_type::power:
//make a setting in mcm for equip or instant cast
magic::power::equip_power(top_handle);
//magic::spell::instant_cast(top_handle);
//magic::spell::instant_cast(top_handle);
break;
case util::selection_type::weapon:
item::weapon::equip_weapon(top_handle);
Expand Down
7 changes: 0 additions & 7 deletions src/handle/read_data.h

This file was deleted.

16 changes: 8 additions & 8 deletions src/handle/read_data.cpp → src/handle/set_data.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#include "read_data.h"
#include "set_data.h"

#include "setting/mcm_setting.h"
#include "util/constant.h"
#include "handle/slot_setting_handle.h"

namespace handle {
void read_data::read_config_and_set_data() {
logger::trace("Reading mcm config ..."sv);
config::mcm_setting::read_setting();

void set_data::set_slot_data() {
logger::trace("Setting handlers ..."sv);
if (config::mcm_setting::get_selected_top_item_form() > 0) {
slot_setting_handle::get_singleton()->init_top_setting(
RE::TESForm::LookupByID(config::mcm_setting::get_selected_top_item_form()),
if (const auto form = RE::TESForm::LookupByID(config::mcm_setting::get_selected_top_item_form());
form != nullptr) {
slot_setting_handle::get_singleton()->init_top_setting(form,
static_cast<util::selection_type>(config::mcm_setting::get_top_type()));
} else {
logger::warn("form for top type is null. skip."sv);
}
logger::trace("done setting. return."sv);
}
}
7 changes: 7 additions & 0 deletions src/handle/set_data.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once
namespace handle {
class set_data {
public:
static void set_slot_data();
};
}
1 change: 0 additions & 1 deletion src/handle/slot_setting_handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ namespace handle {
}

void slot_setting_handle::init_top_setting(RE::TESForm* a_form, const util::selection_type a_type) {
logger::trace("set top setting from {}"sv, a_form->GetName());
if (!this->data_) {
this->data_ = new slot_setting_handle_data();
}
Expand Down
2 changes: 1 addition & 1 deletion src/item/weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "inventory.h"

namespace item {
void weapon::equip_weapon(RE::TESForm* a_form) {
void weapon::equip_weapon(const RE::TESForm* a_form) {
logger::trace("try to equip {}"sv, a_form->GetName());

RE::TESBoundObject* obj = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/item/weapon.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
namespace item {
class weapon {
public:
static void equip_weapon(RE::TESForm* a_form);
static void equip_weapon(const RE::TESForm* a_form);
};
}
2 changes: 1 addition & 1 deletion src/magic/power.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace magic {

const auto spell = a_form->As<RE::SpellItem>();
//maybe check if it is already equipped
//and make a setting to instant cast, maybe in the keymanager already
//and make a setting to instant cast, maybe in the key manager already
RE::ActorEquipManager::GetSingleton()->EquipSpell(RE::PlayerCharacter::GetSingleton(), spell);
logger::trace("equipped power {}. return."sv, a_form->GetName());
}
Expand Down
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "util/constant.h"
#include "papyrus/papyrus.h"
#include "setting/mcm_setting.h"
#include "ui/hud.h"
#include "ui/ui_renderer.h"

void init_logger() {
if (static bool initialized = false; !initialized) {
Expand Down Expand Up @@ -86,7 +86,7 @@ EXTERN_C [[maybe_unused]] __declspec(dllexport) bool SKSEAPI SKSEPlugin_Load(con
});*/

papyrus::Register();
ui::hud::install();
ui::ui_renderer::install();

logger::info("{} loaded"sv, Version::PROJECT);
return true;
Expand Down
Loading

0 comments on commit aeeb0e5

Please sign in to comment.