[Release] Dangerous HUD

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

cag
Dangerous
Dangerous
Posts: 84
Joined: Fri Mar 17, 2017 1:49 am

Re: [Release] Dangerous HUD

Post by cag » Thu Aug 17, 2017 2:50 am

I didn't mean the deletion or restoration of your functions, but the last line in the else block

Code: Select all

w.shipExitedWitchspace();
executes to presumably setup or initialize the HUD after the HUD is changed. All I did was scan your code quickly and guessed

Code: Select all

shipWillLaunchFromStation()
would fix the problem, so I executed it using the debug console. I didn't alter your code because I'm not sure if I need all of that function or just parts of it (or more than that just that). I got the clock & crosshairs and moved on. Sorry but the complimentary free debug offer has expired :mrgreen:

I knew I was missing some equipment, so I searched for 'awardEquipment' (you have 31) but the clock only showed up in shipWillLaunchFromStation() and, as the Brits say, Bob's your uncle. I haven't noticed any obvious problems but I'm new to this HUD. As a temporary fix, just insert that one line:

Code: Select all

       ....
		if (!w.playerBoughtNewShip) eval("w.playerBoughtNewShip = " + w.$save_playerBoughtNewShip);
		if (!w.playerRequestedDockingClearance) eval("w.playerRequestedDockingClearance = " + w.$save_playerRequestedDockingClearance);
		// force an update
		w.shipExitedWitchspace();
		w.shipWillLaunchFromStation();    // <=============
	}
}
It doesn't appear that it matters if it goes before or after shipExitedWitchspace() but who knows.
"Better to be thought a fool, boy, than to open your trap and remove all doubt." - Grandma [over time, just "Shut your trap... fool"]
"The only stupid questions are the ones you fail to ask." - Dad
How do I...? Nevermind.

User avatar
phkb
Commodore
Commodore
Posts: 2313
Joined: Tue Jan 21, 2014 10:37 pm
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...

Re: [Release] Dangerous HUD

Post by phkb » Thu Aug 17, 2017 3:13 am

cag, would I be right in assuming you were in flight when you changed HUD's?

cag
Dangerous
Dangerous
Posts: 84
Joined: Fri Mar 17, 2017 1:49 am

Re: [Release] Dangerous HUD

Post by cag » Thu Aug 17, 2017 3:40 am

Yes. I had several HUDs I wanted to check out. When I launched, I was set to one that came with HUDselector.
"Better to be thought a fool, boy, than to open your trap and remove all doubt." - Grandma [over time, just "Shut your trap... fool"]
"The only stupid questions are the ones you fail to ask." - Dad
How do I...? Nevermind.

User avatar
phkb
Commodore
Commodore
Posts: 2313
Joined: Tue Jan 21, 2014 10:37 pm
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...

Re: [Release] Dangerous HUD

Post by phkb » Thu Aug 17, 2017 4:01 am

Perfect. Thanks! I imagine updates will be on the way (for this and Xenon HUD).

User avatar
gsagostinho
---- E L I T E ----
---- E L I T E ----
Posts: 558
Joined: Sun Jul 19, 2015 1:09 pm

Re: [Release] Dangerous HUD

Post by gsagostinho » Thu Aug 17, 2017 11:14 am

@cag Xenon HUD has been updated, I will take a look at the code and make a new release as soon as I can.

User avatar
gsagostinho
---- E L I T E ----
---- E L I T E ----
Posts: 558
Joined: Sun Jul 19, 2015 1:09 pm

Re: [Release] Dangerous HUD

Post by gsagostinho » Thu Aug 17, 2017 9:25 pm

A new version 1.5 is now available in the extension manager. I have merged the improvements made by phkb on his Xenon HUD (version 1.5.5), including improved HUDSelector integration and performance improvements (thanks, phkb!!).

@cag would you care to take a look and see if things are looking better on your side?

cag
Dangerous
Dangerous
Posts: 84
Joined: Fri Mar 17, 2017 1:49 am

Re: [Release] Dangerous HUD

Post by cag » Fri Aug 18, 2017 1:31 am

That seems to have fixed it, with one small caveat. Calling shipWillLaunchFromStation() awards me the equipment, so that's good, but it makes an assumption, that you're looking forward. If you have, say, a mining laser w/ different crosshairs in a side view and are in that view when you change HUDs, you get the wrong crosshairs until you cycle your weapon. It's a simple fix, just change line 356 from

Code: Select all

p.script._currentCrosshairs = this.$selectCrosshairs("VIEW_FORWARD");
to

Code: Select all

p.script._currentCrosshairs = this.$selectCrosshairs(p.viewDirection);
I was having fun testing this, in that HUDselector was blowing up, but I cannot reproduce it after all the changes you made. There's a programmer's axiom that says "if you can't reproduce a bug, it never happened" :D

I'd be interested to know why you (or phkb) switched to storing data in the player's ship's script. You take a bit of a performance hit doing that. You can get much of that back by following Norby's rule that if you use it more than once, store it locally. For example, change

Code: Select all

