优化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

@@ -1227,25 +1227,7 @@ do-- function pressKey(k)
return cache[k]
end
end
do-- function goTextReader{text,size,bg}
-- @MrZ626 I don't know where to put, please, deal with them for me lol
local cache={}
function goTextReader(D)
local f
local hash=D
local text,size,bg=D[1],D[2],D[3]
if type(D[1])=='function' then f=D[1] end
if not cache[hash] then
cache[hash]=function()
if f then text=f();f=nil end
SCN.go('textReader',nil,text,size,bg)
end
end
return cache[hash]
end
end
do-- SETXXX(k)
do-- SETXXX(k) & ROOMXXX(k)
local warnList={
'das','arr','dascut','dropcut','sddas','sdarr',
'ihs','irs','ims','RS',

View File

@@ -41,8 +41,8 @@ end
scene.widgetList={
WIDGET.newButton{name='staff', x=1140,y=340,w=200,h=80,font=35,code=goScene'staff'},
WIDGET.newButton{name='his', x=1140,y=440,w=200,h=80,font=35,code=goTextReader{function() return require"parts.updateLog":split("\n") end,20,'cubes'}},
WIDGET.newButton{name='legals', x=1140,y=540,w=200,h=80,font=35,code=goTextReader{function() return love.filesystem.read("legals.md"):split('\n') or "[legals.md not found]" end,15,'cubes'}},
WIDGET.newButton{name='his', x=1140,y=440,w=200,h=80,font=35,code=function() SCN.go('textReader',nil,(love.filesystem.read("updateLog.txt") or ""):split("\n"),20,'cubes') end},
WIDGET.newButton{name='legals', x=1140,y=540,w=200,h=80,font=35,code=function() SCN.go('textReader',nil,(love.filesystem.read("legals.md") or ""):split('\n'),15,'cubes') end},
WIDGET.newButton{name='back', x=1140,y=640,w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=backScene},
}

View File

@@ -201,16 +201,17 @@ function scene.keyDown(key)
SCN.back()
end
elseif key=='f1' then
goTextReader{
function() return (
text.dict.helpText:repD(
CHAR.key.up,CHAR.key.down,CHAR.key.left,CHAR.key.right,
CHAR.controller.dpadU,CHAR.controller.dpadD,CHAR.controller.dpadL,CHAR.controller.dpadR,
CHAR.controller.xboxX,CHAR.controller.xboxY,CHAR.controller.xboxA,CHAR.controller.xboxB,
CHAR.icon.help,CHAR.icon.copy,CHAR.icon.globe,CHAR.key.winMenu)
):split('\n')
end,
currentFontSize,'rainbow'}()
SCN.go(
'textReader',nil,
(text.dict.helpText:repD(
CHAR.key.up,CHAR.key.down,CHAR.key.left,CHAR.key.right,
CHAR.controller.dpadU,CHAR.controller.dpadD,CHAR.controller.dpadL,CHAR.controller.dpadR,
CHAR.controller.xboxX,CHAR.controller.xboxY,CHAR.controller.xboxA,CHAR.controller.xboxB,
CHAR.icon.help,CHAR.icon.copy,CHAR.icon.globe,CHAR.key.winMenu)
):split('\n'),
currentFontSize,
'rainbow'
)
-- ***ONLY USE FOR HOTLOADING ZICTIONARY WHILE IN GAME!***
-- ***Please commenting out this code if you don't use***

View File

@@ -117,7 +117,7 @@ function scene.keyDown(key,isRep)
end
elseif key=='m' then
if _testButton(13) then
goTextReader{function() return FILE.load('parts/language/manual_'..(SETTING.locale:find'zh' and 'zh' or SETTING.locale:find'ja' and 'ja' or SETTING.locale:find'vi' and 'vi' or 'en')..'.txt','-string'):split('\n') or "[manual file not found]" end,15,'cubes'}()
SCN.go('textReader',nil,FILE.load('parts/language/manual_'..(SETTING.locale:find'zh' and 'zh' or SETTING.locale:find'ja' and 'ja' or SETTING.locale:find'vi' and 'vi' or 'en')..'.txt','-string'):split('\n'),15,'cubes')
end
elseif key=='c' then
enterConsole()

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},
}

File diff suppressed because it is too large Load Diff