Back to Index Page generated: Nov 12, 2024, 11:02:04 PM

Expansion GETter HUD

Content

Warnings

  1. http://wiki.alioth.net/index.php/GETter%20HUD -> 404 Not Found
  2. Low hanging fuit: Information URL exists...

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description A compact Trader's HUD based on the standard HUD, with digital speed, re-coloured scanner, compass, gauges, MFD and legends. Cargo carried (with quantity) is shown in place of missile loadout, and shipowner, ship class and name, plus hold capacity are displayed just above the scanner. System's name is also displayed. A compact Trader's HUD based on the standard HUD, with digital speed, re-coloured scanner, compass, gauges, MFD and legends. Cargo carried (with quantity) is shown in place of missile loadout, and shipowner, ship class and name, plus hold capacity are displayed just above the scanner. System's name is also displayed.
Identifier oolite.oxp.Reval.GETTER_HUD oolite.oxp.Reval.GETTER_HUD
Title GETter HUD GETter HUD
Category HUDs HUDs
Author Reval Reval
Version 1.5 1.5
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL https://wiki.alioth.net/index.php/GETter_HUD_OXZ n/a
Download URL https://wiki.alioth.net/img_auth.php/7/7c/GETter_HUD.oxz n/a
License CC-BY-NC-SA 4.0 CC-BY-NC-SA 4.0
File Size n/a
Upload date 1692785669

Documentation

Equipment

This expansion declares no equipment. This may be related to warnings.

Ships

This expansion declares no ships. This may be related to warnings.

Models

This expansion declares no models. This may be related to warnings.

Scripts

Path
Scripts/gh_script.js
"use strict";
this.name = "GETter_HUD";
this.author = "Reval";
this.licence = "CC BY-NC-SA 4.0";
this.version = "1.5";

this._operationalFunctionNames = [ // list of functions to enable/disable at HUDSelector callback
    "playerBoughtNewShip",
	"playerBoughtEquipment",
	"equipmentAdded",
    "shipWillLaunchFromStation",
    "shipExitedWitchspace",
    "guiScreenChanged",
	"shipWillDockWithStation"
];

this.startUp = function() {
	this.$hudSelector = worldScripts.hudselector;
	if(this.$hudSelector) {
		this.$hudSelector.$HUDSelectorAddHUD("GETter HUD", this.name);
		this.$hudSelector.$HUDSelectorAddHUD("GETter HUD Small", this.name + "-small");
	}
}

this.startUpComplete = function() {
	if(!this.$hudSelector && (player.ship.hud === "hud.plist"))
		player.ship.hud =  this.name + ".plist";
	this._ghlistGoods();
	this._ghlistOwner();
	this._ghlistCap();
	this._ghlistSystem();
}


this.playerBoughtNewShip = function(ship, price) {
	if(!this.$hudSelector && (player.ship.hud === "hud.plist"))
		player.ship.hud =  this.name + ".plist";
	this._ghlistGoods();
	this._ghlistOwner();
	this._ghlistCap();
	this._ghlistSystem();
}


this.playerBoughtEquipment = function(equipment, paid) {
	this._ghlistGoods();
	this._ghlistOwner();
	this._ghlistCap();
	this._ghlistSystem();
}


this.equipmentAdded = function(equipmentKey) {
	this._ghlistGoods();
	this._ghlistOwner();
	this._ghlistCap();
	this._ghlistSystem();
}


this.shipWillLaunchFromStation = function() {
	if(!this.$Timer) this.$Timer = new Timer(this,this._ghupdateSpeed.bind(this),0,0.25);
	if(!this.$Timer1) this.$Timer1 = new Timer(this,this._ghshowWeps.bind(this),0,0.25);
	this._ghlistGoods();
	this._ghlistOwner();
	this._ghlistCap();
	this._ghlistSystem();
}

this.shipWillDockWithStation = function() {
	if (this.$Timer && this.$Timer.isRunning) { this.$Timer.stop(); this.$Timer = null; }
	if (this.$Timer1 && this.$Timer1.isRunning) { this.$Timer1.stop(); this.$Timer1 = null; }
}