this.shipWillLaunchFromStation = function(station) {

	var p = player.ship;
	// reset the missile monitoring array
	p.script._missiles = [];
	p.script._missileWarning = false;
	p.script._missileWarningChanged = false;
...
to

Code: Select all

this.shipWillLaunchFromStation = function(station) {

	var p = player.ship;
	var ps = p.script;
	// reset the missile monitoring array
	ps._missiles = [];
	ps._missileWarning = false;
	ps._missileWarningChanged = false;
...
so you only looking for the script object once for the entire function. 'p.script...' appears 179 times over ~20 functions. Same goes for player.ship.
Take $scannerAnimationFrame2 for example. It profiles at 1.263 ms on my machine. By changing it to:

Code: Select all

this.$scannerAnimationFrame2 = function() {
	var p = player.ship;
	p.removeEquipment("EQ_SCANNER_FRAME_1");
	p.awardEquipment("EQ_SCANNER_FRAME_2");
}
it now takes only 0.307 ms. Not much, you say? On my PC, your HUD runs at just under 40 frames/sec. That means there's only 25 ms between frames (1/40) so every little bit helps.

Let me know when you settle on a stable version of the script. I want to take a crack at putting it all in a 'closure', where for some objects, you only fetch them once per game.
"Better to be thought a fool, boy, than to open your trap and remove all doubt." - Grandma [over time, just "Shut your trap... fool"]
"The only stupid questions are the ones you fail to ask." - Dad
How do I...? Nevermind.

User avatar
phkb
Commodore
Commodore
Posts: 2313
Joined: Tue Jan 21, 2014 10:37 pm
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...

Re: [Release] Dangerous HUD

Post by phkb » Fri Aug 18, 2017 3:14 am

cag wrote: I'd be interested to know why you (or phkb) switched to storing data in the player's ship's script.
That was me, and the reason was to try and avoid going to "worldScripts" for each reference. It seemed to profile better when I did this (on my machine anyway), but it's a bit hard to gauge. I missed the extra step of applying a local to the script object, so I'll be doing an update with that. Thanks!
cag wrote:I want to take a crack at putting it all in a 'closure'
Can't wait to see it!

User avatar
gsagostinho
---- E L I T E ----
---- E L I T E ----
Posts: 558
Joined: Sun Jul 19, 2015 1:09 pm

Re: [Release] Dangerous HUD

Post by gsagostinho » Fri Aug 18, 2017 1:42 pm

Many thanks to both of you, cag and phkb! These fixes and suggestions are excellent. I will work through what you guys wrote and try to make another update soon. I really appreciate all the feedback!!

User avatar
gsagostinho
---- E L I T E ----
---- E L I T E ----
Posts: 558
Joined: Sun Jul 19, 2015 1:09 pm

Re: [Release] Dangerous HUD

Post by gsagostinho » Fri Aug 18, 2017 3:04 pm

@cag I have implemented these modifications you suggested and the performance improvement is really huge, many many thanks!! I going to try to get a couple of other things done (fix some other bugs and perhaps add some other things I had on my mind) and make a new release soon.

cag
Dangerous
Dangerous
Posts: 84
Joined: Fri Mar 17, 2017 1:49 am

Re: [Release] Dangerous HUD

Post by cag » Sat Aug 19, 2017 2:30 am

In case it's not on your list, there's another minor issue in shipWillLaunchFromStation(), just after you award the clock equipment:

Code: Select all

	// default view after launching == forward
	p.awardEquipment("EQ_DANGEROUSHUD_VIEW_FORWARD");
Like w/ crosshairs, you're awarding w/o regard to the view the player is in. Perhaps a call to viewDirectionChanged(player.ship.viewDirection) after the call of shipWillLaunchFromStation() in $HUDSelectorCallBack() will work.

Code: Select all

		// force an update
		w.shipExitedWitchspace();
		w.shipWillLaunchFromStation();
		w.viewDirectionChanged( player.ship.viewDirection );
	}
...<hacking>...
It seems to fix the problem. I'll keep running w/ it and let you know if something bad happens.
"Better to be thought a fool, boy, than to open your trap and remove all doubt." - Grandma [over time, just "Shut your trap... fool"]
"The only stupid questions are the ones you fail to ask." - Dad
How do I...? Nevermind.

User avatar
gsagostinho
---- E L I T E ----
---- E L I T E ----
Posts: 558
Joined: Sun Jul 19, 2015 1:09 pm

Re: [Release] Dangerous HUD

Post by gsagostinho » Sat Aug 19, 2017 4:41 pm

Thanks again, cag, phkb has taken care of that on his Xenon HUD and so did I on the Dangerous HUD. I am just trying to solve one more thing before a new release, and then all these suggestions by you will be available to everyone. Many, many, many thanks.

User avatar
gsagostinho
---- E L I T E ----
---- E L I T E ----
Posts: 558
Joined: Sun Jul 19, 2015 1:09 pm

Re: [Release] Dangerous HUD

Post by gsagostinho » Sat Aug 19, 2017 8:28 pm

Hi all, version 1.6 has been release with the following changelog:

- performance improvements (many thanks to cag and phkb for all the help!).
- improvements to the minimal crosshair mode: when crosshairs are set to be visible only in red/yellow alert, the gauges are now visible though very transparent.
- fixed a bug which caused JS errors when escape pod was launched.
- HUD now compatible with Breakable HUD/IFF Scanner OXP.

Concerning the minimal croshair mode, this is the regular mode:
Image

And this is the minimal crosshair mode, which turns the main gauges very transparent while in green or green/yellow alert, and they come back to normal when in red alert:
Image

User avatar
gsagostinho
---- E L I T E ----
---- E L I T E ----
Posts: 558
Joined: Sun Jul 19, 2015 1:09 pm

Re: [Release] Dangerous HUD

Post by gsagostinho » Sun Aug 20, 2017 12:01 am

I just uploaded version 1.6.1 fixing a small typo in the code causing a small error.

Zireael
---- E L I T E ----
---- E L I T E ----
Posts: 1396
Joined: Tue Nov 09, 2010 1:44 pm

Re: [Release] Dangerous HUD

Post by Zireael » Thu Oct 26, 2017 12:25 pm

This is awesome. I once made an ED HUD which was just a recolor of the standard HUD to orange, but I so dearly wished I could pull off a cockpit somehow. Thanks for making this, gsagostinho!

Post Reply