void StatusWindow::statChanged(const AttributesT id, const int oldVal1, const int oldVal2 A_UNUSED) { static bool blocked = false; if (blocked) return; if (id == Attributes::JOB) { if (mJobLvlLabel) { int lvl = PlayerInfo::getStatBase(id); const int oldExp = oldVal1; const std::pair<int, int> exp = PlayerInfo::getStatExperience(id); if (!lvl) { // possible server broken and don't send job level, // then we fixing it :) if (exp.second < 20000) { lvl = 0; } else { lvl = (exp.second - 20000) / 150; blocked = true; PlayerInfo::setStatBase(id, lvl); blocked = false; } } if (exp.first < oldExp && exp.second >= 20000) { // possible job level up. but server broken and don't send // new job exp limit, we fixing it lvl ++; blocked = true; PlayerInfo::setStatExperience( id, exp.first, 20000 + lvl * 150); PlayerInfo::setStatBase(id, lvl); blocked = false; } // TRANSLATORS: status window label mJobLvlLabel->setCaption(strprintf(_("Job: %d"), lvl)); mJobLvlLabel->adjustSize(); updateJobBar(mJobBar, false); } } else { updateMPBar(mMpBar, true); const Attrs::const_iterator it = mAttrs.find(id); if (it != mAttrs.end() && it->second) it->second->update(); } }
void StatusWindow::update() { // Status Part // ----------- mLvlLabel->setCaption(strprintf(_("Level: %d"), mPlayer->getLevel())); mLvlLabel->adjustSize(); mJobLvlLabel->setCaption(strprintf(_("Job: %d"), mPlayer->mJobLevel)); mJobLvlLabel->adjustSize(); if (mCurrency != mPlayer->getMoney()) { mCurrency = mPlayer->getMoney(); mGpLabel->setCaption(strprintf(_("Money: %s"), Units::formatCurrency(mCurrency).c_str())); mGpLabel->adjustSize(); } updateHPBar(mHpBar, true); updateMPBar(mMpBar, true); updateXPBar(mXpBar, false); updateJobBar(mJobBar, false); // Stats Part // ---------- static const char *attrNames[6] = { N_("Strength"), N_("Agility"), N_("Vitality"), N_("Intelligence"), N_("Dexterity"), N_("Luck") }; int statusPoints = mPlayer->mStatsPointsToAttribute; // Update labels for (int i = 0; i < 6; i++) { mStatsLabel[i]->setCaption(gettext(attrNames[i])); mStatsDisplayLabel[i]->setCaption(toString((int) mPlayer->mAttr[i])); mPointsLabel[i]->setCaption(toString((int) mPlayer->mAttrUp[i])); mStatsLabel[i]->adjustSize(); mStatsDisplayLabel[i]->adjustSize(); mPointsLabel[i]->adjustSize(); mStatsButton[i]->setEnabled(mPlayer->mAttrUp[i] <= statusPoints); } mRemainingStatsPointsLabel->setCaption( strprintf(_("Remaining Status Points: %d"), statusPoints)); mRemainingStatsPointsLabel->adjustSize(); // Derived Stats Points // Attack TODO: Count equipped Weapons and items attack bonuses mStatsAttackPoints->setCaption( toString(mPlayer->ATK + mPlayer->ATK_BONUS)); mStatsAttackPoints->adjustSize(); // Defense TODO: Count equipped Armors and items defense bonuses mStatsDefensePoints->setCaption( toString(mPlayer->DEF + mPlayer->DEF_BONUS)); mStatsDefensePoints->adjustSize(); // Magic Attack TODO: Count equipped items M.Attack bonuses mStatsMagicAttackPoints->setCaption( toString(mPlayer->MATK + mPlayer->MATK_BONUS)); mStatsMagicAttackPoints->adjustSize(); // Magic Defense TODO: Count equipped items M.Defense bonuses mStatsMagicDefensePoints->setCaption( toString(mPlayer->MDEF + mPlayer->MDEF_BONUS)); mStatsMagicDefensePoints->adjustSize(); // Accuracy % mStatsAccuracyPoints->setCaption(toString(mPlayer->HIT)); mStatsAccuracyPoints->adjustSize(); // Evasion % mStatsEvadePoints->setCaption(toString(mPlayer->FLEE)); mStatsEvadePoints->adjustSize(); // Reflex % mStatsReflexPoints->setCaption(toString(mPlayer->DEX / 4)); // + counter mStatsReflexPoints->adjustSize(); }