music player, credits
authorhgn <hgodden00@gmail.com>
Sun, 28 May 2023 19:31:35 +0000 (20:31 +0100)
committerhgn <hgodden00@gmail.com>
Sun, 28 May 2023 19:31:35 +0000 (20:31 +0100)
blender_export.py
maps_src/mp_spawn/main.mdl
menu.h
models_src/rs_menu.mdl
sound_src/pencil.ogg [new file with mode: 0644]
workshop.c
workshop.h
world_entity.c
world_gen.c

index ca29004d8c743edf498af4c6446d0695b080b556..32e548b4afa0d1583f4171949d0fec4e534b4886 100644 (file)
@@ -2760,16 +2760,15 @@ class SR_OBJECT_ENT_AUDIO(bpy.types.PropertyGroup):
       box.prop( data[0], 'flag_loop' )
       box.prop( data[0], 'flag_auto' )
 
+      layout.prop( data[0], 'probability_curve' )
+
       split = layout.split(factor=0.7)
       c = split.column()
       c.label( text='Filepath' )
       c = split.column()
-      c.label( text='Chance (0.1s)' )
-
-      layout.prop( data[0], 'probability_curve' )
-
+      c.label( text='Chance' )
       layout.template_list('SR_UL_AUDIO_LIST', 'Files', \
-                            data[0], 'files', data[0], 'file_index', rows=5)
+                            data[0], 'files', data[0], 'files_index', rows=5)
 
       row = layout.row()
       row.operator( 'skaterift.al_new_entry', text='Add' )
index 13847efcf3522ff1415744a6ce3f9e791c7d8ae6..eea495ecc315d96038eb5e4bcdc29f6f702c7ab6 100644 (file)
Binary files a/maps_src/mp_spawn/main.mdl and b/maps_src/mp_spawn/main.mdl differ
diff --git a/menu.h b/menu.h
index dd2cf686d8b3cf286f29afeca822998fd2212240..30c025d17f085c61ed3961a6ed28490dc7223d61 100644 (file)
--- a/menu.h
+++ b/menu.h
@@ -9,11 +9,12 @@
 #include "shaders/model_menu.h"
 #include "audio.h"
 #include "input.h"
+#include "workshop.h"
 
 #define MENU_STACK_SIZE 8
 
 struct {
-   int active;
+   int active, credits_open;
    f32 factive;
    int disable_open;
 
@@ -213,6 +214,12 @@ static void menu_trigger_item( ent_menuitem *item )
          menu.active = 0;
          menu.page = 0xffffffff;
       }
