Skip to content

Free games for graphing calculators: NumWorks, TI-Nspire CX, Casio fx-CG50 and soon TI-84 Plus CE. Balatro, Celeste, Hollow Knight, Minecraft and more.

Hollow Knight: the focus tablet's lesson clear of its text

Mason363e66ad6d234a5
diff --git a/games/hollowknight/src/game.h b/games/hollowknight/src/game.h
index 952f9c68..00c828c2 100644
--- a/games/hollowknight/src/game.h
+++ b/games/hollowknight/src/game.h
@@ -509,6 +509,7 @@ void dialogue_start_yn(int text);
void dialogue_yn_toll(int cost);
void dialogue_yn_requester(int obj);
bool dialogue_finished(void);
+bool dialogue_last_page(void); /* (the text shown on its last page, or none shown) */
bool dialogue_box_shown(void);
void dialogue_cancel(void);
void dialogue_tick(void);
diff --git a/games/hollowknight/src/msg.c b/games/hollowknight/src/msg.c
index a522b0d1..63100223 100644
--- a/games/hollowknight/src/msg.c
+++ b/games/hollowknight/src/msg.c
@@ -67,6 +67,9 @@ static void fade_start(Fade *f, float to, float time, float delay) {
}
static void fade_tick(Fade *f) {
if (f->alpha == f->to) return;
+ /* (the focus tutorial: not up before the tablet's text is on its last page; the game's holds it on one page, the
+ * bigger text here on two) */
+ if (f == &fp && f->to > f->alpha && f->t >= f->delay && !dialogue_last_page()) return;
f->t += DT;
float k = f->time > 0 ? (f->t - f->delay) / f->time : 1;
if (k > 0) f->alpha = f->from + (f->to - f->from) * (k > 1 ? 1 : k);
@@ -308,7 +311,12 @@ static void first_map_draw(void) {
gfx_hud(&in, 0);
}
static const int styles[4] = {STYLE_MSG_NAME, STYLE_MSG, STYLE_MSG, STYLE_MSG};
- for (int i = 0; i < 4; i++) line(rows[i].text, styles[i], rows[i].x, rows[i].top, 0, true, a);
+ for (int i = 0; i < 4; i++) {
+ int style = styles[i]; /* (a size smaller where the bigger text would run off the screen) */
+ while (style != STYLE_MSG_NAME && style != STYLE_MSG_XS && line(rows[i].text, style, 0, 0, 0, true, 0) > VIEW_W - 8)
+ style = style == STYLE_MSG ? STYLE_MSG_S : STYLE_MSG_XS;
+ line(rows[i].text, style, rows[i].x, rows[i].top, 0, true, a);
+ }
/* (the key: its box about its place) */
float w = line(key.text, STYLE_PROMPT, 0, key.y, 0, false, 0) / HUD_PX + 0.5f;
key_box(key.text, key.x - w / 2, key.y, a, 25);
@@ -323,8 +331,16 @@ static void focus_prompt_draw(void) {
Inst in;
sprite_inst(bg.sprite, bg.x, bg.y, 0, bg.kx, bg.ky, gfx_dyn_tint(29, 255, 255, 255, (uint8_t)(a * 255 + 0.5f)), &in);
gfx_hud(&in, 0);
- for (int i = 0; i < 4; i++) line(rows[i].text, STYLE_MSG, rows[i].x, rows[i].top, rows[i].align, true, a);
- key_box(key.text, key.x, key.y, a, 30);
+ /* (its lines in the message's smallest size, still bigger than the game's: each a line under the one above at
+ * least, all over the tablet's stop below them; the key centred on its line, as the game's on its) */
+ const uint8_t *st = font_style(STYLE_MSG_XS);
+ float top = rows[0].top, key_top = top;
+ for (int i = 0; i < 4; i++) {
+ if (i) top = fminf(rows[i].top, top - font_line(st) / HUD_PX);
+ if (rows[i].align == 1) key_top = top; /* (HOLD, the key after it) */
+ line(rows[i].text, STYLE_MSG_XS, rows[i].x, top, rows[i].align, true, a);
+ }
+ key_box(key.text, key.x, key_top - (font_asc(st) + font_desc(st)) / 2 / HUD_PX, a, 30);
}
void msg_draw(void) {
diff --git a/games/hollowknight/src/text.c b/games/hollowknight/src/text.c
index 950af5e5..6c63cf09 100644
--- a/games/hollowknight/src/text.c
+++ b/games/hollowknight/src/text.c
@@ -271,6 +271,7 @@ void dialogue_yn_toll(int cost) { dl.toll = (int16_t)cost; }
void dialogue_yn_requester(int obj) { dl.requester = (int16_t)obj; }
bool dialogue_finished(void) { return dl.finished; }
+bool dialogue_last_page(void) { return !dl.text || dl.page + 1 >= dl.npages; }
bool dialogue_box_shown(void) { return dl.up || dl.alpha > 0; }
static void end_conversation(void) {
diff --git a/games/hollowknight/tests/play.c b/games/hollowknight/tests/play.c
index 73f91dec..b3ef6c79 100644
--- a/games/hollowknight/tests/play.c
+++ b/games/hollowknight/tests/play.c
@@ -645,6 +645,15 @@ static int texts_test(void) {
text_keys("charm tutorial", "_*30,_*60,_*100", false);
charm_tute_close();
}
+ /* King's Pass's first tablet: its text's first page, then its last with the focus tutorial up under it; the first
+ * map's lesson */
+ text_room("Tutorial_01", 111.46f, 31, "");
+ text_keys("focus tablet", "_*60,U*3,_*300", false);
+ text_keys("focus tablet", "O*2,_*300", false);
+ text_room("Crossroads_01", 40, 12, "");
+ first_map_prompt(true);
+ text_keys("first map", "_*200", false);
+ first_map_prompt(false);
/* a conversation (Elderbug's first) */
text_room("Town", 76, 12, "");
text_keys("Elderbug", "_*40,U*2,_*120,O*2,_*60,O*2,_*60,O*2,_*60,O*2,_*60,O*2,_*60", false);