Skip to content
This repository was archived by the owner on Sep 29, 2025. It is now read-only.

Commit dadaa54

Browse files
authored
Merge pull request #1831 from b10z/alpha
Message on Save State (fix for issue #1783)
2 parents 425533e + 742e1ea commit dadaa54

File tree

3 files changed

+46
-4
lines changed

3 files changed

+46
-4
lines changed

libswirl/gui/gui.cpp

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,8 @@ struct ReicastUI_impl : GUI {
534534

535535
ImGui::Begin("Reicast", NULL, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize);
536536

537+
538+
537539
ImGui::Columns(2, "buttons", false);
538540
if (ImGui::Button("Load State", ImVec2(150 * scaling, 50 * scaling)))
539541
{
@@ -542,13 +544,42 @@ struct ReicastUI_impl : GUI {
542544
virtualDreamcast->Resume();
543545
}
544546
ImGui::NextColumn();
547+
548+
545549
if (ImGui::Button("Save State", ImVec2(150 * scaling, 50 * scaling)))
546550
{
547-
virtualDreamcast->SaveState();
548-
gui_state = Closed;
549-
virtualDreamcast->Resume();
551+
if (!settings.savepopup.isShown) {
552+
ImGui::OpenPopup("Warning!");
553+
settings.savepopup.isShown = true;
554+
SaveSettings();
555+
}
556+
else{
557+
virtualDreamcast->SaveState();
558+
gui_state = Closed;
559+
virtualDreamcast->Resume();
560+
}
561+
562+
}
563+
564+
if (ImGui::BeginPopupModal("Warning!"))
565+
{
566+
ImGui::PushTextWrapPos(ImGui::GetCursorPos().x + 250.f * scaling);
567+
ImGui::Text("Save states are not guaranteed to be compatible between releases, please use with caution and always save to VMU");
568+
float currentwidth = ImGui::GetContentRegionAvailWidth();
569+
ImGui::SetCursorPosX((currentwidth - 80.f * scaling) / 2.f + ImGui::GetStyle().WindowPadding.x);
570+
if (ImGui::Button("Okay", ImVec2(80.f * scaling, 0.f)))
571+
{
572+
ImGui::CloseCurrentPopup();
573+
virtualDreamcast->SaveState();
574+
gui_state = Closed;
575+
virtualDreamcast->Resume();
576+
577+
}
578+
ImGui::SetItemDefaultFocus();
579+
ImGui::EndPopup();
550580
}
551581

582+
552583
ImGui::NextColumn();
553584
if (ImGui::Button("Settings", ImVec2(150 * scaling, 50 * scaling)))
554585
{

libswirl/libswirl.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ void InitSettings()
279279
settings.dynarec.ScpuEnable = true;
280280
settings.dynarec.DspEnable = true;
281281

282+
settings.savepopup.isShown = false; // if false, popup on save state should appear
283+
282284
settings.dreamcast.cable = 3; // TV composite
283285
settings.dreamcast.region = 3; // default
284286
settings.dreamcast.broadcast = 4; // default
@@ -366,6 +368,8 @@ void LoadSettings(bool game_specific)
366368
settings.dynarec.ScpuEnable = cfgLoadInt(config_section, "Dynarec.ScpuEnabled", settings.dynarec.ScpuEnable);
367369
settings.dynarec.DspEnable = cfgLoadInt(config_section, "Dynarec.DspEnabled", settings.dynarec.DspEnable);
368370

371+
settings.savepopup.isShown = cfgLoadBool(config_section, "SavePopup.isShown", settings.savepopup.isShown);
372+
369373
//disable_nvmem can't be loaded, because nvmem init is before cfg load
370374
settings.dreamcast.cable = cfgLoadInt(config_section, "Dreamcast.Cable", settings.dreamcast.cable);
371375
settings.dreamcast.region = cfgLoadInt(config_section, "Dreamcast.Region", settings.dreamcast.region);
@@ -511,6 +515,9 @@ void SaveSettings()
511515
cfgSaveBool("config", "Dreamcast.FullMMU", settings.dreamcast.FullMMU);
512516
cfgSaveBool("config", "Dynarec.idleskip", settings.dynarec.idleskip);
513517
cfgSaveBool("config", "Dynarec.unstable-opt", settings.dynarec.unstable_opt);
518+
519+
cfgSaveBool("config", "SavePopup.isShown", settings.savepopup.isShown);
520+
514521
if (!safemode_game || !settings.dynarec.safemode)
515522
cfgSaveBool("config", "Dynarec.safe-mode", settings.dynarec.safemode);
516523
cfgSaveInt("config", "Dynarec.SmcCheckLevel", (int)settings.dynarec.SmcCheckLevel);
@@ -1185,4 +1192,4 @@ struct Dreamcast_impl : VirtualDreamcast {
11851192

11861193
VirtualDreamcast* VirtualDreamcast::Create() {
11871194
return new Dreamcast_impl();
1188-
}
1195+
}

libswirl/types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,10 @@ struct settings_t
462462
string ElfFile;
463463
} reios;
464464

465+
struct {
466+
bool isShown;
467+
} savepopup;
468+
465469
struct
466470
{
467471
bool UseMipmaps;

0 commit comments

Comments
 (0)