summaryrefslogtreecommitdiff
path: root/src/gui/widgets/attrs
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets/attrs')
-rw-r--r--src/gui/widgets/attrs/attrdisplay.cpp67
-rw-r--r--src/gui/widgets/attrs/attrdisplay.h82
-rw-r--r--src/gui/widgets/attrs/changedisplay.cpp119
-rw-r--r--src/gui/widgets/attrs/changedisplay.h61
-rw-r--r--src/gui/widgets/attrs/derdisplay.cpp40
-rw-r--r--src/gui/widgets/attrs/derdisplay.h44
6 files changed, 0 insertions, 413 deletions
diff --git a/src/gui/widgets/attrs/attrdisplay.cpp b/src/gui/widgets/attrs/attrdisplay.cpp
deleted file mode 100644
index 3b91fef9d..000000000
--- a/src/gui/widgets/attrs/attrdisplay.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-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/widgets/attrs/attrdisplay.h"
-
-#include "being/playerinfo.h"
-
-#include "gui/widgets/layouthelper.h"
-
-#include "utils/delete2.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-AttrDisplay::AttrDisplay(const Widget2 *const widget,
- const AttributesT id,
- const std::string &restrict name,
- const std::string &restrict shortName) :
- Container(widget),
- mId(id),
- mName(name),
- mShortName(shortName),
- mLayout(new LayoutHelper(this)),
- mLabel(new Label(this, name)),
- mValue(new Label(this, "1 "))
-{
- setSize(100, 32);
-
- setSelectable(false);
- mLabel->setAlignment(Graphics::CENTER);
- mValue->setAlignment(Graphics::CENTER);
-}
-
-AttrDisplay::~AttrDisplay()
-{
- delete2(mLayout);
-}
-
-std::string AttrDisplay::update()
-{
- const int base = PlayerInfo::getStatBase(mId);
- const int bonus = PlayerInfo::getStatMod(mId);
- std::string value = toString(base + bonus);
- if (bonus != 0)
- value.append(strprintf("=%d%+d", base, bonus));
- mValue->setCaption(value);
- return mName;
-}
diff --git a/src/gui/widgets/attrs/attrdisplay.h b/src/gui/widgets/attrs/attrdisplay.h
deleted file mode 100644
index f682e41f5..000000000
--- a/src/gui/widgets/attrs/attrdisplay.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-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_WIDGETS_ATTRS_ATTRDISPLAY_H
-#define GUI_WIDGETS_ATTRS_ATTRDISPLAY_H
-
-#include "enums/being/attributes.h"
-
-#include "gui/widgets/container.h"
-
-#include "gui/widgets/label.h"
-
-#include "localconsts.h"
-
-class LayoutHelper;
-
-class AttrDisplay notfinal : public Container
-{
- public:
- enum Type
- {
- DERIVED = 0,
- CHANGEABLE,
- UNKNOWN
- };
-
- A_DELETE_COPY(AttrDisplay)
-
- virtual ~AttrDisplay();
-
- virtual std::string update();
-
- virtual Type getType() const
- { return UNKNOWN; }
-
- std::string getValue() const
- {
- if (mValue == nullptr)
- return "-";
- return mValue->getCaption();
- }
-
- const std::string &getShortName() const
- { return mShortName; }
-
- protected:
- AttrDisplay(const Widget2 *const widget,
- const AttributesT id,
- const std::string &restrict name,
- const std::string &restrict shortName);
-
- const AttributesT mId;
- const std::string mName;
- const std::string mShortName;
-
- LayoutHelper *mLayout;
- Label *mLabel;
- Label *mValue;
-};
-
-typedef std::map<AttributesT, AttrDisplay*> Attrs;
-
-#endif // GUI_WIDGETS_ATTRS_ATTRDISPLAY_H
diff --git a/src/gui/widgets/attrs/changedisplay.cpp b/src/gui/widgets/attrs/changedisplay.cpp
deleted file mode 100644
index e1af1eb76..000000000
--- a/src/gui/widgets/attrs/changedisplay.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-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/widgets/attrs/changedisplay.h"
-
-#include "configuration.h"
-
-#include "being/playerinfo.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/layouthelper.h"
-
-#include "net/net.h"
-#include "net/playerhandler.h"
-
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-ChangeDisplay::ChangeDisplay(const Widget2 *const widget,
- const AttributesT id,
- const std::string &restrict name,
- const std::string &restrict shortName) :
- AttrDisplay(widget, id, name, shortName),
- ActionListener(),
- mNeeded(1),
- // TRANSLATORS: status window label
- mPoints(new Label(this, _("Max"))),
- // TRANSLATORS: status window label (plus sign)
- mInc(new Button(this, _("+"), "inc", this))
-{
- // Do the layout
- ContainerPlacer place = mLayout->getPlacer(0, 0);
-
- place(0, 0, mLabel, 3);
- place(4, 0, mValue, 2);
- place(6, 0, mInc);
- place(7, 0, mPoints);
-}
-
-std::string ChangeDisplay::update()
-{
- if (mNeeded > 0)
- {
- mPoints->setCaption(toString(mNeeded));
- }
- else
- {
- // TRANSLATORS: status bar label
- mPoints->setCaption(_("Max"));
- }
-
- mInc->setEnabled(PlayerInfo::getAttribute(Attributes::PLAYER_CHAR_POINTS)
- >= mNeeded && mNeeded > 0);
-
- return AttrDisplay::update();
-}
-
-void ChangeDisplay::setPointsNeeded(const int needed)
-{
- mNeeded = needed;
- update();
-}
-
-void ChangeDisplay::action(const ActionEvent &event)
-{
- if (event.getSource() == mInc)
- {
- int cnt = 1;
- if (config.getBoolValue("quickStats"))
- {
- cnt = mInc->getClickCount();
- if (cnt > 10)
- cnt = 10;
- }
-
- const int newpoints = PlayerInfo::getAttribute(
- Attributes::PLAYER_CHAR_POINTS) - cnt;
- PlayerInfo::setAttribute(Attributes::PLAYER_CHAR_POINTS,
- newpoints);
-
- const int newbase = PlayerInfo::getStatBase(mId) + cnt;
- PlayerInfo::setStatBase(mId, newbase);
-
- if (Net::getNetworkType() != ServerType::TMWATHENA)
- {
- playerHandler->increaseAttribute(mId, cnt);
- }
- else
- {
- for (int f = 0; f < cnt; f ++)
- {
- playerHandler->increaseAttribute(mId, 1);
- if (cnt != 1)
- SDL_Delay(100);
- }
- }
- }
-}
diff --git a/src/gui/widgets/attrs/changedisplay.h b/src/gui/widgets/attrs/changedisplay.h
deleted file mode 100644
index 4e9d1076d..000000000
--- a/src/gui/widgets/attrs/changedisplay.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-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_WIDGETS_ATTRS_CHANGEDISPLAY_H
-#define GUI_WIDGETS_ATTRS_CHANGEDISPLAY_H
-
-#include "gui/widgets/attrs/attrdisplay.h"
-
-#include "listeners/actionlistener.h"
-
-#include "localconsts.h"
-
-class Button;
-
-class ChangeDisplay final : public AttrDisplay,
- public ActionListener
-{
- public:
- ChangeDisplay(const Widget2 *const widget,
- const AttributesT id,
- const std::string &restrict name,
- const std::string &restrict shortName);
-
- A_DELETE_COPY(ChangeDisplay)
-
- std::string update() override final;
-
- Type getType() const override final
- { return CHANGEABLE; }
-
- void setPointsNeeded(const int needed);
-
- void action(const ActionEvent &event) override final;
-
- private:
- int mNeeded;
-
- Label *mPoints;
- Button *mInc;
-};
-
-#endif // GUI_WIDGETS_ATTRS_CHANGEDISPLAY_H
diff --git a/src/gui/widgets/attrs/derdisplay.cpp b/src/gui/widgets/attrs/derdisplay.cpp
deleted file mode 100644
index 2c20c3713..000000000
--- a/src/gui/widgets/attrs/derdisplay.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-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/widgets/attrs/derdisplay.h"
-
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/layouthelper.h"
-
-#include "debug.h"
-
-DerDisplay::DerDisplay(const Widget2 *const widget,
- const AttributesT id,
- const std::string &restrict name,
- const std::string &restrict shortName) :
- AttrDisplay(widget, id, name, shortName)
-{
- ContainerPlacer place = mLayout->getPlacer(0, 0);
-
- place(0, 0, mLabel, 3);
- place(3, 0, mValue, 2);
-}
diff --git a/src/gui/widgets/attrs/derdisplay.h b/src/gui/widgets/attrs/derdisplay.h
deleted file mode 100644
index 8b841694e..000000000
--- a/src/gui/widgets/attrs/derdisplay.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-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_WIDGETS_ATTRS_DERDISPLAY_H
-#define GUI_WIDGETS_ATTRS_DERDISPLAY_H
-
-#include "gui/widgets/attrs/attrdisplay.h"
-
-#include "localconsts.h"
-
-class DerDisplay final : public AttrDisplay
-{
- public:
- DerDisplay(const Widget2 *const widget,
- const AttributesT id,
- const std::string &restrict name,
- const std::string &restrict shortName);
-
- A_DELETE_COPY(DerDisplay)
-
- Type getType() const override final
- { return DERIVED; }
-};
-
-#endif // GUI_WIDGETS_ATTRS_DERDISPLAY_H