X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=fishladder.c;h=7f47fdb54a49c96a1a5e9cfe8a913f88ef590861;hb=8f89e6bd64229500954908e79ce500f80dda774d;hp=12666a8158ffcf80eb4aa165fabc5d5341c704cb;hpb=4e217c7bc7d079364a999ee39773fa70ca25733a;p=fishladder.git diff --git a/fishladder.c b/fishladder.c index 12666a8..7f47fdb 100644 --- a/fishladder.c +++ b/fishladder.c @@ -874,8 +874,12 @@ static int console_changelevel( int argc, char const *argv[] ) return 0; } +void leaderboard_found( LeaderboardFindResult_t *pCallback ); void vg_start(void) { + // Steamworks callbacks + sw_leaderboard_found = &leaderboard_found; + vg_function_push( (struct vg_cmd){ .name = "_map_write", .function = console_save_map @@ -2270,6 +2274,16 @@ static ui_colourset flcol_list_locked = { .hover = 0xff655959, .active = 0xff655959 }; + +static struct +{ + SteamLeaderboard_t steam_leaderboard; + int leaderboard_matches; + + struct cmp_level *level_selected; +} +ui_data; + void vg_ui(void) { // UI memory @@ -2299,8 +2313,6 @@ void vg_ui(void) } }; - static struct cmp_level *level_selected = NULL; - // UI Code ui_global_ctx.cursor[0] = 0; ui_global_ctx.cursor[1] = 0; @@ -2398,8 +2410,12 @@ void vg_ui(void) if( i < unlocked ) { if( gui_button( 2 + i ) == k_button_click ) - level_selected = &levels[i]; - + { + ui_data.level_selected = &levels[i]; + ui_data.leaderboard_matches = 0; + sw_find_leaderboard( ui_data.level_selected->map_name ); + } + ui_global_ctx.override_colour = 0xffffffff; gui_text( lvl_info->title, 6, 0 ); ui_global_ctx.cursor[1] += 18; @@ -2429,7 +2445,7 @@ void vg_ui(void) // Selected level UI // ============================================================ - if( level_selected ) + if( ui_data.level_selected ) { ui_global_ctx.cursor[0] += 16; ui_global_ctx.cursor[1] += 16; @@ -2442,7 +2458,7 @@ void vg_ui(void) gui_fill_rect( ui_global_ctx.cursor, 0xff5a4e4d ); ui_global_ctx.cursor[1] += 4; - gui_text( level_selected->title, 6, 0 ); + gui_text( ui_data.level_selected->title, 6, 0 ); ui_global_ctx.cursor[1] += 30; ui_rect_pad( ui_global_ctx.cursor, 8 ); @@ -2457,7 +2473,7 @@ void vg_ui(void) ui_text_use_paragraph( &ui_global_ctx ); ui_global_ctx.cursor[1] += 2; - gui_text( level_selected->description, 5, 0 ); + gui_text( ui_data.level_selected->description, 5, 0 ); ui_text_use_title( &ui_global_ctx ); // Buttons at the bottom @@ -2469,7 +2485,7 @@ void vg_ui(void) if( gui_button( 3000 ) == k_button_click ) { - level_selected = NULL; + ui_data.level_selected = NULL; } gui_text( "Back", 6, 0 ); gui_end(); @@ -2493,7 +2509,11 @@ void vg_ui(void) { gui_override_colours( &flcol_list_complete_a ); if( gui_button( 3002 ) == k_button_click ) - console_changelevel( 1, &level_selected->map_name ); + { + console_changelevel( 1, &ui_data.level_selected->map_name ); + ui_data.level_selected = NULL; + ui_data.leaderboard_matches = 0; + } gui_text( "Play", 6, 0 ); gui_end(); } @@ -2502,14 +2522,30 @@ void vg_ui(void) } gui_end_right(); - ui_global_ctx.cursor[0] += 16; - ui_global_ctx.cursor[3] = 250; - - // If has results - gui_new_node(); + if( ui_data.leaderboard_matches ) { - gui_fill_rect( ui_global_ctx.cursor, 0xff5a4e4d ); + 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(); } } + +void leaderboard_found( LeaderboardFindResult_t *pCallback ) +{ + if( !pCallback->m_bLeaderboardFound ) + vg_error( "Leaderboard could not be found\n" ); + + ui_data.steam_leaderboard = pCallback->m_hSteamLeaderboard; + ui_data.leaderboard_matches = 0; + + if( ui_data.level_selected ) + if( !strcmp( sw_get_leaderboard_name( ui_data.steam_leaderboard ), ui_data.level_selected->map_name ) ) + ui_data.leaderboard_matches = 1; +}