Jump to content

[WIP] [1.12.x] HUDReplacer - (v1.2.11-beta)


UltraJohn

Recommended Posts

I think it would be better if we also got the size of the pictures in the dump, also when pressing 'd' it prints two consecutive lines of 'HUDReplacer: ----------' and one of them can be removed... The top one I think, because if their use is to distinguish between the other stuff in the log and the image name, we already have that (the '[][][][][][][]').

So I made a pull request that:

  1. prints the size of images in the dump (and not only their name)
  2. removes the 'HUDReplacer: ------------' above an image's name when pressing 'd'.

https://github.com/UltraJohn/HUDReplacer/pull/2

Link to comment
Share on other sites

On 4/6/2023 at 8:25 AM, Nazalassa said:

Does the mod work without it? (like removing the "using UnityEngine.CoreModule")

I did some digging, and it looks like CoreModule was introduced in KSP 1.8, so there's a good chance it'll work from that version and forward. Someone will have to test though.

Edited by UltraJohn
Link to comment
Share on other sites

  • 3 weeks later...

-- BEGINNING OF TRANSMISSION --

After having tried to get aligned pixels on the screen for various elements (recover button, etc.), the way KSP's UI elements are made internally (the images themselves) and are displayed are completely inconsistent, and I feel like it's a joke. Let me explain the many issues I've found making my texture pack (no doubt I'll find even more).


Inconsistency #1

For a button, you need 4 images: when it's idle, when the mouse's over it, when it's pressed, and when it's disabled.

For some buttons, they're all in the same image. (example below: the cargo button in the VAB's topbar)
inconsistent.1

