2024-02-12 01:28:41 +00:00
|
|
|
state_archaeology=klass()
|
|
|
|
function state_archaeology:init()
|
|
|
|
self.n_holy_books=#liturgy.holy_book
|
|
|
|
self:select_book(1)
|
|
|
|
end
|
|
|
|
function state_archaeology:enter() end
|
|
|
|
function state_archaeology:exit(new_top) end
|
|
|
|
|
|
|
|
function state_archaeology:reenter() end
|
|
|
|
function state_archaeology:suspend() end
|
|
|
|
|
|
|
|
function state_archaeology:select_book(n)
|
|
|
|
self.selection=n
|
|
|
|
local lines={}
|
|
|
|
local hb=liturgy.holy_book[self.selection]
|
|
|
|
self.title=hb[1]
|
|
|
|
printh()
|
|
|
|
for source in all(split(hb[2])) do
|
|
|
|
for line in all(liturgy.sacred_text_lines) do
|
|
|
|
if (line[1]==source) add(lines,self:_censor(source,line[2]))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
self.full_text=""
|
|
|
|
for i=1,#lines do
|
|
|
|
if (i>1) self.full_text..="\n"
|
|
|
|
self.full_text..=lines[i]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function state_archaeology:_censor(src,line)
|
|
|
|
if (completion_tracker:was_seen(src)) return line
|
|
|
|
local line2=""
|
|
|
|
for i=1,#line do
|
|
|
|
local c=sub(line,i,i)
|
|
|
|
if ("a"<=c and c<="z") c="?"
|
|
|
|
line2..=c
|
|
|
|
end
|
|
|
|
return "\f6"..line2.."\ff"
|
|
|
|
end
|
|
|
|
|
|
|
|
function state_archaeology:update()
|
|
|
|
local vel=0
|
|
|
|
if (btnp(0)) vel-=1
|
|
|
|
if (btnp(1)) vel+=1
|
2024-02-12 04:54:01 +00:00
|
|
|
if (btnp(5)) sounds:menu() self.done=true
|
|
|
|
if (vel!=0) sounds:menu() self:select_book((self.selection+vel-1)%self.n_holy_books+1)
|
2024-02-12 01:28:41 +00:00
|
|
|
end
|
|
|
|
function state_archaeology:draw()
|
|
|
|
local fullw,fullh=measure_text(self.full_text)
|
|
|
|
local total_height=fullh+16
|
|
|
|
|
|
|
|
cls(13)
|
|
|
|
local y=64-total_height\2
|
|
|
|
local tw=measure_text(self.title)-1
|
|
|
|
local x=64-tw\2
|
|
|
|
local tx=x
|
|
|
|
print(self.title,x,y,15)
|
|
|
|
y+=6
|
|
|
|
line(x,y,x+tw-1,y,15)
|
|
|
|
y+=3
|
|
|
|
|
|
|
|
local x=64-fullw\2
|
|
|
|
rectfill(x-1,y-1,x+fullw,y+fullh-1,4)
|
|
|
|
print(self.full_text,x,y,15)
|
|
|
|
y+=fullh+1
|
|
|
|
|
|
|
|
line(tx,y,tx+tw-1,y,15)
|
|
|
|
y+=2
|
|
|
|
|
|
|
|
print("⬅️",tx,y)
|
|
|
|
print("➡️",tx+tw-7,y)
|
|
|
|
print("❎ go back",1,122,15)
|
|
|
|
end
|