-
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #443 from MihailRis/notifications
Notifications
- Loading branch information
Showing
19 changed files
with
208 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<panel size="300,0" margin="0,0,0,70" max-length='300' min-length='0' | ||
size-func="gui.get_viewport()[1]/2,-1" | ||
padding="0" | ||
min-size="0" | ||
color="0" | ||
interval="0" | ||
gravity="bottom-left" interactive="false"> | ||
</panel> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
local lines = {} | ||
local dead_lines = {} | ||
local nextid = 0 | ||
local timeout = 7 | ||
local fadeout = 1 | ||
local initialized = false | ||
local max_lines = 15 | ||
local animation_fps = 30 | ||
|
||
local function remove_line(line) | ||
document[line[1]]:destruct() | ||
time.post_runnable(function() document.root:reposition() end) | ||
end | ||
|
||
local function update_line(line, uptime) | ||
local diff = uptime - line[2] | ||
if diff > timeout then | ||
remove_line(line) | ||
table.insert(dead_lines, i) | ||
elseif diff > timeout-fadeout then | ||
local opacity = (timeout - diff) / fadeout | ||
document[line[1]].color = {0, 0, 0, opacity * 80} | ||
document[line[1].."L"].color = {255, 255, 255, opacity * 255} | ||
end | ||
end | ||
|
||
events.on("core:chat", function(message) | ||
local current_time = time.uptime() | ||
local id = 'l'..tostring(nextid) | ||
document.root:add(gui.template("chat_line", {id=id})) | ||
document.root:reposition() | ||
document[id.."L"].text = message | ||
nextid = nextid + 1 | ||
if #lines == max_lines then | ||
remove_line(lines[1]) | ||
table.remove(lines, 1) | ||
end | ||
table.insert(lines, {id, current_time}) | ||
end) | ||
|
||
function on_open() | ||
if not initialized then | ||
initialized = true | ||
|
||
document.root:setInterval(1/animation_fps, function () | ||
local uptime = time.uptime() | ||
for _, line in ipairs(lines) do | ||
update_line(line, uptime) | ||
end | ||
if #dead_lines > 0 then | ||
for i = #dead_lines, 1, -1 do | ||
local index = dead_lines[i] | ||
table.remove(lines, i) | ||
end | ||
dead_lines = {} | ||
end | ||
end) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<container id='%{id}' color="#00000050" size="-1,20"> | ||
<label pos='5' id='%{id}L' markup='md'/> | ||
</container> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.