]> icculus.org git repositories - btb/d2x.git/blob - unused/ui/barbox.c
replace byte with sbyte
[btb/d2x.git] / unused / 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
15 #pragma off (unreferenced)
16 static char rcsid[] = "$Id: barbox.c,v 1.1.1.1 2001-01-19 03:30:15 bradleyb Exp $";
17 #pragma on (unreferenced)
18
19 #include <stdio.h>
20 #include <stdarg.h>
21
22 #include "fix.h"
23 #include "types.h"
24 #include "gr.h"
25 #include "ui.h"
26 #include "key.h"
27
28
29 static UI_WINDOW * wnd = NULL;
30 static int bar_width, bar_height, bar_x, bar_y, bar_maxlength;
31
32 void ui_barbox_open( char * text, int length )
33 {
34         grs_font * temp_font;
35         short text_width, text_height, avg;
36         int w,h, width, height, xc, yc, x, y;
37
38         w = grd_curscreen->sc_w;
39         h = grd_curscreen->sc_h;
40
41         width = w/3;
42
43         bar_maxlength = length;
44
45         if ( w < 640 )  {
46                 temp_font = grd_curscreen->sc_canvas.cv_font;
47                 grd_curscreen->sc_canvas.cv_font = ui_small_font;
48         }
49
50         gr_get_string_size(text, &text_width, &text_height, &avg );
51         
52         text_width += avg*6;
53         text_width += 10;
54
55         if (text_width > width )
56                 width = text_width;
57
58         height = text_height;
59         height += 30;
60
61         xc = w/2;
62         yc = h/2;
63
64         x = xc - width/2;
65         y = yc - height/2;
66
67         if (x < 0 ) x = 0;
68         if ( (x+width-1) >= w ) x = w - width;
69         if (y < 0 ) y = 0;
70         if ( (y+height-1) >= h ) y = h - height;
71
72         wnd = ui_open_window( x, y, width, height, WIN_DIALOG );
73
74         y = 5 + text_height/2 ;
75
76         ui_string_centered( width/2, y, text );
77
78         y = 10 + text_height;
79         
80         bar_width = width - 15;
81         bar_height = 10;
82         bar_x = (width/2) - (bar_width/2);
83         bar_y = height - 15;
84
85         ui_draw_line_in( bar_x-2, bar_y-2, bar_x+bar_width+1, bar_y+bar_height+1 );
86
87         grd_curscreen->sc_canvas.cv_font = temp_font;
88                 
89 }
90
91 int ui_barbox_update( int position )
92 {
93         int spos;
94
95         spos =  (position * bar_width)/bar_maxlength;
96
97         gr_set_current_canvas( wnd->canvas );
98
99         ui_mouse_hide();
100         gr_setcolor( BM_XRGB(0,0,10));
101         gr_rect( bar_x, bar_y, bar_x+spos-1, bar_y+bar_height-1 );
102         ui_mouse_show();
103         ui_mouse_process();
104
105 }
106
107 void ui_barbox_close()
108 {
109         if (wnd)
110                 ui_close_window(wnd);
111 }