Jump to content

Recommended Posts

Hi, how can I get out of nowhere HUD size and equip slots number?

Or, How can I do backpack that will be like inventory bar, but on top of it.

I have done it manually, because I don't know nothing about scaling...

But it doesn't fit in width when other mods add equipable slots.

And it doesn't match in height when HUD size is changed...

 

Edited by zetake
Link to comment
https://forums.kleientertainment.com/forums/topic/109069-solved-inventory-bar/
Share on other sites

HUD size out of nowhere:

20*TheFrontEnd:GetHUDScale()-15

But container widget isn't updated after HUD size change... -.-

 

EDIT: Corrected code for HUD size out of nowhere:

(TheFrontEnd:GetHUDScale()-0.75)/0.035 -- From 0 to 10.

I thought scale was from 0.75 to 1.25, but it is from 0.75 to 1.1

Edited by zetake

This works after pause.

		inst:ListenForEvent("continuefrompause", function()
			print("---------------")
			print("HELLLLLLLLOOO")
		end, GetWorld())

But I don't know how can I get container out of nowhere or how to update widget from there...

Because isnt from there is the map... -.- not my container...

Edited by zetake

Correction...

It gets container inst if it is in fn() and not function(inst)

But, I didn't know about it, because to update container widget, container must be open again...

 

With this code now it works...

Spoiler

	local con = inst.components.container
	inst:ListenForEvent("continuefrompause", function()
		local hs = (TheFrontEnd:GetHUDScale()-0.75)/0.035
		if hs ~= con.hsize then
			con.widgetpos = Vector3(xpos, n*hs-ypos, 0)
			if con:IsOpen() then
				local owner = inst.components.inventoryitem.owner
				con:Close(owner)
				con:Open(owner)
			end
			con.hsize = hs
		end
	end, GetWorld())

 

Back to sesond problem, how to get number of equip slots out of nowhere?

Edited by zetake

After all day of scaling, this seems to be most correct...

ypos = ((22.4-(0.7*hs))*hs)-394+(0.14*hs*(hs-10))

Am I missing something?

Why HUD size is twisting size so much? LEL

Numbers to be show in print needs tostring(), and your variable wasn't correct...

This one return number of equip slots out of mods! LOL

print("Num of equipslots: "..tostring(#EQUIPSLOTS))

Now only problem is if these extra slots will be next to vanilla or not...

But I don't think I want to tweak anymore..

Just now, zetake said:

Numbers to be show in print needs tostring(), and your variable wasn't correct...

This one return number of equip slots out of mods! LOL


print("Num of equipslots: "..tostring(#EQUIPSLOTS))

 

Yeah, it was just an idea off the top of my head to point you in a direction, and you got there :)

Just now, zetake said:

After all day of scaling, this seems to be most correct...


ypos = ((22.4-(0.7*hs))*hs)-394+(0.14*hs*(hs-10))

Am I missing something?

Why HUD size is twisting size so much? LEL

Resolutions and aspect ratios would be my guess. Usually you design for one main resolution, and then code a UI system which automatically positions and resizes everything for all the other resolutions and aspect ratios.

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