From 8910e9bbd9615dac875346d1d9e96f4b9148f745 Mon Sep 17 00:00:00 2001 From: Eyal Solnik Date: Sat, 3 Oct 2015 11:06:04 +0300 Subject: [PATCH] Initial refactoring --- Core.lua | 23 ---------- DefaultCastingBar.toc | 21 +++++---- DragFrame.lua | 120 ------------------------------------------------ DragFrame.xml | 36 --------------- Features/DragFrame.lua | 97 ++++++++++++++++++++++++++++++++++++++ Features/DragFrame.xml | 36 +++++++++++++++ Features/Icon.lua | 39 ++++++++++++++++ Features/Timer.lua | 68 +++++++++++++++++++++++++++ Locale/enUS.lua | 14 ++++++ Options.lua | 23 ---------- loc/enUS.lua | 37 --------------- 11 files changed, 267 insertions(+), 247 deletions(-) delete mode 100644 DragFrame.lua delete mode 100644 DragFrame.xml create mode 100644 Features/DragFrame.lua create mode 100644 Features/DragFrame.xml create mode 100644 Features/Icon.lua create mode 100644 Features/Timer.lua create mode 100644 Locale/enUS.lua delete mode 100644 loc/enUS.lua diff --git a/Core.lua b/Core.lua index 5bd8aa1..8dfa71d 100644 --- a/Core.lua +++ b/Core.lua @@ -1,26 +1,3 @@ ---[[ - Copyright (c) 2014 Eyal Shilony - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -]] - local addonName, addon = ... local core = LibStub("Libra"):NewAddon(addonName, addon) diff --git a/DefaultCastingBar.toc b/DefaultCastingBar.toc index 0355a4c..731afe0 100644 --- a/DefaultCastingBar.toc +++ b/DefaultCastingBar.toc @@ -3,7 +3,7 @@ ## Author: Lynxium ## Title: Default: |cffEAE669CastingBar|r -## Notes: A lightweight casting bar that you can move. +## Notes: A lightweight casting bar that you can move and resize. ## Version: @project-version@ ## X-Category: Combat @@ -12,15 +12,20 @@ ## X-License: MIT. ## SavedVariables: DefaultCastingBarDb -libs\LibStub.lua -libs\CallbackHandler-1.0.lua -libs\AceLocale-3.0\AceLocale-3.0.xml -libs\AceDB-3.0\AceDB-3.0.xml -libs\Libra-34\Libra.xml +Libs\LibStub.lua +Libs\CallbackHandler-1.0.lua +Libs\AceLocale-3.0\AceLocale-3.0.xml +Libs\AceDB-3.0\AceDB-3.0.xml +Libs\Libra-36\Libra.xml -loc\enUS.lua +Locale\enUS.lua Core.lua -DragFrame.xml + +Features\Timer.lua +Features\Icon.lua +Features\DragFrame.xml + CastingBar.lua + Options.lua \ No newline at end of file diff --git a/DragFrame.lua b/DragFrame.lua deleted file mode 100644 index 0f5a970..0000000 --- a/DragFrame.lua +++ /dev/null @@ -1,120 +0,0 @@ ---[[ - Copyright (c) 2014 Eyal Shilony - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -]] - -local _, addon = ... -local dragFrame = addon:NewModule("DragFrame") - -local MIN_RESIZE_WIDTH = 128 -local MAX_RESIZE_WIDTH = 512 - -dragFrame.frame = DefaultCastingBar_DragFrame - -local function savePositionAndDimensions(self) - if not addon.db.profile.position then - addon.db.profile.position = {} - end - local point, _, relpoint, x, y = self:GetPoint() - addon.db.profile.position = { point, relpoint, x, y } - addon.db.profile.width = self:GetWidth() -end - -local function initPositionAndDimensions() - local position = addon.db.profile.position - if position then - local point, relpoint, x, y = unpack(position) - dragFrame.frame:ClearAllPoints() - dragFrame.frame:SetPoint(point, UIParent, relpoint, x, y) - end - dragFrame.frame:SetSize(addon.db.profile.width, addon.barMaxHeight) - dragFrame.frame.resizeButton:SetSize(addon.barMaxHeight, addon.barMaxHeight) -end - -function dragFrame:OnInitialize() - addon.db.RegisterCallback(addon, "OnProfileChanged", initPositionAndDimensions) - addon.db.RegisterCallback(addon, "OnProfileCopied", initPositionAndDimensions) - addon.db.RegisterCallback(addon, "OnProfileReset", initPositionAndDimensions) - - initPositionAndDimensions() - - SLASH_DEFAULTCASTINGBAR1 = "/dcb" - SlashCmdList["DEFAULTCASTINGBAR"] = function(input) - if dragFrame.frame:IsVisible() then - dragFrame.frame:Hide() - dragFrame.frame.resizeButton:Hide() - else - dragFrame.frame:Show() - dragFrame.frame.resizeButton:Show() - end - end - - self.frame:SetBackdropColor(0, 1, 0, 0.5) - self.frame.text = _G[self.frame:GetName().."Pos"] - - self.frame:EnableMouse(true) - - self.frame:SetResizable(true) - self.frame:SetMinResize(MIN_RESIZE_WIDTH, addon.barMaxHeight) - self.frame:SetMaxResize(MAX_RESIZE_WIDTH, addon.barMaxHeight) - - self.frame:SetMovable(true) - self.frame:SetClampedToScreen(true) - self.frame:Hide() -end - -dragFrame.frame:RegisterForDrag("LeftButton") -dragFrame.frame:SetScript("OnDragStart", function(self, button) - if button == "LeftButton" then - self:StartMoving() - end -end) - -dragFrame.frame:SetScript("OnDragStop", function(self) - savePositionAndDimensions(self) - - self:StopMovingOrSizing() -end) - -dragFrame.frame:SetScript('OnUpdate', function(self) - local x, y = self:GetLeft(), self:GetBottom() - if x and y then - self.text:SetText(("Left: %d Bottom: %d"):format(x , y)) - end -end) - -dragFrame.frame.resizeButton:SetScript('OnMouseDown', function(self) - self:SetButtonState("PUSHED", true) - - self:GetHighlightTexture():Hide() - - dragFrame.frame:StartSizing("BOTTOMRIGHT") -end) - -dragFrame.frame.resizeButton:SetScript('OnMouseUp', function(self) - self:SetButtonState("NORMAL", false) - - self:GetHighlightTexture():Show() - - savePositionAndDimensions(dragFrame.frame) - - dragFrame.frame:StopMovingOrSizing() -end) \ No newline at end of file diff --git a/DragFrame.xml b/DragFrame.xml deleted file mode 100644 index fb5bfae..0000000 --- a/DragFrame.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - -