From 6679f5cffa9d35a23b76605ddfbf3257f882b6ee Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 17 Apr 2008 23:34:36 +0000 Subject: [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 --- pokemodr/MapTrainerTeamMemberUI.cpp | 126 ++++++++++++++++++------------------ 1 file changed, 62 insertions(+), 64 deletions(-) (limited to 'pokemodr/MapTrainerTeamMemberUI.cpp') diff --git a/pokemodr/MapTrainerTeamMemberUI.cpp b/pokemodr/MapTrainerTeamMemberUI.cpp index 65b6a6f1..e630658f 100644 --- a/pokemodr/MapTrainerTeamMemberUI.cpp +++ b/pokemodr/MapTrainerTeamMemberUI.cpp @@ -1,46 +1,44 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: pokegen/MapTrainerTeamMemberUI.cpp -// Purpose: MapTrainerTeamMember UI form handling -// Author: Ben Boeckel -// Modified by: Ben Boeckel -// Created: Sun Jan 27 13:39:26 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 . -///////////////////////////////////////////////////////////////////////////// +/* + * Copyright 2008 Ben Boeckel + * + * 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 . + */ +// Qt includes #include -#include +// General includes #include #include +// Pokemod includes #include #include #include #include +// Header include #include "MapTrainerTeamMemberUI.h" -MapTrainerTeamMemberUI::MapTrainerTeamMemberUI(MapTrainerTeamMember* t, QWidget* parent) : +MapTrainerTeamMemberUI::MapTrainerTeamMemberUI(MapTrainerTeamMember* teamMember, QWidget* parent) : ObjectUI(parent), - mapTrainerTeamMember(t), - mapTrainerTeamMember_mod(new MapTrainerTeamMember(t->getPokemod(), *t, t->getId())) + m_teamMember(teamMember), + m_teamMember_mod(new MapTrainerTeamMember(*teamMember)) { setupUi(this); QMetaObject::connectSlotsByName(this); - setObjects(mapTrainerTeamMember, mapTrainerTeamMember_mod); + setObjects(m_teamMember, m_teamMember_mod); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); init(); } @@ -48,45 +46,45 @@ MapTrainerTeamMemberUI::MapTrainerTeamMemberUI(MapTrainerTeamMember* t, QWidget* void MapTrainerTeamMemberUI::refreshGui() { varSpecies->clear(); - for (int i = 0; i < mapTrainerTeamMember->getPokemod()->getSpeciesCount(); ++i) + for (int i = 0; i < m_teamMember->pokemod()->speciesCount(); ++i) { - const Species* s = mapTrainerTeamMember->getPokemod()->getSpecies(i); - varSpecies->addItem(s->getName()); - varSpecies->setItemData(i, s->getId()); + const Species* species = m_teamMember->pokemod()->species(i); + varSpecies->addItem(species->name()); + varSpecies->setItemData(i, species->id()); } - varLevel->setMaximum(mapTrainerTeamMember->getPokemod()->getRules()->getMaxLevel()); + varLevel->setMaximum(m_teamMember->pokemod()->rules()->maxLevel()); } void MapTrainerTeamMemberUI::setGui() { - varSpecies->setCurrentIndex(varSpecies->findData(mapTrainerTeamMember_mod->getSpecies())); - varLevel->setValue(mapTrainerTeamMember_mod->getLevel()); - varNature->setCurrentIndex(varNature->findData(mapTrainerTeamMember_mod->getNature())); + varSpecies->setCurrentIndex(varSpecies->findData(m_teamMember_mod->species())); + varLevel->setValue(m_teamMember_mod->level()); + varNature->setCurrentIndex(varNature->findData(m_teamMember_mod->nature())); for (int i = 0; i < varItems->count(); ++i) { - QListWidgetItem* lwi = varItems->item(i); - lwi->setSelected(mapTrainerTeamMember_mod->getItem(lwi->data(Qt::UserRole).toInt())); + QListWidgetItem* widgetItem = varItems->item(i); + widgetItem->setSelected(m_teamMember_mod->item(widgetItem->data(Qt::UserRole).toInt())); } varNature->clear(); - if (mapTrainerTeamMember->getPokemod()->getRules()->getNatureAllowed()) + if (m_teamMember->pokemod()->rules()->natureAllowed()) { - for (int i = 0; i < mapTrainerTeamMember->getPokemod()->getNatureCount(); ++i) + for (int i = 0; i < m_teamMember->pokemod()->natureCount(); ++i) { - const Nature* n = mapTrainerTeamMember->getPokemod()->getNature(i); - varNature->addItem(n->getName()); - varNature->setItemData(i, n->getId()); + const Nature* nature = m_teamMember->pokemod()->nature(i); + varNature->addItem(nature->name()); + varNature->setItemData(i, nature->id()); } } else boxNature->setEnabled(false); varItems->clear(); - if (mapTrainerTeamMember->getPokemod()->getRules()->getHoldItems()) + if (m_teamMember->pokemod()->rules()->holdItems()) { - for (int i = 0; i < mapTrainerTeamMember->getPokemod()->getItemCount(); ++i) + for (int i = 0; i < m_teamMember->pokemod()->itemCount(); ++i) { - const Item* it = mapTrainerTeamMember->getPokemod()->getItem(i); - QListWidgetItem* lwi = new QListWidgetItem(it->getName(), varItems); - lwi->setData(Qt::UserRole, it->getId()); + const Item* item = m_teamMember->pokemod()->item(i); + QListWidgetItem* widgetItem = new QListWidgetItem(item->name(), varItems); + widgetItem->setData(Qt::UserRole, item->id()); } } else @@ -95,55 +93,55 @@ void MapTrainerTeamMemberUI::setGui() void MapTrainerTeamMemberUI::on_buttonApply_clicked() { - *mapTrainerTeamMember = *mapTrainerTeamMember_mod; + *m_teamMember = *m_teamMember_mod; emit(changed(false)); } void MapTrainerTeamMemberUI::on_buttonDiscard_clicked() { - *mapTrainerTeamMember_mod = *mapTrainerTeamMember; + *m_teamMember_mod = *m_teamMember; setGui(); emit(changed(false)); } -void MapTrainerTeamMemberUI::on_varSpecies_currentIndexChanged(const int s) +void MapTrainerTeamMemberUI::on_varSpecies_currentIndexChanged(const int species) { try { - mapTrainerTeamMember_mod->setSpecies(varSpecies->itemData(s).toInt()); + m_teamMember_mod->setSpecies(varSpecies->itemData(species).toInt()); emit(changed(true)); } - catch (BoundsException& e) + catch (BoundsException& exception) { - BugCatcher::report(e); + BugCatcher::report(exception); setGui(); } } -void MapTrainerTeamMemberUI::on_varLevel_valueChanged(const int l) +void MapTrainerTeamMemberUI::on_varLevel_valueChanged(const int level) { try { - mapTrainerTeamMember_mod->setLevel(l); + m_teamMember_mod->setLevel(level); emit(changed(true)); } - catch (Exception& e) + catch (Exception& exception) { - BugCatcher::report(e); + BugCatcher::report(exception); } setGui(); } -void MapTrainerTeamMemberUI::on_varNature_currentIndexChanged(const int n) +void MapTrainerTeamMemberUI::on_varNature_currentIndexChanged(const int nature) { try { - mapTrainerTeamMember_mod->setNature(varNature->itemData(n).toInt()); + m_teamMember_mod->setNature(varNature->itemData(nature).toInt()); emit(changed(true)); } - catch (BoundsException& e) + catch (BoundsException& exception) { - BugCatcher::report(e); + BugCatcher::report(exception); setGui(); } } @@ -154,14 +152,14 @@ void MapTrainerTeamMemberUI::on_varItems_itemSelectionChanged() { for (int i = 0; i < varItems->count(); ++i) { - const QListWidgetItem* lwi = varItems->item(i); - mapTrainerTeamMember_mod->setItem(lwi->data(Qt::UserRole).toInt(), lwi->isSelected()); + const QListWidgetItem* widgetItem = varItems->item(i); + m_teamMember_mod->setItem(widgetItem->data(Qt::UserRole).toInt(), widgetItem->isSelected()); } emit(changed(true)); } - catch (BoundsException& e) + catch (BoundsException& exception) { - BugCatcher::report(e); + BugCatcher::report(exception); setGui(); } } -- cgit