| 5656 | } |
| 5657 | |
| 5658 | static int doOpenFilePopup(lua_State *L, bool saveFile) { |
| 5659 | #ifdef __WIN_DRIVER__ |
| 5660 | char filename[PATH_MAX]; |
| 5661 | OPENFILENAME ofn; |
| 5662 | ZeroMemory(&ofn, sizeof(OPENFILENAME)); |
| 5663 | ofn.lStructSize = sizeof(OPENFILENAME); |
| 5664 | ofn.hwndOwner = hAppWnd; |
| 5665 | ofn.lpstrFilter = TEXT("All files (*.*)\0*.*\0\0"); |
| 5666 | ofn.nFilterIndex = 0; |
| 5667 | filename[0] = TEXT('\0'); |
| 5668 | ofn.lpstrFile = filename; |
| 5669 | ofn.nMaxFile = PATH_MAX; |
| 5670 | ofn.Flags = OFN_NOCHANGEDIR | (saveFile ? OFN_OVERWRITEPROMPT : OFN_FILEMUSTEXIST); |
| 5671 | BOOL bResult = saveFile ? GetSaveFileName(&ofn) : GetOpenFileName(&ofn); |
| 5672 | lua_newtable(L); |
| 5673 | if (bResult) |
| 5674 | { |
| 5675 | lua_pushstring(L, filename); |
| 5676 | lua_rawseti(L, -2, 1); |
| 5677 | } |
| 5678 | #else |
| 5679 | // TODO: more sophisticated interface |
| 5680 | char filename[PATH_MAX]; |
| 5681 | printf("Enter %s filename: ", saveFile ? "save" : "open"); |
| 5682 | if ( fgets(filename, PATH_MAX, stdin) == nullptr ) |
| 5683 | { |
| 5684 | FCEU_printf("Warning: fgets from stdin failed\n"); |
| 5685 | filename[0] = 0; |
| 5686 | } |
| 5687 | lua_newtable(L); |
| 5688 | lua_pushstring(L, filename); |
| 5689 | lua_rawseti(L, -2, 1); |
| 5690 | #endif |
| 5691 | return 1; |
| 5692 | } |
| 5693 | |
| 5694 | // string gui.popup(string message, string type = "ok", string icon = "message") |
| 5695 | // string input.popup(string message, string type = "yesno", string icon = "question") |
no test coverage detected