Skip to content

Commit

Permalink
v1.0.3,界面优化
Browse files Browse the repository at this point in the history
  • Loading branch information
guoyongshi committed Oct 12, 2019
1 parent 69c1921 commit 9c2e029
Show file tree
Hide file tree
Showing 6 changed files with 199 additions and 9 deletions.
3 changes: 2 additions & 1 deletion BFFilter.toc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Interface: 11302
## Title: BigFoot World Channel Filter
## Version: 1.0.2
## Version: 1.0.3
## Notes: BigFoot World Channel Filter
## SavedVariablesPerCharacter: BFWC_Filter_SavedConfigs
## Author: guoyongshi@gmail.com
Expand All @@ -14,5 +14,6 @@ utils.lua
filter.lua
config.lua
minimap.lua
draghandle.lua

main.lua
31 changes: 25 additions & 6 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ local function reset_configs()
hide_enter_leave = true,
auto_filter_by_level = true,
filter_request_to_join = true,
autojoin_bigfoot = true,
minimap = { hide = false},
}
dungeons_init()
Expand Down Expand Up @@ -213,13 +214,15 @@ local config_options = {
dialogControl = 'MacroButton'
},

desc = {
desc1 = {
type = 'description',
name = '\n|cffcc0000您现在还未加入|r|cfffed51f大脚世界频道|r|cffcc0000,请先加入!|r\n',
hidden = function() return not bfwf_big_foot_world_channel_joined end
name = '\n|cffcc0000您现在还未加入|r|cfffed51f大脚世界频道|r|cffcc0000,加入后才能看到大量组队信息!!!|r\n',
hidden = function() return bfwf_big_foot_world_channel_joined end,
width = 'full',
order = 4,
},

desc = {
desc2 = {
type = 'description',
name = '\n' ..
'将大脚世界频道有用的组队信息保留下来,其它信息全部过滤掉!\n\n' ..
Expand All @@ -228,7 +231,7 @@ local config_options = {
'\n'
,
width = 'full',
order = 4
order = 4.1
},

autojoin = {
Expand All @@ -253,7 +256,7 @@ local config_options = {
end,
set = function(info, val)
BFWC_Filter_SavedConfigs.enable = val
bfwf_update_minimap_icon()
bfwf_update_icon()
end
},

Expand Down Expand Up @@ -291,6 +294,22 @@ local config_options = {
end
},

draghdl = {
type = 'toggle',
name = '显示全局可拖拽按钮(在一些整合UI里,小地图按钮不好找,可以用这个)\n',
order = 9.1,
width = 'full',
get = function() return BFWC_Filter_SavedConfigs.show_drag_handle end,
set = function(info,val)
BFWC_Filter_SavedConfigs.show_drag_handle = val
if val then
bfwf_show_drag_handle()
else
bfwf_hide_drag_handle()
end
end
},

interval = {
type = 'range',
name = '刷屏过滤(同一个人,间隔小于设定秒数的发言将被过滤掉)',
Expand Down
157 changes: 157 additions & 0 deletions draghandle.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@

local draghandle_prototype = CreateFrame and CreateFrame('Frame',nil,UIParent) or {} --方便做语法错误检查
local draghandle_meta = { __index = draghandle_prototype }

local function onMouseDown(self,button)
self.xpos = self:GetLeft()
self.ypos = self:GetTop()
if button == 'LeftButton' then
self:StartMoving()
self.isMoving = true
end
end

local function onMouseUp(self,button)
if self.isMoving then
self:StopMovingOrSizing()
self.isMoving = false
end

if not self.xpos or not self.ypos then
return
end

local dx = self:GetLeft()-self.xpos
local dy = self:GetTop()-self.ypos
local dis = math.sqrt(dx*dx+dy*dy)

if dis>2 then
return
end

if button == 'LeftButton' then
self:OnLeftButton()
elseif button == 'RightButton' then
self:OnRightButton()
end
end

local function onMouseEnter(self)
self.icon:SetAlpha(1.0)
self.bg:SetAlpha(1.0)
self:ShowTooltip(true)
end

local function onMouseLeave(self)
self.icon:SetAlpha(0.5)
self.bg:SetAlpha(0.5)
self:ShowTooltip(false)
end

function draghandle_prototype:Init()
self.bg = self:CreateTexture(nil,'BACKGROUND')
self.bg:SetTexture('Interface/Buttons/UI-EmptySlot')
self.bg:SetPoint("TOPLEFT", self, "TOPLEFT",0,0)
self.bg:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT",0,0)
self.bg:SetAlpha(0.5)
self.bg:Show()

self.icon = self:CreateTexture(nil,'ARTWORK')
if BFWC_Filter_SavedConfigs.enable then
self.icon:SetTexture('Interface/AddOns/BFFilter/texture/minimap')
else
self.icon:SetTexture('Interface/AddOns/BFFilter/texture/pause')
end
self.icon:SetPoint("TOPLEFT", self, "TOPLEFT",12,-12)
self.icon:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT",-12,12)
self.icon:SetAlpha(0.5)
self.icon:Show()

self:SetMovable(true)
self:EnableMouse(true)
self:SetUserPlaced(true)
self:SetScript('OnMouseDown',onMouseDown)
self:SetScript('OnMouseUp',onMouseUp)
self:SetScript('OnEnter',onMouseEnter)
self:SetScript('OnLeave',onMouseLeave)
self:SetSize(64,64)
self.is_enable = 'x'
self.tooltip = CreateFrame("GameTooltip", "BFWFDragHandleTooltip", UIParent, "GameTooltipTemplate")
end

local function getAnchors(frame)
local x, y = frame:GetCenter()
if not x or not y then return "CENTER" end
local hhalf = (x > UIParent:GetWidth()*2/3) and "RIGHT" or (x < UIParent:GetWidth()/3) and "LEFT" or ""
local vhalf = (y > UIParent:GetHeight()/2) and "TOP" or "BOTTOM"
return vhalf..hhalf, frame, (vhalf == "TOP" and "BOTTOM" or "TOP")..hhalf
end


function draghandle_prototype:ShowTooltip(show)
if not show then
self.tooltip:Hide()
return
end

self.tooltip:SetOwner(self, "ANCHOR_NONE")
self.tooltip:SetPoint(getAnchors(self))
GameTooltip_SetTitle(self.tooltip, '组队频道信息过滤')
GameTooltip_AddInstructionLine(self.tooltip, '鼠标左键打开设置窗口')
GameTooltip_AddInstructionLine(self.tooltip, '鼠标右键启用/禁用过滤器')
if BFWC_Filter_SavedConfigs.enable then
GameTooltip_AddInstructionLine(self.tooltip, '当前状态:已启用')
else
GameTooltip_AddInstructionLine(self.tooltip, '当前状态:已禁用')
end
self.tooltip:Show()
end

local cfgdlg = LibStub('AceConfigDialog-3.0')
function draghandle_prototype:OnLeftButton()
cfgdlg:SetDefaultSize("BigFootWorldChannelFilter", 800, 600)
cfgdlg:Open("BigFootWorldChannelFilter")
cfgdlg.OpenFrames['BigFootWorldChannelFilter'].frame:SetFrameStrata("MEDIUM")
end

function draghandle_prototype:OnRightButton()
bfwf_toggle_bf_filter()
end

local function onHide(self)
if self.isMoving then
self:StopMoving()
self.isMoving = false
end
end

--在插件加载时创建窗口,窗口位置缓存才生效
local hdl = setmetatable(CreateFrame('Frame','BFWFDragHandle',UIParent),draghandle_meta)
hdl:SetScript('OnHide',onHide)
hdl:Init()
hdl:SetPoint('TOPRIGHT',-150,-150)

bfwf_show_drag_handle = function()
hdl:Show()
end

bfwf_hide_drag_handle = function()
hdl:Hide()
end

bfwf_update_drag_handle = function()
if not hdl then
return
end

if hdl.is_enable == BFWC_Filter_SavedConfigs.enable then
return
end

hdl.is_enable = BFWC_Filter_SavedConfigs.enable
if BFWC_Filter_SavedConfigs.enable then
hdl.icon:SetTexture('Interface/AddOns/BFFilter/texture/minimap')
else
hdl.icon:SetTexture('Interface/AddOns/BFFilter/texture/pause')
end
end
4 changes: 2 additions & 2 deletions filter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ end

bfwf_chat_filter_init = function()
ChatFrame_AddMessageEventFilter('CHAT_MSG_CHANNEL', chat_message_filter)
bfwf_update_minimap_icon()
bfwf_update_icon()
end

bfwf_toggle_bf_filter = function()
BFWC_Filter_SavedConfigs.enable = not BFWC_Filter_SavedConfigs.enable
bfwf_update_minimap_icon()
bfwf_update_icon()
end

local cfgreg = LibStub("AceConfigRegistry-3.0")
Expand Down
9 changes: 9 additions & 0 deletions global.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ bfwf_toggle_config_dialog = function() end
bfwf_update_config_dialog = function() end
bfwf_update_dungeons_filter = function() end

bfwf_show_drag_handle = function() end
bfwf_hide_drag_handle = function() end
bfwf_update_drag_handle = function() end

bfwf_update_icon = function()
bfwf_update_drag_handle()
bfwf_update_minimap_icon()
end

bfwf_chat_team_log = {}
bfwf_chat_task_log = {}

Expand Down
4 changes: 4 additions & 0 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ function BFFilter:OnEnable()
update_player_info()

self:OnLevelUp()

if BFWC_Filter_SavedConfigs.show_drag_handle then
bfwf_show_drag_handle()
end
end

function BFFilter:OnDisable()
Expand Down

0 comments on commit 9c2e029

Please sign in to comment.