summaryrefslogtreecommitdiffstats
path: root/pokemodr/MapUI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pokemodr/MapUI.cpp')
-rw-r--r--pokemodr/MapUI.cpp126
1 files changed, 64 insertions, 62 deletions
diff --git a/pokemodr/MapUI.cpp b/pokemodr/MapUI.cpp
index a9760c28..27bcfc6b 100644
--- a/pokemodr/MapUI.cpp
+++ b/pokemodr/MapUI.cpp
@@ -1,47 +1,45 @@
-/////////////////////////////////////////////////////////////////////////////
-// Name: pokegen/MapUI.cpp
-// Purpose: Map UI form handling
-// Author: Ben Boeckel
-// Modified by: Ben Boeckel
-// Created: Sat Feb 2 00:50:25 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/>.
+ */
+
+// Qt includes
#include <QHeaderView>
#include <QIcon>
-#include <QMetaObject>
+// General includes
#include <BugCatcher.h>
#include <Exception.h>
+// Pokemod includes
#include <MapWarp.h>
#include <Pokemod.h>
+// Header include
#include "MapUI.h"
-MapUI::MapUI(Map* m, QWidget* parent) :
+MapUI::MapUI(Map* map, QWidget* parent) :
ObjectUI(parent),
- map(m),
- map_mod(new Map(m->getPokemod(), *m, m->getId())),
- model(new TilemapModel(this, map_mod->getMap(), map->getPokemod())),
- delegate(new TileDelegate(this))
+ m_map(map),
+ m_map_mod(new Map(*map)),
+ m_model(new TilemapModel(this, m_map_mod->map(), m_map->pokemod())),
+ m_delegate(new TileDelegate(this))
{
setupUi(this);
QMetaObject::connectSlotsByName(this);
- setObjects(map, map_mod);
+ setObjects(m_map, m_map_mod);
connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool)));
init();
}
@@ -53,112 +51,116 @@ void MapUI::initGui()
varTilemap->verticalHeader()->setResizeMode(QHeaderView::Fixed);
varTilemap->horizontalHeader()->setDefaultSectionSize(64);
varTilemap->verticalHeader()->setDefaultSectionSize(64);
- varTilemap->setModel(model);
- varTilemap->setItemDelegate(delegate);
+ varTilemap->setModel(m_model);
+ varTilemap->setItemDelegate(m_delegate);
}
void MapUI::refreshGui()
{
varFlyWarp->clear();
- for (int i = 0; i < map->getWarpCount(); ++i)
+ for (int i = 0; i < m_map->warpCount(); ++i)
{
- const MapWarp* w = map->getWarp(i);
- varFlyWarp->addItem(w->getName());
- varFlyWarp->setItemData(i, w->getId());
+ const MapWarp* warp = m_map->warp(i);
+ varFlyWarp->addItem(warp->name());
+ varFlyWarp->setItemData(i, warp->id());
}
}
void MapUI::setGui()
{
- varName->setText(map_mod->getName());
- boxFlyWarp->setChecked((map_mod->getFlyWarp() == INT_MAX) ? Qt::Unchecked : Qt::Checked);
- varFlyWarp->setCurrentIndex(varFlyWarp->findData(map_mod->getFlyWarp()));
- varType->setCurrentIndex(map_mod->getType());
+ varName->setText(m_map_mod->name());
+ boxFlyWarp->setChecked((m_map_mod->flyWarp() == INT_MAX) ? Qt::Unchecked : Qt::Checked);
+ varFlyWarp->setCurrentIndex(varFlyWarp->findData(m_map_mod->flyWarp()));
+ varType->setCurrentIndex(m_map_mod->type());
+ buttonDeleteColumn->setEnabled(0 < m_model->columnCount());
+ buttonDeleteRow->setEnabled(0 < m_model->rowCount());
}
void MapUI::on_buttonApply_clicked()
{
- *map = *map_mod;
+ *m_map = *m_map_mod;
emit(changed(false));
}
void MapUI::on_buttonDiscard_clicked()
{
- *map_mod = *map;
+ *m_map_mod = *m_map;
setGui();
emit(changed(false));
}
-void MapUI::on_varName_textChanged(const QString& n)
+void MapUI::on_varName_textChanged(const QString& name)
{
- map_mod->setName(n);
+ m_map_mod->setName(name);
emit(changed(true));
}
void MapUI::on_boxFlyWarp_toggled()
{
- map_mod->setFlyWarp(-1);
+ m_map_mod->setFlyWarp(-1);
emit(changed(true));
}
-void MapUI::on_varFlyWarp_currentIndexChanged(const int f)
+void MapUI::on_varFlyWarp_currentIndexChanged(const int flyWarp)
{
try
{
- map_mod->setFlyWarp(varFlyWarp->itemData(f).toInt());
+ m_map_mod->setFlyWarp(varFlyWarp->itemData(flyWarp).toInt());
emit(changed(true));
}
- catch (BoundsException& e)
+ catch (BoundsException& exception)
{
- BugCatcher::report(e);
+ BugCatcher::report(exception);
setGui();
}
}
-void MapUI::on_varType_currentIndexChanged(const int t)
+void MapUI::on_varType_currentIndexChanged(const int type)
{
try
{
- map_mod->setType(t);
+ m_map_mod->setType(type);
emit(changed(true));
}
- catch (BoundsException& e)
+ catch (BoundsException& exception)
{
- BugCatcher::report(e);
+ BugCatcher::report(exception);
setGui();
}
}
void MapUI::on_buttonAddColumn_pressed()
{
- model->addColumn();
- buttonDeleteColumn->setEnabled(true);
+ m_model->addColumn();
+ emit(changed(true));
}
void MapUI::on_buttonAddRow_pressed()
{
- model->addRow();
- buttonDeleteRow->setEnabled(true);
+ m_model->addRow();
+ emit(changed(true));
}
void MapUI::on_buttonDeleteColumn_pressed()
{
- model->removeColumns(varTilemap->currentIndex().column(), 1);
+ m_model->removeColumns(varTilemap->currentIndex().column(), 1);
+ emit(changed(true));
}
void MapUI::on_buttonDeleteRow_pressed()
{
- model->removeRows(varTilemap->currentIndex().row(), 1);
+ m_model->removeRows(varTilemap->currentIndex().row(), 1);
+ emit(changed(true));
}
void MapUI::on_buttonInsertColumn_pressed()
{
- model->insertColumns(varTilemap->currentIndex().column(), 1);
- buttonDeleteColumn->setEnabled(true);
+ m_model->insertColumns(varTilemap->currentIndex().column(), 1);
+ emit(changed(true));
}
void MapUI::on_buttonInsertRow_pressed()
{
- model->insertRows(varTilemap->currentIndex().row(), 1);
- buttonDeleteRow->setEnabled(true);
+ m_model->insertRows(varTilemap->currentIndex().row(), 1);
+ emit(changed(true));
}