zscript statusbar - ssbarinfo code conversion to zscript

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
User avatar
ramon.dexter
Posts: 1562
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

zscript statusbar - ssbarinfo code conversion to zscript

Post by ramon.dexter »

So, I started converting my SBARINFO into zscript. Everything works well, except the displayed inventory bar. The main problem is that my inventory display is wider than stock heretic/hexen/strife statusbars (heretic and hexen has statusbar item window wide 30 pixels), but my statusbar has the window 36 pixels wide. So when I use the stock DrawInventoryBar() function, it shows overlapping inv icon bacrounds as well as the selector.

How do I make the DrawInventoryBar() function to account this wider inventory window? Or do I need to completely redefine the DrawInventoryBar() for my customised wider inv windows? I hope not...

edit: Oh, I get it. It's in the Init().




Also, where do I find the "diparms_" defined? I look through gzdoom.pk3 but haven't found anything...

edit: And another question: Where do I define color of the font used?
Last edited by ramon.dexter on Fri Aug 24, 2018 2:17 pm, edited 2 times in total.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49219
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: zscript statusbar - how to define color of font?

Post by Graf Zahl »

ramon.dexter wrote: Also, where do I find the "diparms_" defined? I look through gzdoom.pk3 but haven't found anything...
They are variables of type InventoryBarState, not constants and created in the Init functions for the status bar.
ramon.dexter wrote: edit: And another question: Where do I define color of the font used?
As a parameter of DrawString. It's the CR_BRICK in the following line:
DrawString(mGrnFont, FormatNumber(CPlayer.health, 3), (4, -10), DI_TEXT_ALIGN_LEFT, Font.CR_BRICK);
User avatar
ramon.dexter
Posts: 1562
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: zscript statusbar - how to define color of font?

Post by ramon.dexter »

Many thanks graf. I already found out where are "diparms_" defined.

edit:

another one: How do I define spaces between each inv icon windows? I thought the "innersize" defines that, but it seems to do something else.

edit2:

Weellll, I managed to make the statusbar part of sbarinfo in zscript. That works.

Now I need someone to help me convert this part of the sbarinfo, that is far above my skills. I simply didnt managed to even show me the bacground, so I need somebody to help with this.

Here's the sbarinfo code for the popup screen (like in strife - the status diplaying weapons and ammo amounts):

Code: Select all

CreatePopup status, 3, 10, SlideInBottom, 4;
statusbar PopupStatus, forcescaled
{
	//background
	Alpha 0.95
	DrawImage "HGPSTBK", 3, 10;	
	DrawImage "HGPSTAT", 3, 10;
	
	InInventory "dexpistol", 1 { DrawImage "P_DEPI", 3, 10; }
	InInventory "zscStrifeCrossbow", 1 { DrawImage "P_XBOW", 3, 10; }
	InInventory "dexAssaultRifle", 1 { DrawImage "P_DEAR", 3, 10; }
	InInventory "staffBlaster", 1 { DrawImage "P_ASTF", 3, 10; }
	InInventory "staffBlasterUpgr", 1 { DrawImage "P_USTF", 3, 10; }
	InInventory "BloodSawedoff", 1 { DrawImage "P_BLSW", 3, 10; }
	InInventory "SA24Riotgun", 1 { DrawImage "P_DEAS", 3, 10; }
	InInventory "SniperRifle", 1 { DrawImage "P_SNIP", 3, 10; }
	InInventory "zscFlameThrower", 1 { DrawImage "P_FLMR", 3, 10; }
	InInventory "RivetGun", 1 { DrawImage "P_RVPU", 3, 10; }
	InInventory "zscMauler", 1 { DrawImage "P_MAUL", 3, 10; }
	InInventory "GatLaser", 1 { DrawImage "P_GATS", 3, 10; }
	InInventory "zscStrifeGrenadeLauncher", 1 { DrawImage "P_GRND", 3, 10; }
	InInventory "napalmSpitter", 1 { DrawImage "P_WIMM", 3, 10; }
	
	//Accuracy stat
	DrawNumber 3, smallfont, yellow, Accuracy, alignment(right), 248, 37;
	//Stamina stat
	Drawnumber 3, smallfont, yellow, Stamina, alignment(right), 248, 56;	
	
	//clipofbullets
	DrawNumber 3, smallfont, yellow, Ammo(ammo57mm), alignment(right), 248, 73;
	DrawNumber 3, smallfont, yellow, AmmoCapacity(ammo57mm), alignment(right), 281, 73;
	
	//shells
	DrawNumber 3, smallfont, yellow, Ammo(ammoShell), alignment(right), 248, 81;
	DrawNumber 3, smallfont, yellow, AmmoCapacity(ammoShell), alignment(right), 281, 81;	
	
	//bolts
	DrawNumber 3, smallfont, yellow, Ammo(poisonBolts), alignment(right), 248, 98;
	DrawNumber 3, smallfont, yellow, AmmoCapacity(poisonBolts), alignment(right), 281, 98;	
	DrawNumber 3, smallfont, yellow, Ammo(ElectricBolts), alignment(right), 248, 106;
	DrawNumber 3, smallfont, yellow, AmmoCapacity(ElectricBolts), alignment(right), 281, 106;
	
	//rivets
	DrawNumber 3, smallfont, yellow, Ammo(Rivets), alignment(right), 248, 115;
	DrawNumber 3, smallfont, yellow, AmmoCapacity(Rivets), alignment(right), 281, 115;
	
	//energypod
	DrawNumber 3, smallfont, yellow, Ammo(EnergyPod), alignment(right), 248, 123;
	DrawNumber 3, smallfont, yellow, AmmoCapacity(EnergyPod), alignment(right), 281, 123;
	
	//grenades
	DrawNumber 3, smallfont, yellow, Ammo(HEGrenadeRounds), alignment(right), 248, 139;
	DrawNumber 3, smallfont, yellow, AmmoCapacity(HEGrenadeRounds), alignment(right), 281, 139;
	
	DrawNumber 3, smallfont, yellow, Ammo(PhosphorusGrenadeRounds), alignment(right), 248, 147;
	DrawNumber 3, smallfont, yellow, AmmoCapacity(PhosphorusGrenadeRounds), alignment(right), 281, 147;
	
	//napalm ammo
	DrawNumber 3, smallfont, yellow, Ammo(napalmAmmo), alignment(right), 248, 155;
	DrawNumber 3, smallfont, yellow, AmmoCapacity(napalmAmmo), alignment(right), 281, 155;
	
	//hand grenades
	DrawNumber 3, smallfont, yellow, "grenadeExplosive", alignment(right), 248, 172;	
	DrawNumber 3, smallfont, yellow, "grenadeFire", alignment(right), 248, 180;	
	
}
So, nothing fancy like strife does - the images are fullscreen images with offsets built-in, so I dont need to bother with setting offsets. I'm just unable tofigure out how the popup works in zscript&how to control it. Looking at strife's zscript statusbar don't really help me. I'm barely understanding the code, yet some parts of it are completely unknown to me. So I need someone who's more skilled with zscript.

Return to “Scripting”