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

Expansion Xenon Redux UI

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Adds backgrounds to all screens, allowing for a narrower screen ratio (eg 4:3). Also includes new title screen music. Also requires the XenonReduxUIResources.oxz. For 16:9 screens, see Xenon UI. This OXP will override any backgrounds currently applied by other OXP's. This is by design, in order to maintain the illusion of looking at a computer display. If conflicts arise, where important information needs to be given to the player via a background screen, code can be applied to allow exceptions to take place. See the Wiki page for more information. Adds backgrounds to all screens, allowing for a narrower screen ratio (eg 4:3). Also includes new title screen music. Also requires the XenonReduxUIResources.oxz. For 16:9 screens, see Xenon UI. This OXP will override any backgrounds currently applied by other OXP's. This is by design, in order to maintain the illusion of looking at a computer display. If conflicts arise, where important information needs to be given to the player via a background screen, code can be applied to allow exceptions to take place. See the Wiki page for more information.
Identifier oolite.oxp.z.phkb.XenonReduxUI oolite.oxp.z.phkb.XenonReduxUI
Title Xenon Redux UI Xenon Redux UI
Category Ambience Ambience
Author phkb phkb
Version 3.5 3.5
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
  • oolite.oxp.z.phkb.XenonReduxUIResources:1.1.0
  • oolite.oxp.z.phkb.XenonReduxUIResources:1.1.0
  • Optional Expansions
    Conflict Expansions
    Information URL http://wiki.alioth.net/index.php/XenonUI n/a
    Download URL https://wiki.alioth.net/img_auth.php/9/90/XenonReduxUI.oxz http://wiki.alioth.net/img_auth.php/9/90/XenonReduxUI.oxz
    License CC-BY-NC-SA 3.0 CC-BY-NC-SA 3.0
    File Size n/a
    Upload date 1624987211

    Documentation

    Also read http://wiki.alioth.net/index.php/Xenon%20Redux%20UI

    readme.txt

    Xenon Redux UI OXP
    By Nick Rogers
    
    About this OXP
    ==============
    This OXP replaces all background UI screens with a new look and feel, based on the assumption that the Oolite UI screens are accessed through some form of computer terminal. 
    
    The method used to add the backgrounds will mean that the background images of most other OXP's, if they set a background, will be overridden with the Xenon UI images. This is by design. 
    
    If an OXP uses background images to convey important information to the player, and the "mission.runScreen" command in the OXP has a "screenID" parameter attached, it is possible to add exceptions to the override by adding the following code to a worldScript:
    
    	var w = worldScripts.XenonReduxUI;
    	if (w) w.$addMissionScreenException("mymissionscreenid");
    
    The OXP is made up of two parts: the main XenonReduxUI.oxz, which holds all the config and code, and the XenonReduxUIResources.oxz, which holds all the images. This will allow fast updates to the code section, which is small, without having to download the large resources file regularly.
    
    The images in this OXP are designed screens narrower than 16:10 (eg. 4:3). For a 16:9 and 16:10 screen version, see the XenonUI.oxz.
    
    BGS 1.10 Compatibility
    ======================
    Xenon Redux UI is compatible with BGS v1.10, but depending on where each one is installed, one OXP may end up taking priority over the other when backgrounds are selected and displayed. When BGS has priority, its images will be displayed ahead of the Xenon Reduc UI images. This will be particular apparent on screens like the title page or the load/save page.
    
    If both OXP's (Xenon Redux UI and BGS) are installed in the Addons folder, Xenon Redux UI will normally take priority over BGS.
    
    If both OXP's are installed via the download manager, again, Xenon Redux UI will normally take priority over BGS.
    
    If BGS is installed via the download manager, and Xenon UI is installed in the AddOns folder, Xenon Redux UI will take priority over BGS.
    
    If Xenon UI is installed via the download manager, and BGS is installed in the AddOns folder, BGS will take priority over Xenon Redux UI.
    
    To ensure the Xenon Redux UI backgrounds appear, the best approach is to make sure they are both installed in the same location.
    
    If you encounter issues where the BGS backgrounds are being displayed rather than the Xenon Redux UI ones, you will need to open the BGS OXP folder, then open the Config folder. Inside Config you will find a 'screenbackgrounds.plist' file. Either remove this or re-name it - perhaps re-name it to 'screenbackgrounds.Xplist' - and the Xenon Redux UI backgrounds will be used without affecting any other aspect of BGS. By re-naming 'screenbackgrounds.plist' rather than removing it you have the option of switching back easily if required.
    
    BGS 2.0 Compatibility
    =====================
    Xenon Redux UI will hook into Library GUI to register itself as a GUI set. Therefore, you can go to the Library GUI settings and change between BGS 2.0 and Xenon Redux UI anytime you like. 
    
    Because of the way the images are created, Xenon Redux UI is still utilising settings in "screenbackgrounds.plist", which may lead to some inconsistencies. For instance, if Xenon Redux UI and BGS 2.0 are installed, when you start Oolite and select the option to open a saved commander, the background will be Xenon Redux UI. Once you have loaded a game, if you then press F2 to load a new game, you will see the BGS background.
    
    Licence
    =======
    This OXP is released under the Creative Commons Attribution - Non-Commercial - Share Alike 3.0 license. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/
    
    Briefcase image form http://simpleicon.com/briefcase-3.html
    Rocket image form http://simpleicon.com/rocket.html
    ID Card from http://simpleicon.com/id_card-2.html
    Power icon from http://simpleicon.com/switch_button_1.html
    Report icon from http://simpleicon.com/note-11.html
    Gears icon from http://simpleicon.com/gear-6.html
    Load icon from http://simpleicon.com/upload_2.html
    Save icon from http://simpleicon.com/download_2.html
    Interface icon from http://simpleicon.com/retweet.html
    Settings icon from http://simpleicon.com/setting.html
    Keyboard icon from https://commons.wikimedia.org/wiki/File:High-contrast-input-keyboard.svg
    Trolley icon from http://simpleicon.com/shopping_trolley_1.html
    Clipboard icon from http://simpleicon.com/admite_form_1.html
    Tag image from http://simpleicon.com/tag-2.html
    Gamepad image from http://simpleicon.com/gaming_remote.html
    Question mark image from http://simpleicon.com/question_mark_1.html
    Warning image from http://simpleicon.com/warning.html
    
    Version History
    ===============
    3.5
    - Bug fixes.
    
    3.4
    - Bug fixes.
    
    3.3
    - Fixes for Ships Library, Sothis TC, New Cargoes and Iron Raven to restore background images.
    
    3.2
    - Improvements in BGS compatibility.
    
    3.1
    - Updated compatibility with Library 1.7.
    
    3.0
    - Added "Amber" background option (selectable via Library Config).
    - Code refactoring.
    
    2.1.5
    - Improvements in Library GUI integration.
    
    2.1.4
    - Improved coverage of different mission screen sequencing scenarios. (Oolite 1.85/86 required)
    - Improved integration with XenonUI via Library GUI.
    - Applied new screenbackgrounds added in v1.87 ("custom_chart_mission").
    
    2.1.3
    - Fixed incorrect key lookup with mission screen overlays.
    - Fixed issue with turning off overlay images with Library GUI.
    - Disabling background images on a mission screen will now also disable any overlays as well.
    - Bug fixes.
    
    2.1.2
    - Bug fixes.
    - Included check for resources pack during startup.
    
    2.1.1
    - Rejigged connection to Library GUI for nicer handovers when GUI's change.
    
    2.1.0
    - Updated for simpler integration with Library GUI.
    - Code refactoring.
    
    2.0.4
    - Adjusted the Random Hits screen ID exception.
    
    2.0.3
    - Hopefully fixed issues with mission screens losing the Xenon Redux UI theme.
    
    2.0.2
    - Updated title screen image.
    
    2.0.1
    - Fixed compatibility issue with HDBG when using Library GUI.
    
    2.0.0
    - Made compatible with Library GUI, and enabled it to be installed alongside Xenon UI, if required.
    - Added some configuration settings to Library Config.
    - Added additional overlays to various data screens.
    - Fixed some image file naming errors.
    - Code cleanup.
    
    1.3.4
    - Added "oxz-manager" to screenbackgrounds.plist.
    - Changed "==" comparisons to "===" for performance improvements.
    
    1.3.3
    - Fixed "p is null" error.
    
    1.3.2
    - Update Nova Mission screen ID's to match core.
    
    1.3.1
    - Updated check for "Allow Big GUI".
    
    1.3.0
    - Changed new game background to the 'no hud' variant.
    - New title screen image.
    - Added mission screen overlays. Can be disabled by setting "this._disableOverlays = true;" in "xenonreduxui.js".
    - Fixed issue with BGS where the F6 overlay image was being removed.
    - Fixed issue where exiting the Ship Library screen would sometimes show the wrong background.
    - Added mission screen exception for Random Hits.
    
    1.2.1
    - Added screenID exceptions for UPS Courier.
    - Added screedID exceptions for Escort Contracts (v1.6.3).
    - Added routine to use 1.83/4 code to check for big GUI HUD's.
    
    1.2.0
    - Updated all images to be 2048x1024 to stop Oolite from rescaling them. Results in a much cleaner image
    - Checks for the "allow_big_gui" option on HUD's. Uses the "nohud" background variations when found.
    - Fixed issue where the wrong background was being selected going to or from the F8 Market screen if Market Observer is installed.
    - Fixed issue with mission screens that exit to the short or long range chart, where the wrong background was being displayed.
    - Added screenID's to nova mission screens.
    - Added screenID exceptions for Rescue Stations.
    - Added screenID exceptions for Blackmonks.
    
    1.1.3
    - Adjusted the main title colour to match with the background.
    - Fixed issue with Trumbles and Nova missions not showing proper background image.
    - Changed license of code section to CC-BY-NC-SA 3.0 due to inclusion of trumbles and nova mission code.
    
    1.1.2
    - Changed manifest identifier to try and position the OXP at the bottom of the install list
    
    1.1.1
    - Fixed bug where "." is missing before "indexOf".
    
    1.1.0
    - Split OXZ into two, one for resources (music and images), one for the code and config.
    - Fixed file name issue for one of the files.
    - Code improvements as suggested by Wildeblood.
    - Added exception for Norby's forthcoming OXP (HDBG)
    - Added some BGS override exceptions
    
    1.0
    - Initial release.
    

    Equipment

    This expansion declares no equipment.

    Ships

    This expansion declares no ships.

    Models

    This expansion declares no models.

    Scripts

    Path
    Scripts/oolite-trumbles-mission.js
    /*
    
    oolite-trumbles-mission.js
    
    Script for random offers of trumbles.
    
    
    Oolite
    Copyright © 2004-2013 Giles C Williams and contributors
    
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
    MA 02110-1301, USA.
    
    Update by phkb to change mission background into overlay, for compatibility with XenonUI.
    
    */
    
    
    /*jslint white: true, undef: true, eqeqeq: true, bitwise: true, regexp: true, newcap: true, immed: true */
    /*global guiScreen, mission, missionVariables, player*/
    
    
    "use strict";
    
    
    this.name			= "oolite-trumbles";
    this.author			= "Jens Ayton";
    this.copyright		= "© 2008-2016 the Oolite team.";
    this.description	= "Random offers of trumbles.";
    
    
    (function () {
    
    var pendingOffer = false;
    
    
    function cleanUp(script)
    {
    	delete script.shipDockedWithStation;
    	delete script.missionScreenOpportunity;
    	delete script.shipWillExitWitchspace;
    }
    
    
    this.startUp = function startUp()
    {
    	/*	In the pre-JavaScript implementation, the mission variable was set to
    		OFFER_MADE while the mission screen was shown. If the player lanched
    		in that state, the offer would never be made again -- unless some
    		other script used the mission choice keys "YES" or "NO". This
    		implementation uses unique choice keys and doesn't change the mission
    		variable, which should be more reliable in all cases.
    	*/
    	if (missionVariables.trumbles === "OFFER_MADE")
    	{
    		missionVariables.trumbles = "BUY_ME";
    	}
    	else if (missionVariables.trumbles === "TRUMBLE_BOUGHT")
    	{
    		cleanUp(this);
    	}
    	delete this.startUp;
    }
    
    
    this.shipDockedWithStation = function shipDockedWithStation(station)
    {
    	pendingOffer = false;
    	if (missionVariables.novacount || missionVariables.nova)
    	{
    		// So the offers eventually stop for long-time players who keep refusing.
    		return;
    	}
    
    	if (station.isMainStation)
    	{
    		if (!missionVariables.trumbles)	
    		{
    			missionVariables.trumbles = "BUY_ME";
    		}
    
    		if (missionVariables.trumbles === "BUY_ME" &&
    			player.trumbleCount === 0 &&
    			Math.random() < 0.2) // 20% chance of trumble being offered.
    		{
    			pendingOffer = true;
    		}
    	}
    }
    
    
    this.missionScreenOpportunity = function missionScreenOpportunity()
    {
    	if (pendingOffer && player.credits > 6553.5)
    	{
    		pendingOffer = false;
    
    		// Show the mission screen.
    		mission.runScreen({
    			titleKey: "oolite_trumble_title",
    			messageKey: "oolite_trumble_offer",
    			overlay: {name:"trumblebox.png", height:512},
    			choicesKey: "oolite_trumble_offer_yesno",
    			screenID: "oolite-trumbles"
    		},
    		function (choice)
    		{
    			if (choice === "OOLITE_TRUMBLE_YES")
    			{
    				player.credits -= 30;
    				player.ship.awardEquipment("EQ_TRUMBLE");
    
    				missionVariables.trumbles = "TRUMBLE_BOUGHT";
    				cleanUp(this);
    			}
    			else
    			{
    				missionVariables.trumbles = "NOT_NOW";
    			}
    		});
    	}
    };
    
    
    this.shipWillExitWitchspace = function shipWillExitWitchspace()
    {
    	// If player has rejected a trumble offer, reset trumble mission with 2% probability per jump.
    	if (missionVariables.trumbles === "NOT_NOW" && Math.random() < 0.02)
    	{
    		missionVariables.trumbles = "BUY_ME";
    	}
    };
    
    }).call(this);
    
    Scripts/xenonreduxui.js
    (function () {
    	"use strict";
    	this.name = "XenonReduxUI";
    	this.author = "phkb";
    	this.copyright = "2016 phkb";
    	this.description = "Simplified versions of the Xenon UI backgrounds (no side panels).";
    	this.licence = "CC BY-NC-SA 3.0";
    
    	this._marketObserverInstalled = false; // flag to indicate when market observer is installed (for wide F8 display)
    	this._disableMissionScreen = []; // array of mission "screenID's" that will have the background disabled
    	this._chartExitScreenTimer = null;
    	this._missionOverlay = {}; // array of mission screen ID's and image names for overlays
    	this._backgroundOverride = []; // array of mission screen ID's we've forcefully added a background to
    	this._disableOverlays = false; // flag that indicates whether mission overlays will be applied to mission screens
    	this._enableLibGUIInt = true; // flag to indicate whether integration with LibGUI is on or off. true means it is on.
    	this._activeMode = true;
    	this._guiActive = ""; // monitors changes in the currently selected GUI (when Library is installed)
    	this._useBGS = "";
    	this._trueValues = ["yes", "1", 1, "true", true];
    	this._hdbgActive = false; // indicates that the HG Backgrounds OXP is active
    	this._addedID = {}; // keeps track of screen ID's we have added to Library GUI, so we can remove them if another GUI is selected
    	this._xn = null; // link to Xenon UI (if installed)
    	this._defaultBG = {};
    	this._amber = false;  // indicates whether blue (false) or amber (true) backgrounds will be used
    
    	// configuration settings for use in Lib_Config
    	this._xenonReduxUIConfig = {
    		Name: this.name,
    		Alias: "Xenon Redux UI",
    		Display: "Config",
    		Alive: "_xenonReduxUIConfig",
    		Notify: "$changeSettings",
    		Bool: {
    			B0: {
    				Name: "_disableOverlays",
    				Def: false,
    				Desc: "Disable overlays"
    			},
    			B1: {
    				Name: "_activeMode",
    				Def: true,
    				Desc: "Active mode"
    			},
    			B2: {
    				Name: "_amber",
    				Def: false,
    				Desc: "Amber color"
    			},
    			Info: "0 - Disables the mission screen overlay images.\n1 - XenonReduxUI will actively attempt to apply backgrounds to all mission screens, except for those added as exceptions.\n2 - Switch amber color on."
    		},
    	};
    
    	/*
    		This OXP replaces all the backgrounds of all UI screens with new versions using a hi-tech-like design theme.
    		In most cases any individual backgrounds supplied by individual OXP's on their mission "runScreen" will overridden by these ones (but see below).
    
    		This OXP is designed to be compatible with the BackGroundSet (BGS). However, on some systems some BGS images may still be shown,
    		depending on the load order of the OXP's. If this OXP loads after BGS, these images will be used. If BGS loads after this OXP, it's images may be used.
    
    		If your OXP has backgrounds you want to keep, and you want to still use this OXP, use the "$addMissionScreenException" to your startUpComplete script:
    		Example:
    			var w = worldScripts.XenonReduxUI;
    			if (w) w.$addMissionScreenException("mymissionscreenid");
    
    	*/
    
    	//-------------------------------------------------------------------------------------------------------------
    	// adds a screen ID to the list of mission screen ID's for which this OXP will not override
    	this.$addMissionScreenException = function $addMissionScreenException(missionScreenID) {
    		var lib = worldScripts.Lib_GUI;
    		if (this._disableMissionScreen.indexOf(missionScreenID) === -1) this._disableMissionScreen.push(missionScreenID);
    		if (lib && this._enableLibGUIInt && (!this._addedID[missionScreenID] || this._addedID[missionScreenID] === 2) && lib.$cur === "XenonReduxUI") {
    			if (!lib.$IDRules[missionScreenID]) {
    				this._addedID[missionScreenID] = 2;
    				this.$passConfig(missionScreenID);
    				lib.$IDRules[missionScreenID] = {
    					mpic: 0
    				};
    			}
    			//lib.$IDRules[missionScreenID] = {
    			//	mpic: 0
    			//};
    		}
    	}
    
    	//-------------------------------------------------------------------------------------------------------------
    	// function to add an overlay image to a mission screen
    	this.$addMissionOverlay = function $addMissionOverlay(missionScreenID, imagename) {
    		if (!this._missionOverlay[missionScreenID] && imagename == null) imagename = "";
    		if (imagename != null) this._missionOverlay[missionScreenID] = imagename;
    		var lib = worldScripts.Lib_GUI;
    		// lib_GUI stuff
    		if (lib && this._enableLibGUIInt) {
    			if (imagename != null && imagename != "") {
    				lib.$IDs.XenonReduxUI[missionScreenID] = {
    					pic: {
    						name: (this._amber === true ? "amber" : "xenon") + "_redux.png",
    						height: 546
    					},
    					picBig: {
    						name: (this._amber === true ? "amber" : "xenon") + "_redux_nohud.png",
    						height: 546
    					},
    					ov: {
    						name: imagename,
    						height: 546
    					},
    					sndRef: this._useBGS
    				};
    				if (lib.$cur === "XenonReduxUI") {
    					if (!this._addedID[missionScreenID] || this._addedID[missionScreenID] === 2) {
    						if (!lib.$IDRules[missionScreenID]) {
    							this._addedID[missionScreenID] = 2;
    							this.$passConfig(missionScreenID);
    							if (this._disableOverlays === true) {
    								lib.$IDRules[missionScreenID] = {
    									pic: 1,
    									ov: 0
    								};
    							} else {
    								lib.$IDRules[missionScreenID] = {
    									pic: 1,
    									ov: 1
    								};
    							}
    						}
    						/*if (this._disableOverlays === true) {
    							lib.$IDRules[missionScreenID] = {
    								pic: 1,
    								ov: 0
    							};
    						} else {
    							lib.$IDRules[missionScreenID] = {
    								pic: 1,
    								ov: 1
    							};
    						}*/
    					}
    				}
    			} else {
    				if (imagename === "") {
    					lib.$IDs.XenonReduxUI[missionScreenID] = {
    						pic: {
    							name: (this._amber === true ? "amber" : "xenon") + "_redux.png",
    							height: 546
    						},
    						picBig: {
    							name: (this._amber === true ? "amber" : "xenon") + "_redux_nohud.png",
    							height: 546
    						},
    						sndRef: this._useBGS
    					};
    					if (lib.$cur === "XenonReduxUI" && (!this._addedID[missionScreenID] || this._addedID[missionScreenID] === 2)) {
    						if (!lib.$IDRules[missionScreenID]) {
    							this._addedID[missionScreenID] = 2;
    							this.$passConfig(missionScreenID);
    							lib.$IDRules[missionScreenID] = {
    								pic: 1
    							};
    						}
    						//lib.$IDRules[missionScreenID] = {
    						//	pic: 1
    						//};
    					}
    				}
    			}
    		}
    	}
    
    	//-------------------------------------------------------------------------------------------------------------
    	this.startUp = function () {
    		this._xn = worldScripts.XenonUI;
    
    		var disable = false;
    		if (worldScriptNames.indexOf("Xenon Redux UI Resource Pack") === -1) {
    			log(this.name, "ERROR! The Xenon Redux UI Resource pack is not installed. Xenon Redux UI cannot function without it.");
    			disable = true;
    		}
    
    		if (disable === true || (worldScripts.XenonUI && (!worldScripts.Lib_GUI || this._enableLibGUIInt === false))) {
    			// disable this OXP if XenonUI is installed along with it, but Library GUI isn't there to mediate.
    			delete this.startUpComplete;
    			delete this.guiScreenChanged;
    			delete this.playerWillSaveGame;
    			delete this.missionScreenEnded;
    			delete this.gameResumed;
    			delete this.startUp;
    			return;
    		}
    
    		var lib = worldScripts.Lib_GUI;
    
    		if (missionVariables.XenonReduxUI_ActiveMode) this._activeMode = (this._trueValues.indexOf(missionVariables.XenonReduxUI_ActiveMode) >= 0 ? true : false);
    		if (missionVariables.XenonReduxUI_DisableOverlays) this._disableOverlays = (this._trueValues.indexOf(missionVariables.XenonReduxUI_DisableOverlays) >= 0 ? true : false);
    		// only reload the amber setting if lib config is present - otherwise we'll just take the preset value
    		if (lib) {
    			if (missionVariables.XenonReduxUI_Amber) this._amber = (this._trueValues.indexOf(missionVariables.XenonReduxUI_Amber) >= 0 ? true : false);
    			this._lastAmber = this._amber;
    		}
    		if (!lib || lib.$cur === "XenonReduxUI") this.$updateGuiColorSettings();
    
    		if (worldScripts["BGS"]) this._useBGS = "BGS";
    		if (worldScripts["market_observer3"]) this._marketObserverInstalled = true;
    		if (worldScripts["hdbg"]) this._hdbgActive = true;
    
    		if (lib && this._enableLibGUIInt === true) {
    			// flag some screens as readonly
    			this._addedID["oolite-contracts-parcels-none"] = 1;
    			this._addedID["oolite-contracts-parcels-details"] = 1;
    			this._addedID["oolite-contracts-parcels-summary"] = 1;
    			this._addedID["oolite-contracts-passengers-none"] = 1;
    			this._addedID["oolite-contracts-passengers-details"] = 1;
    			this._addedID["oolite-contracts-passengers-summary"] = 1;
    			this._addedID["oolite-contracts-cargo-none"] = 1;
    			this._addedID["oolite-contracts-cargo-details"] = 1;
    			this._addedID["oolite-contracts-cargo-summary"] = 1;
    			this._addedID["oolite-primablemanager"] = 1;
    			this._addedID["oolite-register"] = 1;
    			this._addedID["Lib_Config"] = 1;
    
    			// disable our standard functions so LibGUI can take over
    			this.$previous_guiScreenChanged = this.guiScreenChanged;
    			delete this.guiScreenChanged;
    			delete this.missionScreenEnded;
    			delete this.gameResumed;
    			delete this.startUp;
    			this.$libGUISetup();
    		}
    
    		// if we don't have library to orchestrate backgrounds, disable "better screens" so xenon UI has priority
    		// otherwise, we end up with a clash of different background sets
    		if (!lib && worldScripts["smivs_screen-backgrounds_worldscript"]) {
    			worldScripts["smivs_screen-backgrounds_worldscript"].hide_guiScreenChanged = worldScripts["smivs_screen-backgrounds_worldscript"].guiScreenChanged;
    			delete worldScripts["smivs_screen-backgrounds_worldscript"].guiScreenChanged;
    		}
    
    		this.$addStandardMissionScreenOverlays();
    		this.$addStandardMissionScreenExceptions();
    
    		// make Ship's library compatible with XenonUI
    		if (worldScripts["Ships Library"] && !this._xn) {
    			var sl = worldScripts["Ships Library"];
    			sl._showPage = this._showPage;
    		}
    		if (worldScripts.sothis_tc && !this._xn) {
    			var stc = worldScripts.sothis_tc;
    			stc.missionScreenOpportunity = this._sothis_missionScreenOpportunity;
    		}
    	}
    
    	//-------------------------------------------------------------------------------------------------------------
    	this.startUpComplete = function () {
    		// register our settings, if Lib_Config is present
    		if (worldScripts.Lib_Config) {
    			worldScripts.Lib_Config._registerSet(this._xenonReduxUIConfig);
    			if (!worldScripts.XenonUI) this.$setBGSDefaultBackgrounds();
    		}
    	}
    
    	//-------------------------------------------------------------------------------------------------------------
    	this.guiScreenChanged = function (to, from) {
    
    		var p = player.ship;
    
    		var imagetype = "redux";
    		var redalert = "";
    		var nohud = "";
    		var imagename = "";
    		var startTimer = false;
    		var overlay = "";
    
    		if (this._marketObserverInstalled) {
    			if (from == "GUI_SCREEN_MARKET" || from == "GUI_SCREEN_MARKETINFO" || to == "GUI_SCREEN_MARKET" || to == "GUI_SCREEN_MARKETINFO")
    				// Because market observer uses a specialised HUD a slightly incorrect background image was being selected.
    				// This was unnoticable if the "allow_big_gui" was not enabled on the default HUD, but quite noticeable on the Xenon HUD.
    				// So we start a timer to force the correct background after Market Observer has set or reset the HUD.
    				startTimer = true;
    		}
    
    		// fix for the issue where exiting the ship library screen could sometimes result in the wrong background being displayed
    		// this would only be apparent with HUD's that don't implement the "allow_big_gui" setting.
    		if (from == "GUI_SCREEN_SHIPLIBRARY" && p && p.docked) startTimer = true;
    
    		if (p.alertCondition == 3) redalert = "_redalert";
    		if (p.hudHidden) nohud = "_nohud";
    		if (this.$isBigGuiActive() == true) nohud = "_nohud";
    
    		switch (guiScreen) {
    			case "GUI_SCREEN_MAIN":
    				return;
    			case "GUI_SCREEN_KEYBOARD":
    				if (this._disableOverlays === false) overlay = "xrui-keyboard.png";
    				break;
    			case "GUI_SCREEN_STICKMAPPER":
    				if (this._disableOverlays === false) overlay = "xrui-gamepad.png";
    				break;
    			case "GUI_SCREEN_OPTIONS":
    				if (this._disableOverlays === false) overlay = "xrui-settings.png";
    				break;
    			case "GUI_SCREEN_LOAD":
    				if (this._disableOverlays === false) overlay = "xrui-load.png";
    				break;
    			case "GUI_SCREEN_SAVE":
    			case "GUI_SCREEN_SAVE_OVERWRITE":
    				if (this._disableOverlays === false) overlay = "xrui-save.png";
    				break;
    			case "GUI_SCREEN_EQUIP_SHIP":
    				if (this._disableOverlays === false) overlay = "xrui-equipship.png";
    				break;
    			case "GUI_SCREEN_INTERFACES":
    				if (this._disableOverlays === false) overlay = "xrui-interfaces.png";
    				break;
    			case "GUI_SCREEN_STATUS":
    				// override BGS status and nocrowd image, if installed.
    				if (worldScripts["BGS-M"]) {
    					worldScripts["BGS-M"].bgsI.status = {
    						name: "xenon_" + imagetype + "_" + nohud + redalert + ".png",
    						height: 546
    					};
    					worldScripts["BGS-M"].bgsI.noCrowd = {
    						name: "xenon_" + imagetype + "_" + nohud + redalert + ".png",
    						height: 546
    					};
    				}
    				/*if (this._disableOverlays === false) {
    					if (this.$playerHasDamagedEquipment() === true) {
    						overlay = "xrui-warning.png";
    					} else {
    						overlay = "xrui-ok.png";
    					}
    				}*/
    				break;
    			case "GUI_SCREEN_MANIFEST":
    				if (this._disableOverlays === false) overlay = "xrui-clipboard.png";
    				break;
    			case "GUI_SCREEN_SHORT_RANGE_CHART":
    				break;
    			case "GUI_SCREEN_LONG_RANGE_CHART":
    				// override BGS lrc image, if installed.
    				if (worldScripts["BGS-M"]) {
    					worldScripts["BGS-M"].bgsI.lrc = {
    						name: "xenon_" + imagetype + nohud + redalert + ".png",
    						height: 546
    					};
    				}
    				break;
    			case "GUI_SCREEN_SYSTEM_DATA":
    				var sysinf = System.infoForSystem(galaxyNumber, p.targetSystem);
    				if (sysinf["sun_gone_nova"] || sysinf["sun_going_nova"]) imagename += "_nova";
    				break;
    			case "GUI_SCREEN_MARKET":
    				if (this._marketObserverInstalled) imagename += "_wide";
    				if (this._disableOverlays === false) overlay = "xrui-market.png";
    				break;
    			case "GUI_SCREEN_MARKETINFO":
    				if (this._marketObserverInstalled) imagename += "_wide";
    				if (this._disableOverlays === false) overlay = "xrui-tag.png";
    				break;
    			case "GUI_SCREEN_REPORT":
    				if (worldScripts.hdbg) return;
    				if (this._disableOverlays === false) overlay = "xrui-report.png";
    				if (this._hdbgActive === true) return;
    				break;
    			case "GUI_SCREEN_MISSION":
    				// look for any exceptions and jump out if found
    				if (this._disableMissionScreen.indexOf(mission.screenID) != -1) imagename = "disable";
    				// check if we have an overlay to apply to this mission screen
    				if (this._disableOverlays == false && this._disableMissionScreen.indexOf(mission.screenID) === -1) {
    					if (this._missionOverlay[mission.screenID]) overlay = this._missionOverlay[mission.screenID];
    				}
    				break;
    		}
    
    		// build the filename if it hasn't been disabled
    		if (imagename != "disable") {
    			imagename = (this._amber === true ? "amber" : "xenon") + "_" + imagetype + imagename + nohud + redalert + ".png";
    			// load the image to the background
    			setScreenBackground({
    				name: imagename,
    				height: 546
    			});
    		}
    		if (overlay != "") setScreenOverlay({
    			name: overlay,
    			height: 546
    		});
    
    		// start a timer to force the background, if required
    		if (startTimer) {
    			if (this._chartExitScreenTimer && this._chartExitScreenTimer.isRunning) this._chartExitScreenTimer.stop();
    			this._chartExitScreenTimer = new Timer(this, this.$addBackground, 0.25, 0);
    		}
    	}
    
    	//-------------------------------------------------------------------------------------------------------------
    	this.playerWillSaveGame = function () {
    		missionVariables.XenonReduxUI_ActiveMode = this._activeMode;
    		missionVariables.XenonReduxUI_DisableOverlays = this._disableOverlays;
    		missionVariables.XenonReduxUI_Amber = this._amber;
    	}
    
    	//-------------------------------------------------------------------------------------------------------------
    	this.missionScreenEnded = function () {
    		this.guiScreenChanged("", "");
    	}
    
    	//-------------------------------------------------------------------------------------------------------------
    	this.gameResumed = function () {
    		this.guiScreenChanged("", "");
    	}
    
    	//-------------------------------------------------------------------------------------------------------------
    	// adds overlays to the standard mission screens
    	this.$addStandardMissionScreenOverlays = function $addStandardMissionScreenOverlays() {
    		this.$addMissionOverlay("oolite-contracts-parcels-none", "xrui-briefcase.png");
    		this.$addMissionOverlay("oolite-contracts-parcels-summary", "xrui-briefcase.png");
    		this.$addMissionOverlay("oolite-contracts-passengers-none", "xrui-boardingpass.png");
    		this.$addMissionOverlay("oolite-contracts-passengers-summary", "xrui-boardingpass.png");
    		this.$addMissionOverlay("oolite-contracts-cargo-none", "xrui-cargo.png");
    		this.$addMissionOverlay("oolite-contracts-cargo-summary", "xrui-cargo.png");
    		this.$addMissionOverlay("oolite-primablemanager", "xrui-switch.png");
    		this.$addMissionOverlay("oolite-register", "xrui-register.png");
    	}
    
    	//-------------------------------------------------------------------------------------------------------------
    	// adds map screen exceptions for known screen ID's
    	this.$addStandardMissionScreenExceptions = function $addStandardMissionScreenExceptions() {
    		// each of these items can't be set using setScreenBackground - needs to be done via the plist file
    		this.$addMissionScreenException("oolite-contracts-parcels-details");
    		this.$addMissionScreenException("oolite-contracts-passengers-details");
    		this.$addMissionScreenException("oolite-contracts-cargo-details");
    		this.$addMissionScreenException("rrs_mission_map");
    		this.$addMissionScreenException("blackmonks-map");
    		this.$addMissionScreenException("ups-map");
    		this.$addMissionScreenException("escort-contracts");
    		if (worldScripts.Random_Hits) {
    			var ver = worldScripts.Random_Hits.version.split(".");
    			if (parseInt(ver[0]) > 1 ||
    				(parseInt(ver[0]) === 1 && parseInt(ver[1])) > 11 ||
    				(parseInt(ver[0]) === 1 && parseInt(ver[1]) === 11 && parseInt(ver[2]) > 2)) {
    				this.$addMissionScreenException("random_hits_map");
    			} else {
    				this.$addMissionScreenException("random_hits");
    			}
    		}
    	}
    
    	//-------------------------------------------------------------------------------------------------------------
    	// callback handler for when settings are changed
    	this.$changeSettings = function $changeSettings() {
    		var lib = worldScripts.Lib_GUI;
    		if (this._amber != this._lastAmber) {
    			this.$libGUISetup();
    			this._lastAmber = this._amber;
    		}
    		if (lib.$cur === "XenonReduxUI") {
    			if (global.setScreenBackgroundForKey) this.$setBackgroundDefaults(true);
    			this.$updateGuiColorSettings();
    		}
    		/*if (this._disableOverlays === true) {
    			if (this._enableLibGUIInt === true && lib && lib.$cur === "XenonReduxUI") {
    				var keys = Object.keys(this._missionOverlay);
    				for (var i = 0; i < keys.length; i++) {
    					if (!this._addedID[keys[i]] || this._addedID[keys[i]] === 2) {
    						if (!lib.$IDRules[keys[i]]) {
    							this._addedID[keys[i]] = 2;
    							this.$passConfig(keys[i]);
    						}
    						lib.$IDRules[keys[i]] = {
    							pic: 1,
    							ov: 0
    						};
    					}
    				}
    			}
    		} else {
    			if (this._enableLibGUIInt === true && lib && lib.$cur === "XenonReduxUI") {
    				var keys = Object.keys(this._missionOverlay);
    				for (var i = 0; i < keys.length; i++) {
    					if (!this._addedID[keys[i]] || this._addedID[keys[i]] === 2) {
    						if (!lib.$IDRules[keys[i]]) {
    							this._addedID[keys[i]] = 2;
    							this.$passConfig(keys[i]);
    						}
    						lib.$IDRules[keys[i]] = {
    							pic: 1,
    							ov: 1
    						};
    					}
    				}
    			}
    		}*/
    		// remove any background that we added forcefully
    		/*if (lib.$cur === "XenonReduxUI" && this._activeMode === false) {
    			for (var i = 0; i < this._backgroundOverride.length; i++) {
    				//delete lib.$IDs.XenonReduxUI[this._backgroundOverride[i]];
    				if (!this._addedID[this._backgroundOverride[i]] || this._addedID[this._backgroundOverride[i]] === 2) {
    					delete lib.$IDRules[this._backgroundOverride[i]];
    				}
    			}
    		}*/
    		// reset our monitoring array regardless of which gui is active
    		if (this._activeMode === false) this._backgroundOverrride = [];
    
    		this.$setupGeneralOverlays();
    	}
    
    	//-------------------------------------------------------------------------------------------------------------
    	// sets up the LibGUI parameters
    	this.$libGUISetup = function $libGUISetup() {
    
    		var lib = worldScripts.Lib_GUI;
    		// setup some event callbacks
    		this.guiScreenChanged = this.$guiScreenChanged;
    		//this.equipmentDamaged = this.$equipmentDamaged;
    		//this.equipmentRepaired = this.$equipmentRepaired;
    		//this.equipmentAdded = this.$equipmentAdded;
    		//this.equipmentRemoved = this.$equipmentRemoved;
    		this.missionScreenEnded = this.$missionScreenEnded;
    
    		var style = (this._amber === true ? "amber" : "xenon");
    
    		lib.$guis.XenonReduxUI = {
    			GUI_SCREEN_GAMEOPTIONS: {
    				pic: {
    					name: style + "_redux.png",
    					height: 546
    				},
    				picBig: {
    					name: style + "_redux_nohud.png",
    					height: 546
    				},
    				picFlight: {
    					name: style + "_redux.png",
    					height: 546
    				},
    				picRed: {
    					name: style + "_redux_redalert.png",
    					height: 546
    				},
    				sndRef: this._useBGS
    			},
    			GUI_SCREEN_LOAD: {
    				pic: {
    					name: style + "_redux.png",
    					height: 546
    				}
    			},
    			GUI_SCREEN_SAVE: {
    				pic: {
    					name: style + "_redux.png",
    					height: 546
    				}
    			},
    			GUI_SCREEN_SAVE_OVERWRITE: {
    				pic: {
    					name: style + "_redux.png",
    					height: 546
    				}
    			},
    			GUI_SCREEN_EQUIP_SHIP: {
    				pic: {
    					name: style + "_redux.png",
    					height: 546
    				},
    				picBig: {
    					name: style + "_redux_nohud.png",
    					height: 546
    				},
    				sndRef: this._useBGS
    			},
    			GUI_SCREEN_INTERFACES: {
    				pic: {
    					name: style + "_redux.png",
    					height: 546
    				},
    				picBig: {
    					name: style + "_redux_nohud.png",
    					height: 546
    				},
    				sndRef: this._useBGS
    			},
    			GUI_SCREEN_KEYBOARD: {
    				pic: {
    					name: style + "_redux_nohud.png",
    					height: 546
    				},
    				picFlight: {
    					name: style + "_redux_nohud.png",
    					height: 546
    				}
    			},
    			GUI_SCREEN_MANIFEST: {
    				pic: {
    					name: style + "_redux.png",
    					height: 546
    				},
    				picBig: {
    					name: style + "_redux_nohud.png",
    					height: 546
    				},
    				picFlight: {
    					name: style + "_redux.png",
    					height: 546
    				},
    				picRed: {
    					name: style + "_redux_redalert.png",
    					height: 546
    				},
    				sndRef: this._useBGS
    			},
    			GUI_SCREEN_MARKET: {
    				pic: {
    					name: style + "_redux" + (this._marketObserverInstalled === true ? "_wide" : "") + ".png",
    					height: 546
    				},
    				picBig: {
    					name: style + "_redux" + (this._marketObserverInstalled === true ? "_wide" : "") + "_nohud.png",
    					height: 546
    				},
    				picFlight: {
    					name: style + "_redux" + (this._marketObserverInstalled === true ? "_wide" : "") + ".png",
    					height: 546
    				},
    				picRed: {
    					name: style + "_redux" + (this._marketObserverInstalled === true ? "_wide" : "") + "_redalert.png",
    					height: 546
    				},
    				sndRef: this._useBGS
    			},
    			GUI_SCREEN_MARKETINFO: {
    				pic: {
    					name: style + "_redux" + (this._marketObserverInstalled === true ? "_wide" : "") + ".png",
    					height: 546
    				},
    				picBig: {
    					name: style + "_redux" + (this._marketObserverInstalled === true ? "_wide" : "") + "_nohud.png",
    					height: 546
    				},
    				picFlight: {
    					name: style + "_redux" + (this._marketObserverInstalled === true ? "_wide" : "") + ".png",
    					height: 546
    				},
    				picRed: {
    					name: style + "_redux" + (this._marketObserverInstalled === true ? "_wide" : "") + "_redalert.png",
    					height: 546
    				},
    				sndRef: this._useBGS
    			},
    			GUI_SCREEN_OPTIONS: {
    				pic: {
    					name: style + "_redux.png",
    					height: 546
    				},
    				picBig: {
    					name: style + "_redux_nohud.png",
    					height: 546
    				},
    				picFlight: {
    					name: style + "_redux.png",
    					height: 546
    				},
    				picRed: {
    					name: style + "_redux_redalert.png",
    					height: 546
    				},
    				sndRef: this._useBGS
    			},
    			GUI_SCREEN_SHIPLIBRARY: {
    				pic: {
    					name: style + "_redux_nohud.png",
    					height: 546
    				}
    			},
    			GUI_SCREEN_SHIPYARD: {
    				pic: {
    					name: style + "_redux.png",
    					height: 546
    				},
    				picBig: {
    					name: style + "_redux_nohud.png",
    					height: 546
    				},
    				sndRef: this._useBGS
    			},
    			GUI_SCREEN_STATUS: {
    				pic: {
    					name: style + "_redux.png",
    					height: 546
    				},
    				picBig: {
    					name: style + "_redux_nohud.png",
    					height: 546
    				},
    				picFlight: {
    					name: style + "_redux.png",
    					height: 546
    				},
    				picRed: {
    					name: style + "_redux_redalert.png",
    					height: 546
    				},
    				sndRef: this._useBGS
    			},
    			GUI_SCREEN_STICKMAPPER: {
    				pic: {
    					name: style + "_redux.png",
    					height: 546
    				},
    				picBig: {
    					name: style + "_redux_nohud.png",
    					height: 546
    				},
    				picFlight: {
    					name: style + "_redux.png",
    					height: 546
    				},
    				sndRef: this._useBGS
    			},
    			GUI_SCREEN_STICKPROFILE: {
    				pic: {
    					name: style + "_redux.png",
    					height: 546
    				},
    				picBig: {
    					name: style + "_redux_nohud.png",
    					height: 546
    				},
    				picFlight: {
    					name: style + "_redux.png",
    					height: 546
    				},
    				sndRef: this._useBGS
    			},
    			GUI_SCREEN_SYSTEM_DATA: {
    				pic: {
    					name: style + "_redux.png",
    					height: 546
    				},
    				picBig: {
    					name: style + "_redux_nohud.png",
    					height: 546
    				},
    				picNova: {
    					name: style + "_redux_nova.png",
    					height: 546
    				},
    				picNovaBig: {
    					name: style + "_redux_nova_nohud.png",
    					height: 546
    				},
    				picFlight: {
    					name: style + "_redux.png",
    					height: 546
    				},
    				picRed: {
    					name: style + "_redux_redalert.png",
    					height: 546
    				},
    				picNovaRed: {
    					name: style + "_redux_nova_redalert.png",
    					height: 546
    				},
    				sndRef: this._useBGS
    			},
    			GUI_SCREEN_SHORT_RANGE_CHART: {
    				pic: {
    					name: style + "_redux.png",
    					height: 546
    				},
    				picBig: {
    					name: style + "_redux_nohud.png",
    					height: 546
    				},
    				picFlight: {
    					name: style + "_redux.png",
    					height: 546
    				},
    				picRed: {
    					name: style + "_redux_redalert.png",
    					height: 546
    				},
    				sndRef: this._useBGS
    			},
    			GUI_SCREEN_LONG_RANGE_CHART: {
    				pic: {
    					name: style + "_redux.png",
    					height: 546
    				},
    				picBig: {
    					name: style + "_redux_nohud.png",
    					height: 546
    				},
    				picFlight: {
    					name: style + "_redux.png",
    					height: 546
    				},
    				picRed: {
    					name: style + "_redux_redalert.png",
    					height: 546
    				},
    				sndRef: this._useBGS
    			},
    		};
    
    		if (this._hdbgActive === false) {
    			lib.$guis.XenonReduxUI.generic = {
    				pic: {
    					name: style + "_redux.png",
    					height: 546
    				},
    				sndRef: this._useBGS
    			};
    			lib.$guis.XenonReduxUI.GUI_SCREEN_REPORT = {
    				pic: {
    					name: style + "_redux.png",
    					height: 546
    				},
    				picBig: {
    					name: style + "_redux_nohud.png",
    					height: 546
    				},
    				sndRef: this._useBGS
    			};
    		}
    
    		this.$setupVariableScreens();
    		this.$setupGeneralOverlays();
    
    		// mission screen IDs
    		lib.$IDs.XenonReduxUI = {
    			generic: {
    				pic: {
    					name: style + "_redux.png",
    					height: 546
    				},
    				picBig: {
    					name: style + "_redux_nohud.png",
    					height: 546
    				},
    				picFlight: {
    					name: style + "_redux.png",
    					height: 546
    				},
    				picRed: {
    					name: style + "_redux_redalert.png",
    					height: 546
    				},
    				sndRef: this._useBGS
    			}
    		};
    
    	}
    
    	//-------------------------------------------------------------------------------------------------------------
    	// adjust background images on F5 screen based on availability/status of equipment
    	this.$setupVariableScreens = function $setupVariableScreens() {
    		/*if (this._disableOverlays === false) {
    			if (this.$playerHasDamagedEquipment() === true) {
    				worldScripts.Lib_GUI.$guis.XenonReduxUI.GUI_SCREEN_STATUS["ov"] = {name:"xrui-warning.png", height:546};
    			} else {
    				worldScripts.Lib_GUI.$guis.XenonReduxUI.GUI_SCREEN_STATUS["ov"] = {name:"xrui-ok.png", height:546};
    			}
    		}*/
    	}
    
    	//-------------------------------------------------------------------------------------------------------------
    	// adjust overlay images on general (non-mission) screens
    	this.$setupGeneralOverlays = function $setupGeneralOverlays() {
    
    		var lib = worldScripts.Lib_GUI.$guis.XenonReduxUI;
    
    		if (this._disableOverlays) {
    			delete lib.GUI_SCREEN_GAMEOPTIONS["ov"];
    			delete lib.GUI_SCREEN_LOAD["ov"];
    			delete lib.GUI_SCREEN_SAVE["ov"];
    			delete lib.GUI_SCREEN_SAVE_OVERWRITE["ov"];
    			delete lib.GUI_SCREEN_EQUIP_SHIP["ov"];
    			delete lib.GUI_SCREEN_INTERFACES["ov"];
    			delete lib.GUI_SCREEN_KEYBOARD["ov"];
    			delete lib.GUI_SCREEN_MANIFEST["ov"];
    			delete lib.GUI_SCREEN_MARKET["ov"];
    			delete lib.GUI_SCREEN_MARKETINFO["ov"];
    			delete lib.GUI_SCREEN_OPTIONS["ov"];
    			delete lib.GUI_SCREEN_REPORT["ov"];
    			//delete lib.GUI_SCREEN_STATUS["ov"];
    			delete lib.GUI_SCREEN_STICKMAPPER["ov"];
    		} else {
    			lib.GUI_SCREEN_GAMEOPTIONS["ov"] = {
    				name: "xrui-settings.png",
    				height: 546
    			};
    			lib.GUI_SCREEN_LOAD["ov"] = {
    				name: "xrui-load.png",
    				height: 546
    			};
    			lib.GUI_SCREEN_SAVE["ov"] = {
    				name: "xrui-save.png",
    				height: 546
    			};
    			lib.GUI_SCREEN_SAVE_OVERWRITE["ov"] = {
    				name: "xrui-question.png",
    				height: 546
    			};
    			lib.GUI_SCREEN_EQUIP_SHIP["ov"] = {
    				name: "xrui-equipship.png",
    				height: 546
    			};
    			lib.GUI_SCREEN_INTERFACES["ov"] = {
    				name: "xrui-interfaces.png",
    				height: 546
    			};
    			lib.GUI_SCREEN_KEYBOARD["ov"] = {
    				name: "xrui-keyboard.png",
    				height: 546
    			};
    			lib.GUI_SCREEN_MANIFEST["ov"] = {
    				name: "xrui-clipboard.png",
    				height: 546
    			};
    			lib.GUI_SCREEN_MARKET["ov"] = {
    				name: "xrui-market.png",
    				height: 546
    			};
    			lib.GUI_SCREEN_MARKETINFO["ov"] = {
    				name: "xrui-tag.png",
    				height: 546
    			};
    			lib.GUI_SCREEN_OPTIONS["ov"] = {
    				name: "xrui-settings.png",
    				height: 546
    			};
    			if (this._hdbgActive === false) lib.GUI_SCREEN_REPORT["ov"] = {
    				name: "xrui-report.png",
    				height: 546
    			};
    			lib.GUI_SCREEN_STICKMAPPER["ov"] = {
    				name: "xrui-gamepad.png",
    				height: 546
    			};
    		}
    	}
    
    	//-------------------------------------------------------------------------------------------------------------
    	// alternate version for use with Lib_GUI
    	this.$missionScreenEnded = function $missionScreenEnded() {
    		var lib = worldScripts.Lib_GUI;
    		if (this._guiActive != lib.$cur && (this._guiActive === "XenonReduxUI" || lib.$cur === "XenonReduxUI")) {
    			if (lib.$cur === "XenonReduxUI") {
    				// if we've got it available (v1.85/86) then force the default screen background to be Xenon Redux
    				if (global.setScreenBackgroundForKey) this.$setBackgroundDefaults(true);
    				this.$updateGuiColorSettings();
    				for (var i = 0; i < this._disableMissionScreen.length; i++) {
    					if (!this._addedID[this._disableMissionScreen[i]] || this._addedID[this._disableMissionScreen[i]] === 2) {
    						if (!lib.$IDRules[this._disableMissionScreen[i]]) {
    							this._addedID[this._disableMissionScreen[i]] = 2;
    							this.$passConfig(this._disableMissionScreen[i]);
    							lib.$IDRules[this._disableMissionScreen[i]] = {
    								mpic: 0
    							};
    						}
    						/*lib.$IDRules[this._disableMissionScreen[i]] = {
    							mpic: 0
    						};*/
    					}
    				}
    				var keys = Object.keys(this._missionOverlay);
    				for (var i = 0; i < keys.length; i++) {
    					// update Lib_GUI with our settings for mission screens
    					if (!this._addedID[keys[i]] || this._addedID[keys[i]] === 2) {
    						if (!lib.$IDRules[keys[i]]) {
    							this._addedID[keys[i]] = 2;
    							this.$passConfig(keys[i]);
    							if (this._missionOverlay[keys[i]] != "") {
    								if (this._disableOverlays === true) {
    									lib.$IDRules[keys[i]] = {
    										pic: 1,
    										ov: 0
    									};
    								} else {
    									lib.$IDRules[keys[i]] = {
    										pic: 1,
    										ov: 1
    									};
    								}
    							} else {
    								lib.$IDRules[keys[i]] = {
    									pic: 1
    								};
    							}
    						}
    						/*if (this._missionOverlay[keys[i]] != "") {
    							if (this._disableOverlays === true) {
    								lib.$IDRules[keys[i]] = {
    									pic: 1,
    									ov: 0
    								};
    							} else {
    								lib.$IDRules[keys[i]] = {
    									pic: 1,
    									ov: 1
    								};
    							}
    						} else {
    							lib.$IDRules[keys[i]] = {
    								pic: 1
    							};
    						}*/
    					}
    				}
    			} else {
    				// if we've got it available (v1.85/86) then reset the default screen backgrounds to be what it was previously
    				if (global.setScreenBackgroundForKey) this.$setBackgroundDefaults(false);
    				/*var items = Object.keys(this._addedID);
    				for (var i = 0; i < items.length; i++) {
    					if (this._addedID[items[i]] === 2) {
    						delete lib.$IDRules[items[i]];
    					}
    				}*/
    			}
    			this._guiActive = lib.$cur;
    		}
    	}
    
    	//-------------------------------------------------------------------------------------------------------------
    	// activated when Library GUI is in use
    	// gets any unrecorded mission ScreenID's add add them to the list of rules to use Xenon
    	this.$guiScreenChanged = function $guiScreenChanged(to, from) {
    		if (guiScreen === "GUI_SCREEN_STATUS") {
    			// this bit should only be run once after load
    			if (this._guiActive === "") {
    				// force all the screen rego stuff to happen if xenon was set after loading
    				if (worldScripts.Lib_GUI.$cur === "XenonReduxUI") this.missionScreenEnded();
    				// make sure our local copy gets updated
    				this._guiActive = worldScripts.Lib_GUI.$cur;
    			}
    		}
    
    		if (guiScreen === "GUI_SCREEN_MISSION" && this._guiActive === "XenonReduxUI" && this._activeMode === true) {
    			if (mission.screenID && mission.screenID != "" && this._disableMissionScreen.indexOf(mission.screenID) === -1) {
    				this.$addMissionOverlay(mission.screenID, null);
    				// make a note of any screen we add this way
    				if (this._backgroundOverride.indexOf(mission.screenID) === -1) this._backgroundOverride.push(mission.screenID);
    				// force an update
    				worldScripts.Lib_GUI.guiScreenChanged();
    			}
    			// we'll try to override LibGUI if a mission screen is displayed without a screenID
    			if (!mission.screenID) {
    				this.$previous_guiScreenChanged(to, from);
    			}
    		}
    	}
    
    	//-------------------------------------------------------------------------------------------------------------
    	// activated when Library GUI is in use
    	this.$equipmentAdded = function $equipmentAdded(equipmentKey) {
    		this.$setupVariableScreens();
    	}
    
    	//-------------------------------------------------------------------------------------------------------------
    	// activated when Library GUI is in use
    	this.$equipmentRemoved = function $equipmentRemoved(equipmentKey) {
    		this.$setupVariableScreens();
    	}
    
    	//-------------------------------------------------------------------------------------------------------------
    	// activated when Library GUI is in use
    	this.$equipmentDamaged = function $equipmentDamaged(equipmentKey) {
    		this.$setupVariableScreens();
    	}
    
    	//-------------------------------------------------------------------------------------------------------------
    	// activated when Library GUI is in use
    	this.$equipmentRepaired = function $equipmentRepaired(equipmentKey) {
    		this.$setupVariableScreens();
    	}
    
    	//-------------------------------------------------------------------------------------------------------------
    	// forces a background after the timer has expired
    	// used when mission screens exit to the short or long range chart.
    	this.$addBackground = function $addBackground() {
    		this.guiScreenChanged("", "");
    	}
    
    	//-------------------------------------------------------------------------------------------------------------
    	// returns true if a HUD with allowBigGUI is enabled, otherwise false
    	this.$isBigGuiActive = function $isBigGuiActive() {
    		if (oolite.compareVersion("1.83") <= 0) {
    			return player.ship.hudAllowsBigGui;
    		} else {
    			var bigGuiHUD = ["XenonHUD.plist", "coluber_hud_ch01-dock.plist"]; // until there is a property we can check, I'll be listing HUD's that have the allow_big_gui property set here
    			if (bigGuiHUD.indexOf(player.ship.hud) >= 0) {
    				return true;
    			} else {
    				return false;
    			}
    		}
    	}
    
    	//-------------------------------------------------------------------------------------------------------------
    	// returns true if any of the visible equipment items are damaged
    	this.$playerHasDamagedEquipment = function $playerHasDamagedEquipment() {
    		var p = player.ship;
    		var eq = p.equipment;
    		for (var i = 0; i < eq.length; i++) {
    			var itm = eq[i];
    			if (itm.isVisible === true && p.equipmentStatus(itm.equipmentKey) === "EQUIPMENT_DAMAGED") return true;
    		}
    		return false;
    	}
    
    	//-------------------------------------------------------------------------------------------------------------
    	this.$setBackgroundDefaults = function $setBackgroundDefaults(onOff) {
    		if (onOff === true) {
    			this._defaultBG["long_range_chart_mission"] = getScreenBackgroundForKey("long_range_chart_mission");
    			this._defaultBG["short_range_chart_mission"] = getScreenBackgroundForKey("short_range_chart_mission");
    			this._defaultBG["custom_chart_mission"] = getScreenBackgroundForKey("custom_chart_mission");
    			this._defaultBG["long_range_chart"] = getScreenBackgroundForKey("long_range_chart");
    			this._defaultBG["short_range_chart"] = getScreenBackgroundForKey("short_range_chart");
    			this._defaultBG["keyboardsettings"] = getScreenBackgroundForKey("keyboardsettings");
    			this._defaultBG["load_save"] = getScreenBackgroundForKey("load_save");
    			this._defaultBG["mount_weapon"] = getScreenBackgroundForKey("mount_weapon");
    			this._defaultBG["newgame"] = getScreenBackgroundForKey("newgame");
    			this._defaultBG["settings"] = getScreenBackgroundForKey("settings");
    			this._defaultBG["shiplibrary"] = getScreenBackgroundForKey("shiplibrary");
    
    			var nohud = "";
    			if (this.$isBigGuiActive() === true) nohud = "_nohud";
    
    			var style = (this._amber === true ? "amber" : "xenon");
    
    			var imagename = style + "_redux" + nohud + ".png";
    			setScreenBackgroundForKey("short_range_chart_mission", {
    				name: imagename,
    				height: 546
    			});
    			setScreenBackgroundForKey("long_range_chart_mission", {
    				name: imagename,
    				height: 546
    			});
    			setScreenBackgroundForKey("short_range_chart", {
    				name: imagename,
    				height: 546
    			});
    			setScreenBackgroundForKey("long_range_chart", {
    				name: imagename,
    				height: 546
    			});
    
    			setScreenBackgroundForKey("keyboardsettings", {
    				name: style + "_redux_nohud.png",
    				height: 546
    			});
    			setScreenBackgroundForKey("load_save", {
    				name: style + "_redux.png",
    				height: 546
    			});
    			setScreenBackgroundForKey("mount_weapon", {
    				name: style + "_redux.png",
    				height: 546
    			});
    			setScreenBackgroundForKey("newgame", {
    				name: style + "_redux_nohud.png",
    				height: 546
    			});
    			setScreenBackgroundForKey("settings", {
    				name: style + "_redux.png",
    				height: 546
    			});
    			setScreenBackgroundForKey("shiplibrary", {
    				name: style + "_redux_nohud.png",
    				height: 546
    			});
    		} else {
    			var keys = Object.keys(this._defaultBG);
    			for (var i = 0; i < keys.length; i++) {
    				var bg = getScreenBackgroundForKey(keys[i]);
    				// are xenon's backgrounds still set?
    				if (bg.hasOwnProperty("name") === true && bg.name.indexOf(style + "_redux") >= 0) {
    					// ok, we can reset things now
    					setScreenBackgroundForKey(keys[i], this._defaultBG[keys[i]]);
    				}
    			}
    		}
    	}
    
    	//-------------------------------------------------------------------------------------------------------------
    	this.$updateGuiColorSettings = function $updateGuiColorSettings() {
    		if (global.setGuiColorSettingForKey) {
    			global.setGuiColorSettingForKey("screen_divider_color", (this._amber === false ? "0 74 127 200" : "127 74 0 200"));
    			global.setGuiColorSettingForKey("screen_title_color", (this._amber === false ? "0 148 255 200" : "255 148 0 200"));
    		}
    	}
    
    	//-------------------------------------------------------------------------------------------------------------
    	this.$setBGSDefaultBackgrounds = function $setBGSDefaultBackgrounds() {
    		// until BGS has something similar
    		if (worldScripts.Lib_GUI.$cur == "BGS" && global.setGuiColorSettingForKey) {
    			setGuiColorSettingForKey("screen_title_color", "0.9 0.9 0.8");
    			setGuiColorSettingForKey("screen_divider_color", "0.0 0.0 0.0 0.0");
    
    			setScreenBackgroundForKey("paused_docked_overlay", "bgs_ov_paused.png");
    			setScreenBackgroundForKey("paused_overlay", "bgs_ov_paused.png");
    			setScreenBackgroundForKey("intro", "bgs_intro.png");
    			setScreenBackgroundForKey("keyboardsettings", "bgs_fullscr.png");
    			setScreenBackgroundForKey("load_save", "bgs_options.png");
    			setScreenBackgroundForKey("newgame", "bgs_intro.png");
    			setScreenBackgroundForKey("oxz-manager", "bgs_fullscr.png");
    			setScreenBackgroundForKey("settings", "bgs_options.png");
    			setScreenBackgroundForKey("shiplibrary", "bgs_fullscr.png");
    			setScreenBackgroundForKey("long_range_chart_mission", "lib_black.png");
    			setScreenBackgroundForKey("short_range_chart_mission", "lib_black.png");
    		}
    	}
    
    	//-------------------------------------------------------------------------------------------------------------
    	// used to allow XenonUI and XenonReduxUI to co-exist
    	this.$xenonCrossConfig = function $xenonCrossConfig(screenID) {
    		this._addedID[screenID] = 2;
    	}
    	this.$passConfig = function $passConfig(screenID) {
    		if (this._xn) this._xn.$xenonCrossConfig(screenID);
    	}
    
    	//-------------------------------------------------------------------------------------------------------------
    	// to make Ships Library compatible with XenonUI
    	this._showPage = function() {
    		var chapter = this.$contents[this.$chapter];
    	
    		var text = this._textFromOffset(this.$chapter,this.$offset,this.$msStore,this.$msRows,this.$msCols);
    		
    		var opts = {
    			screenID: "ships-library",
    			titleKey: chapter.key+"-title",
    			allowInterrupt: true,
    			exitScreen: "GUI_SCREEN_INTERFACES",
    			choices: {
    				"01_PREV":expandMissionText("ships-library-page-back"),
    				"09_NEXT":expandMissionText("ships-library-page-next"),
    				"10_CONTENTS":expandMissionText("ships-library-contents"),
    				"99_EXIT":expandMissionText("ships-library-exit"),
    			},
    			initialChoicesKey: this.$lastchoice?this.$lastchoice:"09_NEXT",
    			message: text
    		};
    		if (chapter.opts) {
    			var extras = Object.keys(chapter.opts)
    			for (var k=0;k<extras.length;k++) {
    				opts[extras[k]] = chapter.opts[extras[k]];
    			}
    		}
    		if (chapter.backgrounds) {
    			var page = this._pageOfOffset(chapter,this.$offset,this.$msStore);
    			if (page < chapter.backgrounds.length) {
    				var backg = chapter.backgrounds[page];
    			} else {
    				var backg = chapter.backgrounds[chapter.backgrounds.length-1];
    			}
    			if (backg != "") {
    				opts.overlay = backg;
    			}
    		}
    	
    		mission.runScreen(opts,this._manualHandler,this);
    		this.$fcbM = addFrameCallback(this._moveShip.bind(this));
    	
    	}
    
    	//-------------------------------------------------------------------------------------------------------------
    	// to make Sothis TC compatible with XenonUI
    	this._sothis_missionScreenOpportunity = function() {
    		if (!this.$showWelcome) return;
    		var messText = expandDescription("[STC_welcome]");
    		if (this.$new_cargoes)
    			messText = messText + expandDescription("[STC_new_cargoes]");	
    		var tcbgpic = "OOmap_G"+(galaxyNumber+1)+".png";
    		mission.runScreen({
    			title: "Sothis Trade Center",
    			message: messText,
    			overlay: tcbgpic
    		});
    		this.$showWelcome = false;
    	}
    
    }).call(this);
    Scripts/xenonreduxui_compatibility.js
    "use strict";
    this.name = "XenonReduxUI_Compatibility";
    this.author = "phkb";
    this.copyright = "2021 phkb";
    this.description = "OXP Compatibility function overrides";
    this.licence = "CC BY-NC-SA 3.0";
    
    this.startUp = function () {
        // if xenon UI is also installed, then let it do this work.
        if (worldScripts.XenonUI) return;
    
        // make Ship's library compatible
        if (worldScripts["Ships Library"] && worldScripts["Ships Library"].version == "0.8") {
            var sl = worldScripts["Ships Library"];
            sl._showPage = this._showPage;
        }
        // make sothis tc compatible
        if (worldScripts.sothis_tc && worldScripts.sothis_tc.version == "1.0.3") {
            var stc = worldScripts.sothis_tc;
            stc.missionScreenOpportunity = this._sothis_missionScreenOpportunity;
        }
        // make New Cargoes compatible
        if (worldScripts["CargoTypeExtension-Auctions"] && worldScripts["CargoTypeExtension-Auctions"].version == "1.2.3") {
            worldScripts["CargoTypeExtension-Auctions"].runOffer = this._auctions_runOffer;
            worldScripts["CargoTypeExtension-Auctions"].endAuction = this._auctions_endAuction;
            worldScripts["CargoTypeExtension-Auctions"].playSantaariAuction = this.playSantaariAuction;
            worldScripts["CargoTypeExtension-Auctions"].playAngianaAuction = this.playAngianaAuction;
            worldScripts["CargoTypeExtension-Auctions"].playColesqueAuction = this.playColesqueAuction;
            worldScripts["CargoTypeExtension-Auctions"].playJaftraAuction = this.playJaftraAuction;
            worldScripts["CargoTypeExtension-Auctions"].playLaratanAuction = this.playLaratanAuction;
            worldScripts["CargoTypeExtension-Auctions"].playProximusAuction = this.playProximusAuction;
            worldScripts["CargoTypeExtension-Auctions"].playSolansAuction = this.playSolansAuction;
            worldScripts["CargoTypeExtension-Auctions"].playXrataAuction = this.playXrataAuction;
            worldScripts["CargoTypeExtension"].startTrading = this.startTrading;
            worldScripts["CargoTypeExtension"].showBuyScreen = this.showBuyScreen;
            worldScripts["CargoTypeExtension"].showNoBuyScreen = this.showNoBuyScreen;
            worldScripts["CargoTypeExtension"].showSellScreen = this.showSellScreen;
            worldScripts["CargoTypeExtension"].showNoSellScreen = this.showNoSellScreen;
            worldScripts["CargoTypeExtension"].gatherInformation = this.gatherInformation;
            worldScripts["CargoTypeExtension"].gatherInformation2 = this.gatherInformation2;
            worldScripts["CargoTypeExtension"].tradeFloor = this.tradeFloor;
            worldScripts["CargoTypeExtension"].tradeFloorEncounter = this.tradeFloorEncounter;
            worldScripts["CargoTypeExtension"].detailedManifest = this.detailedManifest;
            worldScripts["CargoTypeExtension"].permitListing = this.permitListing;
            worldScripts["CargoTypeExtension"].readTraderNet = this.readTraderNet;
            worldScripts["CargoTypeExtension-FetchContracts"].runNewOffer = this.runNewOffer;
            worldScripts["CargoTypeExtension-FetchContracts"].newOfferChoice = this.newOfferChoice;
            worldScripts["CargoTypeExtension-FetchContracts"].runOldOffer = this.runOldOffer;
            worldScripts["CargoTypeExtension-FetchContracts"].oldOfferChoice = this.oldOfferChoice;
            worldScripts["CargoTypeExtension-OpenContract"].runOffer = this._contract_runOffer;
            worldScripts["CargoTypeExtension-OpenContract"].dealOpenC = this.dealOpenC;
            worldScripts["CargoTypeExtension-OpenContract"].openContractWin = this.openContractWin;
            worldScripts["CargoTypeExtension-OpenContract"].openContractLose = this.openContractLose;
            worldScripts["CargoTypeExtension-Permits"].runOffer = this._permits_runOffer;
            worldScripts["CargoTypeExtension-Permits"].permitDealings = this.permitDealings;
            worldScripts["CargoTypeExtension-Scavenger"].runOffer = this._scavenger_runOffer;
            worldScripts["CargoTypeExtension-Scavenger"].dealScavenger = this.dealScavenger;
        }
        // make Iron Raven compatible
        if (worldScripts["IR-main-script.js"] && worldScripts["IR-main-script.js"].version == "1.4.2.1") {
            worldScripts["IR-main-script.js"].questionScreens = this.questionScreens;
            worldScripts["IR-main-script.js"].shipDockedWithStation = this._ir_shipDockedWithStation;
            worldScripts["IR-main-script.js"].missionScreens = this.missionScreens;
            worldScripts["IR-main-script.js"].choiceEvaluation = this.choiceEvaluation;
        }
    }
    
    //-------------------------------------------------------------------------------------------------------------
    // to make Ships Library compatible
    this._showPage = function () {
        var chapter = this.$contents[this.$chapter];
    
        var text = this._textFromOffset(this.$chapter, this.$offset, this.$msStore, this.$msRows, this.$msCols);
    
        var opts = {
            screenID: "ships-library",
            titleKey: chapter.key + "-title",
            allowInterrupt: true,
            exitScreen: "GUI_SCREEN_INTERFACES",
            choices: {
                "01_PREV": expandMissionText("ships-library-page-back"),
                "09_NEXT": expandMissionText("ships-library-page-next"),
                "10_CONTENTS": expandMissionText("ships-library-contents"),
                "99_EXIT": expandMissionText("ships-library-exit"),
            },
            initialChoicesKey: this.$lastchoice ? this.$lastchoice : "09_NEXT",
            message: text
        };
        if (chapter.opts) {
            var extras = Object.keys(chapter.opts)
            for (var k = 0; k < extras.length; k++) {
                opts[extras[k]] = chapter.opts[extras[k]];
            }
        }
        if (chapter.backgrounds) {
            var page = this._pageOfOffset(chapter, this.$offset, this.$msStore);
            if (page < chapter.backgrounds.length) {
                var backg = chapter.backgrounds[page];
            } else {
                var backg = chapter.backgrounds[chapter.backgrounds.length - 1];
            }
            if (backg != "") {
                opts.overlay = backg;
            }
        }
    
        mission.runScreen(opts, this._manualHandler, this);
        this.$fcbM = addFrameCallback(this._moveShip.bind(this));
    
    }
    
    //-------------------------------------------------------------------------------------------------------------
    // to make Sothis TC compatible
    this._sothis_missionScreenOpportunity = function () {
        if (!this.$showWelcome) return;
        var messText = expandDescription("[STC_welcome]");
        if (this.$new_cargoes)
            messText = messText + expandDescription("[STC_new_cargoes]");
        var tcbgpic = "OOmap_G" + (galaxyNumber + 1) + ".png";
        mission.runScreen({
            title: "Sothis Trade Center",
            message: messText,
            overlay: tcbgpic
        });
        this.$showWelcome = false;
    }
    
    //-------------------------------------------------------------------------------------------------------------
    // to make New Cargoes compatible
    this._auctions_runOffer = function () {
        var auc = this.activeAuction();
        var msg = "Welcome, Trader. Bidding doesn't start until " + clock.clockStringForTime(auc.time) + ", so feel free to get your ship and credit ready before we start. We've got " + auc.quantity + " TC of " + worldScripts["CargoTypeExtension"].cargoDefinition(auc.cargo, "specificType") + " to sell.\n\nRemember, you must have sufficient cargo space to take the goods, and cover all fees and bids from your current credits.\n\nWe'll be using " + this.auctionTypeName(auc.atype) + " bidding:\n" + expandDescription("[cte_auc_rules" + auc.atype + "]");
        mission.runScreen({
            title: this.traderName(),
            message: msg,
            overlay: "cte_auction.png",
            choicesKey: "cte_auc_opening"
        }, this.checkAuction, this);
    }
    
    this._auctions_endAuction = function () {
        mission.runScreen({
            title: "Auction over",
            overlay: "cte_auction.png",
            message: this.auctionmessage + "\nThe auction is over."
        });
        this.localAuctioneer();
    }
    
    this.playSantaariAuction = function () {
        if (this.currentauction.quantity < 1) {
            this.endAuction();
        } else {
            var title = this.currentauction.quantity + " TC of " + worldScripts["CargoTypeExtension"].cargoDefinition(this.currentauction.cargo, "specificType");
            var msg = "Auction: Santaari (" + this.blockSize(this.currentauction) + " TC blocks)\n";
            if (this.auctionmessage != "") {
                msg += "* " + this.auctionmessage + "\n";
                this.auctionmessage = "";
            }
            msg += this.auctionStatus();
            mission.runScreen({
                title: title,
                overlay: "cte_auction.png",
                message: msg,
                choicesKey: "cte_auc_santaari_bid"
            }, this.choiceSantaariAuction, this);
        }
    }
    
    this.playColesqueAuction = function () {
        if (this.currentauction.quantity < 1) {
            this.endAuction();
        } else {
            var title = this.currentauction.quantity + " TC of " + worldScripts["CargoTypeExtension"].cargoDefinition(this.currentauction.cargo, "specificType");
            var msg = "Auction: Colesque (minimum increment " + this.colesqueIncrement(this.currentbid) + "₢)\n";
            if (this.auctionmessage != "") {
                msg += "* " + this.auctionmessage + "\n";
                this.auctionmessage = "";
            }
            msg += this.auctionStatus();
            mission.runScreen({
                title: title,
                overlay: "cte_auction.png",
                message: msg,
                choicesKey: "cte_auc_colesque_bid"
            }, this.choiceColesqueAuction, this);
        }
    }
    
    this.playLaratanAuction = function () {
        if (this.lastcall == 6) {
            this.endLaratanAuction();
        } else {
            var title = this.currentauction.quantity + " TC of " + worldScripts["CargoTypeExtension"].cargoDefinition(this.currentauction.cargo, "specificType");
            var msg = "You: " + player.ship.cargoSpaceAvailable + " TC free, " + player.credits.toFixed(1) + "₢ available\n";
            msg += "Auction: Lara'tan (ticket price " + this.currentbid + "₢)\n";
            msg += "Round " + this.lastcall + "/5\n";
    
            msg += "-----------------------------------\n";
            for (var i = 0; i < this.currentbidders.length; i++) {
                var line = this.currentbidders[i].name + ": ";
                if (this.currentbidders[i].lastbid == 0) {
                    line += "no bid";
                } else {
                    line += this.currentbidders[i].lastbid + " ticket(s)";
                }
                line += "\n";
                msg += line;
            }
            var line = "Commander " + player.name + ": ";
            if (this.playerbid == 0) {
                line += "no bid";
            } else {
                line += this.playerbid + " ticket(s)";
            }
            line += "\n";
            msg += line;
    
            mission.runScreen({
                title: title,
                overlay: "cte_auction.png",
                message: msg,
                choicesKey: "cte_auc_laratan_bid"
            }, this.choiceLaratanAuction, this);
        }
    }
    
    this.playAngianaAuction = function () {
        if (this.currentauction.quantity < 1) {
            this.endAuction();
        } else {
            var title = this.currentauction.quantity + " TC of " + worldScripts["CargoTypeExtension"].cargoDefinition(this.currentauction.cargo, "specificType");
            var msg = "Auction: Angiana (minimum increment " + this.colesqueIncrement(this.currentbid) + "₢, buyout " + this.angianaBuyout() + "₢/TC)\n";
            if (this.auctionmessage != "") {
                msg += "* " + this.auctionmessage + "\n";
                this.auctionmessage = "";
            }
            msg += this.auctionStatus();
            mission.runScreen({
                title: title,
                overlay: "cte_auction.png",
                message: msg,
                choicesKey: "cte_auc_angiana_bid"
            }, this.choiceAngianaAuction, this);
        }
    }
    
    this.playProximusAuction = function () {
        if (this.currentauction.quantity < 1) {
            this.endAuction();
        } else {
            var title = this.currentauction.quantity + " TC of " + worldScripts["CargoTypeExtension"].cargoDefinition(this.currentauction.cargo, "specificType");
            var msg = "Auction: Proximus (minimum increment " + this.colesqueIncrement(this.currentbid) + "₢)\n";
            if (this.auctionmessage != "") {
                msg += "* " + this.auctionmessage + "\n";
                this.auctionmessage = "";
            }
            msg += this.auctionStatus();
            mission.runScreen({
                title: title,
                overlay: "cte_auction.png",
                message: msg,
                choicesKey: "cte_auc_proximus_bid"
            }, this.choiceProximusAuction, this);
        }
    }
    
    this.playSolansAuction = function () {
        if (this.currentauction.quantity < 1) {
            this.endAuction();
        } else {
            var title = this.currentauction.quantity + " TC of " + worldScripts["CargoTypeExtension"].cargoDefinition(this.currentauction.cargo, "specificType");
            var msg = "Auction: Solans (increment " + this.colesqueIncrement(this.currentbid) + "₢)\n";
            if (this.auctionmessage != "") {
                msg += "* " + this.auctionmessage + "\n";
                this.auctionmessage = "";
            }
            msg += this.auctionStatus();
            mission.runScreen({
                title: title,
                overlay: "cte_auction.png",
                message: msg,
                choicesKey: "cte_auc_solans_bid"
            }, this.choiceSolansAuction, this);
        }
    }
    
    this.playJaftraAuction = function () {
        if (this.currentauction.quantity < 1) {
            this.endAuction();
        } else {
            var title = this.currentauction.quantity + " TC of " + worldScripts["CargoTypeExtension"].cargoDefinition(this.currentauction.cargo, "specificType");
            var msg = "Auction: Jaftra\n";
            if (this.auctionmessage != "") {
                msg += "* " + this.auctionmessage + "\n";
                this.auctionmessage = "";
            }
            msg += this.auctionStatus();
            mission.runScreen({
                title: title,
                overlay: "cte_auction.png",
                message: msg,
                choicesKey: "cte_auc_jaftra_bid"
            }, this.choiceJaftraAuction, this);
        }
    }
    
    this.playXrataAuction = function () {
        if (this.currentauction.quantity < 1) {
            this.endAuction();
        } else {
            var title = this.currentauction.quantity + " TC of " + worldScripts["CargoTypeExtension"].cargoDefinition(this.currentauction.cargo, "specificType");
            var msg = "Auction: Xrata (minimum increment " + this.colesqueIncrement(this.currentbid) + "₢)\n";
            if (this.auctionmessage != "") {
                msg += "* " + this.auctionmessage + "\n";
                this.auctionmessage = "";
            }
            msg += this.auctionStatus();
            mission.runScreen({
                title: title,
                overlay: "cte_auction.png",
                message: msg,
                choicesKey: "cte_auc_xrata_bid"
            }, this.choiceXrataAuction, this);
        }
    }
    
    this.startTrading = function () {
        var choices = "cte_initscreenchoice";
        if (missionVariables.cargotypeextension_tradernet && missionVariables.cargotypeextension_tradernet >= clock.days) {
            choices = "cte_initscreenchoice_wtn";
        }
    
        mission.runScreen({
                title: "Specialist Trade Goods Market",
                message: this.showManifest(),
                overlay: "cte_containers.png",
                choicesKey: choices
            },
            this.initScreenChoice, this);
    }
    
    this.showNoBuyScreen = function () {
        mission.runScreen({
                title: "Buy Specialist Trade Goods",
                overlay: "cte_containers.png",
                message: "No specialist trade goods available for purchase"
            },
            this.startTrading, this);
    }
    
    this.showBuyScreen = function () {
        var goods = this.stationMarket[this.pointer];
    
        mission.runScreen({
                title: "Buy " + this.specialCargoRegister[goods.type].specificType,
                overlay: "cte_containers.png",
                message: this.buyMessage(goods),
                choicesKey: "cte_buyscreenchoice",
                initialChoicesKey: this.lastscreenchoice
            },
            this.handleBuyDecision, this);
    }
    
    this.showNoSellScreen = function () {
        mission.runScreen({
                overlay: "cte_containers.png",
                title: "Sell Specialist Trade Goods",
                message: "No specialist trade goods in hold"
            },
            this.startTrading, this);
    }
    
    this.showSellScreen = function () {
        var goods = this.holdgoods[this.pointer];
        mission.runScreen({
                overlay: "cte_containers.png",
                title: "Sell " + this.specialCargoRegister[goods].specificType,
                message: this.sellMessage(goods),
                choicesKey: "cte_sellscreenchoice",
                initialChoicesKey: this.lastscreenchoice
            },
            this.handleSellDecision, this);
    }
    
    this.gatherInformation = function () {
        mission.runScreen({
                title: "Local imports/exports",
                overlay: "cte_tradefloor.png",
                message: this.localTradeGoods()
            },
            this.gatherInformation2, this);
    }
    
    this.gatherInformation2 = function () {
        mission.runScreen({
                title: "Gossip in the trade district",
                overlay: "cte_tradefloor.png",
                message: this.localGossip()
            },
            this.startTrading, this);
    }
    
    this.tradeFloor = function () {
        var choice = "cte_tradefloorchoice";
        this.debug("Building trade floor");
        var traders = new Array;
        var srole = "";
        if (player.ship.dockedStation != system.mainStation) {
            var srole = player.ship.dockedStation.primaryRole;
        }
        for (var i = 0; i < this.personalities.length; i++) {
            if (worldScripts[this.personalities[i]].traderHere && worldScripts[this.personalities[i]].traderHere(srole)) {
                traders.push(this.personalities[i]);
                this.debug(this.personalities[i] + " is present");
            }
        }
        if (traders.length == 0) {
            this.tradeflooractive = 0;
            mission.runScreen({
                    title: "No-one about",
                    overlay: "cte_tradefloor.png",
                    message: "The trade floor is deserted."
                },
                this.startTrading, this
            );
        } else {
            if (traders.length == 1) {
                choice = "cte_tradeflooronlychoice";
            }
            this.tradeFloorEncounter(traders[this.tradefloorpointer % traders.length], choice);
        }
    }
    
    this.tradeFloorEncounter = function (traderscript, choice) {
        var title = worldScripts[traderscript].traderName();
        var desc = worldScripts[traderscript].traderDesc();
    
        this.traderscript = traderscript;
        mission.runScreen({
            title: title,
            overlay: "cte_tradefloor.png",
            message: desc,
            choicesKey: choice
        }, this.tradeFloorChoice, this);
    }
    
    this.detailedManifest = function () {
        var manlines = this.detailedManifestLines();
        var maxlines = 15;
        if (manlines.length <= maxlines) {
            mission.runScreen({
                    title: "Detailed Manifest",
                    overlay: "cte_containers.png",
                    message: this.viewDetailedManifest(manlines, 0, maxlines),
                    choicesKey: "cte_manifestlast"
                },
                this.startTrading, this);
        } else {
            var pages = 1 + Math.floor((manlines.length - 1) / maxlines);
            var cpage = 1 + Math.floor((this.dmanoffset) / maxlines);
            var fn = this.startTrading;
            var choice = "cte_manifestlast";
            if (this.dmanoffset + maxlines < manlines.length) {
                fn = this.detailedManifest;
                var choice = "cte_manifestnext";
            }
            mission.runScreen({
                    title: "Detailed Manifest (" + cpage + "/" + pages + ")",
                    overlay: "cte_containers.png",
                    message: this.viewDetailedManifest(manlines, this.dmanoffset, maxlines),
                    choicesKey: choice
                },
                fn, this);
    
            this.dmanoffset += maxlines;
        }
    }
    
    this.permitListing = function () {
        var msg = "";
        for (var k = 0; k < this.permits.length; k++) {
            this.debug("Trying " + this.permits[k]);
            msg += worldScripts[this.permits[k]].describePermits();
        }
        for (var k = 0; k < this.personalities.length; k++) {
            this.debug("Trying " + this.personalities[k]);
            msg += worldScripts[this.personalities[k]].describeContracts();
        }
    
        if (msg == "") {
            msg = "You have no permits or active contracts, and no local regulations apply to trading.";
        }
        mission.runScreen({
                title: "Permits, Contracts and Regulations",
                overlay: "cte_permit.png",
                message: msg
            },
            this.startTrading, this);
    }
    
    this.readTraderNet = function () {
        var background = worldScripts["CargoTypeExtension-TraderNet"].getPic();
        var messages = worldScripts["CargoTypeExtension-TraderNet"].numMessages();
        if (messages == 0) {
            mission.runScreen({
                    title: "TraderNet News",
                    overlay: background,
                    message: "\n\n\n\n\n\n\n\nNo news available.",
                    choicesKey: "cte_tradernet_last"
                },
                this.startTrading, this);
        } else {
            if (this.tradernetpointer >= messages) {
                var article = worldScripts["CargoTypeExtension-TraderNet"].getMessage(messages);
                var ckey = "cte_tradernet_last";
            } else {
                var ckey = "cte_tradernet";
                var article = worldScripts["CargoTypeExtension-TraderNet"].getMessage(this.tradernetpointer++);
            }
            mission.runScreen({
                    title: "TraderNet News",
                    overlay: background,
                    message: "\n\n\n\n\n\n\n\n" + article,
                    choicesKey: ckey
                },
                function (choice) {
                    if (choice == "01_NEXT") {
                        this.readTraderNet();
                    } else {
                        this.startTrading();
                    }
                }, this);
        }
    }
    
    this.runNewOffer = function () {
        var offer = this.currentOffer();
        var msg = "This is a standard procurement contract - you bring me " + offer.amount + " TC of " + worldScripts["CargoTypeExtension"].cargoDefinition(offer.good, "specificType") + " by " + offer.deadline + ", at a rate of " + offer.price + "₢/TC.\nYou can bring them in more than one load, if you want, and how you obtain the goods is up to you.\nIf you fail to fulfil the contract, there will be a penalty charge of " + offer.price + "₢ for every TC you are short, to cover my risk of being short on what I need, so it's in your interests to have a good idea of how you're going to deliver the goods.\n";
    
        mission.runScreen({
            title: this.traderName(),
            message: msg,
            overlay: "cte_tradefloor.png",
            choicesKey: "cte_fetch_deal"
        }, this.newOfferChoice, this);
    }
    
    this.newOfferChoice = function (choice) {
        if (choice == "01_ACCEPT") {
            this.fetchContracts.push(this.localOffer);
            this.localOffer = false;
            var msg = "Thank you, Trader " + player.name + ". I look forward to you returning with the goods.";
        } else {
            var msg = "If you change your mind after a look at your charts, then I'll be around here for a little bit longer.";
        }
    
        mission.runScreen({
            title: this.traderName(),
            message: msg,
            overlay: "cte_tradefloor.png"
        }, this.leaveFetch, this);
    }
    
    this.runOldOffer = function () {
        var offer = this.currentOffer();
    
        var carried = worldScripts["CargoTypeExtension"].hasSpecialCargo(offer.good);
        if (carried == 0) {
            mission.runScreen({
                title: this.traderName(),
                message: "You don't seem to have any " + worldScripts["CargoTypeExtension"].cargoDefinition(offer.good, "specificType") + " in your hold right now, Trader. Remember, I still need you to deliver " + offer.amount + " TC by " + offer.deadline + ".",
                overlay: "cte_tradefloor.png"
            }, this.leaveFetch, this);
        } else {
            var msg = "Welcome back, Trader " + player.name + ". Your manifest indicates that you have " + carried + " TC of " + worldScripts["CargoTypeExtension"].cargoDefinition(offer.good, "specificType") + " in your hold. Would you like to transfer them now, for the agreed price of " + offer.price + "₢ up to the " + offer.amount + " TC remaining on this contract?";
            mission.runScreen({
                title: this.traderName(),
                message: msg,
                overlay: "cte_tradefloor.png",
                choicesKey: "cte_fetch_transfer"
            }, this.oldOfferChoice, this);
        }
    }
    
    this.oldOfferChoice = function (choice) {
        if (choice != "01_ACCEPT") {
            mission.runScreen({
                title: this.traderName(),
                message: "Don't forget to drop them off here before you leave, then!",
                overlay: "cte_tradefloor.png"
            }, this.leaveFetch, this);
            return;
        }
    
        var offer = this.currentOffer();
        var transferred = 0;
        while (offer.amount > 0 && worldScripts["CargoTypeExtension"].hasSpecialCargo(offer.good) > 0) {
            if (worldScripts["CargoTypeExtension"].removeSpecialCargo(offer.good)) {
                transferred++;
                offer.amount--;
            } else {
                worldScripts["CargoTypeExtension"].error("Unable to transfer expected good in fetch contract?!");
                player.consoleMessage("Warning: Unexpected error in NewCargoes OXP. Please see Latest.Log");
                return;
            }
        }
    
        var price = offer.price * transferred;
        var msg = "Thank you. " + transferred + " TC has been transferred, and " + price + "₢ has been credited to your account.\n";
        player.credits += price;
    
        if (offer.amount > 0) {
            msg += offer.amount + " TC remain to be delivered by " + offer.deadline + ", Trader - I hope to see you back soon with more.";
        } else {
            msg += "Thank you, Trader. This is all of the goods we agreed. I hope to see you again soon.";
        }
        mission.runScreen({
            title: this.traderName(),
            message: msg,
            overlay: "cte_tradefloor.png"
        }, this.leaveFetch, this);
    }
    
    this._contract_runOffer = function () {
        var price = worldScripts["CargoTypeExtension"].cargoPriceExport("CTE_CTOC_1", 15, worldScripts["CargoTypeExtension"].defaultMarketInfo()) / 10;
        var totalprice = price * this.contractdata.amount;
    
        if (player.ship.cargoSpaceCapacity < this.contractdata.amount) {
            var msg = "Trader, I appreciate your enthusiasm, but unfortunately my buyer isn't interested in partial deliveries. Come back and see me when you've got a proper freighter.";
    
            if (player.ship.equipmentStatus("EQ_HYPERCARGO") === "EQUIPMENT_OK" || player.ship.equipmentStatus("EQ_MULTIBAY") === "EQUIPMENT_OK") {
                msg = "Unfortunately, Trader, my buyer is somewhat old-fashioned, and doesn't approve of all these new hyperspatial storage arrangements. I'm afraid I can only offer this contract to people with a sufficiently large primary cargo bay.";
            }
            mission.runScreen({
                title: this.traderName(),
                overlay: "cte_tradefloor.png",
                message: msg
            }, this.leaveOpenC, this);
    
        } else if (player.ship.cargoSpaceAvailable < this.contractdata.amount) {
            var msg = "I'm sorry, Trader. You'll need to free up some hold space before we can discuss this contract.";
    
            if (player.ship.equipmentStatus("EQ_HYPERCARGO") === "EQUIPMENT_OK" || player.ship.equipmentStatus("EQ_MULTIBAY") === "EQUIPMENT_OK") {
                msg = "Unfortunately, Trader, my buyer is somewhat old-fashioned, and doesn't approve of all these new hyperspatial storage arrangements. You'll have to reorganise your cargo to get enough space in the main hold area for the goods before I can transfer them.";
            }
    
            mission.runScreen({
                title: this.traderName(),
                overlay: "cte_tradefloor.png",
                message: msg
            }, this.leaveOpenC, this);
        } else if (totalprice > player.credits) {
            var msg = "I'm sorry, Trader. You don't have enough credits to afford the security deposit. Come back some day when you're a little richer.";
            mission.runScreen({
                title: this.traderName(),
                overlay: "cte_tradefloor.png",
                message: msg
            }, this.leaveOpenC, this);
    
        } else {
    
            var msg = "Here's the deal, " + player.name + ". I'll sell you " + this.contractdata.amount + " of " + this.contractdata.cargospecific + " for " + price.toFixed(1) + "₢/TC (" + totalprice + "₢) security deposit. When you get to " + System.infoForSystem(galaxyNumber, this.contractdata.dest).name + " station, " + this.contractdata.buyer + " will pay you over ten times that for delivery. I can't tell you the exact price, unfortunately, because that obsolete Galcop regulation is still being enforced. They'll then pay me the rest of the goods cost minus your delivery fee and the security deposit. Everyone's a winner.\n\nWhat's that? What's the catch? Well, you're not the only one taking this contract. " + this.contractdata.buyer + " is only going to pay the first one there, so you'll need to be fast. You're one of the first to show up, so your odds are pretty good.";
    
            if (player.ship.equipmentStatus("EQ_HYPERCARGO") === "EQUIPMENT_OK" || player.ship.equipmentStatus("EQ_MULTIBAY") === "EQUIPMENT_OK") {
                msg = "\n\nOh, by the way, Trader, my buyer is somewhat old-fashioned, and doesn't approve of all these new hyperspatial storage arrangements. For auditing purposes, you should keep the cargo in your main hold throughout the trip.";
            }
    
            mission.runScreen({
                title: this.traderName(),
                overlay: "cte_tradefloor.png",
                message: msg,
                choicesKey: "cte_oc_deal"
            }, this.dealOpenC, this);
        }
    }
    
    this.dealOpenC = function (choice) {
        if (choice == "01_DEAL") {
            var price = worldScripts["CargoTypeExtension"].cargoPriceExport("CTE_CTOC_1", 15, worldScripts["CargoTypeExtension"].defaultMarketInfo()) / 10;
            for (var i = 1; i <= this.contractdata.amount; i++) {
                worldScripts["CargoTypeExtension"].addSpecialCargo("CTE_CTOC_1", price.toFixed(1) + "₢ for open contract in " + system.info.name);
            }
            worldScripts["CargoTypeExtension"].debug(price + " " + this.contractdata.amount);
            player.credits = player.credits - (price * this.contractdata.amount);
            this.contractdata.active = 1;
    
            var msg = "Thank you, Trader. The cargo is being loaded on to your ship as we speak. I recommend you launch as soon as possible.";
            if (player.ship.equipmentStatus("EQ_HYPERCARGO") === "EQUIPMENT_OK" || player.ship.equipmentStatus("EQ_MULTIBAY") === "EQUIPMENT_OK") {
                msg += "\n\nRemember that the buyer doesn't approve of hyperspatial cargo storage. You can carry the cargo there in flight at your own risk if you must, but make sure that all the goods are in your primary cargo hold when you dock at the destination station, or they probably won't take them.";
            }
    
        } else {
            var msg = "Understood, Trader. Now, if you'll excuse me, I have a few other potential couriers to talk to. I'll still be here for a little while if you change your mind.";
        }
        mission.runScreen({
            title: this.traderName(),
            overlay: "cte_tradefloor.png",
            message: msg
        }, this.leaveOpenC, this);
    }
    
    this.openContractWin = function () {
        var price = worldScripts["CargoTypeExtension"].cargoPriceImport("CTE_CTOC_1", 15, worldScripts["CargoTypeExtension"].defaultMarketInfo()) / 10;
        var carried = worldScripts["CargoTypeExtension"].hasSpecialCargo("CTE_CTOC_1");
        var msg = "Welcome, Trader " + player.name + ". Let's see those " + this.contractdata.cargospecific + " then.\n\n";
        if (carried == this.contractdata.amount) {
            msg += "Ah, excellent. All present and correct. If you'll just authorise the cargo transfer, the " + price.toFixed(1) + " ₢/TC will be yours.";
    
        } else if (carried >= this.contractdata.amount) { // shouldn't be possible, in general. Well, they probably deserve a small bonus.
            msg += "Ah, excellent. All present and correct. If you'll just authorise the cargo transfer, the " + price.toFixed(1) + " ₢/TC will be yours. I'll take the spares off your hands for the same price, I think. Don't tell " + this.contractdata.seller + ", though, or they'll be wanting their cut.";
    
        } else if (carried > 0) {
            price = Math.floor(price * (carried / this.contractdata.amount));
            msg += "You appear to be missing some of the cargo I need. I'll take what you have off your hands, now it's here, but your payment has been reduced to " + price.toFixed(1) + " ₢/TC to account for my costs in obtaining replacements.";
        } else if (carried == 0) {
            msg += "Ah. Apologies. I seem to have been misinformed. I thought you were carrying some goods for me, but it must have been someone with a similar name.";
        }
    
        player.credits += price * carried;
        for (var i = 1; i <= carried; i++) {
            worldScripts["CargoTypeExtension"].removeSpecialCargo("CTE_CTOC_1");
        }
    
        this.contractdata.active = 0;
        mission.runScreen({
            title: this.contractdata.buyer,
            overlay: "cte_tradefloor.png",
            message: msg
        }, function () {}, this);
    }
    
    this.openContractLose = function () {
        this.contractdata.active = 0;
    
        var missed = clock.adjustedSeconds - this.contractdata.deadline;
        var msg = "You can't find " + this.contractdata.buyer + " when you dock. You ask the harbourmaster if they've seen them.\n\n"
        if (missed < 60) {
            msg += "You've literally just missed them. Some trader in a Boa Clipper was unloading cargo with them over there.";
        } else if (missed < 3600) {
            msg += "They were here a moment ago. I think they left a few minutes ago with a Boa II pilot.";
        } else if (missed < 86400) {
            msg += "I saw them around earlier today. An L-Crate full of cargo came in for them, I think, so they were supervising the unloading.";
        } else if (missed < (86400 * 7)) {
            msg += "Not for a few days, no. They were taking some cargo from a Boa planetside.";
        } else {
            msg += "No, they've not been up here for a while, not since that Anaconda came in last week.";
        }
    
        mission.runScreen({
            title: "Too late...",
            overlay: "cte_tradefloor.png",
            message: msg
        }, function () {}, this);
    }
    
    this._permits_runOffer = function () {
        if (player.ship.targetSystem == system.ID) {
            this.permitDealings("Please set your navigation computer's destination system to your desired importer.");
            return;
        }
        this.currentpermit = this.decodePermit(this.permitSeller.permitcode);
        this.currentpermit.good = this.permitSeller.good;
        this.currentpermit.dest = player.ship.targetSystem;
        this.currentpermit.real = this.permitSeller.real;
        this.currentpermit.deadline = this.calculatePermitDeadline(this.currentpermit.dest, this.currentpermit.timenoise);
        if (this.currentpermit.deadline == 0) {
            this.permitDealings("I'm afraid we don't have a trade agreement with " + System.infoForSystem(galaxyNumber, player.ship.targetSystem).name + ", Trader.");
            return;
        } else {
            var price = this.permitPrice(this.currentpermit);
            var desc = this.permitDescription(this.currentpermit);
            var msg = "We can offer the following permit:\n";
            msg += "-------------------------\n";
            msg += desc + "\n";
            msg += "-------------------------\n";
            msg += "Inclusive of all fees and taxes, this will cost " + price + "₢";
    
            mission.runScreen({
                title: this.traderName(),
                message: msg,
                choicesKey: "cte_permit_deal",
                overlay: "cte_permit.png"
            }, this.permitChoice, this);
        }
    }
    
    this.permitDealings = function (msg) {
        mission.runScreen({
            title: this.traderName(),
            message: msg,
            overlay: "cte_permit.png"
        }, this.permitExit, this);
    }
    
    this._scavenger_runOffer = function () {
        var scav = this.activeScavenger();
    
        var spec = worldScripts["CargoTypeExtension"].cargoDefinition(this.scavengerCargoes[scav], "specificType");
        var gen = worldScripts["CargoTypeExtension"].cargoDefinition(this.scavengerCargoes[scav], "genericType");
    
        var amount = worldScripts["CargoTypeExtension"].hasSpecialCargo(this.scavengerCargoes[scav]);
        if (amount == 0) {
            var msg = "I'm sorry, Trader. I'm sure the contents of your hold are fascinating to the right buyer, but I'm only looking for " + spec + ". I won't take up your time any further.";
            mission.runScreen({
                title: this.traderName(),
                overlay: "cte_tradefloor.png",
                message: msg
            }, this.leaveScavenger, this);
    
        } else {
            var price = Math.floor(1000 * amount * (Math.pow(amount, 0.25)));
            if (gen == "slaves" || gen == "narcotics" || gen == "firearms") {
                price *= 2; // illegal goods
            }
    
            var msg = "Excellent work, Trader. In exchange for the " + amount + " TC of " + spec + " in your hold, I will pay " + price + "₢. Do we have a deal?";
            mission.runScreen({
                title: this.traderName(),
                overlay: "cte_tradefloor.png",
                message: msg,
                choicesKey: "cte_scav_deal"
            }, this.dealScavenger, this);
        }
    }
    
    this.dealScavenger = function (choice) {
        if (choice == "01_DEAL") {
            var scav = this.activeScavenger();
            var gen = worldScripts["CargoTypeExtension"].cargoDefinition(this.scavengerCargoes[scav], "genericType");
    
            var amount = worldScripts["CargoTypeExtension"].hasSpecialCargo(this.scavengerCargoes[scav]);
            for (var i = 0; i < amount; i++) {
                worldScripts["CargoTypeExtension"].removeSpecialCargo(this.scavengerCargoes[scav]);
            }
            var price = Math.floor(1000 * amount * (Math.pow(amount, 0.25)));
            if (gen == "slaves" || gen == "narcotics" || gen == "firearms") {
                price *= 2; // illegal goods
            }
    
            player.credits += price;
    
            var msg = "A pleasure dealing with you, Trader. " + price + "₢ has been credited to your account. Contact me again if you find any more.";
    
        } else {
            var msg = "Your choice, but you won't find anyone else willing to pay this much. Come back when you've figured that out for yourself.";
        }
        mission.runScreen({
            title: this.traderName(),
            overlay: "cte_tradefloor.png",
            message: msg
        }, this.leaveScavenger, this);
    }
    
    //-------------------------------------------------------------------------------------------------------------
    // to make Iron Raven compatible
    this.questionScreens = function () {
        if (system.ID == 23) // Maenes
        {
            if (missionVariables.IR_status == "IR_IBANEZ_4") {
                this._runScreen({
                    title: "QuiCo Pharmaceuticals",
                    overlay: "IR_quico_logo.png",
                    messageKey: "IR_MAENES_intro",
                    choicesKey: "IR_questions"
                }, this.choiceEvaluation);
                missionVariables.IR_offer = "IR_MAENES_QUESTIONS"
            }
        }
    
        if (system.ID == 171) // Yokohama
        {
            if (missionVariables.IR_status == "IR_IBANEZ_4") {
                this._runScreen({
                    title: "Yokohama Exports",
                    overlay: "IR_yk_logo.png",
                    messageKey: "IR_YOKOHAMA_intro",
                    choicesKey: "IR_questions"
                }, this.choiceEvaluation);
                missionVariables.IR_offer = "IR_YOKOHAMA_QUESTIONS"
            }
        }
    
        if (system.ID == 232) //Janes
        {
            if (missionVariables.IR_status == "IR_IBANEZ_4") {
                this._runScreen({
                    title: "Janes's Shipyard Intelligence",
                    overlay: "IR_janes_logo.png",
                    messageKey: "IR_JANES_intro",
                    choicesKey: "IR_questions"
                }, this.choiceEvaluation);
                missionVariables.IR_offer = "IR_JANES_QUESTIONS"
            }
        }
    
        if (system.ID == 240) // Pirate Cove
        {
            if (missionVariables.IR_status == "IR_IBANEZ_4") {
                if (!missionVariables.IR_alsto) {
                    this._runScreen({
                        title: " ",
                        messageKey: "IR_PIRATE_intro",
                        choicesKey: "IR_questions"
                    }, this.choiceEvaluation);
                    missionVariables.IR_offer = "IR_PIRATE_QUESTIONS"
                    missionVariables.IR_alsto = "MET"
                } else {
                    this._runScreen({
                        title: " ",
                        messageKey: "IR_PIRATE_intro_alt",
                        choicesKey: "IR_questions"
                    }, this.choiceEvaluation);
                    missionVariables.IR_offer = "IR_PIRATE_QUESTIONS"
                }
            }
        }
    
        if (system.ID == 119) // PleasureWorld
        {
            if (missionVariables.IR_status == "IR_IBANEZ_4") {
                this._runScreen({
                    title: "PleasureWorld",
                    overlay: "IR_pw_logo.png",
                    messageKey: "IR_PW_intro",
                    choicesKey: "IR_questions"
                }, this.choiceEvaluation);
                missionVariables.IR_offer = "IR_PW_QUESTIONS"
            }
        }
    
        if (system.ID == 180) // NWE
        {
            if (missionVariables.IR_status == "IR_IBANEZ_4") {
                this._runScreen({
                    title: "Naval Weapons Establishment",
                    overlay: "IR_NWE_logo.png",
                    messageKey: "IR_NWE_intro",
                    choicesKey: "IR_questions"
                }, this.choiceEvaluation);
                missionVariables.IR_offer = "IR_NWE_QUESTIONS"
            }
        }
    
        if (system.ID == 219) // GSE
        {
            if (missionVariables.IR_status == "IR_IBANEZ_4") {
                this._runScreen({
                    title: "Galactic Stock Exchange",
                    overlay: "IR_GSE_logo.png",
                    messageKey: "IR_GSE_intro",
                    choicesKey: "IR_questions"
                }, this.choiceEvaluation);
                missionVariables.IR_offer = "IR_GSE_QUESTIONS"
            }
        }
    
        if (system.ID == 31) // KORSHKOV
        {
            if (missionVariables.IR_status == "IR_IBANEZ_4") {
                this._runScreen({
                    title: "OKB Korshkov",
                    overlay: "IR_korshlogo.png",
                    messageKey: "IR_KORSHKOV_intro",
                    choicesKey: "IR_questions"
                }, this.choiceEvaluation);
                missionVariables.IR_offer = "IR_KORSHKOV_QUESTIONS"
            }
        }
    }
    
    this._ir_shipDockedWithStation = function (station) {
        this.addIRinterface()
    
        if (missionVariables.IR_status == "IR_epilogue" && clock.days > missionVariables.IR_epilogue_deadline) {
            this._runScreen({
                messageKey: "IR_final",
                choicesKey: "IR_continue"
            }, function (choice) {
                if (choice == 1) {
                    this._runScreen({
                        overlay: "IR_title.png",
                        messageKey: "IR_theend"
                    });
                    missionVariables.IR_status = "IR_completed"
                    mission.setInstructionsKey(null)
                    missionVariables.IR_epilogue_deadline = null
                    missionVariables.IR_shipment_quest = null
                    missionVariables.IR_SDF_quest = null
                    missionVariables.IR_SDF_question_no = null
                    missionVariables.IR_SDF_question_key = null
                    missionVariables.IR_SDF_question_string = null
                    missionVariables.IR_defences_quest = null
                    missionVariables.IR_defences_question_no = null
                    missionVariables.IR_defences_question_key = null
                    missionVariables.IR_defences_question_string = null
                    missionVariables.IR_finance_quest = null
                    missionVariables.IR_finance_question_no = null
                    missionVariables.IR_finance_question_key = null
                    missionVariables.IR_finance_question_string = null
                    missionVariables.IR_shipment_quest_method = null
                    missionVariables.IR_shipment_question_no = null
                    missionVariables.IR_shipment_question_key = null
                    missionVariables.IR_shipment_question_string = null
                    missionVariables.IR_GSE_loan = null
                    missionVariables.IR_wife_status = null
                    missionVariables.IR_alsto = null
                    missionVariables.IR_count = null
                    missionVariables.IR_defences_kill_count = null
                    missionVariables.IR_SDF_quest_location = null
                    missionVariables.IR_SDF_quest_location_name = null
                    missionVariables.IR_KORSHKOV_deadline = null
                    missionVariables.IR_asked_question = null
                    missionVariables.IR_question_settings = null
                    missionVariables.IR_screen_log = null
                    missionVariables.IR_screen_location = null
                }
            });
        }
        if (player.ship.docked && galaxyNumber == 7) this.missionScreens();
    }
    
    this.missionScreens = function () {
        if (guiScreen == "GUI_SCREEN_MISSION" || !player.ship.docked)
            return;
    
        if (player.ship.dockedStation.hasRole("IR-luft-core")) {
            if (missionVariables.IR_SDF_quest == "JACOB" || missionVariables.IR_SDF_quest == "LUFTSLOTTE") {
                this._runScreen({
                    title: "Luftslotte 6",
                    messageKey: "IR_SDF_quest_4"
                })
                missionVariables.IR_SDF_quest = "KRAIT"
            }
        }
    
        if (player.ship.dockedStation.isMainStation && missionVariables.IR_offer == null) {
            if (missionVariables.IR_status == null) {
                this._runScreen({
                    overlay: "IR_title.png",
                    choicesKey: "IR_continue"
                }, function (choice) {
                    if (choice == 1) {
                        this._runScreen({
                            messageKey: "IR_IBANEZ_1"
                        });
                        mission.setInstructionsKey("IR_IBANEZ_INFO")
                        missionVariables.IR_status = "IR_IBANEZ_1"
                    }
                });
            }
    
            if (missionVariables.IR_finance_quest == "REPROCESSED" && clock.days >= missionVariables.IR_KORSHKOV_deadline) //this is 20 days
            {
                this._runScreen({
                    title: "Jane's Shipyard Intelligence",
                    messageKey: "IR_finance_quest_4"
                });
                missionVariables.IR_finance_quest = "JANES_NEWS"
                missionVariables.IR_KORSHKOV_deadline = null
                player.incrementFinanceStatus()
            }
    
            if (missionVariables.IR_SDF_quest == "ADDRESS" && clock.days >= missionVariables.IR_SDF_deadline) {
                this._runScreen({
                    messageKey: "IR_SDF_quest_2"
                });
                missionVariables.IR_SDF_quest = "JACOB"
                player.incrementSDFStatus()
            }
    
            if (missionVariables.IR_SDF_quest == "POD_SCOOPED") {
                this._runScreen({
                    messageKey: "IR_SDF_quest_5"
                });
                player.ship.useSpecialCargo("WARNING: Radiation detected in cargo hold")
                missionVariables.IR_SDF_quest = "KORSHKOV"
                player.incrementSDFStatus()
            }
    
            if (missionVariables.IR_SDF_quest == "PHOTO" && clock.days >= missionVariables.IR_SDF_deadline) {
                this._runScreen({
                    messageKey: "IR_SDF_quest_8a",
                    overlay: "IR_kinnaird.png",
                    choicesKey: "IR_continue"
                }, function (choice) {
                    if (choice == 1)
                        this._runScreen({
                            messageKey: "IR_SDF_quest_8b",
                            overlay: "IR_match.png",
                            choicesKey: "IR_continue"
                        }, function (choice) {
                            if (choice == 1) {
                                this._runScreen({
                                    messageKey: "IR_SDF_quest_8c"
                                });
                                missionVariables.IR_SDF_quest = "COMPLETED"
                                player.clearSDFStatus()
                                missionVariables.IR_SDF_status_no = null
                                missionVariables.IR_SDF_deadline = null
                                    ++missionVariables.IR_quest_count
                            }
                        });
                });
            }
    
            if (missionVariables.IR_finance_quest == "WAIT3" && clock.days >= missionVariables.IR_KORSHKOV_deadline) {
                this._runScreen({
                    title: " ",
                    overlay: "IR_bloomberg.png",
                    messageKey: "IR_finance_quest_10"
                });
                missionVariables.IR_KORSHKOV_deadline = null
                player.clearFinanceStatus()
                missionVariables.IR_finance_status_no = null
                missionVariables.IR_finance_quest = "COMPLETED"
                    ++missionVariables.IR_quest_count
            }
    
            if (missionVariables.IR_shipment_quest == "SUCCESS") {
                this._runScreen({
                    messageKey: "IR_shipment_success"
                });
                player.clearShipmentStatus()
                missionVariables.IR_shipment_status_no = null
                missionVariables.IR_shipment_quest = "COMPLETED"
                missionVariables.IR_YOKOHAMA_deadline = null
                    ++missionVariables.IR_quest_count
                missionVariables.IR_tipoff_deadline = clock.days + 10
            }
    
            if (missionVariables.IR_shipment_quest == "DISPATCHED") {
                this._runScreen({
                    messageKey: "IR_shipment_failure"
                });
                player.clearShipmentStatus()
                missionVariables.IR_shipment_status_no = null
                missionVariables.IR_shipment_quest = "FAILED"
                    ++missionVariables.IR_quest_count
                missionVariables.IR_YOKOHAMA_deadline = null
            }
    
            if (missionVariables.IR_shipment_quest == "COMPLETED") {
                if (clock.days >= missionVariables.IR_tipoff_deadline) {
                    this._runScreen({
                        messageKey: "IR_tipoff"
                    });
                    missionVariables.IR_tipoff_deadline = null
                    missionVariables.IR_shipment_quest = "TIPPEDOFF"
                }
            }
    
            if (missionVariables.IR_loan_deadline) {
                if (clock.days >= missionVariables.IR_loan_deadline) {
                    this._runScreen({
                        title: "First Galactic Bank",
                        messageKey: "IR_GSE_loan_warning"
                    });
                    mission.setInstructionsKey(null)
                    missionVariables.IR_loan_deadline = null
                    missionVariables.IR_load_remaining = null
                    player.credits -= 550000
                    missionVariables.IR_GSE_loan = "DEFAULTED"
                }
            }
    
            if (missionVariables.IR_defences_quest == "DEMO_6" && clock.days > missionVariables.IR_defences_quest_deadline) {
                this._runScreen({
                    messageKey: "IR_defences_quest_6"
                });
                ++missionVariables.IR_quest_count
                missionVariables.IR_defences_quest = "COMPLETED"
                missionVariables.IR_defences_quest_deadline = null
                missionVariables.IR_defences_status_no = null
                player.clearDefencesStatus()
            }
    
            if (missionVariables.IR_status == "IR_KINNAIRD_2") {
                this._runScreen({
                    messageKey: "IR_kinnaird_3alt"
                });
            }
    
            if (missionVariables.IR_status == "IR_LEXICON_1" && clock.days > missionVariables.IR_LEXICON_deadline) {
                this._runScreen({
                    messageKey: "IR_LEXICON_2"
                });
                missionVariables.IR_status = "IR_LEXICON_2"
                mission.setInstructionsKey("IR_LEXICON_brief_2")
                missionVariables.IR_LEXICON_deadline = null
            }
    
            if (missionVariables.IR_status == "IR_CHERKASOVA_1") // briefing with Cherkasova
            {
                this._runScreen({
                    messageKey: "IR_CHERKASOVA_1a",
                    overlay: "IR_KSR_logo.png",
                    choicesKey: "IR_continue"
                }, function (choice) {
                    if (choice == 1)
                        this._runScreen({
                            messageKey: "IR_CHERKASOVA_1b",
                            overlay: "IR_KSR_logo.png",
                            choicesKey: "IR_continue"
                        }, function (choice) {
                            if (choice == 1)
                                this._runScreen({
                                    messageKey: "IR_CHERKASOVA_1c",
                                    overlay: "IR_KSR_logo.png",
                                    choicesKey: "IR_continue"
                                }, function (choice) {
                                    if (choice == 1)
                                        this._runScreen({
                                            messageKey: "IR_CHERKASOVA_1d",
                                            overlay: "IR_KSR_logo.png",
                                            choicesKey: "IR_cherkasova_choices"
                                        }, function (choice) {
                                            if (choice == 1) {
                                                this._runScreen({
                                                    messageKey: "IR_LOA_1",
                                                    overlay: "IR_KSR_logo.png"
                                                })
                                                mission.setInstructionsKey("IR_LOA_brief_1")
                                                missionVariables.IR_status = "IR_LOA_1"
                                                mission.setInstructionsKey("IR_LOA_brief_1")
                                                missionVariables.IR_cherkasova_deadline = null
                                            }
                                            if (choice == 2) {
                                                this._runScreen({
                                                    messageKey: "IR_sources_1",
                                                    overlay: "IR_KSR_logo.png"
                                                }) //screen fails to run
                                                mission.setInstructionsKey("IR_LEXICON_brief_1")
                                                missionVariables.IR_status = "IR_sources_1"
                                                missionVariables.IR_cherkasova_deadline = null
                                                mission.setInstructionsKey("IR_LEXICON_brief_1")
                                                missionVariables.IR_sources_deadline = clock.days + 15
                                            }
                                        });
                                });
                        });
                });
            }
    
            if (missionVariables.IR_status == "IR_sources_1" && clock.days > missionVariables.IR_sources_deadline) {
                this._runScreen({
                    messageKey: "IR_sources_2"
                });
                missionVariables.IR_status = "IR_sources_2"
                mission.setInstructionsKey("IR_waitforinfo_brief")
                missionVariables.IR_sources_deadline = clock.days + 7
            }
    
            if (missionVariables.IR_status == "IR_sources_2" && clock.days > missionVariables.IR_sources_deadline) {
                this._runScreen({
                    messageKey: "IR_sources_3"
                });
                missionVariables.IR_status = "IR_sources_3"
                missionVariables.IR_sources_deadline = null
                mission.setInstructionsKey("IR_sources_brief_1")
            }
    
            if (missionVariables.IR_status == "IR_LOA_4" && clock.days > missionVariables.IR_attack_deadline) {
                this._runScreen({
                    messageKey: "IR_LOA_5"
                });
                missionVariables.IR_status = "IR_LOA_5"
                missionVariables.IR_attack_deadline = null
                mission.setInstructionsKey("IR_LOA_brief_4")
            }
    
            if (missionVariables.IR_status == "IR_LOA_7" && clock.days > missionVariables.IR_epilogue_deadline) {
                this._runScreen({
                    messageKey: "IR_LOA_7"
                });
                missionVariables.IR_status = "IR_LOA_8"
                missionVariables.IR_epilogue_deadline = clock.days + 10
            }
    
            if (missionVariables.IR_status == "IR_LOA_8" && clock.days > missionVariables.IR_epilogue_deadline) {
                this._runScreen({
                    messageKey: "IR_LOA_8"
                });
                missionVariables.IR_status = "IR_LOA_9"
                missionVariables.IR_epilogue_deadline = clock.days + 7
            }
    
            if (missionVariables.IR_status == "IR_LOA_9" && clock.days > missionVariables.IR_epilogue_deadline) {
                this._runScreen({
                    messageKey: "IR_invite"
                });
                missionVariables.IR_status = "IR_invite"
                mission.setInstructionsKey("IR_invite_brief")
                missionVariables.IR_epilogue_deadline = null
            }
    
            if (missionVariables.IR_status == "IR_sources_6" && clock.days > missionVariables.IR_epilogue_deadline) {
                this._runScreen({
                    messageKey: "IR_sources_6"
                });
                missionVariables.IR_status = "IR_sources_7"
                missionVariables.IR_epilogue_deadline = clock.days + 15
            }
    
            if (missionVariables.IR_status == "IR_sources_7" && clock.days > missionVariables.IR_epilogue_deadline) {
                this._runScreen({
                    messageKey: "IR_invite"
                });
                missionVariables.IR_status = "IR_invite"
                mission.setInstructionsKey("IR_invite_brief")
                missionVariables.IR_epilogue_deadline = null
            }
    
            //Location Specific
            if (system.ID == 7) //Vegedius
            {
                if (missionVariables.IR_status == "IR_IBANEZ_1") {
                    this._runScreen({
                        title: "GalCop High Command",
                        messageKey: "IR_IBANEZ_2a",
                        choicesKey: "IR_continue"
                    }, function (choice) {
                        if (choice == 1)
                            this._runScreen({
                                title: "GalCop High Command",
                                messageKey: "IR_IBANEZ_2b",
                                choicesKey: "IR_continue"
                            }, function (choice) {
                                if (choice == 1) {
                                    this._runScreen({
                                        title: "GalCop High Command",
                                        messageKey: "IR_IBANEZ_2c"
                                    });
                                    missionVariables.IR_status = "IR_IBANEZ_2"
                                    mission.setInstructionsKey("IR_RAAED_INFO")
                                }
                            });
                    });
                }
    
                if (missionVariables.IR_status == "IR_RAAED_1") //return to Ibanez
                {
                    this._runScreen({
                        title: "Galcop High Command",
                        messageKey: "IR_IBANEZ_3"
                    })
                    missionVariables.IR_status = "IR_IBANEZ_3"
                    mission.setInstructionsKey("IR_JANES_INFO")
                }
    
    
                if (missionVariables.IR_status == "IR_JANES_1") // return to Ibanez for big briefing
                {
                    this._runScreen({
                        title: "GalCop High Command",
                        messageKey: "IR_IBANEZ_4a",
                        choicesKey: "IR_continue"
                    }, function (choice) {
                        if (choice == 1)
                            this._runScreen({
                                title: "GalCop High Command",
                                messageKey: "IR_IBANEZ_4b",
                                choicesKey: "IR_continue"
                            }, function (choice) {
                                if (choice == 1)
                                    this._runScreen({
                                        title: "GalCop High Command",
                                        messageKey: "IR_IBANEZ_4c",
                                        choicesKey: "IR_continue"
                                    }, function (choice) {
                                        if (choice == 1) {
                                            this._runScreen({
                                                title: "GalCop High Command",
                                                messageKey: "IR_IBANEZ_4d"
                                            });
                                            missionVariables.IR_status = "IR_IBANEZ_4"
                                            mission.setInstructionsKey(null)
                                            this.setupQuestions()
                                            this.setupStatus()
                                            missionVariables.IR_quest_count = 0
                                            this.addIRinterface();
                                        }
                                    });
                            });
                    });
                }
    
                if (missionVariables.IR_status == "IR_IBANEZ_4" && missionVariables.IR_quest_count == 4) {
                    missionVariables.IR_quest_count = null
    
                    if (missionVariables.IR_shipment_quest_method == "YOKOHAMA_AMBUSH") {
                        this._runScreen({
                            messageKey: "IR_IBANEZ_5a",
                            choicesKey: "IR_continue"
                        }, function (choice) {
                            if (choice == 1) {
                                this._runScreen({
                                    overlay: "IR_title.png",
                                    messageKey: "IR_theend"
                                });
                                missionVariables.IR_status = "IR_completed"
                                mission.setInstructionsKey(null)
                                missionVariables.IR_epilogue_deadline = null
                                missionVariables.IR_shipment_quest = null
                                missionVariables.IR_SDF_quest = null
                                missionVariables.IR_defences_quest = null
                                missionVariables.IR_finance_quest = null
                                missionVariables.IR_shipment_quest_method = null
                            }
                        });
                    }
    
                    if (missionVariables.IR_shipment_quest == "FAILED") {
                        this._runScreen({
                            messageKey: "IR_IBANEZ_5b",
                            choicesKey: "IR_continue"
                        }, function (choice) {
                            if (choice == 1) {
                                this._runScreen({
                                    overlay: "IR_title.png",
                                    messageKey: "IR_theend"
                                });
                                missionVariables.IR_status = "IR_completed"
                                mission.setInstructionsKey(null)
                                missionVariables.IR_epilogue_deadline = null
                                missionVariables.IR_shipment_quest = null
                                missionVariables.IR_SDF_quest = null
                                missionVariables.IR_defences_quest = null
                                missionVariables.IR_finance_quest = null
                                missionVariables.IR_shipment_quest_method = null
                            }
                        });
                    } else
                        this._runScreen({
                            title: "GalCop High Command",
                            messageKey: "IR_IBANEZ_5",
                            choicesKey: "IR_IBANEZ_choices"
                        }, function (choice) {
                            if (choice == "IR_IBANEZ_A_weiss") {
                                this._runScreen({
                                    title: "GalCop High Command",
                                    messageKey: "IR_weiss_1"
                                });
                                missionVariables.IR_status = "IR_WEISS_1"
                                mission.setInstructionsKey("IR_weiss_brief_1")
                            }
                            if (choice == "IR_IBANEZ_B_kinnaird") {
                                this._runScreen({
                                    title: "GalCop High Command",
                                    messageKey: "IR_kinnaird_1"
                                });
                                missionVariables.IR_status = "IR_KINNAIRD_1"
                                mission.setInstructionsKey("IR_kinnaird_brief_1")
                            }
                            if (choice == "IR_IBANEZ_C_moreinfo") {
                                this._runScreen({
                                    title: "GalCop High Command",
                                    messageKey: "IR_LEXICON_1"
                                });
                                missionVariables.IR_status = "IR_LEXICON_1"
                                mission.setInstructionsKey("IR_LEXICON_1")
                                missionVariables.IR_LEXICON_deadline = clock.days + 15
                            }
                        });
                }
    
                if (missionVariables.IR_status == "IR_WEISS_4" || missionVariables.IR_status == "IR_KINNAIRD_4") {
                    this._runScreen({
                        title: "Galcop High Command",
                        messageKey: "IR_IBANEZ_5_debrief"
                    })
                    missionVariables.IR_status = "IR_IBANEZ_5"
                    mission.setInstructionsKey("IR_waitforinfo_brief")
                    missionVariables.IR_cherkasova_deadline = clock.days + 20
                }
    
                if (missionVariables.IR_status == "IR_invite" && clock.days > missionVariables.IR_epilogue_deadline) {
                    this._runScreen({
                        messageKey: "IR_reward_a",
                        choicesKey: "IR_continue"
                    }, function (choice) {
                        if (choice == 1)
                            this._runScreen({
                                messageKey: "IR_reward_b",
                                choicesKey: "IR_continue"
                            }, function (choice) {
                                if (choice == 1)
                                    this._runScreen({
                                        messageKey: "IR_reward_c",
                                        choicesKey: "IR_continue",
                                        overlay: "IR_maenesmedal.png"
                                    }, function (choice) {
                                        if (choice == 1)
                                            this._runScreen({
                                                messageKey: "IR_reward_d",
                                                choicesKey: "IR_continue"
                                            }, function (choice) {
                                                if (choice == 1) {
                                                    this._runScreen({
                                                        messageKey: "IR_reward_e"
                                                    });
                                                    missionVariables.IR_status = "IR_epilogue"
                                                    missionVariables.IR_epilogue_deadline = clock.days + 5
                                                    player.credits += 50000
                                                    mission.setInstructionsKey(null)
                                                }
                                            });
                                    });
                            });
                    });
                }
            }
    
            if (system.ID == 230) // RAAED
            {
                if (missionVariables.IR_status == "IR_IBANEZ_2") {
                    this._runScreen({
                        messageKey: "IR_RAAED_1a",
                        overlay: "IR_forest.png",
                        choicesKey: "IR_continue"
                    }, function (choice) {
                        if (choice == 1)
                            this._runScreen({
                                overlay: "IR_invoice.png",
                                choicesKey: "IR_continue"
                            }, function (choice) {
                                if (choice == 1)
                                    this._runScreen({
                                        messageKey: "IR_RAAED_1c",
                                        overlay: "IR_forest.png",
                                        choicesKey: "IR_continue"
                                    }, function (choice) {
                                        if (choice == 1)
                                            this._runScreen({
                                                messageKey: "IR_RAAED_1d",
                                                choicesKey: "IR_continue",
                                                overlay: "IR_forest.png"
                                            }, function (choice) {
                                                if (choice == 1) {
                                                    this._runScreen({
                                                        messageKey: "IR_RAAED_1e",
                                                        overlay: "IR_forest.png"
                                                    });
                                                    missionVariables.IR_status = "IR_RAAED_1"
                                                    mission.setInstructionsKey("IR_IBANEZ_INFO")
                                                }
                                            });
                                    });
                            });
                    });
                }
            }
    
            if (system.ID == 232) // Janes
            {
                if (missionVariables.IR_status == "IR_IBANEZ_3") // quick visit to Janes
                {
                    this._runScreen({
                        messageKey: "IR_JANES_1a",
                        choicesKey: "IR_continue"
                    }, function (choice) {
                        if (choice == 1)
                            this._runScreen({
                                messageKey: "IR_JANES_1b",
                                choicesKey: "IR_continue"
                            }, function (choice) {
                                if (choice == 1) {
                                    this._runScreen({
                                        messageKey: "IR_JANES_1c"
                                    });
                                    missionVariables.IR_status = "IR_JANES_1"
                                    mission.setInstructionsKey("IR_IBANEZ_INFO")
                                }
                            });
                    });
                }
    
                if (missionVariables.IR_status == "IR_IBANEZ_4") {
                    this._runScreen({
                        title: "Janes's Shipyard Intelligence",
                        overlay: "IR_janes_logo.png",
                        messageKey: "IR_JANES_intro",
                        choicesKey: "IR_questions"
                    }, this.choiceEvaluation);
                    missionVariables.IR_offer = "IR_JANES_QUESTIONS"
                }
            }
    
            if (system.ID == 171) // Yokohama
            {
                if (missionVariables.IR_status == "IR_IBANEZ_4") {
                    this._runScreen({
                        title: "Yokohama Exports",
                        overlay: "IR_yk_logo.png",
                        messageKey: "IR_YOKOHAMA_intro",
                        choicesKey: "IR_questions"
                    }, this.choiceEvaluation);
                    missionVariables.IR_offer = "IR_YOKOHAMA_QUESTIONS"
                }
            }
    
            if (missionVariables.IR_convoy_exited == "TRUE" && missionVariables.IR_alsto == "HELP_ACCEPTED") {
                this._runScreen({
                    messageKey: "IR_shipment_contact_report"
                });
                player.incrementShipmentStatus()
                missionVariables.IR_alsto = "INFORMED"
                missionVariables.IR_convoy_exited = null
            }
    
            if (system.ID == 240) // Pirate Cove
            {
                if (missionVariables.IR_status == "IR_IBANEZ_4")
    
                {
                    if (!missionVariables.IR_alsto) {
                        this._runScreen({
                            title: " ",
                            messageKey: "IR_PIRATE_intro",
                            choicesKey: "IR_questions"
                        }, this.choiceEvaluation);
                        missionVariables.IR_offer = "IR_PIRATE_QUESTIONS"
                        missionVariables.IR_alsto = "MET"
                    } else {
                        this._runScreen({
                            title: " ",
                            messageKey: "IR_PIRATE_intro_alt",
                            choicesKey: "IR_questions"
                        }, this.choiceEvaluation);
                        missionVariables.IR_offer = "IR_PIRATE_QUESTIONS"
                    }
                }
    
                if (missionVariables.IR_status == "IR_LOA_1") {
                    if (missionVariables.IR_alsto)
                        missionVariables.IR_LOA_text = "known"
                    if (missionVariables.IR_alsto == "INFORMED")
                        missionVariables.IR_LOA_text = "helped"
                    if (!missionVariables.IR_alsto)
                        missionVariables.IR_LOA_text = "unknown"
    
                    this._runScreen({
                        messageKey: "IR_LOA_" + [missionVariables.IR_LOA_text] + "_2a",
                        choicesKey: "IR_continue"
                    }, function (choice) {
                        if (choice == 1)
                            this._runScreen({
                                messageKey: "IR_LOA_" + [missionVariables.IR_LOA_text] + "_2b",
                                choicesKey: "IR_continue"
                            }, function (choice) {
                                if (choice == 1)
                                    this._runScreen({
                                        messageKey: "IR_LOA_2c",
                                        choicesKey: "IR_continue"
                                    }, function (choice) {
                                        if (choice == 1) {
                                            this._runScreen({
                                                messageKey: "IR_LOA_2d"
                                            })
                                            missionVariables.IR_status = "IR_LOA_2"
                                            mission.setInstructionsKey("IR_LOA_brief_2")
                                            missionVariables.IR_alsto = null
                                            missionVariables.IR_LOA_text = null
                                        }
                                    });
                            });
                    });
                }
            }
    
            if (system.ID == 119) // PleasureWorld
            {
                if (missionVariables.IR_status == "IR_IBANEZ_4") {
                    this._runScreen({
                        title: "PleasureWorld",
                        overlay: "IR_pw_logo.png",
                        messageKey: "IR_PW_intro",
                        choicesKey: "IR_questions"
                    }, this.choiceEvaluation);
                    missionVariables.IR_offer = "IR_PW_QUESTIONS"
                }
    
                if (missionVariables.IR_status == "IR_WEISS_3") {
                    this._runScreen({
                        title: "PleasureWord",
                        overlay: "IR_pw_logo.png",
                        messageKey: "IR_weiss_3a",
                        choicesKey: "IR_continue"
                    }, function (choice) {
                        if (choice == 1)
                            this._runScreen({
                                overlay: "IR_pw_logo.png",
                                messageKey: "IR_weiss_3b"
                            })
                        missionVariables.IR_status = "IR_WEISS_4"
                        mission.setInstructionsKey("IR_weiss_brief_3")
                    });
                }
    
                if (missionVariables.IR_status == "IR_KINNAIRD_3") {
                    this._runScreen({
                        title: "PleasureWord",
                        overlay: "IR_pw_logo.png",
                        messageKey: "IR_kinnaird_4a",
                        choicesKey: "IR_continue"
                    }, function (choice) {
                        if (choice == 1)
                            this._runScreen({
                                messageKey: "IR_kinnaird_4b"
                            })
                        missionVariables.IR_status = "IR_KINNAIRD_4"
                        mission.setInstructionsKey("IR_kinnaird_brief_4")
                    });
                }
    
                if (missionVariables.IR_status == "IR_LEXICON_2") {
                    this._runScreen({
                        messageKey: "IR_LEXICON_3a",
                        overlay: "IR_nightclub.png",
                        choicesKey: "IR_continue"
                    }, function (choice) {
                        if (choice == 1)
                            this._runScreen({
                                messageKey: "IR_LEXICON_3b",
                                overlay: "IR_nightclub.png",
                                choicesKey: "IR_launch_choice"
                            }, function (choice) {
                                if (choice == 1) {
                                    missionVariables.IR_status = "IR_LEXICON_4"
                                    player.ship.launch()
                                }
                            });
                    });
                }
    
                if (missionVariables.IR_status == "IR_weiss_scooped") {
                    this._runScreen({
                        messageKey: "IR_LEXICON_4a",
                        choicesKey: "IR_continue"
                    }, function (choice) {
                        if (choice == 1)
                            this._runScreen({
                                messageKey: "IR_LEXICON_4b"
                            })
                        missionVariables.IR_status = "IR_IBANEZ_5"
                        mission.setInstructionsKey("IR_waitforinfo_brief")
                        missionVariables.IR_cherkasova_deadline = clock.days + 20
                    });
                }
            }
    
            if (system.ID == 180) // NWE
            {
                if (missionVariables.IR_status == "IR_IBANEZ_4") {
                    this._runScreen({
                        title: "Naval Weapons Establishment",
                        overlay: "IR_NWE_logo.png",
                        messageKey: "IR_NWE_intro",
                        choicesKey: "IR_questions"
                    }, this.choiceEvaluation);
                    missionVariables.IR_offer = "IR_NWE_QUESTIONS"
                }
    
                if (missionVariables.IR_defences_quest == "DEMO_2") {
                    this._runScreen({
                        title: "Naval Weapons Establishment",
                        overlay: "IR_NWE_logo.png",
                        messageKey: "IR_defences_quest_2a",
                        choicesKey: "IR_continue"
                    }, function (choice) {
                        if (choice == 1) {
                            this._runScreen({
                                title: "Naval Weapons Establishment",
                                overlay: "IR_NWE_logo.png",
                                messageKey: "IR_defences_quest_2b"
                            });
                            missionVariables.IR_defences_quest_deadline = clock.days + 7
                            missionVariables.IR_defences_quest = "DEMO_3"
                            player.incrementDefencesStatus()
                        }
                    });
                }
    
                if (missionVariables.IR_defences_quest == "DEMO_3" && clock.days > missionVariables.IR_defences_quest_deadline) {
                    this._runScreen({
                        title: "Naval Weapons Establishment",
                        overlay: "IR_NWE_logo.png",
                        messageKey: "IR_defences_quest_3"
                    });
                    missionVariables.IR_defences_quest_deadline = null
                    missionVariables.IR_defences_quest = "DEMO_4"
                    player.incrementDefencesStatus()
                }
            }
    
            if (system.ID == 82) // Inorle
            {
                if (missionVariables.IR_SDF_quest == "JACOB") {
                    this._runScreen({
                        messageKey: "IR_SDF_quest_3"
                    })
                    missionVariables.IR_SDF_quest = "LUFTSLOTTE"
                }
            }
    
            if (system.ID == 219) // GSE
            {
                if (missionVariables.IR_status == "IR_IBANEZ_4") {
                    this._runScreen({
                        title: "Galactic Stock Exchange",
                        overlay: "IR_GSE_logo.png",
                        messageKey: "IR_GSE_intro",
                        choicesKey: "IR_questions"
                    }, this.choiceEvaluation);
                    missionVariables.IR_offer = "IR_GSE_QUESTIONS"
                }
    
    
                if (missionVariables.IR_finance_quest == "JANES_NEWS") {
                    this._runScreen({
                        title: "Galactic Stock Exchange",
                        overlay: "IR_GSE_logo.png",
                        messageKey: "IR_finance_quest_6a",
                        choicesKey: "IR_continue"
                    }, function (choice) {
                        if (choice == 1) {
                            this._runScreen({
                                title: "Galactic Stock Exchange",
                                overlay: "IR_GSE_logo.png",
                                messageKey: "IR_finance_quest_6b"
                            });
                            player.incrementFinanceStatus()
                            missionVariables.IR_offer = null
                            missionVariables.IR_finance_quest = "WIFE"
                        }
                    });
                }
    
                if (missionVariables.IR_finance_quest == "WIFE_MET") {
                    this._runScreen({
                        title: "Galactic Stock Exchange",
                        overlay: "IR_GSE_logo.png",
                        messageKey: "IR_finance_quest_8",
                        choicesKey: "IR_wife_choices"
                    }, function (choice) {
                        if (choice == "IR_wife_yes") {
                            this._runScreen({
                                title: "Galactic Stock Exchange",
                                overlay: "IR_GSE_logo.png",
                                messageKey: "IR_finance_quest_9_confirm"
                            });
                            missionVariables.IR_wife_status = "AFFAIR_CONFIRMED"
                        }
    
                        if (choice == "IR_wife_no") {
                            this._runScreen({
                                title: "Galactic Stock Exchange",
                                overlay: "IR_GSE_logo.png",
                                messageKey: "IR_finance_quest_9_deny"
                            });
                            missionVariables.IR_wife_status = "AFFAIR_DENIED"
                        }
    
                        player.incrementFinanceStatus()
                        missionVariables.IR_finance_quest = "WAIT3"
                        missionVariables.IR_KORSHKOV_deadline = clock.days + 10
                        missionVariables.IR_offer = null
                    });
                }
            }
    
            if (system.ID == 31) // KORSHKOV
            {
                if (missionVariables.IR_finance_quest == "WAIT" && clock.days >= missionVariables.IR_KORSHKOV_deadline) {
                    this._runScreen({
                        title: "OKB Korshkov",
                        overlay: "IR_korshlogo.png",
                        messageKey: "IR_finance_quest_1"
                    });
                    player.incrementFinanceStatus()
                    missionVariables.IR_finance_quest = "COLLECTION"
                    missionVariables.IR_KORSHKOV_deadline = null
                    return;
                }
    
                if (missionVariables.IR_finance_quest == "COLLECTION") {
                    this.checkManifest()
    
                    if (missionVariables.IR_manifestOK == "TRUE") {
                        this._runScreen({
                            title: "OKB Korshkov",
                            overlay: "IR_korshlogo.png",
                            messageKey: "IR_finance_quest_2"
                        });
                        player.incrementFinanceStatus()
                        missionVariables.IR_KORSHKOV_deadline = clock.days + 10
                        missionVariables.IR_finance_quest = "WAIT2"
                        player.ship.manifest.radioactives -= 10
                        player.ship.manifest.alloys = -5
                        player.ship.manifest.minerals -= 2
                        player.ship.manifest.alienItems -= 2
                        player.ship.manifest.platinum -= 1
                        missionVariables.IR_manifestOK = null
                        return;
                    }
    
                    if (missionVariables.IR_manifestOK != "TRUE")
                        this._runScreen({
                            title: "OKB Korshkov",
                            overlay: "IR_korshlogo.png",
                            messageKey: "IR_finance_quest_3alt"
                        });
                    else return;
                }
    
                if (missionVariables.IR_finance_quest == "WAIT2" && clock.days >= missionVariables.IR_KORSHKOV_deadline) {
                    this._runScreen({
                        title: "OKB Korshkov",
                        overlay: "IR_korshlogo.png",
                        messageKey: "IR_finance_quest_3"
                    });
                    player.incrementFinanceStatus()
                    missionVariables.IR_KORSHKOV_deadline = null
                    missionVariables.IR_finance_quest = "IRRADIATE"
                    return;
                }
    
                if (missionVariables.IR_SDF_quest == "KORSHKOV") {
                    this._runScreen({
                        title: "OKB Korshkov",
                        overlay: "IR_korshlogo.png",
                        messageKey: "IR_SDF_quest_6"
                    });
                    player.incrementSDFStatus()
                    missionVariables.IR_SDF_deadline = clock.days + 10
                    missionVariables.IR_SDF_quest = "ANALYSIS"
                    player.ship.removeAllCargo()
                    missionVariables.IR_cargoCount = null
                    return;
                }
    
                if (missionVariables.IR_SDF_quest == "ANALYSIS" && clock.days >= missionVariables.IR_SDF_deadline)
    
                {
                    this._runScreen({
                        title: "OKB Korshkov",
                        overlay: "IR_korshlogo.png",
                        messageKey: "IR_SDF_quest_7a",
                        choicesKey: "IR_continue"
                    }, function (choice) {
                        if (choice == 1) {
                            this._runScreen({
                                messageKey: "IR_SDF_quest_7b"
                            });
                            missionVariables.IR_SDF_quest = "DATA"
                            player.incrementSDFStatus()
                            this.incrementSDFQuestion()
                            missionVariables.IR_SDF_location = null
                            missionVariables.IR_SDF_location_name = null
                        }
                    });
                    return;
                }
    
                if (missionVariables.IR_status == "IR_IBANEZ_4") {
                    this._runScreen({
                        title: "OKB Korshkov",
                        overlay: "IR_korshlogo.png",
                        messageKey: "IR_KORSHKOV_intro",
                        choicesKey: "IR_questions"
                    }, this.choiceEvaluation);
                    missionVariables.IR_offer = "IR_KORSHKOV_QUESTIONS"
                    return;
                }
            }
    
            if (system.ID == 142) // Tibiri bar
            {
                if (missionVariables.IR_finance_quest == "WIFE_DOCKED") {
                    this._runScreen({
                        messageKey: "IR_finance_quest_7a",
                        choicesKey: "IR_continue"
                    }, function (choice) {
                        if (choice == 1) {
                            this._runScreen({
                                messageKey: "IR_finance_quest_7b"
                            });
                            player.incrementFinanceStatus()
                            player.credits += 1000
                            missionVariables.IR_offer = null
                            missionVariables.IR_finance_quest = "WIFE_MET"
                        }
                    });
                }
                if (missionVariables.IR_finance_quest == "WIFE" || missionVariables.IR_finance_quest == "WIFE_IDENTIFIED")
                    this._runScreen({
                        messageKey: "IR_finance_quest_7alt"
                    });
            }
    
            if (system.ID == 23) // Maenes
            {
                if (missionVariables.IR_defences_question_no == 3 && !missionVariables.IR_defences_quest) {
                    if (!missionVariables.IR_Maenes_visit) {
                        this._runScreen({
                            title: "QuiCo Pharmaceuticals",
                            overlay: "IR_quico_logo.png",
                            messageKey: "IR_defences_quest_1_alt"
                        });
                        missionVariables.IR_defences_quest = "DEMO_1"
                    }
                    if (missionVariables.IR_Maenes_visit == "TRUE") {
                        this._runScreen({
                            title: "QuiCo Pharmaceuticals",
                            overlay: "IR_quico_logo.png",
                            messageKey: "IR_defences_quest_1"
                        });
                        missionVariables.IR_defences_quest = "DEMO_1"
                        missionVariables.IR_Maenes_visit = null
                    }
    
                }
                if (missionVariables.IR_defences_quest == "DEMO_4") {
                    this._runScreen({
                        title: "QuiCo Pharmaceuticals",
                        overlay: "IR_quico_logo.png",
                        messageKey: "IR_defences_quest_4"
                    });
                    missionVariables.IR_defences_quest = "DEMO_5"
                }
    
                if (missionVariables.IR_defences_quest == "SABOTAGED") {
                    this._runScreen({
                        title: "QuiCo Pharmaceuticals",
                        overlay: "IR_quico_logo.png",
                        messageKey: "IR_defences_quest_5a",
                        choicesKey: "IR_continue"
                    }, function (choice) {
                        if (choice == 1) {
                            this._runScreen({
                                messageKey: "IR_defences_quest_5b"
                            });
                            player.incrementDefencesStatus()
                            missionVariables.IR_defences_quest = "DEMO_6"
                            missionVariables.IR_defences_quest_deadline = clock.days + 15
                        }
                    });
                }
    
                if (missionVariables.IR_status == "IR_sources_5") {
                    this._runScreen({
                        title: "QuiCo Pharmaceuticals",
                        overlay: "IR_quico_logo.png",
                        messageKey: "IR_sources_5a",
                        choicesKey: "IR_continue"
                    }, function (choice) {
                        if (choice == 1) {
                            this._runScreen({
                                messageKey: "IR_sources_5b"
                            });
                            mission.setInstructionsKey("IR_waitforinfo_brief")
                            missionVariables.IR_status = "IR_sources_6"
                            missionVariables.IR_epilogue_deadline = clock.days + 10
                        }
                    });
                }
    
                if (missionVariables.IR_status == "IR_LOA_6") {
                    this._runScreen({
                        title: "QuiCo Pharmaceuticals",
                        overlay: "IR_quico_logo.png",
                        messageKey: "IR_LOA_6"
                    });
                    mission.setInstructionsKey("IR_waitforinfo_brief")
                    missionVariables.IR_status = "IR_LOA_7"
                    missionVariables.IR_epilogue_deadline = clock.days + 10
                }
            }
    
            if (system.ID == 35 && missionVariables.IR_status == "IR_KINNAIRD_1") //Atanon
            {
                this._runScreen({
                    messageKey: "IR_kinnaird_2"
                });
                missionVariables.IR_status = "IR_KINNAIRD_2"
            }
    
            if (system.ID == 41 && missionVariables.IR_status == "IR_KINNAIRD_2") //Orlaroor
            {
                this._runScreen({
                    messageKey: "IR_kinnaird_3"
                });
                missionVariables.IR_status = "IR_KINNAIRD_3"
                mission.setInstructionsKey("IR_kinnaird_brief_3")
            }
    
            if (system.ID == 149 && missionVariables.IR_status == "IR_LOA_3") //Arenxeon
            {
                this._runScreen({
                    messageKey: "IR_LOA_4a",
                    choicesKey: "IR_continue"
                }, function (choice) {
                    if (choice == 1) {
                        this._runScreen({
                            messageKey: "IR_LOA_4b"
                        });
                        missionVariables.IR_status = "IR_LOA_4"
                        missionVariables.IR_attack_deadline = clock.days + 10
                        mission.setInstructionsKey("IR_waitforinfo_brief")
                    }
                });
            }
    
            if (system.ID == 63 && missionVariables.IR_status == "IR_sources_3") //Edsoan
            {
                this._runScreen({
                    messageKey: "IR_sources_4a",
                    choicesKey: "IR_continue"
                }, function (choice) {
                    if (choice == 1) {
                        this._runScreen({
                            messageKey: "IR_sources_4b"
                        });
                        missionVariables.IR_status = "IR_sources_4"
                        mission.setInstructionsKey("IR_sources_brief_2")
                    }
                });
            }
            //keep brackets	
        }
    }
    
    this.choiceEvaluation = function (choice) {
        switch (missionVariables.IR_offer) {
            case "IR_GSE_QUESTIONS": {
                if (choice == "IR_B_finance_question_key") {
                    if (missionVariables.IR_finance_question_no == 1) {
                        this._runScreen({
                            title: "Galactic Stock Exchange",
                            overlay: "IR_GSE_logo.png",
                            messageKey: "IR_GSE_finance_answer_1a",
                            choicesKey: "IR_continue"
                        }, function (choice) {
                            if (choice == 1) {
                                this.incrementFinanceQuestion()
                                this._runScreen({
                                    title: "Galactic Stock Exchange",
                                    overlay: "IR_GSE_logo.png",
                                    messageKey: "IR_GSE_finance_answer_1b",
                                    choicesKey: "IR_questions"
                                }, this.choiceEvaluation);
                                missionVariables.IR_offer = "IR_GSE_QUESTIONS"
                            }
                        });
                        break;
                    }
    
                    if (missionVariables.IR_finance_question_no > 1) {
                        missionVariables.IR_asked_question = missionVariables.IR_finance_question_string
                        this._runScreen({
                            title: "Galactic Stock Exchange",
                            overlay: "IR_GSE_logo.png",
                            messageKey: "IR_no_more_answer",
                            choicesKey: "IR_questions"
                        }, this.choiceEvaluation);
                        break;
                    }
                }
    
                if (choice == "IR_A_shipment_question_key") {
                    if (missionVariables.IR_shipment_question_no == 2 && !missionVariables.IR_GSE_loan) {
                        this._runScreen({
                            title: "Galactic Stock Exchange",
                            overlay: "IR_GSE_logo.png",
                            messageKey: "IR_GSE_loan_offer",
                            choicesKey: "IR_loan_choices"
                        }, function (choice) {
                            if (choice == "IR_loan_yes") {
                                this._runScreen({
                                    title: "Galactic Stock Exchange",
                                    overlay: "IR_GSE_logo.png",
                                    messageKey: "IR_GSE_loan_agreed"
                                });
                                missionVariables.IR_GSE_loan = "ACCEPTED"
                                player.credits += 500000
                                missionVariables.IR_loan_deadline = clock.days + 60
                                missionVariables.IR_loan_remaining = missionVariables.IR_loan_deadline - clock.days
                                mission.setInstructionsKey("IR_loan_amount")
                                missionVariables.IR_offer = null
                            }
                            if (choice == "IR_loan_no") {
                                this._runScreen({
                                    title: "Galactic Stock Exchange",
                                    overlay: "IR_GSE_logo.png",
                                    messageKey: "IR_GSE_loan_rejected",
                                    choicesKey: "IR_questions"
                                }, this.choiceEvaluation);
                                missionVariables.IR_offer = null
                                missionVariables.IR_GSE_loan = "REJECTED"
                            }
                            if (choice == "IR_loan_defer") {
                                this._runScreen({
                                    title: "Galactic Stock Exchange",
                                    overlay: "IR_GSE_logo.png",
                                    messageKey: "IR_GSE_loan_deferred",
                                    choicesKey: "IR_questions"
                                }, this.choiceEvaluation);
                                missionVariables.IR_offer = "IR_GSE_QUESTIONS"
                                missionVariables.IR_GSE_loan = "DEFERRED"
                            }
                        });
                        break;
                    }
    
                    if (missionVariables.IR_GSE_loan == "DEFERRED") {
                        this._runScreen({
                            title: "Galactic Stock Exchange",
                            overlay: "IR_GSE_logo.png",
                            messageKey: "IR_GSE_loan_repeat_offer",
                            choicesKey: "IR_loan_choices"
                        }, function (choice) {
                            if (choice == "IR_loan_yes") {
                                this._runScreen({
                                    title: "Galactic Stock Exchange",
                                    overlay: "IR_GSE_logo.png",
                                    messageKey: "IR_GSE_loan_agreed"
                                });
                                missionVariables.IR_GSE_loan = "ACCEPTED"
                                player.credits += 500000
                                missionVariables.IR_loan_deadline = clock.days + 60
                                missionVariables.IR_loan_remaining = missionVariables.IR_loan_deadline - clock.days
                                mission.setInstructionsKey("IR_loan_amount")
                                missionVariables.IR_offer = null
                            }
                            if (choice == "IR_loan_no") {
                                this._runScreen({
                                    title: "Galactic Stock Exchange",
                                    overlay: "IR_GSE_logo.png",
                                    messageKey: "IR_GSE_loan_rejected",
                                    choicesKey: "IR_questions"
                                }, this.choiceEvaluation);
                                missionVariables.IR_offer = "IR_GSE_QUESTIONS"
                                missionVariables.IR_GSE_loan = "REJECTED"
                            }
                            if (choice == "IR_loan_defer") {
                                this._runScreen({
                                    title: "Galactic Stock Exchange",
                                    overlay: "IR_GSE_logo.png",
                                    messageKey: "IR_GSE_loan_deferred",
                                    choicesKey: "IR_questions"
                                }, this.choiceEvaluation);
                                missionVariables.IR_offer = "IR_GSE_QUESTIONS"
                                missionVariables.IR_GSE_loan = "DEFERRED"
                            }
                        });
                        break;
                    }
    
                    if (missionVariables.IR_GSE_loan == "ACCEPTED") {
                        this._runScreen({
                            title: "Galactic Stock Exchange",
                            overlay: "IR_GSE_logo.png",
                            messageKey: "IR_GSE_loan_demand",
                            choicesKey: "IR_pay_choices"
                        }, function (choice) {
                            if (choice == "IR_pay_yes") {
                                this._runScreen({
                                    title: "Galactic Stock Exchange",
                                    overlay: "IR_GSE_logo.png",
                                    messageKey: "IR_GSE_pay_accepted",
                                    choicesKey: "IR_questions"
                                }, this.choiceEvaluation);
                                missionVariables.IR_GSE_loan = "PAID"
                                player.credits -= 550000
                                missionVariables.IR_loan_deadline = null
                                missionVariables.IR_loan_remaining = null
                                mission.setInstructionsKey(null)
                                missionVariables.IR_offer = "IR_GSE_QUESTIONS"
                            }
                            if (choice == "IR_pay_no") {
                                this._runScreen({
                                    title: "Galactic Stock Exchange",
                                    overlay: "IR_GSE_logo.png",
                                    messageKey: "IR_GSE_pay_deferred",
                                    choicesKey: "IR_questions"
                                }, this.choiceEvaluation);
                                missionVariables.IR_offer = "IR_GSE_QUESTIONS"
                            }
                        });
                        break;
                    }
                }
    
                if (choice == "IR_E_exit_question_key")
                    return;
                else
                    this._runScreen({
                        title: "Galactic Stock Exchange",
                        overlay: "IR_GSE_logo.png",
                        messageKey: "IR_negative_answer",
                        choicesKey: "IR_questions"
                    }, this.choiceEvaluation);
                missionVariables.IR_offer = "IR_GSE_QUESTIONS"
                break;
            }
    
            case "IR_KORSHKOV_QUESTIONS": {
                if (choice == "IR_B_finance_question_key") {
                    if (missionVariables.IR_finance_question_no == 2) {
                        this._runScreen({
                            title: "OKB Korshkov",
                            overlay: "IR_korshlogo.png",
                            messageKey: "IR_KORSHKOV_finance_answer_1a",
                            choicesKey: "IR_continue"
                        }, function (choice) {
                            if (choice == 1) {
                                this.incrementFinanceQuestion()
                                this._runScreen({
                                    title: "OKB Korshkov",
                                    overlay: "IR_korshlogo.png",
                                    messageKey: "IR_KORSHKOV_finance_answer_1b"
                                });
                                missionVariables.IR_offer = "IR_KORSHKOV_QUESTIONS"
                                missionVariables.IR_KORSHKOV_deadline = clock.days + 5
                                player.incrementFinanceStatus()
                                missionVariables.IR_offer = null
                                missionVariables.IR_finance_quest = "WAIT"
                            }
                        });
                        break;
                    }
    
                    if (missionVariables.IR_finance_question_no > 2) {
                        missionVariables.IR_asked_question = missionVariables.IR_finance_question_string
                        this._runScreen({
                            title: "OKB Korshkov",
                            overlay: "IR_korshlogo.png",
                            messageKey: "IR_no_more_answer",
                            choicesKey: "IR_questions"
                        }, this.choiceEvaluation);
                        break;
                    }
                }
    
    
                if (choice == "IR_E_exit_question_key") {
                    return;
                } else
                    this._runScreen({
                        title: "OKB Korshkov",
                        overlay: "IR_korshlogo.png",
                        messageKey: "IR_negative_answer",
                        choicesKey: "IR_questions"
                    }, this.choiceEvaluation);
                missionVariables.IR_offer = "IR_KORSHKOV_QUESTIONS"
                break;
            }
    
            case "IR_JANES_QUESTIONS": {
                if (choice == "IR_A_shipment_question_key") {
                    this._runScreen({
                        title: "Jane's Shipyard Intelligence",
                        overlay: "IR_janes_logo.png",
                        messageKey: "IR_no_more_answer",
                        choicesKey: "IR_questions"
                    }, this.choiceEvaluation);
                    break;
                }
    
                if (choice == "IR_C_SDF_question_key") {
                    if (missionVariables.IR_SDF_question_no == 1) {
                        this.incrementSDFQuestion()
                        this._runScreen({
                            title: "Jane's Shipyard Intelligence",
                            overlay: "IR_janes_logo.png",
                            messageKey: "IR_JANES_SDF_answer",
                            choicesKey: "IR_questions"
                        }, this.choiceEvaluation);
                        break;
                    }
    
                    if (missionVariables.IR_SDF_question_no > 1) {
                        this._runScreen({
                            title: "Jane's Shipyard Intelligence",
                            overlay: "IR_janes_logo.png",
                            messageKey: "IR_no_more_answer",
                            choicesKey: "IR_questions"
                        }, this.choiceEvaluation);
                        break;
                    }
                }
    
                if (choice == "IR_D_defences_question_key") {
                    this._runScreen({
                        title: "Jane's Shipyard Intelligence",
                        overlay: "IR_janes_logo.png",
                        messageKey: "IR_JANES_defences_answer",
                        choicesKey: "IR_questions"
                    }, this.choiceEvaluation);
                    break;
                }
    
                if (choice == "IR_E_exit_question_key")
                    return;
                else
                    this._runScreen({
                        title: "Jane's Shipyard Intelligence",
                        messageKey: "IR_negative_answer",
                        choicesKey: "IR_questions"
                    }, this.choiceEvaluation);
                missionVariables.IR_offer = "IR_JANES_QUESTIONS"
                break;
            }
    
            case "IR_PIRATE_QUESTIONS": {
                if (choice == "IR_A_shipment_question_key") {
                    if (missionVariables.IR_shipment_question_no == 2 && missionVariables.IR_shipment_quest == "SET") {
                        this._runScreen({
                            title: " ",
                            messageKey: "IR_PIRATE_shipment_answer",
                            choicesKey: "IR_continue"
                        }, function (choice) {
                            if (choice == 1)
                                this._runScreen({
                                    title: " ",
                                    messageKey: "IR_PIRATE_shipment_offer",
                                    choicesKey: "IR_pirate_choices"
                                }, function (choice) {
                                    if (choice == "IR_pirate_yes") {
                                        this._runScreen({
                                            title: " ",
                                            messageKey: "IR_PIRATE_shipment_accepted"
                                        });
                                        missionVariables.IR_alsto = "HELP_ACCEPTED"
                                        player.credits -= 250000
                                        player.incrementShipmentStatus()
                                        missionVariables.IR_offer = null
                                    }
                                    if (choice == "IR_pirate_no") {
                                        this._runScreen({
                                            title: " ",
                                            messageKey: "IR_PIRATE_shipment_declined"
                                        });
                                        missionVariables.IR_offer = null
                                        missionVariables.IR_alsto = "HELP_DECLINED"
                                    }
                                });
                        });
                        break;
                    }
    
                    if (missionVariables.IR_shipment_question_no == 1) {
                        this._runScreen({
                            title: " ",
                            messageKey: "IR_negative_answer",
                            choicesKey: "IR_questions"
                        }, this.choiceEvaluation);
                        missionVariables.IR_offer = "IR_PIRATE_QUESTIONS"
                        break;
                    }
    
                    if (missionVariables.IR_shipment_question_no == 2 && missionVariables.IR_alsto == "HELP_ACCEPTED")
                        this._runScreen({
                            title: " ",
                            messageKey: "IR_PIRATE_shipment_confirm_help"
                        });
    
    
                    if (missionVariables.IR_shipment_question_no == 2 && missionVariables.IR_alsto == "HELP_DECLINED") {
                        this._runScreen({
                            title: " ",
                            messageKey: "IR_PIRATE_shipment_deferred_help",
                            choicesKey: "IR_pirate_choices"
                        }, function (choice) {
                            if (choice == "IR_pirate_yes") {
                                this._runScreen({
                                    title: " ",
                                    messageKey: "IR_PIRATE_shipment_accepted"
                                });
                                missionVariables.IR_alsto = "HELP_ACCEPTED"
                                player.credits -= 250000
                                player.incrementShipmentStatus()
                                missionVariables.IR_offer = null
                            }
                            if (choice == "IR_pirate_no") {
                                this._runScreen({
                                    title: " ",
                                    messageKey: "IR_PIRATE_shipment_declined"
                                });
                                missionVariables.IR_offer = null
                                missionVariables.IR_alsto = "HELP_DECLINED"
                            }
    
                        });
    
                        if (missionVariables.IR_shipment_question_no == 2 && missionVariables.IR_shipment_quest != "SET") {
                            missionVariables.IR_asked_question = missionVariables.IR_shipment_question_string
                            this._runScreen({
                                title: " ",
                                messageKey: "IR_no_more_answer",
                                choicesKey: "IR_questions"
                            }, this.choiceEvaluation);
                            break;
                        }
                    }
                }
    
                if (choice == "IR_C_SDF_question_key") {
                    if (missionVariables.IR_SDF_question_no < 2)
                        this._runScreen({
                            title: " ",
                            messageKey: "IR_PIRATE_SDF_answer_1",
                            choicesKey: "IR_questions"
                        }, this.choiceEvaluation);
    
                    if (missionVariables.IR_SDF_question_no == 2)
                        this._runScreen({
                            title: " ",
                            messageKey: "IR_PIRATE_SDF_answer_2",
                            choicesKey: "IR_questions"
                        }, this.choiceEvaluation);
    
                    if (missionVariables.IR_SDF_question_no > 2) {
                        this._runScreen({
                            title: " ",
                            messageKey: "IR_no_more_answer",
                            choicesKey: "IR_questions"
                        }, this.choiceEvaluation);
                    }
                    break;
                }
    
                if (choice == "IR_E_exit_question_key")
                    return;
                else
                    this._runScreen({
                        title: " ",
                        messageKey: "IR_negative_answer",
                        choicesKey: "IR_questions"
                    }, this.choiceEvaluation);
                missionVariables.IR_offer = "IR_PIRATE_QUESTIONS"
                break;
            }
    
            case "IR_YOKOHAMA_QUESTIONS": {
                if (choice == "IR_A_shipment_question_key") {
                    if (missionVariables.IR_shipment_question_no == 1) {
                        this.incrementShipmentQuestion()
                        this._runScreen({
                            title: "Yokohama Exports",
                            overlay: "IR_yk_logo.png",
                            messageKey: "IR_YOKOHAMA_shipment_answer_1"
                        });
                        missionVariables.IR_YOKOHAMA_deadline = clock.days + 30
                        missionVariables.IR_shipment_quest = "SET"
                        missionVariables.IR_offer = null
                        player.incrementShipmentStatus()
                        break;
                    }
    
                    if (missionVariables.IR_shipment_question_no == 2 && clock.days < missionVariables.IR_YOKOHAMA_deadline) {
                        this._runScreen({
                            title: "Yokohama Exports",
                            overlay: "IR_yk_logo.png",
                            messageKey: "IR_YOKOHAMA_shipment_answer_2",
                            choicesKey: "IR_YOKOHAMA_choices"
                        }, function (choice) {
                            if (choice == "IR_YOKOHAMA_yes") {
                                if (player.credits >= 1000000) {
                                    this._runScreen({
                                        title: "Yokohama Exports",
                                        overlay: "IR_yk_logo.png",
                                        messageKey: "IR_YOKOHAMA_shipment_agreed"
                                    });
                                    missionVariables.IR_shipment_quest = "SUCCESS"
                                    missionVariables.IR_shipment_quest_method = "PURCHASED"
                                    missionVariables.IR_YOKOHAMA_deadline = null
                                        ++missionVariables.IR_quest_count
                                    this.incrementShipmentQuestion()
                                    player.clearShipmentStatus()
                                    missionVariables.IR_offer = null
                                    player.credits -= 1000000
                                } else {
                                    this._runScreen({
                                        title: "Yokohama Exports",
                                        overlay: "IR_yk_logo.png",
                                        messageKey: "IR_YOKOHAMA_shipment_nomoney"
                                    });
                                    missionVariables.IR_offer = null
                                }
                            }
    
                            if (choice == "IR_YOKOHAMA_no") {
                                this._runScreen({
                                    title: "Yokohama Exports",
                                    overlay: "IR_yk_logo.png",
                                    messageKey: "IR_YOKOHAMA_shipment_declined"
                                });
                                missionVariables.IR_shipment_quest = "ENROUTE"
                                this.incrementShipmentQuestion()
                                missionVariables.IR_offer = null
                                if (missionVariables.IR_alsto) {
                                    player.incrementShipmentStatus()
                                }
                            }
    
                            if (choice == "IR_YOKOHAMA_defer") {
                                this._runScreen({
                                    title: "Yokohama Exports",
                                    overlay: "IR_yk_logo.png",
                                    messageKey: "IR_YOKOHAMA_shipment_defer"
                                });
                                missionVariables.IR_offer = null
                            }
                        });
                        break;
                    }
    
                    if (missionVariables.IR_shipment_question_no == 2 && clock.days > missionVariables.IR_YOKOHAMA_deadline) {
                        this._runScreen({
                            title: "Yokohama Exports",
                            overlay: "IR_yk_logo.png",
                            messageKey: "IR_YOKOHAMA_shipment_toolate"
                        });
                        missionVariables.IR_shipment_quest = "DISPATCHED"
                        player.clearShipmentStatus()
                        missionVariables.IR_offer = null
                        break;
                    }
    
                    if (missionVariables.IR_shipment_question_no > 2) {
                        missionVariables.IR_asked_question = missionVariables.IR_shipment_question_string
                        this._runScreen({
                            title: "Yokohama Exports",
                            overlay: "IR_yk_logo.png",
                            messageKey: "IR_no_more_answer",
                            choicesKey: "IR_questions"
                        }, this.choiceEvaluation);
                        break;
                    }
                }
    
                if (choice == "IR_E_exit_question_key")
                    return;
                else
                    this._runScreen({
                        title: "Yokohama Exports",
                        overlay: "IR_yk_logo.png",
                        messageKey: "IR_negative_answer",
                        choicesKey: "IR_questions"
                    }, this.choiceEvaluation);
                missionVariables.IR_offer = "IR_YOKOHAMA_QUESTIONS"
                break;
            }
    
            case "IR_PW_QUESTIONS": {
                if (choice == "IR_C_SDF_question_key") {
                    if (missionVariables.IR_SDF_question_no == 2) {
                        this._runScreen({
                            title: "PleasureWorld",
                            overlay: "IR_pw_logo.png",
                            messageKey: "IR_PW_SDF_answer_1",
                            choicesKey: "IR_continue"
                        }, function (choice) {
                            if (choice == 1) {
                                this.incrementSDFQuestion()
                                this._runScreen({
                                    title: " ",
                                    messageKey: "IR_SDF_quest_1"
                                });
                                missionVariables.IR_SDF_quest = "ADDRESS"
                                missionVariables.IR_SDF_deadline = clock.days + 10
                            }
                        });
                        break;
                    }
    
                    if (missionVariables.IR_SDF_question_no == 3) {
                        this._runScreen({
                            title: "PleasureWorld",
                            overlay: "IR_pw_logo.png",
                            messageKey: "IR_no_more_answer",
                            choicesKey: "IR_questions"
                        }, this.choiceEvaluation);
                        break;
                    }
    
                    if (missionVariables.IR_SDF_question_no == 5) {
                        this._runScreen({
                            title: "PleasureWorld",
                            overlay: "IR_devries.png",
                            messageKey: "IR_PW_SDF_answer_2"
                        });
                        this.incrementSDFQuestion()
                        missionVariables.IR_SDF_quest = "PHOTO"
                        missionVariables.IR_SDF_deadline = clock.days + 35
                    } else {
                        this._runScreen({
                            title: "PleasureWorld",
                            overlay: "IR_pw_logo.png",
                            messageKey: "IR_negative_answer",
                            choicesKey: "IR_questions"
                        }, this.choiceEvaluation);
                    }
                    break;
                }
    
                if (choice == "IR_E_exit_question_key") {
                    missionVariables.IR_offer = "IR_ASKED"
                    return;
                } else
                    this._runScreen({
                        title: "PleasureWorld",
                        overlay: "IR_pw_logo.png",
                        messageKey: "IR_negative_answer",
                        choicesKey: "IR_questions"
                    }, this.choiceEvaluation);
                missionVariables.IR_offer = "IR_PW_QUESTIONS"
                break;
            }
    
            case "IR_NWE_QUESTIONS": {
                if (choice == "IR_C_SDF_question_key") {
                    if (missionVariables.IR_SDF_question_no == 4) {
                        this._runScreen({
                            title: "Naval Weapons Establishment",
                            overlay: "IR_NWE_logo.png",
                            messageKey: "IR_NWE_SDF_answer_1a",
                            choicesKey: "IR_continue"
                        }, function (choice) {
                            if (choice == 1) {
                                this.incrementSDFQuestion()
                                this._runScreen({
                                    title: " ",
                                    overlay: "IR_NWE_logo.png",
                                    messageKey: "IR_NWE_SDF_answer_1b"
                                });
                            }
                            missionVariables.IR_offer = null
                        });
                    }
    
                    if (missionVariables.IR_SDF_question_no < 4 || missionVariables.IR_SDF_question_no > 4) {
                        this._runScreen({
                            title: "Naval Weapons Establishment",
                            overlay: "IR_NWE_logo.png",
                            messageKey: "IR_negative_answer",
                            choicesKey: "IR_questions"
                        }, this.choiceEvaluation);
                    }
                    break;
                }
    
                if (choice == "IR_D_defences_question_key") {
                    if (missionVariables.IR_defences_question_no < 3) {
                        this._runScreen({
                            title: "Naval Weapons Establishment",
                            overlay: "IR_NWE_logo.png",
                            messageKey: "IR_NWE_defences_answer_1"
                        });
                        missionVariables.IR_defences_question_no = 3
                        missionVariables.IR_offer = null
                        player.incrementDefencesStatus()
                        break;
                    }
    
                    if (missionVariables.IR_defences_question_no == 3) {
                        this._runScreen({
                            title: "Naval Weapons Establishment",
                            overlay: "IR_NWE_logo.png",
                            messageKey: "IR_no_more_answer",
                            choicesKey: "IR_questions"
                        }, this.choiceEvaluation);
                        break;
                    }
                }
    
                if (choice == "IR_E_exit_question_key")
                    return;
                else
                    this._runScreen({
                        title: "Naval Weapons Establishment",
                        messageKey: "IR_negative_answer",
                        choicesKey: "IR_questions"
                    }, this.choiceEvaluation);
                missionVariables.IR_offer = "IR_NWE_QUESTIONS"
                break;
            }
    
            case "IR_MAENES_QUESTIONS": {
                if (choice == "IR_D_defences_question_key") {
                    if (missionVariables.IR_defences_question_no == 1) {
                        this._runScreen({
                            title: "QuiCo Pharmaceuticals",
                            overlay: "IR_quico_logo.png",
                            messageKey: "IR_MAENES_defences_answer_1"
                        });
                        this.incrementDefencesQuestion()
                        missionVariables.IR_offer = null
                        missionVariables.IR_Maenes_visit = "TRUE"
                        break;
                    }
    
                    if (missionVariables.IR_defences_question_no >= 2) {
                        this._runScreen({
                            title: "QuiCo Pharmaceuticals",
                            overlay: "IR_quico_logo.png",
                            messageKey: "IR_no_more_answer",
                            choicesKey: "IR_questions"
                        }, this.choiceEvaluation);
                        break;
                    }
                }
    
                if (choice == "IR_E_exit_question_key")
                    return;
                else
                    this._runScreen({
                        title: "QuiCo Pharmaceuticals",
                        overlay: "IR_quico_logo.png",
                        messageKey: "IR_negative_answer",
                        choicesKey: "IR_questions"
                    }, this.choiceEvaluation);
                missionVariables.IR_offer = "IR_MAENES_QUESTIONS"
                break;
            }
        }
    }
    
    Scripts/xenonreduxui_coremissionfixes.js
    "use strict";
    this.name = "XenonReduxUI_CoreMissionFixes";
    this.author = "phkb";
    this.copyright = "2016 phkb";
    this.description = "Updates routines in core missions for compatibility with XenonReduxUI";
    this.licence = "CC BY-NC-SA 3.0";
    
    //-------------------------------------------------------------------------------------------------------------
    this.startUpComplete = function () {
    	// if XenonUI is installed as well, let it do the monkey patching
    	if (worldScripts.XenonUI) {
    		delete this.startUpComplete;
    		return;
    	}
    
    	// apply fixes for nova missions
    	var wn = worldScripts["oolite-nova"];
    	if (wn) {
    		wn.missionScreenOpportunity = this.$nova_missionScreenOpportunity;
    	}
    }
    
    //-------------------------------------------------------------------------------------------------------------
    this.$nova_missionScreenOpportunity = function $nova_missionScreenOpportunity() {
    	if (!player.ship.docked) {
    		return;
    	}
    
    	function choiceEvaluation(choice) {
    		if (choice === "YES") {
    			player.ship.useSpecialCargo(expandDescription("[oolite-nova-refugees]"));
    			mission.setInstructionsKey("oolite_nova_info");
    			missionVariables.nova = "NOVA_ESCAPE_HERO";
    			player.ship.launch();
    			this._blowUpAllStations();
    			system.sun.goNova(30);
    		} else {
    			// choice == "NO", or null when player launched without making a choice.
    			missionVariables.nova = "NOVA_ESCAPE_COWARD";
    			player.commsMessage(expandDescription("[oolite-nova-coward]"), 4.5);
    			system.sun.goNova(9); // barely enough time to jump out of the system.
    		}
    		missionVariables.novacount = null;
    	}
    
    	if (player.ship.dockedStation.isMainStation) {
    		if (galaxyNumber === 3) {
    			if (!missionVariables.nova && !missionVariables.novacount) {
    				missionVariables.novacount = 0;
    			}
    			if (missionVariables.nova === "TWO_HRS_TO_ZERO") {
    				mission.runScreen({
    						titleKey: "oolite_nova_title",
    						messageKey: "oolite_nova_brief",
    						overlay: {
    							name: "solar.png",
    							height: 512
    						},
    						choicesKey: "oolite_nova_yesno",
    						screenID: "oolite-nova-briefing"
    					},
    					choiceEvaluation);
    
    				this.novaMissionTimer.stop();
    			}
    		}
    		if (galaxyNumber === 3 || galaxyNumber === 4) {
    			if (missionVariables.nova === "NOVA_ESCAPED_SYSTEM") {
    				player.ship.removeAllCargo();
    				mission.runScreen({
    					titleKey: "oolite_nova_title",
    					messageKey: "oolite_nova_hero",
    					overlay: {
    						name: "solar.png",
    						height: 512
    					},
    					screenID: "oolite-nova-hero"
    				});
    				player.ship.manifest["gem_stones"] += 100;
    				this._endTheMission();
    			} else if (missionVariables.nova === "NOVA_ESCAPE_POD") {
    				player.ship.removeAllCargo(); // can only be done while docked.
    				mission.runScreen({
    					titleKey: "oolite_nova_title",
    					messageKey: "oolite_nova_disappointed",
    					overlay: {
    						name: "solar.png",
    						height: 512
    					},
    					screenID: "oolite-nova-disappointed"
    				});
    				this._endTheMission();
    			} else if (missionVariables.nova === "NOVA_ESCAPE_OTHER") {
    				mission.runScreen({
    					titleKey: "oolite_nova_title",
    					messageKey: "oolite_nova_ignored",
    					overlay: {
    						name: "solar.png",
    						height: 512
    					},
    					screenID: "oolite-nova-ignored"
    				});
    				this._endTheMission();
    			} else if (missionVariables.nova === "NOVA_ESCAPE_COWARD" && !system.sun.isGoingNova && !system.sun.hasGoneNova) {
    				player.decreaseContractReputation();
    				player.decreasePassengerReputation();
    				mission.runScreen({
    					titleKey: "oolite_nova_title",
    					messageKey: "oolite_nova_disappointed",
    					overlay: {
    						name: "solar.png",
    						height: 512
    					},
    					screenID: "oolite-nova-coward"
    				});
    				this._endTheMission();
    			}
    		}
    	} else if (missionVariables.nova === "TWO_HRS_TO_ZERO") {
    		// this is the the nova system, but not the main station.
    		player.ship.launch();
    		player.commsMessage(expandDescription("[oolite-nova-visit-main]"));
    	}
    };