summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2025-03-07 22:26:53 +0100
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2025-03-07 22:27:48 +0100
commit36e61479d32809887aae6eb7f126e35dd32de4a5 (patch)
tree7998dba4f283b6d583a2e23f07bbe17c722d1031 /src
parentf5b0403c9d6231ea324932ba76b0cda77d9fcd8f (diff)
downloadmana-36e61479d32809887aae6eb7f126e35dd32de4a5.tar.gz
mana-36e61479d32809887aae6eb7f126e35dd32de4a5.tar.bz2
mana-36e61479d32809887aae6eb7f126e35dd32de4a5.tar.xz
mana-36e61479d32809887aae6eb7f126e35dd32de4a5.zip
Removed the functionality to split item stacks
No longer supported by manaserv and not supported by tmwAthena.
Diffstat (limited to 'src')
-rw-r--r--src/event.h1
-rw-r--r--src/gui/inventorywindow.cpp122
-rw-r--r--src/gui/inventorywindow.h32
-rw-r--r--src/gui/itemamountwindow.cpp6
-rw-r--r--src/gui/itemamountwindow.h3
-rw-r--r--src/gui/popupmenu.cpp10
-rw-r--r--src/net/inventoryhandler.h2
-rw-r--r--src/net/manaserv/generalhandler.cpp2
-rw-r--r--src/net/manaserv/inventoryhandler.cpp5
-rw-r--r--src/net/manaserv/inventoryhandler.h2
-rw-r--r--src/net/tmwa/generalhandler.cpp2
-rw-r--r--src/net/tmwa/inventoryhandler.cpp5
-rw-r--r--src/net/tmwa/inventoryhandler.h2
13 files changed, 30 insertions, 164 deletions
diff --git a/src/event.h b/src/event.h
index 612d77cb..06e38007 100644
--- a/src/event.h
+++ b/src/event.h
@@ -74,7 +74,6 @@ public:
DoDrop,
DoEquip,
DoMove,
- DoSplit,
DoUnequip,
DoUse,
End,
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 048f83f5..73a2522a 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -30,7 +30,6 @@
#include "gui/itemamountwindow.h"
#include "gui/setup.h"
-#include "gui/sdlinput.h"
#include "gui/viewport.h"
#include "gui/widgets/button.h"
@@ -40,9 +39,6 @@
#include "gui/widgets/progressbar.h"
#include "gui/widgets/scrollarea.h"
-#include "net/inventoryhandler.h"
-#include "net/net.h"
-
#include "resources/iteminfo.h"
#include "resources/theme.h"
@@ -105,7 +101,6 @@ InventoryWindow::InventoryWindow(Inventory *inventory):
mEquipButton = new Button(_("Equip"), "equip", this);
mUseButton = new Button(_("Activate"), "activate", this);
mDropButton = new Button(_("Drop..."), "drop", this);
- mSplitButton = new Button(_("Split"), "split", this);
mOutfitButton = new Button(_("Outfits"), "outfit", this);
mWeightLabel = new Label(_("Weight:"));
@@ -121,7 +116,6 @@ InventoryWindow::InventoryWindow(Inventory *inventory):
place(0, 3, mUseButton);
place(1, 3, mEquipButton);
place(3, 3, mDropButton);
- place(4, 3, mSplitButton);
place(7, 3, mOutfitButton);
updateWeight();
@@ -182,7 +176,6 @@ void InventoryWindow::action(const gcn::ActionEvent &event)
if (!inventoryWindow->isVisible()) return;
Item *item = inventoryWindow->getSelectedItem();
-
if (!item)
return;
@@ -190,12 +183,13 @@ void InventoryWindow::action(const gcn::ActionEvent &event)
}
Item *item = mItems->getSelectedItem();
-
if (!item)
return;
if (event.getId() == "activate")
+ {
item->doEvent(Event::DoUse);
+ }
else if (event.getId() == "equip")
{
if (item->isEquippable())
@@ -214,15 +208,9 @@ void InventoryWindow::action(const gcn::ActionEvent &event)
{
ItemAmountWindow::showWindow(ItemAmountWindow::ItemDrop, this, item);
}
- else if (event.getId() == "split")
- {
- ItemAmountWindow::showWindow(ItemAmountWindow::ItemSplit, this, item,
- (item->getQuantity() - 1));
- }
else if (event.getId() == "retrieve")
{
Item *item = mItems->getSelectedItem();
-
if (!item)
return;
@@ -247,26 +235,27 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
Window::mouseClicked(event);
Item *item = mItems->getSelectedItem();
+ if (!item)
+ return;
- if (event.getSource() == mItems && item && isDoubleClick(item->getInvIndex()))
+ if (event.getSource() == mItems && isDoubleClick(item->getInvIndex())
+ && isMainInventory())
{
- if (isMainInventory() && item->getInfo().activatable)
+ if (item->getInfo().activatable)
{
action(gcn::ActionEvent(mUseButton,
mUseButton->getActionEventId()));
}
- else if (isMainInventory() && item->isEquippable())
+ else if (item->isEquippable())
{
action(gcn::ActionEvent(mEquipButton,
mEquipButton->getActionEventId()));
}
+ return;
}
if (event.getButton() == gcn::MouseEvent::RIGHT)
{
- if (!item)
- return;
-
/* Convert relative to the window coordinates to absolute screen
* coordinates.
*/
@@ -279,10 +268,6 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
{
if (instances.size() > 1 && keyboard.isKeyActive(KeyboardConfig::KEY_EMOTE))
{
- Item *item = mItems->getSelectedItem();
-
- if(!item)
- return;
if (mInventory->isMainInventory())
{
Event event(Event::DoMove);
@@ -305,32 +290,10 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
}
}
-void InventoryWindow::keyPressed(gcn::KeyEvent &event)
-{
- switch (event.getKey().getValue())
- {
- case Key::LEFT_SHIFT:
- case Key::RIGHT_SHIFT:
- mSplit = true;
- break;
- }
-}
-
void InventoryWindow::keyReleased(gcn::KeyEvent &event)
{
if (isInputFocused())
- {
mItems->setFilter(mFilterText->getText());
- return;
- }
-
- switch (event.getKey().getValue())
- {
- case Key::LEFT_SHIFT:
- case Key::RIGHT_SHIFT:
- mSplit = false;
- break;
- }
}
void InventoryWindow::valueChanged(const gcn::SelectionEvent &event)
@@ -338,15 +301,6 @@ void InventoryWindow::valueChanged(const gcn::SelectionEvent &event)
if (!mInventory->isMainInventory())
return;
- Item *item = mItems->getSelectedItem();
-
- if (mSplit && Net::getInventoryHandler()->
- canSplit(mItems->getSelectedItem()) && item)
- {
- ItemAmountWindow::showWindow(ItemAmountWindow::ItemSplit, this, item,
- (item->getQuantity() - 1));
- }
-
updateButtons();
}
@@ -359,44 +313,19 @@ void InventoryWindow::updateButtons()
mUseButton->setEnabled(false);
mEquipButton->setEnabled(false);
mDropButton->setEnabled(false);
- mSplitButton->setEnabled(false);
-
return;
}
mDropButton->setEnabled(true);
- if (item->isEquippable())
- {
- if (item->isEquipped())
- mEquipButton->setCaption(_("Unequip"));
- else
- mEquipButton->setCaption(_("Equip"));
- mEquipButton->setEnabled(true);
- }
- else
- mEquipButton->setEnabled(false);
-
+ mEquipButton->setCaption(item->isEquipped() ? _("Unequip") : _("Equip"));
+ mEquipButton->setEnabled(item->isEquippable());
mEquipButton->adjustSize();
mUseButton->setEnabled(item->getInfo().activatable);
- if (item->getQuantity() > 1)
- mDropButton->setCaption(_("Drop..."));
- else
- mDropButton->setCaption(_("Drop"));
-
- if (Net::getInventoryHandler()->canSplit(item))
- mSplitButton->setEnabled(true);
- else
- mSplitButton->setEnabled(false);
-
- mSplitButton->adjustSize();
-}
-
-void InventoryWindow::setSplitAllowed(bool allowed)
-{
- mSplitButton->setVisible(allowed);
+ mDropButton->setCaption(item->getQuantity() > 1 ? _("Drop...") : _("Drop"));
+ mDropButton->adjustSize();
}
void InventoryWindow::close()
@@ -418,12 +347,9 @@ void InventoryWindow::event(Event::Channel channel, const Event &event)
{
if (event.getType() == Event::UpdateAttribute)
{
- int id = event.getInt("id");
- if (id == TOTAL_WEIGHT ||
- id == MAX_WEIGHT)
- {
+ const int id = event.getInt("id");
+ if (id == TOTAL_WEIGHT || id == MAX_WEIGHT)
updateWeight();
- }
}
}
@@ -432,8 +358,8 @@ void InventoryWindow::updateWeight()
if (!isMainInventory())
return;
- int total = PlayerInfo::getAttribute(TOTAL_WEIGHT);
- int max = PlayerInfo::getAttribute(MAX_WEIGHT);
+ const int total = PlayerInfo::getAttribute(TOTAL_WEIGHT);
+ const int max = PlayerInfo::getAttribute(MAX_WEIGHT);
if (max <= 0)
return;
@@ -451,21 +377,14 @@ bool InventoryWindow::isInputFocused() const
bool InventoryWindow::isAnyInputFocused()
{
- auto it = instances.begin();
- auto it_end = instances.end();
-
- for (; it != it_end; it++)
- {
- if ((*it)->isInputFocused())
- {
+ for (auto instance : instances)
+ if (instance->isInputFocused())
return true;
- }
- }
return false;
}
-void InventoryWindow::slotsChanged(Inventory* inventory)
+void InventoryWindow::slotsChanged(Inventory *inventory)
{
if (inventory == mInventory)
{
@@ -473,7 +392,6 @@ void InventoryWindow::slotsChanged(Inventory* inventory)
const int maxSlots = mInventory->getSize();
mSlotsBar->setProgress((float) usedSlots / maxSlots);
-
mSlotsBar->setText(strprintf("%d/%d", usedSlots, maxSlots));
}
}
diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h
index 2bd6fe65..267d8dc1 100644
--- a/src/gui/inventorywindow.h
+++ b/src/gui/inventorywindow.h
@@ -27,8 +27,6 @@
#include "gui/widgets/window.h"
#include "gui/widgets/textfield.h"
-#include "net/inventoryhandler.h"
-
#include <guichan/actionlistener.hpp>
#include <guichan/keylistener.hpp>
#include <guichan/selectionlistener.hpp>
@@ -43,12 +41,12 @@ class TextBox;
*
* \ingroup Interface
*/
-class InventoryWindow : public Window,
- public gcn::ActionListener,
- public gcn::KeyListener,
- public gcn::SelectionListener,
- public InventoryListener,
- public EventListener
+class InventoryWindow final : public Window,
+ public gcn::ActionListener,
+ public gcn::KeyListener,
+ public gcn::SelectionListener,
+ public InventoryListener,
+ public EventListener
{
public:
InventoryWindow(Inventory *inventory);
@@ -63,7 +61,7 @@ class InventoryWindow : public Window,
/**
* Returns the selected item.
*/
- Item* getSelectedItem() const;
+ Item *getSelectedItem() const;
/**
* Handles closing of the window
@@ -76,11 +74,6 @@ class InventoryWindow : public Window,
void mouseClicked(gcn::MouseEvent &event) override;
/**
- * Handles the key presses.
- */
- void keyPressed(gcn::KeyEvent &event) override;
-
- /**
* Handles the key releases.
*/
void keyReleased(gcn::KeyEvent &event) override;
@@ -91,11 +84,6 @@ class InventoryWindow : public Window,
void valueChanged(const gcn::SelectionEvent &event) override;
/**
- * Sets whether the split button should be shown.
- */
- void setSplitAllowed(bool allowed);
-
- /**
* Closes the Storage Window, as well as telling the server that the
* window has been closed.
*/
@@ -110,7 +98,7 @@ class InventoryWindow : public Window,
static bool isAnyInputFocused();
- void slotsChanged(Inventory* inventory) override;
+ void slotsChanged(Inventory *inventory) override;
bool isMainInventory() const { return mInventory->isMainInventory(); }
@@ -133,14 +121,12 @@ class InventoryWindow : public Window,
std::string mWeight, mSlots;
- gcn::Button *mUseButton, *mEquipButton, *mDropButton, *mSplitButton,
+ gcn::Button *mUseButton, *mEquipButton, *mDropButton,
*mOutfitButton, *mStoreButton, *mRetrieveButton;
gcn::Label *mWeightLabel, *mSlotsLabel, *mFilterLabel;
ProgressBar *mWeightBar, *mSlotsBar;
-
- bool mSplit = false;
};
extern InventoryWindow *inventoryWindow;
diff --git a/src/gui/itemamountwindow.cpp b/src/gui/itemamountwindow.cpp
index 947b5bdc..da5dc073 100644
--- a/src/gui/itemamountwindow.cpp
+++ b/src/gui/itemamountwindow.cpp
@@ -49,9 +49,6 @@ void ItemAmountWindow::finish(Item *item, int amount, Usage usage)
case ItemDrop:
item->doEvent(Event::DoDrop, amount);
break;
- case ItemSplit:
- item->doEvent(Event::DoSplit, amount);
- break;
case StoreAdd:
{
Event event(Event::DoMove);
@@ -148,9 +145,6 @@ ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item,
case StoreRemove:
setCaption(_("Select amount of items to retrieve."));
break;
- case ItemSplit:
- setCaption(_("Select amount of items to split."));
- break;
}
setLocationRelativeTo(getParentWindow());
diff --git a/src/gui/itemamountwindow.h b/src/gui/itemamountwindow.h
index 3b73bb7b..489fdbef 100644
--- a/src/gui/itemamountwindow.h
+++ b/src/gui/itemamountwindow.h
@@ -32,7 +32,7 @@ class ItemPopup;
class Icon;
/**
- * Window used for selecting the amount of items to drop, trade or split.
+ * Window used for selecting the amount of items to drop, trade or store.
*
* \ingroup Interface
*/
@@ -46,7 +46,6 @@ class ItemAmountWindow : public Window,
ItemDrop,
StoreAdd,
StoreRemove,
- ItemSplit
};
/**
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 5c240fd6..64f4d753 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -285,11 +285,6 @@ void PopupMenu::handleLink(const std::string &link)
else if (mFloorItem)
chatWindow->addItemText(mFloorItem->getInfo().name);
}
- else if (link == "split")
- {
- ItemAmountWindow::showWindow(ItemAmountWindow::ItemSplit,
- inventoryWindow, mItem);
- }
else if (link == "drop")
{
ItemAmountWindow::showWindow(ItemAmountWindow::ItemDrop,
@@ -365,11 +360,6 @@ void PopupMenu::showPopup(Window *parent, int x, int y, Item *item,
else
mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop")));
}
-
- if (Net::getInventoryHandler()->canSplit(item))
- {
- mBrowserBox->addRow(strprintf("@@split|%s@@", _("Split")));
- }
}
// Assume in storage for now
// TODO: make this whole system more flexible, if needed
diff --git a/src/net/inventoryhandler.h b/src/net/inventoryhandler.h
index 6e501eb0..323dec6c 100644
--- a/src/net/inventoryhandler.h
+++ b/src/net/inventoryhandler.h
@@ -66,8 +66,6 @@ class InventoryHandler
public:
virtual ~InventoryHandler() {}
- virtual bool canSplit(const Item *item) = 0;
-
// TODO: fix/remove me
virtual size_t getSize(int type) const = 0;
diff --git a/src/net/manaserv/generalhandler.cpp b/src/net/manaserv/generalhandler.cpp
index 7f5f5081..32141c29 100644
--- a/src/net/manaserv/generalhandler.cpp
+++ b/src/net/manaserv/generalhandler.cpp
@@ -23,7 +23,6 @@
#include "client.h"
-#include "gui/inventorywindow.h"
#include "gui/skilldialog.h"
#include "net/manaserv/adminhandler.h"
@@ -183,7 +182,6 @@ void GeneralHandler::event(Event::Channel channel,
{
if (event.getType() == Event::GuiWindowsLoaded)
{
- inventoryWindow->setSplitAllowed(false);
skillDialog->loadSkills();
PlayerInfo::setAttribute(EXP_NEEDED, 100);
diff --git a/src/net/manaserv/inventoryhandler.cpp b/src/net/manaserv/inventoryhandler.cpp
index 219e4350..e1dc5dea 100644
--- a/src/net/manaserv/inventoryhandler.cpp
+++ b/src/net/manaserv/inventoryhandler.cpp
@@ -347,11 +347,6 @@ void InventoryHandler::event(Event::Channel channel,
}
}
-bool InventoryHandler::canSplit(const Item *item)
-{
- return false;
-}
-
size_t InventoryHandler::getSize(int type) const
{
switch (type)
diff --git a/src/net/manaserv/inventoryhandler.h b/src/net/manaserv/inventoryhandler.h
index 2b6c98fe..02ce90df 100644
--- a/src/net/manaserv/inventoryhandler.h
+++ b/src/net/manaserv/inventoryhandler.h
@@ -109,8 +109,6 @@ class InventoryHandler final : public MessageHandler, Net::InventoryHandler,
void event(Event::Channel channel, const Event &event) override;
- bool canSplit(const Item *item) override;
-
size_t getSize(int type) const override;
bool isWeaponSlot(unsigned int slotTypeId) const override
diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp
index 2cf7d30f..d6eb3b34 100644
--- a/src/net/tmwa/generalhandler.cpp
+++ b/src/net/tmwa/generalhandler.cpp
@@ -25,7 +25,6 @@
#include "configuration.h"
#include "log.h"
-#include "gui/inventorywindow.h"
#include "gui/skilldialog.h"
#include "gui/socialwindow.h"
#include "gui/statuswindow.h"
@@ -214,7 +213,6 @@ void GeneralHandler::event(Event::Channel channel,
{
if (event.getType() == Event::GuiWindowsLoaded)
{
- inventoryWindow->setSplitAllowed(false);
skillDialog->loadSkills();
statusWindow->addAttribute(STRENGTH, _("Strength"), true, "");
diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp
index 496ce621..0d8e3005 100644
--- a/src/net/tmwa/inventoryhandler.cpp
+++ b/src/net/tmwa/inventoryhandler.cpp
@@ -521,11 +521,6 @@ void InventoryHandler::event(Event::Channel channel,
}
}
-bool InventoryHandler::canSplit(const Item *item)
-{
- return false;
-}
-
size_t InventoryHandler::getSize(int type) const
{
switch (type)
diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h
index ce8231bd..47226bea 100644
--- a/src/net/tmwa/inventoryhandler.h
+++ b/src/net/tmwa/inventoryhandler.h
@@ -165,8 +165,6 @@ class InventoryHandler final : public MessageHandler, public Net::InventoryHandl
void event(Event::Channel channel, const Event &event) override;
- bool canSplit(const Item *item) override;
-
size_t getSize(int type) const override;
// Note the slot type id is equal to the slot Index for tA.