Selaa lähdekoodia

Refresh server button;

bjorn 11 vuotta sitten
vanhempi
sitoutus
4a0c19f880
2 muutettua tiedostoa jossa 27 lisäystä ja 14 poistoa
  1. 14 14
      data/menu/menuback.lua
  2. 13 0
      data/menu/menuserverlist.lua

+ 14 - 14
data/menu/menuback.lua

@@ -4,21 +4,21 @@ local g = love.graphics
 local w, h = g.width, g.height
 
 function MenuBack:draw()
-	local pages = #ctx.pages > 1
-	local x, y = love.mouse.getPosition()
-	local hover = math.inside(x, y, 0, h(.8), w(), h(.2))
-	if not pages then hover = false end
-	g.setColor(0, 0, 0, hover and 120 or 80)
-	g.rectangle('fill', 0, h(.8), w(), h(.2))
-	if pages then
-		g.setColor(hover and {255, 255, 255, 200} or {200, 200, 200, 200})
-		g.setFont('BebasNeue', h(.065))
-		g.printCenter('back', w(.05), h(.9), false, true)
-	end
+  local pages = #ctx.pages > 1
+  local x, y = love.mouse.getPosition()
+  local hover = math.inside(x, y, 0, h(.8), w(), h(.2))
+  if not pages then hover = false end
+  g.setColor(0, 0, 0, hover and 120 or 80)
+  g.rectangle('fill', 0, h(.8), w(), h(.2))
+  if pages then
+    g.setColor(hover and {255, 255, 255, 200} or {200, 200, 200, 200})
+    g.setFont('BebasNeue', h(.065))
+    g.printCenter('back', w(.05), h(.9), false, true)
+  end
 end
 
 function MenuBack:mousepressed(x, y, button)
-	if button == 'l' and math.inside(x, y, 0, h(.8), w(), h(.2)) then
-		ctx:pop()
-	end
+  if button == 'l' and math.inside(x, y, 0, h(.8), w(), h(.2)) then
+    ctx:pop()
+  end
 end

+ 13 - 0
data/menu/menuserverlist.lua

@@ -13,6 +13,14 @@ function MenuServerList:load()
 end
 
 function MenuServerList:draw()
+  local x, y = love.mouse.getPosition()
+  local hover = math.inside(x, y, 0, h(.2), w(), h(.1))
+  g.setColor(0, 0, 0, hover and 50 or 0)
+  g.rectangle('fill', 0, h(.2), w(), h(.1))
+  g.setColor(hover and {255, 255, 255, 200} or {200, 200, 200, 200})
+  g.setFont('BebasNeue', h(.065))
+  g.printCenter('refresh', w(.05), h(.25), false, true)
+
   g.setColor(0, 0, 0, 100)
   g.rectangle('fill', 16, h(.3) + 16, w() - 32, h(.5) - 32)
   g.setFont('pixel', 8)
@@ -33,6 +41,7 @@ function MenuServerList:draw()
     g.setColor(255, 255, 255)
     g.print(self.servers[i].name, 32, yy)
   end
+
 end
 
 function MenuServerList:keypressed(key)
@@ -47,6 +56,10 @@ function MenuServerList:mousepressed(x, y, button)
         ctx.main:connect(self.servers[i].ip)
       end
     end
+
+    if math.inside(x, y, 0, h(.2), w(), h(.1)) then
+      self:refresh()
+    end
   end
 end