Make a scene for showing full text (like manual) but for convenience use (#1043)
This commit is contained in:
committed by
GitHub
parent
55800e307f
commit
c650f268f6
47
parts/scenes/textReader.lua
Normal file
47
parts/scenes/textReader.lua
Normal file
@@ -0,0 +1,47 @@
|
||||
local scene={}
|
||||
local texts=WIDGET.newTextBox{name='texts',x=30,y=45,w=1000,h=640,font=20,fix=true}
|
||||
|
||||
function scene.enter()
|
||||
--[[
|
||||
Argument:
|
||||
[1] - Text (in table format). Default to "No text!"
|
||||
[2] - Font size (in number)
|
||||
[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
|
||||
|
||||
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)
|
||||
elseif key=='down' then
|
||||
scene.widgetList.texts:scroll(5)
|
||||
elseif key=='pageup' then
|
||||
scene.widgetList.texts:scroll(-20)
|
||||
elseif key=='pagedown' then
|
||||
scene.widgetList.texts:scroll(20)
|
||||
elseif key=='escape' then
|
||||
SCN.back()
|
||||
end
|
||||
end
|
||||
|
||||
scene.widgetList={
|
||||
texts,
|
||||
WIDGET.newButton{name='back',x=1140,y=640,w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=backScene},
|
||||
}
|
||||
|
||||
return scene
|
||||
Reference in New Issue
Block a user