From bbd1af873878e5b773f4149057b14e46078c237b Mon Sep 17 00:00:00 2001 From: aa15032261 Date: Thu, 14 Jul 2022 22:16:30 +0800 Subject: [PATCH] Added headlight, neon light and custom tire options to LSC. (#332) --- BigBaseV2/src/api/remote.hpp | 88 +- .../looped/vehicle/auto_drive_to_waypoint.cpp | 15 +- .../looped/vehicle/auto_drive_wander.cpp | 9 +- BigBaseV2/src/backend/looped/vehicle/fly.cpp | 4 +- .../backend/looped/vehicle/speedo_meter.cpp | 56 +- BigBaseV2/src/core/data/lsc_types.hpp | 192 ++++ BigBaseV2/src/core/data/speed_units.hpp | 8 + BigBaseV2/src/core/data/speedo_meters.hpp | 13 - .../src/core/data/vehicle_plate_types.hpp | 18 - .../src/core/data/vehicle_wheel_types.hpp | 21 - BigBaseV2/src/core/enums.hpp | 10 +- BigBaseV2/src/core/globals.hpp | 19 +- BigBaseV2/src/gta/VehicleValues.h | 30 +- .../vehicle_preview_service.cpp | 32 +- .../vehicle_preview_service.hpp | 1 + BigBaseV2/src/util/vehicle.hpp | 31 + BigBaseV2/src/views/vehicle/view_lsc.cpp | 891 ++++++++++++------ BigBaseV2/src/views/vehicle/view_vehicle.cpp | 49 +- .../src/views/vehicle/view_vehicle_fun.cpp | 25 +- 19 files changed, 1101 insertions(+), 411 deletions(-) create mode 100644 BigBaseV2/src/core/data/lsc_types.hpp create mode 100644 BigBaseV2/src/core/data/speed_units.hpp delete mode 100644 BigBaseV2/src/core/data/speedo_meters.hpp delete mode 100644 BigBaseV2/src/core/data/vehicle_plate_types.hpp delete mode 100644 BigBaseV2/src/core/data/vehicle_wheel_types.hpp diff --git a/BigBaseV2/src/api/remote.hpp b/BigBaseV2/src/api/remote.hpp index d6b2f1f7..ff25d43c 100644 --- a/BigBaseV2/src/api/remote.hpp +++ b/BigBaseV2/src/api/remote.hpp @@ -3,28 +3,98 @@ namespace big::remote { - inline bool download_binary(const std::string_view file_url, const std::filesystem::path& location) + inline bool get_remote_file_etag(const std::string_view file_url) { - std::ofstream file(location, std::ios::binary | std::ios::trunc); - try { http::Request req(file_url.data()); - http::Response res = req.send("GET", "", {}, 10s); + http::Response res = req.send("HEAD", "", { "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.2 (KHTML, like Gecko) Chrome/6.0" }, 10s); - std::ostream_iterator outputIter(file); - std::copy(res.body.begin(), res.body.end(), outputIter); + for (auto& header : res.headers) + { + LOG(WARNING) << header; + } } catch (const std::exception& e) { LOG(INFO) << "Failed to download binary, is the host down?: " << e.what(); - file.close(); - return false; } - file.close(); return true; } + + inline std::string get_etag_from_headers(std::vector headers) + { + std::string remote_etag = ""; + + for (auto& header : headers) + { + if (header.rfind("ETag", 0) == 0) + { + remote_etag = header; + break; + } + } + + return remote_etag; + } + + + inline bool update_binary(const std::string_view file_url, const std::filesystem::path& file_location, const std::filesystem::path& etag_location) + { + try + { + std::string local_etag = ""; + std::string remote_etag = ""; + + try { + + { + std::ifstream file_etag_ifstream(etag_location, std::ios::binary); + std::stringstream file_etag_stringstream; + file_etag_stringstream << file_etag_ifstream.rdbuf(); + local_etag = file_etag_stringstream.str(); + } + + if (!local_etag.empty()) + { + http::Request req(file_url.data()); + http::Response res = req.send("HEAD", "", { "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.2 (KHTML, like Gecko) Chrome/6.0" }, 10s); + + remote_etag = get_etag_from_headers(res.headers); + + if (remote_etag == local_etag) + { + return false; + } + } + } + catch (const std::exception& e) + { + LOG(INFO) << "Update Error: " << e.what(); + } + + http::Request req(file_url.data()); + http::Response res = req.send("GET", "", {}, 10s); + + std::ofstream file_ofstream(file_location, std::ios::binary | std::ios::trunc); + std::ostream_iterator file_out_iter(file_ofstream); + std::copy(res.body.begin(), res.body.end(), file_out_iter); + + remote_etag = get_etag_from_headers(res.headers); + + std::ofstream file_etag_ofstream(etag_location, std::ios::binary | std::ios::trunc); + file_etag_ofstream << remote_etag; + + return true; + } + catch (const std::exception& e) + { + LOG(INFO) << "Failed to download binary, is the host down?: " << e.what(); + } + + return false; + } } \ No newline at end of file diff --git a/BigBaseV2/src/backend/looped/vehicle/auto_drive_to_waypoint.cpp b/BigBaseV2/src/backend/looped/vehicle/auto_drive_to_waypoint.cpp index 07965c21..53f99f99 100644 --- a/BigBaseV2/src/backend/looped/vehicle/auto_drive_to_waypoint.cpp +++ b/BigBaseV2/src/backend/looped/vehicle/auto_drive_to_waypoint.cpp @@ -14,7 +14,7 @@ namespace big static bool ran_once = false; static int changing_driving_styles = false; static int current_driving_style = false; - static int current_speed; + static float current_speed; if (g->vehicle.auto_drive_to_waypoint) { @@ -41,12 +41,17 @@ namespace big g_notification_service->push_warning("Auto Drive", "Start driving or leave car to take back control."); } + current_speed = g->vehicle.auto_drive_speed; + current_driving_style = g->vehicle.driving_style_flags; + TASK::CLEAR_VEHICLE_TASKS_(self::veh); TASK::CLEAR_PED_TASKS(self::ped); - TASK::TASK_VEHICLE_DRIVE_TO_COORD(self::ped, self::veh, location.x, location.y, location.z, static_cast(g->vehicle.auto_drive_speed), 5, ENTITY::GET_ENTITY_MODEL(self::veh), g->vehicle.driving_style_flags, 20, true); - - current_driving_style = g->vehicle.driving_style_flags; - current_speed = g->vehicle.auto_drive_speed; + TASK::TASK_VEHICLE_DRIVE_TO_COORD( + self::ped, self::veh, + location.x, location.y, location.z, current_speed, + 5, ENTITY::GET_ENTITY_MODEL(self::veh), + current_driving_style, 20, true + ); g->vehicle.auto_drive_to_waypoint = false; diff --git a/BigBaseV2/src/backend/looped/vehicle/auto_drive_wander.cpp b/BigBaseV2/src/backend/looped/vehicle/auto_drive_wander.cpp index 69387387..169e7e6b 100644 --- a/BigBaseV2/src/backend/looped/vehicle/auto_drive_wander.cpp +++ b/BigBaseV2/src/backend/looped/vehicle/auto_drive_wander.cpp @@ -14,7 +14,7 @@ namespace big static bool ran_once = false; static int changing_driving_styles = false; static int current_driving_style = false; - static int current_speed; + static float current_speed; if (g->vehicle.auto_drive_wander) { @@ -32,13 +32,12 @@ namespace big else { g->vehicle.auto_drive_wander = false; + current_speed = g->vehicle.auto_drive_speed; + current_driving_style = g->vehicle.driving_style_flags; TASK::CLEAR_VEHICLE_TASKS_(self::veh); TASK::CLEAR_PED_TASKS(self::ped); - TASK::TASK_VEHICLE_DRIVE_WANDER(self::ped, self::veh, static_cast(g->vehicle.auto_drive_speed), g->vehicle.driving_style_flags); - - current_driving_style = g->vehicle.driving_style_flags; - current_speed = g->vehicle.auto_drive_speed; + TASK::TASK_VEHICLE_DRIVE_WANDER(self::ped, self::veh, current_speed, current_driving_style); wandering = true; diff --git a/BigBaseV2/src/backend/looped/vehicle/fly.cpp b/BigBaseV2/src/backend/looped/vehicle/fly.cpp index 95e1f61e..043706fd 100644 --- a/BigBaseV2/src/backend/looped/vehicle/fly.cpp +++ b/BigBaseV2/src/backend/looped/vehicle/fly.cpp @@ -16,13 +16,11 @@ namespace big ENTITY::SET_ENTITY_ROTATION(vehicle, cam_pos.x, cam_pos.y, cam_pos.z, 1, true); ENTITY::SET_ENTITY_COLLISION(vehicle, !g->vehicle.fly.no_collision, true); - float locspeed = (g->vehicle.fly.speed * 10); - float locspeed2 = g->vehicle.fly.speed; + float locspeed = g->vehicle.fly.speed; if (PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_MOVE_UP_ONLY)) { locspeed *= 2; - locspeed2 *= 2; } diff --git a/BigBaseV2/src/backend/looped/vehicle/speedo_meter.cpp b/BigBaseV2/src/backend/looped/vehicle/speedo_meter.cpp index 80984a1a..212bb11f 100644 --- a/BigBaseV2/src/backend/looped/vehicle/speedo_meter.cpp +++ b/BigBaseV2/src/backend/looped/vehicle/speedo_meter.cpp @@ -1,45 +1,61 @@ #include "backend/looped/looped.hpp" -#include "core/data/speedo_meters.hpp" #include "natives.hpp" +#include "util/vehicle.hpp" namespace big { void looped::vehicle_speedo_meter() { - SpeedoMeter speedo_type = g->vehicle.speedo_meter.type; + if ( + !g->vehicle.speedo_meter.enabled || + self::veh == 0 || + HUD::IS_PAUSE_MENU_ACTIVE() || + HUD::IS_WARNING_MESSAGE_ACTIVE() || + CAM::IS_SCREEN_FADED_OUT() || + CAM::IS_SCREEN_FADING_OUT() || + CAM::IS_SCREEN_FADING_IN() + ) { + return; + } - if (speedo_type == SpeedoMeter::DISABLED || HUD::IS_PAUSE_MENU_ACTIVE() || HUD::IS_WARNING_MESSAGE_ACTIVE() || CAM::IS_SCREEN_FADED_OUT() || CAM::IS_SCREEN_FADING_OUT() || CAM::IS_SCREEN_FADING_IN()) return; - - if (self::veh == 0) return; char speed_type[16], speed[16]; - float veh_speed = ENTITY::GET_ENTITY_SPEED(self::veh); - switch (speedo_type) + int char_width = 3; + + float veh_speed = vehicle::mps_to_speed( + ENTITY::GET_ENTITY_SPEED(self::veh), + g->vehicle.speed_unit + ); + + switch (g->vehicle.speed_unit) { - case SpeedoMeter::KMH: - veh_speed *= 3.6; - strcpy(speed_type, "kph"); + case SpeedUnit::KMPH: + strcpy(speed_type, "kmph"); + char_width = 4; break; - case SpeedoMeter::MPH: - veh_speed *= 2.2369; + case SpeedUnit::MIPH: strcpy(speed_type, "mph"); break; + case SpeedUnit::MPS: + strcpy(speed_type, "mps"); + break; } - sprintf(speed, "%*d", g->vehicle.speedo_meter.left_side ? 0 : 3, (int)veh_speed); + sprintf(speed, "%*d", g->vehicle.speedo_meter.left_side ? 0 : char_width, (int)veh_speed); + + HUD::SET_TEXT_FONT(2); + HUD::SET_TEXT_SCALE(.9f, .9f); + HUD::SET_TEXT_OUTLINE(); + HUD::BEGIN_TEXT_COMMAND_DISPLAY_TEXT("STRING"); + HUD::ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(speed_type); + HUD::END_TEXT_COMMAND_DISPLAY_TEXT(g->vehicle.speedo_meter.x, g->vehicle.speedo_meter.y, 1); HUD::SET_TEXT_FONT(2); HUD::SET_TEXT_SCALE(.9f, .9f); HUD::SET_TEXT_OUTLINE(); HUD::BEGIN_TEXT_COMMAND_DISPLAY_TEXT("STRING"); HUD::ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(speed); - HUD::END_TEXT_COMMAND_DISPLAY_TEXT(g->vehicle.speedo_meter.x, g->vehicle.speedo_meter.y + .04f, 1); + HUD::END_TEXT_COMMAND_DISPLAY_TEXT(g->vehicle.speedo_meter.x + (g->vehicle.speedo_meter.left_side ? 0 : .003f), g->vehicle.speedo_meter.y + .04f, 1); - HUD::SET_TEXT_FONT(2); - HUD::SET_TEXT_SCALE(.91f, .91f); - HUD::SET_TEXT_OUTLINE(); - HUD::BEGIN_TEXT_COMMAND_DISPLAY_TEXT("STRING"); - HUD::ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(speed_type); - HUD::END_TEXT_COMMAND_DISPLAY_TEXT(g->vehicle.speedo_meter.x, g->vehicle.speedo_meter.y, 1); } } \ No newline at end of file diff --git a/BigBaseV2/src/core/data/lsc_types.hpp b/BigBaseV2/src/core/data/lsc_types.hpp new file mode 100644 index 00000000..d39afb94 --- /dev/null +++ b/BigBaseV2/src/core/data/lsc_types.hpp @@ -0,0 +1,192 @@ +#pragma once +#include "gta\VehicleValues.h" + + +static const std::map lsc_plate_styles = { + { PLATE_BLUEONWHITE1, "Blue on White 1" }, + { PLATE_BLUEONWHITE2, "Blue on White 2" }, + { PLATE_BLUEONWHITE3, "Blue on White 3" }, + { PLATE_YELLOWONBLACK, "Yellow on Black" }, + { PLATE_YELLOWONBLUE, "Yellow on Blue" }, + { PLATE_YANKTON, "Yankton" } +}; + +static const std::map lsc_wheel_styles = { + { WHEEL_TYPE_SPORT, "Sport" }, + { WHEEL_TYPE_MUSCLE, "Muscle" }, + { WHEEL_TYPE_LOWRIDER, "Lowrider" }, + { WHEEL_TYPE_SUV, "SUV" }, + { WHEEL_TYPE_OFFROAD, "Offroad" }, + { WHEEL_TYPE_TUNER, "Tuner" }, + { WHEEL_TYPE_BIKEWHEELS, "Bike Wheels" }, + { WHEEL_TYPE_HIGHEND, "High End" }, + { WHEEL_TYPE_BENNYS_ORIGINAL, "Bennys Original" }, + { WHEEL_TYPE_BENNYS_BESPOKE, "Bennys Bespoke" }, + { WHEEL_TYPE_OPEN_WHEEL, "Open Wheel" }, + { WHEEL_TYPE_STREET, "Street" }, + { WHEEL_TYPE_TRACK, "Track" } +}; + +static const std::map lsc_window_tint_types = { + { WINDOWTINT_NONE, "None" }, + { WINDOWTINT_BLACK, "Black" }, + { WINDOWTINT_DARKSMOKE, "Dark" }, + { WINDOWTINT_LIGHTSMOKE, "Light" }, + { WINDOWTINT_STOCK, "Stock" }, + { WINDOWTINT_LIMO, "Limo" }, + { WINDOWTINT_GREEN, "Green" } +}; + +static const std::map lsc_classic_colors = { + { COLOR_CLASSIC_BLACK, "Black" }, + { COLOR_CLASSIC_CARBON_BLACK, "Carbon Black" }, + { COLOR_CLASSIC_GRAPHITE, "Graphite" }, + { COLOR_CLASSIC_ANHRACITE_BLACK, "Anthracite Black" }, + { COLOR_CLASSIC_BLACK_STEEL, "Black Steel" }, + { COLOR_CLASSIC_DARK_STEEL, "Dark Steel" }, + { COLOR_CLASSIC_SILVER, "Silver" }, + { COLOR_CLASSIC_BLUISH_SILVER, "Bluish Silver" }, + { COLOR_CLASSIC_ROLLED_STEEL, "Rolled Steel" }, + { COLOR_CLASSIC_SHADOW_SILVER, "Shadow SIlver" }, + { COLOR_CLASSIC_STONE_SILVER, "Stone Silver" }, + { COLOR_CLASSIC_MIDNIGHT_SILVER, "Midnight Silver" }, + { COLOR_CLASSIC_CAST_IRON_SILVER, "Cast Iron Silver" }, + { COLOR_CLASSIC_RED, "Red" }, + { COLOR_CLASSIC_TORINO_RED, "Torino Red" }, + { COLOR_CLASSIC_FORMULA_RED, "Formula Red" }, + { COLOR_CLASSIC_LAVA_RED, "Lava Red" }, + { COLOR_CLASSIC_BLAZE_RED, "Blaze Red" }, + { COLOR_CLASSIC_GRACE_RED, "Grace Red" }, + { COLOR_CLASSIC_GARNET_RED, "Garnet Red" }, + { COLOR_CLASSIC_SUNSET_RED, "Sunset Red" }, + { COLOR_CLASSIC_CABERNET_RED, "Cabernet Red" }, + { COLOR_CLASSIC_WINE_RED, "Wine Red" }, + { COLOR_CLASSIC_CANDY_RED, "Candy Red" }, + { COLOR_CLASSIC_HOT_PINK, "Hot Pink" }, + { COLOR_CLASSIC_PFSITER_PINK, "Pfister Pink" }, + { COLOR_CLASSIC_SALMON_PINK, "Salmon Pink" }, + { COLOR_CLASSIC_SUNRISE_ORANGE, "Sunrise Orange" }, + { COLOR_CLASSIC_ORANGE, "Orange" }, + { COLOR_CLASSIC_BRIGHT_ORANGE, "Bright Orange" }, + { COLOR_CLASSIC_GOLD, "Gold" }, + { COLOR_CLASSIC_BRONZE, "Bronze" }, + { COLOR_CLASSIC_YELLOW, "Yellow" }, + { COLOR_CLASSIC_RACE_YELLOW, "Race Yellow" }, + { COLOR_CLASSIC_DEW_YELLOW, "Dew Yellow" }, + { COLOR_CLASSIC_DARK_GREEN, "Dark Green" }, + { COLOR_CLASSIC_RACING_GREEN, "Racing Green" }, + { COLOR_CLASSIC_SEA_GREEN, "Sea Green" }, + { COLOR_CLASSIC_OLIVE_GREEN, "Olive Green" }, + { COLOR_CLASSIC_BRIGHT_GREEN, "Bright Green" }, + { COLOR_CLASSIC_GASOLINE_GREEN, "Gasoline Green" }, + { COLOR_CLASSIC_LIME_GREEN, "Lime Green" }, + { COLOR_CLASSIC_MIDNIGHT_BLUE, "Midnight Blue" }, + { COLOR_CLASSIC_GALAXY_BLUE, "Galaxy Blue" }, + { COLOR_CLASSIC_DARK_BLUE, "Dark Blue" }, + { COLOR_CLASSIC_SAXON_BLUE, "Saxon Blue" }, + { COLOR_CLASSIC_BLUE, "Blue" }, + { COLOR_CLASSIC_MARINER_BLUE, "Mariner Blue" }, + { COLOR_CLASSIC_HARBOR_BLUE, "Harbor Blue" }, + { COLOR_CLASSIC_DIAMOND_BLUE, "Diamond Blue" }, + { COLOR_CLASSIC_SURF_BLUE, "Surf Blue" }, + { COLOR_CLASSIC_NAUTICAL_BLUE, "Nautical Blue" }, + { COLOR_CLASSIC_RACING_BLUE, "Racing Blue" }, + { COLOR_CLASSIC_ULTRA_BLUE, "Ultra Blue" }, + { COLOR_CLASSIC_LIGHT_BLUE, "Light Blue" }, + { COLOR_CLASSIC_CHOCOLATE_BROWN, "Chocolate Brown" }, + { COLOR_CLASSIC_BISON_BROWN, "Bison Brown" }, + { COLOR_CLASSIC_CREEEN_BROWN, "Creek Brown" }, + { COLOR_CLASSIC_FELTZER_BROWN, "Feltzer Brown" }, + { COLOR_CLASSIC_MAPLE_BROWN, "Maple Brown" }, + { COLOR_CLASSIC_BEECHWOOD_BROWN, "Beechwood Brown" }, + { COLOR_CLASSIC_SIENNA_BROWN, "Sienna Brown" }, + { COLOR_CLASSIC_SADDLE_BROWN, "Saddle Brown" }, + { COLOR_CLASSIC_MOSS_BROWN, "Moss Brown" }, + { COLOR_CLASSIC_WOODBEECH_BROWN, "Woodbeech Brown" }, + { COLOR_CLASSIC_STRAW_BROWN, "Straw Brown" }, + { COLOR_CLASSIC_SANDY_BROWN, "Sandy Brown" }, + { COLOR_CLASSIC_BLEACHED_BROWN, "Bleached Brown" }, + { COLOR_CLASSIC_SCHAFTER_PURPLE, "Schafter Purple" }, + { COLOR_CLASSIC_SPINNAKER_PURPLE, "Spinnaker Purple" }, + { COLOR_CLASSIC_MIDNIGHT_PURPLE, "Midnight Purple" }, + { COLOR_CLASSIC_BRIGHT_PURPLE, "Bright Purple" }, + { COLOR_CLASSIC_CREAM, "Cream" }, + { COLOR_CLASSIC_ICE_WHITE, "Ice White" }, + { COLOR_CLASSIC_FROST_WHITE, "Frost White" } +}; + +static const std::map lsc_matte_colors = { + { COLOR_MATTE_BLACK, "Black" }, + { COLOR_MATTE_GRAY, "Gray" }, + { COLOR_MATTE_LIGHT_GRAY, "Light Gray" }, + { COLOR_MATTE_ICE_WHITE, "Ice White" }, + { COLOR_MATTE_BLUE, "Blue" }, + { COLOR_MATTE_DARK_BLUE, "Dark Blue" }, + { COLOR_MATTE_MIDNIGHT_BLUE, "Midnight Blue" }, + { COLOR_MATTE_MIDNIGHT_PURPLE, "Midnight Purple" }, + { COLOR_MATTE_SCHAFTER_PURPLE, "Shafter Purple" }, + { COLOR_MATTE_RED, "Red" }, + { COLOR_MATTE_DARK_RED, "Dark Red" }, + { COLOR_MATTE_ORANGE, "Orange" }, + { COLOR_MATTE_YELLOW, "Yellow" }, + { COLOR_MATTE_LIME_GREEN, "Lime Green" }, + { COLOR_MATTE_GREEN, "Green" }, + { COLOR_MATTE_FOREST_GREEN, "Forest Green" }, + { COLOR_MATTE_FOLIAGE_GREEN, "Foliage Green" }, + { COLOR_MATTE_OLIVE_DARB, "Olive Drab" }, + { COLOR_MATTE_DARK_EARTH, "Dark Earth" }, + { COLOR_MATTE_DESERT_TAN, "Desert Tan" } +}; + +static const std::map lsc_metal_colors = { + { COLOR_METALS_BRUSHED_STEEL, "Brushed Steel" }, + { COLOR_METALS_BRUSHED_BLACK_STEEL, "Brushed Black Steel" }, + { COLOR_METALS_BRUSHED_ALUMINUM, "Brushed Aluminium" }, + { COLOR_METALS_PURE_GOLD, "Pure Gold" }, + { COLOR_METALS_BRUSHED_GOLD, "Brushed Gold" } +}; + +static const std::map lsc_headlight_colors = { + { XENON_DEFAULT, "Default" }, + { XENON_WHITE, "White" }, + { XENON_BLUE, "Blue" }, + { XENON_ELECTRIC_BLUE, "Electric Blue" }, + { XENON_MINT_GREEN, "Mint Green" }, + { XENON_LIME_GREEN, "Lime Green" }, + { XENON_YELLOW, "Yellow" }, + { XENON_GOLDEN_SHOWER, "Golden Shower" }, + { XENON_ORANGE, "Orange" }, + { XENON_RED, "Red" }, + { XENON_PONY_PINK, "Pony Pink" }, + { XENON_HOT_PINK, "Hot Pink" }, + { XENON_PURPLE, "Purple" }, + { XENON_BACKLIGHT, "Backlight" } +}; + +static const std::map> lsc_tire_smoke_rgb = { + { "White", { TIRESMOKE_COLOR_WHITE } }, + { "Black", { TIRESMOKE_COLOR_BLACK } }, + { "Blue", { TIRESMOKE_COLOR_BLUE } }, + { "Yellow", { TIRESMOKE_COLOR_YELLOW } }, + { "Purple", { TIRESMOKE_COLOR_PURPLE } }, + { "Orange", { TIRESMOKE_COLOR_ORANGE } }, + { "Green", { TIRESMOKE_COLOR_GREEN } }, + { "Red", { TIRESMOKE_COLOR_RED } }, + { "Pink", { TIRESMOKE_COLOR_PINK } }, + { "Brown", { TIRESMOKE_COLOR_BROWN } } +}; + +static const std::map> lsc_neon_rgb = { + { "White", { NEON_COLOR_WHITE } }, + { "Blue", { NEON_COLOR_BLUE } }, + { "Electro Blue", { NEON_COLOR_ELECTRICBLUE } }, + { "Mint Green", { NEON_COLOR_MINTGREEN } }, + { "Lime Green", { NEON_COLOR_LIMEGREEN } }, + { "Yellow", { NEON_COLOR_YELLOW } }, + { "Golden Shower", { NEON_COLOR_GOLDENSHOWER } }, + { "Orange", { NEON_COLOR_ORANGE } }, + { "Red", { NEON_COLOR_RED } }, + { "Pony Pink", { NEON_COLOR_PONYPINK } }, + { "Hot Pink", { NEON_COLOR_HOTPINK } }, + { "Purple", { NEON_COLOR_PURPLE } } +}; diff --git a/BigBaseV2/src/core/data/speed_units.hpp b/BigBaseV2/src/core/data/speed_units.hpp new file mode 100644 index 00000000..4405d620 --- /dev/null +++ b/BigBaseV2/src/core/data/speed_units.hpp @@ -0,0 +1,8 @@ +#pragma once +#include "core/enums.hpp" + +static const std::string speed_unit_strings[3] = { + "km/h", + "mi/h", + "m/s" +}; diff --git a/BigBaseV2/src/core/data/speedo_meters.hpp b/BigBaseV2/src/core/data/speedo_meters.hpp deleted file mode 100644 index 722b7d8d..00000000 --- a/BigBaseV2/src/core/data/speedo_meters.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -#include "core/enums.hpp" - -struct speedo_meter { - big::SpeedoMeter id; - const char name[16]; -}; - -const speedo_meter speedo_meters[] = { - { big::SpeedoMeter::DISABLED, "Disabled" }, - { big::SpeedoMeter::KMH, "km/h" }, - { big::SpeedoMeter::MPH, "mph" } -}; \ No newline at end of file diff --git a/BigBaseV2/src/core/data/vehicle_plate_types.hpp b/BigBaseV2/src/core/data/vehicle_plate_types.hpp deleted file mode 100644 index e5608581..00000000 --- a/BigBaseV2/src/core/data/vehicle_plate_types.hpp +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include "gta\VehicleValues.h" - -struct vehicle_plate_type { - PlateTextIndexs type; - const char name[16]; -}; - - -#define PLATE_TYPE_SIZE 6 -vehicle_plate_type vehicle_plate_types[PLATE_TYPE_SIZE] = { - { PLATE_BLUEONWHITE1, "Blue on White 1" }, - { PLATE_BLUEONWHITE2, "Blue on White 2" }, - { PLATE_BLUEONWHITE3, "Blue on White 3" }, - { PLATE_YELLOWONBLACK, "Yellow on Black" }, - { PLATE_YELLOWONBLUE, "Yellow on Blue" }, - { PLATE_YANKTON, "Yankton" } -}; diff --git a/BigBaseV2/src/core/data/vehicle_wheel_types.hpp b/BigBaseV2/src/core/data/vehicle_wheel_types.hpp deleted file mode 100644 index 7c8867c2..00000000 --- a/BigBaseV2/src/core/data/vehicle_wheel_types.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -#include "gta\VehicleValues.h" - -struct vehicle_wheel_type { - WheelTypes type; - const char name[16]; -}; - -std::map vehicle_wheel_types = { - { WHEEL_TYPE_SPORT, "Sport" }, - { WHEEL_TYPE_MUSCLE, "Muscle" }, - { WHEEL_TYPE_LOWRIDER, "Lowrider" }, - { WHEEL_TYPE_SUV, "SUV" }, - { WHEEL_TYPE_OFFROAD, "Offroad" }, - { WHEEL_TYPE_TUNER, "Tuner" }, - { WHEEL_TYPE_BIKEWHEELS, "Bike Wheels" }, - { WHEEL_TYPE_HIGHEND, "High End" }, - { WHEEL_TYPE_BENNYS_ORIGINAL, "Bennys Original" }, - { WHEEL_TYPE_BENNYS_BESPOKE, "Bennys Bespoke" }, - { WHEEL_TYPE_F1, "F1" } -}; diff --git a/BigBaseV2/src/core/enums.hpp b/BigBaseV2/src/core/enums.hpp index fc1a07a1..ceb43dfb 100644 --- a/BigBaseV2/src/core/enums.hpp +++ b/BigBaseV2/src/core/enums.hpp @@ -186,13 +186,15 @@ namespace big LEAVE_ONLINE = -1 }; - enum class SpeedoMeter + enum class SpeedUnit : uint32_t { - DISABLED, - KMH, - MPH + KMPH, + MIPH, + MPS }; + + enum class eEntityProofs : uint32_t { BULLET = 1 << 4, diff --git a/BigBaseV2/src/core/globals.hpp b/BigBaseV2/src/core/globals.hpp index 2f778949..414837d6 100644 --- a/BigBaseV2/src/core/globals.hpp +++ b/BigBaseV2/src/core/globals.hpp @@ -213,11 +213,10 @@ namespace big struct vehicle { struct speedo_meter { - SpeedoMeter type = SpeedoMeter::DISABLED; - float x = .9f; float y = .72f; + bool enabled = false; bool left_side = false; }; @@ -230,6 +229,8 @@ namespace big float speed = 1; }; + SpeedUnit speed_unit = SpeedUnit::MIPH; + bool god_mode = false; bool proof_bullet = false; bool proof_fire = false; @@ -251,7 +252,7 @@ namespace big bool ls_customs = false; // don't save this to dis bool seatbelt = false; bool turn_signals = false; - int auto_drive_speed = 1; + float auto_drive_speed = 1; int driving_style_flags = 443; int driving_style_id = 0; int rainbow_paint = 0; @@ -552,6 +553,7 @@ namespace big this->spoofing.rockstar_id = j["spoofing"]["rockstar_id"]; this->spoofing.username = j["spoofing"]["username"]; + this->vehicle.speed_unit = (SpeedUnit)j["vehicle"]["speed_unit"]; this->vehicle.god_mode = j["vehicle"]["god_mode"]; this->vehicle.proof_bullet = j["vehicle"]["proof_bullet"]; this->vehicle.proof_fire = j["vehicle"]["proof_fire"]; @@ -566,7 +568,8 @@ namespace big this->vehicle.auto_drive_wander = j["vehicle"]["auto_drive_wander"]; this->vehicle.auto_turn_signals = j["vehicle"]["auto_turn_signals"]; this->vehicle.drive_on_water = j["vehicle"]["drive_on_water"]; - this->vehicle.driving_style_id = j["vehicle"]["driving_style"]; + this->vehicle.driving_style_id = j["vehicle"]["driving_style_id"]; + this->vehicle.driving_style_flags = j["vehicle"]["driving_style_flag"]; this->vehicle.horn_boost = j["vehicle"]["horn_boost"]; this->vehicle.vehicle_jump = j["vehicle"]["vehicle_jump"]; this->vehicle.instant_brake = j["vehicle"]["instant_brake"]; @@ -575,7 +578,7 @@ namespace big this->vehicle.seatbelt = j["vehicle"]["seatbelt"]; this->vehicle.turn_signals = j["vehicle"]["turn_signals"]; - this->vehicle.speedo_meter.type = (SpeedoMeter)j["vehicle"]["speedo_meter"]["type"]; + this->vehicle.speedo_meter.enabled = j["vehicle"]["speedo_meter"]["enabled"]; this->vehicle.speedo_meter.left_side = j["vehicle"]["speedo_meter"]["left_side"]; this->vehicle.speedo_meter.x = j["vehicle"]["speedo_meter"]["position_x"]; this->vehicle.speedo_meter.y = j["vehicle"]["speedo_meter"]["position_y"]; @@ -832,6 +835,7 @@ namespace big }, { "vehicle", { + { "speed_unit", this->vehicle.speed_unit }, { "god_mode", this->vehicle.god_mode }, { "proof_bullet", this->vehicle.proof_bullet }, { "proof_fire", this->vehicle.proof_fire }, @@ -846,7 +850,8 @@ namespace big { "auto_drive_wander", this->vehicle.auto_drive_wander }, { "auto_turn_signals", this->vehicle.auto_turn_signals }, { "drive_on_water", this->vehicle.drive_on_water }, - { "driving_style", this->vehicle.driving_style_id }, + { "driving_style_id", this->vehicle.driving_style_id }, + { "driving_style_flag", this->vehicle.driving_style_flags }, { "horn_boost", this->vehicle.horn_boost }, { "vehicle_jump", this->vehicle.vehicle_jump }, { "instant_brake", this->vehicle.instant_brake }, @@ -856,7 +861,7 @@ namespace big { "seatbelt", this->vehicle.seatbelt }, { "speedo_meter", { - { "type", (int)this->vehicle.speedo_meter.type }, + { "enabled", this->vehicle.speedo_meter.enabled }, { "left_side", this->vehicle.speedo_meter.left_side }, { "position_x", this->vehicle.speedo_meter.x }, { "position_y", this->vehicle.speedo_meter.y }, diff --git a/BigBaseV2/src/gta/VehicleValues.h b/BigBaseV2/src/gta/VehicleValues.h index 7ac612b2..145d980f 100644 --- a/BigBaseV2/src/gta/VehicleValues.h +++ b/BigBaseV2/src/gta/VehicleValues.h @@ -23,7 +23,9 @@ enum WheelTypes WHEEL_TYPE_HIGHEND, WHEEL_TYPE_BENNYS_ORIGINAL, WHEEL_TYPE_BENNYS_BESPOKE, - WHEEL_TYPE_F1 + WHEEL_TYPE_OPEN_WHEEL, + WHEEL_TYPE_STREET, + WHEEL_TYPE_TRACK }; enum VehicleWeapons @@ -382,6 +384,14 @@ enum VehicleModType MOD_LIVERY }; +enum CustomVehicleModType +{ + MOD_WHEEL_TYPE = -101, + MOD_PLATE_STYLE = -102, + MOD_WINDOW_TINT = -103 +}; + + static const char* mod_names[] = { "MOD_SPOILERS", "MOD_FRONTBUMPER", "MOD_REARBUMPER", "MOD_SIDESKIRT", "MOD_EXHAUST", "MOD_FRAME", "MOD_GRILLE", "MOD_HOOD", "MOD_FENDER", "MOD_RIGHTFENDER", "MOD_ROOF", "MOD_ENGINE", "MOD_BRAKES", "MOD_TRANSMISSION", "MOD_HORNS", "MOD_SUSPENSION", "MOD_ARMOR", "", "MOD_TURBO", "", "MOD_TIRESMOKE", "", "MOD_XENONHEADLIGHTS", "MOD_FRONTWHEEL", "MOD_REARWHEEL", "MOD_PLATEHOLDER", "MOD_VANITYPLATES", "MOD_TRIMDESIGN", "MOD_ORNAMENTS", "MOD_DASHBOARD", "MOD_DIALDESIGN", "MOD_DOORSPEAKERS", "MOD_SEATS", "MOD_STEERINGWHEELS", "MOD_COLUMNSHIFTERLEVERS", "MOD_PLAQUES", "MOD_SPEAKERS", "MOD_TRUNK", "MOD_HYDRAULICS", "MOD_ENGINEBLOCK", "MOD_AIRFILTER", "MOD_STRUTS", "MOD_ARCHCOVER", "MOD_AERIALS", "MOD_TRIM", "MOD_TANK", "MOD_WINDOWS", "", "MOD_LIVERY" }; enum VehicleModHorns @@ -603,6 +613,24 @@ enum WindowTints //m8 do you even int tint? WINDOWTINT_GREEN }; +enum HeadlightColors +{ + XENON_DEFAULT = -1, + XENON_WHITE, + XENON_BLUE, + XENON_ELECTRIC_BLUE, + XENON_MINT_GREEN, + XENON_LIME_GREEN, + XENON_YELLOW, + XENON_GOLDEN_SHOWER, + XENON_ORANGE, + XENON_RED, + XENON_PONY_PINK, + XENON_HOT_PINK, + XENON_PURPLE, + XENON_BACKLIGHT +}; + #define NEON_COLOR_WHITE 222, 222, 255 #define NEON_COLOR_BLUE 2, 21, 255 #define NEON_COLOR_ELECTRICBLUE 3, 83, 255 diff --git a/BigBaseV2/src/services/vehicle_preview/vehicle_preview_service.cpp b/BigBaseV2/src/services/vehicle_preview/vehicle_preview_service.cpp index b17bfa06..0fbc3b48 100644 --- a/BigBaseV2/src/services/vehicle_preview/vehicle_preview_service.cpp +++ b/BigBaseV2/src/services/vehicle_preview/vehicle_preview_service.cpp @@ -40,21 +40,33 @@ namespace big } vehicle_preview_service::vehicle_preview_service() : - m_vehicle_file(g_file_manager->get_project_file("./lib/vehicles.json")) + m_vehicle_file(g_file_manager->get_project_file("./lib/vehicles.json")), + m_vehicle_file_etag(g_file_manager->get_project_file("./lib/vehicles_etag.txt")) { if (m_vehicle_file.exists()) - this->load(); - else { - g_thread_pool->push([this]() - { - if (remote::download_binary("http://github-proxy.damon.sh/DurtyFree/gta-v-data-dumps/master/vehicles.json", m_vehicle_file.get_path())) - this->load(); - else - LOG(WARNING) << "Failed to download vehicles.json data..."; - }); + this->load(); + LOG(INFO) << "Vehicle data loaded."; } + g_thread_pool->push([this]() { + bool ret = remote::update_binary( + "http://github-proxy.damon.sh/DurtyFree/gta-v-data-dumps/master/vehicles.json", + m_vehicle_file.get_path(), + m_vehicle_file_etag.get_path() + ); + + if (ret) + { + this->load(); + LOG(INFO) << "Vehicle data updated."; + } + else if (!m_vehicle_file.exists()) + { + LOG(WARNING) << "Failed to download vehicles.json data..."; + } + }); + g_vehicle_preview_service = this; } diff --git a/BigBaseV2/src/services/vehicle_preview/vehicle_preview_service.hpp b/BigBaseV2/src/services/vehicle_preview/vehicle_preview_service.hpp index 7acb94de..6ae20b3a 100644 --- a/BigBaseV2/src/services/vehicle_preview/vehicle_preview_service.hpp +++ b/BigBaseV2/src/services/vehicle_preview/vehicle_preview_service.hpp @@ -18,6 +18,7 @@ namespace big class vehicle_preview_service { file m_vehicle_file; + file m_vehicle_file_etag; std::condition_variable m_cond; std::mutex m_mutex; diff --git a/BigBaseV2/src/util/vehicle.hpp b/BigBaseV2/src/util/vehicle.hpp index caca881c..4e93787c 100644 --- a/BigBaseV2/src/util/vehicle.hpp +++ b/BigBaseV2/src/util/vehicle.hpp @@ -18,6 +18,36 @@ namespace big::vehicle *script_global(2671447).at(8).as() = 1; } + inline float mps_to_speed(float mps, SpeedUnit speed_unit) + { + switch (speed_unit) + { + case SpeedUnit::KMPH: + return mps * 3.6f; + break; + case SpeedUnit::MIPH: + return mps * 2.2369f; + break; + } + + return mps; + } + + inline float speed_to_mps(float speed, SpeedUnit speed_unit) + { + switch (speed_unit) + { + case SpeedUnit::KMPH: + return speed / 3.6f; + break; + case SpeedUnit::MIPH: + return speed / 2.2369f; + break; + } + + return speed; + } + inline void bring(Vehicle veh, Vector3 location, bool put_in = true, int seatIdx = -1) { if (!ENTITY::IS_ENTITY_A_VEHICLE(veh)) return g_notification_service->push_error("Vehicle", "Invalid handle"); @@ -184,6 +214,7 @@ namespace big::vehicle } // permission fix + *spawn_global.at(27).at(1).as() = 0; *spawn_global.at(27).at(19).as() = -1; *spawn_global.at(27).at(60).as() = 1; *spawn_global.at(27).at(77).as() = 4030726305; diff --git a/BigBaseV2/src/views/vehicle/view_lsc.cpp b/BigBaseV2/src/views/vehicle/view_lsc.cpp index e2510e86..888d9bec 100644 --- a/BigBaseV2/src/views/vehicle/view_lsc.cpp +++ b/BigBaseV2/src/views/vehicle/view_lsc.cpp @@ -2,10 +2,9 @@ #include "natives.hpp" #include "script.hpp" #include "services/vehicle_helper/vehicle_helper.hpp" +#include "core/data/lsc_types.hpp" #include "views/view.hpp" #include "util/vehicle.hpp" -#include "core/data/vehicle_plate_types.hpp" -#include "core/data/vehicle_wheel_types.hpp" #include namespace big @@ -13,15 +12,35 @@ namespace big void view::lsc() { static Vehicle player_vehicle = 0; + static bool ready = true; + static std::map owned_mods; static std::map slot_display_names; - static std::map> mod_display_names{}; + static std::map> mod_display_names; + static std::map> front_wheel_map; + static std::map> rear_wheel_map; + + static int primary_color_rgb[3] = { 255, 255, 255 }; + static int secondary_color_rgb[3] = { 255, 255, 255 }; + static int tire_smoke_color_rgb[3] = { 255, 255, 255 }; + static int neon_light_color_rgb[3] = { 255, 255, 255 }; + static int selected_slot = -1; + static bool is_bennys = false; + static int front_wheel_stock_mod = -1; + static bool front_wheel_custom = false; + static int rear_wheel_stock_mod = -1; + static bool rear_wheel_custom = false; static bool can_tires_burst = false; static bool tiresmoke = false; static bool turbo = false; + static bool xenon = false; + static bool neon_left = false; + static bool neon_right = false; + static bool neon_front = false; + static bool neon_back = false; static int primary_color = 0; static int secondary_color = 0; @@ -29,32 +48,33 @@ namespace big static int wheel_color = 0; static int interior_color = 0; static int dashboard_color = 0; - - static int plate_type = -1; - static int wheel_type = -1; + static int headlight_color = 0; static Hash veh_model_hash = 0; - static bool is_bike = false; - if (self::veh == 0) + if (self::veh == 0 || player_vehicle != self::veh) { - player_vehicle = 0; - owned_mods.clear(); - slot_display_names.clear(); - mod_display_names.clear(); - - ImGui::Text("Please enter a vehicle."); - return; - } - - g_fiber_pool->queue_job([] { - if (player_vehicle != self::veh) + if (self::veh == 0) { - player_vehicle = 0; owned_mods.clear(); slot_display_names.clear(); mod_display_names.clear(); + front_wheel_map.clear(); + rear_wheel_map.clear(); + player_vehicle = 0; + selected_slot = -1; + ImGui::Text("Please enter a vehicle."); + return; + } + } + + if (player_vehicle != self::veh && ready == true) + { + ready = false; + player_vehicle = self::veh; + + g_fiber_pool->queue_job([] { if (!HUD::HAS_THIS_ADDITIONAL_TEXT_LOADED("MOD_MNU", 10)) { HUD::CLEAR_ADDITIONAL_TEXT(10, TRUE); @@ -62,71 +82,154 @@ namespace big script::get_current()->yield(); } - player_vehicle = PED::GET_VEHICLE_PED_IS_IN(PLAYER::PLAYER_PED_ID(), FALSE); - can_tires_burst = !VEHICLE::GET_VEHICLE_TYRES_CAN_BURST(player_vehicle); - tiresmoke = VEHICLE::IS_TOGGLE_MOD_ON(player_vehicle, MOD_TYRE_SMOKE); - turbo = VEHICLE::IS_TOGGLE_MOD_ON(player_vehicle, MOD_TURBO); - xenon = VEHICLE::IS_TOGGLE_MOD_ON(player_vehicle, MOD_XENON_LIGHTS); - plate_type = VEHICLE::GET_VEHICLE_NUMBER_PLATE_TEXT_INDEX(player_vehicle); - wheel_type = VEHICLE::GET_VEHICLE_WHEEL_TYPE(player_vehicle); - - veh_model_hash = g_local_player->m_vehicle->m_model_info->m_model_hash; - is_bike = VEHICLE::IS_THIS_MODEL_A_BIKE(veh_model_hash) || VEHICLE::IS_THIS_MODEL_A_BICYCLE(veh_model_hash); - VEHICLE::GET_VEHICLE_COLOURS(player_vehicle, &primary_color, &secondary_color); VEHICLE::GET_VEHICLE_EXTRA_COLOURS(player_vehicle, &pearlescent, &wheel_color); VEHICLE::GET_VEHICLE_INTERIOR_COLOR_(player_vehicle, &interior_color); VEHICLE::GET_VEHICLE_DASHBOARD_COLOR_(player_vehicle, &dashboard_color); + headlight_color = VEHICLE::GET_VEHICLE_XENON_LIGHTS_COLOR_(player_vehicle); + VEHICLE::GET_VEHICLE_CUSTOM_PRIMARY_COLOUR(player_vehicle, &primary_color_rgb[0], &primary_color_rgb[1], &primary_color_rgb[2]); + VEHICLE::GET_VEHICLE_CUSTOM_SECONDARY_COLOUR(player_vehicle, &secondary_color_rgb[0], &secondary_color_rgb[1], &secondary_color_rgb[2]); + VEHICLE::GET_VEHICLE_TYRE_SMOKE_COLOR(player_vehicle, &tire_smoke_color_rgb[0], &tire_smoke_color_rgb[1], &tire_smoke_color_rgb[2]); + VEHICLE::GET_VEHICLE_NEON_LIGHTS_COLOUR_(player_vehicle, &neon_light_color_rgb[0], &neon_light_color_rgb[1], &neon_light_color_rgb[2]); + + can_tires_burst = !VEHICLE::GET_VEHICLE_TYRES_CAN_BURST(player_vehicle); + tiresmoke = VEHICLE::IS_TOGGLE_MOD_ON(player_vehicle, MOD_TYRE_SMOKE); + turbo = VEHICLE::IS_TOGGLE_MOD_ON(player_vehicle, MOD_TURBO); + + xenon = VEHICLE::IS_TOGGLE_MOD_ON(player_vehicle, MOD_XENON_LIGHTS); + neon_left = VEHICLE::IS_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_LEFT); + neon_right = VEHICLE::IS_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_RIGHT); + neon_front = VEHICLE::IS_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_FRONT); + neon_back = VEHICLE::IS_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_BACK); + + front_wheel_custom = VEHICLE::GET_VEHICLE_MOD_VARIATION(player_vehicle, MOD_FRONTWHEEL); + rear_wheel_custom = VEHICLE::GET_VEHICLE_MOD_VARIATION(player_vehicle, MOD_REARWHEEL); + + std::map tmp_owned_mods; + std::map tmp_slot_display_names; + std::map> tmp_mod_display_names; + std::map> tmp_front_wheel_map; + std::map> tmp_rear_wheel_map; + + tmp_slot_display_names[MOD_PLATE_STYLE] = "Plate Style"; + tmp_slot_display_names[MOD_WINDOW_TINT] = "Window Tint"; + tmp_slot_display_names[MOD_WHEEL_TYPE] = "Wheel Type"; + + tmp_owned_mods[MOD_PLATE_STYLE] = VEHICLE::GET_VEHICLE_NUMBER_PLATE_TEXT_INDEX(player_vehicle); + tmp_mod_display_names[MOD_PLATE_STYLE].insert(lsc_plate_styles.begin(), lsc_plate_styles.end()); + + tmp_owned_mods[MOD_WINDOW_TINT] = VEHICLE::GET_VEHICLE_WINDOW_TINT(player_vehicle); + tmp_mod_display_names[MOD_WINDOW_TINT].insert(lsc_window_tint_types.begin(), lsc_window_tint_types.end()); + + tmp_owned_mods[MOD_WHEEL_TYPE] = VEHICLE::GET_VEHICLE_WHEEL_TYPE(player_vehicle); + tmp_mod_display_names[MOD_WHEEL_TYPE].insert(lsc_wheel_styles.begin(), lsc_wheel_styles.end()); + + is_bennys = tmp_owned_mods[MOD_WHEEL_TYPE] == WHEEL_TYPE_BENNYS_ORIGINAL || + tmp_owned_mods[MOD_WHEEL_TYPE] == WHEEL_TYPE_BENNYS_BESPOKE || + tmp_owned_mods[MOD_WHEEL_TYPE] == WHEEL_TYPE_OPEN_WHEEL || + tmp_owned_mods[MOD_WHEEL_TYPE] == WHEEL_TYPE_STREET || + tmp_owned_mods[MOD_WHEEL_TYPE] == WHEEL_TYPE_TRACK; for (int slot = MOD_SPOILERS; slot <= MOD_LIVERY; slot++) { int count = VEHICLE::GET_NUM_VEHICLE_MODS(player_vehicle, slot); if (count > 0) { - owned_mods[slot] = VEHICLE::GET_VEHICLE_MOD(player_vehicle, slot); + int owner_mod = VEHICLE::GET_VEHICLE_MOD(player_vehicle, slot); + tmp_owned_mods[slot] = owner_mod; std::string slot_name = vehicle_helper::get_mod_slot_name(slot, player_vehicle); if (slot_name.empty()) { continue; } - slot_display_names[slot] = slot_name; + tmp_slot_display_names[slot] = slot_name; std::map mod_names; for (int mod = -1; mod < count; mod++) { + bool is_repeated = false; + std::string mod_name = vehicle_helper::get_mod_name(mod, slot, count, player_vehicle); - if (mod_name.empty()) + if (mod_name.empty() || mod_name == "NULL") { continue; } - bool repeated = false; - - for (const auto& it : mod_names) + if (slot == MOD_FRONTWHEEL) { - if (it.second == mod_name) + if (is_bennys) { - repeated = true; - break; + if (mod_name.rfind("Chrome ", 0) == 0) + { + std::string new_mod_name = mod_name.substr(7); + + if (tmp_front_wheel_map[new_mod_name].size() > 0) + { + mod_name = new_mod_name; + } + + } + } + + tmp_front_wheel_map[mod_name].push_back(mod); + + if (mod == owner_mod) + { + front_wheel_stock_mod = tmp_front_wheel_map[mod_name][0]; + } + + if (tmp_front_wheel_map[mod_name].size() > 1) + { + is_repeated = true; + + if (!is_bennys) + { + if (mod == owner_mod) + { + front_wheel_custom = true; + } + } + } + } + else if(slot == MOD_REARWHEEL) + { + tmp_rear_wheel_map[mod_name].push_back(mod); + + if (mod == owner_mod) + { + rear_wheel_stock_mod = tmp_rear_wheel_map[mod_name][0]; + } + + if (tmp_rear_wheel_map[mod_name].size() > 1) + { + is_repeated = true; + + if (mod == owner_mod) + { + rear_wheel_custom = true; + } } } - if (!repeated) + if (!is_repeated) { mod_names[mod] = mod_name; } } - mod_display_names[slot] = mod_names; + tmp_mod_display_names[slot] = mod_names; } } - } - }); - if (slot_display_names.empty()) - { - return; + owned_mods = tmp_owned_mods; + slot_display_names = tmp_slot_display_names; + mod_display_names = tmp_mod_display_names; + front_wheel_map = tmp_front_wheel_map; + rear_wheel_map = tmp_rear_wheel_map; + + ready = true; + }); } components::button("Start LS Customs", [] { @@ -143,6 +246,20 @@ namespace big }); } + ImGui::Separator(); + + static char plate[9]; + + ImGui::SetNextItemWidth(200.f); + components::input_text_with_hint("##plate", "Plate Number", plate, sizeof(plate), ImGuiInputTextFlags_None); + ImGui::SameLine(); + if (components::button("Change Plate Number")) + { + g_fiber_pool->queue_job([] { + vehicle::set_plate(self::veh, plate); + }); + } + ImGui::Separator(); components::small_text("Mod Options"); @@ -166,104 +283,13 @@ namespace big VEHICLE::TOGGLE_VEHICLE_MOD(player_vehicle, MOD_TYRE_SMOKE, tiresmoke); }); } - ImGui::SameLine(); - if (ImGui::Checkbox("Xenon", &xenon)) - { - g_fiber_pool->queue_job([] { - VEHICLE::TOGGLE_VEHICLE_MOD(player_vehicle, MOD_XENON_LIGHTS, xenon); - }); - } - - - static char plate[9] = { 0 }; - ImGui::SetNextItemWidth(200.f); - components::input_text_with_hint("##plate", "Plate Number", plate, sizeof(plate), ImGuiInputTextFlags_None, [] { - g->spawn.plate = plate; - }); - ImGui::SameLine(); - if (components::button("Change Plate Number")) - { - g_fiber_pool->queue_job([] { - vehicle::set_plate(self::veh, plate); - }); - } - - ImGui::SetNextItemWidth(200); - if (ImGui::BeginCombo("Plate Style", vehicle_plate_types[plate_type].name)) - { - for (int i = 0; i < PLATE_TYPE_SIZE; i++) - { - auto item = vehicle_plate_types[i]; - - if (ImGui::Selectable(item.name, (int)item.type == plate_type)) - { - if (plate_type != item.type) - { - plate_type = item.type; - VEHICLE::SET_VEHICLE_NUMBER_PLATE_TEXT_INDEX(player_vehicle, plate_type); - } - } - - if (item.type == plate_type) - { - ImGui::SetItemDefaultFocus(); - } - } - - ImGui::EndCombo(); - } - - - - - if (!is_bike) - { - static int windowtint{}; - static char* windowtint_combo[] = { "None", "Black", "Dark", "Light" }; - - ImGui::SetNextItemWidth(200); - if (ImGui::Combo("Window Tint", &windowtint, windowtint_combo, IM_ARRAYSIZE(windowtint_combo))) - { - g_fiber_pool->queue_job([] { - VEHICLE::SET_VEHICLE_WINDOW_TINT(player_vehicle, windowtint); - }); - } - - ImGui::SetNextItemWidth(200); - if (ImGui::BeginCombo("Wheel Type", vehicle_wheel_types[wheel_type].c_str())) - { - for (const auto& [type, name] : vehicle_wheel_types) - { - if (ImGui::Selectable(name.c_str(), (int)type == wheel_type)) - { - if (wheel_type != type) - { - wheel_type = type; - - g_fiber_pool->queue_job([] { - VEHICLE::SET_VEHICLE_WHEEL_TYPE(player_vehicle, wheel_type); - VEHICLE::SET_VEHICLE_MOD(player_vehicle, MOD_FRONTWHEEL, 0, false); - selected_slot = MOD_FRONTWHEEL; - - // refresh mod names - player_vehicle = 0; - }); - } - } - - if (type == wheel_type) - { - ImGui::SetItemDefaultFocus(); - } - } - - ImGui::EndCombo(); - } - } ImGui::Separator(); - if (ImGui::ListBoxHeader("Slot", ImVec2(200, 200))) + ImGui::BeginGroup(); + + components::small_text("Slot"); + if (ImGui::ListBoxHeader("##slot", ImVec2(200, 200))) { for (const auto& [slot, name] : slot_display_names) { @@ -275,82 +301,321 @@ namespace big ImGui::ListBoxFooter(); } + ImGui::EndGroup(); + if (selected_slot != -1) { + static auto wheel_stock_mod = &front_wheel_stock_mod; + static auto wheel_custom = &front_wheel_custom; + static bool is_wheel_mod = false; + + if (selected_slot == MOD_FRONTWHEEL) + { + is_wheel_mod = true; + } + else if (selected_slot == MOD_REARWHEEL) + { + wheel_stock_mod = &rear_wheel_stock_mod; + wheel_custom = &rear_wheel_custom; + is_wheel_mod = true; + } + else + { + is_wheel_mod = false; + } + ImGui::SameLine(); - if (ImGui::ListBoxHeader("Mod", ImVec2(200, 200))) + ImGui::BeginGroup(); + + components::small_text("Mod"); + if (ImGui::ListBoxHeader("##mod", ImVec2(240, 200))) { for (const auto& it : mod_display_names[selected_slot]) { const auto& mod = it.first; const auto& name = it.second; - if (ImGui::Selectable(name.c_str(), mod == owned_mods[selected_slot])) + bool item_selected = mod == owned_mods[selected_slot]; + + if (is_wheel_mod) + { + item_selected = mod == *wheel_stock_mod; + } + + if (ImGui::Selectable(name.c_str(), item_selected)) { g_fiber_pool->queue_job([&mod] { NETWORK::NETWORK_REQUEST_CONTROL_OF_ENTITY(self::veh); - VEHICLE::SET_VEHICLE_MOD(player_vehicle, selected_slot, mod, false); - owned_mods[selected_slot] = VEHICLE::GET_VEHICLE_MOD(player_vehicle, selected_slot); + + if (selected_slot >= 0) + { + VEHICLE::SET_VEHICLE_MOD(player_vehicle, selected_slot, mod, false); + owned_mods[selected_slot] = mod; + + if (is_wheel_mod) + { + *wheel_stock_mod = mod; + *wheel_custom = false; + } + } + else if (selected_slot == MOD_WINDOW_TINT) + { + VEHICLE::SET_VEHICLE_WINDOW_TINT(player_vehicle, mod); + owned_mods[selected_slot] = mod; + } + else if (selected_slot == MOD_WHEEL_TYPE) + { + VEHICLE::SET_VEHICLE_WHEEL_TYPE(player_vehicle, mod); + VEHICLE::SET_VEHICLE_MOD(player_vehicle, MOD_FRONTWHEEL, 0, false); + VEHICLE::SET_VEHICLE_MOD(player_vehicle, MOD_REARWHEEL, 0, false); + player_vehicle = 0; + } + else if (selected_slot == MOD_PLATE_STYLE) + { + VEHICLE::SET_VEHICLE_NUMBER_PLATE_TEXT_INDEX(player_vehicle, mod); + owned_mods[selected_slot] = mod; + } }); } } ImGui::ListBoxFooter(); } + + ImGui::EndGroup(); + + if ( + is_wheel_mod && *wheel_stock_mod != -1 + ) { + auto wheel_map = front_wheel_map; + + if (selected_slot == MOD_REARWHEEL) + { + wheel_map = rear_wheel_map; + } + + ImGui::SameLine(); + ImGui::BeginGroup(); + + components::small_text("Style"); + if (ImGui::ListBoxHeader("##style", ImVec2(200, 200))) + { + std::string mod_name = mod_display_names[selected_slot][*wheel_stock_mod]; + auto wheel_mods = wheel_map[mod_name]; + + for (int i = 0; i < wheel_mods.size(); i++) + { + int& mod = wheel_mods[i]; + + bool should_custom = false; + + // bennys fix + if (!is_bennys) + { + if (i == 0) + { + if (ImGui::Selectable("Stock", mod == owned_mods[selected_slot] && *wheel_custom == false)) + { + g_fiber_pool->queue_job([&mod] { + VEHICLE::SET_VEHICLE_MOD(player_vehicle, selected_slot, mod, false); + player_vehicle = 0; + }); + } + } + + should_custom = true; + } + + std::string label = "Style " + std::to_string(mod); + if (ImGui::Selectable(label.c_str(), mod == owned_mods[selected_slot] && *wheel_custom == should_custom)) + { + g_fiber_pool->queue_job([&mod, should_custom] { + VEHICLE::SET_VEHICLE_MOD(player_vehicle, selected_slot, mod, should_custom); + player_vehicle = 0; + }); + } + } + ImGui::ListBoxFooter(); + } + + ImGui::EndGroup(); + } } + + + ImGui::Separator(); + components::small_text("Neon Light Options"); + + if (ImGui::Checkbox("Headlight##headlight_en", &xenon)) + { + g_fiber_pool->queue_job([] { + VEHICLE::TOGGLE_VEHICLE_MOD(player_vehicle, MOD_XENON_LIGHTS, xenon); + }); + } + ImGui::SameLine(); + if (ImGui::Checkbox("Left", &neon_left)) + { + g_fiber_pool->queue_job([] { + VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_LEFT, neon_left); + }); + } + ImGui::SameLine(); + if (ImGui::Checkbox("Right", &neon_right)) + { + g_fiber_pool->queue_job([] { + VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_RIGHT, neon_right); + }); + } + ImGui::SameLine(); + if (ImGui::Checkbox("Front", &neon_front)) + { + g_fiber_pool->queue_job([] { + VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_FRONT, neon_front); + }); + } + ImGui::SameLine(); + if (ImGui::Checkbox("Back", &neon_back)) + { + g_fiber_pool->queue_job([] { + VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_BACK, neon_back); + }); + } + ImGui::SameLine(); + components::button("Check All##neon_check_all", [] { + xenon = true; + neon_left = true; + neon_right = true; + neon_front = true; + neon_back = true; + + g_fiber_pool->queue_job([] { + VEHICLE::TOGGLE_VEHICLE_MOD(player_vehicle, MOD_XENON_LIGHTS, xenon); + VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_LEFT, neon_left); + VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_RIGHT, neon_right); + VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_FRONT, neon_front); + VEHICLE::SET_VEHICLE_NEON_LIGHT_ENABLED_(player_vehicle, NEON_BACK, neon_back); + }); + }); + ImGui::Separator(); components::small_text("Color Options"); - - static const char* classic_names[] = { "Black", "Carbon Black", "Graphite", "Anthracite Black", "Black Steel", "Dark Steel", "Silver", "Bluish Silver", "Rolled Steel", "Shadow SIlver", "Stone Silver", "Midnight Silver", "Cast Iron Silver", "Red", "Torino Red", "Formula Red", "Lava Red", "Blaze Red", "Grace Red", "Garnet Red", "Sunset Red", "Cabernet Red", "Wine Red", "Candy Red", "Hot Pink", "Pfister Pink", "Salmon Pink", "Sunrise Orange", "Orange", "Bright Orange", "Gold", "Bronze", "Yellow", "Race Yellow", "Dew Yellow", "Dark Green", "Racing Green", "Sea Green", "Olive Green", "Bright Green", "Gasoline Green", "Lime Green", "Midnight Blue", "Galaxy Blue", "Dark Blue", "Saxon Blue", "Blue", "Mariner Blue", "Harbor Blue", "Diamond Blue", "Surf Blue", "Nautical Blue", "Racing Blue", "Ultra Blue", "Light Blue", "Chocolate Brown", "Bison Brown", "Creek Brown", "Feltzer Brown", "Maple Brown", "Beechwood Brown", "Sienna Brown", "Saddle Brown", "Moss Brown", "Woodbeech Brown", "Straw Brown", "Sandy Brown", "Bleached Brown", "Schafter Purple", "Spinnaker Purple", "Midnight Purple", "Bright Purple", "Cream", "Ice White", "Frost White" }; - static int classic_ids[] = { COLOR_CLASSIC_BLACK, COLOR_CLASSIC_CARBON_BLACK, COLOR_CLASSIC_GRAPHITE, COLOR_CLASSIC_ANHRACITE_BLACK, COLOR_CLASSIC_BLACK_STEEL, COLOR_CLASSIC_DARK_STEEL, COLOR_CLASSIC_SILVER, COLOR_CLASSIC_BLUISH_SILVER, COLOR_CLASSIC_ROLLED_STEEL, COLOR_CLASSIC_SHADOW_SILVER, COLOR_CLASSIC_STONE_SILVER, COLOR_CLASSIC_MIDNIGHT_SILVER, COLOR_CLASSIC_CAST_IRON_SILVER, COLOR_CLASSIC_RED, COLOR_CLASSIC_TORINO_RED, COLOR_CLASSIC_FORMULA_RED, COLOR_CLASSIC_LAVA_RED, COLOR_CLASSIC_BLAZE_RED, COLOR_CLASSIC_GRACE_RED, COLOR_CLASSIC_GARNET_RED, COLOR_CLASSIC_SUNSET_RED, COLOR_CLASSIC_CABERNET_RED, COLOR_CLASSIC_WINE_RED, COLOR_CLASSIC_CANDY_RED, COLOR_CLASSIC_HOT_PINK, COLOR_CLASSIC_PFSITER_PINK, COLOR_CLASSIC_SALMON_PINK, COLOR_CLASSIC_SUNRISE_ORANGE, COLOR_CLASSIC_ORANGE, COLOR_CLASSIC_BRIGHT_ORANGE, COLOR_CLASSIC_GOLD, COLOR_CLASSIC_BRONZE, COLOR_CLASSIC_YELLOW, COLOR_CLASSIC_RACE_YELLOW, COLOR_CLASSIC_DEW_YELLOW, COLOR_CLASSIC_DARK_GREEN, COLOR_CLASSIC_RACING_GREEN, COLOR_CLASSIC_SEA_GREEN, COLOR_CLASSIC_OLIVE_GREEN, COLOR_CLASSIC_BRIGHT_GREEN, COLOR_CLASSIC_GASOLINE_GREEN, COLOR_CLASSIC_LIME_GREEN, COLOR_CLASSIC_MIDNIGHT_BLUE, COLOR_CLASSIC_GALAXY_BLUE, COLOR_CLASSIC_DARK_BLUE, COLOR_CLASSIC_SAXON_BLUE, COLOR_CLASSIC_BLUE, COLOR_CLASSIC_MARINER_BLUE, COLOR_CLASSIC_HARBOR_BLUE, COLOR_CLASSIC_DIAMOND_BLUE, COLOR_CLASSIC_SURF_BLUE, COLOR_CLASSIC_NAUTICAL_BLUE, COLOR_CLASSIC_RACING_BLUE, COLOR_CLASSIC_ULTRA_BLUE, COLOR_CLASSIC_LIGHT_BLUE, COLOR_CLASSIC_CHOCOLATE_BROWN, COLOR_CLASSIC_BISON_BROWN, COLOR_CLASSIC_CREEEN_BROWN, COLOR_CLASSIC_FELTZER_BROWN, COLOR_CLASSIC_MAPLE_BROWN, COLOR_CLASSIC_BEECHWOOD_BROWN, COLOR_CLASSIC_SIENNA_BROWN, COLOR_CLASSIC_SADDLE_BROWN, COLOR_CLASSIC_MOSS_BROWN, COLOR_CLASSIC_WOODBEECH_BROWN, COLOR_CLASSIC_STRAW_BROWN, COLOR_CLASSIC_SANDY_BROWN, COLOR_CLASSIC_BLEACHED_BROWN, COLOR_CLASSIC_SCHAFTER_PURPLE, COLOR_CLASSIC_SPINNAKER_PURPLE, COLOR_CLASSIC_MIDNIGHT_PURPLE, COLOR_CLASSIC_BRIGHT_PURPLE, COLOR_CLASSIC_CREAM, COLOR_CLASSIC_ICE_WHITE, COLOR_CLASSIC_FROST_WHITE }; - static const char* matte_names[] = { "Black", "Gray", "Light Gray", "Ice White", "Blue", "Dark Blue", "Midnight Blue", "Midnight Purple", "Shafter Purple", "Red", "Dark Red", "Orange", "Yellow", "Lime Green", "Green", "Forest Green", "Foliage Green", "Olive Drab", "Dark Earth", "Desert Tan" }; - static int matte_ids[] = { COLOR_MATTE_BLACK, COLOR_MATTE_GRAY, COLOR_MATTE_LIGHT_GRAY, COLOR_MATTE_ICE_WHITE, COLOR_MATTE_BLUE, COLOR_MATTE_DARK_BLUE, COLOR_MATTE_MIDNIGHT_BLUE, COLOR_MATTE_MIDNIGHT_PURPLE, COLOR_MATTE_SCHAFTER_PURPLE, COLOR_MATTE_RED, COLOR_MATTE_DARK_RED, COLOR_MATTE_ORANGE, COLOR_MATTE_YELLOW, COLOR_MATTE_LIME_GREEN, COLOR_MATTE_GREEN, COLOR_MATTE_FOREST_GREEN, COLOR_MATTE_FOLIAGE_GREEN, COLOR_MATTE_OLIVE_DARB, COLOR_MATTE_DARK_EARTH, COLOR_MATTE_DESERT_TAN }; - static const char* metal_names[] = { "Brushed Steel", "Brushed Black Steel", "Brushed Aluminium", "Pure Gold", "Brushed Gold" }; - static int metal_ids[] = { COLOR_METALS_BRUSHED_STEEL, COLOR_METALS_BRUSHED_BLACK_STEEL, COLOR_METALS_BRUSHED_ALUMINUM, COLOR_METALS_PURE_GOLD, COLOR_METALS_BRUSHED_GOLD }; - static int color_to_change = 0; - static int color_btn_clicked = 1; static int color_type = 8; - if (ImGui::RadioButton("Primary", &color_to_change, 0)) - { - color_btn_clicked = 1; - } - ImGui::SameLine(); - if (ImGui::RadioButton("Secondary", &color_to_change, 1)) - { - color_btn_clicked = 1; - } - ImGui::SameLine(); - if (ImGui::RadioButton("Tire Smake", &color_to_change, 2)) - { - color_btn_clicked = 1; - } - ImGui::SameLine(); - if (ImGui::Button("Remove Custom Color")) - { - g_fiber_pool->queue_job([] { - VEHICLE::CLEAR_VEHICLE_CUSTOM_PRIMARY_COLOUR(player_vehicle); - VEHICLE::CLEAR_VEHICLE_CUSTOM_SECONDARY_COLOUR(player_vehicle); - VEHICLE::SET_VEHICLE_COLOURS(player_vehicle, primary_color, secondary_color); - }); + if ( + (color_to_change == 7 && !xenon) || + (color_to_change == 5 && !tiresmoke) + ) { + color_to_change = 0; + color_type = 8; } - ImGui::Separator(); + if (ImGui::ListBoxHeader("##color_options", ImVec2(120, 254))) + { + if (ImGui::Selectable("Primary", color_to_change == 0, ImGuiSelectableFlags_SelectOnClick)) + { + color_to_change = 0; + } + + if (ImGui::Selectable("Secondary", color_to_change == 1)) + { + color_to_change = 1; + } + + if (ImGui::Selectable("Pearlescent", color_to_change == 2)) + { + color_to_change = 2; + color_type = 4; + } + + if (ImGui::Selectable("Interior", color_to_change == 3)) + { + color_to_change = 3; + color_type = 6; + } + + if (ImGui::Selectable("Dashboard", color_to_change == 4)) + { + color_to_change = 4; + color_type = 7; + } + + if (!tiresmoke) + { + ImGui::BeginDisabled(); + } + if (ImGui::Selectable("Tire Smoke", color_to_change == 5)) + { + color_to_change = 5; + color_type = 8; + } + if (!tiresmoke) + { + ImGui::EndDisabled(); + } + + if (ImGui::Selectable("Wheel Color", color_to_change == 6)) + { + color_to_change = 6; + color_type = 5; + } + + if (!xenon) + { + ImGui::BeginDisabled(); + } + if (ImGui::Selectable("Headlight##headlight_col", color_to_change == 7)) + { + color_to_change = 7; + color_type = 9; + } + if (!xenon) + { + ImGui::EndDisabled(); + } + + if (ImGui::Selectable("Neon", color_to_change == 8)) + { + color_to_change = 8; + color_type = 8; + } + + ImGui::ListBoxFooter(); + } - ImGui::BeginGroup(); if (color_to_change == 0 || color_to_change == 1) { + if (color_type > 3) + { + color_type = 8; + } + // primary and secondary color - if (ImGui::ListBoxHeader("##colors", ImVec2(200, 254))) + ImGui::SameLine(); + if (ImGui::ListBoxHeader("##colors", ImVec2(140, 254))) { if (ImGui::Selectable("Custom", color_type == 8, ImGuiSelectableFlags_SelectOnClick)) { color_type = 8; } + if (ImGui::Selectable("Remove Custom", false)) + { + g_fiber_pool->queue_job([] { + if (color_to_change == 0) + { + VEHICLE::CLEAR_VEHICLE_CUSTOM_PRIMARY_COLOUR(player_vehicle); + } + else + { + VEHICLE::CLEAR_VEHICLE_CUSTOM_SECONDARY_COLOUR(player_vehicle); + } + VEHICLE::SET_VEHICLE_COLOURS(player_vehicle, primary_color, secondary_color); + }); + } + if (ImGui::Selectable("Chrome", color_type == 0)) { color_type = 0; @@ -367,122 +632,164 @@ namespace big { color_type = 3; } - if (ImGui::Selectable("Pearlescent", color_type == 4)) - { - color_type = 4; - } - if (ImGui::Selectable("Wheel Color", color_type == 5)) - { - color_type = 5; - } - if (ImGui::Selectable("Interior Color", color_type == 6)) - { - color_type = 6; - } - if (ImGui::Selectable("Dashboard Color", color_type == 7)) - { - color_type = 7; - } ImGui::ListBoxFooter(); } } - else + else if (color_to_change == 7) { - // tyre smoke color - - color_type = 8; - ImGui::Text(""); + ImGui::SameLine(); } + if (color_type == 8) { // custom color static float color[3] = { 1, 1, 1 }; + auto color_rgb = primary_color_rgb; + + if (color_to_change == 1) + { + color_rgb = secondary_color_rgb; + } + else if (color_to_change == 2) + { + color_rgb = tire_smoke_color_rgb; + } + else if (color_to_change == 3) + { + color_rgb = neon_light_color_rgb; + } + + color[0] = (float)color_rgb[0] / 255; + color[1] = (float)color_rgb[1] / 255; + color[2] = (float)color_rgb[2] / 255; + + if (color_to_change == 5) + { + ImGui::SameLine(); + if (ImGui::ListBoxHeader("##tire_smoke_rgb", ImVec2(140, 254))) + { + for (const auto& it : lsc_tire_smoke_rgb) + { + auto& name = it.first; + auto& rgb = it.second; + + if (ImGui::Selectable(name.c_str(), false)) + { + g_fiber_pool->queue_job([&rgb] { + VEHICLE::SET_VEHICLE_TYRE_SMOKE_COLOR(player_vehicle, rgb[0], rgb[1], rgb[2]); + }); + color_rgb[0] = rgb[0]; + color_rgb[1] = rgb[1]; + color_rgb[2] = rgb[2]; + } + + } + + ImGui::ListBoxFooter(); + } + } + else if (color_to_change == 8) + { + ImGui::SameLine(); + if (ImGui::ListBoxHeader("##neon_rgb", ImVec2(140, 254))) + { + for (const auto& it : lsc_neon_rgb) + { + auto& name = it.first; + auto& rgb = it.second; + + if (ImGui::Selectable(name.c_str(), false)) + { + g_fiber_pool->queue_job([&rgb] { + VEHICLE::SET_VEHICLE_TYRE_SMOKE_COLOR(player_vehicle, rgb[0], rgb[1], rgb[2]); + }); + color_rgb[0] = rgb[0]; + color_rgb[1] = rgb[1]; + color_rgb[2] = rgb[2]; + } + } + + ImGui::ListBoxFooter(); + } + } ImGui::SameLine(); - ImGui::SetNextItemWidth(212); + ImGui::SetNextItemWidth(214); if (ImGui::ColorPicker3("Custom VehColor", color, ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoDragDrop | ImGuiColorEditFlags_NoOptions | ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_DisplayHex)) { - g_fiber_pool->queue_job([] { + color_rgb[0] = (int)(color[0] * 255); + color_rgb[1] = (int)(color[1] * 255); + color_rgb[2] = (int)(color[2] * 255); + + g_fiber_pool->queue_job([color_rgb] { switch (color_to_change) { case 0: - VEHICLE::SET_VEHICLE_CUSTOM_PRIMARY_COLOUR(player_vehicle, (int)(color[0] * 255), (int)(color[1] * 255), (int)(color[2] * 255)); + VEHICLE::SET_VEHICLE_CUSTOM_PRIMARY_COLOUR(player_vehicle, color_rgb[0], color_rgb[1], color_rgb[2]); break; case 1: - VEHICLE::SET_VEHICLE_CUSTOM_SECONDARY_COLOUR(player_vehicle, (int)(color[0] * 255), (int)(color[1] * 255), (int)(color[2] * 255)); + VEHICLE::SET_VEHICLE_CUSTOM_SECONDARY_COLOUR(player_vehicle, color_rgb[0], color_rgb[1], color_rgb[2]); break; - case 2: - VEHICLE::SET_VEHICLE_TYRE_SMOKE_COLOR(player_vehicle, (int)(color[0] * 255), (int)(color[1] * 255), (int)(color[2] * 255)); + case 5: + VEHICLE::SET_VEHICLE_TYRE_SMOKE_COLOR(player_vehicle, color_rgb[0], color_rgb[1], color_rgb[2]); + break; + case 8: + VEHICLE::SET_VEHICLE_NEON_LIGHTS_COLOUR_(player_vehicle, color_rgb[0], color_rgb[1], color_rgb[2]); break; } }); } - - if (color_btn_clicked == 1) - { - g_fiber_pool->queue_job([] { - int color_get[3]; - - if (color_to_change == 0) - { - VEHICLE::GET_VEHICLE_CUSTOM_PRIMARY_COLOUR(player_vehicle, &color_get[0], &color_get[1], &color_get[2]); - } - else if (color_to_change == 1) - { - VEHICLE::GET_VEHICLE_CUSTOM_SECONDARY_COLOUR(player_vehicle, &color_get[0], &color_get[1], &color_get[2]); - } - else if (color_to_change == 2) - { - VEHICLE::GET_VEHICLE_TYRE_SMOKE_COLOR(player_vehicle, &color_get[0], &color_get[1], &color_get[2]); - } - - color[0] = (float)color_get[0] / 255; - color[1] = (float)color_get[1] / 255; - color[2] = (float)color_get[2] / 255; - }); - - color_btn_clicked = 0; - } - } else { // standard color - int color_check = 0; + int selected_color = 0; switch (color_type) { case 4: - color_check = pearlescent; + selected_color = pearlescent; break; case 5: - color_check = wheel_color; + selected_color = wheel_color; break; case 6: - color_check = interior_color; + selected_color = interior_color; break; case 7: - color_check = dashboard_color; + selected_color = dashboard_color; + break; + case 9: + selected_color = headlight_color; break; default: - color_check = (color_to_change == 0) ? primary_color : secondary_color; + selected_color = (color_to_change == 0) ? primary_color : secondary_color; } - ImGui::SameLine(); - if (ImGui::ListBoxHeader("##color", ImVec2(200, 254))) + if (color_type != 9) + { + ImGui::SameLine(); + } + + if (ImGui::ListBoxHeader("##color", ImVec2(180, 254))) { switch (color_type) { case 0: //Chrome { - if (ImGui::Selectable("Chrome", color_check == COLOR_CHROME)) + if (ImGui::Selectable("Chrome", selected_color == COLOR_CHROME)) { if (color_to_change == 0) + { primary_color = COLOR_CHROME; + } else + { secondary_color = COLOR_CHROME; + } + g_fiber_pool->queue_job([] { VEHICLE::SET_VEHICLE_COLOURS(player_vehicle, primary_color, secondary_color); }); @@ -491,48 +798,71 @@ namespace big } case 1: //Classic { - for (int i = 0; i < 74; i++) + for (const auto& [color, name] : lsc_classic_colors) { - if (ImGui::Selectable(classic_names[i], color_check == classic_ids[i])) + if (ImGui::Selectable(name.c_str(), selected_color == color)) { + selected_color = color; + if (color_to_change == 0) - primary_color = classic_ids[i]; + { + primary_color = color; + } else - secondary_color = classic_ids[i]; + { + secondary_color = color; + } + g_fiber_pool->queue_job([] { VEHICLE::SET_VEHICLE_COLOURS(player_vehicle, primary_color, secondary_color); }); } + } break; } case 2: //Matte { - for (int i = 0; i < 20; i++) + for (const auto& [color, name] : lsc_matte_colors) { - if (ImGui::Selectable(matte_names[i], color_check == matte_ids[i])) + if (ImGui::Selectable(name.c_str(), selected_color == color)) { + selected_color = color; + if (color_to_change == 0) - primary_color = matte_ids[i]; + { + primary_color = color; + } else - secondary_color = matte_ids[i]; + { + secondary_color = color; + } + g_fiber_pool->queue_job([] { VEHICLE::SET_VEHICLE_COLOURS(player_vehicle, primary_color, secondary_color); }); } + } break; } case 3: //Metals { - for (int i = 0; i < 5; i++) + for (const auto& [color, name] : lsc_metal_colors) { - if (ImGui::Selectable(metal_names[i], color_check == metal_ids[i])) + if (ImGui::Selectable(name.c_str(), selected_color == color)) { + selected_color = color; + if (color_to_change == 0) - primary_color = metal_ids[i]; + { + primary_color = color; + } else - secondary_color = metal_ids[i]; + { + secondary_color = color; + } + g_fiber_pool->queue_job([] { VEHICLE::SET_VEHICLE_COLOURS(player_vehicle, primary_color, secondary_color); }); @@ -542,11 +872,13 @@ namespace big } case 4: //Pearlescent { - for (int i = 0; i < 74; i++) + for (const auto& [color, name] : lsc_classic_colors) { - if (ImGui::Selectable(classic_names[i], color_check == classic_ids[i])) + if (ImGui::Selectable(name.c_str(), selected_color == color)) { - pearlescent = classic_ids[i]; + selected_color = color; + pearlescent = color; + g_fiber_pool->queue_job([] { VEHICLE::SET_VEHICLE_EXTRA_COLOURS(player_vehicle, pearlescent, wheel_color); }); @@ -556,11 +888,13 @@ namespace big } case 5: //Wheel Color { - for (int i = 0; i < 74; i++) + for (const auto& [color, name] : lsc_classic_colors) { - if (ImGui::Selectable(classic_names[i], color_check == classic_ids[i])) + if (ImGui::Selectable(name.c_str(), selected_color == color)) { - wheel_color = classic_ids[i]; + selected_color = color; + wheel_color = color; + g_fiber_pool->queue_job([] { VEHICLE::SET_VEHICLE_EXTRA_COLOURS(player_vehicle, pearlescent, wheel_color); }); @@ -570,11 +904,13 @@ namespace big } case 6: //Interior Color { - for (int i = 0; i < 74; i++) + for (const auto& [color, name] : lsc_classic_colors) { - if (ImGui::Selectable(classic_names[i], color_check == classic_ids[i])) + if (ImGui::Selectable(name.c_str(), selected_color == color)) { - interior_color = classic_ids[i]; + selected_color = color; + interior_color = color; + g_fiber_pool->queue_job([] { VEHICLE::SET_VEHICLE_INTERIOR_COLOR_(player_vehicle, interior_color); }); @@ -584,11 +920,13 @@ namespace big } case 7: //Dashboard Color { - for (int i = 0; i < 74; i++) + for (const auto& [color, name] : lsc_classic_colors) { - if (ImGui::Selectable(classic_names[i], color_check == classic_ids[i])) + if (ImGui::Selectable(name.c_str(), selected_color == color)) { - dashboard_color = classic_ids[i]; + selected_color = color; + dashboard_color = color; + g_fiber_pool->queue_job([] { VEHICLE::SET_VEHICLE_DASHBOARD_COLOR_(player_vehicle, dashboard_color); }); @@ -596,11 +934,26 @@ namespace big } break; } + case 9: //Headlight Color + { + for (const auto& [color, name] : lsc_headlight_colors) + { + if (ImGui::Selectable(name.c_str(), selected_color == color)) + { + selected_color = color; + headlight_color = color; + + g_fiber_pool->queue_job([] { + VEHICLE::SET_VEHICLE_XENON_LIGHTS_COLOR_(player_vehicle, headlight_color); + }); + } + } + break; } + } + ImGui::ListBoxFooter(); } } - - ImGui::EndGroup(); } } diff --git a/BigBaseV2/src/views/vehicle/view_vehicle.cpp b/BigBaseV2/src/views/vehicle/view_vehicle.cpp index 34db5af1..1b8727f7 100644 --- a/BigBaseV2/src/views/vehicle/view_vehicle.cpp +++ b/BigBaseV2/src/views/vehicle/view_vehicle.cpp @@ -1,10 +1,10 @@ -#include "core/data/speedo_meters.hpp" #include "fiber_pool.hpp" #include "gui/handling/handling_tabs.hpp" #include "script.hpp" #include "util/vehicle.hpp" #include "views/view.hpp" #include "util/mobile.hpp" +#include "core/data/speed_units.hpp" namespace big { @@ -23,7 +23,7 @@ namespace big ImGui::Separator(); - components::button("Teleport to PV", [] { + components::button("Teleport in PV", [] { Vehicle veh = globals::get_personal_vehicle(); teleport::into_vehicle(veh); }); @@ -125,29 +125,33 @@ namespace big ImGui::Separator(); + components::small_text("Speed Unit"); + + ImGui::RadioButton( + speed_unit_strings[(int)SpeedUnit::KMPH].c_str(), + (int*)&g->vehicle.speed_unit, + (int)SpeedUnit::KMPH + ); + ImGui::SameLine(); + ImGui::RadioButton( + speed_unit_strings[(int)SpeedUnit::MIPH].c_str(), + (int*)&g->vehicle.speed_unit, + (int)SpeedUnit::MIPH + ); + ImGui::SameLine(); + ImGui::RadioButton( + speed_unit_strings[(int)SpeedUnit::MPS].c_str(), + (int*)&g->vehicle.speed_unit, + (int)SpeedUnit::MPS + ); + + ImGui::Separator(); + components::small_text("Speedo Meter"); - SpeedoMeter* speed_meter_type_ptr = &g->vehicle.speedo_meter.type; + ImGui::Checkbox("Enabled", &g->vehicle.speedo_meter.enabled); - if (ImGui::BeginCombo("Format", speedo_meters[(int)*speed_meter_type_ptr].name)) - { - for (const auto& speedo : speedo_meters) - { - if (ImGui::Selectable(speedo.name, speedo.id == *speed_meter_type_ptr)) - { - *speed_meter_type_ptr = speedo.id; - } - - if (speedo.id == *speed_meter_type_ptr) - { - ImGui::SetItemDefaultFocus(); - } - } - - ImGui::EndCombo(); - } - - if (*speed_meter_type_ptr != SpeedoMeter::DISABLED) + if (g->vehicle.speedo_meter.enabled) { ImGui::Text("Position (X, Y)"); @@ -164,7 +168,6 @@ namespace big ImGui::Checkbox("Left Sided", &g->vehicle.speedo_meter.left_side); } - g->vehicle.proof_mask = 0; if (g->vehicle.god_mode) { diff --git a/BigBaseV2/src/views/vehicle/view_vehicle_fun.cpp b/BigBaseV2/src/views/vehicle/view_vehicle_fun.cpp index eb689ee9..f07c8ef0 100644 --- a/BigBaseV2/src/views/vehicle/view_vehicle_fun.cpp +++ b/BigBaseV2/src/views/vehicle/view_vehicle_fun.cpp @@ -1,10 +1,10 @@ -#include "core/data/speedo_meters.hpp" #include "fiber_pool.hpp" #include "gui/handling/handling_tabs.hpp" #include "script.hpp" #include "util/vehicle.hpp" #include "views/view.hpp" #include "util/mobile.hpp" +#include "core/data/speed_units.hpp" namespace big { @@ -28,7 +28,16 @@ namespace big TASK::CLEAR_PED_TASKS(self::ped); }); - ImGui::SliderInt("Top Speed", &g->vehicle.auto_drive_speed, 1, 200); + float auto_drive_speed_user_unit = vehicle::mps_to_speed(g->vehicle.auto_drive_speed, g->vehicle.speed_unit); + if (ImGui::SliderFloat( + fmt::format("Top Speed({})", speed_unit_strings[(int)g->vehicle.speed_unit]).c_str(), + &auto_drive_speed_user_unit, + vehicle::mps_to_speed(0.f, g->vehicle.speed_unit), + vehicle::mps_to_speed(150.f, g->vehicle.speed_unit), + "%.1f" + )) { + g->vehicle.auto_drive_speed = vehicle::speed_to_mps(auto_drive_speed_user_unit, g->vehicle.speed_unit); + } if (ImGui::BeginCombo("Driving Style", vehicle::driving_style_names[g->vehicle.driving_style_id])) { @@ -37,6 +46,7 @@ namespace big if (ImGui::Selectable(vehicle::driving_style_names[i], g->vehicle.driving_style_id == i)) { g->vehicle.driving_style_id = i; + g->vehicle.driving_style_flags = vehicle::driving_styles[g->vehicle.driving_style_id]; g_notification_service->push_warning("Auto Drive", fmt::format("Driving style set to {}.", vehicle::driving_style_names[i])); } @@ -98,6 +108,15 @@ namespace big ImGui::EndGroup(); - ImGui::SliderFloat("Speed", &g->vehicle.fly.speed, 1.f, 100.f, "%.0f", 1); + float fly_speed_user_unit = vehicle::mps_to_speed(g->vehicle.fly.speed, g->vehicle.speed_unit); + if (ImGui::SliderFloat( + fmt::format("Speed({})", speed_unit_strings[(int)g->vehicle.speed_unit]).c_str(), + &fly_speed_user_unit, + vehicle::mps_to_speed(0.f, g->vehicle.speed_unit), + vehicle::mps_to_speed(150.f, g->vehicle.speed_unit), + "%.1f" + )) { + g->vehicle.fly.speed = vehicle::speed_to_mps(fly_speed_user_unit, g->vehicle.speed_unit); + } } }