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:
parent
111e4dc19d
commit
ef3decba53
@ -621,7 +621,21 @@ namespace big
|
||||
|
||||
bool switched_view = true;
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(window, color, gui_scale, switched_view)
|
||||
struct ingame_overlay
|
||||
{
|
||||
bool opened = true;
|
||||
bool show_with_menu_opened = false;
|
||||
|
||||
bool show_fps = true;
|
||||
bool show_players = true;
|
||||
bool show_time = true;
|
||||
bool show_replay_interface = true;
|
||||
bool show_game_versions = true;
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(ingame_overlay, opened, show_with_menu_opened, show_fps, show_players, show_time, show_replay_interface, show_game_versions)
|
||||
} ingame_overlay{};
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(window, color, gui_scale, switched_view, ingame_overlay)
|
||||
} window{};
|
||||
|
||||
struct context_menu
|
||||
|
@ -15,10 +15,11 @@ namespace big
|
||||
{
|
||||
g_renderer->add_dx_callback(view::gta_data, -1); // -1 highest priority of drawing
|
||||
g_renderer->add_dx_callback(view::notifications, -2); // second highest priority
|
||||
g_renderer->add_dx_callback(view::overlay, -3); // 3rd highest priority
|
||||
g_renderer->add_dx_callback([this]
|
||||
{
|
||||
dx_on_tick();
|
||||
}, -3); // 3rd highest priority
|
||||
}, -4); // 4th highest priority
|
||||
|
||||
g_renderer->add_wndproc_callback([this](HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
|
54
src/views/core/view_overlay.cpp
Normal file
54
src/views/core/view_overlay.cpp
Normal 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();
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
@ -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();
|
||||
|
Reference in New Issue
Block a user