Skip to content

Commit

Permalink
Seperate dens by location
Browse files Browse the repository at this point in the history
  • Loading branch information
Admiral-Fish committed Jun 21, 2020
1 parent 33ef42f commit 242066d
Show file tree
Hide file tree
Showing 12 changed files with 334 additions and 171 deletions.
45 changes: 30 additions & 15 deletions Forms/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,7 @@ void MainWindow::setupModels()
ui->comboBoxShinyType->setItemData(1, 1); // Forced non-shiny
ui->comboBoxShinyType->setItemData(2, 2); // Forced shiny

if (QFile::exists(QApplication::applicationDirPath() + "/nests_event.json"))
{
ui->comboBoxDen->addItem(tr("Event"), 255);
}
for (u8 i = 0; i < 190; i++)
{
if (i == 16)
{
continue;
}

QString location = Translator::getLocation(DenLoader::getLocation(i));
ui->comboBoxDen->addItem(QString("%1: %2").arg(i + 1).arg(location), i);
}

locationIndexChanged(0);
denIndexChanged(0);
speciesIndexChanged(0);

Expand Down Expand Up @@ -209,6 +195,7 @@ void MainWindow::setupModels()
connect(ui->actionDownloadEventData, &QAction::triggered, this, &MainWindow::downloadEventData);
connect(ui->comboBoxProfiles, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &MainWindow::profilesIndexChanged);
connect(ui->pushButtonGenerate, &QPushButton::clicked, this, &MainWindow::generate);
connect(ui->comboBoxLocation, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &MainWindow::locationIndexChanged);
connect(ui->comboBoxDen, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &MainWindow::denIndexChanged);
connect(ui->comboBoxRarity, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &MainWindow::rarityIndexChange);
connect(ui->comboBoxSpecies, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &MainWindow::speciesIndexChanged);
Expand Down Expand Up @@ -465,6 +452,34 @@ void MainWindow::checkUpdates()
setting.setValue("settings/lastOpened", today);
}

void MainWindow::locationIndexChanged(int index)
{
if (index >= 0)
{
ui->comboBoxDen->clear();

if (QFile::exists(QApplication::applicationDirPath() + "/nests_event.json"))
{
ui->comboBoxDen->addItem(tr("Event"), 255);
}

u8 start = index == 0 ? 0 : 100;
u8 end = index == 0 ? 100 : 190;
u8 offset = index == 0 ? 0 : 100;

for (u8 denID = start; denID < end; denID++)
{
if (denID == 16)
{
continue;
}

QString location = Translator::getLocation(DenLoader::getLocation(denID));
ui->comboBoxDen->addItem(QString("%1: %2").arg(denID + 1 - offset).arg(location), denID);
}
}
}

