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