mirror of https://github.com/mgba-emu/mgba.git
GUI: Support single-shot runs
This commit is contained in:
parent
2725d6ed2f
commit
396d097db4
|
@ -129,7 +129,7 @@ void GBAGUIDeinit(struct GBAGUIRunner* runner) {
|
||||||
GBAContextDeinit(&runner->context);
|
GBAContextDeinit(&runner->context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GBAGUIRunloop(struct GBAGUIRunner* runner) {
|
void GBAGUIRun(struct GBAGUIRunner* runner, const char* path) {
|
||||||
struct GBAGUIBackground drawState = {
|
struct GBAGUIBackground drawState = {
|
||||||
.d = {
|
.d = {
|
||||||
.draw = _drawState
|
.draw = _drawState
|
||||||
|
@ -185,12 +185,6 @@ void GBAGUIRunloop(struct GBAGUIRunner* runner) {
|
||||||
*GUIMenuItemListAppend(&pauseMenu.items) = (struct GUIMenuItem) { .title = "Reset game", .data = (void*) RUNNER_RESET };
|
*GUIMenuItemListAppend(&pauseMenu.items) = (struct GUIMenuItem) { .title = "Reset game", .data = (void*) RUNNER_RESET };
|
||||||
*GUIMenuItemListAppend(&pauseMenu.items) = (struct GUIMenuItem) { .title = "Exit game", .data = (void*) RUNNER_EXIT };
|
*GUIMenuItemListAppend(&pauseMenu.items) = (struct GUIMenuItem) { .title = "Exit game", .data = (void*) RUNNER_EXIT };
|
||||||
|
|
||||||
while (true) {
|
|
||||||
char path[256];
|
|
||||||
if (!GUISelectFile(&runner->params, path, sizeof(path), 0)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Message box API
|
// TODO: Message box API
|
||||||
runner->params.drawStart();
|
runner->params.drawStart();
|
||||||
if (runner->params.guiPrepare) {
|
if (runner->params.guiPrepare) {
|
||||||
|
@ -215,7 +209,7 @@ void GBAGUIRunloop(struct GBAGUIRunner* runner) {
|
||||||
}
|
}
|
||||||
runner->params.drawEnd();
|
runner->params.drawEnd();
|
||||||
}
|
}
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
bool running = GBAContextStart(&runner->context);
|
bool running = GBAContextStart(&runner->context);
|
||||||
if (runner->gameLoaded) {
|
if (runner->gameLoaded) {
|
||||||
|
@ -355,7 +349,6 @@ void GBAGUIRunloop(struct GBAGUIRunner* runner) {
|
||||||
}
|
}
|
||||||
GBAContextUnloadROM(&runner->context);
|
GBAContextUnloadROM(&runner->context);
|
||||||
drawState.screenshotId = 0;
|
drawState.screenshotId = 0;
|
||||||
}
|
|
||||||
if (drawState.screenshot) {
|
if (drawState.screenshot) {
|
||||||
mappedMemoryFree(drawState.screenshot, VIDEO_HORIZONTAL_PIXELS * VIDEO_VERTICAL_PIXELS * 4);
|
mappedMemoryFree(drawState.screenshot, VIDEO_HORIZONTAL_PIXELS * VIDEO_VERTICAL_PIXELS * 4);
|
||||||
}
|
}
|
||||||
|
@ -363,3 +356,13 @@ void GBAGUIRunloop(struct GBAGUIRunner* runner) {
|
||||||
GUIMenuItemListDeinit(&stateSaveMenu.items);
|
GUIMenuItemListDeinit(&stateSaveMenu.items);
|
||||||
GUIMenuItemListDeinit(&stateLoadMenu.items);
|
GUIMenuItemListDeinit(&stateLoadMenu.items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GBAGUIRunloop(struct GBAGUIRunner* runner) {
|
||||||
|
while (true) {
|
||||||
|
char path[PATH_MAX];
|
||||||
|
if (!GUISelectFile(&runner->params, path, sizeof(path), GBAIsROM)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
GBAGUIRun(runner, path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ struct GBAGUIRunner {
|
||||||
|
|
||||||
void GBAGUIInit(struct GBAGUIRunner*, const char* port);
|
void GBAGUIInit(struct GBAGUIRunner*, const char* port);
|
||||||
void GBAGUIDeinit(struct GBAGUIRunner*);
|
void GBAGUIDeinit(struct GBAGUIRunner*);
|
||||||
|
void GBAGUIRun(struct GBAGUIRunner*, const char* path);
|
||||||
void GBAGUIRunloop(struct GBAGUIRunner*);
|
void GBAGUIRunloop(struct GBAGUIRunner*);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue