Skip to content

Commit

Permalink
Unifiy AR/Gecko/Patch GUI dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
phire committed Apr 11, 2020
1 parent 53d8f5e commit 61a6be7
Show file tree
Hide file tree
Showing 17 changed files with 647 additions and 701 deletions.
6 changes: 3 additions & 3 deletions Source/Core/Core/ActionReplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ std::vector<ARCode> LoadCodes(const IniFile& global_ini, const IniFile& local_in
return codes;
}

void SaveCodes(IniFile* local_ini, const std::vector<ARCode>& codes)
void SaveCodes(IniFile& local_ini, const std::vector<ARCode>& codes)
{
std::vector<std::string> lines;
std::vector<std::string> enabled_lines;
Expand All @@ -302,8 +302,8 @@ void SaveCodes(IniFile* local_ini, const std::vector<ARCode>& codes)
}
}
}
local_ini->SetLines("ActionReplay_Enabled", enabled_lines);
local_ini->SetLines("ActionReplay", lines);
local_ini.SetLines("ActionReplay_Enabled", enabled_lines);
local_ini.SetLines("ActionReplay", lines);
}

static void VLogInfo(std::string_view format, fmt::format_args args)
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/ActionReplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void AddCode(ARCode new_code);
void LoadAndApplyCodes(const IniFile& global_ini, const IniFile& local_ini);

std::vector<ARCode> LoadCodes(const IniFile& global_ini, const IniFile& local_ini);
void SaveCodes(IniFile* local_ini, const std::vector<ARCode>& codes);
void SaveCodes(IniFile& local_ini, const std::vector<ARCode>& codes);

void EnableSelfLogging(bool enable);
std::vector<std::string> GetSelfLog();
Expand Down
30 changes: 28 additions & 2 deletions Source/Core/Core/PatchEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ const char* PatchTypeAsString(PatchType type)
return s_patch_type_strings.at(static_cast<int>(type));
}

void LoadPatchSection(const std::string& section, std::vector<Patch>& patches, IniFile& globalIni,
IniFile& localIni)
void LoadPatchSection(const std::string& section, std::vector<Patch>& patches, const IniFile& globalIni,
const IniFile& localIni)
{
// Load the name of all enabled patches
std::string enabledSectionName = section + "_Enabled";
Expand Down Expand Up @@ -201,6 +201,32 @@ void LoadPatches()
LoadSpeedhacks("Speedhacks", merged);
}

void SavePatches(IniFile& inifile, const std::vector<Patch>& patches)
{
std::vector<std::string> lines;
std::vector<std::string> lines_enabled;

for (const auto& patch : patches)
{
if (patch.active)
lines_enabled.push_back("$" + patch.name);

if (!patch.user_defined)
continue;

lines.push_back("$" + patch.name);

for (const auto& entry : patch.entries)
{
lines.push_back(StringFromFormat("0x%08X:%s:0x%08X", entry.address,
PatchEngine::PatchTypeAsString(entry.type), entry.value));
}
}

inifile.SetLines("OnFrame_Enabled", lines_enabled);
inifile.SetLines("OnFrame", lines);
}

static void ApplyPatches(const std::vector<Patch>& patches)
{
for (const Patch& patch : patches)
Expand Down
5 changes: 3 additions & 2 deletions Source/Core/Core/PatchEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ const char* PatchTypeAsString(PatchType type);

int GetSpeedhackCycles(const u32 addr);
std::vector<Patch>& GetFilePatches();
void LoadPatchSection(const std::string& section, std::vector<Patch>& patches, IniFile& globalIni,
IniFile& localIni);
void LoadPatchSection(const std::string& section, std::vector<Patch>& patches, const IniFile& globalIni,
const IniFile& localIni);
void LoadPatches();
void SavePatches(IniFile& inifile, const std::vector<Patch>& patches);
bool ApplyFramePatches();
void Shutdown();
void Reload();
Expand Down
14 changes: 6 additions & 8 deletions Source/Core/DolphinQt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ add_executable(dolphin-emu
Translation.h
WiiUpdate.cpp
WiiUpdate.h
Config/ARCodeWidget.cpp
Config/ARCodeWidget.h
Config/CheatCodeEditor.cpp
Config/CheatCodeEditor.h
Config/CheatItem.cpp
Config/CheatItem.h
Config/CheatList.cpp
Config/CheatList.h
Config/CheatWarningWidget.cpp
Config/CheatWarningWidget.h
Config/ControllerInterface/DualShockUDPClientWidget.cpp
Expand All @@ -69,8 +71,6 @@ add_executable(dolphin-emu
Config/GameConfigHighlighter.h
Config/GameConfigWidget.cpp
Config/GameConfigWidget.h
Config/GeckoCodeWidget.cpp
Config/GeckoCodeWidget.h
Config/Graphics/AdvancedWidget.cpp
Config/Graphics/AdvancedWidget.h
Config/Graphics/EnhancementsWidget.cpp
Expand Down Expand Up @@ -156,8 +156,6 @@ add_executable(dolphin-emu
Config/Mapping/WiimoteEmuMotionControlIMU.h
Config/NewPatchDialog.cpp
Config/NewPatchDialog.h
Config/PatchesWidget.cpp
Config/PatchesWidget.h
Config/PropertiesDialog.cpp
Config/PropertiesDialog.h
Config/SettingsWindow.cpp
Expand Down Expand Up @@ -450,8 +448,8 @@ if(APPLE)
include(DolphinPostprocessBundle)
dolphin_postprocess_bundle(dolphin-emu)
# Fix rpath
add_custom_command(TARGET dolphin-emu
POST_BUILD COMMAND
add_custom_command(TARGET dolphin-emu
POST_BUILD COMMAND
${CMAKE_INSTALL_NAME_TOOL} -add_rpath "@executable_path/../Frameworks/"
$<TARGET_FILE:dolphin-emu>)
else()
Expand Down
7 changes: 3 additions & 4 deletions Source/Core/DolphinQt/CheatsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@

#include "UICommon/GameFile.h"

#include "DolphinQt/Config/ARCodeWidget.h"
#include "DolphinQt/Config/GeckoCodeWidget.h"
#include "DolphinQt/Config/CheatList.h"
#include "DolphinQt/GameList/GameListModel.h"
#include "DolphinQt/Settings.h"

Expand Down Expand Up @@ -195,9 +194,9 @@ void CheatsManager::OnStateChanged(Core::State state)
if (m_ar_code)
m_ar_code->deleteLater();

m_ar_code = new ARCodeWidget(*m_game_file, false);
m_ar_code = new CheatList(*m_game_file, CheatType::ARCode, false);
m_tab_widget->insertTab(0, m_ar_code, tr("AR Code"));
m_tab_widget->insertTab(1, new GeckoCodeWidget(*m_game_file, false), tr("Gecko Codes"));
m_tab_widget->insertTab(1, new CheatList(*m_game_file, CheatType::GeckoCode, false), tr("Gecko Codes"));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/DolphinQt/CheatsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#include "Common/CommonTypes.h"

class ARCodeWidget;
class CheatList;
class QComboBox;
class QDialogButtonBox;
class QLabel;
Expand Down Expand Up @@ -68,7 +68,7 @@ class CheatsManager : public QDialog
QTabWidget* m_tab_widget = nullptr;

QWidget* m_cheat_search;
ARCodeWidget* m_ar_code = nullptr;
CheatList* m_ar_code = nullptr;

QLabel* m_result_label;
QTableWidget* m_match_table;
Expand Down
Loading

0 comments on commit 61a6be7

Please sign in to comment.