diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2009-01-20 17:05:18 -0500 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2009-01-20 17:05:18 -0500 |
| commit | 0015cc077a261f0da4852f570f83a975b3724cd3 (patch) | |
| tree | 1f881d5e8709ecda30ebf6de68c0bcd5387ccbad | |
| parent | e62af8390d71138aa62467f2fadcc581265da334 (diff) | |
FlyWarp isn't needed on Map and cleaned up widget
| -rw-r--r-- | sigmod/Map.cpp | 14 | ||||
| -rw-r--r-- | sigmod/Map.h | 6 | ||||
| -rw-r--r-- | sigmod/test/TestMap.cpp | 86 | ||||
| -rw-r--r-- | sigmod/test/TestMap.h | 1 | ||||
| -rw-r--r-- | sigmodr/MapUI.cpp | 26 | ||||
| -rw-r--r-- | sigmodr/MapUI.h | 5 | ||||
| -rw-r--r-- | sigmodr/gui/map.ui | 82 | ||||
| -rw-r--r-- | sigscript/MapWrapper.cpp | 7 | ||||
| -rw-r--r-- | sigscript/MapWrapper.h | 3 |
9 files changed, 57 insertions, 173 deletions
diff --git a/sigmod/Map.cpp b/sigmod/Map.cpp index 582e5967..8f61587b 100644 --- a/sigmod/Map.cpp +++ b/sigmod/Map.cpp @@ -41,7 +41,6 @@ Sigmod::Map::Map(const Map& map) : Sigmod::Map::Map(const Sigmod* parent, const int id) : Object(parent, id), m_name(""), - m_flyWarp(-1), m_type(Outdoor), m_width(1), m_height(1) @@ -71,7 +70,6 @@ void Sigmod::Map::validate() TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); - TEST(flyWarp); TEST(width); TEST(height); QSet<int> idChecker; @@ -117,7 +115,6 @@ void Sigmod::Map::load(const QDomElement& xml) { LOAD_BEGIN(); LOAD(name); - LOAD(flyWarp); LOAD_ENUM(type, Type); LOAD(width); LOAD(height); @@ -132,7 +129,6 @@ QDomElement Sigmod::Map::save() const { SAVE_CREATE(); SAVE(name); - SAVE(flyWarp); SAVE_ENUM(type, Type); SAVE(width); SAVE(height); @@ -145,25 +141,16 @@ QDomElement Sigmod::Map::save() const } SETTER(Map, QString&, Name, name) -SETTER(Map, int, FlyWarp, flyWarp) SETTER(Map, Type, Type, type) SETTER(Map, int, Width, width) SETTER(Map, int, Height, height) GETTER(Map, QString, name) -GETTER(Map, int, flyWarp) GETTER(Map, Sigmod::Map::Type, type) GETTER(Map, int, width) GETTER(Map, int, height) CHECK(Map, QString&, name) -CHECK_BEGIN(Map, int, flyWarp) - if ((flyWarp != -1) && !warpById(flyWarp)) - { - EBOUNDS_IDX(flyWarp); - return false; - } -CHECK_END() CHECK(Map, Type, type) CHECK_BOUNDS(Map, int, width, 1, INT_MAX) CHECK_BOUNDS(Map, int, height, 1, INT_MAX) @@ -180,7 +167,6 @@ Sigmod::Map& Sigmod::Map::operator=(const Map& rhs) return *this; clear(); COPY(name); - COPY(flyWarp); COPY(type); COPY(width); COPY(height); diff --git a/sigmod/Map.h b/sigmod/Map.h index 1fc7108e..73726ff0 100644 --- a/sigmod/Map.h +++ b/sigmod/Map.h @@ -1,5 +1,5 @@ /* - * Copyright 2007-2008 Ben Boeckel <MathStuf@gmail.com> + * Copyright 2007-2009 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 @@ -63,19 +63,16 @@ class SIGMOD_EXPORT Map : public Object QDomElement save() const; void setName(const QString& name); - void setFlyWarp(const int flyWarp); void setType(const Type type); void setWidth(const int width); void setHeight(const int height); QString name() const; - int flyWarp() const; Type type() const; int width() const; int height() const; bool nameCheck(const QString& name) const; - bool flyWarpCheck(const int flyWarp) const; bool typeCheck(const Type type) const; bool widthCheck(const int width) const; bool heightCheck(const int height) const; @@ -160,7 +157,6 @@ class SIGMOD_EXPORT Map : public Object void clear(); QString m_name; - int m_flyWarp; Type m_type; int m_width; int m_height; diff --git a/sigmod/test/TestMap.cpp b/sigmod/test/TestMap.cpp index d3e58d47..b96fd371 100644 --- a/sigmod/test/TestMap.cpp +++ b/sigmod/test/TestMap.cpp @@ -76,61 +76,40 @@ void TestMap::validation() QCOMPARE(m_warnings.size(), 8); QCOMPARE(m_errors.size(), 3); - m_map1->newWarp(); - - m_map1->setFlyWarp(0); - m_map1->validate(); - - QCOMPARE(m_warnings.size(), 12); - QCOMPARE(m_errors.size(), 3); - - m_map1->deleteWarp(0); - - m_map1->validate(); - - QCOMPARE(m_warnings.size(), 16); - QCOMPARE(m_errors.size(), 5); - - m_map1->setFlyWarp(-1); - m_map1->validate(); - - QCOMPARE(m_warnings.size(), 20); - QCOMPARE(m_errors.size(), 6); - m_map1->newEffect(); m_map1->validate(); - QCOMPARE(m_warnings.size(), 23); - QCOMPARE(m_errors.size(), 7); + QCOMPARE(m_warnings.size(), 11); + QCOMPARE(m_errors.size(), 4); m_map1->newTile(); m_map1->validate(); - QCOMPARE(m_warnings.size(), 25); - QCOMPARE(m_errors.size(), 8); + QCOMPARE(m_warnings.size(), 13); + QCOMPARE(m_errors.size(), 5); m_map1->newTrainer(); m_map1->validate(); - QCOMPARE(m_warnings.size(), 26); - QCOMPARE(m_errors.size(), 9); + QCOMPARE(m_warnings.size(), 14); + QCOMPARE(m_errors.size(), 6); m_map1->newWarp(); m_map1->validate(); - QCOMPARE(m_warnings.size(), 27); - QCOMPARE(m_errors.size(), 9); + QCOMPARE(m_warnings.size(), 15); + QCOMPARE(m_errors.size(), 6); m_map1->newWildList(); m_map1->validate(); - QCOMPARE(m_warnings.size(), 27); - QCOMPARE(m_errors.size(), 9); + QCOMPARE(m_warnings.size(), 15); + QCOMPARE(m_errors.size(), 6); } void TestMap::saving() @@ -155,7 +134,6 @@ void TestMap::loading() m_map1->newWildList(); m_map1->setName("Bar"); - m_map1->setFlyWarp(1); m_map1->setType(Sigmod::Map::Dungeon); m_map1->setWidth(5); m_map1->setHeight(5); @@ -165,7 +143,6 @@ void TestMap::loading() m_map1->load(xml.firstChildElement("Map")); QCOMPARE(m_map1->name(), QString("Foo")); - QCOMPARE(m_map1->flyWarp(), -1); QCOMPARE(m_map1->type(), Sigmod::Map::Outdoor); QCOMPARE(m_map1->width(), 1); QCOMPARE(m_map1->height(), 1); @@ -189,36 +166,6 @@ void TestMap::setName() QCOMPARE(m_errors.size(), 0); } -void TestMap::setFlyWarp() -{ - m_map2->setFlyWarp(0); - - QCOMPARE(m_warnings.size(), 0); - QCOMPARE(m_errors.size(), 1); - - m_map2->newWarp(); - - m_map2->setFlyWarp(0); - m_map2->setFlyWarp(0); - - QCOMPARE(m_map2->flyWarp(), 0); - - QCOMPARE(m_changedCount, 1); - - QCOMPARE(m_warnings.size(), 0); - QCOMPARE(m_errors.size(), 1); - - m_map2->setFlyWarp(-1); - m_map2->setFlyWarp(-1); - - QCOMPARE(m_map2->flyWarp(), -1); - - QCOMPARE(m_changedCount, 2); - - QCOMPARE(m_warnings.size(), 0); - QCOMPARE(m_errors.size(), 1); -} - void TestMap::setType() { m_map2->setType(Sigmod::Map::Dungeon); @@ -342,23 +289,23 @@ void TestMap::trainers() void TestMap::warps() { + QCOMPARE(m_map2->newWarp()->id(), 0); QCOMPARE(m_map2->newWarp()->id(), 1); QCOMPARE(m_map2->newWarp()->id(), 2); - QCOMPARE(m_map2->newWarp()->id(), 3); - QCOMPARE(m_map2->warpCount(), 4); + QCOMPARE(m_map2->warpCount(), 3); m_map2->deleteWarp(0); - QCOMPARE(m_map2->warpCount(), 3); + QCOMPARE(m_map2->warpCount(), 2); QCOMPARE(m_map2->newWarp()->id(), 0); - QCOMPARE(m_map2->warpIndex(0), 3); + QCOMPARE(m_map2->warpIndex(0), 2); m_map2->deleteWarpById(1); - QCOMPARE(m_map2->warpIndex(0), 2); + QCOMPARE(m_map2->warpIndex(0), 1); QCOMPARE(m_warnings.size(), 0); QCOMPARE(m_errors.size(), 0); @@ -393,14 +340,13 @@ void TestMap::assignment() *m_map3 = *m_map2; QCOMPARE(m_map3->name(), QString("Foo")); - QCOMPARE(m_map3->flyWarp(), -1); QCOMPARE(m_map3->type(), Sigmod::Map::Dungeon); QCOMPARE(m_map3->width(), 5); QCOMPARE(m_map3->height(), 5); QCOMPARE(m_map3->effectCount(), 2); QCOMPARE(m_map3->tileCount(), 2); QCOMPARE(m_map3->trainerCount(), 2); - QCOMPARE(m_map3->warpCount(), 3); + QCOMPARE(m_map3->warpCount(), 2); QCOMPARE(m_map3->wildListCount(), 2); } diff --git a/sigmod/test/TestMap.h b/sigmod/test/TestMap.h index 6cf4a8a1..af49a997 100644 --- a/sigmod/test/TestMap.h +++ b/sigmod/test/TestMap.h @@ -43,7 +43,6 @@ class TestMap : public TestSigmodObject void loading(); void setName(); - void setFlyWarp(); void setType(); void setWidth(); void setHeight(); diff --git a/sigmodr/MapUI.cpp b/sigmodr/MapUI.cpp index 240d7268..6c608f9f 100644 --- a/sigmodr/MapUI.cpp +++ b/sigmodr/MapUI.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * Copyright 2008-2009 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 @@ -47,23 +47,9 @@ void Sigmodr::MapUI::initGui() varType->addItem(Sigmod::Map::TypeStr[Sigmod::Map::Building], QVariant::fromValue(Sigmod::Map::Building)); } -void Sigmodr::MapUI::refreshGui() -{ - const bool blockedFlyWarp = varFlyWarp->blockSignals(true); - varFlyWarp->clear(); - for (int i = 0; i < qobject_cast<Sigmod::Map*>(original())->warpCount(); ++i) - { - const Sigmod::MapWarp* warp = qobject_cast<Sigmod::Map*>(original())->warp(i); - varFlyWarp->addItem(warp->name(), warp->id()); - } - varFlyWarp->blockSignals(blockedFlyWarp); -} - void Sigmodr::MapUI::setGui() { varName->setText(qobject_cast<Sigmod::Map*>(modified())->name()); - boxFlyWarp->setChecked((qobject_cast<Sigmod::Map*>(modified())->flyWarp() == -1) ? Qt::Unchecked : Qt::Checked); - varFlyWarp->setCurrentIndex(varFlyWarp->findData(qobject_cast<Sigmod::Map*>(modified())->flyWarp())); varType->setCurrentIndex(qobject_cast<Sigmod::Map*>(modified())->type()); varMap->reset(); } @@ -88,16 +74,6 @@ void Sigmodr::MapUI::on_varName_textChanged(const QString& name) varName->setCursorPosition(cursor); } -void Sigmodr::MapUI::on_boxFlyWarp_toggled() -{ - qobject_cast<Sigmod::Map*>(modified())->setFlyWarp(-1); -} - -void Sigmodr::MapUI::on_varFlyWarp_activated(const int flyWarp) -{ - qobject_cast<Sigmod::Map*>(modified())->setFlyWarp(varFlyWarp->itemData(flyWarp).toInt()); -} - void Sigmodr::MapUI::on_varType_activated(const int type) { qobject_cast<Sigmod::Map*>(modified())->setType(varType->itemData(type).value<Sigmod::Map::Type>()); diff --git a/sigmodr/MapUI.h b/sigmodr/MapUI.h index 3ac48bf9..f70da1d8 100644 --- a/sigmodr/MapUI.h +++ b/sigmodr/MapUI.h @@ -1,5 +1,5 @@ /* - * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * Copyright 2008-2009 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 @@ -46,12 +46,9 @@ class MapUI : public ObjectUI, private Ui::formMap void discard(); protected slots: void on_varName_textChanged(const QString& name); - void on_boxFlyWarp_toggled(); - void on_varFlyWarp_activated(const int flyWarp); void on_varType_activated(const int type); private slots: void initGui(); - void refreshGui(); void setGui(); }; } diff --git a/sigmodr/gui/map.ui b/sigmodr/gui/map.ui index db5eb256..0f5aab99 100644 --- a/sigmodr/gui/map.ui +++ b/sigmodr/gui/map.ui @@ -1,9 +1,22 @@ <ui version="4.0" > <class>formMap</class> <widget class="QWidget" name="formMap" > - <layout class="QVBoxLayout" > - <item> - <widget class="QGroupBox" name="boxName" > + <layout class="QGridLayout" > + <item row="0" column="0" > + <widget class="QLabel" name="labelName" > + <property name="text" > + <string comment="Label for the name of the map" >Name:</string> + </property> + <property name="alignment" > + <set>Qt::AlignRight|Qt::AlignVCenter</set> + </property> + <property name="buddy" > + <cstring>varName</cstring> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="KLineEdit" name="varName" > <property name="toolTip" > <string>Name of the map (internal use only)</string> </property> @@ -13,46 +26,26 @@ <property name="whatsThis" > <string>Name of the map (internal use only)</string> </property> - <property name="title" > - <string comment="Label for the male sprites of the map" >Name</string> + <property name="showClearButton" stdset="0" > + <bool>true</bool> </property> - <layout class="QHBoxLayout" > - <item> - <widget class="KLineEdit" name="varName" > - <property name="showClearButton" stdset="0" > - <bool>true</bool> - </property> - </widget> - </item> - </layout> </widget> </item> - <item> - <widget class="QGroupBox" name="boxFlyWarp" > - <property name="toolTip" > - <string>The destination when flown to the map</string> - </property> - <property name="statusTip" > - <string>The destination when flown to the map</string> - </property> - <property name="whatsThis" > - <string>The destination when flown to the map</string> + <item row="1" column="0" > + <widget class="QLabel" name="labelType" > + <property name="text" > + <string>Type:</string> </property> - <property name="title" > - <string>Fly Warp</string> + <property name="alignment" > + <set>Qt::AlignRight|Qt::AlignVCenter</set> </property> - <property name="checkable" > - <bool>true</bool> + <property name="buddy" > + <cstring>varType</cstring> </property> - <layout class="QHBoxLayout" > - <item> - <widget class="KComboBox" name="varFlyWarp" /> - </item> - </layout> </widget> </item> - <item> - <widget class="QGroupBox" name="boxType" > + <item row="1" column="1" > + <widget class="KComboBox" name="varType" > <property name="toolTip" > <string>They type of map</string> </property> @@ -62,23 +55,15 @@ <property name="whatsThis" > <string>They type of map</string> </property> - <property name="title" > - <string>Type</string> - </property> - <layout class="QHBoxLayout" > - <item> - <widget class="KComboBox" name="varType" /> - </item> - </layout> </widget> </item> - <item> + <item row="2" column="0" colspan="2" > <widget class="QGroupBox" name="boxMap" > <property name="title" > <string>Map</string> </property> - <layout class="QVBoxLayout" name="verticalLayout" > - <item> + <layout class="QGridLayout" > + <item row="0" column="0" > <widget class="Sigmodr::MapEditor" name="varMap" /> </item> </layout> @@ -109,6 +94,11 @@ <container>1</container> </customwidget> </customwidgets> + <tabstops> + <tabstop>varName</tabstop> + <tabstop>varType</tabstop> + <tabstop>varMap</tabstop> + </tabstops> <resources/> <connections/> </ui> diff --git a/sigscript/MapWrapper.cpp b/sigscript/MapWrapper.cpp index 30e2a6d3..00200272 100644 --- a/sigscript/MapWrapper.cpp +++ b/sigscript/MapWrapper.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * Copyright 2008-2009 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 @@ -81,11 +81,6 @@ QString Sigscript::MapWrapper::name() const return m_map->name(); } -Sigscript::MapWarpWrapper* Sigscript::MapWrapper::flyWarp() -{ - return MapWarpWrapper::create(m_map->warpById(m_map->flyWarp()), this); -} - Sigmod::Map::Type Sigscript::MapWrapper::type() const { return m_map->type(); diff --git a/sigscript/MapWrapper.h b/sigscript/MapWrapper.h index b6cdaae5..fa5e23a9 100644 --- a/sigscript/MapWrapper.h +++ b/sigscript/MapWrapper.h @@ -1,5 +1,5 @@ /* - * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * Copyright 2008-2009 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 @@ -50,7 +50,6 @@ class SIGSCRIPT_EXPORT MapWrapper : public ObjectWrapper Q_SCRIPTABLE Sigmod::Map::Type type(const QString& name) const; Q_SCRIPTABLE QString name() const; - Q_SCRIPTABLE MapWarpWrapper* flyWarp(); Q_SCRIPTABLE Sigmod::Map::Type type() const; Q_SCRIPTABLE int width() const; Q_SCRIPTABLE int height() const; |
