diff options
| -rw-r--r-- | main.lua | 4 | ||||
| -rw-r--r-- | notification.lua | 35 | ||||
| -rw-r--r-- | system.lua | 4 | ||||
| -rw-r--r-- | var.lua | 9 |
4 files changed, 52 insertions, 0 deletions
@@ -14,6 +14,7 @@ function love.load() require "system" require "loading" require "elements" + require "notification" love.graphics.setDefaultFilter("nearest", "nearest") love.graphics.setBackgroundColor(0, 0, 0) love.graphics.setNewFont() @@ -42,6 +43,9 @@ function love.update(dt) elseif fade == 0 and fadeOpacity ~= 0 then fadeOpacity = fadeOpacity - 5 end + if scene == 1 then + updateSystem(dt) + end end function love.mousepressed(x, y, button) sys.mouse.p.x = x diff --git a/notification.lua b/notification.lua new file mode 100644 index 0000000..1a42aa2 --- /dev/null +++ b/notification.lua @@ -0,0 +1,35 @@ +function drawNoti() + if notify.yes == true or notify.op ~= 0 then + love.graphics.setColor(255, 255, 255, notify.op) + love.graphics.draw(notification.bubble, notify.x, notify.y) + love.graphics.setColor(colors.font.dark, notify.op) + love.graphics.print(notify.title, notify.x+10, notify.y+10) + love.graphics.print(notify.body, notify.x+10, notify.y+30) + if notify.sound == true then + notification.sound1:play() + notify.sound = false + end + if notify.op ~= 255 and notify.yes == true then + notify.op = notify.op + 17 + elseif notify.op ~= 0 and notify.yes == false then + notify.op = notify.op - 17 + end + end +end +function timeNoti(dt) + notify.timer = notify.timer + dt + if notify.timer >= 5 then + notify.yes = false + notify.timer = 0 + notify.sound = false + end +end +function notifyNow(title, body) + if notify.yes == false and notify.sound == false then + notify.sound = true + notify.timer = 0 + end + notify.yes = true + notify.title = title + notify.body = body +end @@ -3,6 +3,9 @@ function drawLayer(id) love.graphics.draw(win[layer[id]].cvs, win[layer[id]].x, win[layer[id]].y, 0, win[layer[id]].s) end end +function updateSystem(dt) + timeNoti(dt) +end function drawSystem() love.graphics.setBackgroundColor(0, 128, 128) drawDesktop() @@ -35,6 +38,7 @@ function drawSystem() if start.o == true then drawMenu() end + drawNoti() --love.graphics.print(layer[1] .. layer[2] .. layer[3] .. layer[4] .. layer[5] .. layer[6] .. layer[7]) --love.graphics.print(win[1].layer .. win[2].layer .. win[3].layer .. win[4].layer .. win[5].layer .. win[6].layer, 0, 20) if fade == 0 and fadeOpacity ~= 0 then @@ -103,4 +103,13 @@ function loadVar() colors.win.normal = {192,192,192} colors.font = {} colors.font.dark = {50,50,50} + notify = {} + notify.yes = false + notify.title = "" + notify.body = "" + notify.op = 0 + notify.sound = false + notify.x = sys.w-258 + notify.y = sys.h-135 + notify.timer = 0 end |
