EvBox::EvBox(QWidget *parent) : QWidget(parent), ui(new Ui::EvBox) { ui->setupUi(this); QSlider *sliders[6] = {ui->hpslider, ui->atkslider, ui->defslider, ui->satkslider, ui->sdefslider, ui->speedslider}; QLabel *descs[6] = {ui->hpdesc, ui->atkdesc, ui->defdesc, ui->satkdesc, ui->sdefdesc, ui->speeddesc}; QLabel *labels[6] = {ui->hplabel, ui->atklabel, ui->deflabel, ui->satklabel, ui->sdeflabel, ui->speedlabel}; QLineEdit *edits[6] = {ui->hpedit, ui->atkedit, ui->defedit, ui->satkedit, ui->sdefedit, ui->speededit}; QImageButtonLR *boosts[6] = {ui->hpboost, ui->atkboost, ui->defboost, ui->satkboost, ui->sdefboost, ui->speedboost}; memcpy(m_sliders, sliders, sizeof(sliders)); memcpy(m_descs, descs, sizeof(descs)); memcpy(m_stats, labels, sizeof(labels)); memcpy(m_evs, edits, sizeof(edits)); memcpy(m_boosts, boosts, sizeof(boosts)); #define setNums(var) for (int i = 0; i < 6; i++) { var[i]->setProperty("stat", i);} setNums(m_sliders); setNums(m_evs); setNums(m_boosts); #undef setNums for(int i = 0; i < 6; i++) { connect(m_sliders[i], SIGNAL(valueChanged(int)), this, SLOT(changeEV(int))); connect(m_evs[i], SIGNAL(textChanged(QString)), this, SLOT(changeEV(QString))); connect(m_boosts[i], SIGNAL(rightClick()), this, SLOT(changeToMinusBoost())); connect(m_boosts[i], SIGNAL(leftClick()), this, SLOT(changeToPlusBoost())); } }
IvBox::IvBox(QWidget *parent) : QWidget(parent), ui(new Ui::IvBox) { ui->setupUi(this); QLabel *statsLabels[6] = {ui->hpivlabel, ui->attivlabel, ui->defivlabel, ui->spattivlabel, ui->spdefivlabel, ui->speedivlabel}; QSpinBox *ivChangers[6] = {ui->hpivspin, ui->attivspin, ui->defivspin, ui->spattivspin, ui->spdefivspin, ui->speedivspin}; QRadioButton *abilitiesButtons[3] = {ui->ability1, ui->ability2, ui->ability3}; memcpy(m_statslabel, statsLabels, sizeof(statsLabels)); memcpy(m_ivchangers, ivChangers, sizeof(ivChangers)); memcpy(m_abilities, abilitiesButtons, sizeof(abilitiesButtons)); #define setNums(var) for(int i = 0; i < 6; i++) { var[i]->setProperty("ivstat", i); } setNums(m_ivchangers); #undef setNums for(int i = 0; i < 6; i++) { connect(m_ivchangers[i], SIGNAL(valueChanged(int)), this, SLOT(changeIV(int))); } for (int i = 0; i < 3; i++) { connect(m_abilities[i], SIGNAL(toggled(bool)), this, SLOT(changeAbility())); } for(int i = 1; i < TypeInfo::NumberOfTypes() - 1; i++) { ui->hiddenPowerType->addItem(TypeInfo::Name(i)); } connect(ui->hiddenPowerType, SIGNAL(activated(int)), this, SLOT(changeHiddenPower(int))); }
IvBox::IvBox(QWidget *parent) : QWidget(parent), ui(new Ui::IvBox) { ui->setupUi(this); QLabel *statsLabels[6] = {ui->hpivlabel, ui->attivlabel, ui->defivlabel, ui->spattivlabel, ui->spdefivlabel, ui->speedivlabel}; QSpinBox *ivChangers[6] = {ui->hpivspin, ui->attivspin, ui->defivspin, ui->spattivspin, ui->spdefivspin, ui->speedivspin}; memcpy(m_statslabel, statsLabels, sizeof(statsLabels)); memcpy(m_ivchangers, ivChangers, sizeof(ivChangers)); #define setNums(var) for(int i = 0; i < 6; i++) { var[i]->setProperty("ivstat", i); } setNums(m_ivchangers); #undef setNums for(int i = 0; i < 6; i++) { connect(m_ivchangers[i], SIGNAL(valueChanged(int)), this, SLOT(changeIV(int))); } for(int i = 1; i < Type::Curse-1; i++) { ui->hiddenPowerType->addItem(TypeInfo::Name(i)); } connect(ui->hiddenPowerType, SIGNAL(activated(int)), this, SLOT(changeHiddenPower(int))); connect(ui->hpchoice, SIGNAL(cellActivated(int,int)), SLOT(changeHPSelection(int))); }