diff --git a/resource/CheatMenuSA/misc.txd b/resource/CheatMenuSA/misc.txd index 0836c88..5e508f5 100644 Binary files a/resource/CheatMenuSA/misc.txd and b/resource/CheatMenuSA/misc.txd differ diff --git a/resource/common/locale/English.toml b/resource/common/locale/English.toml index c5feb7c..c834d59 100644 --- a/resource/common/locale/English.toml +++ b/resource/common/locale/English.toml @@ -228,6 +228,7 @@ Example: tp x y z""" TextColor = "Text color" TextOnlyMode = "Text only" TextOnlyModeHint = "Disables all images and shows only text" +TPMarkerKey = "Teleport to marker" Usage = "Usage" UpdaterInfo1 = "It's highly recommanded to update to the latest version. Newer version contains new features and bug fixes." UpdaterInfo2 = "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." @@ -399,8 +400,9 @@ InvalidLocation = "Invalid location" Location = "Location" LocationHint = "Groove Street" LocationRemoved = "Location removed" -QuickTeleport = "Quick teleport" -QuickTeleportHint = """ +QuickTeleport = "Quick Teleport" +QuickTeleportHint = "Open quick teleport using " +TeleportMarkerHint = """ Teleport to the location of your radar target blip using """ TargetBlipText = "Target blip not found. You need to place it on the map first" diff --git a/src/cheatmenu.cpp b/src/cheatmenu.cpp index 083b236..1b4481b 100644 --- a/src/cheatmenu.cpp +++ b/src/cheatmenu.cpp @@ -300,6 +300,11 @@ void CheatMenu::Init() D3dHook::SetMouseState(m_bShowMenu); } + + if (quickTeleport.PressedRealtime()) + { + D3dHook::SetMouseState(true); + } } }; } diff --git a/src/defines.h b/src/defines.h index a2c741c..82adacf 100644 --- a/src/defines.h +++ b/src/defines.h @@ -9,7 +9,7 @@ #define MENU_NAME "Cheat Menu" #define MENU_VERSION_NUMBER "3.3" #define MENU_VERSION MENU_VERSION_NUMBER"-beta" -#define BUILD_NUMBER "20220701" +#define BUILD_NUMBER "20220707" #define MENU_TITLE MENU_NAME " v" MENU_VERSION #ifdef GTASA diff --git a/src/game.cpp b/src/game.cpp index afa364a..d31e61f 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -91,9 +91,9 @@ void Freecam::Process() speed *= 2; } - if (freeCamForward.PressedBasic() || freeCamBackward.PressedBasic()) + if (freeCamForward.PressedRealtime() || freeCamBackward.PressedRealtime()) { - if (freeCamBackward.PressedBasic()) + if (freeCamBackward.PressedRealtime()) { speed *= -1; } @@ -105,9 +105,9 @@ void Freecam::Process() pos.z += speed * 2 * sin(m_fTotalMouse.y / 3 * 3.14159f / 180.0f); } - if (freeCamLeft.PressedBasic() || freeCamRight.PressedBasic()) + if (freeCamLeft.PressedRealtime() || freeCamRight.PressedRealtime()) { - if (freeCamLeft.PressedBasic()) + if (freeCamLeft.PressedRealtime()) { speed *= -1; } diff --git a/src/hotkeys.cpp b/src/hotkeys.cpp index b15e07c..935b1a6 100644 --- a/src/hotkeys.cpp +++ b/src/hotkeys.cpp @@ -282,7 +282,7 @@ bool Hotkey::Pressed() return false; } -bool Hotkey::PressedBasic() +bool Hotkey::PressedRealtime() { return (m_CurrentHotkey == "") ? KeyPressed(m_key1) && KeyPressed(m_key2) : false; } diff --git a/src/hotkeys.h b/src/hotkeys.h index bd1de52..732cfa6 100644 --- a/src/hotkeys.h +++ b/src/hotkeys.h @@ -63,6 +63,6 @@ public: // Returns true if the hotkeys are pressed bool Pressed(); - // Returns true if the hotkeys are pressed, with no checks - bool PressedBasic(); + // Returns true if the hotkeys are pressed in realtime + bool PressedRealtime(); }; diff --git a/src/menu.cpp b/src/menu.cpp index 955f168..02ae0ad 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -464,7 +464,8 @@ void Menu::ShowPage() freeCamLeft.DrawUI(TEXT("Menu.FreecamLeftKey")); freeCamRight.DrawUI(TEXT("Menu.FreecamRightKey")); quickTeleport.DrawUI(TEXT("Menu.QuickTPKey")); - + teleportMarker.DrawUI(TEXT("Menu.TPMarkerKey")); + ImGui::Dummy(ImVec2(0, 10)); fixVeh.DrawUI(TEXT("Menu.FixVehKey")); diff --git a/src/pch.cpp b/src/pch.cpp index 5690a4b..e914125 100644 --- a/src/pch.cpp +++ b/src/pch.cpp @@ -2,6 +2,7 @@ eRenderer gRenderer = Render_Unknown; DataStore gConfig = DataStore(FILE_NAME, true); +ResourceStore gTextureList { "misc", eResourceType::TYPE_IMAGE, ImVec2(100, 80) }; Hotkey aimSkinChanger {VK_RETURN, VK_RETURN, "AimSkinChanger"}; Hotkey freeCam {VK_F6, VK_F6, "Freecam.Toggle"}; Hotkey freeCamForward {VK_KEY_I, VK_KEY_I, "Freecam.Forward"};; @@ -15,7 +16,8 @@ Hotkey flipVeh {VK_NONE, VK_NONE, "Vehicle.Flip"}; Hotkey godMode {VK_NONE, VK_NONE, "GodMode"}; Hotkey menuOpen {VK_LCONTROL, VK_KEY_M, "MenuToggle"}; Hotkey quickSceenShot {VK_F5, VK_F5, "QuickScreenshot"}; -Hotkey quickTeleport {VK_KEY_X, VK_KEY_Y, "QuickTeleport"}; +Hotkey quickTeleport {VK_LSHIFT, VK_KEY_Q, "QuickTeleport"}; +Hotkey teleportMarker {VK_KEY_X, VK_KEY_Y, "TeleportShortcut"}; Hotkey vehEngine {VK_NONE, VK_NONE, "Vehicle.EngineToggle"}; Hotkey vehInstantStart {VK_NONE, VK_NONE, "Vehicle.InstantStart"}; Hotkey vehInstantStop {VK_NONE, VK_NONE, "Vehicle.InstantStop"}; \ No newline at end of file diff --git a/src/pch.h b/src/pch.h index b4448ab..84dbeed 100644 --- a/src/pch.h +++ b/src/pch.h @@ -112,6 +112,8 @@ extern Hotkey godMode; extern Hotkey menuOpen; extern Hotkey quickSceenShot; extern Hotkey quickTeleport; +extern Hotkey teleportMarker; extern Hotkey vehEngine; extern Hotkey vehInstantStart; -extern Hotkey vehInstantStop; \ No newline at end of file +extern Hotkey vehInstantStop; +extern ResourceStore gTextureList; \ No newline at end of file diff --git a/src/resourcestore.cpp b/src/resourcestore.cpp index 98d94e7..e9c5acf 100644 --- a/src/resourcestore.cpp +++ b/src/resourcestore.cpp @@ -50,6 +50,18 @@ RwTexDictionary* LoadTexDictionary(char const* filename) { return plugin::CallAndReturnDynGlobal(0x5B3860, filename); } +RwTexture* ResourceStore::FindTextureByName(std::string&& name) +{ + for (auto& item: m_ImagesList) + { + if (item->m_FileName == name) + { + return item->m_pRwTexture; + } + } + return nullptr; +} + void ResourceStore::LoadTextureResource(std::string&& name) { std::string fullPath = PLUGIN_PATH((char*)FILE_NAME "\\") + name + ".txd"; diff --git a/src/resourcestore.h b/src/resourcestore.h index 1ca82c0..a721f23 100644 --- a/src/resourcestore.h +++ b/src/resourcestore.h @@ -66,4 +66,6 @@ public: bool m_bTexturesLoaded = false; ResourceStore(const char* text, eResourceType type = TYPE_IMAGE, ImVec2 imageSize = ImVec2(64, 64)); + + RwTexture* FindTextureByName(std::string&& name); }; \ No newline at end of file diff --git a/src/rpc.cpp b/src/rpc.cpp index ee359af..26c3f94 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -112,10 +112,12 @@ void RPC::Process() detailsText = std::format("{}: ${}", TEXT("Player.Money"), pInfo->m_nMoney); } +#ifndef GTA3 if (pPed->m_nAreaCode != 0) // world { stateText = TEXT("RPC.InsideInterior"); } +#endif if (BY_GAME(pPed->m_nPedFlags.bInVehicle, pPed->m_bInVehicle, pPed->m_bInVehicle)) { diff --git a/src/teleport.cpp b/src/teleport.cpp index 7023ef9..69a45b0 100644 --- a/src/teleport.cpp +++ b/src/teleport.cpp @@ -36,49 +36,90 @@ void Teleport::FetchRadarSpriteData() void Teleport::Init() { + m_bTeleportMarker = gConfig.Get("Features.TeleportMarker", false); m_bQuickTeleport = gConfig.Get("Features.QuickTeleport", false); Events::processScriptsEvent += [] { - if ((QuickTP::m_bEnabled == true) && ((CTimer::m_snTimeInMilliseconds - QuickTP::m_nTimer) > 500)) + if ((TPMarker::m_bEnabled == true) && ((CTimer::m_snTimeInMilliseconds - TPMarker::m_nTimer) > 500)) { CPlayerPed* player = FindPlayerPed(); #ifdef GTASA CEntity* player_entity = FindPlayerEntity(-1); - QuickTP::m_fPos.z = CWorld::FindGroundZFor3DCoord(QuickTP::m_fPos.x, QuickTP::m_fPos.y, - QuickTP::m_fPos.z + 100.0f, nullptr, &player_entity) + 1.0f; + TPMarker::m_fPos.z = CWorld::FindGroundZFor3DCoord(TPMarker::m_fPos.x, TPMarker::m_fPos.y, + TPMarker::m_fPos.z + 100.0f, nullptr, &player_entity) + 1.0f; #else - QuickTP::m_fPos.z = CWorld::FindGroundZFor3DCoord(QuickTP::m_fPos.x, QuickTP::m_fPos.y, - QuickTP::m_fPos.z + 100.0f, nullptr) + 1.0f; + TPMarker::m_fPos.z = CWorld::FindGroundZFor3DCoord(TPMarker::m_fPos.x, TPMarker::m_fPos.y, + TPMarker::m_fPos.z + 100.0f, nullptr) + 1.0f; #endif CVehicle* pVeh = player->m_pVehicle; if (pVeh && BY_GAME(player->m_nPedFlags.bInVehicle, player->m_pVehicle, player->m_pVehicle)) { - BY_GAME(pVeh->Teleport(QuickTP::m_fPos, false), pVeh->Teleport(QuickTP::m_fPos), player->Teleport(QuickTP::m_fPos)); + BY_GAME(pVeh->Teleport(TPMarker::m_fPos, false), pVeh->Teleport(TPMarker::m_fPos), player->Teleport(TPMarker::m_fPos)); } else { - BY_GAME(player->Teleport(QuickTP::m_fPos, false), player->Teleport(QuickTP::m_fPos), player->Teleport(QuickTP::m_fPos)); + BY_GAME(player->Teleport(TPMarker::m_fPos, false), player->Teleport(TPMarker::m_fPos), player->Teleport(TPMarker::m_fPos)); } - QuickTP::m_bEnabled = false; + TPMarker::m_bEnabled = false; Command(CPools::GetPedRef(player), false); Command(); TheCamera.Fade(0, 1); } - if (m_bQuickTeleport) + if (m_bTeleportMarker && teleportMarker.Pressed()) { - if (quickTeleport.Pressed() - && ((CTimer::m_snTimeInMilliseconds - m_nQuickTeleportTimer) > 500)) + TeleportPlayer(true); + } + }; + +#ifdef GTASA + Events::drawingEvent += [] + { + if (m_bQuickTeleport && quickTeleport.PressedRealtime()) + { + static CSprite2d map; + if (!map.m_pTexture) { - m_nQuickTeleportTimer = CTimer::m_snTimeInMilliseconds; + map.m_pTexture = gTextureList.FindTextureByName("map"); + } + float height = screen::GetScreenHeight(); + float width = screen::GetScreenWidth(); + float size = width * height / width; // keep aspect ratio + float left = (width-size) / 2; + float right = left+size; + map.Draw(CRect(left, 0.0f, right, height), CRGBA(255, 255, 255, 200)); + + if (ImGui::IsMouseClicked(0)) + { + // Convert screen space to image space + ImVec2 pos = ImGui::GetMousePos(); + pos.x = (pos.x < left) ? left : pos.x; + pos.x = (pos.x > right) ? right : pos.x; + pos.x -= left; + pos.x -= size/2; + pos.y -= size/2; + + // Convert image space to map space + pos.x = pos.x / size * 6000; + pos.y = pos.y / size * 6000; + pos.y *= -1; + + tRadarTrace &target = CRadar::ms_RadarTrace[FrontEndMenuManager.m_nTargetBlipIndex]; + CVector temp = target.m_vecPos; + unsigned char sprite = target.m_nRadarSprite; + target.m_nRadarSprite = RADAR_SPRITE_WAYPOINT; + target.m_vecPos = {pos.x, pos.y, 0.0f}; TeleportPlayer(true); + target.m_vecPos = temp; + target.m_nRadarSprite = sprite; } } }; +#endif } void Teleport::TeleportPlayer(bool get_marker, CVector pos, int interior_id) @@ -100,9 +141,9 @@ void Teleport::TeleportPlayer(bool get_marker, CVector pos, int interior_id) pos = targetBlip.m_vecPos; pos.z = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, 1000, nullptr, &pPlayerEntity) + 500.f; - QuickTP::m_fPos = pos; - QuickTP::m_nTimer = CTimer::m_snTimeInMilliseconds; - QuickTP::m_bEnabled = true; + TPMarker::m_fPos = pos; + TPMarker::m_nTimer = CTimer::m_snTimeInMilliseconds; + TPMarker::m_bEnabled = true; TheCamera.Fade(0, 0); Command(CPools::GetPedRef(pPlayer), true); } @@ -214,7 +255,6 @@ void Teleport::ShowPage() { ImGui::Columns(2, nullptr, false); ImGui::Checkbox(TEXT("Teleport.InsertCoord"), &m_bInsertCoord); - ImGui::NextColumn(); #ifdef GTASA if (Widget::Checkbox(TEXT("Teleport.QuickTeleport"), &m_bQuickTeleport, std::string(TEXT_S("Teleport.QuickTeleportHint") @@ -222,6 +262,15 @@ void Teleport::ShowPage() { gConfig.Set("Features.QuickTeleport", m_bQuickTeleport); } +#endif + ImGui::NextColumn(); +#ifdef GTASA + if (Widget::Checkbox(TEXT("Teleport.TeleportMarker"), &m_bTeleportMarker, + std::string(TEXT_S("Teleport.TeleportMarkerHint") + + teleportMarker.GetNameString()).c_str())) + { + gConfig.Set("Features.TeleportMarker", m_bTeleportMarker); + } #endif ImGui::Columns(1); ImGui::Spacing(); diff --git a/src/teleport.h b/src/teleport.h index 3292749..15aa662 100644 --- a/src/teleport.h +++ b/src/teleport.h @@ -6,12 +6,12 @@ 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]; - static inline uint m_nQuickTeleportTimer; - struct QuickTP + struct TPMarker { static inline bool m_bEnabled; static inline CVector m_fPos = { -1, -1, -1 }; diff --git a/src/visual.cpp b/src/visual.cpp index ade70bc..add89c3 100644 --- a/src/visual.cpp +++ b/src/visual.cpp @@ -689,7 +689,7 @@ void Visual::ShowPage() { static float var = 0.000001f; static CSprite2d sprite; - sprite.m_pTexture = m_MiscData.m_ImagesList[0]->m_pRwTexture; + sprite.m_pTexture = gTextureList.FindTextureByName("radardisc"); // rediect to our texture patch::Set(0x58A8C9, &sprite); diff --git a/src/visual.h b/src/visual.h index 5719783..6885566 100644 --- a/src/visual.h +++ b/src/visual.h @@ -16,7 +16,6 @@ private: static inline bool m_bNoTextures; static inline bool m_bFullScreenMap; static inline bool m_bSquareRadar; - static inline ResourceStore m_MiscData { "misc", eResourceType::TYPE_IMAGE, ImVec2(100, 80) }; #endif template