16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 23:19:19 +02:00

fixes to pause popup logic

This commit is contained in:
milek7
2019-08-21 21:52:47 +02:00
parent d961cb17a2
commit ad58c617d4

View File

@@ -80,8 +80,7 @@ driver_ui::on_key( int const Key, int const Action ) {
if (ui_layer::on_key(Key, Action)) if (ui_layer::on_key(Key, Action))
return true; return true;
switch( Key ) { switch( Key ) {
case GLFW_KEY_TAB: case GLFW_KEY_TAB:
case GLFW_KEY_F1: case GLFW_KEY_F1:
case GLFW_KEY_F2: case GLFW_KEY_F2:
@@ -183,7 +182,7 @@ driver_ui::update() {
&& ( false == Global.ControlPicking ) ) { && ( false == Global.ControlPicking ) ) {
set_cursor( ispaused ); set_cursor( ispaused );
} }
m_paused = ispaused; m_paused = ispaused;
set_tooltip( "" ); set_tooltip( "" );
@@ -229,17 +228,13 @@ void
driver_ui::render_() { driver_ui::render_() {
// pause/quit modal // pause/quit modal
auto const popupheader { STR_C("Simulation Paused") }; auto const popupheader { STR_C("Simulation Paused") };
if (m_paused && !m_pause_modal_opened)
{ ImGui::SetNextWindowSize(ImVec2(-1, -1));
m_pause_modal_opened = true; if( ImGui::BeginPopupModal( popupheader, nullptr, 0 ) ) {
ImGui::OpenPopup(popupheader); if( ImGui::Button( STR_C("Resume"), ImVec2( 150, 0 ) ) ) {
}
if( ImGui::BeginPopupModal( popupheader, &m_pause_modal_opened, ImGuiWindowFlags_AlwaysAutoResize ) ) {
auto const popupwidth{ STR("Simulation Paused").size() * 7 };
if( ImGui::Button( STR_C("Resume"), ImVec2( popupwidth, 0 ) ) ) {
m_relay.post(user_command::pausetoggle, 0.0, 0.0, GLFW_PRESS, 0); m_relay.post(user_command::pausetoggle, 0.0, 0.0, GLFW_PRESS, 0);
} }
if( ImGui::Button( STR_C("Quit"), ImVec2( popupwidth, 0 ) ) ) { if( ImGui::Button( STR_C("Quit"), ImVec2( 150, 0 ) ) ) {
m_relay.post(user_command::quitsimulation, 0.0, 0.0, GLFW_PRESS, 0); m_relay.post(user_command::quitsimulation, 0.0, 0.0, GLFW_PRESS, 0);
} }
if (!m_paused) if (!m_paused)
@@ -249,4 +244,9 @@ driver_ui::render_() {
} }
ImGui::EndPopup(); ImGui::EndPopup();
} }
if (m_paused && !m_pause_modal_opened)
{
m_pause_modal_opened = true;
ImGui::OpenPopup(popupheader);
}
} }