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

Method setupWidget

source/frontend/StarMerchantInterface.cpp:235–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

233}
234
235void MerchantPane::setupWidget(WidgetPtr const& widget, Json const& itemConfig) {
236 auto& root = Root::singleton();
237 auto assets = root.assets();
238 ItemPtr item = root.itemDatabase()->itemShared(ItemDescriptor(itemConfig.get("item")));
239
240 String name = item->friendlyName();
241 if (item->count() > 1)
242 name = strf("{} (x{})", name, item->count());
243
244 auto itemName = widget->fetchChild<LabelWidget>("itemName");
245 itemName->setText(name);
246
247 unsigned price = ceil(itemConfig.getInt("price", item->price()) * m_buyFactor);
248 widget->setLabel("priceLabel", toString(price));
249 widget->setData(price);
250
251 bool unavailable = price > m_player->currency("money");
252 auto unavailableoverlay = widget->fetchChild<ImageWidget>("unavailableoverlay");
253 if (unavailable) {
254 itemName->setColor(Color::Gray);
255 unavailableoverlay->show();
256 } else {
257 itemName->setColor(Color::White);
258 unavailableoverlay->hide();
259 }
260
261 widget->fetchChild<ItemSlotWidget>("itemIcon")->setItem(item);
262 widget->show();
263}
264
265void MerchantPane::updateSelection() {
266 if (m_selectedIndex != m_itemGuiList->selectedItem()) {

Callers

nothing calls this directly

Calls 15

singletonClass · 0.85
ItemDescriptorClass · 0.85
strfFunction · 0.85
toStringFunction · 0.85
assetsMethod · 0.80
itemSharedMethod · 0.80
itemDatabaseMethod · 0.80
getIntMethod · 0.80
setLabelMethod · 0.80
getMethod · 0.45
friendlyNameMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected