This repository was archived by the owner on Mar 27, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathse_chat.lua
More file actions
84 lines (67 loc) · 2.55 KB
/
se_chat.lua
File metadata and controls
84 lines (67 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
local SE_Chat = SimpleExtension.Create("SE_CHAT", 1)
SE_Chat.CHAT = {
NEVER_FADE = 0,
DEFAULT_BEGIN = 25,
DEFAULT_DURATION = 2,
setFadeness = function(begin, duration)
for tabIndex, tabObject in ipairs(CHAT_SYSTEM.primaryContainer.windows) do
tabObject.buffer:SetLineFade(begin, duration)
end
end
}
function SE_Chat:New()
local obj = ZO_Object.New(self)
obj:Initialize({
is_full_resize_enabled = true,
is_always_present = true,
})
obj:controls("Chat", {
{
type = "checkbox",
name = "Enable full resizing",
tooltip = "Allow chat window to be resized to any size.",
getFunc = function() return obj.settings.is_full_resize_enabled end,
setFunc = function(value) obj:toggleFullResize(value) end,
},
{
type = "checkbox",
name = "Always present",
tooltip = "Ensure the chat windows do not fade away.",
getFunc = function() return obj.settings.is_always_present end,
setFunc = function(value) obj:toggleAlwaysPresent(value) end,
},
})
return obj
end
function SE_Chat:Run()
EVENT_MANAGER:RegisterForEvent(self.SE_NAME, EVENT_PLAYER_ACTIVATED, function()
EVENT_MANAGER:UnregisterForEvent(self.SE_NAME, EVENT_PLAYER_ACTIVATED)
self.backupCreateNewChatTab = CHAT_SYSTEM.CreateNewChatTab
self.customCreateNewChatTab = function(instance, ...)
self.backupCreateNewChatTab(instance, ...)
self.CHAT.setFadeness(self.CHAT.NEVER_FADE, self.CHAT.NEVER_FADE)
end
self:toggleAlwaysPresent()
end)
self:toggleFullResize()
end
function SE_Chat:toggleAlwaysPresent(value)
self.settings.is_always_present = (value == nil) or value
if self.settings.is_always_present then
CHAT_SYSTEM.CreateNewChatTab = self.customCreateNewChatTab
self.CHAT.setFadeness(self.CHAT.NEVER_FADE, self.CHAT.NEVER_FADE)
else
CHAT_SYSTEM.CreateNewChatTab = self.backupCreateNewChatTab
self.CHAT.setFadeness(self.CHAT.DEFAULT_BEGIN, self.CHAT.DEFAULT_DURATION)
end
end
function SE_Chat:toggleFullResize(value)
self.settings.is_full_resize_enabled = (value == nil) or value
if self.settings.is_full_resize_enabled then
CHAT_SYSTEM.maxContainerWidth, CHAT_SYSTEM.maxContainerHeight = GuiRoot:GetDimensions()
else
for i = 1, #CHAT_SYSTEM.containers do
CHAT_SYSTEM:ResetContainerPositionAndSize(CHAT_SYSTEM.containers[i])
end
end
end