[Added] HudMessage cutoff feature and auto word wrap

Moderator: GZDoom Developers

HudMessage cutoff feature and auto word wrap

Postby cybermind » Sun Sep 23, 2012 9:40 am

This is a realisation of feature request http://forum.zdoom.org/viewtopic.php?f=15&t=34113. It adds a new ACS function and a new HudMessage flag:
SetDisplayWindow(x, y, width, height, wrap)
HUDMSG_FORCENOWRAP
which creates a drawing area at x, y coordinates and with width and height size. wrap specifies if the content inside display area should be wrapped.
Function should be used in conjunction with SetHudSize, otherwise it won't have any effect.
So when the drawing area is created, every HudMessage and HudMessageBold call will show it's output only within this area.
To reset drawing, just call SetDisplayWindow(0, 0, 0, 0, 0)
HUDMSG_FORCENOWRAP forces message not to wrap on the next line.
Example:
Code:
Code: Select allExpand view
#include "zcommon.acs"

Script 1 Enter
{
   SetHudSize(640,480,1);

   // first try, without display window
   HudMessage(s:"plain_text_plain_text_plain_text_plain_text_plain_text_plain_text_plain_text_plain_text_plain_text_plain_text_plain_text_plain_text"; HUDMSG_PLAIN, 0, CR_RED, 0.1, 10.1, 10.0);
   // second try, with display window and without word wrap of display window
   SetDisplayWindow(0, 0, 200, 350, 0);
   HudMessage(s:"plain_text_plain_text_plain_text_plain_text_plain_text_plain_text_plain_text_plain_text_plain_text_plain_text_plain_text_plain_text"; HUDMSG_PLAIN, 0, CR_ORANGE, 0.1, 40.1, 10.0);
   // third try, with display window, without word wrap of display window and with disabled word wrap of HUD screen
   HudMessage(s:"force_no_wrap_force_no_wrap_force_no_wrap_force_no_wrap_force_no_wrap"; HUDMSG_PLAIN + HUDMSG_FORCENOWRAP, 0, CR_GOLD, 0.1, 70.1, 10.0);
   // fourth try, with display window and now use display window's word wrap feature
   SetDisplayWindow(0, 0, 200, 350, 1);
   HudMessage(s:"wrap_in_window_wrap_in_window_wrap_in_window_wrap_in_window_wrap_in_window_wrap_in_window_wrap_in_window"; HUDMSG_PLAIN, 0, CR_GREEN, 0.1, 100.1, 10.0);
   // fifth try, same but with disabled word wrap of HUD screen
   HudMessage(s:"wrap_in_window_force_no_wrap"; HUDMSG_PLAIN + HUDMSG_FORCENOWRAP, 0, CR_BLUE, 0.1, 200.1, 10.0);
   // reset drawing
   SetDisplayWindow(0, 0, 0, 0, 0);
   HudMessage(s:"plain_text_plain_text_plain_text_plain_text_plain_text_plain_text_plain_text_plain_text_plain_text_plain_text_plain_text_plain_text"; HUDMSG_PLAIN, 0, CR_BRICK, 0.1, 250.1, 10.0);
}

Image
Patches in attachment are for ZDoom r3879
You do not have the required permissions to view the files attached to this post.
Last edited by cybermind on Mon Sep 24, 2012 8:21 am, edited 2 times in total.
User avatar
cybermind
 
Joined: 03 Jan 2011

Re: HudMessage cutoff feature

Postby Tormentor667 » Sun Sep 23, 2012 12:25 pm

Useful!
User avatar
Tormentor667
needs more detail
 
Joined: 16 Jul 2003
Location: Germany

Re: HudMessage cutoff feature

Postby Xaser » Sun Sep 23, 2012 12:26 pm

How does this work with text? Is there any wrapping, or is that something extra that needs to be added in later?

Otherwise, neat stuff. :)
User avatar
Xaser
anarchivist
 
 
 
Joined: 20 Jul 2003

Re: HudMessage cutoff feature

Postby Jimmy » Sun Sep 23, 2012 12:56 pm

I don't think it was his intention to make text wrap within one of these windows, but I for one would definitely get some mileage out of such a feature.
User avatar
Jimmy
 
 
 
Joined: 10 Apr 2006
Discord: Jimmy#4100
Twitch ID: JimmySquared
Operating System: Windows 10/8.1/8/201x 64-bit

Re: HudMessage cutoff feature

Postby cybermind » Mon Sep 24, 2012 8:20 am

I've made word wrap, patches are reuploaded
User avatar
cybermind
 
