From: hgn Date: Thu, 18 Apr 2024 21:06:59 +0000 (+0100) Subject: Add some challenges to the world map X-Git-Url: https://harrygodden.com/git/?a=commitdiff_plain;h=5bb71fef0e63780f95f403fb14b824778cecbe9b;p=carveJwlIkooP6JGAAIwe30JlM.git Add some challenges to the world map --- diff --git a/input.h b/input.h index dc89f8b..131ab8c 100644 --- a/input.h +++ b/input.h @@ -88,13 +88,11 @@ static vg_input_op *input_button_list[] = { INPUT_BASIC( SDLK_LEFT, SDL_CONTROLLER_BUTTON_DPAD_LEFT ), [k_srbind_world_right] = INPUT_BASIC( SDLK_RIGHT, SDL_CONTROLLER_BUTTON_DPAD_RIGHT ), -[k_srbind_home] = INPUT_BASIC( SDLK_h, SDL_CONTROLLER_BUTTON_Y ), [k_srbind_mup] = INPUT_BASIC( SDLK_UP, SDL_CONTROLLER_BUTTON_DPAD_UP ), [k_srbind_mdown] = INPUT_BASIC( SDLK_DOWN, SDL_CONTROLLER_BUTTON_DPAD_DOWN ), [k_srbind_mback] = INPUT_BASIC( SDLK_ESCAPE, SDL_CONTROLLER_BUTTON_B ), [k_srbind_mopen] = INPUT_BASIC( SDLK_ESCAPE, SDL_CONTROLLER_BUTTON_START ), -[k_srbind_mhub] = (vg_input_op[]){ vg_joy_button, SDL_CONTROLLER_BUTTON_Y, - vg_end }, +[k_srbind_mhub] = INPUT_BASIC( SDLK_h, SDL_CONTROLLER_BUTTON_Y ), [k_srbind_maccept] = (vg_input_op[]){ vg_keyboard, SDLK_e, vg_gui_visible, 0, vg_keyboard, SDLK_RETURN, vg_keyboard, SDLK_RETURN2, diff --git a/maps_src/dev_tutorial/main.mdl b/maps_src/dev_tutorial/main.mdl index 4539d9f..9a24db8 100644 Binary files a/maps_src/dev_tutorial/main.mdl and b/maps_src/dev_tutorial/main.mdl differ diff --git a/menu.c b/menu.c index daeb61a..eaec907 100644 --- a/menu.c +++ b/menu.c @@ -219,7 +219,7 @@ static bool menu_checkbox( ui_rect inout_panel, bool select, return changed; } -static void menu_heading( ui_rect inout_panel, const char *label ) +static void menu_heading( ui_rect inout_panel, const char *label, u32 colour ) { ui_rect rect; menu_standard_widget( inout_panel, rect, 1 ); @@ -239,10 +239,19 @@ static void menu_heading( ui_rect inout_panel, const char *label ) ui_text( rect, label, 1, k_ui_align_middle_center, 1 ); rect[0] += 1; rect[1] -= 1; - ui_text( rect, label, 1, k_ui_align_middle_center, + ui_text( rect, label, 1, k_ui_align_middle_center, colour? colour: ui_colour(k_ui_blue+k_ui_brighter) ); } +static u32 medal_colour( u32 flags ) +{ + if( flags & k_ent_route_flag_achieve_gold ) + return ui_colour( k_ui_yellow ); + else if( flags & k_ent_route_flag_achieve_silver ) + return ui_colour( k_ui_fg ); + else return 0; +} + void menu_gui(void) { if( button_down( k_srbind_mopen ) ) @@ -461,12 +470,13 @@ void menu_gui(void) vg_strnull( &str, buf, sizeof(buf) ); vg_strcat( &str, "Hub World" ); - if( world_static.active_instance && - (vg_input.display_input_method == k_input_method_controller) ) + if( world_static.active_instance ) { vg_strcat( &str, " (" ); vg_input_string( &str, input_button_list[k_srbind_mhub], 1 ); - vg_strcat( &str, ")" ); + vg_strcatch( &str, '\x06' ); + vg_strcatch( &str, '\x00' ); + vg_strcat( &str, "\x1B[0m)" ); } ui_px w = ui_text( (ui_rect){ x+8, y, 1000, height }, buf, 1, @@ -493,7 +503,9 @@ void menu_gui(void) { vg_strcat( &str, " (" ); vg_input_string( &str, input_button_list[k_srbind_mhub], 1 ); - vg_strcat( &str, ")" ); + vg_strcatch( &str, '\x06' ); + vg_strcatch( &str, '\x00' ); + vg_strcat( &str, "\x1B[0m)" ); } vs = ui_fill( (ui_rect){ x,y, 1000,height }, @@ -516,6 +528,119 @@ void menu_gui(void) vs[1].co[0] = x + 8; vs[2].co[0] = x; } + + x = 8; + y += 8 + height; + + if( world_static.active_instance ) + { + ui_rect stat_panel = { x,y, 256,vg.window_y-y }; + u32 c0 = ui_opacity( GUI_COL_DARK, 0.36f ); + struct ui_vert *vs = ui_fill( stat_panel, c0 ); + + ui_rect_pad( stat_panel, (ui_px[2]){8,0} ); + + for( u32 i=0; ient_region ); i ++ ) + { + ent_region *region = mdl_arritm( &world->ent_region, i ); + + if( !region->zone_volume ) + continue; + + const char *title = mdl_pstr( &world->meta, region->pstr_title ); + ui_font_face( &vgf_default_large ); + + ui_rect title_box; + menu_standard_widget( stat_panel, title_box, 1 ); + + stat_panel[0] += 16; + stat_panel[2] -= 16; + ui_font_face( &vgf_default_small ); + + ent_volume *volume = mdl_arritm(&world->ent_volume, + mdl_entity_id_id(region->zone_volume)); + + u32 combined = k_ent_route_flag_achieve_gold | + k_ent_route_flag_achieve_silver; + + char buf[128]; + vg_str str; + + for( u32 j=0; jent_route); j ++ ) + { + ent_route *route = mdl_arritm(&world->ent_route, j ); + + v3f local; + m4x3_mulv( volume->to_local, route->board_transform[3], local ); + if( !((fabsf(local[0]) <= 1.0f) && + (fabsf(local[1]) <= 1.0f) && + (fabsf(local[2]) <= 1.0f)) ) + { + continue; + } + + combined &= route->flags; + + vg_strnull( &str, buf, sizeof(buf) ); + vg_strcat( &str, mdl_pstr(&world->meta, route->pstr_name)); + + if( route->flags & k_ent_route_flag_achieve_silver ) + vg_strcat( &str, " \xb3"); + if( route->flags & k_ent_route_flag_achieve_gold ) + vg_strcat( &str, "\xb3"); + + ui_rect r; + ui_standard_widget( stat_panel, r, 1 ); + ui_text( r, buf, 1, k_ui_align_middle_left, + medal_colour(route->flags) ); + } + + for( u32 j=0; jent_challenge); j ++ ) + { + ent_challenge *challenge = mdl_arritm( &world->ent_challenge, j ); + + v3f local; + m4x3_mulv( volume->to_local, challenge->transform.co, local ); + if( !((fabsf(local[0]) <= 1.0f) && + (fabsf(local[1]) <= 1.0f) && + (fabsf(local[2]) <= 1.0f)) ) + { + continue; + } + + vg_strnull( &str, buf, sizeof(buf) ); + vg_strcat( &str, mdl_pstr(&world->meta, challenge->pstr_alias)); + + u32 flags = 0x00; + if( challenge->status ) + { + flags |= k_ent_route_flag_achieve_gold; + flags |= k_ent_route_flag_achieve_silver; + vg_strcat( &str, " \xb3\xb3" ); + } + + combined &= flags; + + ui_rect r; + ui_standard_widget( stat_panel, r, 1 ); + ui_text( r, buf, 1, k_ui_align_middle_left, medal_colour(flags) ); + } + + stat_panel[0] -= 16; + stat_panel[2] += 16; + + u32 title_col = 0; + if( combined & k_ent_route_flag_achieve_gold ) + title_col = ui_colour( k_ui_yellow ); + else if( combined & k_ent_route_flag_achieve_silver ) + title_col = ui_colour( k_ui_fg ); + + menu_heading( title_box, title, title_col ); + } + + vs[2].co[1] = stat_panel[1]; + vs[3].co[1] = stat_panel[1]; + } } else { @@ -573,20 +698,20 @@ void menu_gui(void) ui_font_face( &vgf_default_large ); list[1] -= 8; - menu_heading( list, "Game" ); + menu_heading( list, "Game", 0 ); menu_checkbox( list, *row == 0, "Show controls overlay", &control_overlay.enabled ); menu_checkbox( list, *row == 1, "Auto connect to global server", &network_client.auto_connect ); - menu_heading( list, "Audio/Video" ); + menu_heading( list, "Audio/Video", 0 ); menu_slider( list, *row == 2, "Volume", 0, 100, &vg_audio.external_global_volume, "%.f%%" ); menu_slider( list, *row == 3, "Resolution", 0, 100, &k_render_scale, "%.f%%" ); menu_checkbox( list, *row == 4, "Motion Blur", &k_blur_effect ); - menu_heading( list, "Camera" ); + menu_heading( list, "Camera", 0 ); menu_slider( list, *row == 5, "Fov", 97, 135, &k_fov, "%.1f\xb0" ); menu_slider( list, *row == 6, "Cam Height", -0.4f, +1.4f, @@ -597,7 +722,7 @@ void menu_gui(void) ui_rect end = { list[0], list[1]+list[3]-64, list[2], 72 }; ui_font_face( &vgf_default_small ); - menu_heading( end, "Advanced" ); + menu_heading( end, "Advanced", 0 ); if( menu_button( end, *row == 8, "Open Engine Settings" ) ) { vg_settings_open(); @@ -611,7 +736,7 @@ void menu_gui(void) ui_font_face( &vgf_default_large ); list[1] -= 8; - menu_heading( list, "Controls" ); + menu_heading( list, "Controls", 0 ); if( menu_button( list, *row == 0, "Skating \xb2" ) ) { } @@ -619,7 +744,7 @@ void menu_gui(void) { } - menu_heading( list, "Workshop" ); + menu_heading( list, "Workshop", 0 ); if( menu_button( list, *row == 2, "Create a Board \xb2" ) ) { } diff --git a/menu.h b/menu.h index 6cbe297..237a82a 100644 --- a/menu.h +++ b/menu.h @@ -42,51 +42,3 @@ void menu_at_begin(void); void menu_gui(void); void menu_open( enum menu_page page ); bool menu_viewing_map(void); - -#if 0 -#define MENU_STACK_SIZE 8 - -#include "vg/vg_engine.h" -#include "entity.h" - -struct global_menu -{ - int credits_open; - int disable_open; - i32 skip_starter; - - u32 page, /* current page index */ - page_depth, - controls_page_id; - - ent_menuitem *ctr_kbm, - *ctr_deck, - *ctr_ps, - *ctr_steam, - *ctr_xbox; - f32 slider_offset; - - struct page_stack_frame { - u32 page; - ent_menuitem *loc; - ent_camera *cam; - } - page_stack[ MENU_STACK_SIZE ]; - - ent_menuitem *loc; - ent_camera *cam; - vg_camera view; - - mdl_context model; - GLuint *textures; - glmesh mesh; - - mdl_array_ptr items, markers, cameras; -} -extern menu; -void menu_close(void); -void menu_open_page( const char *name, - enum ent_menuitem_stack_behaviour stackmode ); -void menu_link(void); -void menu_render(void); -#endif diff --git a/world_map.c b/world_map.c index 13de85c..2799428 100644 --- a/world_map.c +++ b/world_map.c @@ -84,6 +84,13 @@ static void world_map_help_normal(void) if( gui_new_helper( input_button_list[k_srbind_mback], &text ) ) vg_strcat( &text, "Exit" ); + + if( world_static.instances[1].status == k_world_status_loaded ) + { + if( gui_new_helper( input_button_list[k_srbind_mhub], &text ) ) + vg_strcat( &text, world_static.active_instance? + "Go to Hub": "Go to Active World" ); + } } void world_map_pre_update(void) diff --git a/world_routes_ui.c b/world_routes_ui.c index a4e2f10..e367e66 100644 --- a/world_routes_ui.c +++ b/world_routes_ui.c @@ -151,6 +151,8 @@ static void ent_route_imgui( world_instance *world, ent_route *route, void world_routes_imgui( world_instance *world ) { + if( skaterift.activity == k_skaterift_menu ) return; + ui_point cursor = { 4, 4 }; for( u32 i=0; ient_route); i++ ){ ent_route_imgui( world, mdl_arritm( &world->ent_route, i ), cursor );