From 59ab7dabe6b24fe998764f23d0da15aa7d4af3f9 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Wed, 28 Jun 2023 01:07:55 +1000 Subject: [PATCH] Misc internal UI fixes --- assets/opensb/interface.config.patch | 3 ++- source/frontend/StarInventory.cpp | 16 ++++++++++------ source/frontend/StarTeamBar.cpp | 13 ++++++++----- source/frontend/StarTeamBar.hpp | 3 +++ 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/assets/opensb/interface.config.patch b/assets/opensb/interface.config.patch index b725639..8031217 100644 --- a/assets/opensb/interface.config.patch +++ b/assets/opensb/interface.config.patch @@ -23,5 +23,6 @@ "buttonHoverSound" : [ "/sfx/interface/button/hover.wav" ], "buttonHoverOffSound" : [ "/sfx/interface/button/hover_off.wav" ], - "debugSpatialClearTime" : 0.0 + "debugSpatialClearTime" : 0.0, + "debugOffset" : [32, 100] } \ No newline at end of file diff --git a/source/frontend/StarInventory.cpp b/source/frontend/StarInventory.cpp index e54f288..a5a17e1 100644 --- a/source/frontend/StarInventory.cpp +++ b/source/frontend/StarInventory.cpp @@ -286,10 +286,12 @@ void InventoryPane::update() { } if (ItemPtr swapSlot = inventory->swapSlotItem()) { - for (auto pair : m_itemGrids) { - if (pair.first != m_selectedTab && PlayerInventory::itemAllowedInBag(swapSlot, pair.first)) { - selectTab(pair.first); - break; + if (!PlayerInventory::itemAllowedInBag(swapSlot, m_selectedTab)) { + for (auto& pair : m_itemGrids) { + if (pair.first != m_selectedTab && PlayerInventory::itemAllowedInBag(swapSlot, pair.first)) { + selectTab(pair.first); + break; + } } } } @@ -304,14 +306,14 @@ void InventoryPane::update() { m_itemGrids[m_selectedTab]->clearChangedSlots(); - for (auto pair : m_newItemMarkers) { + for (auto& pair : m_newItemMarkers) { if (m_itemGrids[pair.first]->slotsChanged()) pair.second->show(); else pair.second->hide(); } - for (auto techOverlay : m_disabledTechOverlays) + for (auto& techOverlay : m_disabledTechOverlays) techOverlay->setVisibility(m_player->techOverridden()); auto healthLabel = fetchChild("healthtext"); @@ -408,6 +410,8 @@ void InventoryPane::update() { context->playAudio(RandomSource().randFrom(m_putDownSounds)); m_currentSwapSlotItem = {}; } + + m_title = m_player->name(); } void InventoryPane::selectTab(String const& selected) { diff --git a/source/frontend/StarTeamBar.cpp b/source/frontend/StarTeamBar.cpp index 6091d9c..8bdd3b3 100644 --- a/source/frontend/StarTeamBar.cpp +++ b/source/frontend/StarTeamBar.cpp @@ -40,7 +40,7 @@ TeamBar::TeamBar(MainInterface* mainInterface, UniverseClientPtr client) { return; auto position = jsonToVec2I(Root::singleton().assets()->json("/interface/windowconfig/teambar.config:selfMenuOffset")); position[1] += windowHeight() / m_guiContext->interfaceScale(); - showMemberMenu(m_client->mainPlayer()->uuid(), position); + showMemberMenu(m_client->mainPlayer()->clientContext()->serverUuid(), position); }); reader.construct(assets->json("/interface/windowconfig/teambar.config:paneLayout"), this); @@ -48,6 +48,7 @@ TeamBar::TeamBar(MainInterface* mainInterface, UniverseClientPtr client) { m_healthBar = fetchChild("healthBar"); m_energyBar = fetchChild("energyBar"); m_foodBar = fetchChild("foodBar"); + m_nameLabel = fetchChild("name"); m_energyBarColor = jsonToColor(assets->json("/interface/windowconfig/teambar.config:energyBarColor")); m_energyBarRegenMixColor = jsonToColor(assets->json("/interface/windowconfig/teambar.config:energyBarRegenMixColor")); @@ -58,8 +59,7 @@ TeamBar::TeamBar(MainInterface* mainInterface, UniverseClientPtr client) { auto playerPortrait = fetchChild("portrait"); playerPortrait->setEntity(as(m_client->mainPlayer())); - fetchChild("name")->setText(m_client->mainPlayer()->name()); - + updatePlayerResources(); disableScissoring(); } @@ -131,6 +131,8 @@ void TeamBar::updatePlayerResources() { } else { m_energyBar->setColor(m_energyBarColor.mix(m_energyBarRegenMixColor, player->energyRegenBlockPercent())); } + + m_nameLabel->setText(m_client->mainPlayer()->name()); } void TeamBar::inviteButton() { @@ -153,8 +155,9 @@ void TeamBar::buildTeamBar() { int memberSize = assets->json("/interface/windowconfig/teambar.config:memberSize").toInt(); int memberSpacing = assets->json("/interface/windowconfig/teambar.config:memberSpacing").toInt(); + Uuid myUuid = player->clientContext()->serverUuid(); for (auto member : teamClient->members()) { - if (member.uuid == player->uuid()) { + if (member.uuid == myUuid) { memberIndex++; continue; } @@ -357,7 +360,7 @@ void TeamMemberMenu::update() { void TeamMemberMenu::updateWidgets() { bool isLeader = m_owner->m_client->teamClient()->isTeamLeader(); - bool isSelf = m_owner->m_client->mainPlayer()->uuid() == m_memberUuid; + bool isSelf = m_owner->m_client->mainPlayer()->clientContext()->serverUuid() == m_memberUuid; fetchChild("beamToShip")->setEnabled(m_canBeam); fetchChild("makeLeader")->setEnabled(isLeader && !isSelf); diff --git a/source/frontend/StarTeamBar.hpp b/source/frontend/StarTeamBar.hpp index d781547..8273ab6 100644 --- a/source/frontend/StarTeamBar.hpp +++ b/source/frontend/StarTeamBar.hpp @@ -5,6 +5,7 @@ #include "StarUuid.hpp" #include "StarMainInterfaceTypes.hpp" #include "StarProgressWidget.hpp" +#include "StarLabelWidget.hpp" namespace Star { @@ -103,6 +104,8 @@ private: ProgressWidgetPtr m_energyBar; ProgressWidgetPtr m_foodBar; + LabelWidgetPtr m_nameLabel; + Color m_energyBarColor; Color m_energyBarRegenMixColor; Color m_energyBarUnusableColor;