23 state.world.for_each_technology([&](dcon::technology_id
id) {
25 if(
state.culture_definitions.tech_folders[fat_id.get_folder_index()].category !=
category)
27 bool discovered =
state.world.nation_get_active_technologies(
state.local_player_nation,
id);
29 bool is_current =
state.world.nation_get_current_research(
state.local_player_nation) == id;
30 auto color = discovered
37 auto name = fat_id.get_name();
82 state.world.for_each_technology([&](dcon::technology_id
id) {
84 if(
state.culture_definitions.tech_folders[fat_id.get_folder_index()].category ==
category) {
85 discovered +=
state.world.nation_get_active_technologies(
state.local_player_nation,
id) ? 1 : 0;
89 progress = bool(total) && bool(discovered) ? float(discovered) / float(total) : 0.f;
97 state.world.for_each_technology([&](dcon::technology_id
id) {
99 if(
state.culture_definitions.tech_folders[fat_id.get_folder_index()].category ==
category) {
100 discovered +=
state.world.nation_get_active_technologies(
state.local_player_nation,
id) ? 1 : 0;
135 if(
name ==
"folder_button") {
136 auto ptr = make_element_by_type<technology_folder_tab_sub_button>(
state,
id);
137 folder_button = ptr.
get();
139 }
else if(
name ==
"folder_icon") {
140 auto ptr = make_element_by_type<image_element_base>(
state,
id);
141 folder_icon = ptr.
get();
143 }
else if(
name ==
"folder_category") {
144 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
145 folder_name = ptr.
get();
147 }
else if(
name ==
"folder_progress") {
148 auto ptr = make_element_by_type<technology_tab_progress>(
state,
id);
149 folder_progress = ptr.
get();
151 }
else if(
name ==
"folder_number_discovered") {
152 auto ptr = make_element_by_type<technology_num_discovered_text>(
state,
id);
153 folder_num_discovered = ptr.
get();
166 auto const& folder =
state.culture_definitions.tech_folders[tech.get_folder_index()];
189 auto content = retrieve<dcon::technology_id>(
state,
parent);
197 auto content = retrieve<dcon::technology_id>(
state,
parent);
201 state.game_state_updated.store(
true, std::memory_order::release);
206 auto content = retrieve<dcon::technology_id>(
state,
parent);
212 if(content !=
state.world.nation_get_current_research(
state.local_player_nation) && !
state.world.nation_get_active_technologies(
state.local_player_nation, content)) {
228 auto content = retrieve<dcon::technology_id>(
state,
parent);
230 if(
auto name = fat_id.get_name();
state.key_is_localized(
name)) {
235 if(
auto desc = fat_id.get_desc();
state.key_is_localized(desc)) {
252 auto content = retrieve<dcon::technology_id>(
state,
parent);
274 if(
name ==
"start_research") {
275 auto ptr = make_element_by_type<technology_item_button>(
state,
id);
276 tech_button = ptr.
get();
278 }
else if(
name ==
"tech_name") {
279 return make_element_by_type<technology_name_text>(
state,
id);
289 if(
state.world.nation_get_active_technologies(
state.local_player_nation,
tech_id)) {
291 tech_button->
frame = 1;
294 tech_button->
frame = 0;
297 tech_button->
frame = 2;
300 tech_button->
frame = 3;
305 if(payload.holds_type<dcon::technology_id>()) {
306 payload.emplace<dcon::technology_id>(
tech_id);
317 auto content = retrieve<dcon::invention_id>(
state,
parent);
318 frame = int32_t(
state.world.invention_get_technology_type(content));
326 auto content = retrieve<dcon::invention_id>(
state,
parent);
337 auto content = retrieve<dcon::invention_id>(
state,
parent);
346 auto content = retrieve<dcon::invention_id>(
state,
parent);
348 if(
auto name =
state.world.invention_get_name(content);
name) {
353 if(
auto desc =
state.world.invention_get_name(content); desc) {
367 if(
auto content = retrieve<dcon::invention_id>(
state,
parent); content) {
368 auto mod_k =
state.world.invention_get_chance(content);
380 if(
auto content = retrieve<dcon::invention_id>(
state,
parent); content) {
382 auto mod_k =
state.world.invention_get_chance(content);
391 if(
name ==
"folder_icon") {
392 return make_element_by_type<invention_image>(
state,
id);
393 }
else if(
name ==
"invention_name") {
394 return make_element_by_type<invention_name_text>(
state,
id);
395 }
else if(
name ==
"invention_percent") {
396 return make_element_by_type<invention_chance_percent_text>(
state,
id);
410 return "invention_window";
416 state.world.for_each_invention([&](dcon::invention_id
id) {
417 auto lim_trigger_k =
state.world.invention_get_limit(
id);
423 auto sort_order = retrieve< invention_sort_type>(
state,
parent);
427 auto a_name = text::produce_simple_string(state, dcon::fatten(state.world, a).get_name());
428 auto b_name = text::produce_simple_string(state, dcon::fatten(state.world, b).get_name());
429 return a_name < b_name;
434 return state.world.invention_get_technology_type(a) < state.world.invention_get_technology_type(b);
439 auto mod_a = state.world.invention_get_chance(a);
440 auto chances_a = trigger::evaluate_additive_modifier(state, mod_a, trigger::to_generic(state.local_player_nation),
441 trigger::to_generic(state.local_player_nation), 0);
442 auto mod_b = state.world.invention_get_chance(b);
443 auto chances_b = trigger::evaluate_additive_modifier(state, mod_b, trigger::to_generic(state.local_player_nation),
444 trigger::to_generic(state.local_player_nation), 0);
446 return chances_a > chances_b;
457 auto content = retrieve<dcon::invention_id>(
state,
parent);
459 if(content &&
state.world.nation_get_active_inventions(
state.local_player_nation, content)) {
462 auto tech_id = retrieve<dcon::technology_id>(
state,
parent);
463 if(tech_id &&
state.world.nation_get_active_technologies(
state.local_player_nation, tech_id))
473 auto inv = retrieve<dcon::invention_id>(
state,
parent);
474 auto tech_id = retrieve<dcon::technology_id>(
state,
parent);
475 if(inv &&
state.world.nation_get_active_inventions(
state.local_player_nation, inv)) {
477 }
else if(tech_id &&
state.world.nation_get_active_technologies(
state.local_player_nation, tech_id)) {
487 if(
name ==
"invention_icon") {
488 return make_element_by_type<technology_selected_invention_image>(
state,
id);
489 }
else if(
name ==
"i_invention_name") {
490 return make_element_by_type<invention_name_text>(
state,
id);
499 return "invention_icon_window";
504 auto content = retrieve<dcon::technology_id>(
state,
parent);
506 state.world.for_each_invention([&](dcon::invention_id
id) {
507 auto lim_trigger_k =
state.world.invention_get_limit(
id);
508 bool activable_by_this_tech =
false;
510 [&](uint16_t* tval) {
511 if((tval[0] & trigger::code_mask) == trigger::technology && trigger::payload(tval[1]).tech_id == content)
512 activable_by_this_tech = true;
514 if(activable_by_this_tech)
525 Cyto::Any payload = dcon::technology_id{};
527 auto content = any_cast<dcon::technology_id>(payload);
538 Cyto::Any payload = dcon::technology_id{};
540 auto content = any_cast<dcon::technology_id>(payload);
550 auto t = retrieve<dcon::technology_id>(
state,
parent);
565 auto tech_id = retrieve<dcon::technology_id>(
state,
parent);
569 auto base_cost =
state.world.technology_get_cost(tech_id);
570 auto availability_year =
state.world.technology_get_year(tech_id);
571 auto folder =
state.world.technology_get_folder_index(tech_id);
572 auto category =
state.culture_definitions.tech_folders[folder].category;
615 auto ol_mod =
state.world.nation_get_active_technologies(
state.world.overlord_get_ruler(
state.world.nation_get_overlord_as_subject(
state.local_player_nation)), tech_id) ?
state.defines.tech_factor_vassal : 1.0f;
621 auto year_mod = (1.0f - std::max(0.0f,
float(
state.ui_date.to_ymd(
state.start_date).year - availability_year) /
state.defines.tech_year_span));
622 if(year_mod != 1.0f) {
637 auto content = retrieve<dcon::technology_id>(
state,
parent);
640 base_data.data.text.font_handle, 0, text::alignment::left,
641 text::is_black_from_font_id(base_data.data.text.font_handle) ? text::text_color::black : text::text_color::white, false});
650 auto content = retrieve<dcon::technology_id>(
state,
parent);
655 auto content = retrieve<dcon::technology_id>(
state,
parent);
663 if(
name ==
"picture") {
664 return make_element_by_type<technology_image>(
state,
id);
665 }
else if(
name ==
"title") {
666 return make_element_by_type<generic_name_text<dcon::technology_id>>(
state, id);
667 }
else if(
name ==
"effect") {
668 return make_element_by_type<technology_selected_effect_text>(
state,
id);
669 }
else if(
name ==
"diff_icon") {
670 return make_element_by_type<image_element_base>(
state,
id);
671 }
else if(
name ==
"diff_label") {
672 return make_element_by_type<simple_body_text>(
state,
id);
673 }
else if(
name ==
"diff") {
674 return make_element_by_type<technology_research_points_text>(
state,
id);
675 }
else if(
name ==
"year_label") {
676 return make_element_by_type<simple_body_text>(
state,
id);
677 }
else if(
name ==
"year") {
678 return make_element_by_type<technology_year_text>(
state,
id);
679 }
else if(
name ==
"start") {
680 return make_element_by_type<technology_start_research>(
state,
id);
681 }
else if(
name ==
"inventions") {
682 return make_element_by_type<technology_selected_inventions_listbox>(
state,
id);
696 if(
name ==
"group_name") {
697 auto ptr = make_element_by_type<simple_text_element_base>(
state,
id);
698 group_name = ptr.
get();
707 auto folder = any_cast<culture::folder_info>(payload);
711 auto enum_val = any_cast<culture::tech_category>(payload);
775 dcon::technology_id tech_id{};
784 auto ptr = make_element_by_type<technology_folder_tab_button>(
state,
786 ptr->set_category(
state, curr_folder);
787 ptr->base_data.position = folder_offset;
788 folder_offset.
x += ptr->base_data.size.x;
797 std::vector<std::vector<size_t>> folders_by_category(
static_cast<size_t>(5));
798 for(
size_t i = 0; i <
state.culture_definitions.tech_folders.size(); i++) {
799 auto const& folder =
state.culture_definitions.tech_folders[i];
800 folders_by_category[
static_cast<size_t>(folder.category)].push_back(i);
804 std::vector<size_t> folder_x_offset(
state.culture_definitions.tech_folders.size(), 0);
805 for(
auto const& folder_category : folders_by_category) {
807 for(
auto const folder_index : folder_category)
808 folder_x_offset[folder_index] = y_offset++;
811 std::vector<size_t> items_per_folder(
state.culture_definitions.tech_folders.size(), 0);
820 int16_t group_count = 0;
821 for(
auto const& folder :
state.culture_definitions.tech_folders) {
822 if(folder.category != cat)
825 auto ptr = make_element_by_type<technology_tech_group_window>(
state,
830 ptr->impl_set(
state, payload);
832 ptr->base_data.position.x =
static_cast<int16_t
>(base_group_offset.
x + (group_count * ptr->base_data.size.x));
833 ptr->base_data.position.y = base_group_offset.
y;
839 state.world.for_each_technology([&](dcon::technology_id tid) {
841 size_t folder_id =
static_cast<size_t>(tech.get_folder_index());
842 const auto& folder =
state.culture_definitions.tech_folders[folder_id];
843 if(folder.category != cat)
846 auto ptr = make_element_by_type<technology_item_window>(
state,
850 ptr->impl_set(
state, payload);
852 ptr->base_data.position.x =
853 static_cast<int16_t
>(base_group_offset.
x + (folder_x_offset[folder_id] * ptr->base_data.size.x));
855 ptr->base_data.position.y =
856 static_cast<int16_t
>(base_group_offset.
y + base_tech_offset.
y +
857 (
static_cast<int16_t
>(items_per_folder[folder_id]) * ptr->base_data.size.y));
858 items_per_folder[folder_id]++;
871 if(
name ==
"main_bg") {
872 return make_element_by_type<image_element_base>(
state,
id);
873 }
else if(
name ==
"bg_tech") {
874 return make_element_by_type<opaque_element_base>(
state,
id);
875 }
else if(
name ==
"close_button") {
876 return make_element_by_type<generic_close_button>(
state,
id);
877 }
else if(
name ==
"administration") {
878 return make_element_by_type<simple_body_text>(
state,
id);
879 }
else if(
name ==
"current_research") {
880 return make_element_by_type<simple_body_text>(
state,
id);
881 }
else if(
name ==
"administration_type") {
882 return make_element_by_type<national_tech_school>(
state,
id);
883 }
else if(
name ==
"research_progress") {
884 return make_element_by_type<nation_technology_research_progress>(
state,
id);
885 }
else if(
name ==
"research_progress_name") {
886 return make_element_by_type<nation_current_research_text>(
state,
id);
887 }
else if(
name ==
"research_progress_category") {
888 return make_element_by_type<technology_research_progress_category_text>(
state,
id);
889 }
else if(
name ==
"selected_tech_window") {
890 auto ptr = make_element_by_type<technology_selected_tech_window>(
state,
id);
891 selected_tech_win = ptr.
get();
893 }
else if(
name ==
"sort_by_type") {
894 auto ptr = make_element_by_type<technology_sort_by_type_button>(
state,
id);
895 ptr->base_data.position.y -= 1;
897 }
else if(
name ==
"sort_by_name") {
898 return make_element_by_type<technology_sort_by_name_button>(
state,
id);
899 }
else if(
name ==
"sort_by_percent") {
900 auto ptr = make_element_by_type<technology_sort_by_percent_button>(
state,
id);
901 ptr->base_data.position.y -= 1;
903 }
else if(
name ==
"inventions") {
904 return make_element_by_type<technology_possible_invention_listbox>(
state,
id);
912 active_tab = any_cast<culture::tech_category>(payload);
914 c->impl_set(
state, payload);
917 tech_id = any_cast<technology_select_tech>(payload).tech_id;
925 if(payload.holds_type<dcon::technology_id>()) {
926 payload.emplace<dcon::technology_id>(tech_id);
928 }
else if(payload.holds_type<dcon::nation_id>()) {
929 payload.emplace<dcon::nation_id>(
state.local_player_nation);
932 invention_sort = any_cast<element_selection_wrapper<invention_sort_type>>(payload).data;
936 payload = invention_sort;
dcon::text_key get_name() noexcept
message_result impl_set(sys::state &state, Cyto::Any &payload) noexcept final
void add_child_to_front(std::unique_ptr< element_base > child) noexcept final
std::vector< std::unique_ptr< element_base > > children
void impl_on_update(sys::state &state) noexcept override
virtual message_result impl_set(sys::state &state, Cyto::Any &payload) noexcept
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
virtual void on_create(sys::state &state) noexcept
void set_visible(sys::state &state, bool vis)
culture::tech_category active_tab
void update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void on_update(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
tooltip_behavior has_tooltip(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 update_tooltip(sys::state &state, int32_t x, int32_t y, text::columnar_layout &contents) noexcept override
void on_update(sys::state &state) noexcept override
tooltip_behavior has_tooltip(sys::state &state) noexcept override
std::vector< dcon::invention_id > row_contents
void update(sys::state &state)
text::layout internal_layout
void calibrate_scrollbar(sys::state &state) noexcept
void on_create(sys::state &state) noexcept override
multiline_text_element_base * delegate
void set_text(sys::state &state, std::string const &new_text)
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
message_result set(sys::state &state, Cyto::Any &payload) noexcept override
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
dcon::technology_id tech_id
void on_update(sys::state &state) noexcept override
culture::tech_category category
void on_update(sys::state &state) noexcept override
std::string_view get_row_element_name() 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_update(sys::state &state) noexcept override
tooltip_behavior has_tooltip(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_update(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
void on_create(sys::state &state) noexcept override
tooltip_behavior has_tooltip(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_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 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 button_action(sys::state &state) noexcept override
void on_update(sys::state &state) noexcept override
culture::tech_category category
void on_update(sys::state &state) noexcept override
culture::tech_category category
message_result set(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
void on_create(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
message_result get(sys::state &state, Cyto::Any &payload) noexcept override
message_result set(sys::state &state, Cyto::Any &payload) noexcept override
void on_update(sys::state &state) noexcept override
bool can_start_research(sys::state &state, dcon::nation_id source, dcon::technology_id tech)
float effective_technology_cost(sys::state &state, uint32_t current_year, dcon::nation_id target_nation, dcon::technology_id tech_id)
std::string get_tech_category_name(tech_category t)
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
dcon::technology_id current_research(sys::state const &state, dcon::nation_id n)
void add_to_layout_box(sys::state &state, layout_base &dest, layout_box &box, embedded_flag ico)
std::string get_name_as_string(sys::state &state, T t)
layout_box open_layout_box(layout_base &dest, int32_t indent)
void localised_format_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view key, text::substitution_map const &sub)
endless_layout create_endless_layout(sys::state &state, layout &dest, layout_parameters const ¶ms)
void add_line(sys::state &state, layout_base &dest, dcon::text_key txt, int32_t indent)
void add_line_break_to_layout(sys::state &state, columnar_layout &dest)
std::string produce_simple_string(sys::state const &state, dcon::text_key id)
std::string format_percentage(float num, size_t digits)
void add_space_to_layout_box(sys::state &state, layout_base &dest, layout_box &box)
void close_layout_box(columnar_layout &dest, layout_box &box)
int32_t to_generic(dcon::province_id v)
bool evaluate(sys::state &state, dcon::trigger_key key, int32_t primary, int32_t this_slot, int32_t from_slot)
float evaluate_additive_modifier(sys::state &state, dcon::value_modifier_key modifier, int32_t primary, int32_t this_slot, int32_t from_slot)
uint16_t * recurse_over_triggers(uint16_t *source, T const &f)
void additive_value_modifier_description(sys::state &state, text::layout_base &layout, dcon::value_modifier_key modifier, int32_t primary, int32_t this_slot, int32_t from_slot)
void send(sys::state &state, element_base *parent, T value)
void technology_description(sys::state &state, text::layout_base &contents, dcon::technology_id tech_id) noexcept
void invention_description(sys::state &state, text::layout_base &contents, dcon::invention_id inv_id, int32_t indent) noexcept
void active_modifiers_description(sys::state &state, text::layout_base &layout, dcon::nation_id n, int32_t identation, dcon::national_modifier_value nmid, bool header)
union ui::element_data::internal_data data
dcon::gfx_object_id gfx_object
element_base * technology_subwindow
ankerl::unordered_dense::map< dcon::text_key, element_target, hash_text_key > defs_by_name
std::vector< dcon::technology_id > tech_queue
dcon::technology_id tech_id