GUI: Support single-shot runs

This commit is contained in:
Extrems 2015-11-18 08:35:37 -05:00 committed by Jeffrey Pfau
parent 2725d6ed2f
commit 396d097db4
2 changed files with 175 additions and 171 deletions

View File

@ -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);
}
}

View File

@ -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