summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-01-25 02:21:09 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-01-25 02:21:09 +0000
commit081bd53cf22ca40a6e436bc46eb62ad469909d6f (patch)
tree2b20a84df93e418ab0261231cf4b993ec57b2ca2
parent095c93a62b0be0893063748d67051e35810a7f48 (diff)
downloadsigen-081bd53cf22ca40a6e436bc46eb62ad469909d6f.tar.gz
sigen-081bd53cf22ca40a6e436bc46eb62ad469909d6f.tar.xz
sigen-081bd53cf22ca40a6e436bc46eb62ad469909d6f.zip
[FIX] Frac returns a double (not an unsigned typcast to double, making 0 all the time)
[FIX] maxDV now works on 0 and 1 rather than 16 and 32 [FIX] Stuff ignored (due to other options) can't throw Exceptions in Rules anymore [FIX] UI logic fixed git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@45 6ecfd1a5-f3ed-3746-8530-beee90d26b22
-rw-r--r--Changelog10
-rw-r--r--general/Frac.h2
-rw-r--r--pokemod/Rules.cpp30
-rw-r--r--pokemod/Rules.h6
-rw-r--r--pokemodr/ObjectUI.h21
-rw-r--r--pokemodr/PokeModr.cpp14
-rw-r--r--pokemodr/PokeModrUI.cpp6
-rw-r--r--pokemodr/RulesUI.cpp66
-rw-r--r--pokemodr/TimeUI.cpp5
9 files changed, 95 insertions, 65 deletions
diff --git a/Changelog b/Changelog
index 42a0bfd0..356e3c8f 100644
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,14 @@
-----------------
+Rev: 45
+Date: 24 January 2008
+User: MathStuf
+-----------------
+[FIX] Frac returns a double (not an unsigned typcast to double, making 0 all the time)
+[FIX] maxDV now works on 0 and 1 rather than 16 and 32
+[FIX] Stuff ignored (due to other options) can't throw Exceptions in Rules anymore
+[FIX] UI logic fixed
+
+-----------------
Rev: 44
Date: 24 January 2008
User: MathStuf
diff --git a/general/Frac.h b/general/Frac.h
index 046fc789..fb00845e 100644
--- a/general/Frac.h
+++ b/general/Frac.h
@@ -70,7 +70,7 @@ class Frac
operator double() const
{
- return (num / denom);
+ return (double(num) / denom);
}
private:
unsigned num;
diff --git a/pokemod/Rules.cpp b/pokemod/Rules.cpp
index 7f031eb6..6bf47102 100644
--- a/pokemod/Rules.cpp
+++ b/pokemod/Rules.cpp
@@ -43,7 +43,7 @@ Rules::Rules(const Pokemod& par) :
hardCash(false),
specialSplit(false),
specialDVSplit(false),
- maxDVValue(16),
+ maxDVValue(0),
happiness(false),
happyFaintLoss(0),
happyLevelGain(0),
@@ -95,7 +95,7 @@ bool Rules::validate() const
}
if (!maxMoney)
pokemod.validationMsg("Player cannot carry any money", Pokemod::V_Warn);
- if ((maxDVValue != 16) && (maxDVValue != 32))
+ if (1 < maxDVValue)
{
pokemod.validationMsg("Invalid maximum DV value");
valid = false;
@@ -182,14 +182,10 @@ void Rules::save() const throw(Exception)
void Rules::setGenderAllowed(const bool g)
{
genderAllowed = g;
- if (!genderAllowed)
- breedingAllowed = false;
}
-void Rules::setBreedingAllowed(const bool b) throw(Exception)
+void Rules::setBreedingAllowed(const bool b)
{
- if (b && !genderAllowed)
- throw(Exception(className, "cannot breed without genders"));
breedingAllowed = b;
}
@@ -228,6 +224,8 @@ void Rules::setMaxParty(const unsigned m) throw(BoundsException)
if (!m)
throw(BoundsException(className, "maxParty"));
maxParty = m;
+ if (maxFight < m)
+ setMaxFight(m);
}
void Rules::setMaxFight(const unsigned m) throw(BoundsException)
@@ -264,6 +262,8 @@ void Rules::setHardCash(const bool h)
void Rules::setSpecialSplit(const bool s)
{
specialSplit = s;
+ if (!s)
+ setSpecialDVSplit(false);
}
void Rules::setSpecialDVSplit(const bool s)
@@ -273,7 +273,7 @@ void Rules::setSpecialDVSplit(const bool s)
void Rules::setMaxDVValue(const unsigned char m) throw(BoundsException)
{
- if ((m != 16) && (m != 32))
+ if (1 < m)
throw(BoundsException(className, "maxDVValue"));
maxDVValue = m;
}
@@ -303,18 +303,18 @@ void Rules::setEffortValuesAllowed(const bool e)
effortValuesAllowed = e;
}
-void Rules::setMaxTotalEV(const unsigned m) throw(Exception)
+void Rules::setMaxTotalEV(const unsigned m) throw(BoundsException)
{
- if (!effortValuesAllowed)
- throw(Exception(className, "no effort values"));
+ if (!m)
+ throw(BoundsException(className, "maxTotalEV"));
maxTotalEV = m;
+ if (m < maxEVPerStat)
+ setMaxEVPerStat(m);
}
-void Rules::setMaxEVPerStat(const unsigned m) throw(Exception)
+void Rules::setMaxEVPerStat(const unsigned m) throw(BoundsException)
{
- if (!effortValuesAllowed)
- throw(Exception(className, "no effort values"));
- if (maxTotalEV < m)
+ if (!m || (maxTotalEV < m))
throw(BoundsException(className, "maxEVPerStat"));
maxEVPerStat = m;
}
diff --git a/pokemod/Rules.h b/pokemod/Rules.h
index 3d0b764b..943a5e20 100644
--- a/pokemod/Rules.h
+++ b/pokemod/Rules.h
@@ -43,7 +43,7 @@ class Rules : public Object
void save() const throw(Exception);
void setGenderAllowed(const bool g);
- void setBreedingAllowed(const bool b) throw(Exception);
+ void setBreedingAllowed(const bool b);
void setHoldItems(const unsigned h);
void setCriticalDomains(const bool c);
void setAbilityAllowed(const bool a);
@@ -64,8 +64,8 @@ class Rules : public Object
void setHappyLevelGain(const unsigned h);
void setHappySteps(const unsigned h);
void setEffortValuesAllowed(const bool e);
- void setMaxTotalEV(const unsigned m) throw(Exception);
- void setMaxEVPerStat(const unsigned m) throw(Exception);
+ void setMaxTotalEV(const unsigned m) throw(BoundsException);
+ void setMaxEVPerStat(const unsigned m) throw(BoundsException);
void setPokerusChance(const unsigned n, const unsigned d) throw(Exception);
void setPokerusChanceNum(const unsigned n) throw(Exception);
void setPokerusChanceDenom(const unsigned d) throw(Exception);
diff --git a/pokemodr/ObjectUI.h b/pokemodr/ObjectUI.h
index 0b178641..391ac6af 100644
--- a/pokemodr/ObjectUI.h
+++ b/pokemodr/ObjectUI.h
@@ -33,24 +33,26 @@ class ObjectUI : public QWidget
Q_OBJECT
public:
- ObjectUI(Object* orig, Object* mod, QWidget* parent) :
+ ObjectUI(QWidget* parent) :
QWidget(parent),
- obj(orig),
- obj_mod(mod)
+ obj(NULL),
+ obj_mod(NULL)
{
- connect(this, SIGNAL(changed(bool)), parent->parent(), SLOT(setChangedTitle(bool)));
+ connect(this, SIGNAL(changed(bool)), parent->parent()->parent()->parent(), SLOT(setChangedTitle(bool)));
connect(this, SIGNAL(changed(bool)), SLOT(setChanged(bool)));
}
virtual ~ObjectUI()
{
}
-// virtual KToolBar getToolbar(QWidget* parent) = 0;
- void setChanged(const bool c)
+ void setObjects(Object* orig, Object* mod)
{
- isChanged = c;
+ obj = orig;
+ obj_mod = mod;
}
+// virtual KToolBar getToolbar(QWidget* parent) = 0;
+
const Object* getOriginal() const
{
return obj;
@@ -69,6 +71,11 @@ class ObjectUI : public QWidget
}
signals:
void changed(bool);
+ public slots:
+ void setChanged(const bool c)
+ {
+ isChanged = c;
+ }
protected:
virtual void setGui() = 0;
diff --git a/pokemodr/PokeModr.cpp b/pokemodr/PokeModr.cpp
index 0b668136..ee9d6ee0 100644
--- a/pokemodr/PokeModr.cpp
+++ b/pokemodr/PokeModr.cpp
@@ -45,7 +45,15 @@ int main(int argc, char* argv[])
KConfig cfg("~/.kde/share/config/pokegenrc");
- PokeModrUI mainWindow(cfg.group("pokemodr"), cfg.group("pokemodr-recent"));
- mainWindow.show();
- return app.exec();
+ try
+ {
+ PokeModrUI mainWindow(cfg.group("pokemodr"), cfg.group("pokemodr-recent"));
+ mainWindow.show();
+ return app.exec();
+ }
+ catch (Exception& e)
+ {
+ BugCatcher::report(e);
+ }
+ return -1;
}
diff --git a/pokemodr/PokeModrUI.cpp b/pokemodr/PokeModrUI.cpp
index dc14ac51..3115d2d3 100644
--- a/pokemodr/PokeModrUI.cpp
+++ b/pokemodr/PokeModrUI.cpp
@@ -51,9 +51,9 @@ PokeModrUI::PokeModrUI(KConfigGroup cfg, KConfigGroup history, QWidget* parent)
try
{
Pokemod foo;
- foo.newTime();
- formPanel->setViewport(new TimeUI(&foo.getTime(0), formPanel));
-// formPanel->setViewport(new RulesUI(&foo.getRules(), formPanel));
+// foo.newTime();
+// formPanel->setViewport(new TimeUI(&foo.getTime(0), formPanel));
+ formPanel->setViewport(new RulesUI(&foo.getRules(), formPanel));
}
catch (Exception& e)
{
diff --git a/pokemodr/RulesUI.cpp b/pokemodr/RulesUI.cpp
index 60ea3c50..33168e67 100644
--- a/pokemodr/RulesUI.cpp
+++ b/pokemodr/RulesUI.cpp
@@ -26,12 +26,13 @@
#include "RulesUI.h"
RulesUI::RulesUI(Rules* r, QWidget* parent) :
+ ObjectUI(parent),
rules(r),
- rules_mod(new Rules(r->getPokemod(), *r)),
- ObjectUI(r, rules_mod, parent)
+ rules_mod(new Rules(r->getPokemod(), *r))
{
setupUi(this);
QMetaObject::connectSlotsByName(this);
+ setObjects(rules, rules_mod);
varMaxDV->addItems(Rules::DVStr);
setGui();
}
@@ -60,7 +61,7 @@ void RulesUI::setGui()
boxHardCash->setChecked(rules_mod->getHardCash() ? Qt::Checked : Qt::Unchecked);
boxSplitSpecial->setChecked(rules_mod->getSpecialSplit() ? Qt::Checked : Qt::Unchecked);
varSplitSpecialDV->setCheckState(rules_mod->getSpecialDVSplit() ? Qt::Checked : Qt::Unchecked);
- varMaxDV->setCurrentItem(Rules::DVStr[rules_mod->getMaxDVValue() >> 5]);
+ varMaxDV->setCurrentItem(Rules::DVStr[rules_mod->getMaxDVValue()]);
boxHappiness->setChecked(rules_mod->getHappiness() ? Qt::Checked : Qt::Unchecked);
varFaintLoss->setValue(rules_mod->getHappyFaintLoss());
varLevelGain->setValue(rules_mod->getHappyLevelGain());
@@ -71,7 +72,7 @@ void RulesUI::setGui()
varMaxEVPerStat->setMaximum(rules_mod->getMaxTotalEV());
varPokerusNum->setValue(rules_mod->getPokerusChance().getNum());
varPokerusDenom->setValue(rules_mod->getPokerusChance().getDenom());
- varPokerusNum->setMaximum(rules_mod->getPokerusChance().getDenom() - 1);
+ varPokerusNum->setMaximum(rules_mod->getPokerusChance().getDenom());
}
void RulesUI::on_buttonApply_clicked()
@@ -91,23 +92,13 @@ void RulesUI::on_buttonDiscard_clicked()
void RulesUI::on_boxGenders_toggled(const bool g)
{
rules_mod->setGenderAllowed(g);
- if (!g)
- varBreeding->setCheckState(Qt::Unchecked);
emit(setChanged(true));
}
void RulesUI::on_varBreeding_toggled(const bool b)
{
- try
- {
- rules_mod->setBreedingAllowed(b);
- emit(setChanged(true));
- }
- catch (Exception& e)
- {
- BugCatcher::report(e);
- setGui();
- }
+ rules_mod->setBreedingAllowed(b);
+ emit(setChanged(true));
}
void RulesUI::on_varHeldItems_valueChanged(const int h)
@@ -148,10 +139,9 @@ void RulesUI::on_varBoxSize_valueChanged(const int b)
void RulesUI::on_varMaxParty_valueChanged(const int m)
{
- if (unsigned(m) < rules_mod->getMaxFight())
- varMaxFight->setValue(m);
rules_mod->setMaxParty(m);
varMaxFight->setMaximum(m);
+ setGui();
emit(setChanged(true));
}
@@ -212,8 +202,6 @@ void RulesUI::on_boxHardCash_toggled(const bool h)
void RulesUI::on_boxSplitSpecial_toggled(const bool s)
{
rules_mod->setSpecialSplit(s);
- if (!s)
- varSplitSpecialDV->setCheckState(Qt::Unchecked);
emit(setChanged(true));
}
@@ -229,7 +217,7 @@ void RulesUI::on_varMaxDV_currentIndexChanged(const QString& m)
{
if (Rules::DVStr.contains(m))
{
- rules_mod->setMaxDVValue((Rules::DVStr.indexOf(m) << 4) + 16);
+ rules_mod->setMaxDVValue(Rules::DVStr.indexOf(m));
emit(setChanged(true));
}
else
@@ -274,17 +262,33 @@ void RulesUI::on_boxEffortValues_toggled(const bool e)
void RulesUI::on_varMaxEV_valueChanged(const int m)
{
- if (unsigned(m) < rules_mod->getMaxEVPerStat())
- varMaxEVPerStat->setValue(m);
- rules_mod->setMaxTotalEV(m);
- varMaxEVPerStat->setMaximum(m);
- emit(setChanged(true));
+ try
+ {
+ if (unsigned(m) < rules_mod->getMaxEVPerStat())
+ varMaxEVPerStat->setValue(m);
+ rules_mod->setMaxTotalEV(m);
+ varMaxEVPerStat->setMaximum(m);
+ emit(setChanged(true));
+ }
+ catch (BoundsException& e)
+ {
+ BugCatcher::report(e);
+ setGui();
+ }
}
void RulesUI::on_varMaxEVPerStat_valueChanged(const int m)
{
- rules_mod->setMaxEVPerStat(m);
- emit(setChanged(true));
+ try
+ {
+ rules_mod->setMaxEVPerStat(m);
+ emit(setChanged(true));
+ }
+ catch (BoundsException& e)
+ {
+ BugCatcher::report(e);
+ setGui();
+ }
}
void RulesUI::on_varPokerusNum_valueChanged(const int p)
@@ -292,7 +296,7 @@ void RulesUI::on_varPokerusNum_valueChanged(const int p)
try
{
rules_mod->setPokerusChanceNum(p);
- varPokerus->setText(QString::number(rules_mod->getPokerusChance()));
+ varPokerus->setText(QString::number(rules_mod->getPokerusChance(), 'g', 15));
emit(setChanged(true));
}
catch (Exception& e)
@@ -307,8 +311,8 @@ void RulesUI::on_varPokerusDenom_valueChanged(const int p)
try
{
rules_mod->setPokerusChanceDenom(p);
- varPokerusNum->setMaximum(p - 1);
- varPokerus->setText(QString::number(rules_mod->getPokerusChance()));
+ varPokerusNum->setMaximum(p);
+ varPokerus->setText(QString::number(rules_mod->getPokerusChance(), 'g', 15));
emit(setChanged(true));
}
catch (Exception& e)
diff --git a/pokemodr/TimeUI.cpp b/pokemodr/TimeUI.cpp
index 599efc29..5710d16f 100644
--- a/pokemodr/TimeUI.cpp
+++ b/pokemodr/TimeUI.cpp
@@ -25,12 +25,13 @@
#include "TimeUI.h"
TimeUI::TimeUI(Time* t, QWidget* parent) :
+ ObjectUI(parent),
time(t),
- time_mod(new Time(t->getPokemod(), *t, t->getId())),
- ObjectUI(time, time_mod, parent)
+ time_mod(new Time(t->getPokemod(), *t, t->getId()))
{
setupUi(this);
QMetaObject::connectSlotsByName(this);
+ setObjects(time, time_mod);
setGui();
}