summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/beingpopup.cpp4
-rw-r--r--src/gui/beingpopup.h6
-rw-r--r--src/gui/equipmentwindow.cpp2
-rw-r--r--src/gui/inventorywindow.cpp7
-rw-r--r--src/gui/itemamount.cpp4
-rw-r--r--src/gui/palette.cpp1
-rw-r--r--src/gui/palette.h1
-rw-r--r--src/gui/popupmenu.cpp10
-rw-r--r--src/gui/popupmenu.h6
-rw-r--r--src/gui/recorder.cpp2
-rw-r--r--src/gui/setup_colors.cpp1
-rw-r--r--src/gui/socialwindow.cpp4
-rw-r--r--src/gui/storagewindow.cpp29
-rw-r--r--src/gui/storagewindow.h26
-rw-r--r--src/gui/viewport.cpp5
-rw-r--r--src/gui/viewport.h6
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp2
-rw-r--r--src/gui/widgets/textfield.cpp16
-rw-r--r--src/gui/widgets/textfield.h2
19 files changed, 91 insertions, 43 deletions
diff --git a/src/gui/beingpopup.cpp b/src/gui/beingpopup.cpp
index 3d60589f..7fd99371 100644
--- a/src/gui/beingpopup.cpp
+++ b/src/gui/beingpopup.cpp
@@ -38,14 +38,14 @@
BeingPopup::BeingPopup():
Popup("BeingPopup")
{
- // Item Name
+ // Being Name
mBeingName = new TextBox();
mBeingName->setFont(boldFont);
mBeingName->setPosition(getPadding(), getPadding());
const int fontHeight = getFont()->getHeight();
- // Item Description
+ // Being's party
mBeingParty = new TextBox();
mBeingParty->setPosition(getPadding(), fontHeight);
diff --git a/src/gui/beingpopup.h b/src/gui/beingpopup.h
index b803aacf..078b84d9 100644
--- a/src/gui/beingpopup.h
+++ b/src/gui/beingpopup.h
@@ -29,18 +29,18 @@ class Player;
class TextBox;
/**
- * A popup that displays information about an item.
+ * A popup that displays information about a being.
*/
class BeingPopup : public Popup
{
public:
/**
- * Constructor. Initializes the item popup.
+ * Constructor. Initializes the being popup.
*/
BeingPopup();
/**
- * Destructor. Cleans up the item popup on deletion.
+ * Destructor. Cleans up the being popup on deletion.
*/
~BeingPopup();
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index 4400c9f5..581fd818 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -207,7 +207,7 @@ void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent)
*/
const int mx = x + getX();
const int my = y + getY();
- viewport->showPopup(mx, my, item, true);
+ viewport->showPopup(this, mx, my, item, true);
}
}
}
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 9c5f138e..ed008e63 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -220,19 +220,20 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
*/
const int mx = event.getX() + getX();
const int my = event.getY() + getY();
- viewport->showPopup(mx, my, item);
+ viewport->showPopup(this, mx, my, item);
}
if (event.getButton() == gcn::MouseEvent::LEFT)
{
- if (storageWindow && keyboard.isKeyActive(keyboard.KEY_EMOTE))
+ if (StorageWindow::isActive() &&
+ keyboard.isKeyActive(keyboard.KEY_EMOTE))
{
Item *item = mItems->getSelectedItem();
if(!item)
return;
- storageWindow->addStore(item, item->getQuantity());
+ StorageWindow::addStore(item, item->getQuantity());
}
}
}
diff --git a/src/gui/itemamount.cpp b/src/gui/itemamount.cpp
index c4c38a9d..1dc5425f 100644
--- a/src/gui/itemamount.cpp
+++ b/src/gui/itemamount.cpp
@@ -54,10 +54,10 @@ void ItemAmountWindow::finish(Item *item, int amount, Usage usage)
Net::getInventoryHandler()->splitItem(item, amount);
break;
case StoreAdd:
- storageWindow->addStore(item, amount);
+ StorageWindow::addStore(item, amount);
break;
case StoreRemove:
- storageWindow->removeStore(item, amount);
+ StorageWindow::removeStore(item, amount);
break;
default:
break;
diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp
index e7c49c89..d2309399 100644
--- a/src/gui/palette.cpp
+++ b/src/gui/palette.cpp
@@ -99,6 +99,7 @@ Palette::Palette() :
addColor(WHISPER, 0x00feaf, STATIC, indent + _("Whisper"), 'W');
addColor(IS, 0xa08527, STATIC, indent + _("Is"), 'I');
addColor(PARTY, 0xf48055, STATIC, indent + _("Party"), 'P');
+ addColor(GUILD, 0xf48055, STATIC, indent + _("Guild"), 'U');
addColor(SERVER, 0x8415e2, STATIC, indent + _("Server"), 'S');
addColor(LOGGER, 0x919191, STATIC, indent + _("Logger"), 'L');
addColor(HYPERLINK, 0xe50d0d, STATIC, indent + _("Hyperlink"), '<');
diff --git a/src/gui/palette.h b/src/gui/palette.h
index e353f318..0c1d2df0 100644
--- a/src/gui/palette.h
+++ b/src/gui/palette.h
@@ -71,6 +71,7 @@ class Palette : public gcn::ListModel
ENTRY(WHISPER)\
ENTRY(IS)\
ENTRY(PARTY)\
+ ENTRY(GUILD)\
ENTRY(SERVER)\
ENTRY(LOGGER)\
ENTRY(HYPERLINK)\
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index e9c71496..7e4bfd65 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -320,8 +320,8 @@ void PopupMenu::handleLink(const std::string &link)
else if (link == "retrieve")
{
- ItemAmountWindow::showWindow(ItemAmountWindow::StoreRemove,
- storageWindow, mItem);
+ ItemAmountWindow::showWindow(ItemAmountWindow::StoreRemove, mWindow,
+ mItem);
}
else if (link == "party" && being && being->getType() == Being::PLAYER)
@@ -356,10 +356,12 @@ void PopupMenu::handleLink(const std::string &link)
mItem = NULL;
}
-void PopupMenu::showPopup(int x, int y, Item *item, bool isInventory)
+void PopupMenu::showPopup(Window *parent, int x, int y, Item *item,
+ bool isInventory)
{
assert(item);
mItem = item;
+ mWindow = parent;
mBrowserBox->clearRows();
if (isInventory)
@@ -384,7 +386,7 @@ void PopupMenu::showPopup(int x, int y, Item *item, bool isInventory)
mBrowserBox->addRow(strprintf("@@split|%s@@", _("Split")));
}
- if (player_node->getInStorage())
+ if (StorageWindow::isActive())
{
mBrowserBox->addRow(strprintf("@@store|%s@@", _("Store")));
}
diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h
index 3299694f..3bb49967 100644
--- a/src/gui/popupmenu.h
+++ b/src/gui/popupmenu.h
@@ -29,6 +29,7 @@ class Being;
class BrowserBox;
class FloorItem;
class Item;
+class Window;
/**
* Window showing popup menu.
@@ -56,7 +57,8 @@ class PopupMenu : public Popup, public LinkHandler
* Shows the related popup menu when right click on the inventory
* at the specified mouse coordinates.
*/
- void showPopup(int x, int y, Item *item, bool isInventory);
+ void showPopup(Window *parent, int x, int y, Item *item,
+ bool isInventory);
/**
* Handles link action.
@@ -70,6 +72,8 @@ class PopupMenu : public Popup, public LinkHandler
FloorItem* mFloorItem;
Item *mItem;
+ Window *mWindow;
+
/**
* Shared code for the various showPopup functions.
*/
diff --git a/src/gui/recorder.cpp b/src/gui/recorder.cpp
index 7cb6e055..257afd7f 100644
--- a/src/gui/recorder.cpp
+++ b/src/gui/recorder.cpp
@@ -102,7 +102,7 @@ void Recorder::setRecordingFile(const std::string &msg)
* recorded.
*/
localChatTab->chatLog(_("Starting to record..."), BY_SERVER);
- const std::string file = Client::getHomeDirectory() + msgCopy;
+ const std::string file = Client::getLocalDataDirectory() + "/" + msgCopy;
mStream.open(file.c_str(), std::ios_base::trunc);
diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp
index c476e971..bc86e362 100644
--- a/src/gui/setup_colors.cpp
+++ b/src/gui/setup_colors.cpp
@@ -300,6 +300,7 @@ void Setup_Colors::valueChanged(const gcn::SelectionEvent &event)
case Palette::WHISPER:
case Palette::IS:
case Palette::PARTY:
+ case Palette::GUILD:
case Palette::SERVER:
case Palette::LOGGER:
case Palette::HYPERLINK:
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index 48019bd0..26184cae 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -98,6 +98,8 @@ public:
{
setCaption(guild->getName());
+ setTabColor(&guiPalette->getColor(Palette::GUILD));
+
mList = new AvatarListBox(guild);
mScroll = new ScrollArea(mList);
@@ -161,6 +163,8 @@ public:
{
setCaption(party->getName());
+ setTabColor(&guiPalette->getColor(Palette::PARTY));
+
mList = new AvatarListBox(party);
mScroll = new ScrollArea(mList);
diff --git a/src/gui/storagewindow.cpp b/src/gui/storagewindow.cpp
index ff0ba162..bf54afb9 100644
--- a/src/gui/storagewindow.cpp
+++ b/src/gui/storagewindow.cpp
@@ -52,9 +52,11 @@
#include <string>
-StorageWindow::StorageWindow(int invSize):
+StorageWindow::WindowList StorageWindow::instances;
+
+StorageWindow::StorageWindow(Inventory *inventory):
Window(_("Storage")),
- mMaxSlots(invSize),
+ mInventory(inventory),
mItemDesc(false)
{
setWindowName("Storage");
@@ -70,19 +72,19 @@ StorageWindow::StorageWindow(int invSize):
mCloseButton = new Button(_("Close"), "close", this);
- mItems = new ItemContainer(player_node->getStorage(), true);
+ mItems = new ItemContainer(mInventory, true);
mItems->addSelectionListener(this);
gcn::ScrollArea *invenScroll = new ScrollArea(mItems);
invenScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- mUsedSlots = player_node->getStorage()->getNumberOfSlotsUsed();
+ mUsedSlots = mInventory->getNumberOfSlotsUsed();
mSlotsLabel = new Label(_("Slots:"));
mSlotsBar = new ProgressBar(0.0f, 100, 20, gcn::Color(225, 200, 25));
- mSlotsBar->setText(strprintf("%d/%d", mUsedSlots, mMaxSlots));
- mSlotsBar->setProgress((float) mUsedSlots / mMaxSlots);
+ mSlotsBar->setText(strprintf("%d/%d", mUsedSlots, mInventory->getSize()));
+ mSlotsBar->setProgress((float) mUsedSlots / mInventory->getSize());
setMinHeight(130);
setMinWidth(200);
@@ -98,10 +100,14 @@ StorageWindow::StorageWindow(int invSize):
layout.setRowHeight(0, mStoreButton->getHeight());
loadWindowState();
+
+ instances.push_back(this);
+ setVisible(true);
}
StorageWindow::~StorageWindow()
{
+ instances.remove(this);
}
void StorageWindow::logic()
@@ -111,15 +117,16 @@ void StorageWindow::logic()
Window::logic();
- const int usedSlots = player_node->getStorage()->getNumberOfSlotsUsed();
+ const int usedSlots = mInventory->getNumberOfSlotsUsed();
if (mUsedSlots != usedSlots)
{
mUsedSlots = usedSlots;
- mSlotsBar->setProgress((float) mUsedSlots / mMaxSlots);
+ mSlotsBar->setProgress((float) mUsedSlots / mInventory->getSize());
- mSlotsBar->setText(strprintf("%d/%d", mUsedSlots, mMaxSlots));
+ mSlotsBar->setText(strprintf("%d/%d", mUsedSlots,
+ mInventory->getSize()));
}
}
@@ -173,7 +180,7 @@ void StorageWindow::mouseClicked(gcn::MouseEvent &event)
*/
const int mx = event.getX() + getX();
const int my = event.getY() + getY();
- viewport->showPopup(mx, my, item, false);
+ viewport->showPopup(this, mx, my, item, false);
}
if (event.getButton() == gcn::MouseEvent::LEFT)
{
@@ -211,4 +218,6 @@ void StorageWindow::removeStore(Item *item, int amount)
void StorageWindow::close()
{
Net::getInventoryHandler()->closeStorage(Net::InventoryHandler::STORAGE);
+
+ scheduleDelete();
}
diff --git a/src/gui/storagewindow.h b/src/gui/storagewindow.h
index 766f2b1a..046b7613 100644
--- a/src/gui/storagewindow.h
+++ b/src/gui/storagewindow.h
@@ -49,8 +49,7 @@ class StorageWindow : public Window, gcn::ActionListener,
/**
* Constructor.
*/
- StorageWindow(int invSize = Net::getInventoryHandler()
- ->getSize(Net::InventoryHandler::STORAGE));
+ StorageWindow(Inventory *inventory);
/**
* Destructor.
@@ -75,22 +74,31 @@ class StorageWindow : public Window, gcn::ActionListener,
void mouseClicked(gcn::MouseEvent &event);
/**
+ * Closes the Storage Window, as well as telling the server that the
+ * window has been closed.
+ */
+ void close();
+
+ /**
* Add the specified ammount of the specified item to storage
*/
- void addStore(Item* item, int amount);
+ static void addStore(Item* item, int amount);
/**
* Remove the specified ammount of the specified item from storage
*/
- void removeStore(Item* item, int amount);
+ static void removeStore(Item* item, int amount);
/**
- * Closes the Storage Window, as well as telling the server that the
- * window has been closed.
+ * Returns true if any instances exist.
*/
- void close();
+ static bool isActive() { return instances.size() > 0; }
private:
+ typedef std::list<StorageWindow*> WindowList;
+ static WindowList instances;
+
+ Inventory *mInventory;
ItemContainer *mItems;
int mSlots;
@@ -101,11 +109,7 @@ class StorageWindow : public Window, gcn::ActionListener,
ProgressBar *mSlotsBar;
- int mMaxSlots;
-
bool mItemDesc;
};
-extern StorageWindow *storageWindow;
-
#endif // STORAGEWINDOW_H
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 48f19b9a..763d0c43 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -449,9 +449,10 @@ void Viewport::mouseReleased(gcn::MouseEvent &event)
mLocalWalkTime = -1;
}
-void Viewport::showPopup(int x, int y, Item *item, bool isInventory)
+void Viewport::showPopup(Window *parent, int x, int y, Item *item,
+ bool isInventory)
{
- mPopupMenu->showPopup(x, y, item, isInventory);
+ mPopupMenu->showPopup(parent, x, y, item, isInventory);
}
void Viewport::closePopupMenu()
diff --git a/src/gui/viewport.h b/src/gui/viewport.h
index 9a64ff78..5b92d950 100644
--- a/src/gui/viewport.h
+++ b/src/gui/viewport.h
@@ -30,13 +30,14 @@
#include <guichan/mouselistener.hpp>
class Being;
+class BeingPopup;
class FloorItem;
class Graphics;
class ImageSet;
class Item;
class Map;
class PopupMenu;
-class BeingPopup;
+class Window;
/** Delay between two mouse calls when dragging mouse and move the player */
const int walkingMouseDelay = 500;
@@ -107,7 +108,8 @@ class Viewport : public WindowContainer, public gcn::MouseListener,
* Shows a popup for an item.
* TODO Find some way to get rid of Item here
*/
- void showPopup(int x, int y, Item *item, bool isInventory = true);
+ void showPopup(Window *parent, int x, int y, Item *item,
+ bool isInventory = true);
/**
* Closes the popup menu. Needed for when the player dies or switching
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index b2ddcf0c..66e053d8 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -193,7 +193,7 @@ void ItemShortcutContainer::mousePressed(gcn::MouseEvent &event)
// Convert relative to the window coordinates to absolute screen
// coordinates.
- viewport->showPopup(viewport->getMouseX(), viewport->getMouseY(), item);
+ viewport->showPopup(NULL, viewport->getMouseX(), viewport->getMouseY(), item);
}
}
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index 803de396..278b4cb9 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -31,6 +31,7 @@
#include "resources/image.h"
#include "resources/resourcemanager.h"
+#include "utils/copynpaste.h"
#include "utils/dtor.h"
#include <guichan/font.hpp>
@@ -250,8 +251,23 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent)
if (mLoseFocusOnTab)
return;
break;
+
+ case 22: // Control code 22, SYNCHRONOUS IDLE, sent on Ctrl+v
+ handlePaste();
+ break;
}
keyEvent.consume();
fixScroll();
}
+
+void TextField::handlePaste()
+{
+ std::string text = getText();
+ std::string::size_type caretPos = getCaretPosition();
+
+ if (RetrieveBuffer(text, caretPos)) {
+ setText(text);
+ setCaretPosition(caretPos);
+ }
+}
diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h
index c66139cd..58e37f5c 100644
--- a/src/gui/widgets/textfield.h
+++ b/src/gui/widgets/textfield.h
@@ -91,6 +91,8 @@ class TextField : public gcn::TextField
int getValue() const;
private:
+ void handlePaste();
+
static int instances;
static float mAlpha;
static ImageRect skin;