WoWInterface SVN ChatEdit

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk
    from Rev 3 to Rev 4
    Reverse comparison

Rev 3 → Rev 4

ChatEdit/ChatEdit.xml
17,13 → 17,13
ChatEdit:Hide()
</OnEscapePressed>
<OnMouseDown>
ChatEdit:OnMouseDown()
ChatEdit:OnMouseDown(self)
</OnMouseDown>
<OnMouseUp>
ChatEdit:OnMouseUp()
ChatEdit:OnMouseUp(self)
</OnMouseUp>
<OnHide>
ChatEdit:OnHide()
ChatEdit:OnHide(self)
</OnHide>
</Scripts>
<FontString inherits="GameFontHighlightSmall"/>
32,14 → 32,110
<Frames>
<!-- Used for hidden scroll offset measurement -->
<MessageFrame name="$parentMessageFrame" setAllPoints="true" enableMouse="false" hidden="true"/>
<Frame name="$parentScrollUp">
<Size>
<AbsDimension y="10"/>
</Size>
<Anchors>
<Anchor point="TOPLEFT" relativeTo="$parent" relativePoint="TOPLEFT">
<Offset>
<AbsDimension x="-2" y="3"/>
</Offset>
</Anchor>
<Anchor point="TOPRIGHT" relativeTo="$parent" relativePoint="TOPRIGHT">
<Offset>
<AbsDimension x="2" y="3"/>
</Offset>
</Anchor>
</Anchors>
<!--
<Layers>
<Layer level="BACKGROUND">
<Texture name="$parentBackground" urgency="5" file="Interface\ChatFrame\ChatFrameBackground">
<Anchors>
<Anchor point="TOPLEFT">
<Offset>
<AbsDimension x="0" y="0"/>
</Offset>
</Anchor>
<Anchor point="TOPRIGHT">
<Offset>
<AbsDimension x="0" y="0"/>
</Offset>
</Anchor>
<Anchor point="BOTTOMLEFT">
<Offset>
<AbsDimension x="0" y="0"/>
</Offset>
</Anchor>
<Anchor point="BOTTOMRIGHT">
<Offset>
<AbsDimension x="0" y="0"/>
</Offset>
</Anchor>
</Anchors>
</Texture>
</Layer>
</Layers>
-->
</Frame>
<Frame name="$parentScrollDown">
<Size>
<AbsDimension y="10"/>
</Size>
<Anchors>
<Anchor point="BOTTOMLEFT" relativeTo="$parent" relativePoint="BOTTOMLEFT">
<Offset>
<AbsDimension x="-2" y="-4"/>
</Offset>
</Anchor>
<Anchor point="BOTTOMRIGHT" relativeTo="$parent" relativePoint="BOTTOMRIGHT">
<Offset>
<AbsDimension x="2" y="-4"/>
</Offset>
</Anchor>
</Anchors>
<!--
<Layers>
<Layer level="BACKGROUND">
<Texture name="$parentBackground" urgency="5" file="Interface\ChatFrame\ChatFrameBackground">
<Anchors>
<Anchor point="TOPLEFT">
<Offset>
<AbsDimension x="0" y="0"/>
</Offset>
</Anchor>
<Anchor point="TOPRIGHT">
<Offset>
<AbsDimension x="0" y="0"/>
</Offset>
</Anchor>
<Anchor point="BOTTOMLEFT">
<Offset>
<AbsDimension x="0" y="0"/>
</Offset>
</Anchor>
<Anchor point="BOTTOMRIGHT">
<Offset>
<AbsDimension x="0" y="0"/>
</Offset>
</Anchor>
</Anchors>
</Texture>
</Layer>
</Layers>
-->
</Frame>
</Frames>
<Scripts>
<OnLoad>
ChatEdit:OnLoad(self)
</OnLoad>
<!--
<OnEvent>
ChatEdit:OnEvent(self, event)
</OnEvent>
-->
<OnSizeChanged>
ChatEdit:OnSizeChanged(self)
</OnSizeChanged>
ChatEdit/ChatEdit.lua
10,7 → 10,7
CHAT_EDIT_HOVER_SCROLL_TIMER = 1/10;
 
for i=1, 7 do
getglobal("ChatFrame"..i):SetMaxLines(CHAT_EDIT_MAX_LINES);
_G["ChatFrame"..i]:SetMaxLines(CHAT_EDIT_MAX_LINES);
end
 
local function Compare(x, y)
33,7 → 33,7
elseif (type(ChatEditScrollFrame.text) == "string") then
if (ChatEditScrollFrameEditBox:GetText() ~= ChatEditScrollFrame.text) then
ChatEditScrollFrameEditBox:SetText(ChatEditScrollFrame.text);
self.ignoreTextChange = 2;
self.ignoreTextChange = 1; --This used to be 2, not sure why
end
 
else
52,7 → 52,7
end
 
