summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/inventorywindow.cpp2
-rw-r--r--src/gui/trade.cpp13
-rw-r--r--src/gui/trade.h13
3 files changed, 15 insertions, 13 deletions
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 3b786f62..5227152c 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -53,7 +53,7 @@ InventoryWindow::InventoryWindow():
useButton = new Button("Use");
dropButton = new Button("Drop");
- items = new ItemContainer(player_node->mInventory);
+ items = new ItemContainer(player_node->mInventory.get());
invenScroll = new ScrollArea(items);
invenScroll->setPosition(8, 8);
invenScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp
index f7286fd2..9d10774b 100644
--- a/src/gui/trade.cpp
+++ b/src/gui/trade.cpp
@@ -45,7 +45,9 @@
TradeWindow::TradeWindow(Network *network):
Window("Trade: You"),
- mNetwork(network)
+ mNetwork(network),
+ myInventory(new Inventory()),
+ partnerInventory(new Inventory())
{
setContentSize(322, 150);
@@ -54,16 +56,13 @@ TradeWindow::TradeWindow(Network *network):
cancelButton = new Button("Cancel");
tradeButton = new Button("Trade");
- myInventory = new Inventory();
- partnerInventory = new Inventory();
-
- myItemContainer = new ItemContainer(myInventory);
+ myItemContainer = new ItemContainer(myInventory.get());
myItemContainer->setPosition(2, 2);
myScroll = new ScrollArea(myItemContainer);
myScroll->setPosition(8, 8);
- partnerItemContainer = new ItemContainer(partnerInventory);
+ partnerItemContainer = new ItemContainer(partnerInventory.get());
partnerItemContainer->setPosition(2, 58);
partnerScroll = new ScrollArea(partnerItemContainer);
@@ -137,8 +136,6 @@ TradeWindow::TradeWindow(Network *network):
TradeWindow::~TradeWindow()
{
- delete myInventory;
- delete partnerInventory;
}
void TradeWindow::addMoney(int amount)
diff --git a/src/gui/trade.h b/src/gui/trade.h
index d95cd9ce..3d6eef53 100644
--- a/src/gui/trade.h
+++ b/src/gui/trade.h
@@ -24,6 +24,8 @@
#ifndef _TMW_TRADE_H
#define _TMW_TRADE_H
+#include <memory>
+
#include <guichan/actionlistener.hpp>
#include "window.h"
@@ -110,13 +112,16 @@ class TradeWindow : public Window, gcn::ActionListener
*/
void action(const std::string& eventId);
- Inventory *myInventory;
- Inventory *partnerInventory;
+ private:
+ Network *mNetwork;
+
+ typedef std::auto_ptr<Inventory> InventoryPtr;
+ InventoryPtr myInventory;
+ InventoryPtr partnerInventory;
+
ItemContainer *myItemContainer;
ItemContainer *partnerItemContainer;
- private:
- Network *mNetwork;
gcn::Label *itemNameLabel;
gcn::Label *itemDescriptionLabel;
gcn::Label *moneyLabel;