词典支持跳转超链接

This commit is contained in:
MrZ626
2020-10-06 18:15:32 +08:00
parent 36460f5d1f
commit 80d14da564
4 changed files with 1103 additions and 193 deletions

View File

@@ -442,7 +442,8 @@ local langList={
back="返回",
},
dict={
hideKB="键盘",
link="打开链接",
keyboard="键盘",
back="返回",
},
staff={
@@ -991,7 +992,8 @@ local langList={
back="返回",
},
dict={
hideKB="键盘",
link="打开链接",
keyboard="键盘",
back="返回",
},
staff={
@@ -1537,7 +1539,8 @@ local langList={
back="Back",
},
dict={
hideKB="Keyboard",
link="Open URL",
keyboard="Keyboard",
back="Back",
},
staff={
@@ -2082,7 +2085,8 @@ local langList={
back="X",
},
dict={
hideKB="□□□",
link="~~e>>",
keyboard="□□□",
back="X",
},
staff={
@@ -2628,7 +2632,8 @@ local langList={
back="返回",
},
dict={
hideKB="键盘",
link="看链接",
keyboard="键盘",
back="返回",
},
staff={

View File

@@ -621,8 +621,9 @@ local Widgets={
newButton({name="back", x=640, y=600,w=170,h=80,color="white",font=35,code=BACK}),
},
dict={
newKey({name="hideKB", x=940,y=70,w=240,h=80,color="white",font=40,code=pressKey("kb"),hide=function()return not sceneTemp.select end}),
newButton({name="back", x=1165,y=70,w=170,h=80,color="white",font=40,code=BACK}),
newKey({name="link", x=740,y=60,w=200,h=80,color="white",font=35,code=pressKey("link")}),
newKey({name="keyboard", x=960,y=60,w=200,h=80,color="white",font=35,code=pressKey("kb"),hide=function()return not sceneTemp.select end}),
newButton({name="back", x=1165,y=60,w=170,h=80,color="white",font=40,code=BACK}),
newKeyboard({name="kb", x=310,y=325,w=940,h=370,hide=function()return sceneTemp.hideKB end}),
},
staff={

File diff suppressed because it is too large Load Diff

View File

@@ -5,7 +5,7 @@ local Timer=love.timer.getTime
local setFont=setFont
local mStr=mStr
local int,ceil,rnd,abs=math.floor,math.ceil,math.random,math.abs
local int,ceil,abs=math.floor,math.ceil,math.abs
local max,min,sin,cos=math.max,math.min,math.sin,math.cos
local log,rnd=math.log,math.random
local format=string.format
@@ -3166,7 +3166,7 @@ do--dict
local result=S.result
local first
for i=1,#dict do
local pos=find(dict[i][1],S.input,nil,true)
local pos=find(dict[i][2],S.input,nil,true)
if pos==1 and not first then
ins(result,1,dict[i])
first=true
@@ -3199,6 +3199,12 @@ do--dict
S.scroll=S.select-15
end
end
elseif key=="link"then
local url=(S.result[1]and S.result or S.dict)[S.select][5]
LOG.print(url)
if url then
love.system.openURL(url)
end
elseif key=="kb"then
S.hideKB=not S.hideKB
elseif key=="delete"then
@@ -3271,12 +3277,12 @@ do--dict
i=i+S.scroll
local S=list[i]
gc.setColor(0,0,0)
gc.print(S[3],29,y-1)
gc.print(S[3],29,y+1)
gc.print(S[3],31,y-1)
gc.print(S[3],31,y+1)
gc.setColor(typeColor[S[2]])
gc.print(S[3],30,y)
gc.print(S[1],29,y-1)
gc.print(S[1],29,y+1)
gc.print(S[1],31,y-1)
gc.print(S[1],31,y+1)
gc.setColor(typeColor[S[3]])
gc.print(S[1],30,y)
end
gc.setColor(1,1,1)