Improve cutscene subtitle legibility. Adjust some ui
authorhgn <hgodden00@gmail.com>
Mon, 24 Mar 2025 22:27:38 +0000 (22:27 +0000)
committerhgn <hgodden00@gmail.com>
Mon, 24 Mar 2025 22:27:38 +0000 (22:27 +0000)
content_skaterift/maps/dev_tutorial/main.mdl
src/ent_challenge.c
src/metascene.c
src/metascene.h
src/scripts/tutorial_island.c
src/skaterift_script.c

index e4564566892264226b9a070009d4a14f4eb04477..3aa56889a93e20e6627d39fb51472d015b560508 100644 (file)
Binary files a/content_skaterift/maps/dev_tutorial/main.mdl and b/content_skaterift/maps/dev_tutorial/main.mdl differ
index 50c27cb9da4afd981376dc67e7f2ed63fd17a297..1dfe7a354ea94bea420f144be994f325d1614811 100644 (file)
@@ -307,8 +307,8 @@ void _ent_challenge_ui( ui_context *ctx )
       ui_outline( ctx, box, 1, GUI_COL_NORM, 0 );
 
       ctx->font = &vgf_default_title;
-      ui_rect title = { box[0], box[1] + 16, box[2], box[3]-16 };
-      ui_text( ctx, box, "Retry?", 1, k_ui_align_center, 0 );
+      ui_rect title = { box[0], box[1] + 12, box[2], box[3]-16 };
+      ui_text( ctx, title, "Retry?", 1, k_ui_align_center, 0 );
 
       ui_rect bar = { box[0] + 8, (box[1] + box[3]) - (24+8), box[2] - 16, 24 };
       ui_fill( ctx, bar, ui_opacity( GUI_COL_DARK, 0.8f ) );
index afe277ffe9c04fe72e111255f4c6f06fe5afb810..20ca10f3fd76f06a861359ebbeacbda793400f90 100644 (file)
@@ -91,6 +91,7 @@ void _cutscene_unload(void)
    _cutscene.state = k_cutscene_state_unloading;
    _cutscene.player_binding = NULL;
    _cutscene.subtitle = NULL;
+   _cutscene.subtitle_length_warning = 0;
    _cutscene.subtitle_list = NULL;
    _cutscene.subtitle_index = 0;
    _cutscene.fadeout = 0;
@@ -503,6 +504,7 @@ void cutscene_update( f32 delta )
       _cutscene.state = k_cutscene_state_none;
       _cutscene.marker_this_frame = NULL;
       _cutscene.subtitle = NULL;
+      _cutscene.subtitle_length_warning = 0;
       return;
    }
 
@@ -590,12 +592,14 @@ void cutscene_update( f32 delta )
                if( vg_str_eq( marker, next->key ) )
                {
                   _cutscene.subtitle = next->value;
+                  _cutscene.subtitle_length_warning = 0;
                   _cutscene.subtitle_index ++;
                   absorbed = 1;
                }
                else if( vg_str_eq( marker, "$clear_subtitles" ) )
                {
                   _cutscene.subtitle = NULL;
+                  _cutscene.subtitle_length_warning = 0;
                   absorbed = 1;
                }
             }
@@ -846,15 +850,73 @@ void _cutscene_gui( ui_context *ctx )
 {
    if( _cutscene.subtitle )
    {
-      ui_rect box = { 0,0, 800, 40 };
+      ctx->font = &vgf_default_small;
+      ctx->kern[1] = 16;
+      ui_px scale = 2;
+
+      ui_rect box = { 0,0, 1000, 80*2 };
       ui_rect_center( (ui_rect){0,0,vg.window_x,vg.window_y}, box );
       box[1] = vg.window_y - (box[3] + 8);
-      ui_fill( ctx, box, ui_opacity( GUI_COL_DARK, 0.36f ) );
 
-      ctx->font = &vgf_default_large;
-      ui_text( ctx, box, _cutscene.subtitle, 1, k_ui_align_middle_center, 0 );
+      i32 lines = 1;
+      
+      const char *_c = _cutscene.subtitle;
+      u8 c;
+
+      i32 length = 0;
+      ui_px y = box[1];
+
+      while(1) 
+      {
+         c = *(_c ++);
+
+         /* TODO: This is pasted straight from vg_ui, maybe create a vg_ui_text_iter() ...? */
+         if( c == '\x1B' )
+         {
+            while( (c = *(_c ++)) )
+            {
+               if( c == 'm' ) 
+                  break;
+            } 
+           
+            if( c == 0 ) 
+               break;
+            else 
+               continue;
+         }
+
+         if( c >= 32 ) 
+            length ++;
+         else if( c == '\n' || c == '\0' ) 
+         {
+            ui_px w = length * ctx->font->sx*scale + 16;
+            ui_rect background_rect = { vg.window_x/2 - w/2, y-8, w, ctx->font->sy*scale+16 };
+
+            ui_fill( ctx, background_rect, ui_opacity( GUI_COL_DARK, 0.75f ) );
+            y += (ctx->font->sy)*scale + 16;
+
+            if( !_cutscene.subtitle_length_warning && (length > 50) )
+            {
+               vg_warn( "Subtitle text too long; '%s'\nLine limit 50chs, line was: %u\n", _cutscene.subtitle, length );
+               _cutscene.subtitle_length_warning = 1;
+            }
+            length = 0;
+
+            if( !_cutscene.subtitle_length_warning && (lines == 2) && (c != '\0') )
+            {
+               vg_warn( "Subtitle contains more than 2 lines; '%s'\n", _cutscene.subtitle );
+               _cutscene.subtitle_length_warning = 1;
+            }
+            lines ++;
+         }
+         
+         if( c == '\0' )
+            break;
+      }
 
+      ui_text( ctx, box, _cutscene.subtitle, scale, k_ui_align_center, 0 );
       ctx->font = &vgf_default_small;
+      ctx->kern[1] = 0;
    }
 }
 
