diff --git a/src/widgets/data/CharEditor.cpp b/src/widgets/data/CharEditor.cpp index 2a800ee4c..07fdb5490 100644 --- a/src/widgets/data/CharEditor.cpp +++ b/src/widgets/data/CharEditor.cpp @@ -85,9 +85,8 @@ void CharEditor::updateText() sbBaseHp = new QSpinBox(this); sbBaseHp->setToolTip(tr("Base HP")); - if (!lblBaseHp){ + if (!lblBaseHp) lblBaseHp = new QLabel(this); - } lblBaseHp->setText(tr("HP")); if (!lblBaseHpBonus) @@ -313,9 +312,8 @@ void CharEditor::updateText() lblLckTotal = new QLabel(this); lblLckTotal->setToolTip(tr("Luck Stat Total")); - if (!toolbox) { + if (!toolbox) toolbox = new QToolBox(this); - } toolbox->setItemText(0, tr("Status Info")); toolbox->setItemText(1, tr("Equipment")); @@ -444,11 +442,10 @@ void CharEditor::updateMateriaToolTips() { int i =0; for(auto button : std::as_const(materiaSlots)) { - if (data.materias[i].id != FF7Materia::EmptyId) { + if (data.materias[i].id != FF7Materia::EmptyId) button->setToolTip(FF7Materia::name(data.materias[i].id)); - } else { + else button->setToolTip(QString(tr("-Empty-"))); - } i++; } } @@ -838,146 +835,182 @@ quint8 CharEditor::id() { return data.id; } + quint8 CharEditor::level() { return data.level; } + quint8 CharEditor::str() { return data.strength; } + quint8 CharEditor::vit() { return data.vitality; } + quint8 CharEditor::mag() { return data.magic; } + quint8 CharEditor::spi() { return data.spirit; } + quint8 CharEditor::dex() { return data.dexterity; } + quint8 CharEditor::lck() { return data.luck; } + quint8 CharEditor::strBonus() { return data.strength_bonus; } + quint8 CharEditor::vitBonus() { return data.vitality_bonus; } + quint8 CharEditor::magBonus() { return data.magic_bonus; } + quint8 CharEditor::spiBonus() { return data.spirit_bonus; } + quint8 CharEditor::dexBonus() { return data.dexterity_bonus; } + quint8 CharEditor::lckBonus() { return data.luck_bonus; } + qint8 CharEditor::limitLevel() { return data.limitlevel; } + quint8 CharEditor::limitBar() { return data.limitbar; } + QString CharEditor::name() { return lineName->text(); } + quint8 CharEditor::weapon() { return data.weapon; } + quint8 CharEditor::armor() { return data.armor; } + quint8 CharEditor::accessory() { return data.accessory; } + quint16 CharEditor::curHp() { return data.curHP; } + quint16 CharEditor::maxHp() { return data.maxHP; } + quint16 CharEditor::curMp() { return data.curMP; } + quint16 CharEditor::maxMp() { return data.maxMP; } + quint16 CharEditor::kills() { return data.kills; } + quint8 CharEditor::row() { return data.rowFlag; } + quint8 CharEditor::levelProgress() { return data.tnlFlag; } + quint8 CharEditor::sadnessfury() { return data.statusFlag; } + quint16 CharEditor::limits() { return data.limits; } + quint16 CharEditor::timesused1() { return data.timesused1; } + quint16 CharEditor::timesused2() { return data.timesused2; } + quint16 CharEditor::timesused3() { return data.timesused3; } + quint16 CharEditor::baseHp() { return data.baseHP; } + quint16 CharEditor::baseMp() { return data.baseMP; } + quint32 CharEditor::exp() { return data.exp; } + quint32 CharEditor::expNext() { return data.expNext; } + materia CharEditor::char_materia(int mat) { return data.materias[mat]; @@ -992,9 +1025,8 @@ void CharEditor::Exp_Changed(int exp) int level = 0; int prev_level = data.level; for (int i = level; i < 99; i++) { - if (data.exp >= FF7Char::totalExpForLevel(data.id, i)) { + if (data.exp >= FF7Char::totalExpForLevel(data.id, i)) level++; - } } sbLevel->blockSignals(true); sbLevel->setValue(level); @@ -1013,11 +1045,10 @@ void CharEditor::Level_Changed(int level) if (autolevel) { int prev_level = data.level; setLevel(level); - if (level <= 0) { + if (level <= 0) setExp(0); - } else { + else setExp(int(FF7Char::totalExpForLevel(data.id, level - 1))); - } sbTotalExp->blockSignals(true); sbTotalExp->setValue(int(data.exp)); sbTotalExp->blockSignals(false); @@ -1381,10 +1412,8 @@ void CharEditor::setWeapon(int weapon) elemental_info(); status_info(); update_materia_slots(); - if(mslotsel >= 0 && mslotsel <= 7) { + if (mslotsel >= 0 && mslotsel <= 7) materiaSlotClicked(-1); - } - } void CharEditor::setArmor(int armor) @@ -1402,9 +1431,8 @@ void CharEditor::setArmor(int armor) elemental_info(); status_info(); update_materia_slots(); - if(mslotsel >= 8 && mslotsel <= 15) { + if(mslotsel >= 8 && mslotsel <= 15) materiaSlotClicked(-1); - } } void CharEditor::setAccessory(int accessory) @@ -1540,37 +1568,41 @@ void CharEditor::calc_limit_value(QModelIndex item) { int row = item.row(); int limits = data.limits; - if (list_limits->item(row)->checkState() == Qt::Checked) { + if (list_limits->item(row)->checkState() == Qt::Checked) limits |= (1 << FF7Char::limitBitConvert(row)); - } else { + else limits &= ~(1 << FF7Char::limitBitConvert(row)); - } setLimits(limits); } + void CharEditor::setAutoLevel(bool ans) { autolevel = ans; //used to turn off auto char leveling - if (ans) { + if (ans) Level_Changed(data.level); - } } + bool CharEditor::AutoLevel() { return autolevel; } + void CharEditor::setAutoStatCalc(bool ans) { autostatcalc = ans; //Toggle stat calculation calc_stats(); } + bool CharEditor::AutoStatCalc() { return autostatcalc; } + bool CharEditor::AdvancedMode() { return advancedMode; } + void CharEditor::setAdvancedMode(bool new_advancedMode) { advancedMode = new_advancedMode; @@ -1578,19 +1610,14 @@ void CharEditor::setAdvancedMode(bool new_advancedMode) comboId->setVisible(advancedMode); //if viewing cait/vincent/y.cloud or sephiroth hid the checkbox for simple id changing. - if (data.id == FF7Char::CaitSith || data.id == FF7Char::Vincent || data.id == FF7Char::YoungCloud || data.id == FF7Char::Sephiroth) { + if (data.id == FF7Char::CaitSith || data.id == FF7Char::Vincent || data.id == FF7Char::YoungCloud || data.id == FF7Char::Sephiroth) cb_idChanger->setHidden(advancedMode); - } } void CharEditor::setEditable(bool edit) { editable = edit; - if (editable) { - setEnabled(true); - } else { - setEnabled(false); - } + setEnabled(editable); } void CharEditor::setShowPlaceholderMateria(bool shown) @@ -1648,30 +1675,30 @@ void CharEditor::calc_stats() QString title; title.append(tr("AP:x%1").arg(QString::number(FF7Item::materiaGrowthRate(data.weapon + 128)))); - if (FF7Item::statSTR(data.weapon + 128) != 0) { + if (FF7Item::statSTR(data.weapon + 128) != 0) title.append(tr(" Str:+%1").arg(QString::number(FF7Item::statSTR(data.weapon + 128)))); - } - if (FF7Item::statVIT(data.weapon + 128) != 0) { + + if (FF7Item::statVIT(data.weapon + 128) != 0) title.append(tr(" Vit:+%1").arg(QString::number(FF7Item::statVIT(data.weapon + 128)))); - } - if (FF7Item::statDEX(data.weapon + 128) != 0) { + + if (FF7Item::statDEX(data.weapon + 128) != 0) title.append(tr(" Dex:+%1").arg(QString::number(FF7Item::statDEX(data.weapon + 128)))); - } - if (FF7Item::statSPI(data.weapon + 128) != 0) { + + if (FF7Item::statSPI(data.weapon + 128) != 0) title.append(tr(" Spi:+%1").arg(QString::number(FF7Item::statSPI(data.weapon + 128)))); - } - if (FF7Item::statMAG(data.weapon + 128) != 0) { + + if (FF7Item::statMAG(data.weapon + 128) != 0) title.append(tr(" Mag:+%1").arg(QString::number(FF7Item::statMAG(data.weapon + 128)))); - } - if (FF7Item::statLCK(data.weapon + 128) != 0) { + + if (FF7Item::statLCK(data.weapon + 128) != 0) title.append(tr(" Lck:+%1").arg(QString::number(FF7Item::statLCK(data.weapon + 128)))); - } - if (FF7Item::statHP(data.weapon + 128) != 0) { + + if (FF7Item::statHP(data.weapon + 128) != 0) title.append(tr(" Hp:+%1%").arg(QString::number(FF7Item::statHP(data.weapon + 128)))); - } - if (FF7Item::statMP(data.weapon + 128) != 0) { + + if (FF7Item::statMP(data.weapon + 128) != 0) title.append(tr(" Mp:+%1%").arg(QString::number(FF7Item::statMP(data.weapon + 128)))); - } + lblWeaponStats->setText(title); //Armor str_bonus += FF7Item::statSTR(data.armor + 256); @@ -1684,30 +1711,30 @@ void CharEditor::calc_stats() mp_bonus += FF7Item::statMP(data.armor + 256); title.clear(); title.append(tr("AP:x%1").arg(QString::number(FF7Item::materiaGrowthRate(data.armor + 256)))); - if (FF7Item::statSTR(data.armor + 256) != 0) { + if (FF7Item::statSTR(data.armor + 256) != 0) title.append(tr(" Str:+%1").arg(QString::number(FF7Item::statSTR(data.armor + 256)))); - } - if (FF7Item::statVIT(data.armor + 256) != 0) { + + if (FF7Item::statVIT(data.armor + 256) != 0) title.append(tr(" Vit:+%1").arg(QString::number(FF7Item::statVIT(data.armor + 256)))); - } - if (FF7Item::statDEX(data.armor + 256) != 0) { + + if (FF7Item::statDEX(data.armor + 256) != 0) title.append(tr(" Dex:+%1").arg(QString::number(FF7Item::statDEX(data.armor + 256)))); - } - if (FF7Item::statSPI(data.armor + 256) != 0) { + + if (FF7Item::statSPI(data.armor + 256) != 0) title.append(tr(" Spi:+%1").arg(QString::number(FF7Item::statSPI(data.armor + 256)))); - } - if (FF7Item::statMAG(data.armor + 256) != 0) { + + if (FF7Item::statMAG(data.armor + 256) != 0) title.append(tr(" Mag:+%1").arg(QString::number(FF7Item::statMAG(data.armor + 256)))); - } - if (FF7Item::statLCK(data.armor + 256) != 0) { + + if (FF7Item::statLCK(data.armor + 256) != 0) title.append(tr(" Lck:+%1").arg(QString::number(FF7Item::statLCK(data.armor + 256)))); - } - if (FF7Item::statHP(data.armor + 256) != 0) { + + if (FF7Item::statHP(data.armor + 256) != 0) title.append(tr(" Hp:+%1%").arg(QString::number(FF7Item::statHP(data.armor + 256)))); - } - if (FF7Item::statMP(data.armor + 256) != 0) { + + if (FF7Item::statMP(data.armor + 256) != 0) title.append(tr(" Mp:+%1%").arg(QString::number(FF7Item::statMP(data.armor + 256)))); - } + lblArmorStats->setText(title); //Accessory if (data.accessory < 32) { @@ -1721,30 +1748,30 @@ void CharEditor::calc_stats() mp_bonus += FF7Item::statMP(data.accessory + 288); title.clear(); title.append(tr("Accessory")); - if (FF7Item::statSTR(data.accessory + 288) != 0) { + if (FF7Item::statSTR(data.accessory + 288) != 0) title.append(tr(" Str:+%1").arg(QString::number(FF7Item::statSTR(data.accessory + 288)))); - } - if (FF7Item::statVIT(data.accessory + 288) != 0) { + + if (FF7Item::statVIT(data.accessory + 288) != 0) title.append(tr(" Vit:+%1").arg(QString::number(FF7Item::statVIT(data.accessory + 288)))); - } - if (FF7Item::statDEX(data.accessory + 288) != 0) { + + if (FF7Item::statDEX(data.accessory + 288) != 0) title.append(tr(" Dex:+%1").arg(QString::number(FF7Item::statDEX(data.accessory + 288)))); - } - if (FF7Item::statSPI(data.accessory + 288) != 0) { + + if (FF7Item::statSPI(data.accessory + 288) != 0) title.append(tr(" Spi:+%1").arg(QString::number(FF7Item::statSPI(data.accessory + 288)))); - } - if (FF7Item::statMAG(data.accessory + 288) != 0) { + + if (FF7Item::statMAG(data.accessory + 288) != 0) title.append(tr(" Mag:+%1").arg(QString::number(FF7Item::statMAG(data.accessory + 288)))); - } - if (FF7Item::statLCK(data.accessory + 288) != 0) { + + if (FF7Item::statLCK(data.accessory + 288) != 0) title.append(tr(" Lck:+%1").arg(QString::number(FF7Item::statLCK(data.accessory + 288)))); - } - if (FF7Item::statHP(data.accessory + 288) != 0) { + + if (FF7Item::statHP(data.accessory + 288) != 0) title.append(tr(" Hp:+%1%").arg(QString::number(FF7Item::statHP(data.accessory + 288)))); - } - if (FF7Item::statMP(data.accessory + 288) != 0) { + + if (FF7Item::statMP(data.accessory + 288) != 0) title.append(tr(" Mp:+%1%").arg(QString::number(FF7Item::statMP(data.accessory + 288)))); - } + accessory_box->setTitle(title); } else { title.clear(); @@ -1757,9 +1784,8 @@ void CharEditor::calc_stats() int level = 0; qint32 aptemp = FF7Materia::materiaAP(data.materias[i]); for (int m = 0; m < FF7Materia::levels(data.materias[i].id); m++) { - if (aptemp >= FF7Materia::apForLevel(data.materias[i].id, m)) { + if (aptemp >= FF7Materia::apForLevel(data.materias[i].id, m)) level++; - } } if (!materiaSlots.at(i)->isHidden()) { @@ -1769,36 +1795,31 @@ void CharEditor::calc_stats() spi_bonus += FF7Materia::spiritChange(data.materias[i].id); //Show in Percentage. - if (data.materias[i].id == FF7Materia::MpPlus) { + if (data.materias[i].id == FF7Materia::MpPlus) mp_bonus += (10 * level); - } else { + else mp_bonus += FF7Materia::mpChange(data.materias[i].id); - } - if (data.materias[i].id == FF7Materia::HpPlus) { + if (data.materias[i].id == FF7Materia::HpPlus) hp_bonus += (10 * level); - } else { + else hp_bonus += FF7Materia::hpChange(data.materias[i].id); - } //show exact numbers - if (data.materias[i].id == FF7Materia::SpeedPlus) { + if (data.materias[i].id == FF7Materia::SpeedPlus) dex_bonus += data.dexterity * int(0.01 * (level * 10)); - } else { + else dex_bonus += FF7Materia::dexterityChange(data.materias[i].id); - } - if (data.materias[i].id == FF7Materia::MagicPlus) { + if (data.materias[i].id == FF7Materia::MagicPlus) mag_bonus += data.magic * int(0.01 * (level * 10)); - } else { + else mag_bonus += FF7Materia::magicChange(data.materias[i].id); - } - if (data.materias[i].id == FF7Materia::LuckPlus) { + if (data.materias[i].id == FF7Materia::LuckPlus) lck_bonus += data.luck * int(0.01 * (level * 10)); - } else { + else lck_bonus += FF7Materia::luckChange(data.materias[i].id); - } }// end of add case. } } @@ -1826,17 +1847,15 @@ void CharEditor::calc_stats() lblDexTotal->setText(QString::number(std::min(dex_total, quint8Max))); lblLckTotal->setText(QString::number(std::min(lck_total, quint8Max))); - if (hp_bonus >= 0) { + if (hp_bonus >= 0) lblBaseHpBonus->setText(QStringLiteral(" +%1%").arg(QString::number(hp_bonus))); - } else { + else lblBaseHpBonus->setText(QStringLiteral(" %1%").arg(QString::number(hp_bonus))); - } - if (mp_bonus >= 0) { + if (mp_bonus >= 0) lblBaseMpBonus->setText(QStringLiteral(" +%1%").arg(QString::number(mp_bonus))); - } else { + else lblBaseMpBonus->setText(QString(" %1%").arg(QString::number(mp_bonus))); - } lblMaxHp->setNum(std::min(int(data.baseHP + (data.baseHP * (hp_bonus * .01))), qint16Max)); lblMaxMp->setNum(std::min(int(data.baseMP + (data.baseMP * (mp_bonus * .01))), qint16Max)); @@ -1877,17 +1896,15 @@ void CharEditor::update_tnl_bar() { if (data.level != 99) { setExpNext(int(FF7Char::totalExpForLevel(data.id, data.level) - data.exp)); - if (data.level > 0) { + if (data.level > 0) setLevelProgress(int(((FF7Char::tnlForLevel(data.id, data.level) - data.expNext) * 62) / FF7Char::tnlForLevel(data.id, data.level))); - } } else { setExpNext(0); setLevelProgress(0x3D); } bar_tnl->setValue(data.tnlFlag); - if (bar_tnl->value() < 4) { + if (bar_tnl->value() < 4) bar_tnl->setValue(0); //ff7 ingores the value if its <4 (but we don't save this) - } lbl_level_next->setText(tr("Next: %1").arg(QString::number(data.expNext))); } @@ -1900,37 +1917,36 @@ void CharEditor::elemental_info() elemental_effects->clear(); for (int r = 0; r < 3; r++) { switch (r) { - case 0: item_id = data.weapon + 128; break; - case 1: item_id = data.armor + 256; break; - case 2: item_id = data.accessory + 288; break; + case 0: item_id = data.weapon + 128; break; + case 1: item_id = data.armor + 256; break; + case 2: item_id = data.accessory + 288; break; } - if (item_id < 0 || item_id > 319) {} - else { + if ((item_id >= 0) && (item_id <= 319)) { for (int i = 0; i < 14; i++) { QString effect; int element = 0; switch (i) { - case 0: element = FF7Item::elementRestoration(item_id); effect.append(tr("Restoration")); break; - case 1: element = FF7Item::elementFire(item_id); effect.append(tr("Fire")); break; - case 2: element = FF7Item::elementCold(item_id); effect.append(tr("Cold")); break; - case 3: element = FF7Item::elementLightning(item_id); effect.append(tr("Lightning")); break; - case 4: element = FF7Item::elementEarth(item_id); effect.append(tr("Earth")); break; - case 5: element = FF7Item::elementWind(item_id); effect.append(tr("Wind")); break; - case 6: element = FF7Item::elementWater(item_id); effect.append(tr("Water")); break; - case 7: element = FF7Item::elementGravity(item_id); effect.append(tr("Gravity")); break; - case 8: element = FF7Item::elementHoly(item_id); effect.append(tr("Holy")); break; - case 9: element = FF7Item::elementPoison(item_id); effect.append(tr("Poison")); break; - case 10: element = FF7Item::elementCut(item_id); effect.append(tr("Cut")); break; - case 11: element = FF7Item::elementShoot(item_id); effect.append(tr("Shoot")); break; - case 12: element = FF7Item::elementPunch(item_id); effect.append(tr("Punch")); break; - case 13: element = FF7Item::elementHit(item_id); effect.append(tr("Hit")); break; + case 0: element = FF7Item::elementRestoration(item_id); effect.append(tr("Restoration")); break; + case 1: element = FF7Item::elementFire(item_id); effect.append(tr("Fire")); break; + case 2: element = FF7Item::elementCold(item_id); effect.append(tr("Cold")); break; + case 3: element = FF7Item::elementLightning(item_id); effect.append(tr("Lightning")); break; + case 4: element = FF7Item::elementEarth(item_id); effect.append(tr("Earth")); break; + case 5: element = FF7Item::elementWind(item_id); effect.append(tr("Wind")); break; + case 6: element = FF7Item::elementWater(item_id); effect.append(tr("Water")); break; + case 7: element = FF7Item::elementGravity(item_id); effect.append(tr("Gravity")); break; + case 8: element = FF7Item::elementHoly(item_id); effect.append(tr("Holy")); break; + case 9: element = FF7Item::elementPoison(item_id); effect.append(tr("Poison")); break; + case 10: element = FF7Item::elementCut(item_id); effect.append(tr("Cut")); break; + case 11: element = FF7Item::elementShoot(item_id); effect.append(tr("Shoot")); break; + case 12: element = FF7Item::elementPunch(item_id); effect.append(tr("Punch")); break; + case 13: element = FF7Item::elementHit(item_id); effect.append(tr("Hit")); break; } switch (element) { - case -3: effect.prepend(tr("Absorb:")); break; - case -2: effect.prepend(tr("Nullify:")); break; - case -1: effect.prepend(tr("Halve:")); break; - case 0: effect.clear(); break; - case +1: effect.prepend(tr("Attack:")); break; + case -3: effect.prepend(tr("Absorb:")); break; + case -2: effect.prepend(tr("Nullify:")); break; + case -1: effect.prepend(tr("Halve:")); break; + case 0: effect.clear(); break; + case +1: effect.prepend(tr("Attack:")); break; } if (!effect.isNull() && !m_effect.contains(effect, Qt::CaseSensitive)) { m_effect.append(effect); @@ -1940,9 +1956,8 @@ void CharEditor::elemental_info() } }//end of for Loop elemental_effects->setFixedHeight(y); - elemental_box->setFixedSize( (charWidth * 16), y + elemental_box->contentsMargins().top() + elemental_box->contentsMargins().bottom()); - }//end of else. + }//end of if }//end of other loop. elemental_box->setVisible(show); elemental_box->adjustSize(); @@ -1958,47 +1973,46 @@ void CharEditor::status_info() status_effects->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); for (int r = 0; r < 3; r++) { switch (r) { - case 0: item_id = data.weapon + 128; break; - case 1: item_id = data.armor + 256; break; - case 2: item_id = data.accessory + 288; break; + case 0: item_id = data.weapon + 128; break; + case 1: item_id = data.armor + 256; break; + case 2: item_id = data.accessory + 288; break; } - if (item_id < 0 || item_id > 319) {} - else { + if ((item_id >= 0) && (item_id <= 319)) { for (int i = 0; i < 24; i++) { QString effect; int status = 0; switch (i) { - case 0: status = FF7Item::statusDeath(item_id); effect.append(tr("Death")); break; - case 1: status = FF7Item::statusSlowNumb(item_id); effect.append(tr("Slow-Numb")); break; - case 2: status = FF7Item::statusDeathSentence(item_id); effect.append(tr("D.Sentence")); break; - case 3: status = FF7Item::statusParalysis(item_id); effect.append(tr("Paralysis")); break; - case 4: status = FF7Item::statusPetrify(item_id); effect.append(tr("Petrify")); break; - case 5: status = FF7Item::statusSilence(item_id); effect.append(tr("Silence")); break; - case 6: status = FF7Item::statusSleep(item_id); effect.append(tr("Sleep")); break; - case 7: status = FF7Item::statusConfusion(item_id); effect.append(tr("Confusion")); break; - case 8: status = FF7Item::statusBerserk(item_id); effect.append(tr("Berserk")); break; - case 9: status = FF7Item::statusFrog(item_id); effect.append(tr("Frog")); break; - case 10: status = FF7Item::statusMini(item_id); effect.append(tr("Mini")); break; - case 11: status = FF7Item::statusPoison(item_id); effect.append(tr("Poison")); break; - case 12: status = FF7Item::statusFury(item_id); effect.append(tr("Fury")); break; - case 13: status = FF7Item::statusSadness(item_id); effect.append(tr("Sadness")); break; - case 14: status = FF7Item::statusDarkness(item_id); effect.append(tr("Darkness")); break; - case 15: status = FF7Item::statusHaste(item_id); effect.append(tr("Haste")); break; - case 16: status = FF7Item::statusSlow(item_id); effect.append(tr("Slow")); break; - case 17: status = FF7Item::statusStop(item_id); effect.append(tr("Stop")); break; - case 18: status = FF7Item::statusBarrier(item_id); effect.append(tr("Barrier")); break; - case 19: status = FF7Item::statusMagicBarrier(item_id); effect.append(tr("M.Barrier")); break; - case 20: status = FF7Item::statusReflect(item_id); effect.append(tr("Reflect")); break; - case 21: status = FF7Item::statusShield(item_id); effect.append(tr("Shield")); break; - case 22: status = FF7Item::statusRegen(item_id); effect.append(tr("Regen")); break; - case 23: status = FF7Item::statusResist(item_id); effect.append(tr("Resist")); break; + case 0: status = FF7Item::statusDeath(item_id); effect.append(tr("Death")); break; + case 1: status = FF7Item::statusSlowNumb(item_id); effect.append(tr("Slow-Numb")); break; + case 2: status = FF7Item::statusDeathSentence(item_id); effect.append(tr("D.Sentence")); break; + case 3: status = FF7Item::statusParalysis(item_id); effect.append(tr("Paralysis")); break; + case 4: status = FF7Item::statusPetrify(item_id); effect.append(tr("Petrify")); break; + case 5: status = FF7Item::statusSilence(item_id); effect.append(tr("Silence")); break; + case 6: status = FF7Item::statusSleep(item_id); effect.append(tr("Sleep")); break; + case 7: status = FF7Item::statusConfusion(item_id); effect.append(tr("Confusion")); break; + case 8: status = FF7Item::statusBerserk(item_id); effect.append(tr("Berserk")); break; + case 9: status = FF7Item::statusFrog(item_id); effect.append(tr("Frog")); break; + case 10: status = FF7Item::statusMini(item_id); effect.append(tr("Mini")); break; + case 11: status = FF7Item::statusPoison(item_id); effect.append(tr("Poison")); break; + case 12: status = FF7Item::statusFury(item_id); effect.append(tr("Fury")); break; + case 13: status = FF7Item::statusSadness(item_id); effect.append(tr("Sadness")); break; + case 14: status = FF7Item::statusDarkness(item_id); effect.append(tr("Darkness")); break; + case 15: status = FF7Item::statusHaste(item_id); effect.append(tr("Haste")); break; + case 16: status = FF7Item::statusSlow(item_id); effect.append(tr("Slow")); break; + case 17: status = FF7Item::statusStop(item_id); effect.append(tr("Stop")); break; + case 18: status = FF7Item::statusBarrier(item_id); effect.append(tr("Barrier")); break; + case 19: status = FF7Item::statusMagicBarrier(item_id); effect.append(tr("M.Barrier")); break; + case 20: status = FF7Item::statusReflect(item_id); effect.append(tr("Reflect")); break; + case 21: status = FF7Item::statusShield(item_id); effect.append(tr("Shield")); break; + case 22: status = FF7Item::statusRegen(item_id); effect.append(tr("Regen")); break; + case 23: status = FF7Item::statusResist(item_id); effect.append(tr("Resist")); break; } switch (status) { - case -2: effect.prepend(tr("Protect:")); break; - case -1: effect.prepend(tr("Remove:")); break; - case 0: effect.clear(); break; - case +1: effect.prepend(tr("Inflict:")); break; - case +2: effect.prepend(tr("OnBattle:")); break; + case -2: effect.prepend(tr("Protect:")); break; + case -1: effect.prepend(tr("Remove:")); break; + case 0: effect.clear(); break; + case +1: effect.prepend(tr("Inflict:")); break; + case +2: effect.prepend(tr("OnBattle:")); break; } if (!effect.isNull() && !m_status.contains(effect, Qt::CaseSensitive)) { m_status.append(effect); @@ -2020,21 +2034,19 @@ void CharEditor::update_materia_slots() int i = 0; for(auto button : std::as_const(buttons)) { button->setVisible((i+1) <= FF7Item::materiaSlots(data.weapon + 128)); - if (data.materias[i].id != FF7Materia::EmptyId) { + if (data.materias[i].id != FF7Materia::EmptyId) button->setIcon(FF7Materia::icon(data.materias[i].id)); - } else { + else button->setIcon(QIcon()); - } i++; } buttons = armor_box->findChildren(); for(auto button : std::as_const(buttons)) { button->setVisible((i-7) <= FF7Item::materiaSlots(data.armor + 256)); - if (data.materias[i].id != FF7Materia::EmptyId) { + if (data.materias[i].id != FF7Materia::EmptyId) button->setIcon(FF7Materia::icon(data.materias[i].id)); - } else { + else button->setIcon(QIcon()); - } i++; } @@ -2049,10 +2061,10 @@ void CharEditor::update_materia_slots() label->setStyleSheet(QString()); switch (FF7Item::linkedSlots((data.weapon + 128))) { - case 4: weapon_m_link_4->setStyleSheet(FF7Item::styleMateriaLink()); [[fallthrough]]; - case 3: weapon_m_link_3->setStyleSheet(FF7Item::styleMateriaLink()); [[fallthrough]]; - case 2: weapon_m_link_2->setStyleSheet(FF7Item::styleMateriaLink()); [[fallthrough]]; - case 1: weapon_m_link_1->setStyleSheet(FF7Item::styleMateriaLink()); + case 4: weapon_m_link_4->setStyleSheet(FF7Item::styleMateriaLink()); [[fallthrough]]; + case 3: weapon_m_link_3->setStyleSheet(FF7Item::styleMateriaLink()); [[fallthrough]]; + case 2: weapon_m_link_2->setStyleSheet(FF7Item::styleMateriaLink()); [[fallthrough]]; + case 1: weapon_m_link_1->setStyleSheet(FF7Item::styleMateriaLink()); } //set up armor @@ -2060,10 +2072,10 @@ void CharEditor::update_materia_slots() lblArmorStats->setText(ap_rate); switch (FF7Item::linkedSlots((data.armor + 256))) { - case 4: armor_m_link_4->setStyleSheet(FF7Item::styleMateriaLink()); [[fallthrough]]; - case 3: armor_m_link_3->setStyleSheet(FF7Item::styleMateriaLink()); [[fallthrough]]; - case 2: armor_m_link_2->setStyleSheet(FF7Item::styleMateriaLink()); [[fallthrough]]; - case 1: armor_m_link_1->setStyleSheet(FF7Item::styleMateriaLink()); + case 4: armor_m_link_4->setStyleSheet(FF7Item::styleMateriaLink()); [[fallthrough]]; + case 3: armor_m_link_3->setStyleSheet(FF7Item::styleMateriaLink()); [[fallthrough]]; + case 2: armor_m_link_2->setStyleSheet(FF7Item::styleMateriaLink()); [[fallthrough]]; + case 1: armor_m_link_1->setStyleSheet(FF7Item::styleMateriaLink()); } calc_stats(); } @@ -2104,7 +2116,7 @@ void CharEditor::matAp_changed(qint32 ap) void CharEditor::materiaSlotClicked(int slotClicked) { if (slotClicked == mslotsel) { - if(slotClicked < 0 ) + if (slotClicked < 0 ) return; load = true; materia_edit->setMateria(char_materia(mslotsel).id, FF7Materia::materiaAP(char_materia(mslotsel))); @@ -2114,14 +2126,14 @@ void CharEditor::materiaSlotClicked(int slotClicked) mslotsel = slotClicked; - for(auto frame : std::as_const(materiaSlotFrames)) { + for (auto frame : std::as_const(materiaSlotFrames)) frame->setFrameShape(QFrame::NoFrame); - } if (slotClicked < 0) { materia_edit->setVisible(false); return; } + materia_edit->setVisible(true); materiaSlotFrames.at(mslotsel)->setFrameShape(QFrame::Box); @@ -2187,21 +2199,21 @@ void CharEditor::MaxEquip() quint8 new_id = FF7Materia::EmptyId; switch (mslotsel) { - case 6: new_id = FF7Materia::MegaAll; - break; - case 5: new_id = FF7Materia::LongRange; - break; - case 4: new_id = FF7Materia::PreEmptive; - break; - case 3: new_id = FF7Materia::MasterSummon; - break; - case 2: new_id = FF7Materia::EnemySkill; - break; - case 1: new_id = FF7Materia::MasterCommand; - break; - case 0: materiaSlotClicked(0); - new_id = FF7Materia::MasterMagic; - break; + case 6: new_id = FF7Materia::MegaAll; + break; + case 5: new_id = FF7Materia::LongRange; + break; + case 4: new_id = FF7Materia::PreEmptive; + break; + case 3: new_id = FF7Materia::MasterSummon; + break; + case 2: new_id = FF7Materia::EnemySkill; + break; + case 1: new_id = FF7Materia::MasterCommand; + break; + case 0: materiaSlotClicked(0); + new_id = FF7Materia::MasterMagic; + break; } data.materias[mslotsel].id = new_id; diff --git a/src/widgets/data/ChocoboEditor.cpp b/src/widgets/data/ChocoboEditor.cpp index bfd83f5af..b18de11db 100644 --- a/src/widgets/data/ChocoboEditor.cpp +++ b/src/widgets/data/ChocoboEditor.cpp @@ -66,9 +66,8 @@ void ChocoboEditor::updateText() }; if (combo_rating->count() != 0) { - for (int i = 0; i < typelist.count(); i++) { + for (int i = 0; i < typelist.count(); i++) combo_rating->setItemText(i, typelist.at(i)); - } } else { combo_rating->addItems(typelist); } @@ -193,7 +192,7 @@ ChocoboEditor::ChocoboEditor(QWidget *parent) : Final->addWidget(lblSpeedWarning, 8, 0, 2, 2, Qt::AlignCenter); Final->addWidget(advancedModeBox, 10, 0, 1, 2); Final->addItem(new QSpacerItem(0, 0, QSizePolicy::Preferred, QSizePolicy::Expanding), 11, 0, 1, 2); - this->setLayout(Final); + setLayout(Final); init_connections(); } @@ -320,15 +319,14 @@ void ChocoboEditor::SetChocobo(FF7CHOCOBO choco, const QString &Processed_Name, } void ChocoboEditor::getRank(void) { - if (choco_data.raceswon < 3) { + if (choco_data.raceswon < 3) lbl_rank->setText(tr("Rank: C")); - } else if (choco_data.raceswon < 6) { + else if (choco_data.raceswon < 6) lbl_rank->setText(tr("Rank: B")); - } else if (choco_data.raceswon < 9) { + else if (choco_data.raceswon < 9) lbl_rank->setText(tr("Rank: A")); - } else { + else lbl_rank->setText(tr("Rank: S")); - } } void ChocoboEditor::setAdvancedMode(bool advancedMode) @@ -464,11 +462,10 @@ void ChocoboEditor::setName(const QString &newName) { if (choco_name != newName) { choco_name = newName.mid(0, 6); - if (choco_name.startsWith(QString("\xff"), Qt::CaseInsensitive) || choco_name == QString(6, '\x20')) { + if (choco_name.startsWith(QString("\xff"), Qt::CaseInsensitive) || choco_name == QString(6, '\x20')) line_name->setText(QString()); - } else { + else line_name->setText(choco_name); - } } } diff --git a/src/widgets/data/ChocoboLabel.cpp b/src/widgets/data/ChocoboLabel.cpp index f57c9d07d..25e4d81ea 100644 --- a/src/widgets/data/ChocoboLabel.cpp +++ b/src/widgets/data/ChocoboLabel.cpp @@ -157,12 +157,12 @@ ChocoboLabel::ChocoboLabel(const QString &titleText, bool occupied, QWidget *par void ChocoboLabel::setType(int type) { switch (type) { - case 0: lblType->setPixmap(QPixmap("://chocobo/yellow")); break; - case 1: lblType->setPixmap(QPixmap("://chocobo/green")); break; - case 2: lblType->setPixmap(QPixmap("://chocobo/blue")); break; - case 3: lblType->setPixmap(QPixmap("://chocobo/black")); break; - case 4: lblType->setPixmap(QPixmap("://chocobo/gold")); break; - default: lblType->setPixmap(QPixmap()); break; + case 0: lblType->setPixmap(QPixmap("://chocobo/yellow")); break; + case 1: lblType->setPixmap(QPixmap("://chocobo/green")); break; + case 2: lblType->setPixmap(QPixmap("://chocobo/blue")); break; + case 3: lblType->setPixmap(QPixmap("://chocobo/black")); break; + case 4: lblType->setPixmap(QPixmap("://chocobo/gold")); break; + default: lblType->setPixmap(QPixmap()); break; } } @@ -178,38 +178,35 @@ void ChocoboLabel::setName(QString decodedName) void ChocoboLabel::setSex(bool male) { - if (male) { + if (male) lblSex->setText(QString::fromUtf8("♂")); - } else { + else lblSex->setText(QString::fromUtf8("♀")); - } } void ChocoboLabel::setSex(int sex) { - if (sex == 0) { + if (sex == 0) lblSex->setText(QString::fromUtf8("♂")); - } else if (sex == 1) { + else if (sex == 1) lblSex->setText(QString::fromUtf8("♀")); - } else { + else lblSex->setText(QString()); - } } void ChocoboLabel::setRank(int wins) { m_wins = wins; - if (wins < 0) { + if (wins < 0) lblRank->setText(QString()); - } else if (wins < 3) { + else if (wins < 3) lblRank->setText(tr("Rank:C")); - } else if (wins < 6) { + else if (wins < 6) lblRank->setText(tr("Rank:B")); - } else if (wins < 9) { + else if (wins < 9) lblRank->setText(tr("Rank:A")); - } else { + else lblRank->setText(tr("Rank:S")); - } } void ChocoboLabel::setOccupied(bool occupied) diff --git a/src/widgets/data/ChocoboManager.cpp b/src/widgets/data/ChocoboManager.cpp index de4e03df6..0a9406133 100644 --- a/src/widgets/data/ChocoboManager.cpp +++ b/src/widgets/data/ChocoboManager.cpp @@ -22,7 +22,7 @@ void ChocoboManager::changeEvent(QEvent *e) } else if (e->type() == QEvent::PaletteChange) { const auto list = findChildren(); for( auto i: list) - i->setPalette(palette()); + i->setPalette(palette()); } QWidget::changeEvent(e); } @@ -246,9 +246,8 @@ void ChocoboManager::rmChocobo(int s) void ChocoboManager::labelUpdate(int label) { - if (!(chocoboName[label].startsWith(QString("\xff")))) { + if (!(chocoboName[label].startsWith(QString("\xff")))) chocoboLabel[label]->setName(chocoboName[label]); - } chocoboLabel[label]->setSex(chocoboData[label].sex); chocoboLabel[label]->setRank(chocoboData[label].raceswon); chocoboLabel[label]->setType(chocoboData[label].type); @@ -260,19 +259,18 @@ void ChocoboManager::setData(FF7CHOCOBO chocos[6], QString names[6], quint16 sta { for (int i = 0; i < 6; i++) { setChocobo(i, chocos[i], names[i], staminas[i], cMate[i], chocoboRatings[i]); - if (!chocoboLabel[i]->isOccupied()) { + if (!chocoboLabel[i]->isOccupied()) chocoboLabel[i]->clearLabel(); - } chocoboLabel[i]->setSelected(false); } setOwned(owned); setOccupied(occupied, mask); selectedStable = -1; //reset chocoboEditor->setHidden(true); - for (int i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) setChocoboPen(i, chocoPens[i]); - } } + void ChocoboManager::setData(QList chocos, QList names, QList staminas, QList cMate, qint8 owned, qint8 occupied, qint8 mask, QList chocoPens, QList chocoboRatings) { setOwned(owned); @@ -283,16 +281,15 @@ void ChocoboManager::setData(QList chocos, QList names, QLi for (int i = 0; i < 6; i++) { setChocobo(i, chocos.at(i), names.at(i), staminas.at(i), cMate.at(i), chocoboRatings.at(i)); - if (!chocoboLabel[i]->isOccupied()) { + if (!chocoboLabel[i]->isOccupied()) chocoboLabel[i]->clearLabel(); - } chocoboLabel[i]->setSelected(false); } - for (int i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) setChocoboPen(i, chocoPens[i]); - } } + void ChocoboManager::setChocobo(int s, const FF7CHOCOBO &chocoData, const QString &chocoName, quint16 chocoStamina, bool chocoCmate, quint8 rating) { chocoboLabel[s]->clearLabel(); @@ -301,57 +298,54 @@ void ChocoboManager::setChocobo(int s, const FF7CHOCOBO &chocoData, const QStrin chocoboStamina[s] = chocoStamina; chocoboRatings[s] = rating; cantMate[s] = chocoCmate; - if (chocoboLabel[s]->isOccupied()) { + if (chocoboLabel[s]->isOccupied()) labelUpdate(s); - } else { + else chocoboLabel[s]->clearLabel(); - } } + void ChocoboManager::setChocoboPen(int pen, int value) { - if ((pen < 0) || (pen > 3) || (value < 0) || (value > 8)) { + if ((pen < 0) || (pen > 3) || (value < 0) || (value > 8)) return; - } else { - comboChocoPen[pen]->setCurrentIndex(value); - } + comboChocoPen[pen]->setCurrentIndex(value); } + void ChocoboManager::setOwned(int owned) { - if ((owned < 0) || (owned > 6)) { + if ((owned < 0) || (owned > 6)) return; - } else { - stablesOwned = qint8(owned); - sbStablesOwned->blockSignals(true); - sbStablesOwned->setValue(owned); - disableChocoLabels(); - enableChocoboLabels(owned); - sbStablesOwned->blockSignals(false); - } + stablesOwned = qint8(owned); + sbStablesOwned->blockSignals(true); + sbStablesOwned->setValue(owned); + disableChocoLabels(); + enableChocoboLabels(owned); + sbStablesOwned->blockSignals(false); } + void ChocoboManager::setOccupied(int occupied, int mask) { - if ((occupied < 0) || (occupied > 6)) { + if ((occupied < 0) || (occupied > 6)) return; - } else { - stablesOccupied = qint8(occupied); - stableMask = qint8(mask); - - for (int i = 0; i < 6; i++) { - chocoboLabel[i]->blockSignals(true); - if ((mask & (1 << i))) { - chocoboLabel[i]->setOccupied(true); - labelUpdate(i); - } else { - chocoboLabel[i]->setOccupied(false); - chocoboLabel[i]->clearLabel(); - } - chocoboLabel[i]->blockSignals(false); + stablesOccupied = qint8(occupied); + stableMask = qint8(mask); + + for (int i = 0; i < 6; i++) { + chocoboLabel[i]->blockSignals(true); + if ((mask & (1 << i))) { + chocoboLabel[i]->setOccupied(true); + labelUpdate(i); + } else { + chocoboLabel[i]->setOccupied(false); + chocoboLabel[i]->clearLabel(); } - lcdStablesOccupied->blockSignals(true); - lcdStablesOccupied->display(occupied); - lcdStablesOccupied->blockSignals(false); + chocoboLabel[i]->blockSignals(false); } + lcdStablesOccupied->blockSignals(true); + lcdStablesOccupied->display(occupied); + lcdStablesOccupied->blockSignals(false); } + void ChocoboManager::ChocoboChanged(int s) { Q_EMIT nameChanged(s, chocoboName[s]); @@ -371,70 +365,69 @@ void ChocoboManager::ChocoboChanged(int s) Q_EMIT winsChanged(s, chocoboData[s].raceswon); Q_EMIT ratingChanged(s, chocoboRatings[s]); } + bool ChocoboManager::isEmpty(FF7CHOCOBO choco) { int score = 0; - if (!choco.accel) { + if (!choco.accel) score++; - } - if (!choco.coop) { + + if (!choco.coop) score++; - } - if (!choco.intelligence) { + + if (!choco.intelligence) score++; - } - if (!choco.maxspeed) { + + if (!choco.maxspeed) score++; - } - if (!choco.maxsprintspd) { + + if (!choco.maxsprintspd) score++; - } - if (!choco.pcount) { + + if (!choco.pcount) score++; - } - if (!choco.personality) { + + if (!choco.personality) score++; - } - if (!choco.raceswon) { + + if (!choco.raceswon) score++; - } - if (!choco.sex) { + + if (!choco.sex) score++; - } - if (!choco.speed) { + + if (!choco.speed) score++; - } - if (!choco.sprintspd) { + + if (!choco.sprintspd) score++; - } - if (!choco.type) { + + if (!choco.type) score++; - } - if (score > 5) { + + if (score > 5) return false; - } else { - return true; - } + return true; } void ChocoboManager::clearSelection() { - for (int i = 0; i < 6; i++) { + for (int i = 0; i < 6; i++) chocoboLabel[i]->setSelected(false); - } } + void ChocoboManager::disableChocoLabels() { - for (int i = 0; i < 6; i++) { + for (int i = 0; i < 6; i++) chocoboLabel[i]->setEnabled(false); - } } + void ChocoboManager::enableChocoboLabels(int count) { - for (int i = 0; i < count; i++) { + for (int i = 0; i < count; i++) chocoboLabel[i]->setEnabled(true); - } } + QGridLayout *ChocoboManager::createChocoboLabelGrid() { auto gridLayout = new QGridLayout; @@ -448,9 +441,7 @@ QGridLayout *ChocoboManager::createChocoboLabelGrid() connect(chocoboLabel[i], &ChocoboLabel::clicked, this, [this] { if (selectedStable == -1) - { chocoboEditor->setHidden(false); - } selectedStable = sender()->objectName().toInt(); chocoboEditor->SetChocobo(chocoboData[selectedStable], chocoboName[selectedStable], cantMate[selectedStable], chocoboStamina[selectedStable], chocoboRatings[selectedStable]); clearSelection(); @@ -469,8 +460,7 @@ QGridLayout *ChocoboManager::createChocoboLabelGrid() setChocobo(s, chocoboData[6], chocoboName[6], chocoboStamina[6], cantMate[6], chocoboRatings[6]); //emit the changes ChocoboChanged(s); - if (!chocoboLabel[s]->isOccupied()) - { + if (!chocoboLabel[s]->isOccupied()) { chocoboLabel[s]->setOccupied(true); setOccupied(stablesOccupied + 1, stableMask |= (1 << s)); Q_EMIT occupiedChanged(stablesOccupied); @@ -537,9 +527,8 @@ void ChocoboManager::updateCombos() for (int i = 0; i < 4; i++) { if (comboChocoPen[i]->count() != 0) { - for (int j = 0; j < comboChocoPen[i]->count(); j++) { + for (int j = 0; j < comboChocoPen[i]->count(); j++) comboChocoPen[i]->setItemText(j, typeList.at(j)); - } } else { comboChocoPen[i]->addItems(typeList); } diff --git a/src/widgets/data/ItemListView.cpp b/src/widgets/data/ItemListView.cpp index b1fe05bad..11826743f 100644 --- a/src/widgets/data/ItemListView.cpp +++ b/src/widgets/data/ItemListView.cpp @@ -78,7 +78,7 @@ void ItemListView::destroyTooltip() int ItemListView::sizeHintForColumn(int column) { - if(column < 0 || column > 2) + if ((column < 0) || (column > 2)) return -1; return m_columnWidth[column]; } diff --git a/src/widgets/data/ItemPreview.cpp b/src/widgets/data/ItemPreview.cpp index 7e9da45af..96fe99d00 100644 --- a/src/widgets/data/ItemPreview.cpp +++ b/src/widgets/data/ItemPreview.cpp @@ -50,7 +50,7 @@ ItemPreview::ItemPreview(QFlags WindowFlags, QWidget *parent) setWindowFlags(WindowFlags); Qt::WindowFlags WidgetType = (this->windowFlags() & Qt::WindowType_Mask); - if (WidgetType == Qt::Popup || WidgetType == Qt::ToolTip) + if ((WidgetType == Qt::Popup) || (WidgetType == Qt::ToolTip)) installEventFilter(this); _id = FF7Item::EmptyItem; @@ -161,7 +161,7 @@ void ItemPreview::setItem(int id) status_box->setHidden(true); elemental_box->setHidden(true); - if (id < 0 || id > 319) + if ((id < 0) || (id > 319)) _id = FF7Item::EmptyItem;/*InValid Number..Do Nothing*/ else { _id = id; @@ -204,33 +204,32 @@ void ItemPreview::elemental_info(int id) { elemental_effects->clear(); bool show = false; - if (id < 0 || id > 319) {/*invalid number*/} - else { + if ((id >= 0) && (id <= 319)) { for (int i = 0; i < 14; i++) { QString effect; int element = 0; switch (i) { - case 0: element = FF7Item::elementRestoration(id); effect.append(tr("Restoration")); break; - case 1: element = FF7Item::elementFire(id); effect.append(tr("Fire")); break; - case 2: element = FF7Item::elementCold(id); effect.append(tr("Cold")); break; - case 3: element = FF7Item::elementLightning(id); effect.append(tr("Lightning")); break; - case 4: element = FF7Item::elementEarth(id); effect.append(tr("Earth")); break; - case 5: element = FF7Item::elementWind(id); effect.append(tr("Wind")); break; - case 6: element = FF7Item::elementWater(id); effect.append(tr("Water")); break; - case 7: element = FF7Item::elementGravity(id); effect.append(tr("Gravity")); break; - case 8: element = FF7Item::elementHoly(id); effect.append(tr("Holy")); break; - case 9: element = FF7Item::elementPoison(id); effect.append(tr("Poison")); break; - case 10: element = FF7Item::elementCut(id); effect.append(tr("Cut")); break; - case 11: element = FF7Item::elementShoot(id); effect.append(tr("Shoot")); break; - case 12: element = FF7Item::elementPunch(id); effect.append(tr("Punch")); break; - case 13: element = FF7Item::elementHit(id); effect.append(tr("Hit")); break; + case 0: element = FF7Item::elementRestoration(id); effect.append(tr("Restoration")); break; + case 1: element = FF7Item::elementFire(id); effect.append(tr("Fire")); break; + case 2: element = FF7Item::elementCold(id); effect.append(tr("Cold")); break; + case 3: element = FF7Item::elementLightning(id); effect.append(tr("Lightning")); break; + case 4: element = FF7Item::elementEarth(id); effect.append(tr("Earth")); break; + case 5: element = FF7Item::elementWind(id); effect.append(tr("Wind")); break; + case 6: element = FF7Item::elementWater(id); effect.append(tr("Water")); break; + case 7: element = FF7Item::elementGravity(id); effect.append(tr("Gravity")); break; + case 8: element = FF7Item::elementHoly(id); effect.append(tr("Holy")); break; + case 9: element = FF7Item::elementPoison(id); effect.append(tr("Poison")); break; + case 10: element = FF7Item::elementCut(id); effect.append(tr("Cut")); break; + case 11: element = FF7Item::elementShoot(id); effect.append(tr("Shoot")); break; + case 12: element = FF7Item::elementPunch(id); effect.append(tr("Punch")); break; + case 13: element = FF7Item::elementHit(id); effect.append(tr("Hit")); break; } switch (element) { - case FF7Item::Absorb: effect.prepend(tr("Absorb:")); break; - case FF7Item::Nullify: effect.prepend(tr("Nullify:")); break; - case FF7Item::Halve: effect.prepend(tr("Halve:")); break; - case FF7Item::NoEffect: effect.clear(); break; - case FF7Item::Damage: effect.prepend(tr("Attack:")); break; + case FF7Item::Absorb: effect.prepend(tr("Absorb:")); break; + case FF7Item::Nullify: effect.prepend(tr("Nullify:")); break; + case FF7Item::Halve: effect.prepend(tr("Halve:")); break; + case FF7Item::NoEffect: effect.clear(); break; + case FF7Item::Damage: effect.prepend(tr("Attack:")); break; } if (!effect.isNull()) { elemental_effects->addItem(effect); @@ -258,44 +257,43 @@ void ItemPreview::status_info(int id) int y = status_effects->contentsMargins().top() + status_effects->contentsMargins().bottom(); status_effects->clear(); bool show = false; - if (id < 0 || id > 319) {/*invalid number*/} - else { + if ((id >= 0) && (id <= 319)) { for (int i = 0; i < 24; i++) { QString effect; int status = 0; switch (i) { - case 0: status = FF7Item::statusDeath(id); effect.append(tr("Death")); break; - case 1: status = FF7Item::statusSlowNumb(id); effect.append(tr("Slow-Numb")); break; - case 2: status = FF7Item::statusDeathSentence(id); effect.append(tr("D.Sentence")); break; - case 3: status = FF7Item::statusParalysis(id); effect.append(tr("Paralysis")); break; - case 4: status = FF7Item::statusPetrify(id); effect.append(tr("Petrify")); break; - case 5: status = FF7Item::statusSilence(id); effect.append(tr("Silence")); break; - case 6: status = FF7Item::statusSleep(id); effect.append(tr("Sleep")); break; - case 7: status = FF7Item::statusConfusion(id); effect.append(tr("Confusion")); break; - case 8: status = FF7Item::statusBerserk(id); effect.append(tr("Berserk")); break; - case 9: status = FF7Item::statusFrog(id); effect.append(tr("Frog")); break; - case 10: status = FF7Item::statusMini(id); effect.append(tr("Mini")); break; - case 11: status = FF7Item::statusPoison(id); effect.append(tr("Poison")); break; - case 12: status = FF7Item::statusFury(id); effect.append(tr("Fury")); break; - case 13: status = FF7Item::statusSadness(id); effect.append(tr("Sadness")); break; - case 14: status = FF7Item::statusDarkness(id); effect.append(tr("Darkness")); break; - case 15: status = FF7Item::statusHaste(id); effect.append(tr("Haste")); break; - case 16: status = FF7Item::statusSlow(id); effect.append(tr("Slow")); break; - case 17: status = FF7Item::statusStop(id); effect.append(tr("Stop")); break; - case 18: status = FF7Item::statusBarrier(id); effect.append(tr("Barrier")); break; - case 19: status = FF7Item::statusMagicBarrier(id); effect.append(tr("M.Barrier")); break; - case 20: status = FF7Item::statusReflect(id); effect.append(tr("Reflect")); break; - case 21: status = FF7Item::statusShield(id); effect.append(tr("Shield")); break; - case 22: status = FF7Item::statusRegen(id); effect.append(tr("Regen")); break; - case 23: status = FF7Item::statusResist(id); effect.append(tr("Resist")); break; + case 0: status = FF7Item::statusDeath(id); effect.append(tr("Death")); break; + case 1: status = FF7Item::statusSlowNumb(id); effect.append(tr("Slow-Numb")); break; + case 2: status = FF7Item::statusDeathSentence(id); effect.append(tr("D.Sentence")); break; + case 3: status = FF7Item::statusParalysis(id); effect.append(tr("Paralysis")); break; + case 4: status = FF7Item::statusPetrify(id); effect.append(tr("Petrify")); break; + case 5: status = FF7Item::statusSilence(id); effect.append(tr("Silence")); break; + case 6: status = FF7Item::statusSleep(id); effect.append(tr("Sleep")); break; + case 7: status = FF7Item::statusConfusion(id); effect.append(tr("Confusion")); break; + case 8: status = FF7Item::statusBerserk(id); effect.append(tr("Berserk")); break; + case 9: status = FF7Item::statusFrog(id); effect.append(tr("Frog")); break; + case 10: status = FF7Item::statusMini(id); effect.append(tr("Mini")); break; + case 11: status = FF7Item::statusPoison(id); effect.append(tr("Poison")); break; + case 12: status = FF7Item::statusFury(id); effect.append(tr("Fury")); break; + case 13: status = FF7Item::statusSadness(id); effect.append(tr("Sadness")); break; + case 14: status = FF7Item::statusDarkness(id); effect.append(tr("Darkness")); break; + case 15: status = FF7Item::statusHaste(id); effect.append(tr("Haste")); break; + case 16: status = FF7Item::statusSlow(id); effect.append(tr("Slow")); break; + case 17: status = FF7Item::statusStop(id); effect.append(tr("Stop")); break; + case 18: status = FF7Item::statusBarrier(id); effect.append(tr("Barrier")); break; + case 19: status = FF7Item::statusMagicBarrier(id); effect.append(tr("M.Barrier")); break; + case 20: status = FF7Item::statusReflect(id); effect.append(tr("Reflect")); break; + case 21: status = FF7Item::statusShield(id); effect.append(tr("Shield")); break; + case 22: status = FF7Item::statusRegen(id); effect.append(tr("Regen")); break; + case 23: status = FF7Item::statusResist(id); effect.append(tr("Resist")); break; } switch (status) { - case FF7Item::Protect: effect.prepend(tr("Protect:")); break; - case FF7Item::Remove: effect.prepend(tr("Remove:")); break; - case FF7Item::NoEffect: effect.clear(); break; - case FF7Item::Infilict: effect.prepend(tr("Inflict:")); break; - case FF7Item::SelfCast: effect.prepend(tr("OnBattle:")); break; + case FF7Item::Protect: effect.prepend(tr("Protect:")); break; + case FF7Item::Remove: effect.prepend(tr("Remove:")); break; + case FF7Item::NoEffect: effect.clear(); break; + case FF7Item::Infilict: effect.prepend(tr("Inflict:")); break; + case FF7Item::SelfCast: effect.prepend(tr("OnBattle:")); break; } if (!effect.isNull()) { diff --git a/src/widgets/data/LocationViewer.cpp b/src/widgets/data/LocationViewer.cpp index cddc4fe0d..b18a95e29 100644 --- a/src/widgets/data/LocationViewer.cpp +++ b/src/widgets/data/LocationViewer.cpp @@ -63,18 +63,16 @@ void LocationViewer::resizeEvent(QResizeEvent *ev) { if (ev->type() == QResizeEvent::Resize) { QPixmap pix(QStringLiteral(":/locations/%1_%2").arg(QString::number(sbMapID->value()), QString::number(sbLocID->value()))); - if (pix.isNull()) { + if (pix.isNull()) return; - } lblLocationPreview->setPixmap(pix.scaled(lblLocationPreview->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation)); } } void LocationViewer::changeEvent(QEvent *e) { - if (e->type() == QEvent::LanguageChange) { + if (e->type() == QEvent::LanguageChange) updateText(); - } QWidget::changeEvent(e); } @@ -499,8 +497,8 @@ void LocationViewer::filterLocations(QString filter) QRegularExpression exp(filter); exp.setPatternOptions(caseSensitive ? QRegularExpression::PatternOption::NoPatternOption : QRegularExpression::CaseInsensitiveOption ); switch (searchMode) { - case NAME: searchName(exp); break; - case ITEM: searchItem(exp); break; + case NAME: searchName(exp); break; + case ITEM: searchItem(exp); break; } } @@ -510,9 +508,8 @@ void LocationViewer::actionNameSearchToggled(bool checked) actionItemSearchToggled(false); searchMode = NAME; lineTableFilter->setPlaceholderText(actionNameSearch->text()); - if (!lineTableFilter->text().isEmpty()) { + if (!lineTableFilter->text().isEmpty()) filterLocations(lineTableFilter->text()); - } } else { actionNameSearch->setChecked(false); } @@ -582,24 +579,14 @@ void LocationViewer::init_fieldItems(void) void LocationViewer::fieldItemListItemChanged(QModelIndex index) { - bool checked; - if (fieldItemList->item(index.row())->checkState() == Qt::Checked) - checked = true; - else - checked = false; - - Q_EMIT fieldItemChanged(index.row(), checked); - + Q_EMIT fieldItemChanged(index.row(), (fieldItemList->item(index.row())->checkState() == Qt::Checked)); } + void LocationViewer::setFieldItemChecked(int row, bool checked) { init_disconnect(); - if (fieldItemList->count() > row) { - if (checked) - fieldItemList->item(row)->setCheckState(Qt::Checked); - else - fieldItemList->item(row)->setCheckState(Qt::Unchecked); - } + if (fieldItemList->count() > row) + fieldItemList->item(row)->setCheckState(checked ? Qt::Checked : Qt::Unchecked); init_connections(); } void LocationViewer::searchName(QRegularExpression exp) @@ -632,7 +619,7 @@ void LocationViewer::searchItem(QRegularExpression exp) if(regExpSearch) { for (const FieldItem &fieldItem : FF7FieldItemList::fieldItemList()) { if (exp.match(QCoreApplication::translate("FF7FieldItemList", fieldItem.Text.toUtf8())).hasMatch()) - locationNames.append(fieldItem.Maps); + locationNames.append(fieldItem.Maps); } } else { Qt::CaseSensitivity caseSensitiveValue = caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive; diff --git a/src/widgets/data/MateriaEditor.cpp b/src/widgets/data/MateriaEditor.cpp index a9ead3362..3a0a7dd22 100644 --- a/src/widgets/data/MateriaEditor.cpp +++ b/src/widgets/data/MateriaEditor.cpp @@ -163,23 +163,21 @@ void MateriaEditor::setLevel() void MateriaEditor::setStars() { //show if its eskill Materia - if (FF7Materia::levels(_id) == 1 - || (_id == FF7Materia::EmptyId)) { + if ( (FF7Materia::levels(_id) == 1) || (_id == FF7Materia::EmptyId)) { box_stars->setHidden(true); return; - } else { - box_stars->setHidden(false); + } + box_stars->setHidden(false); + for (QPushButton *button : std::as_const(btn_stars)) + button->setHidden(true); + if (FF7Materia::type(_id) != 0) { for (QPushButton *button : std::as_const(btn_stars)) - button->setHidden(true); - if (FF7Materia::type(_id) != 0) { - for (QPushButton *button : std::as_const(btn_stars)) - button->setIcon(FF7Materia::pixmapEmptyStar(_id)); - } - for (int i = 0 ; i < _level ; i ++) - btn_stars.at(i)->setIcon(FF7Materia::pixmapFullStar(_id)); - for (int i = 0 ; i < FF7Materia::levels(_id) ; i ++) - btn_stars.at(i)->setHidden(false); + button->setIcon(FF7Materia::pixmapEmptyStar(_id)); } + for (int i = 0 ; i < _level ; i ++) + btn_stars.at(i)->setIcon(FF7Materia::pixmapFullStar(_id)); + for (int i = 0 ; i < FF7Materia::levels(_id) ; i ++) + btn_stars.at(i)->setHidden(false); } void MateriaEditor::setSkills() @@ -371,9 +369,8 @@ QHBoxLayout *MateriaEditor::makeNameLayout() combo_materia->setStyleSheet(_comboStyle); combo_materia->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); for (int i = 0; i < 91; i++) { - if (!FF7Materia::placeHolderIdList().contains(i)) { + if (!FF7Materia::placeHolderIdList().contains(i)) combo_materia->addItem(FF7Materia::pixmap(i), FF7Materia::name(i)); - } } connect(combo_materia, &QComboBox::currentTextChanged, this, &MateriaEditor::materia_changed); @@ -464,9 +461,8 @@ QWidget *MateriaEditor::makeStarWidget() auto stars = new QHBoxLayout; stars->setContentsMargins(3, 0, 0, 0); - for (QPushButton *button : std::as_const(btn_stars)) { + for (QPushButton *button : std::as_const(btn_stars)) stars->addWidget(button); - } auto spacer = new QSpacerItem(30, 0, QSizePolicy::Expanding, QSizePolicy::Fixed); stars->addSpacerItem(spacer); box_stars->setLayout(stars); diff --git a/src/widgets/data/MenuListWidget.cpp b/src/widgets/data/MenuListWidget.cpp index 66bfc1b71..81eb1f736 100644 --- a/src/widgets/data/MenuListWidget.cpp +++ b/src/widgets/data/MenuListWidget.cpp @@ -102,16 +102,16 @@ void MenuListWidget::setChecked(int row, int box, bool checked) { disconnectAll(); switch (row) { - case 0: cb_item->setChecked(box, checked); break; - case 1: cb_magic->setChecked(box, checked); break; - case 2: cb_materia->setChecked(box, checked); break; - case 3: cb_equip->setChecked(box, checked); break; - case 4: cb_status->setChecked(box, checked); break; - case 5: cb_order->setChecked(box, checked); break; - case 6: cb_limit->setChecked(box, checked); break; - case 7: cb_config->setChecked(box, checked); break; - case 8: cb_phs->setChecked(box, checked); break; - case 9: cb_save->setChecked(box, checked); break; + case 0: cb_item->setChecked(box, checked); break; + case 1: cb_magic->setChecked(box, checked); break; + case 2: cb_materia->setChecked(box, checked); break; + case 3: cb_equip->setChecked(box, checked); break; + case 4: cb_status->setChecked(box, checked); break; + case 5: cb_order->setChecked(box, checked); break; + case 6: cb_limit->setChecked(box, checked); break; + case 7: cb_config->setChecked(box, checked); break; + case 8: cb_phs->setChecked(box, checked); break; + case 9: cb_save->setChecked(box, checked); break; }; connectAll(); } diff --git a/src/widgets/data/SlotSelect.cpp b/src/widgets/data/SlotSelect.cpp index e09fcd2bc..87e4bc4cc 100644 --- a/src/widgets/data/SlotSelect.cpp +++ b/src/widgets/data/SlotSelect.cpp @@ -78,10 +78,9 @@ void SlotSelect::remove_slot(int s) void SlotSelect::copy_slot(int s) { - if (!ff7->isFF7(s)) { - //We can not Copy Non FF7 Slots Since we don't modify their region data and it will result in a duplicate index entry. + //We can not Copy Non FF7 Slots Since we don't modify their region data and it will result in a duplicate index entry. + if (!ff7->isFF7(s)) return; - } ff7->copySlot(s); } @@ -119,7 +118,9 @@ void SlotSelect::ReIntSlot(int s) void SlotSelect::setSlotPreview(int s) { - if (ff7->isFF7(s)) { + if (ff7->isSlotEmpty(s)) { + preview[s]->setMode(SlotPreview::EMPTY); + } else if (ff7->isFF7(s)) { preview[s]->setMode(SlotPreview::FF7SAVE); //show real Dialog background. QImage image(2, 2, QImage::Format_ARGB32); @@ -135,8 +136,6 @@ void SlotSelect::setSlotPreview(int s) preview[s]->setLevel(ff7->descLevel(s)); preview[s]->setGil(int(ff7->descGil(s))); preview[s]->setTime((ff7->descTime(s) / 3600), (ff7->descTime(s) / 60 % 60)); - } else if (ff7->isSlotEmpty(s)) { - preview[s]->setMode(SlotPreview::EMPTY); } else { // all other psx saves. preview[s]->setMode(SlotPreview::PSXGAME); @@ -148,11 +147,11 @@ void SlotSelect::setSlotPreview(int s) || ff7->psx_block_type(s) == char(FF7SaveInfo::PSXBLOCKTYPE::BLOCK_ENDLINK) || ff7->psx_block_type(s) == char(FF7SaveInfo::PSXBLOCKTYPE::BLOCK_DELETED_ENDLINK)) { switch (ff7->psx_block_type(s)) { - case char(FF7SaveInfo::PSXBLOCKTYPE::BLOCK_MIDLINK): Slottext.append(tr(" Mid-Linked Block")); break; - case char(FF7SaveInfo::PSXBLOCKTYPE::BLOCK_DELETED_MIDLINK): Slottext.append(tr(" Mid-Linked Block (Deleted)")); break; - case char(FF7SaveInfo::PSXBLOCKTYPE::BLOCK_ENDLINK): Slottext.append(tr(" End Of Linked Blocks")); break; - case char(FF7SaveInfo::PSXBLOCKTYPE::BLOCK_DELETED_ENDLINK): Slottext.append(tr(" End Of Linked Blocks (Deleted)")); break; - default: Slottext.append(tr("ERROR")); break; + case char(FF7SaveInfo::PSXBLOCKTYPE::BLOCK_MIDLINK): Slottext.append(tr(" Mid-Linked Block")); break; + case char(FF7SaveInfo::PSXBLOCKTYPE::BLOCK_DELETED_MIDLINK): Slottext.append(tr(" Mid-Linked Block (Deleted)")); break; + case char(FF7SaveInfo::PSXBLOCKTYPE::BLOCK_ENDLINK): Slottext.append(tr(" End Of Linked Blocks")); break; + case char(FF7SaveInfo::PSXBLOCKTYPE::BLOCK_DELETED_ENDLINK): Slottext.append(tr(" End Of Linked Blocks (Deleted)")); break; + default: Slottext.append(tr("ERROR")); break; } } Slottext.append(ff7->psxDesc(s));