X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=ent_skateshop.c;h=e7049b5a6309b03c7a1b1088528bb16c795ae024;hb=ec90a4b46865009c1e1b1679f6926e35d2ee3f12;hp=92e7660255ef06f813b800bb0f4e6dd79e4f8c96;hpb=a6880a555be0e8bed7aae08c95b95eeb62ade0b4;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/ent_skateshop.c b/ent_skateshop.c index 92e7660..e7049b5 100644 --- a/ent_skateshop.c +++ b/ent_skateshop.c @@ -451,6 +451,7 @@ VG_STATIC struct cache_board *skateshop_selected_cache_if_loaded(void) /* * VG event preupdate */ +void temp_update_playermodel(void); VG_STATIC void global_skateshop_preupdate(void) { float rate = vg_minf( 1.0f, vg.time_frame_delta * 2.0f ); @@ -462,18 +463,30 @@ VG_STATIC void global_skateshop_preupdate(void) world_instance *world = get_active_world(); ent_skateshop *shop = global_skateshop.ptr_ent; + + /* camera positioning */ ent_camera *ref = mdl_arritm( &world->ent_camera, mdl_entity_id_id(shop->id_camera) ); - ent_marker *display = mdl_arritm( &world->ent_marker, - mdl_entity_id_id(shop->id_display) ); - + v3f dir = {0.0f,-1.0f,0.0f}; mdl_transform_vector( &ref->transform, dir, dir ); player_vector_angles( localplayer.cam_override_angles, dir, 1.0f, 0.0f ); - + v3f lookat; - v3_sub( display->transform.co, localplayer.rb.co, lookat ); - + if( shop->type == k_skateshop_type_boardshop ){ + ent_marker *display = mdl_arritm( &world->ent_marker, + mdl_entity_id_id(shop->boards.id_display) ); + + v3_sub( display->transform.co, localplayer.rb.co, lookat ); + + } + else if( shop->type == k_skateshop_type_charshop ){ + v3_sub( ref->transform.co, localplayer.rb.co, lookat ); + } + else{ + vg_fatal_error( "Unknown store (%u)\n", shop->type ); + } + q_axis_angle( localplayer.rb.q, (v3f){0.0f,1.0f,0.0f}, atan2f(lookat[0],lookat[2]) ); @@ -481,60 +494,83 @@ VG_STATIC void global_skateshop_preupdate(void) localplayer.cam_override_fov = ref->fov; localplayer.cam_override_strength = global_skateshop.factive; - gui_helper_action( axis_display_string( k_sraxis_mbrowse_h ), "browse" ); - gui_helper_action( button_display_string( k_srbind_mback ), "exit" ); + /* input */ + if( shop->type == k_skateshop_type_boardshop ){ + gui_helper_action( axis_display_string( k_sraxis_mbrowse_h ), "browse" ); + gui_helper_action( button_display_string( k_srbind_mback ), "exit" ); - int moved = 0; - struct cache_board *selected_cache = skateshop_selected_cache_if_loaded(); + struct cache_board *selected_cache = skateshop_selected_cache_if_loaded(); - if( selected_cache ){ - gui_helper_action( button_display_string( k_srbind_maccept ), "pick" ); - } + if( selected_cache ){ + gui_helper_action( button_display_string( k_srbind_maccept ), "pick" ); + } - /* - * Controls - * ---------------------- - */ + /* + * Controls + * ---------------------- + */ - if( global_skateshop.interaction_cooldown > 0.0f ){ - global_skateshop.interaction_cooldown -= vg.time_delta; - return; - } - - if( button_down( k_srbind_mleft ) ){ - if( global_skateshop.selected_registry_id > 0 ){ - global_skateshop.selected_registry_id --; - moved = 1; + if( button_down( k_srbind_mleft ) ){ + if( global_skateshop.selected_registry_id > 0 ){ + global_skateshop.selected_registry_id --; + } } - } - if( button_down( k_srbind_mright ) ){ - if( global_skateshop.selected_registry_id+1 < - global_skateshop.registry_count ) - { - global_skateshop.selected_registry_id ++; - moved = 1; + if( button_down( k_srbind_mright ) ){ + if( global_skateshop.selected_registry_id+1 < + global_skateshop.registry_count ) + { + global_skateshop.selected_registry_id ++; + } } - } - if( moved ){ - global_skateshop.interaction_cooldown = 0.125f; - return; - } + if( selected_cache && button_down( k_srbind_maccept ) ){ + vg_info( "chose board from skateshop (%u)\n", + global_skateshop.selected_registry_id ); - if( selected_cache && button_down( k_srbind_maccept ) ){ - vg_info( "chose board from skateshop (%u)\n", - global_skateshop.selected_registry_id ); + if( localplayer.board_view_slot ){ + unwatch_cache_board( localplayer.board_view_slot ); + } + + localplayer.board_view_slot = selected_cache; + watch_cache_board( localplayer.board_view_slot ); - if( localplayer.board_view_slot ){ - unwatch_cache_board( localplayer.board_view_slot ); + global_skateshop_exit(); + return; + } + } + else if( shop->type == k_skateshop_type_charshop ){ + gui_helper_action( axis_display_string( k_sraxis_mbrowse_h ), "browse" ); + gui_helper_action( button_display_string( k_srbind_mback ), "exit" ); + gui_helper_action( button_display_string( k_srbind_maccept ), "pick" ); + + if( button_down( k_srbind_mleft ) ){ + if( cl_playermdl_id > 0 ){ + cl_playermdl_id --; + } + else{ + cl_playermdl_id = 2; /* HACK */ + } + temp_update_playermodel(); /* HACK */ } - localplayer.board_view_slot = selected_cache; - watch_cache_board( localplayer.board_view_slot ); + if( button_down( k_srbind_mright ) ){ + if( cl_playermdl_id+1 < 3 ){ + cl_playermdl_id ++; + } + else{ + cl_playermdl_id = 0; /* HACK */ + } + temp_update_playermodel(); /* HACK */ + /*lol*/ + } - global_skateshop_exit(); - return; + if( button_down( k_srbind_maccept ) ){ + global_skateshop_exit(); + } + } + else{ + vg_fatal_error( "Unknown store (%u)\n", shop->type ); } if( button_down( k_srbind_mback ) ){ @@ -543,22 +579,17 @@ VG_STATIC void global_skateshop_preupdate(void) } } -/* - * World: render event - */ -VG_STATIC void skateshop_render(void) +VG_STATIC void skateshop_render_boardshop(void) { - if( !global_skateshop.active ) return; - - ent_skateshop *shop = global_skateshop.ptr_ent; world_instance *world = get_active_world(); + ent_skateshop *shop = global_skateshop.ptr_ent; u32 slot_count = vg_list_size(global_skateshop.shop_view_slots); ent_marker *mark_rack = mdl_arritm( &world->ent_marker, - mdl_entity_id_id(shop->id_rack)), + mdl_entity_id_id(shop->boards.id_rack)), *mark_display = mdl_arritm( &world->ent_marker, - mdl_entity_id_id(shop->id_display)); + mdl_entity_id_id(shop->boards.id_display)); int visibility[ SKATESHOP_VIEW_SLOT_MAX ]; SDL_AtomicLock( &global_skateshop.sl_cache_access ); @@ -607,7 +638,7 @@ fade_out:; } ent_marker *mark_info = mdl_arritm( &world->ent_marker, - mdl_entity_id_id(shop->id_info)); + mdl_entity_id_id(shop->boards.id_info)); m4x3f mtext, mrack; mdl_transform_m4x3( &mark_info->transform, mtext ); mdl_transform_m4x3( &mark_rack->transform, mrack ); @@ -681,6 +712,30 @@ fade_out:; info->author_name, &main_camera, mmdl ); } +VG_STATIC void skateshop_render_charshop(void) +{ +} + +/* + * World: render event + */ +VG_STATIC void skateshop_render(void) +{ + if( !global_skateshop.active ) return; + + ent_skateshop *shop = global_skateshop.ptr_ent; + + if( shop->type == k_skateshop_type_boardshop ){ + skateshop_render_boardshop(); + } + else if( shop->type == k_skateshop_type_charshop ){ + skateshop_render_charshop(); + } + else{ + vg_fatal_error( "Unknown store (%u)\n", shop->type ); + } +} + /* * Entity logic: entrance event */ @@ -708,8 +763,10 @@ VG_STATIC void ent_skateshop_call( world_instance *world, ent_call *call ) localplayer._walk.move_speed = 0.0f; global_skateshop.ptr_ent = shop; - skateshop_update_viewpage(); - workshop_op_item_scan(); + if( shop->type == k_skateshop_type_boardshop ){ + skateshop_update_viewpage(); + workshop_op_item_scan(); + } } }