summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2006-03-09 01:20:48 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2006-03-09 01:20:48 +0000
commit78ab0ec914d3c5a97f162905afb3dede53f8b9ed (patch)
tree53e386c28d5621535c76c35c20f28b7dd6235ee3 /src/gui
parent3bd2abeeffe9fb9b23293975b159ee2ddc868e5b (diff)
downloadmana-78ab0ec914d3c5a97f162905afb3dede53f8b9ed.tar.gz
mana-78ab0ec914d3c5a97f162905afb3dede53f8b9ed.tar.bz2
mana-78ab0ec914d3c5a97f162905afb3dede53f8b9ed.tar.xz
mana-78ab0ec914d3c5a97f162905afb3dede53f8b9ed.zip
Use std::auto_ptr in some places.
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;