From: hgn Date: Sun, 28 May 2023 19:31:35 +0000 (+0100) Subject: music player, credits X-Git-Url: https://harrygodden.com/git/?a=commitdiff_plain;h=7fb47c3eb672f4468da8b5b452c09d44e1389d5f;p=carveJwlIkooP6JGAAIwe30JlM.git music player, credits --- diff --git a/blender_export.py b/blender_export.py index ca29004..32e548b 100644 --- a/blender_export.py +++ b/blender_export.py @@ -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' ) diff --git a/maps_src/mp_spawn/main.mdl b/maps_src/mp_spawn/main.mdl index 13847ef..eea495e 100644 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 dd2cf68..30c025d 100644 --- 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 ); diff --git a/models_src/rs_menu.mdl b/models_src/rs_menu.mdl index 95f7de0..8d997b5 100644 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 index 0000000..a89eb4a Binary files /dev/null and b/sound_src/pencil.ogg differ diff --git a/workshop.c b/workshop.c index 61a4899..bcb8574 100644 --- a/workshop.c +++ b/workshop.c @@ -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" @@ -14,97 +16,6 @@ #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 }, diff --git a/workshop.h b/workshop.h index 36a6aa5..f328d17 100644 --- a/workshop.h +++ b/workshop.h @@ -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, diff --git a/world_entity.c b/world_entity.c index 61d014d..006ef9f 100644 --- a/world_entity.c +++ b/world_entity.c @@ -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(); diff --git a/world_gen.c b/world_gen.c index f7f8eda..a454d02 100644 --- a/world_gen.c +++ b/world_gen.c @@ -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; ient_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 */