Jump to content

Widgets... Is there a guide for them?

Recommended Posts

I'm testing out a stamina system I made for one of my characters.

The stamina stat works so now I want to try and create a visualization for it.


WIDGETS... I have no idea where I should start.

Trying to find the beginning for figuring these things out so I can understand how to create one in the future.



Tried searching for a widget guide but can't really find what I'm looking for.  From their outward appearance they look complicated, but I bet they might be easier than I'm making them out to be.



At any rate, where should I start for figuring these things out?  Did anyone make a guide for widgets that I just seemed to overlook?


Edit: Looking at the mod Always-On Status, I think I got them figured out, at least some of the basic parts of it.  I managed to get what I want to show up.


Edit 2: This is what I managed to come up with out of looking at Always-On Status

local function StatusPostConstruct(self)	if true then		self.staminabar = self:AddChild(Badge("stamina", self.owner))		self.staminabar.bg = self:AddChild(Image("images/status_bgs.xml", "status_bgs.tex"))		self.staminabar.num:SetFont(GLOBAL.NUMBERFONT)		self.staminabar.num:SetSize(28)		self.staminabar.bg:SetScale(.4,.43,0)		self.staminabar.bg:SetPosition(-80.5, -40.5, 0)		self.staminabar.num:SetPosition(3.5, -40.5, 0)		self.staminabar.num:SetScale(1,.78,1)		self.staminabar.num:MoveToFront()		self.staminabar.num:Show()		self.staminabar.bg:MoveToBack()		self.inst:ListenForEvent("panicstaminadelta",			function(inst)				local val = self.owner.PanicStamina or 0				self.staminabar.num:SetString(tostring(math.ceil(val)).."")			end,			self.owner)		self.staminabar:SetPosition(-80.5,0,0)				self.restmeter = self:AddChild(Badge("restmeter", self.owner))		self.restmeter.bg = self:AddChild(Image("images/status_bgs.xml", "status_bgs.tex"))		self.restmeter.num:SetFont(GLOBAL.NUMBERFONT)		self.restmeter.num:SetSize(28)		self.restmeter.bg:SetScale(.4,.43,0)		self.restmeter.bg:SetPosition(-80.5,-70,0)		self.restmeter.num:SetPosition(3.5, -40.5, 0)		self.restmeter.num:SetScale(1,.78,1)		self.restmeter.num:MoveToFront()		self.restmeter.num:Show()		self.restmeter.bg:MoveToBack()		self.inst:ListenForEvent("restmeterdelta",			function(inst)				local val = self.owner.RestMeter or 0				self.restmeter.num:SetString(tostring(math.ceil(val)).."")			end,			self.owner)		self.restmeter:SetPosition(-80.5,-30,0)		self.restmeter:Show()	endendAddClassPostConstruct("widgets/statusdisplays", StatusPostConstruct)


The if true then is just there for me to replace with a config boolean to replace it later.  But I think I figured it out generally well.


Edit 3: Okay I figured out basic widgets (sorta) though I am quite curious as to how the badges handle their meter graphic going up and down.


A new question, how would I make a widget that act's as a bar that fills up or empties depending on the variable it's referencing?  I'm going to dig at the healthbadge and badges a bit for this info, but if anyone who's worked with them knows what does what, some guidance would be helpful.

Edited by Zackreaver
Link to comment
Share on other sites

Widgets generally are very straightforward... As for a bar meter, I believe RPG HUD does this in single-player. Widget code should be pretty much the same between single-player and DST, except that it will get data from the replica or classified instead of the controlling component.

Link to comment
Share on other sites

Widgets can be fairly daunting until you start messing around with them.  They're a lot more simple than they look at first glance.  The only tricky bit is how the default HUD has quite a few levels of nesting in order to abstract the widgets.


The whole widget implementation seems XMLish to me.  It would be interesting to try to create a LuaXML parser that could import XML documents to customize the HUD-- not unlike using XAML to define window elements for WPF apps in VS.



(I apologize if I've exceeded my acronym limit on that last sentence)

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

  • Create New...