diff --git a/CHANGELOG.md b/CHANGELOG.md index 95fa39c..3e3238b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,9 @@ -# GhTrTool 0.11u ~ [2024-04-14] +# GhTrTool 0.11v ~ [2024-04-29] ## 完整更新日志 -### 更新 -- 对GhTr ~ Perfect Voyage 0.16m版本提供支持,停止支持之前的版本 ### 特性 -- 重构代码,提升可读性和可维护性 +- 增加一键允许创建ub存档 +- 完善存档标记 ### 正在进行 - 地址常数化 -![image](https://github.com/Xcating/GhTrTool/assets/82816129/bf18c318-a437-4fd1-ba5e-9e3d37f36f00) \ No newline at end of file +![image](https://github.com/Xcating/GhTrTool/assets/82816129/a2077550-108f-4334-9cf5-c5c4b29e4379) \ No newline at end of file diff --git a/GhTrTool/GhTrTool.rc b/GhTrTool/GhTrTool.rc index 192af52..37c0fef 100644 Binary files a/GhTrTool/GhTrTool.rc and b/GhTrTool/GhTrTool.rc differ diff --git a/GhTrTool/GhTrToolDlg.cpp b/GhTrTool/GhTrToolDlg.cpp index b46cff5..aa51b11 100644 --- a/GhTrTool/GhTrToolDlg.cpp +++ b/GhTrTool/GhTrToolDlg.cpp @@ -122,6 +122,7 @@ BEGIN_MESSAGE_MAP(CGhTrToolDlg, CDialogEx) ON_BN_CLICKED(IDC_BTN_ClearZombie, &CGhTrToolDlg::OnBnClickedBtnClearZombie) ON_BN_CLICKED(IDC_BTN_FixCrashBug, &CGhTrToolDlg::OnBnClickedBtnFixCrashBug) ON_BN_CLICKED(IDC_BTN_ToDaoXiangJi, &CGhTrToolDlg::OnBnClickedBtnToDaoXiangJi) + ON_BN_CLICKED(IDC_BTN_ArrUb, &CGhTrToolDlg::OnBnClickedBtnArrUb) ON_BN_CLICKED(IDC_BTN_ToHongZhen, &CGhTrToolDlg::OnBnClickedBtnToHongZhen) ON_BN_CLICKED(IDC_BTN_ClearPlant, &CGhTrToolDlg::OnBnClickedBtnClearPlant) ON_BN_CLICKED(IDC_BTN_ClearBullet, &CGhTrToolDlg::OnBnClickedBtnClearBullet) @@ -172,6 +173,7 @@ void CGhTrToolDlg::OnClickMenuShowSaveFunction() GetDlgItem(IDC_BTN_DifficultySwitcher)->ShowWindow(SW_SHOW); GetDlgItem(IDC_EDIT_Diff)->ShowWindow(SW_SHOW); GetDlgItem(IDC_BTN_ToDaoXiangJi)->ShowWindow(SW_SHOW); + GetDlgItem(IDC_BTN_ArrUb)->ShowWindow(SW_SHOW); GetDlgItem(IDC_BTN_ToHongZhen)->ShowWindow(SW_SHOW); GetDlgItem(IDC_BTN_NoUbBroken)->ShowWindow(SW_SHOW); GetDlgItem(IDC_STATIC_DiffID)->ShowWindow(SW_SHOW); @@ -183,6 +185,7 @@ void CGhTrToolDlg::OnClickMenuShowSaveFunction() GetDlgItem(IDC_BTN_DifficultySwitcher)->ShowWindow(SW_HIDE); GetDlgItem(IDC_EDIT_Diff)->ShowWindow(SW_HIDE); GetDlgItem(IDC_BTN_ToDaoXiangJi)->ShowWindow(SW_HIDE); + GetDlgItem(IDC_BTN_ArrUb)->ShowWindow(SW_HIDE); GetDlgItem(IDC_BTN_ToHongZhen)->ShowWindow(SW_HIDE); GetDlgItem(IDC_BTN_NoUbBroken)->ShowWindow(SW_HIDE); GetDlgItem(IDC_STATIC_DiffID)->ShowWindow(SW_HIDE); @@ -539,6 +542,12 @@ void CGhTrToolDlg::OnBnClickedBtnToDaoXiangJi() pvz.ToDaoXiangJi(); } +void CGhTrToolDlg::OnBnClickedBtnArrUb() +{ + GhTrManager pvz = GhTrManager(); + pvz.ArrUb(); +} + void CGhTrToolDlg::OnBnClickedBtnToHongZhen() { GhTrManager pvz = GhTrManager(); pvz.WriteConfig(); diff --git a/GhTrTool/GhTrToolDlg.h b/GhTrTool/GhTrToolDlg.h index 3bf4720..558af9c 100644 --- a/GhTrTool/GhTrToolDlg.h +++ b/GhTrTool/GhTrToolDlg.h @@ -89,6 +89,7 @@ class CGhTrToolDlg : public CDialogEx afx_msg void OnBnClickedBtnFixCrashBug(); afx_msg void OnBnClickedBtnToHongZhen(); afx_msg void OnBnClickedBtnToDaoXiangJi(); + afx_msg void OnBnClickedBtnArrUb(); afx_msg void UpdateText(); afx_msg void OnBnClickedBtnPlantIDList(); void OnTimer(UINT_PTR nIDEvent); diff --git a/GhTrTool/Pvz.cpp b/GhTrTool/Pvz.cpp index 6e35ad3..eda8370 100644 --- a/GhTrTool/Pvz.cpp +++ b/GhTrTool/Pvz.cpp @@ -204,8 +204,15 @@ bool GhTrManager::CheckGamePid(DWORD dw_pid, bool is_message) { * @return bool 枚举是否继续 */ BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM l_param) { + DWORD dw_pid; GetWindowThreadProcessId(hwnd, &dw_pid); + HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dw_pid); + DWORD base_address = GetGamebase_address(hProcess); + DWORD target_address = base_address + GAME_BASE_OFFSET; + DWORD dwNum = 0; + ReadProcessMemory(hProcess, (LPCVOID)target_address, &dwNum, sizeof(DWORD), NULL); + ReadProcessMemory(hProcess, (LPCVOID)(dwNum + 0x80C), &dwNum, sizeof(DWORD), NULL); auto millis = std::chrono::duration_cast( std::chrono::system_clock::now().time_since_epoch()) .count(); @@ -219,8 +226,8 @@ BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM l_param) { #else std::wstring wstr = (std::wstringstream() << L"Plants Vs Zombies GhTr ~ Perfect Voyage " - << L"ver.0.16m - [已被GhTrTool修改] [ver.0.11u] [" - << millis << L"]") + << L"ver.0.16m - [已被GhTrTool修改] [ver.0.11v] [" + << millis << L"]" << L" [Save" << dwNum<> j; + input_file.close(); + } + // 修改Cheat为true,如果不存在则创建 + j["Cheat"] = true; + auto millis = std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch()) + .count(); + j["LastCheatTime"] = millis; + // 写入修改后的JSON到文件 + std::ofstream output_file(file_path); + if (output_file.is_open()) { + output_file << j.dump(4); // 以漂亮打印的格式写入文件(缩进为4个空格) + output_file.close(); + } + else { + MessageBoxA(NULL, "无法打开文件进行写入!请检查你的GhTr是否能正确的存档", "警告", MB_OK); + } } /** * 修改游戏中的阳光数量 @@ -1516,6 +1553,40 @@ void GhTrManager::ShowDiffBox(DWORD dwDiff) break; } } +/** + * 切换是否可以创建Ub存档的变量 + */ +void GhTrManager::ArrUb() +{ + // 定义JSON对象 + nlohmann::json j; + // 读取JSON文件 + std::ifstream input_file("C:\\ProgramData\\PerfectVoyage\\allusers.ghtr"); + if (input_file.is_open()) { + input_file >> j; + input_file.close(); + } + // 修改UbOpen为true,如果不存在则创建 + if (j["UbOpen"]) + { + j["UbOpen"] = false; + MessageBoxA(NULL, "成功[禁止]Unbalanced存档的创建,再次点击则允许", "提示", MB_OK); + } + else + { + j["UbOpen"] = true; + MessageBoxA(NULL, "成功[允许]Unbalanced存档的创建,再次点击则禁止", "提示", MB_OK); + } + // 写入修改后的JSON到文件 + std::ofstream output_file("C:\\ProgramData\\PerfectVoyage\\allusers.ghtr"); + if (output_file.is_open()) { + output_file << j.dump(4); // 以漂亮打印的格式写入文件(缩进为4个空格) + output_file.close(); + } + else { + MessageBoxA(NULL, "无法打开文件进行写入!请检查你的GhTr是否能正确的存档", "警告", MB_OK); + } +} /** * 切换当前存档难度 * diff --git a/GhTrTool/Pvz.h b/GhTrTool/Pvz.h index 126dea3..2efc4a3 100644 --- a/GhTrTool/Pvz.h +++ b/GhTrTool/Pvz.h @@ -118,6 +118,8 @@ class GhTrManager void FixCrashBug(); //切换至导向线 void ToDaoXiangJi(); + //切换是否可以创建Ub存档 + void ArrUb(); //显示难度提示信息 void ShowDiffBox(DWORD dwDiff); //切换至红针线 diff --git a/GhTrTool/resource.h b/GhTrTool/resource.h index 4fb5545..c222420 100644 Binary files a/GhTrTool/resource.h and b/GhTrTool/resource.h differ diff --git a/README.md b/README.md index 3893d1f..25f0009 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ # GhTrTool -#### If you are not Chinese? pls Use ***[English Version](https://github.com/Xcating/GhTrTool/releases/tag/0.11c-en-us)*** 植物大战僵尸GhTr同人游戏工具,娱乐学习 PlantsVsZombies ~ GhTr *PersonGames Tools*