+      else if( MDL_CONST_PSTREQ( &menu.model, q, "credits" ) ){
+         menu.credits_open = 1;
+      }
+      else if( MDL_CONST_PSTREQ( &menu.model, q, "workshop" ) ){
+         workshop_submit_command(0,NULL);
+      }
    }
    else if( item->type == k_ent_menuitem_type_page_button ){
       menu_open_page( mdl_pstr( &menu.model, item->button.pstr ) );
@@ -246,6 +253,18 @@ static f32 menu_slider_snap( f32 value, f32 old, f32 notch )
  */
 static void menu_update(void)
 {
+   if( workshop_form.page != k_workshop_form_hidden ){
+      return;
+   }
+
+   int escape = button_down( k_srbind_mback );
+   if( menu.credits_open ){
+      if( escape ){
+         menu.credits_open = 0;
+      }
+      return;
+   }
+
    if( button_down( k_srbind_mopen ) ){
       if( !menu.active && !menu.disable_open ){
          menu.active = 1;
@@ -270,8 +289,7 @@ static void menu_update(void)
        md = button_down( k_srbind_mdown ),
        mh = ml-mr,
        mv = mu-md,
-       enter = button_down( k_srbind_maccept ),
-       escape = button_down( k_srbind_mback );
+       enter = button_down( k_srbind_maccept );
 
    if( mh||mv||enter ){
       menu.input_mode = k_menu_input_mode_keys;
@@ -503,6 +521,45 @@ VG_STATIC void menu_render(void)
    shader_blitcolour_uColour( colour );
    render_fsquad();
 
+   if( workshop_form.page != k_workshop_form_hidden ){
+      return;
+   }
+
+   if( menu.credits_open ){
+      ui_rect panel = { 0,0, 460, 400 },
+              screen = { 0,0, vg.window_x,vg.window_y };
+      ui_rect_center( screen, panel );
+      ui_fill( panel, ui_colour(k_ui_bg) );
+      ui_outline( panel, 1, ui_colour(k_ui_fg) );
+      ui_rect_pad( panel, (ui_px[]){8,8} );
+
+      ui_rect title;
+      ui_split( panel, k_ui_axis_h, 28*2, 0, title, panel );
+      ui_text( title, "Skate Rift - Credits", 2, k_ui_align_middle_center, 0 );
+      ui_split( panel, k_ui_axis_h, 28, 0, title, panel );
+      ui_text( title, "Mt.Zero Software", 1, k_ui_align_middle_center, 0 );
+
+      ui_split( panel, k_ui_axis_h, 8, 0, title, panel );
+      ui_split( panel, k_ui_axis_h, 28, 0, title, panel );
+      ui_text( title, "A game by Harry Godden", 1, 
+               k_ui_align_middle_center, 0 );
+
+      ui_split( panel, k_ui_axis_h, 8, 0, title, panel );
+      ui_split( panel, k_ui_axis_h, 28*2, 0, title, panel );
+      ui_text( title, "Free Software", 2, k_ui_align_middle_center, 0 );
+
+      ui_split( panel, k_ui_axis_h, 8, 0, title, panel );
+      ui_text( panel, 
+            "Sam Lantinga       - SDL2 - libsdl.org\n"
+            "Hunter WB          - Anyascii\n"
+            "David Herberth     - GLAD\n"
+            "Dominic Szablewski - QOI - qoiformat.org\n"
+            "Sean Barrett       - stb_image,stb_vorbis,stb_include\n"
+            "Khronos Group      - OpenGL\n"
+            , 1, k_ui_align_left, 0 );
+      return;
+   }
+
    glEnable( GL_DEPTH_TEST );
    glDisable( GL_BLEND );
 
index 95f7de0ca1d5144bc6c3084e10b1c331b342940c..8d997b5ff4e98cdf974157dc40ab64f869583c0e 100644 (file)
Binary files a/models_src/rs_menu.mdl and b/models_src/rs_menu.mdl differ
diff --git a/sound_src/pencil.ogg b/sound_src/pencil.ogg
new file mode 100644 (file)
index 0000000..a89eb4a
Binary files /dev/null and b/sound_src/pencil.ogg differ
index 61a4899793505e344fc227f252a15d1e6f420f1e..bcb8574a016497006818e5ad81084cc8083c7876 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef WORKSHOP_C
 #define WORKSHOP_C
 
+#include "workshop.h"
+
 #define VG_GAME
 #include "vg/vg.h"
 #include "vg/vg_tex.h"
 #include "steam.h"
 #include "highscores.h"
 
-#define WORKSHOP_VIEW_PER_PAGE 15
-
-struct workshop_form{
-   struct {
-      char title[80];
-      char description[512];
-      char author[32];
-      struct ui_dropdown_value submission_type_selection;
-      enum workshop_file_type type;
-
-      PublishedFileId_t file_id; /* 0 if not published yet */
-
-      struct ui_dropdown_value visibility;
-      int submit_title,       /* set if the respective controls are touched */
-          submit_description,
-          submit_file_and_image;
-   } 
-   submission;
-
-   enum workshop_form_page{
-      k_workshop_form_hidden, 
-      k_workshop_form_open,      /* open but not looking at anything */
-      k_workshop_form_edit,      /* editing a submission */
-      k_workshop_form_cclosing,
-      k_workshop_form_closing_good, /* post upload screen */
-      k_workshop_form_closing_bad,  
-   }
-   page;
-
-   /* model viewer 
-    * -----------------------------
-    */
-
-   char addon_folder[128];
-   struct player_board board_model;
-
-   /* what does the user want to do with the image preview? */
-   enum workshop_form_file_intent{
-      k_workshop_form_file_intent_none,         /* loading probably */
-      k_workshop_form_file_intent_new,          /* board_model is valid */
-      k_workshop_form_file_intent_keep_old      /* just browsing */
-   }
-   file_intent;
-
-   world_instance *view_world;
-   ent_swspreview *ptr_ent;
-   v2f view_angles,
-       view_angles_begin;
-   v3f view_offset,
-       view_offset_begin;
-
-   float view_dist;
-   int view_changed;
-
-   /*
-    * published UGC request
-    * ------------------------------
-    */
-
-   struct {
-      UGCQueryHandle_t handle;
-      EResult result;
-
-      int all_item_count,
-          returned_item_count;
-   }
-   ugc_query;
-
-   /* 
-    * UI information
-    * ------------------------------------------
-    */
-
-   const char *failure_or_success_string;
-
-   int img_w, img_h;
-   u8 *img_buffer;
-
-   int view_published_page_count,
-       view_published_page_id;
-
-   struct published_file{
-      EResult result;
-      int result_index;
-      char title[80];
-   }
-   published_files_list[WORKSHOP_VIEW_PER_PAGE];
-   int published_files_list_length;
-}
-static workshop_form;
-
 static struct ui_dropdown_opt workshop_form_visibility_opts[] = {
  { "Public",       k_ERemoteStoragePublishedFileVisibilityPublic },
  { "Unlisted",     k_ERemoteStoragePublishedFileVisibilityUnlisted },
index 36a6aa5ad2f0b7e2ce18ab4006104242ea72e8fe..f328d179316444e80e5b3dfaa84672bb54a23ecc 100644 (file)
@@ -8,6 +8,11 @@
 #include "vg/vg_steam_remote_storage.h"
 #include "skaterift.h"
 #include "pointcloud.h"
+#include "vg/vg_steam_auth.h"
+#include "vg/vg_steam_ugc.h"
+#include "vg/vg_steam_friends.h"
+#include "steam.h"
+#include "ent_skateshop.h"
 
 struct async_workshop_filepath_info{
    PublishedFileId_t id;
@@ -25,6 +30,101 @@ struct async_workshop_metadata_info{
    const char *path;
 };
 
+
+#define WORKSHOP_VIEW_PER_PAGE 15
+
+struct workshop_form{
+   struct {
+      char title[80];
+      char description[512];
+      char author[32];
+      struct ui_dropdown_value submission_type_selection;
+      enum workshop_file_type type;
+
+      PublishedFileId_t file_id; /* 0 if not published yet */
+
+      struct ui_dropdown_value visibility;
+      int submit_title,       /* set if the respective controls are touched */
+          submit_description,
+          submit_file_and_image;
+   } 
+   submission;
+
+   enum workshop_form_page{
+      k_workshop_form_hidden, 
+      k_workshop_form_open,      /* open but not looking at anything */
+      k_workshop_form_edit,      /* editing a submission */
+      k_workshop_form_cclosing,
+      k_workshop_form_closing_good, /* post upload screen */
+      k_workshop_form_closing_bad,  
+   }
+   page;
+
+   /* model viewer 
+    * -----------------------------
+    */
+
+   char addon_folder[128];
+   struct player_board board_model;
+
+   /* what does the user want to do with the image preview? */
+   enum workshop_form_file_intent{
+      k_workshop_form_file_intent_none,         /* loading probably */
+      k_workshop_form_file_intent_new,          /* board_model is valid */
+      k_workshop_form_file_intent_keep_old      /* just browsing */
+   }
+   file_intent;
+
+   world_instance *view_world;
+   ent_swspreview *ptr_ent;
+   v2f view_angles,
+       view_angles_begin;
+   v3f view_offset,
+       view_offset_begin;
+
+   float view_dist;
+   int view_changed;
+
+   /*
+    * published UGC request
+    * ------------------------------
+    */
+
+   struct {
+      UGCQueryHandle_t handle;
+      EResult result;
+
+      int all_item_count,
+          returned_item_count;
+   }
+   ugc_query;
+
+   /* 
+    * UI information
+    * ------------------------------------------
+    */
+
+   const char *failure_or_success_string;
+
+   int img_w, img_h;
+   u8 *img_buffer;
+
+   int view_published_page_count,
+       view_published_page_id;
+
+   struct published_file{
+      EResult result;
+      int result_index;
+      char title[80];
+   }
+   published_files_list[WORKSHOP_VIEW_PER_PAGE];
+   int published_files_list_length;
+}
+static workshop_form;
+
+
+
+VG_STATIC int workshop_submit_command( int argc, const char *argv[] );
 VG_STATIC void async_workshop_get_filepath( void *data, u32 len );
 VG_STATIC void async_workshop_get_installed_files( void *data, u32 len );
 VG_STATIC void workshop_load_metadata( const char *path,
index 61d014d6ea38806dcecfef8ab4066ba72aba89cd..006ef9faa5e27edf2d35cd8da76759c8ec749ad8 100644 (file)
@@ -194,7 +194,6 @@ VG_STATIC void ent_audio_call( world_instance *world, ent_call *call ){
             p   = clip->probability * mod;
 
       bar += p;
-
       if( chance < bar ){
          audio_lock();
 
index f7f8eda03658b8638b41888c33507689e65fbfd7..a454d02509b6baac826cd00b74b7662e3a5985da 100644 (file)
@@ -577,6 +577,19 @@ VG_STATIC void async_world_postprocess_render( void *payload, u32 _size )
    glBindBuffer( GL_UNIFORM_BUFFER, world->ubo_lighting );
    glBufferSubData( GL_UNIFORM_BUFFER, 0, 
                     sizeof(struct ub_world_lighting), &world->ub_lighting );
+
+   /* yes we are using this as the entity begin thing. FIXME */
+   world->probabilities[ k_probability_curve_constant ] = 1.0f;
+   for( u32 i=0; i<mdl_arrcount(&world->ent_audio); i++ ){
+      ent_audio *audio = mdl_arritm(&world->ent_audio,i);
+      if( audio->flags & AUDIO_FLAG_AUTO_START ){
+         ent_call call;
+         call.data = NULL;
+         call.function = k_ent_function_trigger;
+         call.id = mdl_entity_id( k_ent_audio, i );
+         entity_call( world, &call );
+      }
+   }
 }
 
 /* Loads textures from the pack file */