Skip to content

Commit

Permalink
Allow editing of mod materia ids
Browse files Browse the repository at this point in the history
  • Loading branch information
sithlord48 committed Aug 4, 2024
1 parent 0a0367d commit faba680
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 35 deletions.
2 changes: 2 additions & 0 deletions src/data/FF7Materia.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ class FF7TKDATA_EXPORT FF7Materia : public QObject
if(m.name.startsWith(get()->d->_placeHolderFilter))
phList.append(m.id);
}
for (int i = 91; i < FF7Materia::EmptyId; i++)
phList.append(i);
return phList;
}

Expand Down
8 changes: 2 additions & 6 deletions src/widgets/data/CharEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void CharEditor::changeEvent(QEvent *e)
weapon_selection->setStyleSheet(comboStyle);
armor_selection->setStyleSheet(comboStyle);
accessory_selection->setStyleSheet(comboStyle);
for(auto m : materiaSlotFrames) {
for(auto m : std::as_const(materiaSlotFrames)) {
m->setStyleSheet(transparentBackgroundStyle);
}
}
Expand Down Expand Up @@ -2081,11 +2081,7 @@ void CharEditor::update_materia_slots()
}
void CharEditor::matId_changed(qint8 id)
{
if (id >= 0 && id < 91)
data.materias[mslotsel].id = quint8(id);
else
data.materias[mslotsel].id = FF7Materia::EmptyId;

data.materias[mslotsel].id = quint8(id);
if (!load) {
Q_EMIT materiaChanged(data.materias[mslotsel]);
/* Remove for 2.0 */Q_EMIT Materias_changed(data.materias[mslotsel]);
Expand Down
65 changes: 36 additions & 29 deletions src/widgets/data/MateriaEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,43 +52,42 @@ void MateriaEditor::init_display()

void MateriaEditor::setMateria(quint8 materia_id, qint32 materia_ap)
{
if (materia_id < 91) {
//valid Materia..
if (_id != materia_id) {
_id = materia_id;
sb_ap->setEnabled(1);
Q_EMIT idChanged(qint8(_id));
}
} else {
//Invalid Data Reset Materia.
if (_id != FF7Materia::EmptyId)
Q_EMIT idChanged(qint8(FF7Materia::EmptyId));
_id = FF7Materia::EmptyId;
sb_ap->setEnabled(false);
sb_ap->setValue(FF7Materia::MaxMateriaAp);
_current_ap = FF7Materia::MaxMateriaAp;//set since setAp ingores the 0xFF id.
if(_id == materia_id)
return;
_id = materia_id;
Q_EMIT idChanged(qint8(_id));
sb_ap->setEnabled(_id != FF7Materia::EmptyId);

if (FF7Materia::isModID(_id) && _showPlaceHolders == false) {
setShowPlaceHolderMateria(true);
}

if (_id > FF7Materia::TotalMateria) {
box_status_effects->setHidden(true);
box_stats->setHidden(true);
}

if (_id == FF7Materia::EmptyId) {
sb_ap->setValue(FF7Materia::MaxMateriaAp);
_current_ap = FF7Materia::MaxMateriaAp;//set since setAp ingores the 0xFF id.
}
setName();
setAP(materia_ap);
setStats();
}

void MateriaEditor::setAP(qint32 ap)
{
if (FF7Materia::levels(_id) == 1) {
if (_id == FF7Materia::EnemySkill) {
if (_current_ap != ap) {
_current_ap = ap;
Q_EMIT apChanged(_current_ap);
}
if (_id == FF7Materia::EnemySkill) {
for (int i = 0; i < 24; i++) {
if (_current_ap & (1 << i))
eskill_list->item(i)->setCheckState(Qt::Checked);
else
eskill_list->item(i)->setCheckState(Qt::Unchecked);
}
for (int i = 0; i < 24; i++) {
if (_current_ap & (1 << i))
eskill_list->item(i)->setCheckState(Qt::Checked);
else
eskill_list->item(i)->setCheckState(Qt::Unchecked);
}
} else {
//All Other Materia
Expand Down Expand Up @@ -121,7 +120,7 @@ void MateriaEditor::setName()
if (combo_type->currentIndex() != FF7Materia::AllMaterias)
combo_type->setCurrentIndex(FF7Materia::type(_id));
combo_materia->setCurrentIndex(combo_materia->findText(FF7Materia::name(_id)));
if(FF7Materia::levels(_id) != 1)
if(FF7Materia::levels(_id) != 1 || FF7Materia::isModID(_id))
frm_ap_stars->setHidden(false);
}
}
Expand All @@ -130,6 +129,11 @@ void MateriaEditor::setStats()
{
list_status->clear();
lbl_stats->clear();
if (FF7Materia::isModID(_id)) {
box_skills->setHidden(true);
box_status_effects->setHidden(true);
return;
}
QString title = tr("Skills");
if (_id != FF7Materia::EmptyId) {
if (!FF7Materia::element(_id).isEmpty()) {
Expand Down Expand Up @@ -183,11 +187,14 @@ void MateriaEditor::setStars()
void MateriaEditor::setSkills()
{
list_skills->clear();
box_skills->setHidden(false);
box_skills->setHidden(true);
eskill_group->setHidden(true);
list_skills->setHidden(false);
frm_skill_status->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
if(FF7Materia::isModID(_id))
return;
box_skills->setHidden(false);

frm_skill_status->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
if (_id == FF7Materia::EmptyId) {
box_skills->setHidden(true);
list_skills->setHidden(true);
Expand All @@ -205,13 +212,13 @@ void MateriaEditor::typeChanged(int new_type)
combo_materia->clear();
combo_materia->blockSignals(true);
if (new_type == 0) {
for (int i = 0; i < 91; i++) {
for (int i = 0; i < FF7Materia::EmptyId; i++) {
if (!_showPlaceHolders && FF7Materia::placeHolderIdList().contains(i))
continue;
combo_materia->addItem(FF7Materia::icon(i), FF7Materia::name(i));
}
} else {
for (int i = 0; i < 91; i++) {
for (int i = 0; i < FF7Materia::EmptyId; i++) {
if (FF7Materia::type(i) == new_type)
combo_materia->addItem(FF7Materia::icon(i), FF7Materia::name(i));
}
Expand All @@ -225,7 +232,7 @@ void MateriaEditor::typeChanged(int new_type)

void MateriaEditor::materia_changed(const QString &new_name)
{
for (quint8 i = 0; i < 91; i++) {
for (quint8 i = 0; i < FF7Materia::EmptyId; i++) {
if (!_showPlaceHolders && FF7Materia::placeHolderIdList().contains(i))
continue;
if (FF7Materia::name(i) == new_name) {
Expand Down

0 comments on commit faba680

Please sign in to comment.