+
+ if( !menu.active ) return;
+ if( !menu.loc ) return;
+ if( !menu.cam ) return;
+
+ int ml = button_down( k_srbind_mleft ),
+ mr = button_down( k_srbind_mright ),
+ mu = button_down( k_srbind_mup ),
+ md = button_down( k_srbind_mdown ),
+ mh = ml-mr,
+ mv = mu-md,
+ enter = button_down( k_srbind_maccept ),
+ escape = button_down( k_srbind_mback );
+
+ if( escape ){
+ menu_back_page();
+ }
+ else if( enter ){
+ if ( menu.loc->type == k_ent_menuitem_type_event_button ){
+
+ }
+ else if( menu.loc->type == k_ent_menuitem_type_page_button ){
+ menu_open_page( mdl_pstr( &menu.model, menu.loc->button.pstr ) );
+ }
+ else if( menu.loc->type == k_ent_menuitem_type_toggle ){
+
+ }
+ }
+ else if( mh||mv ){
+ v3f opt;
+ v3_zero( opt );
+ f32 best = 0.707f;
+ ent_menuitem *nextpos = NULL;
+
+ opt[0] += mh;
+ opt[2] += mv;
+ mdl_transform_vector( &menu.cam->transform, opt, opt );
+
+ for( u32 i=0; i<4; i++ ){
+ u32 id = menu.loc->id_links[i];
+ if( !id ) continue;
+ u32 index = mdl_entity_id_id( id );
+
+ ent_menuitem *other = mdl_arritm( &menu.items, index );
+ v3f delta;
+ v3_sub( menu.loc->transform.co, other->transform.co, delta );
+ v3_normalize( delta );
+
+ f32 score = v3_dot( delta, opt );
+ if( score > best ){
+ best = score;
+ nextpos = other;
+ }
+ }
+
+ if( nextpos ){
+ menu.loc = nextpos;
+ }
+ }