summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Changelog14
-rw-r--r--pokemod/CoinList.cpp6
-rw-r--r--pokemod/Item.cpp9
-rw-r--r--pokemod/Item.h2
-rw-r--r--pokemod/ItemEffect.h1
-rw-r--r--pokemod/Pokemod.cpp2
-rw-r--r--pokemod/Pokemod.h2
-rw-r--r--pokemod/Rules.cpp2
-rw-r--r--pokemod/Rules.h2
-rw-r--r--pokemodr/AbilityUI.cpp1
-rw-r--r--pokemodr/CoinListUI.cpp82
-rw-r--r--pokemodr/CoinListUI.h56
-rw-r--r--pokemodr/EggGroupUI.cpp64
-rw-r--r--pokemodr/EggGroupUI.h55
-rw-r--r--pokemodr/ItemUI.cpp106
-rw-r--r--pokemodr/ItemUI.h59
-rw-r--r--pokemodr/PokeModrUI.cpp8
17 files changed, 459 insertions, 12 deletions
diff --git a/Changelog b/Changelog
index 88fb97ac..f06727f8 100644
--- a/Changelog
+++ b/Changelog
@@ -1,11 +1,23 @@
-----------------
+Rev: 52
+Date: 31 January 2008
+User: MathStuf
+-----------------
+[FIX] Changelog fixed
+[FIX] Warnings in pokemod gone
+[FIX] BoundsException thrown from Item::setPrice()
+[FIX] CoinLIst now has correct className
+[FIX] Frac needed in header for ItemEffect
+[ADD] CoinList, EggGroup, and Item UI logic added
+
+-----------------
Rev: 51
Date: 31 January 2008
User: MathStuf
-----------------
[ADD] GenericListItem.{h, cpp}
[FIX] BadgeUI bugs (some still exist)
-[FIX] Other UI bugs
+[FIX] Other UI bugs fixed
-----------------
Rev: 50
diff --git a/pokemod/CoinList.cpp b/pokemod/CoinList.cpp
index 5dd0f3df..339bc45a 100644
--- a/pokemod/CoinList.cpp
+++ b/pokemod/CoinList.cpp
@@ -32,20 +32,20 @@
#include "CoinList.h"
CoinList::CoinList(const Pokemod& par, const unsigned _id) :
- Object("ClassName", par, _id),
+ Object("CoinList", par, _id),
name(""),
value(0)
{
}
CoinList::CoinList(const Pokemod& par, const CoinList& c, const unsigned _id) :
- Object("ClassName", par, _id)
+ Object("CoinList", par, _id)
{
*this = c;
}
CoinList::CoinList(const Pokemod& par, const QString& fname, const unsigned _id) :
- Object("ClassName", par, _id)
+ Object("CoinList", par, _id)
{
load(fname, _id);
}
diff --git a/pokemod/Item.cpp b/pokemod/Item.cpp
index 57bba3eb..ad51768d 100644
--- a/pokemod/Item.cpp
+++ b/pokemod/Item.cpp
@@ -65,6 +65,11 @@ bool Item::validate() const
pokemod.validationMsg("Invalid item type");
valid = false;
}
+ if (pokemod.getRules().getMaxMoney() < price)
+ {
+ pokemod.validationMsg("Invalid price");
+ valid = false;
+ }
if (getEffectCount())
{
QMap<unsigned, unsigned> idChecker;
@@ -153,8 +158,10 @@ void Item::setType(const unsigned t) throw(BoundsException)
type = t;
}
-void Item::setPrice(const unsigned p)
+void Item::setPrice(const unsigned p) throw(BoundsException)
{
+ if (pokemod.getRules().getMaxMoney() < p)
+ throw(BoundsException(className, "price"));
price = p;
}
diff --git a/pokemod/Item.h b/pokemod/Item.h
index db146f92..b6c69d68 100644
--- a/pokemod/Item.h
+++ b/pokemod/Item.h
@@ -44,7 +44,7 @@ class Item : public Object
void setName(const QString& n);
void setSellable(const bool s);
void setType(const unsigned t) throw(BoundsException);
- void setPrice(const unsigned p);
+ void setPrice(const unsigned p) throw(BoundsException);
void setDescription(const QString& d);
QString getName() const;
diff --git a/pokemod/ItemEffect.h b/pokemod/ItemEffect.h
index e602e597..3fdb5471 100644
--- a/pokemod/ItemEffect.h
+++ b/pokemod/ItemEffect.h
@@ -26,6 +26,7 @@
#include <QString>
#include <QStringList>
#include "../general/Exception.h"
+#include "../general/Frac.h"
#include "Object.h"
class Pokemod;
diff --git a/pokemod/Pokemod.cpp b/pokemod/Pokemod.cpp
index 919828eb..973d297a 100644
--- a/pokemod/Pokemod.cpp
+++ b/pokemod/Pokemod.cpp
@@ -741,7 +741,7 @@ unsigned Pokemod::getNewTypeId() const
;
return i;
}
-void Pokemod::load(const QString& fname, const unsigned _id) throw(Exception)
+void Pokemod::load(const QString& fname, const unsigned) throw(Exception)
{
Ini ini(fname);
QStringList fpath = fname.split('\\', QString::SkipEmptyParts).join("/").split('\\', QString::SkipEmptyParts);
diff --git a/pokemod/Pokemod.h b/pokemod/Pokemod.h
index 1ef026e4..a97b5d6c 100644
--- a/pokemod/Pokemod.h
+++ b/pokemod/Pokemod.h
@@ -63,7 +63,7 @@ class Pokemod : public Object
Pokemod();
Pokemod(const QString& fpath);
- void load(const QString& fpath, const unsigned _id = 0) throw(Exception);
+ void load(const QString& fpath, const unsigned = 0) throw(Exception);
void save() const throw(Exception);
QString getPath() const;
diff --git a/pokemod/Rules.cpp b/pokemod/Rules.cpp
index 866c3d13..122d1750 100644
--- a/pokemod/Rules.cpp
+++ b/pokemod/Rules.cpp
@@ -113,7 +113,7 @@ bool Rules::validate() const
return valid;
}
-void Rules::load(const QString& fname, const unsigned _id) throw(Exception)
+void Rules::load(const QString& fname, const unsigned) throw(Exception)
{
Ini ini(fname);
unsigned i;
diff --git a/pokemod/Rules.h b/pokemod/Rules.h
index 943a5e20..f6c23dbb 100644
--- a/pokemod/Rules.h
+++ b/pokemod/Rules.h
@@ -39,7 +39,7 @@ class Rules : public Object
Rules(const Pokemod& par, const Rules& r);
Rules(const Pokemod& par, const QString& fname);
- void load(const QString& fname, const unsigned _id = 0) throw(Exception);
+ void load(const QString& fname, const unsigned = 0) throw(Exception);
void save() const throw(Exception);
void setGenderAllowed(const bool g);
diff --git a/pokemodr/AbilityUI.cpp b/pokemodr/AbilityUI.cpp
index bee4a90c..dccbfa2d 100644
--- a/pokemodr/AbilityUI.cpp
+++ b/pokemodr/AbilityUI.cpp
@@ -21,7 +21,6 @@
/////////////////////////////////////////////////////////////////////////////
#include <QMetaObject>
-#include "../general/Exception.h"
#include "AbilityUI.h"
AbilityUI::AbilityUI(Ability* a, QWidget* parent) :
diff --git a/pokemodr/CoinListUI.cpp b/pokemodr/CoinListUI.cpp
new file mode 100644
index 00000000..6fc14aa0
--- /dev/null
+++ b/pokemodr/CoinListUI.cpp
@@ -0,0 +1,82 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: pokegen/CoinListUI.cpp
+// Purpose: CoinList UI form handling
+// Author: Ben Boeckel
+// Modified by: Ben Boeckel
+// Created: Sun Jan 27 12:31:08 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
+// MERCHANTCoinList 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 "../general/BugCatcher.h"
+#include "../general/Exception.h"
+#include "CoinListUI.h"
+
+CoinListUI::CoinListUI(CoinList* c, QWidget* parent) :
+ ObjectUI(parent),
+ coinList(c),
+ coinList_mod(new CoinList(c->getPokemod(), *c, c->getId()))
+{
+ setupUi(this);
+ QMetaObject::connectSlotsByName(this);
+ setObjects(coinList, coinList_mod);
+ setGui();
+}
+
+// KToolbar CoinListUI::getToolbar(QWidget* parent)
+// {
+//
+// }
+
+void CoinListUI::setGui()
+{
+ varName->setText(coinList_mod->getName());
+ varValue->setValue(coinList_mod->getValue());
+}
+
+void CoinListUI::on_buttonApply_clicked()
+{
+ *coinList = *coinList_mod;
+ emit(setChanged(false));
+}
+
+void CoinListUI::on_buttonDiscard_clicked()
+{
+ *coinList_mod = *coinList;
+ emit(setChanged(false));
+ setGui();
+}
+
+void CoinListUI::on_varName_textChanged(const QString& n)
+{
+ coinList_mod->setName(n);
+ emit(setChanged(true));
+}
+
+void CoinListUI::on_varValue_valueChanged(const int v)
+{
+ // TODO: Make a KComboBox with all available coin types instead
+ try
+ {
+ coinList_mod->setValue(v);
+ emit(setChanged(true));
+ }
+ catch (Exception& e)
+ {
+// BugCatcher::report(e);
+ setGui();
+ }
+}
diff --git a/pokemodr/CoinListUI.h b/pokemodr/CoinListUI.h
new file mode 100644
index 00000000..a157b69e
--- /dev/null
+++ b/pokemodr/CoinListUI.h
@@ -0,0 +1,56 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: pokegen/CoinListUI.h
+// Purpose: CoinList UI form handling
+// Author: Ben Boeckel
+// Modified by: Ben Boeckel
+// Created: Thu Jan 31 14:10:45 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
+// MERCHANTCoinList 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_COINLISTUI__
+#define __POKEMODR_COINLISTUI__
+
+#include <ktoolbar.h>
+#include <QString>
+#include "../pokemod/CoinList.h"
+#include "ObjectUI.h"
+#include "ui_coinlist.h"
+
+class CoinListUI : public ObjectUI, private Ui::formCoinList
+{
+ Q_OBJECT
+
+ public:
+ CoinListUI(CoinList* c, QWidget* parent);
+ ~CoinListUI()
+ {
+ delete coinList_mod;
+ }
+
+// KToolbar getToolbar(QWidget* parent);
+ public slots:
+ void on_buttonApply_clicked();
+ void on_buttonDiscard_clicked();
+ void on_varName_textChanged(const QString& n);
+ void on_varValue_valueChanged(const int v);
+ private:
+ void setGui();
+
+ CoinList* coinList;
+ CoinList* coinList_mod;
+};
+
+#endif
diff --git a/pokemodr/EggGroupUI.cpp b/pokemodr/EggGroupUI.cpp
new file mode 100644
index 00000000..94afe722
--- /dev/null
+++ b/pokemodr/EggGroupUI.cpp
@@ -0,0 +1,64 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: pokegen/EggGroupUI.cpp
+// Purpose: EggGroup UI form handling
+// Author: Ben Boeckel
+// Modified by: Ben Boeckel
+// Created: Sun Jan 27 12:31:08 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
+// MERCHANTEggGroup 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 "EggGroupUI.h"
+
+EggGroupUI::EggGroupUI(EggGroup* e, QWidget* parent) :
+ ObjectUI(parent),
+ eggGroup(e),
+ eggGroup_mod(new EggGroup(e->getPokemod(), *e, e->getId()))
+{
+ setupUi(this);
+ QMetaObject::connectSlotsByName(this);
+ setObjects(eggGroup, eggGroup_mod);
+ setGui();
+}
+
+// KToolbar EggGroupUI::getToolbar(QWidget* parent)
+// {
+//
+// }
+
+void EggGroupUI::setGui()
+{
+ varName->setText(eggGroup_mod->getName());
+}
+
+void EggGroupUI::on_buttonApply_clicked()
+{
+ *eggGroup = *eggGroup_mod;
+ emit(setChanged(false));
+}
+
+void EggGroupUI::on_buttonDiscard_clicked()
+{
+ *eggGroup_mod = *eggGroup;
+ emit(setChanged(false));
+ setGui();
+}
+
+void EggGroupUI::on_varName_textChanged(const QString& n)
+{
+ eggGroup_mod->setName(n);
+ emit(setChanged(true));
+}
diff --git a/pokemodr/EggGroupUI.h b/pokemodr/EggGroupUI.h
new file mode 100644
index 00000000..e52e6738
--- /dev/null
+++ b/pokemodr/EggGroupUI.h
@@ -0,0 +1,55 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: pokegen/EggGroupUI.h
+// Purpose: EggGroup UI form handling
+// Author: Ben Boeckel
+// Modified by: Ben Boeckel
+// Created: Sun Jan 27 12:29:48 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
+// MERCHANTEggGroup 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_EGGGROUPUI__
+#define __POKEMODR_EGGGROUPUI__
+
+#include <ktoolbar.h>
+#include <QString>
+#include "../pokemod/EggGroup.h"
+#include "ObjectUI.h"
+#include "ui_egggroup.h"
+
+class EggGroupUI : public ObjectUI, private Ui::formEggGroup
+{
+ Q_OBJECT
+
+ public:
+ EggGroupUI(EggGroup* e, QWidget* parent);
+ ~EggGroupUI()
+ {
+ delete eggGroup_mod;
+ }
+
+// KToolbar getToolbar(QWidget* parent);
+ public slots:
+ void on_buttonApply_clicked();
+ void on_buttonDiscard_clicked();
+ void on_varName_textChanged(const QString& n);
+ private:
+ void setGui();
+
+ EggGroup* eggGroup;
+ EggGroup* eggGroup_mod;
+};
+
+#endif
diff --git a/pokemodr/ItemUI.cpp b/pokemodr/ItemUI.cpp
new file mode 100644
index 00000000..8bc7e914
--- /dev/null
+++ b/pokemodr/ItemUI.cpp
@@ -0,0 +1,106 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: pokegen/ItemUI.cpp
+// Purpose: Item UI form handling
+// Author: Ben Boeckel
+// Modified by: Ben Boeckel
+// Created: Sun Jan 27 12:31:08 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
+// MERCHANTItem 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 "../general/BugCatcher.h"
+#include "../general/Exception.h"
+#include "../pokemod/Pokemod.h"
+#include "ItemUI.h"
+
+ItemUI::ItemUI(Item* i, QWidget* parent) :
+ ObjectUI(parent),
+ item(i),
+ item_mod(new Item(i->getPokemod(), *i, i->getId()))
+{
+ setupUi(this);
+ QMetaObject::connectSlotsByName(this);
+ setObjects(item, item_mod);
+ setGui();
+}
+
+// KToolbar ItemUI::getToolbar(QWidget* parent)
+// {
+//
+// }
+
+void ItemUI::setGui()
+{
+ varName->setText(item_mod->getName());
+ boxSellable->setChecked(item_mod->getSellable() ? Qt::Checked : Qt::Unchecked);
+ varType->clear();
+//
+//
+//
+ varPrice->setMaximum(item->getPokemod().getRules().getMaxMoney());
+ varPrice->setValue(item_mod->getPrice());
+ varDescription->setText(item_mod->getDescription());
+}
+
+void ItemUI::on_buttonApply_clicked()
+{
+ *item = *item_mod;
+ emit(setChanged(false));
+}
+
+void ItemUI::on_buttonDiscard_clicked()
+{
+ *item_mod = *item;
+ emit(setChanged(false));
+ setGui();
+}
+
+void ItemUI::on_varName_textChanged(const QString& n)
+{
+ item_mod->setName(n);
+ emit(setChanged(true));
+}
+
+void ItemUI::on_boxSellable_toggled(const bool s)
+{
+ item_mod->setSellable(s);
+ emit(setChanged(true));
+}
+
+void ItemUI::on_varType_currentIndexChanged(const QString& t)
+{
+
+}
+
+void ItemUI::on_varPrice_valueChanged(const int p)
+{
+ try
+ {
+ item_mod->setPrice(p);
+ emit(setChanged(true));
+ }
+ catch (BoundsException& e)
+ {
+ BugCatcher::report(e);
+ setGui();
+ }
+}
+
+void ItemUI::on_varDescription_textChanged()
+{
+ item_mod->setDescription(varDescription->toPlainText());
+ emit(setChanged(true));
+}
diff --git a/pokemodr/ItemUI.h b/pokemodr/ItemUI.h
new file mode 100644
index 00000000..e3bea958
--- /dev/null
+++ b/pokemodr/ItemUI.h
@@ -0,0 +1,59 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: pokegen/ItemUI.h
+// Purpose: Item UI form handling
+// Author: Ben Boeckel
+// Modified by: Ben Boeckel
+// Created: Sun Jan 27 12:29:48 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
+// MERCHANTItem 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_ITEMUI__
+#define __POKEMODR_ITEMUI__
+
+#include <ktoolbar.h>
+#include <QString>
+#include "../pokemod/Item.h"
+#include "ObjectUI.h"
+#include "ui_item.h"
+
+class ItemUI : public ObjectUI, private Ui::formItem
+{
+ Q_OBJECT
+
+ public:
+ ItemUI(Item* e, QWidget* parent);
+ ~ItemUI()
+ {
+ delete item_mod;
+ }
+
+// KToolbar getToolbar(QWidget* parent);
+ public slots:
+ void on_buttonApply_clicked();
+ void on_buttonDiscard_clicked();
+ void on_varName_textChanged(const QString& n);
+ void on_boxSellable_toggled(const bool s);
+ void on_varType_currentIndexChanged(const QString& t);
+ void on_varPrice_valueChanged(const int p);
+ void on_varDescription_textChanged();
+ private:
+ void setGui();
+
+ Item* item;
+ Item* item_mod;
+};
+
+#endif
diff --git a/pokemodr/PokeModrUI.cpp b/pokemodr/PokeModrUI.cpp
index 8c932d3b..5a66050b 100644
--- a/pokemodr/PokeModrUI.cpp
+++ b/pokemodr/PokeModrUI.cpp
@@ -31,7 +31,10 @@
#include "AbilityUI.h"
#include "AuthorUI.h"
#include "BadgeUI.h"
+#include "CoinListUI.h"
+#include "EggGroupUI.h"
#include "NatureUI.h"
+#include "ItemUI.h"
#include "ItemTypeUI.h"
#include "RulesUI.h"
#include "TimeUI.h"
@@ -58,7 +61,10 @@ PokeModrUI::PokeModrUI(KConfigGroup cfg, KConfigGroup history, QWidget* parent)
{
// formPanel->setViewport(new AbilityUI(&pokemod->newAbility(), formPanel));
// formPanel->setViewport(new AuthorUI(&pokemod->newAuthor(), formPanel));
- formPanel->setViewport(new BadgeUI(&pokemod->newBadge(), formPanel));
+// formPanel->setViewport(new BadgeUI(&pokemod->newBadge(), formPanel));
+// formPanel->setViewport(new CoinListUI(&pokemod->newCoinList(), formPanel));
+// formPanel->setViewport(new EggGroupUI(&pokemod->newEggGroup(), formPanel));
+ formPanel->setViewport(new ItemUI(&pokemod->newItem(), formPanel));
// formPanel->setViewport(NatureUI(&pokemod->newNature(), formPanel));
// formPanel->setViewport(new ItemTypeUI(&pokemod->newItemType(), formPanel));
// formPanel->setViewport(new TimeUI(&pokemod->newTime(), formPanel));