GBA Pokémon now supported

Added some fields to PokemonUI
StrategyMemoUI now working properly
Other minor fixes
This commit is contained in:
Elouan Appéré
2015-09-12 22:50:05 +02:00
parent 3c863d7f5e
commit e73e92debd
40 changed files with 2661 additions and 715 deletions

View File

@@ -19,7 +19,7 @@
#ifndef _PKMGCSAVEEDITOR_GLOBALS_H
#define _PKMGCSAVEEDITOR_GLOBALS_H
#define PKMGCSAVEEDITOR_VERSION 1000000
#define PKMGCSAVEEDITOR_VERSION 1001000
#define PKMGCSAVEEDITOR_VERSION_MAJOR ((PKMGCSAVEEDITOR_VERSION / 1000000) % 1000)
#define PKMGCSAVEEDITOR_VERSION_MINOR ((PKMGCSAVEEDITOR_VERSION / 1000) % 1000)
#define PKMGCSAVEEDITOR_VERSION_BUILD (PKMGCSAVEEDITOR_VERSION % 1000)
@@ -28,6 +28,7 @@
#include <LibPkmGC/XD/SaveEditing/Save.h>
#include <LibPkmGC/Colosseum/SaveEditing/Save.h>
#include <LibPkmGC/Core/Localization.h>
#include <LibPkmGC/GBA/Pokemon.h>
#include <QLocale>
#include <QMap>

View File

