mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-19 12:15:31 +02:00
Translate the clock-setting screens' day names and time-of-day word
DAYS (SUNDAY..SATURDAY), the MORN/DAY/NITE word PrintHour prints, and the "o'clock"/"min." suffixes bypassed src/core/Strings.lua entirely -- they were plain Lua literals with no lookup, so a translation mod's `strings` registry had nothing to catch and Oak's clock screens, the day-of-week wheel, the main menu clock box and the Pokegear's clock card kept printing English regardless of the loaded language (reported from a real Spanish Gold build). Both live in src/core/gen2/Clock.lua, which already owns weekday/hour arithmetic and is already required by InitClock.lua, MainMenu.lua and Pokegear.lua: Clock.DAY_NAMES + Clock.weekdayName(day) is the one place the three screens read a weekday's name from, so a fix to it cannot land on one screen and silently miss the other two. Clock.daytimeLabel(hour) is the translated counterpart to Palettes.clockDaytime, which keeps answering the untranslated MORN/DAY/NITE key every FORCED_DAYTIME lookup in Palettes.lua compares against -- src/world/gen2/Palettes.lua itself is untouched, so that module stays pure table/color math with no Strings coupling.
This commit is contained in:
@@ -16,13 +16,56 @@
|
||||
-- it (src/ui/gen2/InitClock.lua, src/script/gen2/Specials.lua SetDayOfWeek)
|
||||
-- and World only ever reads it.
|
||||
|
||||
local Palettes = require("src.world.gen2.Palettes")
|
||||
local Runtime = require("src.mods.Runtime")
|
||||
local Strings = require("src.core.Strings")
|
||||
|
||||
local Clock = {}
|
||||
|
||||
Clock.MINUTES_PER_DAY = 24 * 60
|
||||
Clock.DAYS = 7
|
||||
|
||||
-- data/text/day_of_week.asm order, which is wCurDay's own: SUNDAY is 0, so
|
||||
-- index 1 is SUNDAY -- matching both InitClock's `self.day + 1` and
|
||||
-- `Clock.weekday(save) + 1`. Strings.source, not Strings: built at require
|
||||
-- time, before Strings.load has a catalog, so Clock.weekdayName looks each
|
||||
-- name up at display time instead (src/battle/MoveEffects.lua's STAT_LABEL
|
||||
-- is the same pattern). One shared table and one lookup function, so
|
||||
-- InitClock's screens, the main menu clock box and the Pokegear clock card
|
||||
-- cannot drift apart on what a weekday is called.
|
||||
Clock.DAY_NAMES = {
|
||||
Strings.source("SUNDAY"), Strings.source("MONDAY"), Strings.source("TUESDAY"),
|
||||
Strings.source("WEDNESDAY"), Strings.source("THURSDAY"), Strings.source("FRIDAY"),
|
||||
Strings.source("SATURDAY"),
|
||||
}
|
||||
|
||||
-- The translated name for a 1-based weekday (SUNDAY = 1), or nil if `day` is
|
||||
-- out of range.
|
||||
function Clock.weekdayName(day)
|
||||
local name = Clock.DAY_NAMES[day]
|
||||
return name and Strings(name)
|
||||
end
|
||||
|
||||
-- The three words Palettes.clockDaytime can hand back, translated (never
|
||||
-- DARK: that one only comes out of Palettes.daytimeFor, for a PALETTE_DARK
|
||||
-- map, and is never printed as text). Strings.source, not Strings:
|
||||
-- clockDaytime's return value is also an internal key every
|
||||
-- FORCED_DAYTIME/palette lookup in Palettes.lua compares against, so THAT
|
||||
-- stays untranslated -- only this table, and Clock.daytimeLabel below, look
|
||||
-- a word up, at the UI call sites that actually print it.
|
||||
local DAYTIME_LABEL = {
|
||||
MORN = Strings.source("MORN"), DAY = Strings.source("DAY"),
|
||||
NITE = Strings.source("NITE"),
|
||||
}
|
||||
|
||||
-- clockDaytime's word, translated -- the one InitClock's clock-setting
|
||||
-- screen and the Pokegear's clock card print (DisplayHourOClock /
|
||||
-- Pokegear_UpdateClock).
|
||||
function Clock.daytimeLabel(hour)
|
||||
local daytime = Palettes.clockDaytime(hour)
|
||||
return Strings(DAYTIME_LABEL[daytime] or daytime)
|
||||
end
|
||||
|
||||
-- InitClock's own default: `ld a, 10 ; default hour = 10 AM`, with the minute
|
||||
-- buffer left at the zero ByteFill put there.
|
||||
Clock.DEFAULT_HOUR = 10
|
||||
|
||||
Reference in New Issue
Block a user