Refactor code & cleanup
This commit is contained in:
parent
48b519af03
commit
6044deb156
@ -32,12 +32,12 @@ Be sure to check [here](https://github.com/user-grinch/Cheat-Menu/issues/48) to
|
|||||||
|
|
||||||
## Incompatible Mods
|
## Incompatible Mods
|
||||||
### GTA SA
|
### GTA SA
|
||||||
1. **ENB/ SA_DirectX 2.0** - **FIX:** disable Effect/ Enable water
|
1. **ENB/ SA_DirectX 2.0** **FIX:** Disable Effect/ Enable water
|
||||||
2. **MSI Afterburner** - **FIX:** Enable Stealth mode in rivatuner
|
2. **MSI Afterburner** **FIX:** Enable Stealth mode in rivatuner
|
||||||
3. **GTA Underground**
|
3. **GTA Underground**
|
||||||
|
|
||||||
### GTA III
|
### GTA III
|
||||||
1. SilentPatch **ddraw.dll** component. Just delete it for now.
|
1. SilentPatch **ddraw.dll** component. **FIX:** Delete ddraw.dll file for now
|
||||||
|
|
||||||
Let me know if you mind more.
|
Let me know if you mind more.
|
||||||
|
|
||||||
|
@ -34,13 +34,18 @@ void CheatMenu::DrawWindow()
|
|||||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,
|
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,
|
||||||
ImVec2(ImGui::GetWindowWidth() / 85, ImGui::GetWindowHeight() / 200));
|
ImVec2(ImGui::GetWindowWidth() / 85, ImGui::GetWindowHeight() / 200));
|
||||||
|
|
||||||
if (Updater::m_State == UPDATER_UPDATE_FOUND)
|
if (Updater::IsUpdateAvailable())
|
||||||
{
|
{
|
||||||
Updater::ShowUpdateScreen();
|
ShowUpdateScreen();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Ui::DrawHeaders(header);
|
Ui::DrawHeaders(header);
|
||||||
|
|
||||||
|
if (Ui::m_HeaderId == -1)
|
||||||
|
{
|
||||||
|
ShowWelcomeScreen();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_bSizeChangedExternal)
|
if (m_bSizeChangedExternal)
|
||||||
@ -113,6 +118,74 @@ CheatMenu::CheatMenu()
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CheatMenu::ShowWelcomeScreen()
|
||||||
|
{
|
||||||
|
ImGui::BeginChild("WelcomeScreen");
|
||||||
|
ImGui::NewLine();
|
||||||
|
|
||||||
|
Ui::CenterdText("Welcome to Cheat Menu");
|
||||||
|
Ui::CenterdText("Author: Grinch_");
|
||||||
|
|
||||||
|
ImGui::NewLine();
|
||||||
|
ImGui::TextWrapped("Please ensure you have the latest version from GitHub.");
|
||||||
|
ImGui::NewLine();
|
||||||
|
if (ImGui::Button("Discord server", ImVec2(Ui::GetSize(2))))
|
||||||
|
{
|
||||||
|
ShellExecute(nullptr, "open", DISCORD_INVITE, nullptr, nullptr, SW_SHOWNORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::SameLine();
|
||||||
|
|
||||||
|
if (ImGui::Button("GitHub repo", ImVec2(Ui::GetSize(2))))
|
||||||
|
{
|
||||||
|
ShellExecute(nullptr, "open", GITHUB_LINK, nullptr, nullptr, SW_SHOWNORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::NewLine();
|
||||||
|
ImGui::TextWrapped("If you find bugs or have suggestions, you can let me know on discord :)");
|
||||||
|
ImGui::Dummy(ImVec2(0, 30));
|
||||||
|
Ui::CenterdText("Copyright Grinch_ 2019-2022. All rights reserved.");
|
||||||
|
ImGui::EndChild();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CheatMenu::ShowUpdateScreen()
|
||||||
|
{
|
||||||
|
ImGui::BeginChild("UPdateScreen");
|
||||||
|
std::string ver = Updater::GetUpdateVersion();
|
||||||
|
ImGui::Dummy(ImVec2(0, 20));
|
||||||
|
Ui::CenterdText("A new version of the mod is available.");
|
||||||
|
Ui::CenterdText(std::string("Current version: ") + MENU_VERSION);
|
||||||
|
Ui::CenterdText("Latest version: " + ver);
|
||||||
|
ImGui::Dummy(ImVec2(0, 10));
|
||||||
|
ImGui::TextWrapped("In order to keep using the menu, you need to update to the latest version."
|
||||||
|
" This is to ensure everything is using the most up-to-date version.");
|
||||||
|
ImGui::Dummy(ImVec2(0, 10));
|
||||||
|
ImGui::TextWrapped("To know what changes are made or to download, click on the \"Download page\" button."
|
||||||
|
" Follow the instructions there. If you're still having issues, let me know on discord.");
|
||||||
|
|
||||||
|
ImGui::Dummy(ImVec2(0, 5));
|
||||||
|
if (ImGui::Button("Discord server", ImVec2(Ui::GetSize(3))))
|
||||||
|
{
|
||||||
|
ShellExecute(NULL, "open", DISCORD_INVITE, NULL, NULL, SW_SHOWNORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::SameLine();
|
||||||
|
|
||||||
|
if (ImGui::Button("Download page", Ui::GetSize(3)))
|
||||||
|
{
|
||||||
|
ShellExecute(NULL, "open", std::string("https://github.com/user-grinch/Cheat-Menu/releases/tag/" +
|
||||||
|
ver).c_str(), NULL, NULL, SW_SHOWNORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::SameLine();
|
||||||
|
|
||||||
|
if (ImGui::Button("Hide page", Ui::GetSize(3)))
|
||||||
|
{
|
||||||
|
Updater::ResetUpdaterState();
|
||||||
|
}
|
||||||
|
ImGui::EndChild();
|
||||||
|
}
|
||||||
|
|
||||||
void CheatMenu::ApplyStyle()
|
void CheatMenu::ApplyStyle()
|
||||||
{
|
{
|
||||||
ImGuiStyle* style = &ImGui::GetStyle();
|
ImGuiStyle* style = &ImGui::GetStyle();
|
||||||
@ -141,11 +214,11 @@ void CheatMenu::ApplyStyle()
|
|||||||
style->Colors[ImGuiCol_TextDisabled] = ImVec4(0.35f, 0.33f, 0.3f, 1.00f);
|
style->Colors[ImGuiCol_TextDisabled] = ImVec4(0.35f, 0.33f, 0.3f, 1.00f);
|
||||||
style->Colors[ImGuiCol_WindowBg] = ImVec4(0.06f, 0.05f, 0.06f, 0.95f);
|
style->Colors[ImGuiCol_WindowBg] = ImVec4(0.06f, 0.05f, 0.06f, 0.95f);
|
||||||
style->Colors[ImGuiCol_ChildBg] = ImVec4(0.0f, 0.0f, 0.0f, 0.0f);
|
style->Colors[ImGuiCol_ChildBg] = ImVec4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
style->Colors[ImGuiCol_PopupBg] = ImVec4(0.07f, 0.07f, 0.09f, 0.95f);
|
style->Colors[ImGuiCol_PopupBg] = ImVec4(0.06f, 0.05f, 0.06f, 0.95f);
|
||||||
style->Colors[ImGuiCol_Border] = ImVec4(0.12f, 0.12f, 0.12f, 1.0f);
|
style->Colors[ImGuiCol_Border] = ImVec4(0.12f, 0.12f, 0.12f, 1.0f);
|
||||||
style->Colors[ImGuiCol_BorderShadow] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
|
style->Colors[ImGuiCol_BorderShadow] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
|
||||||
style->Colors[ImGuiCol_FrameBg] = ImVec4(0.15f, 0.15f, 0.15f, 0.95f);
|
style->Colors[ImGuiCol_FrameBg] = ImVec4(0.15f, 0.15f, 0.15f, 0.95f);
|
||||||
style->Colors[ImGuiCol_FrameBgHovered] = ImVec4(0.17f, 0.17f, 0.17f, 1.00f);
|
style->Colors[ImGuiCol_FrameBgHovered] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f);
|
||||||
style->Colors[ImGuiCol_FrameBgActive] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
|
style->Colors[ImGuiCol_FrameBgActive] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
|
||||||
style->Colors[ImGuiCol_TitleBg] = ImVec4(0.12f, 0.12f, 0.12f, 0.94f);
|
style->Colors[ImGuiCol_TitleBg] = ImVec4(0.12f, 0.12f, 0.12f, 0.94f);
|
||||||
style->Colors[ImGuiCol_TitleBgCollapsed] = ImVec4(1.00f, 0.98f, 0.95f, 0.75f);
|
style->Colors[ImGuiCol_TitleBgCollapsed] = ImVec4(1.00f, 0.98f, 0.95f, 0.75f);
|
||||||
@ -160,16 +233,16 @@ void CheatMenu::ApplyStyle()
|
|||||||
style->Colors[ImGuiCol_SliderGrabActive] = ImVec4(0.80f, 0.80f, 0.83f, 0.31f);
|
style->Colors[ImGuiCol_SliderGrabActive] = ImVec4(0.80f, 0.80f, 0.83f, 0.31f);
|
||||||
style->Colors[ImGuiCol_Separator] = ImVec4(0.15f, 0.15f, 0.15f, 0.95f);
|
style->Colors[ImGuiCol_Separator] = ImVec4(0.15f, 0.15f, 0.15f, 0.95f);
|
||||||
style->Colors[ImGuiCol_Button] = ImVec4(0.15f, 0.15f, 0.15f, 0.95f);
|
style->Colors[ImGuiCol_Button] = ImVec4(0.15f, 0.15f, 0.15f, 0.95f);
|
||||||
style->Colors[ImGuiCol_ButtonHovered] = ImVec4(0.17f, 0.17f, 0.17f, 1.00f);
|
style->Colors[ImGuiCol_ButtonHovered] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f);
|
||||||
style->Colors[ImGuiCol_ButtonActive] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
|
style->Colors[ImGuiCol_ButtonActive] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
|
||||||
style->Colors[ImGuiCol_Tab] = ImVec4(0.15f, 0.15f, 0.15f, 0.95f);
|
style->Colors[ImGuiCol_Tab] = ImVec4(0.15f, 0.15f, 0.15f, 0.95f);
|
||||||
style->Colors[ImGuiCol_TabHovered] = ImVec4(0.17f, 0.17f, 0.17f, 1.00f);
|
style->Colors[ImGuiCol_TabHovered] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f);
|
||||||
style->Colors[ImGuiCol_TabActive] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
|
style->Colors[ImGuiCol_TabActive] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
|
||||||
style->Colors[ImGuiCol_Header] = ImVec4(0.0f, 0.0f, 0.0f, 0.0f);
|
style->Colors[ImGuiCol_Header] = ImVec4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
style->Colors[ImGuiCol_HeaderHovered] = ImVec4(0.17f, 0.17f, 0.17f, 1.00f);
|
style->Colors[ImGuiCol_HeaderHovered] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f);
|
||||||
style->Colors[ImGuiCol_HeaderActive] = ImVec4(0.06f, 0.05f, 0.07f, 1.00f);
|
style->Colors[ImGuiCol_HeaderActive] = ImVec4(0.06f, 0.05f, 0.07f, 1.00f);
|
||||||
style->Colors[ImGuiCol_ResizeGrip] = ImVec4(0.12f, 0.12f, 0.12f, 0.00f);
|
style->Colors[ImGuiCol_ResizeGrip] = ImVec4(0.12f, 0.12f, 0.12f, 0.00f);
|
||||||
style->Colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.17f, 0.17f, 0.17f, 1.00f);
|
style->Colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f);
|
||||||
style->Colors[ImGuiCol_ResizeGripActive] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
|
style->Colors[ImGuiCol_ResizeGripActive] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
|
||||||
style->Colors[ImGuiCol_PlotLines] = ImVec4(0.40f, 0.39f, 0.38f, 0.63f);
|
style->Colors[ImGuiCol_PlotLines] = ImVec4(0.40f, 0.39f, 0.38f, 0.63f);
|
||||||
style->Colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.25f, 1.00f, 0.00f, 1.00f);
|
style->Colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.25f, 1.00f, 0.00f, 1.00f);
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
Required:
|
Required:
|
||||||
DirectX 9 SDK
|
DirectX 9 SDK
|
||||||
Plugin SDK
|
Plugin SDK
|
||||||
Build Tools 2019 (v142)
|
Build Tools 2022 (v143)
|
||||||
Windows SDK
|
Windows SDK
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -36,6 +36,8 @@ private:
|
|||||||
|
|
||||||
static void ApplyStyle();
|
static void ApplyStyle();
|
||||||
static void DrawWindow();
|
static void DrawWindow();
|
||||||
|
static void ShowUpdateScreen();
|
||||||
|
static void ShowWelcomeScreen();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CheatMenu();
|
CheatMenu();
|
||||||
|
@ -72,18 +72,14 @@ void MenuThread(void* param)
|
|||||||
|
|
||||||
if (lastCheckDate != tstruct.tm_mday)
|
if (lastCheckDate != tstruct.tm_mday)
|
||||||
{
|
{
|
||||||
Updater::CheckForUpdate();
|
Updater::CheckUpdate();
|
||||||
gConfig.SetValue("config.last_update_checked", tstruct.tm_mday);
|
gConfig.SetValue("config.last_update_checked", tstruct.tm_mday);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
Sleep(5000);
|
Sleep(5000);
|
||||||
|
Updater::Process();
|
||||||
if (Updater::m_State == UPDATER_CHECKING)
|
|
||||||
{
|
|
||||||
Updater::CheckForUpdate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,8 +93,8 @@ BOOL WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gLog << "Error: Unknown game version. GTA " << BY_GAME("SA v1.0 US Hoodlum", "GTA VC v1.0 EN", "GTA III v1.0 EN") << " is required." << std::endl;
|
gLog << "Error: Unknown game version. GTA " << BY_GAME("SA v1.0 US Hoodlum", "VC v1.0 EN", "III v1.0 EN") << " is required." << std::endl;
|
||||||
MessageBox(HWND_DESKTOP, "Unknown game version. GTA " BY_GAME("SA v1.0 US Hoodlum", "GTA VC v1.0 EN", "GTA III v1.0 EN") " is required.", "CheatMenu", MB_ICONERROR);
|
MessageBox(HWND_DESKTOP, "Unknown game version. GTA " BY_GAME("SA v1.0 US Hoodlum", "VC v1.0 EN", "III v1.0 EN") " is required.", "CheatMenu", MB_ICONERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "filehandler.h"
|
#include "filehandler.h"
|
||||||
#include "visual.h"
|
|
||||||
|
|
||||||
// TODO: Clean up this mess, use structures instead?
|
// TODO: Clean up this mess, use structures instead?
|
||||||
void FileHandler::GenerateHandlingFile(int pHandling, std::map<int, std::string>& storeMap)
|
void FileHandler::GenerateHandlingFile(int pHandling, std::map<int, std::string>& storeMap)
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
FileHandler class
|
||||||
|
Handles files IO and processing
|
||||||
|
*/
|
||||||
class FileHandler
|
class FileHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
17
src/menu.cpp
17
src/menu.cpp
@ -24,7 +24,7 @@ Menu::Menu()
|
|||||||
m_Overlay::bMemUsage = gConfig.GetValue("overlay.mem_usage", false);
|
m_Overlay::bMemUsage = gConfig.GetValue("overlay.mem_usage", false);
|
||||||
m_Overlay::bVehHealth = gConfig.GetValue("overlay.veh_health", false);
|
m_Overlay::bVehHealth = gConfig.GetValue("overlay.veh_health", false);
|
||||||
m_Overlay::bVehSpeed = gConfig.GetValue("overlay.veh_speed", false);
|
m_Overlay::bVehSpeed = gConfig.GetValue("overlay.veh_speed", false);
|
||||||
m_Overlay::mSelectedPos = (DISPLAY_POS)gConfig.GetValue("overlay.selected_pos", (int)DISPLAY_POS::BOTTOM_RIGHT);
|
m_Overlay::mSelectedPos = (DisplayPos)gConfig.GetValue("overlay.selected_pos", (int)DisplayPos::BOTTOM_RIGHT);
|
||||||
m_Overlay::fPosX = gConfig.GetValue("overlay.pox", 0);
|
m_Overlay::fPosX = gConfig.GetValue("overlay.pox", 0);
|
||||||
m_Overlay::fPosY = gConfig.GetValue("overlay.posy", 0);
|
m_Overlay::fPosY = gConfig.GetValue("overlay.posy", 0);
|
||||||
m_Overlay::textColor[0] = gConfig.GetValue("overlay.text_color.r", 1.0f);
|
m_Overlay::textColor[0] = gConfig.GetValue("overlay.text_color.r", 1.0f);
|
||||||
@ -91,7 +91,7 @@ void Menu::DrawOverlay()
|
|||||||
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize |
|
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize |
|
||||||
ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav;
|
ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav;
|
||||||
|
|
||||||
if (m_Overlay::mSelectedPos == DISPLAY_POS::CUSTOM)
|
if (m_Overlay::mSelectedPos == DisplayPos::CUSTOM)
|
||||||
{
|
{
|
||||||
if (m_Overlay::fPosX != NULL && m_Overlay::fPosY != NULL)
|
if (m_Overlay::fPosX != NULL && m_Overlay::fPosY != NULL)
|
||||||
{
|
{
|
||||||
@ -105,25 +105,25 @@ void Menu::DrawOverlay()
|
|||||||
window_flags |= ImGuiWindowFlags_NoMove;
|
window_flags |= ImGuiWindowFlags_NoMove;
|
||||||
ImVec2 pos, pivot;
|
ImVec2 pos, pivot;
|
||||||
|
|
||||||
if (m_Overlay::mSelectedPos == DISPLAY_POS::TOP_LEFT)
|
if (m_Overlay::mSelectedPos == DisplayPos::TOP_LEFT)
|
||||||
{
|
{
|
||||||
pos = ImVec2(offset, offset);
|
pos = ImVec2(offset, offset);
|
||||||
pivot = ImVec2(0.0f, 0.0f);
|
pivot = ImVec2(0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_Overlay::mSelectedPos == DISPLAY_POS::TOP_RIGHT)
|
if (m_Overlay::mSelectedPos == DisplayPos::TOP_RIGHT)
|
||||||
{
|
{
|
||||||
pos = ImVec2(io.DisplaySize.x - offset, offset);
|
pos = ImVec2(io.DisplaySize.x - offset, offset);
|
||||||
pivot = ImVec2(1.0f, 0.0f);
|
pivot = ImVec2(1.0f, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_Overlay::mSelectedPos == DISPLAY_POS::BOTTOM_LEFT)
|
if (m_Overlay::mSelectedPos == DisplayPos::BOTTOM_LEFT)
|
||||||
{
|
{
|
||||||
pos = ImVec2(offset, io.DisplaySize.y - offset);
|
pos = ImVec2(offset, io.DisplaySize.y - offset);
|
||||||
pivot = ImVec2(0.0f, 1.0f);
|
pivot = ImVec2(0.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_Overlay::mSelectedPos == DISPLAY_POS::BOTTOM_RIGHT)
|
if (m_Overlay::mSelectedPos == DisplayPos::BOTTOM_RIGHT)
|
||||||
{
|
{
|
||||||
pos = ImVec2(io.DisplaySize.x - offset, io.DisplaySize.y - offset);
|
pos = ImVec2(io.DisplaySize.x - offset, io.DisplaySize.y - offset);
|
||||||
pivot = ImVec2(1.0f, 1.0f);
|
pivot = ImVec2(1.0f, 1.0f);
|
||||||
@ -573,10 +573,7 @@ void Menu::Draw()
|
|||||||
|
|
||||||
if (ImGui::Button("Check update", ImVec2(Ui::GetSize(3))))
|
if (ImGui::Button("Check update", ImVec2(Ui::GetSize(3))))
|
||||||
{
|
{
|
||||||
if (Updater::m_State == UPDATER_IDLE)
|
Updater::CheckUpdate();
|
||||||
{
|
|
||||||
Updater::m_State = UPDATER_CHECKING;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
@ -4,7 +4,7 @@ class Menu
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
enum DISPLAY_POS
|
enum class DisplayPos
|
||||||
{
|
{
|
||||||
CUSTOM,
|
CUSTOM,
|
||||||
TOP_LEFT,
|
TOP_LEFT,
|
||||||
@ -30,7 +30,7 @@ private:
|
|||||||
{
|
{
|
||||||
"Custom", "Top left", "Top right", "Bottom left", "Bottom right"
|
"Custom", "Top left", "Top right", "Bottom left", "Bottom right"
|
||||||
};
|
};
|
||||||
static inline DISPLAY_POS mSelectedPos = DISPLAY_POS::BOTTOM_RIGHT;
|
static inline DisplayPos mSelectedPos = DisplayPos::BOTTOM_RIGHT;
|
||||||
static inline float fPosX;
|
static inline float fPosX;
|
||||||
static inline float fPosY;
|
static inline float fPosY;
|
||||||
static inline int mTotalRam = 0;
|
static inline int mTotalRam = 0;
|
||||||
|
40
src/neon.cpp
40
src/neon.cpp
@ -1,6 +1,5 @@
|
|||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "neon.h"
|
#include "neon.h"
|
||||||
#include "util.h"
|
|
||||||
|
|
||||||
// Neon sprite
|
// Neon sprite
|
||||||
const unsigned char neon_mask[1689] =
|
const unsigned char neon_mask[1689] =
|
||||||
@ -161,13 +160,36 @@ const unsigned char neon_mask[1689] =
|
|||||||
0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
|
0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
|
||||||
};
|
};
|
||||||
|
|
||||||
Neon::Neon()
|
// Thanks DKPac22
|
||||||
|
static RwTexture* LoadTextureFromMemory(char* data, unsigned int size)
|
||||||
{
|
{
|
||||||
Events::processScriptsEvent += [this]
|
patch::SetChar(0x7CF9CA, rwSTREAMMEMORY);
|
||||||
|
RwMemory memoryImage;
|
||||||
|
RwInt32 width, height, depth, flags;
|
||||||
|
memoryImage.start = (RwUInt8*)data;
|
||||||
|
memoryImage.length = size;
|
||||||
|
RwImage* image = RtPNGImageRead((char*)&memoryImage);
|
||||||
|
RwImageFindRasterFormat(image, 4, &width, &height, &depth, &flags);
|
||||||
|
RwRaster* raster = RwRasterCreate(width, height, depth, flags);
|
||||||
|
RwRasterSetFromImage(raster, image);
|
||||||
|
RwImageDestroy(image);
|
||||||
|
patch::SetChar(0x7CF9CA, rwSTREAMFILENAME);
|
||||||
|
|
||||||
|
return RwTextureCreate(raster);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Neon::InitHooks()
|
||||||
|
{
|
||||||
|
if (m_bInit)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Events::processScriptsEvent += []
|
||||||
{
|
{
|
||||||
if (!m_pNeonTexture)
|
if (!m_pNeonTexture)
|
||||||
{
|
{
|
||||||
m_pNeonTexture = Util::LoadTextureFromMemory((char*)neon_mask, sizeof(neon_mask));
|
m_pNeonTexture = LoadTextureFromMemory((char*)neon_mask, sizeof(neon_mask));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -208,9 +230,11 @@ Neon::Neon()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
m_bInit = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Neon::~Neon()
|
void Neon::RemoveHooks()
|
||||||
{
|
{
|
||||||
if (m_pNeonTexture)
|
if (m_pNeonTexture)
|
||||||
{
|
{
|
||||||
@ -219,7 +243,7 @@ Neon::~Neon()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Neon::IsNeonInstalled(CVehicle* pVeh)
|
bool Neon::IsInstalled(CVehicle* pVeh)
|
||||||
{
|
{
|
||||||
return m_VehNeon.Get(pVeh).m_bNeonInstalled;
|
return m_VehNeon.Get(pVeh).m_bNeonInstalled;
|
||||||
}
|
}
|
||||||
@ -234,7 +258,7 @@ void Neon::SetPulsing(CVehicle* pVeh, bool state)
|
|||||||
m_VehNeon.Get(pVeh).m_bPulsing = state;
|
m_VehNeon.Get(pVeh).m_bPulsing = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Neon::InstallNeon(CVehicle* pVeh, int red, int green, int blue)
|
void Neon::Install(CVehicle* pVeh, int red, int green, int blue)
|
||||||
{
|
{
|
||||||
CRGBA& color = m_VehNeon.Get(pVeh).m_Color;
|
CRGBA& color = m_VehNeon.Get(pVeh).m_Color;
|
||||||
|
|
||||||
@ -246,7 +270,7 @@ void Neon::InstallNeon(CVehicle* pVeh, int red, int green, int blue)
|
|||||||
m_VehNeon.Get(pVeh).m_bNeonInstalled = true;
|
m_VehNeon.Get(pVeh).m_bNeonInstalled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Neon::RemoveNeon(CVehicle* pVeh)
|
void Neon::Remove(CVehicle* pVeh)
|
||||||
{
|
{
|
||||||
m_VehNeon.Get(pVeh).m_bNeonInstalled = false;
|
m_VehNeon.Get(pVeh).m_bNeonInstalled = false;
|
||||||
}
|
}
|
||||||
|
14
src/neon.h
14
src/neon.h
@ -30,13 +30,17 @@ private:
|
|||||||
|
|
||||||
static inline RwTexture* m_pNeonTexture = nullptr; // pointer to the neon mask texture
|
static inline RwTexture* m_pNeonTexture = nullptr; // pointer to the neon mask texture
|
||||||
static inline VehicleExtendedData<NeonData> m_VehNeon;
|
static inline VehicleExtendedData<NeonData> m_VehNeon;
|
||||||
|
static inline bool m_bInit;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Neon();
|
Neon() = delete;
|
||||||
~Neon();
|
Neon(Neon&) = delete;
|
||||||
static void InstallNeon(CVehicle* veh, int red, int green, int blue);
|
|
||||||
static bool IsNeonInstalled(CVehicle* veh);
|
static void InitHooks();
|
||||||
|
static void Install(CVehicle* veh, int red, int green, int blue);
|
||||||
|
static bool IsInstalled(CVehicle* veh);
|
||||||
static bool IsPulsingEnabled(CVehicle* veh);
|
static bool IsPulsingEnabled(CVehicle* veh);
|
||||||
static void SetPulsing(CVehicle* veh, bool state);
|
static void SetPulsing(CVehicle* veh, bool state);
|
||||||
static void RemoveNeon(CVehicle* veh);
|
static void RemoveHooks();
|
||||||
|
static void Remove(CVehicle* veh);
|
||||||
};
|
};
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "NodeName.h"
|
#include "NodeName.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
Paint::Paint()
|
void Paint::InitHooks()
|
||||||
{
|
{
|
||||||
Events::vehicleRenderEvent.before += [](CVehicle* pVeh)
|
Events::vehicleRenderEvent.before += [](CVehicle* pVeh)
|
||||||
{
|
{
|
||||||
@ -142,16 +142,16 @@ void Paint::NodeWrapperRecursive(RwFrame* frame, CVehicle* pVeh, std::function<v
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Paint::UpdateNodeListRecursive(CVehicle* pVeh)
|
void Paint::GenerateNodeList(CVehicle* pVeh, std::vector<std::string>& names_vec)
|
||||||
{
|
{
|
||||||
RwFrame* frame = (RwFrame*)pVeh->m_pRwClump->object.parent;
|
RwFrame* frame = (RwFrame*)pVeh->m_pRwClump->object.parent;
|
||||||
|
|
||||||
NodeWrapperRecursive(frame, pVeh, [](RwFrame* frame)
|
NodeWrapperRecursive(frame, pVeh, [&](RwFrame* frame)
|
||||||
{
|
{
|
||||||
const std::string name = GetFrameNodeName(frame);
|
const std::string name = GetFrameNodeName(frame);
|
||||||
|
|
||||||
if (!(std::find(veh_nodes::names_vec.begin(), veh_nodes::names_vec.end(), name) != veh_nodes::names_vec.end()))
|
if (!(std::find(names_vec.begin(), names_vec.end(), name) != names_vec.end()))
|
||||||
veh_nodes::names_vec.push_back(name);
|
names_vec.push_back(name);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
15
src/paint.h
15
src/paint.h
@ -23,6 +23,7 @@
|
|||||||
// SOFTWARE.
|
// SOFTWARE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
class Paint
|
class Paint
|
||||||
{
|
{
|
||||||
@ -70,19 +71,13 @@ private:
|
|||||||
void resetMaterialTexture(RpMaterial* material);
|
void resetMaterialTexture(RpMaterial* material);
|
||||||
};
|
};
|
||||||
static inline VehicleExtendedData<VehData> m_VehData;
|
static inline VehicleExtendedData<VehData> m_VehData;
|
||||||
|
static void NodeWrapperRecursive(RwFrame* frame, CVehicle* pVeh, std::function<void(RwFrame*)> func);
|
||||||
|
|
||||||
protected:
|
public:
|
||||||
static inline ResourceStore m_TextureData { "textures", eResourceType::TYPE_IMAGE, ImVec2(100, 80) };
|
static inline ResourceStore m_TextureData { "textures", eResourceType::TYPE_IMAGE, ImVec2(100, 80) };
|
||||||
|
|
||||||
struct veh_nodes
|
static void InitHooks();
|
||||||
{
|
static void GenerateNodeList(CVehicle* pVeh, std::vector<std::string>& names_vec);
|
||||||
static inline std::vector<std::string> names_vec{"Default"};
|
|
||||||
static inline std::string selected = "Default";
|
|
||||||
};
|
|
||||||
|
|
||||||
Paint();
|
|
||||||
static void UpdateNodeListRecursive(CVehicle* pVeh);
|
|
||||||
static void NodeWrapperRecursive(RwFrame* frame, CVehicle* pVeh, std::function<void(RwFrame*)> func);
|
|
||||||
static void SetNodeColor(CVehicle* pVeh, std::string node_name, CRGBA color, bool filter_mat = false);
|
static void SetNodeColor(CVehicle* pVeh, std::string node_name, CRGBA color, bool filter_mat = false);
|
||||||
static void SetNodeTexture(CVehicle* pVeh, std::string node_name, std::string texturename, bool filter_mat = false);
|
static void SetNodeTexture(CVehicle* pVeh, std::string node_name, std::string texturename, bool filter_mat = false);
|
||||||
static void ResetNodeColor(CVehicle* veh, std::string node_name);
|
static void ResetNodeColor(CVehicle* veh, std::string node_name);
|
||||||
|
32
src/ui.cpp
32
src/ui.cpp
@ -234,7 +234,7 @@ void Ui::DrawHeaders(CallbackTable& data)
|
|||||||
ImGui::PushFont(FontMgr::GetFont("header"));
|
ImGui::PushFont(FontMgr::GetFont("header"));
|
||||||
|
|
||||||
ImDrawList *pDrawList = ImGui::GetWindowDrawList();
|
ImDrawList *pDrawList = ImGui::GetWindowDrawList();
|
||||||
for (int i = 0; i < data.size(); ++i)
|
for (size_t i = 0; i < data.size(); ++i)
|
||||||
{
|
{
|
||||||
const char* btn_text = data[i].first.c_str();
|
const char* btn_text = data[i].first.c_str();
|
||||||
|
|
||||||
@ -283,35 +283,7 @@ void Ui::DrawHeaders(CallbackTable& data)
|
|||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
ImGui::Dummy(ImVec2(0, 10));
|
ImGui::Dummy(ImVec2(0, 10));
|
||||||
|
|
||||||
if (m_HeaderId == -1)
|
if (m_HeaderId != -1)
|
||||||
{
|
|
||||||
// Show Welcome page
|
|
||||||
ImGui::NewLine();
|
|
||||||
|
|
||||||
CenterdText("Welcome to Cheat Menu");
|
|
||||||
CenterdText("Author: Grinch_");
|
|
||||||
|
|
||||||
ImGui::NewLine();
|
|
||||||
ImGui::TextWrapped("Please ensure you have the latest version from GitHub.");
|
|
||||||
ImGui::NewLine();
|
|
||||||
if (ImGui::Button("Discord server", ImVec2(GetSize(2))))
|
|
||||||
{
|
|
||||||
ShellExecute(nullptr, "open", DISCORD_INVITE, nullptr, nullptr, SW_SHOWNORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::SameLine();
|
|
||||||
|
|
||||||
if (ImGui::Button("GitHub repo", ImVec2(GetSize(2))))
|
|
||||||
{
|
|
||||||
ShellExecute(nullptr, "open", GITHUB_LINK, nullptr, nullptr, SW_SHOWNORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::NewLine();
|
|
||||||
ImGui::TextWrapped("If you find bugs or have suggestions, you can let me know on discord :)");
|
|
||||||
ImGui::Dummy(ImVec2(0, 30));
|
|
||||||
CenterdText("Copyright Grinch_ 2019-2022. All rights reserved.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (pCallback != nullptr && ImGui::BeginChild("TABSBAR"))
|
if (pCallback != nullptr && ImGui::BeginChild("TABSBAR"))
|
||||||
{
|
{
|
||||||
|
@ -1,11 +1,37 @@
|
|||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "updater.h"
|
#include "updater.h"
|
||||||
#include "ui.h"
|
|
||||||
#include "menuinfo.h"
|
#include "menuinfo.h"
|
||||||
#include "util.h"
|
|
||||||
|
|
||||||
void Updater::CheckForUpdate()
|
bool Updater::IsUpdateAvailable()
|
||||||
{
|
{
|
||||||
|
return Updater::curState == States::FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Updater::ResetUpdaterState()
|
||||||
|
{
|
||||||
|
Updater::curState = States::IDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Updater::GetUpdateVersion()
|
||||||
|
{
|
||||||
|
return Updater::latestVer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Updater::CheckUpdate()
|
||||||
|
{
|
||||||
|
if (Updater::curState == States::IDLE)
|
||||||
|
{
|
||||||
|
Updater::curState = States::CHECKING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Updater::Process()
|
||||||
|
{
|
||||||
|
if (Updater::curState != States::CHECKING)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const char* link = "https://api.github.com/repos/user-grinch/Cheat-Menu/tags";
|
const char* link = "https://api.github.com/repos/user-grinch/Cheat-Menu/tags";
|
||||||
char* path = PLUGIN_PATH((char*)"CheatMenu/json/versioninfo.json");
|
char* path = PLUGIN_PATH((char*)"CheatMenu/json/versioninfo.json");
|
||||||
HRESULT res = URLDownloadToFile(NULL, link, path, 0, NULL);
|
HRESULT res = URLDownloadToFile(NULL, link, path, 0, NULL);
|
||||||
@ -21,56 +47,21 @@ void Updater::CheckForUpdate()
|
|||||||
// fetch the version number
|
// fetch the version number
|
||||||
if (verinfo.m_Data.empty())
|
if (verinfo.m_Data.empty())
|
||||||
{
|
{
|
||||||
m_LatestVersion = MENU_VERSION_NUMBER;
|
latestVer = MENU_VERSION_NUMBER;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_LatestVersion = verinfo.m_Data.items().begin().value()["name"].get<std::string>();
|
latestVer = verinfo.m_Data.items().begin().value()["name"].get<std::string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_LatestVersion > MENU_VERSION_NUMBER)
|
if (latestVer > MENU_VERSION_NUMBER)
|
||||||
{
|
{
|
||||||
SetHelpMessage("Update found", false, false, false);
|
SetHelpMessage("Update found", false, false, false);
|
||||||
m_State = UPDATER_UPDATE_FOUND;
|
curState = States::FOUND;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetHelpMessage("No update found.", false, false, false);
|
SetHelpMessage("No update found.", false, false, false);
|
||||||
Updater::m_State = UPDATER_IDLE;
|
Updater::curState = States::IDLE;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Updater::ShowUpdateScreen()
|
|
||||||
{
|
|
||||||
ImGui::Dummy(ImVec2(0, 20));
|
|
||||||
Ui::CenterdText("A new version of the mod is available.");
|
|
||||||
Ui::CenterdText(std::string("Current version: ") + MENU_VERSION);
|
|
||||||
Ui::CenterdText("Latest version: " + Updater::m_LatestVersion);
|
|
||||||
ImGui::Dummy(ImVec2(0, 10));
|
|
||||||
ImGui::TextWrapped("In order to keep using the menu, you need to update to the latest version."
|
|
||||||
" This is to ensure everything is using the most up-to-date version.");
|
|
||||||
ImGui::Dummy(ImVec2(0, 10));
|
|
||||||
ImGui::TextWrapped("To know what changes are made or to download, click on the \"Download page\" button."
|
|
||||||
" Follow the instructions there. If you're still having issues, let me know on discord.");
|
|
||||||
|
|
||||||
ImGui::Dummy(ImVec2(0, 5));
|
|
||||||
if (ImGui::Button("Discord server", ImVec2(Ui::GetSize(3))))
|
|
||||||
{
|
|
||||||
ShellExecute(NULL, "open", DISCORD_INVITE, NULL, NULL, SW_SHOWNORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::SameLine();
|
|
||||||
|
|
||||||
if (ImGui::Button("Download page", Ui::GetSize(3)))
|
|
||||||
{
|
|
||||||
ShellExecute(NULL, "open", std::string("https://github.com/user-grinch/Cheat-Menu/releases/tag/" +
|
|
||||||
Updater::m_LatestVersion).c_str(), NULL, NULL, SW_SHOWNORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::SameLine();
|
|
||||||
|
|
||||||
if (ImGui::Button("Hide page", Ui::GetSize(3)))
|
|
||||||
{
|
|
||||||
Updater::m_State = UPDATER_IDLE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,31 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
|
||||||
|
|
||||||
enum UPDATER_STATE
|
|
||||||
{
|
|
||||||
UPDATER_IDLE,
|
|
||||||
UPDATER_CHECKING,
|
|
||||||
UPDATER_UPDATE_FOUND
|
|
||||||
};
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Update class
|
||||||
|
Checks for menu updates and provides a way to update the menu.
|
||||||
|
*/
|
||||||
class Updater
|
class Updater
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
enum class States
|
||||||
|
{
|
||||||
|
IDLE,
|
||||||
|
CHECKING,
|
||||||
|
FOUND
|
||||||
|
};
|
||||||
|
static inline States curState = States::IDLE;
|
||||||
|
static inline std::string latestVer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static inline UPDATER_STATE m_State = UPDATER_IDLE;
|
|
||||||
static inline std::string m_LatestVersion;
|
|
||||||
|
|
||||||
static void CheckForUpdate();
|
Updater() = delete;
|
||||||
static void ShowUpdateScreen();
|
Updater(const Updater&) = delete;
|
||||||
|
|
||||||
|
static void CheckUpdate();
|
||||||
|
static std::string GetUpdateVersion();
|
||||||
|
static bool IsUpdateAvailable();
|
||||||
|
|
||||||
|
// Needs to run in it's own thread to prevent the game from freezing
|
||||||
|
static void Process();
|
||||||
|
static void ResetUpdaterState();
|
||||||
};
|
};
|
||||||
|
32
src/util.cpp
32
src/util.cpp
@ -4,9 +4,9 @@
|
|||||||
|
|
||||||
std::string Util::GetLocationName(CVector* pos)
|
std::string Util::GetLocationName(CVector* pos)
|
||||||
{
|
{
|
||||||
CPlayerPed *pPlayer = FindPlayerPed();
|
|
||||||
|
|
||||||
#ifdef GTASA
|
#ifdef GTASA
|
||||||
|
CPlayerPed *pPlayer = FindPlayerPed();
|
||||||
int hplayer = CPools::GetPedRef(pPlayer);
|
int hplayer = CPools::GetPedRef(pPlayer);
|
||||||
|
|
||||||
int interior = 0;
|
int interior = 0;
|
||||||
@ -39,38 +39,13 @@ std::string Util::GetLocationName(CVector* pos)
|
|||||||
return std::string("Interior ") + std::to_string(interior) + ", " + town;
|
return std::string("Interior ") + std::to_string(interior) + ", " + town;
|
||||||
|
|
||||||
#elif GTAVC
|
#elif GTAVC
|
||||||
if (pPlayer)
|
return "Vice City";
|
||||||
{
|
|
||||||
return std::to_string(pPlayer->m_nInterior) + ", Vice City" ;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return "Vice City";
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
return "Liberty City";
|
return "Liberty City";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef GTASA
|
#ifdef GTASA
|
||||||
// Thanks DKPac22
|
|
||||||
RwTexture* Util::LoadTextureFromMemory(char* data, unsigned int size)
|
|
||||||
{
|
|
||||||
patch::SetChar(0x7CF9CA, rwSTREAMMEMORY);
|
|
||||||
RwMemory memoryImage;
|
|
||||||
RwInt32 width, height, depth, flags;
|
|
||||||
memoryImage.start = (RwUInt8*)data;
|
|
||||||
memoryImage.length = size;
|
|
||||||
RwImage* image = RtPNGImageRead((char*)&memoryImage);
|
|
||||||
RwImageFindRasterFormat(image, 4, &width, &height, &depth, &flags);
|
|
||||||
RwRaster* raster = RwRasterCreate(width, height, depth, flags);
|
|
||||||
RwRasterSetFromImage(raster, image);
|
|
||||||
RwImageDestroy(image);
|
|
||||||
patch::SetChar(0x7CF9CA, rwSTREAMFILENAME);
|
|
||||||
|
|
||||||
return RwTextureCreate(raster);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Util::ClearCharTasksVehCheck(CPed* ped)
|
void Util::ClearCharTasksVehCheck(CPed* ped)
|
||||||
{
|
{
|
||||||
uint hped = CPools::GetPedRef(ped);
|
uint hped = CPools::GetPedRef(ped);
|
||||||
@ -97,8 +72,7 @@ void Util::ClearCharTasksVehCheck(CPed* ped)
|
|||||||
|
|
||||||
bool Util::IsOnMission()
|
bool Util::IsOnMission()
|
||||||
{
|
{
|
||||||
return FindPlayerPed()->CanPlayerStartMission() && !*(patch::Get<char*>(0x5D5380, false) +
|
return FindPlayerPed()->CanPlayerStartMission() && !*(patch::Get<char*>(0x5D5380, false) + CTheScripts::OnAMissionFlag);
|
||||||
CTheScripts::OnAMissionFlag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Util::GetLargestGangInZone()
|
int Util::GetLargestGangInZone()
|
||||||
|
24
src/util.h
24
src/util.h
@ -2,28 +2,30 @@
|
|||||||
#include "tchar.h"
|
#include "tchar.h"
|
||||||
#include "pdh.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
|
class Util
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
static inline PDH_HQUERY cpuQuery;
|
||||||
|
static inline PDH_HCOUNTER cpuTotal;
|
||||||
|
static inline ULARGE_INTEGER lastCPU, lastSysCPU, lastUserCPU;
|
||||||
|
static inline int numProcessors;
|
||||||
|
static inline HANDLE self;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Util() = delete;
|
||||||
|
Util(Util&) = delete;
|
||||||
|
|
||||||
#ifdef GTASA
|
#ifdef GTASA
|
||||||
static void ClearCharTasksVehCheck(CPed* ped);
|
static void ClearCharTasksVehCheck(CPed* ped);
|
||||||
static int GetLargestGangInZone();
|
static int GetLargestGangInZone();
|
||||||
static RwTexture* LoadTextureFromMemory(char* data, unsigned int size);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static CPed* GetClosestPed();
|
static CPed* GetClosestPed();
|
||||||
static CVehicle* GetClosestVehicle();
|
static CVehicle* GetClosestVehicle();
|
||||||
static std::string GetLocationName(CVector* pos);
|
|
||||||
static bool IsOnMission();
|
|
||||||
static bool IsOnCutscene();
|
|
||||||
static void RainbowValues(int& r, int& g, int& b, float speed);
|
|
||||||
static void GetCPUUsageInit();
|
static void GetCPUUsageInit();
|
||||||
static double GetCurrentCPUUsage();
|
static double GetCurrentCPUUsage();
|
||||||
|
static std::string GetLocationName(CVector* pos);
|
||||||
|
static bool IsOnCutscene();
|
||||||
|
static bool IsOnMission();
|
||||||
|
static void RainbowValues(int& r, int& g, int& b, float speed);
|
||||||
};
|
};
|
||||||
|
@ -7,6 +7,11 @@
|
|||||||
#include <CPopulation.h>
|
#include <CPopulation.h>
|
||||||
#include <CDamageManager.h>
|
#include <CDamageManager.h>
|
||||||
|
|
||||||
|
#ifdef GTASA
|
||||||
|
#include "neon.h"
|
||||||
|
#include "paint.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
void Vehicle::FixVehicle(CVehicle *pVeh)
|
void Vehicle::FixVehicle(CVehicle *pVeh)
|
||||||
{
|
{
|
||||||
#ifdef GTASA
|
#ifdef GTASA
|
||||||
@ -68,7 +73,10 @@ Vehicle::Vehicle()
|
|||||||
{
|
{
|
||||||
#ifdef GTASA
|
#ifdef GTASA
|
||||||
FileHandler::FetchHandlingID(m_VehicleIDE);
|
FileHandler::FetchHandlingID(m_VehicleIDE);
|
||||||
|
Neon::InitHooks();
|
||||||
|
Paint::InitHooks();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FileHandler::FetchColorData(m_CarcolsColorData);
|
FileHandler::FetchColorData(m_CarcolsColorData);
|
||||||
|
|
||||||
Events::processScriptsEvent += [this]
|
Events::processScriptsEvent += [this]
|
||||||
@ -184,7 +192,7 @@ Vehicle::Vehicle()
|
|||||||
int red, green, blue;
|
int red, green, blue;
|
||||||
|
|
||||||
Util::RainbowValues(red, green, blue, 0.25);
|
Util::RainbowValues(red, green, blue, 0.25);
|
||||||
InstallNeon(pVeh, red, green, blue);
|
Neon::Install(pVeh, red, green, blue);
|
||||||
m_Neon::m_nRainbowTimer = timer;
|
m_Neon::m_nRainbowTimer = timer;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -213,9 +221,9 @@ Vehicle::Vehicle()
|
|||||||
chance = Random(1, 3);
|
chance = Random(1, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chance == 1 && !IsNeonInstalled(veh) && veh->m_pDriver != pPlayer)
|
if (chance == 1 && !Neon::IsInstalled(veh) && veh->m_pDriver != pPlayer)
|
||||||
{
|
{
|
||||||
InstallNeon(veh, Random(0, 255), Random(0, 255), Random(0, 255));
|
Neon::Install(veh, Random(0, 255), Random(0, 255), Random(0, 255));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_Neon::m_bTrafficTimer = timer;
|
m_Neon::m_bTrafficTimer = timer;
|
||||||
@ -239,6 +247,13 @@ Vehicle::Vehicle()
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vehicle::~Vehicle()
|
||||||
|
{
|
||||||
|
#ifdef GTASA
|
||||||
|
Neon::RemoveHooks();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef GTASA
|
#ifdef GTASA
|
||||||
void Vehicle::AddComponent(const std::string& component, const bool display_message)
|
void Vehicle::AddComponent(const std::string& component, const bool display_message)
|
||||||
{
|
{
|
||||||
@ -1055,24 +1070,24 @@ void Vehicle::Draw()
|
|||||||
if (ImGui::BeginTabItem("Color"))
|
if (ImGui::BeginTabItem("Color"))
|
||||||
{
|
{
|
||||||
#ifdef GTASA
|
#ifdef GTASA
|
||||||
Paint::UpdateNodeListRecursive(veh);
|
Paint::GenerateNodeList(veh, m_Paint::m_vecNames);
|
||||||
|
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
if (ImGui::Button("Reset color", ImVec2(Ui::GetSize())))
|
if (ImGui::Button("Reset color", ImVec2(Ui::GetSize())))
|
||||||
{
|
{
|
||||||
Paint::ResetNodeColor(veh, Paint::veh_nodes::selected);
|
Paint::ResetNodeColor(veh, m_Paint::m_Selected);
|
||||||
SetHelpMessage("Color reset", false, false, false);
|
SetHelpMessage("Color reset", false, false, false);
|
||||||
}
|
}
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
|
|
||||||
Ui::ListBoxStr("Component", Paint::veh_nodes::names_vec, Paint::veh_nodes::selected);
|
Ui::ListBoxStr("Component", m_Paint::m_vecNames, m_Paint::m_Selected);
|
||||||
|
|
||||||
if (ImGui::ColorEdit3("Color picker", m_Color::m_fColorPicker))
|
if (ImGui::ColorEdit3("Color picker", m_Paint::m_fColorPicker))
|
||||||
{
|
{
|
||||||
uchar r = m_Color::m_fColorPicker[0] * 255;
|
uchar r = m_Paint::m_fColorPicker[0] * 255;
|
||||||
uchar g = m_Color::m_fColorPicker[1] * 255;
|
uchar g = m_Paint::m_fColorPicker[1] * 255;
|
||||||
uchar b = m_Color::m_fColorPicker[2] * 255;
|
uchar b = m_Paint::m_fColorPicker[2] * 255;
|
||||||
Paint::SetNodeColor(veh, Paint::veh_nodes::selected, { r, g, b, 255 }, m_Color::m_bMatFilter);
|
Paint::SetNodeColor(veh, m_Paint::m_Selected, { r, g, b, 255 }, m_Paint::m_bMatFilter);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1080,13 +1095,13 @@ void Vehicle::Draw()
|
|||||||
ImGui::Columns(2, NULL, false);
|
ImGui::Columns(2, NULL, false);
|
||||||
|
|
||||||
#ifdef GTASA
|
#ifdef GTASA
|
||||||
ImGui::Checkbox("Material filter", &m_Color::m_bMatFilter);
|
ImGui::Checkbox("Material filter", &m_Paint::m_bMatFilter);
|
||||||
ImGui::RadioButton("Primary", &m_Color::m_nRadioButton, 1);
|
ImGui::RadioButton("Primary", &m_Paint::m_nRadioButton, 1);
|
||||||
ImGui::RadioButton("Secondary", &m_Color::m_nRadioButton, 2);
|
ImGui::RadioButton("Secondary", &m_Paint::m_nRadioButton, 2);
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
ImGui::NewLine();
|
ImGui::NewLine();
|
||||||
ImGui::RadioButton("Tertiary", &m_Color::m_nRadioButton, 3);
|
ImGui::RadioButton("Tertiary", &m_Paint::m_nRadioButton, 3);
|
||||||
ImGui::RadioButton("Quaternary", &m_Color::m_nRadioButton, 4);
|
ImGui::RadioButton("Quaternary", &m_Paint::m_nRadioButton, 4);
|
||||||
#else // GTA3 & GTAVC
|
#else // GTA3 & GTAVC
|
||||||
ImGui::RadioButton("Primary", &m_Color::m_nRadioButton, 1);
|
ImGui::RadioButton("Primary", &m_Color::m_nRadioButton, 1);
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
@ -1110,7 +1125,7 @@ void Vehicle::Draw()
|
|||||||
{
|
{
|
||||||
if (Ui::ColorButton(colorId, m_CarcolsColorData[colorId], ImVec2(btnSize, btnSize)))
|
if (Ui::ColorButton(colorId, m_CarcolsColorData[colorId], ImVec2(btnSize, btnSize)))
|
||||||
{
|
{
|
||||||
*(uint8_replacement*)(int(veh) + BY_GAME(0x433, 0x19F, 0x19B) + m_Color::m_nRadioButton) = colorId;
|
*(uint8_replacement*)(int(veh) + BY_GAME(0x433, 0x19F, 0x19B) + m_Paint::m_nRadioButton) = colorId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((colorId + 1) % btnsInRow != 0)
|
if ((colorId + 1) % btnsInRow != 0)
|
||||||
@ -1130,16 +1145,18 @@ void Vehicle::Draw()
|
|||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
if (ImGui::Button("Remove neon", ImVec2(Ui::GetSize())))
|
if (ImGui::Button("Remove neon", ImVec2(Ui::GetSize())))
|
||||||
{
|
{
|
||||||
RemoveNeon(veh);
|
Neon::Remove(veh);
|
||||||
SetHelpMessage("Neon removed", false, false, false);
|
SetHelpMessage("Neon removed", false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
ImGui::Columns(2, NULL, false);
|
ImGui::Columns(2, NULL, false);
|
||||||
|
|
||||||
bool pulsing = IsPulsingEnabled(veh);
|
bool pulsing = Neon::IsPulsingEnabled(veh);
|
||||||
if (Ui::CheckboxWithHint("Pulsing neons", &pulsing))
|
if (Ui::CheckboxWithHint("Pulsing neons", &pulsing))
|
||||||
SetPulsing(veh, pulsing);
|
{
|
||||||
|
Neon::SetPulsing(veh, pulsing);
|
||||||
|
}
|
||||||
|
|
||||||
Ui::CheckboxWithHint("Rainbow neons", &m_Neon::m_bRainbowEffect, "Rainbow effect to neon lights");
|
Ui::CheckboxWithHint("Rainbow neons", &m_Neon::m_bRainbowEffect, "Rainbow effect to neon lights");
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
@ -1150,8 +1167,11 @@ void Vehicle::Draw()
|
|||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
|
|
||||||
if (ImGui::ColorEdit3("Color picker", m_Neon::m_fColorPicker))
|
if (ImGui::ColorEdit3("Color picker", m_Neon::m_fColorPicker))
|
||||||
InstallNeon(veh, m_Neon::m_fColorPicker[0] * 255, m_Neon::m_fColorPicker[1] * 255,
|
{
|
||||||
m_Neon::m_fColorPicker[2] * 255);
|
Neon::Install(veh, m_Neon::m_fColorPicker[0] * 255, m_Neon::m_fColorPicker[1] * 255,
|
||||||
|
m_Neon::m_fColorPicker[2] * 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
ImGui::Text("Select neon preset:");
|
ImGui::Text("Select neon preset:");
|
||||||
@ -1169,11 +1189,13 @@ void Vehicle::Draw()
|
|||||||
if (Ui::ColorButton(color_id, m_CarcolsColorData[color_id], ImVec2(btnSize, btnSize)))
|
if (Ui::ColorButton(color_id, m_CarcolsColorData[color_id], ImVec2(btnSize, btnSize)))
|
||||||
{
|
{
|
||||||
std::vector<float>& color = m_CarcolsColorData[color_id];
|
std::vector<float>& color = m_CarcolsColorData[color_id];
|
||||||
InstallNeon(veh, color[0] * 255, color[1] * 255, color[2] * 255);
|
Neon::Install(veh, color[0] * 255, color[1] * 255, color[2] * 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((color_id + 1) % btnsInRow != 0)
|
if ((color_id + 1) % btnsInRow != 0)
|
||||||
|
{
|
||||||
ImGui::SameLine(0.0, 4.0);
|
ImGui::SameLine(0.0, 4.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
@ -1181,17 +1203,17 @@ void Vehicle::Draw()
|
|||||||
}
|
}
|
||||||
if (ImGui::BeginTabItem("Textures"))
|
if (ImGui::BeginTabItem("Textures"))
|
||||||
{
|
{
|
||||||
Paint::UpdateNodeListRecursive(veh);
|
Paint::GenerateNodeList(veh, m_Paint::m_vecNames);
|
||||||
|
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
if (ImGui::Button("Reset texture", ImVec2(Ui::GetSize())))
|
if (ImGui::Button("Reset texture", ImVec2(Ui::GetSize())))
|
||||||
{
|
{
|
||||||
Paint::ResetNodeTexture(veh, Paint::veh_nodes::selected);
|
Paint::ResetNodeTexture(veh, m_Paint::m_Selected);
|
||||||
SetHelpMessage("Texture reset", false, false, false);
|
SetHelpMessage("Texture reset", false, false, false);
|
||||||
}
|
}
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
|
|
||||||
Ui::ListBoxStr("Component", Paint::veh_nodes::names_vec, Paint::veh_nodes::selected);
|
Ui::ListBoxStr("Component", m_Paint::m_vecNames, m_Paint::m_Selected);
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
|
|
||||||
int maxpjob, curpjob;
|
int maxpjob, curpjob;
|
||||||
@ -1216,13 +1238,13 @@ void Vehicle::Draw()
|
|||||||
|
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::Checkbox("Material filter", &m_Color::m_bMatFilter);
|
ImGui::Checkbox("Material filter", &m_Paint::m_bMatFilter);
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
Ui::DrawImages(m_TextureData,
|
Ui::DrawImages(Paint::m_TextureData,
|
||||||
[](std::string& str)
|
[](std::string& str)
|
||||||
{
|
{
|
||||||
Paint::SetNodeTexture(FindPlayerPed()->m_pVehicle, Paint::veh_nodes::selected, str,
|
Paint::SetNodeTexture(FindPlayerPed()->m_pVehicle, m_Paint::m_Selected, str,
|
||||||
m_Color::m_bMatFilter);
|
m_Paint::m_bMatFilter);
|
||||||
},
|
},
|
||||||
nullptr,
|
nullptr,
|
||||||
[](std::string& str)
|
[](std::string& str)
|
||||||
|
@ -1,15 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#ifdef GTASA
|
|
||||||
#include "neon.h"
|
|
||||||
#include "paint.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef GTASA
|
|
||||||
class Vehicle : public Paint, public Neon
|
|
||||||
#else // GTA3 & GTAVC
|
|
||||||
class Vehicle
|
class Vehicle
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
static inline bool m_bBikeFly;
|
static inline bool m_bBikeFly;
|
||||||
@ -24,11 +16,13 @@ private:
|
|||||||
static inline bool m_bLockSpeed;
|
static inline bool m_bLockSpeed;
|
||||||
static inline float m_fLockSpeed;
|
static inline float m_fLockSpeed;
|
||||||
static inline std::vector<std::vector<float>> m_CarcolsColorData;
|
static inline std::vector<std::vector<float>> m_CarcolsColorData;
|
||||||
struct m_Color
|
struct m_Paint
|
||||||
{
|
{
|
||||||
static inline bool m_bMatFilter = true;
|
static inline bool m_bMatFilter = true;
|
||||||
static inline int m_nRadioButton = 1;
|
static inline int m_nRadioButton = 1;
|
||||||
static inline float m_fColorPicker[3]{ 0, 0, 0 };
|
static inline float m_fColorPicker[3]{ 0, 0, 0 };
|
||||||
|
static inline std::vector<std::string> m_vecNames{"Default"};
|
||||||
|
static inline std::string m_Selected = "Default";
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef GTASA
|
#ifdef GTASA
|
||||||
@ -106,4 +100,5 @@ public:
|
|||||||
static int GetModelFromName(const char* name);
|
static int GetModelFromName(const char* name);
|
||||||
static void Draw();
|
static void Draw();
|
||||||
Vehicle();
|
Vehicle();
|
||||||
|
~Vehicle();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user