From 1770e2893ab6b7767e1b7180fd2c049c74ab6293 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sun, 29 Mar 2009 16:43:56 -0400 Subject: Maps don't have a type anymore --- sigmod/Map.cpp | 9 ------- sigmod/Map.h | 14 ----------- sigmodr/widgets/MapUI.cpp | 11 +------- sigmodr/widgets/MapUI_p.h | 2 -- sigmodr/widgets/gui/map.ui | 43 -------------------------------- sigmodr/widgets/mapeditor/EffectItem.cpp | 32 ++++++++++++++++++------ sigmodr/widgets/mapeditor/EffectItem.h | 1 + sigscript/MapWrapper.cpp | 16 ------------ sigscript/MapWrapper.h | 3 --- 9 files changed, 26 insertions(+), 105 deletions(-) diff --git a/sigmod/Map.cpp b/sigmod/Map.cpp index dd85bd67..ff078c2c 100644 --- a/sigmod/Map.cpp +++ b/sigmod/Map.cpp @@ -32,8 +32,6 @@ using namespace Sigmod; -const QStringList Map::TypeStr = QStringList() << "Outdoor" << "Dungeon" << "Building"; - Map::Map(const Map& map) : Object(map.parent(), map.id()) { @@ -43,7 +41,6 @@ Map::Map(const Map& map) : Map::Map(const Game* parent, const int id) : Object(parent, id), m_name(""), - m_type(Outdoor), m_width(1), m_height(1) { @@ -117,7 +114,6 @@ void Map::load(const QDomElement& xml) { LOAD_BEGIN(); LOAD(name); - LOAD_ENUM(type, Type); LOAD(width); LOAD(height); LOAD_SUB(newEffect, MapEffect); @@ -131,7 +127,6 @@ QDomElement Map::save() const { SAVE_CREATE(); SAVE(name); - SAVE_ENUM(type, Type); SAVE(width); SAVE(height); SAVE_SUB(MapEffect, effects); @@ -143,17 +138,14 @@ QDomElement Map::save() const } SETTER(Map, QString&, Name, name) -SETTER(Map, Type, Type, type) SETTER(Map, int, Width, width) SETTER(Map, int, Height, height) GETTER(Map, QString, name) -GETTER(Map, Map::Type, type) GETTER(Map, int, width) GETTER(Map, int, height) CHECK(Map, QString&, name) -CHECK(Map, Type, type) CHECK_BOUNDS(Map, int, width, 1, INT_MAX) CHECK_BOUNDS(Map, int, height, 1, INT_MAX) @@ -169,7 +161,6 @@ Map& Map::operator=(const Map& rhs) return *this; clear(); COPY(name); - COPY(type); COPY(width); COPY(height); COPY_SUB(MapEffect, effects); diff --git a/sigmod/Map.h b/sigmod/Map.h index 5cb7dc4e..70607a54 100644 --- a/sigmod/Map.h +++ b/sigmod/Map.h @@ -26,7 +26,6 @@ // Qt includes #include -#include namespace Sigmod { @@ -44,14 +43,6 @@ class SIGMOD_EXPORT Map : public Object Q_ENUMS(Type) public: - enum Type - { - Outdoor = 0, - Dungeon = 1, - Building = 2 - }; - static const QStringList TypeStr; - Map(const Map& map); Map(const Game* parent, const int id); Map(const Map& map, const Game* parent, const int id); @@ -64,17 +55,14 @@ class SIGMOD_EXPORT Map : public Object QDomElement save() const; void setName(const QString& name); - void setType(const Type type); void setWidth(const int width); void setHeight(const int height); QString name() const; - Type type() const; int width() const; int height() const; bool nameCheck(const QString& name) const; - bool typeCheck(const Type type) const; bool widthCheck(const int width) const; bool heightCheck(const int height) const; @@ -158,7 +146,6 @@ class SIGMOD_EXPORT Map : public Object void clear(); QString m_name; - Type m_type; int m_width; int m_height; QList m_effects; @@ -168,6 +155,5 @@ class SIGMOD_EXPORT Map : public Object QList m_wildLists; }; } -Q_DECLARE_METATYPE(Sigmod::Map::Type) #endif diff --git a/sigmodr/widgets/MapUI.cpp b/sigmodr/widgets/MapUI.cpp index c7cf7cde..6d1f00ec 100644 --- a/sigmodr/widgets/MapUI.cpp +++ b/sigmodr/widgets/MapUI.cpp @@ -74,22 +74,18 @@ QWidget* MapUI::Private::makeWidgets(ObjectUI* widget) { QWidget *form = openUiFile(":/gui/map.ui", widget); ui_name = form->findChild("varName"); - ui_type = form->findChild("varType"); QGridLayout* editorLayout = form->findChild("editorLayout"); ui_editor = new MapEditor(m_map, widget); editorLayout->addWidget(ui_editor, 0, 0); connect(ui_name, SIGNAL(textChanged(QString)), this, SLOT(nameChanged(QString))); - connect(ui_type, SIGNAL(currentIndexChanged(int)), this, SLOT(typeChanged(int))); connect(ui_editor, SIGNAL(changed()), this, SIGNAL(changed())); - widget->setTabOrder(ui_type, ui_editor); - ui_type->addItems(Map::TypeStr); + widget->setTabOrder(ui_name, ui_editor); return form; } void MapUI::Private::resetGui() { ui_name->setText(m_map->name()); - ui_type->setCurrentIndex(m_map->type()); ui_editor->setMap(m_map); } @@ -99,8 +95,3 @@ void MapUI::Private::nameChanged(const QString& name) m_map->setName(name); ui_name->setCursorPosition(cursor); } - -void MapUI::Private::typeChanged(const int type) -{ - m_map->setType(static_cast(type)); -} diff --git a/sigmodr/widgets/MapUI_p.h b/sigmodr/widgets/MapUI_p.h index ee95aa39..0080174e 100644 --- a/sigmodr/widgets/MapUI_p.h +++ b/sigmodr/widgets/MapUI_p.h @@ -49,10 +49,8 @@ class SIGMODRWIDGETS_NO_EXPORT MapUI::Private : public ObjectUIPrivate void resetGui(); protected slots: void nameChanged(const QString& name); - void typeChanged(const int type); private: KLineEdit* ui_name; - KComboBox* ui_type; MapEditor* ui_editor; }; } diff --git a/sigmodr/widgets/gui/map.ui b/sigmodr/widgets/gui/map.ui index 9a0f287a..ebfcf760 100644 --- a/sigmodr/widgets/gui/map.ui +++ b/sigmodr/widgets/gui/map.ui @@ -16,35 +16,6 @@ - - - Name of the map (internal use only) - - - Name of the map (internal use only) - - - Name of the map (internal use only) - - - true - - - - - - - Type: - - - Qt::AlignRight|Qt::AlignVCenter - - - varType - - - - They type of map @@ -68,17 +39,6 @@ - - KComboBox - QComboBox -
KComboBox
-
- - KIntNumInput - QWidget -
KIntNumInput
-
- KLineEdit QLineEdit
KLineEdit
@@ -91,8 +51,5 @@
varName - varType - - diff --git a/sigmodr/widgets/mapeditor/EffectItem.cpp b/sigmodr/widgets/mapeditor/EffectItem.cpp index ae35135b..3282352d 100644 --- a/sigmodr/widgets/mapeditor/EffectItem.cpp +++ b/sigmodr/widgets/mapeditor/EffectItem.cpp @@ -19,7 +19,9 @@ #include "EffectItem.h" // Sigmod includes +#include #include +#include // Qt includes #include @@ -44,21 +46,30 @@ EffectItem::EffectItem(Sigmod::Map* map, MapEffect* effect, QGraphicsScene* pare QRectF EffectItem::boundingRect() const { - QPainterPath path = m_effect->area(); - if (path.isEmpty()) - return QRect(0, 0, 32, 32); - return m_effect->area().boundingRect(); + if (m_size.isNull()) + { + QPainterPath path = m_effect->area(); + if (path.isEmpty()) + return QRect(0, 0, 32, 32); + return m_effect->area().boundingRect(); + } + return QRect(QPoint(), m_size); } void EffectItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { painter->setBrush(QBrush(Qt::red)); painter->setPen(QPen(Qt::black, 2)); - QPainterPath path = m_effect->area(); - if (path.isEmpty()) - painter->drawRect(0, 0, 32, 32); + if (m_size.isNull()) + { + QPainterPath path = m_effect->area(); + if (path.isEmpty()) + painter->drawRect(boundingRect()); + else + painter->drawPath(path); + } else - painter->drawPath(path); + painter->drawRect(QRect(QPoint(), m_size)); MapItem::paint(painter, option, widget); } @@ -75,6 +86,11 @@ void EffectItem::moveTo(const QPoint& point) void EffectItem::effectChanged() { setPos(m_effect->position()); + const Skin* skin = m_effect->game()->skinById(m_effect->skin()); + if (skin) + m_size = skin->size(); + else + m_size = QSize(); resetLabel(); update(); } diff --git a/sigmodr/widgets/mapeditor/EffectItem.h b/sigmodr/widgets/mapeditor/EffectItem.h index 0b8e42d7..9ae5bdb2 100644 --- a/sigmodr/widgets/mapeditor/EffectItem.h +++ b/sigmodr/widgets/mapeditor/EffectItem.h @@ -56,6 +56,7 @@ class SIGMODRWIDGETS_NO_EXPORT EffectItem : public MapItem void resetLabel(); Sigmod::MapEffect* m_effect; + QSize m_size; }; } } diff --git a/sigscript/MapWrapper.cpp b/sigscript/MapWrapper.cpp index a016f635..beca24cb 100644 --- a/sigscript/MapWrapper.cpp +++ b/sigscript/MapWrapper.cpp @@ -73,27 +73,11 @@ MapWildListWrapper* MapWrapper::wildList(const int id) return MapWildListWrapper::create(m_map->wildListById(id), this); } -Map::Type MapWrapper::type(const QString& name) const -{ - if (name == "Outdoor") - return Map::Outdoor; - else if (name == "Dungeon") - return Map::Dungeon; - else if (name == "Building") - return Map::Building; - return QVariant(-1).value(); -} - QString MapWrapper::name() const { return m_map->name(); } -Map::Type MapWrapper::type() const -{ - return m_map->type(); -} - int MapWrapper::width() const { return m_map->width(); diff --git a/sigscript/MapWrapper.h b/sigscript/MapWrapper.h index a3b7d172..fb3fe38f 100644 --- a/sigscript/MapWrapper.h +++ b/sigscript/MapWrapper.h @@ -47,10 +47,7 @@ class SIGSCRIPT_EXPORT MapWrapper : public ObjectWrapper MapWarpWrapper* warp(const int id); MapWildListWrapper* wildList(const int id); - Q_SCRIPTABLE Sigmod::Map::Type type(const QString& name) const; - Q_SCRIPTABLE QString name() const; - Q_SCRIPTABLE Sigmod::Map::Type type() const; Q_SCRIPTABLE int width() const; Q_SCRIPTABLE int height() const; -- cgit