Back to Index Page generated: May 8, 2024, 6:16:03 AM

Expansion Display Current Course

Content

Warnings

  1. Information URL mismatch between OXP Manifest and Expansion Manager string length at character position 0

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Shows players current course on the galactic map when contract courses are shown Shows players current course on the galactic map when contract courses are shown
Identifier oolite.oxp.phkb.DisplayCurrentCourse oolite.oxp.phkb.DisplayCurrentCourse
Title Display Current Course Display Current Course
Category Mechanics Mechanics
Author phkb phkb
Version 1.9 1.9
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL n/a
Download URL https://wiki.alioth.net/img_auth.php/9/96/DisplayCurrentCourse.oxz n/a
License CC-BY-NC-SA 4.0 CC-BY-NC-SA 4.0
File Size n/a
Upload date 1610873378

Documentation

Also read http://wiki.alioth.net/index.php/Display%20Current%20Course

readme.txt

Display Current Course
By Nick Rogers

Overview
========
This OXP aims to improve the usefulness of the Advanced Navigational Array by adding the players current plotted course to all contract detail pages, enabling them to see if the contract is on a similar path to what they are currently travelling along.

Installation and use
====================
In order to get the benefits of this enhancement, the Advanced Navigation Array must be installed and functional. Once installed, and you have a course plotted on the F6 galactic chart, you will then see your current course plotted in green whenever you examine the details of a contract.

Link Color Variation
====================
It is possible to switch the color of the current course on the map, if the Library OXP is installed. You can switch between the default green, red, blue, orange, purple, white and magenta.

Third Party OXP's
=================
If a third party OXP would like to have their mission screen included in those screens which get the current course plotted, all they need to do is:
1. Make sure their mission screen has a "screenID" property set.
2. Add the following code to their worldScript (usually in the startUpComplete function):

	var dcc = worldScripts.DisplayCurrentCourse;
	if (dcc) dcc._screenIDList.push("my_screen_id");
	
License
=======
This work is licensed under the Creative Commons Attribution-Noncommercial-Share Alike 4.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/

Version History
===============
1.9
- Version number change only, to test Mac download problems.

1.8
- Added ability to change the link color (via Library Config).

1.7
- Better handling of Galactic jumps.
- Code refactoring.

1.6
- Updated list of known screenID's.
- Fixed issue where viewing Escort Contracts would potentially stop the current route from showing.
- Added Random Hits screen ID inclusion.

1.5
- Fixed the issue with the course being reset to the contract destination if only 1 contract was available.

1.4
- Changed assumptions about "Route Mode - None" - this mode will now turn off the display of your current course on contract screens, rather than default to a "fewest jumps" route.

1.3
- Added contract summary pages to the list of screen ID's to monitor to fix issue where player's current course is sometimes not displayed.

1.2
- Attempts to fix issue where player's true current course is sometimes not displayed.

1.1
- Small improvements to marking logic, so only one link is required.

1.0
- Initial release.

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/displaycurrentcourse.js
"use strict";
this.name = "DisplayCurrentCourse";
this.author = "phkb";
this.copyright = "2015 phkb";
this.description = "Routines for adding the players current course to the galactic map when also showing a contract course.";
this.licence = "CC BY-NC-SA 4.0";

this._debug = false;
this._currentRoute = null;
this._currentTarget = null;
this._currentRouteMode = "";
this._marked = false;
this._screenIDList = [
	"oolite-contracts-parcels-details", 
	"oolite-contracts-passengers-details", 
	"oolite-contracts-cargo-details",
	"oolite-damagereport-detail-map", 
	"damage_report_detail", 
	"oolite-galcopsecoffice-screen4-map", 
	"oolite-galcopsecoffice-screen8-map", 
	"oolite-smuggling-contracts-map", 
	"smuggling-contracts-details",
	"rrs_mission_map", 
	"blackmonks-map", 
	"ups-map", 
	"escort-contracts", 
	"random_hits_map"
];
this._refresh = null;
this._holdDestination = -1;
this._colorList = [
	"greenColor", 
	"redColor", 
	"blueColor", 
	"orangeColor", 
	"purpleColor", 
	"whiteColor", 
	"magentaColor"
];
this._color = 0;
this._libSettings = {
	Name: this.name,
	Display: "UI Settings",
	Alias: "Display Current Course",
	Alive: "_libSettings",
	SInt: {
		S0: {
			Name: "_color",
			Def: 0,
			Min: 0,
			Max: 6,
			Desc: "Link Color"
		},
		Info: "0 = green, 1 = red, 2 = blue, 3 = orange, 4 = purple, 5 = white, 6 = magenta"
	},
};

// IDEA: Include course plot info from any contracts currently in play

//-------------------------------------------------------------------------------------------------------------
this.startUpComplete = function () {
	if (worldScripts.Lib_Config) {
		if (missionVariables.DCC_LinkColor) this._color = parseInt(missionVariables.DCC_LinkColor);
		worldScripts.Lib_Config._registerSet(this._libSettings);
	}

	// make sure we get a copy of the player's target system after a game load
	if (player.ship.targetSystem >= 0) this._holdDestination = player.ship.targetSystem;
}

