-- Read-only Quest Log movie, drawn from recorded tiles and actor tracks. local Q=require('src.core.game3.quest_log') local Font=require('src.ui.game3.frlg_font') local UI={} function UI.install(cache) UI.pack=nil local src=cache and cache:read('data/generated/gba/quest_log/pack.lua') if src then local f=loadstring(src,'@quest_log/pack.lua') if f then setfenv(f,{});UI.pack=f() end end end function UI.text(key,args,session) local text=UI.pack and UI.pack.text[key] or '' args=args or {};session=session or {} return (text:gsub('{([^}]+)}',function(k) if k=='PLAYER' then return session.name or 'RED' end if k=='RIVAL' then return session.rivalName or 'BLUE' end local v=args[k] or args[tonumber(k:match('^S(%d+)$'))] or args[k:match('^S(%d+)$')] if type(v)=='table' then return UI.pack.text[v.text] or '' end return tostring(v or '') end)) end function UI.begin(session) if not UI.pack then return nil end return Q.playback(session.questLog) end local function tiles(scene,frame,over) local T=require('src.core.game3.tileset_native') local cx=math.floor(frame.x+8-120);local cy=math.floor(frame.y+8-80) local textures={} for y=math.floor(cy/16),math.floor((cy+159)/16) do for x=math.floor(cx/16),math.floor((cx+239)/16) do local tile=scene.tiles and scene.tiles[x..','..y] if tile then local ts=textures[tile[2]] or T.get(tile[2]) if tile[2] then textures[tile[2]]=ts end if ts then local slot=T.slotFor(ts,tile[1]) local quad if over then quad=T.overQuad(ts,slot) else quad=T.quad(ts,slot) end local image if over then image=ts.overImage else image=ts.image end if image and quad and (not over or ts.layered) then love.graphics.draw(image,quad,x*16-cx,y*16-cy) end end end end end end function UI.draw(playback,session) love.graphics.clear(0,0,0,1) local scene=playback:current();local frame=playback:frame() if not scene or not frame then return end -- The original presents previous scenes in monochrome, then the save in color. if not UI.shader and love.graphics.newShader then UI.shader=love.graphics.newShader([[vec4 effect(vec4 c, Image tex, vec2 uv, vec2 sc) { vec4 p=Texel(tex,uv)*c; float y=dot(p.rgb,vec3(0.299,0.587,0.114)); return vec4(vec3(y),p.a); }]]) end if not playback:isFinal() then love.graphics.setShader(UI.shader) end love.graphics.setColor(1,1,1,1) tiles(scene,frame,false) local actors=frame.actors table.sort(actors,function(a,b)return a.y