Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Form/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ set(PROJECT_SOURCES
Controls/IDsFilter.hpp
Controls/TableView.cpp
Controls/TableView.hpp
Controls/TabWidget.hpp
Controls/TabWidget.cpp
Controls/TextBox.cpp
Controls/TextBox.hpp
Gen3/Eggs3.cpp
Expand Down
34 changes: 34 additions & 0 deletions Form/Controls/EggSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,40 @@ bool EggSettings::compatibleParents() const
return false;
}

void EggSettings::copyFrom(const EggSettings *other)
{
ui->spinBoxParentAHP->setValue(other->ui->spinBoxParentAHP->value());
ui->spinBoxParentAAtk->setValue(other->ui->spinBoxParentAAtk->value());
ui->spinBoxParentADef->setValue(other->ui->spinBoxParentADef->value());
ui->spinBoxParentASpA->setValue(other->ui->spinBoxParentASpA->value());
ui->spinBoxParentASpD->setValue(other->ui->spinBoxParentASpD->value());
ui->spinBoxParentASpe->setValue(other->ui->spinBoxParentASpe->value());

ui->spinBoxParentBHP->setValue(other->ui->spinBoxParentBHP->value());
ui->spinBoxParentBAtk->setValue(other->ui->spinBoxParentBAtk->value());
ui->spinBoxParentBDef->setValue(other->ui->spinBoxParentBDef->value());
ui->spinBoxParentBSpA->setValue(other->ui->spinBoxParentBSpA->value());
ui->spinBoxParentBSpD->setValue(other->ui->spinBoxParentBSpD->value());
ui->spinBoxParentBSpe->setValue(other->ui->spinBoxParentBSpe->value());

ui->comboBoxParentAAbility->setCurrentIndex(other->ui->comboBoxParentAAbility->currentIndex());
ui->comboBoxParentBAbility->setCurrentIndex(other->ui->comboBoxParentBAbility->currentIndex());

ui->comboBoxParentAGender->setCurrentIndex(other->ui->comboBoxParentAGender->currentIndex());
ui->comboBoxParentBGender->setCurrentIndex(other->ui->comboBoxParentBGender->currentIndex());

ui->comboBoxParentAItem->setCurrentIndex(other->ui->comboBoxParentAItem->currentIndex());
ui->comboBoxParentBItem->setCurrentIndex(other->ui->comboBoxParentBItem->currentIndex());

ui->comboBoxParentANature->setCurrentIndex(other->ui->comboBoxParentANature->currentIndex());
ui->comboBoxParentBNature->setCurrentIndex(other->ui->comboBoxParentBNature->currentIndex());

ui->comboBoxEggSpecie->setCurrentIndex(other->ui->comboBoxEggSpecie->currentIndex());

ui->checkBoxMasuda->setCheckState(other->ui->checkBoxMasuda->checkState());
ui->checkBoxShowInheritance->setCheckState(other->ui->checkBoxShowInheritance->checkState());
}

