-VG_STATIC int menu_controller_inf( struct menu_btn_userdata ud )
-{
- if( (game_menu.page & k_menu_page_settings)
- && (ud.i == steam_display_controller) )
- return 1;
- return 0;
-}
-#endif
-
-struct menu_button
-{
- const char *name;
-
- int (*fn_visibility)( struct menu_btn_userdata ud );
- struct menu_btn_userdata user;
-
- void (*fn_press)( int event );
-
- const char *ll,
- *lu,
- *lr,
- *ld;
-
- mdl_mesh *mesh;
- float falpha, fsize;
-}
-VG_STATIC menu_buttons[] =
-{
- {
- "text_quit", menu_vis, {.i=k_menu_page_main|k_menu_page_quit},
- .fn_press = menu_btn_quit,
- .ld="text_reset", .lr="text_settings", /*.ll="text_map"*/
- },
- {
- "text_quitty", menu_vis, {.i=k_menu_page_quit}
- },
- {
- "text_yes", menu_vis, {.i=k_menu_page_quit},
- .fn_press = menu_btn_fuckoff
- },
-{
- "text_reset", menu_vis, {.i=k_menu_page_main},
- .fn_press = menu_btn_reset,
- .lu="text_quit", .ld="text_skater", /*.ll="text_map",*/ .lr="text_settings"
-},
-{
- "text_skater", menu_vis, {.i=k_menu_page_main|k_menu_page_skater},
- .fn_press = menu_btn_skater,
- .lu="text_reset", /*.ll="text_map",*/ .lr="text_settings"
-},
-/*
-{
- "text_map", menu_vis, {.i=k_menu_page_main},
- .fn_press = menu_btn_map,
- .lr="text_reset"
-},
-*/
-{
- "text_settings", menu_vis, {.i=k_menu_page_main|k_menu_page_settings},
- .fn_press = menu_btn_settings,
- .ll="text_reset"
-},
-{
- "skater_left", menu_vis, {k_menu_page_skater}
-},
-{
- "skater_right", menu_vis, {k_menu_page_skater}
-},
-
-{
- "fov_slider", menu_vis, {k_menu_page_settings},
- .ld="text_invert_y"
-},
-{ "fov_info", menu_vis, {k_menu_page_settings} },
-
-{
- "vol_slider", menu_vis, {k_menu_page_settings},
- .lu="res_slider"
-},
-{ "vol_info", menu_vis, {k_menu_page_settings} },
-
-{
- "text_invert_y", menu_vis, {k_menu_page_settings},
- .fn_press = menu_btn_invert_y,
- .lu = "fov_slider", .ld="text_blur"
-},
-{
- "text_invert_y_check", menu_settings_if, {.ptr_generic=&cl_invert_y}
-},
-{
- "text_blur", menu_vis, {k_menu_page_settings},
- .fn_press = menu_btn_blur,
- .lu="text_invert_y", .ld="res_slider"
-},
-{
- "text_blur_check", menu_settings_if, {.ptr_generic=&cl_blur}
-},
-{
- "res_slider", menu_vis, {k_menu_page_settings},
- .ld = "vol_slider", .lu = "text_blur"
-},
-{
- "res_info", menu_vis, {k_menu_page_settings},
-},
-#if 0
-{ "ctr_xbox", menu_controller_inf, {k_steam_controller_type_xbox}},
-{ "ctr_xbox_text", menu_controller_inf, {k_steam_controller_type_xbox}},
-{ "ctr_steam", menu_controller_inf, {k_steam_controller_type_steam}},
-{ "ctr_steam_text", menu_controller_inf, {k_steam_controller_type_steam}},
-{ "ctr_deck", menu_controller_inf, {k_steam_controller_type_steam_deck}},
-{ "ctr_deck_text", menu_controller_inf, {k_steam_controller_type_steam_deck}},
-{ "ctr_ps", menu_controller_inf, {k_steam_controller_type_playstation}},
-{ "ctr_ps_text", menu_controller_inf, {k_steam_controller_type_playstation}},
-{ "ctr_kbm", menu_controller_inf, {k_steam_controller_type_keyboard}},
-{ "ctr_kbm_text", menu_controller_inf, {k_steam_controller_type_keyboard}},
-#endif
-{
- "text_paused", menu_vis, {k_menu_page_main}
-},
-};
-
-VG_STATIC int menu_get_loc( const char *loc )
-{
- for( int i=0; i<vg_list_size(menu_buttons); i++ )
- if( !strcmp( menu_buttons[i].name, loc ) )
- return i;
-
- assert(0);
- return 0;
-}
-
-VG_STATIC void menu_btn_reset( int event )
-{
- localplayer_cmd_respawn( 0, NULL );
- cl_menu_go_away = 1;
- game_menu.page = 0;
-}
+ if( ui_clicking(UI_MOUSE_LEFT) || ui_clicking(UI_MOUSE_RIGHT) ){
+ menu.input_mode = k_menu_input_mode_mouse;
+ }
+
+ if( menu.input_mode == k_menu_input_mode_mouse ){
+ /*
+ * handle mouse input
+ * ------------------------------------------------------------*/
+ vg_ui.wants_mouse = 1;
+
+ /*
+ * this raycasting is super cumbersome because all the functions were
+ * designed for other purposes. we dont care though.
+ */
+ m4x4f inverse;
+ m4x4_inv( menu.view.mtx.p, inverse );
+ v4f coords;
+ coords[0] = vg_ui.mouse[0];
+ coords[1] = vg.window_y - vg_ui.mouse[1];
+ v2_div( coords, (v2f){ vg.window_x, vg.window_y }, coords );
+ v2_muls( coords, 2.0f, coords );
+ v2_add( coords, (v2f){-1.0f,-1.0f}, coords );
+ coords[2] = 1.0f;
+ coords[3] = 1.0f;
+ m4x4_mulv( inverse, coords, coords );
+ v3f ray;
+ m3x3_mulv( menu.view.transform, coords, ray );
+ v3_normalize( ray );
+
+ if( menu.loc && (menu.loc->type == k_ent_menuitem_type_slider) &&
+ ui_clicking(UI_MOUSE_LEFT) && menu.loc->pf32 ){
+
+ u32 il = mdl_entity_id_id( menu.loc->slider.id_min ),
+ ir = mdl_entity_id_id( menu.loc->slider.id_max );
+ ent_marker *ml = mdl_arritm( &menu.markers, il ),
+ *mr = mdl_arritm( &menu.markers, ir );
+
+ v3f q2;
+ v3_muladds( menu.view.pos, ray, 100.0f, q2 );
+
+ f32 s,t;
+ v3f c1, c2;
+ v3f p1, q1, v0;
+ v3_sub( mr->transform.co, ml->transform.co, v0 );
+ v3_muladds( ml->transform.co, v0, -1.0f, p1 );
+ v3_muladds( mr->transform.co, v0, 1.0f, q1 );
+ closest_segment_segment( p1, q1, menu.view.pos, q2, &s,&t, c1,c2 );
+
+ s-=(1.0f/3.0f);
+ s/=(1.0f/3.0f);
+
+ if( ui_click_down(UI_MOUSE_LEFT) ){
+ menu.slider_offset = *menu.loc->pf32 - s;
+ }