Skip to content

Commit

Permalink
[feature]
Browse files Browse the repository at this point in the history
* added option to fade in and out in comebat (in is instant) (Misc
  Setting>Checks>Fade Timer Outside Combat)
* accepting input now if "Hide HUD Outside Combat" is set, it will fade
  in the HUD, counter will be reset for fading out.
  • Loading branch information
mlthelama committed Jan 21, 2023
1 parent 307bcc2 commit bfec72f
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 6 deletions.
2 changes: 1 addition & 1 deletion 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" CACHE STRING "")
set(VERSION 1.0.6.0 CACHE STRING "")
set(VERSION 1.0.7.0 CACHE STRING "")

# ---- Options ----

Expand Down
13 changes: 13 additions & 0 deletions mcm/Config/LamasTinyHUD/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,19 @@
"sourceType": "ModSettingBool"
}
},
{
"id": "fFadeTimerOutsideCombat:MiscSetting",
"text": "$LamasTinyHUD_MiscSetting_FadeTimerOutsideCombat_OptionText",
"type": "slider",
"help": "$LamasTinyHUD_MiscSetting_FadeTimerOutsideCombat_InfoText",
"valueOptions": {
"min": 1.0,
"max": 30.0,
"step": 1,
"formatString": "{0}",
"sourceType": "ModSettingFloat"
}
},
{
"id": "bDisableInputQuickLoot:MiscSetting",
"text": "$LamasTinyHUD_DisableInputQuickLoot_OptionText",
Expand Down
1 change: 1 addition & 0 deletions mcm/Config/LamasTinyHUD/settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@ uCurrentItemsBlue = 255
bActionCheck = 0
bEmptyHandSetting = 1
bHideOutsideCombat = 0
fFadeTimerOutsideCombat = 5
bDisableInputQuickLoot = 0
uMaxPageCount = 2
Binary file modified mcm/Interface/Translations/LamasTinyHUD_english.txt
Binary file not shown.
8 changes: 6 additions & 2 deletions src/event/key_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "handle/setting/setting_execute.h"
#include "handle/setting/set_setting_data.h"
#include "setting/mcm_setting.h"
#include "ui/ui_renderer.h"
#include "util/helper.h"

namespace event {
Expand Down Expand Up @@ -102,10 +103,13 @@ namespace event {
continue;
}

if (config::mcm_setting::get_hide_outside_combat() && !RE::PlayerCharacter::GetSingleton()->IsInCombat()) {
continue;
if (config::mcm_setting::get_hide_outside_combat() && !ui::ui_renderer::get_fade()) {
if ((is_position_button(key_) || key_ == key_toggle_) && (button->IsDown() || button->IsPressed())) {
ui::ui_renderer::set_fade(true, 1.f);
}
}


if (is_position_button(key_)) {
if (button->IsHeld() && button->HeldDuration() >= config::mcm_setting::get_config_button_hold_time()) {
do_button_hold(key_);
Expand Down
5 changes: 5 additions & 0 deletions src/setting/mcm_setting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ namespace config {
static bool action_check;
static bool empty_hand_setting;
static bool hide_outside_combat;
static float fade_timer_outside_combat;
static bool disable_input_quick_loot;
static uint32_t max_page_count;

Expand Down Expand Up @@ -114,6 +115,9 @@ namespace config {
action_check = mcm.GetBoolValue("MiscSetting", "bActionCheck", false);
empty_hand_setting = mcm.GetBoolValue("MiscSetting", "bEmptyHandSetting", true);
hide_outside_combat = mcm.GetBoolValue("MiscSetting", "bHideOutsideCombat", false);
fade_timer_outside_combat = static_cast<float>(mcm.GetDoubleValue("MiscSetting",
"fFadeTimerOutsideCombat",
5));
disable_input_quick_loot = mcm.GetBoolValue("MiscSetting", "bDisableInputQuickLoot", false);
max_page_count = static_cast<uint32_t>(mcm.GetLongValue("MiscSetting", "uMaxPageCount", 2));
};
Expand Down Expand Up @@ -165,6 +169,7 @@ namespace config {
bool mcm_setting::get_action_check() { return action_check; }
bool mcm_setting::get_empty_hand_setting() { return empty_hand_setting; }
bool mcm_setting::get_hide_outside_combat() { return hide_outside_combat; }
float mcm_setting::get_fade_timer_outside_combat() { return fade_timer_outside_combat; }
bool mcm_setting::get_disable_input_quick_loot() { return disable_input_quick_loot; }
uint32_t mcm_setting::get_max_page_count() { return max_page_count; }
}
1 change: 1 addition & 0 deletions src/setting/mcm_setting.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ namespace config {
static bool get_action_check();
static bool get_empty_hand_setting();
static bool get_hide_outside_combat();
static float get_fade_timer_outside_combat();
static bool get_disable_input_quick_loot();
static uint32_t get_max_page_count();
};
Expand Down
41 changes: 39 additions & 2 deletions src/ui/ui_renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ namespace ui {
static std::map<uint32_t, image> ps_key_struct;
static std::map<uint32_t, image> xbox_key_struct;

float fade = 1.0f;
bool fade_in = true;
float fade_out_timer = mcm::get_fade_timer_outside_combat();

LRESULT ui_renderer::wnd_proc_hook::thunk(const HWND h_wnd,
const UINT u_msg,
const WPARAM w_param,
Expand Down Expand Up @@ -395,8 +399,12 @@ namespace ui {
return;
}

if (mcm::get_hide_outside_combat() && !RE::PlayerCharacter::GetSingleton()->IsInCombat()) {
return;
if (mcm::get_hide_outside_combat()) {
if (!RE::PlayerCharacter::GetSingleton()->IsInCombat()) {
fade_in = false;
} else {
fade_in = true;
}
}


Expand All @@ -410,6 +418,10 @@ namespace ui {
ImGui::SetNextWindowSize(ImVec2(screen_size_x, screen_size_y));
ImGui::SetNextWindowPos(ImVec2(0.f, 0.f));


ImGuiStyle& style = ImGui::GetStyle();
style.Alpha = fade;

ImGui::Begin(hud_name, nullptr, window_flag);

if (const auto settings = handle::page_handle::get_singleton()->get_active_page(); !settings.empty()) {
Expand Down Expand Up @@ -443,6 +455,19 @@ namespace ui {
}

ImGui::End();
if (fade_in) {
fade_out_timer = mcm::get_fade_timer_outside_combat();

fade += 0.01f;
if (fade < 1.0f) fade = 1.0f;
} else {
if (fade_out_timer > 0.0f) {
fade_out_timer -= ImGui::GetIO().DeltaTime;
} else {
fade -= 0.01f;
if (fade < 0.0f) fade = 0.0f;
}
}
}


Expand Down Expand Up @@ -534,4 +559,16 @@ namespace ui {
float ui_renderer::get_resolution_width() { return ImGui::GetIO().DisplaySize.x; }

float ui_renderer::get_resolution_height() { return ImGui::GetIO().DisplaySize.y; }

void ui_renderer::set_fade(const bool a_in, const float a_value) {
fade_in = a_in;
fade = a_value;
if (a_in) {
fade_out_timer = mcm::get_fade_timer_outside_combat();
}
}

bool ui_renderer::get_fade() {
return fade_in;
}
}
3 changes: 3 additions & 0 deletions src/ui/ui_renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,8 @@ namespace ui {

static float get_resolution_width();
static float get_resolution_height();

static void set_fade(bool a_in, float a_value);
static bool get_fade();
};
}
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lamastinyhud",
"version-string": "1.0.6",
"version-string": "1.0.7",
"description": "hud element for skyrim",
"homepage": "https://github.com/mlthelama/LamasTinyHUD",
"license": "GPL-2.0-or-later",
Expand Down

0 comments on commit bfec72f

Please sign in to comment.