Report post

Are you sure you want to report the post shown below? This will send an email to the ATVO administrators. Please include a short reason for reporting.

Users reporting for no reason may be locked out.


Post

Posted by Nick Thissen
on
The code that handles these "timing modes" looks long and complicated but once you understand it it's not too bad. Basically it boils down to:
  • The script handles both the data conversion (taking input result and outputting the desired data string) and changing the current timing mode
  • If the script is used as data conversion, then it runs the path that goes into "ConvertToGapString". Here it simply checks which mode is currently selected, and converts the input to the desired text. For most things like pitstops and laptimes that conversion is trivial. For gaps and intervals you can see how I use our own internal "gap binding converters" to do the conversion for me; you can mostly copy those.
  • If the script is used to set the current mode, then it reads the text/name of the selected item of the dropdown and uses that to determine which mode is being requested. The text should match one of the possible timing modes that are defined near the top under "TimingDisplayModes". It converts the input text to the corresponding timing mode and stores that in the TimingDisplayProvider.CurrentModeH or TimingDisplayProvider.CurrentModeV property so the conversion script can check which is the current mode.

Beyond that it is mostly about keeping track which ticker is being updated - the same script supports changing H and V ticker both to avoid duplicating code for each ticker. There is also some kind to chang the "title" or header on top of the ticker to reflect what it is currently showing.

Finally, the dropdown used to switch the mode simply executes the script whenever the selected item changes. It passes either "H" or "V" as the value to indicate which ticker you're changing. The name / text of the items, again, must correspond to the possible TimingDisplayModes.


All in all it is not trivial, but I added this to show what kind of complicated logic you can achieve with some more advanced scripting.