]> icculus.org git repositories - divverent/nexuiz.git/blob - scmenu/source/base/gfx.qc
Adding my current version of the scmenu to the nexuiz cvs.
[divverent/nexuiz.git] / scmenu / source / base / gfx.qc
1 // NG-Menu
2 // base/gfx.qc
3
4 // cvar ngmenu_menu_height
5 void() gfx_updateres =
6 {
7         Gfx_Real_Width = cvar( "vid_conwidth" );
8         Gfx_Real_Height = cvar( "vid_conheight" );
9         Gfx_Menu_Width = cvar( CVAR_SCMENU_MENU_WIDTH );
10         Gfx_Menu_Height = cvar( CVAR_SCMENU_MENU_HEIGHT );
11
12         if( Gfx_Menu_Width == 0.0 )
13                 Gfx_Menu_Width = GFX_MENU_DEFAULT_WIDTH;
14         if( Gfx_Menu_Height == 0.0 )
15                 Gfx_Menu_Height = GFX_MENU_DEFAULT_HEIGHT;
16 };
17
18 void() Gfx_Init =
19 {
20         local string lWidth, lHeight;
21
22         lWidth = ftos( GFX_MENU_DEFAULT_WIDTH );
23         lHeight = ftos( GFX_MENU_DEFAULT_HEIGHT );
24
25         registercvar( CVAR_SCMENU_MENU_WIDTH, lWidth, CVAR_SAVE );
26         registercvar( CVAR_SCMENU_MENU_HEIGHT, lHeight, CVAR_SAVE );
27
28         gfx_updateres();
29 };
30
31 void() Gfx_Quit =
32 {
33 };
34
35 void() Gfx_Display =
36 {
37         Gfx_ResetClipArea();
38 };
39
40 void() Gfx_Hide =
41 {
42 };
43
44 void() Gfx_Update =
45 {
46         gfx_updateres();
47 };
48
49 void() Gfx_Draw =
50 {
51 };
52
53 bool( string pPic )     Gfx_IsCached =
54 {
55         return iscachedpic( pPic );
56 };
57
58 bool( string pPic )     Gfx_Precache =
59 {
60         if( pPic == "" )
61                 return false;
62
63         if( iscachedpic( pPic ) )
64                 return true;
65         if( precache_pic( pPic ) == pPic )
66                 return true;
67         return false;
68 };
69
70 void( string pPic )     Gfx_Free
71 {
72         // DO NOTHING UNTIL A REF COUNTER IS IMPLEMENTED
73 };
74
75 vector( string pPic )   Gfx_GetImageSize
76 {
77         return drawgetimagesize( pPic );
78 };
79
80 vector( vector pPos )  Gfx_ConToMen =
81 {
82         pPos_x = pPos_x * Gfx_Menu_Width / Gfx_Real_Width;
83         pPos_y = pPos_y * Gfx_Menu_Height / Gfx_Real_Height;
84         pPos_z = 0.0;
85
86         return pPos;
87 };
88
89 vector( vector pPos )  Gfx_MenToCon =
90 {
91         pPos_x = pPos_x * Gfx_Real_Width / Gfx_Menu_Width;
92         pPos_y = pPos_y * Gfx_Real_Height / Gfx_Menu_Height;
93         pPos_z = 0.0;
94
95         return pPos;
96 };
97
98 void() Gfx_ResetClipArea =
99 {
100         drawresetcliparea();
101 };
102
103 vector( vector pPosition ) _Gfx_FitCenter =
104 {
105         return (pPosition + '0.375 0.375 0');
106 };
107
108 float( vector pPosition, float pCharacter, vector pScale, vector pRGB, float pAlpha, float pFlag )
109 Gfx_DrawCharacter =
110 {
111         pPosition = _Gfx_FitCenter( Gfx_MenToCon( pPosition ) );
112         pScale = Gfx_MenToCon( pScale );
113
114         return drawcharacter( pPosition, pCharacter, pScale, pRGB, pAlpha, pFlag );
115 };
116
117 float( vector pPosition, string pText, vector pScale, vector pRGB, float pAlpha, float pFlag )
118 Gfx_DrawString =
119 {
120         pPosition = _Gfx_FitCenter( Gfx_MenToCon( pPosition ) );
121         pScale = Gfx_MenToCon( pScale );
122
123         return drawstring( pPosition, pText, pScale, pRGB, pAlpha, pFlag );
124 };
125
126 float( vector pPosition, string pPicture, vector pSize, vector pRGB, float pAlpha, float pFlag )
127 Gfx_DrawPic =
128 {
129         pPosition = _Gfx_FitCenter( Gfx_MenToCon( pPosition ) );
130         pSize = Gfx_MenToCon( pSize );
131
132         return drawpic( pPosition, pPicture, pSize, pRGB, pAlpha, pFlag );
133 };
134
135 float( vector pPosition, vector pSize, vector pRGB, float pAlpha, float pFlag )
136 Gfx_Fill =
137 {
138         pPosition = _Gfx_FitCenter( Gfx_MenToCon( pPosition ) );
139         pSize = Gfx_MenToCon( pSize );
140
141         return drawfill( pPosition, pSize, pRGB, pAlpha, pFlag );
142 };
143
144 void( float pX, float pY, float pWidth, float pHeight )
145 Gfx_SetClipArea =
146 {
147         local vector lPosition, lSize;
148
149         lPosition_x = pX;
150         lPosition_y = pY;
151
152         lSize_x = pWidth;
153         lSize_y = pHeight;
154
155         lPosition = _Gfx_FitCenter( Gfx_MenToCon( lPosition ) );
156         lSize = Gfx_MenToCon( lSize ) + '1 1 0';
157
158         drawsetcliparea( lPosition_x, lPosition_y, lSize_x, lSize_y );
159 };