diff options
Diffstat (limited to '')
-rw-r--r-- | src/input_common/tas/tas_input.cpp | 19 | ||||
-rw-r--r-- | src/input_common/tas/tas_input.h | 6 | ||||
-rw-r--r-- | src/yuzu/main.cpp | 11 |
3 files changed, 16 insertions, 20 deletions
diff --git a/src/input_common/tas/tas_input.cpp b/src/input_common/tas/tas_input.cpp index baeb18c22..eb3327520 100644 --- a/src/input_common/tas/tas_input.cpp +++ b/src/input_common/tas/tas_input.cpp @@ -102,7 +102,7 @@ void Tas::LoadTasFile(size_t player_index) { LOG_INFO(Input, "TAS file loaded! {} frames", frame_no); } -void Tas::WriteTasFile() { +void Tas::WriteTasFile(std::string file_name) { std::string output_text; for (size_t frame = 0; frame < record_commands.size(); frame++) { if (!output_text.empty()) { @@ -113,7 +113,7 @@ void Tas::WriteTasFile() { WriteCommandAxis(line.l_axis) + " " + WriteCommandAxis(line.r_axis); } const size_t bytes_written = Common::FS::WriteStringToFile( - Common::FS::GetYuzuPathString(Common::FS::YuzuPath::TASDir) + "record.txt", + Common::FS::GetYuzuPathString(Common::FS::YuzuPath::TASDir) + file_name, Common::FS::FileType::TextFile, output_text); if (bytes_written == output_text.size()) { LOG_INFO(Input, "TAS file written to file!"); @@ -189,18 +189,8 @@ void Tas::UpdateThread() { if (is_recording) { record_commands.push_back(last_input); } - if (!is_recording && !record_commands.empty()) { - WriteTasFile(); - needs_reset = true; - refresh_tas_fle = true; - record_commands.clear(); - } if (needs_reset) { current_command = 0; - if (refresh_tas_fle) { - LoadTasFiles(); - refresh_tas_fle = false; - } needs_reset = false; LoadTasFiles(); LOG_DEBUG(Input, "tas_reset done"); @@ -306,10 +296,8 @@ void Tas::Reset() { needs_reset = true; } -void Tas::Record() { +bool Tas::Record() { is_recording = !is_recording; -<<<<<<< HEAD -======= return is_recording; } @@ -326,7 +314,6 @@ void Tas::SaveRecording(bool overwrite_file) { } needs_reset = true; record_commands.clear(); ->>>>>>> 773d268db (config: disable pause on load) } InputCommon::ButtonMapping Tas::GetButtonMappingForDevice( diff --git a/src/input_common/tas/tas_input.h b/src/input_common/tas/tas_input.h index e011e559e..e0462e858 100644 --- a/src/input_common/tas/tas_input.h +++ b/src/input_common/tas/tas_input.h @@ -68,7 +68,8 @@ public: void StartStop(); void Reset(); - void Record(); + bool Record(); + void SaveRecording(bool overwrite_file); /** * Returns the current status values of TAS playback/recording @@ -90,7 +91,7 @@ private: }; void LoadTasFiles(); void LoadTasFile(size_t player_index); - void WriteTasFile(); + void WriteTasFile(std::string file_name); TasAnalog ReadCommandAxis(const std::string& line) const; u32 ReadCommandButtons(const std::string& line) const; std::string WriteCommandButtons(u32 data) const; @@ -106,7 +107,6 @@ private: size_t script_length{0}; std::array<TasData, PLAYER_NUMBER> tas_data; - bool refresh_tas_fle{false}; bool is_recording{false}; bool is_running{false}; bool needs_reset{false}; diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 6c2835a2f..560de89af 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -1027,7 +1027,16 @@ void GMainWindow::InitializeHotkeys() { connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("TAS Reset"), this), &QShortcut::activated, this, [&] { input_subsystem->GetTas()->Reset(); }); connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("TAS Record"), this), - &QShortcut::activated, this, [&] { input_subsystem->GetTas()->Record(); }); + &QShortcut::activated, this, [&] { + bool is_recording = input_subsystem->GetTas()->Record(); + if (!is_recording) { + QMessageBox::StandardButton reply; + reply = QMessageBox::question(this, tr("TAS Recording"), + tr("Overwrite file of player 1?"), + QMessageBox::Yes | QMessageBox::No); + input_subsystem->GetTas()->SaveRecording(reply == QMessageBox::Yes); + } + }); } void GMainWindow::SetDefaultUIGeometry() { |