ManaPlus
clanwindow.cpp
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2011-2019 The ManaPlus Developers
4  * Copyright (C) 2019-2021 Andrei Karas
5  *
6  * This file is part of The ManaPlus Client.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #include "gui/windows/clanwindow.h"
23 
24 #include "being/localclan.h"
25 
27 
29 #include "gui/widgets/tabbedarea.h"
30 
32 
33 #include "utils/delete2.h"
34 #include "utils/gettext.h"
35 
36 #include "debug.h"
37 
39 
41  // TRANSLATORS: clan window name
42  Window(_("Clan"), Modal_false, nullptr, "clan.xml"),
43  mTabs(CREATEWIDGETR(TabbedArea, this)),
44  mInfoWidget(new InfoClanTab(this)),
45  mStatsWidget(new StatsClanTab(this)),
46  mAllyWidget(new RelationClanTab(this)),
47  mAntagonistWidget(new RelationClanTab(this))
48 {
49  setWindowName("clan");
50  if (setupWindow != nullptr)
52 
53  setResizable(true);
54  setCloseButton(true);
55  setSaveVisible(true);
56  setStickyButtonLock(true);
57 
58  setDefaultSize(400, 300, ImagePosition::CENTER, 0, 0);
59 
60  mTabs->setSelectable(false);
63  // TRANSLATORS: clan window tab
64  mTabs->addTab(std::string(_("Info")), mInfoWidget);
65  // TRANSLATORS: clan window tab
66  mTabs->addTab(std::string(_("Stats")), mStatsWidget);
67  // TRANSLATORS: clan window tab
68  mTabs->addTab(std::string(_("Ally")), mAllyWidget);
69  // TRANSLATORS: clan window tab
70  mTabs->addTab(std::string(_("Antagonist")), mAntagonistWidget);
71 
72  mTabs->setDimension(Rect(0, 0, 600, 300));
73 
74  const int w = mDimension.width;
75  const int h = mDimension.height;
76  mInfoWidget->setDimension(Rect(0, 0, w, h));
77  mStatsWidget->setDimension(Rect(0, 0, w, h));
78  mAllyWidget->setDimension(Rect(0, 0, w, h));
79  mAntagonistWidget->setDimension(Rect(0, 0, w, h));
81  enableVisibleSound(true);
82  resetClan();
83 }
84 
86 {
91 }
92 
94 {
96  add(mTabs);
97 }
98 
100 {
101  BLOCK_START("ClanWindow::slowLogic")
102  if (!isWindowVisible() || (mTabs == nullptr))
103  {
104  BLOCK_END("ClanWindow::slowLogic")
105  return;
106  }
107 
108  switch (mTabs->getSelectedTabIndex())
109  {
110  default:
111  case 0:
112  mInfoWidget->logic();
113  break;
114  case 1:
115  mStatsWidget->logic();
116  break;
117  case 2:
118  mAllyWidget->logic();
119  break;
120  case 3:
122  break;
123  }
124 
125  BLOCK_END("ClanWindow::slowLogic")
126 }
127 
129 {
130  Window::widgetResized(event);
131 
132  mTabs->setDimension(Rect(0, 0,
134 }
135 
137 {
142 }
143 
145 {
150 }
151 
153 {
154 }
155 
156 #ifdef USE_PROFILER
158 {
159  BLOCK_START("ClanWindow::logicChildren")
162 }
163 #endif // USE_PROFILER
ClanWindow * clanWindow
Definition: clanwindow.cpp:38
virtual void add(Widget *const widget)
virtual void logicChildren()
void slowLogic()
Definition: clanwindow.cpp:99
InfoClanTab * mInfoWidget
Definition: clanwindow.h:70
void resetClan()
Definition: clanwindow.cpp:144
TabbedArea * mTabs
Definition: clanwindow.h:69
RelationClanTab * mAllyWidget
Definition: clanwindow.h:72
RelationClanTab * mAntagonistWidget
Definition: clanwindow.h:73
void updateClan()
Definition: clanwindow.cpp:136
void postInit()
Definition: clanwindow.cpp:93
StatsClanTab * mStatsWidget
Definition: clanwindow.h:71
void widgetResized(const Event &event)
Definition: clanwindow.cpp:128
void updateClanMembers()
Definition: clanwindow.cpp:152
Definition: event.h:79
Definition: rect.h:74
int width
Definition: rect.h:219
int height
Definition: rect.h:224
void updateClan(const std::vector< std::string > &names)
void registerWindowForReset(Window *const window)
Widget * getTabContainer() const
Definition: tabbedarea.h:241
int getSelectedTabIndex() const
Definition: tabbedarea.cpp:449
Widget * getWidgetContainer() const
Definition: tabbedarea.h:244
void setDimension(const Rect &dimension)
Definition: tabbedarea.cpp:771
void addTab(Tab *const tab, Widget *const widget)
Definition: tabbedarea.cpp:238
Rect mDimension
Definition: widget.h:1101
void setDimension(const Rect &dimension)
Definition: widget.cpp:169
void setSelectable(const bool selectable)
Definition: widget.h:948
Definition: window.h:102
void setSaveVisible(const bool save)
Definition: window.h:300
void setResizable(const bool resize)
Definition: window.cpp:627
bool isWindowVisible() const
Definition: window.h:484
void setWindowName(const std::string &name)
Definition: window.h:355
void postInit()
Definition: window.cpp:249
void enableVisibleSound(bool b)
Definition: window.h:481
void widgetResized(const Event &event)
Definition: window.cpp:655
void setCloseButton(const bool flag)
Definition: window.cpp:749
void setStickyButtonLock(const bool sticky)
Definition: window.cpp:772
void setDefaultSize()
Definition: window.cpp:1198
void loadWindowState()
Definition: window.cpp:1087
#define CREATEWIDGETR(type,...)
Definition: createwidget.h:36
#define new
Definition: debug_new.h:147
#define delete2(var)
Definition: delete2.h:25
#define _(s)
Definition: gettext.h:35
LocalClan localClan
Definition: localclan.cpp:26
#define nullptr
Definition: localconsts.h:45
const bool Modal_false
Definition: modal.h:30
#define BLOCK_END(name)
Definition: perfomance.h:80
#define BLOCK_START(name)
Definition: perfomance.h:79
SetupWindow * setupWindow
Definition: setupwindow.cpp:64
std::vector< std::string > allyClans
Definition: localclan.h:61
std::vector< std::string > antagonistClans
Definition: localclan.h:62