MCPcopy Create free account
hub / github.com/TASEmulators/fceux / ShowCheatFileBox

Function ShowCheatFileBox

src/drivers/win/cheat.cpp:1469–1516  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1467}
1468
1469bool ShowCheatFileBox(HWND hwnd, char* buf, bool save)
1470{
1471 if (!buf)
1472 return false;
1473
1474 char filename[2048] = { 0 };
1475
1476 OPENFILENAME ofn;
1477 memset(&ofn, 0, sizeof(OPENFILENAME));
1478 ofn.lStructSize = sizeof(OPENFILENAME);
1479 ofn.hInstance = fceu_hInstance;
1480 ofn.hwndOwner = hwnd;
1481 ofn.lpstrTitle = save ? "Save cheats file" : "Open cheats file";
1482 ofn.lpstrFilter = "Cheat files (*.cht)\0*.cht\0All Files (*.*)\0*.*\0\0";
1483
1484 // I gave up setting the default filename for import cheat dialog, since the filename display contains a bug.
1485 if (save)
1486 {
1487 if (GameInfo)
1488 {
1489 char* _filename;
1490 if ((_filename = strrchr(GameInfo->filename, '\\')) || (_filename = strrchr(GameInfo->filename, '/')))
1491 strcpy(filename, _filename + 1);
1492 else
1493 strcpy(filename, GameInfo->filename);
1494
1495 _filename = strrchr(filename, '.');
1496 if (_filename)
1497 strcpy(_filename, ".cht");
1498 else
1499 strcat(filename, ".cht");
1500 }
1501 }
1502
1503 ofn.lpstrFile = filename;
1504 ofn.nMaxFile = sizeof(filename);
1505 ofn.lpstrDefExt = "cht";
1506 ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_FILEMUSTEXIST;
1507 ofn.lpstrInitialDir = FCEU_GetPath(FCEUMKF_CHEAT).c_str();
1508
1509 if (save ? GetSaveFileName(&ofn) : GetOpenFileName(&ofn))
1510 {
1511 strcpy(buf, filename);
1512 return true;
1513 }
1514
1515 return false;
1516}
1517
1518void AskSaveCheat()
1519{

Callers 2

CheatConsoleCallBFunction · 0.85
SaveCheatAsFunction · 0.85

Calls 1

FCEU_GetPathFunction · 0.85

Tested by

no test coverage detected