Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
276 changes: 156 additions & 120 deletions BearEmoteStatistics.lua

Large diffs are not rendered by default.

284 changes: 249 additions & 35 deletions BearEmotes.lua

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions BearEmotes.toc
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
## Interface: 100207
## Title: |TInterface\Addons\BearEmotes\Emotes\BearGigaChad:0|tBear Emotes|TInterface\Addons\BearEmotes\Emotes\BearLaugh:0|t
## Interface: 120001
## Title: |TInterface\Addons\BearEmotes\Emotes\beargun:0|tBear Emotes|TInterface\Addons\BearEmotes\Emotes\bearlaugh:0|t
## IconTexture: Interface\AddOns\BearEmotes\Emotes\beargun.tga
## Author: Mandl
## Notes: Adds Bear emotes to your chat. Built on top of TwitchEmotes
## Notes: Adds Bear emotes to your chat. Built on top of TwitchEmotes and updated for newer Midnight-compatible behavior.
## Version: v2
## SavedVariables: BearEmoticons_Settings
## SavedVariables: BearEmoticons_Settings, BearEmoteStatistics
## OptionalDeps: LibStub, LibUIDropDownMenu

Libs\load_libs.xml
Expand All @@ -13,4 +14,4 @@ BearEmotesAnimator.lua
BearEmotes.lua
BearEmoteStatistics.lua
UI\BearEmotes.xml
UI\BearEmoteStats.xml
UI\BearEmoteStats.xml
117 changes: 56 additions & 61 deletions BearEmotesAnimator.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
local BEAREMOTES_TimeSinceLastUpdate = 0
local BEAREMOTES_T = 0;
local issecretvalue = issecretvalue or function()
return false
end

function BearEmotesAnimator_OnUpdate(self, elapsed)

if (BEAREMOTES_TimeSinceLastUpdate >= 0.033) then
-- Update animated emotes in chat windows
for i = 1, NUM_CHAT_WINDOWS do
for _, visibleLine in ipairs(_G["ChatFrame" .. i].visibleLines) do
if(_G["ChatFrame" .. i]:IsShown() and visibleLine.messageInfo ~= BearEmotes_HoverMessageInfo) then
for _, frameName in pairs(CHAT_FRAMES) do
for _, visibleLine in ipairs(_G[frameName].visibleLines) do
if (_G[frameName]:IsShown() and visibleLine.messageInfo ~= BearEmotes_HoverMessageInfo) then
BearEmotesAnimator_UpdateEmoteInFontString(visibleLine, 28, 28);
end
end
Expand All @@ -27,69 +30,56 @@ function BearEmotesAnimator_OnUpdate(self, elapsed)
end

-- Update animated emotes in statistics screen
if(BearStatsScreen:IsVisible()) then

local topSentImagePath = BearEmotes_defaultpack[BearEmoteSentStatKeys[1]] or "Interface\\AddOns\\BearEmotes\\Emotes\\1337.tga";
if (BearStatsScreen:IsVisible()) then
local topSentImagePath = BearEmotes_defaultpack[BearEmoteSentStatKeys[1]] or "Interface\\AddOns\\BearEmotes\\Emotes\\beargun.tga:28:28";
local animdata = BearEmotes_animation_metadata[topSentImagePath:match("(Interface\\AddOns\\BearEmotes\\Emotes.-.tga)")]

if(animdata ~= nil) then
if (animdata ~= nil) then
local cFrame = BearEmotes_GetCurrentFrameNum(animdata)
BearStatsScreen.topSentEmoteTexture:SetTexCoord(BearEmotes_GetTexCoordsForFrame(animdata, cFrame))
BearStatsScreen.topSentEmoteTexture:SetTexCoord(BearEmotes_GetTexCoordsForFrame(animdata, cFrame))
end


