Need help with GUI extension.

Discussion in 'User Interface and HUD Modding' started by TheRexorcist, Jun 19, 2016.

  1. TheRexorcist

    TheRexorcist Registered

    Joined:
    Jun 19, 2016
    Messages:
    7
    Likes Received:
    1
    Hi guys,

    I have been playing rF2 for a couple of days now, so I'm not a veteran or anything, but I've been playing Gran Turismo across all systems for an eternity. For me, and you may disagree, the part of video game racing that was giving me the most joy were the Gran Turismo "Time Trials", and I think rF2 is lacking in that department. In other words: I've spent countless nights battling my friends on the various PlayStation systems (offline only) until the sun came up, and I'd like to get the same experience with rF2.

    Since I'm a software developer, I gathered some resources over the last couple of days and wrote a little plugin which would track hot lap times and store them in a SQLite database. It's all nice and dandy, but for this implementation to satisfy all my needs, I have to modify the rF2 GUI, and I'm completely lost in that aspect. I've been looking into the various .MAS files, and I can't get my head around it for the life of me.

    SO HERE'S MY QUESTION: What do I have to do in order to integrate a little list box (containing driver names, for example) in the pre-race monitor where I could select which one of my friends is actually driving? In other words: I just need to find a way to create a new gizmo/widget/whatever displaying a few strings, and then I'd like to pass the selected string to an internal structure to track which driver is actually controlling the car in each session.

    I was playing around with the .MAS files with a lot of enthusiasm, but it didn't get me anywhere. Within the .MAS files (within the UI.OSC files, actually) there are sections like RunCode="foobar", but I have no idea how I can connect these items to my plugin code. Does anybody have any pointers for me?

    Any help greatly appreciated! If anybody can point me in the right direction, I'll happily submit my code to github. To be honest, I'm kind of surprised nobody attempted to re-implement that functionality in rF2, because like I said, for me personally the time trials were the only thing that kept me interested in Gran Turismo.
     
  2. TheRexorcist

    TheRexorcist Registered

    Joined:
    Jun 19, 2016
    Messages:
    7
    Likes Received:
    1
    FOLLOW UP POST: I just came up with another idea.

    I thought about integrating a QT-based GUI over the existing rF2 GUI. So for my case it'd be sufficient if I somehow managed to call my plugin code as soon as the "Race" button is pressed in the pre-race monitor screen. Then I could simply display a QT dialog containing the available drivers and then call back into the rF2 application. I hope you understand what I'm trying to do... don't hesitate to ask if I didn't make myself clear enough.

    Anyway, either way I slice it, I need to call my plugin code from within rF2, do some processing, and then call back into the rF2 code. I'm really lost as to how this can be accomplished...
     
  3. Lazza

    Lazza Registered

    Joined:
    Oct 5, 2010
    Messages:
    12,346
    Likes Received:
    6,572
    I very much doubt you can call your own code from within the .osc file. UI modifications are really about design, but still triggering the standard event code.
     
  4. TheRexorcist

    TheRexorcist Registered

    Joined:
    Jun 19, 2016
    Messages:
    7
    Likes Received:
    1
    Thanks for your reply. I kind of was suspecting that...

    I think I found a solution for my needs though: I run rF2, and then I run a Qt application which embeds the rF2 window into a Qt widget. My rig is powerful enough to deal with the overhead, so I'm pretty sure I can get something acceptable out of it. Unfortunately it won't be a rF2 MOD, it's more of a gigantic hack, but if it gets the job done for me, I'm happy.

    If anyone cares how this can be accomplished: Just include the <windows.h> header in your Qt application, use the "FindWindow" Windows function to acquire a handle to the rF2 window, create a Qt container widget, and then re-parent the rF2 window to the containter widget using the "SetParent" Windows function.
     
  5. TheRexorcist

    TheRexorcist Registered

    Joined:
    Jun 19, 2016
    Messages:
    7
    Likes Received:
    1
    Hey guys,

    even though I don't expect a lot of people over here to find my implementation useful, I still wanted to share.

    Just think of it as giving something back to all the people creating those awesome mods.

    The README is quite extensive, so there's no need to get into any details here.

    You can find the code below:

    https://github.com/flomar/rFactor2TimeTrial

    Have fun...
     

Share This Page