local name, fontSize, r, g, b, a, shown, locked, docked = GetChatWindowInfo(id);
local chatFrame = getglobal("ChatFrame"..id);
local chatFrame = _G["ChatFrame"..id];
ChatEditScrollFrame:SetParent(chatFrame);
ChatEditScrollFrame:SetAllPoints(chatFrame);
ChatEditScrollFrame:SetScrollChild(ChatEditScrollFrameEditBox);
99,8 → 99,8
-- SetFontObject, SetFont and SetText all trigger OnTextChanged. Ignore them any amount of times. 'ignore' still updates the rect.
self.ignoreTextChange = ignores;
 
self.hoverUp = getglobal(chatFrame:GetName().."ResizeTop")
self.hoverDown = getglobal(chatFrame:GetName().."ResizeBottom")
self.hoverUp = ChatEditScrollFrameScrollUp
self.hoverDown = ChatEditScrollFrameScrollDown
 
--/run for i=1111111000, 1111111040 do Portfolio.Print(i) end
end
141,7 → 141,7
end
 
function ChatEdit:HideNormalChat(id)
local chatFrame = getglobal("ChatFrame"..id);
local chatFrame = _G["ChatFrame"..id];
if (not self.CurrentScroll) then
self.CurrentScroll = {}
end
171,7 → 171,7
end
 
function ChatEdit:RestoreNormalChat(id)
local chatFrame = getglobal("ChatFrame"..id);
local chatFrame = _G["ChatFrame"..id];
if (self.CurrentScroll and self.CurrentScroll[id]) then
chatFrame:SetScrollOffset(self.CurrentScroll[id])
end
244,17 → 244,17
end
 
--[[
function ChatEdit.OnMouseWheel()
function ChatEdit.OnMouseWheel(self,direction)
if ( IsShiftKeyDown() ) then
if ( arg1 > 0 ) then
if ( direction > 0 ) then
ChatEditScrollFrame:ScrollToTop()
elseif ( arg1 < 0 ) then
elseif ( direction < 0 ) then
ChatEditScrollFrame:ScrollToBottom();
end
else
if ( arg1 > 0 ) then
if ( direction > 0 ) then
ChatEditScrollFrame:ScrollUp();
elseif ( arg1 < 0 ) then
elseif ( direction < 0 ) then
ChatEditScrollFrame:ScrollDown();
end
end
262,7 → 262,7
]]--
 
function ChatEdit:OnLoad(frame)
frame:RegisterEvent("PLAYER_ENTERING_WORLD");
--frame:RegisterEvent("PLAYER_ENTERING_WORLD");
local chatData = {}
for id=1, NUM_CHAT_WINDOWS do
-- init curr text storage
273,35 → 273,69
ScrollFrame_OnLoad(frame);
 
self.ignoreTextChange = 0;
 
ChatEdit:SetUpHooks();
end
 
function ChatEdit.ColorText(text, r, g, b)
function ChatEdit.ColorText(text, r, g, b, id)
local color = "|c"..format("FF%.2X%.2X%.2X", (r or 1) * 255, (g or 1) * 255, (b or 1) * 255);
text = gsub(text, "|r", color)
text = color..text.."|r"
local colorPrefix = format("[%.2f,%.2f,%.2f,%s]", r, g, b, id or "")
text = colorPrefix..color..text.."|r"
return text
end
 
-- after hook
-- Insert at the end, remove from the front
-- only store as many as are normally visible
function ChatEdit.ChatFrameAddMessage(self, text, r, g, b, lineID)
-- only store as many as are normally visible.
-- addToFront causes it to add to the front of the array, which is usually the oldest text (combat log does this)
function ChatEdit.ChatFrameAddMessage(self, text, r, g, b, lineID, addToFront)
local id = self:GetID()
if (type(text) ~= "string" and type(text) ~= "number") then
return;
return
end
table.insert(ChatEditScrollFrame.chatData[id], ChatEdit.ColorText(text, r, g, b))
if (getn(ChatEditScrollFrame.chatData[id]) > self:GetMaxLines()) then
table.remove(ChatEditScrollFrame.chatData[id], 1)
local currentMax = getn(ChatEditScrollFrame.chatData[id])
if (addToFront) then
tinsert(ChatEditScrollFrame.chatData[id], 1, ChatEdit.ColorText(text, r, g, b))
if (currentMax > self:GetMaxLines()) then
tremove(ChatEditScrollFrame.chatData[id])
end
else
tinsert(ChatEditScrollFrame.chatData[id], ChatEdit.ColorText(text, r, g, b))
if (currentMax > self:GetMaxLines()) then
tremove(ChatEditScrollFrame.chatData[id], 1)
end
end
end
 
function ChatEdit.WorldFrameOnMouseDown()
if (arg1 == "LeftButton" and IsShiftKeyDown()) then
-- after hook
-- Clear the message history
function ChatEdit.ChatFrameClear(self)
local id = self:GetID()
ChatEditScrollFrame.chatData[id] = {}
end
 