void MainWindow::denIndexChanged(int index)
{
if (index >= 0)
Expand Down
1 change: 1 addition & 0 deletions Forms/MainWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ private slots:
void openSeedCalculator();
void downloadEventData();
void checkUpdates();
void locationIndexChanged(int index);
void denIndexChanged(int index);
void rarityIndexChange(int index);
void speciesIndexChanged(int index);
Expand Down
88 changes: 55 additions & 33 deletions Forms/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -30,84 +30,105 @@
<string>RNG Info</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="1">
<widget class="TextBox" name="textBoxSeed"/>
</item>
<item row="3" column="1">
<widget class="TextBox" name="textBoxInitialFrame">
<property name="text">
<string notr="true">1</string>
<item row="4" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QPushButton" name="pushButtonGenerate">
<property name="text">
<string>Generate</string>
<string>Initial Frame</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label">
<item row="5" column="0">
<widget class="QLabel" name="labelMaxResults">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Initial Frame</string>
<string>Max Results</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="TextBox" name="textBoxMaxResults">
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxDen"/>
</item>
<item row="6" column="0" colspan="2">
<widget class="QPushButton" name="pushButtonGenerate">
<property name="text">
<string notr="true">100</string>
<string>Generate</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelSeed">
<widget class="QLabel" name="labelDen">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Seed</string>
<string>Den</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="labelMaxResults">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item row="2" column="1">
<widget class="TextBox" name="textBoxSeed"/>
</item>
<item row="4" column="1">
<widget class="TextBox" name="textBoxInitialFrame">
<property name="text">
<string notr="true">1</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="TextBox" name="textBoxMaxResults">
<property name="text">
<string>Max Results</string>
<string notr="true">100</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="labelDen">
<item row="2" column="0">
<widget class="QLabel" name="labelSeed">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Den</string>
<string>Seed</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="labelLocation">
<property name="text">
<string>Location</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxDen"/>
<widget class="QComboBox" name="comboBoxLocation">
<item>
<property name="text">
<string>Wild Area</string>
</property>
</item>
<item>
<property name="text">
<string>Isle of Armor</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
Expand Down Expand Up @@ -728,7 +749,7 @@
<x>0</x>
<y>0</y>
<width>1200</width>
<height>22</height>
<height>20</height>
</rect>
</property>
<widget class="QMenu" name="menuSettings">
Expand Down Expand Up @@ -930,6 +951,7 @@
<tabstops>
<tabstop>comboBoxProfiles</tabstop>
<tabstop>pushButtonProfileManager</tabstop>
<tabstop>comboBoxLocation</tabstop>
<tabstop>comboBoxDen</tabstop>
<tabstop>textBoxSeed</tabstop>
<tabstop>textBoxInitialFrame</tabstop>
Expand Down
34 changes: 26 additions & 8 deletions Forms/Tools/DenMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,43 @@ DenMap::~DenMap()

void DenMap::setupModels()
{
for (u8 i = 0; i < 190; i++)
{
QString location = Translator::getLocation(DenLoader::getLocation(i));
ui->comboBoxDen->addItem(QString("%1: %2").arg(i + 1).arg(location));
}
locationIndexChanged(0);

connect(ui->comboBoxLocation, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &DenMap::locationIndexChanged);
connect(ui->comboBoxDen, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &DenMap::denIndexChanged);
}

void DenMap::locationIndexChanged(int index)
{
if (index >= 0)
{
ui->comboBoxDen->clear();

denIndexChanged(0);
u8 start = index == 0 ? 0 : 100;
u8 end = index == 0 ? 100 : 190;
u8 offset = index == 0 ? 0 : 100;

for (u8 denID = start; denID < end; denID++)
{
QString location = Translator::getLocation(DenLoader::getLocation(denID));
ui->comboBoxDen->addItem(QString("%1: %2").arg(denID + 1 - offset).arg(location));
}

denIndexChanged(0);
}
}

void DenMap::denIndexChanged(int index)
{
if (index >= 0)
{
QVector<u16> coordinates = DenLoader::getCoordinates(index);
int location = ui->comboBoxLocation->currentIndex();
int offset = location == 0 ? 0 : 100;

QVector<u16> coordinates = DenLoader::getCoordinates(index + offset);

QPixmap image;
if (index < 100)
if (location == 0)
{
image.load(":/images/map.png");
this->resize(245, 578);
Expand Down
1 change: 1 addition & 0 deletions Forms/Tools/DenMap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class DenMap : public QWidget
void setupModels();

private slots:
void locationIndexChanged(int index);
void denIndexChanged(int index);
};

Expand Down
20 changes: 19 additions & 1 deletion Forms/Tools/DenMap.ui
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
<string>Den Map</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="2">
<widget class="QComboBox" name="comboBoxDen"/>
</item>
<item row="1" column="2">
<widget class="QLabel" name="labelMap">
<property name="sizePolicy">
Expand All @@ -37,10 +40,25 @@
</widget>
</item>
<item row="2" column="2">
<widget class="QComboBox" name="comboBoxDen"/>
<widget class="QComboBox" name="comboBoxLocation">
<item>
<property name="text">
<string>Wild Area</string>
</property>
</item>
<item>
<property name="text">
<string>Isle of Armor</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>comboBoxLocation</tabstop>
<tabstop>comboBoxDen</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
Loading

0 comments on commit 242066d

Please sign in to comment.