refactor!: Replace premake5 with CMake. (#551)
Co-authored-by: tupoy-ya <tupoy-ya@users.noreply.github.com>
This commit is contained in:
24
src/views/core/view_active_view.cpp
Normal file
24
src/views/core/view_active_view.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#include "views/view.hpp"
|
||||
#include "pointers.hpp"
|
||||
#include "services/gui/gui_service.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void view::active_view() {
|
||||
if (g_gui_service->get_selected()->func == nullptr) return;
|
||||
|
||||
static float alpha = 1.f;
|
||||
|
||||
ImGui::SetNextWindowPos({ 300.f + 20.f, 100.f }, ImGuiCond_Always);
|
||||
ImGui::SetNextWindowSize({ 0.f, 0.f });
|
||||
ImGui::SetNextWindowSizeConstraints({ 300.f, 100.f }, { (float)*g_pointers->m_resolution_x - 270.f, (float)*g_pointers->m_resolution_y - 110.f });
|
||||
if (ImGui::Begin("main", nullptr, window_flags))
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, alpha);
|
||||
components::title(g_gui_service->get_selected()->name);
|
||||
ImGui::Separator();
|
||||
g_gui_service->get_selected()->func();
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
}
|
||||
}
|
27
src/views/core/view_heading.cpp
Normal file
27
src/views/core/view_heading.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
#include "views/view.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void view::heading()
|
||||
{
|
||||
ImGui::SetNextWindowSize({ 300.f, 80.f });
|
||||
ImGui::SetNextWindowPos({ 10.f, 10.f });
|
||||
if (ImGui::Begin("menu_heading", nullptr, window_flags | ImGuiWindowFlags_NoScrollbar))
|
||||
{
|
||||
ImGui::BeginGroup();
|
||||
ImGui::Text("Welcome");
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.172f, 0.380f, 0.909f, 1.f));
|
||||
ImGui::Text(g_local_player == nullptr || g_local_player->m_player_info == nullptr ? "unknown" : g_local_player->m_player_info->m_net_player_data.m_name);
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::EndGroup();
|
||||
ImGui::SameLine();
|
||||
ImGui::SetCursorPos({ 300.f - ImGui::CalcTextSize("Unload").x - ImGui::GetStyle().ItemSpacing.x, ImGui::GetStyle().WindowPadding.y / 2 + ImGui::GetStyle().ItemSpacing.y + (ImGui::CalcTextSize("W").y / 2) });
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.69f, 0.29f, 0.29f, 1.00f));
|
||||
if (components::nav_button("Unload"))
|
||||
{
|
||||
g_running = false;
|
||||
}
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
}
|
||||
}
|
28
src/views/core/view_navigation.cpp
Normal file
28
src/views/core/view_navigation.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
#include "services/gui/gui_service.hpp"
|
||||
#include "views/view.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void view::navigation() {
|
||||
ImGui::SetNextWindowPos({ 10.f, 100.f }, ImGuiCond_Always);
|
||||
ImGui::SetNextWindowSize({ 300.f, 0.f }, ImGuiCond_Always);
|
||||
|
||||
if (ImGui::Begin("navigation", 0, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoNav))
|
||||
{
|
||||
g_gui_service->reset_nav_size();
|
||||
for (std::pair<tabs, navigation_struct> navItem : g_gui_service->get_navigation())
|
||||
{
|
||||
switch (navItem.first)
|
||||
{
|
||||
case tabs::PLAYER:
|
||||
case tabs::DEBUG:
|
||||
continue;
|
||||
default:
|
||||
components::nav_item(navItem, 0);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
||||
}
|
96
src/views/core/view_notifications.cpp
Normal file
96
src/views/core/view_notifications.cpp
Normal file
@ -0,0 +1,96 @@
|
||||
#include "pointers.hpp"
|
||||
#include "views/view.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
float draw_notification(float start_pos, ImDrawList* dl, std::string title, std::string message, ImVec4 color)
|
||||
{
|
||||
ImColor textCol = ImGui::ColorConvertFloat4ToU32({ 1.f, 1.f, 1.f, 1.f });
|
||||
color.w = 0.5f;
|
||||
ImColor fadeBegin = ImGui::ColorConvertFloat4ToU32(color);
|
||||
color.w = 0.f;
|
||||
ImColor fadeEnd = ImGui::ColorConvertFloat4ToU32(color);
|
||||
|
||||
int j = 0;
|
||||
int prevSpace = 0;
|
||||
float total_size = 0.f;
|
||||
std::vector<std::string> split_points;
|
||||
for (int i = 0; i <= message.size(); i++)
|
||||
{
|
||||
std::string current_message = message.substr(j, i - j);
|
||||
|
||||
if (message.substr(i, 1) == " ")
|
||||
{
|
||||
prevSpace = i;
|
||||
}
|
||||
|
||||
ImVec2 size = ImGui::CalcTextSize(current_message.c_str());
|
||||
|
||||
if (i == message.size())
|
||||
{
|
||||
total_size = total_size + size.y;
|
||||
split_points.push_back(message.substr(j, i));
|
||||
}
|
||||
else if (size.x >= 330.f)
|
||||
{
|
||||
total_size = total_size + size.y;
|
||||
split_points.push_back(message.substr(j, prevSpace - j));
|
||||
j = prevSpace + 1;
|
||||
i = prevSpace;
|
||||
}
|
||||
}
|
||||
|
||||
dl->AddRectFilled({ (float)*g_pointers->m_resolution_x - 360.f, 10.f + start_pos }, { (float)*g_pointers->m_resolution_x - 10.f, start_pos + 45.f + total_size }, g->window.color);
|
||||
dl->AddRectFilledMultiColor({ (float)*g_pointers->m_resolution_x - 360.f, 10.f + start_pos }, { (float)*g_pointers->m_resolution_x - 255.f, start_pos + 45.f + total_size }, fadeBegin, fadeEnd, fadeEnd, fadeBegin);
|
||||
|
||||
dl->AddText(g->window.font_sub_title, 22.f, { (float)*g_pointers->m_resolution_x - 350.f, 15.f + start_pos }, textCol, title.c_str());
|
||||
int i = 0;
|
||||
for (std::string txt : split_points)
|
||||
{
|
||||
dl->AddText({ (float)*g_pointers->m_resolution_x - 350.f, 40.f + (i * 20.f) + start_pos}, textCol, txt.c_str());
|
||||
i++;
|
||||
}
|
||||
|
||||
return start_pos + 45.f + total_size;
|
||||
}
|
||||
|
||||
void view::notifications()
|
||||
{
|
||||
ImDrawList* draw_list = ImGui::GetBackgroundDrawList();
|
||||
|
||||
std::vector<notification> notifications = g_notification_service->get();
|
||||
|
||||
float prev_pos = 0.f;
|
||||
for (int i = 0; i < notifications.size(); i++)
|
||||
{
|
||||
notification& n = notifications[i];
|
||||
|
||||
prev_pos = draw_notification(prev_pos, draw_list, n.title, n.message, g_notification_service->notification_colors.at(n.type));
|
||||
}
|
||||
|
||||
/*ImGui::SetNextWindowSize({ (float)g->window.x * 0.2f, (float)g->window.y });
|
||||
ImGui::SetNextWindowPos({ (float)g->window.x - (float)g->window.x * 0.2f, 0 });
|
||||
if (ImGui::Begin("notifications", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoBringToFrontOnFocus))
|
||||
{
|
||||
std::vector<notification> notifications = g_notification_service->get();
|
||||
|
||||
for (int i = 0; i < notifications.size(); i++)
|
||||
{
|
||||
notification& n = notifications[i];
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, n.alpha);
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.10f, 0.09f, 0.12f, 1.00f));
|
||||
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.10f, 0.09f, 0.12f, 1.00f));
|
||||
ImGui::SetNextWindowBgAlpha(n.alpha);
|
||||
ImGui::BeginChildFrame(i, ImVec2(0, 75.f + (float)(20 * (int)(n.message.size() / 28) + 20 * (float)std::count(n.message.begin(), n.message.end(), '\n'))), ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoInputs);
|
||||
ImGui::Text(n.title.c_str());
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, g_notification_service->notification_colors.at(n.type));
|
||||
ImGui::TextWrapped(n.message.c_str());
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::EndChildFrame();
|
||||
ImGui::PopStyleColor(2);
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
ImGui::End();
|
||||
} */
|
||||
}
|
||||
}
|
14
src/views/core/view_root.cpp
Normal file
14
src/views/core/view_root.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
#include "views/view.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void view::root()
|
||||
{
|
||||
view::heading();
|
||||
view::navigation();
|
||||
view::players();
|
||||
view::active_view();
|
||||
|
||||
debug::main();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user