整理词典代码,添加触屏可用的翻页按钮

This commit is contained in:
MrZ626
2021-04-19 13:35:09 +08:00
parent 129e9d5417
commit 635be949f0
8 changed files with 41 additions and 46 deletions

View File

@@ -505,8 +505,8 @@ return{
dict={ dict={
title="TetroDictionary", title="TetroDictionary",
link="Open URL", link="Open URL",
up="", up="",down="",
down="", pageup="↑↑",pagedown="",
}, },
stat={ stat={
path="Open Data Folder", path="Open Data Folder",

View File

@@ -461,8 +461,6 @@ return{
dict={ dict={
title="TetroDictionary", title="TetroDictionary",
link="Ouvrir URL", link="Ouvrir URL",
up="",
down="",
}, },
stat={ stat={
path="Ouvrir dossier des données", path="Ouvrir dossier des données",

View File

@@ -505,8 +505,6 @@ return{
dict={ dict={
title="TetroDictionary", title="TetroDictionary",
link="Abrir URL", link="Abrir URL",
up="",
down="",
}, },
stat={ stat={
path="Abrir Pasta De Data", path="Abrir Pasta De Data",

View File

@@ -466,8 +466,6 @@ return{
dict={ dict={
title="TetroDictionary", title="TetroDictionary",
link="Abrir URL", link="Abrir URL",
up="",
down="",
}, },
stat={ stat={
path="Abrir carpeta del juego", path="Abrir carpeta del juego",

View File

@@ -346,8 +346,6 @@ return{
dict={ dict={
title="TetroDictionary", title="TetroDictionary",
link="~~e>>", link="~~e>>",
up="",
down="",
}, },
stat={ stat={
path="%$%", path="%$%",

View File

@@ -582,8 +582,8 @@ return{
dict={ dict={
title="小Z方块词典", title="小Z方块词典",
link="打开链接", link="打开链接",
up="", up="",down="",
down="", pageup="↑↑",pagedown="",
}, },
stat={ stat={
path="打开存储目录", path="打开存储目录",

View File

@@ -19,22 +19,17 @@ local scrollPos--Scroll down length
local lastSearch--Last searched string local lastSearch--Last searched string
function scene.sceneInit() local typeColor={
dict=require("parts.language.dict_"..({"zh","zh","zh","en","en","en","en","en"})[SETTING.lang]) help=COLOR.Y,
other=COLOR.lOrange,
inputBox:clear() game=COLOR.lC,
result={} term=COLOR.lR,
url=dict[1][5] setup=COLOR.lY,
pattern=COLOR.lGrass,
waiting=0 english=COLOR.B,
selected=1 name=COLOR.lPurple,
scrollPos=0 }
local function getList()return result[1]and result or dict end
lastSearch=false
TASK.new(function()YIELD()WIDGET.sel=inputBox end)
BG.set("rainbow")
end
local function clearResult() local function clearResult()
TABLE.clear(result) TABLE.clear(result)
selected,scrollPos=1,0 selected,scrollPos=1,0
@@ -56,10 +51,26 @@ local function search()
if #result>0 then if #result>0 then
SFX.play("reach") SFX.play("reach")
end end
url=(result[1]and result or dict)[selected][5] url=getList()[selected][5]
lastSearch=input lastSearch=input
end end
function scene.sceneInit()
dict=require("parts.language.dict_"..({"zh","zh","zh","en","en","en","en","en"})[SETTING.lang])
inputBox:clear()
result={}
url=dict[1][5]
waiting=0
selected=1
scrollPos=0
lastSearch=false
TASK.new(function()YIELD()WIDGET.sel=inputBox end)
BG.set("rainbow")
end
function scene.wheelMoved(_,y) function scene.wheelMoved(_,y)
WHEELMOV(y) WHEELMOV(y)
end end
@@ -72,7 +83,7 @@ function scene.keyDown(key)
end end
end end
elseif key=="down"then elseif key=="down"then
if selected and selected<#(result[1]and result or dict)then if selected and selected<#getList()then
selected=selected+1 selected=selected+1
if selected>scrollPos+15 then if selected>scrollPos+15 then
scrollPos=selected-15 scrollPos=selected-15
@@ -99,7 +110,7 @@ function scene.keyDown(key)
SCN.back() SCN.back()
end end
end end
url=(result[1]and result or dict)[selected][5] url=getList()[selected][5]
end end
function scene.update(dt) function scene.update(dt)
@@ -122,18 +133,8 @@ function scene.update(dt)
end end
end end
local typeColor={
help=COLOR.yellow,
other=COLOR.lOrange,
game=COLOR.lCyan,
term=COLOR.lRed,
setup=COLOR.lYellow,
pattern=COLOR.lGrass,
english=COLOR.blue,
name=COLOR.lPurple,
}
function scene.draw() function scene.draw()
local list=result[1]and result or dict local list=getList()
gc.setColor(1,1,1) gc.setColor(1,1,1)
local t=list[selected][4] local t=list[selected][4]
if #t>900 then if #t>900 then
@@ -181,9 +182,11 @@ end
scene.widgetList={ scene.widgetList={
WIDGET.newText{name="title", x=20, y=5,font=70,align="L"}, WIDGET.newText{name="title", x=20, y=5,font=70,align="L"},
inputBox, inputBox,
WIDGET.newKey{name="link", x=1140, y=650,w=200,h=80,font=35,code=pressKey"link",hide=function()return not url end}, WIDGET.newKey{name="link", x=1150, y=655,w=200,h=80,font=35,code=pressKey"link",hide=function()return not url end},
WIDGET.newKey{name="up", x=1190, y=440,w=100,h=100,font=35,code=pressKey"up",hide=not MOBILE}, WIDGET.newKey{name="up", x=1130, y=460,w=60,h=90,font=35,code=pressKey"up",hide=not MOBILE},
WIDGET.newKey{name="down", x=1190, y=550,w=100,h=100,font=35,code=pressKey"down",hide=not MOBILE}, WIDGET.newKey{name="down", x=1130, y=560,w=60,h=90,font=35,code=pressKey"down",hide=not MOBILE},
WIDGET.newKey{name="pageup", x=1210, y=460,w=80,h=90,font=35,code=pressKey"pageup",hide=not MOBILE},
WIDGET.newKey{name="pagedown", x=1210, y=560,w=80,h=90,font=35,code=pressKey"pagedown",hide=not MOBILE},
WIDGET.newButton{name="back", x=1165, y=60,w=170,h=80,font=40,code=backScene}, WIDGET.newButton{name="back", x=1165, y=60,w=170,h=80,font=40,code=backScene},
} }

View File

@@ -38,7 +38,7 @@ return SPLITSTR([=[
修改硬降音效 修改硬降音效
词典修改部分词条,调整词条顺序(意见来自群友 库德里尔) 词典修改部分词条,调整词条顺序(意见来自群友 库德里尔)
移除词典中两个不必要的个人词条 移除词典中两个不必要的个人词条
词典支持左右键翻页 词典支持左右键翻页,添加触屏可用的翻页按钮
"命令行"改名控制台 "命令行"改名控制台
代码: 代码:
file模块升级 file模块升级