From 9da0b1bd14c04b36ad1af2bdcc9f28f10f00826c Mon Sep 17 00:00:00 2001 From: mlthelama <47679057+mlthelama@users.noreply.github.com> Date: Wed, 5 Apr 2023 20:44:50 +0200 Subject: [PATCH] `feature` * added: seperate alpha/transparency settings for current items, current shout, slot count and slot item name (HUD Graphic>Transparency) * added: seperate color setting for current items (applies to current shout as well), slot count and slot item name (HUD Graphic>Color) --- CMakeLists.txt | 2 +- mcm/Config/LamasTinyHUD/config.json | 84 +++++++++++++++++- mcm/Config/LamasTinyHUD/settings.ini | 8 +- .../Translations/LamasTinyHUD_english.txt | Bin 56172 -> 58538 bytes src/handle/data/page/position_draw_setting.h | 10 ++- src/handle/page_handle.cpp | 11 ++- src/processing/game_menu_setting.cpp | 2 +- src/processing/set_setting_data.cpp | 4 +- src/processing/set_setting_data.h | 2 +- src/setting/mcm_setting.cpp | 30 ++++++- src/setting/mcm_setting.h | 9 +- src/ui/ui_renderer.cpp | 50 ++++++----- src/ui/ui_renderer.h | 5 +- 13 files changed, 178 insertions(+), 39 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 65d8e9c..fc3bd34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.20) set(NAME "LamasTinyHUD") -set(VERSION 1.4.2.0) +set(VERSION 1.4.2.1) # ---- Options ---- diff --git a/mcm/Config/LamasTinyHUD/config.json b/mcm/Config/LamasTinyHUD/config.json index b550cbf..902d12f 100644 --- a/mcm/Config/LamasTinyHUD/config.json +++ b/mcm/Config/LamasTinyHUD/config.json @@ -997,10 +997,49 @@ } }, { - "id": "uTextTransparency:GraphicSetting", - "text": "$LamasTinyHUD_GraphicSetting_Transparency_Text_OptionText", + "id": "uCurrentItemsTransparency:GraphicSetting", + "text": "$LamasTinyHUD_GraphicSetting_Transparency_CurrentItemsText_OptionText", "type": "slider", - "help": "$LamasTinyHUD_GraphicSetting_Transparency_Text_InfoText", + "help": "$LamasTinyHUD_GraphicSetting_Transparency_CurrentItemsText_InfoText", + "valueOptions": { + "min": 0, + "max": 255, + "step": 1, + "formatString": "{0}", + "sourceType": "ModSettingInt" + } + }, + { + "id": "uCurrentShoutTransparency:GraphicSetting", + "text": "$LamasTinyHUD_GraphicSetting_Transparency_CurrentShoutText_OptionText", + "type": "slider", + "help": "$LamasTinyHUD_GraphicSetting_Transparency_CurrentShoutText_InfoText", + "valueOptions": { + "min": 0, + "max": 255, + "step": 1, + "formatString": "{0}", + "sourceType": "ModSettingInt" + } + }, + { + "id": "uSlotCountTransparency:GraphicSetting", + "text": "$LamasTinyHUD_GraphicSetting_Transparency_SlotCountText_OptionText", + "type": "slider", + "help": "$LamasTinyHUD_GraphicSetting_Transparency_SlotCountText_InfoText", + "valueOptions": { + "min": 0, + "max": 255, + "step": 1, + "formatString": "{0}", + "sourceType": "ModSettingInt" + } + }, + { + "id": "uSlotItemNameTransparency:GraphicSetting", + "text": "$LamasTinyHUD_GraphicSetting_Transparency_SlotItemNameText_OptionText", + "type": "slider", + "help": "$LamasTinyHUD_GraphicSetting_Transparency_SlotItemNameText_InfoText", "valueOptions": { "min": 0, "max": 255, @@ -1178,6 +1217,45 @@ "sourceType": "ModSettingInt" } }, + { + "id": "uSlotItemRed:GraphicSetting", + "text": "$LamasTinyHUD_GraphicSetting_SlotItemRed_OptionText", + "type": "slider", + "help": "$LamasTinyHUD_GraphicSetting_SlotItemRed_InfoText", + "valueOptions": { + "min": 0, + "max": 255, + "step": 1, + "formatString": "{0}", + "sourceType": "ModSettingInt" + } + }, + { + "id": "uSlotItemGreen:GraphicSetting", + "text": "$LamasTinyHUD_GraphicSetting_SlotItemGreen_OptionText", + "type": "slider", + "help": "$LamasTinyHUD_GraphicSetting_SlotItemGreen_InfoText", + "valueOptions": { + "min": 0, + "max": 255, + "step": 1, + "formatString": "{0}", + "sourceType": "ModSettingInt" + } + }, + { + "id": "uSlotItemBlue:GraphicSetting", + "text": "$LamasTinyHUD_GraphicSetting_SlotItemBlue_OptionText", + "type": "slider", + "help": "$LamasTinyHUD_GraphicSetting_SlotItemBlue_InfoText", + "valueOptions": { + "min": 0, + "max": 255, + "step": 1, + "formatString": "{0}", + "sourceType": "ModSettingInt" + } + }, { "text": "$LamasTinyHUD_GraphicSetting_Misc", "type": "header" diff --git a/mcm/Config/LamasTinyHUD/settings.ini b/mcm/Config/LamasTinyHUD/settings.ini index e68445d..4053ea4 100644 --- a/mcm/Config/LamasTinyHUD/settings.ini +++ b/mcm/Config/LamasTinyHUD/settings.ini @@ -74,7 +74,10 @@ uBackgroundTransparency = 255 uBackgroundIconTransparency = 255 uIconTransparency = 125 uKeyTransparency = 255 -uTextTransparency = 255 +uCurrentItemsTransparency = 255 +uCurrentShoutTransparency = 255 +uSlotCountTransparency = 255 +uSlotItemNameTransparency = 255 uIconTransparencyBlocked = 50 uCurrentItemsRed = 255 uCurrentItemsGreen = 255 @@ -82,6 +85,9 @@ uCurrentItemsBlue = 255 uSlotCountRed = 255 uSlotCountGreen = 255 uSlotCountBlue = 255 +uSlotItemRed = 255 +uSlotItemGreen = 255 +uSlotItemBlue = 255 fSlotCountTextFontSize = 20 fCurrentItemsFontSize = 20 uSlotButtonFeedback = 175 diff --git a/mcm/Interface/Translations/LamasTinyHUD_english.txt b/mcm/Interface/Translations/LamasTinyHUD_english.txt index b867604c571ab0e97f5d31ef90ee9fd3fdd44a73..bad24e40621b5dcefd3cb9c2d3cec035ae7468f5 100644 GIT binary patch delta 443 zcmaE}jd|5c<_$dQlT(T%Cg)UgO}0FKE4r3RDV1aV9@(*uS=sTxR(F=+Dp49UrHMM{(31#(P&6~r^y zrQ8p!InIp)c2%nFkm+D#@eXcC#M Ym!3Ddpp|3tuSTWGIUPQmnpY(P01i|$yZ`_I diff --git a/src/handle/data/page/position_draw_setting.h b/src/handle/data/page/position_draw_setting.h index 184ef6c..7388772 100644 --- a/src/handle/data/page/position_draw_setting.h +++ b/src/handle/data/page/position_draw_setting.h @@ -13,7 +13,15 @@ namespace handle { uint32_t background_icon_transparency = ui::draw_full; uint32_t icon_transparency = ui::draw_full; uint32_t key_transparency = ui::draw_full; - uint32_t text_transparency = ui::draw_full; + uint32_t slot_count_transparency = ui::draw_full; + uint32_t slot_item_name_transparency = ui::draw_full; + + uint32_t slot_count_red = ui::draw_full; + uint32_t slot_count_green = ui::draw_full; + uint32_t slot_count_blue = ui::draw_full; + uint32_t slot_item_red = ui::draw_full; + uint32_t slot_item_green = ui::draw_full; + uint32_t slot_item_blue = ui::draw_full; float offset_slot_x = 0.f; float offset_slot_y = 0.f; diff --git a/src/handle/page_handle.cpp b/src/handle/page_handle.cpp index 4d0e863..ad714d3 100644 --- a/src/handle/page_handle.cpp +++ b/src/handle/page_handle.cpp @@ -102,7 +102,16 @@ namespace handle { draw->background_icon_transparency = mcm::get_background_icon_transparency(); draw->icon_transparency = mcm::get_icon_transparency(); draw->key_transparency = mcm::get_key_transparency(); - draw->text_transparency = mcm::get_text_transparency(); + draw->slot_count_transparency = mcm::get_slot_count_transparency(); + draw->slot_item_name_transparency = mcm::get_slot_item_name_transparency(); + + draw->slot_count_red = mcm::get_slot_count_red(); + draw->slot_count_green = mcm::get_slot_count_green(); + draw->slot_count_blue = mcm::get_slot_count_blue(); + draw->slot_item_red = mcm::get_slot_item_red(); + draw->slot_item_green = mcm::get_slot_item_green(); + draw->slot_item_blue = mcm::get_slot_item_blue(); + draw->alpha_slot_animation = mcm::get_alpha_slot_animation(); draw->duration_slot_animation = mcm::get_duration_slot_animation(); diff --git a/src/processing/game_menu_setting.cpp b/src/processing/game_menu_setting.cpp index 729ece2..66f20bf 100644 --- a/src/processing/game_menu_setting.cpp +++ b/src/processing/game_menu_setting.cpp @@ -75,7 +75,7 @@ namespace processing { logger::warn("form is null. return."sv); return; } - + const auto two_handed = util::helper::is_two_handed(a_form); if (two_handed && a_left) { auto log_string = fmt::format("Going to Ignore {}, because Two Handed {} and Left {}", diff --git a/src/processing/set_setting_data.cpp b/src/processing/set_setting_data.cpp index 2cd425c..bbb8170 100644 --- a/src/processing/set_setting_data.cpp +++ b/src/processing/set_setting_data.cpp @@ -398,7 +398,7 @@ namespace processing { logger::trace("done equip for first set"sv); } - void set_setting_data::clear_hands() { + [[maybe_unused]] void set_setting_data::clear_hands() { logger::trace("clear hands"sv); auto player = RE::PlayerCharacter::GetSingleton(); auto equip_manager = RE::ActorEquipManager::GetSingleton(); @@ -628,7 +628,7 @@ namespace processing { logger::warn("form is null. return."sv); return; } - + auto page_handle = handle::page_handle::get_singleton(); for (auto pages = page_handle->get_pages(); auto& [page, page_settings] : pages) { for (auto [position, page_setting] : page_settings) { diff --git a/src/processing/set_setting_data.h b/src/processing/set_setting_data.h index 7e00580..9b1328b 100644 --- a/src/processing/set_setting_data.h +++ b/src/processing/set_setting_data.h @@ -37,7 +37,7 @@ namespace processing { static void set_active_and_equip(handle::page_handle*& a_page_handle); static void process_config_data(); static void write_empty_config_and_init_active(); - static void clear_hands(); + [[maybe_unused]] static void clear_hands(); static void block_location(handle::position_setting* a_position_setting, bool a_condition); static void look_for_ammo(bool a_crossbow); //easier to have both, first only needed to get the page, position. the second, so it is easier to have the form diff --git a/src/setting/mcm_setting.cpp b/src/setting/mcm_setting.cpp index de37e00..14b970b 100644 --- a/src/setting/mcm_setting.cpp +++ b/src/setting/mcm_setting.cpp @@ -52,7 +52,10 @@ namespace config { static uint32_t background_icon_transparency; static uint32_t icon_transparency; static uint32_t key_transparency; - static uint32_t text_transparency; + static uint32_t current_items_transparency; + static uint32_t current_shout_transparency; + static uint32_t slot_count_transparency; + static uint32_t slot_item_name_transparency; static uint32_t icon_transparency_blocked; static float slot_count_text_font_size; static float current_items_font_size; @@ -63,6 +66,9 @@ namespace config { static uint32_t slot_count_red; static uint32_t slot_count_green; static uint32_t slot_count_blue; + static uint32_t slot_item_red; + static uint32_t slot_item_green; + static uint32_t slot_item_blue; static uint32_t slot_button_feedback; static bool draw_current_items_text; static bool draw_item_name_text; @@ -177,7 +183,14 @@ namespace config { static_cast(mcm.GetLongValue("GraphicSetting", "uBackgroundIconTransparency", 175)); icon_transparency = static_cast(mcm.GetLongValue("GraphicSetting", "uIconTransparency", 125)); key_transparency = static_cast(mcm.GetLongValue("GraphicSetting", "uKeyTransparency", 225)); - text_transparency = static_cast(mcm.GetLongValue("GraphicSetting", "uTextTransparency", 255)); + current_items_transparency = + static_cast(mcm.GetLongValue("GraphicSetting", "uCurrentItemsTransparency", 255)); + current_shout_transparency = + static_cast(mcm.GetLongValue("GraphicSetting", "uCurrentShoutTransparency", 255)); + slot_count_transparency = + static_cast(mcm.GetLongValue("GraphicSetting", "uSlotCountTransparency", 255)); + slot_item_name_transparency = + static_cast(mcm.GetLongValue("GraphicSetting", "uSlotItemNameTransparency", 255)); icon_transparency_blocked = static_cast(mcm.GetLongValue("GraphicSetting", "uIconTransparencyBlocked", 50)); slot_count_text_font_size = @@ -191,6 +204,10 @@ namespace config { slot_count_red = static_cast(mcm.GetLongValue("GraphicSetting", "uSlotCountRed", 255)); slot_count_green = static_cast(mcm.GetLongValue("GraphicSetting", "uSlotCountGreen", 255)); slot_count_blue = static_cast(mcm.GetLongValue("GraphicSetting", "uSlotCountBlue", 255)); + slot_item_red = static_cast(mcm.GetLongValue("GraphicSetting", "uSlotItemRed", 255)); + slot_item_green = static_cast(mcm.GetLongValue("GraphicSetting", "uSlotItemGreen", 255)); + slot_item_blue = static_cast(mcm.GetLongValue("GraphicSetting", "uSlotItemBlue", 255)); + slot_button_feedback = static_cast(mcm.GetLongValue("GraphicSetting", "uSlotButtonFeedback", 150)); draw_current_items_text = mcm.GetBoolValue("GraphicSetting", "bDrawCurrentItemsText", true); @@ -302,7 +319,10 @@ namespace config { uint32_t mcm_setting::get_background_icon_transparency() { return background_icon_transparency; } uint32_t mcm_setting::get_icon_transparency() { return icon_transparency; } uint32_t mcm_setting::get_key_transparency() { return key_transparency; } - uint32_t mcm_setting::get_text_transparency() { return text_transparency; } + uint32_t mcm_setting::get_current_items_transparency() { return current_items_transparency; } + uint32_t mcm_setting::get_current_shout_transparency() { return current_shout_transparency; } + uint32_t mcm_setting::get_slot_count_transparency() { return slot_count_transparency; } + uint32_t mcm_setting::get_slot_item_name_transparency() { return slot_item_name_transparency; } uint32_t mcm_setting::get_icon_transparency_blocked() { return icon_transparency_blocked; } float mcm_setting::get_slot_count_text_font_size() { return slot_count_text_font_size * master_scale; } float mcm_setting::get_current_items_font_size() { return current_items_font_size * master_scale; } @@ -313,6 +333,9 @@ namespace config { uint32_t mcm_setting::get_slot_count_red() { return slot_count_red; } uint32_t mcm_setting::get_slot_count_green() { return slot_count_green; } uint32_t mcm_setting::get_slot_count_blue() { return slot_count_blue; } + uint32_t mcm_setting::get_slot_item_red() { return slot_item_red; } + uint32_t mcm_setting::get_slot_item_green() { return slot_item_green; } + uint32_t mcm_setting::get_slot_item_blue() { return slot_item_blue; } bool mcm_setting::get_draw_current_items_text() { return draw_current_items_text; } uint32_t mcm_setting::get_slot_button_feedback() { return slot_button_feedback; } bool mcm_setting::get_draw_item_name_text() { return draw_item_name_text; } @@ -322,7 +345,6 @@ namespace config { float mcm_setting::get_item_name_font_size() { return item_name_font_size; } bool mcm_setting::get_draw_page_id() { return draw_page_id; } - uint32_t mcm_setting::get_alpha_slot_animation() { return alpha_slot_animation; } float mcm_setting::get_duration_slot_animation() { return duration_slot_animation; } diff --git a/src/setting/mcm_setting.h b/src/setting/mcm_setting.h index 628d1bd..98afe1d 100644 --- a/src/setting/mcm_setting.h +++ b/src/setting/mcm_setting.h @@ -54,7 +54,10 @@ namespace config { static uint32_t get_background_icon_transparency(); static uint32_t get_icon_transparency(); static uint32_t get_key_transparency(); - static uint32_t get_text_transparency(); + static uint32_t get_current_items_transparency(); + static uint32_t get_current_shout_transparency(); + static uint32_t get_slot_count_transparency(); + static uint32_t get_slot_item_name_transparency(); static uint32_t get_icon_transparency_blocked(); static float get_slot_count_text_font_size(); static float get_current_items_font_size(); @@ -65,6 +68,10 @@ namespace config { static uint32_t get_slot_count_red(); static uint32_t get_slot_count_green(); static uint32_t get_slot_count_blue(); + static uint32_t get_slot_item_red(); + static uint32_t get_slot_item_green(); + static uint32_t get_slot_item_blue(); + static uint32_t get_slot_button_feedback(); static bool get_draw_current_items_text(); static bool get_draw_item_name_text(); diff --git a/src/ui/ui_renderer.cpp b/src/ui/ui_renderer.cpp index ab850ad..34cbf90 100644 --- a/src/ui/ui_renderer.cpp +++ b/src/ui/ui_renderer.cpp @@ -217,7 +217,10 @@ namespace ui { const float a_offset_extra_x, const float a_offset_extra_y, const char* a_text, - const ImU32 a_color, + uint32_t a_alpha, + uint32_t a_red, + uint32_t a_green, + uint32_t a_blue, const float a_font_size, bool a_center_text, bool a_deduct_text_x, @@ -228,10 +231,12 @@ namespace ui { auto text_x = 0.f; auto text_y = 0.f; - if (!a_text || !*a_text) { + if (!a_text || !*a_text || a_alpha == 0) { return; } + const ImU32 color = IM_COL32(a_red, a_green, a_blue, a_alpha); + const ImVec2 text_size = ImGui::CalcTextSize(a_text); if (a_center_text) { text_x = -text_size.x * 0.5f; @@ -258,7 +263,7 @@ namespace ui { font = ImGui::GetDefaultFont(); } - ImGui::GetWindowDrawList()->AddText(font, a_font_size, position, a_color, a_text, nullptr, 0.0f, nullptr); + ImGui::GetWindowDrawList()->AddText(font, a_font_size, position, color, a_text, nullptr, 0.0f, nullptr); } void ui_renderer::draw_element(ID3D11ShaderResourceView* a_texture, @@ -393,8 +398,6 @@ namespace ui { } if (page_setting->item_name && !page_setting->slot_settings.empty()) { - const ImU32 color = - IM_COL32(draw_full, draw_full, draw_full, page_setting->draw_setting->text_transparency); auto slot_setting = page_setting->slot_settings.front(); auto slot_name = ""; if (slot_setting && slot_setting->form) { @@ -423,7 +426,10 @@ namespace ui { draw_setting->offset_name_text_x, draw_setting->offset_name_text_y, slot_name, - color, + draw_setting->slot_item_name_transparency, + draw_setting->slot_item_red, + draw_setting->slot_item_green, + draw_setting->slot_item_blue, page_setting->item_name_font_size, center_text, deduct_text_x, @@ -435,10 +441,6 @@ namespace ui { if (auto slot_settings = page_setting->slot_settings; !slot_settings.empty()) { const auto first_type = slot_settings.front()->type; - const ImU32 color = IM_COL32(mcm::get_slot_count_red(), - mcm::get_slot_count_green(), - mcm::get_slot_count_blue(), - page_setting->draw_setting->text_transparency); std::string slot_text; switch (first_type) { case slot_type::scroll: @@ -507,17 +509,16 @@ namespace ui { draw_setting->offset_text_x, draw_setting->offset_text_y, slot_text.c_str(), - color, + draw_setting->slot_count_transparency, + draw_setting->slot_count_red, + draw_setting->slot_count_green, + draw_setting->slot_count_blue, page_setting->count_font_size); } } } const auto ammo_handle = handle::ammo_handle::get_singleton(); if (const auto current_ammo = ammo_handle->get_current(); current_ammo && mcm::get_elden_demon_souls()) { - const ImU32 color = IM_COL32(mcm::get_slot_count_red(), - mcm::get_slot_count_green(), - mcm::get_slot_count_blue(), - mcm::get_text_transparency()); draw_slot(a_x, a_y, mcm::get_hud_arrow_image_scale_width(), @@ -541,7 +542,10 @@ namespace ui { mcm::get_arrow_slot_count_text_offset(), mcm::get_arrow_slot_count_text_offset(), std::to_string(current_ammo->item_count ? current_ammo->item_count : 0).c_str(), - color, + mcm::get_slot_count_transparency(), + mcm::get_slot_count_red(), + mcm::get_slot_count_green(), + mcm::get_slot_count_blue(), mcm::get_arrow_count_font_size()); if (current_ammo->highlight_slot) { @@ -723,10 +727,6 @@ namespace ui { draw_slots(x, y, settings); draw_keys(x, y, settings); if (mcm::get_draw_current_items_text() || mcm::get_draw_current_shout_text()) { - const ImU32 color = IM_COL32(mcm::get_current_items_red(), - mcm::get_current_items_green(), - mcm::get_current_items_blue(), - mcm::get_text_transparency()); if (mcm::get_draw_current_items_text()) { draw_text(x, y, @@ -735,7 +735,10 @@ namespace ui { 0.f, 0.f, handle::name_handle::get_singleton()->get_item_name_string().c_str(), - color, + mcm::get_current_items_transparency(), + mcm::get_current_items_red(), + mcm::get_current_items_green(), + mcm::get_current_items_blue(), mcm::get_current_items_font_size()); } if (mcm::get_draw_current_shout_text()) { @@ -746,7 +749,10 @@ namespace ui { 0.f, 0.f, handle::name_handle::get_singleton()->get_voice_name_string().c_str(), - color, + mcm::get_current_shout_transparency(), + mcm::get_current_items_red(), + mcm::get_current_items_green(), + mcm::get_current_items_blue(), mcm::get_current_shout_font_size()); } } diff --git a/src/ui/ui_renderer.h b/src/ui/ui_renderer.h index 4f3d1ce..dbaa583 100644 --- a/src/ui/ui_renderer.h +++ b/src/ui/ui_renderer.h @@ -30,7 +30,10 @@ namespace ui { float a_offset_extra_x, float a_offset_extra_y, const char* a_text, - ImU32 a_color = IM_COL32_WHITE, + uint32_t a_alpha, + uint32_t a_red, + uint32_t a_green, + uint32_t a_blue, float a_font_size = 20.f, bool a_center_text = true, bool a_deduct_text_x = false,