Project Alice
Loading...
Searching...
No Matches
economy_viewer.cpp
Go to the documentation of this file.
1#include "economy_viewer.hpp"
2
3namespace economy_viewer {
4
5enum class static_elements : int32_t {
6 markets = 0,
7 factory_types = 1000,
12 commodities = 3000,
13 commodities_inputs = 4000,
19
20
21 commodities_output = 10000,
24
25 commodities_button = 10000000,
26 factory_types_button = 10000001,
28 province_name = 10000003,
29 state_def_name = 10000004,
30 factory_type_name = 10000005,
31 factory_type_total = 10000006,
32
33 priority_text = 10000007,
34 priority_text_national = 10000008,
35 priority_text_private = 10000009,
36 priority_text_bonus = 10000010,
37 priority_value_national = 10000011,
38 priority_value_private = 10000012,
39 priority_value_bonus = 10000013,
40
41 tab_name_commodity = 10005000,
42 tab_name_factory_type = 10005001,
44
45
47};
48
49void update(sys::state& state) {
50
51 auto key = state.lookup_key("alice_button_factory_type_priority");
52 auto def = state.ui_state.defs_by_name.find(key)->second.definition;
53 auto& data = state.ui_defs.gui[def];
54
55 if(state.iui_state.per_market_data.size() != state.world.market_size()) {
56 state.iui_state.per_market_data.resize(state.world.market_size());
57 }
58
59 state.iui_state.input_efficiency_leaders.clear();
60 state.iui_state.input_efficiency_leaders_string.clear();
61
62 if(state.selected_factory_type) {
63 auto& inputs = state.world.factory_type_get_inputs(state.selected_factory_type);
64 auto& e_inputs = state.world.factory_type_get_efficiency_inputs(state.selected_factory_type);
65 auto ftid = state.selected_factory_type;
66
67 state.world.for_each_market([&](dcon::market_id market) {
68 auto sid = state.world.market_get_zone_from_local_market(market);
69 auto sdif = state.world.state_instance_get_definition(sid);
70 auto nid = state.world.state_instance_get_nation_from_state_ownership(sid);
71 auto mid = market;
72
73 auto e_input_mult = state.world.nation_get_modifier_values(nid, sys::national_mod_offsets::factory_maintenance) + 1.0f;
74 auto input_mult = economy::nation_factory_input_multiplier(state, ftid, nid);
75 auto output_mult = economy::nation_factory_output_multiplier(state, ftid, nid);
76
77 float total = 0.f;
78 for(unsigned i = 0; i < inputs.set_size; i++) {
79 if(inputs.commodity_type[i]) {
80 auto cid = inputs.commodity_type[i];
81 total -= inputs.commodity_amounts[i] * input_mult * state.world.market_get_price(mid, cid);
82 }
83 }
84 for(unsigned i = 0; i < e_inputs.set_size; i++) {
85 if(e_inputs.commodity_type[i]) {
86 auto cid = e_inputs.commodity_type[i];
87 total -= e_inputs.commodity_amounts[i] * input_mult * e_input_mult * state.world.market_get_price(mid, cid);
88 }
89 }
90
91 auto cid = state.world.factory_type_get_output(ftid).id;
92 total += state.world.factory_type_get_output_amount(ftid) * output_mult * state.world.market_get_price(mid, cid);
93 state.iui_state.per_market_data[market.index()] = total;
94 });
95
96 state.world.for_each_nation([&](dcon::nation_id nid) {
97 if(economy::priority_multiplier(state, ftid, nid) < 0.85f) {
98 state.iui_state.input_efficiency_leaders.push_back(nid);
99 }
100 });
101 }
102}
103
104void commodity_panel(sys::state& state, int32_t identifier_amount, int32_t identifier_cost, dcon::commodity_id cid, float amount, float price, iui::rect& r) {
105 auto icon_size = 20.f;
107 state, cid,
108 r.x + 5.f, r.y + r.h / 2.f - icon_size / 2.f, icon_size, icon_size
109 );
110 iui::rect data{ r.x + 15.f, r.y, r.w - 18.f, r.h / 2.f };
111 state.iui_state.float_2(
112 state, identifier_amount,
113 data, amount
114 );
115 data.y += r.h / 2.f;
116 state.iui_state.price(
117 state, identifier_cost,
118 data, amount * price
119 );
120}
121
122void render(sys::state& state) {
123 if(state.iui_state.per_market_data.size() != state.world.market_size()) {
124 state.iui_state.per_market_data.resize(state.world.market_size());
125 }
126
127 state.iui_state.frame_start();
128
129 if(!state.iui_state.loaded_descriptions) {
130 state.iui_state.load_description(
131 state,
132 "alice_button_factory_type_priority",
133 state.iui_state.priority_button
134 );
135 state.iui_state.load_description(
136 state,
137 "alice_button_economy_viewer_page",
138 state.iui_state.page_button
139 );
140 state.iui_state.load_description(
141 state,
142 "alice_page_selector_bg",
143 state.iui_state.page_selector_bg
144 );
145 state.iui_state.load_description(
146 state,
147 "alice_button_economy_item_selector",
148 state.iui_state.item_selector_bg
149 );
150 state.iui_state.load_description(
151 state,
152 "alice_factory_type_bg",
153 state.iui_state.factory_type_bg
154 );
155 state.iui_state.load_description(
156 state,
157 "commodity_bg",
158 state.iui_state.commodity_bg
159 );
160 state.iui_state.load_description(
161 state,
162 "alice_factory_type_name_bg",
163 state.iui_state.factory_type_name_bg
164 );
165
166 state.iui_state.load_description(
167 state,
168 "alice_factory_type_priority_bg",
169 state.iui_state.factory_type_priority_bg
170 );
171
172 state.iui_state.load_description(
173 state,
174 "alice_economy_view_close_button",
175 state.iui_state.close_button
176 );
177
178 state.iui_state.load_description(
179 state,
180 "alice_economy_view_top_bar",
181 state.iui_state.top_bar_button
182 );
183
184 state.iui_state.load_description(
185 state,
186 "alice_economy_view_map_label",
187 state.iui_state.map_label
188 );
189
190
191 state.iui_state.loaded_descriptions = true;
192 }
193
194 glEnable(GL_BLEND);
195 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
196 glUseProgram(state.open_gl.ui_shader_program);
197 glUniform1i(state.open_gl.ui_shader_texture_sampler_uniform, 0);
198 glUniform1i(state.open_gl.ui_shader_secondary_texture_sampler_uniform, 1);
199 glUniform1f(state.open_gl.ui_shader_screen_width_uniform, float(state.x_size) / state.user_settings.ui_scale);
200 glUniform1f(state.open_gl.ui_shader_screen_height_uniform, float(state.y_size) / state.user_settings.ui_scale);
201 glUniform1f(state.open_gl.ui_shader_gamma_uniform, state.user_settings.gamma);
202 glViewport(0, 0, state.x_size, state.y_size);
203 glDepthRange(-1.0f, 1.0f);
204
205 auto zoom = state.map_state.zoom;
206 auto screen_size = glm::vec2(state.x_size, state.y_size) / state.user_settings.ui_scale;
207
208 // render market data
209 if(zoom > map::zoom_close) {
210
211
212 if(state.iui_state.current_font == 0) {
213 state.iui_state.current_font = text::name_into_font_id(state, "garamond_16");
214 }
215
216 iui::rect market_label_rect{ 0.f, 0.f, state.iui_state.map_label.w, state.iui_state.map_label.h };
217 iui::rect market_label_rect_text = market_label_rect;
218 iui::shrink(market_label_rect_text, 2.f);
219 market_label_rect_text.w -= 5.f;
220
221 state.world.for_each_market([&](dcon::market_id mid) {
222 auto sid = state.world.market_get_zone_from_local_market(mid);
223 auto capital = state.world.state_instance_get_capital(sid);
224 auto& midpoint = state.world.province_get_mid_point(capital);
225 auto map_pos = state.map_state.normalize_map_coord(midpoint);
226 glm::vec2 screen_pos{};
227 if(!state.map_state.map_to_screen(state, map_pos, screen_size, screen_pos)) {
228 return;
229 }
230
231 if(screen_pos.x < -100.f) {
232 return;
233 }
234 if(screen_pos.y < -100.f) {
235 return;
236 }
237 if(screen_pos.x > screen_size.x + 100.f) {
238 return;
239 }
240 if(screen_pos.y > screen_size.y + 100.f) {
241 return;
242 }
243
245 market_label_rect,
246 screen_pos.x - market_label_rect.w / 2.f, screen_pos.y - market_label_rect.h / 2.f
247 );
248
250 market_label_rect_text,
251 screen_pos.x - market_label_rect.w / 2.f + 5.f, screen_pos.y - market_label_rect.h / 2.f + 2.f
252 );
253
254 state.iui_state.panel_textured(state, market_label_rect, state.iui_state.map_label.texture_handle);
255
256 if(state.selected_factory_type) {
257 if(mid.index() < (int32_t)(state.iui_state.per_market_data.size())) {
258 state.iui_state.price(
259 state, mid.index(),
260 market_label_rect_text,
261 state.iui_state.per_market_data[mid.index()]
262 );
263 }
264 } else {
265 state.iui_state.float_2(
266 state, mid.index(),
267 market_label_rect_text,
268 state.world.market_get_max_throughput(mid)
269 );
270 }
271 });
272 }
273
274 {
275 float tabs_layout_start = 0.f;
276 float tabs_layout_margin = 0.f;
277 float tab_height = state.iui_state.top_bar_button.h;
278 float tab_width = state.iui_state.top_bar_button.w;
279
280 iui::rect tab_rect{ tabs_layout_start, tabs_layout_margin, tab_width, tab_height };
281
282 iui::rect tab_name_rect = tab_rect;
283 iui::shrink(tab_name_rect, 10.f);
284
285 if(state.iui_state.button_textured(
286 state, (int32_t)(static_elements::commodities_button),
287 tab_rect, 3, state.iui_state.top_bar_button.texture_handle,
289 )) {
291 }
292
293 state.iui_state.localized_string(
294 state, (int32_t)static_elements::tab_name_commodity, tab_name_rect, "alice_commodity_tab",
296 );
297
298 tab_rect.x += tab_width + tabs_layout_margin;
299 tab_name_rect.x += tab_width + tabs_layout_margin;
300
301 if(state.iui_state.button_textured(
303 tab_rect, 3, state.iui_state.top_bar_button.texture_handle,
304 state.iui_state.tab == iui::iui_tab::factory_types
305 )) {
306 state.iui_state.tab = iui::iui_tab::factory_types;
307 }
308
309 state.iui_state.localized_string(
310 state, (int32_t)static_elements::tab_name_commodity, tab_name_rect, "alice_factory_type_tab",
312 );
313 }
314
315 if(state.iui_state.tab == iui::iui_tab::commodities_markets) {
316 } else if(state.iui_state.tab == iui::iui_tab::factory_types) {
317
318 // absolute
319 float size_panel_w = 400.f;
320 float size_panel_h = 500.f;
321 float margin = 5.f;
322 float size_selector_w = 150.f;
323 float size_page_selector_h = 50.f;
324 float top = screen_size.y - size_panel_h;
325 float priority_settings_height = 80.f;
326
327 // calculated
328 float size_view_w = size_panel_w - size_selector_w;
329 iui::rect selector_panel = { margin, top, size_selector_w, size_panel_h - size_page_selector_h };
330 iui::rect page_selector_rect = { margin, top + size_panel_h - size_page_selector_h, size_selector_w, size_page_selector_h };
331 iui::rect view_panel = { margin + size_selector_w, top, size_view_w, size_panel_h };
332
333 iui::shrink(selector_panel, margin);
334 iui::shrink(page_selector_rect, margin);
335 iui::shrink(view_panel, margin);
336
337 uint32_t factories_on_a_page = 10;
338 iui::rect selector_button = selector_panel;
339 selector_button.h = selector_panel.h / float(factories_on_a_page);
340 auto page = state.iui_state.page_production_methods;
341
342
343 {
344 auto icon_size = 20.f;
345 state.iui_state.panel(state, selector_panel);
346 float y = 10.f;
347 for(
348 uint32_t i = 0;
349 i < factories_on_a_page;
350 i++
351 ) {
352 auto factory_index = i + factories_on_a_page * page;
353 if(factory_index >= state.world.factory_type_size()) {
354 break;
355 }
356 dcon::factory_type_id ftid{ (dcon::factory_type_id::value_base_t)factory_index };
357 selector_button.y = selector_panel.y + i * selector_button.h;
358 if(state.iui_state.button_textured(
359 state, (int32_t)static_elements::factory_type_selector + ftid.index(),
360 selector_button,
361 3, state.iui_state.item_selector_bg.texture_handle,
362 state.selected_factory_type == ftid
363 )) {
364 if(state.selected_factory_type == ftid) {
365 state.selected_factory_type = { };
366 } else {
367 state.selected_factory_type = ftid;
368 update(state);
369 }
370 }
371 state.iui_state.localized_string_r(
372 state, (int32_t)static_elements::factory_types + ftid.index(),
373 { selector_button.x + 30.f, selector_button.y, selector_button.w - 30.f, selector_button.h },
374 text::produce_simple_string(state, state.world.factory_type_get_name(ftid))
375 );
377 state, state.world.factory_type_get_output(ftid),
378 selector_button.x + 5.f,
379 selector_button.y + selector_button.h / 2.f - icon_size / 2.f, icon_size, icon_size
380 );
381 }
382
383 state.iui_state.panel_textured(
384 state, page_selector_rect, state.iui_state.page_selector_bg.texture_handle
385 );
386
387 int pages = (state.world.factory_type_size() - 1) / factories_on_a_page + 1;
388
389 iui::rect page_button{
390 0.f,
391 page_selector_rect.y - state.iui_state.page_button.h / 2.f + page_selector_rect.h / 2.f,
392 state.iui_state.page_button.w,
393 state.iui_state.page_button.h
394 };
395
396 if(pages * state.iui_state.page_button.w <= page_selector_rect.w) {
397 float margin_pages = (page_selector_rect.w - pages * page_button.w) / (pages + 1);
398
399 for(int i = 0; i < pages; i++) {
400 page_button.x = page_selector_rect.x + (page_button.w + margin_pages) * i + margin_pages;
401
402 if(state.iui_state.button_textured(
403 state,
405 page_button,
406 3, state.iui_state.page_button.texture_handle,
407 state.iui_state.page_production_methods == i
408 )) {
409 state.iui_state.page_production_methods = i;
410 }
411
412 state.iui_state.int_whole(
413 state,
415 page_button, i
416 );
417 }
418 } else {
419 page_button.x = page_selector_rect.x + margin;
420 if(state.iui_state.button_textured(
422 page_button, 3, state.iui_state.page_button.texture_handle, false
423 )) {
424 state.iui_state.page_production_methods = std::max(0, state.iui_state.page_production_methods - 1);
425 }
426
427 page_button.x = page_selector_rect.x + page_selector_rect.w - page_button.w - margin;
428 if(state.iui_state.button_textured(
429 state, (int32_t)static_elements::factory_type_page + 2,
430 page_button, 3, state.iui_state.page_button.texture_handle, false
431 )) {
432 state.iui_state.page_production_methods = std::min(
433 pages - 1, state.iui_state.page_production_methods + 1
434 );
435 }
436
437 iui::rect page_selector_page_current = page_selector_rect;
438 page_selector_page_current.x = page_selector_rect.x + page_selector_rect.w / 4.f;
439 page_selector_page_current.w = page_selector_rect.w / 2.f;
440 page_selector_page_current.y = page_selector_rect.y + margin;
441 page_selector_page_current.h = page_selector_rect.h - margin * 2.f;
442
443 page_selector_page_current.w /= 2.f;
444 state.iui_state.int_whole(
445 state,
447 page_selector_page_current, state.iui_state.page_production_methods
448 );
449
450 page_selector_page_current.x += page_selector_page_current.w;
451 state.iui_state.int_whole(
452 state,
454 page_selector_page_current, pages
455 );
456 }
457 }
458
459 if(state.selected_factory_type && state.map_state.selected_province) {
460 auto ftid = state.selected_factory_type;
461 auto sid = state.world.province_get_state_membership(state.map_state.selected_province);
462 auto sdif = state.world.state_instance_get_definition(sid);
463 auto nid = state.world.province_get_nation_from_province_ownership(state.map_state.selected_province);
464 auto mid = state.world.state_instance_get_market_from_local_market(sid);
465
466 auto e_input_mult = state.world.nation_get_modifier_values(nid, sys::national_mod_offsets::factory_maintenance) + 1.0f;
467 auto input_mult = economy::nation_factory_input_multiplier(state, ftid, nid);
468 auto output_mult = economy::nation_factory_output_multiplier(state, ftid, nid);
469
470 state.iui_state.panel_textured(state, view_panel, state.iui_state.factory_type_bg.texture_handle);
471
472 iui::rect name_labels{
473 view_panel.x + 5.f, view_panel.y + 5.f, 200.f, 40.f
474 };
475
476 state.iui_state.panel_textured(state, name_labels, state.iui_state.factory_type_name_bg.texture_handle);
477
478 state.iui_state.localized_string_r(
479 state,
481 { view_panel.x + 10.f, view_panel.y + 7.f, view_panel.w, 18.f },
482 text::produce_simple_string(state, state.world.state_definition_get_name(sdif))
483 );
484
485 state.iui_state.localized_string_r(
486 state,
488 { view_panel.x + 10.f, view_panel.y + 25.f, view_panel.w, 18.f },
489 text::produce_simple_string(state, state.world.factory_type_get_name(ftid))
490 );
491
493 view_panel.x + view_panel.w - state.iui_state.close_button.w,
494 view_panel.y,
495 state.iui_state.close_button.w,
496 state.iui_state.close_button.h
497 };
498 if(state.iui_state.button_textured(
500 3, state.iui_state.close_button.texture_handle, false
501 )) {
502 state.selected_factory_type = { };
503 }
504
505 //retrieve data
506 auto& inputs = state.world.factory_type_get_inputs(ftid);
507 int inputs_size = 0;
508 for(unsigned i = 0; i < inputs.set_size; i++) {
509 if(inputs.commodity_type[i]) {
510 inputs_size++;
511 }
512 }
513 auto& e_inputs = state.world.factory_type_get_efficiency_inputs(ftid);
514 int e_inputs_size = 0;
515 for(unsigned i = 0; i < e_inputs.set_size; i++) {
516 if(e_inputs.commodity_type[i]) {
517 e_inputs_size++;
518 }
519 }
520
521 float grid_margin = 5.f;
522 int items_per_row = 3;
523
524 iui::rect commodity_rect{ 0.f, 0.f, (view_panel.w - grid_margin) / float(items_per_row) - grid_margin, 40.f };
525 iui::rect commodity_labels{ 0.f, 0.f, ((view_panel.w - grid_margin) / float(items_per_row) - grid_margin) - 5.f, 40.f };
526
527 int rows_input = ((inputs_size - 1) / items_per_row) + 1;
528 int rows_e_input = ((e_inputs_size - 1) / items_per_row) + 1;
529
530 // data about production method
531 {
532 // inputs
533 float total = 0.f;
534
535 float current_y = view_panel.y + 50.f;
536
537 for(unsigned i = 0; i < inputs.set_size; i++) {
538 if(inputs.commodity_type[i]) {
539 auto cid = inputs.commodity_type[i];
540
541 int row = i / items_per_row;
542 int column = i - row * items_per_row;
543 commodity_rect.x = view_panel.x + grid_margin + column * (grid_margin + commodity_rect.w);
544 commodity_rect.y = current_y + grid_margin + row * (grid_margin + commodity_rect.h);
545
546 commodity_labels.x = commodity_rect.x;
547 commodity_labels.y = commodity_rect.y;
548
549 state.iui_state.panel_textured(state, commodity_rect, state.iui_state.commodity_bg.texture_handle);
551 state,
552 (int32_t)static_elements::commodities_inputs_amount + cid.index(),
553 (int32_t)static_elements::commodities_inputs_cost + cid.index(),
554 cid,
555 inputs.commodity_amounts[i] * input_mult,
556 state.world.market_get_price(mid, cid),
557 commodity_labels
558 );
559
560 total -= inputs.commodity_amounts[i] * input_mult * state.world.market_get_price(mid, cid);
561 }
562 }
563
564 current_y += grid_margin + rows_input * (grid_margin + commodity_rect.h) + 10.f;
565
566 // maintenance
567
568 for(unsigned i = 0; i < e_inputs.set_size; i++) {
569 if(e_inputs.commodity_type[i]) {
570 auto cid = e_inputs.commodity_type[i];
571
572 int row = i / items_per_row;
573 int column = i - row * items_per_row;
574 commodity_rect.x = view_panel.x + grid_margin + column * (grid_margin + commodity_rect.w);
575 commodity_rect.y = current_y + grid_margin + row * (grid_margin + commodity_rect.h);
576
577 commodity_labels.x = commodity_rect.x;
578 commodity_labels.y = commodity_rect.y;
579
580 state.iui_state.panel_textured(state, commodity_rect, state.iui_state.commodity_bg.texture_handle);
582 state,
583 (int32_t)static_elements::commodities_inputs_amount + cid.index(),
584 (int32_t)static_elements::commodities_inputs_cost + cid.index(),
585 cid,
586 e_inputs.commodity_amounts[i] * input_mult * e_input_mult,
587 state.world.market_get_price(mid, cid),
588 commodity_labels
589 );
590
591 total -= e_inputs.commodity_amounts[i] * input_mult * e_input_mult * state.world.market_get_price(mid, cid);
592 }
593 }
594
595 current_y += grid_margin + rows_e_input * (grid_margin + commodity_rect.h) + 10.f;
596
597 commodity_rect.x = view_panel.x + grid_margin;
598 commodity_rect.y = current_y;
599
600 // output
601 auto cid = state.world.factory_type_get_output(ftid).id;
602
603 commodity_labels.x = commodity_rect.x;
604 commodity_labels.y = commodity_rect.y;
605
606 state.iui_state.panel_textured(state, commodity_rect, state.iui_state.commodity_bg.texture_handle);
608 state,
609 (int32_t)static_elements::commodities_inputs_amount + cid.index(),
610 (int32_t)static_elements::commodities_inputs_cost + cid.index(),
611 cid,
612 state.world.factory_type_get_output_amount(ftid) * output_mult,
613 state.world.market_get_price(mid, cid),
614 commodity_labels
615 );
616
617 commodity_rect.x += commodity_rect.w + grid_margin;
618 commodity_labels.x = commodity_rect.x;
619 commodity_labels.y = commodity_rect.y;
620
621 total += state.world.factory_type_get_output_amount(ftid) * output_mult * state.world.market_get_price(mid, cid);
622 state.iui_state.panel_textured(state, commodity_rect, state.iui_state.commodity_bg.texture_handle);
623 state.iui_state.price(
625 commodity_labels, total
626 );
627
628 iui::rect leader_rect{ view_panel.x + margin, commodity_labels.y + commodity_labels.h + 5.f, 20.f, 20.f };
629
630 auto font_size = float(text::size_from_font_id(state.iui_state.current_font));
631 auto font_index = text::font_index_from_font_id(state, state.iui_state.current_font);
632 auto& current_font = state.font_collection.get_font(state, font_index);
633
634 for(unsigned i = 0; i < state.iui_state.input_efficiency_leaders.size(); i++) {
635 auto leader = state.iui_state.input_efficiency_leaders[i];
637 state,
638 { state.world.nation_get_identity_from_identity_holder(leader) },
639 leader_rect.x,
640 leader_rect.y,
641 font_size,
642 current_font
643 );
644
645 leader_rect.x += leader_rect.w;
646
647 if(leader_rect.x + leader_rect.w > view_panel.x + view_panel.w - margin) {
648 leader_rect.y += leader_rect.h;
649 leader_rect.x = view_panel.x + margin;
650 }
651 }
652
653
654 iui::rect priority_settings{ view_panel.x, view_panel.y + view_panel.h - priority_settings_height - 30.f, view_panel.w, priority_settings_height };
655 iui::shrink(priority_settings, margin);
656 state.iui_state.panel_textured(state, priority_settings, state.iui_state.factory_type_priority_bg.texture_handle);
657 iui::shrink(priority_settings, margin);
658
659 iui::rect priority_description{ priority_settings.x, priority_settings.y, priority_settings.w - 10.f, 20.f };
660
661 state.iui_state.localized_string(
662 state,
664 priority_description,
665 text::produce_simple_string(state, "alice_factory_type_viewer_priority")
666 );
667
668 priority_description.y += 15.f;
669 state.iui_state.localized_string(
670 state,
672 priority_description,
673 text::produce_simple_string(state, "alice_factory_type_viewer_priority_national")
674 );
675 state.iui_state.float_2(
676 state,
678 priority_description, nations::priority_national(state, nid, ftid)
679 );
680
681 priority_description.y += 15.f;
682 state.iui_state.localized_string(
683 state,
685 priority_description,
686 text::produce_simple_string(state, "alice_factory_type_viewer_priority_private")
687 );
688 state.iui_state.float_2(
689 state,
691 priority_description, nations::priority_private(state, nid, ftid)
692 );
693
694 priority_description.y += 15.f;
695 state.iui_state.localized_string(
696 state,
698 priority_description,
699 text::produce_simple_string(state, "alice_factory_type_viewer_priority_bonus")
700 );
701 state.iui_state.float_2(
702 state,
704 priority_description,
705 economy::priority_multiplier(state, ftid, nid)
706 );
707
708 iui::rect button_priority{
709 view_panel.x + 7.f, view_panel.y + view_panel.h - 30.f,
710 state.iui_state.priority_button.w, state.iui_state.priority_button.h
711 };
712
713 auto current_priority = state.world.nation_get_factory_type_experience_priority_national(
714 state.local_player_nation, ftid
715 );
716
717 for(int i = 0; i < 9; i++) {
718 if(state.iui_state.button_textured(
720 button_priority,
721 3, state.iui_state.priority_button.texture_handle,
722 current_priority >= (float)(i) * 100.f
723 )) {
724 command::set_factory_type_priority(state, state.local_player_nation, ftid, (float)(i) * 100.f);
725 }
726 button_priority.x += button_priority.w;
727 }
728 }
729 }
730 }
731
732 state.iui_state.frame_end();
733}
734}
constexpr dcon::demographics_key total(0)
void commodity_panel(sys::state &state, int32_t identifier_amount, int32_t identifier_cost, dcon::commodity_id cid, float amount, float price, iui::rect &r)
void update(sys::state &state)
void render(sys::state &state)
float nation_factory_output_multiplier(sys::state const &state, dcon::factory_type_id fac_type, dcon::nation_id n)
Definition: economy.cpp:2322
float nation_factory_input_multiplier(sys::state const &state, dcon::factory_type_id fac_type, dcon::nation_id n)
Definition: economy.cpp:2313
float priority_multiplier(sys::state const &state, dcon::factory_type_id fac_type, dcon::nation_id n)
Definition: economy.cpp:2308
void shrink(rect &rectangle, float value)
void move_to(rect &rectangle, float x, float y)
@ factory_types
@ commodities_markets
constexpr float zoom_close
Definition: constants.hpp:605
float priority_national(sys::state &state, dcon::nation_id n, dcon::factory_type_id ftid)
Definition: nations.cpp:766
float priority_private(sys::state &state, dcon::nation_id n, dcon::factory_type_id ftid)
Definition: nations.cpp:781
void render_text_flag(sys::state &state, text::embedded_flag ico, float x, float baseline_y, float font_size, text::font &f, ogl::color_modification cmod)
void render_commodity_icon(sys::state &state, dcon::commodity_id cid, float x, float y, float w, float h)
int32_t size_from_font_id(uint16_t id)
Definition: fonts.cpp:119
uint32_t font_index(std::string_view txt)
Definition: fonts.cpp:68
uint16_t name_into_font_id(sys::state &state, std::string_view txt)
Definition: fonts.cpp:93
std::string produce_simple_string(sys::state const &state, dcon::text_key id)
Definition: text.cpp:617
font_selection font_index_from_font_id(sys::state &state, uint16_t id)
Definition: fonts.cpp:130
uint32_t font_size(std::string_view txt)
Definition: fonts.cpp:35
ogl::color3f get_text_color(sys::state &state, text::text_color text_color)
uint uint32_t
Holds important data about the game world, state, and other data regarding windowing,...