summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar german772021-06-26 10:38:39 -0500
committerGravatar MonsterDruide12021-09-18 23:22:42 +0200
commit9bb6580d89efb76534d9395bc052459d5f58e7c4 (patch)
treeaab812da6162e4f9ac305c80e245409d2781d8a2 /src
parentinput_common/tas: Fallback to simple update (diff)
downloadyuzu-9bb6580d89efb76534d9395bc052459d5f58e7c4.tar.gz
yuzu-9bb6580d89efb76534d9395bc052459d5f58e7c4.tar.xz
yuzu-9bb6580d89efb76534d9395bc052459d5f58e7c4.zip
input_common/tas: overwrite file dialog
Diffstat (limited to 'src')
-rw-r--r--src/input_common/tas/tas_input.cpp19
-rw-r--r--src/input_common/tas/tas_input.h6
-rw-r--r--src/yuzu/main.cpp11
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) {
102 LOG_INFO(Input, "TAS file loaded! {} frames", frame_no); 102 LOG_INFO(Input, "TAS file loaded! {} frames", frame_no);
103} 103}
104 104
105void Tas::WriteTasFile() { 105void Tas::WriteTasFile(std::string file_name) {
106 std::string output_text; 106 std::string output_text;
107 for (size_t frame = 0; frame < record_commands.size(); frame++) { 107 for (size_t frame = 0; frame < record_commands.size(); frame++) {
108 if (!output_text.empty()) { 108 if (!output_text.empty()) {
@@ -113,7 +113,7 @@ void Tas::WriteTasFile() {
113 WriteCommandAxis(line.l_axis) + " " + WriteCommandAxis(line.r_axis); 113 WriteCommandAxis(line.l_axis) + " " + WriteCommandAxis(line.r_axis);
114 } 114 }
115 const size_t bytes_written = Common::FS::WriteStringToFile( 115 const size_t bytes_written = Common::FS::WriteStringToFile(
116 Common::FS::GetYuzuPathString(Common::FS::YuzuPath::TASDir) + "record.txt", 116 Common::FS::GetYuzuPathString(Common::FS::YuzuPath::TASDir) + file_name,
117 Common::FS::FileType::TextFile, output_text); 117 Common::FS::FileType::TextFile, output_text);
118 if (bytes_written == output_text.size()) { 118 if (bytes_written == output_text.size()) {
119 LOG_INFO(Input, "TAS file written to file!"); 119 LOG_INFO(Input, "TAS file written to file!");
@@ -189,18 +189,8 @@ void Tas::UpdateThread() {
189 if (is_recording) { 189 if (is_recording) {
190 record_commands.push_back(last_input); 190 record_commands.push_back(last_input);
191 } 191 }
192 if (!is_recording && !record_commands.empty()) {
193 WriteTasFile();
194 needs_reset = true;
195 refresh_tas_fle = true;
196 record_commands.clear();
197 }
198 if (needs_reset) { 192 if (needs_reset) {
199 current_command = 0; 193 current_command = 0;
200 if (refresh_tas_fle) {
201 LoadTasFiles();
202 refresh_tas_fle = false;
203 }
204 needs_reset = false; 194 needs_reset = false;
205 LoadTasFiles(); 195 LoadTasFiles();
206 LOG_DEBUG(Input, "tas_reset done"); 196 LOG_DEBUG(Input, "tas_reset done");
@@ -306,10 +296,8 @@ void Tas::Reset() {
306 needs_reset = true; 296 needs_reset = true;
307} 297}
308 298
309void Tas::Record() { 299bool Tas::Record() {
310 is_recording = !is_recording; 300 is_recording = !is_recording;
311<<<<<<< HEAD
312=======
313 return is_recording; 301 return is_recording;
314} 302}
315 303
@@ -326,7 +314,6 @@ void Tas::SaveRecording(bool overwrite_file) {
326 } 314 }
327 needs_reset = true; 315 needs_reset = true;
328 record_commands.clear(); 316 record_commands.clear();
329>>>>>>> 773d268db (config: disable pause on load)
330} 317}
331 318
332InputCommon::ButtonMapping Tas::GetButtonMappingForDevice( 319InputCommon::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:
68 68
69 void StartStop(); 69 void StartStop();
70 void Reset(); 70 void Reset();
71 void Record(); 71 bool Record();
72 void SaveRecording(bool overwrite_file);
72 73
73 /** 74 /**
74 * Returns the current status values of TAS playback/recording 75 * Returns the current status values of TAS playback/recording
@@ -90,7 +91,7 @@ private:
90 }; 91 };
91 void LoadTasFiles(); 92 void LoadTasFiles();
92 void LoadTasFile(size_t player_index); 93 void LoadTasFile(size_t player_index);
93 void WriteTasFile(); 94 void WriteTasFile(std::string file_name);
94 TasAnalog ReadCommandAxis(const std::string& line) const; 95 TasAnalog ReadCommandAxis(const std::string& line) const;
95 u32 ReadCommandButtons(const std::string& line) const; 96 u32 ReadCommandButtons(const std::string& line) const;
96 std::string WriteCommandButtons(u32 data) const; 97 std::string WriteCommandButtons(u32 data) const;
@@ -106,7 +107,6 @@ private:
106 107
107 size_t script_length{0}; 108 size_t script_length{0};
108 std::array<TasData, PLAYER_NUMBER> tas_data; 109 std::array<TasData, PLAYER_NUMBER> tas_data;
109 bool refresh_tas_fle{false};
110 bool is_recording{false}; 110 bool is_recording{false};
111 bool is_running{false}; 111 bool is_running{false};
112 bool needs_reset{false}; 112 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() {
1027 connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("TAS Reset"), this), 1027 connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("TAS Reset"), this),
1028 &QShortcut::activated, this, [&] { input_subsystem->GetTas()->Reset(); }); 1028 &QShortcut::activated, this, [&] { input_subsystem->GetTas()->Reset(); });
1029 connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("TAS Record"), this), 1029 connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("TAS Record"), this),
1030 &QShortcut::activated, this, [&] { input_subsystem->GetTas()->Record(); }); 1030 &QShortcut::activated, this, [&] {
1031 bool is_recording = input_subsystem->GetTas()->Record();
1032 if (!is_recording) {
1033 QMessageBox::StandardButton reply;
1034 reply = QMessageBox::question(this, tr("TAS Recording"),
1035 tr("Overwrite file of player 1?"),
1036 QMessageBox::Yes | QMessageBox::No);
1037 input_subsystem->GetTas()->SaveRecording(reply == QMessageBox::Yes);
1038 }
1039 });
1031} 1040}
1032 1041
1033void GMainWindow::SetDefaultUIGeometry() { 1042void GMainWindow::SetDefaultUIGeometry() {