ID:2014078
 
(See the best response by Ter13.)
Problem description:

Im looking for a way to create a hud based chat that's over the map. I've tried looking up libraries for it but im not really finding anything that fits the need so far. Does anyone have a library in mind that can do this, or is anyone willing to explain to me in logic how I could go about putting this together? Thanks

As a start, I know how to use maptext and such, but some of the issues I'm coming up with in my head are, how do I add cut-off and scrolling?

In my opinion the best way is create world list -
var/tmp/list/Chat=list()

And when you send message proc just add it for chat list.
For scrolling i usualy use copytext() proc.
Well, there would be messages that are specific to players, or groups of people, things that don't apply to everyone. Maybe I'm misunderstanding what you're saying, but it seems that I would need a list for every player's chatbox.

How would I go about using copytext() for that? Keep in mind I'm talking about displaying text that may be half viewable, but then again it'd probably be best to just have it jump single lines instead of move it pixels at a time.

How would I get the chatbox to be functional as in, using the arrow buttons to scroll up an down? Seems I'd need to save the position and update which lines of text are being shown via that position.
Best response
There is no current method to get the width or height of maptext on the server. You won't be able to do this line-by-line.
In response to Ter13
I could just pick so many entries and display them, they'd all be the same size for the most part so I wouldnt need to check the size, just know how much can fit at once.
In response to Ter13
Ter13 wrote:
There is no current method to get the width or height of maptext on the server. You won't be able to do this line-by-line.

Do you think the 510 update will open doors for this possibility, given that there will be text processing support?
Probably not. Text rendering happens on the client, and there's a lot of things that can happen that can cause a client to render text differently from another client.

For starters, map.style can differ from client to client, causing the text to be drawn in a different font face, etc.

The server has no say on how maptext is rendered, so it'd be very difficult to have a reasonable approximation of text rendering returning any kind of a size.
There is a way to get the width/height of maptext, but it's hacky and potentially unreliable. Basically, you use a client-side browser and export the maptext you want to get the size of on the client and use the browser to insert the message into a DIV. Then you can use javascript to get the innerwidth/height of said div to get the information on that text and send it back to the server.
I'm somewhat guardedly open to adding some way of polling the maptext sizes (not in 510 though), but because it can vary by client such a thing would have to be done only on a per-client basis. It can even technically vary by rendering mode, but the two modes try to stay in sync as much as they can.
Now, please take this with a grain of salt here, Lum, because it's not meant to be a criticism.

Maptext is awesome. But in the context of networked game development, particularly in an engine that emphasizes retro pixel art games, any feature that results in unreliable output between clients for reasons not desired by the developer is a bad one.

The idea of polling text width/height from the server to the client back to the server, well... It's not a bad stopgap and I welcome it in the absence of anything else, but I reckon that it's symptomatic of a feature that was applied inappropriately in the first place.

The other thing that would make something like this infinitely more useful is some way of transforming maptext's drawn boundaries so that you could simply apply the transformation to the maptext and it would appear to scroll. Something like that would nicely sidestep the issue, but of course, I can't begin to understand the way that the current implementation works without seeing the code for myself.
In response to Ter13
Ter13 wrote:
Now, please take this with a grain of salt here, Lum, because it's not meant to be a criticism.

Maptext is awesome. But in the context of networked game development, particularly in an engine that emphasizes retro pixel art games, any feature that results in unreliable output between clients for reasons not desired by the developer is a bad one.

Truth be told, I'm in full agreement. Of course this is a problem with the web at large; ideally we always want a specific presentation, and in practice the client doing the rendering can have a lot of variation.

I would prefer, and even Tom mentioned this a few times, a way of simply sending the text from the server and including all of the layout info necessary to ensure a consistent rendering. DmiFontsPlus already has code to that end, but designed for icon math.

The hard part is, we'd need the font to be in some kind of easily accessible format that was readable by both Windows and Linux and could handle the font consistently. To be flexible on size, it wouldn't be feasible to simply render the font beforehand; there'd have to be some kind of server-side library to handle the text metrics and drawing. The last time I looked into FreeType, though, I was whelmed. I've kept it in mind for a while but I've been loath to actually do anything with it.
Guess I probably wont get much insight out of this topic, Lol.