Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local frame = CreateFrame("FRAME");
- local defaults = {
- x = 0,
- y = 0,
- p = "CENTER",
- s = 40
- }
- if GarrisonReportConf == nil then
- GarrisonReportConf = defaults
- end
- local f = CreateFrame('Button', nil, UIParent)
- f:RegisterEvent("PLAYER_ENTERING_WORLD")
- f:SetFrameStrata('LOW')
- f:SetScript("OnEvent", function(self, button)
- f:SetSize(GarrisonReportConf.s, GarrisonReportConf.s)
- f:SetPoint(GarrisonReportConf.p, GarrisonReportConf.x, GarrisonReportConf.y)
- end)
- f:RegisterForClicks('Anyup')
- f:SetNormalTexture('Interface\\ICONS\\ACHIEVEMENT_ARENA_2V2_1')
- f:GetNormalTexture():SetSize(GarrisonReportConf.s, GarrisonReportConf.s)
- f:SetHighlightTexture('Interface\\AddOns\\GarrisonReport\\Highlight')
- f:GetHighlightTexture():SetAllPoints(f:GetNormalTexture())
- SLASH_GARRISON1= '/gar';
- local GarrisonCommandTable = {
- ["unlock"] = function()
- f:SetMovable(true)
- f:SetScript("OnMouseDown", function(self, button)
- if button == "LeftButton" and not self.isMoving then
- local movable = f:IsMovable()
- if movable == true then
- self:StartMoving();
- self.isMoving = true;
- end
- end
- end)
- f:SetScript("OnMouseUp", function(self, button)
- if button == "LeftButton" and self.isMoving then
- self:StopMovingOrSizing();
- self.isMoving = false;
- end
- end)
- f:SetScript('OnEnter', function(self) end)
- f:SetScript('OnLeave', function() end)
- end,
- ["lock"] = function()
- f:SetMovable(false)
- GarrisonReportConf.p = "BOTTOMLEFT"
- GarrisonReportConf.x = f:GetLeft()
- GarrisonReportConf.y = f:GetBottom()
- f:SetPoint(GarrisonReportConf.p, GarrisonReportConf.x, GarrisonReportConf.y)
- f:SetScript('OnMouseDown', function(self)
- self:GetNormalTexture():ClearAllPoints()
- self:GetNormalTexture():SetPoint('CENTER', 1, -1)
- end)
- f:SetScript('OnMouseUp', function(self, button)
- self:GetNormalTexture():ClearAllPoints()
- self:GetNormalTexture():SetPoint('CENTER')
- if (self:IsMouseOver()) then
- GarrisonLandingPageMinimapButton_OnClick()
- end
- GameTooltip:Hide()
- end)
- f:SetScript('OnEnter', function(self)
- GameTooltip:SetOwner(self, 'ANCHOR_TOPLEFT', 25, -5)
- GameTooltip:AddLine(GARRISON_LANDING_PAGE_TITLE)
- GameTooltip:Show()
- end)
- f:SetScript('OnLeave', function()
- GameTooltip:Hide()
- end)
- end,
- ["defaults"] = function()
- GarrisonReportConf = defaults
- f:SetSize(defaults.s, defaults.s)
- f:SetPoint(defaults.p, defaults.x, defaults.y)
- print("Resetted to defaults")
- end,
- ["size"] = function(size)
- f:SetSize(size, size)
- f:GetNormalTexture():SetSize(size,size)
- f:GetHighlightTexture():SetAllPoints(f:GetNormalTexture())
- GarrisonReportConf.s = size
- end,
- ["help"] = function()
- print("Syntax: /gar (unlock|lock|defaults|size x)");
- end
- }
- local function DispatchCommand(msg, GarrisonCommandTable)
- local command, parameters = string.split(" ", msg, 2)
- local entry = GarrisonCommandTable[command:lower()]
- local which = type(entry)
- if which == "function" then
- entry(parameters)
- elseif which == "table" then
- DispatchCommand(parameters or "", entry)
- elseif which == "string" then
- print(entry)
- elseif msg ~= "help" then
- DispatchCommand("help", GarrisonCommandTable)
- end
- end
- SlashCmdList["GARRISON"] = function(msg)
- DispatchCommand(msg, GarrisonCommandTable)
- end
- f:SetScript('OnMouseDown', function(self)
- self:GetNormalTexture():ClearAllPoints()
- self:GetNormalTexture():SetPoint('CENTER', 1, -1)
- --f:GetNormalTexture():SetSize(GarrisonReportConf.s, GarrisonReportConf.s)
- end)
- f:SetScript('OnMouseUp', function(self, button)
- self:GetNormalTexture():ClearAllPoints()
- self:GetNormalTexture():SetPoint('CENTER')
- --f:GetNormalTexture():SetSize(GarrisonReportConf.s, GarrisonReportConf.s)
- if (self:IsMouseOver()) then
- GarrisonLandingPageMinimapButton_OnClick()
- end
- GameTooltip:Hide()
- end)
- f:SetScript('OnEnter', function(self)
- GameTooltip:SetOwner(self, 'ANCHOR_TOPLEFT', 25, -5)
- GameTooltip:AddLine(GARRISON_LANDING_PAGE_TITLE)
- GameTooltip:Show()
- end)
- f:SetScript('OnLeave', function()
- GameTooltip:Hide()
- end)
- function GarrisonLandingPageMinimapButton_OnClick()
- GarrisonLandingPage_Toggle();
- end
- function GarrisonLandingPage_Toggle()
- if (not GarrisonLandingPage) then
- Garrison_LoadUI();
- end
- if (not GarrisonLandingPage:IsShown()) then
- ShowUIPanel(GarrisonLandingPage);
- else
- HideUIPanel(GarrisonLandingPage);
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement