-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Created vehicle tuning GUI using new .addonpart mod type #3096
Created vehicle tuning GUI using new .addonpart mod type #3096
Conversation
Nice! Hopefully we'll be able to make temporary edits and apply them to the vehicle. Would be fun to mess with, say, engine tunes in real time. |
@CuriousMike56 💌 I'd like that too, here's facts:
|
This is why I started this branch in the first place... While working on the script editor, I prototyped a |
f4464f3
to
48e5551
Compare
Some interesting thoughts from Discord (UPDATE: added "-->" closures):
|
After Discord debate, I steered this PR towards a vehicle configuration/tuning system. STATUS: ALPHA! Glitchy, only adding a part works, the remove-button is dummy. This adds a new mod type "addonpart" (file pattern *.addonpart) which works as a partial truck file - when selected, it adds additional elements to it. Currently supported features are: managedmaterials, props, flexbodies. The point is to automate what users had to do manually before: https://docs.rigsofrods.org/tools-tutorials/addons/ The addon parts receive all usual treatment from modcache: they can have preview images, name + description are always displayed, they can be searched for, the MainSelectorUI can be opened in mode 'LT_AddonPart' to show only addon parts. In addition, the search can be filtered by a vehicle GUID, much like with SkinZips. This is an example addonpart (port of https://forum.rigsofrods.org/resources/heavy-bumper-for-the-chevy-k3500.461/):
There's a new menu in TopMenubarUI: "Tuning". It lists already installed addonparts and contains [add parts] button which opens MainSelectorUI in 'LT_AddonPart' mode, with GUID filtering for the current vehicle. To remember what addonparts user selected, an additional mod type was added: "tuneup" (file pattern *.tuneup) - this works like ".skin for addonparts" and has intentionally similar syntax. There are 2 power tools:
Note: An option to replace prop was intentionally not implemented because that would be a duplicate feature with addonparts. It's up to user to remove props if and only if they don't want them together with new parts. When user uses addonpart with a vehicle for the first time, the game creates a .tuneup file for it in {Documents\My Games\Rigs of Rods\projects}. When spawning the vehicle next time, the .tuneup is loaded automatically. In the future the menu will be able to save custom tuneups. Here's an example:
Under the hood, applying the addonparts to the vehicle works entirely in system memory, no truck files are modified or written.
|
By popular demand, I added 'tweaks' in the addonpart system. These directives let you modify existing elements. There are 2 new directives in the addonpart format:
See bottom posts for updated downloads. |
d7f313a
to
c622acc
Compare
I fixed the last big glitch and renamed the PR to advertise the new main feature. Originally the goal was an example truck editing script, which is present, but the main focus became an addon part system with UI, which doesn't use scripting. new features so far
scripting extensions so far:
|
In addition to the above, I've realized it is technically possible to create wheel addons that can be applied to almost any vehicle. Only real problem is the wheel side flag, as the direction the wheel mesh faces depends on the vehicle. Would be awesome if the wheel direction could be changed on-the-fly through the tuning menu. |
The design agreed on Discord https://discord.com/channels/136544456244461568/189904947649708032/1174499523901534218
Ditto: https://discord.com/channels/136544456244461568/189904947649708032/1174464748461506634
|
Tuneup format + UI changeAll vehicle elements in the Tuning menu now show with numbers. They represent the order of definition in the truckfile, starting with 0. The removed_/protected_ arrays in the .tuneup file now use these numbers (instead of mesh names), to cover cases where the same mesh is used multiple times. New .addonpart features:
This is an example flexbody tweak. Note that presently you must fill in all the parameters. In the future I'll add a
For updated downloads, see bottom posts. |
5de8d7a
to
c221bf8
Compare
Reported by CuriousMike: "load map, spawn any vehicle, go back to main menu, click settings -> general -> update cache". Fixed by introducing a rule "we just always load subdirs as 'writable', even during modcache update."
an older bug that Mike reported and I didn't note down: "if the last character in .addonpart file isn't a whitespace (space, tab or linebreak), the last token is skipped. For example, if last line is `addonpart_tweak_wheel 3 "myfacemat" "" n 0.2`, the custom facemat applies but the radius '0.2' doesn't."
I fixed the 'addonpart_tweak_wheel tire radius won't apply if rim radius value is missing' bug
5fa2575
to
b4e6299
Compare
Wrapping upAlmost all bugs are fixed, only minor glitches may be left. Below is a draft documentation. The .addonpart mod typeThere's a new mod type "Addon part" (file extension .addonpart) which automates the process of customizing a vehicle, previously requiring to manually edit files as you can read in https://docs.rigsofrods.org/tools-tutorials/addons/. The addonpart file format is similar to truck file format with added Organizational info
Note: Preview images for selector UI (aka mini-images) are also supported. Tweaking existing elements'Tweaking' is the process of modifying existing elements. You use a directive Parameters in The 'media' can be meshes/materials (more types may come) depending on what the targeted element accepts.
Internally, the edits are applied in memory at last moment during spawn, files in mod cache are not affected. Adding new elementsJust use the same syntax as in truck file, anywhere in the .addonpart file. Currently supported elements are Note that
Supressing existing elementsThese accept a single parameter - the target element's position in the truck file, numbered from 0.
The .tuneup mod typeThis one is intentionally similar to .skin; it has the same structure and serves very similar purpose - applying addonparts and other user changes to a vehicle on spawn. The internal processing is also very similar. The game creates and edits these files automatically as the player uses the Tuning menu. Files are saved to UPDATE: Only the user-saved tuneups are now stored to modcache (category ID 8001), the working tuneup instances are just in memory and individual to every spawned actor. The tuning menuThere's a new menu "Tuning" in the top menubar UI, which allows user to pick addonparts. Following paragraphs are a description of the UI, in top down order: "Enable tuning" checkboxToggles cvar List of saved tuneupsSaved tuneups for current vehicle. Only created or modified on user request. When saving, the 'auto' (working) tuneup gets copied to the save; when loading, the 'auto' (working) tuneup gets overwritten by the save. Each line has [Delete] button in purplish color, indicating it's a "hold to confirm" type button. The Save/Reset buttons[Save] button shows a save box with text field to enter name. [Delete] button has purplish color, indicating it's a "hold to confirm" type button. List of installed addonpartsEach comes with a [Reload] button to reload the file from disk if you're modding it. User overrides: props/flexbodies/wheelsNumber: All vehicle elements in the Tuning menu now show with numbers. They represent the order of definition in the truckfile, starting with 0. The removed_/protected_ arrays in the .tuneup file use these numbers (instead of mesh names), to cover cases where the same mesh is used multiple times. Override checkbox: All the UI overrides (removed flexbodies/flipped wheel rims) are separate from any addonpart changes (tweaks or The 'protected' checkbox: (on the right) - Just blocks addonpart changes, doesn't affect the UI overrides in any way. Translates to In the .tuneup file, the UI overrides are called "force_something", while parts removed via addonparts are called 'unwanted_something'. Updated addonparts to testMostly by @CuriousMike56 |
Problem: if addonpart defines new prop or flexbody, the meshes are still searched in the mod's resource group. This is because the new elements are added as extra 'section' (Module) to the RigDef::Document so they're treated as any other. Solution: add a `_mesh_rg_override` string field to RigDef::Prop/Flexbody (in RigDef_File.h) and make ActorSpawner respect it.
`Parser::ProcessForsetLine()` puts the node ranges to `node_list_to_import`. Normally `SequentialImporter::ResolveFlexbodyForset()` handles the resolution but that only works when parsing the actual truckfile, not when programmatically injecting further elements.
1a2107e
to
80973b8
Compare
This required an internal overhaul as the 'working tuneup' is no longer a CacheEntry (common to all instances of the given mod), but an individual TuneupDef instance (specific to each spawned actor). SIGNIFFICANT CODE CHANGES: * Actor.h - Replaced `CacheEntryPtr m_used_tuneup_entry;` with `TuneupDefPtr m_working_tuneup_def;` * TuneupFileFormat: added `isFooTweaked()` helpers (where Foo is Prop/Wheel etc...) used by all specific `getTweaked*()` helpers. * Savegame.cpp - Added a "tuneup_document" field to actor entries, carrying the entire .tuneup file content. * CacheSystem: only user-saved tuneups are now placed to modcache, the working tuneups are just in memory.
6e12d7c
to
cf9ff5b
Compare
Problem1 = .tuneup with empty name-line breaks parsing. Fixed in Actor.cpp Problem2 = the addonpart bundles didn't get always loaded. Fixed in ActorSpawner.cpp
Added tracking of active button ID - that way multiple buttons on same window don't interfere by resetting it's timer.
When disabled, the Tuning menu in TopMenubar UI doesn't appear at all and any attempt to use a tuneup (via scripting or in savegame) will be ignored.
✅ ✅ |
Caused by a copypaste derp.
Problem: Initially the TuneupDef object was always present, but in recent commits it's just created when actually applying some tuning. The saving logic was not updated, though, so saving early caused crash. Fix: The UI was updated to only show the [SaveAs...] button when the TuneupDef already exists. UI improvement: the [Reset] button now removes the TuneupDef object instead of just resetting it, so the UI returns to initial state, clearly indicating there are no changes to be saved anymore.
UPDATE 01/2024: For most up-to-date info, please see the Wrapping Up post below.
The master branch has almost everything you need to create a truck editor script. Almost. This PR will fill the blanks. EDIT: After Discord debate, I steered this PR towards a vehicle configuration/tuning system.
So far I've done the most important bit: I've made
GenericDocument
editable, as originally promised. TheGenericDocReaderClass
was renamed toGenericDocContextClass
and there are new functions:To showcase it, I created an example script - you can run it by opening ingame console and typing
loadscript example_GenericDoc_editor.as
. It doesn't edit yet, just lets you select tokens with mouse and prints details. Green text is hovered, red text has focus.