local topSeenImagePath = BearEmotes_defaultpack[BearEmoteRecievedStatKeys[1]] or "Interface\\AddOns\\BearEmotes\\Emotes\\1337.tga";
local animdata = BearEmotes_animation_metadata[topSeenImagePath:match("(Interface\\AddOns\\BearEmotes\\Emotes.-.tga)")]
if(animdata ~= nil) then
local topSeenImagePath = BearEmotes_defaultpack[BearEmoteRecievedStatKeys[1]] or "Interface\\AddOns\\BearEmotes\\Emotes\\beargun.tga:28:28";
animdata = BearEmotes_animation_metadata[topSeenImagePath:match("(Interface\\AddOns\\BearEmotes\\Emotes.-.tga)")]
if (animdata ~= nil) then
local cFrame = BearEmotes_GetCurrentFrameNum(animdata)
BearStatsScreen.topSeenEmoteTexture:SetTexCoord(BearEmotes_GetTexCoordsForFrame(animdata, cFrame))
BearStatsScreen.topSeenEmoteTexture:SetTexCoord(BearEmotes_GetTexCoordsForFrame(animdata, cFrame))
end


for line=1, 17 do
local sentEntry = getglobal("BearStatsSentEntry"..line)
local recievedEntry = getglobal("BearStatsRecievedEntry"..line)
for line = 1, 17 do
local sentEntry = getglobal("BearStatsSentEntry" .. line)
local recievedEntry = getglobal("BearStatsRecievedEntry" .. line)

if(sentEntry:IsVisible()) then
if (sentEntry:IsVisible()) then
BearEmotesAnimator_UpdateEmoteInFontString(sentEntry, 16, 16);
end

if(recievedEntry:IsVisible()) then
if (recievedEntry:IsVisible()) then
BearEmotesAnimator_UpdateEmoteInFontString(recievedEntry, 16, 16);
end
end
end


BEAREMOTES_TimeSinceLastUpdate = 0;
end

BEAREMOTES_T = BEAREMOTES_T + elapsed
BEAREMOTES_TimeSinceLastUpdate = BEAREMOTES_TimeSinceLastUpdate +
elapsed;
BEAREMOTES_TimeSinceLastUpdate = BEAREMOTES_TimeSinceLastUpdate + elapsed;
end

local function escpattern(x)
return (
--x:gsub('%%', '%%%%')
--:gsub('^%^', '%%^')
--:gsub('%$$', '%%$')
--:gsub('%(', '%%(')
--:gsub('%)', '%%)')
--:gsub('%.', '%%.')
--:gsub('%[', '%%[')
--:gsub('%]', '%%]')
--:gsub('%*', '%%*')
x:gsub('%+', '%%+')
:gsub('%-', '%%-')
--:gsub('%?', '%%?'))
)
x:gsub('%+', '%%+')
:gsub('%-', '%%-')
)
end

