.hover = 0xff655959,
.active = 0xff655959
};
-
-
-
-static void draw_levels_list( struct cmp_level *levels, int count, int unlocked )
-{
- static struct ui_scrollbar sb = {
- .bar_height = 400
- };
-
- ui_px view_height = ui_global_ctx.cursor[3];
- ui_px level_height = 50;
-
- // Level scroll view
- gui_new_node();
- {
- gui_fill_rect( ui_global_ctx.cursor, 0xff5a4e4d );
- gui_set_clip( ui_global_ctx.cursor );
-
- ui_global_ctx.cursor[2] = 14;
- gui_align_right();
-
- ui_px content_height = count*level_height;
- if( content_height > view_height )
- {
- ui_scrollbar( &ui_global_ctx, &sb, 1 );
- ui_global_ctx.cursor[1] -= ui_calculate_content_scroll( &sb, content_height );
- }
- else
- {
- gui_fill_rect( ui_global_ctx.cursor, 0xff807373 );
- }
-
- ui_global_ctx.cursor[2] = 240;
- ui_global_ctx.cursor[3] = level_height;
- gui_align_left();
-
- for( int i = 0; i < count; i ++ )
- {
- struct cmp_level *lvl_info = &levels[i];
-
- if( i < unlocked )
- {
- if( lvl_info->completed_score != 0 )
- gui_override_colours( i&0x1? &flcol_list_complete_a: &flcol_list_complete_b );
- else
- gui_override_colours( i&0x1? &flcol_list_a: &flcol_list_b );
- }
- else
- gui_override_colours( &flcol_list_locked );
-
- if( i < unlocked )
- {
- if( gui_button( 2 + i ) == k_button_click )
- {
- console_changelevel( 1, &lvl_info->map_name );
- }
-
- ui_global_ctx.override_colour = 0xffffffff;
- gui_text( lvl_info->title, 3, 0 );
- ui_global_ctx.cursor[1] += 18;
- gui_text( "incomplete", 2, 0 );
- }
- else
- {
- gui_button( 2 + i );
-
- ui_global_ctx.override_colour = 0xff786f6f;
- gui_text( "???", 3, 0 );
- ui_global_ctx.cursor[1] += 18;
- gui_text( "locked", 2, 0 );
- }
-
- gui_end_down();
- }
-
- gui_reset_colours();
- gui_release_clip();
- }
- gui_end_down();
-}
-
void vg_ui(void)
{
- ui_global_ctx.cursor[0] = 0;
- ui_global_ctx.cursor[1] = 0;
- ui_global_ctx.cursor[2] = 256;
-
- gui_fill_y();
-
- ui_global_ctx.id_base = 4 << 16;
-
+ // UI memory
static int pack_selection = 0;
static struct pack_info
{
}
};
+ static struct cmp_level *level_selected = NULL;
+
+ // UI Code
+ ui_global_ctx.cursor[0] = 0;
+ ui_global_ctx.cursor[1] = 0;
+ ui_global_ctx.cursor[2] = 256;
+
+ gui_fill_y();
+
+ ui_global_ctx.id_base = 4 << 16;
+
gui_new_node();
{
+ gui_capture_mouse( 9999 );
gui_fill_rect( ui_global_ctx.cursor, 0xff5577ff );
- gui_text( "ASSIGNMENTS", 4, 0 );
+ gui_text( "ASSIGNMENTS", 8, 0 );
ui_global_ctx.cursor[1] += 30;
ui_global_ctx.cursor[3] = 25;
pack_selection = i;
ui_global_ctx.cursor[1] += 2;
- gui_text( pack_infos[i].name, 2, 0 );
+ gui_text( pack_infos[i].name, 4, 0 );
gui_end_right();
gui_reset_colours();
ui_global_ctx.cursor[3] = 500;
- draw_levels_list( pack_infos[ pack_selection ].levels, pack_infos[ pack_selection ].level_count, 3 );
+ // DRAW LEVEL SELECTION LIST
+ {
+ struct cmp_level *levels = pack_infos[ pack_selection ].levels;
+ int count = pack_infos[ pack_selection ].level_count;
+ int unlocked = 3000;
+
+ static struct ui_scrollbar sb = {
+ .bar_height = 400
+ };
+
+ ui_px view_height = ui_global_ctx.cursor[3];
+ ui_px level_height = 50;
+
+ // Level scroll view
+ gui_new_node();
+ {
+ gui_fill_rect( ui_global_ctx.cursor, 0xff5a4e4d );
+ gui_set_clip( ui_global_ctx.cursor );
+
+ ui_global_ctx.cursor[2] = 14;
+ gui_align_right();
+
+ ui_px content_height = count*level_height;
+ if( content_height > view_height )
+ {
+ ui_scrollbar( &ui_global_ctx, &sb, 1 );
+ ui_global_ctx.cursor[1] -= ui_calculate_content_scroll( &sb, content_height );
+ }
+ else
+ {
+ gui_fill_rect( ui_global_ctx.cursor, 0xff807373 );
+ }
+
+ ui_global_ctx.cursor[2] = 240;
+ ui_global_ctx.cursor[3] = level_height;
+ gui_align_left();
+
+ for( int i = 0; i < count; i ++ )
+ {
+ struct cmp_level *lvl_info = &levels[i];
+
+ if( i < unlocked )
+ {
+ if( lvl_info->completed_score != 0 )
+ gui_override_colours( i&0x1? &flcol_list_complete_a: &flcol_list_complete_b );
+ else
+ gui_override_colours( i&0x1? &flcol_list_a: &flcol_list_b );
+ }
+ else
+ gui_override_colours( &flcol_list_locked );
+
+ if( i < unlocked )
+ {
+ if( gui_button( 2 + i ) == k_button_click )
+ level_selected = &levels[i];
+
+ ui_global_ctx.override_colour = 0xffffffff;
+ gui_text( lvl_info->title, 6, 0 );
+ ui_global_ctx.cursor[1] += 18;
+ gui_text( "incomplete", 4, 0 );
+ }
+ else
+ {
+ gui_button( 2 + i );
+
+ ui_global_ctx.override_colour = 0xff786f6f;
+ gui_text( "???", 6, 0 );
+ ui_global_ctx.cursor[1] += 18;
+ gui_text( "locked", 4, 0 );
+ }
+
+ gui_end_down();
+ }
+
+ gui_reset_colours();
+ gui_release_clip();
+ }
+ gui_end_down();
+ }
+ }
+ gui_end_right();
+
+ // Selected level UI
+ // ============================================================
+
+ if( level_selected )
+ {
+ ui_global_ctx.cursor[0] += 16;
+ ui_global_ctx.cursor[1] += 16;
+ ui_global_ctx.cursor[2] = 512-40;
+ ui_global_ctx.cursor[3] = 560-16;
+
+ gui_new_node();
+ {
+ gui_capture_mouse( 9999 );
+
+ gui_fill_rect( ui_global_ctx.cursor, 0xff5a4e4d );
+ ui_global_ctx.cursor[1] += 4;
+ gui_text( level_selected->title, 6, 0 );
+
+ ui_global_ctx.cursor[1] += 30;
+ ui_rect_pad( ui_global_ctx.cursor, 8 );
+ ui_global_ctx.cursor[3] = 300;
+
+ gui_new_node();
+ {
+ gui_fill_rect( ui_global_ctx.cursor, 0xff655959 );
+ }
+ gui_end_down();
+
+ ui_text_use_paragraph( &ui_global_ctx );
+ ui_global_ctx.cursor[1] += 2;
+
+ gui_text( level_selected->description, 5, 0 );
+ ui_text_use_title( &ui_global_ctx );
+
+ // Buttons at the bottom
+ ui_global_ctx.cursor[3] = 30;
+ ui_global_ctx.cursor[2] = 80;
+
+ gui_align_bottom();
+ ui_global_ctx.cursor[1] -= 8;
+
+ if( gui_button( 3000 ) == k_button_click )
+ {
+ level_selected = NULL;
+ }
+ gui_text( "Back", 6, 0 );
+ gui_end();
+
+ gui_align_right();
+ ui_global_ctx.cursor[2] = 170;
+ ui_global_ctx.cursor[0] -= 8 + 170 + 2;
+
+ {
+ gui_override_colours( &flcol_list_locked );
+ if( gui_button( 3001 ) == k_button_click )
+ vg_error( "UNIMPLEMENTED\n" );
+
+ gui_text( "Restore Solution", 6, 0 );
+ gui_end_right();
+ }
+
+ ui_global_ctx.cursor[0] += 2;
+ ui_global_ctx.cursor[2] = 80;
+
+ {
+ gui_override_colours( &flcol_list_complete_a );
+ if( gui_button( 3002 ) == k_button_click )
+ console_changelevel( 1, &level_selected->map_name );
+ gui_text( "Play", 6, 0 );
+ gui_end();
+ }
+
+ gui_reset_colours();
+ }
+ gui_end_right();
+
+ ui_global_ctx.cursor[0] += 16;
+ ui_global_ctx.cursor[3] = 250;
+
+ // If has results
+ gui_new_node();
+ {
+ gui_fill_rect( ui_global_ctx.cursor, 0xff5a4e4d );
+ }
+ gui_end();
}
- gui_end();
}