Jump to content

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


UltraJohn

Recommended Posts

10 hours ago, zapsnh said:

This doesn't seem to recolor the text in advanced orbital info and the approach info tabs, only the orbital info one (2nd and 3rd tabs).

Thanks! Forgot about those tabs.

 

1.2.8-beta is released.

https://github.com/UltraJohn/HUDReplacer/releases/tag/1.2.8-beta

 

What's Changed

  • Recolor support for: Advanced maneuver node editor tabs. Uses the same setting as for the other maneuver node color (maneuverNodeEditorTextColor)

 

Full list of available recolor options can be found in the README.

Link to comment
Share on other sites

This is amazing!

Would be great if the debug showed width info about the 9-slice sprite borders. Even better would be to be able to edit those widths somehow.

Also would be nice to be able to recolor the navball throttle and g-force text (really I just want to make it transparent).

Edited by shelshok
Link to comment
Share on other sites

10 minutes ago, shelshok said:

This is amazing!

Would be great if the debug showed width info about the 9-slice sprite borders. Even better would be to be able to edit those widths somehow.

Also would be nice to be able to recolor the navball throttle and g-force text (really I just want to make it transparent).

Hey, thanks :)

I assume those sprites would be equally divided in size. A texture containing 9 sprites would probably be 1/3rd of width and height each.

As for the navball text, is that not just a texture? You could replace it with an empty texture in that case, but otherwise I can take a look at that.

Link to comment
Share on other sites

40 minutes ago, UltraJohn said:

Hey, thanks :)

I assume those sprites would be equally divided in size. A texture containing 9 sprites would probably be 1/3rd of width and height each.

As for the navball text, is that not just a texture? You could replace it with an empty texture in that case, but otherwise I can take a look at that.

"9-slice" sprites have a border width for each side that determines how corners and edges are scaled. They are used for any UI images that get arbitrarily scaled (buttons, progress bars, etc).

If you don't get your borders to fit exactly in the specified scaling region when changing the image, you end up with a distorted blurry mess...

OJUSuEE.png

Unity stores that info in the sprite's meta file. I believe the relevant line is:

Quote

spriteBorder: {x: 6, y: 4, z: 6, w: 4}

More info here: https://docs.unity3d.com/Manual/9SliceSprites.html

 

And yeah, you're right about the throttle/g-force text! They are textures. Just didn't show up in the debug.

Edited by shelshok
Link to comment
Share on other sites

13 minutes ago, shelshok said:

And yeah, you're right about the throttle/g-force text! They are textures. Just didn't show up in the debug.

Actually, adding a blank GaugeThrottle.png and GaugeGee.png doesn't seem to do anything.

Edit... seems they are also in the Navball model in the Squad folder, so I guess that's a job for Navball Replacer?

Edited by shelshok
Link to comment
Share on other sites

22 minutes ago, shelshok said:

"9-slice" sprites have a border width for each side that determines how corners and edges are scaled. They are used for any UI images that get arbitrarily scaled (buttons, progress bars, etc).

If you don't get your borders to fit exactly in the specified scaling region when changing the image, you end up with a distorted blurry mess...

Ah, now I get what you're talking about. It might be possible to do this, but I'd need some example textures to test a possible implementation with if someone can provide that.

