10 const char *bindstr
, *text
;
24 k_guitrick_type_ollie
,
25 k_guitrick_type_trick
,
26 k_guitrick_type_backflip
,
35 void gui_helper_action( const char *bindstr
, const char *text
){
36 if( gui
.helper_count
>= vg_list_size(gui
.helpers
) ){
37 vg_error( "Too many helpers\n" );
41 struct gui_helper
*helper
= &gui
.helpers
[ gui
.helper_count
++ ];
42 helper
->bindstr
= bindstr
;
49 if( v3_dist2(localplayer
.rb
.co
,gui
.trick_co
) > 2.0f
){
50 gui
.trick_type
= k_guitrick_type_none
;
53 if( gui
.trick_type
== k_guitrick_type_pump
){
54 gui_helper_action(axis_display_string(k_sraxis_grab
),"Crouch");
56 else if( gui
.trick_type
== k_guitrick_type_backflip
){
57 gui_helper_action(joystick_display_string(k_srjoystick_steer
,1),"Flip");
59 else if( gui
.trick_type
== k_guitrick_type_ollie
){
60 gui_helper_action(button_display_string(k_srbind_jump
),"Ollie");
62 else if( gui
.trick_type
== k_guitrick_type_trick
){
63 gui_helper_action(button_display_string(k_srbind_trick0
),"Shuvit");
64 gui_helper_action(button_display_string(k_srbind_trick1
),"Kickflip");
65 gui_helper_action(button_display_string(k_srbind_trick2
),"Tre-Flip");
67 else if( gui
.trick_type
== k_guitrick_type_isc
){
68 gui_helper_action(button_display_string(k_srbind_camera
),"Camera");
69 gui_helper_action(button_display_string(k_srbind_use
), "Skate/Walk");
81 m4x4_zero( ortho
.mtx
.p
);
82 ortho
.mtx
.p
[0][0] = 2.0f
* rl
;
83 ortho
.mtx
.p
[1][1] = 2.0f
* tb
;
84 ortho
.mtx
.p
[3][0] = (fr
+ fl
) * -rl
;
85 ortho
.mtx
.p
[3][1] = (ft
+ fb
) * -tb
;
86 ortho
.mtx
.p
[3][3] = 1.0f
;
87 m4x3_identity( ortho
.transform
);
88 camera_update_view( &ortho
);
89 m4x4_mul( ortho
.mtx
.p
, ortho
.mtx
.v
, ortho
.mtx
.pv
); /* HACK */
90 camera_finalize( &ortho
);
92 gui
.factive
= vg_lerpf( gui
.factive
, gui
.helper_count
?1.0f
:0.0f
,
93 vg
.time_frame_delta
*2.0f
);
95 if( gui
.factive
> 0.01f
){
98 glDisable(GL_DEPTH_TEST
);
99 glBlendFunc( GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
100 glBlendEquation(GL_FUNC_ADD
);
102 shader_blitcolour_use();
103 shader_blitcolour_uColour( (v4f
){ 0.0f
, 0.0f
, 0.0f
, gui
.factive
*0.8f
} );
107 f64 loc_t
= (vg
.time_real
- gui
.location_time
) / 5.0;
108 if( (loc_t
< 1.0) && (gui
.location_time
!= 0.0) ){
109 /* yep this code is a mess, i dont care anymore */
111 glDisable(GL_DEPTH_TEST
);
112 glBlendFunc( GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
113 glBlendEquation(GL_FUNC_ADD
);
115 f32 t
= 1.0f
-vg_minf(1.0f
,vg_minf(loc_t
*20.0f
,2.0f
-loc_t
*2.0f
)),
116 o
= 1.0f
-t
*t
*(2.0f
-t
);
118 shader_blitcolour_use();
119 shader_blitcolour_uColour( (v4f
){ 0.0f
, 0.0f
, 0.0f
, o
*0.5f
} );
123 scale
= dy
*0x1p
-4f
*0.5f
;
126 m3x3_identity( mmdl
);
127 m3x3_scale( mmdl
, (v3f
){scale
,scale
,scale
} );
130 f32 pad
= dy
*0x1p
-4f
*0.125f
;
131 f32 w
= font3d_string_width( &gui
.font
,2,gui
.location
);
133 mmdl
[3][0] = fr
*0.5f
- w
*scale
*0.5f
;
134 mmdl
[3][1] = 0.3f
*ft
+pad
*2.0f
;
136 font3d_bind( &gui
.font
, &ortho
);
137 shader_model_font_uColour( (v4f
){1.2f
,1.2f
,1.2f
,o
} );
138 font3d_simple_draw( &gui
.font
, 2, k_font_shader_default
,
139 gui
.location
, &ortho
, mmdl
);
142 font3d_bind( &gui
.font
, &ortho
);
145 scale
= dy
*0x1p
-4f
*0.75f
;
148 m3x3_identity( mmdl
);
149 m3x3_scale( mmdl
, (v3f
){scale
,scale
,scale
} );
152 float pad
= dy
*0x1p
-4f
*0.125f
;
153 mmdl
[3][0] = pad
*2.0f
;
156 for( u32 i
=0; i
<gui
.helper_count
; i
++ ){
157 struct gui_helper
*helper
= &gui
.helpers
[i
];
159 shader_model_font_uColour( (v4f
){1.0f
,1.0f
,1.0f
,1.0f
} );
161 struct font3d_render render
= {
164 .shader
= k_font_shader_default
166 font3d_begin( helper
->bindstr
, &ortho
, mmdl
, &render
);
167 font3d_draw( &render
);
169 const char *make_smaller
= "\x02\xaf\x03 ";
170 render
.u8pch
= (const u8
*)make_smaller
;
171 font3d_draw( &render
);
173 render
.u8pch
= (u8
*)helper
->text
;
174 font3d_draw( &render
);
176 float w
= render
.offset
[0]+1.0f
;
177 mmdl
[3][0] += w
*scale
;
180 gui
.helper_count
= 0;
184 int gui_location_print_ccmd( int argc
, const char *argv
[] ){
188 vg_strnull( &str
, new_loc
, 64 );
189 for( int i
=0; i
<argc
; i
++ ){
190 vg_strcat( &str
, argv
[i
] );
191 vg_strcat( &str
, " " );
193 if( !strcmp(gui
.location
,new_loc
) ) return 0;
194 vg_strncpy( new_loc
, gui
.location
, 64, k_strncpy_always_add_null
);
195 gui
.location_time
= vg
.time_real
;
200 VG_STATIC
int gui_showtrick_ccmd( int argc
, const char *argv
[] ){
202 enum guitrick_type type
= k_guitrick_type_none
;
203 if( !strcmp( argv
[0], "pump" ) ) type
= k_guitrick_type_pump
;
204 else if( !strcmp( argv
[0], "flip" ) ) type
= k_guitrick_type_backflip
;
205 else if( !strcmp( argv
[0], "ollie" ) ) type
= k_guitrick_type_ollie
;
206 else if( !strcmp( argv
[0], "trick" ) ) type
= k_guitrick_type_trick
;
207 else if( !strcmp( argv
[0], "misc" ) ) type
= k_guitrick_type_isc
;
209 gui
.trick_type
= type
;
210 v3_copy( localplayer
.rb
.co
, gui
.trick_co
);
216 VG_STATIC
void gui_init(void)
218 font3d_load( &gui
.font
, "models/rs_font.mdl", vg_mem
.rtmemory
);
219 vg_console_reg_cmd( "gui_location", gui_location_print_ccmd
, NULL
);
220 vg_console_reg_cmd( "showtrick", gui_showtrick_ccmd
, NULL
);