basic replayable replays
[carveJwlIkooP6JGAAIwe30JlM.git] / menu.h
diff --git a/menu.h b/menu.h
index 0707e7344b30686a9fd5f70bdbd8335f73f9c77c..9f62242cc42de8589ea94d679bcca2260de0a7f3 100644 (file)
--- a/menu.h
+++ b/menu.h
@@ -5,22 +5,23 @@
 #include "model.h"
 #include "world_render.h"
 #include "player.h"
-#include "conf.h"
 #include "shaders/model_menu.h"
+#include "audio.h"
+#include "input.h"
+#include "workshop.h"
 
 #define MENU_STACK_SIZE 8
 
 struct {
-   int active;
-   f32 factive;
+   int active, credits_open;
    int disable_open;
 
    u32 page, /* current page index */
        page_depth;
 
    enum menu_input_mode{
-      k_menu_input_mode_mouse,
-      k_menu_input_mode_keys
+      k_menu_input_mode_keys,
+      k_menu_input_mode_mouse
    }
    input_mode;
    f32 mouse_track, mouse_dist;  /* used for waking up mouse */
@@ -204,13 +205,29 @@ static void menu_trigger_item( ent_menuitem *item )
       if( MDL_CONST_PSTREQ( &menu.model, q, "quit" ) ){
          vg.window_should_close = 1;
       }
-      else if( MDL_CONST_PSTREQ( &menu.model, q, "reset" ) ){
+      else if( MDL_CONST_PSTREQ( &menu.model, q, "reset_nearest" ) ){
          localplayer_cmd_respawn( 0, NULL );
          
          menu.page_depth = 0;
          menu.active = 0;
          menu.page = 0xffffffff;
       }
+      else if( MDL_CONST_PSTREQ( &menu.model, q, "reset_home" ) ){
+         world_static.active_world = 0;
+         world_static.active_trigger_volume_count = 0;
+         localplayer.viewable_world = world_current_instance();
+         localplayer_cmd_respawn( 1, (const char *[]){"start"} );
+
+         menu.page_depth = 0;
+         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 ) );
@@ -244,6 +261,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;
@@ -253,9 +282,6 @@ static void menu_update(void)
       }
    }
 
-   menu.factive = vg_lerpf( menu.factive, menu.active, 
-                            vg.time_frame_delta * 6.0f );
-
    if( !menu.active ) return;
 
    enum menu_input_mode prev_mode = menu.input_mode;
@@ -268,8 +294,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;
@@ -501,6 +526,46 @@ VG_STATIC void menu_render(void)
    shader_blitcolour_uColour( colour );
    render_fsquad();
 
+   if( (workshop_form.page != k_workshop_form_hidden) ||
+       (vg_ui.focused_control_type != k_ui_control_none) ){
+      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 );