diff --git a/pcsx2/CMakeLists.txt b/pcsx2/CMakeLists.txt index 92a34f7126..9dabfcd83d 100644 --- a/pcsx2/CMakeLists.txt +++ b/pcsx2/CMakeLists.txt @@ -555,6 +555,7 @@ set(pcsx2RecordingHeaders ${rec_src}/InputRecordingFile.h ${rec_src}/NewRecordingFrame.h ${rec_src}/PadData.h + ${rec_src}/Utilities/InputRecordingLogger.h ${rec_vp_src}/VirtualPad.h ${rec_vp_src}/VirtualPadData.h ${rec_vp_src}/VirtualPadResources.h diff --git a/pcsx2/Recording/Utilities/InputRecordingLogger.h b/pcsx2/Recording/Utilities/InputRecordingLogger.h new file mode 100644 index 0000000000..d80f1b989a --- /dev/null +++ b/pcsx2/Recording/Utilities/InputRecordingLogger.h @@ -0,0 +1,86 @@ +/* PCSX2 - PS2 Emulator for PCs + * Copyright (C) 2002-2020 PCSX2 Dev Team + * + * PCSX2 is free software: you can redistribute it and/or modify it under the terms + * of the GNU Lesser General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with PCSX2. + * If not, see . + */ + +#pragma once + +#include "App.h" +#include "ConsoleLogger.h" +#include "DebugTools/Debug.h" +#include "Utilities/Console.h" + +#include +#include + +namespace inputRec +{ + namespace + { + template + static std::string fmtStr(const std::string& format, Args... args) + { + size_t size = snprintf(nullptr, 0, format.c_str(), args...) + 1; + if (size <= 0) + return std::string(""); + + std::unique_ptr buf(new char[size]); + snprintf(buf.get(), size, format.c_str(), args...); + return std::string(buf.get(), buf.get() + size - 1); + } + } // namespace + + + template + static void log(const std::string& format, Args... args) + { + std::string finalStr = fmtStr(format, std::forward(args)...); + if (finalStr.empty()) + return; + + recordingConLog("[REC]: " + finalStr + "\n"); + + // NOTE - Color is not currently used for OSD logs + if (GSosdLog) + GSosdLog(finalStr.c_str(), wxGetApp().GetProgramLog()->GetRGBA(ConsoleColors::Color_StrongMagenta)); + } + + template + static void consoleLog(const std::string& format, Args... args) + { + std::string finalStr = fmtStr(format, std::forward(args)...); + if (finalStr.empty()) + return; + + recordingConLog(finalStr + "\n"); + } + + static void consoleMultiLog(std::vector strs) + { + std::string finalStr; + for (std::string s : strs) + finalStr.append("[REC]: " + s + "\n"); + + recordingConLog(finalStr); + } + + + static void consoleMultiLog(std::vector strs) + { + std::vector stdStrs; + for (wxString s : strs) + stdStrs.push_back(std::string(s)); + + consoleMultiLog(stdStrs); + } +} // namespace inputRec diff --git a/pcsx2/windows/VCprojects/pcsx2.vcxproj b/pcsx2/windows/VCprojects/pcsx2.vcxproj index f4606e17ec..70a7b1ca9d 100644 --- a/pcsx2/windows/VCprojects/pcsx2.vcxproj +++ b/pcsx2/windows/VCprojects/pcsx2.vcxproj @@ -598,6 +598,7 @@ + diff --git a/pcsx2/windows/VCprojects/pcsx2.vcxproj.filters b/pcsx2/windows/VCprojects/pcsx2.vcxproj.filters index d88bc24224..29b601065b 100644 --- a/pcsx2/windows/VCprojects/pcsx2.vcxproj.filters +++ b/pcsx2/windows/VCprojects/pcsx2.vcxproj.filters @@ -163,6 +163,9 @@ {bed493d6-96dc-4057-a1f2-31f88ec927d9} + + {85c5a0d2-6404-439f-8756-d908a1442b96} + {ad528458-08eb-49a2-aefa-3c2b86ab8896} @@ -1518,6 +1521,9 @@ System\Ps2\SPU2 + + Recording\Utilities +