Refactored code, fixes

This commit is contained in:
Grinch_ 2020-12-11 01:36:18 +06:00
parent d506387a42
commit 68e63a7ccb
5 changed files with 42 additions and 28 deletions

1
.gitignore vendored
View File

@ -43,3 +43,4 @@ moonloader/lib/cheat-menu/json/config.json
/CheatMenu.VC.db
.vs/CheatMenu/v14/.suo
ipch/CHEATMENU.VCXPROJ-daebb660/CHEATMENU-7e055069.ipch
/ipch/CHEATMENU.VCXPROJ-daebb660/CHEATMENU-ac659b63.ipch

View File

@ -58,9 +58,6 @@ CheatMenu::CheatMenu()
if (Globals::init_done && !FrontEndMenuManager.m_bMenuActive && CTimer::m_snTimeInMilliseconds - Globals::last_key_timer > 250)
{
CPlayerPed* player = FindPlayerPed();
CPad *pad = player->GetPadFromPlayer();
if (Ui::HotKeyPressed(hotkey::menu_open))
{
Globals::show_menu = !Globals::show_menu;
@ -77,6 +74,11 @@ CheatMenu::CheatMenu()
}
};
Events::drawMenuBackgroundEvent += [this]
{
Hook::show_mouse = false;
};
Events::shutdownRwEvent += []
{
// Save config data

View File

@ -34,28 +34,27 @@ class Launcher
public:
Launcher()
{
bool launch = true;
uint gameVersion = GetGameVersion();
if (gameVersion != GAME_10US_HOODLUM && gameVersion != GAME_10US_COMPACT) {
MessageBox(HWND_DESKTOP, "CheatMenu requires v1.0 US of the game.", "CheatMenu", MB_ICONERROR);
flog << "Game version isn't 1.0" << std::endl;
launch = false;
}
else
Events::initRwEvent += []()
{
Events::initRwEvent += [&launch]()
{
if (GetModuleHandleA("SAMP.dll")) {
MessageBox(HWND_DESKTOP, "SAMP detected. Exiting CheatMenu.", "CheatMenu", MB_ICONERROR);
flog << "SAMP detected. Exiting..." << std::endl;
launch = false;
}
bool launch = true;
if (launch)
static CheatMenu cheatmenu;
};
}
uint gameVersion = GetGameVersion();
if (gameVersion != GAME_10US_HOODLUM && gameVersion != GAME_10US_COMPACT) {
MessageBox(HWND_DESKTOP, "CheatMenu requires v1.0 US of the game.", "CheatMenu", MB_ICONERROR);
launch = false;
}
if (GetModuleHandleA("SAMP.dll")) {
MessageBox(HWND_DESKTOP, "SAMP detected. Exiting CheatMenu.", "CheatMenu", MB_ICONERROR);
launch = false;
}
if (launch)
{
flog << "Loading CheatMenu" << std::endl;
static CheatMenu cheatmenu;
}
};
}
} launcher;

View File

@ -65,6 +65,7 @@ HRESULT Hook::PresentDx9(IDirect3DDevice9 *pDevice, RECT* pSourceRect, RECT* pDe
ImGui::EndFrame();
ImGui::Render();
ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData());
}
else
{
@ -121,6 +122,7 @@ HRESULT Hook::PresentDx11(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Fl
ImGui::EndFrame();
ImGui::Render();
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
}
else
{
@ -171,7 +173,10 @@ void Hook::ShowMouse(bool state)
ImGui::GetIO().MouseDrawCursor = state;
CPad::NewMouseControllerState.X = 0;
CPad::NewMouseControllerState.Y = 0;
// Broken in psdk
Call<0x541BD0>(); // CPad::ClearMouseHistory
Call<0x53F1E0>(); // CPad::ClearKeyboardHistory
Call<0x541DD0>(); // CPad::UpdatePads
}

View File

@ -474,18 +474,24 @@ void Vehicle::SpawnVehicle(std::string &smodel)
if (spawner::license_text != "")
Command<Commands::CUSTOM_PLATE_FOR_NEXT_CAR>(imodel, spawner::license_text);
if (!spawner::spawn_inside)
veh = CCheat::VehicleCheat(imodel);
else
if (spawner::spawn_inside)
{
int hveh = 0;
Command<Commands::CREATE_CAR>(imodel, pos.x, pos.y, pos.z, &hveh);
Command<Commands::CREATE_CAR>(imodel, pos.x, pos.y, pos.z + 4.0f, &hveh);
veh = CPools::GetVehicle(hveh);
veh->SetHeading(player->GetHeading());
Command<Commands::WARP_CHAR_INTO_CAR>(hplayer, hveh);
Command<Commands::SET_CAR_FORWARD_SPEED>(hveh, speed);
}
else
{
int hveh = 0;
player->TransformFromObjectSpace(pos, CVector(0, 10, 0));
Command<Commands::CREATE_CAR>(imodel, pos.x, pos.y, pos.z + 4.0f, &hveh);
veh = CPools::GetVehicle(hveh);
veh->SetHeading(player->GetHeading()+55.0f);
}
CStreaming::SetModelIsDeletable(imodel);
}
@ -830,6 +836,7 @@ void Vehicle::Main()
ImGui::NextColumn();
Ui::CheckboxWithHint("Spawn aircraft in air", &spawner::spawn_in_air);
ImGui::Columns(1);
ImGui::Spacing();
ImGui::SetNextItemWidth(ImGui::GetWindowContentRegionWidth() - 2.5);