turbo chaos
[carveJwlIkooP6JGAAIwe30JlM.git] / ent_skateshop.c
index bfec73f9edaf24fe6082b90af3182f7fb2875478..427347d430379a153f2b1206f396a804d5744cb4 100644 (file)
@@ -10,7 +10,6 @@
 #include "player.h"
 #include "gui.h"
 #include "menu.h"
-#include "pointcloud.h"
 #include "highscores.h"
 #include "steam.h"
 #include "addon.h"
@@ -122,63 +121,6 @@ static u16 skateshop_selected_cache_id(void){
    else return 0;
 }
 
-static void pointcloud_async_end(void *_, u32 __)
-{
-   pointcloud_animate( k_pointcloud_anim_opening );
-}
-
-static void pointcloud_clear_async(void *_, u32 __)
-{
-   pointcloud.count = 0;
-   pointcloud_animate( k_pointcloud_anim_opening );
-}
-
-static void skateshop_world_preview_loader_thread( void *_data )
-{
-   addon_reg *reg = _data;
-
-   char path_buf[4096];
-   vg_str path;
-   vg_strnull( &path, path_buf, 4096 );
-   addon_get_content_folder( reg, &path );
-   vg_strcat( &path, "/preview.bin" );
-
-   vg_linear_clear(vg_mem.scratch);
-   u32 size;
-   
-   void *data = vg_file_read( vg_mem.scratch, path_buf, &size );
-   if( data ){
-      if( size < sizeof(pointcloud_buffer) ){
-         vg_async_call( pointcloud_clear_async, NULL, 0 );
-         return;
-      }
-      
-      vg_async_item *call = vg_async_alloc(size);
-      pointcloud_buffer *pcbuf = call->payload;
-      memcpy( pcbuf, data, size );
-
-      u32 point_count = (size-sizeof(pointcloud_buffer)) /
-                           sizeof(struct pointcloud_vert);
-      pcbuf->max = point_count;
-      pcbuf->count = point_count;
-      pcbuf->op = k_pointcloud_op_clear;
-
-      vg_async_dispatch( call, async_pointcloud_sub );
-      vg_async_call( pointcloud_async_end, NULL, 0 );
-   }
-   else{
-      vg_async_call( pointcloud_clear_async, NULL, 0 );
-   }
-}
-
-static void skateshop_world_preview_loader_thread_and_end( void *_data ){
-   skateshop_world_preview_loader_thread( _data );
-}
-
-static void skateshop_load_world_preview( addon_reg *reg ){
-   vg_loader_start( skateshop_world_preview_loader_thread_and_end, reg );
-}
-
 /*
  * VG event preupdate 
  */
