BlueBeka Posted October 4, 2021 Share Posted October 4, 2021 I've noticed for thing like inventory images, they need to be 64x64 pixels to fit in the inventory slots properly. Is there anyway I can provide higher resolution images (say 256x256) and have them be scaled down to the right size? On 4K or higher resolution displays, it would look a lot nicer if the images where of a higher resolution. Link to comment https://forums.kleientertainment.com/forums/topic/134201-solved-how-to-use-hd-images/ Share on other sites More sharing options...
Monti18 Posted October 4, 2021 Share Posted October 4, 2021 Have a look at this mod, it does exactly what you are looking for with twigs https://steamcommunity.com/sharedfiles/filedetails/?id=1885733291 1 Link to comment https://forums.kleientertainment.com/forums/topic/134201-solved-how-to-use-hd-images/#findComment-1501657 Share on other sites More sharing options...
me real life Posted October 4, 2021 Share Posted October 4, 2021 1 hour ago, Monti18 said: Have a look at this mod, it does exactly what you are looking for with twigs https://steamcommunity.com/sharedfiles/filedetails/?id=1885733291 Glad this little joke mod could actually be helpful for someone!! I didn't do the code myself but the friend who did is super super competent at modding, so I have to imagine that it's an easy and effective way to do this kind of thing. Link to comment https://forums.kleientertainment.com/forums/topic/134201-solved-how-to-use-hd-images/#findComment-1501670 Share on other sites More sharing options...
BlueBeka Posted October 5, 2021 Author Share Posted October 5, 2021 I've been having a play with trying to copy how that mod works but I'm having a bit of trouble. The issue seems to be that as I'm working on a server mod rather than a client mod. I can't get the client to run the appropriate code. Link to comment https://forums.kleientertainment.com/forums/topic/134201-solved-how-to-use-hd-images/#findComment-1502036 Share on other sites More sharing options...
BlueBeka Posted October 6, 2021 Author Share Posted October 6, 2021 (edited) Do some further testing, it is really starting to seem like that strategy doesn't work at all for custom prefabs. As far as I can tell, custom prefabs don't seem to ever call `Image:SetTexture`. Edited October 6, 2021 by BlueBeka Link to comment https://forums.kleientertainment.com/forums/topic/134201-solved-how-to-use-hd-images/#findComment-1502102 Share on other sites More sharing options...
Monti18 Posted October 6, 2021 Share Posted October 6, 2021 The problem lies in the fact that the path is transformed into a hash, that's why it won't run with your code. Mod Items are generally a hash as the regular items all use RegisterInventoryItemAtlas to save their atlas and tex. I think you can do it this way: Spoiler local G = GLOBAL local TextureReplace = { [G.hash("your_item.tex")] = { G.resolvefilepath('your_new_item.xml'), 'your_new_item.tex', 64 / 256 }, } Assets = { Asset('ATLAS', 'your_new_item.xml') } local Image = G.require('widgets/image') local SetTexture_old = Image.SetTexture local function SetTexture_new(self, atlas, tex, ...) local replace = TextureReplace[tex] or nil if replace == nil then SetTexture_old(self, atlas, tex, ...) return end SetTexture_old(self, replace[1] or atlas, replace[2] or tex, ...) local scale = replace[3] or nil if scale == nil then return end self.inst.UITransform:SetScale(scale, scale, scale) end Image.SetTexture = SetTexture_new By hashing your imagename you will (should?) get the same number and can then compare these two. Another way, but I'm not sure if it works, would be that you do a AddPrefabPostInit of each Item you want to change where you set the inst.components.inventoryitem.atlasname and the inst.components.inventoryitem.imagename to nil. Then you use RegisterInventoryItemAtlas to save these paths so that they are called by inst.replica.inventoryitem:GetAtlas() 1 Link to comment https://forums.kleientertainment.com/forums/topic/134201-solved-how-to-use-hd-images/#findComment-1502364 Share on other sites More sharing options...
BlueBeka Posted October 6, 2021 Author Share Posted October 6, 2021 Thanks. I've got it working now Not sure how I missed that the atlas/tex were hashed. I guess as I wasn't looking for it I missed it. I might make a little dependency mod so not every HD mod needs to overwrite the `Image.SetTexture`. Link to comment https://forums.kleientertainment.com/forums/topic/134201-solved-how-to-use-hd-images/#findComment-1502439 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now