Skip to content

Commit

Permalink
file stuff ig
Browse files Browse the repository at this point in the history
  • Loading branch information
Lythium4848 committed Mar 16, 2024
1 parent b8ade0e commit b049a42
Show file tree
Hide file tree
Showing 63 changed files with 6,743 additions and 6,582 deletions.
8 changes: 4 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Lua.diagnostics.globals": [
"GM"
]
{
"Lua.diagnostics.globals": [
"GM"
]
}
86 changes: 43 additions & 43 deletions lua/autorun/sh_pulsarui_loader.lua
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
PulsarUI = PulsarUI or {}
PulsarUI.Version = "2.0.0"

function PulsarUI.LoadDirectory(path)
local files, folders = file.Find(path .. "/*", "LUA")

for _, fileName in ipairs(files) do
local filePath = path .. "/" .. fileName

if CLIENT then
include(filePath)
else
if fileName:StartWith("cl_") then
AddCSLuaFile(filePath)
elseif fileName:StartWith("sh_") then
AddCSLuaFile(filePath)
include(filePath)
else
include(filePath)
end
end
end

return files, folders
end

function PulsarUI.LoadDirectoryRecursive(basePath, onLoad)
local _, folders = PulsarUI.LoadDirectory(basePath)

for _, folderName in ipairs(folders) do
PulsarUI.LoadDirectoryRecursive(basePath .. "/" .. folderName)
end

if onLoad and isfunction(onLoad) then
onLoad()
end
end

PulsarUI.LoadDirectoryRecursive("pulsarui")
hook.Run("PulsarUI.FullyLoaded")

if CLIENT then return end
resource.AddWorkshop("2825396224")
PulsarUI = PulsarUI or {}
PulsarUI.Version = "2.0.0"

function PulsarUI.LoadDirectory(path)
local files, folders = file.Find(path .. "/*", "LUA")

for _, fileName in ipairs(files) do
local filePath = path .. "/" .. fileName

if CLIENT then
include(filePath)
else
if fileName:StartWith("cl_") then
AddCSLuaFile(filePath)
elseif fileName:StartWith("sh_") then
AddCSLuaFile(filePath)
include(filePath)
else
include(filePath)
end
end
end

return files, folders
end

function PulsarUI.LoadDirectoryRecursive(basePath, onLoad)
local _, folders = PulsarUI.LoadDirectory(basePath)

for _, folderName in ipairs(folders) do
PulsarUI.LoadDirectoryRecursive(basePath .. "/" .. folderName)
end

if onLoad and isfunction(onLoad) then
onLoad()
end
end

PulsarUI.LoadDirectoryRecursive("pulsarui")
hook.Run("PulsarUI.FullyLoaded")

if CLIENT then return end
resource.AddWorkshop("2825396224")
186 changes: 93 additions & 93 deletions lua/pulsarui/core/cl_fonts.lua
Original file line number Diff line number Diff line change
@@ -1,93 +1,93 @@

PulsarUI.RegisteredFonts = PulsarUI.RegisteredFonts or {}
local registeredFonts = PulsarUI.RegisteredFonts

do
PulsarUI.SharedFonts = PulsarUI.SharedFonts or {}
local sharedFonts = PulsarUI.SharedFonts

function PulsarUI.RegisterFontUnscaled(name, font, size, weight)
weight = weight or 500

local identifier = font .. size .. ":" .. weight

local fontName = "PulsarUI:" .. identifier
registeredFonts[name] = fontName

if sharedFonts[identifier] then return end
sharedFonts[identifier] = true

surface.CreateFont(fontName, {
font = font,
size = size,
weight = weight,
extended = true,
antialias = true
})
end
end

do
PulsarUI.ScaledFonts = PulsarUI.ScaledFonts or {}
local scaledFonts = PulsarUI.ScaledFonts

function PulsarUI.RegisterFont(name, font, size, weight)
scaledFonts[name] = {
font = font,
size = size,
weight = weight
}

