优化textReader场景和相关方法

框架跟进
This commit is contained in:
MrZ_26
2023-11-13 18:23:27 +08:00
parent 7d23fe4acb
commit 3806f02fa5
7 changed files with 56 additions and 51 deletions

View File

@@ -1,5 +1,5 @@
local scene={}
local texts=WIDGET.newTextBox{name='texts',x=30,y=45,w=1000,h=640,font=20,fix=true}
local textBox=WIDGET.newTextBox{name='texts',x=30,y=45,w=1000,h=640,font=20,fix=true}
function scene.enter()
--[[
@@ -9,38 +9,33 @@ function scene.enter()
[3] - Background (in string format)
]]
if SCN.args[2] then
assert(type(SCN.args[2]=='number'), "2nd argument (font size) must be a number!")
scene.widgetList.texts=WIDGET.newTextBox{name='texts',x=30,y=45,w=1000,h=640,font=SCN.args[2],fix=true}
end
if SCN.args[3] then
assert(type(SCN.args[3]=='string'), "3rd argument (background) must be a string!")
end
textBox.font=SCN.args[2] or 20
textBox:setTexts(SCN.args[1] and SCN.args[1] or {"No text loaded"})
textBox:reset()
BG.set(SCN.args[3])
scene.widgetList.texts:setTexts(SCN.args[1] and SCN.args[1] or {"No text!"})
end
function scene.wheelMoved(_,y)
WHEELMOV(y)
end
function scene.keyDown(key)
if key=='up' then
scene.widgetList.texts:scroll(-5)
textBox:scroll(-5)
elseif key=='down' then
scene.widgetList.texts:scroll(5)
textBox:scroll(5)
elseif key=='pageup' then
scene.widgetList.texts:scroll(-20)
textBox:scroll(-20)
elseif key=='pagedown' then
scene.widgetList.texts:scroll(20)
textBox:scroll(20)
elseif key=='escape' then
SCN.back()
end
end
scene.widgetList={
texts,
textBox,
WIDGET.newButton{name='back',x=1140,y=640,w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=backScene},
}