Daycare EggSettings::getDaycare() const
{
std::array<std::array<u8, 6>, 2> parentIVs
Expand Down
7 changes: 7 additions & 0 deletions Form/Controls/EggSettings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ class EggSettings : public QWidget
*/
bool compatibleParents() const;

/**
* @brief Copies the values from another EggSettings
*
* @param other The EggSettings to copy values from
*/
void copyFrom(const EggSettings *other);

/**
* @brief Gets various parent information: IVs, ability, gender, item masuda, etc.
*
Expand Down
34 changes: 32 additions & 2 deletions Form/Controls/Filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ Filter::Filter(QWidget *parent) : QWidget(parent), ui(new Ui::Filter)
ui->labelAtk->installEventFilter(this);
ui->labelDef->installEventFilter(this);
ui->labelSpA->installEventFilter(this);
ui->labelSpA->installEventFilter(this);
ui->labelSpD->installEventFilter(this);
ui->labelSpe->installEventFilter(this);

Expand All @@ -118,6 +117,37 @@ Filter::~Filter()
delete ui;
}

void Filter::copyFrom(const Filter *other)
{
ui->spinBoxHPMin->setValue(other->ui->spinBoxHPMin->value());
ui->spinBoxAtkMin->setValue(other->ui->spinBoxAtkMin->value());
ui->spinBoxDefMin->setValue(other->ui->spinBoxDefMin->value());
ui->spinBoxSpAMin->setValue(other->ui->spinBoxSpAMin->value());
ui->spinBoxSpDMin->setValue(other->ui->spinBoxSpDMin->value());
ui->spinBoxSpeMin->setValue(other->ui->spinBoxSpeMin->value());

ui->spinBoxHPMax->setValue(other->ui->spinBoxHPMax->value());
ui->spinBoxAtkMax->setValue(other->ui->spinBoxAtkMax->value());
ui->spinBoxDefMax->setValue(other->ui->spinBoxDefMax->value());
ui->spinBoxSpAMax->setValue(other->ui->spinBoxSpAMax->value());
ui->spinBoxSpDMax->setValue(other->ui->spinBoxSpDMax->value());
ui->spinBoxSpeMax->setValue(other->ui->spinBoxSpeMax->value());

ui->checkBoxShowStats->setChecked(other->ui->checkBoxShowStats->isChecked());

ui->comboBoxAbility->setCurrentIndex(other->ui->comboBoxAbility->currentIndex());
ui->checkListEncounterSlot->setChecks(other->ui->checkListEncounterSlot->getChecked());
ui->comboBoxGender->setCurrentIndex(other->ui->comboBoxGender->currentIndex());
ui->spinBoxHeightMin->setValue(other->ui->spinBoxHeightMin->value());
ui->spinBoxHeightMax->setValue(other->ui->spinBoxHeightMax->value());
ui->checkListHiddenPower->setChecks(other->ui->checkListHiddenPower->getChecked());
ui->checkListNature->setChecks(other->ui->checkListNature->getChecked());
ui->comboBoxShiny->setCurrentIndex(other->ui->comboBoxShiny->currentIndex());
ui->spinBoxWeightMin->setValue(other->ui->spinBoxWeightMin->value());
ui->spinBoxWeightMax->setValue(other->ui->spinBoxWeightMax->value());
ui->checkBoxDisableFilters->setChecked(other->ui->checkBoxDisableFilters->isChecked());
}

void Filter::disableControls(Controls control)
{
if ((control & Controls::Ability) != Controls::None)
Expand Down Expand Up @@ -197,7 +227,7 @@ void Filter::disableControls(Controls control)
ui->labelShiny->setVisible(false);
ui->comboBoxShiny->setVisible(false);
}

if ((control & Controls::Weight) != Controls::None)
{
ui->labelWeight->setVisible(false);
Expand Down
7 changes: 7 additions & 0 deletions Form/Controls/Filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ class Filter : public QWidget
*/
~Filter() override;

/**
* @brief Copies the values from another Filter
*
* @param other The Filter to copy values from
*/
void copyFrom(const Filter *other);

/**
* @brief Disables specified controls
*
Expand Down
37 changes: 37 additions & 0 deletions Form/Controls/TabWidget.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* This file is part of PokéFinder
* Copyright (C) 2017-2024 by Admiral_Fish, bumba, and EzPzStreamz
*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#include "TabWidget.hpp"
#include <QAction>
#include <QContextMenuEvent>
#include <QMenu>

TabWidget::TabWidget(QWidget *parent) : QTabWidget(parent)
{
auto *filters = addAction(tr("Transfer Filters"));
connect(filters, &QAction::triggered, this, [=] { emit transferFilters(currentIndex()); });

auto *settings = addAction(tr("Transfer Settings"));
connect(settings, &QAction::triggered, this, [=] { emit transferSettings(currentIndex()); });
}

void TabWidget::contextMenuEvent(QContextMenuEvent *event)
{
QMenu::exec(actions(), event->globalPos(), nullptr, this);
}
55 changes: 55 additions & 0 deletions Form/Controls/TabWidget.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* This file is part of PokéFinder
* Copyright (C) 2017-2024 by Admiral_Fish, bumba, and EzPzStreamz
*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#ifndef TABWIDGET_HPP
#define TABWIDGET_HPP

#include <QTabWidget>

class TabWidget : public QTabWidget
{
Q_OBJECT
signals:
/**
* @brief Emits that the filters should be transferred
*/
void transferFilters(int);

/**
* @brief Emits that the settings should be transferred
*/
void transferSettings(int);

public:
/**
* @brief Construct a new TabWidget object
*
* @param parent Parent widget, which takes memory ownership
*/
TabWidget(QWidget *parent = nullptr);

/**
* @brief Handles when the context menu is requested
*
* @param event Contains context menu event information
*/
void contextMenuEvent(QContextMenuEvent *event) override;
};

#endif // TABWIDGET_HPP
30 changes: 29 additions & 1 deletion Form/Gen3/GameCube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@ GameCube::GameCube(QWidget *parent) : QWidget(parent), ui(new Ui::GameCube)
ui->textBoxGeneratorMaxAdvances->setValues(InputType::Advance32Bit);
ui->textBoxGeneratorOffset->setValues(InputType::Advance32Bit);

ui->filterGenerator->disableControls(Controls::EncounterSlots | Controls::Height | Controls::Weight);
ui->filterGenerator->disableControls(Controls::EncounterSlots | Controls::Height | Controls::Weight);
ui->filterSearcher->disableControls(Controls::DisableFilter | Controls::EncounterSlots | Controls::Height | Controls::Weight);

ui->comboBoxGeneratorPokemon->enableAutoComplete();
ui->comboBoxSearcherPokemon->enableAutoComplete();

