move done variable into window class
This commit is contained in:
@@ -21,7 +21,6 @@ struct Core {
|
||||
bool pause = true;
|
||||
int cycles = 0;
|
||||
bool romLoaded = false;
|
||||
bool done = false;
|
||||
std::string rom;
|
||||
Interpreter* cpu = nullptr;
|
||||
};
|
||||
|
||||
@@ -11,7 +11,7 @@ void App::Run() {
|
||||
SDL_EventState(SDL_DROPFILE, SDL_ENABLE);
|
||||
n64::SI& si = core.cpu->mem.mmio.si;
|
||||
|
||||
while (!core.done) {
|
||||
while (!window.done) {
|
||||
if(core.romLoaded) {
|
||||
if(!core.pause) {
|
||||
core.Run(window.settings.GetVolumeL(), window.settings.GetVolumeR());
|
||||
@@ -26,10 +26,10 @@ void App::Run() {
|
||||
ImGui_ImplSDL2_ProcessEvent(&event);
|
||||
switch(event.type) {
|
||||
case SDL_QUIT:
|
||||
core.done = true;
|
||||
window.done = true;
|
||||
break;
|
||||
case SDL_WINDOWEVENT:
|
||||
core.done = window.gotClosed(event);
|
||||
window.onClose(event);
|
||||
break;
|
||||
case SDL_CONTROLLERDEVICEADDED: {
|
||||
const int index = event.cdevice.which;
|
||||
@@ -56,7 +56,8 @@ void App::Run() {
|
||||
NFD_FreePath(outpath);
|
||||
}
|
||||
} break;
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
case SDL_DROPFILE: {
|
||||
char *droppedDir = event.drop.file;
|
||||
if (droppedDir) {
|
||||
|
||||
@@ -16,8 +16,8 @@ Window::Window(n64::Core& core) : settings() {
|
||||
NFD::Init();
|
||||
}
|
||||
|
||||
[[nodiscard]] bool Window::gotClosed(SDL_Event event) {
|
||||
return event.window.event == SDL_WINDOWEVENT_CLOSE
|
||||
void Window::onClose(SDL_Event event) {
|
||||
done = event.window.event == SDL_WINDOWEVENT_CLOSE
|
||||
&& event.window.windowID == SDL_GetWindowID(window);
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ void Window::RenderMainMenuBar(n64::Core &core) {
|
||||
core.cpu->mem.DumpDMEM();
|
||||
}
|
||||
if (ImGui::MenuItem("Exit")) {
|
||||
core.done = true;
|
||||
done = true;
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
@@ -12,10 +12,11 @@ struct Window {
|
||||
~Window();
|
||||
ImDrawData* Present(n64::Core& core);
|
||||
|
||||
[[nodiscard]] bool gotClosed(SDL_Event event);
|
||||
void onClose(SDL_Event event);
|
||||
ImFont *uiFont{};
|
||||
Settings settings;
|
||||
void LoadROM(n64::Core& core, const std::string& path);
|
||||
bool done = false;
|
||||
private:
|
||||
bool showSettings = false;
|
||||
SDL_Window* window{};
|
||||
|
||||
Reference in New Issue
Block a user