mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2025-07-01 12:02:55 +08:00
Player database improvements (#1705)
* feat(protections): add per-player sync block options * feat(player_database): improve player tracker * fix(rapid_fire): remove unnecessary log statement * fix(player_database): default state should be UNKNOWN, not INVALID
This commit is contained in:
@ -249,6 +249,7 @@ namespace big
|
||||
global_test.global_appendages.clear();
|
||||
}
|
||||
ImGui::EndGroup();
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
}
|
||||
}
|
@ -47,8 +47,10 @@ namespace big
|
||||
ImGui::SameLine();
|
||||
components::button("JOIN_SESSION_INFO"_T, [] {
|
||||
rage::rlSessionInfo info;
|
||||
g_pointers->m_gta.m_decode_session_info(&info, base64, nullptr);
|
||||
session::join_session(info);
|
||||
if (g_pointers->m_gta.m_decode_session_info(&info, base64, nullptr))
|
||||
session::join_session(info);
|
||||
else
|
||||
g_notification_service->push_error("Join", "Session info is invalid");
|
||||
});
|
||||
|
||||
components::button("COPY_SESSION_INFO"_T, [] {
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "core/data/command_access_levels.hpp"
|
||||
#include "core/data/infractions.hpp"
|
||||
#include "fiber_pool.hpp"
|
||||
#include "gta/enums.hpp"
|
||||
#include "pointers.hpp"
|
||||
#include "services/api/api_service.hpp"
|
||||
#include "services/player_database/player_database_service.hpp"
|
||||
@ -17,6 +18,18 @@ namespace big
|
||||
bool notes_dirty = false;
|
||||
std::shared_ptr<persistent_player> current_player;
|
||||
|
||||
ImVec4 get_player_color(persistent_player& player)
|
||||
{
|
||||
if (player.session_type == GSType::Unknown)
|
||||
return ImVec4(.5f, .5f, .5f, 1.0f);
|
||||
else if (player.session_type == GSType::Invalid)
|
||||
return ImVec4(1.f, 0.f, 0.f, 1.f);
|
||||
else if (!player_database_service::is_joinable_session(player.session_type))
|
||||
return ImVec4(1.f, 1.f, 0.f, 1.f);
|
||||
else
|
||||
return ImVec4(0.f, 1.f, 0.f, 1.f);
|
||||
}
|
||||
|
||||
void draw_player_db_entry(std::shared_ptr<persistent_player> player, const std::string& lower_search)
|
||||
{
|
||||
std::string name = player->name;
|
||||
@ -28,15 +41,9 @@ namespace big
|
||||
|
||||
float circle_size = 7.5f;
|
||||
auto cursor_pos = ImGui::GetCursorScreenPos();
|
||||
auto plyr_state = player->online_state;
|
||||
|
||||
//render status circle
|
||||
ImGui::GetWindowDrawList()->AddCircleFilled(ImVec2(cursor_pos.x + 4.f + circle_size, cursor_pos.y + 4.f + circle_size),
|
||||
circle_size,
|
||||
ImColor(plyr_state == PlayerOnlineStatus::ONLINE ? ImVec4(0.f, 1.f, 0.f, 1.f) :
|
||||
plyr_state == PlayerOnlineStatus::OFFLINE ? ImVec4(1.f, 0.f, 0.f, 1.f) :
|
||||
plyr_state == PlayerOnlineStatus::UNKNOWN ? ImVec4(.5f, .5f, .5f, 1.0f) :
|
||||
ImVec4(.5f, .5f, .5f, 1.0f)));
|
||||
ImGui::GetWindowDrawList()->AddCircleFilled(ImVec2(cursor_pos.x + 4.f + circle_size, cursor_pos.y + 4.f + circle_size), circle_size, ImColor(get_player_color(*player)));
|
||||
|
||||
//we need some padding
|
||||
ImVec2 cursor = ImGui::GetCursorPos();
|
||||
@ -57,6 +64,9 @@ namespace big
|
||||
strncpy(note_buffer, current_player->notes.data(), sizeof(note_buffer));
|
||||
}
|
||||
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip(player_database_service::get_session_type_str(player->session_type));
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
}
|
||||
@ -76,13 +86,20 @@ namespace big
|
||||
|
||||
for (auto& player : item_arr | std::ranges::views::values)
|
||||
{
|
||||
if (player->online_state == PlayerOnlineStatus::ONLINE)
|
||||
if (player_database_service::is_joinable_session(player->session_type))
|
||||
draw_player_db_entry(player, lower_search);
|
||||
}
|
||||
|
||||
for (auto& player : item_arr | std::ranges::views::values)
|
||||
{
|
||||
if (player->online_state != PlayerOnlineStatus::ONLINE)
|
||||
if (!player_database_service::is_joinable_session(player->session_type) && player->session_type != GSType::Invalid
|
||||
&& player->session_type != GSType::Unknown)
|
||||
draw_player_db_entry(player, lower_search);
|
||||
}
|
||||
|
||||
for (auto& player : item_arr | std::ranges::views::values)
|
||||
{
|
||||
if (player->session_type == GSType::Invalid || player->session_type == GSType::Unknown)
|
||||
draw_player_db_entry(player, lower_search);
|
||||
}
|
||||
}
|
||||
@ -107,7 +124,7 @@ namespace big
|
||||
if (ImGui::InputScalar("RID"_T.data(), ImGuiDataType_S64, ¤t_player->rockstar_id)
|
||||
|| ImGui::Checkbox("IS_MODDER"_T.data(), ¤t_player->is_modder)
|
||||
|| ImGui::Checkbox("BLOCK_JOIN"_T.data(), ¤t_player->block_join)
|
||||
|| ImGui::Checkbox("Notify When Online", ¤t_player->notify_online))
|
||||
|| ImGui::Checkbox("Track Player", ¤t_player->notify_online))
|
||||
{
|
||||
if (current_player->rockstar_id != selected->rockstar_id)
|
||||
g_player_database_service->update_rockstar_id(selected->rockstar_id, current_player->rockstar_id);
|
||||
@ -212,10 +229,28 @@ namespace big
|
||||
|
||||
if (ImGui::Button("REMOVE_ALL"_T.data()))
|
||||
{
|
||||
g_player_database_service->set_selected(nullptr);
|
||||
g_player_database_service->get_players().clear();
|
||||
g_player_database_service->get_sorted_players().clear();
|
||||
g_player_database_service->save();
|
||||
ImGui::OpenPopup("##removeall");
|
||||
}
|
||||
|
||||
if (ImGui::BeginPopupModal("##removeall"))
|
||||
{
|
||||
ImGui::Text("Are you sure?");
|
||||
|
||||
if (ImGui::Button("Yes"))
|
||||
{
|
||||
g_player_database_service->set_selected(nullptr);
|
||||
g_player_database_service->get_players().clear();
|
||||
g_player_database_service->get_sorted_players().clear();
|
||||
g_player_database_service->save();
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("No"))
|
||||
{
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
@ -224,8 +259,18 @@ namespace big
|
||||
g_player_database_service->update_player_states();
|
||||
});
|
||||
|
||||
if (components::command_checkbox<"player_db_auto_update_states">())
|
||||
g_player_database_service->start_update_loop();
|
||||
if (ImGui::TreeNode("Player Tracking"))
|
||||
{
|
||||
if (components::command_checkbox<"player_db_auto_update_states">("Enable"))
|
||||
g_player_database_service->start_update_loop();
|
||||
ImGui::Checkbox("Notify When Online", &g.player_db.notify_when_online);
|
||||
ImGui::Checkbox("Notify When Joinable", &g.player_db.notify_when_joinable);
|
||||
ImGui::Checkbox("Notify When Unjoinable", &g.player_db.notify_when_unjoinable);
|
||||
ImGui::Checkbox("Notify When Offline", &g.player_db.notify_when_offline);
|
||||
ImGui::Checkbox("Notify On Session Type Change", &g.player_db.notify_on_session_type_change);
|
||||
ImGui::Checkbox("Notify On Session Change", &g.player_db.notify_on_session_change);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
components::sub_title("NEW_ENTRY"_T);
|
||||
@ -244,7 +289,7 @@ namespace big
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("SEARCH"_T.data()))
|
||||
{
|
||||
g_thread_pool->push([]{
|
||||
g_thread_pool->push([] {
|
||||
if (!g_api_service->get_rid_from_username(new_name, *(uint64_t*)&new_rockstar_id))
|
||||
{
|
||||
g_notification_service->push_error("New Player DB Entry", std::format("No user '{}' called could be found.", new_name));
|
||||
|
@ -40,11 +40,11 @@ namespace big
|
||||
|
||||
if (id != -1)
|
||||
{
|
||||
auto& stats = scr_globals::gpbd_fm_1.as<GPBD_FM*>()->Entries[id].PlayerStats;
|
||||
auto& boss_goon = scr_globals::gpbd_fm_3.as<GPBD_FM_3*>()->Entries[id].BossGoon;
|
||||
auto& stats = scr_globals::gpbd_fm_1.as<GPBD_FM*>()->Entries[id].PlayerStats;
|
||||
auto& boss_goon = scr_globals::gpbd_fm_3.as<GPBD_FM_3*>()->Entries[id].BossGoon;
|
||||
|
||||
const auto money = reinterpret_cast<uint64_t&>(stats.Money);
|
||||
const auto wallet = reinterpret_cast<uint64_t&>(stats.WalletBalance);
|
||||
const auto money = reinterpret_cast<uint64_t&>(stats.Money);
|
||||
const auto wallet = reinterpret_cast<uint64_t&>(stats.WalletBalance);
|
||||
|
||||
if (boss_goon.Language >= 0 && boss_goon.Language < 13)
|
||||
ImGui::Text("PLAYER_INFO_LANGUAGE"_T.data(), languages[boss_goon.Language].name);
|
||||
@ -69,6 +69,11 @@ namespace big
|
||||
}
|
||||
|
||||
ImGui::Checkbox("Block Explosions", &g_player_service->get_selected()->block_explosions);
|
||||
ImGui::Checkbox("Block Clone Creates", &g_player_service->get_selected()->block_clone_create);
|
||||
ImGui::Checkbox("Block Clone Syncs", &g_player_service->get_selected()->block_clone_sync);
|
||||
ImGui::Checkbox("Block Network Events", &g_player_service->get_selected()->block_net_events);
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::BeginCombo("CHAT_COMMAND_PERMISSIONS"_T.data(),
|
||||
COMMAND_ACCESS_LEVELS[g_player_service->get_selected()->command_access_level.value_or(
|
||||
|
@ -3,12 +3,12 @@
|
||||
#include "core/data/special_ammo_types.hpp"
|
||||
#include "fiber_pool.hpp"
|
||||
#include "gta/joaat.hpp"
|
||||
#include "gta/weapons.hpp"
|
||||
#include "natives.hpp"
|
||||
#include "pointers.hpp"
|
||||
#include "services/gta_data/gta_data_service.hpp"
|
||||
#include "views/view.hpp"
|
||||
#include "services/persist_weapons/persist_weapons.hpp"
|
||||
#include "gta/weapons.hpp"
|
||||
#include "views/view.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
@ -274,7 +274,7 @@ namespace big
|
||||
}
|
||||
if (ImGui::CollapsingHeader("Persist Weapons"))
|
||||
{
|
||||
ImGui::Checkbox("Enabled", &g.persist_weapons.enabled);
|
||||
ImGui::Checkbox("Enabled##persist_weapons", &g.persist_weapons.enabled);
|
||||
|
||||
static std::string selected_loadout = g.persist_weapons.weapon_loadout_file;
|
||||
ImGui::PushItemWidth(250);
|
||||
@ -311,14 +311,14 @@ namespace big
|
||||
}
|
||||
if (ImGui::CollapsingHeader("Weapon Hotkeys"))
|
||||
{
|
||||
ImGui::Checkbox("Enabled", &g.weapons.enable_weapon_hotkeys);
|
||||
ImGui::Checkbox("Enabled##weapon_hotkeys", &g.weapons.enable_weapon_hotkeys);
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
ImGui::SetTooltip("This will select the next weapon in the hotkey list.\r\nThe first weapon in the list is the first weapon it will select, then the second is the one it will select after and so on.\r\nAfter the end of the list, it will wrap back to the first weapon.");
|
||||
}
|
||||
|
||||
static int selected_key = 0;
|
||||
const char* const keys[]{ "1", "2", "3", "4", "5", "6" };
|
||||
const char* const keys[]{"1", "2", "3", "4", "5", "6"};
|
||||
|
||||
ImGui::PushItemWidth(250);
|
||||
ImGui::Combo("Key", &selected_key, keys, IM_ARRAYSIZE(keys));
|
||||
|
Reference in New Issue
Block a user