Attempt to rewrite patch_createfont.lua so it's compilable.
parent
2cf2fbe95a
commit
d463542883
|
@ -1,48 +1,47 @@
|
||||||
/**
|
--
|
||||||
* Disguiser SWEP - Lets you disguise as any prop on a map.
|
-- Disguiser SWEP - Lets you disguise as any prop on a map.
|
||||||
*
|
--
|
||||||
* File:
|
-- File:
|
||||||
* patch_createfont.lua
|
-- patch_createfont.lua
|
||||||
*
|
--
|
||||||
* Purpose:
|
-- Purpose:
|
||||||
* This code will allow any font to be checked for existence. I hope it works
|
-- This code will allow any font to be checked for existence. I hope it works
|
||||||
* as it is only a function patch which should be loaded right at the beginning.
|
-- as it is only a function patch which should be loaded right at the beginning.
|
||||||
* Can't guarantee that it loads right at the beginning though.
|
-- Can't guarantee that it loads right at the beginning though.
|
||||||
*
|
--
|
||||||
* Copyright (C) 2013 Carl Kittelberger (Icedream)
|
-- Copyright (C) 2013 Carl Kittelberger (Icedream)
|
||||||
*
|
--
|
||||||
* This program is free software: you can redistribute it and/or modify
|
-- This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
-- it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
-- published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
-- License, or (at your option) any later version.
|
||||||
*
|
--
|
||||||
* This program is distributed in the hope that it will be useful,
|
-- This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
-- GNU Affero General Public License for more details.
|
||||||
*
|
--
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
-- You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
|
||||||
|
|
||||||
print("[Disguiser] Loading compatibility layer for surface.CreateFont...")
|
print("[Disguiser] Loading compatibility layer for surface.CreateFont...")
|
||||||
|
|
||||||
local registered_fonts = {}
|
local registered_fonts = {}
|
||||||
|
|
||||||
// Function already patched by us?
|
-- Function already patched by us?
|
||||||
if !!surface.__createFont then
|
if not surface.__createFont == nil then
|
||||||
MsgC(Color(255, 255, 0), "[Fontpatch] Can't patch surface.CreateFont, already patched. Skipping patch.\n")
|
MsgC(Color(255, 255, 0), "[Fontpatch] Can't patch surface.CreateFont, already patched. Skipping patch.\n")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
// Original function
|
-- Original function
|
||||||
surface.__createFont = surface.CreateFont
|
surface.__createFont = surface.CreateFont
|
||||||
|
|
||||||
// Patch function
|
-- Patch function
|
||||||
function surface.CreateFont(name, data)
|
function surface.CreateFont(name, data)
|
||||||
if !name || !data then return false end
|
if not name or not data then return false end
|
||||||
|
|
||||||
if !!registered_fonts[name] then
|
if registered_fonts[name] then
|
||||||
MsgN("[Fontpatch] Skipping font " .. name .. ", already registered")
|
MsgN("[Fontpatch] Skipping font " .. name .. ", already registered")
|
||||||
else
|
else
|
||||||
MsgN("[Fontpatch] Registering font " .. name .. "...")
|
MsgN("[Fontpatch] Registering font " .. name .. "...")
|
||||||
|
@ -51,7 +50,7 @@ function surface.CreateFont(name, data)
|
||||||
surface.__createFont(name, data)
|
surface.__createFont(name, data)
|
||||||
end
|
end
|
||||||
|
|
||||||
// Check if a font exists
|
-- Check if a font exists
|
||||||
function surface.FontExists(name)
|
function surface.FontExists(name)
|
||||||
return !!registered_fonts[name] // I love how all those peeps on the internet still don't use the !! thingie
|
return not not registered_fonts[name]
|
||||||
end
|
end
|
Loading…
Reference in New Issue