public
anonymous / ChannelSticky.lua
Created

Prat ChannelSticky.lua working for 5.1

  • Download Gist
ChannelSticky.lua
Lua
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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504
---------------------------------------------------------------------------------
--
-- Prat - A framework for World of Warcraft chat mods
--
-- Copyright (C) 2006-2011 Prat Development Team
--
-- This program is free software; you can redistribute it and/or
-- modify it under the terms of the GNU General Public License
-- as published by the Free Software Foundation; either version 2
-- of the License, or (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to:
--
-- Free Software Foundation, Inc.,
-- 51 Franklin Street, Fifth Floor,
-- Boston, MA 02110-1301, USA.
--
--
-------------------------------------------------------------------------------
 
 
 
 
 
Prat:AddModuleToLoad(function()
 
local PRAT_MODULE = Prat:RequestModuleName("ChannelSticky")
 
if PRAT_MODULE == nil then
return
end
 
local L = Prat:GetLocalizer({})
 
--[===[@debug@
L:AddLocale("enUS", {
["ChannelSticky"] = true,
["Chat channel sticky options."] = true,
["ChatType"] = true,
["Per chat type options."] = true,
["Channel"] = true,
["Sticky %s"] = true,
["Toggles sticky on and off for %s."] = true,
["smartgroup_name"] = "Smart Groups",
["smartgroup_desc"] = "Adds a /gr command which automatically picks the correct type of chat, RAID, PARTY, or BATTLEGROUND",
["Sticky Per Chat Frame"] = true,
["Toggle remembering the chat type last used per chat frame."] = true,
})
--@end-debug@]===]
 
-- These Localizations are auto-generated. To help with localization
-- please go to http://www.wowace.com/projects/prat-3-0/localization/
 
 
--@non-debug@
L:AddLocale("enUS",
{
Channel = true,
ChannelSticky = true,
["Chat channel sticky options."] = true,
ChatType = true,
["Per chat type options."] = true,
["Sticky %s"] = true,
["Sticky Per Chat Frame"] = true,
["Toggle remembering the chat type last used per chat frame."] = true,
["Toggles sticky on and off for %s."] = true,
smartgroup_desc = "Adds a /gr command which automatically picks the correct type of chat, RAID, PARTY, or BATTLEGROUND",
smartgroup_name = "Smart Groups",
}
 
)
L:AddLocale("frFR",
{
-- Channel = "",
-- ChannelSticky = "",
-- ["Chat channel sticky options."] = "",
-- ChatType = "",
-- ["Per chat type options."] = "",
-- ["Sticky %s"] = "",
-- ["Sticky Per Chat Frame"] = "",
-- ["Toggle remembering the chat type last used per chat frame."] = "",
-- ["Toggles sticky on and off for %s."] = "",
smartgroup_desc = "Ajouter une commande /gr qui sélectionne automatiquement le bon type de chat : raid, groupe, champ de bataille",
smartgroup_name = "Groupes intelligents",
}
 
)
L:AddLocale("deDE",
{
Channel = "Kanal",
ChannelSticky = true,
["Chat channel sticky options."] = "\"Sticky\"-Optionen für Chat-Kanal.",
ChatType = true,
["Per chat type options."] = "Optionen nach Chat-Type.",
["Sticky %s"] = "\"Sticky\" %s",
["Sticky Per Chat Frame"] = "\"Sticky\" nach Chat-Rahmen",
["Toggle remembering the chat type last used per chat frame."] = "Das Merken des Chat-Typs, der zuletzt im Chat-Rahmen aktiviert war, umschalten.",
["Toggles sticky on and off for %s."] = "\"Sticky\" ein- und ausschalten für %s.",
smartgroup_desc = "Fügt einen Befehl /gr hinzu, der automatisch den richtigen Chat-Typ aufnimmt - RAID, PARTY, oder BATTLEGROUND",
smartgroup_name = "Intelligente Gruppen",
}
 
)
L:AddLocale("koKR",
{
Channel = "채널",
ChannelSticky = "채널고정",
["Chat channel sticky options."] = "채팅 채널 고정 옵션.",
-- ChatType = "",
-- ["Per chat type options."] = "",
["Sticky %s"] = "%s 고정",
["Sticky Per Chat Frame"] = "채팅창 별 고정",
-- ["Toggle remembering the chat type last used per chat frame."] = "",
["Toggles sticky on and off for %s."] = "입력고정 켜거나 끄기 %s.",
smartgroup_desc = "자동으로 유효한 채팅 타입을 선택하도록 /gr 명령어를 추가합니다. (공격대, 파티 또는 전장)",
smartgroup_name = "스마트 그룹",
}
 
)
L:AddLocale("esMX",
{
-- Channel = "",
-- ChannelSticky = "",
-- ["Chat channel sticky options."] = "",
-- ChatType = "",
-- ["Per chat type options."] = "",
-- ["Sticky %s"] = "",
-- ["Sticky Per Chat Frame"] = "",
-- ["Toggle remembering the chat type last used per chat frame."] = "",
-- ["Toggles sticky on and off for %s."] = "",
-- smartgroup_desc = "",
-- smartgroup_name = "",
}
 
)
L:AddLocale("ruRU",
{
Channel = "Канал",
ChannelSticky = "Совмещение каналов",
["Chat channel sticky options."] = "Настройки прилипания каналов чата.",
ChatType = "Тип чата",
["Per chat type options."] = "Настройки по типу чата.",
["Sticky %s"] = "Прилепить к %s",
["Sticky Per Chat Frame"] = "Прилипать к окнам чата",
["Toggle remembering the chat type last used per chat frame."] = "Вкл/Выкл запоминание тип чата при последнем использовании чата.",
["Toggles sticky on and off for %s."] = "Вкл/Выкл прилепание для %s.",
smartgroup_desc = "Добавляет команду /gr , автоматически выбирающую корректный тип чата, РЕЙД, ГРУППА, или ПОЛЕ БОЯ",
smartgroup_name = "Быстрая сортировка",
}
 
)
L:AddLocale("zhCN",
{
Channel = "频道",
ChannelSticky = "频道粘连",
["Chat channel sticky options."] = "聊天频道粘连选项",
ChatType = "聊天分类",
["Per chat type options."] = "每个聊天分类选项",
["Sticky %s"] = "粘连 %s",
["Sticky Per Chat Frame"] = "粘连每个聊天框",
["Toggle remembering the chat type last used per chat frame."] = "记住每个聊天框上一次使用的聊天分类",
["Toggles sticky on and off for %s."] = "切换%s的粘连开关",
smartgroup_desc = "添加一个/gr命令用来自动选择正确的聊天分类,比如团队,小队或战场",
smartgroup_name = "智能分组",
}
 
)
L:AddLocale("esES",
{
Channel = "Canal",
ChannelSticky = "CanalAdhesivo",
["Chat channel sticky options."] = "Opciones de canal adhesivo de chat.",
ChatType = "TipoChat",
["Per chat type options."] = "Opciones por tipo de chat.",
["Sticky %s"] = "Adhesivo %s",
["Sticky Per Chat Frame"] = "Adhesivo Por Marco de Chat",
["Toggle remembering the chat type last used per chat frame."] = "Alternar recordar el último tipo de chat utilizado por el marco de chat.",
["Toggles sticky on and off for %s."] = "Alterna activar adhesivo para %s.",
smartgroup_desc = "Agrega un comando /gr que escoge automáticamente el tipo correcto de chat, BANDA, GRUPO, o CAMPO DE BATALLA",
smartgroup_name = "Grupos Inteligentes",
}
 
)
L:AddLocale("zhTW",
{
Channel = "頻道",
ChannelSticky = "固定頻道",
["Chat channel sticky options."] = "聊天頻道固定選項",
ChatType = "聊天類型",
["Per chat type options."] = "每聊天類型選項。",
["Sticky %s"] = "固定 %s",
["Sticky Per Chat Frame"] = "個別聊天視窗固定",
-- ["Toggle remembering the chat type last used per chat frame."] = "",
-- ["Toggles sticky on and off for %s."] = "",
-- smartgroup_desc = "",
smartgroup_name = "智慧化群組",
}
 
)
--@end-non-debug@
 
 
-- chat channel list
local chatList = {
"SAY",
"WHISPER",
"YELL",
"PARTY",
"GUILD",
"OFFICER",
"RAID",
"RAID_WARNING",
"INSTANCE_CHAT",
"INSTANCE_CHAT_LEADER",
"CHANNEL",
"EMOTE",
"BN_WHISPER",
"BN_CONVERSATION",
}
 
local module = Prat:NewModule(PRAT_MODULE, "AceEvent-3.0", "AceTimer-3.0", "AceHook-3.0")
 
Prat:SetModuleDefaults(module, {
profile = {
on = true,
say = true,
whisper = true,
yell = true,
party = true,
guild = true,
officer = true,
raid = true,
raid_warning = true,
instance_chat = true,
instance_chat_leader = true,
channel = true,
emote = true,
perframe = false,
smartgroup = false,
bn_whisper = true,
bn_conversation=true,
}
} )
 
local chatTypePlugins = { ctype = {} }
 
Prat:SetModuleOptions(module, {
name = L["ChannelSticky"],
desc = L["Chat channel sticky options."],
type = "group",
plugins = chatTypePlugins,
args = {
-- perframe = {
-- name = L["Sticky Per Chat Frame"],
-- desc = L["Toggle remembering the chat type last used per chat frame."],
-- type = "toggle",
-- },
smartgroup = {
name = L["smartgroup_name"],
desc = L["smartgroup_desc"],
type = "toggle",
}
}
}
)
 
--[[------------------------------------------------
Module Event Functions
------------------------------------------------]]--
 
function module:OnModuleEnable()
self:BuildChannelList()
 
self:RegisterEvent("UPDATE_CHAT_COLOR")
 
local prof = self.db.profile
 
-- sticky each channel based on db settings
self:Stickum("SAY",prof.say)
self:Stickum("WHISPER",prof.whisper)
self:Stickum("YELL",prof.yell)
self:Stickum("PARTY",prof.party)
self:Stickum("GUILD",prof.guild)
self:Stickum("OFFICER",prof.officer)
self:Stickum("RAID",prof.raid)
self:Stickum("RAID_WARNING",prof.raid_warning)
self:Stickum("INSTANCE_CHAT",prof.instance_chat)
self:Stickum("INSTANCE_CHAT_LEADER",prof.instance_leader)
self:Stickum("CHANNEL",prof.channel)
self:Stickum("EMOTE",prof.emote)
 
self:Stickum("BN_WHISPER",prof.bn_whisper)
self:Stickum("BN_CONVERSATION",prof.bn_conversation)
--self:StickyFrameChan(prof.perframe)
Prat.RegisterChatEvent(self, "Prat_OutboundChat")
if prof.smartgroup then
self:RegisterSmartGroup()
end
end
 
function module:OnModuleDisable()
-- dont sticky no mo!
self:Stickum("SAY",false)
self:Stickum("WHISPER",false)
self:Stickum("YELL",false)
self:Stickum("PARTY",false)
self:Stickum("GUILD",false)
self:Stickum("OFFICER",false)
self:Stickum("RAID",false)
self:Stickum("RAID_WARNING",false)
self:Stickum("INSTANCE_CHAT",false)
self:Stickum("INSTANCE_CHAT_LEADER",false)
self:Stickum("CHANNEL",false)
self:Stickum("EMOTE",false)
-- forget about per chat frame stickying
self:StickyFrameChan(false)
-- unregister events
self:UnregisterAllEvents()
 
Prat.UnregisterAllChatEvents(self)
end
 
--[[------------------------------------------------
Core Functions
------------------------------------------------]]--
 
-- rebuild options menu is chat colors change
function module:UPDATE_CHAT_COLOR()
self:ScheduleTimer("BuildChannelList", 1)
end
 
function module:StickyFrameChan(enabled)
-- if not enabled then
-- self:UnhookAll()
-- else
-- self.perframe = {}
-- self.perframechannum = {}
-- self:RawHook("ChatFrame_OpenChat", true)
-- self:SecureHook("ChatEdit_OnEscapePressed")
-- self:SecureHook("SendChatMessage")
-- self:SecureHook("ChatEdit_OnEnterPressed")
-- end
end
 
--function module:ChatFrame_OpenChat(text, chatFrame)
-- if ( not chatFrame ) then
-- chatFrame = SELECTED_CHAT_FRAME
-- end
--
-- local eb = chatFrame.editBox
--
-- if eb == nil then
-- return self.hooks["ChatFrame_OpenChat"](text, chatFrame)
-- end
--
-- local chatFrameN = chatFrame:GetName()
--
--Prat:Print(eb:GetAttribute("chatType"))
--
-- if eb:GetAttribute("chatType") == "WHISPER" then
---- NADA
-- elseif eb:GetAttribute("chatType") == "GROUPSAY" then
-- eb:SetAttribute("origchatType", "GROUPSAY");
-- elseif self.perframe[chatFrameN] then
-- eb:SetAttribute("channelTarget", self.perframechannum[chatFrameN]);
-- eb:SetAttribute("chatType", self.perframe[chatFrameN]);
-- eb:SetAttribute("stickyType", self.perframe[chatFrameN]);
-- end
--
-- self.hooks["ChatFrame_OpenChat"](text, chatFrame)
--end
--
--function module:SendChatMessage(msg, chatType, language, channel)
-- if self.memoNext then
-- self.perframe[self.memoNext] = chatType
-- self.perframechannum[self.memoNext] = channel
-- end
--end
--
--function module:ChatEdit_OnEscapePressed(this)
-- self.memoNext = nil
--end
--
--function module:ChatEdit_OnEnterPressed(this)
-- this = this or _G.this
-- local chatFrameN = SELECTED_CHAT_FRAME:GetName()
-- local chatType = this:GetAttribute("chatType")
--
-- local channel = this:GetAttribute("channelTarget")
-- self.perframe[chatFrameN] = chatType
-- self.perframechannum[chatFrameN] = channel
-- self.memoNext = nil
--end
local ChatTypeInfo = getmetatable(ChatTypeInfo).__index
function module:Stickum(channel, stickied)
ChatTypeInfo[channel:upper()].sticky = stickied and 1 or 0
end
 
--[[------------------------------------------------
Menu Builder Functions
------------------------------------------------]]--
 
local CLR = Prat.CLR
local function StkyChatType(text, type) return CLR:Colorize(module:GetChatCLR(type), text) end
 
function module:BuildChannelList()
local o = chatTypePlugins["ctype"]
 
for _,va in ipairs(chatList) do
local val = va:lower()
local chan
if va ~= "CHANNEL" then
if va == "INSTANCE_CHAT" or va == "INSTANCE_CHAT_LEADER" then
chan = va == "INSTANCE_CHAT" and "Instance" or "Instance Leader"
else
chan = TEXT(_G["CHAT_MSG_"..va])
end
else
chan = L["Channel"]
end
o[val] = o[val] or {
type = "toggle",
}
 
o[val].name = (L["Sticky %s"]):format(StkyChatType(chan:gsub(" ", ""), va))
o[val].desc = (L["Toggles sticky on and off for %s."]):format(chan)
end
end
 
function module:OnValueChanged(info, b)
local o = info[#info]
if o == "smartgroup" then
if b then self:RegisterSmartGroup() end
elseif o == "perframe" then
self:StickyFrameChan(b)
else
self:Stickum(o, b)
end
end
 
function module:GetChatCLR(name)
local info = ChatTypeInfo[name];
if not info then
return CLR.COLOR_NONE
end
return CLR:GetHexColor(info)
end
 
 
 
function module:RegisterSmartGroup()
if not self.smart_group then
self:SecureHook("ChatEdit_SendText", function(this) if self.groupsay then this:SetAttribute("chatType", "GROUPSAY") self.groupsay=nil end end)
 
self.smart_group = true
 
 
SLASH_GROUPSAY1 = "/gr"
SLASH_GROUPSAY2 = "/group"
ChatTypeInfo["GROUPSAY"] = { r=0.5, g=0.9, b=0.9, sticky = 1 }
CHAT_GROUPSAY_SEND = "SmartGroup:\32 "
CHAT_GROUPSAY_GET = "SmartGroup: %1\32 "
end
end
 
 
function module:SmartGroupChatType()
local _,pvp = IsInInstance()
 
if pvp == "pvp" then
return "INSTANCE_CHAT"
elseif GetNumRaidMembers() > 0 then
if IsLFGModeActive(LE_LFG_CATEGORY_LFD) then
return "INSTANCE_CHAT"
else
return "RAID"
end
elseif GetNumPartyMembers() > 0 then
return "PARTY"
end
return "SAY"
end
 
function module:Prat_OutboundChat(arg, m)
if m.CTYPE == "GROUPSAY" then
self.groupsay = true
m.CTYPE = self:SmartGroupChatType()
end
end
 
return
end ) -- Prat:AddModuleToLoad

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.