mirror of
https://github.com/k4zmu2a/SpaceCadetPinball.git
synced 2023-12-30 21:52:56 +00:00
Adjusted exit key: added shortcut binding, confirmation dialog.
This commit is contained in:
parent
215599684c
commit
9454e11fd9
@ -35,7 +35,7 @@ void font_selection::RenderDialog()
|
|||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::InputText("##Font", DialogInputBuffer, IM_ARRAYSIZE(DialogInputBuffer));
|
ImGui::InputText("##Font", DialogInputBuffer, IM_ARRAYSIZE(DialogInputBuffer));
|
||||||
|
|
||||||
if (ImGui::Button(pb::get_rc_string(Msg::HIGHSCORES_Ok)))
|
if (ImGui::Button(pb::get_rc_string(Msg::GenericOk)))
|
||||||
{
|
{
|
||||||
options::Options.FontFileName.V = DialogInputBuffer;
|
options::Options.FontFileName.V = DialogInputBuffer;
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
@ -43,7 +43,7 @@ void font_selection::RenderDialog()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::Button(pb::get_rc_string(Msg::HIGHSCORES_Cancel)))
|
if (ImGui::Button(pb::get_rc_string(Msg::GenericCancel)))
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
|
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
|
@ -172,12 +172,9 @@ void high_score::RenderHighScoreDialog()
|
|||||||
score = DlgData.Entry.Score;
|
score = DlgData.Entry.Score;
|
||||||
ImGui::PushItemWidth(200);
|
ImGui::PushItemWidth(200);
|
||||||
|
|
||||||
static bool doubleFocus = false;
|
if (ImGui::IsWindowAppearing())
|
||||||
if (ImGui::IsWindowAppearing() || doubleFocus)
|
|
||||||
{
|
{
|
||||||
// Hack - set focus only works on the second time.
|
|
||||||
ImGui::SetKeyboardFocusHere(0);
|
ImGui::SetKeyboardFocusHere(0);
|
||||||
doubleFocus ^= true;
|
|
||||||
}
|
}
|
||||||
if (ImGui::InputText("", DlgData.Entry.Name, IM_ARRAYSIZE(DlgData.Entry.Name),
|
if (ImGui::InputText("", DlgData.Entry.Name, IM_ARRAYSIZE(DlgData.Entry.Name),
|
||||||
ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_AutoSelectAll))
|
ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_AutoSelectAll))
|
||||||
@ -197,7 +194,7 @@ void high_score::RenderHighScoreDialog()
|
|||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui::Button(pb::get_rc_string(Msg::HIGHSCORES_Ok)) || textBoxSubmit)
|
if (ImGui::Button(pb::get_rc_string(Msg::GenericOk)) || textBoxSubmit)
|
||||||
{
|
{
|
||||||
if (dlg_enter_name)
|
if (dlg_enter_name)
|
||||||
{
|
{
|
||||||
@ -207,7 +204,7 @@ void high_score::RenderHighScoreDialog()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::Button(pb::get_rc_string(Msg::HIGHSCORES_Cancel)))
|
if (ImGui::Button(pb::get_rc_string(Msg::GenericCancel)))
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@ -216,14 +213,14 @@ void high_score::RenderHighScoreDialog()
|
|||||||
if (ImGui::BeginPopupModal("Confirm", nullptr, ImGuiWindowFlags_MenuBar))
|
if (ImGui::BeginPopupModal("Confirm", nullptr, ImGuiWindowFlags_MenuBar))
|
||||||
{
|
{
|
||||||
ImGui::TextUnformatted(pb::get_rc_string(Msg::STRING141));
|
ImGui::TextUnformatted(pb::get_rc_string(Msg::STRING141));
|
||||||
if (ImGui::Button(pb::get_rc_string(Msg::HIGHSCORES_Ok), ImVec2(120, 0)))
|
if (ImGui::Button(pb::get_rc_string(Msg::GenericOk), ImVec2(120, 0)))
|
||||||
{
|
{
|
||||||
clear_table();
|
clear_table();
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
ImGui::SetItemDefaultFocus();
|
ImGui::SetItemDefaultFocus();
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::Button(pb::get_rc_string(Msg::HIGHSCORES_Cancel), ImVec2(120, 0)))
|
if (ImGui::Button(pb::get_rc_string(Msg::GenericCancel), ImVec2(120, 0)))
|
||||||
{
|
{
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
|
@ -112,6 +112,13 @@ optionsStruct options::Options
|
|||||||
{InputTypes::None, -1},
|
{InputTypes::None, -1},
|
||||||
{InputTypes::None, -1}
|
{InputTypes::None, -1}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"Exit",
|
||||||
|
Msg::Menu1_Exit,
|
||||||
|
{InputTypes::Keyboard, SDLK_ESCAPE},
|
||||||
|
{InputTypes::None, -1},
|
||||||
|
{InputTypes::GameController, SDL_CONTROLLER_BUTTON_BACK}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{"Sounds", true},
|
{"Sounds", true},
|
||||||
{"Music", false},
|
{"Music", false},
|
||||||
@ -411,13 +418,13 @@ void options::RenderControlDialog()
|
|||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
|
|
||||||
if (ImGui::Button(pb::get_rc_string(Msg::KEYMAPPER_Ok)))
|
if (ImGui::Button(pb::get_rc_string(Msg::GenericOk)))
|
||||||
{
|
{
|
||||||
ShowDialog = false;
|
ShowDialog = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::Button(pb::get_rc_string(Msg::KEYMAPPER_Cancel)))
|
if (ImGui::Button(pb::get_rc_string(Msg::GenericCancel)))
|
||||||
{
|
{
|
||||||
for (auto& control : Options.Key)
|
for (auto& control : Options.Key)
|
||||||
{
|
{
|
||||||
|
@ -72,6 +72,7 @@ enum class GameBindings
|
|||||||
ToggleMusic,
|
ToggleMusic,
|
||||||
ShowControlDialog,
|
ShowControlDialog,
|
||||||
ToggleMenuDisplay,
|
ToggleMenuDisplay,
|
||||||
|
Exit,
|
||||||
Max
|
Max
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5056,7 +5056,7 @@ const TextArray translations::Translations =
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Msg::HIGHSCORES_Ok,
|
Msg::GenericOk,
|
||||||
{
|
{
|
||||||
{ Lang::Arabic, "موافق" },
|
{ Lang::Arabic, "موافق" },
|
||||||
{ Lang::Czech, "OK" },
|
{ Lang::Czech, "OK" },
|
||||||
@ -5085,7 +5085,7 @@ const TextArray translations::Translations =
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Msg::HIGHSCORES_Cancel,
|
Msg::GenericCancel,
|
||||||
{
|
{
|
||||||
{ Lang::Arabic, "إلغاء الأمر" },
|
{ Lang::Arabic, "إلغاء الأمر" },
|
||||||
{ Lang::Czech, "Storno" },
|
{ Lang::Czech, "Storno" },
|
||||||
@ -5258,64 +5258,6 @@ const TextArray translations::Translations =
|
|||||||
{ Lang::TraditionalChinese, "立體彈珠台:玩家控制" },
|
{ Lang::TraditionalChinese, "立體彈珠台:玩家控制" },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
Msg::KEYMAPPER_Ok,
|
|
||||||
{
|
|
||||||
{ Lang::Arabic, "موافق" },
|
|
||||||
{ Lang::Czech, "OK" },
|
|
||||||
{ Lang::Danish, "OK" },
|
|
||||||
{ Lang::German, "OK" },
|
|
||||||
{ Lang::Greek, "OK" },
|
|
||||||
{ Lang::English, "OK" },
|
|
||||||
{ Lang::Spanish, "Aceptar" },
|
|
||||||
{ Lang::Finnish, "OK" },
|
|
||||||
{ Lang::French, "OK" },
|
|
||||||
{ Lang::Hebrew, "אישור" },
|
|
||||||
{ Lang::Hungarian, "OK" },
|
|
||||||
{ Lang::Italian, "OK" },
|
|
||||||
{ Lang::Japanese, "OK" },
|
|
||||||
{ Lang::Korean, "확인" },
|
|
||||||
{ Lang::Norwegian, "OK" },
|
|
||||||
{ Lang::Dutch, "OK" },
|
|
||||||
{ Lang::Polish, "OK" },
|
|
||||||
{ Lang::BrazilianPortuguese, "OK" },
|
|
||||||
{ Lang::Portuguese, "OK" },
|
|
||||||
{ Lang::Russian, "ОК" },
|
|
||||||
{ Lang::Swedish, "OK" },
|
|
||||||
{ Lang::Turkish, "Tamam" },
|
|
||||||
{ Lang::SimplifiedChinese, "确定" },
|
|
||||||
{ Lang::TraditionalChinese, "確定" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Msg::KEYMAPPER_Cancel,
|
|
||||||
{
|
|
||||||
{ Lang::Arabic, "إلغاء الأمر" },
|
|
||||||
{ Lang::Czech, "Storno" },
|
|
||||||
{ Lang::Danish, "Annuller" },
|
|
||||||
{ Lang::German, "Abbrechen" },
|
|
||||||
{ Lang::Greek, "Άκυρο" },
|
|
||||||
{ Lang::English, "Cancel" },
|
|
||||||
{ Lang::Spanish, "Cancelar" },
|
|
||||||
{ Lang::Finnish, "Peruuta" },
|
|
||||||
{ Lang::French, "Annuler" },
|
|
||||||
{ Lang::Hebrew, "ביטול" },
|
|
||||||
{ Lang::Hungarian, "Mégse" },
|
|
||||||
{ Lang::Italian, "Annulla" },
|
|
||||||
{ Lang::Japanese, "キャンセル" },
|
|
||||||
{ Lang::Korean, "취소" },
|
|
||||||
{ Lang::Norwegian, "Avbryt" },
|
|
||||||
{ Lang::Dutch, "Annuleren" },
|
|
||||||
{ Lang::Polish, "Anuluj" },
|
|
||||||
{ Lang::BrazilianPortuguese, "Cancelar" },
|
|
||||||
{ Lang::Portuguese, "Cancelar" },
|
|
||||||
{ Lang::Russian, "Отмена" },
|
|
||||||
{ Lang::Swedish, "Avbryt" },
|
|
||||||
{ Lang::Turkish, "İptal" },
|
|
||||||
{ Lang::SimplifiedChinese, "取消" },
|
|
||||||
{ Lang::TraditionalChinese, "取消" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
Msg::KEYMAPPER_FlipperL,
|
Msg::KEYMAPPER_FlipperL,
|
||||||
{
|
{
|
||||||
|
@ -175,15 +175,13 @@ enum class Msg : int
|
|||||||
TextBoxColor,
|
TextBoxColor,
|
||||||
|
|
||||||
HIGHSCORES_Caption,
|
HIGHSCORES_Caption,
|
||||||
HIGHSCORES_Ok,
|
GenericOk,
|
||||||
HIGHSCORES_Cancel,
|
GenericCancel,
|
||||||
HIGHSCORES_Clear,
|
HIGHSCORES_Clear,
|
||||||
HIGHSCORES_Name,
|
HIGHSCORES_Name,
|
||||||
HIGHSCORES_Score,
|
HIGHSCORES_Score,
|
||||||
HIGHSCORES_Rank,
|
HIGHSCORES_Rank,
|
||||||
KEYMAPPER_Caption,
|
KEYMAPPER_Caption,
|
||||||
KEYMAPPER_Ok,
|
|
||||||
KEYMAPPER_Cancel,
|
|
||||||
KEYMAPPER_FlipperL,
|
KEYMAPPER_FlipperL,
|
||||||
KEYMAPPER_FlipperR,
|
KEYMAPPER_FlipperR,
|
||||||
KEYMAPPER_Plunger,
|
KEYMAPPER_Plunger,
|
||||||
|
@ -20,7 +20,7 @@ ImGuiIO* winmain::ImIO = nullptr;
|
|||||||
int winmain::return_value = 0;
|
int winmain::return_value = 0;
|
||||||
bool winmain::bQuit = false;
|
bool winmain::bQuit = false;
|
||||||
bool winmain::activated = false;
|
bool winmain::activated = false;
|
||||||
int winmain::DispFrameRate = 0;
|
bool winmain::DispFrameRate = false;
|
||||||
bool winmain::DispGRhistory = false;
|
bool winmain::DispGRhistory = false;
|
||||||
bool winmain::single_step = false;
|
bool winmain::single_step = false;
|
||||||
bool winmain::has_focus = true;
|
bool winmain::has_focus = true;
|
||||||
@ -37,6 +37,7 @@ float winmain::gfrWindow = 5.0f;
|
|||||||
bool winmain::ShowAboutDialog = false;
|
bool winmain::ShowAboutDialog = false;
|
||||||
bool winmain::ShowImGuiDemo = false;
|
bool winmain::ShowImGuiDemo = false;
|
||||||
bool winmain::ShowSpriteViewer = false;
|
bool winmain::ShowSpriteViewer = false;
|
||||||
|
bool winmain::ShowExitPopup = false;
|
||||||
bool winmain::LaunchBallEnabled = true;
|
bool winmain::LaunchBallEnabled = true;
|
||||||
bool winmain::HighScoresEnabled = true;
|
bool winmain::HighScoresEnabled = true;
|
||||||
bool winmain::DemoActive = false;
|
bool winmain::DemoActive = false;
|
||||||
@ -488,11 +489,7 @@ void winmain::RenderUi()
|
|||||||
end_pause();
|
end_pause();
|
||||||
pb::toggle_demo();
|
pb::toggle_demo();
|
||||||
}
|
}
|
||||||
if (ImGui::MenuItem(pb::get_rc_string(Msg::Menu1_Exit)))
|
ImGuiMenuItemWShortcut(GameBindings::Exit);
|
||||||
{
|
|
||||||
SDL_Event event{SDL_QUIT};
|
|
||||||
SDL_PushEvent(&event);
|
|
||||||
}
|
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -771,6 +768,38 @@ void winmain::RenderUi()
|
|||||||
if (DispGRhistory)
|
if (DispGRhistory)
|
||||||
RenderFrameTimeDialog();
|
RenderFrameTimeDialog();
|
||||||
|
|
||||||
|
const auto exitText = translations::GetTranslation(Msg::Menu1_Exit);
|
||||||
|
if (ShowExitPopup)
|
||||||
|
{
|
||||||
|
ShowExitPopup = false;
|
||||||
|
pause(false);
|
||||||
|
ImGui::OpenPopup(exitText);
|
||||||
|
}
|
||||||
|
if (ImGui::BeginPopupModal(exitText, nullptr, ImGuiWindowFlags_AlwaysAutoResize))
|
||||||
|
{
|
||||||
|
ImGui::Text("Exit the game?");
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
|
if (ImGui::Button(pb::get_rc_string(Msg::GenericOk), ImVec2(120, 0)))
|
||||||
|
{
|
||||||
|
SDL_Event event{SDL_QUIT};
|
||||||
|
SDL_PushEvent(&event);
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
if (ImGui::IsWindowAppearing())
|
||||||
|
{
|
||||||
|
ImGui::SetKeyboardFocusHere(0);
|
||||||
|
}
|
||||||
|
if (ImGui::Button(pb::get_rc_string(Msg::GenericCancel), ImVec2(120, 0)))
|
||||||
|
{
|
||||||
|
end_pause();
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
|
ImGui::SetItemDefaultFocus();
|
||||||
|
ImGui::EndPopup();
|
||||||
|
}
|
||||||
|
|
||||||
// Print game texts on the sidebar
|
// Print game texts on the sidebar
|
||||||
gdrv::grtext_draw_ttext_in_box();
|
gdrv::grtext_draw_ttext_in_box();
|
||||||
}
|
}
|
||||||
@ -821,19 +850,10 @@ int winmain::event_handler(const SDL_Event* event)
|
|||||||
pb::InputUp({InputTypes::Keyboard, event->key.keysym.sym});
|
pb::InputUp({InputTypes::Keyboard, event->key.keysym.sym});
|
||||||
break;
|
break;
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
if (!event->key.repeat)
|
if (event->key.repeat)
|
||||||
pb::InputDown({InputTypes::Keyboard, event->key.keysym.sym});
|
|
||||||
switch (event->key.keysym.sym)
|
|
||||||
{
|
|
||||||
case SDLK_ESCAPE:
|
|
||||||
if (Options.FullScreen)
|
|
||||||
options::toggle(Menu1::Full_Screen);
|
|
||||||
SDL_MinimizeWindow(MainWindow);
|
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
pb::InputDown({InputTypes::Keyboard, event->key.keysym.sym});
|
||||||
if (!pb::cheat_mode)
|
if (!pb::cheat_mode)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -863,7 +883,7 @@ int winmain::event_handler(const SDL_Event* event)
|
|||||||
break;
|
break;
|
||||||
case SDLK_y:
|
case SDLK_y:
|
||||||
SDL_SetWindowTitle(MainWindow, "Pinball");
|
SDL_SetWindowTitle(MainWindow, "Pinball");
|
||||||
DispFrameRate = DispFrameRate == 0;
|
DispFrameRate ^= true;
|
||||||
break;
|
break;
|
||||||
case SDLK_F1:
|
case SDLK_F1:
|
||||||
pb::frame(10);
|
pb::frame(10);
|
||||||
@ -968,17 +988,6 @@ int winmain::event_handler(const SDL_Event* event)
|
|||||||
break;
|
break;
|
||||||
case SDL_CONTROLLERBUTTONDOWN:
|
case SDL_CONTROLLERBUTTONDOWN:
|
||||||
pb::InputDown({InputTypes::GameController, event->cbutton.button});
|
pb::InputDown({InputTypes::GameController, event->cbutton.button});
|
||||||
switch (event->cbutton.button)
|
|
||||||
{
|
|
||||||
case SDL_CONTROLLER_BUTTON_BACK:
|
|
||||||
if (single_step)
|
|
||||||
{
|
|
||||||
SDL_Event event{SDL_QUIT};
|
|
||||||
SDL_PushEvent(&event);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default: ;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case SDL_CONTROLLERBUTTONUP:
|
case SDL_CONTROLLERBUTTONUP:
|
||||||
pb::InputUp({InputTypes::GameController, event->cbutton.button});
|
pb::InputUp({InputTypes::GameController, event->cbutton.button});
|
||||||
@ -1124,6 +1133,11 @@ void winmain::HandleGameBinding(GameBindings binding)
|
|||||||
case GameBindings::ToggleMenuDisplay:
|
case GameBindings::ToggleMenuDisplay:
|
||||||
options::toggle(Menu1::Show_Menu);
|
options::toggle(Menu1::Show_Menu);
|
||||||
break;
|
break;
|
||||||
|
case GameBindings::Exit:
|
||||||
|
{
|
||||||
|
ShowExitPopup = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,6 @@ struct WelfordState
|
|||||||
|
|
||||||
WelfordState() : mean(0.005), M2(0), count(1)
|
WelfordState() : mean(0.005), M2(0), count(1)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Advance(double newValue)
|
void Advance(double newValue)
|
||||||
@ -89,15 +88,16 @@ public:
|
|||||||
static void UpdateFrameRate();
|
static void UpdateFrameRate();
|
||||||
static void HandleGameBinding(GameBindings binding);
|
static void HandleGameBinding(GameBindings binding);
|
||||||
private:
|
private:
|
||||||
static int return_value, DispFrameRate;
|
static int return_value;
|
||||||
static int mouse_down, last_mouse_x, last_mouse_y;
|
static int mouse_down, last_mouse_x, last_mouse_y;
|
||||||
static bool no_time_loss, activated, bQuit, has_focus, DispGRhistory;
|
static bool no_time_loss, activated, bQuit, has_focus, DispGRhistory, DispFrameRate;
|
||||||
static std::vector<float> gfrDisplay;
|
static std::vector<float> gfrDisplay;
|
||||||
static std::string FpsDetails, PrevSdlError;
|
static std::string FpsDetails, PrevSdlError;
|
||||||
static bool restart;
|
static bool restart;
|
||||||
static bool ShowAboutDialog;
|
static bool ShowAboutDialog;
|
||||||
static bool ShowImGuiDemo;
|
static bool ShowImGuiDemo;
|
||||||
static bool ShowSpriteViewer;
|
static bool ShowSpriteViewer;
|
||||||
|
static bool ShowExitPopup;
|
||||||
static double UpdateToFrameRatio;
|
static double UpdateToFrameRatio;
|
||||||
static DurationMs TargetFrameTime;
|
static DurationMs TargetFrameTime;
|
||||||
static struct optionsStruct& Options;
|
static struct optionsStruct& Options;
|
||||||
|
Loading…
Reference in New Issue
Block a user