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);
|
||||
}
|
||||
|
||||
void GBAGUIRunloop(struct GBAGUIRunner* runner) {
|
||||
void GBAGUIRun(struct GBAGUIRunner* runner, const char* path) {
|
||||
struct GBAGUIBackground drawState = {
|
||||
.d = {
|
||||
.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 = "Exit game", .data = (void*) RUNNER_EXIT };
|
||||
|
||||
while (true) {
|
||||
char path[256];
|
||||
if (!GUISelectFile(&runner->params, path, sizeof(path), 0)) {
|
||||
break;
|
||||
}
|
||||
|
||||
// TODO: Message box API
|
||||
runner->params.drawStart();
|
||||
if (runner->params.guiPrepare) {
|
||||
|
@ -215,7 +209,7 @@ void GBAGUIRunloop(struct GBAGUIRunner* runner) {
|
|||
}
|
||||
runner->params.drawEnd();
|
||||
}
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
bool running = GBAContextStart(&runner->context);
|
||||
if (runner->gameLoaded) {
|
||||
|
@ -355,7 +349,6 @@ void GBAGUIRunloop(struct GBAGUIRunner* runner) {
|
|||
}
|
||||
GBAContextUnloadROM(&runner->context);
|
||||
drawState.screenshotId = 0;
|
||||
}
|
||||
if (drawState.screenshot) {
|
||||
mappedMemoryFree(drawState.screenshot, VIDEO_HORIZONTAL_PIXELS * VIDEO_VERTICAL_PIXELS * 4);
|
||||
}
|
||||
|
@ -363,3 +356,13 @@ void GBAGUIRunloop(struct GBAGUIRunner* runner) {
|
|||
GUIMenuItemListDeinit(&stateSaveMenu.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 GBAGUIDeinit(struct GBAGUIRunner*);
|
||||
void GBAGUIRun(struct GBAGUIRunner*, const char* path);
|
||||
void GBAGUIRunloop(struct GBAGUIRunner*);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue