Page 2 of 9
Re: [Release] Dangerous HUD
Posted: Sun Jul 09, 2017 4:31 pm
by gsagostinho
Norby wrote:
Then maybe if on screen but use 0 or 1 width and height, or full transparent alpha?
@Norby I tried both solutions but nothing changed
Re: [Release] Dangerous HUD
Posted: Sun Jul 09, 2017 6:18 pm
by Norby
gsagostinho wrote: ↑Sun Jul 09, 2017 4:31 pmI tried both solutions but nothing changed
There is an other way to show and hide images: replace the equipment_required parts to
drawCustomImage.
So put something like this into your hud.plist:
Code: Select all
{
data_source = "DangerousHUD_scanner_circles_background";
selector = "drawCustomImage:";
height = 150.0;
width = 306.0;
x = 0;
y = 66.0;
y_origin = -1;
x_origin = 0;
alpha = 1.0;
},
Then call this in your js:
Code: Select all
player.ship.setCustomHUDDial("DangerousHUD_scanner_circles_background",
"DangerousHUD_scanner_circles_background_red.png");
I am not sure that this will help, just I have no more idea at OXP level.
Re: [Release] Dangerous HUD
Posted: Sun Jul 09, 2017 8:49 pm
by gsagostinho
@Norby many thanks for all your tips, I really appreciate it.
There is an other way to show and hide images: replace the equipment_required parts to drawCustomImage.
I made a test and I have converted all my code to use drawCustomImage instead of awarding/removing equipments, but the performance is pretty much identical as far as I can tell, perhaps even a bit worse than use equipments
I have also tested this OXP with vanilla 1.85, and then those lags are not present at all. It is when I have my huge list of OXPs installed that I start seeing issues. The thing is no other HUD shows these problems, but I guess that this work here is a bit heavier on the computer. Funny enough, my frame rate always stay around 50-60 fps, and the lags occur only on two moments: when the alert change between yellow and red (or vice-versa) and when the mass lock indicator changes its status. But if the alert condition or mass lock condition changes soon after a previous change, then no lag is present which is why I have been suspecting this is an issue with how images are cached.
I honestly ran out of ideas on how to try to optimize this...
Re: [Release] Dangerous HUD
Posted: Mon Jul 10, 2017 7:40 pm
by gsagostinho
Hi all,
I have made some more progress with this HUD and I am now releasing the version 1.1. Here are the new features:
- added new sound for missile warning.
- text on the message display is now also orange.
- fixed small bug with ECM noise sound being heard while docked.
- shipyard screen now also uses the same colour scheme as the other screens.
- new mass lock indicator.
- new green and blue variants.
I will be happy to hear your feedback!
Screenshots
===========
And here is a screenshot of the new mass lock indicator:
Download Links
==============
gsagostinho.DangerousHUD.BlueVariant.v1.1.zip
gsagostinho.DangerousHUD.GreenVariant.v1.1.zip
gsagostinho.DangerousHUD.OrangeVariant.v1.1.zip
Re: [Release] Dangerous HUD
Posted: Mon Jul 10, 2017 9:31 pm
by Cody
Sweet - the Hooloovoo is well-pleased!
Re: [Release] Dangerous HUD
Posted: Mon Jul 10, 2017 10:08 pm
by gsagostinho
Glad to hear that, Cody
Re: [Release] Dangerous HUD
Posted: Mon Jul 17, 2017 3:33 pm
by gsagostinho
Hi all, I just released a new version of this HUD, link updated in the first post. Here is the changelog for version 1.2:
- new pink variant.
- slight modification to the green variation's hue.
- darker scanner's background.
- added glass only mode (i.e. no cockpit).
- fixed wrong dates in version history.
- target reticle now has the same colours as the HUD.
I also made some modifications of Dangerous Keyconfig OXP, so version 1.1 now does the following:
- TAB key now activates fuel injectors.
- Shift + numbers for fast activation of equipments ('!' and '@').
- fixed wrong dates in version history.
Link is updated in the first post (soon I will add all my OXP to the in-game manager, but for now please use that link).
I also added a link for the glass texture I use, in case someone wants to add that effect to the HUD of their preference (instructions included).
Re: [Release] Dangerous HUD
Posted: Tue Jul 18, 2017 11:12 am
by phkb
Thought I'd give your HUD a spin! Very sweet it is too.
One issue for the next release, though:
Code: Select all
21:01:37.817 [script.javaScript.exception.notDefined]: ***** JavaScript exception (DangerousHUD 1.2): ReferenceError: h is not defined
21:01:37.817 [script.javaScript.exception.notDefined]: ../AddOns/HUDs.oxp/gsagostinho.DangerousHUD.OrangeVariant.oxp/Config/script.js, line 232.
Re: [Release] Dangerous HUD
Posted: Tue Jul 18, 2017 11:53 am
by gsagostinho
@phkb thanks catching this. I had removed all variables such as w, p, h and used the full "worldScripts.hudselector", "player.ship", etc. in an attempt to optimize a bit the code, but apparently I had skipped one reference to w. This is fixed, I will release a new version today. Thanks for all the bug spotting with my OXPs!
Re: [Release] Dangerous HUD
Posted: Tue Jul 18, 2017 12:14 pm
by phkb
No problem! BTW, it's actually faster to create a local variable and access that, than to use the fully described element.
Re: [Release] Dangerous HUD
Posted: Tue Jul 18, 2017 12:21 pm
by gsagostinho
phkb wrote:
BTW, it's actually faster to create a local variable and access that, than to use the fully described element.
Really?!
I would never have thought that would be the case, it seemed to me the case with the extra statement in which the local variable is assigned its value would be slower, since it has one more operation to do. Do you know why that is faster?
Re: [Release] Dangerous HUD
Posted: Tue Jul 18, 2017 1:01 pm
by Norby
The time depends on that how many objects are in the used scope what must search through for the wanted data. Local variables are the fastest so if you use something at least two times then faster if you save the pointer into a local variable first. Here is a speed test:
Code: Select all
var a=console.getProfile(function(){for(var i=0;i<10000;i++){player.ship;}});
log("A",a.javaScriptTime+" : "+a.totalTime);
14:46:04.661 [A] GlobalLog (OOJSGlobal.m:256): 0.004737 : 0.004761
var p=player.ship,a=console.getProfile(function(){for(var i=0;i<10000;i++){p;}});
log("A",a.javaScriptTime+" : "+a.totalTime);
14:46:27.965 [A] GlobalLog (OOJSGlobal.m:256): 0.000196 : 0.000198
var a=console.getProfile(function(){for(var i=0;i<10000;i++){worldScripts.telescope;}});
log("A",a.javaScriptTime+" : "+a.totalTime);
14:37:59.036 [A] GlobalLog (OOJSGlobal.m:256): 0.01512 : 0.615031
var w=worldScripts.telescope,a=console.getProfile(function(){for(var i=0;i<10000;i++){w;}});
log("A",a.javaScriptTime+" : "+a.totalTime);
14:37:53.048 [A] GlobalLog (OOJSGlobal.m:256): 0.000192 : 0.000194
So the "p" local variable is 24 times faster than player.ship, and at me where I use about 200 OXPs the "w" is 3170(!) times faster than accessing a script in the long worldScripts array.
Re: [Release] Dangerous HUD
Posted: Tue Jul 18, 2017 4:52 pm
by gsagostinho
@Norby Thanks for the tests, this explains a lot. I was naively thinking that more lines == more things for the CPU to be busy with, but that is silly. I will re-replace those in the HUD's code.
Re: [Release] Dangerous HUD
Posted: Tue Jul 18, 2017 7:02 pm
by gsagostinho
Version 1.3 is released, here is the changelog:
- fixed a small error in the script.js, using a variable which was not defined.
- optimized the script by switching back to local variables.
- improved scanner pulsation.
Re: [Release] Dangerous HUD
Posted: Tue Jul 18, 2017 7:56 pm
by another_commander
Getting many of those with the latest version:
Code: Select all
21:54:04.753 [script.javaScript.exception.unexpectedType]: ***** JavaScript exception (DangerousHUD 1.3): TypeError: player.shiplayer is undefined
21:54:04.753 [script.javaScript.exception.unexpectedType]: ../AddOns/gsagostinho.DangerousHUD.OrangeVariant.oxp/Config/script.js, line 114.