@@ -64,7 +64,7 @@ void GameConfigUI::parseData(void) {
SaveSlot* sl = saveSlot_;
isXD = LIBPKMGC_IS_XD(SaveEditing::SaveSlot, sl);
versionFld->disconnect(SIGNAL(versionChanged()));
versionFld->disconnect(SIGNAL(versionChanged()), this);
versionFld->setInfo(sl->version);
connect(versionFld, SIGNAL(versionChanged()), this, SLOT(versionChangeHandler()));

View File

@@ -136,72 +136,45 @@ void PokemonDisplayWidget::deletePkm(void) {
QString PokemonDisplayWidget::selectFilters(void) {
QString PokemonDisplayWidget::selectFilters(bool op) {
const QString allsupportedfilesfilter = tr("All supported files (*.colopkm *.xdpkm *.pkm *.3gpkm)");
const QString colofilter = tr("Colosseum Pok\xc3\xa9mon files (*.colopkm)");
const QString xdfilter = tr("XD Pok\xc3\xa9mon files (*.xdpkm)");
const QString gbafilter = tr("GBA Pok\xc3\xa9mon files (*.pkm *.3gpkm)");
const QString gbaencfilter = tr("Encrypted GBA Pok\xc3\xa9mon files (*.pkm *.3gpkm)");
const QString allfilesfilter = tr("All files (*)");
return ((pkm == NULL || LIBPKMGC_IS_COLOSSEUM(Pokemon, pkm)) ?
colofilter + ";;" + xdfilter + ";;" + allfilesfilter :
xdfilter + ";;" + colofilter + ";;" + allfilesfilter);
QString F[] = { colofilter, xdfilter, gbafilter };
if (pkm != NULL) {
if (LIBPKMGC_IS_GBA(Pokemon, pkm)) std::swap(F[0], F[2]);
else if (LIBPKMGC_IS_XD(Pokemon, pkm)) std::swap(F[0], F[1]);
}
return (op) ? (allsupportedfilesfilter + ";;" + F[0] + ";;" + F[1] + ";;" + F[2]) :
(F[0] + ";;" + F[1] + ";;" + F[2] + ";;" + gbaencfilter);
}
void PokemonDisplayWidget::openImportPkmDialog(void) {
const QString errmsg = tr("Could not open file.");
const QString errmsg2 = tr("An error occured while reading the specified Pok\xc3\xa9mon file.");
QString fileName = QFileDialog::getOpenFileName(this, tr("Open Pok\xc3\xa9mon file"), lastPkmDirectory, selectFilters());
void PokemonDisplayWidget::openImportPkmDialog(void) {
QString fileName = QFileDialog::getOpenFileName(this, tr("Open Pok\xc3\xa9mon file"), lastPkmDirectory, selectFilters(true));
if (fileName.isEmpty()) return;
QFileInfo fileInfo(fileName);
size_t fileSize = (size_t) fileInfo.size();
if (fileSize == 0x138) { // Colosseum Pokémon
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly)) {
QMessageBox::critical(this, tr("Error"), errmsg);
return;
}
QByteArray ba = file.readAll();
if (ba.size() != 0x138) {
QMessageBox::critical(this, tr("Error"), errmsg2);
return;
}
Colosseum::Pokemon importedPkm((u8*)ba.data());
if (pkm == NULL) pkm = importedPkm.clone();
else { *pkm = importedPkm; }
parseData();
lastPkmDirectory = fileInfo.canonicalPath();
switch (fileSize) {
case 0x138: readExpected<Colosseum::Pokemon>(fileName); break;
case 0xc4: readExpected<XD::Pokemon>(fileName); break;
case 100: case 80: readExpected<GBA::Pokemon>(fileName, fileSize); break;
default: QMessageBox::critical(this, tr("Error"), tr("Invalid file size.")); break;
}
else if (fileSize == 0xc4) {
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly)) {
QMessageBox::critical(this, tr("Error"), errmsg);
return;
}
QByteArray ba = file.readAll();
if (ba.size() != 0xc4) {
QMessageBox::critical(this, tr("Error"), errmsg2);
return;
}
XD::Pokemon importedPkm((const u8*)ba.data());
if (pkm == NULL) pkm = importedPkm.clone();
else { *pkm = importedPkm; }
parseData();
lastPkmDirectory = fileInfo.canonicalPath();
}
else {
QMessageBox::critical(this, tr("Error"), tr("Invalid file size."));
}
}
void PokemonDisplayWidget::openExportPkmDialog(void) {
const QString errmsg = tr("Could not write to file.");
const QString errmsg2 = tr("An error occured while writing to the specified Pok\xc3\xa9mon file.");
const QString gbaencfilter = tr("Encrypted GBA Pok\xc3\xa9mon files (*.pkm *.3gpkm)");
QString fileName = QFileDialog::getSaveFileName(this, tr("Save Pok\xc3\xa9mon file"), lastPkmDirectory, selectFilters());
QString selectedFilter;
QString fileName = QFileDialog::getSaveFileName(this, tr("Save Pok\xc3\xa9mon file"), lastPkmDirectory, selectFilters(false), &selectedFilter);
if (fileName.isEmpty()) return;
QFile file(fileName);
@@ -213,7 +186,7 @@ void PokemonDisplayWidget::openExportPkmDialog(void) {
QString selectedExt = fileName.section(".", -1);
GC::Pokemon* exportedPkm = pkm;
Base::Pokemon* exportedPkm = pkm;
bool created = false;
if ((selectedExt == "colopkm") && !LIBPKMGC_IS_COLOSSEUM(Pokemon, pkm)) {
@@ -224,10 +197,22 @@ void PokemonDisplayWidget::openExportPkmDialog(void) {
exportedPkm = new XD::Pokemon(*(Colosseum::Pokemon*)pkm);
created = true;
}
else if ((selectedExt == "3gpkm" || selectedExt == "pkm") && !LIBPKMGC_IS_GBA(Pokemon, pkm)) {
exportedPkm = new GBA::Pokemon(*pkm);
created = true;
}
exportedPkm->save();
if (file.write((const char*)exportedPkm->data, exportedPkm->fixedSize) != (qint64)exportedPkm->fixedSize)
char* dta = (char*)exportedPkm->data;
QByteArray dt(100, 0);
if (selectedFilter == gbaencfilter) {
static_cast<GBA::Pokemon*>(exportedPkm)->saveEncrypted((u8*)dt.data());
dta = dt.data();
}
if (file.write(dta, exportedPkm->fixedSize) != (qint64)exportedPkm->fixedSize)
QMessageBox::critical(this, tr("Error"), errmsg2);
else
lastPkmDirectory = QFileInfo(fileName).canonicalPath();

View File

@@ -43,7 +43,50 @@ private:
QPushButton *importButton;
QPushButton *exportButton;
QString selectFilters(void);
QString selectFilters(bool op = true);
template<typename P>
void readExpected(QString fileName, size_t sz = P::size) {
const QString errmsg = tr("Could not open file.");
const QString errmsg2 = tr("An error occured while reading the specified Pok\xc3\xa9mon file.");
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly)) {
QMessageBox::critical(this, tr("Error"), errmsg);
return;
}
QByteArray ba = file.readAll();
if (ba.size() != sz) {
QMessageBox::critical(this, tr("Error"), errmsg2);
return;
}
P* importedPkm = NULL;
if (sz != 80)
importedPkm = new P((const u8*)ba.data());
else {
GBA::Pokemon* pk2 = GBA::Pokemon::load80((const u8*)ba.data());
importedPkm = new P(*pk2);
delete pk2;
}
if (pkm == NULL) {
if (LIBPKMGC_IS_XD(Pokemon, importedPkm) || (currentSaveSlot != NULL && LIBPKMGC_IS_XD(SaveEditing::SaveSlot, currentSaveSlot)))
pkm = new XD::Pokemon(*importedPkm);
else
pkm = new Colosseum::Pokemon(*importedPkm);
}
else *pkm = *importedPkm;
if (P::size == 100 && currentSaveSlot != NULL)
pkm->version.currentRegion = currentSaveSlot->version.currentRegion;
parseData();
lastPkmDirectory = QFileInfo(fileName).canonicalPath();
delete importedPkm;
}
};

View File

@@ -16,12 +16,18 @@ PokemonMoveLayout::PokemonMoveLayout(PokemonMove const& inMove) : QHBoxLayout(){
currentPPsFld->setRange(0, 64);
this->addWidget(moveNameFld);
this->addWidget(currentPPsFld);
this->addWidget(maxPPsFld);
this->addWidget(nbPPUpsUsedFld, 0, Qt::AlignRight);
this->addWidget(nbPPUpsUsedText, 0, Qt::AlignRight);
QHBoxLayout* w1 = new QHBoxLayout;
w1->addWidget(moveNameFld);
w1->addWidget(currentPPsFld);
w1->addWidget(maxPPsFld);
QHBoxLayout* w2 = new QHBoxLayout;
w2->addWidget(nbPPUpsUsedFld);
w2->addWidget(nbPPUpsUsedText);
w2->setAlignment(Qt::AlignRight);
this->addLayout(w1, 3);
this->addLayout(w2, 1);
for (size_t i = 0; i <= (size_t)PsychoBoost; ++i)
moveNameFld->addItem(getPokemonMoveName(lg, (PokemonMoveIndex)i));
@@ -38,12 +44,17 @@ PokemonMove PokemonMoveLayout::move(void) const {
}
void PokemonMoveLayout::setMove(PokemonMove const& inMove) {
blockSignals(true);
moveNameFld->disconnect(SIGNAL(currentIndexChanged(int)), this);
nbPPUpsUsedFld->disconnect(SIGNAL(valueChanged(int)), this);
currentPPsFld->setUnsignedRange(0, 64);
currentPPsFld->setUnsignedValue(inMove.currentPPs);
moveNameFld->setCurrentIndex((inMove.moveIndex > PsychoBoost) ? 0 : (int) inMove.moveIndex);
moveNameFld->setCurrentIndex((inMove.move > PsychoBoost) ? 0 : (int) inMove.move);
nbPPUpsUsedFld->setUnsignedValue(inMove.nbPPUpsUsed);
blockSignals(false);
connect(moveNameFld, SIGNAL(currentIndexChanged(int)), this, SLOT(updateFields()));
connect(nbPPUpsUsedFld, SIGNAL(valueChanged(int)), this, SLOT(updateFields()));
updateFields();
}
@@ -59,9 +70,9 @@ PokemonStatLayout::PokemonStatLayout(u8 inIV, u8 inEV, u16 inStat) : QHBoxLayout
EVFld = new UnsignedSpinbox<8>;
statFld = new UnsignedSpinbox<16>;
IVFld->setValue((int)inIV);
EVFld->setValue((int)inEV);
statFld->setValue((int)inStat);
IVFld->setUnsignedValue(inIV);
EVFld->setUnsignedValue(inEV);
statFld->setUnsignedValue(inStat);
this->addWidget(IVFld);
this->addWidget(EVFld);
this->addWidget(statFld);
@@ -111,13 +122,19 @@ void PokemonUI::initWidget(void){
movesTab = new QWidget;
ribbonsTab = new QWidget;
generalTabLayout = new QFormLayout;
generalTabLayout = new QVBoxLayout;
metTabLayout = new QVBoxLayout;
statsTabLayout = new QVBoxLayout;
movesTabLayout = new QVBoxLayout;
ribbonsTabLayout = new QVBoxLayout;
//-----------------------------"General" tab:-----------------------------------------------
generalSubTabs = new QTabWidget;
generalCoreSubTab = new QWidget;
generalCoreSubTabLayout = new QFormLayout;
generalStatusSubTab = new QWidget;
generalStatusSubTabLayout = new QFormLayout;
speciesFld = new QComboBox;
nameLayout = new QHBoxLayout;
@@ -134,14 +151,14 @@ void PokemonUI::initWidget(void){
heldItemFld = new ItemComboBox;
happinessFld = new UnsignedSpinbox<8>;
pkrsStatusFld = new UnsignedSpinbox<8>;
statusFld = new QComboBox;
pkrsStatusLayout = new QHBoxLayout;
pkrsDaysRemainingFld = new UnsignedSpinbox<3>;
pkrsStrainFld = new UnsignedSpinbox<4>;
flagsLayout = new QGridLayout;
flagsButtonGroup = new QButtonGroup;
markingsLayout = new QHBoxLayout;
markingsButtonGroup = new QButtonGroup;
statusFld->addItems(statusNames());
for (size_t i = 0; i < 387; ++i)
speciesFld->addItem(Localization::getPokemonSpeciesNameByPkdxIndex(lg, i));
@@ -155,6 +172,8 @@ void PokemonUI::initWidget(void){
levelFld->setRange(1, 100);
syncLevelAndExpFldsCheckBox->setChecked(true);
pkrsDaysRemainingFld->setUnsignedRange(0, 4);
experienceLevelAndSyncLayout->addWidget(experienceFld,2);
levelAndSyncLayout->addWidget(levelFld,1);
@@ -162,6 +181,9 @@ void PokemonUI::initWidget(void){
levelAndSyncLayout->setAlignment(Qt::AlignRight);
experienceLevelAndSyncLayout->addLayout(levelAndSyncLayout);
pkrsStatusLayout->addWidget(pkrsDaysRemainingFld);
pkrsStatusLayout->addWidget(pkrsStrainFld);
eggFlagCheckBox = new QCheckBox(tr("Egg")); secondAbilityFlagCheckBox = new QCheckBox(tr("Second ability"));
invalidPokemonCheckBox = new QCheckBox(tr("Invalid Pok\xc3\xa9mon"));
notTradableInGameFlagCheckBox = new QCheckBox(tr("Not tradable in-game")); unknownFlagCheckBox = new QCheckBox(tr("Unknown"));
@@ -190,20 +212,43 @@ void PokemonUI::initWidget(void){
markingsLayout->addWidget(g2[i]);
}
generalTabLayout->addRow(tr("Species"), speciesFld);
generalTabLayout->addRow(tr("Name or nickname"), nameLayout);
generalTabLayout->addRow(tr("PID"), PIDFld);
generalTabLayout->addRow(tr("Attributes"), attributesFld);
generalTabLayout->addRow(tr("Ability"), abilityFld);
generalTabLayout->addRow(tr("Experience and level"), experienceLevelAndSyncLayout);
generalTabLayout->addRow(tr("Held item"), heldItemFld);
generalTabLayout->addRow(tr("Happiness"), happinessFld);
generalTabLayout->addRow(tr("Pok\xc3\xa9rus"), pkrsStatusFld);
generalTabLayout->addRow(tr("Status"), statusFld);
generalTabLayout->addRow(tr("Flags"), flagsLayout);
generalTabLayout->addRow(tr("Markings"), markingsLayout);
generalCoreSubTabLayout->addRow(tr("Species"), speciesFld);
generalCoreSubTabLayout->addRow(tr("Name or nickname"), nameLayout);
generalCoreSubTabLayout->addRow(tr("PID"), PIDFld);
generalCoreSubTabLayout->addRow(tr("Attributes"), attributesFld);
generalCoreSubTabLayout->addRow(tr("Ability"), abilityFld);
generalCoreSubTabLayout->addRow(tr("Experience and level"), experienceLevelAndSyncLayout);
generalCoreSubTabLayout->addRow(tr("Held item"), heldItemFld);
generalCoreSubTabLayout->addRow(tr("Happiness"), happinessFld);
generalCoreSubTabLayout->addRow(tr("Pok\xc3\xa9rus (days remaing and strain)"), pkrsStatusLayout);
generalCoreSubTabLayout->addRow(tr("Flags"), flagsLayout);
generalCoreSubTabLayout->addRow(tr("Markings"), markingsLayout);
statusFld = new QComboBox;
partyPrksDaysRemainingFld = new QSpinBox;
turnsOfBadPoisonFld = new QSpinBox;
turnsOfSleepRemainingFld = new QSpinBox;
statusFld->addItems(statusNames());
partyPrksDaysRemainingFld->setRange(-1, 4);
turnsOfBadPoisonFld->setRange(0, 15);
turnsOfSleepRemainingFld->setRange(0, 7);
generalStatusSubTabLayout->addRow(tr("Status"), statusFld);
generalStatusSubTabLayout->addRow(tr("Pok\xc3\xa9rus days remaining"), partyPrksDaysRemainingFld);
generalStatusSubTabLayout->addRow(tr("Turns of sleep remaining"), turnsOfSleepRemainingFld);
generalStatusSubTabLayout->addRow(tr("Turns of bad poison"), turnsOfBadPoisonFld);
generalCoreSubTab->setLayout(generalCoreSubTabLayout);
generalStatusSubTab->setLayout(generalStatusSubTabLayout);
generalSubTabs->addTab(generalCoreSubTab, tr("Core"));
generalSubTabs->addTab(generalStatusSubTab, tr("Status"));
generalTabLayout->addWidget(generalSubTabs);
generalTab->setLayout(generalTabLayout);
//----------------------------------------------------------------------------------------
@@ -217,16 +262,23 @@ void PokemonUI::initWidget(void){
OTField = new TrainerInfoLayout;
versionFld = new VersionInfoLayout;
ballCaughtWithFld = new ItemComboBox(POKEBALLS_ALLOWED | EMPTY_ITEM_FORBIDDEN);
locationCaughtFld = new UnsignedSpinbox<8>;
levelMetFld = new UnsignedSpinbox<7>;
obedientFld = new QCheckBox;
ballCaughtWithFld = new ItemComboBox(POKEBALLS_ALLOWED | EMPTY_ITEM_FORBIDDEN);
metActionsLayout = new QHBoxLayout;
copyInfoFromSaveButton = new QPushButton(tr("Copy info from save"));
generateShinyIDsButton = new QPushButton(tr("Generate shiny IDs"));
coreCaptureInfoLayout->addRow(tr("Ball caught with"), ballCaughtWithFld);
coreCaptureInfoLayout->addRow(tr("Location caught"), locationCaughtFld);
levelMetFld->setUnsignedRange(1, 100);
coreCaptureInfoLayout->addRow(tr("Location caught"), locationCaughtFld);
coreCaptureInfoLayout->addRow(tr("Level met"), levelMetFld);
coreCaptureInfoLayout->addRow(tr("Fateful encounter (obedient)"), obedientFld);
coreCaptureInfoLayout->addRow(tr("Ball caught with"), ballCaughtWithFld);
coreCaptureInfoLayout->labelForField(obedientFld)->setToolTip(tr("Mew and Deoxys need this field to be checked so they can obey"));
coreCaptureInfoBox->setLayout(coreCaptureInfoLayout);
OTBox->setLayout(OTField);
versionBox->setLayout(versionFld);
@@ -343,7 +395,6 @@ void PokemonUI::initWidget(void){
generalTab->setLayout(generalTabLayout);
metTab->setLayout(metTabLayout);
statsTab->setLayout(statsTabLayout);
movesTab->setLayout(movesTabLayout);
@@ -364,6 +415,8 @@ void PokemonUI::initWidget(void){
connect(abilityFld, SIGNAL(currentIndexChanged(int)), this, SLOT(updateFlags()));
connect(experienceFld, SIGNAL(valueChanged(int)), this, SLOT(updateLevelFromExperience()));
connect(levelFld, SIGNAL(valueChanged(int)), this, SLOT(updateExperienceFromLevel()));
connect(statusFld, SIGNAL(currentIndexChanged(int)), SLOT(statusChangeHandler()));
connect(pkrsStrainFld, SIGNAL(valueChanged(int)), this, SLOT(updatePkrsDaysRemaining()));
connect(OTField, SIGNAL(TIDorSIDChanged()), this, SLOT(updatePkmAttributes()));
connect(versionFld, SIGNAL(versionChanged()), this, SLOT(versionChangeHandler()));
connect(copyInfoFromSaveButton, SIGNAL(clicked()), this, SLOT(copyInfoFromSave()));
@@ -376,7 +429,7 @@ void PokemonUI::parseData(void){
if (pkm == NULL) return;
copyInfoFromSaveButton->setDisabled(currentSaveSlot == NULL);
// Blocking signals have a strange yet enormous cost on the main window when loading the save
// Blocking signals have a strange yet enormous cost on the main window when loading the save file
autoUpdateMainStatsCheckBox->setChecked(false);
syncLevelAndExpFldsCheckBox->setChecked(false);
@@ -408,8 +461,37 @@ void PokemonUI::parseData(void){
heldItemFld->setCurrentItemIndex(pkm->heldItem);
happinessFld->setUnsignedValue(pkm->happiness);
pkrsStatusFld->setUnsignedValue(pkm->pkrsStatus);
statusFld->disconnect(SIGNAL(currentIndexChanged(int)), this);
statusFld->setCurrentIndex((pkm->partyData.status == NoStatus) ? 0 : (int)pkm->partyData.status - 2);
turnsOfBadPoisonFld->setValue(pkm->partyData.turnsOfBadPoison);
turnsOfSleepRemainingFld->setValue(pkm->partyData.turnsOfSleepRemaining);
statusChangeHandler();
connect(statusFld, SIGNAL(currentIndexChanged(int)), SLOT(statusChangeHandler()));
pkrsStrainFld->disconnect(SIGNAL(valueChanged(int)), this);
pkrsStrainFld->setUnsignedValue(pkm->pkrsStatus & 0xf);
pkrsDaysRemainingFld->setUnsignedValue(pkm->pkrsStatus >> 4);
partyPrksDaysRemainingFld->setValue(pkm->pkrsStatus >> 4);
updatePkrsDaysRemaining();
/*if ((pkm->pkrsStatus & 0xf) == 0) {
pkrsDaysRemainingFld->setValue(0);
pkrsDaysRemainingFld->setDisabled(true);
partyPrksDaysRemainingFld->setValue(-1);
partyPrksDaysRemainingFld->setDisabled(true);
}
else {
pkrsDaysRemainingFld->setUnsignedRange(0, (pkm->pkrsStatus & 0x3) + 1);
partyPrksDaysRemainingFld->setRange(0, (pkm->pkrsStatus & 0x3) + 1);
pkrsDaysRemainingFld->setUnsignedValue(pkm->pkrsStatus >> 4);
partyPrksDaysRemainingFld->setValue(pkm->pkrsStatus >> 4);
}*/
connect(pkrsStrainFld, SIGNAL(valueChanged(int)), this, SLOT(updatePkrsDaysRemaining()));
QCheckBox* g1[] = { eggFlagCheckBox, secondAbilityFlagCheckBox, invalidPokemonCheckBox,
notTradableInGameFlagCheckBox, unknownFlagCheckBox, caughtFlagCheckBox };
@@ -425,12 +507,14 @@ void PokemonUI::parseData(void){
squareMarkingCheckBox->setChecked(pkm->markings.square);
triangleMarkingCheckBox->setChecked(pkm->markings.triangle);
heartMarkingCheckBox->setChecked(pkm->markings.heart);
ballCaughtWithFld->setCurrentItemIndex(pkm->ballCaughtWith);
locationCaughtFld->setUnsignedValue(pkm->locationCaught);
levelMetFld->setUnsignedValue(pkm->levelMet);
ballCaughtWithFld->setCurrentItemIndex(pkm->ballCaughtWith);
obedientFld->setChecked(pkm->obedient);
OTField->set(pkm->OTName, pkm->TID, pkm->SID, pkm->OTGender);
versionFld->disconnect(SIGNAL(versionChanged()));
versionFld->disconnect(SIGNAL(versionChanged()), this);
versionFld->setInfo(pkm->version);
connect(versionFld, SIGNAL(versionChanged()), this, SLOT(versionChangeHandler()));
@@ -454,7 +538,7 @@ void PokemonUI::parseData(void){
autoUpdateMainStatsCheckBox->setChecked(true);
versionChangeHandler();
abilityFld->setCurrentIndex((pkm->pkmFlags[LIBPKMGC_GC_SECOND_ABILITY_FLAG]) ? 1 : 0);
abilityFld->setCurrentIndex((pkm->hasSecondAbility()) ? 1 : 0);
oldSpecies = pkm->species;
}
@@ -464,13 +548,14 @@ void PokemonUI::saveChanges(void){
pkm->name->fromUTF8(nameFld->text().toUtf8().data());
pkm->PID = PIDFld->unsignedValue();
pkm->pkmFlags[LIBPKMGC_GC_SECOND_ABILITY_FLAG] = (abilityFld->currentIndex() != 0);
pkm->setSecondAbilityFlag(abilityFld->currentIndex() != 0);
pkm->experience = experienceFld->unsignedValue();
pkm->partyData.level = (u8)levelFld->unsignedValue();
pkm->heldItem = heldItemFld->currentItemIndex();
pkm->happiness = (u8)happinessFld->unsignedValue();
pkm->pkrsStatus = (u8)pkrsStatusFld->unsignedValue();
pkm->pkrsStatus = (u8)((pkrsDaysRemainingFld->unsignedValue() << 4) | pkrsStrainFld->unsignedValue());
pkm->partyData.pkrsDaysRemaining = (s8)(partyPrksDaysRemainingFld->value());
pkm->partyData.status = (statusFld->currentIndex() == 0) ? NoStatus : (PokemonStatus)(2 + statusFld->currentIndex());
QCheckBox* g1[] = { eggFlagCheckBox, secondAbilityFlagCheckBox, invalidPokemonCheckBox,
@@ -487,8 +572,10 @@ void PokemonUI::saveChanges(void){
pkm->markings.triangle = triangleMarkingCheckBox->isChecked();
pkm->markings.heart = heartMarkingCheckBox->isChecked();
pkm->ballCaughtWith = ballCaughtWithFld->currentItemIndex();
pkm->locationCaught = (u8)locationCaughtFld->unsignedValue();
pkm->levelMet = (u8)levelMetFld->unsignedValue();
pkm->ballCaughtWith = ballCaughtWithFld->currentItemIndex();
pkm->obedient = obedientFld->isChecked();
OTField->trainerName(pkm->OTName);
pkm->TID = OTField->TID();
@@ -631,8 +718,8 @@ void PokemonUI::updateAbilityList(void) {
const PokemonAbilityIndex* ab = getSpeciesData(id).possibleAbilities;
bool sec = abilityFld->currentIndex() == 1;
disconnect(abilityFld, SIGNAL(currentIndexChanged(int)));
disconnect(secondAbilityFlagCheckBox, SIGNAL(stateChanged(int)));
abilityFld->disconnect(SIGNAL(currentIndexChanged(int)), this);
secondAbilityFlagCheckBox->disconnect(SIGNAL(stateChanged(int)), this);
abilityFld->clear();
abilityFld->addItem(Localization::getPokemonAbilityName(lg, ab[0]));
@@ -652,7 +739,6 @@ void PokemonUI::updateAbilityList(void) {
void PokemonUI::updateExperienceFromLevel(bool proportionally) {
proportionally = false; // not working a.t.m
if (syncLevelAndExpFldsCheckBox->isChecked()) {
u32 experience = 0;
if (!proportionally) {
@@ -663,7 +749,7 @@ void PokemonUI::updateExperienceFromLevel(bool proportionally) {
else {
experience = Base::Pokemon::fixExperienceProportionally(oldSpecies, experienceFld->unsignedValue(), nameIndexToPkmSpeciesIndex(speciesFld->currentIndex()));
}
experienceFld->disconnect(SIGNAL(valueChanged(int)));
experienceFld->disconnect(SIGNAL(valueChanged(int)), this);
experienceFld->setValue((int)experience);
connect(experienceFld, SIGNAL(valueChanged(int)), this, SLOT(updateLevelFromExperience()));
}
@@ -673,7 +759,7 @@ void PokemonUI::updateLevelFromExperience(void) {
if (syncLevelAndExpFldsCheckBox->isChecked()) {
u8 lvl = Pokemon::calculateLevelFromExp(nameIndexToPkmSpeciesIndex((size_t)speciesFld->currentIndex()), (u32)experienceFld->value());
levelFld->disconnect(SIGNAL(valueChanged(int)));
levelFld->disconnect(SIGNAL(valueChanged(int)), this);
levelFld->setValue((int)lvl);
connect(levelFld, SIGNAL(valueChanged(int)), this, SLOT(updateExperienceFromLevel()));
}
@@ -694,6 +780,42 @@ void PokemonUI::PIDChangeHandler(void) {
updateMainStats();
}
void PokemonUI::updatePkrsDaysRemaining(void) {
if (pkrsStrainFld->unsignedValue() == 0) {
pkrsDaysRemainingFld->setValue(0);
pkrsDaysRemainingFld->setDisabled(true);
partyPrksDaysRemainingFld->setRange(-1, -1);
partyPrksDaysRemainingFld->setValue(-1);
partyPrksDaysRemainingFld->setDisabled(true);
}
else {
pkrsDaysRemainingFld->setDisabled(false);
partyPrksDaysRemainingFld->setDisabled(false);
pkrsDaysRemainingFld->setUnsignedRange(0, (pkrsStrainFld->unsignedValue() & 0x3) + 1);
partyPrksDaysRemainingFld->setRange(0, (pkrsStrainFld->unsignedValue() & 0x3) + 1);
}
}
void PokemonUI::statusChangeHandler(void) {
PokemonStatus status = (statusFld->currentIndex() == 0) ? NoStatus : (PokemonStatus)(2 + statusFld->currentIndex());
if (status != BadlyPoisoned) {
turnsOfBadPoisonFld->setValue(0);
turnsOfBadPoisonFld->setDisabled(true);
}
else {
turnsOfBadPoisonFld->setDisabled(false);
}
if (status != Asleep) {
turnsOfSleepRemainingFld->setValue(0);
turnsOfSleepRemainingFld->setDisabled(true);
}
else {
turnsOfSleepRemainingFld->setDisabled(false);
}
}
void PokemonUI::updateFlags(void) {
secondAbilityFlagCheckBox->setDisabled(abilityFld->count() == 1);
secondAbilityFlagCheckBox->setChecked(abilityFld->currentIndex() == 1);

View File

@@ -100,11 +100,17 @@ protected:
private:
QTabWidget* tabs;
QWidget *generalTab, *metTab;
QFormLayout *generalTabLayout;
QWidget *generalTab;
QWidget *metTab;
QVBoxLayout *metTabLayout;
// "General" tab:
QVBoxLayout *generalTabLayout;
QTabWidget *generalSubTabs;
QWidget *generalCoreSubTab, *generalStatusSubTab;
QFormLayout *generalCoreSubTabLayout, *generalStatusSubTabLayout;
QComboBox *speciesFld;
QHBoxLayout* nameLayout;
QLineEdit* nameFld;
@@ -123,9 +129,15 @@ private:
ItemComboBox* heldItemFld;
UnsignedSpinbox<8>* happinessFld;
UnsignedSpinbox<8>* pkrsStatusFld;
QHBoxLayout* pkrsStatusLayout;
UnsignedSpinbox<3>* pkrsDaysRemainingFld;
UnsignedSpinbox<4>* pkrsStrainFld;
QComboBox* statusFld;
QSpinBox* turnsOfBadPoisonFld;
QSpinBox* turnsOfSleepRemainingFld;
QSpinBox* partyPrksDaysRemainingFld;
QGridLayout *flagsLayout;
QButtonGroup *flagsButtonGroup;
@@ -140,8 +152,10 @@ private:
// "Met" tab:
QGroupBox* coreCaptureInfoBox;
QFormLayout* coreCaptureInfoLayout;
ItemComboBox* ballCaughtWithFld;
UnsignedSpinbox<8>* locationCaughtFld;
ItemComboBox* ballCaughtWithFld;
UnsignedSpinbox<7>* levelMetFld;
QCheckBox* obedientFld;
QGroupBox* OTBox;
TrainerInfoLayout* OTField;
@@ -172,7 +186,6 @@ private:
// "Moves" tab:
QWidget* movesTab;
QVBoxLayout* movesTabLayout;
//QHBoxLayout* movesTitleLayout;
PokemonMoveLayout* moveLayouts[4];
// "Ribbons" tab:
@@ -197,6 +210,8 @@ public slots:
void updateLevelFromExperience(void);
void speciesChangeHandler(void);
void PIDChangeHandler(void);
void updatePkrsDaysRemaining(void);
void statusChangeHandler(void);
void updateFlags(void);
void flagsStateChangeHandler(void);

View File

@@ -49,6 +49,10 @@ void StrategyMemoEntryWidget::generateShinyIDs(void) {
firstSIDFld->setUnsignedValue(PID & 0xffff);
}
void StrategyMemoEntryWidget::truncateMemoFromHere(void) {
speciesSelector->setCurrentIndex(0);
}
void StrategyMemoEntryWidget::initWidget(void) {
LanguageIndex lg = generateDumpedNamesLanguage();
mainLayout = new QVBoxLayout;
@@ -63,6 +67,7 @@ void StrategyMemoEntryWidget::initWidget(void) {
firstPIDFld = new UnsignedSpinbox<32>;
PIDText = new QLabel;
generateShinyIDsButton = new QPushButton(tr("Generate shiny IDs"));
truncateMemoFromHereButton = new QPushButton(tr("Truncate memo from here"));
for (size_t i = 0; i <= 386; ++i)
speciesSelector->addItem(getPokemonSpeciesNameByPkdxIndex(lg, (u16)i));
@@ -77,6 +82,7 @@ void StrategyMemoEntryWidget::initWidget(void) {
mainLayout2->addRow(tr("Partial information"), partialInfoCheckBox);
mainLayout->addLayout(mainLayout2);
mainLayout->addWidget(generateShinyIDsButton);
mainLayout->addWidget(truncateMemoFromHereButton);
mainLayout2->setHorizontalSpacing(20);
this->setLayout(mainLayout);
@@ -87,6 +93,7 @@ void StrategyMemoEntryWidget::initWidget(void) {
connect(firstTIDFld, SIGNAL(valueChanged(int)), this, SLOT(updatePIDText()));
connect(firstSIDFld, SIGNAL(valueChanged(int)), this, SLOT(updatePIDText()));
connect(generateShinyIDsButton, SIGNAL(clicked()), this, SLOT(generateShinyIDs()));
connect(truncateMemoFromHereButton, SIGNAL(clicked()), this, SLOT(truncateMemoFromHere()));
}
StrategyMemoEntryWidget::~StrategyMemoEntryWidget(void) {

View File

@@ -47,10 +47,11 @@ public:
signals:
void speciesChanged(int index, size_t nameIndex);
public slots:
public slots:
void speciesChangeHandler(int nameIndex);
void updatePIDText(void);
void generateShinyIDs(void);
void truncateMemoFromHere(void);
protected:
void initWidget(void);
@@ -67,6 +68,7 @@ private:
UnsignedSpinbox<32> *firstPIDFld;
QLabel* PIDText;
QPushButton* generateShinyIDsButton;
QPushButton* truncateMemoFromHereButton;
};

View File

@@ -39,6 +39,7 @@ void StrategyMemoUI::initWidget(void) {
entrySelector = new QComboBox;
nbEntriesFld = new UnsignedSpinbox<16>;
nbEntriesFld->setDisabled(true);
currentEntry = new StrategyMemoEntryWidget;
connect(currentEntry, SIGNAL(speciesChanged(int, size_t)), this, SLOT(updateEntryNameAndNbEntries(int, size_t)));