| 81 | } |
| 82 | |
| 83 | bool InputRecording::play(const std::string& filename) |
| 84 | { |
| 85 | if (!m_file.openExisting(filename)) |
| 86 | { |
| 87 | return false; |
| 88 | } |
| 89 | |
| 90 | // Either load the savestate, or restart the game |
| 91 | if (m_file.fromSaveState()) |
| 92 | { |
| 93 | std::string savestatePath = fmt::format("{}_SaveState.p2s", m_file.getFilename()); |
| 94 | if (!FileSystem::FileExists(savestatePath.c_str())) |
| 95 | { |
| 96 | InputRec::consoleLog(fmt::format("Could not locate savestate file at location - {}", savestatePath)); |
| 97 | InputRec::log(TRANSLATE_STR("InputRecording", "Failed to load state for input recording"), Host::OSD_ERROR_DURATION); |
| 98 | m_file.close(); |
| 99 | return false; |
| 100 | } |
| 101 | m_type = Type::FROM_SAVESTATE; |
| 102 | m_initial_load_complete = false; |
| 103 | m_is_active = true; |
| 104 | const auto loaded = VMManager::LoadState(savestatePath.c_str()); |
| 105 | if (!loaded) |
| 106 | { |
| 107 | InputRec::log(TRANSLATE_STR("InputRecording", "Failed to load state for input recording, unsupported version?"), Host::OSD_ERROR_DURATION); |
| 108 | m_file.close(); |
| 109 | m_is_active = false; |
| 110 | return false; |
| 111 | } |
| 112 | } |
| 113 | else |
| 114 | { |
| 115 | m_starting_frame = 0; |
| 116 | m_type = Type::POWER_ON; |
| 117 | m_initial_load_complete = false; |
| 118 | m_is_active = true; |
| 119 | // TODO - should this be an explicit [full] boot instead of a reset? |
| 120 | VMManager::Reset(); |
| 121 | } |
| 122 | m_controls.setReplayMode(); |
| 123 | initializeState(); |
| 124 | InputRec::log(TRANSLATE_STR("InputRecording", "Replaying input recording"), Host::OSD_INFO_DURATION); |
| 125 | m_file.logRecordingMetadata(); |
| 126 | if (VMManager::GetTitle(false) != m_file.getGameName()) |
| 127 | { |
| 128 | InputRec::consoleLog(fmt::format("Input recording was possibly constructed for a different game. Expected: {}, Actual: {}", m_file.getGameName(), VMManager::GetTitle(false))); |
| 129 | } |
| 130 | return true; |
| 131 | } |
| 132 | |
| 133 | void InputRecording::closeActiveFile() |
| 134 | { |
no test coverage detected