Files
VnUtest/garrysmod/gamemodes/militaryrp/plugins/chatbox/derma/cl_chatskin.lua
2026-03-31 10:27:04 +03:00

206 lines
7.2 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- Переопределение стилей чатбокса под общий дизайн Military RP
local PLUGIN = PLUGIN
local gradient = surface.GetTextureID("vgui/gradient-u")
local gradientUp = surface.GetTextureID("vgui/gradient-d")
-- Цвета в стиле HUD
local Colors = {
green = Color(84, 147, 90),
dark_green = Color(52, 91, 60),
darker_green = Color(35, 53, 29),
gray = Color(193, 193, 193),
gray_dark = Color(94, 94, 94),
black = Color(0, 0, 0, 220),
black_light = Color(0, 0, 0, 150),
white = Color(255, 255, 255)
}
-- Переопределяем стандартные функции рисования чатбокса
local SKIN = derma.GetDefaultSkin()
-- Фон чатбокса
function SKIN:PaintChatboxBackground(panel, width, height)
-- Blur эффект
ix.util.DrawBlur(panel, 8)
-- Основной фон с градиентом
surface.SetDrawColor(Colors.black)
surface.DrawRect(0, 0, width, height)
if (panel:GetActive()) then
-- Зелёный градиент сверху когда чат активен
surface.SetDrawColor(Colors.dark_green.r, Colors.dark_green.g, Colors.dark_green.b, 120)
surface.SetTexture(gradientUp)
surface.DrawTexturedRect(0, panel.tabs.buttons:GetTall(), width, height * 0.25)
end
-- Обводка в стиле HUD
surface.SetDrawColor(Colors.darker_green)
surface.DrawOutlinedRect(0, 0, width, height)
-- Тонкая внутренняя обводка
surface.SetDrawColor(Colors.green.r, Colors.green.g, Colors.green.b, 60)
surface.DrawOutlinedRect(1, 1, width - 2, height - 2)
end
-- Кнопки табов
function SKIN:PaintChatboxTabButton(panel, width, height)
if (panel:GetActive()) then
-- Активная вкладка - зелёный градиент
surface.SetDrawColor(Colors.dark_green)
surface.DrawRect(0, 0, width, height)
surface.SetDrawColor(Colors.green.r, Colors.green.g, Colors.green.b, 100)
surface.SetTexture(gradient)
surface.DrawTexturedRect(0, 0, width, height)
else
-- Неактивная вкладка
surface.SetDrawColor(Colors.black_light)
surface.DrawRect(0, 0, width, height)
-- Индикатор непрочитанных сообщений
if (panel:GetUnread()) then
surface.SetDrawColor(ColorAlpha(Color(200, 200, 50), Lerp(panel.unreadAlpha, 0, 120)))
surface.SetTexture(gradient)
surface.DrawTexturedRect(0, 0, width, height - 1)
end
end
-- Разделитель вкладок
surface.SetDrawColor(Colors.darker_green)
surface.DrawRect(width - 1, 0, 1, height)
end
-- Панель табов
function SKIN:PaintChatboxTabs(panel, width, height, alpha)
-- Фон панели табов
surface.SetDrawColor(Colors.black_light)
surface.DrawRect(0, 0, width, height)
-- Градиент вниз
surface.SetDrawColor(Colors.darker_green.r, Colors.darker_green.g, Colors.darker_green.b, 150)
surface.SetTexture(gradient)
surface.DrawTexturedRect(0, height * 0.5, width, height * 0.5)
local tab = panel:GetActiveTab()
if (tab) then
local button = tab:GetButton()
local x, _ = button:GetPos()
-- Линия под активной вкладкой (зелёная)
surface.SetDrawColor(Colors.green)
surface.DrawRect(x, height - 2, button:GetWide(), 2)
-- Обводка панели табов
surface.SetDrawColor(Colors.darker_green)
surface.DrawRect(0, height - 1, x, 1) -- слева
surface.DrawRect(x + button:GetWide(), height - 1, width - x - button:GetWide(), 1) -- справа
end
end
-- Поле ввода текста
function SKIN:PaintChatboxEntry(panel, width, height)
-- Фон поля ввода
surface.SetDrawColor(Colors.darker_green.r, Colors.darker_green.g, Colors.darker_green.b, 100)
surface.DrawRect(0, 0, width, height)
-- Текст
panel:DrawTextEntryText(Colors.white, Colors.green, Colors.white)
-- Обводка
surface.SetDrawColor(Colors.dark_green)
surface.DrawOutlinedRect(0, 0, width, height)
-- Внутренний highlight когда активно
if panel:HasFocus() then
surface.SetDrawColor(Colors.green.r, Colors.green.g, Colors.green.b, 80)
surface.DrawOutlinedRect(1, 1, width - 2, height - 2)
end
end
-- Превью команды
function SKIN:DrawChatboxPreviewBox(x, y, text, color)
color = color or Colors.green
local textWidth, textHeight = surface.GetTextSize(text)
local width, height = textWidth + 8, textHeight + 8
-- Фон
surface.SetDrawColor(Colors.dark_green)
surface.DrawRect(x, y, width, height)
-- Градиент
surface.SetDrawColor(color.r, color.g, color.b, 60)
surface.SetTexture(gradient)
surface.DrawTexturedRect(x, y, width, height)
-- Текст
surface.SetTextColor(Colors.white)
surface.SetTextPos(x + width * 0.5 - textWidth * 0.5, y + height * 0.5 - textHeight * 0.5)
surface.DrawText(text)
-- Обводка
surface.SetDrawColor(Colors.darker_green)
surface.DrawOutlinedRect(x, y, width, height)
return width
end
-- Префикс команды
function SKIN:DrawChatboxPrefixBox(panel, width, height)
local color = panel:GetBackgroundColor() or Colors.green
-- Фон
surface.SetDrawColor(Colors.dark_green)
surface.DrawRect(0, 0, width, height)
-- Градиент
surface.SetDrawColor(color.r, color.g, color.b, 80)
surface.SetTexture(gradient)
surface.DrawTexturedRect(0, 0, width, height)
-- Обводка
surface.SetDrawColor(Colors.darker_green)
surface.DrawOutlinedRect(0, 0, width, height)
end
-- Автодополнение команд
function SKIN:PaintChatboxAutocompleteEntry(panel, width, height)
-- Выделенный фон
if (panel.highlightAlpha > 0) then
surface.SetDrawColor(Colors.dark_green.r, Colors.dark_green.g, Colors.dark_green.b, panel.highlightAlpha * 150)
surface.DrawRect(0, 0, width, height)
-- Градиент выделения
surface.SetDrawColor(Colors.green.r, Colors.green.g, Colors.green.b, panel.highlightAlpha * 60)
surface.SetTexture(gradient)
surface.DrawTexturedRect(0, 0, width, height)
end
-- Разделитель между командами
surface.SetDrawColor(Colors.darker_green.r, Colors.darker_green.g, Colors.darker_green.b, 100)
surface.DrawRect(0, height - 1, width, 1)
end
hook.Add("LoadFonts", "MilitaryRPChatFonts", function()
-- Переопределяем шрифты чата на Montserrat
local scale = ix.option.Get("chatFontScale", 1)
surface.CreateFont("ixChatFont", {
font = "Montserrat",
size = 17 * scale,
weight = 400,
extended = true
})
surface.CreateFont("ixChatFontItalics", {
font = "Montserrat",
size = 17 * scale,
weight = 400,
italic = true,
extended = true
})
end)