Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'source/frontend')
-rw-r--r--source/frontend/StarClientCommandProcessor.cpp17
-rw-r--r--source/frontend/StarClientCommandProcessor.hpp1
-rw-r--r--source/frontend/StarInventory.cpp13
-rw-r--r--source/frontend/StarInventory.hpp1
-rw-r--r--source/frontend/StarTeamBar.cpp6
5 files changed, 30 insertions, 8 deletions
diff --git a/source/frontend/StarClientCommandProcessor.cpp b/source/frontend/StarClientCommandProcessor.cpp
index ec5b27c..c7a510f 100644
--- a/source/frontend/StarClientCommandProcessor.cpp
+++ b/source/frontend/StarClientCommandProcessor.cpp
@@ -50,7 +50,8 @@ ClientCommandProcessor::ClientCommandProcessor(UniverseClientPtr universeClient,
{"giveessentialitem", bind(&ClientCommandProcessor::giveEssentialItem, this, _1)},
{"maketechavailable", bind(&ClientCommandProcessor::makeTechAvailable, this, _1)},
{"enabletech", bind(&ClientCommandProcessor::enableTech, this, _1)},
- {"upgradeship", bind(&ClientCommandProcessor::upgradeShip, this, _1)}
+ {"upgradeship", bind(&ClientCommandProcessor::upgradeShip, this, _1)},
+ {"swap", bind(&ClientCommandProcessor::swap, this, _1)}
};
}
@@ -304,7 +305,7 @@ String ClientCommandProcessor::playTime() {
String ClientCommandProcessor::deathCount() {
auto deaths = m_universeClient->mainPlayer()->log()->deathCount();
- return strf("Total deaths: {}{}", deaths, deaths == 0 ? ". Well done!" : "");
+ return deaths ? strf("Total deaths: {}", deaths) : "Total deaths: 0. Well done!";
}
String ClientCommandProcessor::cinema(String const& argumentsString) {
@@ -408,4 +409,16 @@ String ClientCommandProcessor::upgradeShip(String const& argumentsString) {
return strf("Upgraded ship");
}
+String ClientCommandProcessor::swap(String const& argumentsString) {
+ auto arguments = m_parser.tokenizeToStringList(argumentsString);
+
+ if (arguments.size() == 0)
+ return "Not enouch arguments to /swap";
+
+ if (m_universeClient->switchPlayer(arguments[0]))
+ return "Successfully swapped player";
+ else
+ return "Failed to swap player";
+}
+
}
diff --git a/source/frontend/StarClientCommandProcessor.hpp b/source/frontend/StarClientCommandProcessor.hpp
index e9e8962..7446e70 100644
--- a/source/frontend/StarClientCommandProcessor.hpp
+++ b/source/frontend/StarClientCommandProcessor.hpp
@@ -58,6 +58,7 @@ private:
String makeTechAvailable(String const& argumentsString);
String enableTech(String const& argumentsString);
String upgradeShip(String const& argumentsString);
+ String swap(String const& argumentsString);
UniverseClientPtr m_universeClient;
CinematicPtr m_cinematicOverlay;
diff --git a/source/frontend/StarInventory.cpp b/source/frontend/StarInventory.cpp
index a7626a7..a983f3e 100644
--- a/source/frontend/StarInventory.cpp
+++ b/source/frontend/StarInventory.cpp
@@ -210,7 +210,7 @@ bool InventoryPane::giveContainerResult(ContainerResult result) {
if (!m_expectingSwap)
return false;
- for (auto item : result) {
+ for (auto& item : result) {
auto inv = m_player->inventory();
m_player->triggerPickupEvents(item);
@@ -224,18 +224,25 @@ bool InventoryPane::giveContainerResult(ContainerResult result) {
}
void InventoryPane::updateItems() {
- for (auto p : m_itemGrids)
+ for (auto& p : m_itemGrids)
p.second->updateItemState();
}
bool InventoryPane::containsNewItems() const {
- for (auto p : m_itemGrids) {
+ for (auto& p : m_itemGrids) {
if (p.second->slotsChanged())
return true;
}
return false;
}
+void InventoryPane::clearChangedSlots() {
+ for (auto& p : m_itemGrids) {
+ p.second->updateItemState();
+ p.second->clearChangedSlots();
+ }
+}
+
void InventoryPane::update(float dt) {
auto inventory = m_player->inventory();
auto context = Widget::context();
diff --git a/source/frontend/StarInventory.hpp b/source/frontend/StarInventory.hpp
index cb5deed..807e2ec 100644
--- a/source/frontend/StarInventory.hpp
+++ b/source/frontend/StarInventory.hpp
@@ -33,6 +33,7 @@ public:
// this is a little hacky and should probably be checked in the player inventory instead
void updateItems();
bool containsNewItems() const;
+ void clearChangedSlots();
protected:
virtual void update(float dt) override;
diff --git a/source/frontend/StarTeamBar.cpp b/source/frontend/StarTeamBar.cpp
index 192edfa..a378040 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()->clientContext()->serverUuid(), position);
+ showMemberMenu(m_client->mainPlayer()->clientContext()->playerUuid(), position);
});
reader.construct(assets->json("/interface/windowconfig/teambar.config:paneLayout"), this);
@@ -155,7 +155,7 @@ 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();
+ Uuid myUuid = player->clientContext()->playerUuid();
for (auto member : teamClient->members()) {
if (member.uuid == myUuid) {
memberIndex++;
@@ -360,7 +360,7 @@ void TeamMemberMenu::update(float dt) {
void TeamMemberMenu::updateWidgets() {
bool isLeader = m_owner->m_client->teamClient()->isTeamLeader();
- bool isSelf = m_owner->m_client->mainPlayer()->clientContext()->serverUuid() == m_memberUuid;
+ bool isSelf = m_owner->m_client->mainPlayer()->clientContext()->playerUuid() == m_memberUuid;
fetchChild<ButtonWidget>("beamToShip")->setEnabled(m_canBeam);
fetchChild<ButtonWidget>("makeLeader")->setEnabled(isLeader && !isSelf);