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

Method updateCraftButtons

source/frontend/StarCraftingInterface.cpp:305–327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

303}
304
305void CraftingPane::updateCraftButtons() {
306 auto normalizedBag = m_player->inventory()->availableItems();
307 auto availableCurrencies = m_player->inventory()->availableCurrencies();
308
309 auto recipe = recipeFromSelectedWidget();
310 bool recipeAvailable = !recipe.isNull() && (m_player->isAdmin() || ItemDatabase::canMakeRecipe(recipe, normalizedBag, availableCurrencies));
311
312 fetchChild<ButtonWidget>("btnCraft")->setEnabled(recipeAvailable);
313 if (auto spinCountUp = fetchChild<ButtonWidget>("spinCount.up"))
314 spinCountUp->setEnabled(recipeAvailable);
315 if (auto spinCountDown = fetchChild<ButtonWidget>("spinCount.down"))
316 spinCountDown->setEnabled(recipeAvailable);
317
318 if (auto stopCraftButton = fetchChild<ButtonWidget>("btnStopCraft")) {
319 stopCraftButton->setVisibility(m_crafting);
320 fetchChild<ButtonWidget>("btnCraft")->setVisibility(!m_crafting);
321 }
322
323 if (auto upgradeButton = fetchChild<ButtonWidget>("btnUpgrade")) {
324 bool canUpgrade = (m_upgradeRecipe && (m_player->isAdmin() || ItemDatabase::canMakeRecipe(*m_upgradeRecipe, normalizedBag, availableCurrencies)));
325 upgradeButton->setEnabled(canUpgrade);
326 }
327}
328
329void CraftingPane::updateAvailableRecipes() {
330 m_recipeAutorefreshCooldown = 30;

Callers

nothing calls this directly

Calls 7

availableItemsMethod · 0.80
inventoryMethod · 0.80
availableCurrenciesMethod · 0.80
setVisibilityMethod · 0.80
isNullMethod · 0.45
isAdminMethod · 0.45
setEnabledMethod · 0.45

Tested by

no test coverage detected