Skip to content

Commit

Permalink
fixes for list items not updating
Browse files Browse the repository at this point in the history
  • Loading branch information
schombert committed Oct 9, 2023
1 parent 8a7a91a commit 106d4e0
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/gui/gui_console.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class console_list_entry : public listbox_row_element_base<std::string> {
}
}

void update(sys::state& state) noexcept override {
void on_update(sys::state& state) noexcept override {
entry_text_box->set_text(state, content);
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/gui/gui_element_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ message_result listbox_row_element_base<RowConT>::get(sys::state& state, Cyto::A
return message_result::consumed;
} else if(payload.holds_type<wrapped_listbox_row_content<RowConT>>()) {
content = any_cast<wrapped_listbox_row_content<RowConT>>(payload).content;
update(state);
impl_on_update(state);
return message_result::consumed;
}
return message_result::unseen;
Expand Down
1 change: 0 additions & 1 deletion src/gui/gui_element_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,6 @@ class listbox_row_element_base : public window_element_base {
RowConT content{};

public:
virtual void update(sys::state& state) noexcept { }
message_result get(sys::state& state, Cyto::Any& payload) noexcept override;
};

Expand Down
7 changes: 3 additions & 4 deletions src/gui/gui_ledger_window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ class ledger_nation_ranking_entry : public listbox_row_element_base<dcon::nation
return listbox_row_element_base::get(state, payload);
}

void update(sys::state& state) noexcept override {
country_flag->on_update(state);
void on_update(sys::state& state) noexcept override {
Cyto::Any payload = content;
impl_set(state, payload);
}
Expand Down Expand Up @@ -618,7 +617,7 @@ class ledger_province_entry : public listbox_row_element_base<dcon::province_id>
return listbox_row_element_base::get(state, payload);
}

void update(sys::state& state) noexcept override {
void on_update(sys::state& state) noexcept override {
Cyto::Any payload = content;
impl_set(state, payload);
}
Expand Down Expand Up @@ -785,7 +784,7 @@ class ledger_provinces_production_entry : public listbox_row_element_base<dcon::
return listbox_row_element_base::get(state, payload);
}

void update(sys::state& state) noexcept override {
void on_update(sys::state& state) noexcept override {
Cyto::Any payload = content;
impl_set(state, payload);
}
Expand Down
14 changes: 5 additions & 9 deletions src/gui/topbar_subwindows/gui_population_window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1624,7 +1624,7 @@ class pop_left_side_item : public listbox_row_element_base<pop_left_side_data> {
// After this, the widget will be immediately set by the parent
}

void update(sys::state& state) noexcept override {
void on_update(sys::state& state) noexcept override {
country_window->set_visible(state, std::holds_alternative<dcon::nation_id>(content));
state_window->set_visible(state, std::holds_alternative<dcon::state_instance_id>(content));
province_window->set_visible(state, std::holds_alternative<dcon::province_id>(content));
Expand Down Expand Up @@ -1761,10 +1761,8 @@ class pop_distribution_item : public listbox_row_element_base<std::pair<T, float
}
}

void update(sys::state& state) noexcept override {
void on_update(sys::state& state) noexcept override {
value_text->set_text(state, text::format_percentage(listbox_row_element_base<std::pair<T, float>>::content.second, 1));
for(auto& c : listbox_row_element_base<std::pair<T, float>>::children)
c->impl_on_update(state);
}

message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
Expand Down Expand Up @@ -1969,7 +1967,7 @@ class pop_detailed_issue_distribution_item : public listbox_row_element_base<std
}
}

void update(sys::state& state) noexcept override {
void on_update(sys::state& state) noexcept override {
value_text->set_text(state, text::format_percentage(listbox_row_element_base<std::pair<dcon::issue_option_id, float>>::content.second, 1));
for(auto& c : listbox_row_element_base<std::pair<dcon::issue_option_id, float>>::children)
c->impl_on_update(state);
Expand Down Expand Up @@ -2120,10 +2118,8 @@ class pop_detailed_ideology_distribution_item : public listbox_row_element_base<
}
}

void update(sys::state& state) noexcept override {
void on_update(sys::state& state) noexcept override {
value_text->set_text(state, text::format_percentage(listbox_row_element_base<std::pair<dcon::ideology_id, float>>::content.second, 1));
for(auto& c : listbox_row_element_base<std::pair<dcon::ideology_id, float>>::children)
c->impl_on_update(state);
}

message_result get(sys::state& state, Cyto::Any& payload) noexcept override {
Expand Down Expand Up @@ -2283,7 +2279,7 @@ class pop_details_needs_item : public listbox_row_element_base<pop_details_needs
}
}

void update(sys::state& state) noexcept override {
void on_update(sys::state& state) noexcept override {
value_text->set_text(state, text::format_float(content.second, 1));
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/topbar_subwindows/gui_trade_window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ class trade_flow_entry : public listbox_row_element_base<trade_flow_data> {
}
}

void update(sys::state& state) noexcept override {
void on_update(sys::state& state) noexcept override {
auto commodity_id = retrieve<dcon::commodity_id>(state, parent);

icon->frame = int32_t(content.type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ class units_build_item : public listbox_row_element_base<buildable_unit_entry_in
}
}

void update(sys::state& state) noexcept override {
void on_update(sys::state& state) noexcept override {
dcon::unit_type_id utid = retrieve<dcon::unit_type_id>(state, parent);
if(!content.continent) {
build_button->set_visible(state, true);
Expand Down Expand Up @@ -531,7 +531,7 @@ class units_queue_item : public listbox_row_element_base<queue_unit_entry_info>
}
}

void update(sys::state& state) noexcept override {
void on_update(sys::state& state) noexcept override {
if(!content.is_navy) {
auto c = content.land_id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class military_leaders : public listbox_row_element_base<dcon::leader_id> {
}
}

void update(sys::state& state) noexcept override {
void on_update(sys::state& state) noexcept override {
auto name_id = state.world.leader_get_name(content);
auto name_content = state.to_string_view(name_id);
leader_name->set_text(state, std::string(name_content));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ class military_unit_entry : public listbox_row_element_base<military_unit_info<T
}
}

void update(sys::state& state) noexcept override {
void on_update(sys::state& state) noexcept override {
auto const& content = listbox_row_element_base<military_unit_info<T>>::content;

bool is_building = !std::holds_alternative<T>(content);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,6 @@ class decision_item : public listbox_row_element_base<dcon::decision_id> {
return message_result::unseen;
}
}

void update(sys::state& state) noexcept override {
for(auto& child : children) {
child->impl_on_update(state);
}
}
};

// ----------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ class reforms_option : public listbox_row_element_base<dcon::issue_option_id> {

void on_update(sys::state& state) noexcept override {
selected_icon->set_visible(state, politics::issue_is_selected(state, state.local_player_nation, content));
update(state);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ class unciv_reforms_option : public listbox_row_element_base<dcon::reform_option

void on_update(sys::state& state) noexcept override {
selected_icon->set_visible(state, politics::reform_is_selected(state, state.local_player_nation, content));
update(state);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class production_project_input_item : public listbox_row_element_base<production
}
}

void update(sys::state& state) noexcept override {
void on_update(sys::state& state) noexcept override {
amount_text->set_text(state, text::format_float(content.satisfied, 1) + "/" + text::format_float(content.needed, 1));
}

Expand Down

0 comments on commit 106d4e0

Please sign in to comment.