fix: crafting interfaces not working with new middle-click opening
This commit is contained in:
parent
d76d217901
commit
0f9a200e6b
@ -110,7 +110,7 @@ InventoryPane::InventoryPane(MainInterface* parent, PlayerPtr player, ContainerI
|
|||||||
auto actionData = sourceItem->instanceValue("interactData", Json());
|
auto actionData = sourceItem->instanceValue("interactData", Json());
|
||||||
if (actionData.isType(Json::Type::Object))
|
if (actionData.isType(Json::Type::Object))
|
||||||
actionData = actionData.set("openWithInventory", false);
|
actionData = actionData.set("openWithInventory", false);
|
||||||
InteractAction action(actionType, m_player->entityId(), actionData);
|
InteractAction action(actionType, NullEntityId, actionData);
|
||||||
m_player->interact(action);
|
m_player->interact(action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -199,10 +199,7 @@ bool MainInterface::escapeDialogOpen() const {
|
|||||||
void MainInterface::openCraftingWindow(Json const& config, EntityId sourceEntityId) {
|
void MainInterface::openCraftingWindow(Json const& config, EntityId sourceEntityId) {
|
||||||
if (m_craftingWindow && m_paneManager.isDisplayed(m_craftingWindow)) {
|
if (m_craftingWindow && m_paneManager.isDisplayed(m_craftingWindow)) {
|
||||||
m_paneManager.dismissPane(m_craftingWindow);
|
m_paneManager.dismissPane(m_craftingWindow);
|
||||||
bool fromPlayer = false;
|
if (sourceEntityId != NullEntityId && m_craftingWindow->sourceEntityId() == sourceEntityId) {
|
||||||
if (auto player = m_client->mainPlayer())
|
|
||||||
fromPlayer = player->inWorld() && player->entityId() == sourceEntityId;
|
|
||||||
if (m_craftingWindow->sourceEntityId() == sourceEntityId) {
|
|
||||||
m_craftingWindow.reset();
|
m_craftingWindow.reset();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -218,10 +215,7 @@ void MainInterface::openCraftingWindow(Json const& config, EntityId sourceEntity
|
|||||||
void MainInterface::openMerchantWindow(Json const& config, EntityId sourceEntityId) {
|
void MainInterface::openMerchantWindow(Json const& config, EntityId sourceEntityId) {
|
||||||
if (m_merchantWindow && m_paneManager.isDisplayed(m_merchantWindow)) {
|
if (m_merchantWindow && m_paneManager.isDisplayed(m_merchantWindow)) {
|
||||||
m_paneManager.dismissPane(m_merchantWindow);
|
m_paneManager.dismissPane(m_merchantWindow);
|
||||||
bool fromPlayer = false;
|
if (sourceEntityId != NullEntityId && m_merchantWindow->sourceEntityId() == sourceEntityId) {
|
||||||
if (auto player = m_client->mainPlayer())
|
|
||||||
fromPlayer = player->inWorld() && player->entityId() == sourceEntityId;
|
|
||||||
if (!fromPlayer && m_merchantWindow->sourceEntityId() == sourceEntityId) {
|
|
||||||
m_merchantWindow.reset();
|
m_merchantWindow.reset();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -426,19 +420,19 @@ void MainInterface::handleInteractAction(InteractAction interactAction) {
|
|||||||
} else if (interactAction.type == InteractActionType::SitDown) {
|
} else if (interactAction.type == InteractActionType::SitDown) {
|
||||||
m_client->mainPlayer()->lounge(interactAction.entityId, interactAction.data.toUInt());
|
m_client->mainPlayer()->lounge(interactAction.entityId, interactAction.data.toUInt());
|
||||||
} else if (interactAction.type == InteractActionType::OpenCraftingInterface) {
|
} else if (interactAction.type == InteractActionType::OpenCraftingInterface) {
|
||||||
if (!world->entity(interactAction.entityId))
|
if (interactAction.entityId != NullEntityId && !world->entity(interactAction.entityId))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
openCraftingWindow(interactAction.data, interactAction.entityId);
|
openCraftingWindow(interactAction.data, interactAction.entityId);
|
||||||
} else if (interactAction.type == InteractActionType::OpenSongbookInterface) {
|
} else if (interactAction.type == InteractActionType::OpenSongbookInterface) {
|
||||||
m_paneManager.displayRegisteredPane(MainInterfacePanes::Songbook);
|
m_paneManager.displayRegisteredPane(MainInterfacePanes::Songbook);
|
||||||
} else if (interactAction.type == InteractActionType::OpenNpcCraftingInterface) {
|
} else if (interactAction.type == InteractActionType::OpenNpcCraftingInterface) {
|
||||||
if (!world->entity(interactAction.entityId))
|
if (interactAction.entityId != NullEntityId && !world->entity(interactAction.entityId))
|
||||||
return;
|
return;
|
||||||
|
// wait, this is literally the exact same as OpenCraftingInterface. what the fuck? lol
|
||||||
openCraftingWindow(interactAction.data, interactAction.entityId);
|
openCraftingWindow(interactAction.data, interactAction.entityId);
|
||||||
} else if (interactAction.type == InteractActionType::OpenMerchantInterface) {
|
} else if (interactAction.type == InteractActionType::OpenMerchantInterface) {
|
||||||
if (!world->entity(interactAction.entityId))
|
if (interactAction.entityId != NullEntityId && !world->entity(interactAction.entityId))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
openMerchantWindow(interactAction.data, interactAction.entityId);
|
openMerchantWindow(interactAction.data, interactAction.entityId);
|
||||||
|
@ -118,6 +118,7 @@ void MerchantPane::dismissed() {
|
|||||||
for (auto unsold : m_itemBag->takeAll())
|
for (auto unsold : m_itemBag->takeAll())
|
||||||
m_player->giveItem(unsold);
|
m_player->giveItem(unsold);
|
||||||
|
|
||||||
|
if (m_sourceEntityId != NullEntityId)
|
||||||
m_worldClient->sendEntityMessage(m_sourceEntityId, "onMerchantClosed");
|
m_worldClient->sendEntityMessage(m_sourceEntityId, "onMerchantClosed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +142,7 @@ PanePtr MerchantPane::createTooltip(Vec2I const& screenPosition) {
|
|||||||
void MerchantPane::update(float dt) {
|
void MerchantPane::update(float dt) {
|
||||||
Pane::update(dt);
|
Pane::update(dt);
|
||||||
|
|
||||||
if (!m_worldClient->playerCanReachEntity(m_sourceEntityId))
|
if (m_sourceEntityId != NullEntityId && !m_worldClient->playerCanReachEntity(m_sourceEntityId))
|
||||||
dismiss();
|
dismiss();
|
||||||
|
|
||||||
if (m_refreshTimer.wrapTick()) {
|
if (m_refreshTimer.wrapTick()) {
|
||||||
@ -315,6 +316,7 @@ void MerchantPane::buy() {
|
|||||||
auto reportItem = m_selectedItem->clone();
|
auto reportItem = m_selectedItem->clone();
|
||||||
reportItem->setCount(reportItem->count() * m_buyCount, true);
|
reportItem->setCount(reportItem->count() * m_buyCount, true);
|
||||||
auto buySummary = JsonObject{{"item", reportItem->descriptor().toJson()}, {"total", m_buyTotal}};
|
auto buySummary = JsonObject{{"item", reportItem->descriptor().toJson()}, {"total", m_buyTotal}};
|
||||||
|
if (m_sourceEntityId != NullEntityId)
|
||||||
m_worldClient->sendEntityMessage(m_sourceEntityId, "onBuy", {buySummary});
|
m_worldClient->sendEntityMessage(m_sourceEntityId, "onBuy", {buySummary});
|
||||||
|
|
||||||
auto& guiContext = GuiContext::singleton();
|
auto& guiContext = GuiContext::singleton();
|
||||||
|
Loading…
Reference in New Issue
Block a user