refactor!: globals (#717)

* refactor(globals): use macro's for to_json/from_json
* refactor(globals): switch from global pointer to global instance
This commit is contained in:
Yimura
2022-12-18 23:15:52 +01:00
committed by GitHub
parent b74dd7516c
commit ddddbd4efd
146 changed files with 1279 additions and 1901 deletions

View File

@ -31,16 +31,16 @@ namespace big
components::small_text("Teleports");
if (ImGui::BeginCombo("##apartment", apartment_names[g->session.send_to_apartment_idx]))
if (ImGui::BeginCombo("##apartment", apartment_names[g.session.send_to_apartment_idx]))
{
for (int i = 1; i < apartment_names.size(); i++)
{
if (ImGui::Selectable(apartment_names[i], i == g->session.send_to_apartment_idx))
if (ImGui::Selectable(apartment_names[i], i == g.session.send_to_apartment_idx))
{
g->session.send_to_apartment_idx = i;
g.session.send_to_apartment_idx = i;
}
if (i == g->session.send_to_apartment_idx)
if (i == g.session.send_to_apartment_idx)
{
ImGui::SetItemDefaultFocus();
}
@ -51,18 +51,18 @@ namespace big
ImGui::SameLine();
components::button("TP To Apartment", [] { toxic::send_player_to_apartment(g_player_service->get_selected(), g->session.send_to_apartment_idx); });
components::button("TP To Apartment", [] { toxic::send_player_to_apartment(g_player_service->get_selected(), g.session.send_to_apartment_idx); });
if (ImGui::BeginCombo("##warehouse", warehouse_names[g->session.send_to_warehouse_idx]))
if (ImGui::BeginCombo("##warehouse", warehouse_names[g.session.send_to_warehouse_idx]))
{
for (int i = 1; i < warehouse_names.size(); i++)
{
if (ImGui::Selectable(warehouse_names[i], i == g->session.send_to_warehouse_idx))
if (ImGui::Selectable(warehouse_names[i], i == g.session.send_to_warehouse_idx))
{
g->session.send_to_warehouse_idx = i;
g.session.send_to_warehouse_idx = i;
}
if (i == g->session.send_to_warehouse_idx)
if (i == g.session.send_to_warehouse_idx)
{
ImGui::SetItemDefaultFocus();
}
@ -73,7 +73,7 @@ namespace big
ImGui::SameLine();
components::button("TP To Warehouse", [] { toxic::send_player_to_warehouse(g_player_service->get_selected(), g->session.send_to_warehouse_idx); });
components::button("TP To Warehouse", [] { toxic::send_player_to_warehouse(g_player_service->get_selected(), g.session.send_to_warehouse_idx); });
components::button("TP To Darts", [] { toxic::start_activity(g_player_service->get_selected(), eActivityType::Darts); });
ImGui::SameLine();

View File

@ -32,7 +32,7 @@ namespace big
Vehicle veh = PED::GET_VEHICLE_PED_IS_IN(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_player_service->get_selected()->id()), FALSE);
if (veh == 0)
{
if (g->player.spectating)
if (g.player.spectating)
g_notification_service->push_warning("Remote Control", "Player not in a vehicle");
else
g_notification_service->push_warning("Remote Control", "Player not in a vehicle, try spectating the player");
@ -40,7 +40,7 @@ namespace big
}
vehicle::remote_control_vehicle(veh);
g->player.spectating = false;
g.player.spectating = false;
});
ImGui::TreePop();

View File

@ -7,7 +7,7 @@ namespace big
std::string title = std::format("Player Options: {}", g_player_service->get_selected()->get_name());
ImGui::Text(title.c_str());
ImGui::Checkbox("Spectate", &g->player.spectating);
ImGui::Checkbox("Spectate", &g.player.spectating);
if (g_player_service->get_selected()->is_valid())
{

View File

@ -30,7 +30,7 @@ namespace big
// calculate icons width
const auto window = ImGui::GetCurrentWindow();
ImGui::PushFont(g->window.font_icon);
ImGui::PushFont(g.window.font_icon);
const auto icons_size = ImGui::CalcTextSize(player_iconsc, player_icons_end);
const ImVec2 icons_pos(window->DC.CursorPos.x + 300.0f - 32.0f - icons_size.x, window->DC.CursorPos.y + 2.0f);
const ImRect icons_box(icons_pos, icons_pos + icons_size);
@ -48,7 +48,7 @@ namespace big
{
g_player_service->set_selected(plyr);
g_gui_service->set_selected(tabs::PLAYER);
g->window.switched_view = true;
g.window.switched_view = true;
}
ImGui::PopID();
ImGui::PopStyleVar();
@ -60,7 +60,7 @@ namespace big
ImGui::PopStyleColor();
// render icons on top of the player button
ImGui::PushFont(g->window.font_icon);
ImGui::PushFont(g.window.font_icon);
ImGui::RenderTextWrapped(icons_box.Min, player_iconsc, player_icons_end, icons_size.x);
ImGui::PopFont();
}