summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-07 23:17:42 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-07 23:31:20 +0300
commit21036c157955da93485e0b4ea5d22116cfdaba33 (patch)
tree9f0ddb8baa8e6dcb7023a8f39d325b810e9ceab7 /src/gui
parentef6869c9759246b3a0d6cc1c58a25773ccfcc858 (diff)
downloadplus-21036c157955da93485e0b4ea5d22116cfdaba33.tar.gz
plus-21036c157955da93485e0b4ea5d22116cfdaba33.tar.bz2
plus-21036c157955da93485e0b4ea5d22116cfdaba33.tar.xz
plus-21036c157955da93485e0b4ea5d22116cfdaba33.zip
Remove bot checker window.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/models/userstablemodel.h258
-rw-r--r--src/gui/windowmenu.cpp3
-rw-r--r--src/gui/windows/botcheckerwindow.cpp216
-rw-r--r--src/gui/windows/botcheckerwindow.h92
4 files changed, 0 insertions, 569 deletions
diff --git a/src/gui/models/userstablemodel.h b/src/gui/models/userstablemodel.h
deleted file mode 100644
index 788fcd2d0..000000000
--- a/src/gui/models/userstablemodel.h
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009-2010 Andrei Karas
- * Copyright (C) 2011-2015 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_MODELS_USERSTABLEMODEL_H
-#define GUI_MODELS_USERSTABLEMODEL_H
-
-#include "gui/windows/botcheckerwindow.h"
-
-#include "gui/widgets/label.h"
-
-#include "gui/models/tablemodel.h"
-
-#include "actormanager.h"
-
-#include "being/localplayer.h"
-
-#include "utils/stringutils.h"
-
-#include "localconsts.h"
-
-const int COLUMNS_NR = 5; // name plus listbox
-const int NAME_COLUMN = 0;
-const int TIME_COLUMN = 1;
-
-const int ROW_HEIGHT = 12;
-// The following column widths really shouldn't be hardcoded but should
-// scale with the size of the widget... excep
-// that, right now, the widget doesn't exactly scale either.
-const int NAME_COLUMN_WIDTH = 185;
-const int TIME_COLUMN_WIDTH = 70;
-
-#define WIDGET_AT(row, column) (((row) * COLUMNS_NR) + column)
-
-class UsersTableModel final : public TableModel,
- public Widget2
-{
- public:
- explicit UsersTableModel(const Widget2 *const widget) :
- TableModel(),
- Widget2(widget),
- mPlayers(0),
- mWidgets()
- {
- playersUpdated();
- }
-
- A_DELETE_COPY(UsersTableModel)
-
- ~UsersTableModel()
- {
- freeWidgets();
- }
-
- int getRows() const override final
- {
- return static_cast<int>(mPlayers.size());
- }
-
- int getColumns() const override final
- {
- return COLUMNS_NR;
- }
-
- int getRowHeight() const override final
- {
- return ROW_HEIGHT;
- }
-
- int getColumnWidth(const int index) const override final
- {
- if (index == NAME_COLUMN)
- return NAME_COLUMN_WIDTH;
- else
- return TIME_COLUMN_WIDTH;
- }
-
- void playersUpdated()
- {
- signalBeforeUpdate();
-
- freeWidgets();
- mPlayers.clear();
- if (actorManager && botCheckerWindow
- && botCheckerWindow->mBotcheckerEnabled)
- {
- std::set<ActorSprite*> beings = actorManager->getAll();
- FOR_EACH (ActorSprites::iterator, i, beings)
- {
- Being *const being = dynamic_cast<Being*>(*i);
-
- if (being && being->getType() == ActorType::Player
- && being != localPlayer && !being->getName().empty())
- {
- mPlayers.push_back(being);
- }
- }
- }
-
- const unsigned int curTime = cur_time;
- const size_t sz = mPlayers.size();
- // set up widgets
- for (size_t r = 0; r < sz; ++r)
- {
- if (!mPlayers.at(r))
- continue;
-
- const Being *const player = mPlayers.at(r);
- Widget *widget = new Label(this, player->getName());
-
- mWidgets.push_back(widget);
-
- if (player->getAttackTime() != 0)
- {
- widget = new Label(this, toString(curTime
- - player->getAttackTime()));
- }
- else
- {
- widget = new Label(this, toString(curTime
- - player->getTestTime()).append("?"));
- }
- mWidgets.push_back(widget);
-
- if (player->getTalkTime() != 0)
- {
- widget = new Label(this, toString(curTime
- - player->getTalkTime()));
- }
- else
- {
- widget = new Label(this, toString(curTime
- - player->getTestTime()).append("?"));
- }
- mWidgets.push_back(widget);
-
- if (player->getMoveTime() != 0)
- {
- widget = new Label(this, toString(curTime
- - player->getMoveTime()));
- }
- else
- {
- widget = new Label(this, toString(curTime
- - player->getTestTime()).append("?"));
- }
- mWidgets.push_back(widget);
-
- std::string str;
- bool talkBot = false;
- bool moveBot = false;
- bool attackBot = false;
- bool otherBot = false;
-
- if (curTime - player->getTestTime() > 2 * 60)
- {
- const int attack = curTime - (player->getAttackTime()
- ? player->getAttackTime()
- : player->getTestTime());
- const int talk = curTime - (player->getTalkTime()
- ? player->getTalkTime()
- : player->getTestTime()) - attack;
- const int move = curTime - (player->getMoveTime()
- ? player->getMoveTime()
- : player->getTestTime()) - attack;
- const int other = curTime - (player->getOtherTime()
- ? player->getMoveTime()
- : player->getOtherTime()) - attack;
-
- if (attack < 2 * 60)
- attackBot = true;
-
- // attacking but not talking more than 2 minutes
- if (talk > 2 * 60)
- {
- talkBot = true;
- str.append(toString((talk) / 60)).append(" ");
- }
-
- // attacking but not moving more than 2 minutes
- if (move > 2 * 60)
- {
- moveBot = true;
- str.append(toString((move) / 60));
- }
-
- // attacking but not other activity more than 2 minutes
- if (move > 2 * 60 && other > 2 * 60)
- otherBot = true;
- }
-
- if (str.length() > 0)
- {
- if (attackBot && talkBot && moveBot && otherBot)
- str = "bot!! " + str;
- else if (attackBot && talkBot && moveBot)
- str = "bot! " + str;
- else if (talkBot && moveBot)
- str = "bot " + str;
- else if (talkBot || moveBot)
- str = "bot? " + str;
- }
- else
- {
- str = "ok";
- }
-
- widget = new Label(this, str);
- mWidgets.push_back(widget);
- }
-
- signalAfterUpdate();
- }
-
- void updateModelInRow(const int row A_UNUSED) const
- {
- }
-
- Widget *getElementAt(const int row,
- const int column) const override final
- {
- return mWidgets[WIDGET_AT(row, column)];
- }
-
- void freeWidgets()
- {
- for (std::vector<Widget *>::const_iterator it = mWidgets.begin();
- it != mWidgets.end(); ++it)
- {
- delete *it;
- }
-
- mWidgets.clear();
- }
-
- protected:
- std::vector<Being*> mPlayers;
- std::vector<Widget*> mWidgets;
-};
-
-#endif // GUI_MODELS_USERSTABLEMODEL_H
diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp
index 81bcd5e6b..4cf0a6b2b 100644
--- a/src/gui/windowmenu.cpp
+++ b/src/gui/windowmenu.cpp
@@ -73,9 +73,6 @@ WindowMenu::WindowMenu(const Widget2 *const widget) :
// TRANSLATORS: short button name for quests window.
addButton(N_("QE"),
_("Quests"), x, h, InputAction::WINDOW_QUESTS);
- // TRANSLATORS: short button name for bot checker window.
- addButton(N_("BC"),
- _("Bot checker"), x, h, InputAction::WINDOW_BOT_CHECKER, false);
// TRANSLATORS: short button name for kill stats window.
addButton(N_("KS"),
_("Kill stats"), x, h, InputAction::WINDOW_KILLS);
diff --git a/src/gui/windows/botcheckerwindow.cpp b/src/gui/windows/botcheckerwindow.cpp
deleted file mode 100644
index e49bd65b1..000000000
--- a/src/gui/windows/botcheckerwindow.cpp
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * Copyright (C) 2011-2015 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/windows/botcheckerwindow.h"
-
-#include "gui/windows/setupwindow.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/guitable.h"
-
-#include "gui/models/userstablemodel.h"
-
-#include "client.h"
-#include "configuration.h"
-
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-BotCheckerWindow *botCheckerWindow = nullptr;
-
-BotCheckerWindow::BotCheckerWindow() :
- // TRANSLATORS: bot checker window header
- Window(_("Bot Checker"), Modal_false, nullptr, "botchecker.xml"),
- ActionListener(),
- mTableModel(new UsersTableModel(this)),
- mTable(new GuiTable(this, mTableModel)),
- playersScrollArea(new ScrollArea(this, mTable, true,
- "bochecker_background.xml")),
- mPlayerTableTitleModel(new StaticTableModel(1, COLUMNS_NR)),
- mPlayerTitleTable(new GuiTable(this, mPlayerTableTitleModel)),
- // TRANSLATORS: bot checker window button
- mIncButton(new Button(this, _("Reset"), "reset", this)),
- mLastUpdateTime(0),
- mNeedUpdate(false),
- mBotcheckerEnabled(false)
-{
- const int w = 500;
- const int h = 250;
-
- setSaveVisible(true);
-
- if (setupWindow)
- setupWindow->registerWindowForReset(this);
-
- mTable->setOpaque(false);
- mTable->setLinewiseSelection(true);
- mTable->setWrappingEnabled(true);
- mTable->setActionEventId("skill");
- mTable->addActionListener(this);
-
- mPlayerTableTitleModel->fixColumnWidth(NAME_COLUMN, NAME_COLUMN_WIDTH);
-
- for (int f = 0; f < 4; f++)
- {
- mPlayerTableTitleModel->fixColumnWidth(
- TIME_COLUMN + f, TIME_COLUMN_WIDTH);
- }
-
- mPlayerTitleTable->setHeight(1);
- mPlayerTitleTable->setBackgroundColor(getThemeColor(
- Theme::TABLE_BACKGROUND));
- mPlayerTitleTable->setSelectable(false);
-
- // TRANSLATORS: bot checker window table header
- mPlayerTableTitleModel->set(0, 0, new Label(this, _("Name")));
- // TRANSLATORS: bot checker window table header
- mPlayerTableTitleModel->set(0, 1, new Label(this, _("Attack")));
- // TRANSLATORS: bot checker window table header
- mPlayerTableTitleModel->set(0, 2, new Label(this, _("Talk")));
- // TRANSLATORS: bot checker window table header
- mPlayerTableTitleModel->set(0, 3, new Label(this, _("Move")));
- // TRANSLATORS: bot checker window table header
- mPlayerTableTitleModel->set(0, 4, new Label(this, _("Result")));
-
- mPlayerTitleTable->setLinewiseSelection(true);
-
- setWindowName("BotCheckerWindow");
- setCloseButton(true);
- setStickyButtonLock(true);
- setDefaultSize(w, h, ImageRect::CENTER);
-
- playersScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
- mIncButton->adjustSize();
-
- const int pad4 = mPadding * 4;
- int y = mPadding;
- mPlayerTitleTable->setPosition(mPadding, y);
- mPlayerTitleTable->setWidth(w - pad4);
- mPlayerTitleTable->setHeight(20);
-
- y += 20 + mPadding;
- playersScrollArea->setPosition(mPadding, y);
- playersScrollArea->setWidth(w - pad4);
- const int scrollHeight = h - y - mTitleBarHeight - mPadding * 3
- - mIncButton->getHeight();
- playersScrollArea->setHeight(scrollHeight);
- y += scrollHeight + mPadding;
-
- mIncButton->setPosition(mPadding, y);
-
- mLastHost += 0x1234;
-
- add(mPlayerTitleTable);
- add(playersScrollArea);
- add(mIncButton);
-
- center();
-
- setWidth(w);
- setHeight(h);
- loadWindowState();
- enableVisibleSound(true);
-
- config.addListener("enableBotCheker", this);
- mBotcheckerEnabled = config.getBoolValue("enableBotCheker");
-}
-
-BotCheckerWindow::~BotCheckerWindow()
-{
- config.removeListener("enableBotCheker", this);
- CHECKLISTENERS
-}
-
-void BotCheckerWindow::slowLogic()
-{
- BLOCK_START("BotCheckerWindow::slowLogic")
- if (mBotcheckerEnabled && mTableModel)
- {
- const unsigned int nowTime = cur_time;
- if (nowTime - mLastUpdateTime > 5 && mNeedUpdate)
- {
- mTableModel->playersUpdated();
- mNeedUpdate = false;
- mLastUpdateTime = nowTime;
- }
- else if (nowTime - mLastUpdateTime > 15)
- {
- mTableModel->playersUpdated();
- mNeedUpdate = false;
- mLastUpdateTime = nowTime;
- }
- }
- BLOCK_END("BotCheckerWindow::slowLogic")
-}
-
-void BotCheckerWindow::action(const ActionEvent &event)
-{
- if (event.getId() == "reset")
- {
- reset();
- mNeedUpdate = true;
- }
-}
-
-void BotCheckerWindow::update()
-{
-}
-
-void BotCheckerWindow::updateList()
-{
- if (mTableModel)
- mNeedUpdate = true;
-}
-
-void BotCheckerWindow::reset()
-{
- if (actorManager)
- {
- std::set<ActorSprite*> beings = actorManager->getAll();
- FOR_EACH (ActorSprites::iterator, i, beings)
- {
- if ((*i)->getType() == ActorType::Player)
- {
- Being *const being = static_cast<Being*>(*i);
- if (being != localPlayer && !being->getName().empty())
- being->resetCounters();
- }
- }
- }
-}
-
-void BotCheckerWindow::optionChanged(const std::string &name)
-{
- if (name == "enableBotCheker")
- mBotcheckerEnabled = config.getBoolValue("enableBotCheker");
-}
-
-#ifdef USE_PROFILER
-void BotCheckerWindow::logicChildren()
-{
- BLOCK_START("BotCheckerWindow::logicChildren")
- BasicContainer::logicChildren();
- BLOCK_END("BotCheckerWindow::logicChildren")
-}
-#endif
diff --git a/src/gui/windows/botcheckerwindow.h b/src/gui/windows/botcheckerwindow.h
deleted file mode 100644
index 76f06af4c..000000000
--- a/src/gui/windows/botcheckerwindow.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * Copyright (C) 2011-2015 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_WINDOWS_BOTCHECKERWINDOW_H
-#define GUI_WINDOWS_BOTCHECKERWINDOW_H
-
-#include "gui/widgets/window.h"
-
-#include "listeners/actionlistener.h"
-
-struct BOTCHK final
-{
- int16_t id; /**< Index into "botchecker_db" array */
- int16_t lv;
- int16_t sp;
-};
-
-class Button;
-class GuiTable;
-class ScrollArea;
-class UsersTableModel;
-class StaticTableModel;
-
-class BotCheckerWindow final : public Window,
- public ActionListener,
- public ConfigListener
-{
- public:
- friend class UsersTableModel;
-
- /**
- * Constructor.
- */
- BotCheckerWindow();
-
- A_DELETE_COPY(BotCheckerWindow)
-
- /**
- * Destructor.
- */
- ~BotCheckerWindow();
-
- void action(const ActionEvent &event) override final;
-
- void update();
-
- void slowLogic();
-
- void updateList();
-
- void reset();
-
- void optionChanged(const std::string &name) override final;
-
-#ifdef USE_PROFILER
- void logicChildren();
-#endif
-
- private:
- UsersTableModel *mTableModel;
- GuiTable *mTable;
- ScrollArea *playersScrollArea;
- StaticTableModel *mPlayerTableTitleModel;
- GuiTable *mPlayerTitleTable;
- Button *mIncButton;
- int mLastUpdateTime;
- bool mNeedUpdate;
- bool mBotcheckerEnabled;
-};
-
-extern BotCheckerWindow *botCheckerWindow;
-
-#endif // GUI_WINDOWS_BOTCHECKERWINDOW_H