From 3c03cc795ce5620eb88e04bef70acc162ba2f339 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 7 Feb 2008 15:33:44 +0000 Subject: [FIX] Tile UI form fixes [FIX] BadgeUI logic cleaned up [FIX] Tilemap editing Model and Delegate fleshed out [ADD] TileUI.{h, cpp} and TypeUI.{h, cpp} [FIX] Default path for Pokemod added [FIX] Tile HM and Force setting git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@58 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- Changelog | 12 +++ pokemod/Pokemod.cpp | 3 +- pokemod/Tile.cpp | 28 +++--- pokemod/Tile.h | 15 ++- pokemodr/BadgeUI.cpp | 5 +- pokemodr/BadgeUI.h | 3 +- pokemodr/PokeModrUI.cpp | 6 +- pokemodr/TileDelegate.cpp | 8 +- pokemodr/TileUI.cpp | 244 ++++++++++++++++++++++++++++++++++++++++++++++ pokemodr/TileUI.h | 66 +++++++++++++ pokemodr/TilemapModel.cpp | 43 ++++---- pokemodr/TilemapModel.h | 5 +- pokemodr/TypeUI.cpp | 100 +++++++++++++++++++ pokemodr/TypeUI.h | 57 +++++++++++ pokemodr/gui/tile.ui | 41 ++++---- 15 files changed, 570 insertions(+), 66 deletions(-) create mode 100644 pokemodr/TileUI.cpp create mode 100644 pokemodr/TileUI.h create mode 100644 pokemodr/TypeUI.cpp create mode 100644 pokemodr/TypeUI.h diff --git a/Changelog b/Changelog index d4df6fa7..afb76e09 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,15 @@ +----------------- +Rev: 58 +Date: 7 February 2008 +User: MathStuf +----------------- +[FIX] Tile UI form fixes +[FIX] BadgeUI logic cleaned up +[FIX] Tilemap editing Model and Delegate fleshed out +[ADD] TileUI.{h, cpp} and TypeUI.{h, cpp} +[FIX] Default path for Pokemod added +[FIX] Tile HM and Force setting + ----------------- Rev: 57 Date: 6 February 2008 diff --git a/pokemod/Pokemod.cpp b/pokemod/Pokemod.cpp index cd8d121f..f097b662 100644 --- a/pokemod/Pokemod.cpp +++ b/pokemod/Pokemod.cpp @@ -43,7 +43,8 @@ Pokemod::Pokemod() : superPCUname(""), superPCPasswd(""), typeChart(1, 1, Frac(1, 1, Frac::Improper)), - rules(*this) + rules(*this), + path("~/.kde/share/apps/pokegen/mods") { } diff --git a/pokemod/Tile.cpp b/pokemod/Tile.cpp index 8c0535d1..2c8e1c34 100644 --- a/pokemod/Tile.cpp +++ b/pokemod/Tile.cpp @@ -23,7 +23,7 @@ #include "Pokemod.h" #include "Tile.h" -const QStringList Tile::ForceStr = QStringList() << "None" << "Slip" << "Stop" << "Force" << "Push"; +const QStringList Tile::ForceStr = QStringList() << "Slip" << "Stop" << "Force" << "Push"; Tile::Tile(const Pokemod& par, const int _id) : Object("Tile", par, _id), @@ -169,12 +169,12 @@ void Tile::setWildChance(const int n, const int d) throw(Exception) wildChance.set(n, d); } -void Tile::setWildChanceNumerator(const int n) throw(Exception) +void Tile::setWildChanceNum(const int n) throw(Exception) { wildChance.setNum(n); } -void Tile::setWildChanceDenominator(const int d) throw(Exception) +void Tile::setWildChanceDenom(const int d) throw(Exception) { wildChance.setDenom(d); } @@ -189,10 +189,13 @@ void Tile::setHMType(const int h) throw(BoundsException) void Tile::setUnder(const int u) throw(Exception) { - if ((hmType != HM_Whirlpool) || (hmType != HM_Cut) || (hmType != HM_RockSmash)) - throw(UnusedException(className, "under")); - if ((u == id) || (pokemod.getTileIndex(u) == -1)) - throw(BoundsException(className, "under")); + if (hmType != -1) + { + if ((hmType != HM_Whirlpool) || (hmType != HM_Cut) || (hmType != HM_RockSmash)) + throw(UnusedException(className, "under")); + if ((u == id) || (pokemod.getTileIndex(u) == -1)) + throw(BoundsException(className, "under")); + } under = u; } @@ -205,10 +208,13 @@ void Tile::setForceType(const int f) throw(BoundsException) void Tile::setForceDirection(const int f) throw(Exception) { - if ((forceType == None) || (forceType == Stop)) - throw(UnusedException(className, "forceDirection")); - if (D_End <= f) - throw(BoundsException(className, "forceDirection")); + if (forceType != -1) + { + if (forceType == Stop) + throw(UnusedException(className, "forceDirection")); + if (D_End <= f) + throw(BoundsException(className, "forceDirection")); + } forceDirection = f; } diff --git a/pokemod/Tile.h b/pokemod/Tile.h index 241f8d27..27a26977 100644 --- a/pokemod/Tile.h +++ b/pokemod/Tile.h @@ -37,12 +37,11 @@ class Tile : public Object public: enum Force { - None = 0, - Slip = 1, - Stop = 2, - Force = 3, - Push = 4, - End = 5 + Slip = 0, + Stop = 1, + Force = 2, + Push = 3, + End = 4 }; static const QStringList ForceStr; @@ -57,8 +56,8 @@ class Tile : public Object void setPic(const QString& p) throw(OpenException); void setFrom(const int d, const bool f) throw(BoundsException); void setWildChance(const int n, const int d) throw(Exception); - void setWildChanceNumerator(const int n) throw(Exception); - void setWildChanceDenominator(const int d) throw(Exception); + void setWildChanceNum(const int n) throw(Exception); + void setWildChanceDenom(const int d) throw(Exception); void setHMType(const int h) throw(BoundsException); void setUnder(const int u) throw(Exception); void setForceType(const int f) throw(BoundsException); diff --git a/pokemodr/BadgeUI.cpp b/pokemodr/BadgeUI.cpp index 97edb6e6..4eb62294 100644 --- a/pokemodr/BadgeUI.cpp +++ b/pokemodr/BadgeUI.cpp @@ -20,7 +20,6 @@ // with this program. If not, see . ///////////////////////////////////////////////////////////////////////////// -#include #include #include #include "../general/BugCatcher.h" @@ -180,8 +179,8 @@ void BadgeUI::on_varHMs_itemSelectionChanged() { try { - for (QListIterator i(varHMs->selectedItems()); i.hasNext(); i.next()) - badge_mod->setHm(i.peekNext()->data(QListWidgetItem::UserType).toInt(), i.peekNext()->isSelected()); + for (int i = 0; i < varHMs->count(); ++i) + badge_mod->setHm(i, varHMs->item(i)->isSelected()); emit(setChanged(true)); } catch (BoundsException& e) diff --git a/pokemodr/BadgeUI.h b/pokemodr/BadgeUI.h index d1c73e64..6ed72f6e 100644 --- a/pokemodr/BadgeUI.h +++ b/pokemodr/BadgeUI.h @@ -24,7 +24,6 @@ #define __POKEMODR_BADGEUI__ #include -#include #include #include "../pokemod/Badge.h" #include "../pokemod/Pokemod.h" @@ -57,7 +56,7 @@ class BadgeUI : public ObjectUI, private Ui::formBadge private: void setGui(); - unsigned curStat; + int curStat; Badge* badge; Badge* badge_mod; diff --git a/pokemodr/PokeModrUI.cpp b/pokemodr/PokeModrUI.cpp index b2154acb..9917b7d0 100644 --- a/pokemodr/PokeModrUI.cpp +++ b/pokemodr/PokeModrUI.cpp @@ -39,7 +39,9 @@ #include "ItemUI.h" #include "ItemTypeUI.h" #include "RulesUI.h" +#include "TileUI.h" #include "TimeUI.h" +#include "TypeUI.h" #include @@ -66,10 +68,12 @@ PokeModrUI::PokeModrUI(KConfigGroup cfg, KConfigGroup history, QWidget* parent) // formPanel->setWidget(new CoinListObjectUI(&pokemod->newCoinList().newItem(), formPanel)); // formPanel->setWidget(new EggGroupUI(&pokemod->newEggGroup(), formPanel)); // formPanel->setWidget(new ItemUI(&pokemod->newItem(), formPanel)); - formPanel->setWidget(new MapUI(&pokemod->newMap(), formPanel)); +// formPanel->setWidget(new MapUI(&pokemod->newMap(), formPanel)); // formPanel->setWidget(new NatureUI(&pokemod->newNature(), formPanel)); // formPanel->setWidget(new ItemTypeUI(&pokemod->newItemType(), formPanel)); + formPanel->setWidget(new TileUI(&pokemod->newTile(), formPanel)); // formPanel->setWidget(new TimeUI(&pokemod->newTime(), formPanel)); +// formPanel->setWidget(new TypeUI(&pokemod->newType(), formPanel)); // formPanel->setWidget(new RulesUI(&foo.getRules(), formPanel)); } diff --git a/pokemodr/TileDelegate.cpp b/pokemodr/TileDelegate.cpp index 1fb26541..ce6a67eb 100644 --- a/pokemodr/TileDelegate.cpp +++ b/pokemodr/TileDelegate.cpp @@ -38,13 +38,17 @@ QWidget* TileDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& void TileDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const { for (int i = 0; i < static_cast(editor->parent())->getOriginal()->getPokemod().getTileCount(); ++i) - static_cast(editor)->addItem(ImageCache::open(static_cast(editor->parent())->getOriginal()->getPokemod().getTile(i).getPic()), static_cast(editor->parent())->getOriginal()->getPokemod().getTile(i).getName()); + { + const Tile& t = static_cast(editor->parent())->getOriginal()->getPokemod().getTile(i); + static_cast(editor)->addItem(ImageCache::open(t.getPic()), t.getName()); + static_cast(editor)->setItemData(i, QVariant(t.getId())); + } static_cast(editor)->setCurrentIndex(index.data(Qt::EditRole).toInt()); } void TileDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const { - static_cast(model)->setData(index, static_cast(editor)->currentIndex()); + static_cast(model)->setData(index, static_cast(editor)->itemData(static_cast(editor)->currentIndex())); } void TileDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex&) const diff --git a/pokemodr/TileUI.cpp b/pokemodr/TileUI.cpp new file mode 100644 index 00000000..2b13ca87 --- /dev/null +++ b/pokemodr/TileUI.cpp @@ -0,0 +1,244 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: pokegen/TileUI.cpp +// Purpose: Tile UI form handling +// Author: Ben Boeckel +// Modified by: Ben Boeckel +// Created: Wed Feb 6 14:22:36 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 . +///////////////////////////////////////////////////////////////////////////// + +#include +#include +#include +#include +#include "../general/BugCatcher.h" +#include "../general/Exception.h" +#include "../general/ImageCache.h" +#include "../general/Ref.h" +#include "../pokemod/Pokemod.h" +#include "ImageDialog.h" +#include "TileUI.h" + +TileUI::TileUI(Tile* t, QWidget* parent) : + ObjectUI(parent), + tile(t), + tile_mod(new Tile(t->getPokemod(), *t, t->getId())) +{ + setupUi(this); + QMetaObject::connectSlotsByName(this); + setObjects(tile, tile_mod); + varAccessibility->addItems(DirectionStr.mid(0, 4)); + varHMType->addItems(HMStr); + for (int i = 0; i < tile->getPokemod().getTileCount(); ++i) + { + const Tile& tl = tile->getPokemod().getTile(i); + if (tl.getId() != t->getId()) + { + varHMUnder->addItem(ImageCache::open(tl.getPic()), tl.getName()); + varHMUnder->setItemData(i, tl.getId()); + } + } + varForce->addItems(Tile::ForceStr); + varDirection->addItems(DirectionStr.mid(0, 4)); + setGui(); +} + +// KToolbar getToolbar(QWidget* parent) +// { +// +// } + +void TileUI::setGui() +{ + varName->setText(tile_mod->getName()); + try + { + varImage->setIcon(ImageCache::open(tile_mod->getPic())); + } + catch (OpenException& e) + { + BugCatcher::report(e); + } + for (unsigned i = 0; i < D_End; ++i) + varAccessibility->item(i)->setSelected(tile_mod->getFrom(i)); + varWildNum->setValue(tile_mod->getWildChance().getNum()); + varWildDenom->setValue(tile_mod->getWildChance().getDenom()); + varWildNum->setMaximum(tile_mod->getWildChance().getDenom()); + varWild->setText(QString::number(tile_mod->getWildChance(), 'g', 15)); + boxHMs->setChecked((tile_mod->getHMType() == -1) ? Qt::Unchecked : Qt::Checked); + varHMType->setCurrentIndex(tile_mod->getHMType()); + varHMUnder->setCurrentIndex(tile_mod->getUnder()); + varHMUnder->setEnabled((tile_mod->getHMType() == HM_Whirlpool) || (tile_mod->getHMType() == HM_Cut) || (tile_mod->getHMType() == HM_RockSmash)); + boxForces->setChecked((tile_mod->getForceType() == -1) ? Qt::Unchecked : Qt::Checked); + varForce->setCurrentIndex(tile_mod->getForceType()); + varDirection->setCurrentIndex(tile_mod->getForceDirection()); + varDirection->setEnabled(tile_mod->getForceType() != Tile::Stop); +} + +void TileUI::on_buttonApply_clicked() +{ + *tile = *tile_mod; + emit(setChanged(false)); +} + +void TileUI::on_buttonDiscard_clicked() +{ + *tile_mod = *tile; + emit(setChanged(false)); + setGui(); +} + +void TileUI::on_varName_textChanged(const QString& n) +{ + tile_mod->setName(n); + emit(setChanged(true)); +} + +void TileUI::on_varImage_pressed() +{ + if (ImageDialog::exec()) + { + try + { + tile_mod->setPic(ImageDialog::selectedUrl()); + } + catch (SaveException& e) + { + BugCatcher::report(e); + } + setGui(); + } +} + +void TileUI::on_varWildNum_valueChanged(const int m) +{ + try + { + tile_mod->setWildChanceNum(m); + varWild->setText(QString::number(tile_mod->getWildChance(), 'g', 15)); + emit(setChanged(true)); + } + catch (BoundsException& e) + { + BugCatcher::report(e); + setGui(); + } +} + +void TileUI::on_varWildDenom_valueChanged(const int m) +{ + try + { + tile_mod->setWildChanceDenom(m); + varWildNum->setMaximum(m); + varWild->setText(QString::number(tile_mod->getWildChance(), 'g', 15)); + emit(setChanged(true)); + } + catch (BoundsException& e) + { + BugCatcher::report(e); + setGui(); + } +} + +void TileUI::on_varAccessibility_itemSelectionChanged() +{ + try + { + for (QListIterator i(varAccessibility->selectedItems()); i.hasNext(); i.next()) + tile_mod->setFrom(i.peekNext()->data(QListWidgetItem::UserType).toInt(), i.peekNext()->isSelected()); + emit(setChanged(true)); + } + catch (BoundsException& e) + { + BugCatcher::report(e); + setGui(); + } +} + +void TileUI::on_boxHMs_toggled(const bool h) +{ + if (!h) + { + varHMType->setCurrentIndex(-1); + varHMUnder->setCurrentIndex(-1); + setGui(); + emit(setChanged(true)); + } +} + +void TileUI::on_varHMType_currentIndexChanged(const int h) +{ + try + { + tile_mod->setHMType(h); + } + catch (BoundsException& e) + { + BugCatcher::report(e); + } + setGui(); +} + +void TileUI::on_varHMUnder_currentIndexChanged(const int h) +{ + try + { + tile_mod->setUnder(varHMUnder->itemData(h, Qt::UserRole).toInt()); + } + catch (BoundsException& e) + { + BugCatcher::report(e); + setGui(); + } +} + +void TileUI::on_boxForces_toggled(const bool f) +{ + if (!f) + { + varForce->setCurrentIndex(-1); + varDirection->setCurrentIndex(-1); + setGui(); + emit(setChanged(true)); + } +} + +void TileUI::on_varForce_currentIndexChanged(const int f) +{ + try + { + tile_mod->setForceType(f); + } + catch (BoundsException& e) + { + BugCatcher::report(e); + } + setGui(); +} + +void TileUI::on_varDirection_currentIndexChanged(const int d) +{ + try + { + tile_mod->setForceDirection(d); + } + catch (BoundsException& e) + { + BugCatcher::report(e); + setGui(); + } +} diff --git a/pokemodr/TileUI.h b/pokemodr/TileUI.h new file mode 100644 index 00000000..1c428d36 --- /dev/null +++ b/pokemodr/TileUI.h @@ -0,0 +1,66 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: pokegen/TileUI.h +// Purpose: Tile UI form handling +// Author: Ben Boeckel +// Modified by: Ben Boeckel +// Created: Sun Jan 27 12:52:44 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 . +///////////////////////////////////////////////////////////////////////////// + +#ifndef __POKEMODR_TILEUI__ +#define __POKEMODR_TILEUI__ + +#include +#include +#include +#include "../pokemod/Tile.h" +#include "ObjectUI.h" +#include "ui_tile.h" + +class TileUI : public ObjectUI, private Ui::formTile +{ + Q_OBJECT + + public: + TileUI(Tile* t, QWidget* parent); + ~TileUI() + { + delete tile_mod; + } + +// KToolbar getToolbar(QWidget* parent); + public slots: + void on_buttonApply_clicked(); + void on_buttonDiscard_clicked(); + void on_varName_textChanged(const QString& n); + void on_varImage_pressed(); + void on_varAccessibility_itemSelectionChanged(); + void on_varWildNum_valueChanged(const int w); + void on_varWildDenom_valueChanged(const int w); + void on_boxHMs_toggled(const bool h); + void on_varHMType_currentIndexChanged(const int h); + void on_varHMUnder_currentIndexChanged(const int h); + void on_boxForces_toggled(const bool f); + void on_varForce_currentIndexChanged(const int f); + void on_varDirection_currentIndexChanged(const int d); + private: + void setGui(); + + Tile* tile; + Tile* tile_mod; +}; + +#endif diff --git a/pokemodr/TilemapModel.cpp b/pokemodr/TilemapModel.cpp index 6618f7d8..9d0c6a81 100644 --- a/pokemodr/TilemapModel.cpp +++ b/pokemodr/TilemapModel.cpp @@ -32,10 +32,10 @@ TilemapModel::TilemapModel(QObject* parent, Matrix& tilemap, const Pokemod& map(tilemap), pokemod(mod) { - updateData(); + setGui(); } -void TilemapModel::updateData() +void TilemapModel::setGui() { } @@ -51,26 +51,22 @@ int TilemapModel::columnCount(const QModelIndex&) const QVariant TilemapModel::data(const QModelIndex& index, int role) const { - QVariant ret; - switch (role) - { - case Qt::DisplayRole: - ret = QVariant(ImageCache::open(pokemod.getTileByID(map.at(index.row(), index.column())).getPic())); - break; - case Qt::EditRole: - ret = QVariant(map.at(index.row(), index.column())); - break; - case Qt::ToolTipRole: - ret = QVariant(pokemod.getTileByID(map.at(index.row(), index.column())).getName()); - break; - default: - break; - } - return ret; + if (!index.isValid()) + return QVariant(); + if (role == Qt::DisplayRole) + return ImageCache::open(pokemod.getTileByID(map.at(index.row(), index.column())).getPic()); + if (role == Qt::EditRole) + map.at(index.row(), index.column()); + if (role == Qt::ToolTipRole) + return pokemod.getTileByID(map.at(index.row(), index.column())).getName(); + return QVariant(); } -QVariant TilemapModel::headerData(int section, Qt::Orientation orientation, int role) const +QVariant TilemapModel::headerData(int section, Qt::Orientation, int role) const { + if (role != Qt::DisplayRole) + return QVariant(); + return QString::number(section); } bool TilemapModel::setData(const QModelIndex& index, const QVariant& value, int role) @@ -78,6 +74,7 @@ bool TilemapModel::setData(const QModelIndex& index, const QVariant& value, int if (role != Qt::EditRole) return false; map.set(index.row(), index.column(), pokemod.getTile(value.toInt()).getId()); + emit(dataChanged(index, index)); return true; } @@ -88,28 +85,36 @@ Qt::ItemFlags TilemapModel::flags(const QModelIndex&) const bool TilemapModel::insertRows(int row, int count, const QModelIndex&) { + emit(beginInsertRows(QModelIndex(), row, row + count - 1)); for (int i = 0; i < count; ++i) map.insertRow(row); + emit(endInsertRows()); return true; } bool TilemapModel::insertColumns(int column, int count, const QModelIndex&) { + emit(beginInsertColumns(QModelIndex(), column, column + count - 1)); for (int i = 0; i < count; ++i) map.insertCol(column); + emit(endInsertColumns()); return true; } bool TilemapModel::removeRows(int row, int count, const QModelIndex&) { + emit(beginRemoveRows(QModelIndex(), row, row + count - 1)); for (int i = 0; i < count; ++i) map.deleteRow(row); + emit(endRemoveRows()); return true; } bool TilemapModel::removeColumns(int column, int count, const QModelIndex&) { + emit(beginRemoveColumns(QModelIndex(), column, column + count - 1)); for (int i = 0; i < count; ++i) map.deleteCol(column); + emit(endRemoveColumns()); return true; } diff --git a/pokemodr/TilemapModel.h b/pokemodr/TilemapModel.h index cfb7444b..9cfe4900 100644 --- a/pokemodr/TilemapModel.h +++ b/pokemodr/TilemapModel.h @@ -36,7 +36,8 @@ class TilemapModel : public QAbstractTableModel public: TilemapModel(QObject* parent, Matrix& tilemap, const Pokemod& mod); - void updateData(); + void apply(); + void discard(); int rowCount(const QModelIndex& = QModelIndex()) const; int columnCount(const QModelIndex& = QModelIndex()) const; @@ -53,6 +54,8 @@ class TilemapModel : public QAbstractTableModel bool removeRows(int row, int count, const QModelIndex& = QModelIndex()); bool removeColumns(int column, int count, const QModelIndex& = QModelIndex()); private: + void setGui(); + Matrix& map; const Pokemod& pokemod; }; diff --git a/pokemodr/TypeUI.cpp b/pokemodr/TypeUI.cpp new file mode 100644 index 00000000..a7de8ca1 --- /dev/null +++ b/pokemodr/TypeUI.cpp @@ -0,0 +1,100 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: pokegen/TypeUI.cpp +// Purpose: Type UI form handling +// Author: Ben Boeckel +// Modified by: Ben Boeckel +// Created: Wed Feb 6 14:09:47 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 . +///////////////////////////////////////////////////////////////////////////// + +#include +#include +#include "../general/BugCatcher.h" +#include "../general/Exception.h" +#include "TypeUI.h" + +TypeUI::TypeUI(Type* t, QWidget* parent) : + ObjectUI(parent), + type(t), + type_mod(new Type(t->getPokemod(), *t, t->getId())) +{ + setupUi(this); + QMetaObject::connectSlotsByName(this); + setObjects(type, type_mod); + setGui(); +} + +// KToolbar TypeUI::getToolbar(QWidget* parent) +// { +// } + +void TypeUI::setGui() +{ + varName->setText(type_mod->getName()); + varSTABNum->setValue(type_mod->getStab().getNum()); + varSTABDenom->setValue(type_mod->getStab().getDenom()); + varSTABNum->setMaximum(type_mod->getStab().getDenom()); + varSTAB->setText(QString::number(type_mod->getStab(), 'g', 15)); +} + +void TypeUI::on_buttonApply_clicked() +{ + *type = *type_mod; + emit(setChanged(false)); +} + +void TypeUI::on_buttonDiscard_clicked() +{ + *type_mod = *type; + emit(setChanged(false)); + setGui(); +} + +void TypeUI::on_varName_textChanged(const QString& n) +{ + type_mod->setName(n); +} + +void TypeUI::on_varSTABNum_valueChanged(const int s) +{ + try + { + type_mod->setStabNum(s); + varSTAB->setText(QString::number(type_mod->getStab(), 'g', 15)); + emit(setChanged(true)); + } + catch (BoundsException& e) + { + BugCatcher::report(e); + setGui(); + } +} + +void TypeUI::on_varSTABDenom_valueChanged(const int s) +{ + try + { + type_mod->setStabDenom(s); + varSTABNum->setMaximum(s); + varSTAB->setText(QString::number(type_mod->getStab(), 'g', 15)); + emit(setChanged(true)); + } + catch (BoundsException& e) + { + BugCatcher::report(e); + setGui(); + } +} diff --git a/pokemodr/TypeUI.h b/pokemodr/TypeUI.h new file mode 100644 index 00000000..221d9121 --- /dev/null +++ b/pokemodr/TypeUI.h @@ -0,0 +1,57 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: pokegen/TypeUI.h +// Purpose: Type UI form handling +// Author: Ben Boeckel +// Modified by: Ben Boeckel +// Created: Wed Feb 6 14:03:01 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 . +///////////////////////////////////////////////////////////////////////////// + +#ifndef __POKEMODR_TYPEUI__ +#define __POKEMODR_TYPEUI__ + +#include +#include +#include "../pokemod/Type.h" +#include "ObjectUI.h" +#include "ui_type.h" + +class TypeUI : public ObjectUI, private Ui::formType +{ + Q_OBJECT + + public: + TypeUI(Type* t, QWidget* parent); + ~TypeUI() + { + delete type_mod; + } + +// KToolbar getToolbar(QWidget* parent); + public slots: + void on_buttonApply_clicked(); + void on_buttonDiscard_clicked(); + void on_varName_textChanged(const QString& n); + void on_varSTABNum_valueChanged(const int s); + void on_varSTABDenom_valueChanged(const int s); + private: + void setGui(); + + Type* type; + Type* type_mod; +}; + +#endif diff --git a/pokemodr/gui/tile.ui b/pokemodr/gui/tile.ui index 8198b4e6..4c0b0371 100644 --- a/pokemodr/gui/tile.ui +++ b/pokemodr/gui/tile.ui @@ -5,8 +5,8 @@ 0 0 - 226 - 953 + 236 + 941 @@ -68,13 +68,7 @@ - - - - 64 - 64 - - + Image of the tile @@ -90,13 +84,7 @@ - - - - 150 - 75 - - + Directions into the tile @@ -112,13 +100,13 @@ - + Wild - + Chacne of having a wild encounter on the tile @@ -155,6 +143,12 @@ HMs + + true + + + false + @@ -208,6 +202,12 @@ Forces + + true + + + false + @@ -287,6 +287,11 @@ QLineEdit
klineedit.h
+ + KListWidget + QListWidget +
klistwidget.h
+
KPushButton QPushButton -- cgit