textBox控件名让给真·文本框,输入框控件改名inputBox,更新历史界面使用文本框控件
This commit is contained in:
@@ -1,49 +1,35 @@
|
||||
local gc=love.graphics
|
||||
local max,min=math.max,math.min
|
||||
|
||||
local scene={}
|
||||
|
||||
local texts--Text list
|
||||
local scrollPos--Scroll down length
|
||||
local inited
|
||||
|
||||
function scene.sceneInit()
|
||||
BG.set("cubes")
|
||||
texts=require"parts/updateLog"
|
||||
scrollPos=1
|
||||
if not inited then
|
||||
inited=true
|
||||
WIDGET.active.texts:setTexts(require"parts/updateLog")
|
||||
end
|
||||
if newVersionLaunch then
|
||||
newVersionLaunch=false
|
||||
scrollPos=3
|
||||
end
|
||||
end
|
||||
|
||||
function scene.wheelMoved(_,y)
|
||||
wheelScroll(y)
|
||||
end
|
||||
function scene.keyDown(key)
|
||||
if key=="up"then
|
||||
scrollPos=max(scrollPos-6,1)
|
||||
elseif key=="down"then
|
||||
scrollPos=min(scrollPos+6,#texts-22)
|
||||
elseif key=="escape"then
|
||||
SCN.back()
|
||||
end
|
||||
end
|
||||
|
||||
function scene.draw()
|
||||
gc.setColor(.2,.2,.2,.7)
|
||||
gc.rectangle("fill",30,45,1000,632)
|
||||
gc.setColor(1,1,1)
|
||||
gc.setLineWidth(4)
|
||||
gc.rectangle("line",30,45,1000,632)
|
||||
setFont(20)
|
||||
for i=0,22 do
|
||||
gc.print(texts[scrollPos+i],40,50+27*i)
|
||||
function scene.keyDown(k)
|
||||
if k=="up"then
|
||||
WIDGET.active.texts:scroll(-5)
|
||||
elseif k=="down"then
|
||||
WIDGET.active.texts:scroll(5)
|
||||
elseif k=="pgup"then
|
||||
WIDGET.active.texts:scroll(-20)
|
||||
elseif k=="pgdown"then
|
||||
WIDGET.active.texts:scroll(20)
|
||||
end
|
||||
end
|
||||
|
||||
scene.widgetList={
|
||||
WIDGET.newKey{name="prev", x=1155, y=170,w=180,fText="↑",font=65,code=pressKey"up",hide=function()return scrollPos==1 end},
|
||||
WIDGET.newKey{name="next", x=1155, y=400,w=180,fText="↓",font=65,code=pressKey"down",hide=function()return scrollPos==#texts end},
|
||||
WIDGET.newTextBox{name="texts", x=30,y=45,w=1000,h=640,font=20,fix=true},
|
||||
WIDGET.newButton{name="back", x=1140, y=640,w=170,h=80,font=40,code=backScene},
|
||||
}
|
||||
|
||||
|
||||
@@ -65,8 +65,8 @@ local scene={}
|
||||
scene.widgetList={
|
||||
WIDGET.newText{name="title", x=80, y=50,font=70,align="L"},
|
||||
-- WIDGET.newButton{name="register", x=1140, y=100,w=170,h=80,color="green",code=function()SCN.swapTo("register","swipeR")end},
|
||||
WIDGET.newTextBox{name="email", x=380, y=200,w=500,h=60,regex="[0-9A-Za-z@._-]"},
|
||||
WIDGET.newTextBox{name="password", x=380, y=300,w=626,h=60,secret=true,regex="[ -~]"},
|
||||
WIDGET.newInputBox{name="email", x=380, y=200,w=500,h=60,regex="[0-9A-Za-z@._-]"},
|
||||
WIDGET.newInputBox{name="password", x=380, y=300,w=626,h=60,secret=true,regex="[ -~]"},
|
||||
WIDGET.newKey{name="login", x=1140, y=540,w=170,h=80,font=40,code=login},
|
||||
WIDGET.newButton{name="back", x=1140, y=640,w=170,h=80,font=40,code=backScene},
|
||||
}
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
local gc=love.graphics
|
||||
|
||||
local chatBox=WIDGET.newChatBox{name="texts",x=50,y=50,w=1200,h=430}
|
||||
local textBox=WIDGET.newTextBox{name="texts",x=40,y=50,w=1200,h=430}
|
||||
local remain--People in chat room
|
||||
local heartBeatTimer
|
||||
local escapeTimer=0
|
||||
|
||||
local function _init()
|
||||
coroutine.yield()
|
||||
WIDGET.sel=WIDGET.active.text
|
||||
local texts=chatBox.texts
|
||||
if #texts==0 then
|
||||
chatBox:push{COLOR.dG,text.chatStart}
|
||||
elseif #texts>1 and texts[#texts][1]~=COLOR.dG then
|
||||
chatBox:push{COLOR.dG,text.chatHistory}
|
||||
end
|
||||
chatBox:scroll(1)
|
||||
WIDGET.sel=WIDGET.active.input
|
||||
end
|
||||
local function sendMessage()
|
||||
local W=WIDGET.active.text
|
||||
local W=WIDGET.active.input
|
||||
if #W.value>0 and wsWrite("T"..W.value)then
|
||||
W.value=""
|
||||
end
|
||||
@@ -29,6 +22,13 @@ function scene.sceneInit()
|
||||
heartBeatTimer=0
|
||||
remain=false
|
||||
|
||||
local texts=textBox.texts
|
||||
if #texts==0 then
|
||||
textBox:push{COLOR.dG,text.chatStart}
|
||||
elseif #texts>1 and texts[#texts][1]~=COLOR.dG then
|
||||
textBox:push{COLOR.dG,text.chatHistory}
|
||||
end
|
||||
textBox:scroll(1)
|
||||
TASK.new(_init)--Widgets are not initialized, so active after 1 frame
|
||||
TASK.new(TICK_wsRead)
|
||||
BG.set("none")
|
||||
@@ -44,9 +44,9 @@ function scene.wheelMoved(_,y)
|
||||
end
|
||||
function scene.keyDown(k)
|
||||
if k=="up"then
|
||||
chatBox:scroll(-1)
|
||||
textBox:scroll(-1)
|
||||
elseif k=="down"then
|
||||
chatBox:scroll(1)
|
||||
textBox:scroll(1)
|
||||
elseif k=="return"then
|
||||
sendMessage()
|
||||
elseif k=="escape"then
|
||||
@@ -65,14 +65,14 @@ function scene.socketRead(mes)
|
||||
local cmd=mes:sub(1,1)
|
||||
local args=splitStr(mes:sub(2),":")
|
||||
if cmd=="J"or cmd=="L"then
|
||||
chatBox:push{
|
||||
textBox:push{
|
||||
COLOR.lR,args[1],
|
||||
COLOR.dY,args[2].." ",
|
||||
COLOR.Y,text[cmd=="J"and"chatJoin"or"chatLeave"]
|
||||
}
|
||||
remain=tonumber(args[3])
|
||||
elseif cmd=="T"then
|
||||
chatBox:push{
|
||||
textBox:push{
|
||||
COLOR.W,args[1],
|
||||
COLOR.dY,args[2].." ",
|
||||
COLOR.sky,args[3]
|
||||
@@ -98,7 +98,8 @@ function scene.draw()
|
||||
end
|
||||
|
||||
scene.widgetList={
|
||||
chatBox,
|
||||
textBox,
|
||||
WIDGET.newInputBox{name="input",x=40, y=500,w=980,h=180,font=40},
|
||||
WIDGET.newButton{name="send", x=1140, y=540,w=170,h=80,font=40,code=sendMessage},
|
||||
WIDGET.newButton{name="back", x=1140, y=640,w=170,h=80,font=40,code=backScene},
|
||||
}
|
||||
|
||||
@@ -63,10 +63,10 @@ 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="green",code=function()SCN.swapTo("login","swipeL")end},
|
||||
WIDGET.newTextBox{name="username", x=380, y=200,w=500,h=60,regex="[0-9A-Za-z_]"},
|
||||
WIDGET.newTextBox{name="email", x=380, y=300,w=626,h=60,regex="[0-9A-Za-z@._-]"},
|
||||
WIDGET.newTextBox{name="password", x=380, y=400,w=626,h=60,secret=true,regex="[ -~]"},
|
||||
WIDGET.newTextBox{name="password2", x=380, y=500,w=626,h=60,secret=true,regex="[ -~]"},
|
||||
WIDGET.newInputBox{name="username", x=380, y=200,w=500,h=60,regex="[0-9A-Za-z_]"},
|
||||
WIDGET.newInputBox{name="email", x=380, y=300,w=626,h=60,regex="[0-9A-Za-z@._-]"},
|
||||
WIDGET.newInputBox{name="password", x=380, y=400,w=626,h=60,secret=true,regex="[ -~]"},
|
||||
WIDGET.newInputBox{name="password2", x=380, y=500,w=626,h=60,secret=true,regex="[ -~]"},
|
||||
WIDGET.newButton{name="back", x=1140, y=640,w=170,h=80,font=40,code=backScene},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user