Add support for monospacing alignment modes to HUDFont

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: Add support for monospacing alignment modes to HUDFont

Re: Add support for monospacing alignment modes to HUDFont

by Player701 » Sat Apr 13, 2019 10:50 am

The PR has been merged, I guess this can be closed?

Re: Add support for monospacing alignment modes to HUDFont

by Player701 » Sat Apr 13, 2019 7: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 39 times

Re: Add support for monospacing alignment modes to HUDFont

by Graf Zahl » Sat Apr 13, 2019 7: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.

Add support for monospacing alignment modes to HUDFont

by Player701 » Sat Apr 13, 2019 6: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 41 times

Top