diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-02-20 00:21:01 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-02-20 00:21:01 +0000 |
| commit | 6551bb8f486ed2cc83c4d35e3c59a21f2f27e0d4 (patch) | |
| tree | 78777981888d7a897673294d2a3a5dd0e0cc2f2d | |
| parent | 2d3ab5c520bb61fecb66e0f143d93c3386bf451a (diff) | |
[ADD] SpeciesEvolution.{h, cpp}
[ADD] Appropriate includes for Species*UI.cpp files
[FIX] SpeciesEvolution values now fixed up
[FIX] Relative enum in more logical order
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@65 6ecfd1a5-f3ed-3746-8530-beee90d26b22
| -rw-r--r-- | Changelog | 10 | ||||
| -rw-r--r-- | general/Ref.cpp | 2 | ||||
| -rw-r--r-- | general/Ref.h | 6 | ||||
| -rw-r--r-- | pokemod/SpeciesEvolution.cpp | 35 | ||||
| -rw-r--r-- | pokemod/SpeciesEvolution.h | 2 | ||||
| -rw-r--r-- | pokemodr/SpeciesAbilityUI.cpp | 1 | ||||
| -rw-r--r-- | pokemodr/SpeciesEvolutionUI.cpp | 226 | ||||
| -rw-r--r-- | pokemodr/SpeciesEvolutionUI.h | 62 | ||||
| -rw-r--r-- | pokemodr/SpeciesItemUI.cpp | 1 | ||||
| -rw-r--r-- | pokemodr/SpeciesMoveUI.cpp | 1 | ||||
| -rw-r--r-- | pokemodr/TODO | 1 | ||||
| -rw-r--r-- | pokemodr/gui/speciesevolution.ui | 16 |
12 files changed, 324 insertions, 39 deletions
@@ -1,4 +1,14 @@ ----------------- +Rev: 65 +Date: 19 February 2008 +User: MathStuf +----------------- +[ADD] SpeciesEvolution.{h, cpp} +[ADD] Appropriate includes for Species*UI.cpp files +[FIX] SpeciesEvolution values now fixed up +[FIX] Relative enum in more logical order + +----------------- Rev: 64 Date: 19 February 2008 User: MathStuf diff --git a/general/Ref.cpp b/general/Ref.cpp index 4ccda5e4..26014390 100644 --- a/general/Ref.cpp +++ b/general/Ref.cpp @@ -31,7 +31,7 @@ const QStringList WeatherStr = QStringList() << "Ice" << "Rain" << "Sun" << "San const QStringList DirectionStr = QStringList() << "Up" << "Down" << "Left" << "Right" << "None"; -const QStringList RelativeStr = QStringList() << "Less" << "Less or Equal" << "Equal" << "Greater or Equal" << "Greater" << "Not Equal"; +const QStringList RelativeStr = QStringList() << "Less" << "Less or Equal" << "Greater or Equal" << "Greater" << "Equal" << "Not Equal"; const QStringList StatusStr = QStringList() << "Freeze" << "Paralyze" << "Sleep" << "Poison" << "Toxic Poison" << "Burn" << "Any"; diff --git a/general/Ref.h b/general/Ref.h index faf8ffdd..e37e5a3c 100644 --- a/general/Ref.h +++ b/general/Ref.h @@ -79,9 +79,9 @@ enum EnumRelative { REL_Less = 0, REL_LessOrEqual = 1, - REL_Equal = 2, - REL_GreaterOrEqual = 3, - REL_Greater = 4, + REL_GreaterOrEqual = 2, + REL_Greater = 3, + REL_Equal = 4, REL_NotEqual = 5, REL_End = 6 }; diff --git a/pokemod/SpeciesEvolution.cpp b/pokemod/SpeciesEvolution.cpp index dc2053f7..48098dd7 100644 --- a/pokemod/SpeciesEvolution.cpp +++ b/pokemod/SpeciesEvolution.cpp @@ -66,6 +66,7 @@ bool SpeciesEvolution::validate() const bool ok = true; switch (style) { + case S_Happiness: case S_Stat: case S_Personality: if (REL_End <= val1) @@ -93,6 +94,9 @@ bool SpeciesEvolution::validate() const } switch (style) { + case S_Stat: + if ((pokemod->getRules()->getSpecialSplit() ? ST_End_GSC : ST_End_RBY) <= val2) + ok = false; case S_Item: if ((G_End <= val2) || ((val2 == G_Hold) && !pokemod->getRules()->getHoldItems())) ok = false; @@ -104,18 +108,6 @@ bool SpeciesEvolution::validate() const valid = false; ok = true; } - switch (style) - { - case S_Stat: - if ((pokemod->getRules()->getSpecialSplit() ? ST_End_GSC : ST_End_RBY) <= val1) - ok = false; - break; - } - if (!ok) - { - pokemod->validationMsg("Invalid val3"); - valid = false; - } } else { @@ -178,7 +170,6 @@ void SpeciesEvolution::setVal1(const int v1) throw(Exception) switch (style) { case S_Happiness: - break; case S_Stat: case S_Personality: if (REL_End <= v1) @@ -186,11 +177,11 @@ void SpeciesEvolution::setVal1(const int v1) throw(Exception) break; case S_Item: case S_TradeItem: - if (pokemod->getItemIndex(val1) == -1) + if (pokemod->getItemIndex(v1) == -1) throw(BoundsException(className, "val1")); - for (int i = 0; (i < pokemod->getItemByID(val1)->getEffectCount()) && !ok; ++i) + for (int i = 0; (i < pokemod->getItemByID(v1)->getEffectCount()) && !ok; ++i) { - if (pokemod->getItemByID(val1)->getEffect(i)->getEffect() == ItemEffect::E_Evolution) + if (pokemod->getItemByID(v1)->getEffect(i)->getEffect() == ItemEffect::E_Evolution) ok = true; } if (!ok) @@ -208,10 +199,10 @@ void SpeciesEvolution::setVal2(const int v2) throw(Exception) switch (style) { case S_Stat: - case S_Personality: - break; + if ((pokemod->getRules()->getSpecialSplit() ? ST_End_GSC : ST_End_RBY) <= v2) + throw(BoundsException(className, "val2")); case S_Item: - if ((G_End <= val2) || ((val2 == G_Hold) && !pokemod->getRules()->getHoldItems())) + if ((G_End <= v2) || ((v2 == G_Hold) && !pokemod->getRules()->getHoldItems())) throw(BoundsException(className, "val2")); break; default: @@ -221,13 +212,13 @@ void SpeciesEvolution::setVal2(const int v2) throw(Exception) val2 = v2; } -void SpeciesEvolution::setVal3(const int v3) throw(Exception) +void SpeciesEvolution::setVal3(const int v3) throw(UnusedException) { switch (style) { + case S_Happiness: case S_Stat: - if ((pokemod->getRules()->getSpecialSplit() ? ST_End_GSC : ST_End_RBY) <= v3) - throw(BoundsException(className, "val3")); + case S_Personality: break; default: throw(UnusedException(className, "val3")); diff --git a/pokemod/SpeciesEvolution.h b/pokemod/SpeciesEvolution.h index e8d6c8c9..3d1a092c 100644 --- a/pokemod/SpeciesEvolution.h +++ b/pokemod/SpeciesEvolution.h @@ -66,7 +66,7 @@ class SpeciesEvolution : public Object void setStyle(const int s) throw(BoundsException); void setVal1(const int v1) throw(Exception); void setVal2(const int v2) throw(Exception); - void setVal3(const int v3) throw(Exception); + void setVal3(const int v3) throw(UnusedException); void setLevel(const int l) throw(BoundsException); int getSpecies() const; diff --git a/pokemodr/SpeciesAbilityUI.cpp b/pokemodr/SpeciesAbilityUI.cpp index b28e709d..88a6f1ad 100644 --- a/pokemodr/SpeciesAbilityUI.cpp +++ b/pokemodr/SpeciesAbilityUI.cpp @@ -27,6 +27,7 @@ #include "../general/Exception.h" #include "../pokemod/Ability.h" #include "../pokemod/Pokemod.h" +#include "../pokemod/SpeciesAbility.h" #include "SpeciesAbilityUI.h" SpeciesAbilityUI::SpeciesAbilityUI(SpeciesAbility* s, QWidget* parent) : diff --git a/pokemodr/SpeciesEvolutionUI.cpp b/pokemodr/SpeciesEvolutionUI.cpp new file mode 100644 index 00000000..0eb60163 --- /dev/null +++ b/pokemodr/SpeciesEvolutionUI.cpp @@ -0,0 +1,226 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: pokegen/SpeciesEvolutionUI.cpp +// Purpose: SpeciesEvolution UI form handling +// Author: Ben Boeckel +// Modified by: Ben Boeckel +// Created: Tue Feb 19 19:08:26 2008 +// Copyright: ©2007-2008 Ben Boeckel and Nerdy Productions +// Licence: +// 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, see <http://www.gnu.org/licenses/>. +///////////////////////////////////////////////////////////////////////////// + +#include <QMetaObject> +#include <QStringListModel> +#include <QVariant> +#include "../general/BugCatcher.h" +#include "../general/Exception.h" +#include "../general/Ref.h" +#include "../pokemod/Pokemod.h" +#include "../pokemod/Species.h" +#include "../pokemod/SpeciesEvolution.h" +#include "SpeciesEvolutionUI.h" + +SpeciesEvolutionUI::SpeciesEvolutionUI(SpeciesEvolution* s, QWidget* parent) : + ObjectUI(parent), + lastStyle(-1), + speciesEvolution(s), + speciesEvolution_mod(new SpeciesEvolution(s->getPokemod(), *s, s->getId())) +{ + setupUi(this); + QMetaObject::connectSlotsByName(this); + setObjects(speciesEvolution, speciesEvolution_mod); + for (int i = 0; i < speciesEvolution->getPokemod()->getSpeciesCount(); ++i) + { + const Species* s = speciesEvolution->getPokemod()->getSpecies(i); + varSpecies->addItem(s->getName()); + varSpecies->setItemData(i, s->getId()); + } + varStyle->addItems(SpeciesEvolution::StyleStr); + setGui(); +} + +// KToolbar SpeciesEvolutionUI::getToolbar(QWidget* parent) +// { +// +// } + +void SpeciesEvolutionUI::setGui() +{ + const bool styleChanged = (speciesEvolution_mod->getStyle() != lastStyle); + varSpecies->setCurrentIndex(varSpecies->findData(speciesEvolution_mod->getSpecies())); + varStyle->setCurrentIndex(speciesEvolution_mod->getStyle()); + if (styleChanged) + { + varVal1->clear(); + varVal1->setEnabled(false); + varVal2->clear(); + varVal2->setEnabled(false); + varVal3->setEnabled(false); + switch (speciesEvolution_mod->getStyle()) + { + case SpeciesEvolution::S_Level: + case SpeciesEvolution::S_Happiness: + case SpeciesEvolution::S_Stat: + case SpeciesEvolution::S_Personality: + varVal1->setEnabled(true); + varVal1->addItems(RelativeStr); + break; + case SpeciesEvolution::S_Item: + case SpeciesEvolution::S_TradeItem: + varVal1->setEnabled(true); + for (int i = 0; i < speciesEvolution->getPokemod()->getItemCount(); ++i) + { + const Item* it = speciesEvolution->getPokemod()->getItem(i); + for (int j = 0; j < it->getEffectCount(); ++j) + { + if (it->getEffect(i)->getEffect() == ItemEffect::E_Evolution) + { + varVal1->addItem(it->getName()); + varVal1->setItemData(i, it->getId()); + } + } + } + break; + } + const bool isSplit = speciesEvolution->getPokemod()->getRules()->getSpecialSplit(); + switch (speciesEvolution_mod->getStyle()) + { + case SpeciesEvolution::S_Stat: + varVal2->setEnabled(true); + varVal2->addItems((isSplit ? StatGSCStr : StatRBYStr).mid(0, isSplit ? ST_End_GSC : ST_End_RBY)); + break; + case SpeciesEvolution::S_Item: + varVal2->setEnabled(true); + varVal2->addItems(SpeciesEvolution::GiveHoldStr); + break; + } + switch (speciesEvolution_mod->getStyle()) + { + case SpeciesEvolution::S_Happiness: + case SpeciesEvolution::S_Stat: + case SpeciesEvolution::S_Item: + case SpeciesEvolution::S_Personality: + varVal3->setEnabled(true); + break; + } + lastStyle = speciesEvolution_mod->getStyle(); + } + if ((speciesEvolution_mod->getStyle() == SpeciesEvolution::S_Item) ||(speciesEvolution_mod->getStyle() == SpeciesEvolution::S_TradeItem)) + varVal1->setCurrentIndex(varVal1->findData(speciesEvolution_mod->getVal1())); + else + varVal1->setCurrentIndex(speciesEvolution_mod->getVal1()); + varVal2->setCurrentIndex(speciesEvolution_mod->getVal2()); + varVal3->setValue(speciesEvolution_mod->getVal3()); + varLevel->setValue(speciesEvolution_mod->getLevel()); +} + +void SpeciesEvolutionUI::on_buttonApply_clicked() +{ + *speciesEvolution = *speciesEvolution_mod; + emit(setChanged(false)); +} + +void SpeciesEvolutionUI::on_buttonDiscard_clicked() +{ + *speciesEvolution_mod = *speciesEvolution; + emit(setChanged(false)); + setGui(); +} + +void SpeciesEvolutionUI::on_varSpecies_currentIndexChanged(const int s) +{ + try + { + speciesEvolution_mod->setSpecies(varSpecies->itemData(s).toInt()); + emit(setChanged(true)); + } + catch (BoundsException& e) + { + BugCatcher::report(e); + } + setGui(); +} + +void SpeciesEvolutionUI::on_varStyle_currentIndexChanged(const int s) +{ + try + { + speciesEvolution_mod->setStyle(s); + emit(setChanged(true)); + } + catch (BoundsException& e) + { + BugCatcher::report(e); + } + setGui(); +} + +void SpeciesEvolutionUI::on_varVal1_currentIndexChanged(const int v) +{ + try + { + if ((speciesEvolution_mod->getStyle() == SpeciesEvolution::S_Item) ||(speciesEvolution_mod->getStyle() == SpeciesEvolution::S_TradeItem)) + speciesEvolution_mod->setVal1(varVal1->itemData(v).toInt()); + else + speciesEvolution_mod->setVal1(v); + emit(setChanged(true)); + } + catch (Exception& e) + { + BugCatcher::report(e); + } + setGui(); +} + +void SpeciesEvolutionUI::on_varVal2_currentIndexChanged(const int v) +{ + try + { + speciesEvolution_mod->setVal3(v); + emit(setChanged(true)); + } + catch (Exception& e) + { + BugCatcher::report(e); + } + setGui(); +} + +void SpeciesEvolutionUI::on_varVal3_valueChanged(const int v) +{ + try + { + speciesEvolution_mod->setVal3(v); + emit(setChanged(true)); + } + catch (UnusedException& e) + { + BugCatcher::report(e); + } + setGui(); +} + +void SpeciesEvolutionUI::on_varLevel_valueChanged(const int l) +{ + try + { + speciesEvolution_mod->setLevel(l); + emit(setChanged(true)); + } + catch (BoundsException& e) + { + BugCatcher::report(e); + } + setGui(); +} diff --git a/pokemodr/SpeciesEvolutionUI.h b/pokemodr/SpeciesEvolutionUI.h new file mode 100644 index 00000000..196e8bdf --- /dev/null +++ b/pokemodr/SpeciesEvolutionUI.h @@ -0,0 +1,62 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: pokegen/SpeciesEvolutionUI.h +// Purpose: SpeciesEvolution UI form handling +// Author: Ben Boeckel +// Modified by: Ben Boeckel +// Created: Tue Feb 19 19:08:58 2008 +// Copyright: ©2007-2008 Ben Boeckel and Nerdy Productions +// Licence: +// 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, see <http://www.gnu.org/licenses/>. +///////////////////////////////////////////////////////////////////////////// + +#ifndef __POKEMODR_SPECIESEVOLUTIONUI__ +#define __POKEMODR_SPECIESEVOLUTIONUI__ + +#include <ktoolbar.h> +#include <QString> +#include "../pokemod/SpeciesEvolution.h" +#include "ObjectUI.h" +#include "ui_speciesevolution.h" + +class SpeciesEvolutionUI : public ObjectUI, private Ui::formSpeciesEvolution +{ + Q_OBJECT + + public: + SpeciesEvolutionUI(SpeciesEvolution* s, QWidget* parent); + ~SpeciesEvolutionUI() + { + delete speciesEvolution_mod; + } + +// KToolbar getToolbar(QWidget* parent); + public slots: + void on_buttonApply_clicked(); + void on_buttonDiscard_clicked(); + void on_varSpecies_currentIndexChanged(const int s); + void on_varStyle_currentIndexChanged(const int s); + void on_varVal1_currentIndexChanged(const int v); + void on_varVal2_currentIndexChanged(const int v); + void on_varVal3_valueChanged(const int v); + void on_varLevel_valueChanged(const int l); + private: + void setGui(); + + int lastStyle; + + SpeciesEvolution* speciesEvolution; + SpeciesEvolution* speciesEvolution_mod; +}; + +#endif diff --git a/pokemodr/SpeciesItemUI.cpp b/pokemodr/SpeciesItemUI.cpp index f68aa412..c4d140e8 100644 --- a/pokemodr/SpeciesItemUI.cpp +++ b/pokemodr/SpeciesItemUI.cpp @@ -27,6 +27,7 @@ #include "../general/Exception.h" #include "../pokemod/Item.h" #include "../pokemod/Pokemod.h" +#include "../pokemod/SpeciesItem.h" #include "SpeciesItemUI.h" SpeciesItemUI::SpeciesItemUI(SpeciesItem* s, QWidget* parent) : diff --git a/pokemodr/SpeciesMoveUI.cpp b/pokemodr/SpeciesMoveUI.cpp index 241998ec..9922d0d9 100644 --- a/pokemodr/SpeciesMoveUI.cpp +++ b/pokemodr/SpeciesMoveUI.cpp @@ -27,6 +27,7 @@ #include "../general/Exception.h" #include "../pokemod/Move.h" #include "../pokemod/Pokemod.h" +#include "../pokemod/SpeciesMove.h" #include "SpeciesMoveUI.h" SpeciesMoveUI::SpeciesMoveUI(SpeciesMove* s, QWidget* parent) : diff --git a/pokemodr/TODO b/pokemodr/TODO index ca246088..409eadee 100644 --- a/pokemodr/TODO +++ b/pokemodr/TODO @@ -11,7 +11,6 @@ MapWildListEncounter MoveEffect Pokemod Species -SpeciesEvolution Tree Handling Toolbar loading diff --git a/pokemodr/gui/speciesevolution.ui b/pokemodr/gui/speciesevolution.ui index b41cba16..7ff2f2e5 100644 --- a/pokemodr/gui/speciesevolution.ui +++ b/pokemodr/gui/speciesevolution.ui @@ -5,8 +5,8 @@ <rect> <x>0</x> <y>0</y> - <width>226</width> - <height>542</height> + <width>244</width> + <height>545</height> </rect> </property> <property name="windowTitle" > @@ -134,15 +134,9 @@ </property> <layout class="QHBoxLayout" > <item> - <widget class="KComboBox" name="varVal3" > - <property name="toolTip" > - <string>Value 3</string> - </property> - <property name="insertPolicy" > - <enum>QComboBox::NoInsert</enum> - </property> - <property name="sizeAdjustPolicy" > - <enum>QComboBox::AdjustToContents</enum> + <widget class="KIntNumInput" name="varVal3" > + <property name="minimum" > + <number>0</number> </property> </widget> </item> |
