forked from TomDotBat/pixel-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8ade0e
commit b049a42
Showing
63 changed files
with
6,743 additions
and
6,582 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"Lua.diagnostics.globals": [ | ||
"GM" | ||
] | ||
{ | ||
"Lua.diagnostics.globals": [ | ||
"GM" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.