About Store Forum Documentation Contact
Donations:
140$/mo



Post Reply 
Dynamically Resizing Message Box
Author Message
Chris Offline
Member

Post: #1
Dynamically Resizing Message Box
Hi, i'd like a dynamically resizing message box for network messages and admin shouts etc.

Header:

Code:
struct MESSAGEBOX
{
Window window;
Text msgtext;
Str message;

void create();
void update();
} extern
MsgBox;

Source:

Code:
void MESSAGEBOX::create() {
Gui  += window .create(Rect_C(0,0,0.5,0.2)).barVisible(false).hide();
window += msgtext .create(Vec2(window.crect.w()/2,-0.1),message);
window    .flag &= ~WIN_MOVABLE;
}
void MESSAGEBOX::update() {
msgtext .set(message);
window .setRect(Rect_C(0,0,msgtext.tds->textWidth(message)+0.1,0.2));
window += msgtext.create(Vec2(window.crect.w()/2,-0.1),message);
}

1. It works, but can it be done more efficiently without window += msgtext.create(...) in the update loop?

2. How can I animate it, when the message changes, so that it blurs, and resizes smoothly?

3. Is there an easy way to add multiple line support, which also blurs and resizes elegantly?

Thanks,
Chris
04-06-2010 04:29 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Dynamically Resizing Message Box
Hello,

1. you can use 'set' and 'setPos', but 'create' is ok too (its fast)

2,3. what would blur exactly?
you can use custom textdraw settings for each text, and adjust its alpha values, so it goes transparent
then use different different Text with different text draw settings which would fade in.
04-08-2010 12:59 AM
Find all posts by this user Quote this message in a reply
Post Reply