diff options
Diffstat (limited to 'pokemodr/PokemodUI.cpp')
| -rw-r--r-- | pokemodr/PokemodUI.cpp | 153 |
1 files changed, 153 insertions, 0 deletions
diff --git a/pokemodr/PokemodUI.cpp b/pokemodr/PokemodUI.cpp new file mode 100644 index 00000000..d3be9621 --- /dev/null +++ b/pokemodr/PokemodUI.cpp @@ -0,0 +1,153 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: pokegen/PokemodUI.cpp +// Purpose: Pokemod UI form handling +// Author: Ben Boeckel +// Modified by: Ben Boeckel +// Created: Fri Feb 22 16:30:10 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 <QMetaObject> + +#include <BugCatcher.h> +#include <Exception.h> + +#include <Pokemod.h> + +#include "PokemodUI.h" + +PokemodUI::PokemodUI(Pokemod* p, QWidget* parent) : + ObjectUI(parent), + lastMap(-1), + pokemod(p), + pokemod_mod(new Pokemod(*p)) +{ + setupUi(this); + QMetaObject::connectSlotsByName(this); + setObjects(pokemod, pokemod_mod); + for (int i = 0; i < pokemod->getPokemod()->getMapCount(); ++i) + { + const Map* m = pokemod->getPokemod()->getMap(i); + varMap->addItem(m->getName()); + varMap->setItemData(i, m->getId()); + } + setGui(); +} + +// KToolbar PokemodUI::getToolbar(QWidget* parent) +// { +// +// } + +void PokemodUI::setGui() +{ + const bool resetWarps = (pokemod_mod->getStartMap() == lastMap); + varTitle->setText(pokemod_mod->getTitle()); + varVersion->setText(pokemod_mod->getVersion()); + varDescription->setText(pokemod_mod->getDescription()); + varMap->setCurrentIndex(varMap->findData(pokemod_mod->getStartMap())); + if (resetWarps) + { + try + { + const Map* m = pokemod->getMapByID(pokemod_mod->getStartMap()); + for (int i = 0; i < m->getWarpCount(); ++i) + { + const MapWarp* w = m->getWarp(i); + varWarp->addItem(w->getName()); + varWarp->setItemData(i, w->getId()); + } + } + catch (BoundsException& e) + { + BugCatcher::report(e); + } + } + varWarp->setCurrentIndex(varWarp->findData(pokemod_mod->getStartWarp())); + varSuperPCUsername->setText(pokemod_mod->getSuperPCUname()); + varSuperPCPassword->setText(pokemod_mod->getSuperPCPasswd()); +} + +void PokemodUI::on_buttonApply_clicked() +{ + *pokemod = *pokemod_mod; + emit(setChanged(false)); +} + +void PokemodUI::on_buttonDiscard_clicked() +{ + *pokemod_mod = *pokemod; + emit(setChanged(false)); + setGui(); +} + +void PokemodUI::on_varTitle_textChanged(const QString & t) +{ + pokemod_mod->setTitle(t); + emit(setChanged(true)); +} + +void PokemodUI::on_varVersion_textChanged(const QString & v) +{ + pokemod_mod->setVersion(v); + emit(setChanged(true)); +} + +void PokemodUI::on_varDescription_textChanged() +{ + pokemod_mod->setDescription(varDescription->toPlainText()); + emit(setChanged(true)); +} + +void PokemodUI::on_varMap_currentIndexChanged(const int s) +{ + try + { + pokemod_mod->setStartMap(s); + emit(setChanged(true)); + } + catch (BoundsException& e) + { + BugCatcher::report(e); + setGui(); + } +} + +void PokemodUI::on_varWarp_currentIndexChanged(const int s) +{ + try + { + pokemod_mod->setStartWarp(s); + emit(setChanged(true)); + } + catch (BoundsException& e) + { + BugCatcher::report(e); + setGui(); + } +} + +void PokemodUI::on_varSuperPCUsername_textChanged(const QString & u) +{ + pokemod_mod->setSuperPCUname(u); + emit(setChanged(true)); +} + +void PokemodUI::on_varSuperPCPassword_textChanged(const QString & p) +{ + pokemod_mod->setSuperPCPasswd(p); + emit(setChanged(true)); +} |
