3#include "dcon_generated.hpp"
21 auto com = retrieve<dcon::commodity_id>(
state,
parent);
22 if(
state.world.nation_get_drawing_on_stockpiles(
state.local_player_nation, com)) {
23 if(
state.world.nation_get_stockpiles(
state.local_player_nation, com) > 0)
27 }
else if(
state.world.nation_get_stockpiles(
state.local_player_nation, com) <
state.world.nation_get_stockpile_targets(
state.local_player_nation, com)) {
35 auto com = retrieve<dcon::commodity_id>(
state,
parent);
36 if(
state.world.nation_get_drawing_on_stockpiles(
state.local_player_nation, com)) {
38 }
else if(
state.world.nation_get_stockpiles(
state.local_player_nation, com) <
state.world.nation_get_stockpile_targets(
state.local_player_nation, com)) {
47 auto com = retrieve<dcon::commodity_id>(
state,
parent);
48 if(
state.world.nation_get_drawing_on_stockpiles(
state.local_player_nation, com)) {
49 if(
state.world.nation_get_stockpiles(
state.local_player_nation, com) > 0)
51 }
else if(
state.world.nation_get_stockpiles(
state.local_player_nation, com) <
state.world.nation_get_stockpile_targets(
state.local_player_nation, com)) {
62 auto com = retrieve<dcon::commodity_id>(
state,
parent);
65 if(current_price > previous_price) {
67 }
else if(current_price < previous_price) {
124 return !(*
this == o);
136 auto ptr = make_element_by_type<image_element_base>(
state,
id);
139 }
else if(
name ==
"title") {
140 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
143 }
else if(
name ==
"value") {
144 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
147 }
else if(
name ==
"output_icon") {
148 auto ptr = make_element_by_type<image_element_base>(
state,
id);
149 output_icon = ptr.
get();
157 auto commodity_id = retrieve<dcon::commodity_id>(
state,
parent);
169 auto ftid =
state.world.factory_get_building_type(fid);
172 amount +=
state.world.factory_get_actual_production(fid);
175 auto& inputs =
state.world.factory_type_get_inputs(ftid);
176 for(
uint32_t i = 0; i < inputs.set_size; ++i)
177 if(inputs.commodity_type[i] == commodity_id)
178 amount += inputs.commodity_amounts[i];
179 output_icon->
frame =
state.world.commodity_get_icon(
state.world.factory_type_get_output(ftid));
182 output_icon->
frame =
state.world.commodity_get_icon(
state.world.factory_type_get_output(ftid));
187 auto name =
state.world.factory_type_get_name(ftid);
201 auto name =
state.world.province_get_name(pid);
213 if(value->is_visible())
220 return "trade_flow_entry";
225 auto commodity_id = retrieve<dcon::commodity_id>(
state,
parent);
226 for(
auto const fat_stown_id :
state.world.nation_get_state_ownership(
state.local_player_nation)) {
228 auto fat_id = dcon::fatten(state.world, pid);
229 fat_id.for_each_factory_location_as_province([&](dcon::factory_location_id flid) {
230 auto fid = state.world.factory_location_get_factory(flid);
231 if(factory_func(fid)) {
232 trade_flow_data td{};
233 td.type = trade_flow_data::type::factory;
235 td.data.factory_id = fid;
236 td.trade_good = commodity_id;
237 row_contents.push_back(td);
241 if(
state.world.province_get_rgo_actual_production_per_good(pid, commodity_id) > 0.f) {
245 td.data.province_id = pid;
246 td.trade_good = commodity_id;
257 auto commodity_id = retrieve<dcon::commodity_id>(
state, parent);
259 row_contents.clear();
262 [&](dcon::factory_id fid) ->
bool {
263 auto ftid =
state.world.factory_get_building_type(fid);
264 return state.world.factory_type_get_output(ftid) == commodity_id;
266 trade_flow_data::value_type::produced_by);
273 auto commodity_id = retrieve<dcon::commodity_id>(
state, parent);
275 row_contents.clear();
278 [&](dcon::factory_id fid) ->
bool {
279 auto ftid =
state.world.factory_get_building_type(fid);
280 auto& inputs =
state.world.factory_type_get_inputs(ftid);
281 for(
uint32_t i = 0; i < inputs.set_size; ++i)
282 if(inputs.commodity_type[i] == commodity_id)
283 return inputs.commodity_amounts[i] > 0.f;
286 trade_flow_data::value_type::used_by);
293 auto commodity_id = retrieve<dcon::commodity_id>(
state, parent);
295 row_contents.clear();
298 [&](dcon::factory_id fid) ->
bool {
299 auto ftid =
state.world.factory_get_building_type(fid);
300 auto& inputs =
state.world.factory_type_get_inputs(ftid);
301 for(
uint32_t i = 0; i < inputs.set_size; ++i)
302 if(inputs.commodity_type[i] == commodity_id)
303 return inputs.commodity_amounts[i] == 0.f;
306 trade_flow_data::value_type::may_be_used_by);
314 auto com = retrieve<dcon::commodity_id>(
state, parent);
315 distribution.clear();
316 for(
auto n :
state.world.in_nation)
317 if(n.get_owned_province_count() != 0)
326 auto com = retrieve<dcon::commodity_id>(
state, parent);
327 distribution.clear();
328 for(
auto n :
state.world.in_nation)
329 if(n.get_owned_province_count() != 0)
339 auto com = retrieve<dcon::commodity_id>(
state, parent);
340 distribution.clear();
344 for(
const auto pc :
state.world.nation_get_province_control(
state.local_player_nation)) {
345 for(
const auto fl : pc.get_province().get_factory_location()) {
346 if(fl.get_factory().get_building_type().get_output() == com)
347 amount += fl.get_factory().get_actual_production();
351 distribution.emplace_back(
state.culture_definitions.primary_factory_worker, amount);
355 distribution.emplace_back(
state.culture_definitions.capitalists, imports);
360 for(
const auto pc :
state.world.nation_get_province_control(
state.local_player_nation)) {
361 amount += pc.get_province().get_rgo_actual_production_per_good(com);
364 distribution.emplace_back(
state.culture_definitions.aristocrat, amount);
368 state.world.nation_for_each_state_ownership(
state.local_player_nation, [&](
auto soid) {
369 auto sid = state.world.state_ownership_get_state(soid);
370 auto market = state.world.state_instance_get_market_from_local_market(sid);
371 amount += state.world.market_get_artisan_actual_production(market, com);
374 distribution.emplace_back(
state.culture_definitions.artisans, amount);
381 if(produced >= total) {
382 distribution.emplace_back(
state.culture_definitions.laborers, total - produced);
391 if(
name ==
"current_price_label") {
392 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
394 ptr->base_data.size.x *= 2;
396 }
else if(
name ==
"current_price_value"
397 ||
name ==
"price_linechart"
398 ||
name ==
"price_chart_low"
399 ||
name ==
"price_chart_time") {
400 return make_element_by_type<invisible_element>(
state,
id);
401 }
else if(
name ==
"price_chart_high") {
402 auto ptr = make_element_by_type<invisible_element>(
state,
id);
404 auto ov_elm = make_element_by_type<image_element_base>(
state,
"generic_piechart_overlay");
405 ov_elm->base_data.position.x = ptr->base_data.position.x;
406 ov_elm->base_data.position.y = ptr->base_data.position.y;
407 auto pc_elm = make_element_by_type<trade_flow_producers_piechart>(
state,
"generic_piechart");
408 pc_elm->base_data.position.x += ov_elm->base_data.position.x;
409 pc_elm->base_data.position.y += ov_elm->base_data.position.y;
410 auto lg_elm = make_element_by_type<simple_text_element_base>(
state,
id);
412 lg_elm->base_data.position.x = ptr->base_data.position.x;
413 lg_elm->base_data.position.y = ptr->base_data.position.y - 8;
414 add_child_to_front(std::move(lg_elm));
415 add_child_to_front(std::move(pc_elm));
416 add_child_to_front(std::move(ov_elm));
419 auto ov_elm = make_element_by_type<image_element_base>(
state,
"generic_piechart_overlay");
420 ov_elm->base_data.position.x = ptr->base_data.position.x + (ov_elm->base_data.size.x + 20) * 1;
421 ov_elm->base_data.position.y = ptr->base_data.position.y;
422 auto pc_elm = make_element_by_type<trade_flow_consumers_piechart>(
state,
"generic_piechart");
423 pc_elm->base_data.position.x += ov_elm->base_data.position.x;
424 pc_elm->base_data.position.y += ov_elm->base_data.position.y;
425 auto lg_elm = make_element_by_type<simple_text_element_base>(
state,
id);
427 lg_elm->base_data.position.x = ptr->base_data.position.x + (ov_elm->base_data.size.x + 20) * 1;
428 lg_elm->base_data.position.y = ptr->base_data.position.y - 8;
429 add_child_to_front(std::move(lg_elm));
430 add_child_to_front(std::move(pc_elm));
431 add_child_to_front(std::move(ov_elm));
434 auto ov_elm = make_element_by_type<image_element_base>(
state,
"generic_piechart_overlay");
435 ov_elm->base_data.position.x = ptr->base_data.position.x + (ov_elm->base_data.size.x + 20) * 2;
436 ov_elm->base_data.position.y = ptr->base_data.position.y;
437 auto pc_elm = make_element_by_type<trade_flow_workers_piechart>(
state,
"generic_piechart");
438 pc_elm->base_data.position.x += ov_elm->base_data.position.x;
439 pc_elm->base_data.position.y += ov_elm->base_data.position.y;
440 auto lg_elm = make_element_by_type<simple_text_element_base>(
state,
id);
442 lg_elm->base_data.position.x = ptr->base_data.position.x + (ov_elm->base_data.size.x + 20) * 2;
443 lg_elm->base_data.position.y = ptr->base_data.position.y - 8;
444 add_child_to_front(std::move(lg_elm));
445 add_child_to_front(std::move(pc_elm));
446 add_child_to_front(std::move(ov_elm));
458 auto commodity_id = retrieve<dcon::commodity_id>(
state, parent);
461 for(
auto const fat_stown_id :
state.world.nation_get_state_ownership(
state.local_player_nation)) {
463 auto fat_id = dcon::fatten(state.world, pid);
464 fat_id.for_each_factory_location_as_province([&](dcon::factory_location_id flid) {
465 auto fid = state.world.factory_location_get_factory(flid);
466 auto ftid = state.world.factory_get_building_type(fid);
467 if(state.world.factory_type_get_output(ftid) == commodity_id)
468 amount += state.world.factory_get_actual_production(fid);
470 if(
state.world.province_get_rgo(pid) == commodity_id)
471 amount +=
state.world.province_get_rgo_actual_production_per_good(pid, commodity_id);
481 auto commodity_id = retrieve<dcon::commodity_id>(
state, parent);
489 window_element_base::on_create(
state);
490 set_visible(
state,
false);
494 if(
name ==
"close_button") {
495 return make_element_by_type<generic_close_button>(
state,
id);
496 }
else if(
name ==
"trade_flow_bg") {
497 return make_element_by_type<draggable_target>(
state,
id);
498 }
else if(
name ==
"material_name") {
499 return make_element_by_type<generic_name_text<dcon::commodity_id>>(
state, id);
500 }
else if(
name ==
"material_icon_big") {
501 return make_element_by_type<commodity_image>(
state,
id);
502 }
else if(
name ==
"header_produced_by") {
503 auto ptr = make_element_by_type<single_multiline_text_element_base>(
state,
id);
506 }
else if(
name ==
"header_used_by") {
507 auto ptr = make_element_by_type<single_multiline_text_element_base>(
state,
id);
510 }
else if(
name ==
"header_may_be_used_by") {
511 auto ptr = make_element_by_type<single_multiline_text_element_base>(
state,
id);
514 }
else if(
name ==
"total_produced_text") {
515 auto ptr = make_element_by_type<single_multiline_text_element_base>(
state,
id);
517 ptr->base_data.position.x += 48;
519 }
else if(
name ==
"total_used_text") {
520 auto ptr = make_element_by_type<single_multiline_text_element_base>(
state,
id);
522 ptr->base_data.position.x += 48;
524 }
else if(
name ==
"total_produced_value") {
525 return make_element_by_type<trade_flow_total_produced_text>(
state,
id);
526 }
else if(
name ==
"total_used_value") {
527 return make_element_by_type<trade_flow_total_used_text>(
state,
id);
528 }
else if(
name ==
"price_graph") {
529 return make_element_by_type<trade_flow_price_graph_window>(
state,
id);
530 }
else if(
name ==
"produced_by_listbox") {
531 return make_element_by_type<trade_flow_produced_by_listbox>(
state,
id);
532 }
else if(
name ==
"used_by_listbox") {
533 return make_element_by_type<trade_flow_used_by_listbox>(
state,
id);
534 }
else if(
name ==
"may_be_used_by_listbox") {
535 return make_element_by_type<trade_flow_may_be_used_by_listbox>(
state,
id);
544 std::string padding = item.index() < 10 ?
"0" :
"";
545 std::string description =
"@$" + padding + std::to_string(item.index());
559 return a.index() < b.index();
574 auto balance = supply - demand;
597 if(value_a != value_b)
598 return value_a > value_b;
600 return a.index() < b.index();
605 if(value_a != value_b)
606 return value_a > value_b;
608 return a.index() < b.index();
613 if(value_a != value_b)
614 return value_a > value_b;
616 return a.index() < b.index();
621 auto balance_a = supply_a - demand_a;
625 auto balance_b = supply_b - demand_b;
627 if(balance_a != balance_b)
628 return balance_a > balance_b;
630 return a.index() < b.index();
635 if(value_a != value_b)
636 return value_a > value_b;
638 return a.index() < b.index();
641 auto value_a =
state.world.nation_get_stockpiles(
state.local_player_nation, a);
642 auto value_b =
state.world.nation_get_stockpiles(
state.local_player_nation, b);
643 if(value_a != value_b)
644 return value_a > value_b;
646 return a.index() < b.index();
651 .header =
"trade_good_name_header",
654 .cell_definition_string =
"thin_cell_name",
655 .header_definition_string =
"thin_cell_name"
662 .cell_definition_string =
"thin_cell_number"
670 .cell_definition_string =
"thin_cell_number"
677 .cell_definition_string =
"thin_cell_number"
684 .cell_definition_string =
"thin_cell_number"
688 .header =
"market_stockpiles",
691 .cell_definition_string =
"thin_cell_number"
695 .header =
"national_stockpile",
698 .cell_definition_string =
"thin_cell_number"
704 .header =
"government_need",
711 return a.index() < b.index();
721 .header =
"price_nation",
728 return a.index() < b.index();
738 .header =
"factory_need",
745 return a.index() < b.index();
755 .header =
"pop_need",
762 return a.index() < b.index();
772 .header =
"rgo_production",
776 for(
auto p :
state.world.in_province) {
777 if(p.get_nation_from_province_ownership()) {
778 av += p.get_rgo_actual_production_per_good(a);
781 for(
auto p :
state.world.in_province) {
782 if(p.get_nation_from_province_ownership()) {
783 bv += p.get_rgo_actual_production_per_good(b);
789 return a.index() < b.index();
793 for(
auto p :
state.world.in_province) {
794 if(p.get_nation_from_province_ownership()) {
795 value += p.get_rgo_actual_production_per_good(
id);
804 .header =
"artisan_production",
808 for(
auto n :
state.world.in_market) {
809 av += n.get_artisan_actual_production(a);
811 for(
auto n :
state.world.in_market) {
812 bv += n.get_artisan_actual_production(b);
817 return a.index() < b.index();
821 for(
auto n :
state.world.in_market) {
822 value += n.get_artisan_actual_production(
id);
830 .header =
"factory_production",
834 for(
auto f :
state.world.in_factory) {
835 if(f.get_building_type().get_output() == a)
836 av += f.get_actual_production();
838 for(
auto f :
state.world.in_factory) {
839 if(f.get_building_type().get_output() == b)
840 bv += f.get_actual_production();
845 return a.index() < b.index();
849 for(
auto f :
state.world.in_factory) {
850 if(f.get_building_type().get_output() == id)
851 value += f.get_actual_production();
879 .header =
"artisan_distribution",
886 return a.index() < b.index();
896 .header =
"produced_nation",
903 return a.index() < b.index();
913 .header =
"consumed_nation",
920 return a.index() < b.index();
930 .header =
"price_nation",
932 dcon::commodity_id good = retrieve<dcon::commodity_id>(
state, container);
938 return a.index() < b.index();
941 dcon::commodity_id good = retrieve<dcon::commodity_id>(
state, container);
949 .header =
"nation_name",
956 return a.index() < b.index();
959 auto niid =
state.world.nation_get_identity_from_identity_holder(
id);
960 auto ii =
state.world.national_identity_get_identifying_int(niid);
962 auto prefix =
"@" + tag;
967 .cell_definition_string =
"thin_cell_name",
968 .header_definition_string =
"thin_cell_name"
973 .header =
"produced_nation",
975 dcon::commodity_id good = retrieve<dcon::commodity_id>(
state, container);
981 return a.index() < b.index();
984 dcon::commodity_id good = retrieve<dcon::commodity_id>(
state, container);
992 .header =
"demanded_nation",
994 dcon::commodity_id good = retrieve<dcon::commodity_id>(
state, container);
1000 return a.index() < b.index();
1003 dcon::commodity_id good = retrieve<dcon::commodity_id>(
state, container);
1011 .header =
"consumed_nation",
1013 dcon::commodity_id good = retrieve<dcon::commodity_id>(
state, container);
1019 return a.index() < b.index();
1022 dcon::commodity_id good = retrieve<dcon::commodity_id>(
state, container);
1031 .header =
"market_name",
1033 auto sa =
state.world.market_get_zone_from_local_market(a);
1034 auto sb =
state.world.market_get_zone_from_local_market(b);
1036 auto pa =
state.world.state_instance_get_capital(sa);
1037 auto pb =
state.world.state_instance_get_capital(sb);
1044 return a.index() < b.index();
1047 auto s =
state.world.market_get_zone_from_local_market(
id);
1048 auto p =
state.world.state_instance_get_capital(s);
1052 .cell_definition_string =
"thin_cell_name",
1053 .header_definition_string =
"thin_cell_name"
1058 .header =
"produced_nation",
1060 dcon::commodity_id good = retrieve<dcon::commodity_id>(
state, container);
1066 return a.index() < b.index();
1069 dcon::commodity_id good = retrieve<dcon::commodity_id>(
state, container);
1077 .header =
"demanded_nation",
1079 dcon::commodity_id good = retrieve<dcon::commodity_id>(
state, container);
1085 return a.index() < b.index();
1088 dcon::commodity_id good = retrieve<dcon::commodity_id>(
state, container);
1096 .header =
"consumed_nation",
1098 dcon::commodity_id good = retrieve<dcon::commodity_id>(
state, container);
1104 return a.index() < b.index();
1107 dcon::commodity_id good = retrieve<dcon::commodity_id>(
state, container);
1115 .header =
"stockpile_market",
1117 dcon::commodity_id good = retrieve<dcon::commodity_id>(
state, container);
1118 auto av =
state.world.market_get_stockpile(a, good);
1119 auto bv =
state.world.market_get_stockpile(b, good);
1123 return a.index() < b.index();
1126 dcon::commodity_id good = retrieve<dcon::commodity_id>(
state, container);
1127 auto value =
state.world.market_get_stockpile(
id, good);
1134 .header =
"price_market",
1136 dcon::commodity_id good = retrieve<dcon::commodity_id>(
state, container);
1142 return a.index() < b.index();
1145 dcon::commodity_id good = retrieve<dcon::commodity_id>(
state, container);
1153 .header =
"w_artisan_profit",
1155 dcon::commodity_id good = retrieve<dcon::commodity_id>(
state, container);
1161 return a.index() < b.index();
1164 dcon::commodity_id good = retrieve<dcon::commodity_id>(
state, container);
1172 .header =
"w_artisan_distribution",
1174 dcon::commodity_id good = retrieve<dcon::commodity_id>(
state, container);
1175 auto av =
state.world.market_get_artisan_score(a, good);
1176 auto bv =
state.world.market_get_artisan_score(b, good);
1180 return a.index() < b.index();
1183 dcon::commodity_id good = retrieve<dcon::commodity_id>(
state, container);
1184 auto value =
state.world.market_get_artisan_score(
id, good);
1197 auto commodity_id = retrieve<dcon::commodity_id>(
state, parent);
1219 line_graph::on_create(
state);
1223 auto com = retrieve<dcon::commodity_id>(
state, parent);
1235 auto com = retrieve<dcon::commodity_id>(
state, parent);
1236 line_graph::render(
state, x, y);
1243 auto com = retrieve<dcon::commodity_id>(
state, parent);
1246 float max_price =
state.world.commodity_get_price_record(com, newest_index);
1248 for(int32_t i = 1; i < 32; ++i) {
1258 auto com = retrieve<dcon::commodity_id>(
state, parent);
1261 float min_price =
state.world.commodity_get_price_record(com, newest_index);
1263 for(int32_t i = 1; i < 32; ++i) {
1273 auto com = retrieve<dcon::commodity_id>(
state, parent);
1274 if(
state.world.nation_get_drawing_on_stockpiles(
state.local_player_nation, com)) {
1282 auto com = retrieve<dcon::commodity_id>(
state, parent);
1283 button_element_base::render(
state, x, y);
1287 auto com = retrieve<dcon::commodity_id>(
state, parent);
1295 auto com = retrieve<dcon::commodity_id>(
state, parent);
1306 auto com = retrieve<dcon::commodity_id>(
state, parent);
1307 simple_text_element_base::render(
state, x, y);
1317 auto com = retrieve<dcon::commodity_id>(
state, parent);
1325 auto com = retrieve<dcon::commodity_id>(
state, parent);
1342 float a = std::pow(10.0f,
float(v) * (6.0f / 2000.0f)) - 1.0f;
1345 commit_changes(
state);
1349 auto com = retrieve<dcon::commodity_id>(
state, parent);
1356 auto value =
state.world.nation_get_stockpile_targets(
state.local_player_nation, com);
1357 auto a = std::log10(value + 1.0f);
1358 auto b = a * (2000.0f / 6.0f);
1359 update_raw_value(
state, int32_t(b));
1365 auto com = retrieve<dcon::commodity_id>(
state, parent);
1366 scrollbar::impl_render(
state, x, y);
1369 commit_changes(
state);
1372 auto com = retrieve<dcon::commodity_id>(
state, parent);
1373 float v = std::pow(10.0f,
float(raw_value()) * (6.0f / 2000.0f)) - 1.0f;
1381 auto com = retrieve<dcon::commodity_id>(
state, parent);
1382 auto val = retrieve<get_stockpile_target>(
state, parent);
1390 auto commodity_id = retrieve<dcon::commodity_id>(
state, parent);
1399 float trade_amount = 0.0f;
1402 if(
name ==
"trade_flow_bg") {
1403 return make_element_by_type<image_element_base>(
state,
id);
1404 }
else if(
name ==
"goods_icon") {
1405 return make_element_by_type<commodity_image>(
state,
id);
1406 }
else if(
name ==
"goods_title") {
1407 return make_element_by_type<generic_name_text<dcon::commodity_id>>(
state, id);
1408 }
else if(
name ==
"goods_price") {
1409 return make_element_by_type<commodity_price_text>(
state,
id);
1410 }
else if(
name ==
"automate_label") {
1411 return make_element_by_type<invisible_element>(
state,
id);
1412 }
else if(
name ==
"automate") {
1413 return make_element_by_type<invisible_element>(
state,
id);
1414 }
else if(
name ==
"price_linechart") {
1415 return make_element_by_type<prices_line_graph>(
state,
id);
1416 }
else if(
name ==
"price_chart_low") {
1417 return make_element_by_type<price_chart_low>(
state,
id);
1418 }
else if(
name ==
"price_chart_high") {
1419 return make_element_by_type<price_chart_high>(
state,
id);
1420 }
else if(
name ==
"price_chart_time") {
1421 return make_element_by_type<invisible_element>(
state,
id);
1422 }
else if(
name ==
"sell_stockpile") {
1423 return make_element_by_type<stockpile_sell_button>(
state,
id);
1424 }
else if(
name ==
"sell_stockpile_label") {
1425 return make_element_by_type<stockpile_sell_label>(
state,
id);
1426 }
else if(
name ==
"sell_slidier_desc") {
1427 return make_element_by_type<stockpile_slider_label>(
state,
id);
1428 }
else if(
name ==
"sell_slider") {
1429 return make_element_by_type<trade_slider>(
state,
id);
1430 }
else if(
name ==
"slider_value") {
1431 auto ptr = make_element_by_type<trade_slider_amount>(
state,
id);
1432 slider_value_display = ptr.
get();
1434 }
else if(
name ==
"confirm_trade") {
1435 return make_element_by_type<stockpile_amount_label>(
state,
id);
1436 }
else if(
name ==
"goods_details") {
1437 return make_element_by_type<trade_details_button>(
state,
id);
1438 }
else if(
name ==
"goods_need_gov_desc") {
1439 return make_element_by_type<invisible_element>(
state,
id);
1440 }
else if(
name ==
"goods_need_factory_desc") {
1441 return make_element_by_type<invisible_element>(
state,
id);
1442 }
else if(
name ==
"produced_detail_desc") {
1443 return make_element_by_type<detail_domestic_production>(
state,
id);
1444 }
else if(
name ==
"goods_need_pop_desc") {
1445 return make_element_by_type<invisible_element>(
state,
id);
1454 return message_result::consumed;
1456 trade_amount = any_cast<stockpile_target_change>(payload).
value;
1458 return message_result::consumed;
1461 return message_result::unseen;
1471 button_element_base::on_create(
state);
1485 if(index == 1 && subindex == 2) {
1488 button_element_base::render(
state, x, y);
1494 if(click_amount >= 10)
1496 if(click_amount >= 15)
1502 return tooltip_behavior::variable_tooltip;
1506 std::string key =
"alice_stockpile_button_" + std::to_string(index) +
"_" + std::to_string(subindex);
1519 send<signal_global_table>(
state, parent, signal);
1526 send<signal_nation_table>(
state, parent, signal);
1533 send<signal_trade_good_table>(
state, parent, signal);
1540 send<signal_trade_good_markets_table>(
state, parent, signal);
1547 dcon::commodity_id commodity_id{1};
1556 window_element_base::on_create(
state);
1558 auto ptr = make_element_by_type<trade_flow_window>(
state,
state.ui_state.
defs_by_name.find(
state.lookup_key(
"trade_flow"))->second.definition);
1559 trade_flow_win = ptr.
get();
1560 add_child_to_front(std::move(ptr));
1562 set_visible(
state,
false);
1566 if(
name ==
"main_bg") {
1567 return make_element_by_type<image_element_base>(
state,
id);
1568 }
else if(
name ==
"bg_trade") {
1569 return make_element_by_type<opaque_element_base>(
state,
id);
1570 }
else if(
name ==
"close_button") {
1571 return make_element_by_type<generic_close_button>(
state,
id);
1572 }
else if(
name ==
"commodity_table_nation") {
1573 std::vector<table::column<dcon::commodity_id>> columns = {
1584 auto ptr = make_element_by_type<table::display<dcon::commodity_id>>(
1587 std::string(
"commodity_table_body"),
1590 table_nation = ptr.
get();
1593 send<trade_details_select_commodity>(
state, container, payload);
1595 state.world.for_each_commodity([&](dcon::commodity_id
id) {
1596 table_nation->content.data.push_back(
id);
1598 table_nation->set_visible(
state,
false);
1600 }
else if(
name ==
"commodity_table_global") {
1601 std::vector<table::column<dcon::commodity_id>> columns = {
1612 auto ptr = make_element_by_type<table::display<dcon::commodity_id>>(
1615 std::string(
"commodity_table_body"),
1618 table_global = ptr.
get();
1621 send<trade_details_select_commodity>(
state, container, payload);
1623 state.world.for_each_commodity([&](dcon::commodity_id
id) {
1624 table_global->content.data.push_back(
id);
1627 }
else if(
name ==
"trade_good_global_stats") {
1628 std::vector<table::column<dcon::nation_id>> columns = {
1631 auto ptr = make_element_by_type<table::display<dcon::nation_id>>(
1634 std::string(
"commodity_table_body"),
1637 table_trade_good_stats = ptr.
get();
1638 table_trade_good_stats->set_visible(
state,
false);
1639 state.world.for_each_nation([&](dcon::nation_id
id) {
1640 table_trade_good_stats->content.data.push_back(
id);
1643 }
else if(
name ==
"trade_good_markets_stats") {
1644 std::vector<table::column<dcon::market_id>> columns = {
1650 auto ptr = make_element_by_type<table::display<dcon::market_id>>(
1653 std::string(
"commodity_table_body"),
1656 table_trade_good_stats_market = ptr.
get();
1657 table_trade_good_stats_market->set_visible(
state,
false);
1658 state.world.for_each_market([&](dcon::market_id
id) {
1659 table_trade_good_stats_market->content.data.push_back(
id);
1662 }
else if(
name ==
"market_table_global") {
1663 return make_element_by_type<switch_to_global_button>(
state,
id);
1664 }
else if(
name ==
"market_table_nation") {
1665 return make_element_by_type<switch_to_nation_button>(
state,
id);
1666 }
else if(
name ==
"market_table_trade_good_global") {
1667 return make_element_by_type<switch_to_trade_good_button>(
state,
id);
1668 }
else if(
name ==
"market_table_trade_good_markets") {
1669 return make_element_by_type<switch_to_trade_good_markets_button>(
state,
id);
1670 }
else if(
name ==
"trade_details") {
1671 auto ptr = make_element_by_type<trade_details_window>(
state,
id);
1672 details_win = ptr.
get();
1680 table_trade_good_stats_market->
content.data.clear();
1681 state.world.for_each_market([&](dcon::market_id
id) {
1682 auto sid =
state.world.market_get_zone_from_local_market(
id);
1683 auto nid =
state.world.state_instance_get_nation_from_state_ownership(sid);
1685 auto selected_nid = retrieve<dcon::nation_id>(
state,
this);
1687 if (selected_nid && selected_nid == nid)
1688 table_trade_good_stats_market->
content.data.push_back(
id);
1691 table_trade_good_stats_market->
content.data.push_back(
id);
1717 }
else if(payload.holds_type<dcon::commodity_id>()) {
1718 payload.emplace<dcon::commodity_id>(commodity_id);
1719 return message_result::consumed;
1721 commodity_id = any_cast<trade_details_open_window>(payload).commodity_id;
1724 return message_result::consumed;
1726 commodity_id = any_cast<trade_details_select_commodity>(payload).commodity_id;
1728 details_win->
trade_amount =
state.world.nation_get_stockpile_targets(
state.local_player_nation, commodity_id);
1730 return message_result::consumed;
1731 }
else if(payload.holds_type<dcon::nation_id>()) {
1732 payload.emplace<dcon::nation_id>(
state.local_player_nation);
1733 return message_result::consumed;
1735 return message_result::unseen;
ui::message_result get(sys::state &state, Cyto::Any &payload) noexcept override
data< item_type > content
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void impl_on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
virtual message_result get(sys::state &state, Cyto::Any &payload) noexcept
virtual void impl_on_update(sys::state &state) noexcept
message_result impl_get(sys::state &state, Cyto::Any &payload) noexcept
void set_visible(sys::state &state, bool vis)
std::vector< trade_flow_data > row_contents
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_update(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void on_create(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
void button_action(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
void render(sys::state &state, int32_t x, int32_t y) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
void on_update(sys::state &state) noexcept override
bool operator==(trade_flow_data const &o) const
bool operator!=(trade_flow_data const &o) const
dcon::province_id province_id
union ui::trade_flow_data::@4 data
dcon::commodity_id trade_good
dcon::factory_id factory_id
dcon::province_id pop_province_id
void on_update(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
std::string_view get_row_element_name() override
void populate_rows(sys::state &state, F &&factory_func, enum trade_flow_data::value_type vt)
void on_update(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void commit_changes(sys::state &state) noexcept
void impl_render(sys::state &state, int32_t x, int32_t y) noexcept override
void on_update(sys::state &state) noexcept final
void on_drag_finish(sys::state &state) noexcept override
void on_value_change(sys::state &state, int32_t v) noexcept final
void on_create(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
std::unique_ptr< element_base > make_child(sys::state &state, std::string_view name, dcon::gui_def_id id) noexcept override
#define assert(condition)
@ change_stockpile_settings
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
float government_consumption(sys::state &state, dcon::nation_id n, dcon::commodity_id c)
float consumption(sys::state &state, dcon::market_id s, dcon::commodity_id c)
float supply(sys::state &state, dcon::market_id s, dcon::commodity_id c)
float nation_factory_consumption(sys::state &state, dcon::nation_id n, dcon::commodity_id c)
float price(sys::state const &state, dcon::state_instance_id s, dcon::commodity_id c)
constexpr uint32_t price_history_length
int32_t most_recent_price_record_index(sys::state &state)
float import_volume(sys::state &state, dcon::market_id s, dcon::commodity_id c)
float demand_satisfaction(sys::state &state, dcon::market_id s, dcon::commodity_id c)
float market_pool(sys::state &state, dcon::market_id s, dcon::commodity_id c)
float demand(sys::state &state, dcon::market_id s, dcon::commodity_id c)
float nation_pop_consumption(sys::state &state, dcon::nation_id n, dcon::commodity_id c)
ve::fp_vector base_artisan_profit(sys::state &state, T markets, S nations, dcon::commodity_id c)
std::string int_to_tag(uint32_t v)
void for_each_province_in_state_instance(sys::state &state, dcon::state_instance_id s, F const &func)
std::string resolve_string_substitution(sys::state &state, dcon::text_key source_text, substitution_map const &mp)
std::string format_money(float num)
std::string get_name_as_string(sys::state &state, T t)
std::string prettify(int64_t num)
std::string format_float(float num, size_t digits)
void add_line(sys::state &state, layout_base &dest, dcon::text_key txt, int32_t indent)
void add_to_substitution_map(substitution_map &mp, variable_type key, substitution value)
ankerl::unordered_dense::map< uint32_t, substitution > substitution_map
std::string produce_simple_string(sys::state const &state, dcon::text_key id)
dcon::text_key get_name(sys::state &state, dcon::nation_id id)
std::string format_percentage(float num, size_t digits)
dcon::text_key find_or_add_key(sys::state &state, std::string_view key, bool as_unicode)
table::column< dcon::commodity_id > trade_good_consumed_nation
std::string stockpile_target_player_view_commodity_id(sys::state &state, element_base *container, dcon::commodity_id item)
table::column< dcon::commodity_id > trade_good_satisfaction
table::column< dcon::commodity_id > trade_good_production_artisan
bool compare_stockpile_market(sys::state &state, element_base *container, dcon::commodity_id a, dcon::commodity_id b)
std::string price_view_commodity_id(sys::state &state, element_base *container, dcon::commodity_id item)
table::column< dcon::commodity_id > trade_good_production_factory
std::string stockpile_player_view_commodity_id(sys::state &state, element_base *container, dcon::commodity_id item)
bool compare_name(sys::state &state, element_base *container, dcon::commodity_id a, dcon::commodity_id b)
table::column< dcon::market_id > market_demand
table::column< dcon::nation_id > nation_name
table::column< dcon::market_id > market_production
bool compare_stockpile_player(sys::state &state, element_base *container, dcon::commodity_id a, dcon::commodity_id b)
table::column< dcon::market_id > market_consumption
table::column< dcon::nation_id > nation_price
std::string supply_view_commodity_id(sys::state &state, element_base *container, dcon::commodity_id item)
bool compare_balance(sys::state &state, element_base *container, dcon::commodity_id a, dcon::commodity_id b)
table::column< dcon::commodity_id > trade_good_demand_column
bool compare_demand(sys::state &state, element_base *container, dcon::commodity_id a, dcon::commodity_id b)
table::column< dcon::market_id > market_stockpile
bool compare_supply(sys::state &state, element_base *container, dcon::commodity_id a, dcon::commodity_id b)
table::column< dcon::nation_id > nation_consumption
table::column< dcon::commodity_id > trade_good_player_gov_needs
table::column< dcon::nation_id > nation_demand
void send(sys::state &state, element_base *parent, T value)
table::column< dcon::market_id > market_price
std::string stockpile_market_view_commodity_id(sys::state &state, element_base *container, dcon::commodity_id item)
std::string demand_view_commodity_id(sys::state &state, element_base *container, dcon::commodity_id item)
table::column< dcon::commodity_id > trade_good_player_pop_needs
std::string name_view_commodity_id(sys::state &state, element_base *container, dcon::commodity_id item)
table::column< dcon::commodity_id > trade_good_market_stockpile_column
table::column< dcon::commodity_id > trade_good_name_column
bool compare_price(sys::state &state, element_base *container, const dcon::commodity_id a, const dcon::commodity_id b)
table::column< dcon::commodity_id > trade_good_production_rgo
table::column< dcon::commodity_id > trade_good_produced_nation
table::column< dcon::commodity_id > trade_good_player_stockpile_column
table::column< dcon::commodity_id > trade_good_player_factory_needs
table::column< dcon::market_id > market_name
table::column< dcon::nation_id > nation_production
table::column< dcon::commodity_id > trade_good_price_column
table::column< dcon::market_id > market_artisan_profit
std::string balance_view_commodity_id(sys::state &state, element_base *container, dcon::commodity_id item)
table::column< dcon::commodity_id > trade_good_player_price
table::column< dcon::commodity_id > trade_good_supply_column
table::column< dcon::commodity_id > trade_good_balance_column
table::column< dcon::market_id > market_artisan_score
Holds important data about the game world, state, and other data regarding windowing,...
element_base * trade_subwindow
ankerl::unordered_dense::map< dcon::text_key, element_target, hash_text_key > defs_by_name
element_base * drag_target
dcon::commodity_id commodity_id
dcon::commodity_id commodity_id