Misc internal UI fixes

This commit is contained in:
Kae 2023-06-28 01:07:55 +10:00
parent a1e428fafa
commit 59ab7dabe6
4 changed files with 23 additions and 12 deletions

View File

@ -23,5 +23,6 @@
"buttonHoverSound" : [ "/sfx/interface/button/hover.wav" ], "buttonHoverSound" : [ "/sfx/interface/button/hover.wav" ],
"buttonHoverOffSound" : [ "/sfx/interface/button/hover_off.wav" ], "buttonHoverOffSound" : [ "/sfx/interface/button/hover_off.wav" ],
"debugSpatialClearTime" : 0.0 "debugSpatialClearTime" : 0.0,
"debugOffset" : [32, 100]
} }

View File

@ -286,13 +286,15 @@ void InventoryPane::update() {
} }
if (ItemPtr swapSlot = inventory->swapSlotItem()) { if (ItemPtr swapSlot = inventory->swapSlotItem()) {
for (auto pair : m_itemGrids) { if (!PlayerInventory::itemAllowedInBag(swapSlot, m_selectedTab)) {
for (auto& pair : m_itemGrids) {
if (pair.first != m_selectedTab && PlayerInventory::itemAllowedInBag(swapSlot, pair.first)) { if (pair.first != m_selectedTab && PlayerInventory::itemAllowedInBag(swapSlot, pair.first)) {
selectTab(pair.first); selectTab(pair.first);
break; break;
} }
} }
} }
}
for (auto p : m_itemGrids) { for (auto p : m_itemGrids) {
p.second->updateItemState(); p.second->updateItemState();
@ -304,14 +306,14 @@ void InventoryPane::update() {
m_itemGrids[m_selectedTab]->clearChangedSlots(); m_itemGrids[m_selectedTab]->clearChangedSlots();
for (auto pair : m_newItemMarkers) { for (auto& pair : m_newItemMarkers) {
if (m_itemGrids[pair.first]->slotsChanged()) if (m_itemGrids[pair.first]->slotsChanged())
pair.second->show(); pair.second->show();
else else
pair.second->hide(); pair.second->hide();
} }
for (auto techOverlay : m_disabledTechOverlays) for (auto& techOverlay : m_disabledTechOverlays)
techOverlay->setVisibility(m_player->techOverridden()); techOverlay->setVisibility(m_player->techOverridden());
auto healthLabel = fetchChild<LabelWidget>("healthtext"); auto healthLabel = fetchChild<LabelWidget>("healthtext");
@ -408,6 +410,8 @@ void InventoryPane::update() {
context->playAudio(RandomSource().randFrom(m_putDownSounds)); context->playAudio(RandomSource().randFrom(m_putDownSounds));
m_currentSwapSlotItem = {}; m_currentSwapSlotItem = {};
} }
m_title = m_player->name();
} }
void InventoryPane::selectTab(String const& selected) { void InventoryPane::selectTab(String const& selected) {

View File

@ -40,7 +40,7 @@ TeamBar::TeamBar(MainInterface* mainInterface, UniverseClientPtr client) {
return; return;
auto position = jsonToVec2I(Root::singleton().assets()->json("/interface/windowconfig/teambar.config:selfMenuOffset")); auto position = jsonToVec2I(Root::singleton().assets()->json("/interface/windowconfig/teambar.config:selfMenuOffset"));
position[1] += windowHeight() / m_guiContext->interfaceScale(); 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); reader.construct(assets->json("/interface/windowconfig/teambar.config:paneLayout"), this);
@ -48,6 +48,7 @@ TeamBar::TeamBar(MainInterface* mainInterface, UniverseClientPtr client) {
m_healthBar = fetchChild<ProgressWidget>("healthBar"); m_healthBar = fetchChild<ProgressWidget>("healthBar");
m_energyBar = fetchChild<ProgressWidget>("energyBar"); m_energyBar = fetchChild<ProgressWidget>("energyBar");
m_foodBar = fetchChild<ProgressWidget>("foodBar"); m_foodBar = fetchChild<ProgressWidget>("foodBar");
m_nameLabel = fetchChild<LabelWidget>("name");
m_energyBarColor = jsonToColor(assets->json("/interface/windowconfig/teambar.config:energyBarColor")); m_energyBarColor = jsonToColor(assets->json("/interface/windowconfig/teambar.config:energyBarColor"));
m_energyBarRegenMixColor = jsonToColor(assets->json("/interface/windowconfig/teambar.config:energyBarRegenMixColor")); m_energyBarRegenMixColor = jsonToColor(assets->json("/interface/windowconfig/teambar.config:energyBarRegenMixColor"));
@ -58,8 +59,7 @@ TeamBar::TeamBar(MainInterface* mainInterface, UniverseClientPtr client) {
auto playerPortrait = fetchChild<PortraitWidget>("portrait"); auto playerPortrait = fetchChild<PortraitWidget>("portrait");
playerPortrait->setEntity(as<PortraitEntity>(m_client->mainPlayer())); playerPortrait->setEntity(as<PortraitEntity>(m_client->mainPlayer()));
fetchChild<LabelWidget>("name")->setText(m_client->mainPlayer()->name()); updatePlayerResources();
disableScissoring(); disableScissoring();
} }
@ -131,6 +131,8 @@ void TeamBar::updatePlayerResources() {
} else { } else {
m_energyBar->setColor(m_energyBarColor.mix(m_energyBarRegenMixColor, player->energyRegenBlockPercent())); m_energyBar->setColor(m_energyBarColor.mix(m_energyBarRegenMixColor, player->energyRegenBlockPercent()));
} }
m_nameLabel->setText(m_client->mainPlayer()->name());
} }
void TeamBar::inviteButton() { void TeamBar::inviteButton() {
@ -153,8 +155,9 @@ void TeamBar::buildTeamBar() {
int memberSize = assets->json("/interface/windowconfig/teambar.config:memberSize").toInt(); int memberSize = assets->json("/interface/windowconfig/teambar.config:memberSize").toInt();
int memberSpacing = assets->json("/interface/windowconfig/teambar.config:memberSpacing").toInt(); int memberSpacing = assets->json("/interface/windowconfig/teambar.config:memberSpacing").toInt();
Uuid myUuid = player->clientContext()->serverUuid();
for (auto member : teamClient->members()) { for (auto member : teamClient->members()) {
if (member.uuid == player->uuid()) { if (member.uuid == myUuid) {
memberIndex++; memberIndex++;
continue; continue;
} }
@ -357,7 +360,7 @@ void TeamMemberMenu::update() {
void TeamMemberMenu::updateWidgets() { void TeamMemberMenu::updateWidgets() {
bool isLeader = m_owner->m_client->teamClient()->isTeamLeader(); 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<ButtonWidget>("beamToShip")->setEnabled(m_canBeam); fetchChild<ButtonWidget>("beamToShip")->setEnabled(m_canBeam);
fetchChild<ButtonWidget>("makeLeader")->setEnabled(isLeader && !isSelf); fetchChild<ButtonWidget>("makeLeader")->setEnabled(isLeader && !isSelf);

View File

@ -5,6 +5,7 @@
#include "StarUuid.hpp" #include "StarUuid.hpp"
#include "StarMainInterfaceTypes.hpp" #include "StarMainInterfaceTypes.hpp"
#include "StarProgressWidget.hpp" #include "StarProgressWidget.hpp"
#include "StarLabelWidget.hpp"
namespace Star { namespace Star {
@ -103,6 +104,8 @@ private:
ProgressWidgetPtr m_energyBar; ProgressWidgetPtr m_energyBar;
ProgressWidgetPtr m_foodBar; ProgressWidgetPtr m_foodBar;
LabelWidgetPtr m_nameLabel;
Color m_energyBarColor; Color m_energyBarColor;
Color m_energyBarRegenMixColor; Color m_energyBarRegenMixColor;
Color m_energyBarUnusableColor; Color m_energyBarUnusableColor;