Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
* added: null check to avoid ctd
* adjusted: do no add items to draw list if alpha is 0
  • Loading branch information
mlthelama committed Apr 5, 2023
1 parent 6a6848d commit fa99130
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 4 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")
set(VERSION 1.4.1.0)
set(VERSION 1.4.2.0)

# ---- Options ----

Expand Down
1 change: 0 additions & 1 deletion src/PCH.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once

#define STB_IMAGE_IMPLEMENTATION
#define IMGUI_DEFINE_MATH_OPERATORS
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
Expand Down
10 changes: 10 additions & 0 deletions src/processing/game_menu_setting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@

namespace processing {
void game_menu_setting::elden_souls_config(RE::TESForm* a_form, position_type a_position, bool a_overwrite) {
if (!a_form) {
logger::warn("form is null. return."sv);
return;
}

std::vector<data_helper*> data;

write_notification(fmt::format("Elden Souls Config, Position {}, overwrite {}"sv,
Expand Down Expand Up @@ -66,6 +71,11 @@ namespace processing {
logger::trace("Setting done. return.");
}
void game_menu_setting::default_config(RE::TESForm*& a_form, position_type a_position_type, bool a_left) {
if (!a_form) {
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 {}",
Expand Down
5 changes: 5 additions & 0 deletions src/processing/set_setting_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,11 @@ namespace processing {
}

void set_setting_data::default_remove(RE::TESForm* a_form) {
if (!a_form) {
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) {
Expand Down
20 changes: 20 additions & 0 deletions src/ui/ui_renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ namespace ui {
const float a_scale_x,
const float a_scale_y,
const uint32_t a_alpha) {
if (a_alpha == 0) {
return;
}

constexpr auto angle = 0.f;

const auto center = ImVec2(a_x, a_y);
Expand Down Expand Up @@ -323,6 +327,10 @@ namespace ui {
const uint32_t a_modify,
const uint32_t a_alpha,
float a_duration) {
if (a_alpha == 0) {
return;
}

logger::trace("starting inited animation");
constexpr auto angle = 0.0f;

Expand Down Expand Up @@ -560,6 +568,10 @@ namespace ui {
const float a_offset_x,
const float a_offset_y,
const uint32_t a_alpha) {
if (a_alpha == 0) {
return;
}

constexpr auto angle = 0.f;

const auto center = ImVec2(a_x + a_offset_x, a_y + a_offset_y);
Expand Down Expand Up @@ -616,6 +628,10 @@ namespace ui {
const float a_offset_y,
const icon_image_type a_type,
const uint32_t a_alpha) {
if (a_alpha == 0) {
return;
}

constexpr auto angle = 0.f;

const auto center = ImVec2(a_x + a_offset_x, a_y + a_offset_y);
Expand All @@ -637,6 +653,10 @@ namespace ui {
const float a_offset_y,
const uint32_t a_key,
const uint32_t a_alpha) {
if (a_alpha == 0) {
return;
}

constexpr auto angle = 0.f;

const auto center = ImVec2(a_x + a_offset_x, a_y + a_offset_y);
Expand Down
2 changes: 1 addition & 1 deletion src/util/constant.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ namespace util {
0x0003EADE },
{ RE::ActorValue::kStamina, 0x00039BE8 },
{ RE::ActorValue::kMagicka, 0x0003EAE1 } };

constexpr RE::FormID bound_arrow = 0x0010b0a7;
}
5 changes: 5 additions & 0 deletions src/util/helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ namespace util {
}

bool helper::is_two_handed(RE::TESForm*& a_form) {
if (!a_form) {
logger::warn("return false, form is null."sv);
return false;
}

//check if two-handed
if (a_form->Is(RE::FormType::Spell)) {
if (const auto spell = a_form->As<RE::SpellItem>(); spell->IsTwoHanded()) {
Expand Down
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.4.1",
"version-string": "1.4.2",
"description": "hud element for skyrim",
"homepage": "https://github.com/mlthelama/LamasTinyHUD",
"license": "GPL-2.0-or-later",
Expand Down

0 comments on commit fa99130

Please sign in to comment.