diff --git a/resource/common/locale/English.toml b/resource/common/locale/English.toml index f582329..452daea 100644 --- a/resource/common/locale/English.toml +++ b/resource/common/locale/English.toml @@ -423,6 +423,12 @@ All = "All" AllNitro = "All cars have nitro" AllTaxiNitro = "All taxis have nitro" AnimGroup = "Anim group" +AutoDrive = "Auto drive" +AutoDriveNoVeh = "You need to be inside a vehicle!" +AutoDriveCoord = "Drive to coordinates" +AutoDriveMarker = "Drive to marker" +AutoDriveStop = "Stop driving" +AutoDriveInfo = """Automatically drives you to selected location. This doesn't work very well and AI might get stuck!""" AutoUnflip = "Auto unflip" Big = "Big" BikeFly = "Bikes fly" @@ -464,7 +470,7 @@ EngineAccel = "Engine acceleration" EngineInertia = "Engine inertia" EngineOn = "Engine on" EngineType = "Engine type" -EnterNearVeh = "Enter nearest vehicle as" +EnterNearVeh = "Enter nearest vehicle" ExplosionProof = "Explosion proof" Fast = "Fast" FireProof = "Fire proof" @@ -513,7 +519,7 @@ MonValue = "Monetary value" LockTrainCam = "Lock train cam" NeonsTab = "Neons" NoColl = "Disable collisions" -NoNearVeh = "No nearby vehicles" +NoNearVeh = "No nearby vehicles!" NoParticles = "Disable particles" NoDerail = "No train derail" NumGears = "Number of gears" @@ -522,7 +528,7 @@ On = "On" OnlyWheels = "Wheels only" Open = "Open" Paintjob = "Paintjob" -Passenger = "Passenger " +Passenger = "Passenger" PentrolTank = "Petrol tank KO" PercentSubmerged = "Percent submerged" PerfectHandling = "Perfect handling" @@ -565,11 +571,12 @@ SpawnInside = "Spawn as driver" StayOnBike = "Don't fall off bike" SteeringLock = "Steering lock" SuspensionBias = "Suspension bias" +SwitchSeats = "Switch seats" Tall = "Tall" TankMode = "Tank mode" Tertiary = "Tertiary" TextureTab = "Textures" -TotalSeats = "Total seats: %d" +TotalSeats = "Seats: %d" TractionBias = "Traction bias" TractionLoss = "Traction loss" TractionMul = "Traction multiplier" diff --git a/src/cheatmenu.cpp b/src/cheatmenu.cpp index 804fc63..c2e30b8 100644 --- a/src/cheatmenu.cpp +++ b/src/cheatmenu.cpp @@ -302,7 +302,7 @@ void CheatMenu::Init() D3dHook::SetMouseState(m_bShowMenu); } - if (quickTeleport.PressedRealtime()) + if (Teleport::m_bQuickTeleport && quickTeleport.PressedRealtime()) { D3dHook::SetMouseState(true); } diff --git a/src/teleport.cpp b/src/teleport.cpp index 15ddd5c..703b82f 100644 --- a/src/teleport.cpp +++ b/src/teleport.cpp @@ -20,7 +20,7 @@ void Teleport::FetchRadarSpriteData() return; } - m_tpData.m_pData->RemoveTable("Radar"); + m_locData.m_pData->RemoveTable("Radar"); for (int i = 0; i != maxSprites; ++i) { CVector pos = CRadar::ms_RadarTrace[i].m_vecPos; @@ -28,7 +28,7 @@ void Teleport::FetchRadarSpriteData() std::string keyName = m_SpriteData.Get(sprite.c_str(), "Unknown"); keyName += ", " + Util::GetLocationName(&pos); std::string key = "Radar." + keyName; - m_tpData.m_pData->Set(key.c_str(), std::format("0, {}, {}, {}", pos.x, pos.y, pos.z)); + m_locData.m_pData->Set(key.c_str(), std::format("0, {}, {}, {}", pos.x, pos.y, pos.z)); } lastUpdated = timer; } @@ -249,9 +249,9 @@ void Teleport::RemoveTeleportEntry(std::string& category, std::string& key, std: { if (category == "Custom") { - m_tpData.m_pData->RemoveKey("Custom", key.c_str()); + m_locData.m_pData->RemoveKey("Custom", key.c_str()); SetHelpMessage(TEXT("Teleport.LocationRemoved")); - m_tpData.m_pData->Save(); + m_locData.m_pData->Save(); } else { @@ -351,19 +351,19 @@ void Teleport::ShowPage() if (ImGui::Button(TEXT("Teleport.AddLocation"), Widget::CalcSize())) { std::string key = std::string("Custom.") + m_nLocationBuffer; - m_tpData.m_pData->Set(key.c_str(), ("0, " + std::string(m_nInputBuffer))); + m_locData.m_pData->Set(key.c_str(), ("0, " + std::string(m_nInputBuffer))); #ifdef GTASA // Clear the Radar coordinates - m_tpData.m_pData->RemoveTable("Radar"); + m_locData.m_pData->RemoveTable("Radar"); #endif - m_tpData.m_pData->Save(); + m_locData.m_pData->Save(); } } ImGui::Spacing(); - Widget::DataList(m_tpData, TeleportToLocation, RemoveTeleportEntry); + Widget::DataList(m_locData, TeleportToLocation, RemoveTeleportEntry); ImGui::EndTabItem(); } ImGui::EndTabBar(); diff --git a/src/teleport.h b/src/teleport.h index 8898403..f45d6ef 100644 --- a/src/teleport.h +++ b/src/teleport.h @@ -5,10 +5,8 @@ class Teleport { private: static inline bool m_bInsertCoord; - static inline bool m_bQuickTeleport; static inline bool m_bTeleportMarker; static inline char m_nInputBuffer[INPUT_BUFFER_SIZE]; - static inline ResourceStore m_tpData{ "locations", eResourceType::TYPE_TEXT }; static inline char m_nLocationBuffer[INPUT_BUFFER_SIZE]; struct TPMarker @@ -35,6 +33,8 @@ private: public: Teleport() = delete; Teleport(const Teleport&) = delete; + static inline ResourceStore m_locData{ "locations", eResourceType::TYPE_TEXT }; + static inline bool m_bQuickTeleport; static void Init(); static void TeleportPlayer(bool get_marker = false, CVector pos = CVector(0, 0, 0), int interior_id = 0); diff --git a/src/vehicle.cpp b/src/vehicle.cpp index db32a94..b734506 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -3,11 +3,11 @@ #include "menu.h" #include "widget.h" #include "util.h" +#include "teleport.h" #include "filehandler.h" #include #include - #ifdef GTASA #include "tHandlingData.h" #include "neon.h" @@ -323,7 +323,6 @@ void Vehicle::SpawnVehicle(std::string& rootkey, std::string& vehName, std::stri { CPlayerPed* player = FindPlayerPed(); int hplayer = CPools::GetPedRef(player); - int imodel = std::stoi(smodel); CVehicle* veh = nullptr; int interior = BY_GAME(player->m_nAreaCode, player->m_nAreaCode, NULL); @@ -504,11 +503,83 @@ int Vehicle::GetModelFromName(const char* name) } } +static void StartAutoDrive(CVehicle *pVeh, const char *buf = nullptr) +{ + int hVeh = CPools::GetVehicleRef(pVeh); + CVector pos; + + if (buf == nullptr) + { +#ifdef GTA SA + tRadarTrace targetBlip = CRadar::ms_RadarTrace[LOWORD(FrontEndMenuManager.m_nTargetBlipIndex)]; + pos = targetBlip.m_vecPos; + if (targetBlip.m_nRadarSprite != RADAR_SPRITE_WAYPOINT) + { + SetHelpMessage(TEXT("Teleport.TargetBlipText")); + return; + } +#else + return; +#endif + } + else + { + if (sscanf(buf, "%f,%f,%f", &pos.x, &pos.y, &pos.z) != 3) + { + int dim; + sscanf(buf, "%d,%f,%f,%f", &dim, &pos.x, &pos.y, &pos.z); + } + } + + int model = pVeh->m_nModelIndex; + if (CModelInfo::IsBoatModel(model)) + { + Command(hVeh, pos.x, pos.y, pos.z); + } + else if (CModelInfo::IsPlaneModel(model)) + { + CVector p = pVeh->GetPosition(); + p.z = 300.0f; +#ifdef GTASA + pVeh->SetPosn(p); +#elif GTAVC + pVeh->SetPosition(p); +#else + pVeh->SetPos(p); +#endif + Command(hVeh, pos.x, pos.y, 300.0f, 30, 200); + } + else if (CModelInfo::IsHeliModel(model)) + { + CVector p = pVeh->GetPosition(); + p.z = 300.0f; +#ifdef GTASA + pVeh->SetPosn(p); +#elif GTAVC + pVeh->SetPosition(p); +#else + pVeh->SetPos(p); +#endif + Command(hVeh, pos.x, pos.y, 300.0f, 30, 200); + } +#ifdef GTASA + else if (CModelInfo::IsTrainModel(model)) + { + return; + } +#endif + else + { + Command(hVeh, pos.x, pos.y, pos.z); + } +} + void Vehicle::ShowPage() { ImGui::Spacing(); CPlayerPed* pPlayer = FindPlayerPed(); int hplayer = CPools::GetPedRef(pPlayer); + bool bPlayerInCar = Command(hplayer); CVehicle *pVeh = pPlayer->m_pVehicle; if (ImGui::Button(TEXT("Vehicle.BlowCar"), ImVec2(Widget::CalcSize(3)))) @@ -822,19 +893,18 @@ void Vehicle::ShowPage() #ifdef GTASA Widget::EditAddr(TEXT("Vehicle.DensityMul"), 0x8A5B20, 0, 1, 10); #endif - if (ImGui::CollapsingHeader(TEXT("Vehicle.EnterNearVeh"))) + if (ImGui::CollapsingHeader(TEXT(bPlayerInCar ? "Vehicle.SwitchSeats" : "Vehicle.EnterNearVeh"))) { - int hplayer = CPools::GetPedRef(pPlayer); - CVehicle* pClosestVeh = Util::GetClosestVehicle(); + CVehicle* pTargetVeh = bPlayerInCar ? pVeh : Util::GetClosestVehicle(); - if (pClosestVeh) + if (pTargetVeh) { - int seats = pClosestVeh->m_nMaxPassengers; + int seats = pTargetVeh->m_nMaxPassengers; ImGui::Spacing(); ImGui::Columns(2, 0, false); - ImGui::Text(GetNameFromModel(pClosestVeh->m_nModelIndex).c_str()); + ImGui::Text(GetNameFromModel(pTargetVeh->m_nModelIndex).c_str()); ImGui::NextColumn(); ImGui::Text(TEXT("Vehicle.TotalSeats"), (seats + 1)); ImGui::Columns(1); @@ -842,7 +912,7 @@ void Vehicle::ShowPage() ImGui::Spacing(); if (ImGui::Button(TEXT("Vehicle.Driver"), ImVec2(Widget::CalcSize(2)))) { - Command(hplayer, pClosestVeh); + Command(hplayer, pTargetVeh); } #ifndef GTA3 @@ -852,14 +922,14 @@ void Vehicle::ShowPage() { ImGui::SameLine(); } - - if (ImGui::Button((std::string(TEXT("Vehicle.Passenger")) + std::to_string(i + 1)).c_str(), + + if (ImGui::Button(std::format("{} {}", TEXT("Vehicle.Passenger"), i+1).c_str(), ImVec2(Widget::CalcSize(2)))) { #ifdef GTASA - Command(hplayer, pClosestVeh, i); + Command(hplayer, pTargetVeh, i); #elif GTAVC - WarpPlayerIntoVehicle(pClosestVeh, i); + WarpPlayerIntoVehicle(pTargetVeh, i); #endif } } @@ -867,7 +937,8 @@ void Vehicle::ShowPage() } else { - ImGui::Text(TEXT("Vehicle.NoNearVeh")); + ImGui::Spacing(); + Widget::TextCentered(TEXT("Vehicle.NoNearVeh")); } ImGui::Spacing(); @@ -1080,11 +1151,56 @@ void Vehicle::ShowPage() #endif ImGui::EndTabItem(); } - - if (pPlayer->m_pVehicle && Command(hplayer)) + if (pPlayer->m_pVehicle && bPlayerInCar) { CVehicle* veh = FindPlayerPed()->m_pVehicle; int hveh = CPools::GetVehicleRef(veh); + if (ImGui::BeginTabItem(TEXT("Vehicle.AutoDrive"))) + { + ImGui::Spacing(); + if (ImGui::Button(TEXT("Vehicle.AutoDriveStop"), Widget::CalcSize(1))) + { + + } + ImGui::Spacing(); + if (ImGui::BeginTabBar("PassTabaBar")) + { + if (ImGui::BeginTabItem(TEXT("Teleport.Coordinates"))) + { + static char buf[INPUT_BUFFER_SIZE]; + ImGui::Spacing(); + ImGui::TextWrapped(TEXT("Vehicle.AutoDriveInfo")); + ImGui::Spacing(); + ImGui::InputTextWithHint(TEXT("Teleport.Coordinates"), "x, y, z", buf, IM_ARRAYSIZE(buf)); + ImGui::Spacing(); + if (ImGui::Button(TEXT("Vehicle.AutoDriveCoord"), Widget::CalcSize(BY_GAME(2,1,1)))) + { + StartAutoDrive(pVeh, buf); + } +#ifdef GTASA + ImGui::SameLine(); + if (ImGui::Button(TEXT("Vehicle.AutoDriveMarker"), Widget::CalcSize(2))) + { + StartAutoDrive(pVeh); + } +#endif + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem(TEXT("Teleport.Location"))) + { + ImGui::Spacing(); + Widget::DataList(Teleport::m_locData, + [](std::string& rootkey, std::string& bLocName, std::string& loc) + { + CVehicle* pVeh = BY_GAME(FindPlayerVehicle(-1, false), FindPlayerVehicle(), FindPlayerVehicle()); + StartAutoDrive(pVeh, loc.c_str()); + }, nullptr); + ImGui::EndTabItem(); + } + ImGui::EndTabBar(); + } + ImGui::EndTabItem(); + } if (ImGui::BeginTabItem(TEXT("Vehicle.Color"))) { #ifdef GTASA diff --git a/tools/DebugAll.bat b/tools/DebugAll.bat index 9dbad03..f384b2c 100644 --- a/tools/DebugAll.bat +++ b/tools/DebugAll.bat @@ -16,4 +16,7 @@ xcopy /s "bin\CheatMenuVC.asi" %VC_DIR% /K /D /H /Y xcopy /s "bin\CheatMenuIII.asi" %III_DIR% /K /D /H /Y xcopy /s "bin\CheatMenuSA.pdb" %SA_DIR% /K /D /H /Y xcopy /s "bin\CheatMenuVC.pdb" %VC_DIR% /K /D /H /Y -xcopy /s "bin\CheatMenuIII.pdb" %III_DIR% /K /D /H /Y \ No newline at end of file +xcopy /s "bin\CheatMenuIII.pdb" %III_DIR% /K /D /H /Y +xcopy /s "..\resource\common\locale\English.toml" %SA_DIR%"\CheatMenuSA\locale\" /K /D /H /Y +xcopy /s "..\resource\common\locale\English.toml" %VC_DIR%"\CheatMenuVC\locale\" /K /D /H /Y +xcopy /s "..\resource\common\locale\English.toml" %III_DIR%"\CheatMenuIII\locale\" /K /D /H /Y \ No newline at end of file diff --git a/tools/DebugIII.bat b/tools/DebugIII.bat index a4fc6a9..b2112b3 100644 --- a/tools/DebugIII.bat +++ b/tools/DebugIII.bat @@ -9,3 +9,4 @@ del %III_DIR%"\CheatMenuIII.asi" /Q del %III_DIR%"\CheatMenuIII.pdb" /Q xcopy /s "bin\CheatMenuIII.asi" %III_DIR% /K /D /H /Y xcopy /s "bin\CheatMenuIII.pdb" %III_DIR% /K /D /H /Y +xcopy /s "..\resource\common\locale\English.toml" %III_DIR%"\CheatMenuIII\locale\" /K /D /H /Y \ No newline at end of file diff --git a/tools/DebugSA.bat b/tools/DebugSA.bat index 2acda55..bbe83e6 100644 --- a/tools/DebugSA.bat +++ b/tools/DebugSA.bat @@ -9,3 +9,5 @@ del %SA_DIR%"\CheatMenuSA.asi" /Q del %SA_DIR%"\CheatMenuSA.pdb" /Q xcopy /s "bin\CheatMenuSA.asi" %SA_DIR% /K /D /H /Y xcopy /s "bin\CheatMenuSA.pdb" %SA_DIR% /K /D /H /Y +xcopy /s "..\resource\common\locale\English.toml" %SA_DIR%"\CheatMenuSA\locale\" /K /D /H /Y + diff --git a/tools/DebugVC.bat b/tools/DebugVC.bat index 7639350..542579e 100644 --- a/tools/DebugVC.bat +++ b/tools/DebugVC.bat @@ -9,3 +9,4 @@ del %VC_DIR%"\CheatMenuVC.asi" /Q del %VC_DIR%"\CheatMenuVC.pdb" /Q xcopy /s "bin\CheatMenuVC.asi" %VC_DIR% /K /D /H /Y xcopy /s "bin\CheatMenuVC.pdb" %VC_DIR% /K /D /H /Y +xcopy /s "..\resource\common\locale\English.toml" %VC_DIR%"\CheatMenuVC\locale\" /K /D /H /Y \ No newline at end of file diff --git a/tools/ReleaseAll.bat b/tools/ReleaseAll.bat index 521ebec..5299aec 100644 --- a/tools/ReleaseAll.bat +++ b/tools/ReleaseAll.bat @@ -10,4 +10,7 @@ del %VC_DIR%"\CheatMenuVC.asi" /Q del %III_DIR%"\CheatMenuIII.asi" /Q xcopy /s "bin\CheatMenuSA.asi" %SA_DIR% /K /D /H /Y xcopy /s "bin\CheatMenuVC.asi" %VC_DIR% /K /D /H /Y -xcopy /s "bin\CheatMenuIII.asi" %III_DIR% /K /D /H /Y \ No newline at end of file +xcopy /s "bin\CheatMenuIII.asi" %III_DIR% /K /D /H /Y +xcopy /s "..\resource\common\locale\English.toml" %SA_DIR%"\CheatMenuSA\locale\" /K /D /H /Y +xcopy /s "..\resource\common\locale\English.toml" %VC_DIR%"\CheatMenuVC\locale\" /K /D /H /Y +xcopy /s "..\resource\common\locale\English.toml" %III_DIR%"\CheatMenuIII\locale\" /K /D /H /Y \ No newline at end of file diff --git a/tools/ReleaseIII.bat b/tools/ReleaseIII.bat index 5e5054e..733981d 100644 --- a/tools/ReleaseIII.bat +++ b/tools/ReleaseIII.bat @@ -7,3 +7,4 @@ call "tools\Setup.bat" MsBuild CheatMenu.sln /property:Configuration=Release /t:CheatMenuIII del %III_DIR%"\CheatMenuIII.asi" /Q xcopy /s "bin\CheatMenuIII.asi" %III_DIR% /K /D /H /Y +xcopy /s "..\resource\common\locale\English.toml" %III_DIR%"\CheatMenuIII\locale\" /K /D /H /Y \ No newline at end of file diff --git a/tools/ReleaseSA.bat b/tools/ReleaseSA.bat index a3ea188..80b8390 100644 --- a/tools/ReleaseSA.bat +++ b/tools/ReleaseSA.bat @@ -7,3 +7,4 @@ call "tools\Setup.bat" MsBuild CheatMenu.sln /property:Configuration=Release /t:CheatMenuSA del %SA_DIR%"\CheatMenuSA.asi" /Q xcopy /s "bin\CheatMenuSA.asi" %SA_DIR% /K /D /H /Y +xcopy /s "..\resource\common\locale\English.toml" %SA_DIR%"\CheatMenuSA\locale\" /K /D /H /Y \ No newline at end of file diff --git a/tools/ReleaseVC.bat b/tools/ReleaseVC.bat index 15955dd..57a504e 100644 --- a/tools/ReleaseVC.bat +++ b/tools/ReleaseVC.bat @@ -7,3 +7,4 @@ call "tools\Setup.bat" MsBuild CheatMenu.sln /property:Configuration=Release /t:CheatMenuVC del %VC_DIR%"\CheatMenuVC.asi" /Q xcopy /s "bin\CheatMenuVC.asi" %VC_DIR% /K /D /H /Y +xcopy /s "..\resource\common\locale\English.toml" %VC_DIR%"\CheatMenuVC\locale\" /K /D /H /Y \ No newline at end of file