Jump to content

Recommended Posts

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.

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.

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 by BlueBeka

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()

  • Thanks 1

Thanks. I've got it working now :wilson_celebrate:

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...