This commit is contained in:
2026-03-31 11:26:49 +03:00
parent f457aa2a11
commit 5bdd797b73
2 changed files with 78 additions and 49 deletions

View File

@@ -311,22 +311,26 @@ function PLUGIN:UpdateLogsList()
end end
for _, log in ipairs(clientLogs) do for _, log in ipairs(clientLogs) do
local logEntry = vgui.Create("DPanel", self.logsList) local logEntry = vgui.Create("DButton", self.logsList)
logEntry:SetTall(60) logEntry:SetTall(66)
logEntry:Dock(TOP) logEntry:Dock(TOP)
logEntry:DockMargin(5, 5, 5, 0) logEntry:DockMargin(5, 5, 5, 0)
logEntry:SetText("")
local category = self.LOG_CATEGORIES[log.category] local category = self.LOG_CATEGORIES[log.category]
local categoryColor = category and category.color or color_white local categoryColor = category and category.color or color_white
logEntry.Paint = function(s, w, h) logEntry.Paint = function(s, w, h)
draw.RoundedBox(4, 0, 0, w, h, COLOR_BG_LIGHT) local isHovered = s:IsHovered() or s:IsChildHovered()
local bgCol = isHovered and Color(18, 25, 20) or COLOR_BG_LIGHT
draw.RoundedBox(4, 0, 0, w, h, bgCol)
-- Боковая полоска категории -- Боковая полоска категории
draw.RoundedBoxEx(4, 0, 0, 5, h, categoryColor, true, false, true, false) draw.RoundedBoxEx(4, 0, 0, 5, h, categoryColor, true, false, true, false)
-- Рамка -- Рамка
surface.SetDrawColor(COLOR_BORDER) surface.SetDrawColor(isHovered and COLOR_PRIMARY or COLOR_BORDER)
surface.DrawOutlinedRect(0, 0, w, h, 1) surface.DrawOutlinedRect(0, 0, w, h, 1)
-- Время -- Время
@@ -340,23 +344,38 @@ function PLUGIN:UpdateLogsList()
draw.SimpleText(log.message, "ixSmallFont", 15, 43, COLOR_TEXT_PRIMARY, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP) draw.SimpleText(log.message, "ixSmallFont", 15, 43, COLOR_TEXT_PRIMARY, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)
end end
-- Контекстное меню -- Поиск SteamID в тексте сообщения
logEntry.OnMousePressed = function(s, btn) local function findSteamID(text)
if btn == MOUSE_RIGHT then if not text then return nil end
return string.match(text, "STEAM_[0-5]:[0-9]:[0-9]+")
end
local extractedID = findSteamID(log.message)
logEntry.DoRightClick = function(s)
local menu = DermaMenu() local menu = DermaMenu()
-- Опция копирования основного сообщения
menu:AddOption("Копировать сообщение", function() menu:AddOption("Копировать сообщение", function()
SetClipboardText(log.message) SetClipboardText(log.message)
ix.util.Notify("Сообщение скопировано") ix.util.Notify("Сообщение скопировано")
end):SetIcon("icon16/page_copy.png") end):SetIcon("icon16/page_copy.png")
-- Копирование SteamID цели (если есть в метаданных)
if log.target and log.target.steamid and log.target.steamid ~= "N/A" then if log.target and log.target.steamid and log.target.steamid ~= "N/A" then
menu:AddOption("Копировать SteamID (" .. log.target.name .. ")", function() menu:AddOption("Копировать SteamID (" .. log.target.name .. ")", function()
SetClipboardText(log.target.steamid) SetClipboardText(log.target.steamid)
ix.util.Notify("SteamID скопирован: " .. log.target.steamid) ix.util.Notify("SteamID скопирован: " .. log.target.steamid)
end):SetIcon("icon16/user_edit.png") end):SetIcon("icon16/user_edit.png")
-- Если нет в метаданных, но нашли в тексте (для архива)
elseif extractedID then
menu:AddOption("Копировать найденный SteamID (" .. extractedID .. ")", function()
SetClipboardText(extractedID)
ix.util.Notify("SteamID скопирован: " .. extractedID)
end):SetIcon("icon16/user_magnify.png")
end end
-- Копирование SteamID атакующего (для убийств)
if log.data and log.data.attacker and log.data.attacker ~= "world" then if log.data and log.data.attacker and log.data.attacker ~= "world" then
menu:AddOption("Копировать SteamID Атакующего", function() menu:AddOption("Копировать SteamID Атакующего", function()
SetClipboardText(log.data.attacker) SetClipboardText(log.data.attacker)
@@ -379,5 +398,4 @@ function PLUGIN:UpdateLogsList()
menu:Open() menu:Open()
end end
end end
end
end end

View File

@@ -58,9 +58,14 @@ function PLUGIN:LoadPersistentLogs()
local line = lines[i] local line = lines[i]
if not line or line == "" or string.StartWith(line, "===") then continue end if not line or line == "" or string.StartWith(line, "===") then continue end
-- Пример лога: [10:38:40][Боевые действия] Игрок умер -- Пробуем новый формат: [Время][Категория][SteamID] Сообщение
-- Нам нужно распарсить это обратно в таблицу local timeStr, categoryName, steamid, msg = string.match(line, "^%[(%d%d:%d%d:%d%d)%]%[(.-)%]%[(STEAM_%d:%d:%d+)%] (.*)")
local timeStr, categoryName, msg = string.match(line, "%[(%d%d:%d%d:%d%d)%]%[(.-)%] (.*)")
-- Если не вышло, пробуем старый формат: [Время][Категория] Сообщение
if not timeStr then
timeStr, categoryName, msg = string.match(line, "^%[(%d%d:%d%d:%d%d)%]%[(.-)%] (.*)")
steamid = "N/A"
end
if timeStr and categoryName and msg then if timeStr and categoryName and msg then
-- Находим ID категории по имени -- Находим ID категории по имени
@@ -74,10 +79,14 @@ function PLUGIN:LoadPersistentLogs()
table.insert(logsToLoad, { table.insert(logsToLoad, {
id = #logsToLoad + 1, id = #logsToLoad + 1,
type = "LOADED", -- Специальный тип для загруженных type = "LOADED",
category = categoryID, category = categoryID,
message = "[АРХИВ] " .. msg, message = "[АРХИВ] " .. msg,
timestamp = 0, -- Мы не знаем точную дату, только время target = {
name = steamid ~= "N/A" and steamid or "Архив",
steamid = steamid
},
timestamp = 0,
timeString = timeStr, timeString = timeStr,
isPersistent = true isPersistent = true
}) })
@@ -106,8 +115,8 @@ function PLUGIN:AddLog(logType, message, target, data)
category = self.LOG_TYPES[logType].category, category = self.LOG_TYPES[logType].category,
message = message, message = message,
target = target and { target = target and {
name = IsValid(target) and target:Nick() or tostring(target), name = IsValid(target) and target:Nick() or (isstring(target) and target or tostring(target)),
steamid = IsValid(target) and target:SteamID() or "N/A" steamid = IsValid(target) and target:SteamID() or (isstring(target) and string.match(target, "STEAM_%d:%d:%d+") and target or "N/A")
} or nil, } or nil,
data = data or {}, data = data or {},
timestamp = os.time(), timestamp = os.time(),
@@ -124,9 +133,11 @@ function PLUGIN:AddLog(logType, message, target, data)
-- Сохраняем в файл -- Сохраняем в файл
if self.logFile then if self.logFile then
local logString = string.format("[%s][%s] %s\n", local targetSID = (logEntry.target and logEntry.target.steamid ~= "N/A") and ("[" .. logEntry.target.steamid .. "]") or ""
local logString = string.format("[%s][%s]%s %s\n",
logEntry.timeString, logEntry.timeString,
self.LOG_CATEGORIES[logEntry.category].name, self.LOG_CATEGORIES[logEntry.category].name,
targetSID,
message message
) )
file.Append(self.logFile, logString) file.Append(self.logFile, logString)