diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-03-27 16:00:13 +1100 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-03-27 16:00:13 +1100 |
commit | 888cde79ef8f6d1b008e86207b41e1fd686c7636 (patch) | |
tree | 576e23c94d227f76bec06cd0357809c703dc4c53 /source/frontend/StarMainInterface.cpp | |
parent | c484fab32dcac655164f082805d1d55d1d058f2f (diff) |
feat: middle click objects in the inventory to open their interface
makes carrying around shop objects easier
might need to restrict the allowed interaction types more, as some may break due to the source entity being the player
Diffstat (limited to 'source/frontend/StarMainInterface.cpp')
-rw-r--r-- | source/frontend/StarMainInterface.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/source/frontend/StarMainInterface.cpp b/source/frontend/StarMainInterface.cpp index 0d0cb5f..4098705 100644 --- a/source/frontend/StarMainInterface.cpp +++ b/source/frontend/StarMainInterface.cpp @@ -199,6 +199,9 @@ bool MainInterface::escapeDialogOpen() const { void MainInterface::openCraftingWindow(Json const& config, EntityId sourceEntityId) { if (m_craftingWindow && m_paneManager.isDisplayed(m_craftingWindow)) { m_paneManager.dismissPane(m_craftingWindow); + bool fromPlayer = false; + if (auto player = m_client->mainPlayer()) + fromPlayer = player->inWorld() && player->entityId() == sourceEntityId; if (m_craftingWindow->sourceEntityId() == sourceEntityId) { m_craftingWindow.reset(); return; @@ -215,21 +218,27 @@ void MainInterface::openCraftingWindow(Json const& config, EntityId sourceEntity void MainInterface::openMerchantWindow(Json const& config, EntityId sourceEntityId) { if (m_merchantWindow && m_paneManager.isDisplayed(m_merchantWindow)) { m_paneManager.dismissPane(m_merchantWindow); - if (m_merchantWindow->sourceEntityId() == sourceEntityId) { + bool fromPlayer = false; + if (auto player = m_client->mainPlayer()) + fromPlayer = player->inWorld() && player->entityId() == sourceEntityId; + if (!fromPlayer && m_merchantWindow->sourceEntityId() == sourceEntityId) { m_merchantWindow.reset(); return; } } + bool openWithInventory = config.getBool("openWithInventory", true); m_merchantWindow = make_shared<MerchantPane>(m_client->worldClient(), m_client->mainPlayer(), config, sourceEntityId); m_paneManager.displayPane(PaneLayer::Window, m_merchantWindow, - [this](PanePtr const&) { + [this, openWithInventory](PanePtr const&) { if (auto player = m_client->mainPlayer()) player->clearSwap(); - m_paneManager.dismissRegisteredPane(MainInterfacePanes::Inventory); + if (openWithInventory) + m_paneManager.dismissRegisteredPane(MainInterfacePanes::Inventory); }); - m_paneManager.displayRegisteredPane(MainInterfacePanes::Inventory); + if (openWithInventory) + m_paneManager.displayRegisteredPane(MainInterfacePanes::Inventory); m_paneManager.bringPaneAdjacent(m_paneManager.registeredPane(MainInterfacePanes::Inventory), m_merchantWindow, Root::singleton().assets()->json("/interface.config:bringAdjacentWindowGap").toFloat()); |