diff --git a/CMakeLists.txt b/CMakeLists.txt index 9bb4336ce8..88cf594103 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,9 @@ project(dolphin-emu) # unique name here. set(DISTRIBUTOR "None" CACHE STRING "Name of the distributor.") +# Slippi Playback build option +add_compile_definitions(IS_PLAYBACK) + if(UNIX AND NOT APPLE AND NOT ANDROID) option(ENABLE_X11 "Enables X11 Support" ON) endif() diff --git a/Source/Core/Common/Version.cpp b/Source/Core/Common/Version.cpp index f2a4d9fbdd..eb8cb7e28a 100644 --- a/Source/Core/Common/Version.cpp +++ b/Source/Core/Common/Version.cpp @@ -20,7 +20,6 @@ namespace Common #define SLIPPI_REV_STR "2.1.1" -#define IS_PLAYBACK 1 const std::string scm_slippi_semver_str = SLIPPI_REV_STR; #ifdef IS_PLAYBACK diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.cpp index 9e4cb06cc5..3da8b3ad7f 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.cpp +++ b/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.cpp @@ -1168,7 +1168,7 @@ void CEXISlippi::prepareFrameData(u8* payload) g_playbackStatus->lastFrame = m_current_game->GetLatestIndex(); auto isNextFrameFound = g_playbackStatus->lastFrame > frameIndex; auto isFrameComplete = checkFrameFullyFetched(frameIndex); - auto isFrameReady = !g_playbackStatus->shouldPause && isFrameFound && (isProcessingComplete || isNextFrameFound || isFrameComplete); + auto isFrameReady = isFrameFound && (isProcessingComplete || isNextFrameFound || isFrameComplete); // If there is a startFrame configured, manage the fast-forward flag if (watchSettings.startFrame > Slippi::GAME_FIRST_FRAME) diff --git a/Source/Core/Core/Slippi/SlippiPlayback.cpp b/Source/Core/Core/Slippi/SlippiPlayback.cpp index 96cbb0535c..a61765f21d 100644 --- a/Source/Core/Core/Slippi/SlippiPlayback.cpp +++ b/Source/Core/Core/Slippi/SlippiPlayback.cpp @@ -232,7 +232,6 @@ void SlippiPlaybackStatus::SeekToFrame() } targetFrameNum = INT_MAX; - shouldPause = false; Core::SetState(prevState); seekMtx.unlock(); } else { diff --git a/Source/Core/Core/Slippi/SlippiPlayback.h b/Source/Core/Core/Slippi/SlippiPlayback.h index 10010b0a5a..6da63a6854 100644 --- a/Source/Core/Core/Slippi/SlippiPlayback.h +++ b/Source/Core/Core/Slippi/SlippiPlayback.h @@ -19,7 +19,6 @@ public: bool shouldJumpBack = false; bool shouldJumpForward = false; bool inSlippiPlayback = false; - volatile bool shouldPause = false; volatile bool shouldRunThreads = false; bool isHardFFW = false; bool isSoftFFW = false; diff --git a/Source/Core/DolphinQt/HotkeyScheduler.cpp b/Source/Core/DolphinQt/HotkeyScheduler.cpp index 24f3f5ef03..007c536972 100644 --- a/Source/Core/DolphinQt/HotkeyScheduler.cpp +++ b/Source/Core/DolphinQt/HotkeyScheduler.cpp @@ -234,7 +234,7 @@ void HotkeyScheduler::Run() if (device != nullptr) std::static_pointer_cast(device)->UpdateSyncButtonState( - IsHotkey(HK_TRIGGER_SYNC_BUTTON, true)); + IsHotkey(HK_TRIGGER_SYNC_BUTTON, true)); } if (SConfig::GetInstance().bEnableDebugging) @@ -267,7 +267,7 @@ void HotkeyScheduler::Run() if (IsHotkey(HK_TOGGLE_USB_KEYBOARD)) { Settings::Instance().SetUSBKeyboardConnected( - !Settings::Instance().IsUSBKeyboardConnected()); + !Settings::Instance().IsUSBKeyboardConnected()); } } @@ -313,9 +313,9 @@ void HotkeyScheduler::Run() auto ShowVolume = []() { OSD::AddMessage(std::string("Volume: ") + - (SConfig::GetInstance().m_IsMuted ? - "Muted" : - std::to_string(SConfig::GetInstance().m_Volume) + "%")); + (SConfig::GetInstance().m_IsMuted ? + "Muted" : + std::to_string(SConfig::GetInstance().m_Volume) + "%")); }; // Volume @@ -401,20 +401,20 @@ void HotkeyScheduler::Run() auto ShowXFBCopies = []() { OSD::AddMessage(StringFromFormat( - "Copy XFB: %s%s", Config::Get(Config::GFX_HACK_IMMEDIATE_XFB) ? " (Immediate)" : "", - Config::Get(Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM) ? "to Texture" : "to RAM")); + "Copy XFB: %s%s", Config::Get(Config::GFX_HACK_IMMEDIATE_XFB) ? " (Immediate)" : "", + Config::Get(Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM) ? "to Texture" : "to RAM")); }; if (IsHotkey(HK_TOGGLE_XFBCOPIES)) { Config::SetCurrent(Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM, - !Config::Get(Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM)); + !Config::Get(Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM)); ShowXFBCopies(); } if (IsHotkey(HK_TOGGLE_IMMEDIATE_XFB)) { Config::SetCurrent(Config::GFX_HACK_IMMEDIATE_XFB, - !Config::Get(Config::GFX_HACK_IMMEDIATE_XFB)); + !Config::Get(Config::GFX_HACK_IMMEDIATE_XFB)); ShowXFBCopies(); } if (IsHotkey(HK_TOGGLE_FOG)) @@ -434,10 +434,10 @@ void HotkeyScheduler::Run() auto ShowEmulationSpeed = []() { OSD::AddMessage( - SConfig::GetInstance().m_EmulationSpeed <= 0 ? - "Speed Limit: Unlimited" : - StringFromFormat("Speed Limit: %li%%", - std::lround(SConfig::GetInstance().m_EmulationSpeed * 100.f))); + SConfig::GetInstance().m_EmulationSpeed <= 0 ? + "Speed Limit: Unlimited" : + StringFromFormat("Speed Limit: %li%%", + std::lround(SConfig::GetInstance().m_EmulationSpeed * 100.f))); }; if (IsHotkey(HK_DECREASE_EMULATION_SPEED)) @@ -509,40 +509,45 @@ void HotkeyScheduler::Run() Config::SetCurrent(Config::GFX_ENHANCE_POST_SHADER, ""); } } + } #ifdef IS_PLAYBACK - // Slippi Playback - if (IsHotkey(HK_SLIPPI_JUMP_BACK)) - { - if (g_playbackStatus->targetFrameNum == INT_MAX) { - g_playbackStatus->targetFrameNum = g_playbackStatus->currentPlaybackFrame - 1200; - Host_PlaybackSeek(); - } + // Slippi Playback + if (IsHotkey(HK_SLIPPI_JUMP_BACK)) + { + INFO_LOG(SLIPPI, "jump back"); + if (g_playbackStatus->targetFrameNum == INT_MAX) { + g_playbackStatus->targetFrameNum = g_playbackStatus->currentPlaybackFrame - 1200; + Host_PlaybackSeek(); } + } - if (IsHotkey(HK_SLIPPI_STEP_BACK)) - { - if (g_playbackStatus->targetFrameNum == INT_MAX) { - g_playbackStatus->targetFrameNum = g_playbackStatus->currentPlaybackFrame - 300; - Host_PlaybackSeek(); - } + if (IsHotkey(HK_SLIPPI_STEP_BACK)) + { + INFO_LOG(SLIPPI, "step back"); + if (g_playbackStatus->targetFrameNum == INT_MAX) { + g_playbackStatus->targetFrameNum = g_playbackStatus->currentPlaybackFrame - 300; + Host_PlaybackSeek(); } + } - if (IsHotkey(HK_SLIPPI_STEP_FORWARD)) - { - if (g_playbackStatus->targetFrameNum == INT_MAX) { - g_playbackStatus->targetFrameNum = g_playbackStatus->currentPlaybackFrame + 300; - Host_PlaybackSeek(); - } + if (IsHotkey(HK_SLIPPI_STEP_FORWARD)) + { + INFO_LOG(SLIPPI, "step forward"); + if (g_playbackStatus->targetFrameNum == INT_MAX) { + g_playbackStatus->targetFrameNum = g_playbackStatus->currentPlaybackFrame + 300; + Host_PlaybackSeek(); } + } - if (IsHotkey(HK_SLIPPI_JUMP_FORWARD)) - { - if (g_playbackStatus->targetFrameNum == INT_MAX) { - g_playbackStatus->targetFrameNum = g_playbackStatus->currentPlaybackFrame + 1200; - Host_PlaybackSeek(); - } + if (IsHotkey(HK_SLIPPI_JUMP_FORWARD)) + { + INFO_LOG(SLIPPI, "jump forward"); + if (g_playbackStatus->targetFrameNum == INT_MAX) { + g_playbackStatus->targetFrameNum = g_playbackStatus->currentPlaybackFrame + 1200; + Host_PlaybackSeek(); } + } #endif const auto stereo_depth = Config::Get(Config::GFX_STEREO_DEPTH); @@ -552,7 +557,7 @@ void HotkeyScheduler::Run() if (IsHotkey(HK_INCREASE_DEPTH, true)) Config::SetCurrent(Config::GFX_STEREO_DEPTH, - std::min(stereo_depth + 1, Config::GFX_STEREO_DEPTH_MAXIMUM)); + std::min(stereo_depth + 1, Config::GFX_STEREO_DEPTH_MAXIMUM)); const auto stereo_convergence = Config::Get(Config::GFX_STEREO_CONVERGENCE); @@ -561,7 +566,7 @@ void HotkeyScheduler::Run() if (IsHotkey(HK_INCREASE_CONVERGENCE, true)) Config::SetCurrent(Config::GFX_STEREO_CONVERGENCE, - std::min(stereo_convergence + 5, Config::GFX_STEREO_CONVERGENCE_MAXIMUM)); + std::min(stereo_convergence + 5, Config::GFX_STEREO_CONVERGENCE_MAXIMUM)); // Freelook static float fl_speed = 1.0; diff --git a/Source/Core/VideoCommon/CMakeLists.txt b/Source/Core/VideoCommon/CMakeLists.txt index 9d29a6eff1..0c6eba39c6 100644 --- a/Source/Core/VideoCommon/CMakeLists.txt +++ b/Source/Core/VideoCommon/CMakeLists.txt @@ -42,7 +42,7 @@ add_library(videocommon HiresTextures.cpp HiresTextures.h HiresTextures_DDSLoader.cpp - IconsFontAwesome4.h + IconsFontAwesome4.h ImageWrite.cpp ImageWrite.h IndexGenerator.cpp diff --git a/Source/Core/VideoCommon/OnScreenDisplay.cpp b/Source/Core/VideoCommon/OnScreenDisplay.cpp index d55cbf4c4d..72fb827dbd 100644 --- a/Source/Core/VideoCommon/OnScreenDisplay.cpp +++ b/Source/Core/VideoCommon/OnScreenDisplay.cpp @@ -3,7 +3,6 @@ // Refer to the license.txt file included. #include -#include #include #include #include @@ -18,10 +17,12 @@ #include "Common/CommonTypes.h" #include "Common/Logging/Log.h" #include "Common/Timer.h" -#include "Core/Core.h" + #include "Core/ConfigManager.h" +#include "Core/Core.h" #include "Core/Host.h" #include "Core/Slippi/SlippiPlayback.h" + #include "VideoCommon/OnScreenDisplay.h" #include "VideoCommon/IconsFontAwesome4.h" @@ -46,6 +47,7 @@ struct Message }; static std::multimap s_messages; static std::mutex s_messages_mutex; + static s32 frame = 0; static std::string GetTimeForFrame(s32 currFrame) { @@ -422,9 +424,7 @@ void DrawSlippiPlaybackControls() } ImGui::SetCursorPos(ImVec2(0.0f, ImGui::GetWindowHeight() - 30)); ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.5f, 0.45f)); - //auto const paused = g_playbackStatus->shouldPause; //if (ButtonCustom(paused ? ICON_FA_PLAY : ICON_FA_PAUSE, ImVec2(40.0f, 32.0f))) { - // g_playbackStatus->shouldPause = !paused; // INFO_LOG(SLIPPI, "playing"); //} //ImGui::SameLine(0.0f, 5.0f); diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index 9fd43bb306..a8125c7f76 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -919,12 +919,14 @@ bool Renderer::InitializeImGui() return false; } +#ifdef IS_PLAYBACK ImFontConfig config; config.MergeMode = true; ImGui::GetIO().Fonts->AddFontFromFileTTF("Roboto-Medium.ttf", 14.0f, 0, ImGui::GetIO().Fonts->GetGlyphRangesDefault()); static const ImWchar icons_ranges[] = { ICON_MIN_FA, ICON_MAX_FA, 0 }; ImFontConfig icons_config; icons_config.MergeMode = true; icons_config.PixelSnapH = true; ImGui::GetIO().Fonts->AddFontFromFileTTF(FONT_ICON_FILE_NAME_FA, 16.0f, &icons_config, icons_ranges); +#endif // Don't create an ini file. TODO: Do we want this in the future? ImGui::GetIO().IniFilename = nullptr;