Quantcast

improve rchat

rawoil [06-18-21 - 06:41]
improve rchat
Filename
rChat/bar.lua
rChat/init.lua
rChat/rChat.toc
diff --git a/rChat/bar.lua b/rChat/bar.lua
index 7f48bab..d3ed61f 100644
--- a/rChat/bar.lua
+++ b/rChat/bar.lua
@@ -95,20 +95,25 @@ local ChannelButtons = {
 }

 local function CreateChannelButton(data, index)
-  local frame = CreateFrame("Button", "frameName", ChatBar)
-  frame:SetWidth(22) -- 按钮宽度
-  frame:SetHeight(22) -- 按钮高度
-  frame:SetAlpha(config.alpha.leave)
-
-  frame:SetFrameLevel(1)
-
-  frame:SetScript(
+  local button = CreateFrame("Button", nil, ChatBar)
+  button:SetSize(20, 10)
+  -- frame:SetWidth(22) -- 按钮宽度
+  -- frame:SetHeight(22) -- 按钮高度
+  button:SetAlpha(config.alpha.leave)
+  button:SetFrameLevel(1)
+
+  local tex = button:CreateTexture()
+  tex:SetTexture("Interface\\Buttons\\WHITE8x8")
+  tex:SetAllPoints()
+  tex:SetColorTexture(unpack(data.color))
+
+  button:SetScript(
     "OnEnter",
     function(self)
       self:SetAlpha(config.alpha.enter)
     end
   )
-  frame:SetScript(
+  button:SetScript(
     "OnLeave",
     function(self)
       self:SetAlpha(config.alpha.leave)
@@ -116,26 +121,26 @@ local function CreateChannelButton(data, index)
   )

   if config.bar.is_vertical then
-    frame:SetPoint("TOP", ChatBar, "TOP", 0, (1 - index) * config.bar.padding)
+    button:SetPoint("TOP", ChatBar, "TOP", 0, (1 - index) * config.bar.padding)
   else
-    frame:SetPoint("LEFT", ChatBar, "LEFT", 10 + (index - 1) * config.bar.padding, 0)
+    button:SetPoint("LEFT", ChatBar, "LEFT", 10 + (index - 1) * config.bar.padding, 0)
   end

-  frame:RegisterForClicks("AnyUp")
-  frame:SetScript("OnClick", data.callback)
+  button:RegisterForClicks("AnyUp")
+  button:SetScript("OnClick", data.callback)
   -- 显示的文字
-  frameText = frame:CreateFontString(data.name .. "Text", "OVERLAY")
+  -- frameText = frame:CreateFontString(data.name .. "Text", "OVERLAY")
   -- 字体设置
-  frameText:SetFont(STANDARD_TEXT_FONT, 15, "OUTLINE")
+  -- frameText:SetFont(STANDARD_TEXT_FONT, 15, "OUTLINE")

-  frameText:SetJustifyH("CENTER")
-  frameText:SetWidth(26)
-  frameText:SetHeight(26)
-  frameText:SetText(data.text)
-  frameText:SetPoint("CENTER", 0, 0)
+  -- frameText:SetJustifyH("CENTER")
+  -- frameText:SetWidth(26)
+  -- frameText:SetHeight(26)
+  -- frameText:SetText(data.text)
+  -- frameText:SetPoint("CENTER", 0, 0)

   -- 文字按钮的颜色
-  frameText:SetTextColor(data.color[1], data.color[2], data.color[3])
+  -- frameText:SetTextColor(data.color[1], data.color[2], data.color[3])
 end

 ChatBar:SetFrameLevel(0)
@@ -167,13 +172,15 @@ else
   ChatBar:SetPoint("TOPLEFT", "ChatFrame1", "BOTTOMLEFT", config.bar.offsetx, config.bar.offsety - 5)
 end

-ChatBar:SetMovable(true)
-ChatBar:RegisterForDrag("LeftButton")
-ChatBar:SetScript("OnDragStart", ChatBar.StartMoving)
-ChatBar:SetScript("OnDragStop", ChatBar.StopMovingOrSizing)
+if GetLocale() ~= 'zhCN' then
+  table.remove(ChannelButtons, 6)
+end

 for i = 1, #ChannelButtons do -- 对非战斗记录聊天框的信息进行处理
   CreateChannelButton(ChannelButtons[i], i)
 end

-print("|cffff7d0arChat|r quickbar loaded.")
\ No newline at end of file
+--create drag frame
+rLib:CreateDragFrame(ChatBar, L.dragFrames, -2, true)
+--create slash commands
+rLib:CreateSlashCmd(L.addonName, L.addonShortcut, L.dragFrames, L.addonColor)
\ No newline at end of file
diff --git a/rChat/init.lua b/rChat/init.lua
index defb57b..1d4b18b 100644
--- a/rChat/init.lua
+++ b/rChat/init.lua
@@ -1,5 +1,10 @@
 local A, L = ...

+L.dragFrames        = {}
+L.addonName         = A
+L.addonColor        = "ffff7d0a"
+L.addonShortcut     = "rchat"
+
 -----------------------------
 -- rChat Global
 -----------------------------
diff --git a/rChat/rChat.toc b/rChat/rChat.toc
index 1261f88..469747f 100644
--- a/rChat/rChat.toc
+++ b/rChat/rChat.toc
@@ -2,6 +2,7 @@
 ## Author: zork
 ## Title: rChat |cff1a9fc0BCC|r
 ## Notes: Chat enhancements
+## RequiredDeps: rLib

 init.lua
 core.lua
@@ -10,4 +11,4 @@ item.lua
 switch.lua
 copy.lua
 emote.lua
-# bar.lua
\ No newline at end of file
+bar.lua
\ No newline at end of file