MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / refreshSkillButtonState

Method refreshSkillButtonState

source/modes/GameMode.cpp:1437–1561  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1435}
1436
1437void GameMode::refreshSkillButtonState(const std::string& skillButtonName, const std::string& castButtonName,
1438 const std::string& skillProgressBarName, SkillType resType)
1439{
1440 // Determine the widget name and button accordingly to the SkillType given
1441 Seat* localPlayerSeat = mGameMap->getLocalPlayer()->getSeat();
1442 bool isDone = localPlayerSeat->isSkillDone(resType);
1443 bool isAllowed = true;
1444 uint32_t queueNumber = 0;
1445 if(!isDone)
1446 {
1447 const std::vector<SkillType>& skillNotAllowed = localPlayerSeat->getSkillNotAllowed();
1448 if(std::find(skillNotAllowed.begin(), skillNotAllowed.end(), resType) != skillNotAllowed.end())
1449 {
1450 // Skill is not allowed
1451 isAllowed = false;
1452 }
1453 else
1454 {
1455 // If we are currently changing the skill window, we display the temporary
1456 // modified pending list
1457 if(mIsSkillWindowOpen)
1458 {
1459 uint32_t cpt = 1;
1460 for (SkillType pendingRes : mSkillPending)
1461 {
1462 if (pendingRes == resType)
1463 {
1464 queueNumber = cpt;
1465 break;
1466 }
1467 ++cpt;
1468 }
1469 }
1470 else
1471 {
1472 queueNumber = localPlayerSeat->isSkillPending(resType);
1473 }
1474 }
1475 }
1476
1477 const std::string okIcon = "OpenDungeonsIcons/CheckIcon";
1478 const std::string pendingIcon = "OpenDungeonsIcons/HourglassIcon";
1479 const std::string abortIcon = "OpenDungeonsIcons/AbortIcon";
1480 const std::string workIcon = "OpenDungeonsIcons/CogIcon";
1481
1482 float curSkillProgress;
1483 SkillType curResType;
1484 if(!localPlayerSeat->getCurrentSkillProgress(curResType, curSkillProgress))
1485 {
1486 curResType = SkillType::nullSkillType;
1487 }
1488
1489 // We show/hide the icons depending on available skills
1490 CEGUI::Window* guiSheet = mRootWindow;
1491 CEGUI::Window* skillsWindow = guiSheet->getChild("SkillTreeWindow/Skills");
1492
1493 CEGUI::Window* skillButton = skillsWindow->getChild(skillButtonName);
1494 CEGUI::ProgressBar* skillProgressBar =

Callers

nothing calls this directly

Calls 10

getLocalPlayerMethod · 0.80
isSkillDoneMethod · 0.80
isSkillPendingMethod · 0.80
showMethod · 0.80
setTextMethod · 0.80
hideMethod · 0.80
setValueMethod · 0.80
toStringFunction · 0.50
getSeatMethod · 0.45

Tested by

no test coverage detected