-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/schombert/Project-Alice int…
…o HEAD
- Loading branch information
Showing
21 changed files
with
324 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#include "gui_error_window.hpp" | ||
|
||
namespace ui { | ||
|
||
void error_body_text::populate_layout(sys::state& state, text::endless_layout& contents) noexcept { | ||
auto box = text::open_layout_box(contents); | ||
text::add_to_layout_box(state, contents, box, msg); | ||
text::close_layout_box(contents, box); | ||
} | ||
void error_body_text::on_create(sys::state& state) noexcept { | ||
base_data.size.y = int16_t(150); | ||
scrollable_text::on_create(state); | ||
} | ||
void error_body_text::on_update(sys::state& state) noexcept { | ||
text::alignment align = text::alignment::left; | ||
switch(base_data.data.text.get_alignment()) { | ||
case ui::alignment::right: | ||
align = text::alignment::right; | ||
break; | ||
case ui::alignment::centered: | ||
align = text::alignment::center; | ||
break; | ||
default: | ||
break; | ||
} | ||
auto border = base_data.data.text.border_size; | ||
auto color = delegate->black_text ? text::text_color::black : text::text_color::white; | ||
auto container = text::create_endless_layout( | ||
delegate->internal_layout, | ||
text::layout_parameters{ | ||
border.x, | ||
border.y, | ||
int16_t(base_data.size.x - border.x * 2), | ||
int16_t(base_data.size.y - border.y * 2), | ||
base_data.data.text.font_handle, | ||
0, | ||
align, | ||
color, | ||
false }); | ||
populate_layout(state, container); | ||
} | ||
|
||
std::unique_ptr<element_base> error_dialog_window::make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept { | ||
if(name == "title") { | ||
auto ptr = make_element_by_type<simple_text_element_base>(state, id); | ||
title = ptr.get(); | ||
return ptr; | ||
} else if(name == "description") { | ||
auto ptr = make_element_by_type<error_body_text>(state, id); | ||
body = ptr.get(); | ||
return ptr; | ||
} else if(name == "agreebutton") { | ||
return make_element_by_type<generic_close_button>(state, id); | ||
} else if(name == "background") { | ||
auto ptr = make_element_by_type<draggable_target>(state, id); | ||
ptr->base_data.size = base_data.size; | ||
return ptr; | ||
} else { | ||
return nullptr; | ||
} | ||
} | ||
void popup_error_window(sys::state& state, std::string_view title, std::string_view body) { | ||
if(state.ui_state.error_win == nullptr) { | ||
auto new_elm = ui::make_element_by_type<ui::error_dialog_window>(state, "defaultinfodialog"); | ||
state.ui_state.error_win = new_elm.get(); | ||
if(state.mode == sys::game_mode_type::pick_nation) { | ||
state.ui_state.nation_picker->add_child_to_front(std::move(new_elm)); | ||
} else if(state.mode == sys::game_mode_type::in_game) { | ||
state.ui_state.root->add_child_to_front(std::move(new_elm)); | ||
} else if(state.mode == sys::game_mode_type::end_screen) { | ||
state.ui_state.end_screen->add_child_to_front(std::move(new_elm)); | ||
} else if(state.mode == sys::game_mode_type::select_states) { | ||
state.ui_state.select_states_legend->add_child_to_front(std::move(new_elm)); | ||
} | ||
} | ||
|
||
auto win = static_cast<ui::error_dialog_window*>(state.ui_state.error_win); | ||
win->title->set_text(state, std::string(title)); | ||
win->body->msg = std::string(body); | ||
win->set_visible(state, true); | ||
win->impl_on_update(state); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
|
||
#include "gui_common_elements.hpp" | ||
#include "gui_element_types.hpp" | ||
#include <string_view> | ||
|
||
namespace ui { | ||
class error_body_text : public scrollable_text { | ||
void populate_layout(sys::state& state, text::endless_layout& contents) noexcept; | ||
public: | ||
std::string msg = ""; | ||
void on_create(sys::state& state) noexcept override; | ||
void on_update(sys::state& state) noexcept override; | ||
}; | ||
class error_dialog_window : public window_element_base { | ||
public: | ||
simple_text_element_base* title = nullptr; | ||
error_body_text* body = nullptr; | ||
std::unique_ptr<element_base> make_child(sys::state& state, std::string_view name, dcon::gui_def_id id) noexcept override; | ||
}; | ||
void popup_error_window(sys::state& state, std::string_view title, std::string_view body); | ||
} // namespace ui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.