diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-02-23 20:35:06 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-02-23 20:35:06 +0000 |
| commit | 35c3bd12416bc4a44efb12bd92757837d661ec21 (patch) | |
| tree | 954a380f0570473f6128271839f2e48c084e4c76 /pokemodr/MapWildListUI.cpp | |
| parent | e4f17883b6c71645933f1930d2dabf338d65a5ba (diff) | |
| download | sigen-35c3bd12416bc4a44efb12bd92757837d661ec21.tar.gz sigen-35c3bd12416bc4a44efb12bd92757837d661ec21.tar.xz sigen-35c3bd12416bc4a44efb12bd92757837d661ec21.zip | |
[FIX] MapWildList now checks value setting
[ADD] MapWildListUI.{h, cpp}
[FIX] Minor bug in MapWarpUI
[FIX] TileUI underHm ComboBox won't go out of range
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@78 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemodr/MapWildListUI.cpp')
| -rw-r--r-- | pokemodr/MapWildListUI.cpp | 173 |
1 files changed, 173 insertions, 0 deletions
diff --git a/pokemodr/MapWildListUI.cpp b/pokemodr/MapWildListUI.cpp new file mode 100644 index 00000000..8b5d8d32 --- /dev/null +++ b/pokemodr/MapWildListUI.cpp @@ -0,0 +1,173 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: pokegen/MapWildListUI.cpp +// Purpose: MapWildList UI form handling +// Author: Ben Boeckel +// Modified by: Ben Boeckel +// Created: Sat Feb 23 15:12:59 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 <QListWidgetItem> +#include <QMetaObject> +#include <QVariant> + +#include <BugCatcher.h> +#include <Exception.h> + +#include <Item.h> +#include <ItemEffect.h> +#include <Pokemod.h> +#include <MapWildList.h> +#include <Time.h> + +#include "MapWildListUI.h" + +MapWildListUI::MapWildListUI(MapWildList* w, QWidget* parent) : + ObjectUI(parent), + mapWildList(w), + mapWildList_mod(new MapWildList(w->getPokemod(), *w, w->getId())) +{ + setupUi(this); + QMetaObject::connectSlotsByName(this); + setObjects(mapWildList, mapWildList_mod); + connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setDisabled(bool))); + varControl->addItems(MapWildList::ControlStr); + for (int i = 0; i < mapWildList->getPokemod()->getItemCount(); ++i) + { + const Item* it = mapWildList->getPokemod()->getItem(i); + for (int j = 0; j < it->getEffectCount(); ++j) + { + const ItemEffect* e = it->getEffect(j); + if (e->getEffect() == ItemEffect::E_Fish) + { + varValue->addItem(it->getName()); + varValue->setItemData(varValue->count() - 1, e->getVal2()); + } + if (e->getEffect() == ItemEffect::E_Scope) + { + varScope->addItem(it->getName()); + varScope->setItemData(varScope->count() - 1, e->getVal2()); + } + } + } + for (int i = 0; i < mapWildList->getPokemod()->getTimeCount(); ++i) + { + const Time* t = mapWildList->getPokemod()->getTime(i); + QListWidgetItem* lwi = new QListWidgetItem(t->getName(), varTimes); + lwi->setData(Qt::UserRole, t->getId()); + } + setGui(); +} + +// KToolbar getToolbar(QWidget* parent) +// { +// +// } + +void MapWildListUI::setGui() +{ + varControl->setCurrentIndex(mapWildList_mod->getControl()); + varValue->setEnabled(mapWildList_mod->getControl() == MapWildList::Fishing); + varValue->setCurrentIndex(varValue->findData(mapWildList_mod->getValue())); + for (int i = 0; i < varTimes->count(); ++i) + { + QListWidgetItem* lwi = varTimes->item(i); + lwi->setSelected(mapWildList_mod->getTime(lwi->data(Qt::UserRole).toInt())); + } + boxScope->setChecked(mapWildList_mod->getScope() == -1); + varScope->setCurrentIndex(varScope->findData(mapWildList_mod->getScope())); +} + +void MapWildListUI::on_buttonApply_clicked() +{ + *mapWildList = *mapWildList_mod; + emit(changed(false)); +} + +void MapWildListUI::on_buttonDiscard_clicked() +{ + *mapWildList_mod = *mapWildList; + emit(changed(false)); + setGui(); +} + +void MapWildListUI::on_varControl_currentIndexChanged(const int c) +{ + try + { + mapWildList_mod->setControl(c); + emit(changed(true)); + } + catch (BoundsException& e) + { + BugCatcher::report(e); + } + setGui(); +} + +void MapWildListUI::on_varValue_currentIndexChanged(const int v) +{ + try + { + mapWildList_mod->setValue(varValue->itemData(v).toInt()); + emit(changed(true)); + } + catch (BoundsException& e) + { + BugCatcher::report(e); + } + setGui(); +} + +void MapWildListUI::on_varTimes_itemSelectionChanged() +{ + try + { + for (int i = 0; i < varTimes->count(); ++i) + { + const QListWidgetItem* lwi = varTimes->item(i); + mapWildList_mod->setTime(lwi->data(Qt::UserRole).toInt(), lwi->isSelected()); + } + emit(changed(true)); + } + catch (BoundsException& e) + { + BugCatcher::report(e); + setGui(); + } +} + +void MapWildListUI::on_boxScope_toggled(const bool s) +{ + if (!s) + mapWildList_mod->setScope(-1); + emit(changed(true)); + setGui(); +} + +void MapWildListUI::on_varScope_currentIndexChanged(const int s) +{ + try + { + mapWildList_mod->setScope(varScope->itemData(s).toInt()); + emit(changed(true)); + } + catch (BoundsException& e) + { + BugCatcher::report(e); + setGui(); + } +} |
