MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / swapSlot

Method swapSlot

source/frontend/StarMerchantInterface.cpp:178–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

176}
177
178void MerchantPane::swapSlot() {
179 ItemPtr source = m_player->inventory()->swapSlotItem();
180 auto inv = m_player->inventory();
181 if (context()->shiftHeld()) {
182 if (m_itemGrid->selectedItem()) {
183 auto remainder = inv->addItems(m_itemBag->takeItems(m_itemGrid->selectedIndex()));
184 if (remainder && !remainder->empty())
185 m_itemBag->setItem(m_itemGrid->selectedIndex(), remainder);
186 }
187 } else {
188 if (auto heldItem = m_player->inventory()->swapSlotItem())
189 inv->setSwapSlotItem(m_itemBag->swapItems(m_itemGrid->selectedIndex(), heldItem));
190 else
191 inv->setSwapSlotItem(m_itemBag->takeItems(m_itemGrid->selectedIndex()));
192 }
193}
194
195void MerchantPane::buildItemList() {
196 m_itemGuiList->clear();

Callers

nothing calls this directly

Calls 11

swapSlotItemMethod · 0.80
inventoryMethod · 0.80
shiftHeldMethod · 0.80
selectedIndexMethod · 0.80
setSwapSlotItemMethod · 0.80
selectedItemMethod · 0.45
addItemsMethod · 0.45
takeItemsMethod · 0.45
emptyMethod · 0.45
setItemMethod · 0.45
swapItemsMethod · 0.45

Tested by

no test coverage detected