Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qt: patch creator #10816

Merged
merged 1 commit into from Sep 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 40 additions & 7 deletions Utilities/bin_patch.cpp
Expand Up @@ -176,6 +176,14 @@ bool patch_engine::load(patch_map& patches_map, const std::string& path, std::st
continue;
}

if (main_key.empty())
{
append_log_message(log_messages, "Error: Skipping empty key");
patch_log.error("Skipping empty key (file: %s)", path);
is_valid = false;
continue;
}

// Skip Anchors
if (main_key == patch_key::anchors)
{
Expand All @@ -184,8 +192,8 @@ bool patch_engine::load(patch_map& patches_map, const std::string& path, std::st

// Find or create an entry matching the key/hash in our map
auto& container = patches_map[main_key];
container.hash = main_key;
container.version = version;
container.hash = main_key;
container.version = version;

// Go through each patch
for (auto patches_entry : pair.second)
Expand Down Expand Up @@ -223,10 +231,18 @@ bool patch_engine::load(patch_map& patches_map, const std::string& path, std::st
{
const std::string& title = game_node.first.Scalar();

if (title.empty())
{
append_log_message(log_messages, fmt::format("Error: Empty game title (key: %s, file: %s)", main_key, path));
patch_log.error("Empty game title (key: %s, file: %s)", main_key, path);
is_valid = false;
continue;
}

if (const auto yml_type = game_node.second.Type(); yml_type != YAML::NodeType::Map)
{
append_log_message(log_messages, fmt::format("Error: Skipping %s: expected Map, found %s (patch: %s, key: %s)", title, yml_type, description, main_key));
patch_log.error("Skipping %s: expected Map, found %s (patch: %s, key: %s, file: %s)", title, yml_type, description, main_key, path);
append_log_message(log_messages, fmt::format("Error: Skipping game %s: expected Map, found %s (patch: %s, key: %s)", title, yml_type, description, main_key));
patch_log.error("Skipping game %s: expected Map, found %s (patch: %s, key: %s, file: %s)", title, yml_type, description, main_key, path);
is_valid = false;
continue;
}
Expand All @@ -237,7 +253,14 @@ bool patch_engine::load(patch_map& patches_map, const std::string& path, std::st
{
const std::string& serial = serial_node.first.Scalar();

if (serial == patch_key::all)
if (serial.empty())
{
append_log_message(log_messages, fmt::format("Error: Using empty serial (title: %s, patch: %s, key: %s)", title, description, main_key));
patch_log.error("Using empty serial (title: %s, patch: %s, key: %s, file: %s)", title, description, main_key, path);
is_valid = false;
continue;
}
else if (serial == patch_key::all)
{
if (!title_is_all_key)
{
Expand Down Expand Up @@ -363,18 +386,28 @@ bool patch_engine::load(patch_map& patches_map, const std::string& path, std::st
return is_valid;
}

patch_type patch_engine::get_patch_type(YAML::Node node)
patch_type patch_engine::get_patch_type(const std::string& text)
{
u64 type_val = 0;

if (!node || !node.IsScalar() || !cfg::try_to_enum_value(&type_val, &fmt_class_string<patch_type>::format, node.Scalar()))
if (!cfg::try_to_enum_value(&type_val, &fmt_class_string<patch_type>::format, text))
{
return patch_type::invalid;
}

return static_cast<patch_type>(type_val);
}

patch_type patch_engine::get_patch_type(YAML::Node node)
{
if (!node || !node.IsScalar())
{
return patch_type::invalid;
}

return get_patch_type(node.Scalar());
}

bool patch_engine::add_patch_data(YAML::Node node, patch_info& info, u32 modifier, const YAML::Node& root, std::stringstream* log_messages)
{
if (!node || !node.IsSequence())
Expand Down
3 changes: 3 additions & 0 deletions Utilities/bin_patch.h
Expand Up @@ -121,6 +121,9 @@ class patch_engine
// Read and add a patch node to the patch info
static bool read_patch_node(patch_info& info, YAML::Node node, const YAML::Node& root, std::stringstream* log_messages = nullptr);

// Get the patch type from a string
static patch_type get_patch_type(const std::string& text);

// Get the patch type of a patch node
static patch_type get_patch_type(YAML::Node node);

Expand Down
29 changes: 28 additions & 1 deletion rpcs3/rpcs3.vcxproj
Expand Up @@ -291,6 +291,9 @@
<ClCompile Include="QTGeneratedFiles\Debug\moc_pad_settings_dialog.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="QTGeneratedFiles\Debug\moc_patch_creator_dialog.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="QTGeneratedFiles\Debug\moc_patch_manager_dialog.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
Expand Down Expand Up @@ -480,6 +483,9 @@
<ClCompile Include="QTGeneratedFiles\Release\moc_pad_settings_dialog.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="QTGeneratedFiles\Release\moc_patch_creator_dialog.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="QTGeneratedFiles\Release\moc_patch_manager_dialog.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
</ClCompile>
Expand Down Expand Up @@ -572,6 +578,7 @@
<ClCompile Include="rpcs3qt\microphone_creator.cpp" />
<ClCompile Include="rpcs3qt\osk_dialog_frame.cpp" />
<ClCompile Include="rpcs3qt\pad_led_settings_dialog.cpp" />
<ClCompile Include="rpcs3qt\patch_creator_dialog.cpp" />
<ClCompile Include="rpcs3qt\patch_manager_dialog.cpp" />
<ClCompile Include="rpcs3qt\pkg_install_dialog.cpp" />
<ClCompile Include="rpcs3qt\persistent_settings.cpp" />
Expand Down Expand Up @@ -1046,6 +1053,16 @@
</CustomBuild>
<ClInclude Include="rpcs3qt\movie_item.h" />
<ClInclude Include="rpcs3qt\numbered_widget_item.h" />
<CustomBuild Include="rpcs3qt\patch_creator_dialog.h">
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Moc%27ing %(Identity)...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\QTGeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\QTGeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -D_WINDOWS -DUNICODE -DWIN32 -DWIN64 -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_WINEXTRAS_LIB -DQT_CONCURRENT_LIB -D%(PreprocessorDefinitions) "-I.\..\3rdparty\flatbuffers\include" "-I.\..\3rdparty\wolfssl\wolfssl" "-I.\..\3rdparty\curl\curl\include" "-I.\..\3rdparty\libusb\libusb\libusb" "-I$(VULKAN_SDK)\Include" "-I.\..\3rdparty\XAudio2Redist\include" "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtCore" "-I.\debug" "-I$(QTDIR)\mkspecs\win32-msvc2015" "-I.\QTGeneratedFiles\$(ConfigurationName)" "-I.\QTGeneratedFiles" "-I$(QTDIR)\include\QtWinExtras" "-I$(QTDIR)\include\QtConcurrent"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Moc%27ing %(Identity)...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\QTGeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\QTGeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -D_WINDOWS -DUNICODE -DWIN32 -DWIN64 -DWITH_DISCORD_RPC -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DNDEBUG -DQT_WINEXTRAS_LIB -DQT_CONCURRENT_LIB -D%(PreprocessorDefinitions) "-I.\..\3rdparty\flatbuffers\include" "-I.\..\3rdparty\wolfssl\wolfssl" "-I.\..\3rdparty\curl\curl\include" "-I.\..\3rdparty\libusb\libusb\libusb" "-I$(VULKAN_SDK)\Include" "-I.\..\3rdparty\XAudio2Redist\include" "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtCore" "-I.\release" "-I$(QTDIR)\mkspecs\win32-msvc2015" "-I.\QTGeneratedFiles\$(ConfigurationName)" "-I.\QTGeneratedFiles" "-I$(QTDIR)\include\QtWinExtras" "-I$(QTDIR)\include\QtConcurrent"</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
</CustomBuild>
<ClInclude Include="rpcs3qt\richtext_item_delegate.h" />
<ClInclude Include="rpcs3qt\stylesheets.h" />
<CustomBuild Include="rpcs3qt\skylander_dialog.h">
Expand Down Expand Up @@ -1398,6 +1415,16 @@
<ItemGroup>
<None Include="QTGeneratedFiles\Debug\pkg_install_dialog.moc" />
<None Include="QTGeneratedFiles\Release\pkg_install_dialog.moc" />
<CustomBuild Include="rpcs3qt\patch_creator_dialog.ui">
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(QTDIR)\bin\uic.exe;%(AdditionalInputs)</AdditionalInputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Uic%27ing %(Identity)...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\QTGeneratedFiles\ui_%(Filename).h;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(QTDIR)\bin\uic.exe" -o ".\QTGeneratedFiles\ui_%(Filename).h" "%(FullPath)"</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(QTDIR)\bin\uic.exe;%(AdditionalInputs)</AdditionalInputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Uic%27ing %(Identity)...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\QTGeneratedFiles\ui_%(Filename).h;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(QTDIR)\bin\uic.exe" -o ".\QTGeneratedFiles\ui_%(Filename).h" "%(FullPath)"</Command>
</CustomBuild>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" />
Expand All @@ -1406,4 +1433,4 @@
<UserProperties MocDir=".\QTGeneratedFiles\$(ConfigurationName)" Qt5Version_x0020_x64="$(DefaultQtVersion)" RccDir=".\QTGeneratedFiles" UicDir=".\QTGeneratedFiles" />
</VisualStudio>
</ProjectExtensions>
</Project>
</Project>
15 changes: 15 additions & 0 deletions rpcs3/rpcs3.vcxproj.filters
Expand Up @@ -747,6 +747,15 @@
<ClCompile Include="rpcs3qt\game_list.cpp">
<Filter>Gui\game list</Filter>
</ClCompile>
<ClCompile Include="QTGeneratedFiles\Debug\moc_patch_creator_dialog.cpp">
<Filter>Generated Files\Debug</Filter>
</ClCompile>
<ClCompile Include="rpcs3qt\patch_creator_dialog.cpp">
<Filter>Gui\patch manager</Filter>
</ClCompile>
<ClCompile Include="QTGeneratedFiles\Release\moc_patch_creator_dialog.cpp">
<Filter>Generated Files\Release</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Input\ds4_pad_handler.h">
Expand Down Expand Up @@ -1093,6 +1102,12 @@
<CustomBuild Include="rpcs3qt\log_viewer.h">
<Filter>Gui\log</Filter>
</CustomBuild>
<CustomBuild Include="rpcs3qt\patch_creator_dialog.ui">
<Filter>Form Files</Filter>
</CustomBuild>
<CustomBuild Include="rpcs3qt\patch_creator_dialog.h">
<Filter>Gui\patch manager</Filter>
</CustomBuild>
</ItemGroup>
<ItemGroup>
<Image Include="rpcs3.ico" />
Expand Down
3 changes: 3 additions & 0 deletions rpcs3/rpcs3qt/CMakeLists.txt
Expand Up @@ -44,6 +44,7 @@ set(SRC_FILES
osk_dialog_frame.cpp
pad_led_settings_dialog.cpp
pad_settings_dialog.cpp
patch_creator_dialog.cpp
patch_manager_dialog.cpp
persistent_settings.cpp
pkg_install_dialog.cpp
Expand Down Expand Up @@ -80,6 +81,8 @@ set(UI_FILES
main_window.ui
pad_led_settings_dialog.ui
pad_settings_dialog.ui
patch_creator_dialog.ui
patch_manager_dialog.ui
settings_dialog.ui
welcome_dialog.ui
)
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/rpcs3qt/game_list_frame.cpp
Expand Up @@ -2211,7 +2211,7 @@ bool game_list_frame::eventFilter(QObject *object, QEvent *event)
return true;
}
}
else
else if (!key_event->isAutoRepeat())
{
if (key_event->key() == Qt::Key_Enter || key_event->key() == Qt::Key_Return)
{
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/rpcs3qt/log_frame.cpp
Expand Up @@ -683,7 +683,7 @@ bool log_frame::eventFilter(QObject* object, QEvent* event)
if (event->type() == QEvent::KeyPress)
{
QKeyEvent* e = static_cast<QKeyEvent*>(event);
if (e->modifiers() == Qt::ControlModifier && e->key() == Qt::Key_F)
if (e && !e->isAutoRepeat() && e->modifiers() == Qt::ControlModifier && e->key() == Qt::Key_F)
{
if (m_find_dialog && m_find_dialog->isVisible())
m_find_dialog->close();
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/rpcs3qt/log_viewer.cpp
Expand Up @@ -182,7 +182,7 @@ bool log_viewer::eventFilter(QObject* object, QEvent* event)
if (event->type() == QEvent::KeyPress)
{
QKeyEvent* e = static_cast<QKeyEvent*>(event);
if (e && e->modifiers() == Qt::ControlModifier && e->key() == Qt::Key_F)
if (e && !e->isAutoRepeat() && e->modifiers() == Qt::ControlModifier && e->key() == Qt::Key_F)
{
if (m_find_dialog && m_find_dialog->isVisible())
m_find_dialog->close();
Expand Down
7 changes: 7 additions & 0 deletions rpcs3/rpcs3qt/main_window.cpp
Expand Up @@ -23,6 +23,7 @@
#include "skylander_dialog.h"
#include "cheat_manager.h"
#include "patch_manager_dialog.h"
#include "patch_creator_dialog.h"
#include "pkg_install_dialog.h"
#include "category.h"
#include "gui_settings.h"
Expand Down Expand Up @@ -2111,6 +2112,12 @@ void main_window::CreateConnects()
patch_manager.exec();
});

connect(ui->patchCreatorAct, &QAction::triggered, this, [this]
{
patch_creator_dialog patch_creator(this);
patch_creator.exec();
});

connect(ui->actionManage_Users, &QAction::triggered, this, [this]
{
user_manager_dialog user_manager(m_gui_settings, m_persistent_settings, this);
Expand Down
6 changes: 6 additions & 0 deletions rpcs3/rpcs3qt/main_window.ui
Expand Up @@ -255,6 +255,7 @@
<addaction name="toolsmemory_viewerAct"/>
<addaction name="toolsRsxDebuggerAct"/>
<addaction name="toolsStringSearchAct"/>
<addaction name="patchCreatorAct"/>
<addaction name="separator"/>
<addaction name="toolsDecryptSprxLibsAct"/>
<addaction name="separator"/>
Expand Down Expand Up @@ -1169,6 +1170,11 @@
<string>Boot VSH/XMB</string>
</property>
</action>
<action name="patchCreatorAct">
<property name="text">
<string>Patch Creator</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
Expand Down