General code and GUI cleanup (#1200)

* feat(native_hooks): removed useless bail kick hook
* feat(Translations): add button to force update languages
* refactor: reorganize GUI for world
* refactor: improve exception handler
Modified the exception handler to not catch C++ try/catch blocks before those could gracefully catch the error.

* chore: debug removed crash test button
* chore: removed script exception handler
* feat(OrbitalDrone): add translations
* feat(VehicleController): add translation keys
* feat: added player admin detected translation keys
* feat(Views): add cache sub menu
This commit is contained in:
Andreas Maerten
2023-04-07 23:08:34 +02:00
committed by GitHub
parent 60d8269d3b
commit 6df7be6f06
23 changed files with 1076 additions and 1079 deletions

View File

@ -1,251 +1,251 @@
#include "natives.hpp"
#include "pointers.hpp"
#include "util/outfit.hpp"
#include "util/ped.hpp"
#include "views/view.hpp"
namespace big
{
void view::outfit_editor()
{
static outfit::components_t components;
static outfit::props_t props;
g_fiber_pool->queue_job([] {
for (auto& item : components.items)
{
item.drawable_id = PED::GET_PED_DRAWABLE_VARIATION(self::ped, item.id);
item.drawable_id_max = PED::GET_NUMBER_OF_PED_DRAWABLE_VARIATIONS(self::ped, item.id) - 1;
item.texture_id = PED::GET_PED_TEXTURE_VARIATION(self::ped, item.id);
item.texture_id_max = PED::GET_NUMBER_OF_PED_TEXTURE_VARIATIONS(self::ped, item.id, item.drawable_id) - 1;
}
for (auto& item : props.items)
{
item.drawable_id = PED::GET_PED_PROP_INDEX(self::ped, item.id, 1);
item.drawable_id_max = PED::GET_NUMBER_OF_PED_PROP_DRAWABLE_VARIATIONS(self::ped, item.id) - 1;
item.texture_id = PED::GET_PED_PROP_TEXTURE_INDEX(self::ped, item.id);
item.texture_id_max = PED::GET_NUMBER_OF_PED_PROP_TEXTURE_VARIATIONS(self::ped, item.id, item.drawable_id) - 1;
}
});
components::button("OUTFIT_RANDOM_COMPONENT"_T, [] {
ped::set_ped_random_component_variation(self::ped);
});
ImGui::SameLine();
components::button("OUTFIT_DEFAULT_COMPONENT"_T, [] {
PED::SET_PED_DEFAULT_COMPONENT_VARIATION(self::ped);
});
ImGui::SameLine();
components::button("OUTFIT_RANDOM_PROPS"_T, [] {
PED::SET_PED_RANDOM_PROPS(self::ped);
});
ImGui::SameLine();
components::button("OUTFIT_CLEAR_PROPS"_T, [] {
PED::CLEAR_ALL_PED_PROPS(self::ped, 1);
});
ImGui::SameLine();
components::button("EXPORT_TO_CLIPBOARD"_T, [] {
std::stringstream ss;
for (auto& item : components.items)
ss << item.id << " " << item.drawable_id << " " << item.texture_id << " ";
for (auto& item : props.items)
ss << item.id << " " << item.drawable_id << " " << item.texture_id << " ";
ImGui::SetClipboardText(ss.str().c_str());
g_notification_service->push("OUTFIT"_T.data(), "EXPORT_TO_CLIPBOARD"_T.data());
});
ImGui::SameLine();
components::button("IMPORT_FROM_CLIPBOARD"_T, [] {
std::stringstream ss(ImGui::GetClipboardText());
for (auto& item : components.items)
{
int id = 0;
int drawable_id = 0;
int texture_id = 0;
ss >> id;
ss >> drawable_id;
ss >> texture_id;
PED::SET_PED_COMPONENT_VARIATION(self::ped, id, drawable_id, texture_id, PED::GET_PED_PALETTE_VARIATION(self::ped, id));
}
for (auto& item : props.items)
{
int id = 0;
int drawable_id = 0;
int texture_id = 0;
ss >> id;
ss >> drawable_id;
ss >> texture_id;
if (drawable_id == -1)
PED::CLEAR_PED_PROP(self::ped, id, 1);
else
PED::SET_PED_PROP_INDEX(self::ped, id, drawable_id, texture_id, TRUE, 1);
}
});
ImGui::BeginGroup();
for (auto& item : components.items)
{
ImGui::SetNextItemWidth(60);
if (ImGui::InputInt(std::format("{} [0,{}]", item.label, item.drawable_id_max).c_str(), &item.drawable_id, 0))
{
g_fiber_pool->queue_job([item] {
PED::SET_PED_COMPONENT_VARIATION(self::ped, item.id, item.drawable_id, 0, PED::GET_PED_PALETTE_VARIATION(self::ped, item.id));
});
}
}
ImGui::EndGroup();
ImGui::SameLine();
ImGui::BeginGroup();
for (auto& item : components.items)
{
ImGui::SetNextItemWidth(60);
if (ImGui::InputInt(std::format("{} {} [0,{}]", item.label, "OUTFIT_TEX"_T, item.texture_id_max).c_str(), &item.texture_id, 0))
{
g_fiber_pool->queue_job([item] {
PED::SET_PED_COMPONENT_VARIATION(self::ped, item.id, item.drawable_id, item.texture_id, PED::GET_PED_PALETTE_VARIATION(self::ped, item.id));
});
}
}
ImGui::EndGroup();
ImGui::SameLine();
ImGui::BeginGroup();
for (auto& item : props.items)
{
ImGui::SetNextItemWidth(60);
if (ImGui::InputInt(std::format("{} [0,{}]", item.label, item.drawable_id_max).c_str(), &item.drawable_id, 0))
{
g_fiber_pool->queue_job([item] {
if (item.drawable_id == -1)
PED::CLEAR_PED_PROP(self::ped, item.id, 1);
else
PED::SET_PED_PROP_INDEX(self::ped, item.id, item.drawable_id, 0, TRUE, 1);
});
}
}
ImGui::EndGroup();
ImGui::SameLine();
ImGui::BeginGroup();
for (auto& item : props.items)
{
ImGui::SetNextItemWidth(60);
if (ImGui::InputInt(std::format("{} {} [0,{}]", item.label, "OUTFIT_TEX"_T, item.texture_id_max).c_str(), &item.texture_id, 0))
{
g_fiber_pool->queue_job([item] {
PED::SET_PED_PROP_INDEX(self::ped, item.id, item.drawable_id, item.texture_id, TRUE, 1);
});
}
}
ImGui::EndGroup();
ImGui::Separator();
static char outfit_name[MAX_PATH] = {};
static folder saved_outfit_path = g_file_manager->get_project_folder("saved_outfits");
std::vector<std::string> saved_outfits;
for (const auto& directory_entry : std::filesystem::directory_iterator(saved_outfit_path.get_path()))
saved_outfits.push_back(directory_entry.path().filename().generic_string());
static int selected_index = -1;
ImGui::SetNextItemWidth(300);
ImGui::InputText("##outfit_name", outfit_name, sizeof(outfit_name));
ImGui::SameLine();
components::button("OUTFIT_SAVE_CURRENT"_T, [] {
nlohmann::json j;
nlohmann::json j_components;
nlohmann::json j_props;
for (auto& item : components.items)
{
nlohmann::json tmp;
tmp["drawable_id"] = item.drawable_id;
tmp["texture_id"] = item.texture_id;
j_components[std::to_string(item.id)] = tmp;
}
for (auto& item : props.items)
{
nlohmann::json tmp;
tmp["drawable_id"] = item.drawable_id;
tmp["texture_id"] = item.texture_id;
j_props[std::to_string(item.id)] = tmp;
}
j["components"] = j_components;
j["props"] = j_props;
size_t index = 0;
std::string str = outfit_name;
while (saved_outfit_path.get_file(str + ".json").exists())
str = std::format("{}({})", outfit_name, ++index);
std::ofstream o(saved_outfit_path.get_file(str + ".json").get_path());
o << std::setw(4) << j << std::endl;
});
ImGui::SameLine();
components::button("OUTFIT_APPLY_SELECTED"_T, [saved_outfits] {
if (selected_index >= 0 && selected_index < saved_outfits.size())
{
std::ifstream i(saved_outfit_path.get_file(saved_outfits[selected_index]).get_path());
nlohmann::json j;
i >> j;
for (auto& item : j["components"].items())
{
std::stringstream ss(item.key());
int id = 0;
ss >> id;
int drawable_id = item.value()["drawable_id"];
int texture_id = item.value()["texture_id"];
PED::SET_PED_COMPONENT_VARIATION(self::ped, id, drawable_id, texture_id, PED::GET_PED_PALETTE_VARIATION(self::ped, id));
}
for (auto& item : j["props"].items())
{
std::stringstream ss(item.key());
int id = 0;
ss >> id;
int drawable_id = item.value()["drawable_id"];
int texture_id = item.value()["texture_id"];
if (drawable_id == -1)
PED::CLEAR_PED_PROP(self::ped, id, 1);
else
PED::SET_PED_PROP_INDEX(self::ped, id, drawable_id, texture_id, TRUE, 1);
}
}
});
ImGui::SameLine();
components::button("OUTFIT_DELETE_SELECTED"_T, [saved_outfits] {
if (selected_index >= 0 && selected_index < saved_outfits.size())
{
std::filesystem::remove(saved_outfit_path.get_file(saved_outfits[selected_index]).get_path());
if (selected_index == saved_outfits.size() - 1)
--selected_index;
}
});
if (ImGui::BeginListBox("##outfit_editor_list_box", ImVec2(300, 0)))
{
for (size_t i = 0; i < saved_outfits.size(); i++)
if (ImGui::Selectable(saved_outfits[i].c_str(), selected_index == i))
selected_index = i;
ImGui::EndListBox();
}
}
#include "natives.hpp"
#include "pointers.hpp"
#include "util/outfit.hpp"
#include "util/ped.hpp"
#include "views/view.hpp"
namespace big
{
void view::outfit_editor()
{
static outfit::components_t components;
static outfit::props_t props;
g_fiber_pool->queue_job([] {
for (auto& item : components.items)
{
item.drawable_id = PED::GET_PED_DRAWABLE_VARIATION(self::ped, item.id);
item.drawable_id_max = PED::GET_NUMBER_OF_PED_DRAWABLE_VARIATIONS(self::ped, item.id) - 1;
item.texture_id = PED::GET_PED_TEXTURE_VARIATION(self::ped, item.id);
item.texture_id_max = PED::GET_NUMBER_OF_PED_TEXTURE_VARIATIONS(self::ped, item.id, item.drawable_id) - 1;
}
for (auto& item : props.items)
{
item.drawable_id = PED::GET_PED_PROP_INDEX(self::ped, item.id, 1);
item.drawable_id_max = PED::GET_NUMBER_OF_PED_PROP_DRAWABLE_VARIATIONS(self::ped, item.id) - 1;
item.texture_id = PED::GET_PED_PROP_TEXTURE_INDEX(self::ped, item.id);
item.texture_id_max = PED::GET_NUMBER_OF_PED_PROP_TEXTURE_VARIATIONS(self::ped, item.id, item.drawable_id) - 1;
}
});
components::button("OUTFIT_RANDOM_COMPONENT"_T, [] {
ped::set_ped_random_component_variation(self::ped);
});
ImGui::SameLine();
components::button("OUTFIT_DEFAULT_COMPONENT"_T, [] {
PED::SET_PED_DEFAULT_COMPONENT_VARIATION(self::ped);
});
ImGui::SameLine();
components::button("OUTFIT_RANDOM_PROPS"_T, [] {
PED::SET_PED_RANDOM_PROPS(self::ped);
});
ImGui::SameLine();
components::button("OUTFIT_CLEAR_PROPS"_T, [] {
PED::CLEAR_ALL_PED_PROPS(self::ped, 1);
});
ImGui::SameLine();
components::button("EXPORT_TO_CLIPBOARD"_T, [] {
std::stringstream ss;
for (auto& item : components.items)
ss << item.id << " " << item.drawable_id << " " << item.texture_id << " ";
for (auto& item : props.items)
ss << item.id << " " << item.drawable_id << " " << item.texture_id << " ";
ImGui::SetClipboardText(ss.str().c_str());
g_notification_service->push("OUTFIT"_T.data(), "EXPORT_TO_CLIPBOARD"_T.data());
});
ImGui::SameLine();
components::button("IMPORT_FROM_CLIPBOARD"_T, [] {
std::stringstream ss(ImGui::GetClipboardText());
for (auto& item : components.items)
{
int id = 0;
int drawable_id = 0;
int texture_id = 0;
ss >> id;
ss >> drawable_id;
ss >> texture_id;
PED::SET_PED_COMPONENT_VARIATION(self::ped, id, drawable_id, texture_id, PED::GET_PED_PALETTE_VARIATION(self::ped, id));
}
for (auto& item : props.items)
{
int id = 0;
int drawable_id = 0;
int texture_id = 0;
ss >> id;
ss >> drawable_id;
ss >> texture_id;
if (drawable_id == -1)
PED::CLEAR_PED_PROP(self::ped, id, 1);
else
PED::SET_PED_PROP_INDEX(self::ped, id, drawable_id, texture_id, TRUE, 1);
}
});
ImGui::BeginGroup();
for (auto& item : components.items)
{
ImGui::SetNextItemWidth(60);
if (ImGui::InputInt(std::format("{} [0,{}]", item.label, item.drawable_id_max).c_str(), &item.drawable_id, 0))
{
g_fiber_pool->queue_job([item] {
PED::SET_PED_COMPONENT_VARIATION(self::ped, item.id, item.drawable_id, 0, PED::GET_PED_PALETTE_VARIATION(self::ped, item.id));
});
}
}
ImGui::EndGroup();
ImGui::SameLine();
ImGui::BeginGroup();
for (auto& item : components.items)
{
ImGui::SetNextItemWidth(60);
if (ImGui::InputInt(std::format("{} {} [0,{}]", item.label, "OUTFIT_TEX"_T, item.texture_id_max).c_str(), &item.texture_id, 0))
{
g_fiber_pool->queue_job([item] {
PED::SET_PED_COMPONENT_VARIATION(self::ped, item.id, item.drawable_id, item.texture_id, PED::GET_PED_PALETTE_VARIATION(self::ped, item.id));
});
}
}
ImGui::EndGroup();
ImGui::SameLine();
ImGui::BeginGroup();
for (auto& item : props.items)
{
ImGui::SetNextItemWidth(60);
if (ImGui::InputInt(std::format("{} [0,{}]", item.label, item.drawable_id_max).c_str(), &item.drawable_id, 0))
{
g_fiber_pool->queue_job([item] {
if (item.drawable_id == -1)
PED::CLEAR_PED_PROP(self::ped, item.id, 1);
else
PED::SET_PED_PROP_INDEX(self::ped, item.id, item.drawable_id, 0, TRUE, 1);
});
}
}
ImGui::EndGroup();
ImGui::SameLine();
ImGui::BeginGroup();
for (auto& item : props.items)
{
ImGui::SetNextItemWidth(60);
if (ImGui::InputInt(std::format("{} {} [0,{}]", item.label, "OUTFIT_TEX"_T, item.texture_id_max).c_str(), &item.texture_id, 0))
{
g_fiber_pool->queue_job([item] {
PED::SET_PED_PROP_INDEX(self::ped, item.id, item.drawable_id, item.texture_id, TRUE, 1);
});
}
}
ImGui::EndGroup();
ImGui::Separator();
static char outfit_name[MAX_PATH] = {};
static folder saved_outfit_path = g_file_manager->get_project_folder("saved_outfits");
std::vector<std::string> saved_outfits;
for (const auto& directory_entry : std::filesystem::directory_iterator(saved_outfit_path.get_path()))
saved_outfits.push_back(directory_entry.path().filename().generic_string());
static int selected_index = -1;
ImGui::SetNextItemWidth(300);
ImGui::InputText("##outfit_name", outfit_name, sizeof(outfit_name));
ImGui::SameLine();
components::button("OUTFIT_SAVE_CURRENT"_T, [] {
nlohmann::json j;
nlohmann::json j_components;
nlohmann::json j_props;
for (auto& item : components.items)
{
nlohmann::json tmp;
tmp["drawable_id"] = item.drawable_id;
tmp["texture_id"] = item.texture_id;
j_components[std::to_string(item.id)] = tmp;
}
for (auto& item : props.items)
{
nlohmann::json tmp;
tmp["drawable_id"] = item.drawable_id;
tmp["texture_id"] = item.texture_id;
j_props[std::to_string(item.id)] = tmp;
}
j["components"] = j_components;
j["props"] = j_props;
size_t index = 0;
std::string str = outfit_name;
while (saved_outfit_path.get_file(str + ".json").exists())
str = std::format("{}({})", outfit_name, ++index);
std::ofstream o(saved_outfit_path.get_file(str + ".json").get_path());
o << std::setw(4) << j << std::endl;
});
ImGui::SameLine();
components::button("OUTFIT_APPLY_SELECTED"_T, [saved_outfits] {
if (selected_index >= 0 && selected_index < saved_outfits.size())
{
std::ifstream i(saved_outfit_path.get_file(saved_outfits[selected_index]).get_path());
nlohmann::json j;
i >> j;
for (auto& item : j["components"].items())
{
std::stringstream ss(item.key());
int id = 0;
ss >> id;
int drawable_id = item.value()["drawable_id"];
int texture_id = item.value()["texture_id"];
PED::SET_PED_COMPONENT_VARIATION(self::ped, id, drawable_id, texture_id, PED::GET_PED_PALETTE_VARIATION(self::ped, id));
}
for (auto& item : j["props"].items())
{
std::stringstream ss(item.key());
int id = 0;
ss >> id;
int drawable_id = item.value()["drawable_id"];
int texture_id = item.value()["texture_id"];
if (drawable_id == -1)
PED::CLEAR_PED_PROP(self::ped, id, 1);
else
PED::SET_PED_PROP_INDEX(self::ped, id, drawable_id, texture_id, TRUE, 1);
}
}
});
ImGui::SameLine();
components::button("OUTFIT_DELETE_SELECTED"_T, [saved_outfits] {
if (selected_index >= 0 && selected_index < saved_outfits.size())
{
std::filesystem::remove(saved_outfit_path.get_file(saved_outfits[selected_index]).get_path());
if (selected_index == saved_outfits.size() - 1)
--selected_index;
}
});
if (ImGui::BeginListBox("##outfit_editor_list_box", ImVec2(300, 0)))
{
for (size_t i = 0; i < saved_outfits.size(); i++)
if (ImGui::Selectable(saved_outfits[i].c_str(), selected_index == i))
selected_index = i;
ImGui::EndListBox();
}
}
}

View File

@ -1,124 +1,124 @@
#include "natives.hpp"
#include "pointers.hpp"
#include "util/outfit.hpp"
#include "views/view.hpp"
namespace big
{
void view::outfit_slots()
{
if (*g_pointers->m_script_globals)
{
static int slot = 0;
ImGui::SetNextItemWidth(160);
if (ImGui::InputInt("OUTFIT_SLOT"_T.data(), &slot))
{
if (slot < 0)
slot = 19;
if (slot > 19)
slot = 0;
}
ImGui::SetNextItemWidth(300);
ImGui::InputText("OUTFIT_NAME"_T.data(), outfit::get_slot_name_address(slot), 16);
static outfit::components_t components;
static outfit::props_t props;
g_fiber_pool->queue_job([] {
for (auto& item : components.items)
{
item.drawable_id = *outfit::get_component_drawable_id_address(slot, item.id);
item.drawable_id_max = PED::GET_NUMBER_OF_PED_DRAWABLE_VARIATIONS(self::ped, item.id) - 1;
item.texture_id = *outfit::get_component_texture_id_address(slot, item.id);
item.texture_id_max = PED::GET_NUMBER_OF_PED_TEXTURE_VARIATIONS(self::ped, item.id, item.drawable_id) - 1;
}
for (auto& item : props.items)
{
item.drawable_id = *outfit::get_prop_drawable_id_address(slot, item.id);
item.drawable_id_max = PED::GET_NUMBER_OF_PED_PROP_DRAWABLE_VARIATIONS(self::ped, item.id) - 1;
item.texture_id = *outfit::get_prop_texture_id_address(slot, item.id);
item.texture_id_max = PED::GET_NUMBER_OF_PED_PROP_TEXTURE_VARIATIONS(self::ped, item.id, item.drawable_id) - 1;
}
});
components::button("EXPORT_TO_CLIPBOARD"_T, [] {
std::stringstream ss;
for (auto& item : components.items)
ss << item.id << " " << item.drawable_id << " " << item.texture_id << " ";
for (auto& item : props.items)
ss << item.id << " " << item.drawable_id << " " << item.texture_id << " ";
ImGui::SetClipboardText(ss.str().c_str());
g_notification_service->push("OUTFIT"_T.data(), "EXPORT_TO_CLIPBOARD"_T.data());
});
ImGui::SameLine();
components::button("IMPORT_FROM_CLIPBOARD"_T, [] {
std::stringstream ss(ImGui::GetClipboardText());
for (auto& item : components.items)
{
int id = 0;
int drawable_id = 0;
int texture_id = 0;
ss >> id;
ss >> drawable_id;
ss >> texture_id;
*outfit::get_component_drawable_id_address(slot, id) = drawable_id;
*outfit::get_component_texture_id_address(slot, id) = texture_id;
}
for (auto& item : props.items)
{
int id = 0;
int drawable_id = 0;
int texture_id = 0;
ss >> id;
ss >> drawable_id;
ss >> texture_id;
*outfit::get_prop_drawable_id_address(slot, id) = drawable_id;
*outfit::get_prop_texture_id_address(slot, id) = texture_id;
}
});
ImGui::BeginGroup();
for (auto& item : components.items)
{
ImGui::SetNextItemWidth(60);
ImGui::InputInt(std::format("{} [0,{}]", item.label, item.drawable_id_max).c_str(), outfit::get_component_drawable_id_address(slot, item.id), 0);
}
ImGui::EndGroup();
ImGui::SameLine();
ImGui::BeginGroup();
for (auto& item : components.items)
{
ImGui::SetNextItemWidth(60);
ImGui::InputInt(std::format("{} {} [0,{}]", item.label, "OUTFIT_TEX"_T, item.texture_id_max).c_str(), outfit::get_component_texture_id_address(slot, item.id), 0);
}
ImGui::EndGroup();
ImGui::SameLine();
ImGui::BeginGroup();
for (auto& item : props.items)
{
ImGui::SetNextItemWidth(60);
ImGui::InputInt(std::format("{} [0,{}]", item.label, item.drawable_id_max).c_str(), outfit::get_prop_drawable_id_address(slot, item.id), 0);
}
ImGui::EndGroup();
ImGui::SameLine();
ImGui::BeginGroup();
for (auto& item : props.items)
{
ImGui::SetNextItemWidth(60);
ImGui::InputInt(std::format("{} {} [0,{}]", item.label, "OUTFIT_TEX"_T, item.texture_id_max).c_str(), outfit::get_prop_texture_id_address(slot, item.id), 0);
}
ImGui::EndGroup();
}
}
#include "natives.hpp"
#include "pointers.hpp"
#include "util/outfit.hpp"
#include "views/view.hpp"
namespace big
{
void view::outfit_slots()
{
if (*g_pointers->m_script_globals)
{
static int slot = 0;
ImGui::SetNextItemWidth(160);
if (ImGui::InputInt("OUTFIT_SLOT"_T.data(), &slot))
{
if (slot < 0)
slot = 19;
if (slot > 19)
slot = 0;
}
ImGui::SetNextItemWidth(300);
ImGui::InputText("OUTFIT_NAME"_T.data(), outfit::get_slot_name_address(slot), 16);
static outfit::components_t components;
static outfit::props_t props;
g_fiber_pool->queue_job([] {
for (auto& item : components.items)
{
item.drawable_id = *outfit::get_component_drawable_id_address(slot, item.id);
item.drawable_id_max = PED::GET_NUMBER_OF_PED_DRAWABLE_VARIATIONS(self::ped, item.id) - 1;
item.texture_id = *outfit::get_component_texture_id_address(slot, item.id);
item.texture_id_max = PED::GET_NUMBER_OF_PED_TEXTURE_VARIATIONS(self::ped, item.id, item.drawable_id) - 1;
}
for (auto& item : props.items)
{
item.drawable_id = *outfit::get_prop_drawable_id_address(slot, item.id);
item.drawable_id_max = PED::GET_NUMBER_OF_PED_PROP_DRAWABLE_VARIATIONS(self::ped, item.id) - 1;
item.texture_id = *outfit::get_prop_texture_id_address(slot, item.id);
item.texture_id_max = PED::GET_NUMBER_OF_PED_PROP_TEXTURE_VARIATIONS(self::ped, item.id, item.drawable_id) - 1;
}
});
components::button("EXPORT_TO_CLIPBOARD"_T, [] {
std::stringstream ss;
for (auto& item : components.items)
ss << item.id << " " << item.drawable_id << " " << item.texture_id << " ";
for (auto& item : props.items)
ss << item.id << " " << item.drawable_id << " " << item.texture_id << " ";
ImGui::SetClipboardText(ss.str().c_str());
g_notification_service->push("OUTFIT"_T.data(), "EXPORT_TO_CLIPBOARD"_T.data());
});
ImGui::SameLine();
components::button("IMPORT_FROM_CLIPBOARD"_T, [] {
std::stringstream ss(ImGui::GetClipboardText());
for (auto& item : components.items)
{
int id = 0;
int drawable_id = 0;
int texture_id = 0;
ss >> id;
ss >> drawable_id;
ss >> texture_id;
*outfit::get_component_drawable_id_address(slot, id) = drawable_id;
*outfit::get_component_texture_id_address(slot, id) = texture_id;
}
for (auto& item : props.items)
{
int id = 0;
int drawable_id = 0;
int texture_id = 0;
ss >> id;
ss >> drawable_id;
ss >> texture_id;
*outfit::get_prop_drawable_id_address(slot, id) = drawable_id;
*outfit::get_prop_texture_id_address(slot, id) = texture_id;
}
});
ImGui::BeginGroup();
for (auto& item : components.items)
{
ImGui::SetNextItemWidth(60);
ImGui::InputInt(std::format("{} [0,{}]", item.label, item.drawable_id_max).c_str(), outfit::get_component_drawable_id_address(slot, item.id), 0);
}
ImGui::EndGroup();
ImGui::SameLine();
ImGui::BeginGroup();
for (auto& item : components.items)
{
ImGui::SetNextItemWidth(60);
ImGui::InputInt(std::format("{} {} [0,{}]", item.label, "OUTFIT_TEX"_T, item.texture_id_max).c_str(), outfit::get_component_texture_id_address(slot, item.id), 0);
}
ImGui::EndGroup();
ImGui::SameLine();
ImGui::BeginGroup();
for (auto& item : props.items)
{
ImGui::SetNextItemWidth(60);
ImGui::InputInt(std::format("{} [0,{}]", item.label, item.drawable_id_max).c_str(), outfit::get_prop_drawable_id_address(slot, item.id), 0);
}
ImGui::EndGroup();
ImGui::SameLine();
ImGui::BeginGroup();
for (auto& item : props.items)
{
ImGui::SetNextItemWidth(60);
ImGui::InputInt(std::format("{} {} [0,{}]", item.label, "OUTFIT_TEX"_T, item.texture_id_max).c_str(), outfit::get_prop_texture_id_address(slot, item.id), 0);
}
ImGui::EndGroup();
}
}
}

View File

@ -0,0 +1,33 @@
#include "natives.hpp"
#include "pointers.hpp"
#include "script.hpp"
#include "services/gta_data/gta_data_service.hpp"
#include "thread_pool.hpp"
#include "views/view.hpp"
namespace big
{
void view::gta_cache()
{
auto ped_count = g_gta_data_service->peds().size();
auto veh_count = g_gta_data_service->vehicles().size();
auto wep_count = g_gta_data_service->weapons().size();
components::sub_title("GTA cache stats:");
ImGui::Text("Peds Cached: %d\nVehicles Cached: %d\nWeapons Cached: %d", ped_count, veh_count, wep_count);
if (components::button("Rebuild Cache in Online"))
{
g_gta_data_service->set_state(eGtaDataUpdateState::NEEDS_UPDATE);
if (!*g_pointers->m_is_session_started)
{
g_gta_data_service->update_in_online();
}
else
{
g_gta_data_service->update_now();
}
}
}
}

View File

@ -1,26 +1,38 @@
#include "views/view.hpp"
namespace big
{
void view::translation_settings()
{
const auto& language_entries = g_translation_service.available_translations();
const auto current_pack = g_translation_service.current_language_pack();
ImGui::Text("SETTINGS_LANGUAGES"_T.data());
if (ImGui::BeginCombo("##combo-languages", language_entries.at(current_pack).name.c_str()))
{
for (auto& i : language_entries)
{
if (ImGui::Selectable(i.second.name.c_str(), i.first == current_pack))
g_translation_service.select_language_pack(i.first);
if (i.first == current_pack)
{
ImGui::SetItemDefaultFocus();
}
}
ImGui::EndCombo();
}
}
}
#include "thread_pool.hpp"
#include "views/view.hpp"
namespace big
{
void view::translation_settings()
{
const auto& language_entries = g_translation_service.available_translations();
const auto current_pack = g_translation_service.current_language_pack();
ImGui::Text("SETTINGS_LANGUAGES"_T.data());
if (ImGui::BeginCombo("##combo-languages", language_entries.at(current_pack).name.c_str()))
{
for (auto& i : language_entries)
{
if (ImGui::Selectable(i.second.name.c_str(), i.first == current_pack))
g_translation_service.select_language_pack(i.first);
if (i.first == current_pack)
{
ImGui::SetItemDefaultFocus();
}
}
ImGui::EndCombo();
}
if (components::button("Force Update Languages"))
{
g_thread_pool->push([]
{
g_translation_service.update_language_packs();
g_notification_service->push("Translations", "Finished updating translations.");
});
}
}
}

View File

@ -57,10 +57,11 @@ namespace big
static void gta_data();
static void creator();
static void train();
static void water();
static void blackhole();
static void model_swapper();
static void nearby();
static void world();
static void gta_cache();
static void player_info();
static void player_troll();

View File

@ -37,7 +37,7 @@ namespace big
ImGui::BeginGroup();
ImGui::SetNextItemWidth(200);
if (ImGui::BeginCombo("##alldoorslock", "All doors"))
if (ImGui::BeginCombo("##alldoorslock", "VEHICLE_CONTROLLER_ALL_DOORS"_T.data()))
{
for (int lockindex = 0; lockindex < MAX_VEHICLE_LOCK_STATES; lockindex++)
{
@ -52,7 +52,7 @@ namespace big
}
ImGui::SameLine();
if (ImGui::Button("Open all"))
if (components::button("OPEN_ALL_DOORS"_T))
{
g_fiber_pool->queue_job([=] {
g_vehicle_control_service.operate_door(eDoorId::VEH_EXT_DOOR_INVALID_ID, true);
@ -60,7 +60,7 @@ namespace big
}
ImGui::SameLine();
if (ImGui::Button("Close all"))
if (components::button("CLOSE_ALL_DOORS"_T))
{
g_fiber_pool->queue_job([=] {
g_vehicle_control_service.operate_door(eDoorId::VEH_EXT_DOOR_INVALID_ID, false);
@ -75,6 +75,7 @@ namespace big
for (int i = 0; i < MAX_VEHICLE_DOORS; i++)
{
ImGui::PushID(i);
if (!g_vehicle_control_service.m_controlled_vehicle.doors[i].valid)
continue;
ImGui::SetNextItemWidth(200);
@ -94,15 +95,15 @@ namespace big
ImGui::SameLine(300);
std::string buttonlabel = g_vehicle_control_service.m_controlled_vehicle.doors[i].open ? "Close" : "Open";
buttonlabel.append("##").append(std::to_string(i));
if (ImGui::Button(buttonlabel.data()))
const auto button_label = g_vehicle_control_service.m_controlled_vehicle.doors[i].open ? "CLOSE"_T : "OPEN"_T;
if (components::button(button_label))
{
g_fiber_pool->queue_job([=] {
g_vehicle_control_service.operate_door((eDoorId)i,
!g_vehicle_control_service.m_controlled_vehicle.doors[i].open);
});
}
ImGui::PopID();
}
@ -118,21 +119,21 @@ namespace big
"Rear",
};
if (ImGui::Button("Toggle lights"))
if (components::button("VEHICLE_CONTROLLER_TOGGLE_LIGHTS"_T))
{
g_fiber_pool->queue_job([=] {
g_vehicle_control_service.operate_lights(!g_vehicle_control_service.m_controlled_vehicle.headlights, false);
});
}
ImGui::SameLine();
if (ImGui::Button("Toggle High beams"))
if (components::button("VEHICLE_CONTROLLER_TOGGLE_HIGH_BEAMS"_T))
{
g_fiber_pool->queue_job([=] {
g_vehicle_control_service.operate_lights(g_vehicle_control_service.m_controlled_vehicle.headlights,
!g_vehicle_control_service.m_controlled_vehicle.highbeams);
});
}
if (ImGui::Button("Interior lights on"))
if (components::button("VEHICLE_CONTROLLER_INTERIOR_LIGHTS_ON"_T))
{
g_fiber_pool->queue_job([=] {
if (g.window.vehicle_control.operation_animation)
@ -141,7 +142,7 @@ namespace big
});
}
ImGui::SameLine();
if (ImGui::Button("Interior lights off"))
if (components::button("VEHICLE_CONTROLLER_INTERIOR_LIGHTS_OFF"_T))
{
g_fiber_pool->queue_job([=] {
if (g.window.vehicle_control.operation_animation)
@ -150,7 +151,7 @@ namespace big
});
}
ImGui::Text("Neon lights");
ImGui::Text("VEHICLE_CONTROLLER_NEON_LIGHTS"_T.data());
ImGui::Separator();
for (int i = 0; i < 4; i++)
@ -180,18 +181,18 @@ namespace big
static int movespeed = 1;
if (ImGui::RadioButton("Walk", movespeed == 1))
if (ImGui::RadioButton("VEHICLE_CONTROLLER_ENTER_VEHICLE_SPEED_WALKING"_T.data(), movespeed == 1))
movespeed = 1;
ImGui::SameLine();
if (ImGui::RadioButton("Run", movespeed == 2))
if (ImGui::RadioButton("VEHICLE_CONTROLLER_ENTER_VEHICLE_SPEED_RUNNING"_T.data(), movespeed == 2))
movespeed = 2;
ImGui::SameLine();
if (ImGui::RadioButton("Sprint", movespeed == 3))
if (ImGui::RadioButton("VEHICLE_CONTROLLER_ENTER_VEHICLE_SPEED_SPRINTING"_T.data(), movespeed == 3))
movespeed = 3;
for (int i = 0; i < 6; i++)
{
if (ImGui::Button(seatnames[i]))
if (components::button(seatnames[i]))
{
g_fiber_pool->queue_job([=] {
if (g.window.vehicle_control.operation_animation)
@ -214,7 +215,7 @@ namespace big
if (g_vehicle_control_service.m_controlled_vehicle.isconvertible)
{
if (ImGui::Button(g_vehicle_control_service.m_controlled_vehicle.convertibelstate ? "Raise" : "Lower"))
if (components::button(g_vehicle_control_service.m_controlled_vehicle.convertibelstate ? "Raise" : "Lower"))
{
g_fiber_pool->queue_job([=] {
if (g.window.vehicle_control.operation_animation)

View File

@ -10,22 +10,21 @@ namespace big
{
ImGui::Separator();
ImGui::BeginGroup();
ImGui::Text("press 'Look behind' (C/R3 by default) to activate\npress WASD buttons or Left thumbstick to navigate\nUse scroll wheel/Mouse or Right thumbstick to zoom\npress E/Q or L1/R1 to modify speed\npress 'Jump' (Space/X/Square by default) to lock on an entity\npress 'Fire' (Mouse button 1/Right trigger by default) to Obliterate\npress Enter or A/X by default to teleport to target");
ImGui::Text("ORBITAL_DRONE_USAGE_DESCR"_T.data());
ImGui::EndGroup();
ImGui::Separator();
ImGui::BeginGroup();
ImGui::Checkbox("Detect player on lock", &g.world.orbital_drone.detect_player);
ImGui::Checkbox("ORBITAL_DRONE_AUTO_LOCK_ON_PLAYER"_T.data(), &g.world.orbital_drone.detect_player);
if (ImGui::IsItemHovered())
{
ImGui::BeginTooltip();
ImGui::Text("if enabled, changes the selected player to the one it detects upon locking on an entity");
ImGui::Text("All explosions will be blamed on the selected player, defaulting to the local player");
ImGui::TextWrapped("ORBITAL_DRONE_AUTO_LOCK_ON_PLAYER_TOOLTIP"_T.data());
ImGui::EndTooltip();
}
ImGui::Text("Adjust fast modifier");
ImGui::Text("ORBITAL_DRONE_HIGH_SPEED_MULTIPLIER"_T.data());
ImGui::SliderFloat("##fastspeed", &g.world.orbital_drone.nav_ovverride_fast, 1.f, 10.f);
ImGui::Text("Adjust slow modifier");
ImGui::Text("ORBITAL_DRONE_LOW_SPEED_MULTIPLIER"_T.data());
ImGui::SliderFloat("##slowspeed", &g.world.orbital_drone.nav_ovverride_slow, 0.f, 1.f);
ImGui::EndGroup();
}

View File

@ -1,41 +1,41 @@
#include "fiber_pool.hpp"
#include "util/session.hpp"
#include "views/view.hpp"
namespace big
{
void view::time_and_weather()
{
if (ImGui::TreeNode("LOCAL_TIME"_T.data()))
{
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();
}
if (ImGui::TreeNode("LOCAL_WEATHER"_T.data()))
{
components::button("CLEAR_OVERRIDE"_T, [] {
MISC::CLEAR_OVERRIDE_WEATHER();
});
if (ImGui::ListBox("##weather-listbox", &g.session.local_weather, session::weathers, 15))
{
g_fiber_pool->queue_job([] {
session::local_weather();
});
ImGui::ListBoxFooter();
}
ImGui::TreePop();
}
}
}
#include "fiber_pool.hpp"
#include "util/session.hpp"
#include "views/view.hpp"
namespace big
{
void view::time_and_weather()
{
if (ImGui::TreeNode("LOCAL_TIME"_T.data()))
{
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();
}
if (ImGui::TreeNode("LOCAL_WEATHER"_T.data()))
{
components::button("CLEAR_OVERRIDE"_T, [] {
MISC::CLEAR_OVERRIDE_WEATHER();
});
if (ImGui::ListBox("##weather-listbox", &g.session.local_weather, session::weathers, 15))
{
g_fiber_pool->queue_job([] {
session::local_weather();
});
ImGui::ListBoxFooter();
}
ImGui::TreePop();
}
}
}

View File

@ -1,10 +0,0 @@
#include "fiber_pool.hpp"
#include "views/view.hpp"
namespace big
{
void view::water()
{
components::command_checkbox<"partwater">();
}
}

View File

@ -0,0 +1,19 @@
#include "views/view.hpp"
namespace big
{
void view::world()
{
components::sub_title("GUI_TAB_TIME_N_WEATHER"_T);
{
view::time_and_weather();
}
ImGui::Separator();
components::sub_title("GUI_TAB_WATER"_T);
{
components::command_checkbox<"partwater">();
}
}
}