connect(ui->tabRNGSelector, &TabWidget::transferFilters, this, &GameCube::transferFilters);
connect(ui->tabRNGSelector, &TabWidget::transferSettings, this, &GameCube::transferSettings);
connect(ui->pushButtonGenerate, &QPushButton::clicked, this, &GameCube::generate);
connect(ui->pushButtonSearch, &QPushButton::clicked, this, &GameCube::search);
connect(ui->pushButtonProfileManager, &QPushButton::clicked, this, &GameCube::profileManager);
Expand Down Expand Up @@ -346,3 +348,29 @@ void GameCube::searcherPokemonIndexChanged(int index)
}
}
}

void GameCube::transferFilters(int index)
{
if (index == 0)
{
ui->filterSearcher->copyFrom(ui->filterGenerator);
}
else
{
ui->filterGenerator->copyFrom(ui->filterSearcher);
}
}

void GameCube::transferSettings(int index)
{
if (index == 0)
{
ui->comboBoxSearcherCategory->setCurrentIndex(ui->comboBoxGeneratorCategory->currentIndex());
ui->comboBoxSearcherPokemon->setCurrentIndex(ui->comboBoxGeneratorPokemon->currentIndex());
}
else
{
ui->comboBoxGeneratorCategory->setCurrentIndex(ui->comboBoxSearcherCategory->currentIndex());
ui->comboBoxGeneratorPokemon->setCurrentIndex(ui->comboBoxSearcherPokemon->currentIndex());
}
}
14 changes: 14 additions & 0 deletions Form/Gen3/GameCube.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,20 @@ private slots:
* @param index Pokemon index
*/
void searcherPokemonIndexChanged(int index);

/**
* @brief Transfers the filters from the active tab to the inactive tab
*
* @param index Which tab widget to copy from
*/
void transferFilters(int index);

/**
* @brief Transfers the settings from the active tab to the inactive tab
*
* @param index Which tab widget to copy from
*/
void transferSettings(int index);
};

#endif // GAMECUBE_HPP
14 changes: 10 additions & 4 deletions Form/Gen3/GameCube.ui
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<item row="0" column="4" rowspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
</widget>
</item>
Expand All @@ -78,7 +78,7 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QTabWidget" name="tabRNGSelector">
<widget class="TabWidget" name="tabRNGSelector">
<widget class="QWidget" name="tabGenerator">
<attribute name="title">
<string>Generator</string>
Expand Down Expand Up @@ -200,7 +200,7 @@
<item row="2" column="0" colspan="2">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
</item>
Expand Down Expand Up @@ -331,7 +331,7 @@
<item row="2" column="0" colspan="3">
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
</item>
Expand Down Expand Up @@ -408,6 +408,12 @@
<header>Form/Controls/Filter.hpp</header>
<container>1</container>
</customwidget>
<customwidget>
<class>TabWidget</class>
<extends>QTabWidget</extends>
<header>Form/Controls/TabWidget.hpp</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>comboBoxProfiles</tabstop>
Expand Down
28 changes: 28 additions & 0 deletions Form/Gen3/Static3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ Static3::Static3(QWidget *parent) : QWidget(parent), ui(new Ui::Static3)
connect(seedToTime, &QAction::triggered, this, &Static3::seedToTime);
ui->tableViewSearcher->addAction(seedToTime);

connect(ui->tabRNGSelector, &TabWidget::transferFilters, this, &Static3::transferFilters);
connect(ui->tabRNGSelector, &TabWidget::transferSettings, this, &Static3::transferSettings);
connect(ui->pushButtonGenerate, &QPushButton::clicked, this, &Static3::generate);
connect(ui->pushButtonSearch, &QPushButton::clicked, this, &Static3::search);
connect(ui->pushButtonProfileManager, &QPushButton::clicked, this, &Static3::profileManager);
Expand Down Expand Up @@ -293,3 +295,29 @@ void Static3::seedToTime()
auto *time = new SeedToTime3(state.getSeed());
time->show();
}

void Static3::transferFilters(int index)
{
if (index == 0)
{
ui->filterSearcher->copyFrom(ui->filterGenerator);
}
else
{
ui->filterGenerator->copyFrom(ui->filterSearcher);
}
}

void Static3::transferSettings(int index)
{
if (index == 0)
{
ui->comboBoxSearcherCategory->setCurrentIndex(ui->comboBoxGeneratorCategory->currentIndex());
ui->comboBoxSearcherPokemon->setCurrentIndex(ui->comboBoxGeneratorPokemon->currentIndex());
}
else
{
ui->comboBoxGeneratorCategory->setCurrentIndex(ui->comboBoxSearcherCategory->currentIndex());
ui->comboBoxGeneratorPokemon->setCurrentIndex(ui->comboBoxSearcherPokemon->currentIndex());
}
}
Loading