summaryrefslogtreecommitdiffstats
path: root/sigmodr/ItemUI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sigmodr/ItemUI.cpp')
-rw-r--r--sigmodr/ItemUI.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/sigmodr/ItemUI.cpp b/sigmodr/ItemUI.cpp
index 41207c14..337181db 100644
--- a/sigmodr/ItemUI.cpp
+++ b/sigmodr/ItemUI.cpp
@@ -25,7 +25,8 @@
#include "../sigmod/Sigmod.h"
Sigmodr::ItemUI::ItemUI(Sigmod::Item* item, QWidget* parent) :
- ObjectUI(parent)
+ ObjectUI(parent),
+ m_lastType(-1)
{
setupUi(this);
setObjects(item, new Sigmod::Item(*item));
@@ -48,10 +49,20 @@ void Sigmodr::ItemUI::refreshGui()
void Sigmodr::ItemUI::setGui()
{
+ const bool resetWeight = (qobject_cast<Sigmod::Item*>(modified())->type() != m_lastType);
varName->setText(qobject_cast<Sigmod::Item*>(modified())->name());
boxSellable->setChecked(qobject_cast<Sigmod::Item*>(modified())->sellable() ? Qt::Checked : Qt::Unchecked);
varType->setCurrentIndex(varType->findData(qobject_cast<Sigmod::Item*>(modified())->type()));
+ m_lastType = qobject_cast<Sigmod::Item*>(modified())->type();
varPrice->setValue(qobject_cast<Sigmod::Item*>(modified())->price());
+ varSellPrice->setValue(qobject_cast<Sigmod::Item*>(modified())->sellPrice());
+ if (resetWeight)
+ {
+ const int itemTypeIndex = sigmod()->itemTypeIndex(qobject_cast<Sigmod::Item*>(modified())->type());
+ if (itemTypeIndex != INT_MAX)
+ varWeight->setMaximum(sigmod()->itemType(itemTypeIndex)->maxWeight());
+ }
+ varWeight->setValue(qobject_cast<Sigmod::Item*>(modified())->weight());
varDescription->setText(qobject_cast<Sigmod::Item*>(modified())->description());
varScript->setValue(qobject_cast<Sigmod::Item*>(modified())->script());
}
@@ -91,6 +102,16 @@ void Sigmodr::ItemUI::on_varPrice_valueChanged(const int price)
qobject_cast<Sigmod::Item*>(modified())->setPrice(price);
}
+void Sigmodr::ItemUI::on_varSellPrice_valueChanged(const int sellPrice)
+{
+ qobject_cast<Sigmod::Item*>(modified())->setSellPrice(sellPrice);
+}
+
+void Sigmodr::ItemUI::on_varWeight_valueChanged(const int weight)
+{
+ qobject_cast<Sigmod::Item*>(modified())->setWeight(weight);
+}
+
void Sigmodr::ItemUI::on_varDescription_textChanged(const QString& description)
{
qobject_cast<Sigmod::Item*>(modified())->setDescription(description);