chat-timestamps: show timestamps in chat
This commit is contained in:
@@ -47,6 +47,9 @@ For a detailed view of what's new and improved, check out the feature list below
|
||||
- **Chat History**
|
||||
*Save chat history of all non-combatlog windows and restore it on login.*
|
||||
|
||||
- **Chat Timestamps**
|
||||
*Add timestamps to chat messages.*
|
||||
|
||||
- **Center Text Input Box**
|
||||
*Move the chat input box to the center of the screen.*
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ mods\worldmap-reveal.lua
|
||||
mods\chat-input-center.lua
|
||||
mods\chat-history.lua
|
||||
mods\chat-text-shadow.lua
|
||||
mods\chat-timestamps.lua
|
||||
|
||||
# raid frames
|
||||
mods\raid.lua
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
local _G = ShaguTweaks.GetGlobalEnv()
|
||||
local T = ShaguTweaks.T
|
||||
local rgbhex = ShaguTweaks.rgbhex
|
||||
|
||||
local module = ShaguTweaks:register({
|
||||
title = T["Chat Timestamps"],
|
||||
description = T["Add timestamps to chat messages."],
|
||||
expansions = { ["vanilla"] = true, ["tbc"] = false },
|
||||
category = T["Chat"],
|
||||
maintainer = "@shagu (GitHub)",
|
||||
enabled = false,
|
||||
config = {
|
||||
["chat.timestamp.bracket"] = "[]",
|
||||
["chat.timestamp.format"] = 24,
|
||||
["chat.timestamp.color"] = { r = .8, g = .8, b = .8, a = 1},
|
||||
}
|
||||
})
|
||||
|
||||
module.enable = function(self)
|
||||
-- config shortcuts
|
||||
local bracket = self.config["chat.timestamp.bracket"]
|
||||
local clock = self.config["chat.timestamp.format"]
|
||||
local rgb = self.config["chat.timestamp.color"]
|
||||
|
||||
-- parse config
|
||||
local left = string.sub(bracket, 1, 1) or ""
|
||||
local right = string.sub(bracket, 2, 2) or ""
|
||||
local format = clock == 24 and "%H:%M:%S" or "%I:%M:%S %p"
|
||||
local color = rgbhex({ rgb.r, rgb.g, rgb.b, rgb.a })
|
||||
|
||||
-- add hooks to each frame
|
||||
for i=1,NUM_CHAT_WINDOWS do
|
||||
local original = _G["ChatFrame"..i].AddMessage
|
||||
_G["ChatFrame"..i].AddMessage = function(frame, msg, a1, a2, a3, a4, a5)
|
||||
-- ignore empty messages
|
||||
if not msg then return end
|
||||
|
||||
-- add timestamp to chat
|
||||
msg = color .. left .. date(format) .. right .. "|r " .. msg
|
||||
original(frame, msg, a1, a2, a3, a4, a5)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user