 |
RigsofRods
2023.09
Soft-body Physics Simulation
|
Go to the documentation of this file.
54 bool show_translucent =
false;
59 fmt::format(
_LC(
"VehicleButtons",
"Hover the mouse on the left to see controls")),
"lightbulb.png");
64 show_translucent =
true;
71 && (ImGui::GetIO().MousePos.x <=
MIN_PANEL_WIDTH + ImGui::GetStyle().WindowPadding.x*2))
73 show_translucent =
true;
123 ImGui::Begin(
"VehicleInfoTPanel",
nullptr, flags);
148 ImVec2 name_pos = ImGui::GetCursorPos();
152 Ogre::TexturePtr preview_tex = Ogre::TextureManager::getSingleton().load(
156 ImVec2 size(preview_tex->getWidth(), preview_tex->getHeight());
163 ImGui::Image(
reinterpret_cast<ImTextureID
>(preview_tex->getHandle()), size);
164 tabs_pos = ImGui::GetCursorPos();
166 name_pos.x += size.x + ImGui::GetStyle().ItemSpacing.x;
167 ImGui::SetCursorPos(name_pos);
176 ImGui::SetCursorPos(tabs_pos);
211 ImGui::PopStyleColor(2);
222 ImGui::TextDisabled(
"%s",
_LC(
"VehicleDescription",
"Description text:"));
225 ImGui::TextWrapped(
"%s", line.c_str());
233 ImGui::TextDisabled(
"%s",
_LC(
"VehicleDescription",
"Help image:"));
252 ImTextureID im_tex =
reinterpret_cast<ImTextureID
>(actorx->
GetHelpTex()->getHandle());
264 ImGui::TextDisabled(
"%s",
_LC(
"VehicleDescription",
"Command controls:"));
266 ImGui::Text(
"%s",
_LC(
"VehicleDescription",
"Hover controls for on-vehicle highlight"));
267 ImGui::PopStyleColor(1);
272 ImVec2 initial_cursor = ImGui::GetCursorScreenPos();
275 std::string desc = qpair.uckp_description;
276 if (qpair.uckp_description ==
"")
278 desc =
_LC(
"VehicleDescription",
"~unlabeled~");
283 const bool single_line = ImGui::GetWindowContentRegionMax().x > desc_size.x + key1_size.x + key2_size.x;
284 static const float BUMP_HEIGHT = 3.f;
285 static const float MOUSEHIGHLIGHT_MAGICPADRIGHT = 4.f;
288 ImVec2 highlight_mouse_min = initial_cursor - ImGui::GetStyle().ItemSpacing/2;
289 ImVec2 highlight_mouse_max = highlight_mouse_min + ImVec2(ImGui::GetWindowContentRegionWidth()+MOUSEHIGHLIGHT_MAGICPADRIGHT, ImGui::GetTextLineHeightWithSpacing());
292 highlight_mouse_max.y += ImGui::GetTextLineHeightWithSpacing() - BUMP_HEIGHT;
304 ImDrawList* draw_list = ImGui::GetWindowDrawList();
305 draw_list->AddRectFilled(highlight_mouse_min, highlight_mouse_max, ImColor(col));
313 ImGui::Text(
"%s", desc.c_str());
323 ImGui::SetCursorPos(ImGui::GetCursorPos() + ImVec2(0.f, -BUMP_HEIGHT));
327 bool key1_hovered =
false;
328 bool key1_active =
false;
329 ImGui::SetCursorPosX((ImGui::GetWindowContentRegionMax().
x) - key1_size.x - key2_size.x - ImGui::GetStyle().ItemSpacing.x);
342 ImGui::SetCursorPosX((ImGui::GetWindowContentRegionMax().
x) - key2_size.x);
343 bool key2_hovered =
false;
344 bool key2_active =
false;
366 if (label_size.x + value_size.x + ImGui::GetStyle().ItemSpacing.x < ImGui::GetWindowContentRegionWidth())
370 ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().
x - value_size.x);
371 ImGui::TextColored(value_color,
"%s", value.c_str());
384 ImGui::PopStyleColor();
413 const float avg_deform =
static_cast<float>(
Round((
float)
m_stat_avg_deform / (
float)num_beams, 4) * 100.0f );
442 const double PI = 3.14159265358979323846;
458 const float currentKw = (((cur_rpm * (torque + ((turbo_psi * 6.8) * torque) / 100) * ( PI / 30)) / 1000));
472 float velocityKPH = wheel_speed * 3.6f;
473 float velocityMPH = wheel_speed * 2.23693629f;
474 float carSpeedKPH = n0_velo_len * 3.6f;
475 float carSpeedMPH = n0_velo_len * 2.23693629f;
478 if (fabs(wheel_speed) < 1.0f)
480 velocityKPH = velocityMPH = 0.0f;
482 if (fabs(n0_velo_len) < 1.0f)
484 carSpeedKPH = carSpeedMPH = 0.0f;
502 float speedKN = n0_velo_len * 1.94384449f;
526 std::string label =
fmt::format(
"{} #{}:",
_LC(
"SimActorStats",
"Engine "), engine_num);
543 std::string label =
fmt::format(
"{} #{}:",
_LC(
"SimActorStats",
"Engine "), engine_num);
570 ImGui::PopStyleVar();
575 ImGui::TextDisabled(
"%s",
_LC(
"TopMenubar",
"Live diagnostic views:"));
579 int debug_view_type =
static_cast<int>(actorx->
GetDebugView());
606 if ((current_actor !=
nullptr) && (debug_view_type !=
static_cast<int>(current_actor->
GetGfxActor()->
GetDebugView())))
614 ImGui::TextDisabled(
"%s",
_LC(
"TopMenubar",
"Settings:"));
619 if (debug_view_type >= 2)
637 float average_deformation = 0.0f;
638 float beamstress = 0.0f;
641 int beamdeformed = 0;
651 beamstress += std::abs(beam->
stress);
652 float current_deformation = fabs(beam->
L - beam->
refL);
657 average_deformation += current_deformation;
681 ImGui::Dummy(
BUTTONDUMMY_SIZE); ImGui::SameLine(); ImGui::Bullet(); ImGui::Text(
"%s", name);
684 ImGui::SetCursorPosX(ImGui::GetWindowContentRegionWidth() - btn_size.x);
697 ImGui::TextDisabled(
"Simulation:");
707 if (num_headlights || num_taillights || num_blinkleft || num_blinkright || num_beacons || has_horn)
709 ImGui::TextDisabled(
"Lights and signals:");
710 if (num_headlights || num_taillights)
722 if (num_blinkright || num_blinkleft)
736 int total_customlights = 0;
741 if (total_customlights > 0)
754 ImGui::TextDisabled(
"Engine:");
760 if (has_transfercase && has_4wd && has_2wd)
764 if (has_transfercase && num_tc_gears > 1)
801 if (num_axlediffs || num_wheeldiffs || tc_visible || alb_visible || has_parkingbrake || has_engine)
803 ImGui::TextDisabled(
"Traction:");
820 if (has_parkingbrake)
832 if (num_locks || num_ties)
834 ImGui::TextDisabled(
"Connections:");
845 const size_t num_cparticles = actorx->
getCParticles().size();
847 ImGui::TextDisabled(
"View:");
871 ImVec2 p1_pos, p2_pos;
890 ImGui::Begin(
"T-Panel help tex fullsize", NULL, window_flags);
891 ImDrawList* drawlist = ImGui::GetWindowDrawList();
892 ImTextureID im_tex =
reinterpret_cast<ImTextureID
>(actorx->
GetHelpTex()->getHandle());
896 ImGui::PopStyleColor(1);
910 ImGui::GetWindowDrawList()->AddRectFilled(
912 ImColor(ImGui::GetStyle().Colors[
ImGuiCol_Button]), ImGui::GetStyle().FrameRounding);
913 ImGui::GetWindowDrawList()->AddImage(
reinterpret_cast<ImTextureID
>(icon->getHandle()),
915 ImGui::SetCursorPosX(ImGui::GetCursorPosX() +
BUTTON_SIZE.x + 2*ImGui::GetStyle().ItemSpacing.x);
916 ImGui::PopStyleColor();
918 ImGui::Text(
"%s", name);
921 ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().
x - btn_size.x);
1093 const char* msg =
nullptr;
1128 int num_custom_flares = 0;
1135 num_custom_flares++;
1137 if (i == 5 || i == 9)
1142 std::string label =
"L" + std::to_string(i + 1);
1153 if (ImGui::Button(label.c_str(), ImVec2(32, 0)))
1165 ImGui::PopStyleColor();
1169 if (num_custom_flares > 0)
1231 ImGui::GetWindowDrawList()->AddImage(
reinterpret_cast<ImTextureID
>(
m_beacons_icon->getHandle()),
1233 ImGui::SetCursorPosX(ImGui::GetCursorPosX() +
BUTTON_SIZE.x + 2 * ImGui::GetStyle().ItemSpacing.x);
1235 ImGui::Text(
"Custom lights");
1237 const char* hotkey =
"CTRL+[1...]";
1239 ImGui::SetCursorPosX((ImGui::GetWindowContentRegionMax().
x) - keysize.x - ImGui::GetStyle().ItemSpacing.x);
1240 ImGui::Text(hotkey);
1242 const ImVec2 BTN_PADDING = ImVec2(1, 1);
1251 std::string label = std::to_string(i + 1);
1262 if (ImGui::Button(label.c_str(), btn_size))
1272 ImGui::PopStyleColor();
1277 ImGui::PopStyleVar();
int getAxleDiffMode()
Writes info to console/notify box.
Game state manager and message-queue provider.
Ogre::TexturePtr m_m_icon
void toggleContact()
Ignition.
int tr_ax_2
This axle is only driven in 4WD mode.
void DrawEngineButton(RoR::GfxActor *actorx)
int m_stat_deformed_beams
void SetDebugView(DebugViewType dv)
void DrawRepairButton(RoR::GfxActor *actorx)
bool cc_mode
Cruise Control.
void DrawLockButton(RoR::GfxActor *actorx)
int getWheelDiffMode()
Writes info to console/notify box.
enum Script2Game::ImGuiStyleVar ImGuiWindowFlags_AlwaysAutoResize
Resize every window to its content every frame.
enum Script2Game::ImGuiStyleVar ImGuiCol_TextDisabled
CVar * gfx_speedo_imperial
enum Script2Game::ImGuiStyleVar ImGuiWindowFlags_NoScrollbar
Disable scrollbars (window can still scroll with mouse or programmatically)
bool getBeaconMode() const
void ImTextWrappedColorMarked(std::string const &text)
Prints multiline text with '#rrggbb' color markers. Behaves like ImGui::Text* functions.
Ogre::TexturePtr m_a_icon
ImVec2 ImCalcEventHighlightedSize(events input_event)
void DrawBeaconButton(RoR::GfxActor *actorx)
ImVec4 value_red_text_color
@ MSG_SIM_MODIFY_ACTOR_REQUESTED
Payload = RoR::ActorModifyRequest* (owner)
void DrawStatsLineColored(const char *name, const std::string &value, ImVec4 value_color)
Ogre::TexturePtr FetchIcon(const char *name)
Ogre::TexturePtr m_physics_icon
bool ar_physics_paused
Actor physics individually paused by user.
bool isLocked()
Are hooks locked?
@ TRUCK
its a truck (or other land vehicle)
void DrawWarnBlinkerButton(RoR::GfxActor *actorx)
void toggleAxleDiffMode()
static const int MAX_CLIGHTS
See RoRnet::Lightmask and enum events in InputEngine.h.
TPanelMode m_visibility_mode
CameraManager * GetCameraManager()
Ogre::Vector3 AbsPosition
absolute position in the world (shaky)
GUIManager * GetGuiManager()
CVar * diag_hide_broken_beams
ImVec4 value_blue_text_color
Estabilishing a physics linkage between 2 actors modifies a global linkage table and triggers immedia...
NodeSB * GetSimNodeBuffer()
@ ImGuiTabItemFlags_SetSelected
Trigger flag to programmatically make the tab selected when calling BeginTabItem()
bool getCustomParticleMode()
ActorInstanceID_t ar_instance_id
Static attr; session-unique ID.
bool GetScreenPosFromWorldPos(Ogre::Vector3 const &world_pos, ImVec2 &out_screen)
enum Script2Game::ImGuiStyleVar ImGuiCol_ButtonActive
enum Script2Game::ImGuiStyleVar ImGuiWindowFlags_NoCollapse
Disable user collapsing window by double-clicking on it.
const float MIN_PANEL_WIDTH
std::vector< UniqueCommandKeyPair > ar_unique_commandkey_pairs
UI helper for displaying command control keys to user (must be built at spawn).
Ogre::TexturePtr m_particle_icon
void DrawAntiLockBrakeButton(RoR::GfxActor *actorx)
const ImVec2 BUTTONDUMMY_SIZE(18, 1)
void toggleWheelDiffMode()
Truck file format(technical spec)
std::vector< ScrewpropSB > simbuf_screwprops
Ogre::TexturePtr m_w_icon
bool tr_2wd
Does it support 2WD mode?
int getWheelNodeCount() const
Ogre::TexturePtr m_warning_light_icon
int countBeaconProps() const
SimGearboxMode getAutoMode()
void DrawActorPhysicsButton(RoR::GfxActor *actorx)
void DrawSecureButton(RoR::GfxActor *actorx)
enum Script2Game::ImGuiStyleVar ImGuiWindowFlags_NoSavedSettings
Never load/save settings in .ini file.
std::vector< VideoCamera > & getVideoCameras()
void UpdateStats(float dt, ActorPtr actor)
Caution: touches live data, must be synced with sim. thread.
CVar * ui_always_show_fullsize
ActorLinkingRequestType alr_type
enum Script2Game::ImGuiStyleVar ImGuiCol_Text
Enumeration for AngelImGui::PushStyleColor() / AngelImGui::PopStyleColor()
bool BeginTabBar(const string &in, int=0)
Ogre::Vector3 simbuf_node0_velo
Ogre::Real Round(Ogre::Real value, unsigned short ndigits=0)
bool IsItemHovered(int=0)
void RequestUpdateHudFeatures()
std::vector< std::string > getDescription()
void toggleCustomParticles()
void DrawMirrorButton(RoR::GfxActor *actorx)
void putMessage(MessageArea area, MessageType type, std::string const &msg, std::string icon="")
std::vector< hook_t > ar_hooks
std::vector< AeroEngineSB > simbuf_aeroengines
Ogre::TexturePtr m_beacons_icon
vector2 CalcTextSize(const string &in, bool hide_text_after_double_hash=false, float wrap_width=-1.0f)
std::vector< tie_t > ar_ties
Ogre::TexturePtr m_abs_icon
void DrawHornButton(RoR::GfxActor *actorx)
CommandkeyID_t m_active_commandkey
std::vector< float > tr_gear_ratios
Gear reduction ratios.
void DrawRightBlinkerButton(RoR::GfxActor *actorx)
CVar * diag_hide_beam_stress
TPanelFocus m_requested_focus
Requested by SetVisible()
@ NOT_DRIVEABLE
not drivable at all
void displayAxleDiffMode()
Cycles through the available inter axle diff modes.
ImVec4 semitransparent_window_bg
void tractioncontrolToggle()
ImVec4 m_command_hovered_text_color
void DrawVehicleCommandsUI(RoR::GfxActor *actorx)
void DrawStatsLine(const char *name, const std::string &value)
void SetVideoCamState(VideoCamState state)
void DrawTransferCaseModeButton(RoR::GfxActor *actorx)
CVar * diag_hide_wheel_info
bool tc_nodash
Hide the dashboard indicator?
float refL
reference length
void DrawWheelDiffButton(RoR::GfxActor *actorx)
void DrawStatsBullet(const char *name, const std::string &value)
std::vector< CParticle > & getCParticles()
Ogre::Vector3 getMaxGForces()
ImDrawList * GetImDummyFullscreenWindow(const std::string &name="RoR_TransparentFullscreenWindow")
ActorInstanceID_t amr_actor
@ MANUAL_STICK
Fully manual: stick shift.
Ogre::TexturePtr m_headlight_icon
VideoCamState GetVideoCamState() const
Simulation: An edge in the softbody structure.
Ogre::TexturePtr m_left_blinker_icon
Ogre::TexturePtr m_horn_icon
Ogre::TexturePtr m_actor_physics_icon
ImVec4 m_cmdbeam_highlight_color
Core data structures for simulation; Everything affected by by either physics, network or user intera...
Ogre::String filecachename
preview image filename
void PushID(const string &in)
Ogre::TexturePtr GetHelpTex()
TransferCase * getTransferCaseMode()
Toggles between 2WD and 4WD mode.
float m_cmdbeam_highlight_thickness
bool BeginTabItem(const string &in, int=0)
BeginTabItem() without X close button.
void PushMessage(Message m)
Doesn't guarantee order! Use ChainMessage() if order matters.
void DrawSingleBulletRow(const char *name, RoR::events ev)
enum Script2Game::ImGuiStyleVar ImGuiWindowFlags_NoResize
Disable user resizing with the lower-right grip.
float simbuf_inputshaft_rpm
void DrawVehicleDiagUI(RoR::GfxActor *actorx)
const float HELP_TEXTURE_WIDTH
Ogre::TexturePtr m_parking_brake_icon
void DrawVehicleCommandHighlights(RoR::GfxActor *actorx)
void antilockbrakeToggle()
bool getHeadlightsVisible() const
CmdKeyArray ar_command_key
BEWARE: commandkeys are indexed 1-MAX_COMMANDS!
void DrawParticlesButton(RoR::GfxActor *actorx)
const ImVec2 BUTTON_SIZE(18, 18)
ImVec4 m_transluc_textdis_color
Central state/object manager and communications hub.
@ SEMI_AUTO
Manual shift with auto clutch.
TPanelFocus m_current_focus
Updated based on currently open tab.
const ImVec2 BUTTON_OFFSET(0, 3.f)
bool ImDrawEventHighlightedButton(events input_event, bool *btn_hovered=nullptr, bool *btn_active=nullptr)
GameContext * GetGameContext()
Ogre::TexturePtr m_engine_icon
const float HELP_TEXTURE_HEIGHT
@ AIRPLANE
its an airplane
Ogre::TexturePtr m_camera_icon
void DrawVehicleHelpTextureFullsize(RoR::GfxActor *actorx)
@ ImGuiStyleVar_FramePadding
ImVec2 FramePadding.
Ogre::TexturePtr m_cruise_control_icon
void DrawParkingBrakeButton(RoR::GfxActor *actorx)
void DrawCustomLightButton(RoR::GfxActor *actorx)
float getTotalMass(bool withLocked=true)
Ogre::TexturePtr m_shift_icon
CacheEntryPtr & getUsedActorEntry()
The actor entry itself.
void DrawTransferCaseGearRatioButton(RoR::GfxActor *actorx)
@ MANUAL
Fully manual: sequential shift.
Ogre::Vector3 AbsPosition
void toggleTransferCaseMode()
void parkingbrakeToggle()
ImVec2 screen_edge_padding
enum Script2Game::ImGuiStyleVar ImGuiWindowFlags_NoTitleBar
Disable title-bar.
bool ar_is_police
Gfx/sfx attr.
Ogre::Timer m_startupdemo_timer
bool alb_mode
Anti-lock brake state; Enabled? {1/0}.
CVar * ui_show_vehicle_buttons
UI helper for displaying command control keys to user.
float simbuf_engine_max_rpm
Ogre::TexturePtr m_g_icon
enum Script2Game::ImGuiStyleVar ImGuiCol_Button
void toggleBlinkType(BlinkType blink)
void DrawTractionControlButton(RoR::GfxActor *actorx)
@ MSG_SIM_ACTOR_LINKING_REQUESTED
Payload = RoR::ActorLinkingRequest* (owner)
Unified game event system - all requests and state changes are reported using a message.
void DrawShiftModeButton(RoR::GfxActor *actorx)
bool alb_nodash
Anti-lock brake attribute: Hide the dashboard indicator?
void DrawVehicleBasicsUI(RoR::GfxActor *actorx)
void DrawAxleDiffButton(RoR::GfxActor *actorx)
void toggleTransferCaseGearRatio()
InputEngine * GetInputEngine()
ActorInstanceID_t alr_actor_instance_id
float simbuf_engine_turbo_psi
Ogre::TexturePtr m_mirror_icon
void setCustomLightVisible(int number, bool visible)
@ ImGuiStyleVar_ItemSpacing
ImVec2 ItemSpacing.
const ImVec2 MAX_PREVIEW_SIZE(100.f, 100.f)
void Draw(RoR::GfxActor *actorx)
ImVec4 m_panel_translucent_color
@ MANUAL_RANGES
Fully manual: stick shift with ranges.
Manager for all visuals belonging to a single actor.
Ogre::TexturePtr m_lock_icon
enum Script2Game::ImGuiStyleVar ImGuiWindowFlags_NoBringToFrontOnFocus
Disable bringing window to front when taking focus (e.g. clicking on it or programmatically giving it...
int countFlaresByType(FlareType type)
Ogre::TexturePtr m_repair_icon
int countCustomLights(int control_number)
bool DrawGCheckbox(CVar *cvar, const char *label)
Ogre::TexturePtr m_secure_icon
ImVec2 m_helptext_fullsize_screenpos
The image is drawn into separate window.
DebugViewType GetDebugView() const
const float HELP_TEXTURE_HEIGHT_FULL
void ImDrawEventHighlighted(events input_event)
@ CONSOLE_MSGTYPE_INFO
Generic message.
std::string getTruckName()
void SetVisible(TPanelMode mode, TPanelFocus focus=TPANELFOCUS_NONE)
void DrawLeftBlinkerButton(RoR::GfxActor *actorx)
Ogre::Vector3 getGForces()
void displayWheelDiffMode()
Cycles through the available inter wheel diff modes.
void DrawCruiseControlButton(RoR::GfxActor *actorx)
Ogre::TexturePtr m_right_blinker_icon
#define SOUND_GET_STATE(_ACTOR_, _TRIG_)
void startEngine()
Quick engine start. Plays sounds.
void DrawVehicleStatsUI(RoR::GfxActor *actorx)
CommandkeyID_t m_hovered_commandkey
Ogre::TexturePtr m_traction_control_icon
void cruisecontrolToggle()
Defined in 'gameplay/CruiseControl.cpp'.
ActorSB & GetSimDataBuffer()
int ar_num_shocks
Number of shock absorbers.
float simbuf_engine_torque
bool DrawSingleButtonRow(bool active, const Ogre::TexturePtr &icon, const char *name, RoR::events ev, bool *btn_active=nullptr)
static const CommandkeyID_t COMMANDKEYID_INVALID
enum Script2Game::ImGuiStyleVar ImGuiCol_WindowBg
Background of normal windows.
#define SOUND_TOGGLE(_ACTOR_, _TRIG_)
void DrawHeadLightButton(RoR::GfxActor *actorx)
void switchToNextBehavior()
bool getCustomLightVisible(int number)
void displayTransferCaseMode()
Gets the current transfer case mode name (4WD Hi, ...)
const float BUTTON_Y_OFFSET
enum Script2Game::ImGuiStyleVar ImGuiWindowFlags_NoMove
Disable user moving the window.
void DrawCustomLightButtons(RoR::GfxActor *actorx)