DROPDOWN as INPUT?

Posts: 9
Hey Guys,
first a big thanks for your fantastic overlay app and the help in the last times.
Now I have a question is it possible to us a DROPDOWN as an INPUT for dynamic backgrounds?

In example:
I have a dropdown with some race events and for each event I have a logo.
Now I will choose my race event in the dropdown on the control page and then the right logo is visible in the overlay.

I hope you understand my question...

BR Alex ;)
Posts: 49
It would not be classified as dynamic.

Yes you can have dropdown buttons tied to specific images.
A dropdown is basically a button just several in the space of 1.
Posts: 9
ah ok...

is there a way to do this with a script?
Read the text from the dropdown?
Posts: 785
I don't see why you need a script. You can associate Actions with each item in the dropdown. When you change the selected item, those actions will be executed. So just put an Action for each item to change the widget to the correct one.

If you do want to use a script you can get the SelectedItem and its Text property. But I don't think there is a way to react to the dropdown selected item changing. Except by putting the Action to execute your script under every item but that kind of defeats the point.
Posts: 1
Hello,
Sorry but i up this topic.
I want take a dropdowns to choice iracing series for associate this choice to a dynamic background (so the dropdowns muist be in input), but i don't koiwn if i can do something like that.
Thanks for your help.
Posts: 14
Sorry for hijacking but I am trying to do the same.

I want to use the theme in different series and want to be able to configure the series logo on the fly rather than build a new version of the theme just to add a new image to the dropdown menu. This would make the theme more flexible in my opinion. The image in this case is not part of the theme file but is outside of it in any directory accessable. I know that for some cases like spreadsheets it is possible to use an external reference for the file which has higher priority than the in theme included file, this would do the job too.

I have seen in other themes that this and other things like event name, caster, social media etc. can be configured in theme settings. Even external data (spreadsheets can be loaded on the fly). Is this something that is possible with using the editor or was it build programmatically?

By the way in the past there was an .NET (some C# or so) project for programming a theme instead of using the editor, is this not supported anymore or did I just not found it?
Posts: 785
It is no longer possible to create C# themes yourself. We can create these custom themes but it is reserved for professional customers. If you are interested to have one made you can contact us by mail.



It sounds like you want to build a dropdown that dynamically loads a list of images from some known location, and allows you to change the displayed image based on what you select in the dropdown.

This can be achieved with a bit of scripting. I should note up front that this will only work while you have an active iRacing connection established, otherwise the data updater will not run and scripts / event triggers will not fire.

First, create the items you need:
  • A Script 'LoadImages.cs' which will load the images on theme load.
  • A Script 'ConvertImage.cs' which will take the selected dropdown item and convert it to an image path.
  • A Dropdown 'Dropdown1' for the list of images. Leave it empty.
  • A Widget 'Widget1' which will display the image.
    • Under Background - Dynamic Background, select the ConvertImage.cs as the Converter Script, and select any data binding (it does not matter which one, we just need one otherwise the converter script will not trigger).
  • An EventTrigger to run the LoadImages script once on theme load. Select ThemeLoaded as the event type, and put a Script - Execute action to execute the LoadImages script.

The scripts are hopefully mostly self-explanatory.

LoadImages will look for all PNG files in a specific folder. For each file, it will add a new item to Dropdown1 and use the filename as the text.
using System;
using System.IO;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;

namespace Scripts
{
public class LoadImages : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
// Find the dropdown
var dropdown = (Dropdown) item.Theme.Dropdowns.Find("Dropdown1");

// Find all png files
var path = @"C:\Your\Path\To\Your\Images";
foreach (var file in Directory.GetFiles(path,"*.png"))
{
Console.WriteLine(file);

// Add a new dropdown item for each file
var ddItem = new DropdownItem(dropdown);
ddItem.Text = Path.GetFileName(file);
dropdown.Items.Add(ddItem);
}

return null;
}
}
}


ConvertImage will trigger on each data update. We'll ignore the data binding value but instead get the text of the selected dropdown item, which was the filename of the image you want to show. We add that name to the folder path to create the full filepath, and return that as the path of the Dynamic Image background.
using System;
using System.IO;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;

namespace Scripts
{
public class ConvertImage : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
var path = @"C:\Your\Path\To\Your\Images";

// Find the dropdown
var dropdown = item.Theme.Dropdowns.Find("Dropdown1");

// Find the selected item
if (dropdown.SelectedItem != null)
{
// Return the full path of the selected image
var fileName = dropdown.SelectedItem.Text;
var filePath = Path.Combine(path, fileName);

Console.WriteLine(filePath);

return filePath;
}
return null;
}
}
}


This seems to work fine in my quick test. It should be cleaned up a bit, for example the ConvertImage script runs every data update (30 times per second) but should really check if the selected item has actually changed, and not do anything if it hasn't. It's a small optimization but it may add up in large themes.
Edited (2 times)
Posts: 14
Thank you for this detailed description!

On today I didnt made it to show a picture. (was connected to iracing live session) I have seen that the loadimages script in the script performance monitor is running and not stopping. Had only 2 images in the directory but the dropdown gave me around 20 or so to choose. Will try it again another day.