summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-02-06 00:27:11 +0300
committerAndrei Karas <akaras@inbox.ru>2013-02-06 00:28:01 +0300
commitd514c4c7bc62061935579505b497307f89fc8db5 (patch)
tree23262e97103dc794ee49b83d9afe47c43afe6d2e
parent8bbc32ceeb0522064d6ee9789c9c666d2874d29a (diff)
downloadplus-d514c4c7bc62061935579505b497307f89fc8db5.tar.gz
plus-d514c4c7bc62061935579505b497307f89fc8db5.tar.bz2
plus-d514c4c7bc62061935579505b497307f89fc8db5.tar.xz
plus-d514c4c7bc62061935579505b497307f89fc8db5.zip
Remove specials window and db.
It was used only in manaserv and manaserv support now almost deleted.
-rw-r--r--src/gui/specialswindow.cpp254
-rw-r--r--src/gui/specialswindow.h68
-rw-r--r--src/resources/specialdb.cpp132
-rw-r--r--src/resources/specialdb.h90
4 files changed, 0 insertions, 544 deletions
diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp
deleted file mode 100644
index ef6e2a428..000000000
--- a/src/gui/specialswindow.cpp
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2013 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/specialswindow.h"
-
-#include "gui/setup.h"
-
-#include "gui/widgets/container.h"
-#include "gui/widgets/icon.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/layouthelper.h"
-#include "gui/widgets/listbox.h"
-#include "gui/widgets/progressbar.h"
-#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/tab.h"
-#include "gui/widgets/flowcontainer.h"
-#include "gui/widgets/windowcontainer.h"
-
-#include "net/net.h"
-#include "net/specialhandler.h"
-
-#include "resources/specialdb.h"
-
-#include "utils/dtor.h"
-#include "utils/gettext.h"
-#include "utils/xml.h"
-
-#include <string>
-
-#include "debug.h"
-
-static const unsigned int SPECIALS_WIDTH = 200;
-static const unsigned int SPECIALS_HEIGHT = 32;
-
-class SpecialEntry final : public Container
-{
- public:
- SpecialEntry(SpecialInfo *info);
-
- A_DELETE_COPY(SpecialEntry)
-
- void update(int current, int needed);
-
- protected:
- friend class SpecialsWindow;
- SpecialInfo *mInfo;
-
- private:
- Icon *mIcon; // icon to display
- Label *mNameLabel; // name to display
- Label *mLevelLabel; // level number label (only shown when applicable)
- Button *mUse; // use button (only shown when applicable)
- ProgressBar *mRechargeBar; // recharge bar (only shown when applicable)
-};
-
-SpecialsWindow::SpecialsWindow():
- Window(_("Specials"), false, nullptr, "specials.xml")
-{
- setWindowName("Specials");
- setCloseButton(true);
- setResizable(true);
- setSaveVisible(true);
- setStickyButtonLock(true);
- setDefaultSize(windowContainer->getWidth() - 280, 30, 275, 425);
- setupWindow->registerWindowForReset(this);
-
- mTabs = new TabbedArea();
-
- place(0, 0, mTabs, 5, 5);
-
- setLocationRelativeTo(getParent());
- loadWindowState();
-}
-
-SpecialsWindow::~SpecialsWindow()
-{
- // Clear gui
-}
-
-void SpecialsWindow::action(const gcn::ActionEvent &event)
-{
- if (event.getId() == "use")
- {
- if (!event.getSource())
- return;
-
- const SpecialEntry *const disp = dynamic_cast<SpecialEntry*>(
- event.getSource()->getParent());
-
- if (disp && disp->mInfo)
- {
- /*Being *target = player_node->getTarget();
-
- if (target)
- Net::getSpecialHandler()->use(disp->mInfo->id,
- 1, target->getId());
- else*/
- Net::getSpecialHandler()->use(disp->mInfo->id);
- }
- }
- else if (event.getId() == "close")
- {
- setVisible(false);
- }
-}
-
-void SpecialsWindow::draw(gcn::Graphics *graphics)
-{
- // update the progress bars
- std::map<int, Special> specialData = PlayerInfo::getSpecialStatus();
- bool foundNew = false;
- unsigned int found = 0; // number of entries in specialData
- // which match mEntries
-
- for (std::map<int, Special>::const_iterator i = specialData.begin(),
- i_end = specialData.end(); i != i_end; ++i)
- {
- std::map<int, SpecialEntry *>::const_iterator
- e = mEntries.find(i->first);
- if (e == mEntries.end())
- {
- // found a new special - abort update and rebuild from scratch
- foundNew = true;
- break;
- }
- else
- {
- // update progress bar of special
- if (e->second)
- e->second->update(i->second.currentMana, i->second.neededMana);
- found++;
- }
- }
- // a rebuild is needed when a) the number of specials changed or b)
- // an existing entry isn't found anymore
- if (foundNew || found != mEntries.size())
- rebuild(specialData);
-
- Window::draw(graphics);
-}
-
-void SpecialsWindow::rebuild(const std::map<int, Special> &specialData)
-{
- make_dtor(mEntries);
- mEntries.clear();
- int vPos = 0; //vertical position of next placed element
-
- for (std::map<int, Special>::const_iterator i = specialData.begin(),
- i_end = specialData.end(); i != i_end; ++i)
- {
- logger->log("Updating special GUI for %d", i->first);
-
- SpecialInfo *const info = SpecialDB::get(i->first);
- if (info)
- {
- info->rechargeCurrent = i->second.currentMana;
- info->rechargeNeeded = i->second.neededMana;
- SpecialEntry *const entry = new SpecialEntry(info);
- entry->setPosition(0, vPos);
- vPos += entry->getHeight();
- add(entry);
- mEntries[i->first] = entry;
- }
- else
- {
- logger->log("Warning: No info available of special %d", i->first);
- }
- }
-}
-
-
-SpecialEntry::SpecialEntry(SpecialInfo *const info) :
- mInfo(info),
- mIcon(nullptr),
- mLevelLabel(nullptr),
- mUse(nullptr),
- mRechargeBar(nullptr)
-{
- setFrameSize(1);
- setOpaque(false);
- setSize(SPECIALS_WIDTH, SPECIALS_HEIGHT);
-
- if (info && !info->icon.empty())
- mIcon = new Icon(info->icon);
- else
- mIcon = new Icon(Theme::resolveThemePath("unknown-item.png"));
-
- mIcon->setPosition(1, 0);
- add(mIcon);
-
- if (info)
- mNameLabel = new Label(this, info->name);
- else
- mNameLabel = new Label(this, "");
-
- mNameLabel->setPosition(35, 0);
- add(mNameLabel);
-
- if (info && info->hasLevel)
- {
- mLevelLabel = new Label(this, toString(info->level));
- mLevelLabel->setPosition(getWidth() - mLevelLabel->getWidth(), 0);
- add(mLevelLabel);
- }
-
- if (info && info->isActive)
- {
- mUse = new Button("Use", "use", specialsWindow);
- mUse->setPosition(getWidth() - mUse->getWidth(), 13);
- add(mUse);
- }
-
- if (info->hasRechargeBar)
- {
- float progress = 0;
- if (info->rechargeNeeded)
- {
- progress = static_cast<float>(info->rechargeCurrent)
- / static_cast<float>(info->rechargeNeeded);
- }
- mRechargeBar = new ProgressBar(this, progress, 100, 0, Theme::PROG_MP);
- mRechargeBar->setSmoothProgress(false);
- mRechargeBar->setPosition(0, 13);
- add(mRechargeBar);
- }
-
-}
-
-void SpecialEntry::update(int current, int needed)
-{
- if (mRechargeBar && needed)
- {
- mRechargeBar->setProgress(static_cast<float>(current)
- / static_cast<float>(needed));
- }
-}
diff --git a/src/gui/specialswindow.h b/src/gui/specialswindow.h
deleted file mode 100644
index 3b19eefa8..000000000
--- a/src/gui/specialswindow.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2013 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 SPECIALSWINDOW_H
-#define SPECIALSWINDOW_H
-
-#include <vector>
-
-#include "playerinfo.h"
-
-#include "gui/widgets/window.h"
-
-#include <guichan/actionlistener.hpp>
-
-#include <map>
-
-class Label;
-class ScrollArea;
-class Tab;
-class TabbedArea;
-
-class SpecialEntry;
-
-class SpecialsWindow final : public Window, public gcn::ActionListener
-{
- public:
- SpecialsWindow();
-
- A_DELETE_COPY(SpecialsWindow)
-
- ~SpecialsWindow();
-
- /**
- * Called when receiving actions from widget.
- */
- void action(const gcn::ActionEvent &actionEvent) override;
-
- void draw(gcn::Graphics *graphics) override;
-
- private:
- // (re)constructs the list of specials
- void rebuild(const std::map<int, Special> &specialData);
-
- TabbedArea *mTabs;
- std::map<int, SpecialEntry *> mEntries;
-};
-
-extern SpecialsWindow *specialsWindow;
-
-#endif // SPECIALSWINDOW_H
diff --git a/src/resources/specialdb.cpp b/src/resources/specialdb.cpp
deleted file mode 100644
index aa51a7898..000000000
--- a/src/resources/specialdb.cpp
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2010 The Mana Developers
- * Copyright (C) 2011-2013 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 "resources/specialdb.h"
-
-#include "logger.h"
-
-#include "utils/dtor.h"
-#include "utils/xml.h"
-
-#include "debug.h"
-
-namespace
-{
- SpecialInfos mSpecialInfos;
- bool mLoaded = false;
-}
-
-SpecialInfo::TargetMode SpecialDB::targetModeFromString(const std::string& str)
-{
- if (str == "self") return SpecialInfo::TARGET_SELF;
- else if (str == "friend") return SpecialInfo::TARGET_FRIEND;
- else if (str == "enemy") return SpecialInfo::TARGET_ENEMY;
- else if (str == "being") return SpecialInfo::TARGET_BEING;
- else if (str == "point") return SpecialInfo::TARGET_POINT;
-
- logger->log("SpecialDB: Warning, unknown target mode \"%s\"",
- str.c_str() );
- return SpecialInfo::TARGET_SELF;
-}
-
-void SpecialDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log("Initializing special database...");
-
- XML::Document doc("specials.xml");
- const XmlNodePtr root = doc.rootNode();
-
- if (!root || !xmlNameEqual(root, "specials"))
- {
- logger->log("Error loading specials file specials.xml");
- return;
- }
-
- std::string setName;
-
- for_each_xml_child_node(set, root)
- {
- if (xmlNameEqual(set, "set"))
- {
- setName = XML::getProperty(set, "name", "Actions");
-
- for_each_xml_child_node(special, set)
- {
- if (xmlNameEqual(special, "special"))
- {
- SpecialInfo *const info = new SpecialInfo();
- const int id = XML::getProperty(special, "id", 0);
- info->id = id;
- info->set = setName;
- info->name = XML::getProperty(special, "name", "");
- info->icon = XML::getProperty(special, "icon", "");
-
- info->isActive = XML::getBoolProperty(
- special, "active", false);
- info->targetMode = targetModeFromString(XML::getProperty(
- special, "target", "self"));
-
- info->level = XML::getProperty(special, "level", -1);
- info->hasLevel = info->level > -1;
-
- info->hasRechargeBar = XML::getBoolProperty(special,
- "recharge", false);
- info->rechargeNeeded = 0;
- info->rechargeCurrent = 0;
-
- if (mSpecialInfos.find(id) != mSpecialInfos.end())
- {
- logger->log("SpecialDB: Duplicate special ID"
- " %d (ignoring)", id);
- }
- else
- {
- mSpecialInfos[id] = info;
- }
- }
- }
- }
- }
-
- mLoaded = true;
-}
-
-void SpecialDB::unload()
-{
- delete_all(mSpecialInfos);
- mSpecialInfos.clear();
-
- mLoaded = false;
-}
-
-
-SpecialInfo *SpecialDB::get(const int id)
-{
- const SpecialInfos::const_iterator i = mSpecialInfos.find(id);
-
- if (i == mSpecialInfos.end())
- return nullptr;
- else
- return i->second;
-}
diff --git a/src/resources/specialdb.h b/src/resources/specialdb.h
deleted file mode 100644
index e392216f2..000000000
--- a/src/resources/specialdb.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2010 The Mana Developers
- * Copyright (C) 2011-2013 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 SPECIAL_DB_H
-#define SPECIAL_DB_H
-
-#include <string>
-#include <map>
-
-#include "localconsts.h"
-
-struct SpecialInfo final
-{
- enum TargetMode
- {
- TARGET_SELF = 0, // no target selection
- TARGET_FRIEND, // target friendly being
- TARGET_ENEMY, // target hostile being
- TARGET_BEING, // target any being
- TARGET_POINT // target map location
- };
-
- SpecialInfo() :
- id(0),
- isActive(false),
- targetMode(TARGET_SELF),
- hasLevel(false),
- level(0),
- hasRechargeBar(false),
- rechargeNeeded(0),
- rechargeCurrent(0)
- { }
-
- A_DELETE_COPY(SpecialInfo)
-
- int id;
- std::string set; // tab on which the special is shown
- std::string name; // displayed name of special
- std::string icon; // filename of graphical icon
-
- bool isActive; // true when the special can be used
- TargetMode targetMode; // target mode
-
- bool hasLevel; // true when the special has levels
- int level; // level of special when applicable
-
- bool hasRechargeBar; // true when the special has a recharge bar
- int rechargeNeeded; // maximum recharge when applicable
- int rechargeCurrent; // current recharge when applicable
-};
-
-/**
- * Special information database.
- */
-namespace SpecialDB
-{
- void load();
-
- void unload();
-
- /** gets the special info for ID. Will return 0 when it is
- * a server-specific special.
- */
- SpecialInfo *get(const int id) A_WARN_UNUSED;
-
- SpecialInfo::TargetMode targetModeFromString(const std::string& str)
- A_WARN_UNUSED;
-}
-
-typedef std::map<int, SpecialInfo *> SpecialInfos;
-
-#endif