Recommended Posts

Hornete    879

So, my problem lies in the screenshots below. I have always used the hud size of 3, and never even remembered other hud sizes when doing this mod. After switching to hud size 6 and 3, my custom container widget just spazzes around and honestly i'm not sure what to do, Is there a way I can make the widget next to the inventory bar at all hud sizes?

Any help is apreciated, here's my code
 

Quote

local Vector3 = GLOBAL.Vector3
local modparams = {}

modparams.shooter = {
    widget =
    {
        slotpos = {},
        animbank = "ui_oneslot_1x1",
        animbuild = "ui_oneslot_1x1",
        pos = Vector3(525, -395, 50),
        side_align_tip = 0,     
    },
    type = "shooter",
}

modparams.tracker = {
    widget =
    {
        slotpos = {},
        animbank = "ui_oneslot_1x1",
        animbuild = "ui_oneslot_1x1",
        pos = Vector3(525, -395, 50),
        side_align_tip = 0,     
    },
	acceptsstacks = false,
    type = "tracker",
}

table.insert(modparams.shooter.widget.slotpos, Vector3(0, 0, 0))
table.insert(modparams.tracker.widget.slotpos, Vector3(0, 0, 0))

local containers = require("containers")

for k, v in pairs(modparams) do
	containers.MAXITEMSLOTS = math.max(containers.MAXITEMSLOTS, v.widget.slotpos ~= nil and #v.widget.slotpos or 0)
end

local old_wsetup = containers.widgetsetup

function modparams.shooter.itemtestfn(container, item, slot)
    if not item:HasTag("irreplaceable2") then
        return true
    end

    return false
end

function containers.widgetsetup(container, prefab, data)
	if modparams[prefab or container.inst.prefab] and not data then
		data = modparams[prefab or container.inst.prefab]
	end
	old_wsetup(container, prefab, data)
end

 

 

Screenshot (403).png

Screenshot (404).png

Share this post


Link to post
Share on other sites
Mobbstar    13,859

Where are you anchoring the widget?

from widgets/controls.lua, this is where the inventory bar is anchored:


    self.bottom_root = self:AddChild(Widget("bottom"))
    self.bottom_root:SetScaleMode(SCALEMODE_PROPORTIONAL)
    self.bottom_root:SetHAnchor(ANCHOR_MIDDLE)
    self.bottom_root:SetVAnchor(ANCHOR_BOTTOM)
    self.bottom_root:SetMaxPropUpscale(MAX_HUD_SCALE)

 

  • Thanks 2

Share this post


Link to post
Share on other sites
Hornete    879

Oooh, that does point me a lil closer, thing is. Where do I set/edit the anchor?
 

modparams.shooter = {
    widget =
    {
        slotpos = {},
        animbank = "ui_oneslot_1x1",
        animbuild = "ui_oneslot_1x1",
        pos = Vector3(525, -395, 50),
        side_align_tip = 0,     
    },
    type = "shooter",
}

modparams.tracker = {
    widget =
    {
        slotpos = {},
        animbank = "ui_oneslot_1x1",
        animbuild = "ui_oneslot_1x1",
        pos = Vector3(525, -395, 50),
        side_align_tip = 0,     
    },
	acceptsstacks = false,
    type = "tracker",
}

I'm assuming somewhere here possibly?

Share this post


Link to post
Share on other sites
Hornete    879
AddClassPostConstruct( "widgets/containerwidget", function(self)
	if self.owner:HasTag("wheeler_item") then
		self.bgatlas:SetScaleMode(SCALEMODE_PROPORTIONAL)
		self.bgatlas:SetHAnchor(ANCHOR_MIDDLE)
		self.bgatlas:SetVAnchor(ANCHOR_BOTTOM)
		self.bgatlas:SetMaxPropUpscale(MAX_HUD_SCALE)
		
		self.bgimage:SetScaleMode(SCALEMODE_PROPORTIONAL)
		self.bgimage:SetHAnchor(ANCHOR_MIDDLE)
		self.bgimage:SetVAnchor(ANCHOR_BOTTOM)
		self.bgimage:SetMaxPropUpscale(MAX_HUD_SCALE)
	end
end)

I tried this but same problem.... Can anyone point me somewhere else?

(Also, yes both of my items have the wheeler_item tag)

I've also tried self.inst:HasTag but still nothing.

Share this post


Link to post
Share on other sites
Hornete    879

I'm really sorry for bothering the forums but does anyone have any ideas? This will be my last post here(For real this time)

Share this post


Link to post
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