From 252d19a465e81275d1bdcadc3c6eca93ed3b57cc Mon Sep 17 00:00:00 2001 From: hgn Date: Mon, 24 Mar 2025 22:27:38 +0000 Subject: [PATCH] Improve cutscene subtitle legibility. Adjust some ui --- content_skaterift/maps/dev_tutorial/main.mdl | Bin 4770248 -> 4769872 bytes src/ent_challenge.c | 4 +- src/metascene.c | 70 +++++++++++++++++-- src/metascene.h | 1 + src/scripts/tutorial_island.c | 55 +++++++++------ src/skaterift_script.c | 2 +- 6 files changed, 102 insertions(+), 30 deletions(-) diff --git a/content_skaterift/maps/dev_tutorial/main.mdl b/content_skaterift/maps/dev_tutorial/main.mdl index e4564566892264226b9a070009d4a14f4eb04477..3aa56889a93e20e6627d39fb51472d015b560508 100644 GIT binary patch delta 2899 zcmYk8aZHrw9mk*d1&XI2he&}#Dy|(vfpUrzxC1>9D0I-m3LA7dxN?V_0Ytet z=Xsy+-F@JF-@nSc_EPv=+tII-$|jp5j?ApVG^H%w92y=94eUF_-pcm1ODRvJGR+PL zA}_hJ>RwSQg^_g9AL#4s_YVh$LjFEI*%^ss+ToGN?_KuY(a7IiS?OaOWWY^=1H+w% z2K~Pr&@(`-zoVI zpUC%~QY~Mv{F?fweg;waMvHE=>EVOTza^YRETNU=v39E3~q zA-pU1Jrp=3$7>vTjRS}Sh=X$D0OA1R0OFv+IDj~SIDj~SIM`(zKpgC%V6EKSWgP4_ z4&YNV3rpn&tdnG)*J_hS*e6HfxLkqLVpV#rIjMl>WE5VKkKi?V2yaV4mDm2~I@w?4 zvH!bH&Qy7<1X-@~TAL(mkJrkVc33VaV1s-LJ0!7MH`K#%nS#@D8P3T!@SK#@=!V1a znw*EX<%=2`5@cH~4GGdys~b+&>V`WoUoxK64Xv<2BCtcQ!#;7;>4q9OEt7CgK7r@t z5xgYD^}698Fes#skE|PmKqN2Z#rVho2b_5DyR!5DyR!ZN>w{LmLgr@_8E# z$&%AeiT^=lGRonPJFq*6^y~Bg3uZdQQ9HQNxRd_YE_S z=+Sz^QO)QF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S;sD|R;^1ZD z0OA1R0OFw9IDj~SIDj~)pbcYQzU&!m6b0mmbfjK?1LWp4En@c>b9Ds z8b+lHcFQNQS02NoQe3AS!tj!O1aHVaI4XJdx?z1i4Jp!JPeY2_tk(@Gujqyb=#f3p zCzoN9d<~4yO6(x1{$Wy+6Ee?%E1QRaJ@k{ zB>zx1)I*=_hD~x2M&%jomhvCzhAr@@d<;*^LwHGMFV_tLI4Xnik=$8M!!((`f`)0b zdWCM-zd|=$gC23L)D2$PBs*bL&O73;sN3T;^D`}1H=Qw1H{8R8q#I$IvUdD;5y@Bo$;{Vcz}3-cz}3-czDBjfOvp- zfOvS*cz}3-czBbB44J-xh74J~!FbqUJU~2bG#(%xARZtdARc~VJU~1^JU~47jR%Ma zKMk33%TGh5q&FE4O~wPn1H?l>H&jDBKs-P^Ks@}^cz}3-cz}3lHXfR3$ddkM8nWbO zv+)o#9)j*vPu90jFvU}bCsA*(G9%|IPk~9}6Z%R04oKtosNCC@Z4Jq@ZJP^5SmO&! zRQW{-X64`5Df+=AmA`-Ng+sD?dj;2ietQX@77t;IMp!Ml3RD#P7|XAJLY4yWyGwyoabt-F4k$kmtkh(kZ? z&dK$jUs->W@SfNC(7U+jpLWu8Ikop6R{rqd`y~#?yy;5S4S(^$E_)dxwGPC{oj=d? zWSy$@yj1G({Qu*1?8d+4^N-iDbKSKP|3$C(4is{?T?byn;I#vvClBe}IUK`BdjFb$ z#NCGua5HIrGxcp7t}@&LM8?k-B#|$SnM5Bg-)XGX8eQY(^;{j}1oM3nVb7i4 zV8%1_64mnD`50q+e0?`#YkYi&apKt6QgW%kjH`RvUjd5`SLnx;;UH|0FApy*! z`n#%*{)Uyv&qOsDPGcsOq;X|G_YA!68L)^=5=bI(kO^cWNg~N)5}8bfont = &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 -- 2.25.1