-- This will update the texture escapesequence of an animated emote
-- if it exsists in the contents of the fontstring
-- This will update the texture escape sequence of an animated emote
-- if it exists in the contents of the fontstring.
function BearEmotesAnimator_UpdateEmoteInFontString(fontstring, widthOverride, heightOverride)
local txt = fontstring:GetText();
if issecretvalue(txt) == true then
return
end
if (txt ~= nil) then
for emoteTextureString in txt:gmatch("(|TInterface\\AddOns\\BearEmotes\\Emotes.-|t)") do
local imagepath = emoteTextureString:match("|T(Interface\\AddOns\\BearEmotes\\Emotes.-.tga).-|t")
Expand All @@ -98,17 +88,18 @@ function BearEmotesAnimator_UpdateEmoteInFontString(fontstring, widthOverride, h
if (animdata ~= nil) then
local framenum = BearEmotes_GetCurrentFrameNum(animdata);
local nTxt;
if(widthOverride ~= nil or heightOverride ~= nil) then
nTxt = txt:gsub(escpattern(emoteTextureString),
BearEmotes_BuildEmoteFrameStringWithDimensions(
imagepath, animdata, framenum, widthOverride, heightOverride))
if (widthOverride ~= nil or heightOverride ~= nil) then
nTxt = txt:gsub(
escpattern(emoteTextureString),
BearEmotes_BuildEmoteFrameStringWithDimensions(imagepath, animdata, framenum, widthOverride, heightOverride)
)
else
nTxt = txt:gsub(escpattern(emoteTextureString),
BearEmotes_BuildEmoteFrameString(
imagepath, animdata, framenum))
nTxt = txt:gsub(
escpattern(emoteTextureString),
BearEmotes_BuildEmoteFrameString(imagepath, animdata, framenum)
)
end

-- If we're updating a chat message we need to alter the messageInfo as wel
if (fontstring.messageInfo ~= nil) then
fontstring.messageInfo.message = nTxt
end
Expand All @@ -119,42 +110,46 @@ function BearEmotesAnimator_UpdateEmoteInFontString(fontstring, widthOverride, h
end
end



function BearEmotes_GetAnimData(imagepath)
return BearEmotes_animation_metadata[imagepath]
end

function BearEmotes_GetCurrentFrameNum(animdata)
if (animdata.pingpong) then
local vframen = math.floor((BEAREMOTES_T * animdata.framerate) % ((animdata.nFrames * 2) - 1));
if vframen > animdata.nFrames then
vframen = animdata.nFrames - (vframen % animdata.nFrames)
end
return vframen
end

return math.floor((BEAREMOTES_T * animdata.framerate) % animdata.nFrames);
end

function BearEmotes_GetTexCoordsForFrame(animdata, framenum)
local fHeight = 1/animdata.nFrames
return 0, 1 ,framenum * fHeight, (framenum * fHeight) + fHeight
local fHeight = animdata.frameHeight;
return 0, 1, framenum * fHeight / animdata.imageHeight, ((framenum * fHeight) + fHeight) / animdata.imageHeight
end

function BearEmotes_BuildEmoteFrameString(imagepath, animdata, framenum)
local top = framenum * animdata.frameHeight;
local bottom = top + animdata.frameHeight;

local emoteStr = "|T" .. imagepath .. ":" .. animdata.frameWidth .. ":" ..
animdata.frameHeight .. ":0:0:" .. animdata.imageWidth ..
":" .. animdata.imageHeight .. ":0:" ..
animdata.frameWidth .. ":" .. top .. ":" .. bottom ..
"|t";
animdata.frameHeight .. ":0:0:" .. animdata.imageWidth ..
":" .. animdata.imageHeight .. ":0:" ..
animdata.frameWidth .. ":" .. top .. ":" .. bottom ..
"|t";
return emoteStr
end

function BearEmotes_BuildEmoteFrameStringWithDimensions(imagepath, animdata,
framenum, framewidth,
frameheight)
function BearEmotes_BuildEmoteFrameStringWithDimensions(imagepath, animdata, framenum, framewidth, frameheight)
local top = framenum * animdata.frameHeight;
local bottom = top + animdata.frameHeight;

local emoteStr = "|T" .. imagepath .. ":" .. framewidth .. ":" ..
frameheight .. ":0:0:" .. animdata.imageWidth .. ":" ..
animdata.imageHeight .. ":0:" .. animdata.frameWidth ..
":" .. top .. ":" .. bottom .. "|t";
frameheight .. ":0:0:" .. animdata.imageWidth .. ":" ..
animdata.imageHeight .. ":0:" .. animdata.frameWidth ..
":" .. top .. ":" .. bottom .. "|t";
return emoteStr
end
end
6 changes: 3 additions & 3 deletions DropdownItems.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
-- 45 per menu max
BearEmotes_dropdown_options = {
[01] = {
"bearahegao", "bearangy", "bearawe", "bearbear", "bearbench", "bearbongo", "bearbonk", "bearbutterfly", "bearchefkiss", "bearchrist", "bearcomfy", "bearconcern", "bearcool", "Bearcopium", "bearcopter", "bearcringe", "bearcro", "bearcrodex", "bearcrosux", "bearcrown", "bearcry", "beardoubt", "beardrool", "bearfacepalm", "bearfingerguns", "bearfrench", "beargamer", "beargasp", "beargigachad", "beargiggle", "beargun", "bearhands", "bearheart", "bearhmmm", "bearhug", "bearhungry", "bearkekw", "bearknife", "bearlaugh", "bearlook", "bearmadge", "bearmoney", "bearmplus", "bearnotes", "bearnotlikethis"
"Bear Emotes 1", "bearahegao", "bearangy", "bearawe", "bearbear", "bearbench", "bearbongo", "bearbonk", "bearbutterfly", "bearchefkiss", "bearchrist", "bearcomfy", "bearconcern", "bearcool", "Bearcopium", "bearcopter", "bearcringe", "bearcro", "bearcrodex", "bearcrosux", "bearcrown", "bearcry", "beardoubt", "beardrool", "bearfacepalm", "bearfingerguns", "bearfrench", "beargamer", "beargasp", "beargigachad", "beargiggle", "beargun", "bearhands", "bearheart", "bearhmmm", "bearhug", "bearhungry", "bearkekw", "bearknife", "bearlaugh", "bearlook", "bearmadge", "bearmoney", "bearmplus", "bearnotes", "bearnotlikethis"
},
[02] = {
"bearpepe", "bearpepega", "bearpi", "bearpikachu", "bearping", "bearpog", "bearpoint", "bearpopcorn", "bearpray", "bearprot", "bearrevenj", "bearriot", "bearsadcry", "bearsadge", "bearshrug", "bearsignsimp", "bearsigntoxicgreen", "bearsip", "bearsleep", "bearsmart", "bearspreadsheet", "bearsquint", "bearstonks", "bearstrong", "bearsus", "beartaunt", "bearthief", "bearthonk", "bearthumbsup", "beartimi", "beartinfoil", "beartrumpet", "bearupsidedown", "bearuwu", "bearwagonhappy", "bearwagonsad", "bearwallpeak", "bearwicked", "bearwings", "feelsbearman"
"Bear Emotes 2", "bearpepe", "bearpepega", "bearpi", "bearpikachu", "bearping", "bearpog", "bearpoint", "bearpopcorn", "bearpray", "bearprot", "bearrevenj", "bearriot", "bearsadcry", "bearsadge", "bearshrug", "bearsignsimp", "bearsigntoxicgreen", "bearsip", "bearsleep", "bearsmart", "bearspreadsheet", "bearsquint", "bearstonks", "bearstrong", "bearsus", "beartaunt", "bearthief", "bearthonk", "bearthumbsup", "beartimi", "beartinfoil", "beartrumpet", "bearupsidedown", "bearuwu", "bearwagonhappy", "bearwagonsad", "bearwallpeak", "bearwicked", "bearwings", "feelsbearman"
}
};
};
12 changes: 11 additions & 1 deletion UI/BearEmoteStats.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@
</Anchors>
</FontString>

<FontString name="$parentSearchBoxLabel" text="Search:" inherits="GameFontHighlightSmall" nonSpaceWrap="true" maxLines="3" justifyh="LEFT" justifyv="TOP">
<Anchors>
<Anchor point="CENTER" relativeTo="$parent" relativePoint="TOPLEFT">
<Offset>
<AbsDimension x="25" y="-180"/>
</Offset>
</Anchor>
</Anchors>
</FontString>

<FontString name="$parentSeenListTitle" text="Seen" inherits="GameFontNormal" justifyh="LEFT" justifyv="TOP">
<Anchors>
<Anchor point="TOPLEFT">
Expand Down Expand Up @@ -165,4 +175,4 @@
</Frames>
</Frame>

</Ui>
</Ui>
13 changes: 10 additions & 3 deletions UI/BearEmotes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,13 @@ Revert PowaBarSliderTemplate to inherit from OptionsSliderTemplate if it's fixed
<Scripts>
<OnLoad>
self.name = "BearEmotes";
InterfaceOptions_AddCategory(self);
if SettingsPanel then
self:SetParent(SettingsPanel);
local category = Settings.RegisterCanvasLayoutCategory(self, self.name)
Settings.RegisterAddOnCategory(category)
else
InterfaceOptions_AddCategory(self);
end

self:RegisterEvent("ADDON_LOADED");
self:SetScript("OnEvent",BearEmoticons_OnEvent);
Expand Down Expand Up @@ -532,7 +538,8 @@ Revert PowaBarSliderTemplate to inherit from OptionsSliderTemplate if it's fixed
</Anchors>
<Scripts>
<OnClick>
HideUIPanel(InterfaceOptionsFrame);
if InterfaceOptionsFrame then HideUIPanel(InterfaceOptionsFrame); end
if SettingsPanel then HideUIPanel(SettingsPanel); end
HideUIPanel(GameMenuFrame);
BearStatsScreen_OnLoad();
</OnClick>
Expand Down Expand Up @@ -607,4 +614,4 @@ Revert PowaBarSliderTemplate to inherit from OptionsSliderTemplate if it's fixed
</OnLoad>
</Scripts>
</Frame>
</Ui>
</Ui>
Loading
Loading