mirror of
https://github.com/k4zmu2a/SpaceCadetPinball.git
synced 2023-12-30 21:52:56 +00:00
parent
cfaab257ed
commit
3c6e1c9d47
@ -37,7 +37,8 @@ bool winmain::LaunchBallEnabled = true;
|
|||||||
bool winmain::HighScoresEnabled = true;
|
bool winmain::HighScoresEnabled = true;
|
||||||
bool winmain::DemoActive = false;
|
bool winmain::DemoActive = false;
|
||||||
int winmain::MainMenuHeight = 0;
|
int winmain::MainMenuHeight = 0;
|
||||||
std::string winmain::FpsDetails;
|
std::string winmain::FpsDetails, winmain::PrevSdlError;
|
||||||
|
unsigned winmain::PrevSdlErrorCount = 0;
|
||||||
double winmain::UpdateToFrameRatio;
|
double winmain::UpdateToFrameRatio;
|
||||||
winmain::DurationMs winmain::TargetFrameTime;
|
winmain::DurationMs winmain::TargetFrameTime;
|
||||||
optionsStruct& winmain::Options = options::Options;
|
optionsStruct& winmain::Options = options::Options;
|
||||||
@ -115,7 +116,7 @@ int winmain::WinMain(LPCSTR lpCmdLine)
|
|||||||
// First step: just load the options
|
// First step: just load the options
|
||||||
options::InitPrimary();
|
options::InitPrimary();
|
||||||
|
|
||||||
if(!Options.FontFileName.empty())
|
if (!Options.FontFileName.empty())
|
||||||
{
|
{
|
||||||
ImGuiSDL::Deinitialize();
|
ImGuiSDL::Deinitialize();
|
||||||
io.Fonts->Clear();
|
io.Fonts->Clear();
|
||||||
@ -253,7 +254,8 @@ int winmain::WinMain(LPCSTR lpCmdLine)
|
|||||||
if (xMod != 0 || yMod != 0)
|
if (xMod != 0 || yMod != 0)
|
||||||
{
|
{
|
||||||
// Mouse warp does not work over remote desktop or in some VMs
|
// Mouse warp does not work over remote desktop or in some VMs
|
||||||
x = abs(x - xMod); y = abs(y - yMod);
|
x = abs(x - xMod);
|
||||||
|
y = abs(y - yMod);
|
||||||
SDL_WarpMouseInWindow(window, x, y);
|
SDL_WarpMouseInWindow(window, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,11 +312,29 @@ int winmain::WinMain(LPCSTR lpCmdLine)
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto sdlError = SDL_GetError();
|
auto sdlError = SDL_GetError();
|
||||||
if (sdlError[0])
|
if (sdlError[0] || !PrevSdlError.empty())
|
||||||
{
|
{
|
||||||
|
if (sdlError[0])
|
||||||
SDL_ClearError();
|
SDL_ClearError();
|
||||||
|
|
||||||
|
// Rate limit duplicate SDL error messages.
|
||||||
|
if (sdlError != PrevSdlError)
|
||||||
|
{
|
||||||
|
PrevSdlError = sdlError;
|
||||||
|
if (PrevSdlErrorCount > 0)
|
||||||
|
{
|
||||||
|
printf("SDL Error: ^ Previous Error Repeated %u Times\n", PrevSdlErrorCount + 1);
|
||||||
|
PrevSdlErrorCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sdlError[0])
|
||||||
printf("SDL Error: %s\n", sdlError);
|
printf("SDL Error: %s\n", sdlError);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PrevSdlErrorCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto updateEnd = Clock::now();
|
auto updateEnd = Clock::now();
|
||||||
auto targetTimeDelta = TargetFrameTime - DurationMs(updateEnd - frameStart) - sleepRemainder;
|
auto targetTimeDelta = TargetFrameTime - DurationMs(updateEnd - frameStart) - sleepRemainder;
|
||||||
@ -334,13 +354,19 @@ int winmain::WinMain(LPCSTR lpCmdLine)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Limit duration to 2 * target time
|
// Limit duration to 2 * target time
|
||||||
sleepRemainder = Clamp(DurationMs(frameEnd - updateEnd) - targetTimeDelta, -TargetFrameTime, TargetFrameTime);
|
sleepRemainder = Clamp(DurationMs(frameEnd - updateEnd) - targetTimeDelta, -TargetFrameTime,
|
||||||
|
TargetFrameTime);
|
||||||
frameDuration = std::min<DurationMs>(DurationMs(frameEnd - frameStart), 2 * TargetFrameTime);
|
frameDuration = std::min<DurationMs>(DurationMs(frameEnd - frameStart), 2 * TargetFrameTime);
|
||||||
frameStart = frameEnd;
|
frameStart = frameEnd;
|
||||||
UpdateToFrameCounter++;
|
UpdateToFrameCounter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (PrevSdlErrorCount > 0)
|
||||||
|
{
|
||||||
|
printf("SDL Error: ^ Previous Error Repeated %u Times\n", PrevSdlErrorCount);
|
||||||
|
}
|
||||||
|
|
||||||
SDL_free(basePath);
|
SDL_free(basePath);
|
||||||
SDL_free(prefPath);
|
SDL_free(prefPath);
|
||||||
delete gfr_display;
|
delete gfr_display;
|
||||||
@ -481,7 +507,7 @@ void winmain::RenderUi()
|
|||||||
if (ImGui::BeginMenu("Language"))
|
if (ImGui::BeginMenu("Language"))
|
||||||
{
|
{
|
||||||
auto currentLanguage = translations::GetCurrentLanguage();
|
auto currentLanguage = translations::GetCurrentLanguage();
|
||||||
for (auto &item : translations::Languages)
|
for (auto& item : translations::Languages)
|
||||||
{
|
{
|
||||||
if (ImGui::MenuItem(item.DisplayName, nullptr, currentLanguage->Language == item.Language))
|
if (ImGui::MenuItem(item.DisplayName, nullptr, currentLanguage->Language == item.Language))
|
||||||
{
|
{
|
||||||
@ -504,7 +530,8 @@ void winmain::RenderUi()
|
|||||||
options::toggle(Menu1::SoundStereo);
|
options::toggle(Menu1::SoundStereo);
|
||||||
}
|
}
|
||||||
ImGui::TextUnformatted("Sound Volume");
|
ImGui::TextUnformatted("Sound Volume");
|
||||||
if (ImGui::SliderInt("##Sound Volume", &Options.SoundVolume, options::MinVolume, options::MaxVolume, "%d",
|
if (ImGui::SliderInt("##Sound Volume", &Options.SoundVolume, options::MinVolume, options::MaxVolume,
|
||||||
|
"%d",
|
||||||
ImGuiSliderFlags_AlwaysClamp))
|
ImGuiSliderFlags_AlwaysClamp))
|
||||||
{
|
{
|
||||||
Sound::SetVolume(Options.SoundVolume);
|
Sound::SetVolume(Options.SoundVolume);
|
||||||
@ -522,7 +549,8 @@ void winmain::RenderUi()
|
|||||||
options::toggle(Menu1::Music);
|
options::toggle(Menu1::Music);
|
||||||
}
|
}
|
||||||
ImGui::TextUnformatted("Music Volume");
|
ImGui::TextUnformatted("Music Volume");
|
||||||
if (ImGui::SliderInt("##Music Volume", &Options.MusicVolume, options::MinVolume, options::MaxVolume, "%d",
|
if (ImGui::SliderInt("##Music Volume", &Options.MusicVolume, options::MinVolume, options::MaxVolume,
|
||||||
|
"%d",
|
||||||
ImGuiSliderFlags_AlwaysClamp))
|
ImGuiSliderFlags_AlwaysClamp))
|
||||||
{
|
{
|
||||||
midi::SetVolume(Options.MusicVolume);
|
midi::SetVolume(Options.MusicVolume);
|
||||||
@ -597,10 +625,14 @@ void winmain::RenderUi()
|
|||||||
char buffer[20]{};
|
char buffer[20]{};
|
||||||
Msg resolutionStringId = Msg::Menu1_UseMaxResolution_640x480;
|
Msg resolutionStringId = Msg::Menu1_UseMaxResolution_640x480;
|
||||||
|
|
||||||
switch(fullscrn::GetMaxResolution()) {
|
switch (fullscrn::GetMaxResolution())
|
||||||
case 0: resolutionStringId = Msg::Menu1_UseMaxResolution_640x480; break;
|
{
|
||||||
case 1: resolutionStringId = Msg::Menu1_UseMaxResolution_800x600; break;
|
case 0: resolutionStringId = Msg::Menu1_UseMaxResolution_640x480;
|
||||||
case 2: resolutionStringId = Msg::Menu1_UseMaxResolution_1024x768; break;
|
break;
|
||||||
|
case 1: resolutionStringId = Msg::Menu1_UseMaxResolution_800x600;
|
||||||
|
break;
|
||||||
|
case 2: resolutionStringId = Msg::Menu1_UseMaxResolution_1024x768;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto maxResText = pb::get_rc_string(resolutionStringId);
|
auto maxResText = pb::get_rc_string(resolutionStringId);
|
||||||
|
@ -90,7 +90,7 @@ private:
|
|||||||
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;
|
||||||
static gdrv_bitmap8* gfr_display;
|
static gdrv_bitmap8* gfr_display;
|
||||||
static std::string FpsDetails;
|
static std::string FpsDetails, PrevSdlError;
|
||||||
static bool restart;
|
static bool restart;
|
||||||
static bool ShowAboutDialog;
|
static bool ShowAboutDialog;
|
||||||
static bool ShowImGuiDemo;
|
static bool ShowImGuiDemo;
|
||||||
@ -100,6 +100,7 @@ private:
|
|||||||
static struct optionsStruct& Options;
|
static struct optionsStruct& Options;
|
||||||
static DurationMs SpinThreshold;
|
static DurationMs SpinThreshold;
|
||||||
static WelfordState SleepState;
|
static WelfordState SleepState;
|
||||||
|
static unsigned PrevSdlErrorCount;
|
||||||
|
|
||||||
static void RenderUi();
|
static void RenderUi();
|
||||||
static void RenderFrameTimeDialog();
|
static void RenderFrameTimeDialog();
|
||||||
|
Loading…
Reference in New Issue
Block a user