Oolite Bulletins

For information and discussion about Oolite.
It is currently Fri Sep 22, 2017 9:48 am

All times are UTC




Post new topic  Reply to topic  [ 59 posts ]  Go to page Previous 1 2 3 4
Author Message
PostPosted: Thu Aug 17, 2017 2:50 am 
Offline
Competent
Competent

Joined: Fri Mar 17, 2017 1:49 am
Posts: 44
I didn't mean the deletion or restoration of your functions, but the last line in the else block
Code:
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:
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:
       ....
		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.


Top
   
PostPosted: Thu Aug 17, 2017 3:13 am 
Offline
Commodore
Commodore
User avatar

Joined: Tue Jan 21, 2014 10:37 pm
Posts: 1707
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...
cag, would I be right in assuming you were in flight when you changed HUD's?

_________________
My OXP's


Top
   
PostPosted: Thu Aug 17, 2017 3:40 am 
Offline
Competent
Competent

Joined: Fri Mar 17, 2017 1:49 am
Posts: 44
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.


Top
   
PostPosted: Thu Aug 17, 2017 4:01 am 
Offline
Commodore
Commodore
User avatar

Joined: Tue Jan 21, 2014 10:37 pm
Posts: 1707
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...
Perfect. Thanks! I imagine updates will be on the way (for this and Xenon HUD).

_________________
My OXP's


Top
   
PostPosted: Thu Aug 17, 2017 11:14 am 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Sun Jul 19, 2015 1:09 pm
Posts: 366
@cag Xenon HUD has been updated, I will take a look at the code and make a new release as soon as I can.


Top
   
PostPosted: Thu Aug 17, 2017 9:25 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Sun Jul 19, 2015 1:09 pm
Posts: 366
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?


Top
   
PostPosted: Fri Aug 18, 2017 1:31 am 
Offline
Competent
Competent

Joined: Fri Mar 17, 2017 1:49 am
Posts: 44
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:
p.script._currentCrosshairs = this.$selectCrosshairs("VIEW_FORWARD");
to
Code:
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:
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:
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:
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.


Top
   
PostPosted: Fri Aug 18, 2017 3:14 am 
Offline
Commodore
Commodore
User avatar

Joined: Tue Jan 21, 2014 10:37 pm
Posts: 1707
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...
Quote:
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!
Quote:
I want to take a crack at putting it all in a 'closure'
Can't wait to see it!

_________________
My OXP's


Top
   
PostPosted: Fri Aug 18, 2017 1:42 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Sun Jul 19, 2015 1:09 pm
Posts: 366
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!!


Top
   
PostPosted: Fri Aug 18, 2017 3:04 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Sun Jul 19, 2015 1:09 pm
Posts: 366
@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.


Top
   
PostPosted: Sat Aug 19, 2017 2:30 am 
Offline
Competent
Competent

Joined: Fri Mar 17, 2017 1:49 am
Posts: 44
In case it's not on your list, there's another minor issue in shipWillLaunchFromStation(), just after you award the clock equipment:
Code:
	// 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:
		// 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.


Top
   
PostPosted: Sat Aug 19, 2017 4:41 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Sun Jul 19, 2015 1:09 pm
Posts: 366
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.


Top
   
PostPosted: Sat Aug 19, 2017 8:28 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Sun Jul 19, 2015 1:09 pm
Posts: 366
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


Top
   
PostPosted: Sun Aug 20, 2017 12:01 am 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Sun Jul 19, 2015 1:09 pm
Posts: 366
I just uploaded version 1.6.1 fixing a small typo in the code causing a small error.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 59 posts ]  Go to page Previous 1 2 3 4

All times are UTC


Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 17 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
Powered by phpBB® Forum Software © phpBB Limited