From b69cae8a5d2ce8be58aeb4dc9699d83c466fded6 Mon Sep 17 00:00:00 2001 From: TuxSH Date: Sat, 10 Oct 2015 20:50:20 +0200 Subject: [PATCH] =?UTF-8?q?=20*=20Added=20autocompletion=20for=20Pok=C3=A9?= =?UTF-8?q?mon,=20item,=20and=20move=20names.=20=20*=20Added=20the=20follo?= =?UTF-8?q?wing=20buttons=20to=20the=20Strategy=20Memo=20editor:=20'Fill?= =?UTF-8?q?=20memo'=20(for=20both=20Colosseum=20and=20XD)=20and=20'Fill=20?= =?UTF-8?q?memo=20(all=20shiny)'=20(for=20Colosseum=20only)=20buttons=20.?= =?UTF-8?q?=20=20*=20Stats=20boosted=20(resp.=20hindered)=20by=20each=20na?= =?UTF-8?q?ture=20are=20now=20displayed=20in=20red=20(resp.=20blue).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 7 + LibPkmGC/include/LibPkmGC/Core/Config.h | 2 +- LibPkmGC/include/LibPkmGC/Core/LCRNG32.h | 5 +- .../LibPkmGC/GC/Common/StrategyMemoData.h | 40 ++- .../LibPkmGC/GC/Common/StrategyMemoEntry.h | 8 + .../LibPkmGC/GC/Common/StrategyMemoData.cpp | 21 +- .../LibPkmGC/GC/Common/StrategyMemoEntry.cpp | 6 + .../src/Core/AutocompletingComboBox.cpp | 45 ++++ .../src/Core/AutocompletingComboBox.h | 39 +++ PkmGCSaveEditor/src/Core/Globals.h | 2 +- PkmGCSaveEditor/src/Core/ItemComboBox.cpp | 4 +- PkmGCSaveEditor/src/Core/ItemComboBox.h | 4 +- PkmGCSaveEditor/src/GCUIs/PokemonUI.cpp | 36 ++- PkmGCSaveEditor/src/GCUIs/PokemonUI.h | 4 +- .../src/GCUIs/StrategyMemoEntryWidget.cpp | 10 +- .../src/GCUIs/StrategyMemoEntryWidget.h | 3 +- PkmGCSaveEditor/src/GCUIs/StrategyMemoUI.cpp | 41 ++- PkmGCSaveEditor/src/GCUIs/StrategyMemoUI.h | 8 +- .../translations/PkmGCSaveEditor_de.ts | 244 +++++++++--------- .../translations/PkmGCSaveEditor_en.ts | 244 +++++++++--------- .../translations/PkmGCSaveEditor_fr.ts | 244 +++++++++--------- 21 files changed, 636 insertions(+), 381 deletions(-) create mode 100644 PkmGCSaveEditor/src/Core/AutocompletingComboBox.cpp create mode 100644 PkmGCSaveEditor/src/Core/AutocompletingComboBox.h diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e7fcf6..facdf19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +###PkmGCTools v1.2.1: +* Mostly ergonomic changes: + * Move names are now displayed next to CTs. + * Added autocompletion for Pokémon, item, and move names. + * Added the following buttons to the Strategy Memo editor: 'Fill memo' (for both Colosseum and XD) and 'Fill memo (all shiny)' (for Colosseum only) buttons . + * Stats boosted (resp. hindered) by each nature are now displayed in red (resp. blue). + ###PkmGCTools v1.2: * The interface can now be displayed in **German** (thanks [peterpansexuell](http://www.smogon.com/forums/members/peterpansexuell.158307/) !) * Updates can now be automatically checked for at startup (this is the default) diff --git a/LibPkmGC/include/LibPkmGC/Core/Config.h b/LibPkmGC/include/LibPkmGC/Core/Config.h index 775b887..ffb7083 100644 --- a/LibPkmGC/include/LibPkmGC/Core/Config.h +++ b/LibPkmGC/include/LibPkmGC/Core/Config.h @@ -22,7 +22,7 @@ #include #include -#define LIBPKMGC_VERSION 1002000 +#define LIBPKMGC_VERSION 1002001 #define LIBPKMGC_VERSION_MAJOR ((LIBPKMGC_VERSION / 1000000) % 1000) #define LIBPKMGC_VERSION_MINOR ((LIBPKMGC_VERSION / 1000) % 1000) #define LIBPKMGC_VERSION_BUILD (LIBPKMGC_VERSION % 1000) diff --git a/LibPkmGC/include/LibPkmGC/Core/LCRNG32.h b/LibPkmGC/include/LibPkmGC/Core/LCRNG32.h index ba08be2..af62606 100644 --- a/LibPkmGC/include/LibPkmGC/Core/LCRNG32.h +++ b/LibPkmGC/include/LibPkmGC/Core/LCRNG32.h @@ -135,8 +135,11 @@ public: >::type reverse_generator_type; + static u32 advance32(forward_generator_type rng) { + return (rng() & 0xffff) | (rng() << 16); + } - bool buildParallelSeedTable(u32 initialSeed, u32 nbThreads, u32* outSeeds) { + static bool buildParallelSeedTable(u32 initialSeed, u32 nbThreads, u32* outSeeds) { if (nbThreads == 0) return false; outSeeds[0] = initialSeed; switch (nbThreads) { diff --git a/LibPkmGC/include/LibPkmGC/GC/Common/StrategyMemoData.h b/LibPkmGC/include/LibPkmGC/GC/Common/StrategyMemoData.h index bdce150..5edd8e6 100644 --- a/LibPkmGC/include/LibPkmGC/GC/Common/StrategyMemoData.h +++ b/LibPkmGC/include/LibPkmGC/GC/Common/StrategyMemoData.h @@ -57,9 +57,10 @@ public: size_t recount(void) const; - void sortedBySpeciesIndex(StrategyMemoEntry* dst[0x19b]); // only entries containing a valid Gen III species index are sorted - virtual void fixInvalidEntries(void); + void sortedBySpeciesIndex(StrategyMemoEntry* dst[0x19d]); // only entries containing a valid Gen III species index are sorted + virtual void fixInvalidEntries(StrategyMemoEntry** dst = NULL); + void setInfoCompletenessForAll(bool incomplete); u16 nbEntries; StrategyMemoEntry* entries[500]; @@ -69,6 +70,41 @@ protected: virtual void deleteFields(void); virtual void loadFields(void); +public: + template + void clearMemo(RNGType& rng) { + nbEntries = 0; + for (size_t i = 0; i < 500; ++i) { + entries[i]->species = NoSpecies; + entries[i]->flags = 0; + entries[i]->generateRandomPID(rng); + } + } + + template + void fillMemo(RNGType& rng, bool allShiny = false) { + allShiny = allShiny && !isXD(); + StrategyMemoEntry* bySpecies[0x19d]; + fixInvalidEntries(bySpecies); + for (PokemonSpeciesIndex i = NoSpecies; i <= Chimecho; i = (PokemonSpeciesIndex)(i+1)) { + size_t index = (size_t)i; + if (!getSpeciesData(i).isValid) continue; + if (bySpecies[i] == NULL) { + StrategyMemoEntry *entry = entries[nbEntries++]; + bySpecies[i] = entry; + entry->species = i; + entry->firstTID = (u16)((u32)rng() >> 16); + entry->firstSID = (u16)((u32)rng() >> 16); + entries[nbEntries]->generateRandomPID(rng); + } + StrategyMemoEntry *entry = bySpecies[i]; + if (allShiny) entry->firstSID = entry->firstTID ^ (entry->firstPID >> 16) ^ (entry->firstPID & 0xffff); + } + + setInfoCompletenessForAll(false); + } + + }; } diff --git a/LibPkmGC/include/LibPkmGC/GC/Common/StrategyMemoEntry.h b/LibPkmGC/include/LibPkmGC/GC/Common/StrategyMemoEntry.h index 55dfb6c..572d36b 100644 --- a/LibPkmGC/include/LibPkmGC/GC/Common/StrategyMemoEntry.h +++ b/LibPkmGC/include/LibPkmGC/GC/Common/StrategyMemoEntry.h @@ -52,10 +52,18 @@ public: void swap(StrategyMemoEntry& other); bool isEmpty(void) const; + bool isShiny(void) const; + + template + void generateRandomPID(RNGType& rng) { + firstPID = (((u32)rng() >> 16) | (((u32)rng() >> 16) << 16)) % 0xffffffff; // <-- no & 0xffff here + } + virtual bool isInfoIncomplete(void) const = 0; virtual void setInfoCompleteness(bool incomplete) = 0; + u16 flags; PokemonSpeciesIndex species; u16 firstSID, firstTID; diff --git a/LibPkmGC/src/LibPkmGC/GC/Common/StrategyMemoData.cpp b/LibPkmGC/src/LibPkmGC/GC/Common/StrategyMemoData.cpp index af23c25..633e5f1 100644 --- a/LibPkmGC/src/LibPkmGC/GC/Common/StrategyMemoData.cpp +++ b/LibPkmGC/src/LibPkmGC/GC/Common/StrategyMemoData.cpp @@ -52,11 +52,9 @@ StrategyMemoData& StrategyMemoData::operator=(StrategyMemoData const& other) { void StrategyMemoData::loadFields(void) { LD_FIELD(u16, nbEntries, 0); - //if (nbEntries > 0x1f4) nbEntries = 0x1f4; } void StrategyMemoData::save(void) { - //if (nbEntries > 0x1f4) nbEntries = 0x1f4; SV_FIELD(u16, nbEntries, 0); } @@ -101,16 +99,16 @@ size_t StrategyMemoData::recount(void) const { return i; } -void StrategyMemoData::sortedBySpeciesIndex(StrategyMemoEntry* dst[0x19b]) { - std::fill(dst, dst + 0x19b, (StrategyMemoEntry*)NULL); +void StrategyMemoData::sortedBySpeciesIndex(StrategyMemoEntry* dst[0x19d]) { + std::fill(dst, dst + 0x19d, (StrategyMemoEntry*)NULL); for (size_t i = 0; i < (size_t)nbEntries; ++i) { size_t index = (size_t)entries[i]->species; - if ((dst[index] != NULL) && (index <= 0x19b) && (getSpeciesData(entries[i]->species).isValid)) dst[index] = entries[i]; + if ((dst[index] == NULL) && (index <= 0x19b) && (getSpeciesData(entries[i]->species).isValid)) dst[index] = entries[i]; } } -void StrategyMemoData::fixInvalidEntries(void) { - StrategyMemoEntry* bySpecies[0x19b] = { NULL }; +void StrategyMemoData::fixInvalidEntries(StrategyMemoEntry** dst) { + StrategyMemoEntry* bySpecies[0x19d] = { NULL }; StrategyMemoEntry* entries2[500] = { NULL }; StrategyMemoEntry* emptyobj = entries[0]->create(); @@ -118,7 +116,7 @@ void StrategyMemoData::fixInvalidEntries(void) { nbEntries = 0; for (size_t i = 0; i < 500; ++i) { size_t index = (size_t)entries[i]->species; - if ((bySpecies[index] != NULL) && (index <= 0x19b) && (getSpeciesData(entries[i]->species).isValid)) { + if ((bySpecies[index] == NULL) && (index <= 0x19b) && (getSpeciesData(entries[i]->species).isValid)) { bySpecies[index] = entries[i]; entries2[nbEntries++] = entries[i]; } @@ -131,8 +129,13 @@ void StrategyMemoData::fixInvalidEntries(void) { if (entries2[i] == NULL) entries2[i] = emptyobj->clone(); } - std::copy(entries2, entries2 + nbEntries, entries); + std::copy(entries2, entries2 + 500, entries); delete emptyobj; + if (dst != NULL) std::copy(bySpecies, bySpecies + 0x19d, dst); +} + +void StrategyMemoData::setInfoCompletenessForAll(bool incomplete) { + for (size_t i = 0; i < 500; ++i) entries[i]->setInfoCompleteness(incomplete); } } diff --git a/LibPkmGC/src/LibPkmGC/GC/Common/StrategyMemoEntry.cpp b/LibPkmGC/src/LibPkmGC/GC/Common/StrategyMemoEntry.cpp index d3cadbe..ab7bb31 100644 --- a/LibPkmGC/src/LibPkmGC/GC/Common/StrategyMemoEntry.cpp +++ b/LibPkmGC/src/LibPkmGC/GC/Common/StrategyMemoEntry.cpp @@ -59,9 +59,15 @@ void StrategyMemoEntry::save(void) { SV_FIELD(u32, firstPID, 8); } +bool StrategyMemoEntry::isShiny(void) const { + return !isXD() && (((firstPID >> 16) ^ (firstPID & 0xffff) ^ firstSID ^ firstTID) < 8); +} + bool StrategyMemoEntry::isEmpty(void) const { return species == NoSpecies; } + + } } \ No newline at end of file diff --git a/PkmGCSaveEditor/src/Core/AutocompletingComboBox.cpp b/PkmGCSaveEditor/src/Core/AutocompletingComboBox.cpp new file mode 100644 index 0000000..8027c20 --- /dev/null +++ b/PkmGCSaveEditor/src/Core/AutocompletingComboBox.cpp @@ -0,0 +1,45 @@ +/* +* Copyright (C) TuxSH 2015 +* This file is part of PkmGCSaveEditor. +* +* PkmGCSaveEditor is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* PkmGCSaveEditor is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with PkmGCSaveEditor. If not, see . +*/ + +#include +#include +#include + +AutocompletingComboBox::AutocompletingComboBox(QWidget* parent) : QComboBox(parent) { + setEditable(true); + setInsertPolicy(QComboBox::NoInsert); + completer()->setCompletionMode(QCompleter::PopupCompletion); + + connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(resetColor())); +} + +void AutocompletingComboBox::resetColor(void) { + QAbstractItemModel* m = completer()->model(); + if (QPalette::Base, (m->match(m->index(0, 0), Qt::DisplayRole, currentText(), 1, Qt::MatchFlags(Qt::MatchExactly | Qt::MatchWrap) ).isEmpty())) { + QPalette pal = palette(); + pal.setColor(QPalette::Base, QColor(233,150,122)); + setPalette(pal); + } + else + setPalette(QApplication::palette(this)); +} + +void AutocompletingComboBox::focusOutEvent(QFocusEvent * ev) { + resetColor(); + QComboBox::focusOutEvent(ev); +} diff --git a/PkmGCSaveEditor/src/Core/AutocompletingComboBox.h b/PkmGCSaveEditor/src/Core/AutocompletingComboBox.h new file mode 100644 index 0000000..a36d047 --- /dev/null +++ b/PkmGCSaveEditor/src/Core/AutocompletingComboBox.h @@ -0,0 +1,39 @@ +/* +* Copyright (C) TuxSH 2015 +* This file is part of PkmGCSaveEditor. +* +* PkmGCSaveEditor is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* PkmGCSaveEditor is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with PkmGCSaveEditor. If not, see . +*/ + +#ifndef _PKMGCSAVEEDITOR_AUTOCOMPLETING_COMBO_BOX_H +#define _PKMGCSAVEEDITOR_AUTOCOMPLETING_COMBO_BOX_H + +#include +#include + +class AutocompletingComboBox : public QComboBox { + Q_OBJECT + +public: + AutocompletingComboBox(QWidget* parent = 0); + +public slots: + void resetColor(void); + +protected: + void focusOutEvent(QFocusEvent* ev); + +}; + +#endif \ No newline at end of file diff --git a/PkmGCSaveEditor/src/Core/Globals.h b/PkmGCSaveEditor/src/Core/Globals.h index 2769542..7c4efbb 100644 --- a/PkmGCSaveEditor/src/Core/Globals.h +++ b/PkmGCSaveEditor/src/Core/Globals.h @@ -19,7 +19,7 @@ #ifndef _PKMGCSAVEEDITOR_GLOBALS_H #define _PKMGCSAVEEDITOR_GLOBALS_H -#define PKMGCSAVEEDITOR_VERSION 1002000 +#define PKMGCSAVEEDITOR_VERSION 1002001 #define PKMGCSAVEEDITOR_VERSION_MAJOR ((PKMGCSAVEEDITOR_VERSION / 1000000) % 1000) #define PKMGCSAVEEDITOR_VERSION_MINOR ((PKMGCSAVEEDITOR_VERSION / 1000) % 1000) #define PKMGCSAVEEDITOR_VERSION_BUILD (PKMGCSAVEEDITOR_VERSION % 1000) diff --git a/PkmGCSaveEditor/src/Core/ItemComboBox.cpp b/PkmGCSaveEditor/src/Core/ItemComboBox.cpp index 338de9b..53d4135 100644 --- a/PkmGCSaveEditor/src/Core/ItemComboBox.cpp +++ b/PkmGCSaveEditor/src/Core/ItemComboBox.cpp @@ -21,9 +21,11 @@ using namespace LibPkmGC; using namespace LibPkmGC::Localization; -ItemComboBox::ItemComboBox(unsigned int inFlags, bool isXD, QWidget* parent) : QComboBox(parent), _flags(inFlags), _isXD(isXD){ +ItemComboBox::ItemComboBox(unsigned int inFlags, bool isXD, QWidget* parent) : AutocompletingComboBox(parent), _flags(inFlags), _isXD(isXD){ _indices = new ItemIndex[336]; // 245 + 91 _reverseIndices = new int[594]; + setEditable(true); + setInsertPolicy(QComboBox::NoInsert); resetItemList(); } diff --git a/PkmGCSaveEditor/src/Core/ItemComboBox.h b/PkmGCSaveEditor/src/Core/ItemComboBox.h index e524677..7bbf23c 100644 --- a/PkmGCSaveEditor/src/Core/ItemComboBox.h +++ b/PkmGCSaveEditor/src/Core/ItemComboBox.h @@ -20,7 +20,7 @@ #define _PKMGCSAVEEDITOR_ITEM_COMBO_BOX_H #include -#include +#include #include // (1 << ((int)categoryIndex) @@ -36,7 +36,7 @@ #define GIVABLE_ITEMS_ALLOWED 30 // (2|4|8|16) -class ItemComboBox : public QComboBox { +class ItemComboBox : public AutocompletingComboBox { public: ItemComboBox(unsigned int inFlags = 0, bool isXD = false, QWidget* parent = NULL); ~ItemComboBox(void); diff --git a/PkmGCSaveEditor/src/GCUIs/PokemonUI.cpp b/PkmGCSaveEditor/src/GCUIs/PokemonUI.cpp index b0f677d..8a28e6b 100644 --- a/PkmGCSaveEditor/src/GCUIs/PokemonUI.cpp +++ b/PkmGCSaveEditor/src/GCUIs/PokemonUI.cpp @@ -18,6 +18,9 @@ #include #include +#include +#include +#include using namespace LibPkmGC; using namespace Localization; using namespace Base; @@ -26,12 +29,14 @@ namespace GCUIs { PokemonMoveLayout::PokemonMoveLayout(PokemonMove const& inMove) : QHBoxLayout(){ LanguageIndex lg = generateDumpedNamesLanguage(); - moveNameFld = new QComboBox; + moveNameFld = new AutocompletingComboBox; currentPPsFld = new UnsignedSpinbox<7>; maxPPsFld = new QLabel(tr("(max. %n)", "", 0)); nbPPUpsUsedFld = new UnsignedSpinbox<2>; nbPPUpsUsedText = new QLabel(tr("PP Up(s) used")); + moveNameFld->setEditable(true); + moveNameFld->setInsertPolicy(QComboBox::NoInsert); currentPPsFld->setRange(0, 64); QHBoxLayout* w1 = new QHBoxLayout; @@ -167,7 +172,7 @@ void PokemonUI::initWidget(void){ generalStatusSubTab = new QWidget; generalStatusSubTabLayout = new QFormLayout; - speciesFld = new QComboBox; + speciesFld = new AutocompletingComboBox; nameLayout = new QHBoxLayout; nameFld = new QLineEdit; resetNameButton = new QPushButton(tr("Reset")); @@ -190,7 +195,6 @@ void PokemonUI::initWidget(void){ markingsLayout = new QHBoxLayout; markingsButtonGroup = new QButtonGroup; - for (size_t i = 0; i < 387; ++i) speciesFld->addItem(Localization::getPokemonSpeciesNameByPkdxIndex(lg, i)); @@ -819,6 +823,23 @@ void PokemonUI::speciesChangeHandler(void) { void PokemonUI::PIDChangeHandler(void) { updatePkmAttributes(); updateMainStats(); + + for (size_t i = 0; i < 6; ++i) { + PokemonNatureAffinity aff = getNatureStatAffinity(Base::Pokemon::getNature(PIDFld->unsignedValue()), i); + if (aff == Beneficial) { + QPalette pal = palette(); + pal.setColor(QPalette::Foreground, Qt::red); + mainStatsFormLayout->labelForField(mainStatsFlds[i])->setPalette(pal); + } + else if (aff == Detrimental) { + QPalette pal = palette(); + pal.setColor(QPalette::Foreground, Qt::blue); + mainStatsFormLayout->labelForField(mainStatsFlds[i])->setPalette(pal); + } + else + mainStatsFormLayout->labelForField(mainStatsFlds[i])->setPalette(QApplication::palette(mainStatsFormLayout->labelForField(mainStatsFlds[i]))); + + } } void PokemonUI::updatePokerusDaysRemaining(void) { @@ -902,8 +923,13 @@ void PokemonUI::copyInfoFromSave(void) { } void PokemonUI::generateShinyIDs(void) { - OTField->setTID((u16)(PIDFld->unsignedValue() >> 16)); - OTField->setSID((u16)PIDFld->unsignedValue()); + static GCRNG::forward_generator_type rng(time(NULL)); + u32 PID = PIDFld->unsignedValue(); + u32 TID = rng() >> 16; + u32 setUnsignedValue((PID >> 16) ^ (PID & 0xffff) ^ TID); + + OTField->setTID((u16)TID); + OTField->setSID((u16)((PID >> 16) ^ (PID & 0xffff) ^ TID)); } diff --git a/PkmGCSaveEditor/src/GCUIs/PokemonUI.h b/PkmGCSaveEditor/src/GCUIs/PokemonUI.h index e84adbb..4155629 100644 --- a/PkmGCSaveEditor/src/GCUIs/PokemonUI.h +++ b/PkmGCSaveEditor/src/GCUIs/PokemonUI.h @@ -61,7 +61,7 @@ public: private: - QComboBox *moveNameFld; + AutocompletingComboBox *moveNameFld; UnsignedSpinbox<7> *currentPPsFld; QLabel *maxPPsFld; UnsignedSpinbox<2> *nbPPUpsUsedFld; @@ -113,7 +113,7 @@ private: QWidget *generalCoreSubTab, *generalStatusSubTab; QFormLayout *generalCoreSubTabLayout, *generalStatusSubTabLayout; - QComboBox *speciesFld; + AutocompletingComboBox *speciesFld; QHBoxLayout* nameLayout; QLineEdit* nameFld; QPushButton *resetNameButton; diff --git a/PkmGCSaveEditor/src/GCUIs/StrategyMemoEntryWidget.cpp b/PkmGCSaveEditor/src/GCUIs/StrategyMemoEntryWidget.cpp index 7ffb176..db2cf1e 100644 --- a/PkmGCSaveEditor/src/GCUIs/StrategyMemoEntryWidget.cpp +++ b/PkmGCSaveEditor/src/GCUIs/StrategyMemoEntryWidget.cpp @@ -17,6 +17,8 @@ */ #include +#include +#include using namespace LibPkmGC; using namespace Localization; @@ -44,9 +46,11 @@ void StrategyMemoEntryWidget::updatePIDText(void) { } void StrategyMemoEntryWidget::generateShinyIDs(void) { + static GCRNG::forward_generator_type rng(time(NULL)); u32 PID = firstPIDFld->unsignedValue(); - firstTIDFld->setUnsignedValue(PID >> 16); - firstSIDFld->setUnsignedValue(PID & 0xffff); + u32 TID = rng() >> 16; + firstTIDFld->setUnsignedValue(TID); + firstSIDFld->setUnsignedValue((PID >> 16) ^ (PID & 0xffff) ^ TID); } void StrategyMemoEntryWidget::truncateMemoFromHere(void) { @@ -57,7 +61,7 @@ void StrategyMemoEntryWidget::initWidget(void) { LanguageIndex lg = generateDumpedNamesLanguage(); mainLayout = new QVBoxLayout; mainLayout2 = new QFormLayout; - speciesSelector = new QComboBox; + speciesSelector = new AutocompletingComboBox; incompleteInfoCheckBox = new QCheckBox; diff --git a/PkmGCSaveEditor/src/GCUIs/StrategyMemoEntryWidget.h b/PkmGCSaveEditor/src/GCUIs/StrategyMemoEntryWidget.h index 7dd981c..1fc1a91 100644 --- a/PkmGCSaveEditor/src/GCUIs/StrategyMemoEntryWidget.h +++ b/PkmGCSaveEditor/src/GCUIs/StrategyMemoEntryWidget.h @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -58,7 +59,7 @@ private: bool isXD; QVBoxLayout *mainLayout; QFormLayout *mainLayout2; - QComboBox *speciesSelector; + AutocompletingComboBox *speciesSelector; QCheckBox *incompleteInfoCheckBox; diff --git a/PkmGCSaveEditor/src/GCUIs/StrategyMemoUI.cpp b/PkmGCSaveEditor/src/GCUIs/StrategyMemoUI.cpp index b4d9cbb..a803ced 100644 --- a/PkmGCSaveEditor/src/GCUIs/StrategyMemoUI.cpp +++ b/PkmGCSaveEditor/src/GCUIs/StrategyMemoUI.cpp @@ -17,6 +17,9 @@ */ #include +#include +#include +#include using namespace LibPkmGC; using namespace Localization; @@ -36,7 +39,13 @@ StrategyMemoUI::~StrategyMemoUI(void) { void StrategyMemoUI::initWidget(void) { LanguageIndex lg = generateDumpedNamesLanguage(); entrySelectorLayout = new QFormLayout; - entrySelector = new QComboBox; + entrySelector = new AutocompletingComboBox; + +#if QT_VERSION < QT_VERSION_CHECK(5,2,0) + entrySelector->setEditable(false); +#else + entrySelector->completer()->setFilterMode(Qt::MatchContains); +#endif nbEntriesFld = new UnsignedSpinbox<16>; nbEntriesFld->setDisabled(true); @@ -48,15 +57,24 @@ void StrategyMemoUI::initWidget(void) { for (size_t i = 0; i < 500; ++i) entrySelector->addItem(tmpl.arg((int)i).arg(getPokemonSpeciesName(lg, NoSpecies))); + fillMemoButton = new QPushButton(tr("Fill memo")); + fillMemoAllShinyButton = new QPushButton(tr("Fill memo (all shiny)")); + entrySelectorLayout->addRow(tr("Number of entries"), nbEntriesFld); entrySelectorLayout->addRow(tr("Entry"), entrySelector); mainLayout->addLayout(entrySelectorLayout); mainLayout->addStretch(); mainLayout->addWidget(currentEntry); mainLayout->addStretch(); + mainLayout->addWidget(fillMemoButton); + mainLayout->addWidget(fillMemoAllShinyButton); + DataUI::initWidget(); connect(entrySelector, SIGNAL(currentIndexChanged(int)), this, SLOT(setCurrentEntry(int))); + connect(fillMemoButton, SIGNAL(clicked()), this, SLOT(fillMemo())); + connect(fillMemoAllShinyButton, SIGNAL(clicked()), this, SLOT(fillMemoAllShiny())); + } void StrategyMemoUI::updateEntryName(int index, size_t nameIndex) { @@ -77,6 +95,8 @@ void StrategyMemoUI::parseData(void) { } updateEntryNameAndNbEntries(0, pkmSpeciesIndexToNameIndex(strategyMemo->entries[0]->species)); setCurrentEntry(0); + + fillMemoAllShinyButton->setVisible(!isXD); } void StrategyMemoUI::saveChanges(void) { @@ -96,6 +116,25 @@ void StrategyMemoUI::setCurrentEntry(int index) { currentEntry->parseData(); } +void StrategyMemoUI::fillMemo(void) { + static GCRNG::forward_generator_type rng(time(NULL)); + + currentEntry->saveChanges(); + strategyMemo->fillMemo(rng); + currentEntry->entry = strategyMemo->entries[currentEntry->entryIndex]; + currentEntry->parseData(); + parseData(); +} + +void StrategyMemoUI::fillMemoAllShiny(void) { + static GCRNG::forward_generator_type rng(time(NULL)); + + currentEntry->saveChanges(); + strategyMemo->fillMemo(rng, true); + currentEntry->entry = strategyMemo->entries[currentEntry->entryIndex]; + currentEntry->parseData(); + parseData(); +} void StrategyMemoUI::updateEntryNameAndNbEntries(int index, size_t nameIndex) { updateEntryName(index, nameIndex); diff --git a/PkmGCSaveEditor/src/GCUIs/StrategyMemoUI.h b/PkmGCSaveEditor/src/GCUIs/StrategyMemoUI.h index 159c564..23d7e8c 100644 --- a/PkmGCSaveEditor/src/GCUIs/StrategyMemoUI.h +++ b/PkmGCSaveEditor/src/GCUIs/StrategyMemoUI.h @@ -20,6 +20,7 @@ #define _PKMGCSAVEEDITOR_STRATEGY_MEMO_UI_H #include +#include namespace GCUIs { @@ -38,15 +39,20 @@ public: public slots: void updateEntryNameAndNbEntries(int index, size_t nameIndex); void setCurrentEntry(int index); + void fillMemo(void); + void fillMemoAllShiny(void); + protected: void initWidget(void); private: void updateEntryName(int index, size_t nameIndex); QFormLayout *entrySelectorLayout; UnsignedSpinbox<16>* nbEntriesFld; - QComboBox *entrySelector; + AutocompletingComboBox *entrySelector; StrategyMemoEntryWidget* currentEntry; // we cannot use a QStackedWidget here + + QPushButton* fillMemoButton, *fillMemoAllShinyButton; }; } diff --git a/PkmGCSaveEditor/translations/PkmGCSaveEditor_de.ts b/PkmGCSaveEditor/translations/PkmGCSaveEditor_de.ts index e53a42f..59b39a0 100644 --- a/PkmGCSaveEditor/translations/PkmGCSaveEditor_de.ts +++ b/PkmGCSaveEditor/translations/PkmGCSaveEditor_de.ts @@ -388,8 +388,8 @@ GCUIs::PokemonMoveLayout - - + + (max. %n) (max. %n) @@ -397,7 +397,7 @@ - + PP Up(s) used AP-Plus verwendet @@ -405,520 +405,520 @@ GCUIs::PokemonUI - + None Status keiner - + Poisoned Vergiftet - + Badly poisoned Schwer vergiftet - + Paralyzed Paralysiert - + Burnt Verbrannt - + Frozen Eingefroren - + Asleep Schlafend - + This ribbon has never been made available Dieses Band war nie offiziell verfügbar - + Coolness Coolness - + Beauty Schönheit - + Cuteness Putzigkeit - + Cleverness Klugheit - + Toughness Stärke - + None Contest keiner - + Normal Contest Normal - + Super Contest Super - + Hyper Contest Hyper - + Master Contest Master - + HP KP - + Attack Angriff - + Defense Verteidigung - + S. Attack Sp.-Angriff - + S. Defense Sp.-Verteidigung - + Speed Initiative - + Champion Band des Champs - + Winning Band des Gewinners - + Victory Band des Sieges - + Artist Band des Künstlers - + Effort Fleiß-Band - + Marine Was never used in the game, so I'm not sure what Nintendo’s translation is for this. Meer-Band - + Land Was never used in the game, so I'm not sure what Nintendo’s translation is for this. I didn’t want to put ‘Erd-Band’ or something with ‘Erde’ as the Earth ribbon (Erde-Band) exists. Land-Band - + Sky Was never used in the game, so I'm not sure what Nintendo’s translation is for this. Himmel-Band - + Country Was never used in the game, so I'm not sure what Nintendo’s translation is for this. Landesband - + National National-Band - + Earth Erde-Band - + World Was never used in the game, so I'm not sure what Nintendo’s translation is for this. Welt-Band - + Unimplemented 1 Nicht implementiert 1 - + Unimplemented 2 Nicht implementiert 2 - + Unimplemented 3 Nicht implementiert 3 - + Unimplemented 4 Nicht implementiert 4 - + INVALID UNGÜLTIG - + Invalid species Ungültige Pokémon-Art - + Reset Zurücksetzen - + Egg Ei - + Second ability Zweite Fähigkeit - + Invalid Pokémon Ungültiges Pokémon - + Not tradable in-game im Spiel nicht tauschbar - + Unknown (unbekannte Eigenschaft) - + Caught Gefangen - + Species Art - + Name or nickname Name oder Spitzname - + PID PID - + Attributes Eigenschaften - + Ability Fähigkeit - + Experience and level Erfahrungspunkte und Level - + Held item Getragenes Item - + Friendship Freundschaft - + Pokérus (days remaing and strain) Pokérus (übrige Tage und Stamm) - + Flags Sonstige Eigenschaften (Flags) - + Markings Markierungen - - + + Status Status - + Pokérus days remaining übrige Pokérus-Tage - + Turns of sleep remaining übrige Runden Schlaf - + Turns of bad poison Runden schwerer Vergiftung - + Core Eigenschaften - + Core information Haupt-Info - + Original trainer Originaltrainer - + Game version Spielversion - + Copy info from save Daten von Spielstand kopieren - + Generate shiny IDs Shiny-IDs erstellen - + Location caught Fangort - + Level met Begegnung mit Level - + Fateful encounter (obedient) Schicksalhafte Begegnung (folgsam) - + Ball caught with gefangen mit - + Mew and Deoxys need this field to be checked so they can obey. Pokémon caught in XD always have this field checked Mew und Deoxys folgen nur, wenn dieses Feld ausgewählt wurde. In XD gefangene Pokémon haben dieses Feld immer ausgewählt - + IV IVs - + EV EVs (Fleißpunkte) - + Stat Wert - + Current HP Aktuelle KP - + Update stats automatically Werte automatisch aktualisieren - + Luster Glanz - + Main stats Hauptwerte - + Contest stats Wettbewerbswerte - + Contest ribbons Wettbewerbsbänder - + Contest type Wettbewerbstyp - + Achievement Klasse - + Special ribbons Besondere Bänder - + General Allgemein - + Met/OT Begegnung/OT - + Stats Werte - + Moves Attacken - + Ribbons Bänder - + Genderless Geschlechtslos - + Unown form: Icognito-Form: - + will evolve into: entwickelt sich zu: - + Invalid version info Ungültige Version - + "Invalid Pokémon" flag set Als „ungültiges Pokémon“ markiert - + Location caught (see <a href='http://bulbapedia.bulbagarden.net/wiki/List_of_locations_by_index_number_(Generation_III)'>here</a>) Fangort (Details <a href='http://bulbapedia.bulbagarden.net/wiki/List_of_locations_by_index_number_(Generation_III)'>hier</a>) - + Location caught (see <a href='http://bulbapedia.bulbagarden.net/wiki/List_of_locations_by_index_number_(GCN)'>here</a>) Fangort (Details <a href='http://bulbapedia.bulbagarden.net/wiki/List_of_locations_by_index_number_(GCN)'>hier</a>) - + Warning Warnung - + The version info you specified is invalid. The game will therefore consider this Pokémon invalid. Die angegebene Spielversion ist nicht gültig. Das Spiel wird dieses Pokémon daher für ungültig halten. @@ -926,42 +926,42 @@ Pokémon caught in XD always have this field checked GCUIs::StrategyMemoEntryWidget - + (randomly generated) (zufällig erstellt) - + Generate shiny IDs Shiny-IDs erstellen - + Truncate memo from here Memo von hier weg abschneiden - + Species Art - + First TID Erste TID - + First SID Erste SID - + First PID Erste PID - + Incomplete information unvollständiger Eintrag @@ -969,18 +969,28 @@ Pokémon caught in XD always have this field checked GCUIs::StrategyMemoUI - - + + #%1: %2 #%1: %2 - + + Fill memo + Memo füllen + + + + Fill memo (all shiny) + Memo füllen (alle shiny) + + + Number of entries Anzahl der Einträge - + Entry Eintrag diff --git a/PkmGCSaveEditor/translations/PkmGCSaveEditor_en.ts b/PkmGCSaveEditor/translations/PkmGCSaveEditor_en.ts index 6401e0d..7d40c03 100644 --- a/PkmGCSaveEditor/translations/PkmGCSaveEditor_en.ts +++ b/PkmGCSaveEditor/translations/PkmGCSaveEditor_en.ts @@ -387,8 +387,8 @@ GCUIs::PokemonMoveLayout - - + + (max. %n) (max. %n) @@ -396,7 +396,7 @@ - + PP Up(s) used PP Up(s) used @@ -404,516 +404,516 @@ GCUIs::PokemonUI - + None Status None - + Poisoned Poisoned - + Badly poisoned Badly poisoned - + Paralyzed Paralyzed - + Burnt Burnt - + Frozen Frozen - + Asleep Asleep - + Coolness Coolness - + Beauty Beauty - + Cuteness Cuteness - + Cleverness Cleverness - + Toughness Toughness - + None Contest None - + Normal Contest Normal - + Super Contest Super - + Hyper Contest Hyper - + Master Contest Master - + HP HP - + Attack Attack - + Defense Defense - + S. Attack S. Attack - + S. Defense S. Defense - + Speed Speed - + Champion Champion - + Winning Winning - + Victory Victory - + Artist Artist - + Effort Effort - + Marine Marine - + Land Land - + Sky Sky - + Country Country - + National National - + Earth Earth - + World World - + This ribbon has never been made available This ribbon has never been made available - + Reset Reset - + Egg Egg - + Second ability Second ability - + Invalid Pokémon Invalid Pokémon - + Not tradable in-game Not tradable in-game - + Unknown Unknown - + Caught Caught - + Species Species - + Name or nickname Name or nickname - + PID PID - + Attributes Attributes - + Ability Ability - + Experience and level Experience and level - + Held item Held item - + Mew and Deoxys need this field to be checked so they can obey. Pokémon caught in XD always have this field checked Mew and Deoxys need this field to be checked so they can obey. Pokémon caught in XD always have this field checked - - + + Status Status - + Flags Flags - + Markings Markings - + Pokérus days remaining Pokérus days remaining - + Turns of sleep remaining Turns of sleep remaining - + Turns of bad poison Turns of bad poison - + Core Core - + Core information Core information - + Original trainer Original trainer - + Game version Game version - + Copy info from save Copy info from save - + Generate shiny IDs Generate shiny IDs - + Ball caught with Ball caught with - + Location caught Location caught - + Unimplemented 1 Unimplemented 1 - + Unimplemented 2 Unimplemented 2 - + Unimplemented 3 Unimplemented 3 - + Unimplemented 4 Unimplemented 4 - + INVALID INVALID - + Invalid species Invalid species - + Friendship Friendship - + Pokérus (days remaing and strain) Pokérus (days remaing and strain) - + Level met Level met - + Fateful encounter (obedient) Fateful encounter (obedient) - + IV IV - + EV EV - + Stat Stat - + Current HP Current HP - + Update stats automatically Update stats automatically - + Luster Luster - + Main stats Main stats - + Contest stats Contest stats - + Contest ribbons Contest ribbons - + Contest type Contest type - + Achievement Achievement - + Special ribbons Special ribbons - + General General - + Met/OT Met/OT - + Stats Stats - + Moves Moves - + Ribbons Ribbons - + Genderless Genderless - + Unown form: Unown form: - + will evolve into: will evolve into: - + Invalid version info Invalid version info - + "Invalid Pokémon" flag set "Invalid Pokémon" flag set - + Location caught (see <a href='http://bulbapedia.bulbagarden.net/wiki/List_of_locations_by_index_number_(Generation_III)'>here</a>) Location caught (see <a href='http://bulbapedia.bulbagarden.net/wiki/List_of_locations_by_index_number_(Generation_III)'>here</a>) - + Location caught (see <a href='http://bulbapedia.bulbagarden.net/wiki/List_of_locations_by_index_number_(GCN)'>here</a>) Location caught (see <a href='http://bulbapedia.bulbagarden.net/wiki/List_of_locations_by_index_number_(GCN)'>here</a>) - + Warning Warning - + The version info you specified is invalid. The game will therefore consider this Pokémon invalid. The version info you specified is invalid. The game will therefore consider this Pokémon invalid. @@ -921,42 +921,42 @@ Pokémon caught in XD always have this field checked GCUIs::StrategyMemoEntryWidget - + (randomly generated) (randomly generated) - + Generate shiny IDs Generate shiny IDs - + Truncate memo from here Truncate memo from here - + Species Species - + First TID First TID - + First SID First SID - + First PID First PID - + Incomplete information Incomplete information @@ -964,18 +964,28 @@ Pokémon caught in XD always have this field checked GCUIs::StrategyMemoUI - - + + #%1: %2 #%1: %2 - + + Fill memo + Fill memo + + + + Fill memo (all shiny) + Fill memo (all shiny) + + + Number of entries Number of entries - + Entry Entry diff --git a/PkmGCSaveEditor/translations/PkmGCSaveEditor_fr.ts b/PkmGCSaveEditor/translations/PkmGCSaveEditor_fr.ts index fdcd8cc..0655266 100644 --- a/PkmGCSaveEditor/translations/PkmGCSaveEditor_fr.ts +++ b/PkmGCSaveEditor/translations/PkmGCSaveEditor_fr.ts @@ -387,8 +387,8 @@ GCUIs::PokemonMoveLayout - - + + (max. %n) (max. %n) @@ -396,7 +396,7 @@ - + PP Up(s) used PP Up(s) utilisés @@ -404,516 +404,516 @@ GCUIs::PokemonUI - + None Status Aucun - + Poisoned Empoisonné - + Badly poisoned Gravement empoisonné - + Paralyzed Paralysé - + Burnt Brûlé - + Frozen Gelé - + Asleep Endormi - + Coolness Sang-froid - + Beauty Beauté - + Cuteness Grâce - + Cleverness Intelligence - + Toughness Robustesse - + None Contest Aucun - + Normal Contest Normal - + Super Contest Super - + Hyper Contest Hyper - + Master Contest Master - + HP PV - + Attack Attaque - + Defense Défense - + S. Attack Attaque Spé. - + S. Defense Défense spé. - + Speed Vitesse - + Champion Maître - + Winning Victoire 1 - + Victory Victoire 2 - + Artist Artiste - + Effort - + Marine Marin - + Land Terrestre - + Sky Céleste - + Country Régional - + National National - + Earth Terre - + World Monde - + This ribbon has never been made available Ce ruban n'a jamais été disponible - + Reset RaZ - + Egg Œuf - + Second ability Second talent - + Invalid Pokémon Pokémon invalide - + Not tradable in-game Non échangeable en interne - + Unknown Inconnu - + Caught Capturé - + Species Espèce - + Name or nickname Nom ou surnom - + PID PID - + Attributes Caractéristiques - + Ability Talent - + Experience and level Expérience et niveau - + Held item Objet tenu - + Mew and Deoxys need this field to be checked so they can obey. Pokémon caught in XD always have this field checked Cette case doit être cochée afin que Mew et Deoxys puissent obéir. Les Pokémon attrapés dans XD ont toujours cette case cochée - - + + Status Statut - + Flags Drapeaux - + Markings Marques - + Pokérus days remaining Jours restants de Pokérus - + Turns of sleep remaining Tours de sommeil restants - + Turns of bad poison Tours de poison grave - + Core Essentiel - + Core information Informations essentielles - + Original trainer Dresseur d'origine - + Game version Version du jeu - + Copy info from save Recopier les infos à partir de la sauvegarde - + Generate shiny IDs Générer des IDs rendant ce Pokémon shiny - + Ball caught with Pokéball utilisée - + Location caught Lieu de capture - + Unimplemented 1 Non implémenté 1 - + Unimplemented 2 Non implémenté 2 - + Unimplemented 3 Non implémenté 3 - + Unimplemented 4 Non implémenté 4 - + INVALID INVALIDE - + Invalid species Espèce invalide - + Friendship Bonheur - + Pokérus (days remaing and strain) Pokérus (jours restants et forme) - + Level met Rencontré au niveau - + Fateful encounter (obedient) Rencontré par hasard (obéissant) - + IV IV - + EV EV - + Stat Statistique - + Current HP PVs actuels - + Update stats automatically Mettre à jour les statistiques automatiquement - + Luster Lustre - + Main stats Statistiques principales - + Contest stats Statistiques de concours - + Contest ribbons Rubans de concours - + Contest type Type de concours - + Achievement Avancement - + Special ribbons Rubans spéciaux - + General Général - + Met/OT Infos de rencontre/D.O - + Stats Statistiques - + Moves Attaques - + Ribbons Rubans - + Genderless Asexué - + Unown form: Forme Zarbi : - + will evolve into: évoluera en : - + Invalid version info Infos de version invalides - + "Invalid Pokémon" flag set Drapeau "Pokémon invalide" activé - + Location caught (see <a href='http://bulbapedia.bulbagarden.net/wiki/List_of_locations_by_index_number_(Generation_III)'>here</a>) Lieu de capture (cf. <a href='http://bulbapedia.bulbagarden.net/wiki/List_of_locations_by_index_number_(Generation_III)'>Bulbapedia</a>) - + Location caught (see <a href='http://bulbapedia.bulbagarden.net/wiki/List_of_locations_by_index_number_(GCN)'>here</a>) Lieu de capture (cf. <a href='http://bulbapedia.bulbagarden.net/wiki/List_of_locations_by_index_number_(GCN)'>Bulbapedia</a>) - + Warning Avertissement - + The version info you specified is invalid. The game will therefore consider this Pokémon invalid. Les informations sur la version du jeu que vous avez entrées sont invalides. Le jeu considérera de ce fait ce Pokémon invalide. @@ -921,42 +921,42 @@ Les Pokémon attrapés dans XD ont toujours cette case cochée GCUIs::StrategyMemoEntryWidget - + (randomly generated) (géneré aléatoirement) - + Generate shiny IDs Générer des IDs rendant ce Pokémon shiny - + Truncate memo from here Tronquer le Mémo à partir d'ici - + Species Espèce - + First TID Premier TID - + First SID Premier SID - + First PID Premier PID - + Incomplete information Informations incomplètes @@ -964,18 +964,28 @@ Les Pokémon attrapés dans XD ont toujours cette case cochée GCUIs::StrategyMemoUI - - + + #%1: %2 #%1 : %2 - + + Fill memo + Remplir le mémo + + + + Fill memo (all shiny) + Remplir le mémo (tous shiny) + + + Number of entries Nombre d'entrées - + Entry Entrée