Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » the allegro gui

This thread is locked; no one can reply to it. rss feed Print
the allegro gui
zenofeller_
Member #8,364
February 2007

so what i want is to display a length of text within a fixed size box on the screen, which is not SCREEN but a bitmap, and if it doesn't fit, have it wordwrap and get a scroll bar. so far, d_textbox_proc sounds like the perfect candidate.

everything'd be fine, except the pesky thing doesn't return unless esc is pressed, and thus i get a game that only animates one frame at a time, when the player presses esc. now, this is no end of it's own cuteness and all, but i think i'd rather it returned immediately.

any idea how i do that ? (im sure it is, as usual, trivial).

     char the_text[] = "some text"

     DIALOG the_dialog[] =
{
   { d_textbox_proc,    172, 496,  680,   172,   16,  255,    0,      0,       0,   0,    (void *)the_text,       NULL, NULL  },
   { d_keyboard_proc,     0,   0,    0,    0,   0,  0,    0,      0,  KEY_F1,   0,    NULL,          NULL, NULL  },
   { d_yield_proc,        0,   0,    0,    0,   0,  0,    0,      0,       0,   0,    NULL,                   NULL, NULL  },
   { NULL,                0,   0,    0,    0,   0,  0,    0,      0,       0,   0,    NULL,                   NULL, NULL  }
};

   do_dialog(the_dialog, -1);

(for bonus points, anyone know how i a) get rid of the lines around the box and b) replace the ugly scroll thing with a bitmap)

I, however, am strongly suggesting that you START CAPITALIZING, FUCK IT! (gnolam)

CGamesPlay
Member #2,559
July 2002
avatar

Don't use do_dialog, use a dialog player:init_dialog

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

zenofeller_
Member #8,364
February 2007

i've had partial success with

1void display_chat(BITMAP *bmp, const FONT *f, const char *s, int x, int y, int color, int bg)
2 
3{
4char the_text[] =
5 "some text";
6 
7DIALOG d = { d_textbox_proc, 0, 0, 680, 172, 16, 255/*unused?*/, 1, 0, 0, 0, (void*)the_text, NULL, NULL };
8 
9 gui_set_screen (bmp);
10 
11 d.proc(MSG_START, &d, 0);
12 d.proc(MSG_DRAW, &d, 0);
13 d.proc(MSG_END, &d, 0);
14}

(after a suggestion by kittycat in this thread : http://www.allegro.cc/forums/thread/581296)

namely, it prints just fine, but obviously it doesn't know when the mouse wants the slider moved. im going to look at dialog players next, if i don't figure them out im going to try see what more i need added here to make the scroll mouse-sensitive.

I, however, am strongly suggesting that you START CAPITALIZING, FUCK IT! (gnolam)

CGamesPlay
Member #2,559
July 2002
avatar

By the way, really, start typing properly.

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

zenofeller_
Member #8,364
February 2007

so i've tried

1 DIALOG the_dialog[] =
2{
3 { d_textbox_proc, 0, 0, 680, 172, 16, 255, 1, 0, 0, 0, (void *)the_text, NULL, NULL },
4 
5 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, NULL, NULL, NULL },
6 { d_yield_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8};
9 
10 
11 DIALOG_PLAYER *player = init_dialog(the_dialog, -1);
12 
13 gui_set_screen (bmp);
14 
15 update_dialog(player);

and its significantly slower than the other variant. i wonder why. (also, how do i go about posting a reply in a thread i started as a "question with a definite answer" without locking it ?)

I, however, am strongly suggesting that you START CAPITALIZING, FUCK IT! (gnolam)

CGamesPlay
Member #2,559
July 2002
avatar

Quote:

(also, how do i go about posting a reply in a thread i started as a "question with a definite answer" without locking it ?)

You can't post twice in a row.

The code you showed would be slower by itself, as it would only update the dialog once. Show more code. Type properly.

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

zenofeller_
Member #8,364
February 2007

either snippet i've shown would get updated once per page flip because the function they're in gets called once per flip. the 2nd slows down the flips tho.

or are you saying each call to d.proc in the first triggers a re-draw ? then that should be slower, because it still wouldn't make it to the screen but once, on the page flip. or otherwise what do you mean by "only once" ?

at any rate i'm not sure what i'd show for more code.

and what's with all the typing fascism ?

(now more to the point, what i'd call as a d.proc to make the slider bar functional ? the exgui just uses do_dialog, and i can't seem to find what i need in the manual. i suppose the alternative would be i just use a simple text box and implement scrolling myself... but i'd love to save myself the trouble)

[edit]
well, i've now had enough bashing my head against the wall of this.

what i will do as a work-around is, make the 1st snippet above output to a bitmap that's x+21, y+2 what i need, then blit it at 1,1,x,y of what i need. that way, the annoying as hell border and the unusable scroll are cut out and i'm left with a function that does wordwrapping in a box. i'll implement keyboard shortcuts for scrolling up and down, and that will be the end of it.

it would be absolutely wonderful if there existed some way to use the scroll bar without giving mouse ownership to the "gui" thingy. i understand it's not all that easy or straightforward to do, but that doesn't change the fact it'd be wonderful.

if anyone comes up with anything, i'll be interested to hear, even if it's months later. thanks all.

I, however, am strongly suggesting that you START CAPITALIZING, FUCK IT! (gnolam)

Go to: