1 #include "ResourceBrowseWnd.h"
2
3 #include "../util/i18n.h"
4 #include "CUIControls.h"
5
6 namespace {
7 const int EDGE_PAD(3);
8 const GG::Y ICON_BROWSE_ICON_HEIGHT(64);
9
BrowseTextWidth()10 const GG::X BrowseTextWidth()
11 { return GG::X(FontBasedUpscale(200)); }
12 }
13
14 ////////////////////////////////////////////////////////////
15 // ResourceBrowseWnd
16 ////////////////////////////////////////////////////////////
ResourceBrowseWnd(const std::string & title_text,const std::string & unit_label,float used,float output,float target_output,bool show_stockpile,float stockpile_use,float stockpile,float stockpile_change,bool show_stockpile_limit,float stockpile_use_limit)17 ResourceBrowseWnd::ResourceBrowseWnd(const std::string& title_text,
18 const std::string& unit_label,
19 float used,
20 float output,
21 float target_output,
22 bool show_stockpile /*=false*/,
23 float stockpile_use /*=0.0f*/,
24 float stockpile /*=0.0f*/,
25 float stockpile_change /*=0.0f*/,
26 bool show_stockpile_limit /* = false*/,
27 float stockpile_use_limit /*= 0.0f*/) :
28 GG::BrowseInfoWnd(GG::X0, GG::Y0, BrowseTextWidth(), GG::Y1),
29 m_title_text(GG::Wnd::Create<CUILabel>(title_text, GG::FORMAT_CENTER)),
30 m_show_points(used >= 0.0f),
31 m_used_points_label(GG::Wnd::Create<CUILabel>(UserString("RESOURCE_TT_USED"), GG::FORMAT_RIGHT)),
32 m_used_points(GG::Wnd::Create<CUILabel>(DoubleToString(used, 3, false), GG::FORMAT_LEFT)),
33 m_used_points_P_label(GG::Wnd::Create<CUILabel>(unit_label, GG::FORMAT_LEFT)),
34 m_output_points_label(GG::Wnd::Create<CUILabel>(UserString("RESOURCE_TT_OUTPUT"), GG::FORMAT_RIGHT)),
35 m_output_points(GG::Wnd::Create<CUILabel>(DoubleToString(output, 3, false), GG::FORMAT_LEFT)),
36 m_output_points_P_label(GG::Wnd::Create<CUILabel>(unit_label, GG::FORMAT_LEFT)),
37 m_target_points_label(GG::Wnd::Create<CUILabel>(UserString("RESOURCE_TT_TARGET_OUTPUT"), GG::FORMAT_RIGHT)),
38 m_target_points(GG::Wnd::Create<CUILabel>(DoubleToString(target_output, 3, false), GG::FORMAT_LEFT)),
39 m_target_points_P_label(GG::Wnd::Create<CUILabel>(unit_label, GG::FORMAT_LEFT)),
40 m_show_stockpile(show_stockpile),
41 m_stockpile_points_label(GG::Wnd::Create<CUILabel>(UserString("STOCKPILE_LABEL"), GG::FORMAT_RIGHT)),
42 m_stockpile_points(GG::Wnd::Create<CUILabel>(DoubleToString(stockpile, 3, false), GG::FORMAT_LEFT)),
43 m_stockpile_points_P_label(GG::Wnd::Create<CUILabel>(unit_label, GG::FORMAT_LEFT)),
44 m_stockpile_used_points_label(GG::Wnd::Create<CUILabel>(UserString("STOCKPILE_USE_LABEL"), GG::FORMAT_RIGHT)),
45 m_stockpile_used_points(GG::Wnd::Create<CUILabel>(DoubleToString(stockpile_use, 3, false), GG::FORMAT_LEFT)),
46 m_stockpile_used_points_P_label(GG::Wnd::Create<CUILabel>(unit_label, GG::FORMAT_LEFT)),
47 m_stockpile_change_points_label(GG::Wnd::Create<CUILabel>(UserString("STOCKPILE_CHANGE_LABEL"), GG::FORMAT_RIGHT)),
48 m_stockpile_change_points(GG::Wnd::Create<CUILabel>(DoubleToString(stockpile_change, 3, false), GG::FORMAT_LEFT)),
49 m_stockpile_change_points_P_label(GG::Wnd::Create<CUILabel>(unit_label, GG::FORMAT_LEFT)),
50 m_offset(GG::X0, ICON_BROWSE_ICON_HEIGHT/2),
51 m_show_stockpile_limit(show_stockpile_limit)
52 {
53 if (!m_show_points && m_show_stockpile_limit) {
54 // replace usage with with stockpile limits
55 m_output_points_label->SetText(UserString("STOCKPILE_USE_LIMIT"));
56 m_output_points->SetText(DoubleToString(stockpile_use_limit, 3, false));
57 }
58 }
59
CompleteConstruction()60 void ResourceBrowseWnd::CompleteConstruction() {
61 GG::BrowseInfoWnd::CompleteConstruction();
62
63 const GG::Y ROW_HEIGHT(ClientUI::Pts() * 4 / 3);
64
65 GG::Pt top_left = m_offset;
66
67 m_title_text->MoveTo(GG::Pt(top_left.x + EDGE_PAD, top_left.y));
68 m_title_text->Resize(GG::Pt(BrowseTextWidth() - 2 * EDGE_PAD, ROW_HEIGHT));
69 m_title_text->SetFont(ClientUI::GetBoldFont());
70 top_left.y += m_title_text->Height() + EDGE_PAD;
71
72 AttachChild(m_title_text);
73
74
75 // info controls layout
76 const int STAT_TEXT_PTS = ClientUI::Pts();
77 const int CENTERLINE_GAP = 4;
78 const GG::X LABEL_TEXT_WIDTH = (Width() - 4 - CENTERLINE_GAP) * 2 / 3;
79 const GG::X VALUE_TEXT_WIDTH = Width() - 4 - CENTERLINE_GAP - LABEL_TEXT_WIDTH;
80 const GG::X LEFT_TEXT_X(0);
81 const GG::X RIGHT_TEXT_X = LEFT_TEXT_X + LABEL_TEXT_WIDTH + 8 + CENTERLINE_GAP;
82 const GG::X P_LABEL_X = RIGHT_TEXT_X + FontBasedUpscale(40);
83
84 std::pair<int, int> m_center_gap(Value(LABEL_TEXT_WIDTH + 2), Value(LABEL_TEXT_WIDTH + 2 + CENTERLINE_GAP));
85
86 const GG::Pt LABEL_TEXT_SIZE(LABEL_TEXT_WIDTH, GG::Y(STAT_TEXT_PTS + 4));
87 const GG::Pt VALUE_TEXT_SIZE(VALUE_TEXT_WIDTH, GG::Y(STAT_TEXT_PTS + 4));
88 const GG::Pt P_LABEL_SIZE(Width() - 2 - 5 - P_LABEL_X, GG::Y(STAT_TEXT_PTS + 4));
89
90
91
92 AttachChild(m_used_points_label);
93 AttachChild(m_used_points);
94 AttachChild(m_used_points_P_label);
95 AttachChild(m_output_points_label);
96 AttachChild(m_output_points);
97 AttachChild(m_output_points_P_label);
98 AttachChild(m_target_points_label);
99 AttachChild(m_target_points);
100 AttachChild(m_target_points_P_label);
101
102 if (m_show_points) {
103 m_used_points_label->MoveTo(GG::Pt(top_left.x + LEFT_TEXT_X, top_left.y));
104 m_used_points_label->Resize(LABEL_TEXT_SIZE);
105 m_used_points->MoveTo(GG::Pt(top_left.x + RIGHT_TEXT_X, top_left.y));
106 m_used_points->Resize(VALUE_TEXT_SIZE);
107 m_used_points_P_label->MoveTo(GG::Pt(top_left.x + P_LABEL_X, top_left.y));
108 m_used_points_P_label->Resize(P_LABEL_SIZE);
109 top_left.y += m_used_points_label->Height();
110
111 m_output_points_label->MoveTo(GG::Pt(top_left.x + LEFT_TEXT_X, top_left.y));
112 m_output_points_label->Resize(LABEL_TEXT_SIZE);
113 m_output_points->MoveTo(GG::Pt(top_left.x + RIGHT_TEXT_X, top_left.y));
114 m_output_points->Resize(VALUE_TEXT_SIZE);
115 m_output_points_P_label->MoveTo(GG::Pt(top_left.x + P_LABEL_X, top_left.y));
116 m_output_points_P_label->Resize(P_LABEL_SIZE);
117 top_left.y += m_output_points_label->Height();
118
119 m_target_points_label->MoveTo(GG::Pt(top_left.x + LEFT_TEXT_X, top_left.y));
120 m_target_points_label->Resize(LABEL_TEXT_SIZE);
121 m_target_points->MoveTo(GG::Pt(top_left.x + RIGHT_TEXT_X, top_left.y));
122 m_target_points->Resize(VALUE_TEXT_SIZE);
123 m_target_points_P_label->MoveTo(GG::Pt(top_left.x + P_LABEL_X, top_left.y));
124 m_target_points_P_label->Resize(P_LABEL_SIZE);
125 top_left.y += m_target_points_label->Height();
126 } else {
127 m_used_points_label->Hide();
128 m_used_points->Hide();
129 m_used_points_P_label->Hide();
130
131 m_output_points_label->Hide();
132 m_output_points->Hide();
133 m_output_points_P_label->Hide();
134
135 m_target_points_label->Hide();
136 m_target_points->Hide();
137 m_target_points_P_label->Hide();
138 }
139 AttachChild(m_stockpile_points_label);
140 AttachChild(m_stockpile_points);
141 AttachChild(m_stockpile_points_P_label);
142 AttachChild(m_stockpile_used_points_label);
143 AttachChild(m_stockpile_used_points);
144 AttachChild(m_stockpile_used_points_P_label);
145 AttachChild(m_stockpile_change_points_label);
146 AttachChild(m_stockpile_change_points);
147 AttachChild(m_stockpile_change_points_P_label);
148
149 if (m_show_stockpile) {
150 m_stockpile_used_points_label->MoveTo(GG::Pt(top_left.x + LEFT_TEXT_X, top_left.y));
151 m_stockpile_used_points_label->Resize(LABEL_TEXT_SIZE);
152 m_stockpile_used_points->MoveTo(GG::Pt(top_left.x + RIGHT_TEXT_X, top_left.y));
153 m_stockpile_used_points->Resize(VALUE_TEXT_SIZE);
154 m_stockpile_used_points_P_label->MoveTo(GG::Pt(top_left.x + P_LABEL_X, top_left.y));
155 m_stockpile_used_points_P_label->Resize(P_LABEL_SIZE);
156 top_left.y += m_stockpile_used_points_label->Height();
157 } else {
158 m_stockpile_used_points_label->Hide();
159 m_stockpile_used_points->Hide();
160 m_stockpile_used_points_P_label->Hide();
161 }
162
163 if (!m_show_points && m_show_stockpile_limit) {
164 m_output_points_label->MoveTo(GG::Pt(top_left.x + LEFT_TEXT_X, top_left.y));
165 m_output_points_label->Resize(LABEL_TEXT_SIZE);
166 m_output_points->MoveTo(GG::Pt(top_left.x + RIGHT_TEXT_X, top_left.y));
167 m_output_points->Resize(VALUE_TEXT_SIZE);
168 m_output_points_P_label->MoveTo(GG::Pt(top_left.x + P_LABEL_X, top_left.y));
169 m_output_points_P_label->Resize(P_LABEL_SIZE);
170 top_left.y += m_output_points_label->Height();
171
172 m_output_points_label->Show();
173 m_output_points->Show();
174 m_output_points_P_label->Show();
175 }
176
177 if (m_show_stockpile) {
178 m_stockpile_points_label->MoveTo(GG::Pt(top_left.x + LEFT_TEXT_X, top_left.y));
179 m_stockpile_points_label->Resize(LABEL_TEXT_SIZE);
180 m_stockpile_points->MoveTo(GG::Pt(top_left.x + RIGHT_TEXT_X, top_left.y));
181 m_stockpile_points->Resize(VALUE_TEXT_SIZE);
182 m_stockpile_points_P_label->MoveTo(GG::Pt(top_left.x + P_LABEL_X, top_left.y));
183 m_stockpile_points_P_label->Resize(P_LABEL_SIZE);
184 top_left.y += m_stockpile_points_label->Height();
185
186 m_stockpile_change_points_label->MoveTo(GG::Pt(top_left.x + LEFT_TEXT_X, top_left.y));
187 m_stockpile_change_points_label->Resize(LABEL_TEXT_SIZE);
188 m_stockpile_change_points->MoveTo(GG::Pt(top_left.x + RIGHT_TEXT_X, top_left.y));
189 m_stockpile_change_points->Resize(VALUE_TEXT_SIZE);
190 m_stockpile_change_points_P_label->MoveTo(GG::Pt(top_left.x + P_LABEL_X, top_left.y));
191 m_stockpile_change_points_P_label->Resize(P_LABEL_SIZE);
192 top_left.y += m_stockpile_change_points_label->Height();
193 } else {
194 m_stockpile_points_label->Hide();
195 m_stockpile_points->Hide();
196 m_stockpile_points_P_label->Hide();
197 m_stockpile_change_points_label->Hide();
198 m_stockpile_change_points->Hide();
199 m_stockpile_change_points_P_label->Hide();
200 }
201
202 // background / border rendering prep
203 Resize(GG::Pt(BrowseTextWidth(), top_left.y + EDGE_PAD - m_offset.y));
204
205 InitBuffer();
206 }
207
WndHasBrowseInfo(const Wnd * wnd,std::size_t mode) const208 bool ResourceBrowseWnd::WndHasBrowseInfo(const Wnd* wnd, std::size_t mode) const {
209 assert(mode <= wnd->BrowseModes().size());
210 return true;
211 }
212
InitBuffer()213 void ResourceBrowseWnd::InitBuffer() {
214 GG::Pt sz = Size();
215 const float ROW_HEIGHT(ClientUI::Pts()*4.0/3.0);
216
217 m_buffer.clear();
218
219 m_buffer.store(static_cast<float>(Value(sz.x)), ROW_HEIGHT);
220 m_buffer.store(0.0f, ROW_HEIGHT);
221
222 m_buffer.store(0.0f, 0.0f);
223 m_buffer.store(static_cast<float>(Value(sz.x)), 0.0f);
224 m_buffer.store(static_cast<float>(Value(sz.x)), static_cast<float>(Value(sz.y)));
225 m_buffer.store(0.0f, static_cast<float>(Value(sz.y)));
226 m_buffer.createServerBuffer();
227 }
228
Render()229 void ResourceBrowseWnd::Render() {
230 GG::Pt ul = UpperLeft();
231
232 glPushMatrix();
233 glLoadIdentity();
234 glTranslatef(static_cast<GLfloat>(Value(m_offset.x + ul.x)),
235 static_cast<GLfloat>(Value(m_offset.y + ul.y)),
236 0.0f);
237 glDisable(GL_TEXTURE_2D);
238 glLineWidth(1.0);
239 glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS);
240 glEnableClientState(GL_VERTEX_ARRAY);
241
242 m_buffer.activate();
243 glColor(ClientUI::WndColor());
244 glDrawArrays(GL_TRIANGLE_FAN, 2, 4);
245 glColor(ClientUI::WndOuterBorderColor());
246 glDrawArrays(GL_LINE_LOOP, 2, 4);
247 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
248
249 glEnable(GL_TEXTURE_2D);
250 glPopMatrix();
251 glPopClientAttrib();
252 }
253
254
255 ////////////////////////////////////////////////////////////
256 // WastedStockpiledResourceBrowseWnd
257 ////////////////////////////////////////////////////////////
WastedStockpiledResourceBrowseWnd(const std::string & title_text,const std::string & unit_label,float capacity,float excess,bool show_stockpile,float stockpile_effic,float to_stockpile,float wasted,const std::string & bottom_message)258 WastedStockpiledResourceBrowseWnd::WastedStockpiledResourceBrowseWnd(
259 const std::string& title_text, const std::string& unit_label,
260 float capacity, float excess, bool show_stockpile/* = false*/,
261 float stockpile_effic/* = 0.0f*/, float to_stockpile/* = 0.0f*/,
262 float wasted/* = 0.0f*/, const std::string& bottom_message/* = ""*/) :
263 GG::BrowseInfoWnd(GG::X0, GG::Y0, BrowseTextWidth(), GG::Y1),
264 m_buffer(),
265 m_title_text(GG::Wnd::Create<CUILabel>(title_text, GG::FORMAT_CENTER)),
266
267 m_output_label(GG::Wnd::Create<CUILabel>(UserString("RESOURCE_TT_OUTPUT"), GG::FORMAT_RIGHT)),
268 m_output(GG::Wnd::Create<CUILabel>(DoubleToString(capacity, 3, false), GG::FORMAT_LEFT)),
269 m_output_P_label(GG::Wnd::Create<CUILabel>(unit_label, GG::FORMAT_LEFT)),
270 m_used_label(GG::Wnd::Create<CUILabel>(UserString("RESOURCE_TT_USED"), GG::FORMAT_RIGHT)),
271 m_used(GG::Wnd::Create<CUILabel>(DoubleToString(std::max(0.0f, capacity - excess), 3, false), GG::FORMAT_LEFT)),
272 m_used_P_label(GG::Wnd::Create<CUILabel>(unit_label, GG::FORMAT_LEFT)),
273 m_excess_label(GG::Wnd::Create<CUILabel>(UserString("RESOURCE_TT_EXCESS"), GG::FORMAT_RIGHT)),
274 m_excess(GG::Wnd::Create<CUILabel>(DoubleToString(excess, 3, false), GG::FORMAT_LEFT)),
275 m_excess_P_label(GG::Wnd::Create<CUILabel>(unit_label, GG::FORMAT_LEFT)),
276
277 m_show_stockpile(show_stockpile),
278
279 m_stockpile_label(GG::Wnd::Create<CUILabel>(UserString("RESOURCE_TT_TO_STOCKPILE"), GG::FORMAT_RIGHT)),
280 m_stockpile(GG::Wnd::Create<CUILabel>(DoubleToString(to_stockpile, 3, false), GG::FORMAT_LEFT)),
281 m_stockpile_P_label(GG::Wnd::Create<CUILabel>(unit_label, GG::FORMAT_LEFT)),
282
283 m_wasted_label(GG::Wnd::Create<CUILabel>(UserString("RESOURCE_TT_WASTED"), GG::FORMAT_RIGHT)),
284 m_wasted(GG::Wnd::Create<CUILabel>(DoubleToString(wasted, 3, false), GG::FORMAT_LEFT)),
285 m_wasted_P_label(GG::Wnd::Create<CUILabel>(unit_label, GG::FORMAT_LEFT)),
286
287 m_bottom_message_text(GG::Wnd::Create<CUILabel>(
288 bottom_message,
289 GG::FORMAT_LEFT | GG::FORMAT_WORDBREAK | GG::FORMAT_LINEWRAP | GG::FORMAT_TOP)),
290
291 m_offset(GG::X0, ICON_BROWSE_ICON_HEIGHT/2)
292 {}
293
CompleteConstruction()294 void WastedStockpiledResourceBrowseWnd::CompleteConstruction() {
295 GG::BrowseInfoWnd::CompleteConstruction();
296
297 const GG::Y ROW_HEIGHT(ClientUI::Pts() * 4 / 3);
298
299 GG::Pt top_left = m_offset;
300
301 m_title_text->MoveTo(GG::Pt(top_left.x + EDGE_PAD, top_left.y));
302 m_title_text->Resize(GG::Pt(BrowseTextWidth() - 2 * EDGE_PAD, ROW_HEIGHT));
303 m_title_text->SetFont(ClientUI::GetBoldFont());
304 top_left.y += m_title_text->Height() + EDGE_PAD;
305
306 AttachChild(m_title_text);
307
308
309 // info controls layout
310 const int STAT_TEXT_PTS = ClientUI::Pts();
311 const int CENTERLINE_GAP = 4;
312 const GG::X LABEL_TEXT_WIDTH = (Width() - 4 - CENTERLINE_GAP) * 2 / 3;
313 const GG::X VALUE_TEXT_WIDTH = Width() - 4 - CENTERLINE_GAP - LABEL_TEXT_WIDTH;
314 const GG::X LEFT_TEXT_X(0);
315 const GG::X RIGHT_TEXT_X = LEFT_TEXT_X + LABEL_TEXT_WIDTH + 8 + CENTERLINE_GAP;
316 const GG::X P_LABEL_X = RIGHT_TEXT_X + FontBasedUpscale(40);
317
318 std::pair<int, int> m_center_gap(Value(LABEL_TEXT_WIDTH + 2), Value(LABEL_TEXT_WIDTH + 2 + CENTERLINE_GAP));
319
320 const GG::Pt LABEL_TEXT_SIZE(LABEL_TEXT_WIDTH, GG::Y(STAT_TEXT_PTS + 4));
321 const GG::Pt VALUE_TEXT_SIZE(VALUE_TEXT_WIDTH, GG::Y(STAT_TEXT_PTS + 4));
322 const GG::Pt P_LABEL_SIZE(Width() - 2 - 5 - P_LABEL_X, GG::Y(STAT_TEXT_PTS + 4));
323
324
325 AttachChild(m_output_label);
326 AttachChild(m_output);
327 AttachChild(m_output_P_label);
328 AttachChild(m_used_label);
329 AttachChild(m_used);
330 AttachChild(m_used_P_label);
331 AttachChild(m_excess_label);
332 AttachChild(m_excess);
333 AttachChild(m_excess_P_label);
334
335 m_output_label->MoveTo(GG::Pt(top_left.x + LEFT_TEXT_X, top_left.y));
336 m_output_label->Resize(LABEL_TEXT_SIZE);
337 m_output->MoveTo(GG::Pt(top_left.x + RIGHT_TEXT_X, top_left.y));
338 m_output->Resize(VALUE_TEXT_SIZE);
339 m_output_P_label->MoveTo(GG::Pt(top_left.x + P_LABEL_X, top_left.y));
340 m_output_P_label->Resize(P_LABEL_SIZE);
341 top_left.y += m_output_P_label->Height();
342
343 m_used_label->MoveTo(GG::Pt(top_left.x + LEFT_TEXT_X, top_left.y));
344 m_used_label->Resize(LABEL_TEXT_SIZE);
345 m_used->MoveTo(GG::Pt(top_left.x + RIGHT_TEXT_X, top_left.y));
346 m_used->Resize(VALUE_TEXT_SIZE);
347 m_used_P_label->MoveTo(GG::Pt(top_left.x + P_LABEL_X, top_left.y));
348 m_used_P_label->Resize(P_LABEL_SIZE);
349 top_left.y += m_used_P_label->Height();
350
351 m_excess_label->MoveTo(GG::Pt(top_left.x + LEFT_TEXT_X, top_left.y));
352 m_excess_label->Resize(LABEL_TEXT_SIZE);
353 m_excess->MoveTo(GG::Pt(top_left.x + RIGHT_TEXT_X, top_left.y));
354 m_excess->Resize(VALUE_TEXT_SIZE);
355 m_excess_P_label->MoveTo(GG::Pt(top_left.x + P_LABEL_X, top_left.y));
356 m_excess_P_label->Resize(P_LABEL_SIZE);
357 top_left.y += m_excess_P_label->Height();
358
359 AttachChild(m_stockpile_label);
360 AttachChild(m_stockpile);
361 AttachChild(m_stockpile_P_label);
362 AttachChild(m_wasted_label);
363 AttachChild(m_wasted);
364 AttachChild(m_wasted_P_label);
365
366 if (m_show_stockpile) {
367 m_stockpile_label->MoveTo(GG::Pt(top_left.x + LEFT_TEXT_X, top_left.y));
368 m_stockpile_label->Resize(LABEL_TEXT_SIZE);
369 m_stockpile->MoveTo(GG::Pt(top_left.x + RIGHT_TEXT_X, top_left.y));
370 m_stockpile->Resize(VALUE_TEXT_SIZE);
371 m_stockpile_P_label->MoveTo(GG::Pt(top_left.x + P_LABEL_X, top_left.y));
372 m_stockpile_P_label->Resize(P_LABEL_SIZE);
373 top_left.y += m_stockpile_P_label->Height();
374
375 m_wasted_label->MoveTo(GG::Pt(top_left.x + LEFT_TEXT_X, top_left.y));
376 m_wasted_label->Resize(LABEL_TEXT_SIZE);
377 m_wasted->MoveTo(GG::Pt(top_left.x + RIGHT_TEXT_X, top_left.y));
378 m_wasted->Resize(VALUE_TEXT_SIZE);
379 m_wasted_P_label->MoveTo(GG::Pt(top_left.x + P_LABEL_X, top_left.y));
380 m_wasted_P_label->Resize(P_LABEL_SIZE);
381 top_left.y += m_wasted_P_label->Height();
382
383 } else {
384 m_stockpile_label->Hide();
385 m_stockpile->Hide();
386 m_stockpile_P_label->Hide();
387 m_wasted_label->Hide();
388 m_wasted->Hide();
389 m_wasted_P_label->Hide();
390 }
391
392 AttachChild(m_bottom_message_text);
393 if (!m_bottom_message_text->Text().empty()) {
394 m_bottom_message_text->MoveTo(GG::Pt(top_left.x + LEFT_TEXT_X, top_left.y));
395 m_bottom_message_text->Resize(GG::Pt(BrowseTextWidth() - 2 * EDGE_PAD, GG::Y0));
396 //m_bottom_message_text->Resize(m_bottom_message_text->MinUsableSize());
397 top_left.y += m_bottom_message_text->MinUsableSize().y;
398 } else {
399 m_bottom_message_text->Hide();
400 }
401
402 // background / border rendering prep
403 Resize(GG::Pt(BrowseTextWidth(), top_left.y + EDGE_PAD - m_offset.y));
404
405 InitBuffer();
406 }
407
WndHasBrowseInfo(const Wnd * wnd,std::size_t mode) const408 bool WastedStockpiledResourceBrowseWnd::WndHasBrowseInfo(const Wnd* wnd, std::size_t mode) const {
409 assert(mode <= wnd->BrowseModes().size());
410 return true;
411 }
412
InitBuffer()413 void WastedStockpiledResourceBrowseWnd::InitBuffer() {
414 GG::Pt sz = Size();
415 const float ROW_HEIGHT(ClientUI::Pts()*4.0/3.0);
416
417 m_buffer.clear();
418
419 m_buffer.store(static_cast<float>(Value(sz.x)), ROW_HEIGHT);
420 m_buffer.store(0.0f, ROW_HEIGHT);
421
422 m_buffer.store(0.0f, 0.0f);
423 m_buffer.store(static_cast<float>(Value(sz.x)), 0.0f);
424 m_buffer.store(static_cast<float>(Value(sz.x)), static_cast<float>(Value(sz.y)));
425 m_buffer.store(0.0f, static_cast<float>(Value(sz.y)));
426 m_buffer.createServerBuffer();
427 }
428
Render()429 void WastedStockpiledResourceBrowseWnd::Render() {
430 GG::Pt ul = UpperLeft();
431
432 glPushMatrix();
433 glLoadIdentity();
434 glTranslatef(static_cast<GLfloat>(Value(m_offset.x + ul.x)),
435 static_cast<GLfloat>(Value(m_offset.y + ul.y)),
436 0.0f);
437 glDisable(GL_TEXTURE_2D);
438 glLineWidth(1.0);
439 glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS);
440 glEnableClientState(GL_VERTEX_ARRAY);
441
442 m_buffer.activate();
443 glColor(ClientUI::WndColor());
444 glDrawArrays(GL_TRIANGLE_FAN, 2, 4);
445 glColor(ClientUI::WndOuterBorderColor());
446 glDrawArrays(GL_LINE_LOOP, 2, 4);
447 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
448
449 glEnable(GL_TEXTURE_2D);
450 glPopMatrix();
451 glPopClientAttrib();
452 }
453