mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2025-06-22 16:52:30 +08:00
refactor!: Replace premake5 with CMake. (#551)
Co-authored-by: tupoy-ya <tupoy-ya@users.noreply.github.com>
This commit is contained in:
192
src/views/players/view_player.cpp
Normal file
192
src/views/players/view_player.cpp
Normal file
@ -0,0 +1,192 @@
|
||||
#include "gta_util.hpp"
|
||||
#include "services/pickups/pickup_service.hpp"
|
||||
#include "services/players/player_service.hpp"
|
||||
#include "util/globals.hpp"
|
||||
#include "util/misc.hpp"
|
||||
#include "util/ped.hpp"
|
||||
#include "util/teleport.hpp"
|
||||
#include "views/view.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void view::view_player() {
|
||||
|
||||
std::string title = std::format("Player Options: {}", g_player_service->get_selected()->get_name());
|
||||
|
||||
ImGui::Text(title.c_str());
|
||||
ImGui::Checkbox("Spectate", &g->player.spectating);
|
||||
|
||||
if (g_player_service->get_selected()->is_valid())
|
||||
{
|
||||
if (ImGui::TreeNode("Misc"))
|
||||
{
|
||||
components::button("Steal Outfit", [] {
|
||||
ped::steal_outfit(
|
||||
PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_player_service->get_selected()->id())
|
||||
);
|
||||
});
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
components::button("Steal Identity", [] {
|
||||
ped::steal_identity(
|
||||
PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_player_service->get_selected()->id())
|
||||
);
|
||||
});
|
||||
|
||||
components::button("Clear Wanted Level", [] {
|
||||
globals::clear_wanted_player(g_player_service->get_selected()->id());
|
||||
});
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
ImGui::Checkbox("Never Wanted", &g_player_service->get_selected()->never_wanted);
|
||||
|
||||
components::button("Give Health", [] {
|
||||
g_pickup_service->give_player_health(g_player_service->get_selected()->id());
|
||||
});
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
components::button("Give Armour", [] {
|
||||
g_pickup_service->give_player_armour(g_player_service->get_selected()->id());
|
||||
});
|
||||
|
||||
components::button("Give Ammo", [] {
|
||||
g_pickup_service->give_player_ammo(g_player_service->get_selected()->id());
|
||||
});
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
components::button("Give Weapons", [] {
|
||||
g_pickup_service->give_player_weapons(g_player_service->get_selected()->id());
|
||||
});
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
if (ImGui::TreeNode("Info")) {
|
||||
|
||||
ImGui::Text("Player ID: %d", g_player_service->get_selected()->id());
|
||||
|
||||
ImGui::Text("Session Host: %s", g_player_service->get_selected()->is_host() ? "Yes" : "No");
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (CPlayerInfo* player_info = g_player_service->get_selected()->get_player_info(); player_info != nullptr)
|
||||
{
|
||||
ImGui::Text("Wanted Level: %d", player_info->m_wanted_level);
|
||||
}
|
||||
|
||||
uint32_t ped_damage_bits = 0;
|
||||
uint32_t ped_task_flag = 0;
|
||||
uint32_t veh_damage_bits = 0;
|
||||
std::string mode_str = "";
|
||||
|
||||
if (CPed* ped = g_player_service->get_selected()->get_ped(); ped != nullptr)
|
||||
{
|
||||
ped_damage_bits = ped->m_damage_bits;
|
||||
ped_task_flag = ped->m_ped_task_flag;
|
||||
}
|
||||
|
||||
if (ped_damage_bits & (uint32_t)eEntityProofs::GOD)
|
||||
{
|
||||
mode_str = "God";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ped_damage_bits & (uint32_t)eEntityProofs::BULLET)
|
||||
{
|
||||
mode_str += "Bullet, ";
|
||||
}
|
||||
if (ped_damage_bits & (uint32_t)eEntityProofs::EXPLOSION)
|
||||
{
|
||||
mode_str += "Explosion, ";
|
||||
}
|
||||
}
|
||||
|
||||
if (mode_str.empty())
|
||||
{
|
||||
mode_str = "No";
|
||||
}
|
||||
|
||||
ImGui::Text("Player God Mode: %s", mode_str.c_str());
|
||||
|
||||
mode_str = "";
|
||||
|
||||
if (auto vehicle = g_player_service->get_selected()->get_current_vehicle(); vehicle != nullptr)
|
||||
{
|
||||
veh_damage_bits = vehicle->m_damage_bits;
|
||||
}
|
||||
|
||||
if (ped_task_flag & (uint8_t)ePedTask::TASK_DRIVING)
|
||||
{
|
||||
if (veh_damage_bits & (uint32_t)eEntityProofs::GOD)
|
||||
{
|
||||
mode_str = "God";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (veh_damage_bits & (uint32_t)eEntityProofs::COLLISION)
|
||||
{
|
||||
mode_str += "Collision, ";
|
||||
}
|
||||
if (veh_damage_bits & (uint32_t)eEntityProofs::EXPLOSION)
|
||||
{
|
||||
mode_str += "Explosion, ";
|
||||
}
|
||||
}
|
||||
|
||||
if (mode_str.empty())
|
||||
{
|
||||
mode_str = "No";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mode_str = "No vehicle detected";
|
||||
}
|
||||
|
||||
ImGui::Text("Vehicle God Mode: %s", mode_str.c_str());
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (auto net_player_data = g_player_service->get_selected()->get_net_data(); net_player_data != nullptr)
|
||||
{
|
||||
ImGui::Text("Rockstar ID: %d", net_player_data->m_gamer_handle_2.m_rockstar_id);
|
||||
ImGui::Text(
|
||||
"IP Address: %d.%d.%d.%d:%d",
|
||||
net_player_data->m_external_ip.m_field1,
|
||||
net_player_data->m_external_ip.m_field2,
|
||||
net_player_data->m_external_ip.m_field3,
|
||||
net_player_data->m_external_ip.m_field4,
|
||||
net_player_data->m_external_port
|
||||
);
|
||||
}
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
if (ImGui::TreeNode("Teleport"))
|
||||
{
|
||||
components::button("Teleport", [] {
|
||||
teleport::to_player(g_player_service->get_selected()->id());
|
||||
});
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
components::button("Bring", [] {
|
||||
teleport::bring_player(g_player_service->get_selected()->id());
|
||||
});
|
||||
|
||||
components::button("Teleport into Vehicle", [] {
|
||||
Vehicle veh = PED::GET_VEHICLE_PED_IS_IN(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_player_service->get_selected()->id()), false);
|
||||
|
||||
teleport::into_vehicle(veh);
|
||||
});
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
99
src/views/players/view_players.cpp
Normal file
99
src/views/players/view_players.cpp
Normal file
@ -0,0 +1,99 @@
|
||||
#include "pointers.hpp"
|
||||
#include "services/gui/gui_service.hpp"
|
||||
#include "services/players/player_service.hpp"
|
||||
#include "views/view.hpp"
|
||||
#include "fonts/fonts.hpp"
|
||||
#include "natives.hpp"
|
||||
#include "fiber_pool.hpp"
|
||||
|
||||
#define IMGUI_DEFINE_PLACEMENT_NEW
|
||||
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||
#include <imgui_internal.h>
|
||||
|
||||
namespace big
|
||||
{
|
||||
static void player_button(const player_ptr& plyr)
|
||||
{
|
||||
bool selected_player = plyr == g_player_service->get_selected();
|
||||
|
||||
// generate icons string
|
||||
std::string player_icons;
|
||||
if (plyr->is_host())
|
||||
player_icons += FONT_ICON_HOST;
|
||||
if (plyr->is_friend())
|
||||
player_icons += FONT_ICON_FRIEND;
|
||||
if (const auto ped = plyr->get_ped(); ped != nullptr && ped->m_ped_task_flag & (uint8_t)ePedTask::TASK_DRIVING)
|
||||
player_icons += FONT_ICON_VEHICLE;
|
||||
|
||||
const auto player_iconsc = player_icons.c_str();
|
||||
const auto player_icons_end = player_iconsc + player_icons.size();
|
||||
|
||||
// calculate icons width
|
||||
const auto window = ImGui::GetCurrentWindow();
|
||||
ImGui::PushFont(g->window.font_icon);
|
||||
const auto icons_size = ImGui::CalcTextSize(player_iconsc, player_icons_end);
|
||||
const ImVec2 icons_pos(window->DC.CursorPos.x + 300.0f - 32.0f - icons_size.x, window->DC.CursorPos.y + 2.0f);
|
||||
const ImRect icons_box(icons_pos, icons_pos + icons_size);
|
||||
ImGui::PopFont();
|
||||
|
||||
if (selected_player)
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.29f, 0.45f, 0.69f, 1.f));
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, { 0.0, 0.5 });
|
||||
ImGui::PushID(plyr->id());
|
||||
if (ImGui::Button(plyr->get_name(), { 300.0f - ImGui::GetStyle().ScrollbarSize, 0.f }))
|
||||
{
|
||||
g_player_service->set_selected(plyr);
|
||||
g_gui_service->set_selected(tabs::PLAYER);
|
||||
g->window.switched_view = true;
|
||||
}
|
||||
ImGui::PopID();
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
if (selected_player)
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
// render icons on top of the player button
|
||||
ImGui::PushFont(g->window.font_icon);
|
||||
ImGui::RenderTextWrapped(icons_box.Min, player_iconsc, player_icons_end, icons_size.x);
|
||||
ImGui::PopFont();
|
||||
}
|
||||
|
||||
void view::players()
|
||||
{
|
||||
const auto player_count = g_player_service->players().size() + 1;
|
||||
|
||||
if (!*g_pointers->m_is_session_started && player_count < 2) return;
|
||||
float window_pos = 110.f + g_gui_service->nav_ctr * ImGui::CalcTextSize("W").y + g_gui_service->nav_ctr * ImGui::GetStyle().ItemSpacing.y + g_gui_service->nav_ctr * ImGui::GetStyle().ItemInnerSpacing.y + ImGui::GetStyle().WindowPadding.y;
|
||||
|
||||
ImGui::SetNextWindowSize({ 300.f, 0.f });
|
||||
ImGui::SetNextWindowPos({ 10.f, window_pos });
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, { 2.0f, 2.0f });
|
||||
|
||||
if (ImGui::Begin("playerlist", nullptr, window_flags))
|
||||
{
|
||||
float window_height = (ImGui::CalcTextSize("A").y + ImGui::GetStyle().ItemInnerSpacing.y * 2 + 6.0f) * player_count + 10.0f;
|
||||
window_height = window_height + window_pos > (float)*g_pointers->m_resolution_y - 10.f ? (float)*g_pointers->m_resolution_y - (window_pos + 40.f) : window_height;
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBg, { 0.f, 0.f, 0.f, 0.f });
|
||||
ImGui::PushStyleColor(ImGuiCol_ScrollbarBg, { 0.f, 0.f, 0.f, 0.f });
|
||||
|
||||
if (ImGui::BeginListBox("##players", { ImGui::GetWindowSize().x - ImGui::GetStyle().WindowPadding.x * 2 , window_height }))
|
||||
{
|
||||
player_button(g_player_service->get_self());
|
||||
|
||||
if (player_count > 1)
|
||||
ImGui::Separator();
|
||||
|
||||
for (const auto& [_, player] : g_player_service->players())
|
||||
player_button(player);
|
||||
|
||||
ImGui::EndListBox();
|
||||
}
|
||||
ImGui::PopStyleColor(2);
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user