| 285 | } |
| 286 | |
| 287 | void 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 | |
| 308 | void MerchantPane::buy() { |
| 309 | if (m_buyTotal > 0 && m_player->inventory()->consumeCurrency("money", m_buyTotal)) { |