diff --git a/dictionary/en-custom.txt b/dictionary/en-custom.txt index cf2bcbd1..f7283f51 100644 --- a/dictionary/en-custom.txt +++ b/dictionary/en-custom.txt @@ -127,11 +127,13 @@ cSpline ctrl CTRL CuriousMike +Customdashboardinputs AnotherFoxGuy da DAF dampingrate dampings +DashBoardManagerClass Davded de De diff --git a/source/vehicle-creation/fileformat-truck.md b/source/vehicle-creation/fileformat-truck.md index 92bcc3ac..a8d4d8f1 100644 --- a/source/vehicle-creation/fileformat-truck.md +++ b/source/vehicle-creation/fileformat-truck.md @@ -3125,6 +3125,9 @@ Legacy parameters (not affecting the v0.4 custom HUD system). Will be restored o - **useMaxRPM**: 0 or 1; default = 0; \[Yes/No\] Whether or not to use the max rpm (in the engine section) as the highest number on the tachometer. Note that your actual max rpm is MaxRPM+20%. Do not include the 20% on your tachometer or it will be inaccurate. Tachometer needle is from -120° to 120°. - **helpMaterial**: String; default = tracks/black; The help material (a picture that shows command instructions). NOTE: This value overrides settings from [section "help"](#help) +Since version 2026.01, each `texturedashboard` is rendered to a different RTT texture. The first `texturedashboard` is rendered to `RTTTexture1`, the second one to `RTTTexture2`, and so on. There are +10 textures available and you can preview them using the Texture Tool in _Tools > Texture tool_. + Example: ``` @@ -3132,14 +3135,39 @@ guisettings interactiveOverviewMap zoom dashboard dash_test.layout dashboard dash_test2.layout +; Will be rendered to RTTTexture1 texturedashboard dashGauges.layout +; Will be rendered to RTTTexture2 (since 2026.01) +texturedashboard advancedDash.dashboard ; legacy settings tachoMaterial tracks/MyTacho speedoMaterial tracks/MySpeedo speedoMax 80 useMaxRPM 1 ``` - + +### Customdashboardinputs + +\[ Version 2026.01+ \] + +Adds custom input sources to the vehicle's [dashboard system](making-custom-hud.md). These inputs can be modified using scripts, allowing you to implement highly-customized and complex behaviours. + +Parameters: + +- **input_name**: Custom input name. Do not use [built-in](making-custom-hud.md#input-sources) names! It's highly recommended to +use names that are unique enough to avoid conflicts, since dashboard mods can also add custom inputs! An unique name could be something like `VehicleName_CustomInput_InputName`. +- **data_type**: Input data type. Allowed types: `bool`, `int`, `float`, `string`. The correct data type for the input depends on its +purpose. For instance, you use `float` to [rotate images](making-custom-hud.md#rotate) or [animate props](#add_animation), `int` to control [series](making-custom-hud.md#series), `bool` to control [lamps](making-custom-hud.md#lamp) or [flares](#flares), and `string` to [add text](making-custom-hud.md#textstring-textformat) to your dashboard. + +Example: + +``` +customdashboardinputs +VehicleName_CustomInput_DieselGlowPlugLight bool +VehicleName_CustomInput_FuelLevel float +VehicleName_CustomInput_GaugeFaceType int +VehicleName_CustomInput_ClockString string +``` ### Set\_skeleton\_settings diff --git a/source/vehicle-creation/making-custom-hud.md b/source/vehicle-creation/making-custom-hud.md index abe5179a..fc653251 100644 --- a/source/vehicle-creation/making-custom-hud.md +++ b/source/vehicle-creation/making-custom-hud.md @@ -204,6 +204,50 @@ format=%04.0f km/h link=speedo_kph ``` +### Multiple animations + +Since version 2026.01, you can add multiple animations to a MyGUI widget by appending a number to the properties associated to each animation. These have to be numbered in +order (do not skip numbers!). Properties for the first animation are **not** numbered. + +You can set up to 11 animations (10 rotate, scale and translate operations + 1 series/textstring/textformat/lamp). + +Example for an aircraft attitude indicator, using custom inputs: + +``` +anim=translate +min=-360 +max=360 +vmin=-100 +vmax=100 +direction=left +link=AircraftName_CustomInput_AttitudeTranslateX + +anim2=translate +min2=-360 +max2=360 +vmin2=-100 +vmax2=100 +direction2=down +link2=AircraftName_CustomInput_AttitudeTranslateY + +anim3=rotate +min3=-360 +max3=360 +vmin3=-360 +vmax3=360 +direction3=down +link3=AircraftName_CustomInput_AttitudeRotate +``` + +## Widget visibility + +Each dashboard input source has an enabled/disabled property that sets the visibility of the MyGUI widgets associated to it. + +On widgets that have one or more animations, the visibility is always set by the first animation's dashboard input link. + +Widgets can also have a single dashboard input link with no animations, allowing you to set the visibility only. + + ## Input sources |
Method
| Description | Type / Values / Ranges | Active when | @@ -335,6 +379,7 @@ A dashboard mod contains: - MyGUI `*.layout` file(s) - Textures - (optional) Preview (`filename-mini`) images +- (optional) A [dashboard script](#dashboard-scripts) (`*.as` file) \[ Version 2026.01+ \] ### Dashboard file format @@ -350,6 +395,19 @@ dashboard_author "layouts" 899 "Mark" "example@example.com" dashboard_category 201 ``` +Generic example, using [custom inputs](#dashboard_custom_input): + +``` +dashboard_name "Dashboard with custom inputs" +dashboard_description "Dashboard that uses custom inputs!" +dashboard_author "everything" 22564 "Eze" "example@example.com" +dashboard_category 201 +dashboard_custom_input DashboardModName_CustomInput_DieselGlowPlugLight bool +dashboard_custom_input DashboardModName_CustomInput_FuelLevel float +dashboard_custom_input DashboardModName_CustomInput_GaugeFaceType int +dashboard_custom_input DashboardModName_CustomInput_ClockString string +``` + #### dashboard_name (String) Name of the dashboard. @@ -381,6 +439,76 @@ https://forum.rigsofrods.org/members/curiousmike.5831/ - `201` - Truck - `202` - Boat +#### dashboard_custom_input + +\[ Version 2026.01+ \] + +Specifies a custom input source that can be modified using scripts. + +Parameters: + +- **input_name**: Custom input name. Do not use [built-in](#input-sources) names! It's highly recommended to +use names that are unique enough to avoid conflicts, since vehicles can also have their own custom inputs! An unique name could be something like `DashboardModName_CustomInput_InputName`. +- **data_type**: Input data type. Allowed types: `bool`, `int`, `float`, `string`. The correct data type for the input depends on its +purpose. For instance, you use `float` to [rotate images](#rotate), `int` to control [series](#series), `bool` to control [lamps](#lamp), and `string` to [add text](#textstring-textformat) to your dashboard. + + +### Dashboard scripting with AngelScript + +Since version 2026.01, dashboard mods can execute their own script. You just create an `*.as` file, in the same folder and **with the same name** as the `*.dashboard` file. See the [docs for DashBoardManagerClass](https://developer.rigsofrods.org/d8/d07/class_script2_game_1_1_dash_board_manager_class.html) to start controlling your dashboard! + +Example script: + +```cpp +DashBoardManagerClass@ dash = null; + +// Custom values +int DashLinkID_DieselGlowPlugLight; +int DashLinkID_FuelLevel; +int DashLinkID_MainOdometer; + +bool AreGlowPlugsOn() +{ + // Logic that checks if the glow plugs are on. + return true; +} + +float GetFuelLevel() +{ + // Code that gets the fuel level from somewhere. + return 1; +} + +float GetMainOdometer() +{ + // Code that gets the main odometer value from somewhere. + return 1234.5; +} + +// Get the dash manager instance and link IDs at initialisation +void main() { + // Get the DashBoardManager of the actor associated to this script. + @dash = thisActor.getDashboardManager(); + if (@dash != null) { + DashLinkID_DieselGlowPlugLight = dash.getLinkIDForName("MyDashboardMod_CustomInput_DieselGlowPlugLight"); + DashLinkID_FuelLevel = dash.getLinkIDForName("MyDashboardMod_CustomInput_FuelLevel"); + DashLinkID_MainOdometer = dash.getLinkIDForName("MyDashboardMod_CustomInput_MainOdometer"); + } +} + +void frameStep(float dt) { + if (@dash != null) { + bool glowPlug = AreGlowPlugsOn(); + float fuelLevel = GetFuelLevel(); + float mainOdo = GetMainOdometer(); + string mainOdoFormat = "ODO: " + formatFloat(mainOdo, '0', 6, 1) + " km"; + dash.setBool(DashLinkID_DieselGlowPlugLight, glowPlug); + dash.setFloat(DashLinkID_FuelLevel, fuelLevel); + dash.setString(DashLinkID_MainOdometer, mainOdoFormat); + } +} +``` + ### Layout file names The MyGUI `*.layout` files **MUST** be named the same as the `*.dashboard` file. For example: