Replace ScrollFrame with Messages queue and refactor speeches options
This commit is contained in:
parent
b6d64d65b5
commit
b17f37ee42
5 changed files with 87 additions and 152 deletions
|
@ -1,75 +1,46 @@
|
|||
local _, addon = ...
|
||||
|
||||
local SpeechFrame = CreateFrame("ScrollFrame", "CzechQuestsSpeechFrame", UIParent, "UIPanelScrollFrameTemplate")
|
||||
local SpeechFrame = CreateFrame("Frame", nil, UIParent, "BackdropTemplate")
|
||||
SpeechFrame:Hide()
|
||||
|
||||
local ContentFrame = CreateFrame("Frame", nil, SpeechFrame)
|
||||
ContentFrame:Hide()
|
||||
|
||||
addon.SpeechFrame = SpeechFrame
|
||||
SpeechFrame.ContentFrame = ContentFrame
|
||||
|
||||
function SpeechFrame:Init()
|
||||
local frame = self
|
||||
|
||||
-- Default style
|
||||
self:SetSize(CzechQuestsAddon_Store.config.SPEECH_FRAME_WIDTH, 150)
|
||||
frame:SetHeight(50)
|
||||
frame:SetMovable(true)
|
||||
frame:EnableMouse(true)
|
||||
frame:RegisterForDrag("LeftButton")
|
||||
|
||||
-- Make movable
|
||||
self:SetMovable(true)
|
||||
self:EnableMouse(true)
|
||||
self:RegisterForDrag("LeftButton")
|
||||
|
||||
-- Hide sidebar
|
||||
self.ScrollBar:Hide()
|
||||
|
||||
-- Register drag event
|
||||
self:SetScript("OnDragStart", function()
|
||||
frame:StartMoving()
|
||||
end)
|
||||
self:SetScript("OnDragStop", function(self)
|
||||
frame:SetScript("OnDragStart", function() frame:StartMoving() end)
|
||||
frame:SetScript("OnDragStop", function(self)
|
||||
frame:StopMovingOrSizing()
|
||||
local finalLeft, finalTop = self:GetLeft(), self:GetTop()
|
||||
CzechQuestsAddon_Store.config.SPEECH_FRAME_POSITION = {
|
||||
x = finalLeft,
|
||||
y = finalTop
|
||||
}
|
||||
local finalLeft = self:GetLeft() local finalBottom = self:GetBottom()
|
||||
CzechQuestsAddon_Store.config.SPEECH_FRAME_POSITION_X = math.floor(finalLeft)
|
||||
CzechQuestsAddon_Store.config.SPEECH_FRAME_POSITION_Y = math.floor(finalBottom)
|
||||
end)
|
||||
|
||||
-- Create ContentFrame
|
||||
ContentFrame:Init()
|
||||
SpeechFrame:SetScrollChild(SpeechFrame.ContentFrame)
|
||||
|
||||
-- Register hover events
|
||||
self:SetScript("OnEnter", function() self.ContentFrame.Texture:SetAlpha(0.8) end)
|
||||
self:SetScript("OnLeave", function() self.ContentFrame.Texture:SetAlpha(0.2) end)
|
||||
|
||||
self:UpdateSettings()
|
||||
frame:UpdateSettings()
|
||||
end
|
||||
|
||||
function ContentFrame:Init()
|
||||
-- Default style
|
||||
self:SetSize(SpeechFrame:GetWidth(), 1)
|
||||
function SpeechFrame:UpdateSettings()
|
||||
self:SetWidth(CzechQuestsAddon_Store.config.SPEECH_FRAME_WIDTH)
|
||||
|
||||
-- Texture for control color and alpha
|
||||
self.Texture = self:CreateTexture(nil, "ARTWORK")
|
||||
self.Texture:SetTexture("Interface\\Buttons\\WHITE8x8")
|
||||
self.Texture:SetVertexColor(0, 0, 0, 0.2)
|
||||
|
||||
-- Set points to edges
|
||||
self.Texture:SetPoint("TOPLEFT", self ,"TOPLEFT", 0, 0)
|
||||
self.Texture:SetPoint("BOTTOMRIGHT", self ,"BOTTOMRIGHT", 0, 0)
|
||||
|
||||
-- Set ContentFrame position
|
||||
self:SetPoint("BOTTOMLEFT", SpeechFrame, "BOTTOMLEFT", 0, 0)
|
||||
-- Set position
|
||||
self:SetPoint(
|
||||
"BOTTOMLEFT", UIParent, "BOTTOMLEFT",
|
||||
CzechQuestsAddon_Store.config.SPEECH_FRAME_POSITION_X,
|
||||
CzechQuestsAddon_Store.config.SPEECH_FRAME_POSITION_Y
|
||||
)
|
||||
end
|
||||
|
||||
function ContentFrame:CreateMessage(message)
|
||||
-- Default style
|
||||
local MessageFrame = CreateFrame("Frame", nil, SpeechFrame.ContentFrame)
|
||||
MessageFrame:SetSize(SpeechFrame.ContentFrame:GetWidth() - 20, 1)
|
||||
function SpeechFrame:CreateMessage(message)
|
||||
local frame = self
|
||||
|
||||
local MessageFrame = CreateFrame("Frame", nil, frame)
|
||||
MessageFrame:SetSize(frame:GetWidth(), 1)
|
||||
|
||||
-- Define Message
|
||||
MessageFrame.Message = addon.API.CreateCzechFont(
|
||||
MessageFrame,
|
||||
CzechQuestsAddon_Store.config.SPEECH_TEXT_FONT_NAME,
|
||||
|
@ -80,22 +51,15 @@ function ContentFrame:CreateMessage(message)
|
|||
MessageFrame.Message:SetPoint("TOPLEFT", MessageFrame, "TOPLEFT", 5, -5)
|
||||
MessageFrame.Message:SetPoint("BOTTOMRIGHT", MessageFrame, "BOTTOMRIGHT", -5, 5)
|
||||
|
||||
-- Set text and height
|
||||
-- Create Texture
|
||||
MessageFrame.Texture = MessageFrame:CreateTexture(nil, "ARTWORK")
|
||||
MessageFrame.Texture:SetTexture("Interface\\Buttons\\WHITE8x8")
|
||||
MessageFrame.Texture:SetVertexColor(0, 0, 0, CzechQuestsAddon_Store.config.SPEECH_MESSAGE_TEXTURE_ALPHA / 100)
|
||||
MessageFrame.Texture:SetPoint("TOPLEFT", MessageFrame ,"TOPLEFT", 0, 0)
|
||||
MessageFrame.Texture:SetPoint("BOTTOMRIGHT", MessageFrame ,"BOTTOMRIGHT", 0, 0)
|
||||
|
||||
MessageFrame.Message:SetText(message)
|
||||
MessageFrame:SetHeight(MessageFrame.Message:GetHeight() + 10)
|
||||
|
||||
return MessageFrame
|
||||
end
|
||||
|
||||
function SpeechFrame:UpdateSettings()
|
||||
self:SetWidth(CzechQuestsAddon_Store.config.SPEECH_FRAME_WIDTH)
|
||||
self.ContentFrame:SetWidth(self:GetWidth())
|
||||
|
||||
-- Set position
|
||||
self:ClearAllPoints()
|
||||
self:SetPoint(
|
||||
"TOPLEFT", UIParent, "TOPLEFT",
|
||||
CzechQuestsAddon_Store.config.SPEECH_FRAME_POSITION.x,
|
||||
CzechQuestsAddon_Store.config.SPEECH_FRAME_POSITION.y
|
||||
)
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue