]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/menu/system/mgfx.qc
support for menu_cmd sync to reload all cvar objects - and using that in the video...
[divverent/nexuiz.git] / data / qcsrc / menu / system / mgfx.qc
1 // DP/Nex Menu
2 // system/mgfx.qc
3
4 void( vector pPos, vector pSize, vector pColor, float pAlpha, float pDrawFlag, string pText ) _Mgfx_Debug_Info =
5 {
6         if( !sys_debug_mgfx )
7                 return;
8
9         pText = String_Zone( pText );
10
11         print( "MGFX output: ", vtos( pPos ), " - ", vtos( pSize), " C", vtos( pColor ) );
12         print( " A", ftos( pAlpha ), " X", ftos( pDrawFlag ), " ", pText, "\n" );
13
14         String_Free( pText );
15 };
16
17 /*
18 ===================
19 Menu_MenToOrg
20 ===================
21 */
22 vector( vector pPos )  Menu_MenToOrg =
23 {
24         return pPos - Menu_Origin;
25 };
26
27 /*
28 ===================
29 Menu_OrgToMen
30 ===================
31 */
32 vector( vector pPos )  Menu_OrgToMen =
33 {
34         return pPos + Menu_Origin;
35 };
36
37 /*
38 ===================
39 Menu_ConToOrg
40 ===================
41 */
42 vector( vector pPos )  Menu_ConToOrg =
43 {
44         pPos = Gfx_ConToMen( pPos );
45         return Menu_MenToOrg( pPos );
46 };
47
48 /*
49 ===================
50 Menu_OrgToCon
51 ===================
52 */
53 vector( vector pPos )  Menu_OrgToCon =
54 {
55         pPos = Menu_OrgToMen( pPos );
56         return Gfx_MenToCon( pPos );
57 };
58
59 /*
60 ===================
61 Menu_DrawCharacter
62 ===================
63 */
64 float( vector pPosition, float pCharacter, vector pScale, vector pRGB, float pAlpha, float pFlag )
65 Menu_DrawCharacter =
66 {
67         _Mgfx_Debug_Info( pPosition, pScale, pRGB, pAlpha, pFlag, strcat( "DrawChar: ", ftos( pCharacter ) ) );
68
69         pPosition = Menu_OrgToMen( pPosition );
70         return Gfx_DrawCharacter( pPosition, pCharacter, pScale, pRGB, pAlpha, pFlag );
71 };
72
73 /*
74 ===================
75 Menu_DrawString
76 ===================
77 */
78 float( vector pPosition, string pText, vector pScale, vector pRGB, float pAlpha, float pFlag )
79 Menu_DrawString =
80 {
81         // TODO: FIXME: do I really want this?
82         if( !pText )
83                 return 1;
84
85         _Mgfx_Debug_Info( pPosition, pScale, pRGB, pAlpha, pFlag, strcat( "DrawString: ", pText ) );
86
87         pPosition = Menu_OrgToMen( pPosition );
88         return Gfx_DrawString( pPosition, pText, pScale, pRGB, pAlpha, pFlag );
89 };
90
91 /*
92 ===================
93 Menu_DrawPicture
94 ===================
95 */
96 float( vector pPosition, string pPicture, vector pSize, vector pRGB, float pAlpha, float pFlag )
97 Menu_DrawPicture =
98 {
99         _Mgfx_Debug_Info( pPosition, pSize, pRGB, pAlpha, pFlag, strcat( "DrawPicture: ", pPicture ) );
100
101         pPosition = Menu_OrgToMen( pPosition );
102         return Gfx_DrawPic( pPosition, pPicture, pSize, pRGB, pAlpha, pFlag );
103 };
104
105 /*
106 ===================
107 Menu_Fill
108 ===================
109 */
110 float( vector pPosition, vector pSize, vector pRGB, float pAlpha, float pFlag )
111 Menu_Fill =
112 {
113         _Mgfx_Debug_Info( pPosition, pSize, pRGB, pAlpha, pFlag, "Fill" );
114
115         pPosition = Menu_OrgToMen( pPosition );
116         return Gfx_Fill( pPosition, pSize, pRGB, pAlpha, pFlag );
117 };
118
119 /*
120 ===================
121 Menu_SetClipArea
122 ===================
123 */
124 void( float pX, float pY, float pWidth, float pHeight )
125 Menu_SetClipArea =
126 {
127         local vector lPosition;
128         local vector lDelta;
129         local vector lSize;
130
131         lPosition_x = pX;
132         lPosition_y = pY;
133         lPosition = Menu_OrgToMen( lPosition);
134
135         lSize_x = pWidth;
136         lSize_y = pHeight;
137         // clip it to the current clip area
138         lDelta = Util_GetClipDelta( lPosition, Menu_Clip_Position, Menu_Clip_Size );
139         lPosition = lPosition + lDelta;
140         lSize = Util_ClipRect( lPosition, lSize - lDelta, Menu_Clip_Position, Menu_Clip_Size );
141
142         Gfx_SetClipArea( lPosition_x, lPosition_y, pWidth, pHeight );
143 };
144
145 /*
146 ===================
147 Menu_ResetClipArea
148 ===================
149 */
150 void()
151 Menu_ResetClipArea =
152 {
153         if( Menu_Clip_Position == '0 0 0' && Menu_Clip_Size == '0 0 0' )
154                 Gfx_ResetClipArea();
155         else
156                 Gfx_SetClipArea( Menu_Clip_Position_x, Menu_Clip_Position_y, Menu_Clip_Size_x, Menu_Clip_Size_y );
157 }
158