Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[submodule "extern/GreenSock-AS2"]
path = extern/GreenSock-AS2
url = https://github.com/greensock/GreenSock-AS2
[submodule "extern/CommonLibVR"]
path = extern/CommonLibVR
url = https://github.com/alandtse/CommonLibVR.git
branch = ng
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* [Visual Studio Community 2022](https://visualstudio.microsoft.com/)
* Desktop development with C++
* [CommonLibSSE-NG](https://github.com/alandtse/CommonLibVR/tree/ng)
* Add the environment variable `CommonLibSSEPath_NG` with the value as the path to the folder containing CommonLibSSE-NG
* Add this as as an environment variable `CommonLibSSEPath`

## User Requirements
* [Address Library for SKSE](https://www.nexusmods.com/skyrimspecialedition/mods/32444)
Expand All @@ -17,6 +17,7 @@
```
git clone https://github.com/ersh1/TrueHUD/
cd TrueHUD
# pull commonlib /extern to override the path settings
git submodule init
git submodule update

Expand Down
1 change: 1 addition & 0 deletions extern/CommonLibVR
Submodule CommonLibVR added at 8593e4
9 changes: 5 additions & 4 deletions src/HUDHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ void HUDHandler::AddActorInfoBar(RE::ObjectRefHandle a_actorHandle)
return;
}

if (a_actorHandle.native_handle() == 0x100000) {
if (a_actorHandle.native_handle() == 0x100000 && !extAddedActorInfoBars.contains(a_actorHandle)) {
return;
}

Expand All @@ -363,7 +363,7 @@ void HUDHandler::AddActorInfoBar(RE::ObjectRefHandle a_actorHandle)

void HUDHandler::RemoveActorInfoBar(RE::ObjectRefHandle a_actorHandle, WidgetRemovalMode a_removalMode /*= kImmediate*/)
{
if (a_actorHandle) {
if (a_actorHandle && !extAddedActorInfoBars.contains(a_actorHandle)) {
AddHUDTask([a_actorHandle, a_removalMode](TrueHUDMenu& a_menu) {
a_menu.RemoveActorInfoBar(a_actorHandle, a_removalMode);
});
Expand All @@ -381,7 +381,7 @@ void HUDHandler::AddBossInfoBar(RE::ObjectRefHandle a_actorHandle)
return;
}

if (a_actorHandle.native_handle() == 0x100000) {
if (a_actorHandle.native_handle() == 0x100000 && !extAddedActorInfoBars.contains(a_actorHandle)) {
return;
}

Expand All @@ -394,7 +394,7 @@ void HUDHandler::AddBossInfoBar(RE::ObjectRefHandle a_actorHandle)

void HUDHandler::RemoveBossInfoBar(RE::ObjectRefHandle a_actorHandle, WidgetRemovalMode a_removalMode /*= kImmediate*/)
{
if (a_actorHandle) {
if (a_actorHandle && !extAddedActorInfoBars.contains(a_actorHandle)) {
AddHUDTask([a_actorHandle, a_removalMode](TrueHUDMenu& a_menu) {
a_menu.RemoveBossInfoBar(a_actorHandle, a_removalMode);
});
Expand Down Expand Up @@ -692,6 +692,7 @@ void HUDHandler::RemoveAllWidgets()
AddHUDTask([](TrueHUDMenu& a_menu) {
a_menu.RemoveAllWidgets();
});
extAddedActorInfoBars.clear();
}

bool HUDHandler::CheckActorForBoss(RE::ObjectRefHandle a_refHandle)
Expand Down
1 change: 1 addition & 0 deletions src/HUDHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class HUDHandler :
SpecialResourceCallback GetMaxSpecial = nullptr;
bool bSpecialMode;
bool bDisplaySpecialForPlayer;
std::set<RE::ObjectRefHandle, HandleComp<RE::TESObjectREFR>> extAddedActorInfoBars;

protected:
friend class TrueHUDMenu;
Expand Down
4 changes: 4 additions & 0 deletions src/ModAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ namespace Messaging
{
auto hudHandler = HUDHandler::GetSingleton();
if (hudHandler) {
hudHandler->extAddedActorInfoBars.insert(a_actorHandle);
hudHandler->AddActorInfoBar(a_actorHandle);
}
}
Expand All @@ -91,6 +92,7 @@ namespace Messaging
{
auto hudHandler = HUDHandler::GetSingleton();
if (hudHandler) {
hudHandler->extAddedActorInfoBars.erase(a_actorHandle);
hudHandler->RemoveActorInfoBar(a_actorHandle, static_cast<TRUEHUD_API::WidgetRemovalMode>(a_removalMode));
}
}
Expand All @@ -99,6 +101,7 @@ namespace Messaging
{
auto hudHandler = HUDHandler::GetSingleton();
if (hudHandler) {
hudHandler->extAddedActorInfoBars.insert(a_actorHandle);
hudHandler->AddBossInfoBar(a_actorHandle);
}
}
Expand All @@ -107,6 +110,7 @@ namespace Messaging
{
auto hudHandler = HUDHandler::GetSingleton();
if (hudHandler) {
hudHandler->extAddedActorInfoBars.erase(a_actorHandle);
hudHandler->RemoveBossInfoBar(a_actorHandle, static_cast<TRUEHUD_API::WidgetRemovalMode>(a_removalMode));
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/Scaleform/TrueHUDMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ namespace std
};
}

template <class T>
struct HandleComp
{
bool operator()(const RE::BSPointerHandle<T>& a_lhs, const RE::BSPointerHandle<T>& a_rhs) const
{
return std::hash<RE::BSPointerHandle<T>>()(a_lhs) < std::hash<RE::BSPointerHandle<T>>()(a_rhs);
}
};

namespace Scaleform
{
class DebugLine
Expand Down
12 changes: 7 additions & 5 deletions src/Widgets/InfoBarBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ namespace Scaleform
auto softTargetHandle = hudMenu->GetSoftTarget();

bool bIsTeammate = Utils::IsPlayerTeammateOrSummon(actor);
bool bIsPlayer = actor == playerCharacter;
bool bExtManaged = HUDHandler::GetSingleton()->extAddedActorInfoBars.contains(actor->GetHandle());

TargetType targetType;
if (targetHandle && _refHandle == targetHandle) {
Expand All @@ -125,7 +127,7 @@ namespace Scaleform
targetType = kTarget;
} else if (actor->IsHostileToActor(playerCharacter)) {
targetType = kEnemy;
} else if (bIsTeammate) {
} else if (bIsTeammate || bIsPlayer) {
targetType = kTeammate;
} else {
targetType = kOther;
Expand Down Expand Up @@ -153,9 +155,9 @@ namespace Scaleform

const auto shouldBarBeDisplayed = [&]() {
if (_barType == BarType::kBossInfoBar) {
return !bIsTeammate && actor->IsInCombat() && actor->IsHostileToActor(playerCharacter);
return (bExtManaged) || (!bIsTeammate && actor->IsInCombat() && actor->IsHostileToActor(playerCharacter));
} else if (_barType == BarType::kActorInfoBar) {
if (targetType > kTarget && !actor->IsInCombat()) {
if (!bExtManaged && targetType > kTarget && !actor->IsInCombat()) {
return false;
}
switch (targetType) {
Expand All @@ -181,7 +183,7 @@ namespace Scaleform
SetWidgetState(WidgetStateMode::kHide);
} else {
bool r8 = false;
bool bHasLOS = targetType == kTarget ? true : playerCharacter->HasLineOfSight(actor, r8);
bool bHasLOS = targetType == kTarget || bExtManaged || bIsPlayer ? true : playerCharacter->HasLineOfSight(actor, r8);
bool bVisible = bHasLOS && !(actor->AsActorValueOwner()->GetActorValue(RE::ActorValue::kInvisibility) > 0);
if (bVisible) {
SetWidgetState(WidgetStateMode::kShow);
Expand All @@ -197,7 +199,7 @@ namespace Scaleform

uint32_t levelColor = Settings::uDefaultColor;
uint32_t outlineColor = Settings::uDefaultColorOutline;
if (bIsTeammate) {
if (bIsTeammate || bIsPlayer) {
levelColor = Settings::uTeammateColor;
outlineColor = Settings::uTeammateColorOutline;
} else if (playerLevel - targetLevel > Settings::uInfoBarLevelThreshold) {
Expand Down
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ extern "C" DLLEXPORT constinit auto SKSEPlugin_Version = []() {
v.PluginVersion(Plugin::VERSION);
v.PluginName(Plugin::NAME);
v.AuthorName("Ersh");
v.UsesAddressLibrary(true);
v.UsesAddressLibrary();
v.CompatibleVersions({ SKSE::RUNTIME_SSE_LATEST });
v.HasNoStructUse(true);
v.UsesNoStructs();

return v;
}();
Expand Down