Skip to content

Commit

Permalink
优化textReader场景和相关方法
Browse files Browse the repository at this point in the history
框架跟进
  • Loading branch information
MrZ626 committed Nov 13, 2023
1 parent 7d23fe4 commit 3806f02
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 51 deletions.
2 changes: 1 addition & 1 deletion Zframework
Submodule Zframework updated 1 files
+4 −3 widget.lua
20 changes: 1 addition & 19 deletions parts/gameFuncs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions parts/scenes/about.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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},
}

Expand Down
21 changes: 11 additions & 10 deletions parts/scenes/dict.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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***
Expand Down
2 changes: 1 addition & 1 deletion parts/scenes/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
25 changes: 10 additions & 15 deletions parts/scenes/textReader.lua
Original file line number Diff line number Diff line change
@@ -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()
--[[
Expand All @@ -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},
}

Expand Down
33 changes: 30 additions & 3 deletions parts/updateLog.lua → updateLog.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,40 @@
return [=[
未来计划:
正在点亮科技树...

0.17.16: 暂停 Break
新增:
新模式:拼花-棋盘 (by NOT_A_ROBOT) #999
新模式:拼花-反大于号 (by NOT_A_ROBOT) #999
新模式:消四挖掘 (从隐藏改为地图可见)
TAS工具添加自动跳过功能 (by NOT_A_ROBOT) #992
越南语词典和帮助 (by Shard Nguyễn, Squishy and TVN community) #1012
改动:
20g段位模式铁门未达标时显示具体信息 (by NOT_A_ROBOT) #985
优化科研-操作限制模式的限制规则
自定义游戏可以保存录像并回放了 (by Gompyn) #1007
降低100行竞速B评价要求 (226s → 260s)
回放时模式名称下边不再显示当前模式本地pb
调整c4w_n模式排行榜成绩格式改为时间在前
文本层面统一HPC为Half PC
删除五连块和三连块模式图标的图片文件
场地编辑界面显示隐形块
优化小程序piano性能
调整一些语言文本细节
制作人员名单补漏
修复:
BiRS一些180°旋转时对称方块踢墙表不对称
自定义游戏没有正确传递hold开关 #779
调整语音音量时测试音频太乱 #823
dropper小程序玩不了
词典滚动列表框报错

0.17.15: 暂停 Break
新增:
bagP1inf序列模式
新模式:操作次数限制 (by NOT_A_ROBOT) #946
新模式:操作次数限制 (by NOT_A_ROBOT) #946
如果Hold会导致死亡,会添加一点额外的I_S时间 #971 #646
无尽模式添加无限场地高度开关 (by NOT_A_ROBOT) #961
Piano小程序新增触屏可用按键 (by Squishy) #939 #953
改动:
续上一块的das不再计一次操作次数
更新触屏按键图标/两个方块皮肤/字体 (by C₂₉H₂₅N₃O₅) #932 #944
Expand Down Expand Up @@ -2401,4 +2429,3 @@ return [=[
GUI position editted
grid BG changed
smarter AI
]=]

0 comments on commit 3806f02

Please sign in to comment.