Joined: 03 Jan 2011

Re: HudMessage cutoff feature and auto word wrap

Postby Jimmy » Mon Sep 24, 2012 1:50 pm

Ooh, that's sweet. :D Does it wrap individual words correctly as well (your screenshot only shows strings with underscores instead of proper spaces)?
User avatar
Jimmy
 
 
 
Joined: 10 Apr 2006
Discord: Jimmy#4100
Twitch ID: JimmySquared
Operating System: Windows 10/8.1/8/201x 64-bit

Re: HudMessage cutoff feature and auto word wrap

Postby cybermind » Mon Sep 24, 2012 11:00 pm

No, it wraps only symbols, when they have reached the right border of the window
User avatar
cybermind
 
Joined: 03 Jan 2011

Re: HudMessage cutoff feature and auto word wrap

Postby cybermind » Fri Oct 12, 2012 10:01 am

I wonder if this will be added to trunk, because i've already started to make a mod based on this feature.
User avatar
cybermind
 
Joined: 03 Jan 2011

Re: HudMessage cutoff feature and auto word wrap

Postby Nash » Sun Oct 14, 2012 6:15 am

There's always a period of slow activity with ZDoom development because Randy is busy with other things... don't worry about it, if your submission is good and code is clean, it will be adapted eventually. :)
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: HudMessage cutoff feature and auto word wrap

Postby Edward-san » Sun Oct 14, 2012 1:37 pm

it wraps only symbols

so if I get it correctly, it's not possible, right now, to distinguish between a letter and a space?
Edward-san
Mathematics is the language with which God has written the universe. (Galilei)
 
Joined: 17 Oct 2009

Re: HudMessage cutoff feature and auto word wrap

Postby Xaser » Mon Oct 15, 2012 5:30 pm

As nice as this will be for some things (say, a font of icons or somesuch), its use for text is pretty limited because it doesn't wrap words. Not that I'd oppose adding this, of course -- the "wrap" bool can be extended to a flags parameter later on that specifies the wrap type if someone's brave enough to code in word wrapping.
User avatar
Xaser
anarchivist
 
 
 
Joined: 20 Jul 2003

Re: HudMessage cutoff feature and auto word wrap

Postby Jimmy » Mon Oct 15, 2012 11:30 pm

How difficult would it be to add that? It's the only thing stopping this already quite useful feature from being "complete", and isn't it (I hate to use the "j-word") a case of telling the script where the space closest to the border of the cutoff box is, and wrapping the text at that point, instead of at whichever character crosses over the border?

I have no idea what I'm saying.
User avatar
Jimmy
 
 
 
Joined: 10 Apr 2006
Discord: Jimmy#4100
Twitch ID: JimmySquared
Operating System: Windows 10/8.1/8/201x 64-bit

Re: HudMessage cutoff feature and auto word wrap

Postby Project Dark Fox » Tue Oct 16, 2012 4:07 am

Jimmy wrote:How difficult would it be to add that? It's the only thing stopping this already quite useful feature from being "complete", and isn't it (I hate to use the "j-word") a case of telling the script where the space closest to the border of the cutoff box is, and wrapping the text at that point, instead of at whichever character crosses over the border?

I have no idea what I'm saying.

I do.
User avatar
Project Dark Fox
Married Furry Anxiety Bucket
 
Joined: 15 Jul 2005
Location: Louisville, KY USA
Twitch ID: ProjectDarkFox
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: HudMessage cutoff feature and auto word wrap

Postby FDARI » Thu Oct 18, 2012 4:30 am

The strife-menu (dialogue, I mean) breaks between words properly doesn't it? It might not be reusable, but I think functions for breaking text into lines exists. Perhaps, with or without tweaking, it can be extended to provide breaking on words in hudmessages.
User avatar
FDARI
Melbourne is actually pronounced Mel-Byn, as though it were a wizard.
 
Joined: 03 Nov 2009

Re: HudMessage cutoff feature and auto word wrap

Postby randi » Fri Nov 09, 2012 9:22 pm

There was a surprising amount of work left to do to make this useable, but added for r3960. (Well, that commit message got formatted poorly. Oh well.)
Xaser wrote:its use for text is pretty limited because it doesn't wrap words.

I think this was a communication error due to English as a second language. It did wrap words; the only reason it didn't in that screenshot was because there were no space characters for line breaks, so it had to break at character boundaries instead.
User avatar
randi
Site Admin
 
Joined: 10 Jul 2003

Next

Return to Closed Feature Suggestions

Who is online

Users browsing this forum: No registered users and 1 guest