textBox控件名让给真·文本框,输入框控件改名inputBox,更新历史界面使用文本框控件
This commit is contained in:
@@ -235,7 +235,7 @@ function love.textedited(text)
|
|||||||
end
|
end
|
||||||
function love.textinput(text)
|
function love.textinput(text)
|
||||||
local W=WIDGET.sel
|
local W=WIDGET.sel
|
||||||
if W and W.type=="textBox"then
|
if W and W.type=="inputBox"then
|
||||||
if not W.regex or text:match(W.regex)then
|
if not W.regex or text:match(W.regex)then
|
||||||
WIDGET.sel.value=WIDGET.sel.value..text
|
WIDGET.sel.value=WIDGET.sel.value..text
|
||||||
SFX.play("move")
|
SFX.play("move")
|
||||||
|
|||||||
@@ -689,29 +689,29 @@ function WIDGET.newSelector(D)--name,x,y,w[,fText][,color],list,disp,code,hide
|
|||||||
return _
|
return _
|
||||||
end
|
end
|
||||||
|
|
||||||
local textBox={
|
local inputBox={
|
||||||
type="textBox",
|
type="inputBox",
|
||||||
keepFocus=true,
|
keepFocus=true,
|
||||||
ATV=0,--Activating time(0~4)
|
ATV=0,--Activating time(0~4)
|
||||||
value="",--Text contained
|
value="",--Text contained
|
||||||
}
|
}
|
||||||
function textBox:reset()
|
function inputBox:reset()
|
||||||
self.ATV=0
|
self.ATV=0
|
||||||
if not MOBILE then
|
if not MOBILE then
|
||||||
kb.setTextInput(true)
|
kb.setTextInput(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function textBox:isAbove(x,y)
|
function inputBox:isAbove(x,y)
|
||||||
return
|
return
|
||||||
x>self.x and
|
x>self.x and
|
||||||
y>self.y and
|
y>self.y and
|
||||||
x<self.x+self.w and
|
x<self.x+self.w and
|
||||||
y<self.y+self.h
|
y<self.y+self.h
|
||||||
end
|
end
|
||||||
function textBox:getCenter()
|
function inputBox:getCenter()
|
||||||
return self.x+self.w*.5,self.y
|
return self.x+self.w*.5,self.y
|
||||||
end
|
end
|
||||||
function textBox:update()
|
function inputBox:update()
|
||||||
local ATV=self.ATV
|
local ATV=self.ATV
|
||||||
if WIDGET.sel==self then
|
if WIDGET.sel==self then
|
||||||
if ATV<3 then self.ATV=ATV+1 end
|
if ATV<3 then self.ATV=ATV+1 end
|
||||||
@@ -719,7 +719,7 @@ function textBox:update()
|
|||||||
if ATV>0 then self.ATV=ATV-.25 end
|
if ATV>0 then self.ATV=ATV-.25 end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function textBox:draw()
|
function inputBox:draw()
|
||||||
local x,y,w,h=self.x,self.y,self.w,self.h
|
local x,y,w,h=self.x,self.y,self.w,self.h
|
||||||
local ATV=self.ATV
|
local ATV=self.ATV
|
||||||
|
|
||||||
@@ -748,16 +748,16 @@ function textBox:draw()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function textBox:getInfo()
|
function inputBox:getInfo()
|
||||||
return format("x=%d,y=%d,w=%d,h=%d",self.x+self.w*.5,self.y+self.h*.5,self.w,self.h)
|
return format("x=%d,y=%d,w=%d,h=%d",self.x+self.w*.5,self.y+self.h*.5,self.w,self.h)
|
||||||
end
|
end
|
||||||
function textBox:press()
|
function inputBox:press()
|
||||||
if MOBILE then
|
if MOBILE then
|
||||||
local _,y1=SCR.xOy:transformPoint(0,self.y+self.h)
|
local _,y1=SCR.xOy:transformPoint(0,self.y+self.h)
|
||||||
kb.setTextInput(true,0,y1,1,1)
|
kb.setTextInput(true,0,y1,1,1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function textBox:keypress(k)
|
function inputBox:keypress(k)
|
||||||
local t=self.value
|
local t=self.value
|
||||||
if #t>0 and EDITING==""then
|
if #t>0 and EDITING==""then
|
||||||
if k=="backspace"then
|
if k=="backspace"then
|
||||||
@@ -773,7 +773,7 @@ function textBox:keypress(k)
|
|||||||
self.value=t
|
self.value=t
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function WIDGET.newTextBox(D)--name,x,y,w[,h][,font][,secret][,regex],hide
|
function WIDGET.newInputBox(D)--name,x,y,w[,h][,font][,secret][,regex],hide
|
||||||
local _={
|
local _={
|
||||||
name= D.name,
|
name= D.name,
|
||||||
|
|
||||||
@@ -793,38 +793,42 @@ function WIDGET.newTextBox(D)--name,x,y,w[,h][,font][,secret][,regex],hide
|
|||||||
regex= D.regex,
|
regex= D.regex,
|
||||||
hide= D.hide,
|
hide= D.hide,
|
||||||
}
|
}
|
||||||
for k,v in next,textBox do _[k]=v end
|
for k,v in next,inputBox do _[k]=v end
|
||||||
setmetatable(_,widgetMetatable)
|
setmetatable(_,widgetMetatable)
|
||||||
return _
|
return _
|
||||||
end
|
end
|
||||||
|
|
||||||
local chatBox={
|
local textBox={
|
||||||
type="chatBox",
|
type="textBox",
|
||||||
scrollPos=0,
|
scrollPos=0,
|
||||||
scrollPix=0,
|
scrollPix=0,
|
||||||
sure=0,
|
sure=0,
|
||||||
new=false,
|
new=false,
|
||||||
-- texts={},
|
-- texts={},
|
||||||
}
|
}
|
||||||
function chatBox:reset()
|
function textBox:reset()
|
||||||
--haha nothing here, but techmino is fun!
|
--haha nothing here, but techmino is fun!
|
||||||
end
|
end
|
||||||
function chatBox:isAbove(x,y)
|
function textBox:setTexts(t)
|
||||||
|
self.texts=t
|
||||||
|
self.scrollPos=min(#self.texts,self.capacity)
|
||||||
|
end
|
||||||
|
function textBox:isAbove(x,y)
|
||||||
return
|
return
|
||||||
x>self.x and
|
x>self.x and
|
||||||
y>self.y and
|
y>self.y and
|
||||||
x<self.x+self.w and
|
x<self.x+self.w and
|
||||||
y<self.y+self.h
|
y<self.y+self.h
|
||||||
end
|
end
|
||||||
function chatBox:getCenter()
|
function textBox:getCenter()
|
||||||
return self.x+self.w*.5,self.y+self.w
|
return self.x+self.w*.5,self.y+self.w
|
||||||
end
|
end
|
||||||
function chatBox:update()
|
function textBox:update()
|
||||||
if self.sure>0 then
|
if self.sure>0 then
|
||||||
self.sure=self.sure-1
|
self.sure=self.sure-1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function chatBox:push(t)
|
function textBox:push(t)
|
||||||
ins(self.texts,t)
|
ins(self.texts,t)
|
||||||
if self.scrollPos==#self.texts-1 then
|
if self.scrollPos==#self.texts-1 then
|
||||||
self.scrollPos=self.scrollPos+1
|
self.scrollPos=self.scrollPos+1
|
||||||
@@ -833,19 +837,17 @@ function chatBox:push(t)
|
|||||||
self.new=true
|
self.new=true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function chatBox:drag(_,_,_,dy)
|
function textBox:drag(_,_,_,dy)
|
||||||
_=self.scrollPix+dy
|
_=self.scrollPix+dy
|
||||||
if _>30 then
|
local sign=_>0 and 1 or -1
|
||||||
_=_-30
|
while abs(_)>30 do
|
||||||
self:scroll(-1)
|
_=_-30*sign
|
||||||
elseif _<-30 then
|
self:scroll(-sign)
|
||||||
_=_+30
|
|
||||||
self:scroll(1)
|
|
||||||
end
|
end
|
||||||
self.scrollPix=_
|
self.scrollPix=_
|
||||||
end
|
end
|
||||||
function chatBox:press(x,y)
|
function textBox:press(x,y)
|
||||||
if x>self.x+self.w-40 and y<self.y+40 then
|
if not self.fix and x>self.x+self.w-40 and y<self.y+40 then
|
||||||
if self.sure>0 then
|
if self.sure>0 then
|
||||||
self:clear()
|
self:clear()
|
||||||
self.sure=0
|
self.sure=0
|
||||||
@@ -854,7 +856,7 @@ function chatBox:press(x,y)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function chatBox:scroll(n)
|
function textBox:scroll(n)
|
||||||
if n<0 then
|
if n<0 then
|
||||||
self.scrollPos=max(self.scrollPos+n,min(#self.texts,self.capacity))
|
self.scrollPos=max(self.scrollPos+n,min(#self.texts,self.capacity))
|
||||||
else
|
else
|
||||||
@@ -864,17 +866,20 @@ function chatBox:scroll(n)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function chatBox:clear()
|
function textBox:clear()
|
||||||
self.texts={}
|
if not self.fix then
|
||||||
self.scrollPos=0
|
self.texts={}
|
||||||
SFX.play("fall")
|
self.scrollPos=0
|
||||||
|
SFX.play("fall")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
function chatBox:draw()
|
function textBox:draw()
|
||||||
local x,y,w,h=self.x,self.y,self.w,self.h
|
local x,y,w,h=self.x,self.y,self.w,self.h
|
||||||
local texts=self.texts
|
local texts=self.texts
|
||||||
local scroll=self.scrollPos
|
local scroll=self.scrollPos
|
||||||
local cap=self.capacity
|
local cap=self.capacity
|
||||||
|
|
||||||
|
|
||||||
--Frame
|
--Frame
|
||||||
gc.setLineWidth(4)
|
gc.setLineWidth(4)
|
||||||
gc.setColor(0,0,0,.3)
|
gc.setColor(0,0,0,.3)
|
||||||
@@ -882,34 +887,38 @@ function chatBox:draw()
|
|||||||
gc.setColor(1,1,1)
|
gc.setColor(1,1,1)
|
||||||
gc.rectangle("line",x,y,w,h)
|
gc.rectangle("line",x,y,w,h)
|
||||||
|
|
||||||
--Clear button
|
|
||||||
setFont(30)
|
|
||||||
mStr(self.sure>0 and"?"or"X",x+w-20,y-1)
|
|
||||||
gc.rectangle("line",x+w-40,y,40,40)
|
|
||||||
|
|
||||||
--Texts
|
|
||||||
for i=max(scroll-cap+1,1),scroll do
|
|
||||||
gc.printf(texts[i],x+8,y+h-10-30*(scroll-i+1),w)
|
|
||||||
end
|
|
||||||
|
|
||||||
--Slider
|
--Slider
|
||||||
if #texts>cap then
|
if #texts>cap then
|
||||||
gc.setLineWidth(2)
|
gc.setLineWidth(2)
|
||||||
gc.rectangle("line",x-25,y,20,h)
|
gc.rectangle("line",x-25,y,20,h)
|
||||||
local len=h*cap/#texts
|
local len=h*cap/#texts
|
||||||
|
gc.setColor(COLOR[WIDGET.sel==self and"Y"or"W"])
|
||||||
gc.rectangle("fill",x-22,y+(h-len-6)*(scroll-cap)/(#texts-cap)+3,14,len)
|
gc.rectangle("fill",x-22,y+(h-len-6)*(scroll-cap)/(#texts-cap)+3,14,len)
|
||||||
end
|
end
|
||||||
|
|
||||||
--Draw
|
setFont(30)
|
||||||
|
gc.setColor(1,1,1)
|
||||||
|
--Clear button
|
||||||
|
if not self.fix then
|
||||||
|
mStr(self.sure>0 and"?"or"X",x+w-20,y-1)
|
||||||
|
gc.rectangle("line",x+w-40,y,40,40)
|
||||||
|
end
|
||||||
|
--New message
|
||||||
if self.new and self.scrollPos~=#texts then
|
if self.new and self.scrollPos~=#texts then
|
||||||
gc.setColor(1,TIME()%.4<.2 and 1 or 0,0)
|
gc.setColor(1,TIME()%.4<.2 and 1 or 0,0)
|
||||||
gc.print("v",x+w-25,y+h-40)
|
gc.print("v",x+w-25,y+h-40)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--Texts
|
||||||
|
setFont(self.font)
|
||||||
|
for i=max(scroll-cap+1,1),scroll do
|
||||||
|
gc.printf(texts[i],x+8,y+h-10-self.lineH*(scroll-i+1),w)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
function chatBox:getInfo()
|
function textBox:getInfo()
|
||||||
return format("x=%d,y=%d,w=%d,h=%d",self.x+self.w*.5,self.y+self.h*.5,self.w,self.h)
|
return format("x=%d,y=%d,w=%d,h=%d",self.x+self.w*.5,self.y+self.h*.5,self.w,self.h)
|
||||||
end
|
end
|
||||||
function WIDGET.newChatBox(D)--name,x,y,w[,h][,font],hide
|
function WIDGET.newTextBox(D)--name,x,y,w,h[,font][,fix],hide
|
||||||
local _={
|
local _={
|
||||||
name= D.name,
|
name= D.name,
|
||||||
|
|
||||||
@@ -930,11 +939,15 @@ function WIDGET.newChatBox(D)--name,x,y,w[,h][,font],hide
|
|||||||
w= D.w,
|
w= D.w,
|
||||||
h= D.h,
|
h= D.h,
|
||||||
|
|
||||||
capacity=int((D.h-10)/30),
|
font= D.font or 30,
|
||||||
|
fix=D.fix,
|
||||||
texts={},
|
texts={},
|
||||||
hide= D.hide,
|
hide= D.hide,
|
||||||
}
|
}
|
||||||
for k,v in next,chatBox do _[k]=v end
|
_.lineH=7*(_.font/5)
|
||||||
|
_.capacity=int((D.h-10)/_.lineH)
|
||||||
|
|
||||||
|
for k,v in next,textBox do _[k]=v end
|
||||||
setmetatable(_,widgetMetatable)
|
setmetatable(_,widgetMetatable)
|
||||||
return _
|
return _
|
||||||
end
|
end
|
||||||
@@ -1001,7 +1014,7 @@ end
|
|||||||
function WIDGET.press(x,y)
|
function WIDGET.press(x,y)
|
||||||
local W=WIDGET.sel
|
local W=WIDGET.sel
|
||||||
if not W then return end
|
if not W then return end
|
||||||
if W.type=="button"or W.type=="key"or W.type=="switch"or W.type=="selector"or W.type=="textBox"or W.type=="chatBox"then
|
if W.type=="button"or W.type=="key"or W.type=="switch"or W.type=="selector"or W.type=="inputBox"or W.type=="textBox"then
|
||||||
W:press(x,y)
|
W:press(x,y)
|
||||||
elseif W.type=="slider"then
|
elseif W.type=="slider"then
|
||||||
WIDGET.drag(x,y)
|
WIDGET.drag(x,y)
|
||||||
@@ -1011,7 +1024,7 @@ end
|
|||||||
function WIDGET.drag(x,y,dx,dy)
|
function WIDGET.drag(x,y,dx,dy)
|
||||||
local W=WIDGET.sel
|
local W=WIDGET.sel
|
||||||
if not W then return end
|
if not W then return end
|
||||||
if W.type=="slider"or W.type=="chatBox"then
|
if W.type=="slider"or W.type=="textBox"then
|
||||||
W:drag(x,y,dx,dy)
|
W:drag(x,y,dx,dy)
|
||||||
elseif not W:isAbove(x,y)then
|
elseif not W:isAbove(x,y)then
|
||||||
WIDGET.sel=false
|
WIDGET.sel=false
|
||||||
@@ -1073,7 +1086,7 @@ function WIDGET.keyPressed(k)
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
local W=WIDGET.sel
|
local W=WIDGET.sel
|
||||||
if W and W.type=="textBox"then
|
if W and W.type=="inputBox"then
|
||||||
W:keypress(k)
|
W:keypress(k)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,49 +1,35 @@
|
|||||||
local gc=love.graphics
|
|
||||||
local max,min=math.max,math.min
|
|
||||||
|
|
||||||
local scene={}
|
local scene={}
|
||||||
|
|
||||||
local texts--Text list
|
local inited
|
||||||
local scrollPos--Scroll down length
|
|
||||||
|
|
||||||
function scene.sceneInit()
|
function scene.sceneInit()
|
||||||
BG.set("cubes")
|
BG.set("cubes")
|
||||||
texts=require"parts/updateLog"
|
if not inited then
|
||||||
scrollPos=1
|
inited=true
|
||||||
|
WIDGET.active.texts:setTexts(require"parts/updateLog")
|
||||||
|
end
|
||||||
if newVersionLaunch then
|
if newVersionLaunch then
|
||||||
newVersionLaunch=false
|
newVersionLaunch=false
|
||||||
scrollPos=3
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function scene.wheelMoved(_,y)
|
function scene.wheelMoved(_,y)
|
||||||
wheelScroll(y)
|
wheelScroll(y)
|
||||||
end
|
end
|
||||||
function scene.keyDown(key)
|
function scene.keyDown(k)
|
||||||
if key=="up"then
|
if k=="up"then
|
||||||
scrollPos=max(scrollPos-6,1)
|
WIDGET.active.texts:scroll(-5)
|
||||||
elseif key=="down"then
|
elseif k=="down"then
|
||||||
scrollPos=min(scrollPos+6,#texts-22)
|
WIDGET.active.texts:scroll(5)
|
||||||
elseif key=="escape"then
|
elseif k=="pgup"then
|
||||||
SCN.back()
|
WIDGET.active.texts:scroll(-20)
|
||||||
end
|
elseif k=="pgdown"then
|
||||||
end
|
WIDGET.active.texts:scroll(20)
|
||||||
|
|
||||||
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)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scene.widgetList={
|
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.newTextBox{name="texts", x=30,y=45,w=1000,h=640,font=20,fix=true},
|
||||||
WIDGET.newKey{name="next", x=1155, y=400,w=180,fText="↓",font=65,code=pressKey"down",hide=function()return scrollPos==#texts end},
|
|
||||||
WIDGET.newButton{name="back", x=1140, y=640,w=170,h=80,font=40,code=backScene},
|
WIDGET.newButton{name="back", x=1140, y=640,w=170,h=80,font=40,code=backScene},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,8 +65,8 @@ local scene={}
|
|||||||
scene.widgetList={
|
scene.widgetList={
|
||||||
WIDGET.newText{name="title", x=80, y=50,font=70,align="L"},
|
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.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.newInputBox{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="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.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},
|
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 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 remain--People in chat room
|
||||||
local heartBeatTimer
|
local heartBeatTimer
|
||||||
local escapeTimer=0
|
local escapeTimer=0
|
||||||
|
|
||||||
local function _init()
|
local function _init()
|
||||||
coroutine.yield()
|
coroutine.yield()
|
||||||
WIDGET.sel=WIDGET.active.text
|
WIDGET.sel=WIDGET.active.input
|
||||||
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)
|
|
||||||
end
|
end
|
||||||
local function sendMessage()
|
local function sendMessage()
|
||||||
local W=WIDGET.active.text
|
local W=WIDGET.active.input
|
||||||
if #W.value>0 and wsWrite("T"..W.value)then
|
if #W.value>0 and wsWrite("T"..W.value)then
|
||||||
W.value=""
|
W.value=""
|
||||||
end
|
end
|
||||||
@@ -29,6 +22,13 @@ function scene.sceneInit()
|
|||||||
heartBeatTimer=0
|
heartBeatTimer=0
|
||||||
remain=false
|
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(_init)--Widgets are not initialized, so active after 1 frame
|
||||||
TASK.new(TICK_wsRead)
|
TASK.new(TICK_wsRead)
|
||||||
BG.set("none")
|
BG.set("none")
|
||||||
@@ -44,9 +44,9 @@ function scene.wheelMoved(_,y)
|
|||||||
end
|
end
|
||||||
function scene.keyDown(k)
|
function scene.keyDown(k)
|
||||||
if k=="up"then
|
if k=="up"then
|
||||||
chatBox:scroll(-1)
|
textBox:scroll(-1)
|
||||||
elseif k=="down"then
|
elseif k=="down"then
|
||||||
chatBox:scroll(1)
|
textBox:scroll(1)
|
||||||
elseif k=="return"then
|
elseif k=="return"then
|
||||||
sendMessage()
|
sendMessage()
|
||||||
elseif k=="escape"then
|
elseif k=="escape"then
|
||||||
@@ -65,14 +65,14 @@ function scene.socketRead(mes)
|
|||||||
local cmd=mes:sub(1,1)
|
local cmd=mes:sub(1,1)
|
||||||
local args=splitStr(mes:sub(2),":")
|
local args=splitStr(mes:sub(2),":")
|
||||||
if cmd=="J"or cmd=="L"then
|
if cmd=="J"or cmd=="L"then
|
||||||
chatBox:push{
|
textBox:push{
|
||||||
COLOR.lR,args[1],
|
COLOR.lR,args[1],
|
||||||
COLOR.dY,args[2].." ",
|
COLOR.dY,args[2].." ",
|
||||||
COLOR.Y,text[cmd=="J"and"chatJoin"or"chatLeave"]
|
COLOR.Y,text[cmd=="J"and"chatJoin"or"chatLeave"]
|
||||||
}
|
}
|
||||||
remain=tonumber(args[3])
|
remain=tonumber(args[3])
|
||||||
elseif cmd=="T"then
|
elseif cmd=="T"then
|
||||||
chatBox:push{
|
textBox:push{
|
||||||
COLOR.W,args[1],
|
COLOR.W,args[1],
|
||||||
COLOR.dY,args[2].." ",
|
COLOR.dY,args[2].." ",
|
||||||
COLOR.sky,args[3]
|
COLOR.sky,args[3]
|
||||||
@@ -98,7 +98,8 @@ function scene.draw()
|
|||||||
end
|
end
|
||||||
|
|
||||||
scene.widgetList={
|
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="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},
|
WIDGET.newButton{name="back", x=1140, y=640,w=170,h=80,font=40,code=backScene},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,10 +63,10 @@ end
|
|||||||
scene.widgetList={
|
scene.widgetList={
|
||||||
WIDGET.newText{name="title", x=80, y=50,font=70,align="L"},
|
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.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.newInputBox{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.newInputBox{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.newInputBox{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="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},
|
WIDGET.newButton{name="back", x=1140, y=640,w=170,h=80,font=40,code=backScene},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user