RiddleTime / Race-Element

Solutions for Sim Racing
https://race.elementfuture.com
GNU General Public License v3.0
77 stars 17 forks source link

Add LFM license and next race info #152

Closed iFuSiiOnzZ closed 5 months ago

iFuSiiOnzZ commented 6 months ago

Add information about the LFM license, next race and countdown to the next race.

Output example:

Andrei Jianu    IRON+ (B1) (7.76)    ELO 1087    Assetto Corsa Competizione (PC)    <- License and game info        |
         Coach Dave GT3 Sprint Series | #102118 | Split 1 | SOF 1087 | Drivers 1    <- Next race info              | -> Only visible when sign up for race
                                                                     00:05:25:11    <- Count down until next race   | -> Only visible when sign up for race

Configuration:

iFuSiiOnzZ commented 6 months ago

@RiddleTime As a side note: My C# knowledge is basic, from what I have understood 32-bit integers are atomic, but I think strings are not, can you confirm this? Probably _lfmLicense should be protected by mutex.

RiddleTime commented 6 months ago

@RiddleTime As a side note: My C# knowledge is basic, from what I have understood 32-bit integers are atomic, but I think strings are not, can you confirm this? Probably _lfmLicense should be protected by mutex.

The String is a reference type in c# and integers for example are value types(depending on 32/64 bit) so the string should not be atomic. You can use a lock on some kind of lock object if you like to.

Though I would prefer a different solution, which would be to make Record classes or structs from the LFM License object as well as the next race one instead of using a string. https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/record#immutability

Take a look at the Sector Data overlay, it uses a record to store periodically collected information. https://github.com/RiddleTime/Race-Element/blob/dev/Race_Element.HUD.ACC/Overlays/Driving/SectorData/SectorDataJob.cs I start the data job and subscribe to it's event handler in the BeforeStart override: https://github.com/RiddleTime/Race-Element/blob/6e05bbb993851861637a52ac42e4f3229709ab9f/Race_Element.HUD.ACC/Overlays/Driving/SectorData/SectorDataOverlay.cs#L127C1-L129C24 Don't forget to stop it in BeforeStop.

If you need any help, or if you've got ideas don't feel free to ask, I am willing to do some refactors 😄

You're also welcome to join the discord if you like discuss a bit more.

soonic6 commented 5 months ago

maybe it is much easyer adding those drvier cards:

Big Card https://api.lowfuelmotorsport.de/lfmlicense/81594

Small Card https://api.lowfuelmotorsport.de/lfmlicense/81594?size=sm

Is it also possible counting track cuts or incidents which results in a car damage? This could be helpfull? In LFM you got 1 point for cutting the track and 4 points for Damage (per Contact with a 5seconds deadtime)

iFuSiiOnzZ commented 5 months ago

@soonic6 It's not that easy to add that, those are HTMLs (not images). You would have to render everything from scratch (not that it's not possible, but it's a lot of work because of all the logic behind it, besides, I don't know if the result will be the same).

PS: on the cuts, incidents, etc. no idea, the API doesn't report that. Don't know if they have another API for that. Which makes these a bit test and fail because don't have documentation for it.

PS2: I tried to render the HTML and it was an epic fail, the stile was totally broken.

soonic6 commented 5 months ago

It's not that easy to add that,...

okay, was just an idea. if someone want to use those images, maybe for streaming, it is very easy to add this with OBS or other streaming software.

iFuSiiOnzZ commented 5 months ago

Because they have some kind of built-in browser, or this software is based on electron (web application).

@RiddleTime I accept style suggestion! :)

RiddleTime commented 5 months ago

Because they have some kind of built-in browser, or this software is based on electron (web application).

@RiddleTime I accept style suggestion! :)

I will add some slight refactors and add some 2d styling but for now I'll merge it as the 1.0.4.0 release will include a few other things as well.

Also I am curious which language were you using before?

RiddleTime commented 5 months ago

Just a note, I reverted the AbstractLoopJob change. The abstract class is written so it tries to use the least amount of cpu so it can also be used for loop mechanisms that are high frequency.

There is an IJob interface that I use in general, which can be implemented in a maybe more sophisticated job that allows for greater control.

RiddleTime commented 5 months ago

So @iFuSiiOnzZ I've done some small changes as a refactor, nothing big. But thanks for the refactor, if you want to discuss maybe more about the app, there is a discord: https://discord.gg/26AAEW5mUq

The changes: https://github.com/RiddleTime/Race-Element/compare/fec491567933...dev