Drawing on player screen

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
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
Apeirogon
Posts: 1606
Joined: Mon Jun 12, 2017 12:57 am

Drawing on player screen

Post by Apeirogon »

"Simple" question, how draw something on player screen in zscript? Like, table with some debug/cheat informations or number with signature what that number means?

I try look into d4d zgui and lost. What element, what list menu, what network process event? Сant understand from which side approach to understand.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: Drawing on player screen

Post by Matt »

The short answer for most of us non-technically-inclined users is to use ACS HudMessage for now. Folks are working on a much better interface for this sort of thing in ZS and we're better off waiting for that than kludge something together that would become obsolete/deprecated/grossly inefficient in comparison in a couple months.

More details here.
User avatar
Apeirogon
Posts: 1606
Joined: Mon Jun 12, 2017 12:57 am

Re: Drawing on player screen

Post by Apeirogon »

ACS cant print some stored variable in item or from some actor. Well, technicaly it can, but it require call to machine spirit and dance with tambourine.

Question is how much to wait? d4d hud already exist and work, and in new version of gzdoom from them dont "falls off" anything.
From what I see, there are just trying to simplify drawing of anything. And there are already began battle with windmills of La Mancha(reference to Don Quixote) for PostUITick. Im not saying its not necessary, I say it can wait until we have "simple way to draw something on player screen"(TM).
User avatar
krokots
Posts: 296
Joined: Tue Jan 19, 2010 5:07 pm

Re: Drawing on player screen

Post by krokots »

Apeirogon wrote:"Simple" question, how draw something on player screen in zscript? Like, table with some debug/cheat informations or number with signature what that number means?

I try look into d4d zgui and lost. What element, what list menu, what network process event? Сant understand from which side approach to understand.
So, for simplicity, you can create two things in ZScript which adds graphics to player screen : HUD and MENU. I get that you want to add some values to HUD, so it would show them all the time.
It is not that hard, you need to :
1) Create own HUD / Status bar class which inherits from BaseStatusBar. I recommend just to copy all class DoomStatusBar from doom_sbar.txt in statusbar folder in gzdoom.pk3, rename it to some other class name.
2) In MAPINFO add information about your new hud

Code: Select all

Gameinfo
{
	StatusBarClass = "MyNewHUD"
}
3) Now you can add stuff to the copied Doom HUD. Inside this class you have two functions : protected void DrawMainBar (double TicFrac) and protected void DrawFullScreenStuff (). Just add to that what you want to draw.
you can draw additional stuff using these functions:

Code: Select all

	native void DrawTexture(TextureID texture, Vector2 pos, int flags = 0, double Alpha = 1., Vector2 box = (-1, -1), Vector2 scale = (1, 1));
	native void DrawImage(String texture, Vector2 pos, int flags = 0, double Alpha = 1., Vector2 box = (-1, -1), Vector2 scale = (1, 1));
	native void DrawString(HUDFont font, String string, Vector2 pos, int flags = 0, int translation = Font.CR_UNTRANSLATED, double Alpha = 1., int wrapwidth = -1, int linespacing = 4);
If you need a pointer to player, use : CPlayer.mo. This is an player actor (PlayerPawn) that is seeing the HUD.
If you need additional info how to add stuff - sprites or text to HUD, i'll help.
User avatar
Apeirogon
Posts: 1606
Joined: Mon Jun 12, 2017 12:57 am

Re: Drawing on player screen

Post by Apeirogon »

What means vector2 box?
From what point start coordinate for vector2 pos?
Draw main bar is sbar with doom guy face and draw fullscreen stuff draw something on entire screen!?
Draw string accepts strings from string array?
User avatar
krokots
Posts: 296
Joined: Tue Jan 19, 2010 5:07 pm

Re: Drawing on player screen

Post by krokots »

Apeirogon wrote:What means vector2 box?
From what point start coordinate for vector2 pos?
Draw main bar is sbar with doom guy face and draw fullscreen stuff draw something on entire screen!?
Draw string accepts strings from string array?
I think box is just cropping box(cropping is a word? box that crops), ignore it for now or experiment what can it do (I didn't use it I think).
Draw main bar yes, it's the bar with DoomGuy's face, and full screen is the one with...well, full screen. Health and ammo in corners.
Draw string will accept any string, from array too (that is MyArray of strings).

I don't remember how coords in HUD work exactly, but when I started creating my own HUD, i just thrown in pos (0, 0), just to see where it draws stuff. I recommend starting with 0, 0, see where it draws, and then correct it.

Return to “Scripting”