summaryrefslogtreecommitdiff
path: root/src/gui/windows/clanwindow.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2018-02-13 01:54:28 +0300
committerAndrei Karas <akaras@inbox.ru>2018-02-13 04:28:32 +0300
commitacba95ebb0119e7b0f9ef01d9bf3577582857253 (patch)
treeb5346c2a5642456e793b28487020cf1c727d8f07 /src/gui/windows/clanwindow.cpp
parent0a47f5c44ddd5fb5157d116ffe0f5ee5f4207eb0 (diff)
downloadmv-acba95ebb0119e7b0f9ef01d9bf3577582857253.tar.gz
mv-acba95ebb0119e7b0f9ef01d9bf3577582857253.tar.bz2
mv-acba95ebb0119e7b0f9ef01d9bf3577582857253.tar.xz
mv-acba95ebb0119e7b0f9ef01d9bf3577582857253.zip
Add clan window.
For now can be opened only by chat command /clan.
Diffstat (limited to 'src/gui/windows/clanwindow.cpp')
-rw-r--r--src/gui/windows/clanwindow.cpp163
1 files changed, 163 insertions, 0 deletions
diff --git a/src/gui/windows/clanwindow.cpp b/src/gui/windows/clanwindow.cpp
new file mode 100644
index 000000000..9d08e5914
--- /dev/null
+++ b/src/gui/windows/clanwindow.cpp
@@ -0,0 +1,163 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2018 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/clanwindow.h"
+
+#include "being/localclan.h"
+#include "being/localplayer.h"
+
+#include "gui/windows/setupwindow.h"
+
+#include "gui/widgets/createwidget.h"
+#include "gui/widgets/tabbedarea.h"
+
+#include "gui/widgets/tabs/clanwindowtabs.h"
+
+#include "utils/delete2.h"
+#include "utils/gettext.h"
+
+#include "debug.h"
+
+ClanWindow *clanWindow = nullptr;
+
+ClanWindow::ClanWindow() :
+ // TRANSLATORS: clan window name
+ Window(_("Clan"), Modal_false, nullptr, "clan.xml"),
+ mTabs(CREATEWIDGETR(TabbedArea, this)),
+ mInfoWidget(new InfoClanTab(this)),
+ mStatsWidget(new StatsClanTab(this)),
+ mAllyWidget(new RelationClanTab(this)),
+ mAntagonistWidget(new RelationClanTab(this))
+{
+ setWindowName("clan");
+ if (setupWindow != nullptr)
+ setupWindow->registerWindowForReset(this);
+
+ setResizable(true);
+ setCloseButton(true);
+ setSaveVisible(true);
+ setStickyButtonLock(true);
+
+ setDefaultSize(400, 300, ImagePosition::CENTER, 0, 0);
+
+ mTabs->setSelectable(false);
+ mTabs->getWidgetContainer()->setSelectable(false);
+ mTabs->getTabContainer()->setSelectable(false);
+ // TRANSLATORS: clan window tab
+ mTabs->addTab(std::string(_("Info")), mInfoWidget);
+ // TRANSLATORS: clan window tab
+ mTabs->addTab(std::string(_("Stats")), mStatsWidget);
+ // TRANSLATORS: clan window tab
+ mTabs->addTab(std::string(_("Ally")), mAllyWidget);
+ // TRANSLATORS: clan window tab
+ mTabs->addTab(std::string(_("Antagonist")), mAntagonistWidget);
+
+ mTabs->setDimension(Rect(0, 0, 600, 300));
+
+ const int w = mDimension.width;
+ const int h = mDimension.height;
+ mInfoWidget->setDimension(Rect(0, 0, w, h));
+ mStatsWidget->setDimension(Rect(0, 0, w, h));
+ mAllyWidget->setDimension(Rect(0, 0, w, h));
+ mAntagonistWidget->setDimension(Rect(0, 0, w, h));
+ loadWindowState();
+ enableVisibleSound(true);
+ resetClan();
+}
+
+ClanWindow::~ClanWindow()
+{
+ delete2(mInfoWidget);
+ delete2(mStatsWidget);
+ delete2(mAllyWidget);
+ delete2(mAntagonistWidget);
+}
+
+void ClanWindow::postInit()
+{
+ Window::postInit();
+ add(mTabs);
+}
+
+void ClanWindow::slowLogic()
+{
+ BLOCK_START("ClanWindow::slowLogic")
+ if (!isWindowVisible() || (mTabs == nullptr))
+ {
+ BLOCK_END("ClanWindow::slowLogic")
+ return;
+ }
+
+ switch (mTabs->getSelectedTabIndex())
+ {
+ default:
+ case 0:
+ mInfoWidget->logic();
+ break;
+ case 1:
+ mStatsWidget->logic();
+ break;
+ case 2:
+ mAllyWidget->logic();
+ break;
+ case 3:
+ mAntagonistWidget->logic();
+ break;
+ }
+
+ BLOCK_END("ClanWindow::slowLogic")
+}
+
+void ClanWindow::widgetResized(const Event &event)
+{
+ Window::widgetResized(event);
+
+ mTabs->setDimension(Rect(0, 0,
+ mDimension.width, mDimension.height));
+}
+
+void ClanWindow::updateClan()
+{
+ mInfoWidget->updateClan();
+ mStatsWidget->updateClan();
+ mAllyWidget->updateClan(localClan.allyClans);
+ mAntagonistWidget->updateClan(localClan.antagonistClans);
+}
+
+void ClanWindow::resetClan()
+{
+ mInfoWidget->resetClan();
+ mStatsWidget->resetClan();
+ mAllyWidget->resetClan();
+ mAntagonistWidget->resetClan();
+}
+
+void ClanWindow::updateClanMembers()
+{
+}
+
+#ifdef USE_PROFILER
+void ClanWindow::logicChildren()
+{
+ BLOCK_START("ClanWindow::logicChildren")
+ BasicContainer::logicChildren();
+ BLOCK_END("ClanWindow::logicChildren")
+}
+#endif // USE_PROFILER