From: hgn Date: Mon, 24 Mar 2025 22:27:38 +0000 (+0000) Subject: Improve cutscene subtitle legibility. Adjust some ui X-Git-Url: https://harrygodden.com/git/?a=commitdiff_plain;h=252d19a465e81275d1bdcadc3c6eca93ed3b57cc;p=carveJwlIkooP6JGAAIwe30JlM.git Improve cutscene subtitle legibility. Adjust some ui --- diff --git a/content_skaterift/maps/dev_tutorial/main.mdl b/content_skaterift/maps/dev_tutorial/main.mdl index e456456..3aa5688 100644 Binary files a/content_skaterift/maps/dev_tutorial/main.mdl and b/content_skaterift/maps/dev_tutorial/main.mdl differ diff --git a/src/ent_challenge.c b/src/ent_challenge.c index 50c27cb..1dfe7a3 100644 --- a/src/ent_challenge.c +++ b/src/ent_challenge.c @@ -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 ) ); diff --git a/src/metascene.c b/src/metascene.c index afe277f..20ca10f 100644 --- a/src/metascene.c +++ b/src/metascene.c @@ -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; } } diff --git a/src/metascene.h b/src/metascene.h index e6b9314..6988211 100644 --- a/src/metascene.h +++ b/src/metascene.h @@ -169,6 +169,7 @@ struct _cutscene } const *subtitle_list; u32 subtitle_index; + bool subtitle_length_warning; } extern _cutscene; diff --git a/src/scripts/tutorial_island.c b/src/scripts/tutorial_island.c index 87d2faf..317759b 100644 --- a/src/scripts/tutorial_island.c +++ b/src/scripts/tutorial_island.c @@ -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", diff --git a/src/skaterift_script.c b/src/skaterift_script.c index 5363931..4ce4ebe 100644 --- a/src/skaterift_script.c +++ b/src/skaterift_script.c @@ -1,4 +1,4 @@ -#define KCOL_JOHN KRED +#define KCOL_JOHN KNRM #define KCOL_MIKE KBLU #define KCOL_PRES KYEL #define KCOL_FBI KGRN