5H1N0B11 / flightgear-mirage2000

GNU General Public License v3.0
21 stars 16 forks source link

HUD on Emesary #145

Open 5H1N0B11 opened 4 years ago

5H1N0B11 commented 4 years ago

This should be updated every frame, and I don't know how integrate that, with Richard's code me.NxtElevation = getprop("/autopilot/route-manager/route/wp[" ~ me.input.currentWp.getValue() ~ "]/altitude-m");

Zaretto commented 4 years ago

There are a number of ways to achieve this; you could set a listener which in turn sets a property; however it can also be done directly using the property update manager. I prefer this approach because it gets the variable directly into the hash without the need for listeners.

To do this we only really need to add the property "autopilot/route-manager/current-wp" to the hash and add the two PropertyManager.FromHashList/Value to the update_items; however for efficiency we will also add a property node for the route manager route to the HUD object.

        obj.routeManager = props.getNode("/autopilot/route-manager/route");

Then add to the update_items (also in the constructor/new method) like this

    props.UpdateManager.FromHashList(["RouteManagerCurrentWp"], 1, func(val) {
        #this update will extract the value of altitude from the waypoint node
        #and place it directly in the hash ready for the next method.
        obj.activeWaypointNode = obj.routeManager.getChild("wp", val.RouteManagerCurrentWp);

        if (obj.activeWaypointNode != nil) {
            obj.NxtElevationNode = obj.activeWaypointNode.getNode("altitude-m");

            if (obj.NxtElevationNode == nil)
              val.NxtElevation = nil;
            else
              val.NxtElevation = obj.NxtElevationNode.getValue();
        } else {
            obj.NxtElevationNode = nil;
            val.NxtElevation = nil;
        }
    }),

    props.UpdateManager.FromHashValue("NxtElevation", 1, func(val){
        # output the current elevation to the display
        obj.window8.setText(sprintf("ELV=%02d",val));
    }),

and finally add the request to monitor the variable to the

input = {
...
        RouteManagerCurrentWp                   : "autopilot/route-manager/current-wp",
...
Zaretto commented 4 years ago

The changes to the F-15 HUD to achieve this can be seen in the attached archive by comparing the two files;

HUD-changes-F-15.zip

vanosten commented 1 month ago

It is not clear from the title "HUD on Emesary" and the description "This should be updated" what feature this issue is referring to.

Zaretto commented 1 month ago

"This should be updated..." could read "The HUD should be updated..."

However I suspect this issue is stale but I can't remember anything about doing this.