]> icculus.org git repositories - btb/d2x.git/blob - ui/barbox.c
remove rcs tags
[btb/d2x.git] / ui / barbox.c
1 /*
2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
11 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
12 */
13
14 #ifdef HAVE_CONFIG_H
15 #include "conf.h"
16 #endif
17
18 #include <stdio.h>
19 #include <stdarg.h>
20
21 #include "fix.h"
22 #include "pstypes.h"
23 #include "gr.h"
24 #include "ui.h"
25 #include "key.h"
26
27
28 static UI_WINDOW * wnd = NULL;
29 static int bar_width, bar_height, bar_x, bar_y, bar_maxlength;
30
31 void ui_barbox_open( char * text, int length )
32 {
33         grs_font * temp_font;
34         int text_width, text_height, avg;
35         int w,h, width, height, xc, yc, x, y;
36
37         w = grd_curscreen->sc_w;
38         h = grd_curscreen->sc_h;
39
40         width = w/3;
41
42         bar_maxlength = length;
43
44         if ( w < 640 )  {
45                 temp_font = grd_curscreen->sc_canvas.cv_font;
46                 grd_curscreen->sc_canvas.cv_font = ui_small_font;
47         }
48
49         gr_get_string_size(text, &text_width, &text_height, &avg );
50         
51         text_width += avg*6;
52         text_width += 10;
53
54         if (text_width > width )
55                 width = text_width;
56
57         height = text_height;
58         height += 30;
59
60         xc = w/2;
61         yc = h/2;
62
63         x = xc - width/2;
64         y = yc - height/2;
65
66         if (x < 0 ) x = 0;
67         if ( (x+width-1) >= w ) x = w - width;
68         if (y < 0 ) y = 0;
69         if ( (y+height-1) >= h ) y = h - height;
70
71         wnd = ui_open_window( x, y, width, height, WIN_DIALOG );
72
73         y = 5 + text_height/2 ;
74
75         ui_string_centered( width/2, y, text );
76
77         y = 10 + text_height;
78         
79         bar_width = width - 15;
80         bar_height = 10;
81         bar_x = (width/2) - (bar_width/2);
82         bar_y = height - 15;
83
84         ui_draw_line_in( bar_x-2, bar_y-2, bar_x+bar_width+1, bar_y+bar_height+1 );
85
86         grd_curscreen->sc_canvas.cv_font = temp_font;
87                 
88 }
89
90 void ui_barbox_update( int position )
91 {
92         int spos;
93
94         spos =  (position * bar_width)/bar_maxlength;
95
96         gr_set_current_canvas( wnd->canvas );
97
98         ui_mouse_hide();
99         gr_setcolor( BM_XRGB(0,0,10));
100         gr_rect( bar_x, bar_y, bar_x+spos-1, bar_y+bar_height-1 );
101         ui_mouse_show();
102         ui_mouse_process();
103
104 }
105
106 void ui_barbox_close()
107 {
108         if (wnd)
109                 ui_close_window(wnd);
110 }