Vehicle control additions & fixes (#1926)
* Removed summon distance & car only check * Changed raw UI elements to components. * Added selection methods * feat(VehicleController): add translation strings Co-authored-by: Yimura <24669514+Yimura@users.noreply.github.com>
This commit is contained in:
parent
cd01243904
commit
590fb4af9f
@ -868,9 +868,9 @@ namespace big
|
|||||||
bool opened = false;
|
bool opened = false;
|
||||||
bool operation_animation = true;
|
bool operation_animation = true;
|
||||||
bool render_distance_on_veh = false;
|
bool render_distance_on_veh = false;
|
||||||
float max_summon_range = 200.f;
|
bool show_info = false;
|
||||||
|
|
||||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(vehicle_control, operation_animation, max_summon_range, render_distance_on_veh)
|
NLOHMANN_DEFINE_TYPE_INTRUSIVE(vehicle_control, operation_animation, render_distance_on_veh, show_info)
|
||||||
} vehicle_control{};
|
} vehicle_control{};
|
||||||
|
|
||||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(window, background_color, demo, text_color, button_color, frame_color, gui_scale, switched_view, ingame_overlay, vehicle_control, ingame_overlay_indicators)
|
NLOHMANN_DEFINE_TYPE_INTRUSIVE(window, background_color, demo, text_color, button_color, frame_color, gui_scale, switched_view, ingame_overlay, vehicle_control, ingame_overlay_indicators)
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "util/pathfind.hpp"
|
#include "util/pathfind.hpp"
|
||||||
#include "util/ped.hpp"
|
#include "util/ped.hpp"
|
||||||
#include "util/vehicle.hpp"
|
#include "util/vehicle.hpp"
|
||||||
|
#include "util/mobile.hpp"
|
||||||
|
|
||||||
namespace big
|
namespace big
|
||||||
{
|
{
|
||||||
@ -70,6 +71,9 @@ namespace big
|
|||||||
|
|
||||||
controlled_vehicle vehicle_control::update_vehicle(Vehicle veh)
|
controlled_vehicle vehicle_control::update_vehicle(Vehicle veh)
|
||||||
{
|
{
|
||||||
|
if(!ENTITY::DOES_ENTITY_EXIST(veh))
|
||||||
|
return {};
|
||||||
|
|
||||||
controlled_vehicle new_veh{};
|
controlled_vehicle new_veh{};
|
||||||
|
|
||||||
new_veh.handle = veh;
|
new_veh.handle = veh;
|
||||||
@ -78,6 +82,7 @@ namespace big
|
|||||||
new_veh.doorCount = VEHICLE::GET_NUMBER_OF_VEHICLE_DOORS(veh);
|
new_veh.doorCount = VEHICLE::GET_NUMBER_OF_VEHICLE_DOORS(veh);
|
||||||
new_veh.lockstate = (eVehicleLockState)VEHICLE::GET_VEHICLE_DOOR_LOCK_STATUS(veh);
|
new_veh.lockstate = (eVehicleLockState)VEHICLE::GET_VEHICLE_DOOR_LOCK_STATUS(veh);
|
||||||
new_veh.isconvertible = VEHICLE::IS_VEHICLE_A_CONVERTIBLE(veh, 0);
|
new_veh.isconvertible = VEHICLE::IS_VEHICLE_A_CONVERTIBLE(veh, 0);
|
||||||
|
|
||||||
update_controlled_vehicle_doors(new_veh);
|
update_controlled_vehicle_doors(new_veh);
|
||||||
update_controlled_vehicle_lights(new_veh);
|
update_controlled_vehicle_lights(new_veh);
|
||||||
|
|
||||||
@ -94,9 +99,7 @@ namespace big
|
|||||||
|
|
||||||
veh.convertibelstate = VEHICLE::GET_CONVERTIBLE_ROOF_STATE(veh.handle);
|
veh.convertibelstate = VEHICLE::GET_CONVERTIBLE_ROOF_STATE(veh.handle);
|
||||||
veh.engine = VEHICLE::GET_IS_VEHICLE_ENGINE_RUNNING(veh.handle);
|
veh.engine = VEHICLE::GET_IS_VEHICLE_ENGINE_RUNNING(veh.handle);
|
||||||
veh.radio = AUDIO::IS_VEHICLE_RADIO_ON(veh.handle);
|
|
||||||
veh.radiochannel = AUDIO::GET_PLAYER_RADIO_STATION_INDEX();
|
|
||||||
|
|
||||||
if (g.window.vehicle_control.render_distance_on_veh
|
if (g.window.vehicle_control.render_distance_on_veh
|
||||||
&& math::distance_between_vectors(self::pos, ENTITY::GET_ENTITY_COORDS(m_controlled_vehicle.handle, true)) > 10.f)
|
&& math::distance_between_vectors(self::pos, ENTITY::GET_ENTITY_COORDS(m_controlled_vehicle.handle, true)) > 10.f)
|
||||||
vehicle_control::render_distance_on_vehicle();
|
vehicle_control::render_distance_on_vehicle();
|
||||||
@ -106,47 +109,21 @@ namespace big
|
|||||||
* Imitated from freemode.c script, findable by searching for MISC::GET_HASH_KEY("BONEMASK_HEAD_NECK_AND_R_ARM");
|
* Imitated from freemode.c script, findable by searching for MISC::GET_HASH_KEY("BONEMASK_HEAD_NECK_AND_R_ARM");
|
||||||
* Script uses TASK::TASK_SCRIPTED_ANIMATION but can be dissected to use as follows
|
* Script uses TASK::TASK_SCRIPTED_ANIMATION but can be dissected to use as follows
|
||||||
*/
|
*/
|
||||||
void vehicle_control::animated_vehicle_operation(Ped ped)
|
void vehicle_control::vehicle_operation(std::function<void()> operation)
|
||||||
{
|
{
|
||||||
ped::ped_play_animation(ped, VEH_OP_ANIM_DICT, VEH_OP_ANIM, 4, -4, -1, 48, 0, false);
|
if (g.window.vehicle_control.operation_animation)
|
||||||
AUDIO::PLAY_SOUND_FROM_ENTITY(-1, "Remote_Control_Fob", self::ped, "PI_Menu_Sounds", true, 0);
|
|
||||||
script::get_current()->yield(100ms);
|
|
||||||
for (int i = 0; i < 35 && ENTITY::IS_ENTITY_PLAYING_ANIM(self::ped, VEH_OP_ANIM_DICT, VEH_OP_ANIM, 3); i++)
|
|
||||||
{
|
{
|
||||||
script::get_current()->yield(10ms);
|
ped::ped_play_animation(self::ped, VEH_OP_ANIM_DICT, VEH_OP_ANIM, 4, -4, -1, 48, 0, false);
|
||||||
|
AUDIO::PLAY_SOUND_FROM_ENTITY(-1, "Remote_Control_Fob", self::ped, "PI_Menu_Sounds", true, 0);
|
||||||
|
script::get_current()->yield(100ms);
|
||||||
|
for (int i = 0; i < 35 && ENTITY::IS_ENTITY_PLAYING_ANIM(self::ped, VEH_OP_ANIM_DICT, VEH_OP_ANIM, 3); i++)
|
||||||
|
{
|
||||||
|
script::get_current()->yield(10ms);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void vehicle_control::operate_door(eDoorId door, bool open)
|
if (entity::take_control_of(m_controlled_vehicle.handle))
|
||||||
{
|
operation();
|
||||||
if (g.window.vehicle_control.operation_animation)
|
|
||||||
animated_vehicle_operation(self::ped);
|
|
||||||
|
|
||||||
vehicle::operate_vehicle_door(m_controlled_vehicle.handle, door, open);
|
|
||||||
}
|
|
||||||
|
|
||||||
void vehicle_control::operate_window(eWindowId window, bool open)
|
|
||||||
{
|
|
||||||
if (g.window.vehicle_control.operation_animation)
|
|
||||||
animated_vehicle_operation(self::ped);
|
|
||||||
|
|
||||||
vehicle::operate_vehicle_window(m_controlled_vehicle.handle, window, open);
|
|
||||||
}
|
|
||||||
|
|
||||||
void vehicle_control::operate_lights(bool headlights, bool highbeams)
|
|
||||||
{
|
|
||||||
if (g.window.vehicle_control.operation_animation)
|
|
||||||
animated_vehicle_operation(self::ped);
|
|
||||||
|
|
||||||
vehicle::operate_vehicle_headlights(m_controlled_vehicle.handle, headlights, highbeams);
|
|
||||||
}
|
|
||||||
|
|
||||||
void vehicle_control::operate_neons(int index, bool toggle)
|
|
||||||
{
|
|
||||||
if (g.window.vehicle_control.operation_animation)
|
|
||||||
animated_vehicle_operation(self::ped);
|
|
||||||
|
|
||||||
vehicle::operate_vehicle_neons(m_controlled_vehicle.handle, index, toggle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void vehicle_control::driver_tick()
|
void vehicle_control::driver_tick()
|
||||||
@ -321,15 +298,6 @@ namespace big
|
|||||||
behind_pos = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(self::ped, 0.f, 4.f, 0.f);
|
behind_pos = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(self::ped, 0.f, 4.f, 0.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (math::distance_between_vectors(self::pos, ENTITY::GET_ENTITY_COORDS(m_controlled_vehicle.handle, true))
|
|
||||||
> g.window.vehicle_control.max_summon_range)
|
|
||||||
{
|
|
||||||
//LOG(INFO) << "Vehicle is too far, teleporting";
|
|
||||||
m_destination = behind_pos;
|
|
||||||
ENTITY::SET_ENTITY_COORDS(m_controlled_vehicle.handle, behind_pos.x, behind_pos.y, behind_pos.z, 0, 0, 0, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_driver_performing_task = true;
|
m_driver_performing_task = true;
|
||||||
|
|
||||||
if (ensure_driver())
|
if (ensure_driver())
|
||||||
@ -376,13 +344,8 @@ namespace big
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void vehicle_control::tick()
|
void vehicle_control::get_last_driven_vehicle()
|
||||||
{
|
{
|
||||||
m_controlled_vehicle_exists = m_controlled_vehicle.ptr && ENTITY::DOES_ENTITY_EXIST(m_controlled_vehicle.handle)
|
|
||||||
&& VEHICLE::IS_THIS_MODEL_A_CAR(ENTITY::GET_ENTITY_MODEL(m_controlled_vehicle.handle));
|
|
||||||
|
|
||||||
driver_tick();
|
|
||||||
|
|
||||||
//Check in memory for vehicle
|
//Check in memory for vehicle
|
||||||
if (g_local_player)
|
if (g_local_player)
|
||||||
{
|
{
|
||||||
@ -399,13 +362,42 @@ namespace big
|
|||||||
m_controlled_vehicle = vehicle_control::update_vehicle(self::veh);
|
m_controlled_vehicle = vehicle_control::update_vehicle(self::veh);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g.window.vehicle_control.opened)
|
|
||||||
return;
|
|
||||||
|
|
||||||
//Manual check if there is a last driven vehicle
|
//Manual check if there is a last driven vehicle
|
||||||
if (!m_controlled_vehicle_exists && ENTITY::DOES_ENTITY_EXIST(VEHICLE::GET_LAST_DRIVEN_VEHICLE()))
|
if (!m_controlled_vehicle_exists && ENTITY::DOES_ENTITY_EXIST(VEHICLE::GET_LAST_DRIVEN_VEHICLE()))
|
||||||
m_controlled_vehicle = vehicle_control::update_vehicle(VEHICLE::GET_LAST_DRIVEN_VEHICLE());
|
m_controlled_vehicle = vehicle_control::update_vehicle(VEHICLE::GET_LAST_DRIVEN_VEHICLE());
|
||||||
|
}
|
||||||
|
|
||||||
|
void vehicle_control::get_personal_vehicle()
|
||||||
|
{
|
||||||
|
if(ENTITY::DOES_ENTITY_EXIST(mobile::mechanic::get_personal_vehicle()))
|
||||||
|
m_controlled_vehicle = vehicle_control::update_vehicle(mobile::mechanic::get_personal_vehicle());
|
||||||
|
}
|
||||||
|
|
||||||
|
void vehicle_control::get_closest_vehicle()
|
||||||
|
{
|
||||||
|
if(PED::IS_PED_IN_ANY_VEHICLE(self::ped, true))
|
||||||
|
m_controlled_vehicle = vehicle_control::update_vehicle(PED::GET_VEHICLE_PED_IS_USING(self::ped));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_controlled_vehicle = vehicle_control::update_vehicle(vehicle::get_closest_to_location(self::pos, 1000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void vehicle_control::tick()
|
||||||
|
{
|
||||||
|
m_controlled_vehicle_exists = m_controlled_vehicle.ptr && ENTITY::DOES_ENTITY_EXIST(m_controlled_vehicle.handle);
|
||||||
|
|
||||||
|
driver_tick();
|
||||||
keep_controlled_vehicle_data_updated(m_controlled_vehicle);
|
keep_controlled_vehicle_data_updated(m_controlled_vehicle);
|
||||||
|
|
||||||
|
if (!g.window.vehicle_control.opened)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (m_selection_mode)
|
||||||
|
{
|
||||||
|
case eControlledVehSelectionMode::LAST_DRIVEN: get_last_driven_vehicle(); break;
|
||||||
|
case eControlledVehSelectionMode::PERSONAL: get_personal_vehicle(); break;
|
||||||
|
case eControlledVehSelectionMode::CLOSEST: get_closest_vehicle(); break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,6 +9,13 @@ namespace big
|
|||||||
constexpr auto VEH_OP_ANIM_DICT = "ANIM@MP_PLAYER_INTMENU@KEY_FOB@";
|
constexpr auto VEH_OP_ANIM_DICT = "ANIM@MP_PLAYER_INTMENU@KEY_FOB@";
|
||||||
constexpr auto VEH_OP_ANIM = "FOB_CLICK";
|
constexpr auto VEH_OP_ANIM = "FOB_CLICK";
|
||||||
|
|
||||||
|
enum class eControlledVehSelectionMode
|
||||||
|
{
|
||||||
|
LAST_DRIVEN,
|
||||||
|
PERSONAL,
|
||||||
|
CLOSEST
|
||||||
|
};
|
||||||
|
|
||||||
struct vehicle_door
|
struct vehicle_door
|
||||||
{
|
{
|
||||||
eDoorId id;
|
eDoorId id;
|
||||||
@ -36,8 +43,6 @@ namespace big
|
|||||||
bool engine;
|
bool engine;
|
||||||
bool neons[4];
|
bool neons[4];
|
||||||
bool isconvertible;
|
bool isconvertible;
|
||||||
bool radio;
|
|
||||||
int radiochannel;
|
|
||||||
int convertibelstate;
|
int convertibelstate;
|
||||||
int headlights, highbeams;
|
int headlights, highbeams;
|
||||||
};
|
};
|
||||||
@ -47,6 +52,9 @@ namespace big
|
|||||||
private:
|
private:
|
||||||
controlled_vehicle update_vehicle(Vehicle veh);
|
controlled_vehicle update_vehicle(Vehicle veh);
|
||||||
void keep_controlled_vehicle_data_updated(controlled_vehicle& veh);
|
void keep_controlled_vehicle_data_updated(controlled_vehicle& veh);
|
||||||
|
void get_last_driven_vehicle();
|
||||||
|
void get_personal_vehicle();
|
||||||
|
void get_closest_vehicle();
|
||||||
|
|
||||||
//Autonomy
|
//Autonomy
|
||||||
void driver_tick();
|
void driver_tick();
|
||||||
@ -60,17 +68,14 @@ namespace big
|
|||||||
public:
|
public:
|
||||||
controlled_vehicle m_controlled_vehicle;
|
controlled_vehicle m_controlled_vehicle;
|
||||||
bool m_controlled_vehicle_exists;
|
bool m_controlled_vehicle_exists;
|
||||||
|
eControlledVehSelectionMode m_selection_mode = eControlledVehSelectionMode::LAST_DRIVEN;
|
||||||
|
|
||||||
//Autonomy
|
//Autonomy
|
||||||
bool m_driver_performing_task;
|
bool m_driver_performing_task;
|
||||||
int m_distance_to_destination;
|
int m_distance_to_destination;
|
||||||
char m_currentask[100];
|
char m_currentask[100];
|
||||||
|
|
||||||
void animated_vehicle_operation(Ped ped);
|
void vehicle_operation(std::function<void()> operation);
|
||||||
void operate_door(eDoorId, bool);
|
|
||||||
void operate_window(eWindowId, bool);
|
|
||||||
void operate_lights(bool headlights, bool highbeams);
|
|
||||||
void operate_neons(int index, bool toggle);
|
|
||||||
void summon_vehicle();
|
void summon_vehicle();
|
||||||
|
|
||||||
void tick();
|
void tick();
|
||||||
|
@ -42,31 +42,29 @@ namespace big
|
|||||||
{
|
{
|
||||||
for (int lockindex = 0; lockindex < MAX_VEHICLE_LOCK_STATES; lockindex++)
|
for (int lockindex = 0; lockindex < MAX_VEHICLE_LOCK_STATES; lockindex++)
|
||||||
{
|
{
|
||||||
if (ImGui::Selectable(locknames[lockindex]))
|
components::selectable(locknames[lockindex], false, [lockindex] {
|
||||||
{
|
g_vehicle_control_service.vehicle_operation([lockindex] {
|
||||||
g_fiber_pool->queue_job([=] {
|
|
||||||
vehicle::change_vehicle_door_lock_state(g_vehicle_control_service.m_controlled_vehicle.handle, eDoorId::VEH_EXT_DOOR_INVALID_ID, (eVehicleLockState)lockindex);
|
vehicle::change_vehicle_door_lock_state(g_vehicle_control_service.m_controlled_vehicle.handle, eDoorId::VEH_EXT_DOOR_INVALID_ID, (eVehicleLockState)lockindex);
|
||||||
});
|
});
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
ImGui::EndCombo();
|
ImGui::EndCombo();
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
if (components::button("OPEN_ALL_DOORS"_T))
|
components::button("OPEN_ALL_DOORS"_T, [] {
|
||||||
{
|
g_vehicle_control_service.vehicle_operation([] {
|
||||||
g_fiber_pool->queue_job([=] {
|
vehicle::operate_vehicle_door(g_vehicle_control_service.m_controlled_vehicle.handle, eDoorId::VEH_EXT_DOOR_INVALID_ID, true);
|
||||||
g_vehicle_control_service.operate_door(eDoorId::VEH_EXT_DOOR_INVALID_ID, true);
|
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
if (components::button("CLOSE_ALL_DOORS"_T))
|
components::button("CLOSE_ALL_DOORS"_T, [] {
|
||||||
{
|
g_vehicle_control_service.vehicle_operation([] {
|
||||||
g_fiber_pool->queue_job([=] {
|
vehicle::operate_vehicle_door(g_vehicle_control_service.m_controlled_vehicle.handle, eDoorId::VEH_EXT_DOOR_INVALID_ID, false);
|
||||||
g_vehicle_control_service.operate_door(eDoorId::VEH_EXT_DOOR_INVALID_ID, false);
|
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
|
||||||
ImGui::EndGroup();
|
ImGui::EndGroup();
|
||||||
|
|
||||||
@ -84,12 +82,11 @@ namespace big
|
|||||||
{
|
{
|
||||||
for (int lockindex = 0; lockindex < MAX_VEHICLE_LOCK_STATES; lockindex++)
|
for (int lockindex = 0; lockindex < MAX_VEHICLE_LOCK_STATES; lockindex++)
|
||||||
{
|
{
|
||||||
if (ImGui::Selectable(locknames[lockindex]))
|
components::selectable(locknames[lockindex], false, [i, lockindex] {
|
||||||
{
|
g_vehicle_control_service.vehicle_operation([i, lockindex] {
|
||||||
g_fiber_pool->queue_job([=] {
|
|
||||||
vehicle::change_vehicle_door_lock_state(g_vehicle_control_service.m_controlled_vehicle.handle, (eDoorId)i, (eVehicleLockState)lockindex);
|
vehicle::change_vehicle_door_lock_state(g_vehicle_control_service.m_controlled_vehicle.handle, (eDoorId)i, (eVehicleLockState)lockindex);
|
||||||
});
|
});
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
ImGui::EndCombo();
|
ImGui::EndCombo();
|
||||||
}
|
}
|
||||||
@ -97,17 +94,17 @@ namespace big
|
|||||||
ImGui::SameLine(300);
|
ImGui::SameLine(300);
|
||||||
|
|
||||||
const auto button_label = g_vehicle_control_service.m_controlled_vehicle.doors[i].open ? "CLOSE"_T : "OPEN"_T;
|
const auto button_label = g_vehicle_control_service.m_controlled_vehicle.doors[i].open ? "CLOSE"_T : "OPEN"_T;
|
||||||
if (components::button(button_label))
|
components::button(button_label, [i] {
|
||||||
{
|
g_vehicle_control_service.vehicle_operation([i] {
|
||||||
g_fiber_pool->queue_job([=] {
|
vehicle::operate_vehicle_door(g_vehicle_control_service.m_controlled_vehicle.handle,
|
||||||
g_vehicle_control_service.operate_door((eDoorId)i,
|
(eDoorId)i,
|
||||||
!g_vehicle_control_service.m_controlled_vehicle.doors[i].open);
|
!g_vehicle_control_service.m_controlled_vehicle.doors[i].open);
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ImGui::EndGroup();
|
ImGui::EndGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,11 +121,11 @@ namespace big
|
|||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
ImGui::SetNextItemWidth(200);
|
ImGui::SetNextItemWidth(200);
|
||||||
components::button("VIEW_VEHICLE_CONTROL_ROLL_DOWN_ALL"_T, [] {
|
components::button("VIEW_VEHICLE_CONTROL_ROLL_DOWN_ALL"_T, [] {
|
||||||
g_vehicle_control_service.operate_window(eWindowId::WINDOW_INVALID_ID, true);
|
vehicle::operate_vehicle_window(g_vehicle_control_service.m_controlled_vehicle.handle, eWindowId::WINDOW_INVALID_ID, true);
|
||||||
});
|
});
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
components::button("VIEW_VEHICLE_CONTROL_ROLL_UP_ALL"_T, [] {
|
components::button("VIEW_VEHICLE_CONTROL_ROLL_UP_ALL"_T, [] {
|
||||||
g_vehicle_control_service.operate_window(eWindowId::WINDOW_INVALID_ID, false);
|
vehicle::operate_vehicle_window(g_vehicle_control_service.m_controlled_vehicle.handle, eWindowId::WINDOW_INVALID_ID, false);
|
||||||
});
|
});
|
||||||
ImGui::EndGroup();
|
ImGui::EndGroup();
|
||||||
|
|
||||||
@ -143,11 +140,11 @@ namespace big
|
|||||||
ImGui::Text(windownames[i]);
|
ImGui::Text(windownames[i]);
|
||||||
ImGui::SameLine(300);
|
ImGui::SameLine(300);
|
||||||
components::button("VIEW_VEHICLE_CONTROL_ROLL_DOWN"_T, [i] {
|
components::button("VIEW_VEHICLE_CONTROL_ROLL_DOWN"_T, [i] {
|
||||||
g_vehicle_control_service.operate_window((eWindowId)i, true);
|
vehicle::operate_vehicle_window(g_vehicle_control_service.m_controlled_vehicle.handle, (eWindowId)i, true);
|
||||||
});
|
});
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
components::button("VIEW_VEHICLE_CONTROL_ROLL_UP"_T, [i] {
|
components::button("VIEW_VEHICLE_CONTROL_ROLL_UP"_T, [i] {
|
||||||
g_vehicle_control_service.operate_window((eWindowId)i, false);
|
vehicle::operate_vehicle_window(g_vehicle_control_service.m_controlled_vehicle.handle, (eWindowId)i, false);
|
||||||
});
|
});
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
@ -162,37 +159,36 @@ namespace big
|
|||||||
"BACK"_T.data(),
|
"BACK"_T.data(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (components::button("VEHICLE_CONTROLLER_TOGGLE_LIGHTS"_T))
|
components::button("VEHICLE_CONTROLLER_TOGGLE_LIGHTS"_T, [] {
|
||||||
{
|
g_vehicle_control_service.vehicle_operation([=] {
|
||||||
g_fiber_pool->queue_job([=] {
|
vehicle::operate_vehicle_headlights(g_vehicle_control_service.m_controlled_vehicle.handle,
|
||||||
g_vehicle_control_service.operate_lights(!g_vehicle_control_service.m_controlled_vehicle.headlights, false);
|
!g_vehicle_control_service.m_controlled_vehicle.headlights,
|
||||||
|
false);
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (components::button("VEHICLE_CONTROLLER_TOGGLE_HIGH_BEAMS"_T))
|
components::button("VEHICLE_CONTROLLER_TOGGLE_HIGH_BEAMS"_T, [] {
|
||||||
{
|
g_vehicle_control_service.vehicle_operation([=] {
|
||||||
g_fiber_pool->queue_job([=] {
|
vehicle::operate_vehicle_headlights(g_vehicle_control_service.m_controlled_vehicle.handle,
|
||||||
g_vehicle_control_service.operate_lights(g_vehicle_control_service.m_controlled_vehicle.headlights,
|
g_vehicle_control_service.m_controlled_vehicle.headlights,
|
||||||
!g_vehicle_control_service.m_controlled_vehicle.highbeams);
|
!g_vehicle_control_service.m_controlled_vehicle.highbeams);
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
if (components::button("VEHICLE_CONTROLLER_INTERIOR_LIGHTS_ON"_T))
|
|
||||||
{
|
components::button("VEHICLE_CONTROLLER_INTERIOR_LIGHTS_ON"_T, [] {
|
||||||
g_fiber_pool->queue_job([=] {
|
g_vehicle_control_service.vehicle_operation([] {
|
||||||
if (g.window.vehicle_control.operation_animation)
|
|
||||||
g_vehicle_control_service.animated_vehicle_operation(self::ped);
|
|
||||||
VEHICLE::SET_VEHICLE_INTERIORLIGHT(g_vehicle_control_service.m_controlled_vehicle.handle, true);
|
VEHICLE::SET_VEHICLE_INTERIORLIGHT(g_vehicle_control_service.m_controlled_vehicle.handle, true);
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (components::button("VEHICLE_CONTROLLER_INTERIOR_LIGHTS_OFF"_T))
|
|
||||||
{
|
components::button("VEHICLE_CONTROLLER_INTERIOR_LIGHTS_OFF"_T, [] {
|
||||||
g_fiber_pool->queue_job([=] {
|
g_vehicle_control_service.vehicle_operation([] {
|
||||||
if (g.window.vehicle_control.operation_animation)
|
|
||||||
g_vehicle_control_service.animated_vehicle_operation(self::ped);
|
|
||||||
VEHICLE::SET_VEHICLE_INTERIORLIGHT(g_vehicle_control_service.m_controlled_vehicle.handle, false);
|
VEHICLE::SET_VEHICLE_INTERIORLIGHT(g_vehicle_control_service.m_controlled_vehicle.handle, false);
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
|
||||||
ImGui::Text("VEHICLE_CONTROLLER_NEON_LIGHTS"_T.data());
|
ImGui::Text("VEHICLE_CONTROLLER_NEON_LIGHTS"_T.data());
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
@ -202,7 +198,11 @@ namespace big
|
|||||||
if (ImGui::Checkbox(neonnames[i], &g_vehicle_control_service.m_controlled_vehicle.neons[i]))
|
if (ImGui::Checkbox(neonnames[i], &g_vehicle_control_service.m_controlled_vehicle.neons[i]))
|
||||||
{
|
{
|
||||||
g_fiber_pool->queue_job([=] {
|
g_fiber_pool->queue_job([=] {
|
||||||
g_vehicle_control_service.operate_neons(i, g_vehicle_control_service.m_controlled_vehicle.neons[i]);
|
g_vehicle_control_service.vehicle_operation([i] {
|
||||||
|
vehicle::operate_vehicle_neons(g_vehicle_control_service.m_controlled_vehicle.handle,
|
||||||
|
i,
|
||||||
|
!g_vehicle_control_service.m_controlled_vehicle.neons[i]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -258,49 +258,47 @@ namespace big
|
|||||||
|
|
||||||
if (g_vehicle_control_service.m_controlled_vehicle.isconvertible)
|
if (g_vehicle_control_service.m_controlled_vehicle.isconvertible)
|
||||||
{
|
{
|
||||||
if (components::button(g_vehicle_control_service.m_controlled_vehicle.convertibelstate ? "VIEW_VEHICLE_CONTROL_RAISE"_T : "VIEW_VEHICLE_CONTROL_LOWER"_T))
|
components::button(g_vehicle_control_service.m_controlled_vehicle.convertibelstate ? "VIEW_VEHICLE_CONTROL_RAISE"_T : "VIEW_VEHICLE_CONTROL_LOWER"_T, [] {
|
||||||
{
|
g_vehicle_control_service.vehicle_operation([] {
|
||||||
g_fiber_pool->queue_job([=] {
|
|
||||||
if (g.window.vehicle_control.operation_animation)
|
|
||||||
g_vehicle_control_service.animated_vehicle_operation(self::ped);
|
|
||||||
|
|
||||||
if (g_vehicle_control_service.m_controlled_vehicle.convertibelstate > 0)
|
if (g_vehicle_control_service.m_controlled_vehicle.convertibelstate > 0)
|
||||||
VEHICLE::RAISE_CONVERTIBLE_ROOF(g_vehicle_control_service.m_controlled_vehicle.handle, false);
|
VEHICLE::RAISE_CONVERTIBLE_ROOF(g_vehicle_control_service.m_controlled_vehicle.handle, false);
|
||||||
else
|
else
|
||||||
VEHICLE::LOWER_CONVERTIBLE_ROOF(g_vehicle_control_service.m_controlled_vehicle.handle, false);
|
VEHICLE::LOWER_CONVERTIBLE_ROOF(g_vehicle_control_service.m_controlled_vehicle.handle, false);
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::Text(std::format("{}: {}", "VIEW_VEHICLE_CONTROL_CONVERTIBLE_STATE"_T, convertiblestates[g_vehicle_control_service.m_controlled_vehicle.convertibelstate]).c_str());
|
ImGui::Text(std::format("{}: {}",
|
||||||
|
"VIEW_VEHICLE_CONTROL_CONVERTIBLE_STATE"_T,
|
||||||
|
convertiblestates[g_vehicle_control_service.m_controlled_vehicle.convertibelstate])
|
||||||
|
.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui::Checkbox(g_vehicle_control_service.m_controlled_vehicle.engine ? "VIEW_DEBUG_ANIMATIONS_STOP"_T.data() : "SETTINGS_NOTIFY_GTA_THREADS_START"_T.data(),
|
if (ImGui::Checkbox(g_vehicle_control_service.m_controlled_vehicle.engine ?
|
||||||
|
"VIEW_DEBUG_ANIMATIONS_STOP"_T.data() :
|
||||||
|
"SETTINGS_NOTIFY_GTA_THREADS_START"_T.data(),
|
||||||
&g_vehicle_control_service.m_controlled_vehicle.engine))
|
&g_vehicle_control_service.m_controlled_vehicle.engine))
|
||||||
{
|
{
|
||||||
g_fiber_pool->queue_job([=] {
|
g_fiber_pool->queue_job([=] {
|
||||||
if (g.window.vehicle_control.operation_animation)
|
g_vehicle_control_service.vehicle_operation([] {
|
||||||
g_vehicle_control_service.animated_vehicle_operation(self::ped);
|
|
||||||
|
|
||||||
if (entity::take_control_of(g_vehicle_control_service.m_controlled_vehicle.handle))
|
|
||||||
VEHICLE::SET_VEHICLE_ENGINE_ON(g_vehicle_control_service.m_controlled_vehicle.handle,
|
VEHICLE::SET_VEHICLE_ENGINE_ON(g_vehicle_control_service.m_controlled_vehicle.handle,
|
||||||
!g_vehicle_control_service.m_controlled_vehicle.engine,
|
!g_vehicle_control_service.m_controlled_vehicle.engine,
|
||||||
true,
|
true,
|
||||||
false);
|
false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::Text(std::format("{}: {}", "VIEW_VEHICLE_CONTROL_ENGINE"_T, g_vehicle_control_service.m_controlled_vehicle.engine ? "VIEW_VEHICLE_CONTROL_ENGINE_RUNNING"_T : "OFF"_T).c_str());
|
ImGui::Text(
|
||||||
|
std::format("{}: {}", "VIEW_VEHICLE_CONTROL_ENGINE"_T, g_vehicle_control_service.m_controlled_vehicle.engine ? "VIEW_VEHICLE_CONTROL_ENGINE_RUNNING"_T : "OFF"_T)
|
||||||
|
.c_str());
|
||||||
|
|
||||||
components::button(g_vehicle_control_service.m_driver_performing_task ? "CANCEL"_T : "VIEW_VEHICLE_CONTROL_SUMMON"_T, [] {
|
components::button(g_vehicle_control_service.m_driver_performing_task ? "CANCEL"_T : "VIEW_VEHICLE_CONTROL_SUMMON"_T, [] {
|
||||||
if (!g_vehicle_control_service.m_driver_performing_task)
|
if (!g_vehicle_control_service.m_driver_performing_task)
|
||||||
{
|
g_vehicle_control_service.vehicle_operation([] {
|
||||||
if (g.window.vehicle_control.operation_animation)
|
g_vehicle_control_service.summon_vehicle();
|
||||||
g_vehicle_control_service.animated_vehicle_operation(self::ped);
|
});
|
||||||
|
|
||||||
g_vehicle_control_service.summon_vehicle();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
g_vehicle_control_service.m_driver_performing_task = false;
|
g_vehicle_control_service.m_driver_performing_task = false;
|
||||||
});
|
});
|
||||||
@ -308,7 +306,9 @@ namespace big
|
|||||||
if (g_vehicle_control_service.m_driver_performing_task)
|
if (g_vehicle_control_service.m_driver_performing_task)
|
||||||
{
|
{
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::Text(std::format("{}: {}", "VIEW_SELF_CUSTOM_TELEPORT_DISTANCE"_T, g_vehicle_control_service.m_distance_to_destination).c_str());
|
ImGui::Text(std::format("{}: {}", "VIEW_SELF_CUSTOM_TELEPORT_DISTANCE"_T, g_vehicle_control_service.m_distance_to_destination)
|
||||||
|
.c_str());
|
||||||
|
|
||||||
|
|
||||||
ImGui::Text(std::format("{}: {}", "OUTFIT_TASK"_T, g_vehicle_control_service.m_currentask).c_str());
|
ImGui::Text(std::format("{}: {}", "OUTFIT_TASK"_T, g_vehicle_control_service.m_currentask).c_str());
|
||||||
}
|
}
|
||||||
@ -318,14 +318,23 @@ namespace big
|
|||||||
g.window.vehicle_control.operation_animation);
|
g.window.vehicle_control.operation_animation);
|
||||||
bool_command render_veh_dist("vehcontrolrendervehdist", "VIEW_VEHICLE_CONTROL_RENDER_DISTANCE_ON_VEHICLE", "VIEW_VEHICLE_CONTROL_RENDER_DISTANCE_ON_VEHICLE_DESC",
|
bool_command render_veh_dist("vehcontrolrendervehdist", "VIEW_VEHICLE_CONTROL_RENDER_DISTANCE_ON_VEHICLE", "VIEW_VEHICLE_CONTROL_RENDER_DISTANCE_ON_VEHICLE_DESC",
|
||||||
g.window.vehicle_control.render_distance_on_veh);
|
g.window.vehicle_control.render_distance_on_veh);
|
||||||
float_command max_summon_dist("vehcontrolmaxsummondist", "VIEW_VEHICLE_CONTROL_MAX_SUMMON_DISTANCE", "VIEW_VEHICLE_CONTROL_MAX_SUMMON_DISTANCE_DESC",
|
bool_command show_vehicle_info("vehcontrolshowvehinfo", "VIEW_VEHICLE_CONTROL_SHOW_VEHICLE_INFO", "VIEW_VEHICLE_CONTROL_SHOW_VEHICLE_INFO_DESC",
|
||||||
g.window.vehicle_control.max_summon_range, 10.f, 250.f);
|
g.window.vehicle_control.show_info);
|
||||||
|
|
||||||
void render_settings_tab()
|
void render_settings_tab()
|
||||||
{
|
{
|
||||||
components::command_checkbox<"vehcontroluseanims">();
|
components::command_checkbox<"vehcontroluseanims">();
|
||||||
components::command_checkbox<"vehcontrolrendervehdist">();
|
components::command_checkbox<"vehcontrolrendervehdist">();
|
||||||
components::command_float_slider<"vehcontrolmaxsummondist">();
|
components::command_checkbox<"vehcontrolshowvehinfo">();
|
||||||
|
|
||||||
|
ImGui::SeparatorText("VIEW_VEHICLE_CONTROL_SELECTION_MODE"_T.data());
|
||||||
|
ImGui::RadioButton("VIEW_VEHICLE_CONTROL_SELECTION_MODE_LAST_DRIVEN"_T.data(), (int*)&g_vehicle_control_service.m_selection_mode, (int)eControlledVehSelectionMode::LAST_DRIVEN);
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::RadioButton("VIEW_VEHICLE_CONTROL_SELECTION_MODE_PERSONAL_VEHICLE"_T.data(),
|
||||||
|
(int*)&g_vehicle_control_service.m_selection_mode,
|
||||||
|
(int)eControlledVehSelectionMode::PERSONAL);
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::RadioButton("VIEW_VEHICLE_CONTROL_SELECTION_MODE_CLOSEST"_T.data(), (int*)&g_vehicle_control_service.m_selection_mode, (int)eControlledVehSelectionMode::CLOSEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
void view::vehicle_control()
|
void view::vehicle_control()
|
||||||
@ -340,6 +349,15 @@ namespace big
|
|||||||
if (g_vehicle_control_service.m_controlled_vehicle_exists)
|
if (g_vehicle_control_service.m_controlled_vehicle_exists)
|
||||||
{
|
{
|
||||||
ImGui::Text(g_vehicle_control_service.m_controlled_vehicle.model_name);
|
ImGui::Text(g_vehicle_control_service.m_controlled_vehicle.model_name);
|
||||||
|
if (g.window.vehicle_control.show_info)
|
||||||
|
{
|
||||||
|
ImGui::Text(std::vformat("VIEW_VEHICLE_CONTROL_HEALTH_N_PASSENGERS"_T,
|
||||||
|
std::make_format_args(g_vehicle_control_service.m_controlled_vehicle.ptr->m_health,
|
||||||
|
g_vehicle_control_service.m_controlled_vehicle.ptr->m_num_of_passengers,
|
||||||
|
g_vehicle_control_service.m_controlled_vehicle.ptr->m_max_passengers))
|
||||||
|
.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
if (ImGui::BeginTabBar("##vehiclecontroltabbar"))
|
if (ImGui::BeginTabBar("##vehiclecontroltabbar"))
|
||||||
@ -386,7 +404,6 @@ namespace big
|
|||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ImGui::EndTabBar();
|
ImGui::EndTabBar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user