mirror of
https://github.com/Earu/EasyChat.git
synced 2025-03-04 03:13:20 -05:00
add convar to control if images should be blured in the chatbox [ci skip]
This commit is contained in:
parent
80e893deac
commit
85246fef53
@ -52,6 +52,7 @@ local EC_LEGACY_ENTRY = get_cvar("easychat_legacy_entry")
|
||||
local EC_LEGACY_TEXT = get_cvar("easychat_legacy_text")
|
||||
local EC_MODERN_TEXT_HISTORY_LIMIT = get_cvar("easychat_modern_text_history_limit")
|
||||
local EC_NON_QWERTY = get_cvar("easychat_non_qwerty")
|
||||
local EC_BLUR_IMAGES = get_cvar("easychat_blur_images")
|
||||
|
||||
-- chathud
|
||||
local EC_HUD_FOLLOW = get_cvar("easychat_hud_follow")
|
||||
@ -376,6 +377,7 @@ local function create_default_settings()
|
||||
[EC_IMAGES] = "Display images",
|
||||
[EC_PEEK_COMPLETION] = "Peek at the possible chat completion",
|
||||
[EC_NON_QWERTY] = "Specify whether you have a QWERTY keyboard or not",
|
||||
[EC_BLUR_IMAGES] = "Blur images in the chatbox",
|
||||
})
|
||||
|
||||
settings:AddSpacer(category_name)
|
||||
|
@ -56,13 +56,13 @@ function PANEL:Init()
|
||||
height: 95%;
|
||||
}
|
||||
|
||||
img {
|
||||
.blur {
|
||||
filter: blur(20px);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
img:hover {
|
||||
filter: none;
|
||||
img {
|
||||
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
<pre id="main"></pre>
|
||||
@ -128,10 +128,7 @@ function PANEL:Init()
|
||||
}
|
||||
});
|
||||
|
||||
let span = null;
|
||||
let img = null;
|
||||
let isAtBottom = false;
|
||||
|
||||
function atBottom() {
|
||||
if (BODY.scrollTop === 0) return true;
|
||||
|
||||
@ -204,15 +201,15 @@ function PANEL:AppendText(text)
|
||||
|
||||
local limit = GetConVar("easychat_modern_text_history_limit"):GetInt() * AVERAGE_AMOUNT_OF_ELEMENTS_PER_LINE
|
||||
local css_color = ("rgb(%d,%d,%d)"):format(self.CurrentColor.r, self.CurrentColor.g, self.CurrentColor.b)
|
||||
local js = (self.ClickableTextValue and [[
|
||||
span = document.createElement("span");
|
||||
local js = (self.ClickableTextValue and [[{
|
||||
let span = document.createElement("span");
|
||||
span.onclick = () => RichTextX.OnClick(`]] .. self.ClickableTextValue .. [[`);
|
||||
span.onmouseenter = () => RichTextX.OnTextHover(`]] .. self.ClickableTextValue .. [[`, true);
|
||||
span.onmouseleave = () => RichTextX.OnTextHover(`]] .. self.ClickableTextValue .. [[`, false);
|
||||
span.clickableText = true;
|
||||
span.style.cursor = "pointer";
|
||||
span.style.color = `]] .. css_color .. [[`;
|
||||
]] or [[
|
||||
]] or [[{
|
||||
span = document.createElement("span");
|
||||
span.style.color = `]] .. css_color .. [[`;
|
||||
]]) .. [[
|
||||
@ -227,7 +224,7 @@ function PANEL:AppendText(text)
|
||||
if (isAtBottom) {
|
||||
window.scrollTo(0, BODY.scrollHeight);
|
||||
}
|
||||
]]
|
||||
}]]
|
||||
|
||||
self:QueueJavascript(js)
|
||||
end
|
||||
@ -236,18 +233,22 @@ function PANEL:AppendImageURL(url)
|
||||
url = url:JavascriptSafe()
|
||||
|
||||
local limit = GetConVar("easychat_modern_text_history_limit"):GetInt() * AVERAGE_AMOUNT_OF_ELEMENTS_PER_LINE
|
||||
self:QueueJavascript([[
|
||||
imgContainer = document.createElement("div");
|
||||
self:QueueJavascript([[{
|
||||
let imgContainer = document.createElement("div");
|
||||
imgContainer.style.overflow = "hidden";
|
||||
imgContainer.style.display = "inline-block";
|
||||
|
||||
img = document.createElement("img");
|
||||
let img = document.createElement("img");
|
||||
img.onclick = () => RichTextX.OnClick(`]] .. url .. [[`);
|
||||
img.style.cursor = "pointer";
|
||||
img.src = `]] .. url .. [[`;
|
||||
img.style.maxWidth = `80%`;
|
||||
img.style.maxHeight = `300px`;
|
||||
img.onhover = () =>
|
||||
if (]] .. (GetConVar("easychat_blur_images"):GetBool() and "true" or "false") .. [[) {
|
||||
img.classList.add('blur');
|
||||
img.onmouseover = () => img.classList.remove('blur');
|
||||
img.onmouseout = () => img.classList.add('blur');
|
||||
}
|
||||
|
||||
isAtBottom = atBottom();
|
||||
RICHTEXT.appendChild(document.createElement("br"));
|
||||
@ -262,7 +263,7 @@ function PANEL:AppendImageURL(url)
|
||||
if (isAtBottom) {
|
||||
window.scrollTo(0, BODY.scrollHeight);
|
||||
}
|
||||
]])
|
||||
}]])
|
||||
end
|
||||
|
||||
function PANEL:InsertColorChange(r, g, b)
|
||||
|
@ -398,6 +398,7 @@ if CLIENT then
|
||||
local EC_FORCE_ALLOW_CEF = CreateConVar("easychat_force_allow_cef", "0", FCVAR_ARCHIVE, "Allow usage of CEF features on linux systems")
|
||||
local _ = CreateConVar("easychat_modern_text_history_limit", "-1", FCVAR_ARCHIVE, "Limits how many messages are shown in the modern chat output")
|
||||
local _ = CreateConVar("easychat_non_qwerty", "0", FCVAR_ARCHIVE, "Lets you tell EasyChat that you keyboard layout is not qwerty")
|
||||
local _ = CreateConVar("easychat_blur_images", "1", FCVAR_ARCHIVE, "Blur images in the chatbox")
|
||||
|
||||
-- chathud
|
||||
local _ = CreateConVar("easychat_hud_smooth", "1", FCVAR_ARCHIVE, "Enables chat smoothing")
|
||||
|
Loading…
Reference in New Issue
Block a user