房间选择界面支持点选和拖动,ui调整
This commit is contained in:
@@ -255,8 +255,6 @@ return{
|
|||||||
new="New Room(2)",
|
new="New Room(2)",
|
||||||
new2="New Room(5)",
|
new2="New Room(5)",
|
||||||
join="Join",
|
join="Join",
|
||||||
up="↑",
|
|
||||||
down="↓",
|
|
||||||
},
|
},
|
||||||
net_game={
|
net_game={
|
||||||
ready="Ready",
|
ready="Ready",
|
||||||
|
|||||||
@@ -226,8 +226,6 @@ return{
|
|||||||
noRoom="Aucun salon actuellement",
|
noRoom="Aucun salon actuellement",
|
||||||
-- refresh="Refresh",
|
-- refresh="Refresh",
|
||||||
join="Rejoindre",
|
join="Rejoindre",
|
||||||
up="↑",
|
|
||||||
down="↓",
|
|
||||||
},
|
},
|
||||||
net_game={
|
net_game={
|
||||||
-- ready="Ready",
|
-- ready="Ready",
|
||||||
|
|||||||
@@ -256,8 +256,6 @@ return{
|
|||||||
-- new="New Room(2)",
|
-- new="New Room(2)",
|
||||||
-- new2="New Room(5)",
|
-- new2="New Room(5)",
|
||||||
-- join="Join",
|
-- join="Join",
|
||||||
up="↑",
|
|
||||||
down="↓",
|
|
||||||
},
|
},
|
||||||
net_game={
|
net_game={
|
||||||
-- ready="Ready",
|
-- ready="Ready",
|
||||||
|
|||||||
@@ -233,8 +233,6 @@ return{
|
|||||||
new="Sala Nueva(2)",
|
new="Sala Nueva(2)",
|
||||||
new2="Sala Nueva(5)",
|
new2="Sala Nueva(5)",
|
||||||
join="Unirse",
|
join="Unirse",
|
||||||
up="↑",
|
|
||||||
down="↓",
|
|
||||||
},
|
},
|
||||||
net_game={
|
net_game={
|
||||||
ready="Estoy Listo",
|
ready="Estoy Listo",
|
||||||
|
|||||||
@@ -255,8 +255,6 @@ return{
|
|||||||
new="创建房间(2)",
|
new="创建房间(2)",
|
||||||
new2="创建房间(5)",
|
new2="创建房间(5)",
|
||||||
join="加入",
|
join="加入",
|
||||||
up="↑",
|
|
||||||
down="↓",
|
|
||||||
},
|
},
|
||||||
net_game={
|
net_game={
|
||||||
ready="准备",
|
ready="准备",
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
local gc=love.graphics
|
local gc=love.graphics
|
||||||
local kb=love.keyboard
|
local ms,kb=love.mouse,love.keyboard
|
||||||
|
|
||||||
|
local int,max,min=math.floor,math.max,math.min
|
||||||
|
|
||||||
local NET=NET
|
local NET=NET
|
||||||
local scrollPos,selected
|
local scrollPos,selected
|
||||||
@@ -20,8 +22,23 @@ function scene.sceneInit()
|
|||||||
fetchRoom()
|
fetchRoom()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local floatWheel=0
|
||||||
function scene.wheelMoved(_,y)
|
function scene.wheelMoved(_,y)
|
||||||
WHEELMOV(y)
|
if y>0 then
|
||||||
|
if floatWheel<0 then floatWheel=0 end
|
||||||
|
floatWheel=floatWheel+y^1.2
|
||||||
|
elseif y<0 then
|
||||||
|
if floatWheel>0 then floatWheel=0 end
|
||||||
|
floatWheel=floatWheel-(-y)^1.2
|
||||||
|
end
|
||||||
|
while floatWheel>=1 do
|
||||||
|
scrollPos=max(0,min(scrollPos-1,#NET.roomList-10))
|
||||||
|
floatWheel=floatWheel-1
|
||||||
|
end
|
||||||
|
while floatWheel<=-1 do
|
||||||
|
scrollPos=max(0,min(scrollPos+1,#NET.roomList-10))
|
||||||
|
floatWheel=floatWheel+1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
function scene.keyDown(k)
|
function scene.keyDown(k)
|
||||||
if k=="r"then
|
if k=="r"then
|
||||||
@@ -49,16 +66,12 @@ function scene.keyDown(k)
|
|||||||
if k=="down"then
|
if k=="down"then
|
||||||
if selected<#NET.roomList then
|
if selected<#NET.roomList then
|
||||||
selected=selected+1
|
selected=selected+1
|
||||||
if selected>scrollPos+10 then
|
scrollPos=max(selected-10,min(scrollPos,selected-1))
|
||||||
scrollPos=scrollPos+1
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
elseif k=="up"then
|
elseif k=="up"then
|
||||||
if selected>1 then
|
if selected>1 then
|
||||||
selected=selected-1
|
selected=selected-1
|
||||||
if selected<scrollPos+1 then
|
scrollPos=max(selected-10,min(scrollPos,selected-1))
|
||||||
scrollPos=scrollPos-1
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
elseif k=="return"then
|
elseif k=="return"then
|
||||||
if NET.getlock("fetchRoom")or not NET.roomList[selected]then return end
|
if NET.getlock("fetchRoom")or not NET.roomList[selected]then return end
|
||||||
@@ -71,6 +84,25 @@ function scene.keyDown(k)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function scene.mouseMove(_,_,_,dy)
|
||||||
|
if ms.isDown(1)then
|
||||||
|
scene.wheelMoved(0,dy/30)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function scene.mouseClick(x,y)
|
||||||
|
if x>50 and x<1230 then
|
||||||
|
y=int((y-70)/40)
|
||||||
|
if y>=1 and y<=10 then
|
||||||
|
print(y+scrollPos)
|
||||||
|
selected=y+scrollPos
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function scene.touchMove(_,_,_,dy)
|
||||||
|
scene.wheelMoved(0,dy/30)
|
||||||
|
end
|
||||||
|
scene.touchClick=scene.mouseClick
|
||||||
|
|
||||||
function scene.update(dt)
|
function scene.update(dt)
|
||||||
if not NET.getlock("fetchRoom")then
|
if not NET.getlock("fetchRoom")then
|
||||||
fetchTimer=fetchTimer-dt
|
fetchTimer=fetchTimer-dt
|
||||||
@@ -85,19 +117,21 @@ end
|
|||||||
|
|
||||||
function scene.draw()
|
function scene.draw()
|
||||||
--Fetching timer
|
--Fetching timer
|
||||||
gc.setColor(1,1,1,.26)
|
gc.setColor(1,1,1,.12)
|
||||||
gc.arc("fill","pie",130,620,60,-1.5708,-1.5708-1.2566*fetchTimer)
|
gc.arc("fill","pie",300,620,60,-1.5708,-1.5708-1.2566*fetchTimer)
|
||||||
|
|
||||||
--Room list
|
--Room list
|
||||||
gc.setColor(1,1,1)
|
gc.setColor(1,1,1)
|
||||||
gc.setLineWidth(2)
|
gc.setLineWidth(2)
|
||||||
gc.rectangle("line",50,110,1180,400)
|
gc.rectangle("line",50,110,1180,400)
|
||||||
if #NET.roomList>0 then
|
if #NET.roomList>0 then
|
||||||
gc.setColor(1,1,1,.3)
|
|
||||||
gc.rectangle("fill",50,40*(1+selected-scrollPos)+30,1180,40)
|
|
||||||
setFont(35)
|
setFont(35)
|
||||||
for i=1,math.min(10,#NET.roomList-scrollPos)do
|
for i=1,math.min(10,#NET.roomList-scrollPos)do
|
||||||
local R=NET.roomList[scrollPos+i]
|
local R=NET.roomList[scrollPos+i]
|
||||||
|
if scrollPos+i==selected then
|
||||||
|
gc.setColor(1,1,1,.3)
|
||||||
|
gc.rectangle("fill",50,70+40*i,1180,40)
|
||||||
|
end
|
||||||
if R.private then
|
if R.private then
|
||||||
gc.setColor(1,1,1)
|
gc.setColor(1,1,1)
|
||||||
gc.draw(IMG.lock,59,75+40*i)
|
gc.draw(IMG.lock,59,75+40*i)
|
||||||
@@ -120,16 +154,13 @@ function scene.draw()
|
|||||||
drawSelfProfile()
|
drawSelfProfile()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function hide_noRoom()return #NET.roomList==0 end
|
|
||||||
scene.widgetList={
|
scene.widgetList={
|
||||||
WIDGET.newText{name="refreshing",x=640,y=255,font=45,hide=function()return not NET.getlock("fetchRoom")end},
|
WIDGET.newText{name="refreshing",x=640,y=255,font=45,hide=function()return not NET.getlock("fetchRoom")end},
|
||||||
WIDGET.newText{name="noRoom", x=640,y=260,font=40,hide=function()return #NET.roomList>0 or NET.getlock("fetchRoom")end},
|
WIDGET.newText{name="noRoom", x=640,y=260,font=40,hide=function()return #NET.roomList>0 or NET.getlock("fetchRoom")end},
|
||||||
WIDGET.newKey{name="refresh", x=130,y=620,w=140,h=140,font=35,code=fetchRoom, hide=function()return fetchTimer>3.26 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.newKey{name="new", x=330,y=620,w=140,h=140,font=20,code=pressKey"n"},
|
WIDGET.newKey{name="new", x=500,y=620,w=140,h=140,font=20,code=pressKey"n"},
|
||||||
WIDGET.newKey{name="new2", x=530,y=620,w=140,h=140,font=20,code=pressKey"m"},
|
WIDGET.newKey{name="new2", x=700,y=620,w=140,h=140,font=20,code=pressKey"m"},
|
||||||
WIDGET.newKey{name="join", x=730,y=620,w=140,h=140,font=40,code=pressKey"return", hide=hide_noRoom},
|
WIDGET.newKey{name="join", x=900,y=620,w=140,h=140,font=40,code=pressKey"return",hide=function()return #NET.roomList==0 end},
|
||||||
WIDGET.newKey{name="up", x=930,y=585,w=140,h=70,font=40,code=pressKey"up", hide=hide_noRoom},
|
|
||||||
WIDGET.newKey{name="down", x=930,y=655,w=140,h=70,font=40,code=pressKey"down", hide=hide_noRoom},
|
|
||||||
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