暂时不使用越南语词典,等待翻译更新

This commit is contained in:
MrZ_26
2023-09-19 14:14:48 +08:00
parent 8df321b84d
commit b4901add94

View File

@@ -6,14 +6,14 @@ local find=string.find
local scene={} local scene={}
local dict-- Dict list local dict -- Dict list
local result-- Result Lable local result -- Result Lable
local localeFile -- Language file name, used for force reload local localeFile -- Language file name, used for force reload
local lastTickInput local lastTickInput
local searchWait-- Searching animation timer local searchWait -- Searching animation timer
local lastSearch-- Last searched string local lastSearch -- Last searched string
local lastSelected -- Last selected item local lastSelected -- Last selected item
local currentFontSize=25 -- Current font size, default: 25 local currentFontSize=25 -- Current font size, default: 25
@@ -52,9 +52,9 @@ local function _scanDict(D)
end end
local function _getList() return result[1] and result or dict end local function _getList() return result[1] and result or dict end
local textBox =WIDGET.newTextBox {name='infoBox',x=320,y=180,w=862,h=526,font=25,fix=true} local textBox=WIDGET.newTextBox{name='infoBox',x=320,y=180,w=862,h=526,font=25,fix=true}
local inputBox=WIDGET.newInputBox{name='input', x=20, y=110,w=762,h=60, font=40,limit=32} local inputBox=WIDGET.newInputBox{name='input',x=20,y=110,w=762,h=60,font=40,limit=32}
local listBox =WIDGET.newListBox {name='listBox',x=20, y=180,w=280,h=526,font=30,lineH=35,drawF=function(item,id,ifSel) local listBox=WIDGET.newListBox{name='listBox',x=20,y=180,w=280,h=526,font=30,lineH=35,drawF=function(item,id,ifSel)
-- Background -- Background
if ifSel then if ifSel then
gc.setColor(1,1,1,.4) gc.setColor(1,1,1,.4)
@@ -102,17 +102,19 @@ local function _clearResult()
end end
-- Search through the dictionary -- Search through the dictionary
local function _search() local function _search()
local _utf8lower=SETTING.locale:find'vi'
local input=inputBox:getText() local input=inputBox:getText()
local pos local pos
_clearResult() _clearResult()
local first local first
if dict=='vi' then if _utf8lower then
local success,input=pcall(function() STRING.lowerUTF8(input) end) local success,res=pcall(STRING.lowerUTF8,input)
if not success then input=input:lower() end input=success and res or input:lower()
else else
input=input:lower() end input=input:lower()
end
for i=1,#dict do for i=1,#dict do
if dict=='vi' then if _utf8lower then
pos=find(STRING.lowerUTF8(dict[i].title),input,nil,true) or find(STRING.lowerUTF8(dict[i].keywords),input,nil,true) pos=find(STRING.lowerUTF8(dict[i].title),input,nil,true) or find(STRING.lowerUTF8(dict[i].keywords),input,nil,true)
else else
pos=find(dict[i].title:lower(),input,nil,true) or find(dict[i].keywords:lower(),input,nil,true) pos=find(dict[i].title:lower(),input,nil,true) or find(dict[i].keywords:lower(),input,nil,true)
@@ -163,7 +165,12 @@ end
-- Reset everything when opening Zictionary -- Reset everything when opening Zictionary
function scene.enter() function scene.enter()
localeFile='parts.language.dict_'..(SETTING.locale:find'zh' and 'zh' or SETTING.locale:find'ja' and 'ja' or SETTING.locale:find'vi' and 'vi' or 'en') localeFile='parts.language.dict_'..(
SETTING.locale:find'zh' and 'zh' or
SETTING.locale:find'ja' and 'ja' or
-- SETTING.locale:find'vi' and 'vi' or
'en'
)
dict=require(localeFile) dict=require(localeFile)
_scanDict(dict) _scanDict(dict)
@@ -193,19 +200,15 @@ function scene.keyDown(key)
-- Switching selected items -- Switching selected items
if key=='up' or key=='down' then if key=='up' or key=='down' then
textBox:scroll(key=='up' and -1 or 1) textBox:scroll(key=='up' and -1 or 1)
elseif (key=='left' or key=='pageup' or key=='right' or key=='pagedown') then elseif (key=='left' or key=='pageup' or key=='right' or key=='pagedown') then
_jumpover(key,love.keyboard.isDown('lctrl','rctrl','lalt','ralt','lshift','rshift') and 12) _jumpover(key,love.keyboard.isDown('lctrl','rctrl','lalt','ralt','lshift','rshift') and 12)
elseif key=='cC' or key=='c' and love.keyboard.isDown('lctrl','rctrl') then elseif key=='cC' or key=='c' and love.keyboard.isDown('lctrl','rctrl') then
if listBox.selected>0 then if listBox.selected>0 then
_copy() _copy()
end end
elseif (key=='-' or key=='=' or key=='0') and (inputBox:getText()=="" or not inputBoxFocus) and not MOBILE then elseif (key=='-' or key=='=' or key=='0') and (inputBox:getText()=="" or not inputBoxFocus) and not MOBILE then
WIDGET.unFocus(true) WIDGET.unFocus(true)
_setZoom(key=='0' and 0 or key=='-' and -5 or 5) _setZoom(key=='0' and 0 or key=='-' and -5 or 5)
elseif key=='application' and listBox.selected>=0 then elseif key=='application' and listBox.selected>=0 then
local url=_getList()[listBox.selected].url local url=_getList()[listBox.selected].url
if url then love.system.openURL(url) end if url then love.system.openURL(url) end
@@ -308,13 +311,13 @@ function scene.draw()
-- Draw background -- Draw background
gc.setColor(COLOR.dX) gc.setColor(COLOR.dX)
gc.rectangle('fill',1194,335,80,370,5) gc.rectangle('fill',1194,335,80,370,5)
gc.rectangle('fill',1194,180,80,80 ,5) -- Help key gc.rectangle('fill',1194,180,80,80,5) -- Help key
-- Draw outline -- Draw outline
gc.setLineWidth(2) gc.setLineWidth(2)
gc.setColor(COLOR.Z) gc.setColor(COLOR.Z)
gc.rectangle('line',1194,335,80,370,5) gc.rectangle('line',1194,335,80,370,5)
gc.line(1194,555,1274,555) gc.line(1194,555,1274,555)
gc.rectangle('line',1194,180,80,80 ,5) -- Help key gc.rectangle('line',1194,180,80,80,5) -- Help key
if searchWait>0 then if searchWait>0 then
local r=TIME()*2 local r=TIME()*2
@@ -325,22 +328,22 @@ function scene.draw()
end end
scene.widgetList={ scene.widgetList={
WIDGET.newText {name='book', x=20, y=15, font=70,align='L',fText=CHAR.icon.zBook}, WIDGET.newText{name='book',x=20,y=15,font=70,align='L',fText=CHAR.icon.zBook},
WIDGET.newText {name='title', x=100, y=15, font=70,align='L'}, WIDGET.newText{name='title',x=100,y=15,font=70,align='L'},
listBox, listBox,
inputBox, inputBox,
textBox, textBox,
WIDGET.newKey {name='link', x=1234,y=595,w=60,font=45,fText=CHAR.icon.globe, code=pressKey'application',hideF=function() return not (listBox.selected>0 and _getList()[listBox.selected].url) end}, WIDGET.newKey{name='link',x=1234,y=595,w=60,font=45,fText=CHAR.icon.globe,code=pressKey'application',hideF=function() return not (listBox.selected>0 and _getList()[listBox.selected].url) end},
WIDGET.newKey {name='copy', x=1234,y=665,w=60,font=40,fText=CHAR.icon.copy, code=pressKey'cC',hideF=function() return not (listBox.selected>0) end}, WIDGET.newKey{name='copy',x=1234,y=665,w=60,font=40,fText=CHAR.icon.copy,code=pressKey'cC',hideF=function() return not (listBox.selected>0) end},
WIDGET.newKey {name='zoomin', x=1234,y=375,w=60,font=40,fText=CHAR.icon.zoomIn, code=function() _setZoom(5) end}, WIDGET.newKey{name='zoomin',x=1234,y=375,w=60,font=40,fText=CHAR.icon.zoomIn,code=function() _setZoom(5) end},
WIDGET.newKey {name='zoomout', x=1234,y=445,w=60,font=40,fText=CHAR.icon.zoomOut, code=function() _setZoom(-5) end}, WIDGET.newKey{name='zoomout',x=1234,y=445,w=60,font=40,fText=CHAR.icon.zoomOut,code=function() _setZoom(-5) end},
WIDGET.newKey {name='resetzoom',x=1234,y=515,w=60,font=40,fText=CHAR.icon.zoomDefault,code=function() _setZoom(0) end}, WIDGET.newKey{name='resetzoom',x=1234,y=515,w=60,font=40,fText=CHAR.icon.zoomDefault,code=function() _setZoom(0) end},
WIDGET.newKey {name='help', x=1234,y=220,w=60,font=40,fText=CHAR.icon.help, code=pressKey'f1'}, WIDGET.newKey{name='help',x=1234,y=220,w=60,font=40,fText=CHAR.icon.help,code=pressKey'f1'},
WIDGET.newButton{name='back', x=1185,y=60, w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=backScene}, WIDGET.newButton{name='back',x=1185,y=60,w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=backScene},
WIDGET.newText {name='buttontip',x=1274,y=110,w=762,h=60,font=40,align='R',fText=CHAR.controller.xboxY.."/[F1]: "..CHAR.icon.help} WIDGET.newText{name='buttontip',x=1274,y=110,w=762,h=60,font=40,align='R',fText=CHAR.controller.xboxY.."/[F1]: "..CHAR.icon.help},
} }
-- NOTE: The gap between Link-Copy, Zoom is 60*1.5-10=80 :) The gap between 2 buttons in one group is 60+10=70 -- NOTE: The gap between Link-Copy, Zoom is 60*1.5-10=80 :) The gap between 2 buttons in one group is 60+10=70
return scene return scene