Added cpu & ram usage in overlay, cleaned up code
This commit is contained in:
parent
6a9c4ee1e2
commit
bf6e751a2b
@ -11,6 +11,7 @@ void CheatMenu::DrawWindow()
|
||||
if (FrontEndMenuManager.m_bMenuActive)
|
||||
Hook::show_mouse = false;
|
||||
else
|
||||
{
|
||||
if (Globals::show_menu || Menu::commands::show_menu)
|
||||
{
|
||||
if (Globals::show_menu)
|
||||
@ -37,37 +38,11 @@ void CheatMenu::DrawWindow()
|
||||
else
|
||||
Menu::DrawShortcutsWindow();
|
||||
}
|
||||
}
|
||||
|
||||
Menu::DrawOverlay();
|
||||
}
|
||||
|
||||
void CheatMenu::ProcessEvent()
|
||||
{
|
||||
if (Globals::init_done && !FrontEndMenuManager.m_bMenuActive)
|
||||
{
|
||||
if (Ui::HotKeyPressed(hotkeys::menu_open))
|
||||
Globals::show_menu = !Globals::show_menu;
|
||||
|
||||
if (Ui::HotKeyPressed(hotkeys::command_window))
|
||||
{
|
||||
if (Menu::commands::show_menu)
|
||||
{
|
||||
Menu::ProcessCommands();
|
||||
strcpy(commands::input_buffer, "");
|
||||
}
|
||||
Menu::commands::show_menu = !Menu::commands::show_menu;
|
||||
}
|
||||
|
||||
if (Hook::show_mouse != Globals::show_menu)
|
||||
{
|
||||
if (Hook::show_mouse) // Only write when the menu closes
|
||||
config.WriteToDisk();
|
||||
|
||||
Hook::show_mouse = Globals::show_menu;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CheatMenu::CheatMenu()
|
||||
{
|
||||
ApplyStyle();
|
||||
@ -79,12 +54,32 @@ CheatMenu::CheatMenu()
|
||||
Globals::menu_size.y = config.GetValue("window.sizeY", screen::GetScreenHeight() / 1.2f);
|
||||
srand(CTimer::m_snTimeInMilliseconds);
|
||||
|
||||
Events::processScriptsEvent += ProcessEvent;
|
||||
}
|
||||
Events::processScriptsEvent += []()
|
||||
{
|
||||
if (Globals::init_done && !FrontEndMenuManager.m_bMenuActive)
|
||||
{
|
||||
if (Ui::HotKeyPressed(hotkeys::menu_open))
|
||||
Globals::show_menu = !Globals::show_menu;
|
||||
|
||||
CheatMenu::~CheatMenu()
|
||||
{
|
||||
Events::processScriptsEvent -= ProcessEvent;
|
||||
if (Ui::HotKeyPressed(hotkeys::command_window))
|
||||
{
|
||||
if (Menu::commands::show_menu)
|
||||
{
|
||||
Menu::ProcessCommands();
|
||||
strcpy(commands::input_buffer, "");
|
||||
}
|
||||
Menu::commands::show_menu = !Menu::commands::show_menu;
|
||||
}
|
||||
|
||||
if (Hook::show_mouse != Globals::show_menu)
|
||||
{
|
||||
if (Hook::show_mouse) // Only write when the menu closes
|
||||
config.WriteToDisk();
|
||||
|
||||
Hook::show_mouse = Globals::show_menu;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void CheatMenu::ApplyStyle()
|
||||
@ -166,7 +161,7 @@ void MenuThread(void* param)
|
||||
static bool game_init = false;
|
||||
|
||||
// Wait till the game is initialized
|
||||
Events::processScriptsEvent += []
|
||||
Events::initGameEvent += []
|
||||
{
|
||||
game_init = true;
|
||||
};
|
||||
@ -195,42 +190,10 @@ void MenuThread(void* param)
|
||||
while (true)
|
||||
{
|
||||
Sleep(5000);
|
||||
// if (KeyPressed(VK_LSHIFT) && KeyPressed(VK_BACK))
|
||||
// break;
|
||||
|
||||
if (Updater::state == UPDATER_CHECKING)
|
||||
Updater::CheckForUpdate();
|
||||
|
||||
// if (Updater::state == UPDATER_DOWNLOADING)
|
||||
// Updater::DownloadUpdate();
|
||||
|
||||
// if (Updater::state == UPDATER_INSTALLING)
|
||||
// {
|
||||
// Updater::InstallUpdate();
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
|
||||
// Globals::menu_closing = true;
|
||||
// Sleep(500);
|
||||
// delete menu;
|
||||
|
||||
// // reset mouse patches
|
||||
// patch::SetUChar(0x6194A0, 0xE9);
|
||||
// patch::SetUChar(0x746ED0, 0xA1);
|
||||
// patch::SetRaw(0x53F41F, (void*)"\x85\xC0\x0F\x8C", 4);
|
||||
|
||||
// if (Updater::state == UPDATER_INSTALLING)
|
||||
// {
|
||||
// CHud::SetHelpMessage("Install complete, restarting menu!",false,false,false);
|
||||
// Updater::FinishUpdate();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// CHud::SetHelpMessage("CheatMenu unloaded",false,false,false);
|
||||
// FreeLibraryAndExitThread(GetModuleHandle("CheatMenu.asi"),0);
|
||||
// FreeLibraryAndExitThread(GetModuleHandle("CheatMenuNew.asi"),0);
|
||||
// }
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved)
|
||||
|
@ -30,10 +30,8 @@ private:
|
||||
|
||||
static void ApplyStyle();
|
||||
static void DrawWindow();
|
||||
static void ProcessEvent();
|
||||
|
||||
public:
|
||||
CheatMenu();
|
||||
~CheatMenu();
|
||||
};
|
||||
|
||||
|
@ -74,7 +74,7 @@
|
||||
<GenerateDebugInformation>No</GenerateDebugInformation>
|
||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
<AdditionalLibraryDirectories>$(PLUGIN_SDK_DIR)\output\lib\;$(SolutionDir)\Release\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>urlmon.lib;plugin.lib;d3d9.lib;d3dx9.lib;d3d11.lib;d3dx11.lib;XInput9_1_0.lib;Depend.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>Pdh.lib;urlmon.lib;plugin.lib;d3d9.lib;d3dx9.lib;d3d11.lib;d3dx11.lib;XInput9_1_0.lib;Depend.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<IgnoreAllDefaultLibraries>
|
||||
</IgnoreAllDefaultLibraries>
|
||||
@ -94,7 +94,7 @@
|
||||
<GenerateDebugInformation>Debug</GenerateDebugInformation>
|
||||
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)\Debug\;$(PLUGIN_SDK_DIR)\output\lib\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>urlmon.lib;plugin_d.lib;d3d9.lib;d3dx9.lib;Depend.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>Pdh.lib;urlmon.lib;plugin_d.lib;d3d9.lib;d3dx9.lib;Depend.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
@ -195,7 +195,6 @@
|
||||
<ClInclude Include="Ui.h" />
|
||||
<ClInclude Include="Updater.h" />
|
||||
<ClInclude Include="Util.h" />
|
||||
<ClInclude Include="VehExtender.h" />
|
||||
<ClInclude Include="Vehicle.h" />
|
||||
<ClInclude Include="Visual.h" />
|
||||
<ClInclude Include="VKeys.h" />
|
||||
|
@ -40,7 +40,6 @@
|
||||
<ClInclude Include="Ui.h" />
|
||||
<ClInclude Include="Updater.h" />
|
||||
<ClInclude Include="Util.h" />
|
||||
<ClInclude Include="VehExtender.h" />
|
||||
<ClInclude Include="Vehicle.h" />
|
||||
<ClInclude Include="Visual.h" />
|
||||
<ClInclude Include="VKeys.h" />
|
||||
|
@ -12,15 +12,17 @@ Menu::Menu()
|
||||
{
|
||||
// TODO: use structs
|
||||
// Load config data
|
||||
overlay::coord = config.GetValue("overlay.coord", false);
|
||||
overlay::fps = config.GetValue("overlay.fps", false);
|
||||
overlay::loc_name = config.GetValue("overlay.loc_name", false);
|
||||
overlay::transparent = config.GetValue("overlay.transparent", false);
|
||||
overlay::veh_health = config.GetValue("overlay.veh_health", false);
|
||||
overlay::veh_speed = config.GetValue("overlay.veh_speed", false);
|
||||
overlay::selected_pos = config.GetValue("overlay.selected_pos", 4);
|
||||
overlay::posX = config.GetValue("overlay.posX", 0);
|
||||
overlay::posY = config.GetValue("overlay.posY", 0);
|
||||
overlay::bCoord = config.GetValue("overlay.bCoord", false);
|
||||
overlay::bCpuUsage = config.GetValue("overlay.bCpuUsage", false);
|
||||
overlay::bFPS = config.GetValue("overlay.bFPS", false);
|
||||
overlay::bLocName = config.GetValue("overlay.bLocName", false);
|
||||
overlay::bTransparent = config.GetValue("overlay.bTransparent", false);
|
||||
overlay::bMemUsage = config.GetValue("overlay.bMemUsage", false);
|
||||
overlay::bVehHealth = config.GetValue("overlay.bVehHealth", false);
|
||||
overlay::bVehSpeed = config.GetValue("overlay.bVehSpeed", false);
|
||||
overlay::mSelectedPos = config.GetValue("overlay.mSelectedPos", 4);
|
||||
overlay::fPosX = config.GetValue("overlay.fPosX", 0);
|
||||
overlay::fPosY = config.GetValue("overlay.fPosY", 0);
|
||||
|
||||
// Hotkeys
|
||||
hotkeys::aim_skin_changer.key1 = config.GetValue("hotkey.aim_skin_changer.key1", VK_RETURN);
|
||||
@ -58,15 +60,22 @@ Menu::Menu()
|
||||
|
||||
hotkeys::veh_instant_stop.key1 = config.GetValue("hotkey.veh_instant_stop.key1", VK_NONE);
|
||||
hotkeys::veh_instant_stop.key2 = config.GetValue("hotkey.veh_instant_stop.key2", VK_NONE);
|
||||
|
||||
Util::GetCPUUsageInit();
|
||||
MEMORYSTATUSEX memInfo;
|
||||
memInfo.dwLength = sizeof(MEMORYSTATUSEX);
|
||||
GlobalMemoryStatusEx(&memInfo);
|
||||
|
||||
overlay::mTotalRam = int(memInfo.ullTotalPhys * 1e-6); // Bytes -> MegaBytes
|
||||
}
|
||||
|
||||
void Menu::DrawOverlay()
|
||||
{
|
||||
CPlayerPed* player = FindPlayerPed();
|
||||
bool show_menu = overlay::coord || overlay::fps || overlay::loc_name ||
|
||||
((overlay::veh_health || overlay::veh_speed) && player->m_pVehicle && player->m_pVehicle->IsDriver(player));
|
||||
bool show_menu = overlay::bCoord || overlay::bFPS || overlay::bLocName ||
|
||||
((overlay::bVehHealth || overlay::bVehSpeed) && player->m_pVehicle && player->m_pVehicle->IsDriver(player));
|
||||
|
||||
int corner = overlay::selected_pos - 1;
|
||||
int corner = overlay::mSelectedPos - 1;
|
||||
const float offset = 10.0f;
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav;
|
||||
@ -80,51 +89,66 @@ void Menu::DrawOverlay()
|
||||
}
|
||||
else
|
||||
{
|
||||
if (overlay::posX != NULL && overlay::posY != NULL)
|
||||
if (overlay::fPosX != NULL && overlay::fPosY != NULL)
|
||||
{
|
||||
config.SetValue("overlay.posX", overlay::posX);
|
||||
config.SetValue("overlay.posY", overlay::posY);
|
||||
ImGui::SetNextWindowPos(ImVec2(overlay::posX, overlay::posY), ImGuiCond_Once);
|
||||
config.SetValue("overlay.fPosX", overlay::fPosX);
|
||||
config.SetValue("overlay.fPosY", overlay::fPosY);
|
||||
ImGui::SetNextWindowPos(ImVec2(overlay::fPosX, overlay::fPosY), ImGuiCond_Once);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::SetNextWindowBgAlpha(overlay::transparent ? 0.0f : 0.5f);
|
||||
ImGui::SetNextWindowBgAlpha(overlay::bTransparent ? 0.0f : 0.5f);
|
||||
|
||||
if (show_menu && ImGui::Begin("Overlay", NULL, window_flags))
|
||||
{
|
||||
CPlayerPed* player = FindPlayerPed();
|
||||
CVector pos = player->GetPosition();
|
||||
size_t game_ms = CTimer::m_snTimeInMilliseconds;
|
||||
|
||||
if (overlay::coord)
|
||||
if (game_ms - overlay::mLastInterval > overlay::mInterval)
|
||||
{
|
||||
CVector pos = player->GetPosition();
|
||||
overlay::fCpuUsage = (float)Util::GetCurrentCPUUsage();
|
||||
|
||||
std::string text = "Coord: " + std::to_string(int(pos.x)) + ", " + std::to_string(int(pos.y)) + ", "
|
||||
+ std::to_string(int(pos.z));
|
||||
MEMORYSTATUSEX memInfo;
|
||||
memInfo.dwLength = sizeof(MEMORYSTATUSEX);
|
||||
GlobalMemoryStatusEx(&memInfo);
|
||||
int mUsedRam = int((memInfo.ullTotalPhys - memInfo.ullAvailPhys) * 1e-6);
|
||||
overlay::fMemUsage = 100.0f * (float(mUsedRam) / float(overlay::mTotalRam));
|
||||
overlay::mFPS = (size_t)CTimer::game_FPS;
|
||||
|
||||
ImGui::Text(text.c_str());
|
||||
overlay::mLastInterval = game_ms;
|
||||
}
|
||||
|
||||
if (overlay::fps)
|
||||
ImGui::Text((std::string("Frames: ") + std::to_string(int(io.Framerate))).c_str());
|
||||
if (overlay::bCoord)
|
||||
ImGui::Text("Coord: %.2f, %.2f, %.2f", pos.x, pos.y, pos.z);
|
||||
|
||||
if (overlay::loc_name)
|
||||
ImGui::Text((std::string("Location: ") + Util::GetLocationName(&player->GetPosition())).c_str());
|
||||
if (overlay::bCpuUsage)
|
||||
ImGui::Text("CPU usage: %.2f%%", overlay::fCpuUsage);
|
||||
|
||||
if (overlay::bFPS)
|
||||
ImGui::Text("Frames: %d", overlay::mFPS);
|
||||
|
||||
if (overlay::bLocName)
|
||||
ImGui::Text("Location: %s", Util::GetLocationName(&pos).c_str());
|
||||
|
||||
if (overlay::bMemUsage)
|
||||
ImGui::Text("RAM usage: %.2f%%", overlay::fMemUsage);
|
||||
|
||||
if (player->m_pVehicle && player->m_pVehicle->IsDriver(player))
|
||||
{
|
||||
if (overlay::veh_health)
|
||||
ImGui::Text((std::string("Veh Health: ") + std::to_string(int(player->m_pVehicle->m_fHealth))).c_str());
|
||||
if (overlay::bVehHealth)
|
||||
ImGui::Text("Veh Health: %.f", player->m_pVehicle->m_fHealth);
|
||||
|
||||
if (overlay::veh_speed)
|
||||
if (overlay::bVehSpeed)
|
||||
{
|
||||
int speed = player->m_pVehicle->m_vecMoveSpeed.Magnitude() * 50; // 02E3 - GET_CAR_SPEED
|
||||
ImGui::Text((std::string("Veh Speed: ") + std::to_string(speed)).c_str());
|
||||
ImGui::Text("Veh Speed: %d", speed);
|
||||
}
|
||||
}
|
||||
|
||||
ImVec2 pos = ImGui::GetWindowPos();
|
||||
overlay::posX = pos.x;
|
||||
overlay::posY = pos.y;
|
||||
ImVec2 windowPos = ImGui::GetWindowPos();
|
||||
overlay::fPosX = windowPos.x;
|
||||
overlay::fPosY = windowPos.y;
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
@ -275,31 +299,37 @@ void Menu::Draw()
|
||||
ImGui::Spacing();
|
||||
ImGui::Spacing();
|
||||
ImGui::SameLine();
|
||||
if (Ui::ListBox("Overlay", overlay::pos_names, overlay::selected_pos))
|
||||
config.SetValue("overlay.selected_pos", overlay::selected_pos);
|
||||
if (Ui::ListBox("Overlay", overlay::posNames, overlay::mSelectedPos))
|
||||
config.SetValue("overlay.mSelectedPos", overlay::mSelectedPos);
|
||||
|
||||
ImGui::Spacing();
|
||||
|
||||
ImGui::Columns(2, NULL, false);
|
||||
if (ImGui::Checkbox("No background", &overlay::transparent))
|
||||
config.SetValue("overlay.transparent", overlay::transparent);
|
||||
if (ImGui::Checkbox("No background", &overlay::bTransparent))
|
||||
config.SetValue("overlay.bTransparent", overlay::bTransparent);
|
||||
|
||||
if (ImGui::Checkbox("Show coordinates", &overlay::coord))
|
||||
config.SetValue("overlay.coord", overlay::coord);
|
||||
if (ImGui::Checkbox("Show coordinates", &overlay::bCoord))
|
||||
config.SetValue("overlay.bCoord", overlay::bCoord);
|
||||
|
||||
if (ImGui::Checkbox("Show FPS", &overlay::fps))
|
||||
config.SetValue("overlay.fps", overlay::fps);
|
||||
if (ImGui::Checkbox("Show CPU usage", &overlay::bCpuUsage))
|
||||
config.SetValue("overlay.bCpuUsage", overlay::bCpuUsage);
|
||||
|
||||
if (ImGui::Checkbox("Show FPS", &overlay::bFPS))
|
||||
config.SetValue("overlay.bFPS", overlay::bFPS);
|
||||
|
||||
ImGui::NextColumn();
|
||||
|
||||
if (ImGui::Checkbox("Show location", &overlay::loc_name))
|
||||
config.SetValue("overlay.loc_name", overlay::loc_name);
|
||||
if (ImGui::Checkbox("Show location", &overlay::bLocName))
|
||||
config.SetValue("overlay.bLocName", overlay::bLocName);
|
||||
|
||||
if (ImGui::Checkbox("Show veh health", &overlay::veh_health))
|
||||
config.SetValue("overlay.veh_health", overlay::veh_health);
|
||||
if (ImGui::Checkbox("Show RAM usage", &overlay::bMemUsage))
|
||||
config.SetValue("overlay.bMemUsage", overlay::bMemUsage);
|
||||
|
||||
if (ImGui::Checkbox("Show veh speed", &overlay::veh_speed))
|
||||
config.SetValue("overlay.veh_speed", overlay::veh_speed);
|
||||
if (ImGui::Checkbox("Show veh health", &overlay::bVehHealth))
|
||||
config.SetValue("overlay.bVehHealth", overlay::bVehHealth);
|
||||
|
||||
if (ImGui::Checkbox("Show veh speed", &overlay::bVehSpeed))
|
||||
config.SetValue("overlay.bVehSpeed", overlay::bVehSpeed);
|
||||
|
||||
ImGui::Columns(1);
|
||||
|
||||
|
@ -5,16 +5,24 @@ class Menu
|
||||
private:
|
||||
struct overlay
|
||||
{
|
||||
inline static bool coord = false;
|
||||
inline static bool fps = false;
|
||||
inline static bool loc_name = false;
|
||||
inline static bool transparent = false;
|
||||
inline static bool veh_health = false;
|
||||
inline static bool veh_speed = false;
|
||||
inline static std::vector<std::string> pos_names = { "Custom", "Top left", "Top right", "Bottom left", "Bottom right" };
|
||||
inline static int selected_pos = 4; // TODO: Create Enum
|
||||
inline static float posX = 0.0f;
|
||||
inline static float posY = 0.0f;
|
||||
inline static bool bCoord = false;
|
||||
inline static bool bFPS = false;
|
||||
inline static int mFPS = 0;
|
||||
inline static bool bLocName = false;
|
||||
inline static bool bTransparent = false;
|
||||
inline static bool bVehHealth = false;
|
||||
inline static bool bVehSpeed = false;
|
||||
inline static bool bCpuUsage = false;
|
||||
inline static float fCpuUsage = 0.0f;
|
||||
inline static bool bMemUsage = false;
|
||||
inline static float fMemUsage = 0.0f;
|
||||
inline static std::vector<std::string> posNames = { "Custom", "Top left", "Top right", "Bottom left", "Bottom right" };
|
||||
inline static int mSelectedPos = 4; // TODO: Create Enum
|
||||
inline static float fPosX = 0.0f;
|
||||
inline static float fPosY = 0.0f;
|
||||
inline static size_t mInterval = 1000;
|
||||
inline static size_t mLastInterval = 0;
|
||||
inline static int mTotalRam = 0;
|
||||
};
|
||||
public:
|
||||
struct hotkeys
|
||||
|
@ -2,5 +2,5 @@
|
||||
#define MENU_NAME "Cheat Menu"
|
||||
#define MENU_VERSION_NUMBER "2.7"
|
||||
#define MENU_VERSION MENU_VERSION_NUMBER"-beta"
|
||||
#define BUILD_NUMBER "20210604"
|
||||
#define BUILD_NUMBER "20210615"
|
||||
#define MENU_TITLE MENU_NAME " v" MENU_VERSION "(" BUILD_NUMBER ")"
|
@ -24,7 +24,7 @@ private:
|
||||
|
||||
inline static bool mask_loaded = false;
|
||||
inline static RwTexture* neon_texture = nullptr;
|
||||
inline static VehExtender<NeonData> VehNeon;
|
||||
inline static VehicleExtendedData<NeonData> VehNeon;
|
||||
|
||||
public:
|
||||
Neon();
|
||||
|
@ -74,7 +74,7 @@ private:
|
||||
};
|
||||
|
||||
inline static bool images_loaded = false;
|
||||
inline static VehExtender<VehData> vehdata;
|
||||
inline static VehicleExtendedData<VehData> vehdata;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -122,7 +122,7 @@ void Teleport::TeleportPlayer(bool get_marker, CVector pos, short interior_id)
|
||||
Command<Commands::SET_AREA_VISIBLE>(interior_id);
|
||||
}
|
||||
|
||||
void Teleport::TeleportToLocation(std::string& rootkey, std::string& loc_name,std::string& loc)
|
||||
void Teleport::TeleportToLocation(std::string& rootkey, std::string& bLocName,std::string& loc)
|
||||
{
|
||||
try {
|
||||
int interior = 0;
|
||||
@ -193,7 +193,7 @@ void Teleport::Draw()
|
||||
|
||||
ImGui::Spacing();
|
||||
|
||||
if (ImGui::Button("Teleport to coord", Ui::GetSize(2)))
|
||||
if (ImGui::Button("Teleport to bCoord", Ui::GetSize(2)))
|
||||
{
|
||||
std::stringstream ss(input_buffer);
|
||||
std::string temp;
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
|
||||
static void Draw();
|
||||
static void TeleportPlayer(bool get_marker = false, CVector pos = CVector(0, 0, 0), short interior_id = 0);
|
||||
static void TeleportToLocation(std::string& rootkey, std::string& loc_name, std::string& loc);
|
||||
static void TeleportToLocation(std::string& rootkey, std::string& bLocName, std::string& loc);
|
||||
static void RemoveTeleportEntry(std::string& rootkey, std::string& key, std::string& val);
|
||||
|
||||
};
|
@ -2,7 +2,6 @@
|
||||
#include "Updater.h"
|
||||
#include "Ui.h"
|
||||
#include "MenuInfo.h"
|
||||
#include "..\Depend\zip\zip.h"
|
||||
|
||||
void Updater::CheckForUpdate()
|
||||
{
|
||||
@ -32,63 +31,6 @@ void Updater::CheckForUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
// void Updater::DownloadUpdate()
|
||||
// {
|
||||
// std::string link = "https://github.com/user-grinch/Cheat-Menu/releases/download/" + latest_version + "/CheatMenu.zip";
|
||||
// char* path = PLUGIN_PATH((char*)"update.zip");
|
||||
// HRESULT res = S_OK;//URLDownloadToFile(NULL, link.c_str(), path, 0, NULL);
|
||||
|
||||
// if (res == E_OUTOFMEMORY || res == INET_E_DOWNLOAD_FAILURE)
|
||||
// {
|
||||
// CHud::SetHelpMessage("Failed download update",false,false,false);
|
||||
// state = UPDATER_IDLE;
|
||||
// return;
|
||||
// }
|
||||
// CHud::SetHelpMessage("Update downloaded successfully.",false,false,false);
|
||||
// state = UPDATER_DOWNLOADED;
|
||||
// }
|
||||
|
||||
// void Updater::InstallUpdate()
|
||||
// {
|
||||
// CHud::SetHelpMessage("Update in progress. Do not pause/close the game.",false,false,false);
|
||||
// Sleep(100);
|
||||
// // delete the old menu
|
||||
// std::remove(PLUGIN_PATH((char*)"CheatMenu.asi.old"));
|
||||
// std::string new_name = PLUGIN_PATH((char*)"CheatMenu.asi.old");
|
||||
// std::string old_name = PLUGIN_PATH((char*)"CheatMenu.asi");
|
||||
// std::rename(old_name.c_str(),new_name.c_str());
|
||||
// fs::remove_all(PLUGIN_PATH((char*)"CheatMenu"));
|
||||
|
||||
// std::string dir = PLUGIN_PATH((char*)"");
|
||||
// std::string file = PLUGIN_PATH((char*)"update.zip");
|
||||
// zip_extract(file.c_str(),dir.c_str(),NULL,NULL);
|
||||
// }
|
||||
|
||||
// static bool menu_loaded = false;
|
||||
// static void LoadUpdatedMenu()
|
||||
// {
|
||||
// std::string new_name = PLUGIN_PATH((char*)"CheatMenuNew.asi");
|
||||
// LoadLibrary(new_name.c_str());
|
||||
// menu_loaded = true;
|
||||
// }
|
||||
|
||||
// void Updater::FinishUpdate()
|
||||
// {
|
||||
// // kinda hacky, can't update twice on same instance ( should be unlikely anyways?)
|
||||
// std::string new_name = PLUGIN_PATH((char*)"CheatMenuNew.asi");
|
||||
// std::string old_name = PLUGIN_PATH((char*)"CheatMenu.asi");
|
||||
// std::rename(old_name.c_str(),new_name.c_str());
|
||||
|
||||
// Events::processScriptsEvent += LoadUpdatedMenu;
|
||||
|
||||
// while (!menu_loaded)
|
||||
// Sleep(1000);
|
||||
|
||||
// Events::processScriptsEvent -= LoadUpdatedMenu;
|
||||
|
||||
// std::rename(new_name.c_str(),old_name.c_str());
|
||||
// }
|
||||
|
||||
void Updater::ShowUpdateScreen()
|
||||
{
|
||||
ImGui::Dummy(ImVec2(0,20));
|
||||
@ -111,13 +53,4 @@ void Updater::ShowUpdateScreen()
|
||||
if (ImGui::Button("Download page",Ui::GetSize(2)))
|
||||
ShellExecute(NULL, "open", std::string("https://github.com/user-grinch/Cheat-Menu/releases/tag/" +
|
||||
Updater::latest_version).c_str(), NULL, NULL, SW_SHOWNORMAL);
|
||||
|
||||
// if (Updater::state == UPDATER_DOWNLOADING)
|
||||
// ImGui::Button("Downloading update...",Ui::GetSize());
|
||||
|
||||
// if (Updater::state == UPDATER_DOWNLOADED)
|
||||
// {
|
||||
// if (ImGui::Button("Update downloaded. Click to install.",Ui::GetSize()))
|
||||
// Updater::state = UPDATER_INSTALLING;
|
||||
// }
|
||||
}
|
@ -5,9 +5,6 @@ enum UPDATER_STATE
|
||||
{
|
||||
UPDATER_IDLE,
|
||||
UPDATER_CHECKING,
|
||||
UPDATER_DOWNLOADING,
|
||||
UPDATER_DOWNLOADED,
|
||||
UPDATER_INSTALLING,
|
||||
UPDATER_UPDATE_FOUND
|
||||
};
|
||||
|
||||
@ -18,8 +15,5 @@ public:
|
||||
inline static std::string latest_version = "";
|
||||
|
||||
static void CheckForUpdate();
|
||||
// static void DownloadUpdate();
|
||||
// static void InstallUpdate();
|
||||
// static void FinishUpdate();
|
||||
static void ShowUpdateScreen();
|
||||
};
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "Util.h"
|
||||
#include "../Depend/imgui/stb_image.h"
|
||||
#include <CCutsceneMgr.h>
|
||||
#include "psapi.h"
|
||||
|
||||
void Util::ClearCharTasksVehCheck(CPed* ped)
|
||||
{
|
||||
@ -256,4 +257,20 @@ RwTexture* Util::LoadTextureFromPngFile(fs::path path)
|
||||
RwTexture* texture = CreateRwTextureFromRwImage(image);
|
||||
path.stem().string().copy(texture->name, sizeof(texture->name) - 1);
|
||||
return texture;
|
||||
}
|
||||
|
||||
void Util::GetCPUUsageInit()
|
||||
{
|
||||
PdhOpenQuery(NULL, NULL, &cpuQuery);
|
||||
PdhAddEnglishCounter(cpuQuery, "\\Processor(_Total)\\% Processor Time", NULL, &cpuTotal);
|
||||
PdhCollectQueryData(cpuQuery);
|
||||
}
|
||||
|
||||
double Util::GetCurrentCPUUsage()
|
||||
{
|
||||
PDH_FMT_COUNTERVALUE counterVal;
|
||||
|
||||
PdhCollectQueryData(cpuQuery);
|
||||
PdhGetFormattedCounterValue(cpuTotal, PDH_FMT_DOUBLE, NULL, &counterVal);
|
||||
return counterVal.doubleValue;
|
||||
}
|
@ -1,4 +1,12 @@
|
||||
#pragma once
|
||||
#include "TCHAR.h"
|
||||
#include "pdh.h"
|
||||
|
||||
static PDH_HQUERY cpuQuery;
|
||||
static PDH_HCOUNTER cpuTotal;
|
||||
static ULARGE_INTEGER lastCPU, lastSysCPU, lastUserCPU;
|
||||
static int numProcessors;
|
||||
static HANDLE self;
|
||||
|
||||
class Util
|
||||
{
|
||||
@ -17,5 +25,7 @@ public:
|
||||
static std::string GetLocationName(CVector *pos);
|
||||
static void RainbowValues(int &r, int&g, int &b, float speed);
|
||||
static RwTexture* LoadTextureFromPngFile(fs::path path);
|
||||
static void GetCPUUsageInit();
|
||||
static double GetCurrentCPUUsage();
|
||||
};
|
||||
|
||||
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
VS Code extension doesn't work well with template classes
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include "CVehicle.h"
|
||||
#include "Events.h"
|
||||
|
||||
template <class T>
|
||||
class VehExtender
|
||||
{
|
||||
private:
|
||||
inline static std::vector<std::pair<CVehicle*,T>> data{};
|
||||
|
||||
public:
|
||||
static void RemoveVehEntry(CVehicle *pVeh)
|
||||
{
|
||||
for (auto it = data.begin(); it != data.end(); it++)
|
||||
{
|
||||
if (it->first == pVeh)
|
||||
{
|
||||
data.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VehExtender()
|
||||
{
|
||||
plugin::Events::vehicleDtorEvent.before += RemoveVehEntry;
|
||||
}
|
||||
~VehExtender()
|
||||
{
|
||||
plugin::Events::vehicleDtorEvent.before -= RemoveVehEntry;
|
||||
}
|
||||
VehExtender(const VehExtender&) = delete;
|
||||
|
||||
T& Get(CVehicle *pVeh)
|
||||
{
|
||||
for (auto it = data.begin(); it < data.end(); ++it)
|
||||
{
|
||||
if (it->first == pVeh)
|
||||
return it->second;
|
||||
}
|
||||
|
||||
data.push_back({pVeh, T(pVeh)});
|
||||
return data.back().second;
|
||||
}
|
||||
};
|
@ -287,39 +287,39 @@ void Visual::Draw()
|
||||
ImGui::TextWrapped("These options won't work if you got any mods that drastically changes the game hud. i.e. Mobile Hud, GTA 5 Hud etc.");
|
||||
ImGui::Spacing();
|
||||
Ui::ColorPickerAddress("Armourbar color", *(int*)0x5890FC, ImVec4(180, 25, 29, 255));
|
||||
Ui::EditAddress<float>("Armourbar posX ", 0x866B78, -999, 94, 999);
|
||||
Ui::EditAddress<float>("Armourbar posY ", 0x862D38, -999, 48, 999);
|
||||
Ui::EditAddress<float>("Armourbar fPosX ", 0x866B78, -999, 94, 999);
|
||||
Ui::EditAddress<float>("Armourbar fPosY ", 0x862D38, -999, 48, 999);
|
||||
Ui::ColorPickerAddress("Breathbar color", *(int*)0x5891EB, ImVec4(172, 203, 241, 255));
|
||||
Ui::EditAddress<float>("Breathbar posX ", *(int*)0x58F11F, -999, 94, 999);
|
||||
Ui::EditAddress<float>("Breathbar posY ", *(int*)0x58F100, -999, 62, 999);
|
||||
Ui::EditAddress<float>("Breathbar fPosX ", *(int*)0x58F11F, -999, 94, 999);
|
||||
Ui::EditAddress<float>("Breathbar fPosY ", *(int*)0x58F100, -999, 62, 999);
|
||||
Ui::ColorPickerAddress("Clock color", *(int*)0x58EBD1, ImVec4(180, 25, 29, 255));
|
||||
Ui::EditAddress<float>("Clock posX ", *(int*)0x58EC16, -999, 32, 999);
|
||||
Ui::EditAddress<float>("Clock posY ", *(int*)0x58EC04, -999, 22, 999);
|
||||
Ui::EditAddress<float>("Clock fPosX ", *(int*)0x58EC16, -999, 32, 999);
|
||||
Ui::EditAddress<float>("Clock fPosY ", *(int*)0x58EC04, -999, 22, 999);
|
||||
Ui::ColorPickerAddress("Healthbar color", *(int*)0x589331, ImVec4(180, 25, 29, 255));
|
||||
Ui::EditAddress<float>("Healthbar posX ", 0x86535C, -999, 141, 999);
|
||||
Ui::EditAddress<float>("Healthbar posY ", 0x866CA8, -999, 77, 999);
|
||||
Ui::EditAddress<float>("Healthbar fPosX ", 0x86535C, -999, 141, 999);
|
||||
Ui::EditAddress<float>("Healthbar fPosY ", 0x866CA8, -999, 77, 999);
|
||||
Ui::ColorPickerAddress("Draw menu title border color", 0xBAB240, ImVec4(0, 0, 0, 255));
|
||||
Ui::ColorPickerAddress("Money color", 0xBAB230, ImVec4(54, 104, 44, 255));
|
||||
Ui::EditAddress<float>("Money posX ", *(int*)0x58F5FC, -999, 32, 999);
|
||||
Ui::EditAddress<float>("Money posY ", 0x866C88, -999, 89, 999);
|
||||
Ui::EditAddress<float>("Money fPosX ", *(int*)0x58F5FC, -999, 32, 999);
|
||||
Ui::EditAddress<float>("Money fPosY ", 0x866C88, -999, 89, 999);
|
||||
static std::vector<Ui::NamedValue> font_outline{ { "No outline", 0 }, { "Thin outline" ,1 }, { "Default outline" ,2 } };
|
||||
Ui::EditRadioButtonAddressEx("Money font outline", 0x58F58D, font_outline);
|
||||
static std::vector<Ui::NamedValue> style{ { "Style 1", 1 }, { "Style 2" ,2 }, { "Default style" ,3 } };
|
||||
Ui::EditRadioButtonAddressEx("Money font style", 0x58F57F, style);
|
||||
Ui::EditAddress<float>("Radar Height", *(int*)0x5834F6, 0, 76, 999);
|
||||
Ui::EditAddress<float>("Radar Width", *(int*)0x5834C2, 0, 94, 999);
|
||||
Ui::EditAddress<float>("Radar posX", *(int*)0x5834D4, -999, 40, 999);
|
||||
Ui::EditAddress<float>("Radar posY", *(int*)0x583500, -999, 104, 999);
|
||||
Ui::EditAddress<float>("Radar fPosX", *(int*)0x5834D4, -999, 40, 999);
|
||||
Ui::EditAddress<float>("Radar fPosY", *(int*)0x583500, -999, 104, 999);
|
||||
Ui::EditAddress<int>("Radar zoom", 0xA444A3, 0, 0, 170);
|
||||
Ui::ColorPickerAddress("Radio station color", 0xBAB24C, ImVec4(150, 150, 150, 255));
|
||||
static std::vector<Ui::NamedValue> star_border{ { "No border", 0 }, { "Default" ,1 }, { "Bold border" ,2 } };
|
||||
Ui::EditRadioButtonAddressEx("Wanted star border", 0x58DD41, star_border);
|
||||
Ui::EditAddress<float>("Wanted posX ", *(int*)0x58DD0F, -999, 29, 999);
|
||||
Ui::EditAddress<float>("Wanted posY ", *(int*)0x58DDFC, -999, 114, 999);
|
||||
Ui::EditAddress<float>("Weapon ammo posX ", *(int*)0x58FA02, -999, 32, 999);
|
||||
Ui::EditAddress<float>("Weapon ammo posY ", *(int*)0x58F9E6, -999, 43, 999);
|
||||
Ui::EditAddress<float>("Weapon icon posX ", *(int*)0x58F927, -999, 32, 999);
|
||||
Ui::EditAddress<float>("Weapon icon posY ", *(int*)0x58F913, -999, 20, 999);
|
||||
Ui::EditAddress<float>("Wanted fPosX ", *(int*)0x58DD0F, -999, 29, 999);
|
||||
Ui::EditAddress<float>("Wanted fPosY ", *(int*)0x58DDFC, -999, 114, 999);
|
||||
Ui::EditAddress<float>("Weapon ammo fPosX ", *(int*)0x58FA02, -999, 32, 999);
|
||||
Ui::EditAddress<float>("Weapon ammo fPosY ", *(int*)0x58F9E6, -999, 43, 999);
|
||||
Ui::EditAddress<float>("Weapon icon fPosX ", *(int*)0x58F927, -999, 32, 999);
|
||||
Ui::EditAddress<float>("Weapon icon fPosY ", *(int*)0x58F913, -999, 20, 999);
|
||||
|
||||
ImGui::EndChild();
|
||||
}
|
||||
|
@ -62,7 +62,6 @@
|
||||
#include "MoreEvents.h"
|
||||
#include "Json.h"
|
||||
#include "VKeys.h"
|
||||
#include "VehExtender.h"
|
||||
|
||||
// Globals
|
||||
typedef std::vector<std::pair<std::string, void(*)()>> CallbackTable;
|
||||
|
@ -43,8 +43,6 @@
|
||||
<ClInclude Include="kiero\minhook\hde\table32.h" />
|
||||
<ClInclude Include="kiero\minhook\MinHook.h" />
|
||||
<ClInclude Include="kiero\minhook\trampoline.h" />
|
||||
<ClInclude Include="zip\miniz.h" />
|
||||
<ClInclude Include="zip\zip.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="fla\IDaccess.cpp">
|
||||
@ -97,9 +95,6 @@
|
||||
<ClCompile Include="kiero\minhook\trampoline.c">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="zip\zip.c">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
|
@ -24,8 +24,6 @@
|
||||
<ClInclude Include="kiero\minhook\MinHook.h" />
|
||||
<ClInclude Include="kiero\minhook\trampoline.h" />
|
||||
<ClInclude Include="kiero\kiero.h" />
|
||||
<ClInclude Include="zip\miniz.h" />
|
||||
<ClInclude Include="zip\zip.h" />
|
||||
<ClInclude Include="json.hpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@ -45,6 +43,5 @@
|
||||
<ClCompile Include="kiero\minhook\hook.c" />
|
||||
<ClCompile Include="kiero\minhook\trampoline.c" />
|
||||
<ClCompile Include="kiero\kiero.cpp" />
|
||||
<ClCompile Include="zip\zip.c" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -6381,7 +6381,7 @@ typedef struct
|
||||
stbi_uc *out; // output buffer (always 4 components)
|
||||
stbi_uc *background; // The current "background" as far as a gif is concerned
|
||||
stbi_uc *history;
|
||||
int flags, bgindex, ratio, transparent, eflags;
|
||||
int flags, bgindex, ratio, bTransparent, eflags;
|
||||
stbi_uc pal[256][4];
|
||||
stbi_uc lpal[256][4];
|
||||
stbi__gif_lzw codes[8192];
|
||||
@ -6439,7 +6439,7 @@ static int stbi__gif_header(stbi__context *s, stbi__gif *g, int *comp, int is_in
|
||||
g->flags = stbi__get8(s);
|
||||
g->bgindex = stbi__get8(s);
|
||||
g->ratio = stbi__get8(s);
|
||||
g->transparent = -1;
|
||||
g->bTransparent = -1;
|
||||
|
||||
if (g->w > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)");
|
||||
if (g->h > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)");
|
||||
@ -6697,7 +6697,7 @@ static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, i
|
||||
}
|
||||
|
||||
if (g->lflags & 0x80) {
|
||||
stbi__gif_parse_colortable(s,g->lpal, 2 << (g->lflags & 7), g->eflags & 0x01 ? g->transparent : -1);
|
||||
stbi__gif_parse_colortable(s,g->lpal, 2 << (g->lflags & 7), g->eflags & 0x01 ? g->bTransparent : -1);
|
||||
g->color_table = (stbi_uc *) g->lpal;
|
||||
} else if (g->flags & 0x80) {
|
||||
g->color_table = (stbi_uc *) g->pal;
|
||||
@ -6733,18 +6733,18 @@ static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, i
|
||||
g->delay = 10 * stbi__get16le(s); // delay - 1/100th of a second, saving as 1/1000ths.
|
||||
|
||||
// unset old transparent
|
||||
if (g->transparent >= 0) {
|
||||
g->pal[g->transparent][3] = 255;
|
||||
if (g->bTransparent >= 0) {
|
||||
g->pal[g->bTransparent][3] = 255;
|
||||
}
|
||||
if (g->eflags & 0x01) {
|
||||
g->transparent = stbi__get8(s);
|
||||
if (g->transparent >= 0) {
|
||||
g->pal[g->transparent][3] = 0;
|
||||
g->bTransparent = stbi__get8(s);
|
||||
if (g->bTransparent >= 0) {
|
||||
g->pal[g->bTransparent][3] = 0;
|
||||
}
|
||||
} else {
|
||||
// don't need transparent
|
||||
stbi__skip(s, 1);
|
||||
g->transparent = -1;
|
||||
g->bTransparent = -1;
|
||||
}
|
||||
} else {
|
||||
stbi__skip(s, len);
|
||||
|
6874
Depend/zip/miniz.h
6874
Depend/zip/miniz.h
File diff suppressed because it is too large
Load Diff
1482
Depend/zip/zip.c
1482
Depend/zip/zip.c
File diff suppressed because it is too large
Load Diff
351
Depend/zip/zip.h
351
Depend/zip/zip.h
@ -1,351 +0,0 @@
|
||||
/*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef ZIP_H
|
||||
#define ZIP_H
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if !defined(_POSIX_C_SOURCE) && defined(_MSC_VER)
|
||||
// 64-bit Windows is the only mainstream platform
|
||||
// where sizeof(long) != sizeof(void*)
|
||||
#ifdef _WIN64
|
||||
typedef long long ssize_t; /* byte count or error */
|
||||
#else
|
||||
typedef long ssize_t; /* byte count or error */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef MAX_PATH
|
||||
#define MAX_PATH 32767 /* # chars in a path name including NULL */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @mainpage
|
||||
*
|
||||
* Documenation for @ref zip.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup zip
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Default zip compression level.
|
||||
*/
|
||||
|
||||
#define ZIP_DEFAULT_COMPRESSION_LEVEL 6
|
||||
|
||||
/**
|
||||
* @struct zip_t
|
||||
*
|
||||
* This data structure is used throughout the library to represent zip archive -
|
||||
* forward declaration.
|
||||
*/
|
||||
struct zip_t;
|
||||
|
||||
/**
|
||||
* Opens zip archive with compression level using the given mode.
|
||||
*
|
||||
* @param zipname zip archive file name.
|
||||
* @param level compression level (0-9 are the standard zlib-style levels).
|
||||
* @param mode file access mode.
|
||||
* - 'r': opens a file for reading/extracting (the file must exists).
|
||||
* - 'w': creates an empty file for writing.
|
||||
* - 'a': appends to an existing archive.
|
||||
*
|
||||
* @return the zip archive handler or NULL on error
|
||||
*/
|
||||
extern struct zip_t *zip_open(const char *zipname, int level, char mode);
|
||||
|
||||
/**
|
||||
* Closes the zip archive, releases resources - always finalize.
|
||||
*
|
||||
* @param zip zip archive handler.
|
||||
*/
|
||||
extern void zip_close(struct zip_t *zip);
|
||||
|
||||
/**
|
||||
* Determines if the archive has a zip64 end of central directory headers.
|
||||
*
|
||||
* @param zip zip archive handler.
|
||||
*
|
||||
* @return the return code - 1 (true), 0 (false), negative number (< 0) on
|
||||
* error.
|
||||
*/
|
||||
extern int zip_is64(struct zip_t *zip);
|
||||
|
||||
/**
|
||||
* Opens an entry by name in the zip archive.
|
||||
*
|
||||
* For zip archive opened in 'w' or 'a' mode the function will append
|
||||
* a new entry. In readonly mode the function tries to locate the entry
|
||||
* in global dictionary.
|
||||
*
|
||||
* @param zip zip archive handler.
|
||||
* @param entryname an entry name in local dictionary.
|
||||
*
|
||||
* @return the return code - 0 on success, negative number (< 0) on error.
|
||||
*/
|
||||
extern int zip_entry_open(struct zip_t *zip, const char *entryname);
|
||||
|
||||
/**
|
||||
* Opens a new entry by index in the zip archive.
|
||||
*
|
||||
* This function is only valid if zip archive was opened in 'r' (readonly) mode.
|
||||
*
|
||||
* @param zip zip archive handler.
|
||||
* @param index index in local dictionary.
|
||||
*
|
||||
* @return the return code - 0 on success, negative number (< 0) on error.
|
||||
*/
|
||||
extern int zip_entry_openbyindex(struct zip_t *zip, int index);
|
||||
|
||||
/**
|
||||
* Closes a zip entry, flushes buffer and releases resources.
|
||||
*
|
||||
* @param zip zip archive handler.
|
||||
*
|
||||
* @return the return code - 0 on success, negative number (< 0) on error.
|
||||
*/
|
||||
extern int zip_entry_close(struct zip_t *zip);
|
||||
|
||||
/**
|
||||
* Returns a local name of the current zip entry.
|
||||
*
|
||||
* The main difference between user's entry name and local entry name
|
||||
* is optional relative path.
|
||||
* Following .ZIP File Format Specification - the path stored MUST not contain
|
||||
* a drive or device letter, or a leading slash.
|
||||
* All slashes MUST be forward slashes '/' as opposed to backwards slashes '\'
|
||||
* for compatibility with Amiga and UNIX file systems etc.
|
||||
*
|
||||
* @param zip: zip archive handler.
|
||||
*
|
||||
* @return the pointer to the current zip entry name, or NULL on error.
|
||||
*/
|
||||
extern const char *zip_entry_name(struct zip_t *zip);
|
||||
|
||||
/**
|
||||
* Returns an index of the current zip entry.
|
||||
*
|
||||
* @param zip zip archive handler.
|
||||
*
|
||||
* @return the index on success, negative number (< 0) on error.
|
||||
*/
|
||||
extern int zip_entry_index(struct zip_t *zip);
|
||||
|
||||
/**
|
||||
* Determines if the current zip entry is a directory entry.
|
||||
*
|
||||
* @param zip zip archive handler.
|
||||
*
|
||||
* @return the return code - 1 (true), 0 (false), negative number (< 0) on
|
||||
* error.
|
||||
*/
|
||||
extern int zip_entry_isdir(struct zip_t *zip);
|
||||
|
||||
/**
|
||||
* Returns an uncompressed size of the current zip entry.
|
||||
*
|
||||
* @param zip zip archive handler.
|
||||
*
|
||||
* @return the uncompressed size in bytes.
|
||||
*/
|
||||
extern unsigned long long zip_entry_size(struct zip_t *zip);
|
||||
|
||||
/**
|
||||
* Returns CRC-32 checksum of the current zip entry.
|
||||
*
|
||||
* @param zip zip archive handler.
|
||||
*
|
||||
* @return the CRC-32 checksum.
|
||||
*/
|
||||
extern unsigned int zip_entry_crc32(struct zip_t *zip);
|
||||
|
||||
/**
|
||||
* Compresses an input buffer for the current zip entry.
|
||||
*
|
||||
* @param zip zip archive handler.
|
||||
* @param buf input buffer.
|
||||
* @param bufsize input buffer size (in bytes).
|
||||
*
|
||||
* @return the return code - 0 on success, negative number (< 0) on error.
|
||||
*/
|
||||
extern int zip_entry_write(struct zip_t *zip, const void *buf, size_t bufsize);
|
||||
|
||||
/**
|
||||
* Compresses a file for the current zip entry.
|
||||
*
|
||||
* @param zip zip archive handler.
|
||||
* @param filename input file.
|
||||
*
|
||||
* @return the return code - 0 on success, negative number (< 0) on error.
|
||||
*/
|
||||
extern int zip_entry_fwrite(struct zip_t *zip, const char *filename);
|
||||
|
||||
/**
|
||||
* Extracts the current zip entry into output buffer.
|
||||
*
|
||||
* The function allocates sufficient memory for a output buffer.
|
||||
*
|
||||
* @param zip zip archive handler.
|
||||
* @param buf output buffer.
|
||||
* @param bufsize output buffer size (in bytes).
|
||||
*
|
||||
* @note remember to release memory allocated for a output buffer.
|
||||
* for large entries, please take a look at zip_entry_extract function.
|
||||
*
|
||||
* @return the return code - the number of bytes actually read on success.
|
||||
* Otherwise a -1 on error.
|
||||
*/
|
||||
extern ssize_t zip_entry_read(struct zip_t *zip, void **buf, size_t *bufsize);
|
||||
|
||||
/**
|
||||
* Extracts the current zip entry into a memory buffer using no memory
|
||||
* allocation.
|
||||
*
|
||||
* @param zip zip archive handler.
|
||||
* @param buf preallocated output buffer.
|
||||
* @param bufsize output buffer size (in bytes).
|
||||
*
|
||||
* @note ensure supplied output buffer is large enough.
|
||||
* zip_entry_size function (returns uncompressed size for the current
|
||||
* entry) can be handy to estimate how big buffer is needed. for large
|
||||
* entries, please take a look at zip_entry_extract function.
|
||||
*
|
||||
* @return the return code - the number of bytes actually read on success.
|
||||
* Otherwise a -1 on error (e.g. bufsize is not large enough).
|
||||
*/
|
||||
extern ssize_t zip_entry_noallocread(struct zip_t *zip, void *buf,
|
||||
size_t bufsize);
|
||||
|
||||
/**
|
||||
* Extracts the current zip entry into output file.
|
||||
*
|
||||
* @param zip zip archive handler.
|
||||
* @param filename output file.
|
||||
*
|
||||
* @return the return code - 0 on success, negative number (< 0) on error.
|
||||
*/
|
||||
extern int zip_entry_fread(struct zip_t *zip, const char *filename);
|
||||
|
||||
/**
|
||||
* Extracts the current zip entry using a callback function (on_extract).
|
||||
*
|
||||
* @param zip zip archive handler.
|
||||
* @param on_extract callback function.
|
||||
* @param arg opaque pointer (optional argument, which you can pass to the
|
||||
* on_extract callback)
|
||||
*
|
||||
* @return the return code - 0 on success, negative number (< 0) on error.
|
||||
*/
|
||||
extern int
|
||||
zip_entry_extract(struct zip_t *zip,
|
||||
size_t (*on_extract)(void *arg, unsigned long long offset,
|
||||
const void *data, size_t size),
|
||||
void *arg);
|
||||
|
||||
/**
|
||||
* Returns the number of all entries (files and directories) in the zip archive.
|
||||
*
|
||||
* @param zip zip archive handler.
|
||||
*
|
||||
* @return the return code - the number of entries on success, negative number
|
||||
* (< 0) on error.
|
||||
*/
|
||||
extern int zip_total_entries(struct zip_t *zip);
|
||||
|
||||
/**
|
||||
* Creates a new archive and puts files into a single zip archive.
|
||||
*
|
||||
* @param zipname zip archive file.
|
||||
* @param filenames input files.
|
||||
* @param len: number of input files.
|
||||
*
|
||||
* @return the return code - 0 on success, negative number (< 0) on error.
|
||||
*/
|
||||
extern int zip_create(const char *zipname, const char *filenames[], size_t len);
|
||||
|
||||
/**
|
||||
* Extracts a zip archive file into directory.
|
||||
*
|
||||
* If on_extract_entry is not NULL, the callback will be called after
|
||||
* successfully extracted each zip entry.
|
||||
* Returning a negative value from the callback will cause abort and return an
|
||||
* error. The last argument (void *arg) is optional, which you can use to pass
|
||||
* data to the on_extract_entry callback.
|
||||
*
|
||||
* @param zipname zip archive file.
|
||||
* @param dir output directory.
|
||||
* @param on_extract_entry on extract callback.
|
||||
* @param arg opaque pointer.
|
||||
*
|
||||
* @return the return code - 0 on success, negative number (< 0) on error.
|
||||
*/
|
||||
extern int zip_extract(const char *zipname, const char *dir,
|
||||
int (*on_extract_entry)(const char *filename, void *arg),
|
||||
void *arg);
|
||||
|
||||
/**
|
||||
* Extracts a zip archive stream into directory.
|
||||
*
|
||||
* If on_extract is not NULL, the callback will be called after
|
||||
* successfully extracted each zip entry.
|
||||
* Returning a negative value from the callback will cause abort and return an
|
||||
* error. The last argument (void *arg) is optional, which you can use to pass
|
||||
* data to the on_extract callback.
|
||||
*
|
||||
* @param stream zip archive stream.
|
||||
* @param size stream size.
|
||||
* @param dir output directory.
|
||||
* @param on_extract on extract callback.
|
||||
* @param arg opaque pointer.
|
||||
*
|
||||
* @return the return code - 0 on success, negative number (< 0) on error.
|
||||
*/
|
||||
extern int zip_extract_stream(const char *stream, size_t size, const char *dir,
|
||||
int (*on_extract)(const char *filename,
|
||||
void *arg),
|
||||
void *arg);
|
||||
|
||||
/**
|
||||
* Opens zip archive stream into memory.
|
||||
*
|
||||
* @param stream zip archive stream.
|
||||
* @param size stream size.
|
||||
*
|
||||
* @return the zip archive handler or NULL on error
|
||||
*/
|
||||
extern struct zip_t *zip_open_stream(const char *stream, size_t size);
|
||||
|
||||
/**
|
||||
* Deletes zip archive entries.
|
||||
*
|
||||
* @param zip zip archive handler.
|
||||
* @param entries array of zip archive entries to be deleted.
|
||||
* @param len the number of entries to be deleted.
|
||||
* @return the number of deleted entries, or negative number (< 0) on error.
|
||||
*/
|
||||
extern int zip_entries_delete(struct zip_t *zip, char *const entries[],
|
||||
size_t len);
|
||||
/** @} */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -32,7 +32,6 @@ You'll need to install Visual Studio 2019 (v142), [DirectX9 SDK](https://www.mic
|
||||
2. [Kiero](https://github.com/Rebzzel/kiero)
|
||||
3. [MinHook](https://github.com/TsudaKageyu/minhook)
|
||||
4. [Plugin SDK](https://github.com/DK22Pac/plugin-sdk)
|
||||
5. [Zip](https://github.com/kuba--/zip)
|
||||
|
||||
## Images
|
||||
<details>
|
||||
|
Loading…
Reference in New Issue
Block a user