Detect hardware changes and show it in gui.

Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
Andrea Odetti 2021-10-29 12:09:23 +01:00
parent 232d0e62d3
commit 448de8f6c7
4 changed files with 28 additions and 0 deletions

View file

@ -235,10 +235,19 @@ namespace sa2
ImGui::Separator();
if (frame->HardwareChanged())
{
ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor(180, 0, 0));
}
else
{
ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor(0, 180, 0));
}
if (ImGui::Button("Restart"))
{
frame->Restart();
}
ImGui::PopStyleColor(1);
ImGui::SameLine();
if (ImGui::Button("ResetMachineState"))

View file

@ -89,6 +89,7 @@ namespace sa2
if (strlen(filename) > strlen(yaml) && !strcmp(filename + strlen(filename) - strlen(yaml), yaml))
{
common2::setSnapshotFilename(filename, true);
frame->ResetHardware();
}
else if (strlen(filename) > strlen(wav) && !strcmp(filename + strlen(filename) - strlen(wav), wav))
{

View file

@ -152,6 +152,7 @@ namespace sa2
CommonFrame::Initialize();
mySpeed.reset();
setGLSwapInterval(myTargetGLSwap);
ResetHardware();
}
void SDLFrame::FrameRefreshStatus(int drawflags)
@ -388,6 +389,7 @@ namespace sa2
{
Snapshot_LoadState();
mySpeed.reset();
ResetHardware();
break;
}
case SDLK_F11:
@ -698,6 +700,17 @@ namespace sa2
Execute(0);
}
void SDLFrame::ResetHardware()
{
myHardwareConfig = CConfigNeedingRestart(GetPropertySheet().GetTheFreezesF8Rom());
}
bool SDLFrame::HardwareChanged() const
{
const CConfigNeedingRestart currentConfig(GetPropertySheet().GetTheFreezesF8Rom());
return myHardwareConfig != currentConfig;
}
}
void SingleStep(bool /* bReinit */)

View file

@ -1,6 +1,7 @@
#pragma once
#include "Common.h"
#include "Configuration/Config.h"
#include "frontends/common2/commonframe.h"
#include "frontends/common2/speed.h"
#include <SDL.h>
@ -29,6 +30,8 @@ namespace sa2
void ExecuteOneFrame(const size_t msNextFrame);
void ChangeMode(const AppMode_e mode);
void SingleStep();
void ResetHardware();
bool HardwareChanged() const;
virtual void ResetSpeed();
const std::shared_ptr<SDL_Window> & GetWindow() const;
@ -73,6 +76,8 @@ namespace sa2
common2::Speed mySpeed;
std::shared_ptr<SDL_Window> myWindow;
CConfigNeedingRestart myHardwareConfig;
};
}