-- after hook
-- Truncate the message history
function ChatEdit.ChatFrameSetMaxLines(self, maxLines)
local id = self:GetID()
--[[ This would remove from the end, but we need to remove from the front
for i=maxLines+1, getn(ChatEditScrollFrame.chatData[id]) do
t[i] = nil;
end
]]--
local currentMax = getn(ChatEditScrollFrame.chatData[id])
if (currentMax > maxLines) then
ChatEditScrollFrame.chatData[id] = { unpack(ChatEditScrollFrame.chatData, currentMax-maxLines, currentMax) }
end
end
 
function ChatEdit.WorldFrameOnMouseDown(self, button)
if (button == "LeftButton" and IsShiftKeyDown()) then
local chatFrame;
for id=1, NUM_CHAT_WINDOWS do
chatFrame = getglobal("ChatFrame"..id);
if (chatFrame:IsVisible() and MouseIsOver(chatFrame)) then
chatFrame = _G["ChatFrame"..id];
if (chatFrame:IsVisible() and chatFrame:IsMouseOver()) then
ChatEdit:Show(id);
return;
end
309,7 → 343,7
end
 
if (ChatEditScrollFrame:IsVisible()) then
if (MouseIsOver(ChatEditScrollFrame)) then
if (ChatEditScrollFrame:IsMouseOver()) then
ChatEditScrollFrameEditBox:SetFocus(1);
else
ChatEdit:Hide()
323,6 → 357,8
local frame = _G["ChatFrame"..id];
-- hook AddMessage
hooksecurefunc(frame, "AddMessage", ChatEdit.ChatFrameAddMessage);
hooksecurefunc(frame, "Clear", ChatEdit.ChatFrameClear);
hooksecurefunc(frame, "SetMaxLines", ChatEdit.ChatFrameSetMaxLines);
end
 
if (type(WorldFrame:GetScript("OnMouseDown")) == "function") then
335,18 → 371,20
end
end
 
--[[
function ChatEdit:OnEvent(frame, event)
if (event == "PLAYER_ENTERING_WORLD") then
self:SetUpHooks()
end
end
]]--
 
function ChatEdit:OnSizeChanged()
local name, fontSize, r, g, b, a, shown, locked, docked = GetChatWindowInfo(this:GetParent():GetID());
function ChatEdit:OnSizeChanged(frame)
local name, fontSize, r, g, b, a, shown, locked, docked = GetChatWindowInfo(frame:GetParent():GetID());
if (docked) then
ChatEditScrollFrameEditBox:SetWidth(DEFAULT_CHAT_FRAME:GetWidth());
else
ChatEditScrollFrameEditBox:SetWidth(this:GetWidth());
ChatEditScrollFrameEditBox:SetWidth(frame:GetWidth());
end
if (self.newText) then
ChatEdit:ScrollToBottom();
363,7 → 401,7
end
 
function ChatEdit:OnUpdate()
if (MouseIsOver(self.hoverUp)) then
if (self.hoverUp:IsMouseOver()) then
if (not self.scrollTimer) then
self.scrollTimer = GetTime();
elseif (GetTime() > (self.scrollTimer + CHAT_EDIT_HOVER_SCROLL_TIMER)) then
372,7 → 410,7
self.scrollTimer = GetTime();
end
 
elseif (MouseIsOver(self.hoverDown)) then
elseif (self.hoverDown:IsMouseOver()) then
if (not self.scrollTimer) then
self.scrollTimer = GetTime();
elseif (GetTime() > (self.scrollTimer + CHAT_EDIT_HOVER_SCROLL_TIMER)) then
387,14 → 425,14
end
end
 
function ChatEdit:OnMouseDown()
this:SetScript("OnUpdate", function() ChatEdit:OnUpdate() end)
function ChatEdit:OnMouseDown(frame)
frame:SetScript("OnUpdate", function() ChatEdit:OnUpdate() end)
end
 
function ChatEdit:OnMouseUp()
this:SetScript("OnUpdate", nil)
function ChatEdit:OnMouseUp(frame)
frame:SetScript("OnUpdate", nil)
end
 
function ChatEdit:OnHide()
this:SetScript("OnUpdate", nil)
function ChatEdit:OnHide(frame)
frame:SetScript("OnUpdate", nil)
end
ChatEdit/ChatEdit.toc
1,13 → 1,12
## Interface: 30100
## Interface: 40000
## Title: ChatEdit
## Title-deDE: ChatErweiterung
## Notes: Select and copy chat directly from the frame and still click through it.
## Notes-deDE: Erlaubt es Text aus dem Chatfenster direkt zu kopieren.
## Author: AnduinLothar
## Version: 2.0
## X-Date: Oct 15 2008
## Version: 3.0
## X-Date: Jan 12 2010
## X-Category: Chat
## X-Website: http://www.wowinterface.com/downloads/info5438-ChatEdit.html
## X-CompatibleLocales: enUS, enGB, deDE, frFR, koKR, zhCN, zhTW, esES
## X-Embeds: SeaHooks
ChatEdit.xml