diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-01-31 18:33:10 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-01-31 18:33:10 +0000 |
| commit | 14a52db47b4268b03c4b37d84df48cdb3128f09c (patch) | |
| tree | 4d703295f64905ed6df097ecc870a0ef92c5ffe3 | |
| parent | ebbb362f9e70dc67354706fc2cbfc77d8dfcba4c (diff) | |
| download | sigen-14a52db47b4268b03c4b37d84df48cdb3128f09c.tar.gz sigen-14a52db47b4268b03c4b37d84df48cdb3128f09c.tar.xz sigen-14a52db47b4268b03c4b37d84df48cdb3128f09c.zip | |
[ADD] GenericListItem.{h, cpp}
[FIX] BadgeUI bugs (some still exist)
[FIX] Other UI bugs fixed
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@51 6ecfd1a5-f3ed-3746-8530-beee90d26b22
| -rw-r--r-- | Changelog | 9 | ||||
| -rw-r--r-- | pokemodr/AbilityUI.cpp | 1 | ||||
| -rw-r--r-- | pokemodr/AuthorUI.cpp | 1 | ||||
| -rw-r--r-- | pokemodr/BadgeUI.cpp | 90 | ||||
| -rw-r--r-- | pokemodr/BadgeUI.h | 14 | ||||
| -rw-r--r-- | pokemodr/GenericListItem.cpp | 32 | ||||
| -rw-r--r-- | pokemodr/GenericListItem.h | 48 | ||||
| -rw-r--r-- | pokemodr/PokeModTreeItem.h | 3 | ||||
| -rw-r--r-- | pokemodr/PokeModrUI.cpp | 28 | ||||
| -rw-r--r-- | pokemodr/PokeModrUI.h | 3 | ||||
| -rw-r--r-- | pokemodr/TimeUI.cpp | 15 | ||||
| -rw-r--r-- | pokemodr/gui/badge.ui | 23 |
12 files changed, 217 insertions, 50 deletions
@@ -1,4 +1,13 @@ ----------------- +Rev: 51 +Date: 31 January 2008 +User: MathStuf +----------------- +[ADD] GenericListItem.{h, cpp} +[FIX] BadgeUI bugs (some still exist) +[FIX] Other UI bugs + +----------------- Rev: 50 Date: 30 January 2008 User: MathStuf diff --git a/pokemodr/AbilityUI.cpp b/pokemodr/AbilityUI.cpp index d6c1eed8..bee4a90c 100644 --- a/pokemodr/AbilityUI.cpp +++ b/pokemodr/AbilityUI.cpp @@ -37,6 +37,7 @@ AbilityUI::AbilityUI(Ability* a, QWidget* parent) : // KToolbar AbilityUI::getToolbar(QWidget* parent) // { +// // } void AbilityUI::setGui() diff --git a/pokemodr/AuthorUI.cpp b/pokemodr/AuthorUI.cpp index bab3847b..eb143373 100644 --- a/pokemodr/AuthorUI.cpp +++ b/pokemodr/AuthorUI.cpp @@ -37,6 +37,7 @@ AuthorUI::AuthorUI(Author* a, QWidget* parent) : // KToolbar AuthorUI::getToolbar(QWidget* parent) // { +// // } void AuthorUI::setGui() diff --git a/pokemodr/BadgeUI.cpp b/pokemodr/BadgeUI.cpp index e668e515..4725a088 100644 --- a/pokemodr/BadgeUI.cpp +++ b/pokemodr/BadgeUI.cpp @@ -20,18 +20,34 @@ // with this program. If not, see <http://www.gnu.org/licenses/>. ///////////////////////////////////////////////////////////////////////////// +#include <QListIterator> #include <QMetaObject> +#include "../general/BugCatcher.h" #include "../general/Exception.h" +#include "../general/Ref.h" +#include "../pokemod/Pokemod.h" #include "BadgeUI.h" BadgeUI::BadgeUI(Badge* b, QWidget* parent) : ObjectUI(parent), + curStat(ST_HP), badge(b), badge_mod(new Badge(b->getPokemod(), *b, b->getId())) { - setupUI(this); + setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(badge, badge_mod); + for (unsigned i = 0; i < HM_End_All; ++i) + { + try + { + hmList.append(new GenericListItem(i, HMStr.at(i), badge_mod->getHm(i), varHMs)); + } + catch (BoundsException& e) + { + BugCatcher::report(e); + } + } setGui(); } @@ -40,9 +56,33 @@ BadgeUI::BadgeUI(Badge* b, QWidget* parent) : // // } -void BadgeUI::setGui(); +void BadgeUI::setGui() { - + const bool isSplit = badge_mod->getPokemod().getRules().getSpecialSplit(); + const QStringList& statList = isSplit ? StatRBYStr : StatGSCStr; + varName->setText(badge_mod->getName()); + varObey->setMaximum(badge_mod->getPokemod().getRules().getMaxLevel()); + varObey->setValue(badge_mod->getObey()); + varStat->clear(); + varStat->addItems(statList.mid(0, isSplit ? ST_End_RBY : ST_End_GSC)); +// varStat->setCurrentItem(statList[curStat]); + varMultiplierNum->setValue(badge_mod->getStat(curStat).getNum()); + varMultiplierDenom->setValue(badge_mod->getStat(curStat).getDenom()); + varMultiplierNum->setMaximum(badge_mod->getStat(curStat).getDenom()); + varMultiplier->setText(QString::number(badge_mod->getStat(curStat), 'g', 15)); + varHMs->clear(); + for (QMutableListIterator<GenericListItem*> i(hmList); i.hasNext(); i.next()) + { + try + { +// i.peekNext()->setSelected(badge_mod->getHm(i.value()->getData())); + } + catch (BoundsException& e) + { + BugCatcher::report(e); + } +// varHMs->addItem(i.peekNext()); + } } void BadgeUI::on_buttonApply_clicked() @@ -64,10 +104,18 @@ void BadgeUI::on_varName_textChanged(const QString& n) emit(setChanged(true)); } -void BadgeUI::on_varObey_valueChanged(const QString& o) +void BadgeUI::on_varObey_valueChanged(const int o) { - badge_mod->setObey(o); - emit(setChanged(true)); + try + { + badge_mod->setObey(o); + emit(setChanged(true)); + } + catch (BoundsException& e) + { + BugCatcher::report(e); + setGui(); + } } void BadgeUI::on_varBadge_customContextMenuRequested(const QPoint& p) @@ -87,10 +135,10 @@ void BadgeUI::on_varStat_currentIndexChanged(const QString& s) try { const QStringList& statList = badge_mod->getPokemod().getRules().getSpecialSplit() ? StatRBYStr : StatGSCStr; - if (statList.contains(s)) - curStat = statList.indexOf(s); - else - throw(BoundsException("BadgeUI", "stat")); +// if (statList.contains(s)) +// curStat = statList.indexOf(s); +// else +// throw(BoundsException("BadgeUI", "stat")); emit(setChanged(true)); } catch (BoundsException& e) @@ -100,12 +148,12 @@ void BadgeUI::on_varStat_currentIndexChanged(const QString& s) setGui(); } -void BadgeUI::on_varMultiplierNum_valueChanged(const QString& m) +void BadgeUI::on_varMultiplierNum_valueChanged(const int m) { try { - badge_mod->setMultiplierNum(curStat, m); - varMultiplier->setText(QString::number(badge_mod->getMultiplier(curStat), 'g', 15)); + badge_mod->setStatNum(curStat, m); + varMultiplier->setText(QString::number(badge_mod->getStat(curStat), 'g', 15)); emit(setChanged(true)); } catch (BoundsException& e) @@ -115,13 +163,13 @@ void BadgeUI::on_varMultiplierNum_valueChanged(const QString& m) } } -void BadgeUI::on_varMultiplierDenom_valueChanged(const QString& m) +void BadgeUI::on_varMultiplierDenom_valueChanged(const int m) { try { badge_mod->setStatDenom(curStat, m); varMultiplierNum->setMaximum(m); - varMultiplier->setText(QString::number(nature_mod->getStat(curStat), 'g', 15)); + varMultiplier->setText(QString::number(badge_mod->getStat(curStat), 'g', 15)); emit(setChanged(true)); } catch (BoundsException& e) @@ -133,6 +181,14 @@ void BadgeUI::on_varMultiplierDenom_valueChanged(const QString& m) void BadgeUI::on_varHMs_itemSelectionChanged() { - - emit(setChanged(true)); + try + { +// for (QListIterator<GenericListItem*> i(hmList); i.hasNext(); i.next()) +// badge_mod->setHm(i.peekNext()->getData(), i.peekNext()->isSelected()); + emit(setChanged(true)); + } + catch (BoundsException& e) + { + BugCatcher::report(e); + } } diff --git a/pokemodr/BadgeUI.h b/pokemodr/BadgeUI.h index 8c53978e..63636623 100644 --- a/pokemodr/BadgeUI.h +++ b/pokemodr/BadgeUI.h @@ -24,8 +24,11 @@ #define __POKEMODR_BADGEUI__ #include <ktoolbar.h> +#include <QList> +#include <QMutableListIterator> #include <QString> #include "../pokemod/Badge.h" +#include "GenericListItem.h" #include "ObjectUI.h" #include "ui_badge.h" @@ -37,6 +40,8 @@ class BadgeUI : public ObjectUI, private Ui::formBadge BadgeUI(Badge* b, QWidget* parent); ~BadgeUI() { + for (QMutableListIterator<GenericListItem*> i(hmList); i.hasNext(); i.next()) + delete i.value(); delete badge_mod; } @@ -45,16 +50,19 @@ class BadgeUI : public ObjectUI, private Ui::formBadge void on_buttonApply_clicked(); void on_buttonDiscard_clicked(); void on_varName_textChanged(const QString& n); - void on_varObey_valueChanged(const QString& o); + void on_varObey_valueChanged(const int o); void on_varBadge_customContextMenuRequested(const QPoint& p); void on_varFace_customContextMenuRequested(const QPoint& p); void on_varStat_currentIndexChanged(const QString& s); - void on_varMultiplierNum_valueChanged(const QString& m); - void on_varMultiplierDenom_valueChanged(const QString& m); + void on_varMultiplierNum_valueChanged(const int m); + void on_varMultiplierDenom_valueChanged(const int m); void on_varHMs_itemSelectionChanged(); private: void setGui(); + unsigned curStat; + QList<GenericListItem*> hmList; + Badge* badge; Badge* badge_mod; }; diff --git a/pokemodr/GenericListItem.cpp b/pokemodr/GenericListItem.cpp new file mode 100644 index 00000000..66e3b17c --- /dev/null +++ b/pokemodr/GenericListItem.cpp @@ -0,0 +1,32 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: pokegen/GenericListItem.cpp +// Purpose: Subclass of QListWidgetItem that allows information to be +// tacked on as well +// Author: Ben Boeckel +// Modified by: Ben Boeckel +// Created: Thu Jan 31 13:07: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/>. +///////////////////////////////////////////////////////////////////////////// + +#include "GenericListItem.h" + +GenericListItem::GenericListItem(const unsigned d, const QString& t, const bool s, QListWidget* parent) : + QListWidgetItem(parent, QListWidgetItem::UserType), + data(d) +{ + setText(t); + setSelected(s); +} diff --git a/pokemodr/GenericListItem.h b/pokemodr/GenericListItem.h new file mode 100644 index 00000000..d51638ee --- /dev/null +++ b/pokemodr/GenericListItem.h @@ -0,0 +1,48 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: pokegen/GenericListItem.h +// Purpose: Subclass of QListWidgetItem that allows information to be +// tacked on as well +// Author: Ben Boeckel +// Modified by: Ben Boeckel +// Created: Wed Jan 30 19:12:32 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_GENERICLISTITEM__ +#define __POKEMODR_GENERICLISTITEM__ + +#include <QObject> +#include <QListWidgetItem> + +class GenericListItem : public QObject, public QListWidgetItem +{ + Q_OBJECT + + public: + GenericListItem(const unsigned d, const QString& t, const bool s, QListWidget* parent); + ~GenericListItem() + { + } + + unsigned getData() + { + return data; + } + private: + unsigned data; +}; + +#endif diff --git a/pokemodr/PokeModTreeItem.h b/pokemodr/PokeModTreeItem.h index b135d59a..f430783c 100644 --- a/pokemodr/PokeModTreeItem.h +++ b/pokemodr/PokeModTreeItem.h @@ -1,6 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // Name: pokegen/PokeModTreeItem.h -// Purpose: Subclass of QTreeItem that allows information to be tacked on as wel +// Purpose: Subclass of QTreeItem that allows information to be tacked on +// as well // Author: Ben Boeckel // Modified by: Ben Boeckel // Created: Tue Jan 22 19:12:17 2008 diff --git a/pokemodr/PokeModrUI.cpp b/pokemodr/PokeModrUI.cpp index 6f539844..8c932d3b 100644 --- a/pokemodr/PokeModrUI.cpp +++ b/pokemodr/PokeModrUI.cpp @@ -28,12 +28,16 @@ #include "../general/Exception.h" #include "PokeModrUI.h" -#include "../pokemod/Pokemod.h" +#include "AbilityUI.h" +#include "AuthorUI.h" +#include "BadgeUI.h" #include "NatureUI.h" #include "ItemTypeUI.h" #include "RulesUI.h" #include "TimeUI.h" +#include <iostream> + PokeModrUI::PokeModrUI(KConfigGroup cfg, KConfigGroup history, QWidget* parent) : QMainWindow(parent), config(cfg), @@ -48,19 +52,16 @@ PokeModrUI::PokeModrUI(KConfigGroup cfg, KConfigGroup history, QWidget* parent) // if (cfg.readEntry("reloadOnStart", QVariant(false)).toBool()) // open(recent.urls().at(0)); - // Testing + pokemod = new Pokemod(); try { - Pokemod foo; - foo.newNature(); - NatureUI* n = new NatureUI(&foo.getNature(0), formPanel); - formPanel->setViewport(n); -// foo.newItemType(); -// ItemTypeUI* it = new ItemTypeUI(&foo.getItemType(0), formPanel); -// formPanel->setViewport(it); -// foo.newTime(); -// formPanel->setViewport(new TimeUI(&foo.getTime(0), formPanel)); +// formPanel->setViewport(new AbilityUI(&pokemod->newAbility(), formPanel)); +// formPanel->setViewport(new AuthorUI(&pokemod->newAuthor(), formPanel)); + formPanel->setViewport(new BadgeUI(&pokemod->newBadge(), formPanel)); +// formPanel->setViewport(NatureUI(&pokemod->newNature(), formPanel)); +// formPanel->setViewport(new ItemTypeUI(&pokemod->newItemType(), formPanel)); +// formPanel->setViewport(new TimeUI(&pokemod->newTime(), formPanel)); // formPanel->setViewport(new RulesUI(&foo.getRules(), formPanel)); } catch (Exception& e) @@ -69,6 +70,11 @@ PokeModrUI::PokeModrUI(KConfigGroup cfg, KConfigGroup history, QWidget* parent) } } +PokeModrUI::~PokeModrUI() +{ + delete pokemod; +} + void PokeModrUI::PokeModrUI::setChangedTitle(const bool c) { } diff --git a/pokemodr/PokeModrUI.h b/pokemodr/PokeModrUI.h index c4ebbd52..fa4fbb8b 100644 --- a/pokemodr/PokeModrUI.h +++ b/pokemodr/PokeModrUI.h @@ -29,6 +29,7 @@ #include <QMainWindow> #include <QObject> #include <QWidget> +#include "../pokemod/Pokemod.h" #include "ui_pokemodr.h" class PokeModrUI : public QMainWindow, private Ui::formPokeModr @@ -37,6 +38,7 @@ class PokeModrUI : public QMainWindow, private Ui::formPokeModr public: PokeModrUI(KConfigGroup cfg, KConfigGroup history, QWidget* parent = 0); + ~PokeModrUI(); public slots: void setChangedTitle(const bool c); @@ -54,6 +56,7 @@ class PokeModrUI : public QMainWindow, private Ui::formPokeModr private: KConfigGroup config; KRecentFilesAction recent; + Pokemod* pokemod; }; #endif diff --git a/pokemodr/TimeUI.cpp b/pokemodr/TimeUI.cpp index 43ee3427..68e9d628 100644 --- a/pokemodr/TimeUI.cpp +++ b/pokemodr/TimeUI.cpp @@ -21,6 +21,7 @@ ///////////////////////////////////////////////////////////////////////////// #include <QMetaObject> +#include "../general/BugCatcher.h" #include "../general/Exception.h" #include "TimeUI.h" @@ -66,7 +67,15 @@ void TimeUI::on_varName_textChanged(const QString& n) void TimeUI::on_varTime_timeChanged(const QTime& t) { - time_mod->setStartHour(t.hour()); - time_mod->setStartMinute(t.minute()); - emit(setChanged(true)); + try + { + time_mod->setStartHour(t.hour()); + time_mod->setStartMinute(t.minute()); + emit(setChanged(true)); + } + catch (BoundsException& e) + { + BugCatcher::report(e); + setGui(); + } } diff --git a/pokemodr/gui/badge.ui b/pokemodr/gui/badge.ui index 351b54c7..c80ad0d9 100644 --- a/pokemodr/gui/badge.ui +++ b/pokemodr/gui/badge.ui @@ -5,8 +5,8 @@ <rect> <x>0</x> <y>0</y> - <width>244</width> - <height>722</height> + <width>254</width> + <height>742</height> </rect> </property> <layout class="QVBoxLayout" > @@ -204,19 +204,7 @@ </property> <layout class="QHBoxLayout" > <item> - <widget class="QListWidget" name="varHMs" > - <property name="maximumSize" > - <size> - <width>150</width> - <height>75</height> - </size> - </property> - <property name="toolTip" > - <string>The list of HMs the badge allows to be used in the overworld</string> - </property> - <property name="dragEnabled" > - <bool>true</bool> - </property> + <widget class="KListWidget" name="varHMs" > <property name="selectionMode" > <enum>QAbstractItemView::ExtendedSelection</enum> </property> @@ -257,6 +245,11 @@ <header>klineedit.h</header> </customwidget> <customwidget> + <class>KListWidget</class> + <extends>QListWidget</extends> + <header>klistwidget.h</header> + </customwidget> + <customwidget> <class>KPushButton</class> <extends>QPushButton</extends> <header>kpushbutton.h</header> |
