HudMessage cutoff feature and auto word wrap

Moderator: GZDoom Developers

cybermind
Posts: 64
Joined: Mon Jan 03, 2011 3:33 pm

HudMessage cutoff feature and auto word wrap

Post by cybermind »

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 all

#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
Attachments
patch.zip
(2.66 KiB) Downloaded 94 times
Last edited by cybermind on Mon Sep 24, 2012 8:21 am, edited 2 times in total.
User avatar
Tormentor667
Posts: 13533
Joined: Wed Jul 16, 2003 3:52 am
Contact:

Re: HudMessage cutoff feature

Post by Tormentor667 »

Useful!
User avatar
Xaser
 
 
Posts: 10772
Joined: Sun Jul 20, 2003 12:15 pm
Contact:

Re: HudMessage cutoff feature

Post by Xaser »

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
Jimmy
 
 
Posts: 4720
Joined: Mon Apr 10, 2006 1:49 pm
Preferred Pronouns: He/Him
Contact:

Re: HudMessage cutoff feature

Post by Jimmy »

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.
cybermind
Posts: 64
Joined: Mon Jan 03, 2011 3:33 pm

Re: HudMessage cutoff feature

Post by cybermind »

I've made word wrap, patches are reuploaded
User avatar
Jimmy
 
 
Posts: 4720
Joined: Mon Apr 10, 2006 1:49 pm
Preferred Pronouns: He/Him
Contact:

Re: HudMessage cutoff feature and auto word wrap

Post by Jimmy »

Ooh, that's sweet. :D Does it wrap individual words correctly as well (your screenshot only shows strings with underscores instead of proper spaces)?
cybermind
Posts: 64
Joined: Mon Jan 03, 2011 3:33 pm

Re: HudMessage cutoff feature and auto word wrap

Post by cybermind »

No, it wraps only symbols, when they have reached the right border of the window
cybermind
Posts: 64
Joined: Mon Jan 03, 2011 3:33 pm

Re: HudMessage cutoff feature and auto word wrap

Post by cybermind »

I wonder if this will be added to trunk, because i've already started to make a mod based on this feature.
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: HudMessage cutoff feature and auto word wrap

Post by Nash »

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. :)
Edward-san
Posts: 1774
Joined: Sat Oct 17, 2009 9:40 am

Re: HudMessage cutoff feature and auto word wrap

Post by Edward-san »

it wraps only symbols
so if I get it correctly, it's not possible, right now, to distinguish between a letter and a space?
User avatar
Xaser
 
 
Posts: 10772
Joined: Sun Jul 20, 2003 12:15 pm
Contact:

Re: HudMessage cutoff feature and auto word wrap

Post by Xaser »

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
Jimmy
 
 
Posts: 4720
Joined: Mon Apr 10, 2006 1:49 pm
Preferred Pronouns: He/Him
Contact:

Re: HudMessage cutoff feature and auto word wrap

Post by Jimmy »

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
Project Shadowcat
Posts: 9369
Joined: Thu Jul 14, 2005 8:33 pm
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Blacksburg, SC USA
Contact:

Re: HudMessage cutoff feature and auto word wrap

Post by Project Shadowcat »

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
FDARI
Posts: 1097
Joined: Tue Nov 03, 2009 9:19 am

Re: HudMessage cutoff feature and auto word wrap

Post by FDARI »

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
randi
Site Admin
Posts: 7746
Joined: Wed Jul 09, 2003 10:30 pm
Contact:

Re: HudMessage cutoff feature and auto word wrap

Post by randi »

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.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”