diff --git a/src/game.cpp b/src/game.cpp index 0994e10..28eb5a4 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -705,39 +705,14 @@ void Game::ShowPage() } if (ImGui::CollapsingHeader(TEXT("Game.ChangeRadioStaion"))) { - static std::string channels[] = { - "Playback FM", "KRose", "KDST", "Bounce FM", "SFUR", "Radio Los Santos", "Radio X", - "CSR ", "KJah West", "Master Sounds", "WCTR", "User Tracks", "None" - }; + static const char* channels = + "Playback FM\0KRose\0KDST\0Bounce FM\0SFUR\0Radio Los Santos\0Radio X\0CSR\0KJah West\0" + "Master Sounds\0WCTR\0User Tracks\0None\0"; - int channelIndex = 0; - Command(&channelIndex); - if (ImGui::ArrowButton("Left", ImGuiDir_Left)) + int curStation = Command(); + if (ImGui::Combo(TEXT("Game.CurrentStation"), &curStation, channels)) { - if (channelIndex == 0) - { - channelIndex = 12; - } - else - { - --channelIndex; - } - Command(channelIndex); - } - ImGui::SameLine(); - ImGui::Text("%s: %s",TEXT("Game.CurrentStation"), channels[channelIndex].c_str()); - ImGui::SameLine(); - if (ImGui::ArrowButton("Right", ImGuiDir_Right)) - { - if (channelIndex == 12) - { - channelIndex = 0; - } - else - { - ++channelIndex; - } - Command(channelIndex); + Command(curStation); } ImGui::Spacing(); ImGui::Separator(); diff --git a/src/menu.cpp b/src/menu.cpp index ba1f59b..c471f29 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -278,7 +278,7 @@ void Menu::ProcessCommands() ss >> temp; pos.z = std::stof(temp); - Teleport::TeleportPlayer(false, pos, 0); + Teleport::WarpPlayer(pos); } catch (...) { diff --git a/src/teleport.cpp b/src/teleport.cpp index 703b82f..bdffb6c 100644 --- a/src/teleport.cpp +++ b/src/teleport.cpp @@ -78,7 +78,7 @@ void Teleport::Init() if (m_bTeleportMarker && teleportMarker.Pressed()) { - TeleportPlayer(true); + WarpPlayer(); } }; @@ -114,14 +114,7 @@ void Teleport::Init() 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; + WarpPlayer(CVector(pos.x, pos.y, 0.0f)); } } } @@ -129,7 +122,8 @@ void Teleport::Init() #endif } -void Teleport::TeleportPlayer(bool get_marker, CVector pos, int interior_id) +template +void Teleport::WarpPlayer(CVector pos, int interiorID) { CPlayerPed* pPlayer = FindPlayerPed(); CVehicle* pVeh = pPlayer->m_pVehicle; @@ -137,17 +131,20 @@ void Teleport::TeleportPlayer(bool get_marker, CVector pos, int interior_id) #ifdef GTASA TPMarker::m_bJetpack = Command(0); - if (get_marker) - { - tRadarTrace targetBlip = CRadar::ms_RadarTrace[LOWORD(FrontEndMenuManager.m_nTargetBlipIndex)]; - - if (targetBlip.m_nRadarSprite != RADAR_SPRITE_WAYPOINT) + if (Type == eTeleportType::Marker || Type == eTeleportType::MapPosition) + { + if (Type == eTeleportType::Marker) { - SetHelpMessage(TEXT("Teleport.TargetBlipText")); - return; - } + tRadarTrace targetBlip = CRadar::ms_RadarTrace[LOWORD(FrontEndMenuManager.m_nTargetBlipIndex)]; + if (targetBlip.m_nRadarSprite != RADAR_SPRITE_WAYPOINT) + { + SetHelpMessage(TEXT("Teleport.TargetBlipText")); + return; + } + pos = targetBlip.m_vecPos; + } + CEntity* pPlayerEntity = FindPlayerEntity(-1); - pos = targetBlip.m_vecPos; pos.z = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, 1000, nullptr, &pPlayerEntity) + 500.f; TPMarker::m_fPos = pos; @@ -156,8 +153,6 @@ void Teleport::TeleportPlayer(bool get_marker, CVector pos, int interior_id) TheCamera.Fade(0, 0); Command(CPools::GetPedRef(pPlayer), true); } - - #endif #ifdef GTA3 @@ -198,7 +193,7 @@ void Teleport::TeleportPlayer(bool get_marker, CVector pos, int interior_id) reinterpret_cast(pVeh)->PlaceOnRoadProperly(); } - pVeh->m_nAreaCode = interior_id; + pVeh->m_nAreaCode = interiorID; } } else @@ -225,8 +220,8 @@ void Teleport::TeleportPlayer(bool get_marker, CVector pos, int interior_id) #endif #if defined GTASA || defined GTAVC - pPlayer->m_nAreaCode = interior_id; - Command(interior_id); + pPlayer->m_nAreaCode = interiorID; + Command(interiorID); #endif } @@ -237,7 +232,7 @@ void Teleport::TeleportToLocation(std::string& rootkey, std::string& bLocName, s int dimension = 0; CVector pos; sscanf(loc.c_str(), "%d,%f,%f,%f", &dimension, &pos.x, &pos.y, &pos.z); - TeleportPlayer(false, pos, dimension); + WarpPlayer(pos, dimension); } catch (...) { @@ -312,7 +307,7 @@ void Teleport::ShowPage() { sscanf(m_nInputBuffer,"%f,%f,%f", &pos.x, &pos.y, &pos.z); pos.z += 1.0f; - TeleportPlayer(false, pos); + WarpPlayer(pos); } catch (...) { @@ -323,12 +318,12 @@ void Teleport::ShowPage() #ifdef GTASA if (ImGui::Button((TEXT_S("Teleport.TeleportMarker") + "##Btn").c_str(), Widget::CalcSize(2))) { - TeleportPlayer(true); + WarpPlayer(); } #else if (ImGui::Button(TEXT("Teleport.TeleportCenter"), Widget::CalcSize(2))) { - TeleportPlayer(false, CVector(0, 0, 23)); + TeleportPlayer(CVector(0, 0, 23), eTeleportType::Coordinate); } #endif ImGui::EndChild(); diff --git a/src/teleport.h b/src/teleport.h index f45d6ef..8bb0521 100644 --- a/src/teleport.h +++ b/src/teleport.h @@ -1,6 +1,13 @@ #pragma once #include "pch.h" +enum class eTeleportType +{ + Marker, + MapPosition, + Coordinate, +}; + class Teleport { private: @@ -37,6 +44,7 @@ public: 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); + template + static void WarpPlayer(CVector pos = CVector(0, 0, 0), int interiorID = 0); static void ShowPage(); };