PulsarUI.RegisterFontUnscaled(name, font, PulsarUI.Scale(size), weight)
end

function PulsarUI.GenerateFont(size, weight, font, name)
weight = weight or 700
PulsarUI.Fonts = PulsarUI.Fonts or {}
local fontName = name or ("PulsarUI.Font.Size" .. size)
font = font or "Rubik"

if !PulsarUI.Fonts[fontName] or PulsarUI.Fonts[fontName].size != size or PulsarUI.Fonts[fontName].weight != weight then
PulsarUI.Fonts[fontName] = {
name = fontName,
size = size,
weight = weight
}
PulsarUI.RegisterFont(fontName, font, size, weight)
return fontName
end

return fontName
end

hook.Add("OnScreenSizeChanged", "PulsarUI.ReRegisterFonts", function()
for k,v in pairs(scaledFonts) do
PulsarUI.RegisterFont(k, v.font, v.size, v.weight)
end
end)
end

do
local setFont = surface.SetFont
local function setPixelFont(font)
local pixelFont = registeredFonts[font]
if pixelFont then
setFont(pixelFont)
return
end

setFont(font)
end

PulsarUI.SetFont = setPixelFont

local getTextSize = surface.GetTextSize
function PulsarUI.GetTextSize(text, font)
if font then setPixelFont(font) end
return getTextSize(text)
end

function PulsarUI.GetRealFont(font)
return registeredFonts[font]
end
end

PulsarUI.RegisteredFonts = PulsarUI.RegisteredFonts or {}
local registeredFonts = PulsarUI.RegisteredFonts

do
PulsarUI.SharedFonts = PulsarUI.SharedFonts or {}
local sharedFonts = PulsarUI.SharedFonts

function PulsarUI.RegisterFontUnscaled(name, font, size, weight)
weight = weight or 500

local identifier = font .. size .. ":" .. weight

local fontName = "PulsarUI:" .. identifier
registeredFonts[name] = fontName

if sharedFonts[identifier] then return end
sharedFonts[identifier] = true

surface.CreateFont(fontName, {
font = font,
size = size,
weight = weight,
extended = true,
antialias = true
})
end
end

do
PulsarUI.ScaledFonts = PulsarUI.ScaledFonts or {}
local scaledFonts = PulsarUI.ScaledFonts

function PulsarUI.RegisterFont(name, font, size, weight)
scaledFonts[name] = {
font = font,
size = size,
weight = weight
}

PulsarUI.RegisterFontUnscaled(name, font, PulsarUI.Scale(size), weight)
end

function PulsarUI.GenerateFont(size, weight, font, name)
weight = weight or 700
PulsarUI.Fonts = PulsarUI.Fonts or {}
local fontName = name or ("PulsarUI.Font.Size" .. size)
font = font or "Rubik"

if !PulsarUI.Fonts[fontName] or PulsarUI.Fonts[fontName].size ~= size or PulsarUI.Fonts[fontName].weight ~= weight then
PulsarUI.Fonts[fontName] = {
name = fontName,
size = size,
weight = weight
}
PulsarUI.RegisterFont(fontName, font, size, weight)
return fontName
end

return fontName
end

hook.Add("OnScreenSizeChanged", "PulsarUI.ReRegisterFonts", function()
for k,v in pairs(scaledFonts) do
PulsarUI.RegisterFont(k, v.font, v.size, v.weight)
end
end)
end

do
local setFont = surface.SetFont
local function setPixelFont(font)
local pixelFont = registeredFonts[font]
if pixelFont then
setFont(pixelFont)
return
end

setFont(font)
end

PulsarUI.SetFont = setPixelFont

local getTextSize = surface.GetTextSize
function PulsarUI.GetTextSize(text, font)
if font then setPixelFont(font) end
return getTextSize(text)
end

function PulsarUI.GetRealFont(font)
return registeredFonts[font]
end
end
Loading

0 comments on commit b049a42

Please sign in to comment.