chore: Cleaned and moved handling window code
This commit is contained in:
parent
c349cb521f
commit
a2b2308b20
@ -0,0 +1,38 @@
|
||||
#include "handling_tabs.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void tab_handling::tab_current_profile()
|
||||
{
|
||||
if (ImGui::BeginTabItem("Current Profile"))
|
||||
{
|
||||
if (ImGui::Button("Save Profile"))
|
||||
{
|
||||
ImGui::OpenPopup("Save Handling");
|
||||
}
|
||||
|
||||
modal_handling::modal_save_handling();
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Restore Handling"))
|
||||
{
|
||||
g_vehicle_service->restore_vehicle();
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::BeginTabBar("handling_tabbar");
|
||||
tab_current_profile::tab_general();
|
||||
tab_current_profile::tab_other();
|
||||
tab_current_profile::tab_brakes();
|
||||
tab_current_profile::tab_gearing();
|
||||
tab_current_profile::tab_traction();
|
||||
tab_current_profile::tab_steering();
|
||||
tab_current_profile::tab_suspension();
|
||||
tab_current_profile::tab_rollbars();
|
||||
tab_current_profile::tab_roll_centre_height();
|
||||
ImGui::EndTabBar();
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
}
|
||||
}
|
54
BigBaseV2/src/gui/window/handling/handling_my_profiles.cpp
Normal file
54
BigBaseV2/src/gui/window/handling/handling_my_profiles.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
#include "handling_tabs.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void tab_handling::tab_my_profiles()
|
||||
{
|
||||
if (ImGui::BeginTabItem("My Profiles"))
|
||||
{
|
||||
if (!g_vehicle_service->update_mine())
|
||||
ImGui::Text("Loading profiles...");
|
||||
else
|
||||
{
|
||||
if (g_vehicle_service->m_my_profiles.size() == 0)
|
||||
ImGui::Text("You have no profiles available for this vehicle.");
|
||||
for (auto& key : g_vehicle_service->m_my_profiles)
|
||||
{
|
||||
if (auto it = g_vehicle_service->m_handling_profiles.find(key); it != g_vehicle_service->m_handling_profiles.end())
|
||||
{
|
||||
auto& profile = it->second;
|
||||
|
||||
if (profile.share_code == g_vehicle_service->get_active_profile(profile.handling_hash))
|
||||
ImGui::TextColored({ 0.1254f,0.8039f,0.3137f,1.f }, "Active");
|
||||
|
||||
ImGui::BeginGroup();
|
||||
|
||||
ImGui::Text("Name:");
|
||||
ImGui::Text("Description:");
|
||||
|
||||
ImGui::EndGroup();
|
||||
ImGui::SameLine();
|
||||
ImGui::BeginGroup();
|
||||
|
||||
ImGui::Text(profile.name.c_str());
|
||||
ImGui::TextWrapped(profile.description.c_str());
|
||||
|
||||
ImGui::EndGroup();
|
||||
ImGui::SameLine();
|
||||
ImGui::BeginGroup();
|
||||
|
||||
ImGui::Text("Share Code: %s", profile.share_code.c_str());
|
||||
if (ImGui::Button("Load Profile"))
|
||||
g_vehicle_service->set_handling_profile(profile);
|
||||
|
||||
ImGui::EndGroup();
|
||||
|
||||
ImGui::Separator();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
}
|
||||
}
|
63
BigBaseV2/src/gui/window/handling/handling_search.cpp
Normal file
63
BigBaseV2/src/gui/window/handling/handling_search.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
#include "fiber_pool.hpp"
|
||||
#include "handling_tabs.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void tab_handling::tab_search()
|
||||
{
|
||||
if (ImGui::BeginTabItem("Search"))
|
||||
{
|
||||
static char search[13];
|
||||
ImGui::InputTextWithHint("##search_share_code", "Search by share code", search, sizeof(search));
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Search"))
|
||||
g_fiber_pool->queue_job([&] { g_vehicle_service->get_by_share_code(search); });
|
||||
|
||||
switch (g_vehicle_service->m_search_status)
|
||||
{
|
||||
case SearchStatus::SEARCHING:
|
||||
ImGui::Text("Searching...");
|
||||
|
||||
break;
|
||||
case SearchStatus::NO_RESULT:
|
||||
ImGui::Text("No results found for %s", search);
|
||||
|
||||
break;
|
||||
case SearchStatus::FAILED:
|
||||
ImGui::Text("Search failed, host is down or response body is invalid...");
|
||||
|
||||
break;
|
||||
case SearchStatus::FOUND:
|
||||
if (auto it = g_vehicle_service->m_handling_profiles.find(search); it != g_vehicle_service->m_handling_profiles.end())
|
||||
{
|
||||
auto& profile = it->second;
|
||||
ImGui::BeginGroup();
|
||||
|
||||
ImGui::Text("Name:");
|
||||
ImGui::Text("Description:");
|
||||
|
||||
ImGui::EndGroup();
|
||||
ImGui::SameLine();
|
||||
ImGui::BeginGroup();
|
||||
|
||||
ImGui::Text(profile.name.c_str());
|
||||
ImGui::TextWrapped(profile.description.c_str());
|
||||
|
||||
ImGui::EndGroup();
|
||||
ImGui::SameLine();
|
||||
ImGui::BeginGroup();
|
||||
|
||||
ImGui::Text("Share Code: %s", profile.share_code.c_str());
|
||||
if (ImGui::Button("Load Profile"))
|
||||
g_vehicle_service->set_handling_profile(profile);
|
||||
|
||||
ImGui::EndGroup();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
}
|
||||
}
|
13
BigBaseV2/src/gui/window/handling/handling_tabs.hpp
Normal file
13
BigBaseV2/src/gui/window/handling/handling_tabs.hpp
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
#include "current_profile/current_profile_tabs.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
class tab_handling
|
||||
{
|
||||
public:
|
||||
static void tab_current_profile();
|
||||
static void tab_my_profiles();
|
||||
static void tab_search();
|
||||
};
|
||||
}
|
@ -20,136 +20,9 @@ namespace big
|
||||
g_vehicle_service->attempt_save();
|
||||
|
||||
ImGui::BeginTabBar("handling_profiles");
|
||||
if (ImGui::BeginTabItem("Current Profile"))
|
||||
{
|
||||
if (ImGui::Button("Save Profile"))
|
||||
{
|
||||
ImGui::OpenPopup("Save Handling");
|
||||
}
|
||||
|
||||
modal_handling::modal_save_handling();
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Restore Handling"))
|
||||
{
|
||||
g_vehicle_service->restore_vehicle();
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::BeginTabBar("handling_tabbar");
|
||||
tab_handling::tab_general();
|
||||
tab_handling::tab_other();
|
||||
tab_handling::tab_brakes();
|
||||
tab_handling::tab_gearing();
|
||||
tab_handling::tab_traction();
|
||||
tab_handling::tab_steering();
|
||||
tab_handling::tab_suspension();
|
||||
tab_handling::tab_rollbars();
|
||||
tab_handling::tab_roll_centre_height();
|
||||
ImGui::EndTabBar();
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
if (ImGui::BeginTabItem("My Profiles"))
|
||||
{
|
||||
if (!g_vehicle_service->update_mine())
|
||||
ImGui::Text("Loading profiles...");
|
||||
else
|
||||
{
|
||||
if (g_vehicle_service->m_my_profiles.size() == 0)
|
||||
ImGui::Text("You have no profiles available for this vehicle.");
|
||||
for (auto &key : g_vehicle_service->m_my_profiles)
|
||||
{
|
||||
if (auto it = g_vehicle_service->m_handling_profiles.find(key); it != g_vehicle_service->m_handling_profiles.end())
|
||||
{
|
||||
auto& profile = it->second;
|
||||
|
||||
if (profile.share_code == g_vehicle_service->get_active_profile(profile.handling_hash))
|
||||
ImGui::TextColored({ 0.1254f,0.8039f,0.3137f,1.f }, "Active");
|
||||
|
||||
ImGui::BeginGroup();
|
||||
|
||||
ImGui::Text("Name:");
|
||||
ImGui::Text("Description:");
|
||||
|
||||
ImGui::EndGroup();
|
||||
ImGui::SameLine();
|
||||
ImGui::BeginGroup();
|
||||
|
||||
ImGui::Text(profile.name.c_str());
|
||||
ImGui::TextWrapped(profile.description.c_str());
|
||||
|
||||
ImGui::EndGroup();
|
||||
ImGui::SameLine();
|
||||
ImGui::BeginGroup();
|
||||
|
||||
ImGui::Text("Share Code: %s", profile.share_code.c_str());
|
||||
if (ImGui::Button("Load Profile"))
|
||||
g_vehicle_service->set_handling_profile(profile);
|
||||
|
||||
ImGui::EndGroup();
|
||||
|
||||
ImGui::Separator();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
if (ImGui::BeginTabItem("Search"))
|
||||
{
|
||||
static char search[13];
|
||||
ImGui::InputTextWithHint("##search_share_code", "Search by share code", search, sizeof(search));
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Search"))
|
||||
g_fiber_pool->queue_job([&] { g_vehicle_service->get_by_share_code(search); });
|
||||
|
||||
switch (g_vehicle_service->m_search_status)
|
||||
{
|
||||
case SearchStatus::SEARCHING:
|
||||
ImGui::Text("Searching...");
|
||||
|
||||
break;
|
||||
case SearchStatus::NO_RESULT:
|
||||
ImGui::Text("No results found for %s", search);
|
||||
|
||||
break;
|
||||
case SearchStatus::FAILED:
|
||||
ImGui::Text("Search failed, host is down or response body is invalid...");
|
||||
|
||||
break;
|
||||
case SearchStatus::FOUND:
|
||||
if (auto it = g_vehicle_service->m_handling_profiles.find(search); it != g_vehicle_service->m_handling_profiles.end())
|
||||
{
|
||||
auto& profile = it->second;
|
||||
ImGui::BeginGroup();
|
||||
|
||||
ImGui::Text("Name:");
|
||||
ImGui::Text("Description:");
|
||||
|
||||
ImGui::EndGroup();
|
||||
ImGui::SameLine();
|
||||
ImGui::BeginGroup();
|
||||
|
||||
ImGui::Text(profile.name.c_str());
|
||||
ImGui::TextWrapped(profile.description.c_str());
|
||||
|
||||
ImGui::EndGroup();
|
||||
ImGui::SameLine();
|
||||
ImGui::BeginGroup();
|
||||
|
||||
ImGui::Text("Share Code: %s", profile.share_code.c_str());
|
||||
if (ImGui::Button("Load Profile"))
|
||||
g_vehicle_service->set_handling_profile(profile);
|
||||
|
||||
ImGui::EndGroup();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
tab_handling::tab_current_profile();
|
||||
tab_handling::tab_my_profiles();
|
||||
tab_handling::tab_search();
|
||||
ImGui::EndTabBar();
|
||||
|
||||
ImGui::End();
|
||||
|
Reference in New Issue
Block a user