| 37 | InputRecording g_InputRecording; |
| 38 | |
| 39 | bool InputRecording::create(const std::string& fileName, const bool fromSaveState, const std::string& authorName) |
| 40 | { |
| 41 | if (!m_file.openNew(fileName, fromSaveState)) |
| 42 | { |
| 43 | return false; |
| 44 | } |
| 45 | |
| 46 | m_controls.setRecordMode(); |
| 47 | if (fromSaveState) |
| 48 | { |
| 49 | std::string savestatePath = fmt::format("{}_SaveState.p2s", fileName); |
| 50 | if (FileSystem::FileExists(savestatePath.c_str())) |
| 51 | { |
| 52 | FileSystem::CopyFilePath(savestatePath.c_str(), fmt::format("{}.bak", savestatePath).c_str(), true); |
| 53 | } |
| 54 | m_type = Type::FROM_SAVESTATE; |
| 55 | m_is_active = true; |
| 56 | m_initial_load_complete = true; |
| 57 | m_watching_for_rerecords = true; |
| 58 | setStartingFrame(g_FrameCount); |
| 59 | VMManager::SaveState(savestatePath.c_str(), true, false, [](const std::string& error) { |
| 60 | SaveState_ReportSaveErrorOSD(error, std::nullopt); |
| 61 | }); |
| 62 | } |
| 63 | else |
| 64 | { |
| 65 | m_starting_frame = 0; |
| 66 | m_type = Type::POWER_ON; |
| 67 | m_initial_load_complete = false; |
| 68 | m_is_active = true; |
| 69 | // TODO - should this be an explicit [full] boot instead of a reset? |
| 70 | VMManager::Reset(); |
| 71 | } |
| 72 | |
| 73 | m_file.setEmulatorVersion(); |
| 74 | m_file.setAuthor(authorName); |
| 75 | m_file.setGameName(VMManager::GetTitle(false)); |
| 76 | m_file.writeHeader(); |
| 77 | initializeState(); |
| 78 | InputRec::log(TRANSLATE_STR("InputRecording", "Started new input recording"), Host::OSD_INFO_DURATION); |
| 79 | InputRec::consoleLog(fmt::format("Filename {}", m_file.getFilename())); |
| 80 | return true; |
| 81 | } |
| 82 | |
| 83 | bool InputRecording::play(const std::string& filename) |
| 84 | { |
no test coverage detected