//-------------------------------------------------------------------------------------------------------------
this.playerWillSaveGame = function () {
	if (worldScripts.Lib_Config) {
		missionVariables.DCC_LinkColor = this._color;
	}
}

//-------------------------------------------------------------------------------------------------------------
this.guiScreenChanged = function (to, from) {
	if (guiScreen != "GUI_SCREEN_LONG_RANGE_CHART" && guiScreen != "GUI_SCREEN_SHORT_RANGE_CHART" && (from == "GUI_SCREEN_LONG_RANGE_CHART" || from == "GUI_SCREEN_SHORT_RANGE_CHART")) {
		if (this._marked) this.$unmarkSystems();
		// grab a copy of the player's destination set on the galactic chart
		this._holdDestination = player.ship.targetSystem;
		this._currentTarget = null;
	}

	if (guiScreen == "GUI_SCREEN_MISSION") {
		var p = player.ship;
		if (p.equipmentStatus("EQ_ADVANCED_NAVIGATIONAL_ARRAY") == "EQUIPMENT_OK") {
			// if the route mode is set to "NONE", jump out now.
			if (p.routeMode == "OPTIMIZED_BY_NONE") {
				// make sure we don't get a residue from previous visits to the galactic chart
				if (this._marked) this.$unmarkSystems();
				return;
			}
			// if we don't yet have a target set, get a copy now.
			if (this._currentTarget == null && this._holdDestination != -1) {
				if (this._debug) log(this.name, "setting current target details");
				this._currentTarget = this._holdDestination;
				this._currentRouteMode = p.routeMode;
				if (this._debug) log(this.name, "A: curr " + system.ID + ", curr dest " + this._currentTarget + ", route mode " + this._currentRouteMode + ", route length " + (this._currentRoute && this._currentRoute.route.length > 0 ? this._currentRoute.route.length : 0));
			}
			// if the screen ID mataches one in our list, then we can add the system links in now
			if (this._screenIDList.indexOf(mission.screenID) >= 0 && this._marked == false) {
				if (this._refresh && this._refresh.isRunning) this._refresh.stop();
				var info = System.infoForSystem(galaxyNumber, this._currentTarget);
				this._currentRoute = system.info.routeToSystem(info, this._currentRouteMode);
				if (this._debug) log(this.name, "B: curr " + system.ID + ", curr dest " + this._currentTarget + ", route mode " + this._currentRouteMode + ", route length " + (this._currentRoute && this._currentRoute.route.length > 0 ? this._currentRoute.route.length : 0));
				if (this._currentRoute && this._currentRoute.route.length > 1) {
					for (var i = 0; i < this._currentRoute.route.length - 1; i++) {
						if (this._currentRoute.route[i] < this._currentRoute.route[i + 1]) {
							SystemInfo.setInterstellarProperty(galaxyNumber, this._currentRoute.route[i], this._currentRoute.route[i + 1], 2, "link_color", this._colorList[this._color]);
						} else {
							SystemInfo.setInterstellarProperty(galaxyNumber, this._currentRoute.route[i + 1], this._currentRoute.route[i], 2, "link_color", this._colorList[this._color]);
						}
					}
					this._marked = true;
				}
			}
			if (this._screenIDList.indexOf(mission.screenID) == -1) {
				// this is a bit of a hack to cope with mission screens that actually set the player's target system as part of their actions
				// start a timer to reset the marked system
				if (!this._refresh || this._refresh.isRunning == false) this._refresh = new Timer(this, this.missionScreenEnded, 0.25, 0);
			}
		}
	}
}

//-------------------------------------------------------------------------------------------------------------
this.missionScreenEnded = function () {
	if (this._marked == true) this.$unmarkSystems();
	// reset the holding destination in case a mission screen updated it
	this._holdDestination = player.ship.targetSystem;
}

//-------------------------------------------------------------------------------------------------------------
this.shipWillEnterWitchspace = function (cause) {
	if (cause == "galactic jump") {
		this.$unmarkSystems();
		this._holdDestination = -1;
	}
}

//-------------------------------------------------------------------------------------------------------------
this.$unmarkSystems = function $unmarkSystems () {
	if (this._currentRoute) {
		for (var i = 0; i < this._currentRoute.route.length - 1; i++) {
			if (this._currentRoute.route[i] < this._currentRoute.route[i + 1]) {
				SystemInfo.setInterstellarProperty(galaxyNumber, this._currentRoute.route[i], this._currentRoute.route[i + 1], 2, "link_color", null);
			} else {
				SystemInfo.setInterstellarProperty(galaxyNumber, this._currentRoute.route[i + 1], this._currentRoute.route[i], 2, "link_color", null);
			}
		}
	}
	this._currentTarget = null;
	this._currentRoute = null;
	this._currentRouteMode = "";
	this._marked = false;
}