(menu.main_index == k_menu_main_map);
}
+static void menu_decor_select( ui_rect rect )
+{
+ ui_px b = vg_ui.font->sx, hb = b/2;
+ ui_rect a0 = { rect[0] - 20 - hb, rect[1] + rect[3]/2 - hb, b,b },
+ a1 = { rect[0] + rect[2] + 20 + hb, rect[1] + rect[3]/2 - hb, b,b };
+
+ ui_text( a0, "\x95", 1, k_ui_align_middle_center, 0 );
+ ui_text( a1, "\x93", 1, k_ui_align_middle_center, 0 );
+}
+
+static void menu_standard_widget( ui_rect inout_panel, ui_rect rect, ui_px s )
+{
+ ui_split( inout_panel, k_ui_axis_h, vg_ui.font->sy*s*2,
+ 2, rect, inout_panel );
+}
+
+static bool menu_slider( ui_rect inout_panel, bool select, const char *label,
+ const f32 min, const f32 max, f32 *value,
+ const char *format )
+{
+ ui_rect rect, box;
+ menu_standard_widget( inout_panel, rect, 1 );
+ ui_label( rect, label, 1, 8, box );
+
+ f32 t;
+ enum ui_button_state state = ui_slider_base( box, min, max, value, &t ),
+ mask_using =
+ k_ui_button_holding_inside |
+ k_ui_button_holding_outside |
+ k_ui_button_click,
+ mask_brighter = mask_using | k_ui_button_hover;
+
+ if( menu.input_mode == k_menu_input_mode_keys )
+ {
+ if( select )
+ {
+ f32 m = axis_state( k_sraxis_mbrowse_h );
+ if( fabsf(m) > 0.5f )
+ {
+ *value += m * vg.time_frame_delta * ((max-min) / 2.0f);
+ *value = vg_clampf( *value, min, max );
+ }
+
+ menu_decor_select( rect );
+ state |= k_ui_button_hover;
+ }
+ }
+
+ ui_rect line = { box[0], box[1], t * (f32)box[2], box[3] };
+ ui_fill( line, state&mask_brighter? GUI_COL_ACTIVE: GUI_COL_NORM );
+ ui_fill( (ui_rect){ box[0]+line[2], box[1], box[2]-line[2], box[3] },
+ GUI_COL_DARK );
+
+ ui_outline( box, 1, state? GUI_COL_HI: GUI_COL_ACTIVE, 0 );
+ ui_slider_text( box, NULL, *value );
+
+ return (state & mask_using) && 1;
+}
+
+static enum ui_button_state menu_button( ui_rect inout_panel, bool select,
+ const char *text )
+{
+ ui_rect rect;
+ menu_standard_widget( inout_panel, rect, 1 );
+
+ enum ui_button_state state = k_ui_button_none;
+
+ if( menu.input_mode == k_menu_input_mode_keys )
+ {
+ if( select )
+ {
+ menu_decor_select( rect );
+
+ if( button_down( k_srbind_maccept ) )
+ state = k_ui_button_click;
+ }
+ }
+ else
+ {
+ state = ui_button_base( rect );
+ select = 0;
+ }
+
+ if( state == k_ui_button_click )
+ {
+ ui_fill( rect, GUI_COL_DARK );
+ }
+ else if( state == k_ui_button_holding_inside )
+ {
+ ui_fill( rect, GUI_COL_DARK );
+ }
+ else if( state == k_ui_button_holding_outside )
+ {
+ ui_fill( rect, GUI_COL_DARK );
+ ui_outline( rect, 1, GUI_COL_CLICK, 0 );
+ }
+ else if( state == k_ui_button_hover )
+ {
+ ui_fill( rect, GUI_COL_ACTIVE );
+ ui_outline( rect, 1, GUI_COL_CLICK, 0 );
+ }
+ else
+ ui_fill( rect, select? GUI_COL_ACTIVE: GUI_COL_NORM );
+
+ ui_text( rect, text, 1, k_ui_align_middle_center, 0 );
+ return state;
+}
+
void menu_gui(void)
{
if( button_down( k_srbind_mopen ) )
const char *opts[] = {
[k_menu_main_main] = "Menu",
- [k_menu_main_map] = "Map"
+ [k_menu_main_map] = "Map",
+ [k_menu_main_settings ] = "Settings"
};
/* TAB CONTROL */
}
}
- ui_px x = 0,
- spacer = 8;
+ ui_px x = 0, spacer = 8;
for( u32 draw=0; draw<2; draw ++ )
{
- if( draw )
+ if( menu.input_mode == k_menu_input_mode_keys )
{
- ui_rect inf_lb = { x, 0, 32, height };
- ui_fill( inf_lb, lb_down? GUI_COL_NORM: GUI_COL_NORM );
- ui_text( inf_lb, "\x91", 1, k_ui_align_middle_center, 0 );
+ if( draw )
+ {
+ ui_rect inf_lb = { x, 0, 32, height };
+ ui_fill( inf_lb, lb_down? GUI_COL_NORM: GUI_COL_NORM );
+ ui_text( inf_lb, "\x91", 1, k_ui_align_middle_center, 0 );
+ }
+ x += 32 + spacer;
}
- x += 32 + spacer;
for( i32 i=0; i<vg_list_size(opts); i ++ )
{
x += box[2] + spacer;
}
- if( draw )
+ if( menu.input_mode == k_menu_input_mode_keys )
{
- ui_rect inf_rb = { x, 0, 32, height };
- ui_fill( inf_rb, rb_down? GUI_COL_NORM: GUI_COL_NORM );
- ui_text( inf_rb, "\x92", 1, k_ui_align_middle_center, 0 );
+ if( draw )
+ {
+ ui_rect inf_rb = { x, 0, 32, height };
+ ui_fill( inf_rb, rb_down? GUI_COL_NORM: GUI_COL_NORM );
+ ui_text( inf_rb, "\x92", 1, k_ui_align_middle_center, 0 );
+ }
+ x += 32;
}
- x += 32;
if( draw )
ui_fill( (ui_rect){ x+8,0, vg.window_x-(x+8),height }, GUI_COL_NORM );
skaterift.activity = k_skaterift_default;
return;
}
- }
- /* MAIN / MAIN
- * -------------------------------------------------------------------*/
-
- if( menu.main_index == k_menu_main_main )
- {
ui_rect list = { vg.window_x/2 - 512/2, height+64,
512, vg.window_y-height-128 };
- ui_fill( list, GUI_COL_DARK );
+
+ if( (mv < 0) && (menu.main_row<2) ) menu.main_row ++;
+ if( (mv > 0) && (menu.main_row>0) ) menu.main_row --;
+
+ /* MAIN / MAIN
+ * -------------------------------------------------------------------*/
+
+ if( menu.main_index == k_menu_main_main )
+ {
+ if( menu_button( list, menu.main_row == 0, "Thing 1" ) ==
+ k_ui_button_click )
+ {
+ vg_info( "A\n" );
+ }
+
+ if( menu_button( list, menu.main_row == 1, "Thing 2" ) ==
+ k_ui_button_click )
+ {
+ vg_info( "B\n" );
+ }
+
+ if( menu_button( list, menu.main_row == 2, "Quit Game" ) ==
+ k_ui_button_click )
+ {
+ vg_info( "C\n" );
+ }
+ }
+ else if( menu.main_index == k_menu_main_settings )
+ {
+ ui_font_face( &vgf_default_large );
+ static f32 tester;
+ menu_slider( list, menu.main_row==0, "Yo", 0, 20, &tester, NULL );
+ }
}
vg_ui.frosting = 0.015f;