Jump to content

Custom Inspect Self Image


Recommended Posts

(I got a lil help from Rezecib in doing this. Thx, m80!)

 

First off you are going to need the code for this to work properly! Go ahead and place the following code within your modmain.

local G = GLOBALAddClassPostConstruct("widgets/inventorybar", function(self)    local oldrebuild = self.Rebuild    self.Rebuild = function()        oldrebuild(self)        local image_name = "self_inspect_"..self.owner.prefab..".tex"         local atlas_name = "images/hud.xml"        if G.softresolvefilepath("images/avatars/self_inspect_"..self.owner.prefab..".xml") ~= nil then atlas_name = "images/avatars/self_inspect_"..self.owner.prefab..".xml" end        self.inspectcontrol.icon:SetTexture(atlas_name, image_name, "self_inspect_mod.tex")    endend)
Next would be the image itself! If you take your character's current avatar and make it silhouette-looking then you've got your image! (it should be 64x64 pixels in size)
 
Next you're going to need to place this image in your images/avatars folder under the name of self_inspect_[insert_character's_name_here].png
(let the autocompiler do the rest)
 
Next you'll need to require the .tex and .xml that the autocompiler builds from the image via the assets table in the modmain just as if it were an avatar or minimap icon!
Example:
Assets = {    Asset( "IMAGE", "images/avatars/self_inspect_[insert_character's_name_here].tex" ),    Asset( "ATLAS", "images/avatars/self_inspect_[insert_character's_name_here].xml" )}

I've also got the code for the devs to use in order to fix this so that nobody needs the extra postconstruct!

(It's in the spoiler)

in data/scripts/widgets/inventorybar.lua

line 200 changes from this:

 

to this:

local atlas_name = "images/hud.xml"if softresolvefilepath("images/avatars/self_inspect_"..self.owner.prefab..".xml") ~= nil then atlas_name = "images/avatars/self_inspect_"..self.owner.prefab..".xml" end

and line 201 (now 202) changes from this:

self.inspectcontrol = self.root:AddChild(TEMPLATES.IconButton("images/hud.xml", image_name, STRINGS.UI.HUD.INSPECT_SELF, false, false, function() self.owner.HUD:InspectSelf() end, {size = 40}, "self_inspect_mod.tex"))

to this:

self.inspectcontrol = self.root:AddChild(TEMPLATES.IconButton(atlas_name, image_name, STRINGS.UI.HUD.INSPECT_SELF, false, false, function() self.owner.HUD:InspectSelf() end, {size = 40}, "self_inspect_mod.tex"))

Edited by Fidooop
Link to comment
Share on other sites

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
 Share

×
  • Create New...