summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2009-07-19 13:50:43 -0400
committerBen Boeckel <MathStuf@gmail.com>2009-07-19 13:50:43 -0400
commitdffac4ac7cb7f62619bf1d0b356b17f5791fa765 (patch)
treed7f05be81da9429e7f2d9736bae58cd0647655f8
parent51f1d2c9d6c2a2b89821143de8fc3bce95d8f164 (diff)
downloadsigen-dffac4ac7cb7f62619bf1d0b356b17f5791fa765.tar.gz
sigen-dffac4ac7cb7f62619bf1d0b356b17f5791fa765.tar.xz
sigen-dffac4ac7cb7f62619bf1d0b356b17f5791fa765.zip
Remove sellable from item; set in sellPrice as -1
-rw-r--r--sigmod/Item.cpp12
-rw-r--r--sigmod/Item.h16
-rw-r--r--sigmodr/widgets/ItemUI.cpp14
-rw-r--r--sigmodr/widgets/ItemUI_p.h3
-rw-r--r--sigmodr/widgets/gui/item.ui89
-rw-r--r--sigscript/ItemWrapper.cpp5
-rw-r--r--sigscript/ItemWrapper.h1
7 files changed, 32 insertions, 108 deletions
diff --git a/sigmod/Item.cpp b/sigmod/Item.cpp
index 8f5d4387..fa18fd34 100644
--- a/sigmod/Item.cpp
+++ b/sigmod/Item.cpp
@@ -43,7 +43,6 @@ Item::Item(const Item& item) :
Item::Item(const Game* parent, const int id) :
Object(parent, id),
m_name(""),
- m_sellable(false),
m_type(-1),
m_price(0),
m_sellPrice(0),
@@ -73,8 +72,7 @@ void Item::validate()
emit(error("Name is empty"));
TEST(type);
TEST(price);
- if (m_sellable)
- TEST(sellPrice);
+ TEST(sellPrice);
TEST(weight);
TEST_END();
}
@@ -83,7 +81,6 @@ void Item::load(const QDomElement& xml)
{
LOAD_BEGIN();
LOAD(name);
- LOAD(sellable);
LOAD(type);
LOAD(price);
LOAD(sellPrice);
@@ -96,7 +93,6 @@ QDomElement Item::save() const
{
SAVE_CREATE();
SAVE(name);
- SAVE(sellable);
SAVE(type);
SAVE(price);
SAVE(sellPrice);
@@ -107,7 +103,6 @@ QDomElement Item::save() const
}
SETTER(Item, QString&, Name, name)
-SETTER(Item, bool, Sellable, sellable)
SETTER(Item, int, Type, type)
SETTER(Item, int, Price, price)
SETTER(Item, int, SellPrice, sellPrice)
@@ -116,7 +111,6 @@ SETTER(Item, QString&, Description, description)
SETTER(Item, Script&, Script, script)
GETTER(Item, QString, name)
-GETTER(Item, bool, sellable)
GETTER(Item, int, type)
GETTER(Item, int, price)
GETTER(Item, int, sellPrice)
@@ -125,10 +119,9 @@ GETTER(Item, QString, description)
GETTER(Item, Script, script)
CHECK(Item, QString&, name)
-CHECK(Item, bool, sellable)
CHECK_INDEX(Item, int, type, game(), itemType)
CHECK_BOUNDS(Item, int, price, 1, game()->rules()->maxMoney())
-CHECK_BOUNDS(Item, int, sellPrice, 0, m_price)
+CHECK_BOUNDS(Item, int, sellPrice, -1, m_price)
CHECK_BEGIN(Item, int, weight)
const ItemType* type = game()->itemTypeById(m_type);
if (type)
@@ -142,7 +135,6 @@ Item& Item::operator=(const Item& rhs)
if (this == &rhs)
return *this;
COPY(name);
- COPY(sellable);
COPY(type);
COPY(price);
COPY(sellPrice);
diff --git a/sigmod/Item.h b/sigmod/Item.h
index df477f10..905c81be 100644
--- a/sigmod/Item.h
+++ b/sigmod/Item.h
@@ -101,19 +101,13 @@ class SIGMOD_EXPORT Item : public Object
*/
void setName(const QString& name);
/**
- * Sets whether the item is can be sold or not. If set to \p true, the item can be sold at a \link Store store \endlink.
- *
- * \param sellable Whether the item can be sold or not.
- */
- void setSellable(const bool sellable);
- /**
* Sets the \link ItemType type \endlink of the item.
*
* \param type The id of the type the item is.
*/
void setType(const int type);
/**
- * Sets how much the item is sold for at a \link Store store \endlink.
+ * Sets how much the item is sold for at a \link Store store \endlink. If set to -1, it cannot be sold.
*
* \param price The price of the item.
*/
@@ -160,12 +154,6 @@ class SIGMOD_EXPORT Item : public Object
*/
QString name() const;
/**
- * \sa setSellable
- *
- * \return \p true if the item can be sold at a store, \p false otherwise.
- */
- bool sellable() const;
- /**
* \sa setType
*
* \return The id of the \link ItemType type \endlink of the item.
@@ -203,7 +191,6 @@ class SIGMOD_EXPORT Item : public Object
Sigcore::Script script() const;
bool nameCheck(const QString& name) const;
- bool sellableCheck(const bool sellable) const;
bool typeCheck(const int type) const;
bool priceCheck(const int price) const;
bool sellPriceCheck(const int sellPrice) const;
@@ -214,7 +201,6 @@ class SIGMOD_EXPORT Item : public Object
Item& operator=(const Item& rhs);
private:
QString m_name;
- bool m_sellable;
int m_type;
int m_price;
int m_sellPrice;
diff --git a/sigmodr/widgets/ItemUI.cpp b/sigmodr/widgets/ItemUI.cpp
index 492ed120..4be61c4d 100644
--- a/sigmodr/widgets/ItemUI.cpp
+++ b/sigmodr/widgets/ItemUI.cpp
@@ -33,9 +33,6 @@
#include <KIntNumInput>
#include <KLineEdit>
-// Qt includes
-#include <QtGui/QCheckBox>
-
// Standard includes
#include <climits>
@@ -79,7 +76,6 @@ QWidget* ItemUI::Private::makeWidgets(ObjectUI* widget)
{
QWidget *form = openUiFile(":/gui/item.ui", widget);
ui_name = form->findChild<KLineEdit*>("varName");
- ui_sellable = form->findChild<QCheckBox*>("varSellable");
ui_type = form->findChild<KComboBox*>("varType");
ui_price = form->findChild<KIntNumInput*>("varPrice");
ui_sellPrice = form->findChild<KIntNumInput*>("varSellPrice");
@@ -87,14 +83,12 @@ QWidget* ItemUI::Private::makeWidgets(ObjectUI* widget)
ui_description = form->findChild<KLineEdit*>("varDescription");
ui_script = form->findChild<ScriptWidget*>("varScript");
connect(ui_name, SIGNAL(textChanged(QString)), this, SLOT(nameChanged(QString)));
- connect(ui_sellable, SIGNAL(toggled(bool)), this, SLOT(sellableChanged(bool)));
connect(ui_type, SIGNAL(currentIndexChanged(int)), this, SLOT(typeChanged(int)));
connect(ui_price, SIGNAL(valueChanged(int)), this, SLOT(priceChanged(int)));
connect(ui_sellPrice, SIGNAL(valueChanged(int)), this, SLOT(sellPriceChanged(int)));
connect(ui_weight, SIGNAL(valueChanged(int)), this, SLOT(weightChanged(int)));
connect(ui_description, SIGNAL(textChanged(QString)), this, SLOT(descriptionChanged(QString)));
connect(ui_script, SIGNAL(valueChanged(Sigcore::Script)), this, SLOT(scriptChanged(Sigcore::Script)));
- ui_sellPrice->setEnabled(m_item->sellable());
if (0 <= m_item->type())
{
const ItemType* itemType = m_item->game()->itemType(m_item->type());
@@ -121,11 +115,9 @@ void ItemUI::Private::refreshGui()
void ItemUI::Private::resetGui()
{
ui_name->setText(m_item->name());
- ui_sellable->setCheckState(m_item->sellable() ? Qt::Checked : Qt::Unchecked);
ui_type->setCurrentIndex(m_item->game()->itemTypeIndex(m_item->type()));
ui_price->setValue(m_item->price());
ui_sellPrice->setValue(m_item->sellPrice());
- ui_sellPrice->setEnabled(m_item->sellable());
ui_weight->setValue(m_item->weight());
ui_description->setText(m_item->description());
ui_script->setValue(m_item->script());
@@ -138,12 +130,6 @@ void ItemUI::Private::nameChanged(const QString& name)
ui_name->setCursorPosition(cursor);
}
-void ItemUI::Private::sellableChanged(const bool sellable)
-{
- m_item->setSellable(sellable);
- ui_sellPrice->setEnabled(sellable);
-}
-
void ItemUI::Private::typeChanged(const int type)
{
if (0 <= type)
diff --git a/sigmodr/widgets/ItemUI_p.h b/sigmodr/widgets/ItemUI_p.h
index b86e4934..239fc240 100644
--- a/sigmodr/widgets/ItemUI_p.h
+++ b/sigmodr/widgets/ItemUI_p.h
@@ -28,7 +28,6 @@
class KComboBox;
class KIntNumInput;
class KLineEdit;
-class QCheckBox;
namespace Sigcore
{
class Script;
@@ -59,7 +58,6 @@ class SIGMODRWIDGETS_NO_EXPORT ItemUI::Private : public ObjectUIPrivate
void resetGui();
protected slots:
void nameChanged(const QString& name);
- void sellableChanged(const bool sellable);
void typeChanged(const int type);
void priceChanged(const int price);
void sellPriceChanged(const int sellPrice);
@@ -68,7 +66,6 @@ class SIGMODRWIDGETS_NO_EXPORT ItemUI::Private : public ObjectUIPrivate
void scriptChanged(const Sigcore::Script& script);
private:
KLineEdit* ui_name;
- QCheckBox* ui_sellable;
KComboBox* ui_type;
KIntNumInput* ui_price;
KIntNumInput* ui_sellPrice;
diff --git a/sigmodr/widgets/gui/item.ui b/sigmodr/widgets/gui/item.ui
index f3a1ad69..76459d0f 100644
--- a/sigmodr/widgets/gui/item.ui
+++ b/sigmodr/widgets/gui/item.ui
@@ -88,80 +88,50 @@
</widget>
</item>
<item row="3" column="0">
- <widget class="QLabel" name="labelSellable">
+ <widget class="QLabel" name="labelSellPrice">
+ <property name="sizePolicy">
+ <sizepolicy vsizetype="Minimum" hsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="text">
- <string>Selling:</string>
+ <string>Selling price:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignVCenter</set>
</property>
<property name="buddy">
- <cstring>varSellable</cstring>
+ <cstring>varSellPrice</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
- <widget class="QCheckBox" name="varSellable">
+ <widget class="KIntNumInput" name="varSellPrice">
+ <property name="sizePolicy">
+ <sizepolicy vsizetype="Fixed" hsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="toolTip">
- <string>Whether the item is sellable at a store or not</string>
+ <string>Amount received when item is sold</string>
</property>
<property name="statusTip">
- <string>Whether the item is sellable at a store or not</string>
+ <string>Amount received when item is sold</string>
</property>
<property name="whatsThis">
- <string>Whether the item is sellable at a store or not</string>
+ <string>Amount received when item is sold</string>
</property>
- <property name="text">
- <string>Can sell</string>
+ <property name="minimum">
+ <number>-1</number>
+ </property>
+ <property name="specialValueText">
+ <string>Cannot sell</string>
</property>
</widget>
</item>
- <item row="4" column="1">
- <layout class="QGridLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="labelSellPrice">
- <property name="sizePolicy">
- <sizepolicy vsizetype="Minimum" hsizetype="Minimum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Selling price:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignVCenter</set>
- </property>
- <property name="buddy">
- <cstring>varSellPrice</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KIntNumInput" name="varSellPrice">
- <property name="sizePolicy">
- <sizepolicy vsizetype="Fixed" hsizetype="Expanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="toolTip">
- <string>Amount received when item is sold</string>
- </property>
- <property name="statusTip">
- <string>Amount received when item is sold</string>
- </property>
- <property name="whatsThis">
- <string>Amount received when item is sold</string>
- </property>
- <property name="minimum">
- <number>0</number>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="5" column="0">
+ <item row="4" column="0">
<widget class="QLabel" name="labelWeight">
<property name="text">
<string>Weight:</string>
@@ -174,7 +144,7 @@
</property>
</widget>
</item>
- <item row="5" column="1">
+ <item row="4" column="1">
<widget class="KIntNumInput" name="varWeight">
<property name="toolTip">
<string>How much the item weighs</string>
@@ -190,7 +160,7 @@
</property>
</widget>
</item>
- <item row="6" column="0">
+ <item row="5" column="0">
<widget class="QLabel" name="labelDescription">
<property name="text">
<string>Description:</string>
@@ -203,7 +173,7 @@
</property>
</widget>
</item>
- <item row="6" column="1">
+ <item row="5" column="1">
<widget class="KLineEdit" name="varDescription">
<property name="toolTip">
<string>Description of the item</string>
@@ -219,7 +189,7 @@
</property>
</widget>
</item>
- <item row="7" column="0" colspan="2">
+ <item row="6" column="0" colspan="2">
<widget class="QGroupBox" name="boxScript">
<property name="title">
<string>Script</string>
@@ -269,7 +239,6 @@
<tabstop>varName</tabstop>
<tabstop>varType</tabstop>
<tabstop>varPrice</tabstop>
- <tabstop>varSellable</tabstop>
<tabstop>varSellPrice</tabstop>
<tabstop>varWeight</tabstop>
<tabstop>varDescription</tabstop>
diff --git a/sigscript/ItemWrapper.cpp b/sigscript/ItemWrapper.cpp
index ce1b9aa6..4f724d03 100644
--- a/sigscript/ItemWrapper.cpp
+++ b/sigscript/ItemWrapper.cpp
@@ -47,11 +47,6 @@ QString ItemWrapper::name() const
return m_item->name();
}
-bool ItemWrapper::sellable() const
-{
- return m_item->sellable();
-}
-
ItemTypeWrapper* ItemWrapper::type()
{
return game()->itemType(m_item->type());
diff --git a/sigscript/ItemWrapper.h b/sigscript/ItemWrapper.h
index 88903c0c..5008725d 100644
--- a/sigscript/ItemWrapper.h
+++ b/sigscript/ItemWrapper.h
@@ -42,7 +42,6 @@ class SIGSCRIPT_EXPORT ItemWrapper : public ObjectWrapper
static ItemWrapper* create(const Sigmod::Item* item, GameWrapper* parent);
Q_SCRIPTABLE QString name() const;
- Q_SCRIPTABLE bool sellable() const;
Q_SCRIPTABLE ItemTypeWrapper* type();
Q_SCRIPTABLE int price() const;
Q_SCRIPTABLE int sellPrice() const;