mirror of
https://github.com/yuzu-mirror/yuzu
synced 2024-11-24 11:03:03 +00:00
Merge pull request #9565 from MonsterDruide1/tas-multiplayer-lengths
TAS: Show all script lengths for multiplayer
This commit is contained in:
commit
9f974ea818
4 changed files with 38 additions and 7 deletions
|
@ -156,10 +156,12 @@ void Tas::RecordInput(u64 buttons, TasAnalog left_axis, TasAnalog right_axis) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::tuple<TasState, size_t, size_t> Tas::GetStatus() const {
|
std::tuple<TasState, size_t, std::array<size_t, PLAYER_NUMBER>> Tas::GetStatus() const {
|
||||||
TasState state;
|
TasState state;
|
||||||
|
std::array<size_t, PLAYER_NUMBER> lengths{0};
|
||||||
if (is_recording) {
|
if (is_recording) {
|
||||||
return {TasState::Recording, 0, record_commands.size()};
|
lengths[0] = record_commands.size();
|
||||||
|
return {TasState::Recording, record_commands.size(), lengths};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_running) {
|
if (is_running) {
|
||||||
|
@ -168,7 +170,11 @@ std::tuple<TasState, size_t, size_t> Tas::GetStatus() const {
|
||||||
state = TasState::Stopped;
|
state = TasState::Stopped;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {state, current_command, script_length};
|
for (size_t i = 0; i < PLAYER_NUMBER; i++) {
|
||||||
|
lengths[i] = commands[i].size();
|
||||||
|
}
|
||||||
|
|
||||||
|
return {state, current_command, lengths};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tas::UpdateThread() {
|
void Tas::UpdateThread() {
|
||||||
|
|
|
@ -124,7 +124,7 @@ public:
|
||||||
* Current playback progress ;
|
* Current playback progress ;
|
||||||
* Total length of script file currently loaded or being recorded
|
* Total length of script file currently loaded or being recorded
|
||||||
*/
|
*/
|
||||||
std::tuple<TasState, size_t, size_t> GetStatus() const;
|
std::tuple<TasState, size_t, std::array<size_t, PLAYER_NUMBER>> GetStatus() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum class TasAxis : u8;
|
enum class TasAxis : u8;
|
||||||
|
|
|
@ -3730,15 +3730,36 @@ void GMainWindow::UpdateWindowTitle(std::string_view title_name, std::string_vie
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string GMainWindow::CreateTASFramesString(
|
||||||
|
std::array<size_t, InputCommon::TasInput::PLAYER_NUMBER> frames) const {
|
||||||
|
std::string string = "";
|
||||||
|
size_t maxPlayerIndex = 0;
|
||||||
|
for (size_t i = 0; i < frames.size(); i++) {
|
||||||
|
if (frames[i] != 0) {
|
||||||
|
if (maxPlayerIndex != 0)
|
||||||
|
string += ", ";
|
||||||
|
while (maxPlayerIndex++ != i)
|
||||||
|
string += "0, ";
|
||||||
|
string += std::to_string(frames[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
QString GMainWindow::GetTasStateDescription() const {
|
QString GMainWindow::GetTasStateDescription() const {
|
||||||
auto [tas_status, current_tas_frame, total_tas_frames] = input_subsystem->GetTas()->GetStatus();
|
auto [tas_status, current_tas_frame, total_tas_frames] = input_subsystem->GetTas()->GetStatus();
|
||||||
|
std::string tas_frames_string = CreateTASFramesString(total_tas_frames);
|
||||||
switch (tas_status) {
|
switch (tas_status) {
|
||||||
case InputCommon::TasInput::TasState::Running:
|
case InputCommon::TasInput::TasState::Running:
|
||||||
return tr("TAS state: Running %1/%2").arg(current_tas_frame).arg(total_tas_frames);
|
return tr("TAS state: Running %1/%2")
|
||||||
|
.arg(current_tas_frame)
|
||||||
|
.arg(QString::fromStdString(tas_frames_string));
|
||||||
case InputCommon::TasInput::TasState::Recording:
|
case InputCommon::TasInput::TasState::Recording:
|
||||||
return tr("TAS state: Recording %1").arg(total_tas_frames);
|
return tr("TAS state: Recording %1").arg(total_tas_frames[0]);
|
||||||
case InputCommon::TasInput::TasState::Stopped:
|
case InputCommon::TasInput::TasState::Stopped:
|
||||||
return tr("TAS state: Idle %1/%2").arg(current_tas_frame).arg(total_tas_frames);
|
return tr("TAS state: Idle %1/%2")
|
||||||
|
.arg(current_tas_frame)
|
||||||
|
.arg(QString::fromStdString(tas_frames_string));
|
||||||
default:
|
default:
|
||||||
return tr("TAS State: Invalid");
|
return tr("TAS State: Invalid");
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
#include "common/announce_multiplayer_room.h"
|
#include "common/announce_multiplayer_room.h"
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
#include "input_common/drivers/tas_input.h"
|
||||||
#include "yuzu/compatibility_list.h"
|
#include "yuzu/compatibility_list.h"
|
||||||
#include "yuzu/hotkeys.h"
|
#include "yuzu/hotkeys.h"
|
||||||
|
|
||||||
|
@ -266,6 +267,9 @@ private:
|
||||||
void changeEvent(QEvent* event) override;
|
void changeEvent(QEvent* event) override;
|
||||||
void closeEvent(QCloseEvent* event) override;
|
void closeEvent(QCloseEvent* event) override;
|
||||||
|
|
||||||
|
std::string CreateTASFramesString(
|
||||||
|
std::array<size_t, InputCommon::TasInput::PLAYER_NUMBER> frames) const;
|
||||||
|
|
||||||
#ifdef __unix__
|
#ifdef __unix__
|
||||||
void SetupSigInterrupts();
|
void SetupSigInterrupts();
|
||||||
static void HandleSigInterrupt(int);
|
static void HandleSigInterrupt(int);
|
||||||
|
|
Loading…
Reference in a new issue