From d415d68762c32a53ce89f2bff778db6060c7a7de Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Thu, 13 May 2021 22:04:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A7=E4=BB=B6=E7=B3=BB=E7=BB=9Fhide?= =?UTF-8?q?=E6=9C=BA=E5=88=B6=E5=A4=A7=E6=94=B9=EF=BC=8C=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E6=88=BF=E9=97=B4=E5=86=85=E8=81=8A=E5=A4=A9=E6=A1=86=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/scene.lua | 2 ++ Zframework/widget.lua | 46 +++++++++++++++++----------- parts/gametoolfunc.lua | 2 ++ parts/scenes/app_15p.lua | 12 ++++---- parts/scenes/app_2048.lua | 22 ++++++------- parts/scenes/app_AtoZ.lua | 2 +- parts/scenes/app_console.lua | 1 + parts/scenes/app_dtw.lua | 4 +-- parts/scenes/app_schulteG.lua | 10 +++--- parts/scenes/app_ten.lua | 6 ++-- parts/scenes/customGame.lua | 6 ++-- parts/scenes/custom_advance.lua | 4 +-- parts/scenes/custom_field.lua | 4 +-- parts/scenes/custom_mission.lua | 2 +- parts/scenes/custom_sequence.lua | 2 +- parts/scenes/dict.lua | 3 +- parts/scenes/game.lua | 2 +- parts/scenes/login.lua | 1 + parts/scenes/mod.lua | 2 +- parts/scenes/mode.lua | 2 +- parts/scenes/music.lua | 6 ++-- parts/scenes/net_game.lua | 44 +++++++++++++------------- parts/scenes/net_rooms.lua | 8 ++--- parts/scenes/pause.lua | 4 +-- parts/scenes/register.lua | 4 +++ parts/scenes/setting_key.lua | 6 +++- parts/scenes/setting_sound.lua | 4 +-- parts/scenes/setting_touch.lua | 2 +- parts/scenes/setting_touchSwitch.lua | 2 +- 29 files changed, 121 insertions(+), 94 deletions(-) diff --git a/Zframework/scene.lua b/Zframework/scene.lua index 7d03a638..71fa962a 100644 --- a/Zframework/scene.lua +++ b/Zframework/scene.lua @@ -60,6 +60,8 @@ function SCN.swapUpdate() end end function SCN.init(s,org) + love.keyboard.setTextInput(false) + local S=scenes[s] SCN.cur=s diff --git a/Zframework/widget.lua b/Zframework/widget.lua index 8a2570df..6ba7c49b 100644 --- a/Zframework/widget.lua +++ b/Zframework/widget.lua @@ -41,7 +41,7 @@ local text={ function text:reset()end function text:update() - if self.hideCon and self.hideCon()then + if self.hideF and self.hideF()then if self.alpha>0 then self.alpha=self.alpha-.125 end @@ -62,7 +62,7 @@ function text:draw() end end end -function WIDGET.newText(D)--name,x,y[,fText][,color][,font=30][,align='M'][,hide] +function WIDGET.newText(D)--name,x,y[,fText][,color][,font=30][,align='M'][,hideF][,hide] local _={ name= D.name, x= D.x, @@ -72,10 +72,10 @@ function WIDGET.newText(D)--name,x,y[,fText][,color][,font=30][,align='M'][,hide color= D.color and(COLOR[D.color]or D.color)or COLOR.Z, font= D.font or 30, align= D.align or'M', - hideCon=D.hide, + hideF= D.hideF, } for k,v in next,text do _[k]=v end - if not _.hideCon then _.alpha=1 end + if not _.hideF then _.alpha=1 end setmetatable(_,widgetMetatable) return _ end @@ -92,7 +92,7 @@ function image:draw() gc.setColor(1,1,1,self.alpha) gc.draw(self.img,self.x,self.y,self.ang,self.k) end -function WIDGET.newImage(D)--name[,img(name)],x,y[,ang][,k][,hide] +function WIDGET.newImage(D)--name[,img(name)],x,y[,ang][,k][,hideF][,hide] local _={ name= D.name, img= D.img or D.name, @@ -101,6 +101,7 @@ function WIDGET.newImage(D)--name[,img(name)],x,y[,ang][,k][,hide] y= D.y, ang= D.ang, k= D.k, + hideF= D.hideF, hide= D.hide, } for k,v in next,image do _[k]=v end @@ -198,7 +199,7 @@ function button:press(_,_,k) ) if self.sound then SFX.play('button')end end -function WIDGET.newButton(D)--name,x,y,w[,h][,fText][,color][,font=30][,sound=true][,align='M'][,edge=0],code[,hide] +function WIDGET.newButton(D)--name,x,y,w[,h][,fText][,color][,font=30][,sound=true][,align='M'][,edge=0],code[,hideF][,hide] if not D.h then D.h=D.w end local _={ name= D.name, @@ -223,6 +224,7 @@ function WIDGET.newButton(D)--name,x,y,w[,h][,fText][,color][,font=30][,sound=tr edge= D.edge or 0, sound= D.sound~=false, code= D.code, + hideF= D.hideF, hide= D.hide, } for k,v in next,button do _[k]=v end @@ -292,7 +294,7 @@ function key:press(_,_,k) self.code(k) if self.sound then SFX.play('key')end end -function WIDGET.newKey(D)--name,x,y,w[,h][,fText][,color][,font=30][,sound=true][,align='M'][,edge=0],code[,hide] +function WIDGET.newKey(D)--name,x,y,w[,h][,fText][,color][,font=30][,sound=true][,align='M'][,edge=0],code[,hideF][,hide] if not D.h then D.h=D.w end local _={ name= D.name, @@ -317,6 +319,7 @@ function WIDGET.newKey(D)--name,x,y,w[,h][,fText][,color][,font=30][,sound=true] align= D.align or'M', edge= D.edge or 0, code= D.code, + hideF= D.hideF, hide= D.hide, } for k,v in next,key do _[k]=v end @@ -398,6 +401,7 @@ function WIDGET.newSwitch(D)--name,x,y[,fText][,color][,font=30][,sound=true][,d sound= D.sound~=false, disp= D.disp, code= D.code, + hideF= D.hideF, hide= D.hide, } for k,v in next,switch do _[k]=v end @@ -451,7 +455,7 @@ function slider:update() self.ATV=atv end end - if not(self.hide==true or self.hide and self.hide())then + if not self.hide then self.pos=self.pos*.7+self.disp()*.3 end end @@ -559,6 +563,7 @@ function WIDGET.newSlider(D)--name,x,y,w[,fText][,color][,unit][,smooth][,font=3 change= D.change, disp= D.disp, code= D.code, + hideF= D.hideF, hide= D.hide, show= false, } @@ -723,6 +728,7 @@ function WIDGET.newSelector(D)--name,x,y,w[,fText][,color][,sound=true],list,dis list= D.list, disp= D.disp, code= D.code, + hideF= D.hideF, hide= D.hide, } for k,v in next,selector do _[k]=v end @@ -738,9 +744,6 @@ local inputBox={ } function inputBox:reset() self.ATV=0 - if not MOBILE then - kb.setTextInput(true) - end end function inputBox:hasText() return #self.value>0 @@ -853,6 +856,7 @@ function WIDGET.newInputBox(D)--name,x,y,w[,h][,font=30][,secret][,regex],hide font= D.font or int(D.h/7-1)*5, secret= D.secret==true, regex= D.regex, + hideF= D.hideF, hide= D.hide, } for k,v in next,inputBox do _[k]=v end @@ -892,7 +896,7 @@ function textBox:update() end function textBox:push(t) ins(self.texts,t) - if self.scrollPos==#self.texts-1 and not(self.hide==true or self.hide and self.hide())then + if self.scrollPos==#self.texts-1 and not self.hide then self.scrollPos=#self.texts else self.new=true @@ -1007,6 +1011,7 @@ function WIDGET.newTextBox(D)--name,x,y,w,h[,font=30][,lineH][,fix],hide font= D.font or 30, fix= D.fix, texts= {}, + hideF= D.hideF, hide= D.hide, } _.lineH=D.lineH or _.font*7/5 @@ -1030,7 +1035,6 @@ WIDGET.indexMeta={ end } function WIDGET.set(list) - kb.setTextInput(false) WIDGET.sel=false WIDGET.active=list or NONE @@ -1071,7 +1075,7 @@ end function WIDGET.cursorMove(x,y) for _,W in next,WIDGET.active do - if not(W.hide==true or W.hide and W.hide())and W.resCtr and W:isAbove(x,y)then + if not W.hide and W.resCtr and W:isAbove(x,y)then WIDGET.sel=W return end @@ -1084,7 +1088,7 @@ function WIDGET.press(x,y,k) local W=WIDGET.sel if not W then return end W:press(x,y,k) - if W.hide==true or W.hide and W.hide()then WIDGET.sel=false end + if W.hide then WIDGET.sel=false end end function WIDGET.drag(x,y,dx,dy) local W=WIDGET.sel @@ -1114,7 +1118,7 @@ function WIDGET.keyPressed(k) elseif k=="up"or k=="down"or k=="left"or k=="right"then if not WIDGET.sel then for _,W in next,WIDGET.active do - if not(W.hide==true or W.hide and W.hide())and W.isAbove then + if not W.hide and W.isAbove then WIDGET.sel=W return end @@ -1130,7 +1134,7 @@ function WIDGET.keyPressed(k) local swap_xy=k=="up"or k=="down" if swap_xy then WX,WY=WY,WX end -- note that we do not swap them back later for _,W1 in ipairs(WIDGET.active)do - if W~=W1 and W1.resCtr and not(W1.hide==true or W1.hide and W1.hide())then + if W~=W1 and W1.resCtr and not W1.hide then local L=W1.resCtr for j=1,#L,2 do local x,y=L[j],L[j+1] @@ -1201,12 +1205,18 @@ end function WIDGET.update() for _,W in next,WIDGET.active do + if W.hideF then + local h=W.hideF() + if h~=W.hide then + W.hide=h + end + end if W.update then W:update()end end end function WIDGET.draw() for _,W in next,WIDGET.active do - if not(W.hide==true or W.hide and W.hide())then + if not W.hide then W:draw() end end diff --git a/parts/gametoolfunc.lua b/parts/gametoolfunc.lua index 072894f5..101f9201 100644 --- a/parts/gametoolfunc.lua +++ b/parts/gametoolfunc.lua @@ -1,3 +1,4 @@ +local kb=love.keyboard local gc=love.graphics local gc_push,gc_pop=gc.push,gc.pop local gc_origin,gc_translate=gc.origin,gc.translate @@ -11,6 +12,7 @@ local SETTING,GAME,SCR=SETTING,GAME,SCR --System +function enableTextInput()if not MOBILE then kb.setTextInput(true)end end function switchFullscreen() SETTING.fullscreen=not SETTING.fullscreen love.window.setFullscreen(SETTING.fullscreen) diff --git a/parts/scenes/app_15p.lua b/parts/scenes/app_15p.lua index db209364..87d1cb78 100644 --- a/parts/scenes/app_15p.lua +++ b/parts/scenes/app_15p.lua @@ -313,14 +313,14 @@ function scene.draw() gc.rectangle('line',cx*160+173,cy*160-107,134,134,50) end -local function Gaming()return state==1 end +local function ifGaming()return state==1 end scene.widgetList={ WIDGET.newButton{name="reset", x=160,y=100,w=180,h=100,color='lG', font=40,code=pressKey"space"}, - WIDGET.newSlider{name="color", x=110,y=250,w=170,unit=4,show=false,font=30,disp=function()return color end, code=function(v)if state~=1 then color=v end end,hide=Gaming}, - WIDGET.newSwitch{name="blind", x=240,y=330,w=60, font=40,disp=function()return blind end, code=pressKey"w", hide=Gaming}, - WIDGET.newSwitch{name="slide", x=240,y=420,w=60, font=40,disp=function()return slide end, code=pressKey"e", hide=Gaming}, - WIDGET.newSwitch{name="pathVis",x=240,y=510,w=60, font=40,disp=function()return pathVis end, code=pressKey"r", hide=function()return state==1 or not slide end}, - WIDGET.newSwitch{name="revKB", x=240,y=600,w=60, font=40,disp=function()return revKB end, code=pressKey"t", hide=Gaming}, + WIDGET.newSlider{name="color", x=110,y=250,w=170,unit=4,show=false,font=30,disp=function()return color end, code=function(v)if state~=1 then color=v end end,hideFunc=ifGaming}, + WIDGET.newSwitch{name="blind", x=240,y=330,w=60, font=40,disp=function()return blind end, code=pressKey"w",hideF=ifGaming}, + WIDGET.newSwitch{name="slide", x=240,y=420,w=60, font=40,disp=function()return slide end, code=pressKey"e",hideF=ifGaming}, + WIDGET.newSwitch{name="pathVis",x=240,y=510,w=60, font=40,disp=function()return pathVis end, code=pressKey"r",hideF=function()return state==1 or not slide end}, + WIDGET.newSwitch{name="revKB", x=240,y=600,w=60, font=40,disp=function()return revKB end, code=pressKey"t",hideF=ifGaming}, WIDGET.newButton{name="back", x=1140,y=640,w=170,h=80, font=40,code=backScene}, } diff --git a/parts/scenes/app_2048.lua b/parts/scenes/app_2048.lua index 122ac7a2..0a748d90 100644 --- a/parts/scenes/app_2048.lua +++ b/parts/scenes/app_2048.lua @@ -480,18 +480,18 @@ end scene.widgetList={ WIDGET.newButton{name="reset", x=155,y=100,w=180,h=100,color='lG',font=40,code=pressKey"r"}, - WIDGET.newSwitch{name="blind", x=240,y=300,w=60,font=40,disp=function()return blind end,code=pressKey"q",hide=function()return state==1 end}, - WIDGET.newSwitch{name="tapControl", x=240,y=370,w=60,font=40,disp=function()return tapControl end,code=pressKey"w",hide=function()return state==1 end}, + WIDGET.newSwitch{name="blind", x=240,y=300,w=60,font=40,disp=function()return blind end,code=pressKey"q",hideF=function()return state==1 end}, + WIDGET.newSwitch{name="tapControl", x=240,y=370,w=60,font=40,disp=function()return tapControl end,code=pressKey"w",hideF=function()return state==1 end}, - WIDGET.newKey{name="up", x=155,y=460,w=100,fText="↑",font=50,color='Y',code=pressKey"up",hide=function()return tapControl end}, - WIDGET.newKey{name="down", x=155,y=660,w=100,fText="↓",font=50,color='Y',code=pressKey"down",hide=function()return tapControl end}, - WIDGET.newKey{name="left", x=55,y=560,w=100,fText="←",font=50,color='Y',code=pressKey"left",hide=function()return tapControl end}, - WIDGET.newKey{name="right", x=255,y=560,w=100,fText="→",font=50,color='Y',code=pressKey"right",hide=function()return tapControl end}, - WIDGET.newKey{name="skip", x=155,y=400,w=100,font=20, color='Y',code=pressKey"space",hide=function()return state~=1 or not skipper.cd or skipper.cd>0 end}, - WIDGET.newKey{name="record1", x=1100,y=390,w=220,h=50,fText="", color='H',code=pressKey"1",hide=function()return state==2 end}, - WIDGET.newKey{name="record2", x=1100,y=450,w=220,h=50,fText="", color='H',code=pressKey"2",hide=function()return state==2 end}, - WIDGET.newKey{name="replay1", x=1245,y=390,w=50,fText="!", color='G',code=pressKey"c1",hide=function()return state==2 or #repeater.seq[1]==0 end}, - WIDGET.newKey{name="replay2", x=1245,y=450,w=50,fText="!", color='G',code=pressKey"c2",hide=function()return state==2 or #repeater.seq[2]==0 end}, + WIDGET.newKey{name="up", x=155,y=460,w=100,fText="↑",font=50,color='Y',code=pressKey"up",hideF=function()return tapControl end}, + WIDGET.newKey{name="down", x=155,y=660,w=100,fText="↓",font=50,color='Y',code=pressKey"down",hideF=function()return tapControl end}, + WIDGET.newKey{name="left", x=55,y=560,w=100,fText="←",font=50,color='Y',code=pressKey"left",hideF=function()return tapControl end}, + WIDGET.newKey{name="right", x=255,y=560,w=100,fText="→",font=50,color='Y',code=pressKey"right",hideF=function()return tapControl end}, + WIDGET.newKey{name="skip", x=155,y=400,w=100,font=20, color='Y',code=pressKey"space",hideF=function()return state~=1 or not skipper.cd or skipper.cd>0 end}, + WIDGET.newKey{name="record1", x=1100,y=390,w=220,h=50,fText="", color='H',code=pressKey"1",hideF=function()return state==2 end}, + WIDGET.newKey{name="record2", x=1100,y=450,w=220,h=50,fText="", color='H',code=pressKey"2",hideF=function()return state==2 end}, + WIDGET.newKey{name="replay1", x=1245,y=390,w=50,fText="!", color='G',code=pressKey"c1",hideF=function()return state==2 or #repeater.seq[1]==0 end}, + WIDGET.newKey{name="replay2", x=1245,y=450,w=50,fText="!", color='G',code=pressKey"c2",hideF=function()return state==2 or #repeater.seq[2]==0 end}, WIDGET.newButton{name="back", x=1140,y=640,w=170,h=80,font=40,code=backScene}, } diff --git a/parts/scenes/app_AtoZ.lua b/parts/scenes/app_AtoZ.lua index fa9584f6..04d6af15 100644 --- a/parts/scenes/app_AtoZ.lua +++ b/parts/scenes/app_AtoZ.lua @@ -116,7 +116,7 @@ function scene.draw() end scene.widgetList={ - WIDGET.newSelector{name="level", x=640,y=640,w=200,list={'A_Z','Z_A','Tech1','Tech2','KeyTest1','KeyTest2','Hello','Roll1','Roll2','Roll3','ZZZ','ZXZX','ZMZM','Stair','Stair2','Stair3','BPW'},disp=function()return levelName end,code=function(i)levelName=i;targetString=levels[i]end,hide=function()return state>0 end}, + WIDGET.newSelector{name="level", x=640,y=640,w=200,list={'A_Z','Z_A','Tech1','Tech2','KeyTest1','KeyTest2','Hello','Roll1','Roll2','Roll3','ZZZ','ZXZX','ZMZM','Stair','Stair2','Stair3','BPW'},disp=function()return levelName end,code=function(i)levelName=i;targetString=levels[i]end,hideF=function()return state>0 end}, WIDGET.newButton{name="reset", x=160,y=100,w=180,h=100,color='lG',font=40,code=pressKey"space"}, WIDGET.newButton{name="keyboard", x=160,y=210,w=180,h=100,code=function()love.keyboard.setTextInput(true,0,select(2,SCR.xOy:transformPoint(0,500)),1,1)end,hide=not MOBILE}, WIDGET.newButton{name="back", x=1140,y=640,w=170,h=80,font=40,code=backScene}, diff --git a/parts/scenes/app_console.lua b/parts/scenes/app_console.lua index b030a82f..3eef1009 100644 --- a/parts/scenes/app_console.lua +++ b/parts/scenes/app_console.lua @@ -678,6 +678,7 @@ local scene={} function scene.sceneInit() TASK.new(function()YIELD()WIDGET.sel=inputBox end) + enableTextInput() BG.set('none') end diff --git a/parts/scenes/app_dtw.lua b/parts/scenes/app_dtw.lua index 1fcfd8d8..34e89392 100644 --- a/parts/scenes/app_dtw.lua +++ b/parts/scenes/app_dtw.lua @@ -277,8 +277,8 @@ end scene.widgetList={ WIDGET.newButton{name="reset", x=155,y=100,w=180,h=100,color='lG',font=40,code=pressKey"r"}, - WIDGET.newButton{name="mode", x=155,y=220,w=180,h=100,font=40,code=pressKey"q",hide=function()return state~=0 end}, - WIDGET.newSwitch{name="arcade", x=230,y=330,font=40,disp=function()return arcade end,code=pressKey"w",hide=function()return state~=0 end}, + WIDGET.newButton{name="mode", x=155,y=220,w=180,h=100,font=40,code=pressKey"q",hideF=function()return state~=0 end}, + WIDGET.newSwitch{name="arcade", x=230,y=330,font=40,disp=function()return arcade end,code=pressKey"w",hideF=function()return state~=0 end}, WIDGET.newButton{name="back", x=1140,y=640,w=170,h=80,font=40,code=backScene}, } diff --git a/parts/scenes/app_schulteG.lua b/parts/scenes/app_schulteG.lua index db80f873..3f50377d 100644 --- a/parts/scenes/app_schulteG.lua +++ b/parts/scenes/app_schulteG.lua @@ -168,11 +168,11 @@ function scene.draw() end scene.widgetList={ - WIDGET.newButton{name="reset", x=160,y=100,w=180,h=100,color='lG',font=40,code=pressKey"space",hide=function()return state==0 end}, - WIDGET.newSlider{name="rank", x=130,y=250,w=150,unit=3,show=false,font=40,disp=function()return rank-3 end,code=function(v)rank=v+3 end,hide=function()return state>0 end}, - WIDGET.newSwitch{name="blind", x=240,y=330,w=60, font=40,disp=function()return blind end, code=pressKey"q",hide=function()return state==1 end}, - WIDGET.newSwitch{name="disappear", x=240,y=420,w=60, font=40,disp=function()return disappear end,code=pressKey"w",hide=function()return state==1 end}, - WIDGET.newSwitch{name="tapFX", x=240,y=510,w=60, font=40,disp=function()return tapFX end, code=pressKey"e",hide=function()return state==1 end}, + WIDGET.newButton{name="reset", x=160,y=100,w=180,h=100,color='lG',font=40,code=pressKey"space",hideF=function()return state==0 end}, + WIDGET.newSlider{name="rank", x=130,y=250,w=150,unit=3,show=false,font=40,disp=function()return rank-3 end,code=function(v)rank=v+3 end,hideF=function()return state>0 end}, + WIDGET.newSwitch{name="blind", x=240,y=330,w=60, font=40,disp=function()return blind end, code=pressKey"q",hideF=function()return state==1 end}, + WIDGET.newSwitch{name="disappear", x=240,y=420,w=60, font=40,disp=function()return disappear end,code=pressKey"w",hideF=function()return state==1 end}, + WIDGET.newSwitch{name="tapFX", x=240,y=510,w=60, font=40,disp=function()return tapFX end, code=pressKey"e",hideF=function()return state==1 end}, WIDGET.newButton{name="back", x=1140,y=640,w=170,h=80,font=40,code=backScene}, } diff --git a/parts/scenes/app_ten.lua b/parts/scenes/app_ten.lua index 584a3f9d..9b31a4b7 100644 --- a/parts/scenes/app_ten.lua +++ b/parts/scenes/app_ten.lua @@ -299,9 +299,9 @@ end scene.widgetList={ WIDGET.newButton{name="reset", x=160,y=100,w=180,h=100,color='lG',font=40,code=pressKey"r"}, - WIDGET.newSwitch{name="next", x=240,y=235,font=40,disp=function()return nexts end,code=pressKey"q",hide=function()return state==1 end}, - WIDGET.newSwitch{name="blind", x=240,y=305,font=40,disp=function()return blind end,code=pressKey"w",hide=function()return state==1 end}, - WIDGET.newSwitch{name="fast", x=240,y=375,font=30,disp=function()return fast end,code=pressKey"e",hide=function()return state==1 end}, + WIDGET.newSwitch{name="next", x=240,y=235,font=40,disp=function()return nexts end,code=pressKey"q",hideF=function()return state==1 end}, + WIDGET.newSwitch{name="blind", x=240,y=305,font=40,disp=function()return blind end,code=pressKey"w",hideF=function()return state==1 end}, + WIDGET.newSwitch{name="fast", x=240,y=375,font=30,disp=function()return fast end,code=pressKey"e",hideF=function()return state==1 end}, WIDGET.newButton{name="back", x=1140,y=640,w=170,h=80,font=40,code=backScene}, } diff --git a/parts/scenes/customGame.lua b/parts/scenes/customGame.lua index 8c612f32..091157e9 100644 --- a/parts/scenes/customGame.lua +++ b/parts/scenes/customGame.lua @@ -171,8 +171,8 @@ end scene.widgetList={ WIDGET.newText{name="title", x=520, y=5,font=70,align='R'}, WIDGET.newText{name="subTitle", x=530, y=50,font=35,align='L',color='H'}, - WIDGET.newText{name="defSeq", x=330, y=550,align='L',color='H',hide=function()return BAG[1]end}, - WIDGET.newText{name="noMsn", x=610, y=550,align='L',color='H',hide=function()return MISSION[1]end}, + WIDGET.newText{name="defSeq", x=330, y=550,align='L',color='H',hideF=function()return BAG[1]end}, + WIDGET.newText{name="noMsn", x=610, y=550,align='L',color='H',hideF=function()return MISSION[1]end}, --Basic WIDGET.newSelector{name="drop", x=170, y=150,w=220,color='O',list={0,.125,.25,.5,1,2,3,4,5,6,7,8,9,10,12,14,16,18,20,25,30,40,60,180,1e99},disp=CUSval("drop"),code=CUSsto("drop")}, @@ -188,7 +188,7 @@ scene.widgetList={ WIDGET.newButton{name="copy", x=1070, y=310,w=310,h=70,color='lR',font=25,code=pressKey"cC"}, WIDGET.newButton{name="paste", x=1070, y=390,w=310,h=70,color='lB',font=25,code=pressKey"cV"}, WIDGET.newButton{name="clear", x=1070, y=470,w=310,h=70,color='lY',font=35,code=pressKey"return"}, - WIDGET.newButton{name="puzzle", x=1070, y=550,w=310,h=70,color='lM',font=35,code=pressKey"return2",hide=function()return not initField end}, + WIDGET.newButton{name="puzzle", x=1070, y=550,w=310,h=70,color='lM',font=35,code=pressKey"return2",hideF=function()return not initField end}, --More WIDGET.newKey{name="reset", x=730, y=150,w=220,h=90,color='R',font=30,code=pressKey"delete"}, diff --git a/parts/scenes/custom_advance.lua b/parts/scenes/custom_advance.lua index f28f8210..ed13720c 100644 --- a/parts/scenes/custom_advance.lua +++ b/parts/scenes/custom_advance.lua @@ -18,8 +18,8 @@ scene.widgetList={ --Control WIDGET.newSlider{name="nextCount", x=180, y=150, w=200,unit=6, disp=CUSval("nextCount"),code=CUSsto("nextCount")}, WIDGET.newSlider{name="holdCount", x=180, y=240, w=200,unit=6, disp=CUSval("holdCount"),code=CUSsto("holdCount")}, - WIDGET.newSwitch{name="infHold", x=330, y=340, disp=CUSval("infHold"),code=CUSrev("infHold"),hide=function()return CUSTOMENV.holdCount==0 end}, - WIDGET.newSwitch{name="phyHold", x=330, y=430, disp=CUSval("phyHold"),code=CUSrev("phyHold"),hide=function()return CUSTOMENV.holdCount==0 end}, + WIDGET.newSwitch{name="infHold", x=330, y=340, disp=CUSval("infHold"),code=CUSrev("infHold"),hideF=function()return CUSTOMENV.holdCount==0 end}, + WIDGET.newSwitch{name="phyHold", x=330, y=430, disp=CUSval("phyHold"),code=CUSrev("phyHold"),hideF=function()return CUSTOMENV.holdCount==0 end}, WIDGET.newSwitch{name="initSkip", x=330, y=530, font=25, disp=CUSval("initSkip"),code=CUSrev("initSkip")}, --Rule diff --git a/parts/scenes/custom_field.lua b/parts/scenes/custom_field.lua index 6b99afbe..2da026b9 100644 --- a/parts/scenes/custom_field.lua +++ b/parts/scenes/custom_field.lua @@ -482,8 +482,8 @@ scene.widgetList={ WIDGET.newButton{name="newPg", x=100, y=110,w=160,h=110,color='N',font=20,code=pressKey"n"}, WIDGET.newButton{name="delPg", x=100, y=230,w=160,h=110,color='lR',font=20,code=pressKey"m"}, - WIDGET.newButton{name="prevPg", x=100, y=350,w=160,h=110,color='lG',font=20,code=pressKey"pageup",hide=function()return page==1 end}, - WIDGET.newButton{name="nextPg", x=100, y=470,w=160,h=110,color='lG',font=20,code=pressKey"pagedown",hide=function()return page==#FIELD end}, + WIDGET.newButton{name="prevPg", x=100, y=350,w=160,h=110,color='lG',font=20,code=pressKey"pageup",hideF=function()return page==1 end}, + WIDGET.newButton{name="nextPg", x=100, y=470,w=160,h=110,color='lG',font=20,code=pressKey"pagedown",hideF=function()return page==#FIELD end}, WIDGET.newButton{name="back", x=1140, y=640, w=170,h=80,font=40,code=backScene}, } diff --git a/parts/scenes/custom_mission.lua b/parts/scenes/custom_mission.lua index 3b56ee5d..095d4e16 100644 --- a/parts/scenes/custom_mission.lua +++ b/parts/scenes/custom_mission.lua @@ -232,7 +232,7 @@ scene.widgetList={ WIDGET.newKey{name="ten", x=1000, y=440,w=90, color='lG',font=40,code=pressKey"ten"}, WIDGET.newKey{name="backsp", x=1000, y=540,w=90, color='lY',font=50,code=pressKey"backspace"}, WIDGET.newKey{name="reset", x=1000, y=640,w=90, color='lY',font=50,code=pressKey"delete"}, - WIDGET.newButton{name="copy", x=1140, y=440,w=170,h=80, color='lR',font=40,code=pressKey"cC",hide=function()return #MISSION==0 end}, + WIDGET.newButton{name="copy", x=1140, y=440,w=170,h=80, color='lR',font=40,code=pressKey"cC",hideF=function()return #MISSION==0 end}, WIDGET.newButton{name="paste", x=1140, y=540,w=170,h=80, color='lB',font=40,code=pressKey"cV"}, WIDGET.newSwitch{name="mission",x=1150, y=350,disp=CUSval("missionKill"),code=CUSrev("missionKill")}, diff --git a/parts/scenes/custom_sequence.lua b/parts/scenes/custom_sequence.lua index 8d317ff4..25ecce78 100644 --- a/parts/scenes/custom_sequence.lua +++ b/parts/scenes/custom_sequence.lua @@ -235,7 +235,7 @@ scene.widgetList={ WIDGET.newKey{name="O1", x=920,y=620,w=80,color='dH',font=50,code=pressKey(29)}, - WIDGET.newButton{name="copy",x=1140,y=460,w=170,h=80,color='lR',font=40,code=pressKey"cC",hide=function()return #BAG==0 end}, + WIDGET.newButton{name="copy",x=1140,y=460,w=170,h=80,color='lR',font=40,code=pressKey"cC",hideF=function()return #BAG==0 end}, WIDGET.newButton{name="paste",x=1140,y=550,w=170,h=80,color='lB',font=40,code=pressKey"cV"}, WIDGET.newButton{name="back",x=1140,y=640,w=170,h=80,font=40,code=backScene}, } diff --git a/parts/scenes/dict.lua b/parts/scenes/dict.lua index 89842a72..e77abfde 100644 --- a/parts/scenes/dict.lua +++ b/parts/scenes/dict.lua @@ -69,6 +69,7 @@ function scene.sceneInit() lastSearch=false TASK.new(function()YIELD()WIDGET.sel=inputBox end) + enableTextInput() BG.set('rainbow') end @@ -183,7 +184,7 @@ end scene.widgetList={ WIDGET.newText{name="title", x=20, y=5,font=70,align='L'}, inputBox, - 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="link", x=1150, y=655,w=200,h=80,font=35,code=pressKey"link",hideF=function()return not url end}, 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=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}, diff --git a/parts/scenes/game.lua b/parts/scenes/game.lua index f67cc3a6..6b8c465b 100644 --- a/parts/scenes/game.lua +++ b/parts/scenes/game.lua @@ -201,7 +201,7 @@ function scene.draw() --Mode info gc.setColor(1,1,1,.8) - gc.draw(drawableText.modeName,485,10) + gc.draw(drawableText.modeName,940,0) --Replaying if GAME.replaying then diff --git a/parts/scenes/login.lua b/parts/scenes/login.lua index c046e726..758ec997 100644 --- a/parts/scenes/login.lua +++ b/parts/scenes/login.lua @@ -29,6 +29,7 @@ function scene.sceneInit() emailBox:setText(data[1]) passwordBox:setText(data[2]) end + enableTextInput() end scene.widgetList={ diff --git a/parts/scenes/mod.lua b/parts/scenes/mod.lua index e91c9d70..9a0f5f48 100644 --- a/parts/scenes/mod.lua +++ b/parts/scenes/mod.lua @@ -151,7 +151,7 @@ end scene.widgetList={ WIDGET.newText{name="title", x=80,y=50,font=70,align='L'}, - WIDGET.newText{name="unranked", x=1200,y=60,color='Y',font=50,align='R',hide=function()return scoreValid()end}, + WIDGET.newText{name="unranked", x=1200,y=60,color='Y',font=50,align='R',hideF=function()return scoreValid()end}, WIDGET.newButton{name="reset", x=1140,y=540,w=170,h=80,font=25,code=pressKey"tab"}, WIDGET.newButton{name="back", x=1140,y=640,w=170,h=80,font=40,code=backScene}, } diff --git a/parts/scenes/mode.lua b/parts/scenes/mode.lua index 2da29463..0348b5ba 100644 --- a/parts/scenes/mode.lua +++ b/parts/scenes/mode.lua @@ -307,7 +307,7 @@ end scene.widgetList={ WIDGET.newKey{name="mod", x=140,y=655,w=220,h=80,font=35,code=goScene"mod"}, - WIDGET.newButton{name="start", x=1040,y=655,w=180,h=80,font=40,code=pressKey"return",hide=function()return not mapCam.sel end}, + WIDGET.newButton{name="start", x=1040,y=655,w=180,h=80,font=40,code=pressKey"return",hideF=function()return not mapCam.sel end}, WIDGET.newButton{name="back", x=1200,y=655,w=120,h=80,font=40,code=backScene}, } diff --git a/parts/scenes/music.lua b/parts/scenes/music.lua index 32569e8d..58d8f790 100644 --- a/parts/scenes/music.lua +++ b/parts/scenes/music.lua @@ -85,11 +85,11 @@ end scene.widgetList={ WIDGET.newText{name="title", x=30, y=30,font=80,align='L'}, WIDGET.newText{name="arrow", x=270, y=360,font=45,align='L'}, - WIDGET.newText{name="now", x=700, y=500,font=50,align='R',hide=function()return not BGM.nowPlay end}, + WIDGET.newText{name="now", x=700, y=500,font=50,align='R',hideF=function()return not BGM.nowPlay end}, WIDGET.newSlider{name="bgm", x=760, y=80,w=400, font=35,disp=SETval("bgm"),code=function(v)SETTING.bgm=v BGM.freshVolume()end}, - WIDGET.newButton{name="up", x=200, y=250,w=120, font=55,code=pressKey"up",hide=function()return selected==1 end}, + WIDGET.newButton{name="up", x=200, y=250,w=120, font=55,code=pressKey"up",hideF=function()return selected==1 end}, WIDGET.newButton{name="play", x=200, y=390,w=120, font=35,code=pressKey"space"}, - WIDGET.newButton{name="down", x=200, y=530,w=120, font=55,code=pressKey"down",hide=function()return selected==#bgmList end}, + WIDGET.newButton{name="down", x=200, y=530,w=120, font=55,code=pressKey"down",hideF=function()return selected==#bgmList end}, WIDGET.newButton{name="sound", x=1140, y=540,w=170,h=80,font=40,code=pressKey"tab"}, WIDGET.newButton{name="back", x=1140, y=640,w=170,h=80,font=40,code=backScene}, } diff --git a/parts/scenes/net_game.lua b/parts/scenes/net_game.lua index 8a56086d..5ba479ac 100644 --- a/parts/scenes/net_game.lua +++ b/parts/scenes/net_game.lua @@ -1,4 +1,4 @@ -local gc,tc=love.graphics,love.touch +local gc,tc,kb=love.graphics,love.touch,love.keyboard local ins=table.insert local SCR,VK,NET,netPLY=SCR,VK,NET,netPLY local PLAYERS,GAME=PLAYERS,GAME @@ -85,25 +85,27 @@ function scene.keyDown(key) lastBackTime=TIME() LOG.print(text.sureQuit,COLOR.O) end - elseif key=="\\"then - textBox.hide=not textBox.hide - inputBox.hide=not inputBox.hide - if textBox.hide then - WIDGET.sel=nil - else + elseif key=="return"then + if inputBox.hide then + textBox.hide=false + inputBox.hide=false TASK.new(function()YIELD()WIDGET.sel=inputBox end) + enableTextInput() + else + local mes=inputBox:getText():match"%S+" + if mes and #mes>0 then + NET.sendMessage(mes) + inputBox:clear() + elseif #EDITING==0 then + textBox.hide=true + inputBox.hide=true + WIDGET.sel=nil + kb.setTextInput(false) + end end elseif not inputBox.hide then - if key=="return"then - print(EDITING) - if inputBox:hasText()then - NET.sendMessage(inputBox:getText()) - inputBox:clear() - end - else - WIDGET.sel=inputBox - WIDGET.keyPressed(key) - end + WIDGET.sel=inputBox + WIDGET.keyPressed(key) elseif playing then if noKey then return end local k=keyMap.keyboard[key] @@ -301,9 +303,9 @@ end scene.widgetList={ textBox, inputBox, - WIDGET.newKey{name="setting",fText=TEXTURE.setting,x=1200,y=160,w=90,h=90,code=pressKey"s",hide=function()return playing or netPLY.getSelfReady()or NET.getlock('ready')end}, + WIDGET.newKey{name="setting",fText=TEXTURE.setting,x=1200,y=160,w=90,h=90,code=pressKey"s",hideF=function()return playing or netPLY.getSelfReady()or NET.getlock('ready')end}, WIDGET.newKey{name="ready",x=1060,y=630,w=300,h=80,color='lB',font=40,code=pressKey"space", - hide=function() + hideF=function() return playing or NET.serverGaming or @@ -311,14 +313,14 @@ scene.widgetList={ NET.getlock('ready') end}, WIDGET.newKey{name="cancel",x=1060,y=630,w=300,h=80,color='H',font=40,code=pressKey"space", - hide=function() + hideF=function() return playing or NET.serverGaming or not netPLY.getSelfReady()or NET.getlock('ready') end}, - WIDGET.newKey{name="hideChat",fText="...",x=380,y=35,w=60,font=35,code=pressKey"\\"}, + WIDGET.newKey{name="hideChat",fText="...",x=380,y=35,w=60,font=35,code=pressKey"return"}, WIDGET.newKey{name="quit",fText="X",x=900,y=35,w=60,font=40,code=pressKey"escape"}, } diff --git a/parts/scenes/net_rooms.lua b/parts/scenes/net_rooms.lua index 6d44a669..e96947fe 100644 --- a/parts/scenes/net_rooms.lua +++ b/parts/scenes/net_rooms.lua @@ -171,12 +171,12 @@ end scene.widgetList={ WIDGET.newKey{name="setting",fText=TEXTURE.setting,x=1200,y=160,w=90,h=90,code=pressKey"s"}, - WIDGET.newText{name="refreshing",x=580,y=255,font=45,hide=function()return not NET.getlock('fetchRoom')end}, - WIDGET.newText{name="noRoom", x=580,y=260,font=40,hide=function()return #NET.roomList>0 or NET.getlock('fetchRoom')end}, - WIDGET.newKey{name="refresh", x=300,y=620,w=140,h=140,font=35,code=fetchRoom,hide=function()return fetchTimer>3.26 end}, + WIDGET.newText{name="refreshing",x=580,y=255,font=45,hideF=function()return not NET.getlock('fetchRoom')end}, + WIDGET.newText{name="noRoom", x=580,y=260,font=40,hideF=function()return #NET.roomList>0 or NET.getlock('fetchRoom')end}, + WIDGET.newKey{name="refresh", x=300,y=620,w=140,h=140,font=35,code=fetchRoom,hideF=function()return fetchTimer>3.26 end}, WIDGET.newKey{name="new", x=500,y=620,w=140,h=140,font=20,code=pressKey"n"}, WIDGET.newKey{name="new2", x=700,y=620,w=140,h=140,font=20,code=pressKey"m"}, - WIDGET.newKey{name="join", x=900,y=620,w=140,h=140,font=40,code=pressKey"return",hide=function()return #NET.roomList==0 or NET.getlock('enterRoom')end}, + WIDGET.newKey{name="join", x=900,y=620,w=140,h=140,font=40,code=pressKey"return",hideF=function()return #NET.roomList==0 or NET.getlock('enterRoom')end}, WIDGET.newButton{name="back", x=1140,y=640,w=170,h=80,font=40,code=backScene}, } diff --git a/parts/scenes/pause.lua b/parts/scenes/pause.lua index c2bd5f20..0ffe05dc 100644 --- a/parts/scenes/pause.lua +++ b/parts/scenes/pause.lua @@ -312,8 +312,8 @@ end scene.widgetList={ WIDGET.newButton{name="setting", x=1120,y=70,w=240,h=90, color='lB',font=35,code=pressKey"s"}, - WIDGET.newButton{name="replay", x=535,y=250,w=200,h=100,color='lY',font=30,code=pressKey"p",hide=function()return not(GAME.result or GAME.replaying)or #PLAYERS>1 end}, - WIDGET.newButton{name="save", x=745,y=250,w=200,h=100,color='G',font=30,code=pressKey"o",hide=function()return not(GAME.result or GAME.replaying)or #PLAYERS>1 or GAME.saved end}, + WIDGET.newButton{name="replay", x=535,y=250,w=200,h=100,color='lY',font=30,code=pressKey"p",hideF=function()return not(GAME.result or GAME.replaying)or #PLAYERS>1 end}, + WIDGET.newButton{name="save", x=745,y=250,w=200,h=100,color='G',font=30,code=pressKey"o",hideF=function()return not(GAME.result or GAME.replaying)or #PLAYERS>1 or GAME.saved end}, WIDGET.newButton{name="resume", x=640,y=367,w=240,h=100,color='lG',font=30,code=pressKey"escape"}, WIDGET.newButton{name="restart", x=640,y=483,w=240,h=100,color='lR',font=35,code=pressKey"r"}, WIDGET.newButton{name="quit", x=640,y=600,w=240,h=100,font=35,code=backScene}, diff --git a/parts/scenes/register.lua b/parts/scenes/register.lua index 3e7bbd19..39f5b28d 100644 --- a/parts/scenes/register.lua +++ b/parts/scenes/register.lua @@ -17,6 +17,10 @@ local function register() NET.register(username,email,password) end +function scene.sceneInit() + enableTextInput() +end + scene.widgetList={ WIDGET.newText{name="title", x=80, y=50,font=70,align='L'}, WIDGET.newButton{name="login", x=1140, y=100,w=170,h=80,color='lY',code=function()SCN.swapTo('login','swipeL')end}, diff --git a/parts/scenes/setting_key.lua b/parts/scenes/setting_key.lua index 009e8168..777d0710 100644 --- a/parts/scenes/setting_key.lua +++ b/parts/scenes/setting_key.lua @@ -26,6 +26,10 @@ function scene.sceneBack() FILE.save(keyMap,'conf/key') end +local forbbidenKeys={ + ["\\"]=true, + ["return"]=true, +} function scene.keyDown(key) if key=="escape"then if selected then @@ -41,7 +45,7 @@ function scene.keyDown(key) SCN.back() end elseif selected then - if key~="\\"then + if not forbbidenKeys[key]then keyMap.keyboard[key]=selected freshKeyList() selected=false diff --git a/parts/scenes/setting_sound.lua b/parts/scenes/setting_sound.lua index 7b3a5231..4b7ae652 100644 --- a/parts/scenes/setting_sound.lua +++ b/parts/scenes/setting_sound.lua @@ -64,11 +64,11 @@ scene.widgetList={ WIDGET.newSlider{name="spawn", x=180, y=300,w=400, font=30,change=function()SFX.fplay("spawn_"..math.random(7),SETTING.sfx_spawn)end,disp=SETval("sfx_spawn"),code=SETsto("sfx_spawn")}, WIDGET.newSlider{name='warn', x=180, y=400,w=400, font=30,change=function()SFX.fplay("warning",SETTING.sfx_warn)end,disp=SETval("sfx_warn"),code=SETsto("sfx_warn")}, WIDGET.newSlider{name="bgm", x=180, y=500,w=400, font=35,disp=SETval("bgm"),code=function(v)SETTING.bgm=v BGM.freshVolume()end}, - WIDGET.newSlider{name="stereo", x=180, y=600,w=400, font=35,change=function()SFX.play('move',1,-1)SFX.play('lock',1,1)end,disp=SETval("stereo"),code=SETsto("stereo"),hide=function()return SETTING.sx==0 end}, + WIDGET.newSlider{name="stereo", x=180, y=600,w=400, font=35,change=function()SFX.play('move',1,-1)SFX.play('lock',1,1)end,disp=SETval("stereo"),code=SETsto("stereo"),hideF=function()return SETTING.sx==0 end}, WIDGET.newSlider{name="vib", x=750, y=200,w=400,unit=5, font=25,change=function()VIB(2)end,disp=SETval("vib"),code=SETsto("vib")}, WIDGET.newSlider{name="voc", x=750, y=300,w=400, font=35,change=function()VOC.play('test')end,disp=SETval("voc"),code=SETsto("voc")}, WIDGET.newSelector{name="cv", x=1100, y=380,w=200, list={'miya','naki'},disp=function()return cv end,code=function(i)cv=i end}, - WIDGET.newButton{name="apply", x=1100, y=460,w=180,h=80, code=function()SETTING.cv=cv VOC.loadAll()end,hide=function()return SETTING.cv==cv end}, + WIDGET.newButton{name="apply", x=1100, y=460,w=180,h=80, code=function()SETTING.cv=cv VOC.loadAll()end,hideF=function()return SETTING.cv==cv end}, WIDGET.newButton{name="back", x=1140, y=640,w=170,h=80, font=40,code=backScene}, } diff --git a/parts/scenes/setting_touch.lua b/parts/scenes/setting_touch.lua index fe9fe24f..05e6169e 100644 --- a/parts/scenes/setting_touch.lua +++ b/parts/scenes/setting_touch.lua @@ -211,7 +211,7 @@ scene.widgetList={ VK_org[selected].r=(v+1)*10 end end, - hide=function() + hideF=function() return not selected end}, } diff --git a/parts/scenes/setting_touchSwitch.lua b/parts/scenes/setting_touchSwitch.lua index 0fd32718..2e11de83 100644 --- a/parts/scenes/setting_touchSwitch.lua +++ b/parts/scenes/setting_touchSwitch.lua @@ -39,7 +39,7 @@ scene.widgetList={ code=function() SCN.go('setting_trackSetting') end, - hide=function() + hideF=function() return not SETTING.VKTrack end}, WIDGET.newSlider{name="alpha", x=840, y=540, w=400,font=40,disp=SETval("VKAlpha"),code=SETsto("VKAlpha")},