npcs and tutorial stuff
[carveJwlIkooP6JGAAIwe30JlM.git] / ent_skateshop.c
index 251a58595addae93f9f51c241159612c811c04cb..fd59f3eb047cf652cdca82f3e0c065ac34e34f79 100644 (file)
@@ -1,21 +1,23 @@
-#ifndef ENT_SKATESHOP_C
-#define ENT_SKATESHOP_C
-
-#define VG_GAME
-#include "vg/vg.h"
 #include "vg/vg_steam_ugc.h"
 #include "vg/vg_msg.h"
+#include "vg/vg_tex.h"
+#include "vg/vg_image.h"
+#include "vg/vg_loader.h"
 #include "ent_skateshop.h"
 #include "world.h"
 #include "player.h"
 #include "gui.h"
 #include "menu.h"
-#include "highscores.h"
 #include "steam.h"
 #include "addon.h"
 #include "save.h"
 #include "network.h"
 
+struct global_skateshop global_skateshop = 
+{
+   .render={.reg_id=0xffffffff,.world_reg=0xffffffff}
+};
+
 /*
  * Checks string equality but does a hash check first
  */
@@ -149,7 +151,8 @@ static void skateshop_op_board_scan(void){
 }
 
 /* TODO: migrate to addon.c */
-static void skateshop_autostart_loading(void){
+void skateshop_autostart_loading(void)
+{
    if( !vg_loader_availible() ) return;
 
    SDL_AtomicLock( &addon_system.sl_cache_using_resources );
@@ -200,7 +203,8 @@ static void skateshop_init_async(void *_data,u32 size){
 /*
  * VG event init
  */
-static void skateshop_init(void){
+void skateshop_init(void)
+{
    vg_async_call( skateshop_init_async, NULL, 0 );
 }
 
@@ -234,7 +238,8 @@ static void skateshop_server_helper_update(void){
  * VG event preupdate 
  */
 void temp_update_playermodel(void);
-static void ent_skateshop_preupdate( ent_skateshop *shop, int active ){
+void ent_skateshop_preupdate( ent_skateshop *shop, int active )
+{
    if( !active ) return;
 
    /* input filter */
@@ -312,7 +317,8 @@ static void ent_skateshop_preupdate( ent_skateshop *shop, int active ){
          localplayer.board_view_slot = cache_id;
          network_send_item( k_netmsg_playeritem_board );
 
-         world_entity_unfocus();
+         world_entity_exit_modal();
+         world_entity_clear_focus();
          gui_helper_clear();
          skaterift_autosave(1);
          return;
@@ -359,7 +365,8 @@ 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();
+         world_entity_exit_modal();
+         world_entity_clear_focus();
          gui_helper_clear();
       }
    }
@@ -432,17 +439,20 @@ static void ent_skateshop_preupdate( ent_skateshop *shop, int active ){
       vg_fatal_error( "Unknown store (%u)\n", shop->type );
    }
 
-   if( button_down( k_srbind_mback ) ){
+   if( button_down( k_srbind_mback ) )
+   {
       if( shop->type == k_skateshop_type_charshop )
          network_send_item( k_netmsg_playeritem_player );
 
-      world_entity_unfocus();
+      world_entity_exit_modal();
+      world_entity_clear_focus();
       gui_helper_clear();
       return;
    }
 }
 
-static void skateshop_world_preupdate( world_instance *world ){
+void skateshop_world_preupdate( world_instance *world )
+{
    for( u32 i=0; i<mdl_arrcount(&world->ent_skateshop); i++ ){
       ent_skateshop *shop = mdl_arritm( &world->ent_skateshop, i );
 
@@ -713,7 +723,8 @@ none:;
 /*
  * World: render event
  */
-static void skateshop_render( ent_skateshop *shop ){
+void skateshop_render( ent_skateshop *shop )
+{
    if( shop->type == k_skateshop_type_boardshop )
       skateshop_render_boardshop( shop );
    else if( shop->type == k_skateshop_type_charshop )
@@ -726,7 +737,8 @@ static void skateshop_render( ent_skateshop *shop ){
       vg_fatal_error( "Unknown store (%u)\n", shop->type );
 }
 
-static void skateshop_render_nonfocused( world_instance *world, camera *cam ){
+void skateshop_render_nonfocused( world_instance *world, vg_camera *cam )
+{
    for( u32 j=0; j<mdl_arrcount( &world->ent_skateshop ); j ++ ){
       ent_skateshop *shop = mdl_arritm(&world->ent_skateshop, j );
 
@@ -780,7 +792,8 @@ static void ent_skateshop_helpers_pickable( const char *acceptance ){
 /*
  * Entity logic: entrance event
  */
-static void ent_skateshop_call( world_instance *world, ent_call *call ){
+void ent_skateshop_call( world_instance *world, ent_call *call )
+{
    u32 index = mdl_entity_id_id( call->id );
    ent_skateshop *shop = mdl_arritm( &world->ent_skateshop, index );
    vg_info( "skateshop_call\n" );
@@ -793,7 +806,8 @@ static void ent_skateshop_call( world_instance *world, ent_call *call ){
       
       vg_info( "Entering skateshop\n" );
 
-      world_entity_focus( call->id );
+      world_entity_set_focus( call->id );
+      world_entity_focus_modal();
       gui_helper_clear();
       
       if( shop->type == k_skateshop_type_boardshop ){
@@ -812,9 +826,9 @@ static void ent_skateshop_call( world_instance *world, ent_call *call ){
          vg_str text;
          global_skateshop.helper_pick = gui_new_helper(
                      input_button_list[k_srbind_maccept], &text);
+         if( gui_new_helper( input_button_list[k_srbind_mback], &text ))
+            vg_strcat( &text, "exit" );
          skateshop_server_helper_update();
       }
    }
 }
-
-#endif /* ENT_SKATESHOP_C */