HUD Groups

by Forum_account
An easy way to manage screen objects.
ID:691174
 
I just posted an update that adds support for maptext. Previously you could attach text to a screen object by calling it's set_text() proc. This proc still exists and still creates text using images as it previously had.

The new feature is accessed through the set_maptext() proc:

var/HudObject/h = hud_group.add(0, 0)
h.set_maptext("hello!")

// it takes three parameters so you can set the bounds of maptext:
h.set_maptext("hello, world!", 128, 32)

// you can also set these values in the HudGroup.add proc:
h = hud_group.add(0, 0, maptext = "hello, world!", maptext_width = 128)

By default the HudObject's maptext_width and height are both 32, so even if you don't change them you'll at least see something. The way text is positioned is slightly different so you can't only change calls to set_text() to set_maptext(). It'll work but it won't look exactly the same. HudObject.set_text() is still useful. You can easily create custom fonts and its performance is fine for small amounts of text or static text.

I also updated some of the demos to include alternate examples showing how to use maptext instead of the library's text functions.
This is a fantastic library that should save developers a lot of time. I love the way you set up multiple demos in your libraries to show everything they're capable of.

I think I found a very minor bug, though, and I have a couple of suggestions as well. The bug is in the interface demo, within the demo-form. The "my game" default value cannot currently be erased through any means other than pressing delete. My instinct was to click to move to the end of the text and backspace, but backspace working the way delete works would be fine as well.

My suggestions are adding a menu that displays active party members to the party demo, and adding a HUD bar that isn't repeat-able to the health bar demo, or as an additional demo. I only suggest this because you've covered everything else HUD/interface-like related that I can think of, so this would make sense to me and make the library feel more complete; at least to me.

I think I found a very minor bug, though, and I have a couple of suggestions as well. The bug is in the interface demo, within the demo-form. The "my game" default value cannot currently be erased through any means other than pressing delete. My instinct was to click to move to the end of the text and backspace, but backspace working the way delete works would be fine as well.

Do you have the latest version of the Keyboard library? Maybe the backspace macro is missing in yours because it seems to work fine for me. You can't click to place the cursor and I should make the home/end keys work too, but both backspace and delete should work (as well as the arrow keys).
hud-groups.dm:305:error: maptext_width: undefined var
hud-groups.dm:306:error: maptext_height: undefined var
hud-groups.dm:413:error: src.maptext: undefined var
hud-groups.dm:414:error: src.maptext_width: undefined var
hud-groups.dm:415:error: src.maptext_height: undefined var

These errors came with v8. I can get around it by defining the three variables under HudObject, but it shouldn't have any errors to begin with. Looking forward to playing around with this for chat since you noted it's performance is a little better for text that's updated more often.
If you're using the BYOND v494 beta you won't have these errors. I should have added the compile-time check to see what BYOND version you have, but 494 should have been public a long time ago.
Ah, thanks. I've not updated BYOND in a while and it didn't show up under updates so I didn't notice it went public.
In response to Toddab503
please hire me
I re-downloaded both this, and the Keyboard library and that seems to of fixed what I mentioned before. I did notice when typing in that same form, though, that using any letters that had macros assigned to them would trigger the macro. That is with alt being assigned to the macro, so the key shouldn't be doing anything without pressing alt; not sure how that happens or if its a bug on the libraries part but figured I'd mention it.

Uh, thedarkking25 what are you talking about? Hire you for what? why? That seems very random, and unrelated to this library.
That is with alt being assigned to the macro, so the key shouldn't be doing anything without pressing alt; not sure how that happens or if its a bug on the libraries part but figured I'd mention it.

I'm not sure. Is this occurring with a macro you defined yourself in the .dmf file? If you are using the keyboard library, ideally, you'd be using the key_down() proc instead of defining macros yourself.
In response to Forum_account
It was an old macro I had set for all games during testing of a project I haven't touched in ages. There are a few, and it triggered on all of them. Granted, I should remove them, but I would imagine a lot of people have some macros set to all games.