switch debugtoggle and pausetoggle to release, and logic fixes

This commit is contained in:
milek7
2023-05-28 21:07:38 +02:00
parent 3df159024b
commit 54e5e186a3
5 changed files with 27 additions and 26 deletions

View File

@@ -231,21 +231,15 @@ driver_ui::render_() {
if( ( ImGui::Button( STR_C("Resume"), ImVec2( 150, 0 ) ) )
|| ( ImGui::IsKeyReleased( ImGui::GetKeyIndex( ImGuiKey_Escape ) ) ) )
{
m_relay.post(user_command::pausetoggle, 0.0, 0.0, GLFW_PRESS, 0);
m_relay.post(user_command::pausetoggle, 0.0, 0.0, GLFW_RELEASE, 0);
}
if( ImGui::Button( STR_C("Quit"), ImVec2( 150, 0 ) ) ) {
Application.queue_quit(false);
}
if (!m_paused)
{
m_pause_modal_opened = false;
ImGui::CloseCurrentPopup();
}
ImGui::EndPopup();
}
if (m_paused && !m_pause_modal_opened)
{
m_pause_modal_opened = true;
ImGui::EndPopup();
} else if (m_paused) {
ImGui::OpenPopup(popupheader);
}

View File

@@ -61,7 +61,6 @@ private:
trainingcard_panel m_trainingcardpanel;
perfgraph_panel m_perfgraphpanel;
bool m_paused { false };
bool m_pause_modal_opened { false };
command_relay m_relay;
ui::vehiclelist_panel m_vehiclelist { ui::vehiclelist_panel(*this) };

View File

@@ -634,7 +634,11 @@ debug_panel::render() {
#endif
// toggles
ImGui::Separator();
ImGui::Checkbox( "Debug Mode", &DebugModeFlag );
bool flag = DebugModeFlag;
if (ImGui::Checkbox("Debug Mode", &flag)) {
command_relay relay;
relay.post(user_command::debugtoggle, 0.0, 0.0, GLFW_RELEASE, 0);
}
}
ImGui::End();

View File

@@ -197,21 +197,21 @@ void state_manager::process_commands() {
}
}
if (commanddata.action == GLFW_RELEASE)
if (commanddata.action == GLFW_RELEASE) {
if (commanddata.command == user_command::debugtoggle)
DebugModeFlag = !DebugModeFlag;
if (commanddata.command == user_command::pausetoggle) {
if( Global.iPause & 1 ) {
// jeśli pauza startowa
// odpauzowanie, gdy po wczytaniu miało nie startować
Global.iPause ^= 1;
}
else {
Global.iPause ^= 2; // zmiana stanu zapauzowania
}
}
continue;
if (commanddata.command == user_command::debugtoggle)
DebugModeFlag = !DebugModeFlag;
if (commanddata.command == user_command::pausetoggle) {
if( Global.iPause & 1 ) {
// jeśli pauza startowa
// odpauzowanie, gdy po wczytaniu miało nie startować
Global.iPause ^= 1;
}
else {
Global.iPause ^= 2; // zmiana stanu zapauzowania
}
}
if (commanddata.command == user_command::focuspauseset) {

View File

@@ -465,7 +465,11 @@ void ui_layer::render_menu_contents()
{
if (ImGui::BeginMenu(STR_C("General")))
{
ImGui::MenuItem(STR_C("Debug mode"), nullptr, &DebugModeFlag);
bool flag = DebugModeFlag;
if (ImGui::MenuItem(STR_C("Debug mode"), nullptr, &flag)) {
command_relay relay;
relay.post(user_command::debugtoggle, 0.0, 0.0, GLFW_RELEASE, 0);
}
ImGui::MenuItem(STR_C("Quit"), "F10", &m_quit_active);
ImGui::EndMenu();
}