[Added] Add support for monospacing alignment modes to HUDFont

Moderator: GZDoom Developers

Add support for monospacing alignment modes to HUDFont

Postby Player701 » Sat Apr 13, 2019 7:58 am

With this commit, it became possible to pass monospacing parameters to Screen.DrawText. This includes the character alignment mode (left, center, or right). However, this is not yet supported by HUDFont. It appears that it always uses left alignment, as seen on this picture:



HUDFont should probably support these alignment modes as well.

Attached is an example WAD with the code to draw the strings as seen on the picture above. Enable fullscreen HUD to see them.
Attachments
hud_test.wad
(1.28 KiB) Downloaded 13 times
User avatar
Player701
You are now breathing manually.
 
Joined: 13 May 2009
Location: Russian Federation
Discord: Player701#8214

Re: Add support for monospacing alignment modes to HUDFont

Postby Graf Zahl » Sat Apr 13, 2019 8:24 am

The text printing code in the status bar really needs to be consolidated with the main printing function, but since this is a bigger piece of work I was planning to postpone this until after the next release.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Add support for monospacing alignment modes to HUDFont

Postby Player701 » Sat Apr 13, 2019 8:48 am

Well, if this gets added, it will allow me to get rid of the hack where I break the string down to invidual characters and print them separately. This part of code is HUD-related, so I can't use DrawText for that (since all other code there uses HUDFont and its parameters, so I would have to break the abstraction really badly). It seems that at least it is possible to change the type of the corresponding argument in HUDFont.Create from bool to EMonospacing and it won't break any existing code, because falsy values will translate to 0 (Mono_Off) and truthy values will translate to 1 (Mono_CellLeft).

Upd: So I've made a PR to implement the necessary changes. Everything seems to work fine, here's an updated test WAD and screenshot as proof:



The top 3 rows are rendered with Screen.DrawText, the bottom 3 with DrawString using different monospacing modes. The result is the same.
Attachments
hud_test.wad
(1.28 KiB) Downloaded 13 times
User avatar
Player701
You are now breathing manually.
 
Joined: 13 May 2009
Location: Russian Federation
Discord: Player701#8214

Re: Add support for monospacing alignment modes to HUDFont

Postby Player701 » Sat Apr 13, 2019 11:50 am

The PR has been merged, I guess this can be closed?
User avatar
Player701
You are now breathing manually.
 
Joined: 13 May 2009
Location: Russian Federation
Discord: Player701#8214


Return to Closed Feature Suggestions

Who is online

Users browsing this forum: No registered users and 2 guests