diff --git a/source/gamemodes/prophuntextended/gamemode/client/fontmanager.lua b/source/gamemodes/prophuntextended/gamemode/client/fontmanager.lua deleted file mode 100644 index 8867c00..0000000 --- a/source/gamemodes/prophuntextended/gamemode/client/fontmanager.lua +++ /dev/null @@ -1,55 +0,0 @@ ---[[ - The MIT License (MIT) - - Copyright (c) 2015-2018 Xaymar - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. ---]] - -local FontManagerMeta = {} -FontManagerMeta.__index = FontManagerMeta - --- Global Constructor -function FontManager() - local obj = {} - obj.__index = obj - setmetatable(obj, FontManagerMeta) - obj:__construct() - return obj -end - --- Constructor -function FontManagerMeta:__construct() - self.fonts = {} -end - -function FontManagerMeta:Exists(name) - return (self.fonts[name] != nil) -end - -function FontManagerMeta:Request(name, settings) - if (self.fonts[name] != nil) then - print("[Prop Hunt Font Manager] Request for font '"..name.."' received and cached.") - return name - end - print("[Prop Hunt Font Manager] Request for font '"..name.."' received and fulfilled.") - self.fonts[name] = surface.CreateFont(name, settings) - return name -end - diff --git a/source/gamemodes/prophuntextended/gamemode/vgui/fontmanager.lua b/source/gamemodes/prophuntextended/gamemode/vgui/fontmanager.lua new file mode 100644 index 0000000..f76a270 --- /dev/null +++ b/source/gamemodes/prophuntextended/gamemode/vgui/fontmanager.lua @@ -0,0 +1,103 @@ +--[[ + The MIT License (MIT) + + Copyright (c) 2015-2018 Xaymar + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +--]] + +local FontManagerMeta = {} +FontManagerMeta.__index = FontManagerMeta + +-- Global Constructor +function FontManager() + local obj = {} + obj.__index = obj + setmetatable(obj, FontManagerMeta) + obj:__construct() + return obj +end + +-- Constructor +function FontManagerMeta:__construct() + self.fonts = {} +end + +function FontManagerMeta:Exists(name) + return (self.fonts[name] != nil) +end + +function FontManagerMeta:CreateFontData(settings) + local base = {} + base.font = "Roboto" + base.extended = true + base.size = 13 + base.weight = 500 + base.blursize = 0 + base.scanlines = 0 + base.antialias = true + base.underline = false + base.italic = false + base.strikeout = false + base.symbol = false + base.rotary = false + base.shadow = false + base.additive = false + base.outline = false + local final = table.Merge(base, settings) + return final +end + +function FontManagerMeta:CreateFont(settings) + local final = self:CreateFontData(settings) + local name = self:ToName(final) + return self:Request(name, final) +end + +function FontManagerMeta:ToName(settings) + local name = settings.font + name = name .. "[S" .. settings.size + name = name .. "W" .. settings.weight + if (settings.blursize > 0) then name = name .. "B" .. settings.blursize end + if (settings.scanlines > 0) then name = name .. "L" .. settings.scanlines end + if (settings.antialias) then name = name .. "A" end + if (settings.extended) then name = name .. "E" end + if (settings.underline) then name = name .. "U" end + if (settings.italic) then name = name .. "I" end + if (settings.strikeout) then name = name .. "-" end + if (settings.shadow) then name = name .. "S" end + if (settings.outline) then name = name .. "O" end + if (settings.additive) then name = name .. "+" end + if (settings.rotary) then name = name .. "R" end + if (settings.symbol) then name = name .. "#" end + name = name .. "]" + return name +end + +function FontManagerMeta:Request(name, settings) + if self:Exists(name) then + --print("[Prop Hunt Font Manager] Request for font '"..name.."' received and cached.") + return name + end + print("[Font Manager] Creating new Font '"..name.."'...") + self.fonts[name] = surface.CreateFont(name, settings) + return name +end + +_G["FontManager"] = FontManager() diff --git a/source/gamemodes/prophuntextended/gamemode/client/uimanager.lua b/source/gamemodes/prophuntextended/gamemode/vgui/uimanager.lua similarity index 95% rename from source/gamemodes/prophuntextended/gamemode/client/uimanager.lua rename to source/gamemodes/prophuntextended/gamemode/vgui/uimanager.lua index e478d56..38ead8d 100644 --- a/source/gamemodes/prophuntextended/gamemode/client/uimanager.lua +++ b/source/gamemodes/prophuntextended/gamemode/vgui/uimanager.lua @@ -134,12 +134,12 @@ function UIManagerMeta:InitializeDPI() self.dpi = {} -- Calculate DPI using these base sizes. self.dpi.base = {} - self.dpi.base.width = 1280 - self.dpi.base.height = 720 + self.dpi.base.width = 1920 + self.dpi.base.height = 1080 -- Limits self.dpi.limits = {} - self.dpi.limits.min = 25 - self.dpi.limits.max = 400 + self.dpi.limits.min = 0.25 + self.dpi.limits.max = 4.00 -- Final Value self.dpi.override = nil self.dpi.calculated = self:CalculateDPI() @@ -169,11 +169,10 @@ function UIManagerMeta:GetDPIScale() end function UIManagerMeta:SetDPIScale(newDPIScale) - if (newDPIScale == nil) then - self.dpi.override = nil + self.dpi.override = newDPIScale + if (self.dpi.override == nil) then self:Call("UpdateDPI", self.dpi.calculated) else - self.dpi.override = newDPIScale if (self.dpi.override < self.dpi.limits.min) then self.dpi.override = self.dpi.limits.min end @@ -184,4 +183,4 @@ function UIManagerMeta:SetDPIScale(newDPIScale) end end - +_G["UIManager"] = UIManager()