index e6b931433d5c3f5e4466f0ad504f8ef93820d09d..6988211ae7dee4a08489375d73f8ee904278bd37 100644 (file)
@@ -169,6 +169,7 @@ struct _cutscene
    }
    const *subtitle_list;
    u32 subtitle_index;
+   bool subtitle_length_warning;
 }
 extern _cutscene;
 
index 87d2faf7fd7b4dfb1bbd07999207d0d0d4d6ea9f..317759b3eab0aeb1c80274d993e71652c23df024 100644 (file)
@@ -122,38 +122,47 @@ static bool _skaterift_script_ch1s4( ent_script_event *event )
 static bool _skaterift_script_ch1s5( ent_script_event *event )
 {
    static const struct cs_subtitle EN[] = {
-   { "j1", KCOL_JOHN "Alright, well then" },
-   { "j2", KCOL_JOHN "You're gonna need to play close attention to this part" },
-   { "j3", KCOL_JOHN "because its difficult.." },
-   { "j4", KCOL_JOHN "It's gonna take some practice until it clicks" },
-   { "j5", KCOL_JOHN "Right as you like, go across the transition of the ramp," },
-   { "j6", KCOL_JOHN "Right here," },
-   { "j7", KCOL_JOHN "you need to pump to gain some momentum." },
 
-   { "j8", KCOL_JOHN "What I mean right, watch" },
-   { "j9", KCOL_JOHN "just as I'm going into the base of the ramp" },
-   { "j10",KCOL_JOHN "I'm storing up some energy here by crouching down" },
-   { "j11",KCOL_JOHN "Right as I go across this point" },
-   { "j12",KCOL_JOHN "I'm almost jumping back up, adding some uwpwards momentum" },
+/* 50ch| set cc=70 |################################################| */
+{ "j1", KCOL_JOHN "Alright, well then" },
+{ "j2", KCOL_JOHN "You're gonna need to play close attention to\n"
+                  "this part" },
 
-   { "j13",KCOL_JOHN "Then as the board comes up to this angle.." },
-   { "j14",KCOL_JOHN "that upwards momentum is transferred into my speed" },
+{ "j3", KCOL_JOHN "because its difficult.." },
+{ "j4", KCOL_JOHN "It's gonna take some practice until it clicks" },
+{ "j5", KCOL_JOHN "Right as you like, go across the transition \n"
+                  "of the ramp," },
 
-   { "j15",KCOL_JOHN "Same principle works, same way in the other direction" },
+{ "j6", KCOL_JOHN "Right here," },
+{ "j7", KCOL_JOHN "you need to pump to gain some momentum." },
+{ "j8", KCOL_JOHN "What I mean right, watch" },
+{ "j9", KCOL_JOHN "just as I'm going into the base of the ramp" },
+{ "j10",KCOL_JOHN "I'm storing up some energy here by crouching down" },
+{ "j11",KCOL_JOHN "Right as I go across this point" },
+{ "j12",KCOL_JOHN "I'm almost jumping back up, adding some uwpwards\n"
+                  "momentum" },
 
-   { "j16",KCOL_JOHN "Now, like I'm saying" },
-   { "j17",KCOL_JOHN "this might take you a little bit until it clicks" },
+{ "j13",KCOL_JOHN "Then as the board comes up to this angle.." },
+{ "j14",KCOL_JOHN "that upwards momentum is transferred \n"
+                  "into my speed" },
 
-   { "j18",KCOL_JOHN "But once it does you'll feel it. You'll know!" },
+{ "j15",KCOL_JOHN "Same principle works, same way in the \n"
+                  "other direction" },
 
-   { "j19",KCOL_JOHN "And I uhh, set a target for you" },
-   { "j20",KCOL_JOHN "right up there.." },
-   { "j21",KCOL_JOHN "Thats how we'll know you're back on form." },
+{ "j16",KCOL_JOHN "Now, like I'm saying" },
+{ "j17",KCOL_JOHN "this might take you a little bit until it clicks" },
 
-   { "j22",KCOL_JOHN "Come see me at the docks once you've got it." },
+{ "j18",KCOL_JOHN "But once it does you'll feel it. You'll know!" },
 
-   { NULL, NULL },
+{ "j19",KCOL_JOHN "And I uhh, set a target for you" },
+{ "j20",KCOL_JOHN "right up there.." },
+{ "j21",KCOL_JOHN "Thats how we'll know you're back on form." },
+
+{ "j22",KCOL_JOHN "Come see me at the docks once you've got it." },
+
+{ NULL, NULL },
    };
+
    static const struct generic_cutscene cutscene = 
    {
       .metascene_path = "metascenes/ch1s5.ms",
index 5363931400decfe0d379a9e47c69373a22ec7abb..4ce4ebe253a0b78baf92eca30fce4d7c41c1e6be 100644 (file)
@@ -1,4 +1,4 @@
-#define KCOL_JOHN KRED
+#define KCOL_JOHN KNRM
 #define KCOL_MIKE KBLU
 #define KCOL_PRES KYEL
 #define KCOL_FBI  KGRN