1
0
mirror of https://github.com/Earu/EasyChat.git synced 2025-03-04 03:13:20 -05:00

pick up cefcodecfix on linux

This commit is contained in:
Ryan 2024-09-28 22:29:03 +02:00
parent 4dd4e13033
commit 5e2674e5ab
4 changed files with 79 additions and 4 deletions

View File

@ -9,6 +9,7 @@ AddCSLuaFile("easychat/autoloader.lua")
AddCSLuaFile("easychat/engine_chat_hack.lua") AddCSLuaFile("easychat/engine_chat_hack.lua")
AddCSLuaFile("easychat/client/font_extensions.lua") AddCSLuaFile("easychat/client/font_extensions.lua")
AddCSLuaFile("easychat/client/cef_detection.lua")
AddCSLuaFile("easychat/client/blur_panel.lua") AddCSLuaFile("easychat/client/blur_panel.lua")
AddCSLuaFile("easychat/client/translator.lua") AddCSLuaFile("easychat/client/translator.lua")
AddCSLuaFile("easychat/client/expressions.lua") AddCSLuaFile("easychat/client/expressions.lua")

View File

@ -0,0 +1,72 @@
--[[
GModCEFCodecFix detection code example
Copyright 2024, Solstice Game Studios (www.solsticegamestudios.com)
LICENSE: GNU General Public License v3.0
Purpose: Detects if CEFCodecFix has been applied successfully on a GMod client.
Contact:
Discord: https://www.solsticegamestudios.com/discord/
Email: contact@solsticegamestudios.com
]]
-- CEF is only on the Client
if not CLIENT then return end
-- Use these global variables for detection elsewhere in your Lua code
CEFCodecFixChecked = false
CEFCodecFixAvailable = false
-- We hook PreRender for reliability
hook.Add("PreRender", "CEFCodecFixCheck", function()
hook.Remove("PreRender", "CEFCodecFixCheck")
print("Querying CEF Codec Support...")
-- If the client isn't on the x86-64 beta, it's impossible for them to have CEFCodecFix
if BRANCH ~= "x86-64" then
CEFCodecFixAvailable = false
CEFCodecFixChecked = true
print("CEF does not have CEFCodecFix")
return
end
local cefTestPanel = vgui.Create("DHTML", nil, "CEFCodecFixCheck")
cefTestPanel:SetSize(32, 32)
cefTestPanel:SetKeyboardInputEnabled(false)
cefTestPanel:SetMouseInputEnabled(false)
function cefTestPanel:Paint()
return true -- We don't want this to draw normally
end
function cefTestPanel:RemoveWhileHidden()
-- HACK: The panel apparently draws for a frame once Remove() is called, so we're disabling visibility beforehand
-- NOTE: Don't use SetVisible(false) to replace the Paint override! Panel Think/Javascript won't run without panel "visibility"
self:SetVisible(false)
self:Remove()
end
cefTestPanel:SetHTML("")
function cefTestPanel:OnDocumentReady()
if not CEFCodecFixChecked then
self:AddFunction("gmod", "getCodecStatus", function(codecStatus)
CEFCodecFixAvailable = codecStatus
CEFCodecFixChecked = true
if CEFCodecFixAvailable then
print("CEF has CEFCodecFix")
else
print("CEF does not have CEFCodecFix")
end
self:RemoveWhileHidden()
end)
-- This is what actually does the detection, by seeing if the web framework is capable of playing H.264 (a proprietary video codec)
self:QueueJavascript([[gmod.getCodecStatus(document.createElement("video").canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"') == "probably")]])
elseif IsValid(self) then
self:RemoveWhileHidden()
end
end
end)

View File

@ -635,11 +635,13 @@ if CLIENT then
chat.AddText(COLOR_RED, "[WARN] " .. msg) chat.AddText(COLOR_RED, "[WARN] " .. msg)
end end
-- TODO: Figure out how to check keyboard IME
function EasyChat.CanUseCEFFeatures() function EasyChat.CanUseCEFFeatures()
if EC_FORCE_ALLOW_CEF:GetBool() then return true end if EC_FORCE_ALLOW_CEF:GetBool() then return true end
if not system.IsWindows() and not system.IsOSX() then return false end -- cef is awfully broken on linux / mac
if CEFCodecFixChecked and CEFCodecFixAvailable then return true end -- if someone has the cefcodexfix we're fine
if not system.IsWindows() and not system.IsOSX() then return false end -- cef is awfully broken on linux
if BRANCH == "x86-64" or BRANCH == "chromium" then return true end -- chromium also exists in x86 and on the chromium branch if BRANCH == "x86-64" or BRANCH == "chromium" then return true end -- chromium also exists in x86 and on the chromium branch
return jit.arch == "x64" -- when x64 and chromium are finally pushed to stable return jit.arch == "x64" -- when x64 and chromium are finally pushed to stable
end end

View File

@ -41,7 +41,7 @@ else
timer.Simple(retries * 5, function() timer.Simple(retries * 5, function()
fetch_lookup(retries + 1) fetch_lookup(retries + 1)
end) end)
return return
end end
@ -59,7 +59,7 @@ else
end) end)
end, end,
} }
local success, err = pcall(HTTP, http_params) local success, err = pcall(HTTP, http_params)
if not success or (success and err ~= true) then if not success or (success and err ~= true) then
fail("Could not fetch transliteration lookup: " .. (err or "unsuccessfull")) fail("Could not fetch transliteration lookup: " .. (err or "unsuccessfull"))