summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorYohann Ferreira <bertram@cegetel.net>2005-08-26 18:43:35 +0000
committerYohann Ferreira <bertram@cegetel.net>2005-08-26 18:43:35 +0000
commit9414243208a48a0c6603251e2b6dfc2a96dfd71c (patch)
treeec0584c868afecfd6f82694b34804773f6a90d04 /src/gui
parentd4f310480146a8dd5417e6988ddc25a40e560ff3 (diff)
downloadmana-9414243208a48a0c6603251e2b6dfc2a96dfd71c.tar.gz
mana-9414243208a48a0c6603251e2b6dfc2a96dfd71c.tar.bz2
mana-9414243208a48a0c6603251e2b6dfc2a96dfd71c.tar.xz
mana-9414243208a48a0c6603251e2b6dfc2a96dfd71c.zip
Added effect description to buy/see/inventory, made some improvements and bugfixes, too.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/buy.cpp50
-rw-r--r--src/gui/buy.h2
-rw-r--r--src/gui/inventorywindow.cpp24
-rw-r--r--src/gui/inventorywindow.h1
-rw-r--r--src/gui/sell.cpp51
-rw-r--r--src/gui/sell.h7
6 files changed, 99 insertions, 36 deletions
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp
index 60cc22c0..926f478e 100644
--- a/src/gui/buy.cpp
+++ b/src/gui/buy.cpp
@@ -49,15 +49,15 @@ BuyDialog::BuyDialog():
scrollArea = new ScrollArea(itemList);
slider = new Slider(1.0);
quantityLabel = new gcn::Label("0");
- moneyLabel = new gcn::Label("price : 0 G");
+ moneyLabel = new gcn::Label("Price: 0 GP");
increaseButton = new Button("+");
decreaseButton = new Button("-");
buyButton = new Button("Buy");
quitButton = new Button("Quit");
- itemNameLabel = new gcn::Label("Name:");
itemDescLabel = new gcn::Label("Description:");
+ itemEffectLabel = new gcn::Label("Effect:");
- setContentSize(260, 198);
+ setContentSize(260, 210);
scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
scrollArea->setDimension(gcn::Rectangle(5, 5, 250, 110));
itemList->setDimension(gcn::Rectangle(5, 5, 238, 110));
@@ -66,23 +66,23 @@ BuyDialog::BuyDialog():
slider->setEnabled(false);
quantityLabel->setPosition(215, 120);
- moneyLabel->setPosition(5, 133);
+ moneyLabel->setPosition(5, 130);
- increaseButton->setPosition(40, 174);
+ increaseButton->setPosition(40, 186);
increaseButton->setSize(20, 20);
increaseButton->setEnabled(false);
- decreaseButton->setPosition(10, 174);
+ decreaseButton->setPosition(10, 186);
decreaseButton->setSize(20, 20);
decreaseButton->setEnabled(false);
- buyButton->setPosition(180, 174);
+ buyButton->setPosition(180, 186);
buyButton->setEnabled(false);
- quitButton->setPosition(212, 174);
+ quitButton->setPosition(212, 186);
- itemNameLabel->setDimension(gcn::Rectangle(5, 145, 240, 14));
- itemDescLabel->setDimension(gcn::Rectangle(5, 157, 240, 14));
+ itemEffectLabel->setDimension(gcn::Rectangle(5, 150, 240, 14));
+ itemDescLabel->setDimension(gcn::Rectangle(5, 169, 240, 14));
itemList->setEventId("item");
slider->setEventId("slider");
@@ -102,13 +102,13 @@ BuyDialog::BuyDialog():
add(scrollArea);
add(slider);
add(quantityLabel);
- add(moneyLabel);
add(buyButton);
add(quitButton);
add(increaseButton);
add(decreaseButton);
- add(itemNameLabel);
+ add(moneyLabel);
add(itemDescLabel);
+ add(itemEffectLabel);
setLocationRelativeTo(getParent());
}
@@ -119,32 +119,38 @@ BuyDialog::~BuyDialog()
delete decreaseButton;
delete quitButton;
delete buyButton;
- delete moneyLabel;
delete slider;
delete itemList;
delete scrollArea;
- delete itemNameLabel;
+ delete moneyLabel;
+ delete quantityLabel;
delete itemDescLabel;
+ delete itemEffectLabel;
}
void BuyDialog::setMoney(int amount)
{
m_money = amount;
- //std::stringstream ss;
- //ss << m_money << " G";
- //moneyLabel->setCaption(ss.str());
- //moneyLabel->adjustSize();
}
void BuyDialog::reset()
{
shopInventory.clear();
m_money = 0;
+ slider->setValue(0.0);
+ m_amountItems = 0;
// Reset Previous Selected Items to prevent failing asserts
itemList->setSelected(-1);
increaseButton->setEnabled(false);
decreaseButton->setEnabled(false);
+ quantityLabel->setCaption("0");
+ quantityLabel->adjustSize();
+ moneyLabel->setCaption("Price: 0");
+ moneyLabel->adjustSize();
+ itemDescLabel->setCaption("");
+ itemEffectLabel->setCaption("");
+
}
void BuyDialog::addItem(short id, int price)
@@ -171,7 +177,7 @@ void BuyDialog::action(const std::string& eventId)
slider->setValue(0);
quantityLabel->setCaption("0");
quantityLabel->adjustSize();
- moneyLabel->setCaption("price : 0 GP");
+ moneyLabel->setCaption("Price : 0 GP");
moneyLabel->adjustSize();
// Disable buttons for buying and decreasing
@@ -266,7 +272,7 @@ void BuyDialog::action(const std::string& eventId)
quantityLabel->adjustSize();
oss.str("");
- oss << "price : " << m_amountItems * shopInventory[selectedItem].price << " G";
+ oss << "Price : " << m_amountItems * shopInventory[selectedItem].price << " GP";
moneyLabel->setCaption(oss.str());
moneyLabel->adjustSize();
}
@@ -280,10 +286,10 @@ void BuyDialog::mouseClick(int x, int y, int button, int count)
int selectedItem = itemList->getSelected();
if (selectedItem > -1)
{
- itemNameLabel->setCaption("Name: " +
- itemDb->getItemInfo(shopInventory[selectedItem].id)->getName());
itemDescLabel->setCaption("Description: " +
itemDb->getItemInfo(shopInventory[selectedItem].id)->getDescription());
+ itemEffectLabel->setCaption("Effect: " +
+ itemDb->getItemInfo(shopInventory[selectedItem].id)->getEffect());
}
}
diff --git a/src/gui/buy.h b/src/gui/buy.h
index 92221a45..d66a720a 100644
--- a/src/gui/buy.h
+++ b/src/gui/buy.h
@@ -98,8 +98,8 @@ class BuyDialog : public Window, public gcn::ActionListener,
gcn::Button *decreaseButton;
gcn::ListBox *itemList;
gcn::ScrollArea *scrollArea;
- gcn::Label *itemNameLabel;
gcn::Label *itemDescLabel;
+ gcn::Label *itemEffectLabel;
gcn::Label *moneyLabel;
gcn::Label *quantityLabel;
gcn::Slider *slider;
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index b55fe645..9ed6bb75 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -24,6 +24,7 @@
#include "inventorywindow.h"
#include <string>
+#include <sstream>
#include <guichan/widgets/label.hpp>
@@ -42,7 +43,7 @@
InventoryWindow::InventoryWindow():
Window("Inventory")
{
- setContentSize(322, 160);
+ setContentSize(322, 172);
useButton = new Button("Use");
dropButton = new Button("Drop");
@@ -58,6 +59,7 @@ InventoryWindow::InventoryWindow():
itemNameLabel = new gcn::Label("Name:");
itemDescriptionLabel = new gcn::Label("Description:");
+ itemEffectLabel = new gcn::Label("Effect:");
weightLabel = new gcn::Label("Total Weight: - Maximum Weight: ");
weightLabel->setPosition(8, 8);
invenScroll->setPosition(8,
@@ -68,11 +70,12 @@ InventoryWindow::InventoryWindow():
add(invenScroll);
add(itemNameLabel);
add(itemDescriptionLabel);
+ add(itemEffectLabel);
add(weightLabel);
setResizable(true);
setMinWidth(240);
- setMinHeight(150);
+ setMinHeight(172);
updateWidgets();
useButton->setSize(48, useButton->getHeight());
@@ -86,6 +89,7 @@ InventoryWindow::~InventoryWindow()
delete items;
delete itemNameLabel;
delete itemDescriptionLabel;
+ delete itemEffectLabel;
delete weightLabel;
}
@@ -98,10 +102,9 @@ void InventoryWindow::logic()
updateButtons();
// Update weight information
- char tempstr[128];
- sprintf(tempstr, "Total Weight: %2i - Maximum Weight: %2i",
- char_info->totalWeight, char_info->maxWeight);
- weightLabel->setCaption(tempstr);
+ std::stringstream tempstr;
+ tempstr << "Total Weight: " << char_info->totalWeight << " - Maximum Weight: " << char_info->maxWeight;
+ weightLabel->setCaption(tempstr.str());
weightLabel->adjustSize();
}
@@ -148,6 +151,9 @@ void InventoryWindow::mouseClick(int x, int y, int button, int count)
SomeText = "Name: " + item->getInfo()->getName();
itemNameLabel->setCaption(SomeText);
itemNameLabel->adjustSize();
+ SomeText = "Effect: " + item->getInfo()->getEffect();
+ itemEffectLabel->setCaption(SomeText);
+ itemEffectLabel->adjustSize();
SomeText = "Description: " + item->getInfo()->getDescription();
itemDescriptionLabel->setCaption(SomeText);
itemDescriptionLabel->adjustSize();
@@ -187,12 +193,14 @@ void InventoryWindow::updateWidgets()
// Resize widgets
useButton->setPosition(8, height - 24);
dropButton->setPosition(48 + 16, height - 24);
- invenScroll->setSize(width - 16, height - 90);
+ invenScroll->setSize(width - 16, height - 110);
itemNameLabel->setPosition(8,
invenScroll->getY() + invenScroll->getHeight() + 4);
- itemDescriptionLabel->setPosition(8,
+ itemEffectLabel->setPosition(8,
itemNameLabel->getY() + itemNameLabel->getHeight() + 4);
+ itemDescriptionLabel->setPosition(8,
+ itemEffectLabel->getY() + itemEffectLabel->getHeight() + 4);
}
void InventoryWindow::updateButtons()
diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h
index 7d86d1aa..cec4aa15 100644
--- a/src/gui/inventorywindow.h
+++ b/src/gui/inventorywindow.h
@@ -75,6 +75,7 @@ class InventoryWindow : public Window, gcn::ActionListener
gcn::ScrollArea *invenScroll;
gcn::Label *itemNameLabel;
gcn::Label *itemDescriptionLabel;
+ gcn::Label *itemEffectLabel;
gcn::Label *weightLabel;
};
diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp
index ac40b22c..784f38b6 100644
--- a/src/gui/sell.cpp
+++ b/src/gui/sell.cpp
@@ -38,6 +38,7 @@
#include "../item.h"
#include "../resources/iteminfo.h"
+#include "../resources/itemmanager.h"
#include "../net/network.h"
@@ -50,13 +51,16 @@ SellDialog::SellDialog():
scrollArea = new ScrollArea(itemList);
slider = new Slider(1.0);
quantityLabel = new gcn::Label("0");
+ moneyLabel = new gcn::Label("Price: 0");
+ itemDescLabel = new gcn::Label("Description:");
+ itemEffectLabel = new gcn::Label("Effect:");
increaseButton = new Button("+");
decreaseButton = new Button("-");
sellButton = new Button("Sell");
quitButton = new Button("Quit");
sellButton->setEnabled(false);
- setContentSize(260, 175);
+ setContentSize(260, 210);
scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
scrollArea->setDimension(gcn::Rectangle(5, 5, 250, 110));
itemList->setDimension(gcn::Rectangle(5, 5, 238, 110));
@@ -66,18 +70,22 @@ SellDialog::SellDialog():
quantityLabel->setPosition(215, 120);
- increaseButton->setPosition(40, 145);
+ increaseButton->setPosition(40, 186);
increaseButton->setSize(20, 20);
increaseButton->setEnabled(false);
- decreaseButton->setPosition(10, 145);
+ decreaseButton->setPosition(10, 186);
decreaseButton->setSize(20, 20);
decreaseButton->setEnabled(false);
- sellButton->setPosition(175, 145);
+ moneyLabel->setPosition(5, 130);
+ itemEffectLabel->setDimension(gcn::Rectangle(5, 150, 240, 14));
+ itemDescLabel->setDimension(gcn::Rectangle(5, 169, 240, 14));
+
+ sellButton->setPosition(175, 186);
sellButton->setEnabled(false);
- quitButton->setPosition(208, 145);
+ quitButton->setPosition(208, 186);
itemList->setEventId("item");
slider->setEventId("slider");
@@ -96,6 +104,9 @@ SellDialog::SellDialog():
add(scrollArea);
add(slider);
add(quantityLabel);
+ add(moneyLabel);
+ add(itemEffectLabel);
+ add(itemDescLabel);
add(increaseButton);
add(decreaseButton);
add(sellButton);
@@ -113,6 +124,10 @@ SellDialog::~SellDialog()
delete slider;
delete itemList;
delete scrollArea;
+ delete quantityLabel;
+ delete moneyLabel;
+ delete itemDescLabel;
+ delete itemEffectLabel;
}
void SellDialog::reset()
@@ -120,8 +135,13 @@ void SellDialog::reset()
shopInventory.clear();
slider->setValue(0.0);
m_amountItems = 0;
+
quantityLabel->setCaption("0");
quantityLabel->adjustSize();
+ moneyLabel->setCaption("Price: 0");
+ moneyLabel->adjustSize();
+ itemDescLabel->setCaption("");
+ itemEffectLabel->setCaption("");
// Reset Previous Selected Items to prevent failing asserts
itemList->setSelected(-1);
@@ -161,6 +181,8 @@ void SellDialog::action(const std::string& eventId)
quantityLabel->setCaption("0");
quantityLabel->adjustSize();
+ moneyLabel->setCaption("Price: 0");
+ moneyLabel->adjustSize();
if (selectedItem > -1) {
slider->setEnabled(true);
@@ -236,6 +258,10 @@ void SellDialog::action(const std::string& eventId)
oss << m_amountItems;
quantityLabel->setCaption(oss.str());
quantityLabel->adjustSize();
+ oss.str("");
+ oss << "Price: " << m_amountItems * shopInventory[selectedItem].price;
+ moneyLabel->setCaption(oss.str());
+ moneyLabel->adjustSize();
// Update Buttons
sellButton->setEnabled(m_amountItems > 0);
@@ -244,6 +270,21 @@ void SellDialog::action(const std::string& eventId)
}
}
+void SellDialog::mouseClick(int x, int y, int button, int count)
+{
+ Window::mouseClick(x, y, button, count);
+
+// shopInventory[selectedItem];
+ int selectedItem = itemList->getSelected();
+ if (selectedItem > -1)
+ {
+ itemDescLabel->setCaption("Description: " +
+ itemDb->getItemInfo(shopInventory[selectedItem].id)->getDescription());
+ itemEffectLabel->setCaption("Effect: " +
+ itemDb->getItemInfo(shopInventory[selectedItem].id)->getEffect());
+ }
+}
+
int SellDialog::getNumberOfElements()
{
return shopInventory.size();
diff --git a/src/gui/sell.h b/src/gui/sell.h
index 5cf5479e..864c5f63 100644
--- a/src/gui/sell.h
+++ b/src/gui/sell.h
@@ -79,6 +79,11 @@ class SellDialog : public Window, public gcn::ActionListener,
int getNumberOfElements();
/**
+ * Mouse callback
+ */
+ void mouseClick(int x, int y, int buton, int count);
+
+ /**
* Returns the name of item number i in the inventory.
*/
std::string getElementAt(int i);
@@ -91,6 +96,8 @@ class SellDialog : public Window, public gcn::ActionListener,
gcn::ListBox *itemList;
gcn::ScrollArea *scrollArea;
gcn::Label *moneyLabel;
+ gcn::Label *itemDescLabel;
+ gcn::Label *itemEffectLabel;
gcn::Label *quantityLabel;
gcn::Slider *slider;