feat(ui): add ingame overlay (#910)

* feat(overlay): add current time
* feat(overlay): add customization options
* fix(overlay): use local time zone
* fix(overlay): enable by default
* feat(overlay): add position modification
This commit is contained in:
Johann
2023-01-31 00:21:29 +01:00
committed by GitHub
parent 97240c54b7
commit e95e7d1b47
5 changed files with 92 additions and 2 deletions

View File

@ -0,0 +1,54 @@
#include "views/view.hpp"
#include "pointers.hpp"
#include "gta_util.hpp"
#include "gui.hpp"
namespace big
{
void view::overlay()
{
if (!g.window.ingame_overlay.opened || (g_gui->is_open() && !g.window.ingame_overlay.show_with_menu_opened))
return;
ImGui::SetNextWindowPos(ImVec2(10.0f, 10.0f), ImGuiCond_FirstUseEver, ImVec2(0.0f, 0.0f));
ImGui::SetNextWindowBgAlpha(0.3f);
if (ImGui::Begin("overlay", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav))
{
ImGui::Text("YimMenu");
ImGui::Separator();
if (g.window.ingame_overlay.show_fps)
ImGui::Text("%.0f FPS", ImGui::GetIO().Framerate / 2);
if (CNetworkPlayerMgr *network_player_mgr = gta_util::get_network_player_mgr(); g.window.ingame_overlay.show_players)
ImGui::Text(std::format("Players: {}/{}", network_player_mgr->m_player_count, network_player_mgr->m_player_limit).c_str());
if (g.window.ingame_overlay.show_time)
ImGui::Text(std::format("Time: {:%d-%m-%Y %H:%M:%OS}", std::chrono::current_zone()->to_local(std::chrono::system_clock::now())).c_str());
if (auto replay_interface = *g_pointers->m_replay_interface; g.window.ingame_overlay.show_replay_interface)
{
ImGui::Separator();
if(replay_interface->m_ped_interface)
ImGui::Text(std::format("Ped Pool: {}/{}", replay_interface->m_ped_interface->m_cur_peds, replay_interface->m_ped_interface->m_max_peds).c_str());
if(replay_interface->m_vehicle_interface)
ImGui::Text(std::format("Vehicle Pool: {}/{}", replay_interface->m_vehicle_interface->m_cur_vehicles, replay_interface->m_vehicle_interface->m_max_vehicles).c_str());
if(replay_interface->m_object_interface)
ImGui::Text(std::format("Object Pool: {}/{}", replay_interface->m_object_interface->m_cur_objects, replay_interface->m_object_interface->m_max_objects).c_str());
}
if (g.window.ingame_overlay.show_game_versions)
{
ImGui::Separator();
ImGui::Text(std::format("Game Version: {}", g_pointers->m_game_version).c_str());
ImGui::Text(std::format("Online Version: {}", g_pointers->m_online_version).c_str());
}
}
ImGui::End();
}
}

View File

@ -19,6 +19,26 @@ namespace big
{
g.window.color = ImGui::ColorConvertFloat4ToU32(col_gui);
}
components::sub_title("Ingame Overlay");
ImGui::Checkbox("Show Overlay", &g.window.ingame_overlay.opened);
ImGui::SameLine();
ImGui::Checkbox("Show when Menu opened", &g.window.ingame_overlay.show_with_menu_opened);
ImGui::BeginGroup();
ImGui::Checkbox("Show FPS", &g.window.ingame_overlay.show_fps);
ImGui::Checkbox("Show Players", &g.window.ingame_overlay.show_players);
ImGui::Checkbox("Show Time", &g.window.ingame_overlay.show_time);
ImGui::EndGroup();
ImGui::SameLine();
ImGui::BeginGroup();
ImGui::Checkbox("Show Replay Interface", &g.window.ingame_overlay.show_replay_interface);
ImGui::Checkbox("Show Game Version", &g.window.ingame_overlay.show_game_versions);
ImGui::EndGroup();
}
}

View File

@ -27,6 +27,7 @@ namespace big
static void mobile();
static void navigation();
static void notifications();
static void overlay();
static void root();
static void self();
static void session();