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/widgets/tabs/clanwindowtabs.h" |
23 |
|
|
|
24 |
|
|
#include "being/localclan.h" |
25 |
|
|
|
26 |
|
|
#include "gui/widgets/containerplacer.h" |
27 |
|
|
#include "gui/widgets/label.h" |
28 |
|
|
#include "gui/widgets/layouthelper.h" |
29 |
|
|
|
30 |
|
|
#include "utils/foreach.h" |
31 |
|
|
#include "utils/gettext.h" |
32 |
|
|
#include "utils/stringutils.h" |
33 |
|
|
|
34 |
|
|
#include "debug.h" |
35 |
|
|
|
36 |
|
1 |
InfoClanTab::InfoClanTab(const Widget2 *const widget) : |
37 |
|
|
Container(widget), |
38 |
✓✗✓✗
|
1 |
mNameLabel(new Label(this, " ")), |
39 |
✓✗✓✗
|
1 |
mMasterLabel(new Label(this, " ")), |
40 |
✓✗✓✗ ✓✗✓✗ ✓✗ |
11 |
mMapLabel(new Label(this, " ")) |
41 |
|
|
{ |
42 |
|
2 |
setSelectable(false); |
43 |
|
|
|
44 |
✓✗ |
2 |
LayoutHelper h(this); |
45 |
✓✗ |
1 |
ContainerPlacer place = h.getPlacer(0, 0); |
46 |
|
|
|
47 |
✓✗ |
1 |
place(0, 0, mNameLabel, 2, 1); |
48 |
✓✗ |
1 |
place(0, 1, mMasterLabel, 2, 1); |
49 |
✓✗ |
1 |
place(0, 2, mMapLabel, 2, 1); |
50 |
|
|
|
51 |
|
|
place.getCell().matchColWidth(0, 0); |
52 |
✓✗ |
1 |
setDimension(Rect(0, 0, 600, 300)); |
53 |
|
1 |
} |
54 |
|
|
|
55 |
|
1 |
void InfoClanTab::resetClan() |
56 |
|
|
{ |
57 |
|
|
// TRANSLATORS: not in clan label |
58 |
✓✗ |
4 |
mNameLabel->setCaption(_("Not in clan")); |
59 |
✓✗ |
2 |
mMasterLabel->setCaption(std::string()); |
60 |
✓✗ |
2 |
mMapLabel->setCaption(std::string()); |
61 |
|
1 |
} |
62 |
|
|
|
63 |
|
|
void InfoClanTab::updateClan() |
64 |
|
|
{ |
65 |
|
|
mNameLabel->setCaption(strprintf("%s: %s", |
66 |
|
|
// TRANSLATORS: clan name label |
67 |
|
|
_("Clan name"), |
68 |
|
|
localClan.name.c_str())); |
69 |
|
|
mMasterLabel->setCaption(strprintf("%s: %s", |
70 |
|
|
// TRANSLATORS: clan master name label |
71 |
|
|
_("Master name"), |
72 |
|
|
localClan.masterName.c_str())); |
73 |
|
|
mMapLabel->setCaption(strprintf("%s: %s", |
74 |
|
|
// TRANSLATORS: clan map name label |
75 |
|
|
_("Map name"), |
76 |
|
|
localClan.mapName.c_str())); |
77 |
|
|
} |
78 |
|
|
|
79 |
|
1 |
StatsClanTab::StatsClanTab(const Widget2 *const widget) : |
80 |
|
|
Container(widget), |
81 |
|
2 |
mLabels() |
82 |
|
|
{ |
83 |
|
2 |
setSelectable(false); |
84 |
|
1 |
} |
85 |
|
|
|
86 |
|
1 |
void StatsClanTab::clearLabels() |
87 |
|
|
{ |
88 |
✗✓ |
4 |
FOR_EACH (STD_VECTOR<Label*>::iterator, it, mLabels) |
89 |
|
|
{ |
90 |
|
|
remove(*it); |
91 |
|
|
delete *it; |
92 |
|
|
} |
93 |
|
2 |
mLabels.clear(); |
94 |
|
1 |
} |
95 |
|
|
|
96 |
|
1 |
void StatsClanTab::resetClan() |
97 |
|
|
{ |
98 |
|
1 |
clearLabels(); |
99 |
|
1 |
} |
100 |
|
|
|
101 |
|
|
|
102 |
|
|
void StatsClanTab::updateClan() |
103 |
|
|
{ |
104 |
|
|
clearLabels(); |
105 |
|
|
|
106 |
|
|
LayoutHelper h(this); |
107 |
|
|
|
108 |
|
|
const int hPadding = h.getLayout().getHPadding(); |
109 |
|
|
const int vPadding = h.getLayout().getVPadding(); |
110 |
|
|
int y = vPadding; |
111 |
|
|
FOR_EACH (STD_VECTOR<std::string>::const_iterator, it, localClan.stats) |
112 |
|
|
{ |
113 |
|
|
Label *const label = new Label(this, *it); |
114 |
|
|
add(label); |
115 |
|
|
label->setPosition(hPadding, y); |
116 |
|
|
label->adjustSize(); |
117 |
|
|
y += label->getHeight() + vPadding; |
118 |
|
|
mLabels.push_back(label); |
119 |
|
|
} |
120 |
|
|
} |
121 |
|
|
|
122 |
|
2 |
RelationClanTab::RelationClanTab(const Widget2 *const widget) : |
123 |
|
|
Container(widget), |
124 |
|
4 |
mLabels() |
125 |
|
|
{ |
126 |
|
4 |
setSelectable(false); |
127 |
|
2 |
} |
128 |
|
|
|
129 |
|
2 |
void RelationClanTab::clearLabels() |
130 |
|
|
{ |
131 |
✗✓ |
8 |
FOR_EACH (STD_VECTOR<Label*>::iterator, it, mLabels) |
132 |
|
|
{ |
133 |
|
|
remove(*it); |
134 |
|
|
delete *it; |
135 |
|
|
} |
136 |
|
4 |
mLabels.clear(); |
137 |
|
2 |
} |
138 |
|
|
|
139 |
|
2 |
void RelationClanTab::resetClan() |
140 |
|
|
{ |
141 |
|
2 |
clearLabels(); |
142 |
|
2 |
} |
143 |
|
|
|
144 |
|
|
void RelationClanTab::updateClan(const STD_VECTOR<std::string> &restrict names) |
145 |
|
|
{ |
146 |
|
|
clearLabels(); |
147 |
|
|
|
148 |
|
|
LayoutHelper h(this); |
149 |
|
|
|
150 |
|
|
const int hPadding = h.getLayout().getHPadding(); |
151 |
|
|
const int vPadding = h.getLayout().getVPadding(); |
152 |
|
|
int y = vPadding; |
153 |
|
|
FOR_EACH (STD_VECTOR<std::string>::const_iterator, it, names) |
154 |
|
|
{ |
155 |
|
|
Label *const label = new Label(this, *it); |
156 |
|
|
add(label); |
157 |
|
|
label->setPosition(hPadding, y); |
158 |
|
|
label->adjustSize(); |
159 |
|
|
y += label->getHeight() + vPadding; |
160 |
|
|
mLabels.push_back(label); |
161 |
|
|
} |
162 |
|
|
} |