Bug with using backgroundSpecial "SHORT_RANGE_CHART"

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Bug with using backgroundSpecial "SHORT_RANGE_CHART"

Post by phkb »

I think I've worked this out, but it would be good to get someone else to test it.

The scenario is: if a mission screen is loaded with the "backgroundSpecial" property set to "SHORT_RANGE_CHART", and then the player switches to another screen that isn't a mission screen (eg, the F5 Manifest screen), when the player then goes to the F6 galactic chart screen, the chart will be locked in that page up/down don't zoom in or out.

As soon as another mission screen is opened, though, the chart will be freed up.

I've put together some sample code to demonstrate the error:

Code: Select all

"use strict";
this.name        = "ShortRangeChart_Testing";
this.author      = "phkb";
this.copyright   = "2016 phkb";
this.description = "Test code for the Short Range Chart special background";
this.licence     = "CC BY-NC-SA 4.0";

this._sysID = -1;
this._screenOpen = false;

//-------------------------------------------------------------------------------------------------------------
this.startUpComplete = function() {
	// pick a random destination within 7 LY
	var sys = System.infoForSystem(galaxyNumber, system.ID).systemsInRange(7);
	this._sysID = sys[1].systemID;
	// initialise the interface screen
	this.$initInterface(player.ship.dockedStation);
}

//-------------------------------------------------------------------------------------------------------------
this.guiScreenChanged = function(to, from) {
	var p = player.ship;
	// monitor when the player leaves the screen to reset their destination
	if (from === "GUI_SCREEN_MISSION" && this._screenOpen) {
		this._screenOpen = false;
		if (this._suspendedDestination) p.targetSystem = this._suspendedDestination;
		this._suspendedDestination = null;
	}
	p = null;
}

//-------------------------------------------------------------------------------------------------------------
this.$initInterface = function(station) {
	station.setInterface(this.name,{
		title:"Testing ShortRangeChart",
		category:"Station Interfaces",
		summary:"Testing what happens when using the ShortRangeChart special background.",
		callback:this.$showPage.bind(this)
	});
}

//-------------------------------------------------------------------------------------------------------------
this.$showPage = function() {

	var p = player.ship;
	var curChoices = {};
	this._screenOpen = true;
	
	// hold the player's destination
	this._suspendedDestination = p.targetSystem;
	// override it for the display
	p.targetSystem = this._sysID;

	var bg = "SHORT_RANGE_CHART";
	curChoices["96_SETCOURSE~" + this._sysID] = "Set course for " + System.systemNameForID(this._sysID);

	curChoices["99_EXIT"] = "Exit";
	var def = "99_EXIT";

	var opts = {
		screenID: "src_testing",
		title: "Short Range Chart Testing",
		backgroundSpecial: bg,
		allowInterrupt: true,
		exitScreen: "GUI_SCREEN_INTERFACES",
		choices: curChoices,
		initialChoicesKey: def,
		message: ""
	};

	mission.runScreen(opts, this.$screenHandler, this);

	p = null;
	opts = null;
	curChoices = null;
	
}

//-------------------------------------------------------------------------------------------------------------
// handles player selections on the BB screen
this.$screenHandler = function(choice) {

	if (this._suspendedDestination) player.ship.targetSystem = this._suspendedDestination;
	this._suspendedDestination = null;

	if (!choice) return;

	if (choice.indexOf("96_SETCOURSE") >= 0) {
		var dest = parseInt(choice.substring(choice.indexOf("~") + 1));
		if (dest >= 0 && dest <= 255) {
			player.ship.targetSystem = dest;
			player.consoleMessage("Course set for " + System.systemNameForID(dest));
		}
	}

	if (choice != "99_EXIT") this.$showPage();
}
When I run this code, open the screen from the F4 interfaces list, and then go to the F6 chart, it will be locked.
If I come back to the F4 interfaces list and open any other mission screen, when I go to the F6 chart it will be unlocked.

Please let me know if any of this is unclear!
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6681
Joined: Wed Feb 28, 2007 7:54 am

Re: Bug with using backgroundSpecial "SHORT_RANGE_CHART"

Post by another_commander »

Confirmed if the player ship is not equipped with an Advanced Nav Array. You can simply reproduce it by going to any parcel or contract screen, which displays a chart, then got back to F5 and then F6. Try repeating your process but this time make sure to have an ANA installed and see if this makes it work.

One other thing I noticed while testing this is, when in the F6 screen in search planet mode (awaiting text input), using the zoom in / out controls will make the F6 screen title disappear until the chart is clicked or search mode is exited.
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Bug with using backgroundSpecial "SHORT_RANGE_CHART"

Post by phkb »

The code I posted should demonstrate the issue with the ANA installed.
User avatar
kanthoney
Commodore
Commodore
Posts: 281
Joined: Thu Nov 07, 2013 10:21 pm

Re: Bug with using backgroundSpecial "SHORT_RANGE_CHART"

Post by kanthoney »

That's proper horlicksed, isn't it?

I think it's something to do with the backgroundSpecial variable not being changed back to GUI_BACKGROUND_SPECIAL_SHORT after the mission screen. I'll investigate further when I'm not at work.
User avatar
kanthoney
Commodore
Commodore
Posts: 281
Joined: Thu Nov 07, 2013 10:21 pm

Re: Bug with using backgroundSpecial "SHORT_RANGE_CHART"

Post by kanthoney »

Both the non-zooming and the disappearing chart title should be fixed in tonight's build.
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Bug with using backgroundSpecial "SHORT_RANGE_CHART"

Post by phkb »

Thanks kanthoney and a_c, confirmed it all works fine now!
Post Reply