diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-04-17 23:34:36 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-04-17 23:34:36 +0000 |
| commit | 6679f5cffa9d35a23b76605ddfbf3257f882b6ee (patch) | |
| tree | c8e41854a60b64e8569939bca6b827807175ef9a /pokemodr/TrainerUI.cpp | |
| parent | 05980e883719b1c8ebde1bd2fcbf4f8c16df7ad6 (diff) | |
| download | sigen-6679f5cffa9d35a23b76605ddfbf3257f882b6ee.tar.gz sigen-6679f5cffa9d35a23b76605ddfbf3257f882b6ee.tar.xz sigen-6679f5cffa9d35a23b76605ddfbf3257f882b6ee.zip | |
[FIX] Frac -> Fraction
[FIX] ImageCache and Ini removed
[FIX] Fraction/Point widgets moved to pokemodr
[FIX] Copy ctors made for pokemod classes
[FIX] Ctors in pokemod fixed
[FIX] Copyright headers fixed in pokemodr
[FIX] PokeModr updated to new API and fixed in some places
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@99 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemodr/TrainerUI.cpp')
| -rw-r--r-- | pokemodr/TrainerUI.cpp | 124 |
1 files changed, 58 insertions, 66 deletions
diff --git a/pokemodr/TrainerUI.cpp b/pokemodr/TrainerUI.cpp index 9d77af36..4b5d0d26 100644 --- a/pokemodr/TrainerUI.cpp +++ b/pokemodr/TrainerUI.cpp @@ -1,123 +1,115 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: pokegen/TrainerUI.cpp -// Purpose: Trainer UI form handling -// Author: Ben Boeckel -// Modified by: Ben Boeckel -// Created: Sun Mar 9 18:41:24 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/>. -///////////////////////////////////////////////////////////////////////////// +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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> +// Qt includes #include <QSize> +// General includes #include <BugCatcher.h> #include <Exception.h> -#include <ImageCache.h> +// PokeModr includes #include "FileDialog.h" + +// Header include #include "TrainerUI.h" -TrainerUI::TrainerUI(Trainer * t, QWidget * parent) : +TrainerUI::TrainerUI(Trainer * trainer, QWidget * parent) : ObjectUI(parent), - trainer(t), - trainer_mod(new Trainer(t->getPokemod(), *t, t->getId())) + m_trainer(trainer), + m_trainer_mod(new Trainer(*trainer)) { setupUi(this); QMetaObject::connectSlotsByName(this); - setObjects(trainer, trainer_mod); + setObjects(m_trainer, m_trainer_mod); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); init(); } void TrainerUI::setGui() { - varName->setText(trainer_mod->getName()); - varMoneyFactor->setValue(trainer_mod->getMoneyFactor()); - try - { - varSkin->setIcon(ImageCache::open(trainer_mod->getSkin())); - } - catch (OpenException& e) - { - } - varAI->setText(QFile::exists(trainer_mod->getAi()) ? "Valid" : "Invalid"); + varName->setText(m_trainer_mod->name()); + varMoneyFactor->setValue(m_trainer_mod->moneyFactor()); + varSkin->setIcon(m_trainer_mod->skin()); +// varAI->setText(QFile::exists(trainer_mod->ai()) ? "Valid" : "Invalid"); } void TrainerUI::on_buttonApply_clicked() { - *trainer = *trainer_mod; + *m_trainer = *m_trainer_mod; emit(changed(false)); } void TrainerUI::on_buttonDiscard_clicked() { - *trainer_mod = *trainer; + *m_trainer_mod = *m_trainer; emit(changed(false)); } -void TrainerUI::on_varName_textChanged(const QString & n) +void TrainerUI::on_varName_textChanged(const QString & name) { - trainer_mod->setName(n); + m_trainer_mod->setName(name); emit(changed(true)); } -void TrainerUI::on_varMoneyFactor_valueChaged(const int m) +void TrainerUI::on_varMoneyFactor_valueChaged(const int moneyFactor) { try { - trainer_mod->setMoneyFactor(m); + m_trainer_mod->setMoneyFactor(moneyFactor); emit(changed(true)); } - catch (BoundsException& e) + catch (BoundsException& exception) { - BugCatcher::report(e); + BugCatcher::report(exception); setGui(); } } void TrainerUI::on_varSkin_pressed() { - FileDialog dlg("*.png", QSize(192, 168)); - if (dlg.show()) + FileDialog dialog(QSize(192, 168)); + if (dialog.exec()) { try { - trainer_mod->setSkin(dlg.selectedUrl()); + m_trainer_mod->setSkin(QPixmap(dialog.selectedFile())); } - catch (SaveException& e) + catch (SaveException& exception) { - BugCatcher::report(e); + BugCatcher::report(exception); } setGui(); } } -void TrainerUI::on_varAI_pressed() -{ - FileDialog dlg(QString::fromUtf8("*.pai|PokéMod AI Files")); - if (dlg.show()) - { - try - { - trainer_mod->setAi(dlg.selectedUrl()); - } - catch (SaveException& e) - { - BugCatcher::report(e); - } - setGui(); - } -} +// void TrainerUI::on_varAI_pressed() +// { +// FileDialog dialog(QString::fromUtf8("*.pai|PokéMod AI Files")); +// if (dlg.show()) +// { +// try +// { +// trainer_mod->setAi(dlg.selectedUrl()); +// } +// catch (SaveException& exception) +// { +// BugCatcher::report(exception); +// } +// setGui(); +// } +// } |