EDIT: Nevermind, the border property is readonly :( 

11 minutes ago, shelshok said:

Actually, adding a blank GaugeThrottle.png and GaugeGee.png doesn't seem to do anything.

This should work. Can you post your config?

Edited by UltraJohn
Link to comment
Share on other sites

I just have:

Quote

HUDReplacer:NEEDS[HUDReplacer]
{
    filePath = GameData/UITheme/PluginData/UI/
    priority = 5
}

And these files in that folder:

iSdrtxX.jpg

But it seems they also exist as DDS files in the NavBall prop, which I assume HUDReplacer can't do anything about?

tvdF8JS.jpg

Link to comment
Share on other sites

@shelshok Yeah that looks right. It should be logging into KSP.log whether or not it's finding those textures and loading them. You can do a quick search in the log for the text:

HUDReplacer file paths found:

and it should list your stuff below if it's being loaded.

10 minutes ago, shelshok said:

But it seems they also exist as DDS files in the NavBall prop, which I assume HUDReplacer can't do anything about?

Not sure what these files are, but for HUDReplacer to load them it has to be png.

Edited by UltraJohn
typo
Link to comment
Share on other sites

24 minutes ago, UltraJohn said:

and it should list your stuff below if it's being loaded.

It is listed there, but the changes are not doing anything.

What is also listed in the log though is:

[LOG 12:25:19.340] Load(Texture): Squad/Props/NavBall/GaugeGee
[LOG 12:25:19.341] Load(Texture): Squad/Props/NavBall/GaugeThrottle

Those are the DDS files. Maybe they are overriding the embedded PNG files so replacing the PNGs doesn't do anything?

Link to comment
Share on other sites

1 minute ago, shelshok said:

What is also listed in the log though is:

[LOG 12:25:19.340] Load(Texture): Squad/Props/NavBall/GaugeGee
[LOG 12:25:19.341] Load(Texture): Squad/Props/NavBall/GaugeThrottle

Those are the DDS files. Maybe they are overriding the embedded PNG files so replacing the PNGs doesn't do anything?

You can ignore this. These look to be for the internal NavBall prop in IVA view (the one embedded into the dashboard), not the NavBall on your screen.

Ok I tried myself to replace these two textures without success. I'll take a look at it.

Link to comment
Share on other sites

Awesome, that was quick! Works here.

Totally unrelated and likely out of the scope of this, but I had a thought while making lit and unlit versions of the rcs and sas indicators... Wouldn't it be cool to have alternate lit and unlit elements that would switch based on the vessel's lights being on?

I'm working on a dark theme, but that would be a nice way to toggle light and dark variants of a theme.

I suppose it could be done either by swapping themes or enabling/disabling a theme that has a higher priority or maybe just by appending "-lit" or something to the names of lit copies of the images.

Edited by shelshok
Link to comment
Share on other sites

33 minutes ago, shelshok said:

Totally unrelated and likely out of the scope of this, but I had a thought while making lit and unlit versions of the rcs and sas indicators... Wouldn't it be cool to have alternate lit and unlit elements that would switch based on the vessel's lights being on?

I'm working on a dark theme, but that would be a nice way to toggle light and dark variants of a theme.

I suppose it could be done either by swapping themes or enabling/disabling a theme that has a higher priority.

It's a cool idea, but unfortunately as you say, out of the scope for this framework. It would require a significant amount of work to support this type of switching, for which I am not willing to commit the time to.

HUDReplacer works by replacing all of the textures loaded whenever the scene changes. This process takes a couple of seconds to run as there are a several thousand textures in the scene to go through. This is not noticeable while the game loads the scene as it's just a black screen, but if you were swapping between textures during gameplay you'd notice this as lag every time you turned on/off your lights. That's not ideal.

However, fun fact, you can technically already do what you're asking, but in a very unoptimal and jank way! It's possible to load up the game with a texture pack installed, swap out the assets in the folder and then use the debug mode Q hotkey to refresh the loaded textures. It'll replace the already custom textures with the new ones. Now if you were to write your own plugin that swaps assets on disk between two variants and then calls HUDReplacer's refresher code, you'd have a "functional" on/off texture swap! :D 

You'd basically have to do something like this:

HUDReplacer instance;
public void OnLightsToggled()
{
    YourMod.SwapAssets();
    instance.ReplaceTextures();
}

 

Edited by UltraJohn
Link to comment
Share on other sites

  • 2 weeks later...
On 7/20/2023 at 10:32 PM, UltraJohn said:

You'd basically have to do something like this:

HUDReplacer instance;
public void OnLightsToggled()
{
    YourMod.SwapAssets();
    instance.ReplaceTextures();
}

 

Except that ReplaceTextures() takes "a little bit of time", like 2 seconds with 1,000 or so textures, and two seconds of delay (or more!) when toggling lights is... a bit... long.

Link to comment
Share on other sites

Keep getting errors thrown when trying to use this mod. It gets hit with an exception and the next mod in the mod order is affected as well. Uninstalling the mod fixes the issue. Any ideas?

Edit: The mod it takes down with it is TweakScale if that matters at all.

0EwxoI3.png

Edited by vmatt1203
Link to comment
Share on other sites

10 hours ago, vmatt1203 said:

@UltraJohn Here it is. Took a minute, had to reinstall it and generate a new log.

I don't have access to this file, unfortunately. You need to set the permissions to allow anyone.

But anyway, did you install it through CKAN or manually from github? Make sure you have the dependencies installed as well.

Edited by UltraJohn
Link to comment
Share on other sites

@UltraJohn Yep I'm just a dumbass (kind of). From the ZTheme page on Spacedock he  put the list of requirements with the links and the links take you straight to the GitHub version page so I never saw the Harmony dependency. I should have checked when it didn't work. Also weird I selected "anyone with a link can access" on drive, idk why it didn't work. But everything is working now. Thank you :)

dmHXwmv.png

 

Link to comment
Share on other sites

18 minutes ago, vmatt1203 said:

he  put the list of requirements with the links and the links take you straight to the GitHub version page so I never saw the Harmony dependency.

Ah yes I see what you mean. His forum page does link to github, but also there's a link further up in the description back to this page. On github you can also navigate back to the repository's front page and/or open the readme from the downloaded zip to see the dependencies.

Alternatively you can also install the mod via CKAN and get all of the dependencies installed automatically. That'll save you future headaches! :) 

Link to comment
Share on other sites

  • 4 months later...

@UltraJohn, is it possible to have texture names with slashes in them? I don't think it currently is, but that would be needed for mods that use their own images. For example in RP-1 there is an element which uses RP-1/Resources/confidence_background. If we want to change it, er... We currently can't.


Proposed solution 1:
Maybe HUDReplacer should search in subdirectories too? Like if you have this (in the config file, the only indicated directory is PluginData):

PluginData
 |
 +-- rect_round_dark#69x69.png
 |
 +-- (other normal textures)
 |
 +-- RP-1
      |
      +-- Resources
           |
           +-- rep_background.png
           |
           +-- confidence_background.png

Then the mod would replace images 'rect_round_dark' (69x69), 'RP-1/Resources/rep_background' and 'RP-1/Resources/confidence_background', whereas right now it will not see images in subdirectories or, if these subdirs are in the config file too, it will not add the correct prefix.

Wait no, I have another idea!


Proposed solution 2:
In the mod's config file, there are currently nodes like that:  (2 fields: filePath and priority)

HUDReplacer:NEEDS[HUDReplacer]
{
        filePath = GameData/Naztheme/PluginData/RP-1
        priority = 6
}

Maybe add a third field? Like, prefix = ... which would default to nothing if not set, but would be added in front of the names of any textures found in the directory when replacing textures. Like:

HUDReplacer:NEEDS[HUDReplacer]
{
        filePath = GameData/Naztheme/PluginData/RP-1
        priority = 6
        prefix = RP-1/Resources/
}

That one would be simpler to code (I think).

Link to comment
Share on other sites

Also, would there be a way to change the transparency of some transparent elements? Or at least make them opaque.
Ex.: part info windows that appear when you hover over them in the VAB/SPH part list, PAWs, tooltips, load/save ship dialogs in editor turns out these don't, etc.

The VAB part info windows also have coloration.


Another thing that may be nice would be contextual loading: only load the contents of a directory if we are switching to a certain scene (for example, tracking). That would be nice for things that use the same images in two different scenes (like the exit button in KSC and Editor scenes) but would actually look better if they used different images.

For example, to have a directory that's only loaded when going to the tracking station:

HUDReplacer:NEEDS[HUDReplacer]
{
	filePath = GameData/Naztheme/PluginData/TrackingOnly
	priority = 32767
	onScene = Tracking
}
Edited by Nazalassa
Link to comment
Share on other sites

Posted (edited)

Hey! @Nazalassa

Sorry for getting back late. I've been quite busy lately, but I will take a look at your proposed idea later tonight.

At a quick glance, solution1 would probably not be feasible, as files cannot contain slashes (atleast in Windows,) unless I'm misunderstanding what you mean, but option 2 might work. I'm not sure why this needs the prefix specified, as the code just looks for the texture name itself, and not the whole file path. Again, I might be misunderstanding what you mean. Can you provide a link to the textures in question? e.g. the source to the github page or whatever, so I can get a better idea of how to go about this.

And contextual loading, sounds like a good idea! Will look at that as well. It would be super great if you could provide me with a mockup/test version of what you would like, that way I can quickly plug into my gamedata to implement the functionality exactly how you describe it. Basically just a folder with the textures + config set up for the onScene stuff.

 

Edit: Oh and for transparency, I'm not sure exactly yet. I will have to test. And if you can screenshot some of the elements in question, that would also help me visualize! I don't even remember any of those being transparent to begin with. Then again, I haven't played in a while lol :D 

Edited by UltraJohn
Link to comment
Share on other sites

4 hours ago, UltraJohn said:

I'm not sure why this needs the prefix specified, as the code just looks for the texture name itself, and not the whole file path. Again, I might be misunderstanding what you mean. Can you provide a link to the textures in question? e.g. the source to the github page or whatever, so I can get a better idea of how to go about this.

Some textures (esp. from mods) have names with slashes, e.g. 'RP-1/Resources/rep_background' (see ztheme thread), and since HR only get the internal name from the file name, it can't (yet) replace textures which have internal names with slashes in them.

Example (from the ztheme thread):
FJx0lOm.png

4 hours ago, UltraJohn said:

And contextual loading, sounds like a good idea! Will look at that as well. It would be super great if you could provide me with a mockup/test version of what you would like, that way I can quickly plug into my gamedata to implement the functionality exactly how you describe it. Basically just a folder with the textures + config set up for the onScene stuff.

I think the names should be matched against highlogic.currentscene() or whatever it's called.
Link: <link>

 

4 hours ago, UltraJohn said:

Oh and for transparency, I'm not sure exactly yet. I will have to test. And if you can screenshot some of the elements in question, that would also help me visualize! I don't even remember any of those being transparent to begin with. Then again, I haven't played in a while lol :D 

Tooltips
A1ONO8E.png

Part selector window
LHFWhE1.png

PAW
8wj8lUQ.png

Edited by Nazalassa
<placeholder for edit description>
Link to comment
Share on other sites

1.2.10-beta is released.

https://github.com/UltraJohn/HUDReplacer/releases/tag/1.2.10-beta

 

What's Changed

  • Added new config option: onScene. Check the readme for an explanation.
  • Potential fix for texture paths containing slashes ( / ), for example RP1 textures.

 

@Nazalassa @zapsnh Let me know if this fixes the RP1 issue. It should load the textures now with no additional change necessary in the configs. For example 'RP-1/Resources/confidence_background' is just 'confidence_background.png' the rest is ignored. I haven't tested it much but it seems to work. I've flagged it as a pre-release until I know it won't break other stuff (to avoid ckan update.)

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...