@@ -195,8 +137,7 @@ static void ent_skateshop_preupdate( ent_skateshop *shop, int active ){
       
    v3f dir = {0.0f,-1.0f,0.0f};
    mdl_transform_vector( &ref->transform, dir, dir );
-   m3x3_mulv( localplayer.invbasis, dir, dir );
-   player_vector_angles( world_static.focus_cam.angles, dir, 1.0f, 0.0f );
+   v3_angles( dir, world_static.focus_cam.angles );
 
    v3f lookat;
    if( shop->type == k_skateshop_type_boardshop ||
@@ -220,13 +161,8 @@ static void ent_skateshop_preupdate( ent_skateshop *shop, int active ){
    if( shop->type == k_skateshop_type_boardshop ){
       if( !vg_loader_availible() ) return;
 
-      gui_helper_action( axis_display_string( k_sraxis_mbrowse_h ), "browse" );
-      gui_helper_action( button_display_string( k_srbind_mback ), "exit" );
-
       u16 cache_id = skateshop_selected_cache_id();
-      if( cache_id ){
-         gui_helper_action( button_display_string( k_srbind_maccept ), "pick" );
-      }
+      global_skateshop.helper_pick->greyed = !cache_id;
 
       /*
        * Controls
@@ -264,6 +200,7 @@ static void ent_skateshop_preupdate( ent_skateshop *shop, int active ){
          network_send_item( k_netmsg_playeritem_board );
 
          world_entity_unfocus();
+         gui_helper_clear();
          skaterift_autosave(1);
          return;
       }
@@ -271,10 +208,6 @@ static void ent_skateshop_preupdate( ent_skateshop *shop, int active ){
    else if( shop->type == k_skateshop_type_charshop ){
       if( !vg_loader_availible() ) return;
 
-      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" );
-
       int changed = 0;
 
       if( button_down( k_srbind_mleft ) ){
@@ -309,22 +242,21 @@ static void ent_skateshop_preupdate( ent_skateshop *shop, int active ){
       if( button_down( k_srbind_maccept ) ){
          network_send_item( k_netmsg_playeritem_player );
          world_entity_unfocus();
+         gui_helper_clear();
       }
    }
    else if( shop->type == k_skateshop_type_worldshop ){
       int browseable = 0,
           loadable = 0;
 
-      if( addon_count(k_addon_type_world) && vg_loader_availible() ){
-         gui_helper_action( axis_display_string(k_sraxis_mbrowse_h), "browse" );
+      if( addon_count(k_addon_type_world) && vg_loader_availible() )
          browseable = 1;
-      }
 
-      if( vg_loader_availible() && global_skateshop.selected_world_id > 0 ){
-         gui_helper_action( button_display_string(k_srbind_maccept), 
-                            "open rift" );
+      if( vg_loader_availible() && global_skateshop.selected_world_id > 0 )
          loadable = 1;
-      }
+
+      global_skateshop.helper_browse->greyed = !browseable;
+      global_skateshop.helper_pick->greyed = !loadable;
       
       int change = 0;
 
@@ -346,6 +278,7 @@ static void ent_skateshop_preupdate( ent_skateshop *shop, int active ){
          }
       }
       
+#if 0
       if( change && pointcloud_idle() ){
          pointcloud_animate( k_pointcloud_anim_hiding );
       }
@@ -383,6 +316,7 @@ static void ent_skateshop_preupdate( ent_skateshop *shop, int active ){
             }
          }
       }
+#endif
    }
    else{
       vg_fatal_error( "Unknown store (%u)\n", shop->type );
@@ -393,6 +327,7 @@ static void ent_skateshop_preupdate( ent_skateshop *shop, int active ){
          network_send_item( k_netmsg_playeritem_player );
 
       world_entity_unfocus();
+      gui_helper_clear();
       return;
    }
 }
@@ -641,6 +576,7 @@ static void skateshop_render_worldshop( ent_skateshop *shop ){
    m4x3_mul( mtext, mlocal, mtextmdl );
    font3d_simple_draw( 0, bufsubtext, &skaterift.cam, mtextmdl );
 
+#if 0
    /* pointcloud */
    m4x3f mmdl;
    mdl_transform_m4x3( &mark_display->transform, mmdl );
@@ -652,6 +588,7 @@ static void skateshop_render_worldshop( ent_skateshop *shop ){
    pointcloud_render( world, &skaterift.cam, mmdl );
    glDisable(GL_BLEND);
    glEnable(GL_DEPTH_TEST);
+#endif
 }
 
 /*
@@ -668,6 +605,23 @@ static void skateshop_render( ent_skateshop *shop ){
       vg_fatal_error( "Unknown store (%u)\n", shop->type );
 }
 
+static void ent_skateshop_helpers_pickable( const char *acceptance ){
+   vg_str text;
+
+   if( gui_new_helper( input_button_list[k_srbind_mback], &text ))
+      vg_strcat( &text, "exit" );
+
+   if( (global_skateshop.helper_pick = gui_new_helper(
+               input_button_list[k_srbind_maccept], &text))){
+      vg_strcat( &text, acceptance );
+   }
+
+   if( (global_skateshop.helper_browse = gui_new_helper( 
+               input_axis_list[k_sraxis_mbrowse_h], &text ))){
+      vg_strcat( &text, "browse" );
+   }
+}
+
 /*
  * Entity logic: entrance event
  */
@@ -685,26 +639,18 @@ static void ent_skateshop_call( world_instance *world, ent_call *call ){
       vg_info( "Entering skateshop\n" );
 
       world_entity_focus( call->id );
-#if 0
-      localplayer.immobile = 1;
-      menu.disable_open = 1;
-      skaterift.activity = k_skaterift_skateshop;
-
-      v3_zero( localplayer.rb.v );
-      v3_zero( localplayer.rb.w );
-      localplayer._walk.move_speed = 0.0f;
-      global_skateshop.ptr_ent = shop;
-#endif
+      gui_helper_clear();
       
       if( shop->type == k_skateshop_type_boardshop ){
          skateshop_update_viewpage();
          skateshop_op_board_scan();
+         ent_skateshop_helpers_pickable( "pick" );
       }
       else if( shop->type == k_skateshop_type_charshop ){
-         
+         ent_skateshop_helpers_pickable( "pick" );
       }
       else if( shop->type == k_skateshop_type_worldshop ){
-         pointcloud_animate( k_pointcloud_anim_opening );
+         ent_skateshop_helpers_pickable( "open rift" );
          skateshop_op_world_scan();
       }
    }