summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2009-03-29 16:43:56 -0400
committerBen Boeckel <MathStuf@gmail.com>2009-03-29 16:43:56 -0400
commit1770e2893ab6b7767e1b7180fd2c049c74ab6293 (patch)
tree2ae55f6365e950407131dbb1efdb6af3dcf8156b
parent3ce66c611c72184c01181f493d161c6118e7204a (diff)
downloadsigen-1770e2893ab6b7767e1b7180fd2c049c74ab6293.tar.gz
sigen-1770e2893ab6b7767e1b7180fd2c049c74ab6293.tar.xz
sigen-1770e2893ab6b7767e1b7180fd2c049c74ab6293.zip
Maps don't have a type anymore
-rw-r--r--sigmod/Map.cpp9
-rw-r--r--sigmod/Map.h14
-rw-r--r--sigmodr/widgets/MapUI.cpp11
-rw-r--r--sigmodr/widgets/MapUI_p.h2
-rw-r--r--sigmodr/widgets/gui/map.ui43
-rw-r--r--sigmodr/widgets/mapeditor/EffectItem.cpp32
-rw-r--r--sigmodr/widgets/mapeditor/EffectItem.h1
-rw-r--r--sigscript/MapWrapper.cpp16
-rw-r--r--sigscript/MapWrapper.h3
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 <QtCore/QList>
-#include <QtCore/QMetaType>
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<MapEffect*> m_effects;
@@ -168,6 +155,5 @@ class SIGMOD_EXPORT Map : public Object
QList<MapWildList*> 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<KLineEdit*>("varName");
- ui_type = form->findChild<KComboBox*>("varType");
QGridLayout* editorLayout = form->findChild<QGridLayout*>("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<Map::Type>(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 @@
</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>
- <property name="statusTip" >
- <string>Name of the map (internal use only)</string>
- </property>
- <property name="whatsThis" >
- <string>Name of the map (internal use only)</string>
- </property>
- <property name="showClearButton" stdset="0" >
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="0" >
- <widget class="QLabel" name="labelType" >
- <property name="text" >
- <string>Type:</string>
- </property>
- <property name="alignment" >
- <set>Qt::AlignRight|Qt::AlignVCenter</set>
- </property>
- <property name="buddy" >
- <cstring>varType</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1" >
<widget class="KComboBox" name="varType" >
<property name="toolTip" >
<string>They type of map</string>
@@ -68,17 +39,6 @@
</layout>
</widget>
<customwidgets>
- <customwidget>
- <class>KComboBox</class>
- <extends>QComboBox</extends>
- <header location="global" >KComboBox</header>
- </customwidget>
- <customwidget>
- <class>KIntNumInput</class>
- <extends>QWidget</extends>
- <header location="global" >KIntNumInput</header>
- </customwidget>
- <customwidget>
<class>KLineEdit</class>
<extends>QLineEdit</extends>
<header location="global" >KLineEdit</header>
@@ -91,8 +51,5 @@
</customwidgets>
<tabstops>
<tabstop>varName</tabstop>
- <tabstop>varType</tabstop>
</tabstops>
- <resources/>
- <connections/>
</ui>
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 <sigmod/Game.h>
#include <sigmod/MapEffect.h>
+#include <sigmod/Skin.h>
// Qt includes
#include <QtGui/QPainter>
@@ -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<Map::Type>();
-}
-
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;