mirror of
https://github.com/TuxSH/PkmGCTools.git
synced 2026-09-08 08:45:54 -05:00
* 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).
This commit is contained in:
45
PkmGCSaveEditor/src/Core/AutocompletingComboBox.cpp
Normal file
45
PkmGCSaveEditor/src/Core/AutocompletingComboBox.cpp
Normal file
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <Core/AutocompletingComboBox.h>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QApplication>
|
||||
|
||||
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);
|
||||
}
|
||||
39
PkmGCSaveEditor/src/Core/AutocompletingComboBox.h
Normal file
39
PkmGCSaveEditor/src/Core/AutocompletingComboBox.h
Normal file
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _PKMGCSAVEEDITOR_AUTOCOMPLETING_COMBO_BOX_H
|
||||
#define _PKMGCSAVEEDITOR_AUTOCOMPLETING_COMBO_BOX_H
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QCompleter>
|
||||
|
||||
class AutocompletingComboBox : public QComboBox {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AutocompletingComboBox(QWidget* parent = 0);
|
||||
|
||||
public slots:
|
||||
void resetColor(void);
|
||||
|
||||
protected:
|
||||
void focusOutEvent(QFocusEvent* ev);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#define _PKMGCSAVEEDITOR_ITEM_COMBO_BOX_H
|
||||
|
||||
#include <Core/Globals.h>
|
||||
#include <QComboBox>
|
||||
#include <Core/AutocompletingComboBox.h>
|
||||
#include <LibPkmGC/Core/Localization.h>
|
||||
|
||||
// (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);
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
|
||||
#include <GCUIs/PokemonUI.h>
|
||||
#include <QMessageBox>
|
||||
#include <QApplication>
|
||||
#include <ctime>
|
||||
#include <LibPkmGC/Core/LCRNG32.h>
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
*/
|
||||
|
||||
#include <GCUIs/StrategyMemoEntryWidget.h>
|
||||
#include <ctime>
|
||||
#include <LibPkmGC/Core/LCRNG32.h>
|
||||
|
||||
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;
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <Core/DataUI.h>
|
||||
#include <Core/UnsignedSpinbox.h>
|
||||
#include <Core/AutocompletingComboBox.h>
|
||||
#include <QFormLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QButtonGroup>
|
||||
@@ -58,7 +59,7 @@ private:
|
||||
bool isXD;
|
||||
QVBoxLayout *mainLayout;
|
||||
QFormLayout *mainLayout2;
|
||||
QComboBox *speciesSelector;
|
||||
AutocompletingComboBox *speciesSelector;
|
||||
|
||||
QCheckBox *incompleteInfoCheckBox;
|
||||
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
*/
|
||||
|
||||
#include <GCUIs/StrategyMemoUI.h>
|
||||
#include <ctime>
|
||||
#include <LibPkmGC/Core/LCRNG32.h>
|
||||
#include <QtGlobal>
|
||||
|
||||
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);
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#define _PKMGCSAVEEDITOR_STRATEGY_MEMO_UI_H
|
||||
|
||||
#include <GCUIs/StrategyMemoEntryWidget.h>
|
||||
#include <Core/AutocompletingComboBox.h>
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user