Initial commit

This commit is contained in:
pavetr
2026-03-15 14:54:49 +03:00
commit 64f8029c06
4027 changed files with 254888 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
local file, Mat, Fetch, find = file, Material, http.Fetch, string.find
local errorMat = Mat('error')
local WebImageCache = {}
--[[
Функция для скачивания материала по ссылке и его кэшированного использования
]]--
function http.DownloadMaterial(url, path, callback, retry_count)
if WebImageCache[url] then
return callback(WebImageCache[url])
end
local dataPath = 'data/' .. path
if file.Exists(path, 'DATA') then
WebImageCache[url] = Mat(dataPath, 'noclamp mips')
callback(WebImageCache[url])
else
Fetch(url, function(img)
if !img or find(img, '<!DOCTYPE HTML>', 1, true) then
return callback(errorMat)
end
file.Write(path, img)
WebImageCache[url] = Mat(dataPath, 'noclamp mips')
callback(WebImageCache[url])
end, function()
if retry_count and retry_count > 0 then
retry_count = retry_count - 1
http.DownloadMaterial(url, path, callback, retry_count)
else
callback(errorMat)
end
end)
end
end

View File

@@ -0,0 +1,25 @@
if SERVER then
util.AddNetworkString('Mantle-Notify')
--[[
Функция для выведения в чат текста.
Можно выводить определённой цели информацию, либо всем, указав вместо pl - true
]]--
function Mantle.notify(pl, header_color, header, text)
net.Start('Mantle-Notify')
net.WriteString(header)
net.WriteColor(header_color)
net.WriteString(text)
if pl == true then net.Broadcast() else net.Send(pl) end
end
else
net.Receive('Mantle-Notify', function()
local headerText = net.ReadString()
local headerColor = net.ReadColor()
local headerColorDop = Color(headerColor.r + 10, headerColor.g + 10, headerColor.b + 10)
local text = net.ReadString()
chat.AddText(headerColorDop, '[', headerColor, headerText, headerColorDop, '] ', color_white, text)
chat.PlaySound()
end)
end

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,115 @@
local math_sin = math.sin
local math_cos = math.cos
local math_rad = math.rad
local math_ceil = math.ceil
local function CreateBShadows()
BShadows = {}
local resStr = Mantle.func.sw .. Mantle.func.sh
BShadows.RenderTarget = GetRenderTarget('BShadows_original_' .. resStr, Mantle.func.sw, Mantle.func.sh)
BShadows.RenderTarget2 = GetRenderTarget('BShadows_shadow_' .. resStr, Mantle.func.sw, Mantle.func.sh)
BShadows.ShadowMaterial = CreateMaterial('BShadows', 'UnlitGeneric', {
['$translucent'] = 1,
['$vertexalpha'] = 1,
['alpha'] = 1
})
BShadows.ShadowMaterialGrayscale = CreateMaterial('BShadows_grayscale', 'UnlitGeneric', {
['$translucent'] = 1,
['$vertexalpha'] = 1,
['$alpha'] = 1,
['$color'] = '0 0 0',
['$color2'] = '0 0 0'
})
BShadows.BeginShadow = function()
render.PushRenderTarget(BShadows.RenderTarget)
render.OverrideAlphaWriteEnable(true, true)
render.Clear(0, 0, 0, 0)
render.OverrideAlphaWriteEnable(false, false)
cam.Start2D()
end
BShadows.EndShadow = function(intensity, spread, blur, opacity, direction, distance, bool_shadow_only)
opacity = opacity or 255
direction = direction or 0
distance = distance or 0
bool_shadow_only = bool_shadow_only or false
render.CopyRenderTargetToTexture(BShadows.RenderTarget2)
if blur > 0 then
render.OverrideAlphaWriteEnable(true, true)
render.BlurRenderTarget(BShadows.RenderTarget2, spread, spread, blur)
render.OverrideAlphaWriteEnable(false, false)
end
render.PopRenderTarget()
BShadows.ShadowMaterial:SetTexture('$basetexture', BShadows.RenderTarget)
BShadows.ShadowMaterialGrayscale:SetTexture('$basetexture', BShadows.RenderTarget2)
local xOffset = math_sin(math_rad(direction)) * distance
local yOffset = math_cos(math_rad(direction)) * distance
BShadows.ShadowMaterialGrayscale:SetFloat('$alpha', opacity / 255)
render.SetMaterial(BShadows.ShadowMaterialGrayscale)
for i = 1, math_ceil(intensity) do
render.DrawScreenQuadEx(xOffset, yOffset, Mantle.func.sw, Mantle.func.sh)
end
if !bool_shadow_only then
BShadows.ShadowMaterial:SetTexture('$basetexture', BShadows.RenderTarget)
render.SetMaterial(BShadows.ShadowMaterial)
render.DrawScreenQuad()
end
cam.End2D()
end
BShadows.DrawShadowTexture = function(texture, intensity, spread, blur, opacity, direction, distance, bool_shadow_only)
opacity = opacity or 255
direction = direction or 0
distance = distance or 0
bool_shadow_only = bool_shadow_only or false
render.CopyTexture(texture, BShadows.RenderTarget2)
if blur > 0 then
render.PushRenderTarget(BShadows.RenderTarget2)
render.OverrideAlphaWriteEnable(true, true)
render.BlurRenderTarget(BShadows.RenderTarget2, spread, spread, blur)
render.OverrideAlphaWriteEnable(false, false)
render.PopRenderTarget()
end
BShadows.ShadowMaterialGrayscale:SetTexture('$basetexture', BShadows.RenderTarget2)
local xOffset = math_sin(math_rad(direction)) * distance
local yOffset = math_cos(math_rad(direction)) * distance
BShadows.ShadowMaterialGrayscale:SetFloat('$alpha', opacity / 255)
render.SetMaterial(BShadows.ShadowMaterialGrayscale)
for i = 1, math_ceil(intensity) do
render.DrawScreenQuadEx(xOffset, yOffset, Mantle.func.sw, Mantle.func.sh)
end
if !bool_shadow_only then
BShadows.ShadowMaterial:SetTexture('$basetexture', texture)
render.SetMaterial(BShadows.ShadowMaterial)
render.DrawScreenQuad()
end
end
end
CreateBShadows()
hook.Add('OnScreenSizeChanged', 'Mantle.Shadows', function()
CreateBShadows()
end)

View File

@@ -0,0 +1,23 @@
if utf8 == nil then
utf8 = {
charpattern = '[%z\x01-\x7F\xC2-\xF4][\x80-\xBF]*'
}
end
local uc_lc = {['А']='а',['Б']='б',['В']='в',['Г']='г',['Д']='д',['Е']='е',['Ё']='ё',['Ж']='ж',['З']='з',['И']='и',['Й']='й',['К']='к',['Л']='л',['М']='м',['Н']='н',['О']='о',['П']='п',['Р']='р',['С']='с',['Т']='т',['У']='у',['Ф']='ф',['Х']='х',['Ц']='ц',['Ч']='ч',['Ш']='ш',['Щ']='щ',['Ъ']='ъ',['Ы']='ы',['Ь']='ь',['Э']='э',['Ю']='ю',['Я']='я'}
local lc_uc = {}
for uc, lc in pairs(uc_lc) do
lc_uc[lc] = uc
end
setmetatable(uc_lc, {__index = function(_, char) return char:lower() end})
setmetatable(lc_uc, {__index = function(_, char) return char:upper() end})
function utf8.lower(text)
return text:gsub(utf8.charpattern, uc_lc)
end
function utf8.upper(text)
return text:gsub(utf8.charpattern, lc_uc)
end