Feature Request #932

Ability to Find Races

Added by anonymous1 3 months ago. Updated 3 months ago.

Status:New Start date:02/06/2012
Priority:Normal Due date:
Assignee:neorej16 % Done:

10%

Category:RoR - Scripting (Angelscript)
Target version:0.39

Description

I just though it would be nice if one was able to move their cursor to the top of the screen while in game to make the menu appear, and find a race starting point. There would be a menu option called "Races", and a user would select an available AngleScript race on that terrain. Once a race on that terrain was clicked, a 3D yellow arrow (similar to the one used to find checkpoints while racing) would show up, showing the direction and presenting the distance to the selected race.

There could also be the user's best time for those races (if submitted), and also the leading top score submitted by someone else online.
http://www.rigsofrods.com/threads/86901-Ability-to-Find-Races

History

#1 Updated by neorej16 3 months ago

  • % Done changed from 0 to 10

This mainly involves giving scripts access to GUI elements.

Just what I had currently in mind (without thinking about the actual c++ implementation yet).

// an interface to interact with the menu
interface menuItem
{
    bool enabled;
    void destroy();

    menuItem@ get_opIndex(uint index);

    menuItem@ addMenuItem(const string &in caption, ?&in callbackObject, const string &in callbackFunctionName, any@ internalData);
    menuItem@ addMenuItem(uint index, const string &in caption, ?&in callbackObject, const string &in callbackFunctionName, any@ internalData);
}

// An interface for pop ups
interface popUp
{
    bool visible;
    void destroy();

    void addButton(const string &in caption, const vector2 &in relativePosition, ?&in callbackObject, const string &in callbackFunctionName, any@ internalData);
    void addText(const string &in caption, const vector2 &in relativePosition);

    //...
}

// An interface for the general gui element
interface gui
{
    menuItem@ get_terrainMenu();
    popUp@ addPopUp(const string &in title, const vector2 &in size, int position = (VCENTER | HCENTER));
}

// Some positions where a popup can be positioned
enum popUpPositions
{
    TOP     = 0x0001,
    BOTTOM  = 0x0002,
    VCENTER = 0x0004,
    LEFT    = 0x0010,
    RIGHT   = 0x0020,
    HCENTER = 0x0040,
}

Using the interfaces above, then this would be some example script that will create a menu, similar to this:

terrain
 |- menuItem 1
 |- subMenu
     |- subMenuItem 1
     |- subMenuItem 2

So the AngelScript script for that, would be:

// Create a class that will handle our 'on click' events
class menuHandler
{
    popUp@ alert;

    void on_click1(const string &in caption, any@ internalData)
    {
        game.message("You clicked on button 1", "tick.png", 30000, true);
    }

    void on_click2(const string &in caption, any@ internalData)
    {
        game.message("You clicked on button 1 inside sub-menu 1", "tick.png", 30000, true);
    }

    void on_click2(const string &in caption, any@ internalData)
    {
        game.message("You clicked on button 2 inside sub-menu 1", "tick.png", 30000, true);

        // Let's show a popup here
        alert = game.gui.addPopUp("this is a title for the pop up", vector2(200.0f, 200.0f), (VCENTER | HCENTER));
        alert.addText("This is some text", vector2(20.0f, 20.0f));
        alert.addButton("OK", vector2(20.0f, 150.0f), @this, "on_click_ok", null);
    }

    void on_click_ok(const string &in caption, any@ internalData)
    {
        // hide the popup again
        alert.destroy();
    }
}
menuHandler handler;

void main()
{
    // Get the terrain menu
    menuItem@ menu = game.gui.terrainMenu;

    // Add an item in the terrain menu
    menu.addMenuItem("menuItem 1", @handler, "on_click1", null);

    // Add a submenu to the terrain menu
    menuItem@ subMenu = menu.addMenuItem("submenu", null, "", null);
    subMenu.addMenuItem("subMenuItem 1", @handler, "on_click2", null);
    subMenu.addMenuItem("subMenuItem 2", @handler, "on_click3", null);
}

Again, this is just a suggestion, I'll probably have to look into mygui to see what is possible and what is not.
All other suggestions, improvements or ideas are welcome of course.

Also available in: Atom PDF