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:
@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...
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:
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).
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.
@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!
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?
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:
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.
@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.
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.