this.shipExitedWitchspace = function() {
	this._ghlistSystem();
}
	
	
this.guiScreenChanged = function(to, from) {
	if ((from=="GUI_SCREEN_MARKET")||(from=="GUI_SCREEN_MANIFEST")) {
		this._ghlistGoods();
		this._ghlistOwner();
		this._ghlistCap();
		this._ghlistSystem();
	}
}


this._ghcenteredText = function(txt, width) {
	var t = ""+txt; // force to string, else txt.length is undefined for numbers
	var w = width / 2;
	while( t && t.length < w ) { // for fixed width font in setCustomHUDDial
		t = " " + t;
	}
	return(t);
}


this._ghupdateSpeed = function () {
	var p = player.ship;
	if((!p) || (!p.isValid)) return; // player died

	var setd = p.setCustomHUDDial;
	if (setd) {
		var sp = p.speed;
		sp = this._ghcenteredText(sp.toFixed(1), 28); // default width
		setd("shipSpeed", sp);
	}
}


// output System name to HUD
this._ghlistSystem = function() {
	var p = player.ship;
	if((!p) || (!p.isValid)) return; // player died

	var setd = p.setCustomHUDDial;
	if (setd) {
		var s = this._ghsystemList();
		setd("systemList", s);
	}
}


// show System name
this._ghsystemList = function() {
	var result = "";
	result += System.systemNameForID(system.ID);
	return result;
}


// output capList to HUD
this._ghlistCap = function() {
	var p = player.ship;
	if((!p) || (!p.isValid)) return; // player died

	var setd = p.setCustomHUDDial;
	if (setd) {
		var cap = this._ghcapList();
		setd("capList", cap);
	}
}


// show ship's TC capacity
this._ghcapList = function() {
	var result = "";
	result += "Capacity: ";
	result += player.ship.cargoSpaceCapacity+" TC";
	return result;
}


// output ownerList to HUD
this._ghlistOwner = function() {
	var p = player.ship;
	if((!p) || (!p.isValid)) return; // player died

	var setd = p.setCustomHUDDial;
	if (setd) {
		var owner = this._ghownerList();
		setd("ownerList", owner);
	}
}


// show ship, class, name, owner
this._ghownerList = function() {
	var result = "";
	result += "Cdr. ";
	result += player.name + ", ";
	result += player.ship.displayName;
	return result;
}


// output goods list to HUD
this._ghlistGoods = function() {
	var p = player.ship;
	if((!p) || (!p.isValid)) return; // player died

	var setd = p.setCustomHUDDial;
	if (setd) {
		var goods = this._ghgoodsList();
		setd("goodsList", goods);
	}
}


// list commodities in ship's hold
this._ghgoodsList = function() {
	var result = "";
	var m = manifest.list;
	for (var i=0; i<m.length; i++) {
		var q = m[i].commodity;
		if (q) result += q + " ("+m[i].quantity+")  ";
	}	
	if (result=="") result = "EMPTY";
	return result;
}


// weapons online indicator
this._ghshowWeps = function() {
	var p = player.ship;
	if((!p) || (!p.isValid)) return; // player died

	var setd = p.setCustomHUDDial;
	if (setd) {
		var weps = "";
		if (p.weaponsOnline) weps="W";
		setd("showWeapons", weps);
	}
}

this.$HUDSelectorCallBack = function(off) {
    var ws = worldScripts.GETter_HUD;
    var funcNames = this._operationalFunctionNames;
    var i = funcNames.length;
    if (off) {
        // disable
        while (i--)
            if (ws[funcNames[i]]) {
                ws["$save_" + funcNames[i]] = ws[funcNames[i]];
                delete ws[funcNames[i]];
            }
    } else {
        // enable
        while (i--)
            if (!ws[funcNames[i]]) {
                ws[funcNames[i]] = ws["$save_" + funcNames[i]];
            }
		ws.playerBoughtEquipment();
    }
}