Lua Scripting (#1334)

Closes #83
Fixes #1309
Fixes #1287
Fixes #1129 (actually fixed now)
This commit is contained in:
maybegreat48
2023-06-06 07:40:40 +00:00
committed by GitHub
parent 35bb398c01
commit 03c1a96b67
201 changed files with 156682 additions and 838 deletions

View File

@ -1,5 +1,6 @@
#include "views/view.hpp"
#include "lua/lua_manager.hpp"
#include "pointers.hpp"
#include "services/gui/gui_service.hpp"
#include "services/translation_service/translation_service.hpp"
@ -8,7 +9,9 @@ namespace big
{
void view::active_view()
{
if (g_gui_service->get_selected()->func == nullptr)
auto selected = g_gui_service->get_selected();
if (selected->func == nullptr)
return;
static float alpha = 1.f;
@ -17,16 +20,22 @@ namespace big
ImGui::SetNextWindowSize({0.f, 0.f});
ImGui::SetNextWindowSizeConstraints({300.f, 100.f},
{(float)*g_pointers->m_gta.m_resolution_x - 270.f, (float)*g_pointers->m_gta.m_resolution_y - 110.f});
if (ImGui::Begin("main", nullptr, window_flags))
{
const char* key = nullptr;
if (key = g_translation_service.get_translation(g_gui_service->get_selected()->name).data(); !key)
key = g_gui_service->get_selected()->name;
if (key = g_translation_service.get_translation(selected->hash).data(); !key)
key = selected->name;
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, alpha);
components::title(key);
ImGui::Separator();
g_gui_service->get_selected()->func();
selected->func();
if (g_lua_manager)
g_lua_manager->draw_gui(selected->hash);
ImGui::PopStyleVar();
}
ImGui::End();

View File

@ -191,6 +191,9 @@ namespace big
if (ImGui::IsItemHovered())
ImGui::SetTooltip("INCLUDING_YOU"_T.data());
components::command_button<"bringall">({});
ImGui::SameLine();
components::command_button<"giveweapsall">({});
ImGui::SameLine();
components::command_button<"remweapsall">({});

View File

@ -15,11 +15,6 @@ namespace big
{
if (ImGui::TreeNode("INFO"_T.data()))
{
components::button("Open SC Overlay", [] {
uint64_t gamerHandle[13];
NETWORK::NETWORK_HANDLE_FROM_PLAYER(g_player_service->get_selected()->id(), (Any*)&gamerHandle, 13);
NETWORK::NETWORK_SHOW_PROFILE_UI((Any*)&gamerHandle);
});
ImGui::Text("PLAYER_INFO_ID"_T.data(), g_player_service->get_selected()->id());
ImGui::Text("PLAYER_INFO_SESSION_HOST"_T.data(),
@ -164,12 +159,14 @@ namespace big
ImGui::Text("PLAYER_INFO_LAP_DANCES"_T.data(), stats.LapDancesBought);
ImGui::Text("PLAYER_INFO_MISSIONS_CREATED"_T.data(), stats.MissionsCreated);
ImGui::Text("PLAYER_INFO_METLDOWN_COMPLETE"_T.data(),
scr_globals::gpbd_fm_1.as<GPBD_FM*>()->Entries[id].MeltdownComplete ? "YES"_T.data() : "NO"_T.data()); // curious to see if anyone has actually played singleplayer
scr_globals::gpbd_fm_1.as<GPBD_FM*>()->Entries[id].MeltdownComplete ? "YES"_T.data() : "NO"_T.data()); // curious to see if anyone has actually played singleplayer
ImGui::Separator();
}
ImGui::Checkbox("Block Explosions", &g_player_service->get_selected()->block_explosions);
if (ImGui::BeginCombo("CHAT_COMMAND_PERMISSIONS"_T.data(),
COMMAND_ACCESS_LEVELS[g_player_service->get_selected()->command_access_level.value_or(g.session.chat_command_default_access_level)]))
{
@ -197,6 +194,14 @@ namespace big
g_player_database_service->get_or_create_player(g_player_service->get_selected());
}
ImGui::SameLine();
components::button("Open SC Overlay", [] {
uint64_t gamerHandle[13];
NETWORK::NETWORK_HANDLE_FROM_PLAYER(g_player_service->get_selected()->id(), (Any*)&gamerHandle, 13);
NETWORK::NETWORK_SHOW_PROFILE_UI((Any*)&gamerHandle);
});
ImGui::TreePop();
}
}

View File

@ -79,8 +79,6 @@ namespace big
components::sub_title("MISC"_T);
components::command_checkbox<"crosshairs">();
ImGui::SameLine();
components::command_checkbox<"norecoil">();
ImGui::SameLine();
components::command_checkbox<"nospread">();

View File

@ -0,0 +1,67 @@
#include "fiber_pool.hpp"
#include "lua/lua_manager.hpp"
#include "script.hpp"
#include "thread_pool.hpp"
#include "util/scripts.hpp"
#include "views/view.hpp"
namespace big
{
static std::weak_ptr<lua_module> selected_module{};
static bool show = true;
void view::lua_scripts()
{
ImGui::PushItemWidth(250);
components::sub_title("Loaded Lua Scipts");
if (ImGui::ListBoxHeader("##empty", ImVec2(200, 200)))
{
auto& modules = g_lua_manager->get_modules();
if (show && modules.size() > 0)
{
for (const auto& module : modules)
{
if (ImGui::Selectable(module->module_name().c_str(),
!selected_module.expired() && selected_module.lock().get() == module.get()))
selected_module = module;
}
}
else
{
ImGui::Text("No scripts loaded");
}
ImGui::ListBoxFooter();
}
ImGui::SameLine();
ImGui::BeginGroup();
if (!selected_module.expired())
{
ImGui::Text("Scripts Registered: %d", selected_module.lock()->m_registered_scripts.size());
ImGui::Text("Memory Patches Registered: %d", selected_module.lock()->m_registered_patches.size());
ImGui::Text("GUI Tabs Registered: %d", selected_module.lock()->m_gui.size());
components::button("Reload", [] {
auto name = selected_module.lock()->module_name();
auto id = selected_module.lock()->module_id();
g_lua_manager->unload_module(id);
g_lua_manager->load_module(name);
selected_module = g_lua_manager->get_module(id);
});
}
ImGui::EndGroup();
components::button("Reload All", [] {
show = false;
g_lua_manager->reload_all_modules();
show = true;
});
}
}

View File

@ -141,13 +141,13 @@ namespace big
components::sub_title("RAINBOW_PAINT"_T);
{
ImGui::Checkbox("PRIMARY"_T.data(), &g.vehicle.rainbow_paint.primary);
components::command_checkbox<"rainbowpri">("PRIMARY"_T);
ImGui::SameLine();
ImGui::Checkbox("SECONDARY"_T.data(), &g.vehicle.rainbow_paint.secondary);
components::command_checkbox<"rainbowsec">("SECONDARY"_T);
ImGui::SameLine();
ImGui::Checkbox("NEON"_T.data(), &g.vehicle.rainbow_paint.neon);
components::command_checkbox<"rainbowneons">("NEON"_T);
ImGui::SameLine();
ImGui::Checkbox("SMOKE"_T.data(), &g.vehicle.rainbow_paint.smoke);
components::command_checkbox<"rainbowsmoke">("SMOKE"_T);
const char* rgb_types[] = {"OFF"_T.data(), "FADE"_T.data(), "SPASM"_T.data()};
@ -175,7 +175,7 @@ namespace big
{
ImGui::SameLine();
ImGui::SetNextItemWidth(150);
ImGui::SliderInt("RGB_SPEED"_T.data(), &g.vehicle.rainbow_paint.speed, 1, 10);
components::command_int_slider<"rainbowspeed">("RGB_SPEED"_T);
}
}
ImGui::Separator();
@ -208,7 +208,7 @@ namespace big
{
ImGui::BeginGroup();
ImGui::Checkbox("ENABLED"_T.data(), &g.vehicle.fly.enabled);
components::command_checkbox<"vehiclefly">("ENABLED"_T);
ImGui::Checkbox("DONT_STOP"_T.data(), &g.vehicle.fly.dont_stop);
ImGui::EndGroup();

View File

@ -59,7 +59,7 @@ namespace big
{
ImGui::BeginGroup();
ImGui::Checkbox("GOD_MODE"_T.data(), &g.vehicle.god_mode);
components::command_checkbox<"vehgodmode">("GOD_MODE"_T.data());
components::command_checkbox<"hornboost">();
components::command_checkbox<"vehjump">();
components::command_checkbox<"invisveh">();

View File

@ -62,6 +62,7 @@ namespace big
static void nearby();
static void world();
static void gta_cache();
static void lua_scripts();
static void player_info();
static void player_troll();

View File

@ -1,3 +1,4 @@
#include "core/data/weathers.hpp"
#include "fiber_pool.hpp"
#include "util/session.hpp"
#include "views/view.hpp"
@ -6,36 +7,36 @@ namespace big
{
void view::time_and_weather()
{
if (ImGui::TreeNode("LOCAL_TIME"_T.data()))
components::command_checkbox<"timeoverride">();
if (g.world.custom_time.override_time)
{
ImGui::Checkbox("OVERRIDE_TIME"_T.data(), &g.session.override_time);
if (g.session.override_time)
{
ImGui::SliderInt("HOUR"_T.data(), &g.session.custom_time.hour, 0, 23);
ImGui::SliderInt("MINUTE"_T.data(), &g.session.custom_time.minute, 0, 59);
ImGui::SliderInt("SECOND"_T.data(), &g.session.custom_time.second, 0, 59);
}
ImGui::TreePop();
ImGui::SliderInt("HOUR"_T.data(), &g.world.custom_time.hour, 0, 23);
ImGui::SliderInt("MINUTE"_T.data(), &g.world.custom_time.minute, 0, 59);
ImGui::SliderInt("SECOND"_T.data(), &g.world.custom_time.second, 0, 59);
}
if (ImGui::TreeNode("LOCAL_WEATHER"_T.data()))
components::command_checkbox<"weatheroverride">();
if (g.world.override_weather)
{
components::button("CLEAR_OVERRIDE"_T, [] {
MISC::CLEAR_OVERRIDE_WEATHER();
});
if (ImGui::ListBox("##weather-listbox", &g.session.local_weather, session::weathers, 15))
if (ImGui::BeginCombo("Weather", weathers[g.world.local_weather]))
{
g_fiber_pool->queue_job([] {
session::local_weather();
});
for (int i = 0; i < weathers.size(); i++)
{
if (ImGui::Selectable(weathers[i], g.world.local_weather == i))
{
g.world.local_weather = i;
}
ImGui::ListBoxFooter();
if (g.world.local_weather == i)
{
ImGui::SetItemDefaultFocus();
}
}
ImGui::EndCombo();
}
ImGui::TreePop();
}
}
}