But for other buttons, these four images are separate! (example below: the crew button in the VAB's topbar)
Normal: inconsistent.2   Over: inconsistent.3   Pressed: inconsistent.4   Disabled: inconsistent.5

And the use of either of these ways is not even consistent! These two buttons are right next to each other in the VAB's topbar.

 

Inconsistency #2

Buttons are not rendered 1:1. If you set only one pixel in an image, it won't appear as a pixel on the screen - or if it does, it's rare and you're lucky. I believe the images are mapped to rectangles (like with UVs) and therefore are a bit distor[d/t]ed. Sometimes part of an image is rendered 1:1 (example: the corners and sides of all the rect_round_...) but not the rest of it (example: the center of all the rect_round_...). But that's not really a problem for borders.

It gets more problematic when it happens to buttons. Personally, I want the buttons (and everything else) to be "clean", which means that I want to be able to set single pixels in a specific color, which is damn hard when the image is slightly off-centered by the rendering engine, or anything like that (especially when it's not rendered 1:1).

Here's an example. I want to show this on the screen:  inconsistent.6
So I have to feed the game this image:
inconsistent.7
These buttons (VAB topbar and similar things) are rendered 3:8, 3 pixels on the screen are made from 8 pixels on the image. I have to use this pattern, which is a grid of 1x1 black and white squares when given to the game:
inconsistent.8

For other buttons, such as the recover button, I give up - it's impossible to get the game display proper pixels! I know it probably wasn't designed to do that, but I think it would be better if they just used 1:1 images - faster rendering, less complexity... Maybe they did that because they want the UI to be scalable, in which case um... (they could do several versions of the images... Bah.)

For some buttons, like the little down arrows that show on the KSC scene to indicate nearby ships, it seems that they are randomly shifted by a fraction of a pixel each time they render differently - changing a pixel can cause that, even without moving the camera or things like that (it could have an influence).
One more thing with this arrow: apparently the image is 58x91 (don't ask why). The game seems to try to make it fit into a 57x91 rectangle. No way to have a "clean" icon then.

 

Inconsistency #3

NAMING! The names of internal images are also completely inconsistent. Example: images for a button with the mouse over it can be either: <name>_Over, <name>_over, <name>_Hover, <name>_hover... A true nightmare.

If you want to have an idea of how nightmare-ish it is, have a look at an extract from the sorted dump of HUDReplacer:

Spoiler
Button_SlideTabList_Side_Inactive
Button_SlideTabList_Side_Normal
Button_SlideTabList_Side_Over
Button_SlideTabList_Side_Pressed
...
TrackingStation_Button_Disabled
TrackingStation_Button_Down
TrackingStation_Button_Normal
TrackingStation_Button_Over
...
appButton_disabled
appButton_highlight
appButton_normal
appButton_pressed
appDivider_arrowDOWN_highlight
appDivider_arrowDOWN_normal
appDivider_arrowDOWN_pressed
...
resultsdialog_delete_active
resultsdialog_delete_disabled
resultsdialog_delete_normal
resultsdialog_delete_over
...
vsd_widget_crew_button_x
vsd_widget_crew_button_x_down
vsd_widget_crew_button_x_over

There are plenty of typos, too.

-- END OF TRANSMISSION --

 

Small "bug" report: Apparently, the images for the KAL editor are loaded when the editor is open, which means that if HUDReplacer only loads things when changing scenes, it doesn't load stuff for the KAL editor until changing scene after opening it. Maybe add a way to specify a list of images that must be loaded at the beginning of the game (loading, main menu, or something)? This can probably fix the problem.

Also maybe do another build, there hasn't been one for the last patch and I can't compile C#.

Edited by Nazalassa
Moved images to Codeberg
Link to comment
Share on other sites

I agree, the stock textures naming convention is questionable at best. It's clear to see that they've designed it as a thing that's done once and then never changed again.

Like you say the weird scaling of some of the files is probably for the sake of the gradients in a lot of the textures, so that they can change the UI scale and have the images not look blocky, probably. It can cause issues if you want to define clear borders.

 

2 hours ago, Nazalassa said:

Small "bug" report: Apparently, the images for the KAL editor are loaded when the editor is open, which means that if HUDReplacer only loads things when changing scenes, it doesn't load stuff for the KAL editor until changing scene after opening it. Maybe add a way to specify a list of images that must be loaded at the beginning of the game (loading, main menu, or something)? This can probably fix the problem.

I've been looking at ways to handle this, as the same happens with mods that use stock textures. They are loaded after the scene switch, so it can randomly replace or not replace those as well. Depending on whether that mod is loaded before or after mine or something.

For example, the Blizzy toolbar generally always gets its textures replaced if using the stock mode, but things like KER will only get some of them replaced, as like with the KAL editor, those textures are not loaded till you actually open the window.

I haven't found an elegant solution yet, but once I figure something out, it should cover both the KAL editor, and any other late loading textures, hopefully.

 

2 hours ago, Nazalassa said:

Also maybe do another build, there hasn't been one for the last patch and I can't compile C#.

Hmm I thought I did, but I'll compile a new version later today. Thanks for reminding me.

Edited by UltraJohn
Link to comment
Share on other sites

Will this replace the KSC HUD only interface textures as in Mission Control, Launchpad etc.?  Not sure these are HUD based but have thought they were.

If anyone is working on a minimalist (thin margins and borders, small pallette, etc) low memory profile texture pack for this mod I'm very interested.

Link to comment
Share on other sites

3 minutes ago, darthgently said:

Will this replace the KSC HUD only interface textures as in Mission Control, Launchpad etc.?  Not sure these are HUD based but have thought they were.

If anyone is working on a minimalist (thin margins and borders, small pallette, etc) low memory profile texture pack for this mod I'm very interested.

Well you can check out this project and get an idea of what's possible:

 

There is also another theme in the works called ObsidianUI, but I'm waiting to hear from the person that is making it, before I can give any news.

Link to comment
Share on other sites

Besides, HUDReplacer does not appear to work in:

  • Mission builder
  • Settings
  • Tracking station

In the last two ones, UI elements are loaded, but it's not possible to perform either a dump, a reload, or to ask what is the image here.

4 minutes ago, darthgently said:

Will this replace the KSC HUD only interface textures as in Mission Control, Launchpad etc.?  Not sure these are HUD based but have thought they were.

If anyone is working on a minimalist (thin margins and borders, small pallette, etc) low memory profile texture pack for this mod I'm very interested.

It can replace any internal image - more on that once I've restarted KSP.

Link to comment
Share on other sites

12 minutes ago, UltraJohn said:

Hi, unlike the previous release, this ZIP file uses backslash ("\") in file paths.

Spoiler
$ unzip -l HUDReplacer.zip
Archive:  HUDReplacer.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2023-04-03 15:11   GameData/HUDReplacer/
     7680  2023-04-03 17:52   GameData/HUDReplacer/HUDReplacer.dll
       87  2023-03-29 17:45   GameData/HUDReplacer/LICENSE.txt
     2329  2023-04-03 15:14   GameData/HUDReplacer/README.md
---------                     -------
    10096                     4 files

$ unzip -l HUDReplacer\ \(1\).zip
Archive:  HUDReplacer (1).zip
  Length      Date    Time    Name
---------  ---------- -----   ----
     7680  2023-04-27 17:31   GameData\HUDReplacer\HUDReplacer.dll
       87  2023-03-29 17:45   GameData\HUDReplacer\LICENSE.txt
     2426  2023-04-07 14:48   GameData\HUDReplacer\README.md
---------                     -------
    10193                     3 files

The ZIP spec requires forward slash ("/"):

https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT

Quote

4.4.17 file name: (Variable)

4.4.17.1 The name of the file, with optional relative path. The path stored MUST NOT contain a drive or device letter, or a leading slash. All slashes MUST be forward slashes '/' as opposed to backwards slashes '\' for compatibility with Amiga and UNIX file systems etc. If input came from standard input, there is no file name field.

FYI, this has prevented this release from being added to CKAN.

Link to comment
Share on other sites

35 minutes ago, HebaruSan said:

Hi, unlike the previous release, this ZIP file uses backslash ("\") in file paths.

 

Thanks for the heads up. I changed to using an automated script through visual studio to zip the files. I will fix it asap.

 

Edit: I've reuploaded the zip files. Should be working now.

Edited by UltraJohn
Link to comment
Share on other sites

1 hour ago, Nazalassa said:

In the last two ones, UI elements are loaded, but it's not possible to perform either a dump, a reload, or to ask what is the image here.

New release: https://github.com/UltraJohn/HUDReplacer/releases/tag/1.0.4-beta

I've added tracking station and settings menu scenes. I don't see an option for the mission builder in KSPAddon.Startup, and since I don't have the making history expansion (I assume it's from there) I am unable to test it.

Link to comment
Share on other sites

16 hours ago, UltraJohn said:

New release: https://github.com/UltraJohn/HUDReplacer/releases/tag/1.0.4-beta

I've added tracking station and settings menu scenes. I don't see an option for the mission builder in KSPAddon.Startup, and since I don't have the making history expansion (I assume it's from there) I am unable to test it.

Works perfectly in settings (which are now finished), but not entirely in the Tracking Station (d/e/q don't do anything, although images are still replaced).

Note: From https://www.kerbalspaceprogram.com/ksp/api/class_k_s_p_addon.html: maybe replacing (or adding to) the beginning of  namespace HUDReplacer  (by)

	[KSPAddon(KSPAddon.Startup.AllGameScenes, false)]
	public class HUDReplacerAllGameScenes : HUDReplacer
	{

	}

would enable it everywhere? Just a guess from the KSP API doc.

Link to comment
Share on other sites

1 hour ago, Nazalassa said:

but not entirely in the Tracking Station (d/e/q don't do anything, although images are still replaced).

You sure? It's working for me in the tracking station with the latest version. Can you double check again that it isn't logging to the console? I tested it on the top left "toggle" buttons for vessels.

1 hour ago, Nazalassa said:

Note: From https://www.kerbalspaceprogram.com/ksp/api/class_k_s_p_addon.html: maybe replacing (or adding to) the beginning of  namespace HUDReplacer  (by)

	[KSPAddon(KSPAddon.Startup.AllGameScenes, false)]
	public class HUDReplacerAllGameScenes : HUDReplacer
	{

	}

would enable it everywhere? Just a guess from the KSP API doc.

I vaguely remember it not covering all the necessary scenes, but I'd have to check again after changing some stuff around. It's quite annoying that there isn't any actual documentation of how it works. But as stated above, the tracking station *should* work. Do let me know.

Link to comment
Share on other sites

10 minutes ago, UltraJohn said:

You sure? It's working for me in the tracking station with the latest version. Can you double check again that it isn't logging to the console? I tested it on the top left "toggle" buttons for vessels.

Whoops, you're right, it works. My bad, sorry.

18 minutes ago, UltraJohn said:

I vaguely remember it not covering all the necessary scenes, but I'd have to check again after changing some stuff around. It's quite annoying that there isn't any actual documentation of how it works.

Maybe just add it (and compile it) and I'll see if it works.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...