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

Method updateBuyTotal

source/frontend/StarMerchantInterface.cpp:287–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

285}
286
287void MerchantPane::updateBuyTotal() {
288 if (auto selected = m_itemGuiList->selectedWidget())
289 m_buyTotal = selected->data().toUInt() * m_buyCount;
290 else
291 m_buyTotal = 0;
292
293 m_buyTotalLabel->setText(toString(m_buyTotal));
294
295 if (m_selectedIndex != NPos && m_buyCount > 0)
296 m_buyButton->enable();
297 else
298 m_buyButton->disable();
299
300 if (m_buyTotal > (int)m_player->inventory()->currency("money")) {
301 m_buyTotalLabel->setColor(Color::Red);
302 m_buyButton->disable();
303 } else {
304 m_buyTotalLabel->setColor(Color::White);
305 }
306}
307
308void MerchantPane::buy() {
309 if (m_buyTotal > 0 && m_player->inventory()->consumeCurrency("money", m_buyTotal)) {

Callers

nothing calls this directly

Calls 10

toStringFunction · 0.85
selectedWidgetMethod · 0.80
toUIntMethod · 0.80
inventoryMethod · 0.80
dataMethod · 0.45
setTextMethod · 0.45
enableMethod · 0.45
disableMethod · 0.45
currencyMethod · 0.45
setColorMethod · 0.45

Tested by

no test coverage detected