summaryrefslogtreecommitdiff
path: root/src/gui/shortcut
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/shortcut')
-rw-r--r--src/gui/shortcut/dropshortcut.cpp171
-rw-r--r--src/gui/shortcut/dropshortcut.h69
-rw-r--r--src/gui/shortcut/emoteshortcut.cpp115
-rw-r--r--src/gui/shortcut/emoteshortcut.h133
-rw-r--r--src/gui/shortcut/itemshortcut.cpp289
-rw-r--r--src/gui/shortcut/itemshortcut.h183
-rw-r--r--src/gui/shortcut/shortcutbase.cpp128
-rw-r--r--src/gui/shortcut/shortcutbase.h141
-rw-r--r--src/gui/shortcut/spellshortcut.cpp63
-rw-r--r--src/gui/shortcut/spellshortcut.h88
10 files changed, 0 insertions, 1380 deletions
diff --git a/src/gui/shortcut/dropshortcut.cpp b/src/gui/shortcut/dropshortcut.cpp
deleted file mode 100644
index f9876ebee..000000000
--- a/src/gui/shortcut/dropshortcut.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "gui/shortcut/dropshortcut.h"
-
-#include "settings.h"
-
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-
-#include "resources/inventory/inventory.h"
-
-#include "resources/item/item.h"
-
-#include "net/packetlimiter.h"
-
-#include "debug.h"
-
-static const int DROP_SHORTCUT_ITEMS = 16;
-
-DropShortcut *dropShortcut = nullptr;
-
-DropShortcut::DropShortcut() :
- ShortcutBase("drop", "dropColor", DROP_SHORTCUT_ITEMS),
- mLastDropIndex(0)
-{
- clear(false);
- load();
-}
-
-DropShortcut::~DropShortcut()
-{
-}
-
-void DropShortcut::dropFirst() const
-{
- if (localPlayer == nullptr)
- return;
-
- if (!PacketLimiter::limitPackets(PacketType::PACKET_DROP))
- return;
-
- const int itemId = getItem(0);
- const ItemColor itemColor = getItemColor(0);
- if (PlayerInfo::isItemProtected(itemId))
- return;
-
- if (itemId > 0)
- {
- const Item *const item = PlayerInfo::getInventory()
- ->findItem(itemId, itemColor);
- if ((item != nullptr) && (item->getQuantity() != 0))
- {
- const int cnt = settings.quickDropCounter;
- if (localPlayer->isServerBuggy())
- {
- PlayerInfo::dropItem(item, cnt, Sfx_true);
- }
- else
- {
- for (int i = 0; i < cnt; i++)
- PlayerInfo::dropItem(item, 1, Sfx_false);
- }
- }
- }
-}
-
-void DropShortcut::dropItems(const int cnt)
-{
- if (localPlayer == nullptr)
- return;
-
- if (localPlayer->isServerBuggy())
- {
- dropItem(settings.quickDropCounter);
- return;
- }
-
- int n = 0;
- const int sz = settings.quickDropCounter;
- for (int f = 0; f < 9; f++)
- {
- for (int i = 0; i < sz; i++)
- {
- if (!PacketLimiter::limitPackets(PacketType::PACKET_DROP))
- return;
- if (dropItem())
- n++;
- }
- if (n >= cnt)
- break;
- }
-}
-
-bool DropShortcut::dropItem(const int cnt)
-{
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- return false;
-
- int itemId = 0;
- ItemColor itemColor = ItemColor_one;
- while (mLastDropIndex < DROP_SHORTCUT_ITEMS &&
- itemId < 1)
- {
- if (!PlayerInfo::isItemProtected(itemId))
- {
- itemId = getItem(mLastDropIndex);
- itemColor = getItemColor(mLastDropIndex);
- }
- mLastDropIndex ++;
- }
-
- if (itemId > 0)
- {
- const Item *const item = inv->findItem(itemId, itemColor);
- if ((item != nullptr) &&
- item->getQuantity() > 0)
- {
- PlayerInfo::dropItem(item, cnt, Sfx_true);
- return true;
- }
- }
- if (mLastDropIndex >= DROP_SHORTCUT_ITEMS)
- mLastDropIndex = 0;
-
- if (itemId < 1)
- {
- while (mLastDropIndex < DROP_SHORTCUT_ITEMS &&
- itemId < 1)
- {
- if (!PlayerInfo::isItemProtected(itemId))
- {
- itemId = getItem(mLastDropIndex);
- itemColor = getItemColor(mLastDropIndex);
- }
- mLastDropIndex++;
- }
- if (itemId > 0)
- {
- const Item *const item = inv->findItem(itemId, itemColor);
- if ((item != nullptr) && item->getQuantity() > 0)
- {
- PlayerInfo::dropItem(item, cnt, Sfx_true);
- return true;
- }
- }
- if (mLastDropIndex >= DROP_SHORTCUT_ITEMS)
- mLastDropIndex = 0;
- }
- return false;
-}
diff --git a/src/gui/shortcut/dropshortcut.h b/src/gui/shortcut/dropshortcut.h
deleted file mode 100644
index b3993b96e..000000000
--- a/src/gui/shortcut/dropshortcut.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef GUI_SHORTCUT_DROPSHORTCUT_H
-#define GUI_SHORTCUT_DROPSHORTCUT_H
-
-#include "gui/shortcut/shortcutbase.h"
-
-#include "localconsts.h"
-
-/**
- * The class which keeps track of the item shortcuts.
- */
-class DropShortcut final : public ShortcutBase
-{
- public:
- /**
- * Constructor.
- */
- DropShortcut();
-
- A_DELETE_COPY(DropShortcut)
-
- /**
- * Destructor.
- */
- ~DropShortcut();
-
- /**
- * Drop first item.
- */
- void dropFirst() const;
-
- /**
- * Drop all items in cicle.
- */
- void dropItems(const int cnt = 1);
-
- private:
- /**
- * Drop item in cicle.
- */
- bool dropItem(const int cnt = 1);
-
- int mLastDropIndex;
-};
-
-extern DropShortcut *dropShortcut;
-
-#endif // GUI_SHORTCUT_DROPSHORTCUT_H
diff --git a/src/gui/shortcut/emoteshortcut.cpp b/src/gui/shortcut/emoteshortcut.cpp
deleted file mode 100644
index 8131a11a2..000000000
--- a/src/gui/shortcut/emoteshortcut.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 Aethyra Development Team
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "gui/shortcut/emoteshortcut.h"
-
-#include "configuration.h"
-#include "settings.h"
-
-#include "being/localplayer.h"
-
-#include "net/homunculushandler.h"
-#include "net/mercenaryhandler.h"
-#include "net/pethandler.h"
-
-#include "resources/db/emotedb.h"
-
-#include "debug.h"
-
-EmoteShortcut *emoteShortcut = nullptr;
-
-EmoteShortcut::EmoteShortcut() :
- mEmoteSelected(0)
-{
- for (int i = 0; i < SHORTCUT_EMOTES; i++)
- mEmotes[i] = 0;
-}
-
-EmoteShortcut::~EmoteShortcut()
-{
- save();
-}
-
-void EmoteShortcut::load()
-{
- for (unsigned char i = 0, j = 0,
- fsz = CAST_U8(EmoteDB::getLast());
- i <= fsz && j < SHORTCUT_EMOTES;
- i++)
- {
- const EmoteSprite *const sprite = EmoteDB::getSprite(i, true);
- if (sprite != nullptr)
- {
- mEmotes[j] = CAST_U8(i + 1);
- j ++;
- }
- }
-}
-
-void EmoteShortcut::save() const
-{
- for (int i = 0; i < SHORTCUT_EMOTES; i++)
- {
- const unsigned char emoteId = mEmotes[i] != 0u ? mEmotes[i]
- : CAST_U8(0);
- serverConfig.setValue("emoteshortcut" + toString(i),
- CAST_U32(emoteId));
- }
-}
-
-void EmoteShortcut::useEmotePlayer(const size_t index) const
-{
- if (index <= CAST_SIZE(SHORTCUT_EMOTES))
- {
- if (mEmotes[index - 1] > 0)
- LocalPlayer::emote(mEmotes[index - 1]);
- }
-}
-
-void EmoteShortcut::useEmote(const size_t index) const
-{
- if (localPlayer == nullptr)
- return;
-
- if (index <= CAST_SIZE(SHORTCUT_EMOTES))
- {
- if (mEmotes[index - 1] > 0)
- {
- const uint8_t emote = mEmotes[index - 1];
- switch (settings.emoteType)
- {
- case EmoteType::Player:
- default:
- LocalPlayer::emote(emote);
- break;
- case EmoteType::Pet:
- petHandler->emote(emote);
- break;
- case EmoteType::Homunculus:
- homunculusHandler->emote(emote);
- break;
- case EmoteType::Mercenary:
- mercenaryHandler->emote(emote);
- break;
- }
- }
- }
-}
diff --git a/src/gui/shortcut/emoteshortcut.h b/src/gui/shortcut/emoteshortcut.h
deleted file mode 100644
index 2ecc2c1b7..000000000
--- a/src/gui/shortcut/emoteshortcut.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 Aethyra Development Team
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef GUI_SHORTCUT_EMOTESHORTCUT_H
-#define GUI_SHORTCUT_EMOTESHORTCUT_H
-
-#include "const/emoteshortcut.h"
-
-#include "utils/cast.h"
-
-#include "localconsts.h"
-
-/**
- * The class which keeps track of the emote shortcuts.
- */
-class EmoteShortcut final
-{
- public:
- /**
- * Constructor.
- */
- EmoteShortcut();
-
- A_DELETE_COPY(EmoteShortcut)
-
- /**
- * Destructor.
- */
- ~EmoteShortcut();
-
- /**
- * Load the configuration information.
- */
- void load();
-
- /**
- * Returns the shortcut Emote ID specified by the index.
- *
- * @param index Index of the shortcut Emote.
- */
- unsigned char getEmote(const size_t index) const A_WARN_UNUSED
- { return mEmotes[index]; }
-
- /**
- * Returns the amount of shortcut Emotes.
- */
- static unsigned int getEmoteCount() A_WARN_UNUSED
- { return SHORTCUT_EMOTES; }
-
- /**
- * Returns the emote ID that is currently selected.
- */
- unsigned char getEmoteSelected() const noexcept2 A_WARN_UNUSED
- { return mEmoteSelected; }
-
- /**
- * Adds the selected emote ID to the emotes specified by the index.
- *
- * @param index Index of the emotes.
- */
- void setEmote(const size_t index)
- { mEmotes[index] = mEmoteSelected; }
-
- /**
- * Adds a emoticon to the emotes store specified by the index.
- *
- * @param index Index of the emote.
- * @param emoteId ID of the emote.
- */
- void setEmotes(const size_t index,
- const unsigned char emoteId)
- { mEmotes[index] = emoteId; }
-
- /**
- * Set the Emote that is selected.
- *
- * @param emoteId The ID of the emote that is to be assigned.
- */
- void setEmoteSelected(const unsigned char emoteId)
- { mEmoteSelected = emoteId; }
-
- /**
- * A flag to check if the Emote is selected.
- */
- bool isEmoteSelected() const noexcept2 A_WARN_UNUSED
- { return mEmoteSelected != 0u; }
-
- /**
- * Remove a Emote from the shortcut.
- */
- void removeEmote(const size_t index)
- { if (index < CAST_SIZE(SHORTCUT_EMOTES)) mEmotes[index] = 0; }
-
- /**
- * Try to use the Emote specified by the index.
- *
- * @param index Index of the emote shortcut.
- */
- void useEmote(const size_t index) const;
-
- void useEmotePlayer(const size_t index) const;
-
- private:
- /**
- * Save the configuration information.
- */
- void save() const;
-
- unsigned char mEmotes[SHORTCUT_EMOTES]; // The emote stored.
- unsigned char mEmoteSelected; // The emote held by cursor.
-};
-
-extern EmoteShortcut *emoteShortcut;
-
-#endif // GUI_SHORTCUT_EMOTESHORTCUT_H
diff --git a/src/gui/shortcut/itemshortcut.cpp b/src/gui/shortcut/itemshortcut.cpp
deleted file mode 100644
index f47bfd296..000000000
--- a/src/gui/shortcut/itemshortcut.cpp
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "gui/shortcut/itemshortcut.h"
-
-#include "configuration.h"
-#include "spellmanager.h"
-
-#include "being/playerinfo.h"
-
-#include "const/spells.h"
-
-#include "const/resources/skill.h"
-
-#include "gui/windows/skilldialog.h"
-
-#include "resources/inventory/inventory.h"
-
-#include "resources/item/item.h"
-
-#include "debug.h"
-
-ItemShortcut *itemShortcut[SHORTCUT_TABS];
-
-ItemShortcut::ItemShortcut(const size_t number) :
- mItems(),
- mItemColors(),
- mItemData(),
- mNumber(number),
- mItemSelected(-1),
- mItemColorSelected(ItemColor_one)
-{
- load();
-}
-
-ItemShortcut::~ItemShortcut()
-{
- logger->log1("ItemShortcut::~ItemShortcut");
-}
-
-void ItemShortcut::load()
-{
- std::string name;
- std::string color;
- std::string data;
- if (mNumber == SHORTCUT_AUTO_TAB)
- return;
-
- const Configuration *cfg = &serverConfig;
- if (mNumber != 0)
- {
- name = std::string("shortcut").append(
- toString(CAST_S32(mNumber))).append("_");
- color = std::string("shortcutColor").append(
- toString(CAST_U32(mNumber))).append("_");
- data = std::string("shortcutData").append(
- toString(CAST_U32(mNumber))).append("_");
- }
- else
- {
- name = "shortcut";
- color = "shortcutColor";
- data = "shortcutData";
- }
- for (unsigned int i = 0; i < SHORTCUT_ITEMS; i++)
- {
- const int itemId = cfg->getValue(name + toString(i), -1);
- const ItemColor itemColor = fromInt(
- cfg->getValue(color + toString(i), 1),
- ItemColor);
-
- mItems[i] = itemId;
- mItemColors[i] = itemColor;
- mItemData[i] = cfg->getValue(data + toString(i), std::string());
- }
-}
-
-void ItemShortcut::save() const
-{
- std::string name;
- std::string color;
- std::string data;
- if (mNumber == SHORTCUT_AUTO_TAB)
- return;
- if (mNumber != 0)
- {
- name = std::string("shortcut").append(
- toString(CAST_S32(mNumber))).append("_");
- color = std::string("shortcutColor").append(
- toString(CAST_U32(mNumber))).append("_");
- data = std::string("shortcutData").append(
- toString(CAST_U32(mNumber))).append("_");
- }
- else
- {
- name = "shortcut";
- color = "shortcutColor";
- data = "shortcutData";
- }
-
- for (unsigned int i = 0; i < SHORTCUT_ITEMS; i++)
- {
- const int itemId = mItems[i] != 0 ? mItems[i] : -1;
- const int itemColor = toInt(mItemColors[i], int);
- if (itemId != -1)
- {
- const std::string itemData = mItemData[i];
- serverConfig.setValue(name + toString(i), itemId);
- serverConfig.setValue(color + toString(i), itemColor);
- serverConfig.setValue(data + toString(i), itemData);
- }
- else
- {
- serverConfig.deleteKey(name + toString(i));
- serverConfig.deleteKey(color + toString(i));
- serverConfig.deleteKey(data + toString(i));
- }
- }
-}
-
-void ItemShortcut::clear()
-{
- for (size_t i = 0; i < SHORTCUT_ITEMS; i++)
- {
- mItems[i] = 0;
- mItemColors[i] = ItemColor_zero;
- mItemData[i].clear();
- }
-}
-
-void ItemShortcut::useItem(const size_t index) const
-{
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- return;
-
- const int itemId = mItems[index];
- const ItemColor itemColor = mItemColors[index];
- if (itemId >= 0)
- {
- if (itemId < SPELL_MIN_ID)
- {
- const Item *const item = inv->findItem(itemId, itemColor);
- if (item != nullptr && item->getQuantity() != 0)
- PlayerInfo::useEquipItem(item, 0, Sfx_true);
- }
- else if (itemId < SKILL_MIN_ID && (spellManager != nullptr))
- {
- spellManager->useItem(itemId);
- }
- else if (skillDialog != nullptr)
- {
- skillDialog->useItem(itemId,
- fromBool(config.getBoolValue("skillAutotarget"), AutoTarget),
- toInt(itemColor, int),
- mItemData[index]);
- }
- }
-}
-
-void ItemShortcut::equipItem(const size_t index) const
-{
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- return;
-
- const int itemId = mItems[index];
- if (itemId != 0)
- {
- const Item *const item = inv->findItem(itemId, mItemColors[index]);
- if ((item != nullptr) && (item->getQuantity() != 0))
- {
- if (item->isEquipment() == Equipm_true)
- {
- if (item->isEquipped() == Equipped_false)
- PlayerInfo::equipItem(item, Sfx_true);
- }
- }
- }
-}
-void ItemShortcut::unequipItem(const size_t index) const
-{
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- return;
-
- const int itemId = mItems[index];
- if (itemId != 0)
- {
- const Item *const item = inv->findItem(itemId, mItemColors[index]);
- if ((item != nullptr) && (item->getQuantity() != 0))
- {
- if (item->isEquipment() == Equipm_true)
- {
- if (item->isEquipped() == Equipped_true)
- PlayerInfo::unequipItem(item, Sfx_true);
- }
- }
- }
-}
-
-void ItemShortcut::setItemSelected(const Item *const item)
-{
- if (item != nullptr)
- {
- mItemSelected = item->getId();
- mItemColorSelected = item->getColor();
- }
- else
- {
- mItemSelected = -1;
- mItemColorSelected = ItemColor_one;
- }
-}
-
-void ItemShortcut::setItem(const size_t index)
-{
- mItems[index] = mItemSelected;
- mItemColors[index] = mItemColorSelected;
- save();
-}
-
-void ItemShortcut::setItem(const size_t index,
- const int item,
- const ItemColor color)
-{
- mItems[index] = item;
- mItemColors[index] = color;
- save();
-}
-
-void ItemShortcut::setItemFast(const size_t index,
- const int item,
- const ItemColor color)
-{
- mItems[index] = item;
- mItemColors[index] = color;
-}
-
-void ItemShortcut::swap(const size_t index1,
- const size_t index2)
-{
- if (CAST_U32(index1) >= SHORTCUT_ITEMS ||
- CAST_U32(index2) >= SHORTCUT_ITEMS)
- {
- return;
- }
-
- const int tmpItem = mItems[index1];
- mItems[index1] = mItems[index2];
- mItems[index2] = tmpItem;
- const ItemColor tmpColor = mItemColors[index1];
- mItemColors[index1] = mItemColors[index2];
- mItemColors[index2] = tmpColor;
-
- const std::string tmpData = mItemData[index1];
- mItemData[index1] = mItemData[index2];
- mItemData[index2] = tmpData;
- save();
-}
-
-size_t ItemShortcut::getFreeIndex() const
-{
- for (size_t i = 0; i < SHORTCUT_ITEMS; i++)
- {
- if (mItems[i] < 0)
- return i;
- }
- return SHORTCUT_ITEMS;
-}
diff --git a/src/gui/shortcut/itemshortcut.h b/src/gui/shortcut/itemshortcut.h
deleted file mode 100644
index 5e77e9152..000000000
--- a/src/gui/shortcut/itemshortcut.h
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef GUI_SHORTCUT_ITEMSHORTCUT_H
-#define GUI_SHORTCUT_ITEMSHORTCUT_H
-
-#include "const/itemshortcut.h"
-
-#include "enums/simpletypes/itemcolor.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-class Item;
-
-/**
- * The class which keeps track of the item shortcuts.
- */
-class ItemShortcut final
-{
- public:
- /**
- * Constructor.
- */
- explicit ItemShortcut(const size_t number);
-
- A_DELETE_COPY(ItemShortcut)
-
- /**
- * Destructor.
- */
- ~ItemShortcut();
-
- /**
- * Load the configuration information.
- */
- void load();
-
- /**
- * Save the configuration information.
- */
- void save() const;
-
- /**
- * Returns the shortcut item ID specified by the index.
- *
- * @param index Index of the shortcut item.
- */
- int getItem(const size_t index) const A_WARN_UNUSED
- { return mItems[index]; }
-
- ItemColor getItemColor(const size_t index) const A_WARN_UNUSED
- { return mItemColors[index]; }
-
- void setItemData(const size_t index,
- const std::string &data)
- { mItemData[index] = data; }
-
- std::string getItemData(const size_t index) const A_WARN_UNUSED
- { return mItemData[index]; }
-
- /**
- * Returns the amount of shortcut items.
- */
- constexpr static int getItemCount() A_WARN_UNUSED
- { return SHORTCUT_ITEMS; }
-
- /**
- * Returns the item ID that is currently selected.
- */
- int getItemSelected() const noexcept2 A_WARN_UNUSED
- { return mItemSelected; }
-
- /**
- * Adds the selected item ID to the items specified by the index.
- *
- * @param index Index of the items.
- */
- void setItem(const size_t index);
-
- void setItem(const size_t index,
- const int item,
- const ItemColor color);
-
- void setItemFast(const size_t index,
- const int item,
- const ItemColor color);
-
- /**
- * Adds an item to the items store specified by the index.
- *
- * @param index Index of the item.
- * @param itemId ID of the item.
- */
- void setItems(const size_t index,
- const int itemId,
- const ItemColor color)
- { mItems[index] = itemId; mItemColors[index] = color; save(); }
-
- /**
- * Set the item that is selected.
- *
- * @param itemId The ID of the item that is to be assigned.
- */
- void setItemSelected(const int itemId)
- { mItemSelected = itemId; }
-
- void setItemSelected(const Item *const item);
-
- /**
- * Returns selected shortcut item ID.
- */
- int getSelectedItem() const noexcept2 A_WARN_UNUSED
- { return mItemSelected; }
-
- /**
- * A flag to check if the item is selected.
- */
- bool isItemSelected() const noexcept2 A_WARN_UNUSED
- { return mItemSelected > -1; }
-
- /**
- * Remove a item from the shortcut.
- */
- void removeItem(const size_t index)
- { mItems[index] = -1; save(); }
-
- /**
- * Try to use the item specified by the index.
- *
- * @param index Index of the item shortcut.
- */
- void useItem(const size_t index) const;
-
- /**
- * Equip a item from the shortcut.
- */
- void equipItem(const size_t index) const;
-
- /**
- * UnEquip a item from the shortcut.
- */
- void unequipItem(const size_t index) const;
-
- void swap(const size_t index1,
- const size_t index2);
-
- void clear();
-
- size_t getFreeIndex() const A_WARN_UNUSED;
-
- private:
- int mItems[SHORTCUT_ITEMS]; /**< The items. */
- ItemColor mItemColors[SHORTCUT_ITEMS]; /**< The item colors. */
- std::string mItemData[SHORTCUT_ITEMS];
- size_t mNumber;
- int mItemSelected;
- ItemColor mItemColorSelected;
-};
-
-extern ItemShortcut *itemShortcut[SHORTCUT_TABS];
-
-#endif // GUI_SHORTCUT_ITEMSHORTCUT_H
diff --git a/src/gui/shortcut/shortcutbase.cpp b/src/gui/shortcut/shortcutbase.cpp
deleted file mode 100644
index 489805517..000000000
--- a/src/gui/shortcut/shortcutbase.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "gui/shortcut/shortcutbase.h"
-
-#include "configuration.h"
-
-#include "resources/item/item.h"
-
-#include "debug.h"
-
-ShortcutBase::ShortcutBase(const std::string &itemName,
- const std::string &colorName,
- const int maxSize) :
- mItems(new int[maxSize]),
- mItemColors(new ItemColor[maxSize]),
- mItemName(itemName),
- mColorName(colorName),
- mMaxSize(maxSize),
- mItemSelected(-1),
- mItemColorSelected(ItemColor_one)
-{
- clear(false);
- load();
-}
-
-ShortcutBase::~ShortcutBase()
-{
- delete [] mItems;
- mItems = nullptr;
- delete [] mItemColors;
- mItemColors = nullptr;
-}
-
-void ShortcutBase::load()
-{
- const Configuration *cfg = &serverConfig;
-
- for (size_t i = 0; i < mMaxSize; i++)
- {
- const std::string num = toString(CAST_S32(i));
- const int itemId = cfg->getValue(mItemName + num, -1);
- const ItemColor itemColor = fromInt(
- cfg->getValue(mColorName + num, -1),
- ItemColor);
-
- if (itemId != -1)
- {
- mItems[i] = itemId;
- mItemColors[i] = itemColor;
- }
- }
-}
-
-void ShortcutBase::save() const
-{
- for (size_t i = 0; i < mMaxSize; i++)
- {
- const int itemId = mItems[i] != 0 ? mItems[i] : -1;
- const int itemColor = (mItemColors[i] != ItemColor_zero)
- ? toInt(mItemColors[i], int) : 1;
- const std::string num = toString(CAST_S32(i));
- if (itemId != -1)
- {
- serverConfig.setValue(mItemName + num, itemId);
- serverConfig.setValue(mColorName + num, itemColor);
- }
- else
- {
- serverConfig.deleteKey(mItemName + num);
- serverConfig.deleteKey(mColorName + num);
- }
- }
-}
-
-void ShortcutBase::setItemSelected(const Item *const item)
-{
- if (item != nullptr)
- {
- mItemSelected = item->getId();
- mItemColorSelected = item->getColor();
- }
- else
- {
- mItemSelected = -1;
- mItemColorSelected = ItemColor_one;
- }
-}
-
-void ShortcutBase::setItem(const size_t index)
-{
- if (index >= mMaxSize)
- return;
-
- mItems[index] = mItemSelected;
- mItemColors[index] = mItemColorSelected;
- save();
-}
-
-void ShortcutBase::clear(const bool isSave)
-{
- for (size_t i = 0; i < mMaxSize; i++)
- {
- mItems[i] = -1;
- mItemColors[i] = ItemColor_one;
- }
- if (isSave)
- save();
-}
diff --git a/src/gui/shortcut/shortcutbase.h b/src/gui/shortcut/shortcutbase.h
deleted file mode 100644
index 90ca41ee7..000000000
--- a/src/gui/shortcut/shortcutbase.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef GUI_SHORTCUT_SHORTCUTBASE_H
-#define GUI_SHORTCUT_SHORTCUTBASE_H
-
-#include "enums/simpletypes/itemcolor.h"
-
-#include "utils/cast.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-class Item;
-
-/**
- * The class which keeps track of the item shortcuts.
- */
-class ShortcutBase notfinal
-{
- public:
- /**
- * Constructor.
- */
- ShortcutBase(const std::string &itemName,
- const std::string &colorName,
- const int maxSize);
-
- A_DELETE_COPY(ShortcutBase)
-
- /**
- * Destructor.
- */
- virtual ~ShortcutBase();
-
- /**
- * Load the configuration information.
- */
- void load();
-
- /**
- * Save the configuration information.
- */
- void save() const;
-
- /**
- * Returns the shortcut item ID specified by the index.
- *
- * @param index Index of the shortcut item.
- */
- int getItem(const size_t index) const A_WARN_UNUSED
- { return mItems[index]; }
-
- ItemColor getItemColor(const size_t index) const A_WARN_UNUSED
- { return mItemColors[index]; }
-
- /**
- * Returns the amount of shortcut items.
- */
- int getItemCount() const noexcept2 A_WARN_UNUSED
- { return CAST_S32(mMaxSize); }
-
- /**
- * Returns the item ID that is currently selected.
- */
- int getItemSelected() const noexcept2 A_WARN_UNUSED
- { return mItemSelected; }
-
- /**
- * Adds the selected item ID to the items specified by the index.
- *
- * @param index Index of the items.
- */
- void setItem(const size_t index);
-
- /**
- * Adds an item to the items store specified by the index.
- *
- * @param index Index of the item.
- * @param itemId ID of the item.
- */
- void setItems(const size_t index,
- const int itemId,
- const ItemColor color)
- { mItems[index] = itemId; mItemColors[index] = color; save(); }
-
- /**
- * Set the item that is selected.
- *
- * @param itemId The ID of the item that is to be assigned.
- */
- void setItemSelected(const int itemId)
- { mItemSelected = itemId; }
-
- void setItemSelected(const Item *const item);
-
- /**
- * A flag to check if the item is selected.
- */
- bool isItemSelected() const noexcept2 A_WARN_UNUSED
- { return mItemSelected > -1; }
-
- /**
- * Remove a item from the shortcut.
- */
- void removeItem(const size_t index)
- { mItems[index] = -1; save(); }
-
- void clear(const bool isSave = true);
-
- private:
- int *mItems A_NONNULLPOINTER;
- ItemColor *mItemColors A_NONNULLPOINTER;
- std::string mItemName;
- std::string mColorName;
- size_t mMaxSize;
- int mItemSelected;
- ItemColor mItemColorSelected;
-};
-
-#endif // GUI_SHORTCUT_SHORTCUTBASE_H
diff --git a/src/gui/shortcut/spellshortcut.cpp b/src/gui/shortcut/spellshortcut.cpp
deleted file mode 100644
index 14eaa2f48..000000000
--- a/src/gui/shortcut/spellshortcut.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "gui/shortcut/spellshortcut.h"
-
-#include "spellmanager.h"
-#include "textcommand.h"
-
-#include "debug.h"
-
-SpellShortcut *spellShortcut = nullptr;
-
-SpellShortcut::SpellShortcut() :
- mItemSelected(-1)
-{
- load();
-}
-
-SpellShortcut::~SpellShortcut()
-{
-}
-
-void SpellShortcut::load()
-{
- for (unsigned f = 0; f < SPELLS_SIZE; f ++)
- mItems[f] = -1;
-
- if (spellManager == nullptr)
- return;
-
- const STD_VECTOR<TextCommand*> &spells = spellManager->getAll();
- unsigned k = 0;
-
- for (STD_VECTOR<TextCommand*>::const_iterator i = spells.begin(),
- i_end = spells.end(); i != i_end && k < SPELLS_SIZE; ++i)
- {
- mItems[k++] = (*i)->getId();
- }
-}
-
-unsigned int SpellShortcut::getSpellsCount() const
-{
- return SPELL_SHORTCUT_ITEMS;
-}
diff --git a/src/gui/shortcut/spellshortcut.h b/src/gui/shortcut/spellshortcut.h
deleted file mode 100644
index 4eab518a6..000000000
--- a/src/gui/shortcut/spellshortcut.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef GUI_SHORTCUT_SPELLSHORTCUT_H
-#define GUI_SHORTCUT_SPELLSHORTCUT_H
-
-#include "const/spells.h"
-
-/**
- * The class which keeps track of the item shortcuts.
- */
-class SpellShortcut final
-{
- public:
- /**
- * Constructor.
- */
- SpellShortcut();
-
- A_DELETE_COPY(SpellShortcut)
-
- /**
- * Destructor.
- */
- ~SpellShortcut() A_CONST;
-
- /**
- * Load the configuration information.
- */
- void load();
-
- unsigned int getSpellsCount() const A_CONST A_WARN_UNUSED;
-
- /**
- * Set the item that is selected.
- *
- * @param itemId The ID of the item that is to be assigned.
- */
- void setItemSelected(const int itemId) noexcept2
- { mItemSelected = itemId; }
-
- /**
- * A flag to check if the item is selected.
- */
- bool isItemSelected() const noexcept2 A_WARN_UNUSED
- { return mItemSelected > -1; }
-
- /**
- * Returns selected shortcut item ID.
- */
- int getSelectedItem() const noexcept2 A_WARN_UNUSED
- { return mItemSelected; }
-
- /**
- * Returns the shortcut item ID specified by the index.
- *
- * @param index Index of the shortcut item.
- */
- int getItem(const size_t index) const
- { return mItems[index]; }
-
- private:
- int mItems[SPELLS_SIZE];
- int mItemSelected; /**< The item held by cursor. */
-};
-
-extern SpellShortcut *spellShortcut;
-
-#endif // GUI_SHORTCUT_SPELLSHORTCUT_H