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/MapWarpUI.cpp | 218 ++++++++++++++++++++++++------------------------- 1 file changed, 105 insertions(+), 113 deletions(-) (limited to 'pokemodr/MapWarpUI.cpp') diff --git a/pokemodr/MapWarpUI.cpp b/pokemodr/MapWarpUI.cpp index 01364df7..4d2d4f51 100644 --- a/pokemodr/MapWarpUI.cpp +++ b/pokemodr/MapWarpUI.cpp @@ -1,45 +1,44 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: pokegen/MapWarpUI.cpp -// Purpose: MapWarp UI form handling -// Author: Ben Boeckel -// Modified by: Ben Boeckel -// Created: Sat Feb 23 03:31:28 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 +// Header includeo #include "MapWarpUI.h" -MapWarpUI::MapWarpUI(MapWarp* w, QWidget* parent) : +MapWarpUI::MapWarpUI(MapWarp* warp, QWidget* parent) : ObjectUI(parent), - mapWarp(w), - mapWarp_mod(new MapWarp(w->getPokemod(), *w, w->getId())) + m_lastMap(-1), + m_warp(warp), + m_warp_mod(new MapWarp(*warp)) { setupUi(this); QMetaObject::connectSlotsByName(this); - setObjects(mapWarp, mapWarp_mod); + setObjects(m_warp, m_warp_mod); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); init(); } @@ -53,96 +52,89 @@ void MapWarpUI::initGui() void MapWarpUI::refreshGui() { varToMap->clear(); - for (int i = 0; i < mapWarp->getPokemod()->getMapCount(); ++i) + for (int i = 0; i < m_warp->pokemod()->mapCount(); ++i) { - const Map* m = mapWarp->getPokemod()->getMap(i); - varToMap->addItem(m->getName()); - varToMap->setItemData(i, m->getId()); + const Map* map = m_warp->pokemod()->map(i); + varToMap->addItem(map->name()); + varToMap->setItemData(i, map->id()); } varDialog->clear(); - for (int i = 0; i < mapWarp->getPokemod()->getDialogCount(); ++i) + for (int i = 0; i < m_warp->pokemod()->dialogCount(); ++i) { - const Dialog* d = mapWarp->getPokemod()->getDialog(i); - varDialog->addItem(d->getDialog().mid(0, 25)); - varDialog->setItemData(i, d->getId()); + const Dialog* dialog = m_warp->pokemod()->dialog(i); + varDialog->addItem(dialog->dialog().mid(0, 25)); + varDialog->setItemData(i, dialog->id()); } } void MapWarpUI::setGui() { - const bool resetWarps = (mapWarp_mod->getToMap() == lastMap); - varName->setText(mapWarp_mod->getName()); - varCoordinateX->setValue(mapWarp_mod->getCoordinate().getX()); - varCoordinateY->setValue(mapWarp_mod->getCoordinate().getY()); + const bool resetWarps = (m_warp_mod->toMap() == m_lastMap); + varName->setText(m_warp_mod->name()); + varCoordinate->setValue(m_warp_mod->coordinate()); for (int i = 0; i < varActivation->count(); ++i) - varActivation->item(i)->setSelected(mapWarp_mod->getFrom(i)); - varDirectionOut->setCurrentIndex(mapWarp_mod->getDirectionOut()); - varType->setCurrentIndex(mapWarp_mod->getWarpType()); - varBiking->setCheckState((mapWarp_mod->getIsBiking() == Flag::On) ? Qt::Checked : ((mapWarp_mod->getIsBiking() == Flag::Off) ? Qt::Unchecked : Qt::PartiallyChecked)); - varFlash->setCheckState((mapWarp_mod->getIsFlash() == Flag::On) ? Qt::Checked : ((mapWarp_mod->getIsFlash() == Flag::Off) ? Qt::Unchecked : Qt::PartiallyChecked)); - varFog->setCheckState((mapWarp_mod->getIsFoggy() == Flag::On) ? Qt::Checked : ((mapWarp_mod->getIsFoggy() == Flag::Off) ? Qt::Unchecked : Qt::PartiallyChecked)); - varToMap->setCurrentIndex(varToMap->findData(mapWarp_mod->getToMap())); - lastMap = mapWarp_mod->getToMap(); + varActivation->item(i)->setSelected(m_warp_mod->from(i)); + varDirectionOut->setCurrentIndex(m_warp_mod->directionOut()); + varType->setCurrentIndex(m_warp_mod->warpType()); + varBiking->setCheckState((m_warp_mod->isBiking() == Flag::On) ? Qt::Checked : ((m_warp_mod->isBiking() == Flag::Off) ? Qt::Unchecked : Qt::PartiallyChecked)); + varFlash->setCheckState((m_warp_mod->isFlash() == Flag::On) ? Qt::Checked : ((m_warp_mod->isFlash() == Flag::Off) ? Qt::Unchecked : Qt::PartiallyChecked)); + varFog->setCheckState((m_warp_mod->isFoggy() == Flag::On) ? Qt::Checked : ((m_warp_mod->isFoggy() == Flag::Off) ? Qt::Unchecked : Qt::PartiallyChecked)); + varToMap->setCurrentIndex(varToMap->findData(m_warp_mod->toMap())); + m_lastMap = m_warp_mod->toMap(); if (resetWarps) { varToWarp->clear(); - int index = mapWarp->getPokemod()->getMapIndex(mapWarp_mod->getToMap()); + int index = m_warp->pokemod()->mapIndex(m_warp_mod->toMap()); if (index != INT_MAX) { try { - const Map* m = mapWarp->getPokemod()->getMap(index); - for (int i = 0; i < m->getWarpCount(); ++i) + const Map* map = m_warp->pokemod()->map(index); + for (int i = 0; i < map->warpCount(); ++i) { - const MapWarp* w = m->getWarp(i); - varToWarp->addItem(w->getName()); - varToWarp->setItemData(i, w->getId()); + const MapWarp* warp = map->warp(i); + varToWarp->addItem(warp->name()); + varToWarp->setItemData(i, warp->id()); } } - catch (BoundsException& e) + catch (BoundsException& exception) { - BugCatcher::report(e); + BugCatcher::report(exception); } } } - varToWarp->setCurrentIndex(varToMap->findData(mapWarp_mod->getToWarp())); - boxFlag->setChecked((mapWarp_mod->getWorkingFlag().getStatus() == Flag::Ignore) ? Qt::Unchecked : Qt::Checked); + varToWarp->setCurrentIndex(varToMap->findData(m_warp_mod->toWarp())); + boxFlag->setChecked((m_warp_mod->workingFlag().status() == Flag::Ignore) ? Qt::Unchecked : Qt::Checked); if (boxFlag->isChecked()) { - varFlag->setValue(mapWarp_mod->getWorkingFlag().getFlag()); - varState->setCheckState((mapWarp_mod->getWorkingFlag().getStatus() == Flag::On) ? Qt::Checked : Qt::Unchecked); + varFlag->setValue(m_warp_mod->workingFlag().flag()); + varState->setCheckState((m_warp_mod->workingFlag().status() == Flag::On) ? Qt::Checked : Qt::Unchecked); } - varDialog->setCurrentIndex(varDialog->findData(mapWarp_mod->getDialog())); + varDialog->setCurrentIndex(varDialog->findData(m_warp_mod->dialog())); } void MapWarpUI::on_buttonApply_clicked() { - *mapWarp = *mapWarp_mod; + *m_warp = *m_warp_mod; emit(changed(false)); } void MapWarpUI::on_buttonDiscard_clicked() { - *mapWarp_mod = *mapWarp; + *m_warp_mod = *m_warp; setGui(); emit(changed(false)); } -void MapWarpUI::on_varName_textChanged(const QString& n) +void MapWarpUI::on_varName_textChanged(const QString& name) { - mapWarp_mod->setName(n); + m_warp_mod->setName(name); emit(changed(true)); } -void MapWarpUI::on_varCoordinateX_valueChanged(const int x) +void MapWarpUI::on_varCoordinate_valueChanged(const Point& coordinate) { - mapWarp_mod->setCoordinateX(x); - emit(changed(true)); -} - -void MapWarpUI::on_varCoordinateY_valueChanged(const int y) -{ - mapWarp_mod->setCoordinateY(y); + m_warp_mod->setCoordinate(coordinate); emit(changed(true)); } @@ -151,144 +143,144 @@ void MapWarpUI::on_varActivation_itemSelectionChanged() try { for (int i = 0; i < varActivation->count(); ++i) - mapWarp_mod->setFrom(i, varActivation->item(i)->isSelected()); + m_warp_mod->setFrom(i, varActivation->item(i)->isSelected()); emit(changed(true)); } - catch (BoundsException& e) + catch (BoundsException& exception) { - BugCatcher::report(e); + BugCatcher::report(exception); setGui(); } } -void MapWarpUI::on_varDirectionOut_currentIndexChanged(const int d) +void MapWarpUI::on_varDirectionOut_currentIndexChanged(const int directionOut) { try { - mapWarp_mod->setDirectionOut(d); + m_warp_mod->setDirectionOut(directionOut); emit(changed(true)); } - catch (BoundsException& e) + catch (BoundsException& exception) { - BugCatcher::report(e); + BugCatcher::report(exception); setGui(); } } -void MapWarpUI::on_varType_currentIndexChanged(const int t) +void MapWarpUI::on_varType_currentIndexChanged(const int type) { try { - mapWarp_mod->setWarpType(t); + m_warp_mod->setWarpType(type); emit(changed(true)); } - catch (BoundsException& e) + catch (BoundsException& exception) { - BugCatcher::report(e); + BugCatcher::report(exception); setGui(); } } -void MapWarpUI::on_varBiking_stateChanged(const int b) +void MapWarpUI::on_varBiking_stateChanged(const int biking) { try { - mapWarp_mod->setIsBiking(b); + m_warp_mod->setIsBiking(biking); emit(changed(true)); } - catch (BoundsException& e) + catch (BoundsException& exception) { - BugCatcher::report(e); + BugCatcher::report(exception); setGui(); } } -void MapWarpUI::on_varFlash_stateChanged(const int f) +void MapWarpUI::on_varFlash_stateChanged(const int flash) { try { - mapWarp_mod->setIsFlash(f); + m_warp_mod->setIsFlash(flash); emit(changed(true)); } - catch (BoundsException& e) + catch (BoundsException& exception) { - BugCatcher::report(e); + BugCatcher::report(exception); setGui(); } } -void MapWarpUI::on_varFog_stateChanged(const int f) +void MapWarpUI::on_varFog_stateChanged(const int fog) { try { - mapWarp_mod->setIsFoggy(f); + m_warp_mod->setIsFoggy(fog); emit(changed(true)); } - catch (BoundsException& e) + catch (BoundsException& exception) { - BugCatcher::report(e); + BugCatcher::report(exception); setGui(); } } -void MapWarpUI::on_varToMap_currentIndexChanged(const int m) +void MapWarpUI::on_varToMap_currentIndexChanged(const int toMap) { try { - mapWarp_mod->setToMap(m); + m_warp_mod->setToMap(toMap); emit(changed(true)); } - catch (BoundsException& e) + catch (BoundsException& exception) { - BugCatcher::report(e); + BugCatcher::report(exception); } setGui(); } -void MapWarpUI::on_varToWarp_currentIndexChanged(const int w) +void MapWarpUI::on_varToWarp_currentIndexChanged(const int toWarp) { try { - mapWarp_mod->setToWarp(w); + m_warp_mod->setToWarp(toWarp); emit(changed(true)); } - catch (BoundsException& e) + catch (BoundsException& exception) { - BugCatcher::report(e); + BugCatcher::report(exception); setGui(); } } -void MapWarpUI::on_boxFlag_toggled(const bool f) +void MapWarpUI::on_boxFlag_toggled(const bool flagUsed) { - if (!f) - mapWarp_mod->setWorkingFlagStatus(Flag::Ignore); + if (!flagUsed) + m_warp_mod->setWorkingFlag(Flag(varFlag->value(), Flag::Ignore)); emit(changed(true)); setGui(); } -void MapWarpUI::on_varFlag_valueChanged(const int f) +void MapWarpUI::on_varFlag_valueChanged(const int flag) { - mapWarp_mod->setWorkingFlagFlag(f); + m_warp_mod->setWorkingFlag(Flag(flag, boxFlag->isChecked() ? Flag::Ignore : (varState->isChecked() ? Flag::On : Flag::Off))); emit(changed(true)); } -void MapWarpUI::on_varState_toggled(const bool s) +void MapWarpUI::on_varState_toggled(const bool status) { - mapWarp_mod->setWorkingFlagStatus(s ? Flag::On : Flag::Off); + m_warp_mod->setWorkingFlag(Flag(varFlag->value(), status ? Flag::On : Flag::Off)); emit(changed(true)); } -void MapWarpUI::on_varDialog_currentIndexChanged(const int d) +void MapWarpUI::on_varDialog_currentIndexChanged(const int dialog) { try { - mapWarp_mod->setDialog(d); + m_warp_mod->setDialog(dialog); emit(changed(true)); } - catch (BoundsException& e) + catch (BoundsException& exception) { - BugCatcher::report(e); + BugCatcher::report(exception); setGui(); } } -- cgit