8 const char *bindstr
, *text
;
33 m4x4_zero( ortho
.mtx
.p
);
34 ortho
.mtx
.p
[0][0] = 2.0f
* rl
;
35 ortho
.mtx
.p
[1][1] = 2.0f
* tb
;
36 ortho
.mtx
.p
[3][0] = (fr
+ fl
) * -rl
;
37 ortho
.mtx
.p
[3][1] = (ft
+ fb
) * -tb
;
38 ortho
.mtx
.p
[3][3] = 1.0f
;
39 m4x3_identity( ortho
.transform
);
40 camera_update_view( &ortho
);
41 m4x4_mul( ortho
.mtx
.p
, ortho
.mtx
.v
, ortho
.mtx
.pv
); /* HACK */
42 camera_finalize( &ortho
);
44 gui
.factive
= vg_lerpf( gui
.factive
, gui
.helper_count
?1.0f
:0.0f
,
47 if( gui
.factive
> 0.01f
){
50 glDisable(GL_DEPTH_TEST
);
51 glBlendFunc( GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
52 glBlendEquation(GL_FUNC_ADD
);
54 shader_blitcolour_use();
55 shader_blitcolour_uColour( (v4f
){ 0.0f
, 0.0f
, 0.0f
, gui
.factive
*0.8f
} );
59 f64 loc_t
= (vg
.time
- gui
.location_time
) / 5.0;
60 if( (loc_t
< 1.0) && (gui
.location_time
!= 0.0) ){
61 /* yep this code is a mess, i dont care anymore */
63 glDisable(GL_DEPTH_TEST
);
64 glBlendFunc( GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
65 glBlendEquation(GL_FUNC_ADD
);
67 f32 t
= 1.0f
-vg_minf(1.0f
,vg_minf(loc_t
*20.0f
,2.0f
-loc_t
*2.0f
)),
68 o
= 1.0f
-t
*t
*(2.0f
-t
);
70 shader_blitcolour_use();
71 shader_blitcolour_uColour( (v4f
){ 0.0f
, 0.0f
, 0.0f
, o
*0.5f
} );
75 scale
= dy
*0x1p
-4f
*0.5f
;
78 m3x3_identity( mmdl
);
79 m3x3_scale( mmdl
, (v3f
){scale
,scale
,scale
} );
82 f32 pad
= dy
*0x1p
-4f
*0.125f
;
83 f32 w
= font3d_string_width( &gui
.font
,2,gui
.location
);
85 mmdl
[3][0] = fr
*0.5f
- w
*scale
*0.5f
;
86 mmdl
[3][1] = 0.3f
*ft
+pad
*2.0f
;
88 font3d_bind( &gui
.font
, &ortho
);
89 shader_model_font_uColour( (v4f
){1.2f
,1.2f
,1.2f
,o
} );
90 font3d_simple_draw( &gui
.font
, 2, gui
.location
, &ortho
, mmdl
);
93 font3d_bind( &gui
.font
, &ortho
);
96 scale
= dy
*0x1p
-4f
*0.75f
;
99 m3x3_identity( mmdl
);
100 m3x3_scale( mmdl
, (v3f
){scale
,scale
,scale
} );
103 float pad
= dy
*0x1p
-4f
*0.125f
;
104 mmdl
[3][0] = pad
*2.0f
;
107 for( u32 i
=0; i
<gui
.helper_count
; i
++ ){
108 struct gui_helper
*helper
= &gui
.helpers
[i
];
110 shader_model_font_uColour( (v4f
){1.0f
,1.0f
,1.0f
,1.0f
} );
112 struct font3d_render render
;
113 font3d_begin( &gui
.font
, 2, &ortho
, mmdl
, &render
);
115 render
.u8pch
= (u8
*)helper
->bindstr
;
116 font3d_draw( &render
);
118 const char *make_smaller
= "\x02\xaf\x03 ";
119 render
.u8pch
= (const u8
*)make_smaller
;
120 font3d_draw( &render
);
122 render
.u8pch
= (u8
*)helper
->text
;
123 font3d_draw( &render
);
125 float w
= render
.offset
[0]+1.0f
;
126 mmdl
[3][0] += w
*scale
;
129 gui
.helper_count
= 0;
133 void gui_helper_action( const char *bindstr
, const char *text
)
135 if( gui
.helper_count
>= vg_list_size(gui
.helpers
) )
136 vg_fatal_error( "Too many helpers\n" );
138 struct gui_helper
*helper
= &gui
.helpers
[ gui
.helper_count
++ ];
139 helper
->bindstr
= bindstr
;
144 int gui_location_print_ccmd( int argc
, const char *argv
[] ){
148 vg_strnull( &str
, new_loc
, 64 );
149 for( int i
=0; i
<argc
; i
++ ){
150 vg_strcat( &str
, argv
[i
] );
151 vg_strcat( &str
, " " );
153 if( !strcmp(gui
.location
,new_loc
) ) return 0;
154 vg_strncpy( new_loc
, gui
.location
, 64, k_strncpy_always_add_null
);
155 gui
.location_time
= vg
.time
;
160 VG_STATIC
void gui_init(void)
162 font3d_load( &gui
.font
, "models/rs_font.mdl", vg_mem
.rtmemory
);
163 vg_console_reg_cmd( "gui_location", gui_location_print_ccmd
, NULL
);