diff --git a/Config.lua b/Config.lua deleted file mode 100644 index 8830589..0000000 --- a/Config.lua +++ /dev/null @@ -1,322 +0,0 @@ -local SharedMedia = LibStub('LibSharedMedia-3.0') - -local group, slider, dropdown, checkbox = LibStub('tekKonfig-Group'), LibStub('tekKonfig-Slider'), LibStub('tekKonfig-Dropdown'), LibStub('tekKonfig-Checkbox') - -local function updateStrings() - local font, size, flag = SharedMedia:Fetch('font', pMinimapDB.font), pMinimapDB.fontsize, pMinimapDB.fontflag - - MiniMapMailText:SetFont(font, size, flag) - MinimapZoneText:SetFont(font, size, flag) - MinimapCoordinatesText:SetFont(font, size, flag) - - if(pMinimapDB.clock) then - TimeManagerClockTicker:SetFont(font, size, flag) - end -end - -local function dropStrata(orig) - local info = UIDropDownMenu_CreateInfo() - info.func = function(self) - pMinimapDB.strata = self.value - Minimap:SetFrameStrata(self.value) - orig.text:SetText(self.value) - end - - for k, v in next, {'DIALOG', 'HIGH', 'MEDIUM', 'LOW', 'BACKGROUND'} do - info.text = v - info.value = v - UIDropDownMenu_AddButton(info) - end -end - -local function dropZone(orig) - local info = UIDropDownMenu_CreateInfo() - info.func = function(self) - pMinimapDB.zonepoint = self.value - MinimapZoneTextButton:ClearAllPoints() - if(pMinimapDB.zonefixed) then - MinimapZoneTextButton:SetPoint(self.value == 'BOTTOM' and 'BOTTOMLEFT' or 'TOPLEFT', Minimap, 0, pMinimapDB.zoneoffset) - MinimapZoneTextButton:SetPoint(self.value == 'BOTTOM' and 'BOTTOMRIGHT' or 'TOPRIGHT', Minimap, 0, pMinimapDB.zoneoffset) - else - MinimapZoneTextButton:SetPoint(self.value, Minimap, 0, pMinimapDB.zoneoffset) - MinimapZoneTextButton:SetWidth(Minimap:GetWidth() * 1.5) - end - orig.text:SetText(self.value) - end - - for k, v in next, {'TOP', 'BOTTOM'} do - info.text = v - info.value = v - UIDropDownMenu_AddButton(info) - end -end - -local function dropFont(orig) - local info = UIDropDownMenu_CreateInfo() - info.func = function(self) - pMinimapDB.font = self.value - orig.text:SetText(self.value) - updateStrings() - end - - for k, v in next, SharedMedia:List('font') do - info.text = v - info.value = v - UIDropDownMenu_AddButton(info) - end -end - -local function dropFontflag(orig) - local info = UIDropDownMenu_CreateInfo() - info.func = function(self) - pMinimapDB.fontflag = self.value - updateStrings() - orig.text:SetText(self.value) - end - - for k, v in next, {'OUTLINE', 'THICKOUTLINE', 'MONOCHROME', 'NONE'} do - info.text = v - info.value = v - UIDropDownMenu_AddButton(info) - end -end - -local function config(self) - local header = LibStub('tekKonfig-Heading').new(self, self.name) - - local info = self:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightLeft') - info:SetPoint('TOPLEFT', header, 0, 100) - info:SetWidth(300) - info:SetHeight(400) - info:SetText('Use the colums in the menu to the left to access the options.\n\nThis is most likely temporary, and will be cleaned up later.\n\n\nPlease visit the addon page over at\n|cff8080ffhttp://wowinterface.com/|r for more information and to ask for questions/report bugs.\n\nEnjoy!') -end - -local function minimap(self) - local scale, scaletext = slider.new(self, format('Scale: %.2f', pMinimapDB.scale), 0.5, 2.5, 'TOPLEFT', self, 15, -15) - scale:SetValueStep(0.01) - scale:SetValue(pMinimapDB.scale) - scale:SetScript('OnValueChanged', function(self, value) - pMinimapDB.scale = value - scaletext:SetFormattedText('Scale: %.2f', value) - Minimap:SetScale(value) - end) - - local level, leveltext = slider.new(self, 'Framelevel: '..pMinimapDB.level, 1, 15, 'TOPLEFT', scale, 'BOTTOMLEFT', 0, -30) - level:SetValueStep(1) - level:SetValue(pMinimapDB.level) - level:SetScript('OnValueChanged', function(self, value) - pMinimapDB.level = value - leveltext:SetFormattedText('Framelevel: %d', value) - pMinimap:SetFrameLevel(value) - end) - - local strata, stratatext = dropdown.new(self, 'Framestrata', 'LEFT', scale, 'RIGHT', 40, 0) - strata.text = stratatext - strata.text:SetText(pMinimapDB.strata) - UIDropDownMenu_Initialize(strata, dropStrata) - - local lock = checkbox.new(self, 22, 'Locked', 'LEFT', level, 'RIGHT', 45, 0) - lock:SetChecked(not pMinimap.unlocked) - lock:SetScript('OnClick', function() - pMinimap.unlocked = not pMinimap.unlocked - - if(pMinimap.unlocked) then - Minimap:SetBackdropColor(0, 1, 0, 0.5) - else - Minimap:SetBackdropColor(unpack(pMinimapDB.bordercolors)) - end - end) -end - -local function modules(self) - local coordinates = checkbox.new(self, 22, 'Coordinates', 'TOPLEFT', self, 10, -10) - coordinates:SetChecked(pMinimapDB.coordinates) - coordinates:SetScript('OnClick', function() - pMinimapDB.coordinates = not pMinimapDB.coordinates - - if(pMinimapDB.coordinates) then - MinimapCoordinates:Show() - MinimapCoordinates:ClearAllPoints() - MinimapCoordinates:SetPoint(pMinimapDB.clock and 'BOTTOMRIGHT' or 'BOTTOM') - else - MinimapCoordinates:Hide() - end - - if(pMinimapDB.clock) then - TimeManagerClockButton:ClearAllPoints() - TimeManagerClockButton:SetPoint(pMinimapDB.coordinates and 'BOTTOMLEFT' or 'BOTTOM', Minimap) - end - end) - - local coordinatesdecimals, cdtext = slider.new(self, 'Coord Decimals: '..pMinimapDB.coordinatesdecimals, 0, 3, 'TOPRIGHT', self, -15, -15) - coordinatesdecimals:SetValueStep(1) - coordinatesdecimals:SetValue(pMinimapDB.coordinatesdecimals) - coordinatesdecimals:SetScript('OnValueChanged', function(self, value) - pMinimapDB.coordinatesdecimals = value - cdtext:SetFormattedText('Coord Decimals: %d', value) - end) - - local clock = checkbox.new(self, 22, 'Clock', 'TOPLEFT', coordinates, 'BOTTOMLEFT', 0, -10) - clock:SetChecked(pMinimapDB.clock) - clock:SetScript('OnClick', function() - pMinimapDB.clock = not pMinimapDB.clock - - if(pMinimapDB.clock) then - if(not pMinimap:IsEventRegistered('CALENDAR_UPDATE_PENDING_INVITES')) then - pMinimap:Clock() - else - TimeManagerClockButton:ClearAllPoints() - TimeManagerClockButton:SetPoint(pMinimapDB.coordinates and 'BOTTOMLEFT' or 'BOTTOM', Minimap) - TimeManagerClockButton:SetScript('OnShow', nil) - TimeManagerClockButton:Show() - end - else - TimeManagerClockButton:Hide() - TimeManagerClockButton:SetScript('OnShow', pMinimap.ClockHook) - end - - if(pMinimapDB.coordinates) then - MinimapCoordinates:ClearAllPoints() - MinimapCoordinates:SetPoint(pMinimapDB.clock and 'BOTTOMRIGHT' or 'BOTTOM') - end - end) - - local mail = checkbox.new(self, 22, 'Mail', 'TOPLEFT', clock, 'BOTTOMLEFT', 0, -10) - mail:SetChecked(pMinimapDB.mail) - mail:SetScript('OnClick', function() - pMinimapDB.mail = not pMinimapDB.mail - - if(pMinimapDB.mail) then - MiniMapMailIcon:Hide() - MiniMapMailText:Show() - else - MiniMapMailIcon:Show() - MiniMapMailText:Hide() - end - end) - - local durability = checkbox.new(self, 22, 'Durability', 'LEFT', mail, 'RIGHT', 110, 0) - durability:SetChecked(pMinimapDB.durability) - durability:SetScript('OnClick', function() - pMinimapDB.durability = not pMinimapDB.durability - - if(pMinimapDB.durability) then - DurabilityFrame:SetAlpha(0) - pMinimap:RegisterEvent('UPDATE_INVENTORY_ALERTS') - pMinimap:UPDATE_INVENTORY_ALERTS() - else - DurabilityFrame:SetAlpha(1) - pMinimap:UnregisterEvent('UPDATE_INVENTORY_ALERTS') - Minimap:SetBackdropColor(unpack(pMinimapDB.bordercolors)) - end - end) -end - -local function background(self) - local borderoffset, borderoffsettext = slider.new(self, 'Thickness: '..pMinimapDB.borderoffset, 0, 10, 'TOPLEFT', self, 15, -15) - borderoffset:SetValueStep(1/2) - borderoffset:SetValue(pMinimapDB.borderoffset) - borderoffset:SetScript('OnValueChanged', function(self, value) - pMinimapDB.borderoffset = value - borderoffsettext:SetFormattedText('Thickness: %.1f', value) - Minimap:SetBackdrop({bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], insets = {top = -value, bottom = -value, left = -value, right = -value}}) - Minimap:SetBackdropColor(unpack(pMinimapDB.bordercolors)) - end) - - -- todo: color palette -end - -local function zone(self) - local zone = checkbox.new(self, 22, 'Zone Toggle', 'TOPLEFT', self, 10, -10) - zone:SetChecked(pMinimapDB.zone) - zone:SetScript('OnClick', function() - pMinimapDB.zone = not pMinimapDB.zone - - if(pMinimapDB.zone) then - MinimapZoneTextButton:Show() - else - MinimapZoneTextButton:Hide() - end - end) - - local zonepoint, zonepointtext = dropdown.new(self, 'Zone Point', 'TOPLEFT', zone, 'BOTTOMLEFT') - zonepoint.text = zonepointtext - zonepoint.text:SetText(pMinimapDB.zonepoint) - UIDropDownMenu_Initialize(zonepoint, dropZone) - - local zoneoffset, zoneoffsettext = slider.new(self, 'Zone Offset: '..pMinimapDB.zoneoffset, -45, 45, 'TOPRIGHT', self, -15, -15) - zoneoffset:SetValueStep(1) - zoneoffset:SetValue(pMinimapDB.zoneoffset) - zoneoffset:SetScript('OnValueChanged', function(self, value) - pMinimapDB.zoneoffset = value - zoneoffsettext:SetFormattedText('Zone Offset: %d', value) - - MinimapZoneTextButton:ClearAllPoints() - if(pMinimapDB.zonefixed) then - MinimapZoneTextButton:SetPoint(pMinimapDB.zonepoint == 'BOTTOM' and 'BOTTOMLEFT' or 'TOPLEFT', Minimap, 0, value) - MinimapZoneTextButton:SetPoint(pMinimapDB.zonepoint == 'BOTTOM' and 'BOTTOMRIGHT' or 'TOPRIGHT', Minimap, 0, value) - else - MinimapZoneTextButton:SetPoint(pMinimapDB.zonepoint, Minimap, 0, value) - MinimapZoneTextButton:SetWidth(Minimap:GetWidth() * 1.5) - end - end) - - local zonefixed = checkbox.new(self, 22, 'Zone Fixed Width', 'TOPLEFT', zonepoint, 'BOTTOMLEFT', 10, -10) - zonefixed:SetChecked(pMinimapDB.zonefixed) - zonefixed:SetScript('OnClick', function() - pMinimapDB.zonefixed = not pMinimapDB.zonefixed - - MinimapZoneTextButton:ClearAllPoints() - if(pMinimapDB.zonefixed) then - MinimapZoneTextButton:SetPoint(pMinimapDB.zonepoint == 'BOTTOM' and 'BOTTOMLEFT' or 'TOPLEFT', Minimap, 0, pMinimapDB.zoneoffset) - MinimapZoneTextButton:SetPoint(pMinimapDB.zonepoint == 'BOTTOM' and 'BOTTOMRIGHT' or 'TOPRIGHT', Minimap, 0, pMinimapDB.zoneoffset) - else - MinimapZoneTextButton:SetPoint(pMinimapDB.zonepoint, Minimap, 0, pMinimapDB.zoneoffset) - MinimapZoneTextButton:SetWidth(Minimap:GetWidth() * 1.5) - end - - zoneoffset:GetScript('OnValueChanged')(self, pMinimapDB.zoneoffset) - end) -end - -local function fonts(self) - local font, fonttext, fontcontainer = dropdown.new(self, 'Font', 'TOPLEFT', self, 10, -4) - font:SetWidth(180) - font.text = fonttext - font.text:SetText(pMinimapDB.font) - UIDropDownMenu_Initialize(font, dropFont) - - local fontflag, fontflagtext = dropdown.new(self, 'Font Flag', 'TOPLEFT', font, 'BOTTOMLEFT', 15, 0) - fontflag:SetWidth(180) - fontflag.text = fontflagtext - fontflag.text:SetText(pMinimapDB.fontflag) - UIDropDownMenu_Initialize(fontflag, dropFontflag) - - local fontsize, fontsizetext = slider.new(self, 'Font Size'..pMinimapDB.fontsize, 5, 18, 'TOPRIGHT', self, -15, -15) - fontsize:SetValueStep(1) - fontsize:SetValue(pMinimapDB.fontsize) - fontsize:SetScript('OnValueChanged', function(self, value) - pMinimapDB.fontsize = value - fontsizetext:SetFormattedText('Font Size: %d', value) - updateStrings() - end) -end - -local function spawn(name, func, parent) - local group = CreateFrame('Frame', nil, InterfaceOptionsFramePanelContainer) - group.name = name - group.parent = parent and 'pMinimap' - group.addonname = parent and 'pMinimap' - group:SetScript('OnShow', func) - group:HookScript('OnShow', function(self) self:SetScript('OnShow', nil) end) - - InterfaceOptions_AddCategory(group) - return group -end - -spawn('pMinimap', config):Hide() -spawn('Minimap', minimap, true) -spawn('Modules', modules, true) -spawn('Background', background, true) -spawn('Zone', zone, true) -spawn('Fonts', fonts, true) diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..172c817 --- /dev/null +++ b/LICENSE @@ -0,0 +1,6 @@ +Copyright (c) 2009, Adrian L Lange +All rights reserved. + +You're allowed to use this addon, free of monetary charge, +but you are not allowed to modify, alter, or redistribute +this addon without express, written permission of the author. \ No newline at end of file diff --git a/config/configuration.lua b/config/configuration.lua new file mode 100644 index 0000000..881b676 --- /dev/null +++ b/config/configuration.lua @@ -0,0 +1,161 @@ +local _, ns = ... + +local LSM = LibStub('LibSharedMedia-3.0') +local OBJECTS = { + Zone = 'MinimapZoneTextButton', + Difficulty = 'MiniMapInstanceDifficulty', + Battlefield = 'MiniMapBattlefieldFrame', + Dungeon = 'MiniMapLFGFrame', + Tracking = 'MiniMapTracking', + Clock = 'TimeManagerClockButton', + Mail = 'MiniMapMailFrame', +} + +function ns.UpdateObjects() + for name, setting in pairs(pMinimapDB.objects) do + local object = _G[OBJECTS[name]] + + if(setting.shown) then + object:SetAlpha(1) + object:EnableMouse(true) + else + object:SetAlpha(0) + object:EnableMouse(false) + end + + object:ClearAllPoints() + object:SetPoint(setting.point) + end +end + +function ns.UpdateCore() + Minimap:SetScale(pMinimapDB.minimap.scale) + Minimap:SetFrameStrata(pMinimapDB.minimap.strata) + Minimap:SetFrameLevel(pMinimapDB.minimap.level) + + local size = pMinimapDB.minimap.borderSize + Minimap:SetBackdrop({bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], insets = {left = -size, right = -size, top = -size, bottom = -size}}) + Minimap:SetBackdropColor(unpack(pMinimapDB.minimap.borderColors)) +end + +function ns.UpdateFont() + local font, size = LSM:Fetch('font', pMinimapDB.font.name), pMinimapDB.font.size + local flag = pMinimapDB.font.shadow .. (pMinimapDB.font.monochrome and 'MONOCHROME' or '') + + MinimapZoneText:SetFont(font, size, flag) + TimeManagerClockTicker:SetFont(font, size, flag) +end + + +local function AddConfig(name, func) + local group = CreateFrame('Frame', nil, InterfaceOptionsFramePanelContainer) + group.name = name + group:SetScript('OnShow', func) + group:HookScript('OnShow', function(self) self:SetScript('OnShow', nil) end) + + if(name ~= 'pMinimap') then + group.parent = 'pMinimap' + group.addonname = 'pMinimap' + end + + InterfaceOptions_AddCategory(group) +end + +AddConfig('pMinimap', function(self) + local scale = ns.slider(self, 'Scale', '%.1f', pMinimapDB.minimap.scale, 0.5, 2.5, 0.1, 'TOPLEFT', 30, -30) + scale:HookScript('OnValueChanged', function(frame, value) + pMinimapDB.minimap.scale = value + ns.UpdateCore() + end) + + local level = ns.slider(self, 'Frame Level', '%d', pMinimapDB.minimap.level, 0, 10, 1, 'TOPRIGHT', -30, -30) + level:HookScript('OnValueChanged', function(frame, value) + pMinimapDB.minimap.level = value + ns.UpdateCore() + end) + + local strata = ns.dropdown(self, 'Frame Strata', pMinimapDB.minimap.strata, {'HIGH', 'MEDIUM', 'LOW', 'BACKGROUND'}, + function(self) + pMinimapDB.minimap.strata = self.value + ns.UpdateCore() + end) + strata:SetPoint('TOPRIGHT', -10, -80) + + local background1 = self:CreateTexture(nil, 'BACKGROUND') + background1:SetPoint('TOPLEFT', scale, -20, 20) + background1:SetPoint('BOTTOMRIGHT', strata, 0, -5) + background1:SetTexture(0, 0, 0, 0.5) + + local borderSize = ns.slider(self, 'Border Thickness', '%d', pMinimapDB.minimap.borderSize, 0, 10, 1, 'LEFT', 30, 0) + borderSize:HookScript('OnValueChanged', function(frame, value) + pMinimapDB.minimap.borderSize = value + ns.UpdateCore() + end) + + local borderColor = ns.palette(self, 'Border Color', pMinimapDB.minimap.borderColors, 'RIGHT', -130, 0) + + local background2 = self:CreateTexture(nil, 'BACKGROUND') + background2:SetPoint('TOPLEFT', borderSize, -20, 20) + background2:SetPoint('BOTTOMRIGHT', borderColor, 120, -20) + background2:SetTexture(0, 0, 0, 0.5) + + ns.dropdown(self, 'Font', pMinimapDB.font.name, LSM:List('font'), + function(self) + pMinimapDB.font.name = self.value + ns.UpdateFont() + end + ):SetPoint('BOTTOMLEFT', 10, 20) + + local size = ns.slider(self, 'Font Size', '%d', pMinimapDB.font.size, 6, 36, 1, 'BOTTOMLEFT', 30, 80) + size:HookScript('OnValueChanged', function(frame, value) + pMinimapDB.font.size = value + ns.UpdateFont() + end) + + local shadow = ns.dropdown(self, 'Font Shadow', pMinimapDB.font.shadow, {'OUTLINE', 'THICKOUTLINE', 'NONE'}, + function(self) + pMinimapDB.font.shadow = self.value + ns.UpdateFont() + end) + shadow:SetPoint('BOTTOMRIGHT', -10, 20) + + local monochrome = ns.checkbox(self, 'Monochrome', 'BOTTOMRIGHT', -140, 75) + monochrome:SetChecked(pMinimapDB.font.monochrome) + monochrome:SetScript('OnClick', function() + pMinimapDB.font.monochrome = not pMinimapDB.font.monochrome + ns.UpdateFont() + end) + + local background3 = self:CreateTexture(nil, 'BACKGROUND') + background3:SetPoint('TOPLEFT', size, -20, 20) + background3:SetPoint('BOTTOMRIGHT', shadow, 0, -5) + background3:SetTexture(0, 0, 0, 0.5) +end) + +AddConfig('Objects', function(self) + local points = {'TOPLEFT', 'TOP', 'TOPRIGHT', 'LEFT', 'CENTER', 'RIGHT', 'BOTTOMLEFT', 'BOTTOM', 'BOTTOMRIGHT'} + local offset = 25 + + for name, setting in pairs(pMinimapDB.objects) do + local shown = ns.checkbox(self, name, 'TOPLEFT', 25, -offset) + shown:SetChecked(setting.shown) + shown:SetScript('OnClick', function() + setting.shown = not setting.shown + ns.UpdateObjects() + end) + + local position = ns.dropdown(self, name..' Position', setting.point, points, + function(self) + setting.point = self.value + ns.UpdateObjects() + end) + position:SetPoint('TOPRIGHT', -10, -offset) + + local background = self:CreateTexture(nil, 'BACKGROUND') + background:SetPoint('TOPLEFT', shown, -15, 15) + background:SetPoint('BOTTOMRIGHT', position) + background:SetTexture(0, 0, 0, 0.4) + + offset = offset + 60 + end +end) diff --git a/config/module.checkbox.lua b/config/module.checkbox.lua new file mode 100644 index 0000000..8be23f9 --- /dev/null +++ b/config/module.checkbox.lua @@ -0,0 +1,24 @@ +local _, ns = ... + +local NORMAL = [=[Interface\Buttons\UI-CheckBox-Up]=] +local PUSHED = [=[Interface\Buttons\UI-CheckBox-Down]=] +local CHECKED = [=[Interface\Buttons\UI-CheckBox-Check]=] +local HIGHLIGHT = [=[Interface\Buttons\UI-CheckBox-Highlight]=] + +function ns.checkbox(parent, str, ...) + local button = CreateFrame('CheckButton', nil, parent) + button:SetPoint(...) + button:SetSize(26, 26) + button:SetHitRectInsets(0, -100, 0, 0) + + button:SetNormalTexture(NORMAL) + button:SetPushedTexture(PUSHED) + button:SetCheckedTexture(CHECKED) + button:SetHighlightTexture(HIGHLIGHT) + + local label = button:CreateFontString(nil, 'ARTWORK', 'GameFontHighlight') + label:SetPoint('LEFT', button, 'RIGHT', 0, 1) + label:SetText(str) + + return button +end diff --git a/config/module.dropdown.lua b/config/module.dropdown.lua new file mode 100644 index 0000000..0687bce --- /dev/null +++ b/config/module.dropdown.lua @@ -0,0 +1,40 @@ +local _, ns = ... + +local GLUE = [=[Interface\Glues\CharacterCreate\CharacterCreate-LabelFrame]=] +local NORMAL = [=[Interface\ChatFrame\UI-ChatIcon-ScrollDown-Up]=] +local PUSHED = [=[Interface\ChatFrame\UI-ChatIcon-ScrollDown-Down]=] +local HIGHLIGHT = [=[Interface\Buttons\UI-Common-MouseHilight]=] + +function ns.dropdown(parent, str, default, values, func) + local container = CreateFrame('Button', nil, parent) + container:SetSize(180, 30) + + local frame = CreateFrame('Frame', 'pMinimapDropDown'..str, parent, 'UIDropDownMenuTemplate') + frame:SetPoint('TOPLEFT', container) + frame:EnableMouse(true) + + UIDropDownMenu_SetWidth(frame, 130) + UIDropDownMenu_Initialize(frame, function() + local info = UIDropDownMenu_CreateInfo() + info.notCheckable = true + info.func = function(self) + _G[frame:GetName()..'Text']:SetText(self.value) + func(self) + end + + for _, value in pairs(values) do + info.text = value + info.value = value + UIDropDownMenu_AddButton(info) + end + end) + + local label = container:CreateFontString(nil, 'BACKGROUND', 'GameFontNormalSmall') + label:SetPoint('BOTTOM', container, 'TOP') + label:SetText(str) + + _G['pMinimapDropDown'..str..'Text']:SetText(default) + + return container +end + diff --git a/config/module.palette.lua b/config/module.palette.lua new file mode 100644 index 0000000..5fb7c96 --- /dev/null +++ b/config/module.palette.lua @@ -0,0 +1,73 @@ +local _, ns = ... + +local SWATCH = [=[Interface\ChatFrame\ChatFrameColorSwatch]=] +local CHECKERS = [=[Tileset\Generic\Checkers]=] + +local function OnClick(self) + HideUIPanel(ColorPickerFrame) + + local origR, origG, origB, origA = unpack(pMinimapDB.minimap.borderColors) + ColorPickerFrame:SetFrameStrata('FULLSCREEN_DIALOG') + ColorPickerFrame.func = function() + local r, g, b = ColorPickerFrame:GetColorRGB() + local a = 1 - OpacitySliderFrame:GetValue() + self.swatch:SetVertexColor(r, g, b, a) + pMinimapDB.minimap.borderColors = {r, g, b, a} + ns.UpdateCore() + end + + ColorPickerFrame.hasOpacity = true + ColorPickerFrame.opacityFunc = function() + local r, g, b = ColorPickerFrame:GetColorRGB() + local a = 1 - OpacitySliderFrame:GetValue() + self.swatch:SetVertexColor(r, g, b, a) + pMinimapDB.minimap.borderColors = {r, g, b, a} + ns.UpdateCore() + end + + ColorPickerFrame.cancelFunc = function() + self.swatch:SetVertexColor(origR, origG, origB, origA) + pMinimapDB.minimap.borderColors = {origR, origG, origB, origA} + ns.UpdateCore() + end + + ColorPickerFrame.opacity = 1 - origA + ColorPickerFrame:SetColorRGB(origR, origG, origB) + ShowUIPanel(ColorPickerFrame) +end + +function ns.palette(parent, str, default, ...) + local container = CreateFrame('Button', nil, parent) + container:SetPoint(...) + container:SetSize(22, 22) + container:SetHitRectInsets(0, -100, 0, 0) + container:SetScript('OnClick', OnClick) + container:EnableMouse(true) + + local swatch = container:CreateTexture(nil, 'OVERLAY') + swatch:SetAllPoints() + swatch:SetTexture(SWATCH) + swatch:SetVertexColor(unpack(default)) + container.swatch = swatch + + local background = container:CreateTexture(nil, 'BACKGROUND') + background:SetPoint('CENTER') + background:SetSize(18, 18) + background:SetTexture(1, 1, 1) + + local checkers = container:CreateTexture(nil, 'BACKGROUND') + checkers:SetPoint('CENTER') + checkers:SetSize(17, 17) + checkers:SetTexture(CHECKERS) + checkers:SetTexCoord(0.25, 0, 0.5, 0.25) + checkers:SetDesaturated(true) + checkers:SetVertexColor(1, 1, 1, 0.75) + + local label = container:CreateFontString(nil, 'OVERLAY', 'GameFontHighlight') + label:SetPoint('LEFT', swatch, 'RIGHT', 2, 0) + label:SetHeight(24) + label:SetJustifyH('LEFT') + label:SetText(str) + + return container +end diff --git a/config/module.slider.lua b/config/module.slider.lua new file mode 100644 index 0000000..71a918b --- /dev/null +++ b/config/module.slider.lua @@ -0,0 +1,77 @@ +local _, ns = ... + +local THUMB = [=[Interface\Buttons\UI-SliderBar-Button-Horizontal]=] +local SLIDER = { + bgFile = [=[Interface\Buttons\UI-SliderBar-Background]=], + edgeFile = [=[Interface\Buttons\UI-SliderBar-Border]=], + edgeSize = 8, tile = true, tileSize = 8, + insets = {left = 3, right = 3, top = 6, bottom = 6}, +} + +local EDITBOX = { + bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], + edgeFile = [=[Interface\ChatFrame\ChatFrameBackground]=], + tile = true, edgeSize = 1, tileSize = 5, +} + +local function OnEnterPressed(self) + local value = tonumber(self:GetText()) + if(value) then + PlaySound('igMainMenuOptionCheckBoxOn') + self:GetParent():SetValue(value) + end +end + +local function OnEnter(self) + self:SetBackdropBorderColor(0.5, 0.5, 0.5, 1) +end + +local function OnLeave(self) + self:SetBackdropBorderColor(0.3, 0.3, 0.3, 0.8) +end + +function ns.slider(parent, str, formatting, cur, min, max, step, ...) + local slider = CreateFrame('Slider', nil, parent) + slider:SetPoint(...) + slider:SetSize(144, 16) + slider:SetBackdrop(SLIDER) + slider:SetThumbTexture(THUMB) + slider:SetOrientation('HORIZONTAL') + slider:SetMinMaxValues(min, max) + slider:SetValueStep(step) + slider:SetValue(cur) + + local left = slider:CreateFontString(nil, 'ARTWORK', 'GameFontHighlightSmall') + left:SetPoint('TOPLEFT', slider, 'BOTTOMLEFT', -4, 3) + left:SetText(min) + + local right = slider:CreateFontString(nil, 'ARTWORK', 'GameFontHighlightSmall') + right:SetPoint('TOPRIGHT', slider, 'BOTTOMRIGHT', 4, 3) + right:SetText(max) + + local label = slider:CreateFontString(nil, 'ARTWORK', 'GameFontNormal') + label:SetPoint('BOTTOM', slider, 'TOP') + label:SetText(str) + + local editbox = CreateFrame('EditBox', nil, slider) + editbox:SetPoint('TOP', slider, 'BOTTOM') + editbox:SetSize(40, 14) + editbox:SetAutoFocus(false) + editbox:SetFontObject(GameFontHighlightSmall) + editbox:SetBackdrop(EDITBOX) + editbox:SetBackdropColor(0, 0, 0, 0.5) + editbox:SetBackdropBorderColor(0.3, 0.3, 0.3, 0.8) + editbox:EnableMouse(true) + editbox:SetScript('OnEnter', OnEnter) + editbox:SetScript('OnLeave', OnLeave) + editbox:SetScript('OnEnterPressed', OnEnterPressed) + editbox:SetScript('OnEscapePressed', editbox.ClearFocus) + editbox:SetJustifyH('CENTER') + editbox:SetText(string.format(formatting, cur)) + + slider:SetScript('OnValueChanged', function(self, value) + editbox:SetText(string.format(formatting, value)) + end) + + return slider +end diff --git a/libs/CallbackHandler-1.0.lua b/libs/CallbackHandler-1.0.lua index 06befb3..5ad658f 100644 --- a/libs/CallbackHandler-1.0.lua +++ b/libs/CallbackHandler-1.0.lua @@ -1,4 +1,4 @@ ---[[ $Id: CallbackHandler-1.0.lua 504 2008-02-07 11:04:06Z nevcairiel $ ]] +--[[ $Id: CallbackHandler-1.0.lua 60548 2008-02-07 11:04:06Z nevcairiel $ ]] local MAJOR, MINOR = "CallbackHandler-1.0", 3 local CallbackHandler = LibStub:NewLibrary(MAJOR, MINOR) diff --git a/libs/tekKonfig/tekKonfig.xml b/libs/tekKonfig/tekKonfig.xml deleted file mode 100644 index dbbbb6b..0000000 --- a/libs/tekKonfig/tekKonfig.xml +++ /dev/null @@ -1,8 +0,0 @@ -<Ui xmlns='http://blizzard.com/wow/ui/'> - <Script file='tekKonfigCheckBox.lua'/> - <Script file='tekKonfigDropdown.lua'/> - <Script file='tekKonfigGroup.lua'/> - <Script file='tekKonfigHeading.lua'/> - <Script file='tekKonfigScroll.lua'/> - <Script file='tekKonfigSlider.lua'/> -</Ui> \ No newline at end of file diff --git a/libs/tekKonfig/tekKonfigCheckbox.lua b/libs/tekKonfig/tekKonfigCheckbox.lua deleted file mode 100644 index d03f108..0000000 --- a/libs/tekKonfig/tekKonfigCheckbox.lua +++ /dev/null @@ -1,46 +0,0 @@ - -local lib, oldminor = LibStub:NewLibrary("tekKonfig-Checkbox", 1) -if not lib then return end - - -local GameTooltip = GameTooltip -local function HideTooltip() GameTooltip:Hide() end -local function ShowTooltip(self) - if self.tiptext then - GameTooltip:SetOwner(self, "ANCHOR_RIGHT") - GameTooltip:SetText(self.tiptext, nil, nil, nil, nil, true) - end -end -local function OnClick(self) PlaySound(self:GetChecked() and "igMainMenuOptionCheckBoxOn" or "igMainMenuOptionCheckBoxOff") end - - --- Creates a checkbox. --- All args optional but parent is highly recommended -function lib.new(parent, size, label, ...) - local check = CreateFrame("CheckButton", nil, parent) - check:SetWidth(size or 26) - check:SetHeight(size or 26) - if select(1, ...) then check:SetPoint(...) end - - check:SetHitRectInsets(0, -100, 0, 0) - - check:SetNormalTexture("Interface\\Buttons\\UI-CheckBox-Up") - check:SetPushedTexture("Interface\\Buttons\\UI-CheckBox-Down") - check:SetHighlightTexture("Interface\\Buttons\\UI-CheckBox-Highlight") - check:SetDisabledCheckedTexture("Interface\\Buttons\\UI-CheckBox-Check-Disabled") - check:SetCheckedTexture("Interface\\Buttons\\UI-CheckBox-Check") - - -- Tooltip bits - check:SetScript("OnEnter", ShowTooltip) - check:SetScript("OnLeave", HideTooltip) - - -- Sound - check:SetScript("OnClick", OnClick) - - -- Label - local fs = check:CreateFontString(nil, "ARTWORK", "GameFontHighlight") - fs:SetPoint("LEFT", check, "RIGHT", 0, 1) - fs:SetText(label) - - return check, fs -end diff --git a/libs/tekKonfig/tekKonfigDropdown.lua b/libs/tekKonfig/tekKonfigDropdown.lua deleted file mode 100644 index 2ff43ab..0000000 --- a/libs/tekKonfig/tekKonfigDropdown.lua +++ /dev/null @@ -1,86 +0,0 @@ - -local lib, oldminor = LibStub:NewLibrary("tekKonfig-Dropdown", 3) -if not lib then return end -oldminor = oldminor or 0 - - -local GameTooltip = GameTooltip -local function HideTooltip() GameTooltip:Hide() end -local function ShowTooltip(self) - if self.frame.tiptext then - GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT") - GameTooltip:SetText(self.frame.tiptext, nil, nil, nil, nil, true) - end -end -local function ShowTooltip2(self) ShowTooltip(self.container) end - - -local function OnClick(self) - ToggleDropDownMenu(nil, nil, self:GetParent()) - PlaySound("igMainMenuOptionCheckBoxOn") -end - -local function OnHide() CloseDropDownMenus() end - - --- Create a dropdown. --- All args optional, parent recommended -function lib.new(parent, label, ...) - local container = CreateFrame("Button", nil, parent) - container:SetWidth(149+13) container:SetHeight(32+24) - container:SetScript("OnEnter", ShowTooltip) - container:SetScript("OnLeave", HideTooltip) - if select("#", ...) > 0 then container:SetPoint(...) end - - local name = "tekKonfigDropdown"..GetTime() -- Sadly, some of these frames must be named - local f = CreateFrame("Frame", name, parent) - f:SetWidth(149) f:SetHeight(32) - f:SetPoint("TOPLEFT", container, -13, -24) - f:EnableMouse(true) - f:SetScript("OnHide", OnHide) - container.frame = f - - local ltex = f:CreateTexture(name.."Left", "ARTWORK") - ltex:SetWidth(25) ltex:SetHeight(64) - ltex:SetPoint("TOPLEFT", 0, 17) - ltex:SetTexture("Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame") - ltex:SetTexCoord(0, 0.1953125, 0, 1) - - local rtex = f:CreateTexture(nil, "ARTWORK") - rtex:SetWidth(25) rtex:SetHeight(64) - rtex:SetPoint("RIGHT") - rtex:SetTexture("Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame") - rtex:SetTexCoord(0.8046875, 1, 0, 1) - - local mtex = f:CreateTexture(nil, "ARTWORK") - mtex:SetWidth(115) mtex:SetHeight(64) - mtex:SetPoint("LEFT", ltex, "RIGHT") - mtex:SetPoint("RIGHT", rtex, "LEFT") - mtex:SetTexture("Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame") - mtex:SetTexCoord(0.1953125, 0.8046875, 0, 1) - - local text = f:CreateFontString(name.."Text", "ARTWORK", "GameFontHighlightSmall") - text:SetWidth(0) text:SetHeight(10) - text:SetPoint("RIGHT", rtex, -43, 2) - text:SetJustifyH("RIGHT") - - local button = CreateFrame("Button", nil, f) - button:SetWidth(24) button:SetHeight(24) - button:SetPoint("TOPRIGHT", rtex, -16, -18) - button:SetScript("OnClick", OnClick) - button:SetScript("OnEnter", ShowTooltip2) - button.container = container - - button:SetNormalTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Up") - button:SetPushedTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Down") - button:SetHighlightTexture("Interface\\Buttons\\UI-Common-MouseHilight") - button:SetDisabledTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Disabled") - button:GetHighlightTexture():SetBlendMode("ADD") - - local labeltext = f:CreateFontString(nil, "BACKGROUND", "GameFontNormal")--GameFontHighlight - labeltext:SetPoint("BOTTOMLEFT", container, "TOPLEFT", 16-13, 3-24) - labeltext:SetText(label) - - return f, text, container, labeltext -end - diff --git a/libs/tekKonfig/tekKonfigGroup.lua b/libs/tekKonfig/tekKonfigGroup.lua deleted file mode 100644 index d406c54..0000000 --- a/libs/tekKonfig/tekKonfigGroup.lua +++ /dev/null @@ -1,31 +0,0 @@ - -local lib, oldminor = LibStub:NewLibrary("tekKonfig-Group", 2) -if not lib then return end - -lib.bg = { - bgFile = "Interface\\ChatFrame\\ChatFrameBackground", - edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", - tile = true, - tileSize = 16, - edgeSize = 16, - insets = { left = 5, right = 5, top = 5, bottom = 5 } -} - - --- Creates a background box to place behind widgets for visual grouping. --- All args optional, parent highly recommended -function lib.new(parent, label, ...) - local box = CreateFrame('Frame', nil, parent) - box:SetBackdrop(lib.bg) - box:SetBackdropBorderColor(0.4, 0.4, 0.4) - box:SetBackdropColor(0.1, 0.1, 0.1) - if select('#',...) > 0 then box:SetPoint(...) end - - if label then - local fs = box:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall") - fs:SetPoint("BOTTOMLEFT", box, "TOPLEFT", 16, 0) - fs:SetText(label) - end - - return box -end diff --git a/libs/tekKonfig/tekKonfigHeading.lua b/libs/tekKonfig/tekKonfigHeading.lua deleted file mode 100644 index 2c0dc1e..0000000 --- a/libs/tekKonfig/tekKonfigHeading.lua +++ /dev/null @@ -1,24 +0,0 @@ - -local lib, oldminor = LibStub:NewLibrary("tekKonfig-Heading", 1) -if not lib then return end - - --- Creates a heading and subheading --- parent is required, texts are optional -function lib.new(parent, text, subtext) - local title = parent:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge") - title:SetPoint("TOPLEFT", 16, -16) - title:SetText(text) - - local subtitle = parent:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall") - subtitle:SetHeight(32) - subtitle:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -8) - subtitle:SetPoint("RIGHT", parent, -32, 0) ---~ nonSpaceWrap="true" maxLines="3" - subtitle:SetNonSpaceWrap(true) - subtitle:SetJustifyH("LEFT") - subtitle:SetJustifyV("TOP") - subtitle:SetText(subtext) - - return title, subtitle -end diff --git a/libs/tekKonfig/tekKonfigScroll.lua b/libs/tekKonfig/tekKonfigScroll.lua deleted file mode 100644 index ff69b13..0000000 --- a/libs/tekKonfig/tekKonfigScroll.lua +++ /dev/null @@ -1,80 +0,0 @@ - -local lib, oldminor = LibStub:NewLibrary("tekKonfig-Scroll", 2) -if not lib then return end - -lib.bg = { - edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", - tile = true, - tileSize = 16, - edgeSize = 12, - insets = { left = 0, right = 0, top = 5, bottom = 5 } -} - --- Creates a scrollbar --- Parent is required, offset and step are optional -function lib.new(parent, offset, step) - local f = CreateFrame("Slider", nil, parent) - f:SetWidth(16) - - f:SetPoint("TOPRIGHT", 0 - (offset or 0), -16 - (offset or 0)) - f:SetPoint("BOTTOMRIGHT", 0 - (offset or 0), 16 + (offset or 0)) - - local up = CreateFrame("Button", nil, f) - up:SetPoint("BOTTOM", f, "TOP") - up:SetWidth(16) up:SetHeight(16) - up:SetNormalTexture("Interface\\Buttons\\UI-ScrollBar-ScrollUpButton-Up") - up:SetPushedTexture("Interface\\Buttons\\UI-ScrollBar-ScrollUpButton-Down") - up:SetDisabledTexture("Interface\\Buttons\\UI-ScrollBar-ScrollUpButton-Disabled") - up:SetHighlightTexture("Interface\\Buttons\\UI-ScrollBar-ScrollUpButton-Highlight") - - up:GetNormalTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4) - up:GetPushedTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4) - up:GetDisabledTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4) - up:GetHighlightTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4) - up:GetHighlightTexture():SetBlendMode("ADD") - - up:SetScript("OnClick", function(self) - local parent = self:GetParent() - parent:SetValue(parent:GetValue() - (step or parent:GetHeight()/2)) - PlaySound("UChatScrollButton") - end) - - local down = CreateFrame("Button", nil, f) - down:SetPoint("TOP", f, "BOTTOM") - down:SetWidth(16) down:SetHeight(16) - down:SetNormalTexture("Interface\\Buttons\\UI-ScrollBar-ScrollDownButton-Up") - down:SetPushedTexture("Interface\\Buttons\\UI-ScrollBar-ScrollDownButton-Down") - down:SetDisabledTexture("Interface\\Buttons\\UI-ScrollBar-ScrollDownButton-Disabled") - down:SetHighlightTexture("Interface\\Buttons\\UI-ScrollBar-ScrollDownButton-Highlight") - - down:GetNormalTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4) - down:GetPushedTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4) - down:GetDisabledTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4) - down:GetHighlightTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4) - down:GetHighlightTexture():SetBlendMode("ADD") - - down:SetScript("OnClick", function(self) - local parent = self:GetParent() - parent:SetValue(parent:GetValue() + (step or parent:GetHeight()/2)) - PlaySound("UChatScrollButton") - end) - - f:SetThumbTexture("Interface\\Buttons\\UI-ScrollBar-Knob") - local thumb = f:GetThumbTexture() - thumb:SetWidth(16) thumb:SetHeight(24) - thumb:SetTexCoord(1/4, 3/4, 1/8, 7/8) - - f:SetScript("OnValueChanged", function(self, value) - local min, max = self:GetMinMaxValues() - if value == min then up:Disable() else up:Enable() end - if value == max then down:Disable() else down:Enable() end - end) - - local border = CreateFrame("Frame", nil, f) - border:SetPoint("TOPLEFT", up, -5, 5) - border:SetPoint("BOTTOMRIGHT", down, 5, -3) - border:SetBackdrop(lib.bg) - border:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b, 0.5) - - return f, up, down, border -end diff --git a/libs/tekKonfig/tekKonfigSlider.lua b/libs/tekKonfig/tekKonfigSlider.lua deleted file mode 100644 index 20f9ca8..0000000 --- a/libs/tekKonfig/tekKonfigSlider.lua +++ /dev/null @@ -1,85 +0,0 @@ - -local lib, oldminor = LibStub:NewLibrary("tekKonfig-Slider", 3) -if not lib then return end -oldminor = oldminor or 0 - - -local GameTooltip = GameTooltip -local function HideTooltip() GameTooltip:Hide() end -local function ShowTooltip(self) - if self.tiptext then - GameTooltip:SetOwner(self, "ANCHOR_RIGHT") - GameTooltip:SetText(self.tiptext, nil, nil, nil, nil, true) - end -end - - -local HorizontalSliderBG = { - bgFile = "Interface\\Buttons\\UI-SliderBar-Background", - edgeFile = "Interface\\Buttons\\UI-SliderBar-Border", - edgeSize = 8, tile = true, tileSize = 8, - insets = {left = 3, right = 3, top = 6, bottom = 6} -} - - -if oldminor < 2 then - -- Create a slider. - -- All args optional, parent recommended - -- If lowvalue and highvalue are strings it is assumed they are % values - -- and the % is parsed and set as decimal values for min/max - function lib.new(parent, label, lowvalue, highvalue, ...) - local container = CreateFrame("Frame", nil, parent) - container:SetWidth(144) - container:SetHeight(17+12+10) - if select(1, ...) then container:SetPoint(...) end - - local slider = CreateFrame("Slider", nil, container) - slider:SetPoint("LEFT") - slider:SetPoint("RIGHT") - slider:SetHeight(17) - slider:SetHitRectInsets(0, 0, -10, -10) - slider:SetOrientation("HORIZONTAL") - slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Horizontal") -- Dim: 32x32... can't find API to set this? - slider:SetBackdrop(HorizontalSliderBG) - - local text = slider:CreateFontString(nil, "ARTWORK", "GameFontNormal") - text:SetPoint("BOTTOM", slider, "TOP") - text:SetText(label) - - local low = slider:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall") - low:SetPoint("TOPLEFT", slider, "BOTTOMLEFT", -4, 3) - low:SetText(lowvalue) - - local high = slider:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall") - high:SetPoint("TOPRIGHT", slider, "BOTTOMRIGHT", 4, 3) - high:SetText(highvalue) - - if type(lowvalue) == "string" then slider:SetMinMaxValues(tonumber((lowvalue:gsub("%%", "")))/100, tonumber((highvalue:gsub("%%", "")))/100) - else slider:SetMinMaxValues(lowvalue, highvalue) end - - -- Tooltip bits - slider:SetScript("OnEnter", ShowTooltip) - slider:SetScript("OnLeave", HideTooltip) - - return slider, text, container, low, high - end -end - - --- Create a slider without labels. --- All args optional, parent recommended -function lib.newbare(parent, ...) - local slider = CreateFrame("Slider", nil, parent) - slider:SetHeight(17) - slider:SetWidth(144) - if select(1, ...) then slider:SetPoint(...) end - slider:SetOrientation("HORIZONTAL") - slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Horizontal") -- Dim: 32x32... can't find API to set this? - slider:SetBackdrop(HorizontalSliderBG) - - -- Tooltip bits - slider:SetScript("OnEnter", ShowTooltip) - slider:SetScript("OnLeave", HideTooltip) - - return slider -end diff --git a/media/font.ttf b/media/font.ttf deleted file mode 100644 index 04ce123..0000000 Binary files a/media/font.ttf and /dev/null differ diff --git a/pMinimap.lua b/pMinimap.lua index 85cf1a6..18a6bc8 100644 --- a/pMinimap.lua +++ b/pMinimap.lua @@ -1,100 +1,35 @@ ---[[ - - Copyright (c) 2009, Adrian L Lange - All rights reserved. - - You're allowed to use this addon, free of monetary charge, - but you are not allowed to modify, alter, or redistribute - this addon without express, written permission of the author. - ---]] - -local addon = CreateFrame('Frame', 'pMinimap', Minimap) -addon:SetScript('OnEvent', function(self, event, ...) self[event](self, event, ...) end) -addon:RegisterEvent('ADDON_LOADED') - -local SharedMedia = LibStub('LibSharedMedia-3.0') -local defaults = { - font = 'Visitor TT1', - fontsize = 13, - fontflag = 'OUTLINE', - zone = false, - zonepoint = 'TOP', - zoneoffset = 16, - zonefixed = false, - scale = 0.9, - level = 2, - strata = 'BACKGROUND', - borderoffset = 1, - bordercolors = {0, 0, 0, 1}, - mail = true, - clock = true, - durabilty = true, - coordinates = false, - coordinatesdecimals = 0, +local _, ns = ... + +pMinimap = CreateFrame('Frame', 'pMinimap', Minimap) +pMinimap:SetScript('OnEvent', function(self, event, ...) self[event](self, ...) end) +pMinimap:RegisterEvent('ADDON_LOADED') + +local DEFAULTS = { + minimap = { + scale = 0.9, + level = 2, + strata = 'BACKGROUND', + borderSize = 1, + borderColors = {0, 0, 0, 1}, + }, + objects = { + Zone = {point = 'TOP', shown = false}, + Difficulty = {point = 'BOTTOM', shown = false}, + Battlefield = {point = 'TOPRIGHT', shown = true}, + Dungeon = {point = 'TOPRIGHT', shown = true}, + Tracking = {point = 'TOPLEFT', shown = true}, + Clock = {point = 'BOTTOM', shown = true}, + Mail = {point = 'BOTTOMRIGHT', shown = true}, + }, + font = { + name = LibStub('LibSharedMedia-3.0'):GetDefault('font'), + size = 12, + shadow = 'OUTLINE', + monochrome = false, + }, } -function addon:ClockHook() - self:Hide() -end - -function addon:Clock() - TimeManagerClockButton:GetRegions():Hide() - TimeManagerClockButton:ClearAllPoints() - TimeManagerClockButton:SetPoint(pMinimapDB.coordinates and 'BOTTOMLEFT' or 'BOTTOM', Minimap) - TimeManagerClockButton:SetWidth(40) - TimeManagerClockButton:SetHeight(14) - TimeManagerClockButton:SetScript('OnShow', nil) - TimeManagerClockButton:Show() - TimeManagerClockButton:SetScript('OnClick', function(self, button) - if(button == 'RightButton') then - ToggleCalendar() - else - if(self.alarmFiring) then - PlaySound('igMainMenuQuit') - TimeManager_TurnOffAlarm() - else - ToggleTimeManager() - end - end - end) - - TimeManagerClockTicker:SetPoint('CENTER', TimeManagerClockButton) - TimeManagerClockTicker:SetFont(SharedMedia:Fetch('font', pMinimapDB.font), pMinimapDB.fontsize, pMinimapDB.fontflag) - TimeManagerClockTicker:SetShadowOffset(0, 0) - - TimeManagerAlarmFiredTexture.Show = function() TimeManagerClockTicker:SetTextColor(1, 0, 0) end - TimeManagerAlarmFiredTexture.Hide = function() TimeManagerClockTicker:SetTextColor(1, 1, 1) end - - self:RegisterEvent('CALENDAR_UPDATE_PENDING_INVITES') - self.CALENDAR_UPDATE_PENDING_INVITES() -end - -function addon:OnClick(button) - if(button == 'RightButton') then - ToggleBattlefieldMinimap() - else - ToggleFrame(WorldMapFrame) - end -end - -function addon:OnUpdate(elapsed) - if(self.total <= 0) then - local x, y = GetPlayerMapPosition('player') - if(x ~= 0 and y ~= 0) then - MinimapCoordinatesText:SetFormattedText('%.' .. pMinimapDB.coordinatesdecimals .. 'f,%.' .. pMinimapDB.coordinatesdecimals .. 'f', x * 100, y * 100) - else - MinimapCoordinatesText:SetText() - end - - self.total = 0.25 - else - self.total = self.total - elapsed - end -end - -function addon:Style() - -- Mousewheel zoom +function pMinimap:Init() MinimapZoomIn:Hide() MinimapZoomOut:Hide() Minimap:EnableMouseWheel() @@ -106,192 +41,73 @@ function addon:Style() end end) - -- Tracking icon - MiniMapTracking:ClearAllPoints() + Minimap:SetMaskTexture([=[Interface\ChatFrame\ChatFrameBackground]=]) + MinimapCluster:EnableMouse(false) + MinimapBorder:SetTexture(nil) + MinimapBorderTop:Hide() + MinimapNorthTag:SetAlpha(0) + MiniMapWorldMapButton:Hide() + GameTimeFrame:Hide() + MiniMapTracking:SetParent(Minimap) - MiniMapTracking:SetPoint('TOPLEFT', -2, 2) MiniMapTrackingBackground:Hide() MiniMapTrackingButtonBorder:SetTexture(nil) MiniMapTrackingButton:SetHighlightTexture(nil) MiniMapTrackingIconOverlay:SetTexture(nil) MiniMapTrackingIcon:SetTexCoord(0.065, 0.935, 0.065, 0.935) - -- LFG - MiniMapLFGFrame:ClearAllPoints() MiniMapLFGFrame:SetParent(Minimap) - MiniMapLFGFrame:SetPoint('TOPRIGHT', 0, 2) MiniMapLFGFrame:SetHighlightTexture(nil) MiniMapLFGFrameBorder:Hide() + LFDSearchStatus:SetClampedToScreen(true) - -- Battlefield icon - MiniMapBattlefieldFrame:ClearAllPoints() MiniMapBattlefieldFrame:SetParent(Minimap) - MiniMapBattlefieldFrame:SetPoint('TOPRIGHT', -2, -2) MiniMapBattlefieldBorder:SetTexture(nil) BattlegroundShine:Hide() - -- Mail text - MiniMapMailFrame:ClearAllPoints() MiniMapMailFrame:SetParent(Minimap) - MiniMapMailFrame:SetPoint('TOP', 0, -4) - MiniMapMailFrame:SetHeight(8) MiniMapMailBorder:SetTexture(nil) - MiniMapMailText = MiniMapMailFrame:CreateFontString(nil, 'OVERLAY') - MiniMapMailText:SetPoint('BOTTOM', 0, 2) - MiniMapMailText:SetFont(SharedMedia:Fetch('font', pMinimapDB.font), pMinimapDB.fontsize, pMinimapDB.fontflag) - MiniMapMailText:SetTextColor(1, 1, 1) - MiniMapMailText:SetText('New Mail!') - - if(pMinimapDB.mail) then - MiniMapMailIcon:Hide() - else - MiniMapMailText:Hide() - end - - -- Coordinates - MinimapCoordinates = CreateFrame('Button', nil, Minimap) - MinimapCoordinates:SetPoint(pMinimapDB.clock and 'BOTTOMRIGHT' or 'BOTTOM') - MinimapCoordinates:SetWidth(40) - MinimapCoordinates:SetHeight(14) - MinimapCoordinates:RegisterForClicks('AnyUp') - MinimapCoordinates:SetScript('OnClick', self.OnClick) - MinimapCoordinates:SetScript('OnUpdate', self.OnUpdate) - MinimapCoordinates.total = 0.25 - - MinimapCoordinatesText = MinimapCoordinates:CreateFontString(nil, 'OVERLAY') - MinimapCoordinatesText:SetPoint('BOTTOMRIGHT', MinimapCoordinates) - MinimapCoordinatesText:SetFont(SharedMedia:Fetch('font', pMinimapDB.font), pMinimapDB.fontsize, pMinimapDB.fontflag) - MinimapCoordinatesText:SetTextColor(1, 1, 1) - - if(not pMinimapDB.coordinates) then - MinimapCoordinates:Hide() - end - - -- Zone text - MinimapZoneText:SetAllPoints(MinimapZoneTextButton) - MinimapZoneText:SetFont(SharedMedia:Fetch('font', pMinimapDB.font), pMinimapDB.fontsize, pMinimapDB.fontflag) - MinimapZoneText:SetShadowOffset(0, 0) - - MinimapZoneTextButton:ClearAllPoints() MinimapZoneTextButton:SetParent(Minimap) + MinimapZoneText:SetShadowOffset(0, 0) - if(not pMinimapDB.zone) then - MinimapZoneTextButton:Hide() - end - - if(pMinimapDB.zonefixed) then - MinimapZoneTextButton:SetPoint(pMinimapDB.zonepoint == 'BOTTOM' and 'BOTTOMLEFT' or 'TOPLEFT', Minimap, 0, pMinimapDB.zoneoffset) - MinimapZoneTextButton:SetPoint(pMinimapDB.zonepoint == 'BOTTOM' and 'BOTTOMRIGHT' or 'TOPRIGHT', Minimap, 0, pMinimapDB.zoneoffset) - else - MinimapZoneTextButton:SetPoint(pMinimapDB.zonepoint, Minimap, 0, pMinimapDB.zoneoffset) - MinimapZoneTextButton:SetWidth(Minimap:GetWidth() * 1.5) + if(not IsAddOnLoaded('Blizzard_TimeManager')) then + LoadAddOn('Blizzard_TimeManager') end - -- Misc textures/icons/texts - MinimapBorder:SetTexture(nil) - MinimapBorderTop:Hide() - MinimapNorthTag:SetAlpha(0) - MiniMapInstanceDifficulty:SetAlpha(0) - MiniMapWorldMapButton:Hide() - GameTimeFrame:Hide() - - -- Inject settings - Minimap:SetScale(pMinimapDB.scale) - Minimap:SetFrameLevel(pMinimapDB.level) - Minimap:SetFrameStrata(pMinimapDB.strata) - Minimap:SetMaskTexture([=[Interface\ChatFrame\ChatFrameBackground]=]) - Minimap:SetBackdrop({bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], insets = {top = - pMinimapDB.borderoffset, bottom = - pMinimapDB.borderoffset, left = - pMinimapDB.borderoffset, right = - pMinimapDB.borderoffset}}) - Minimap:SetBackdropColor(unpack(pMinimapDB.bordercolors)) - - Minimap:RegisterForDrag('LeftButton') - Minimap:SetMovable(true) - Minimap:SetScript('OnDragStop', function() if(self.unlocked) then Minimap:StopMovingOrSizing() end end) - Minimap:SetScript('OnDragStart', function() if(self.unlocked) then Minimap:StartMoving() end end) - MinimapCluster:EnableMouse(false) - - -- Modules - if(pMinimapDB.durability) then - DurabilityFrame:SetAlpha(0) - - self:RegisterEvent('UPDATE_INVENTORY_ALERTS') - self:UPDATE_INVENTORY_ALERTS() - end -end + TimeManagerClockButton:GetRegions():Hide() + TimeManagerClockButton:SetSize(40, 14) + TimeManagerClockTicker:SetPoint('CENTER', TimeManagerClockButton) + TimeManagerClockTicker:SetShadowOffset(0, 0) -function addon.Command(str) - if(str == 'reset') then - pMinimapDB = defaults - print('|cffff8080pMinimap:|r Settings reset. You should reload/relog to affect changes.') - else - InterfaceOptionsFrame_OpenToCategory(addon:GetName()) - end + ns.UpdateObjects() + ns.UpdateCore() + ns.UpdateFont() end -function addon:ADDON_LOADED(event, name) - if(name == self:GetName()) then - SharedMedia:Register('font', 'Visitor TT1', [=[Interface\AddOns\pMinimap\media\font.ttf]=]) - - SLASH_pMinimap1 = '/pmm' - SLASH_pMinimap2 = '/pminimap' - SlashCmdList[name] = self.Command - - self.unlocked = false - pMinimapDB = setmetatable(pMinimapDB or {}, {__index = defaults}) - self:RegisterEvent('ZONE_CHANGED_NEW_AREA') - self:RegisterEvent('VARIABLES_LOADED') - - self:Style() - elseif(name == 'Blizzard_TimeManager') then - TimeManagerClockButton:SetScript('OnShow', self.ClockHook) - TimeManagerClockButton:Hide() +function pMinimap:ADDON_LOADED(addon) + if(addon ~= 'pMinimap') then return end - if(pMinimapDB.clock) then - self:Clock() - end - - for k, v in next, {InterfaceOptionsDisplayPanelShowClock} do - v:SetButtonState('DISABLED', true) - end + SLASH_pMinimap1 = '/pmm' + SLASH_pMinimap2 = '/pminimap' + SlashCmdList.pMinimap = function() + InterfaceOptionsFrame_OpenToCategory('pMinimap') end -end -function addon:VARIABLES_LOADED(event) - SetCVar('showClock', '1') + pMinimapDB = pMinimapDB or DEFAULTS - if(not IsAddOnLoaded('Blizzard_TimeManager')) then - LoadAddOn('Blizzard_TimeManager') - elseif(not self:IsEventRegistered('CALENDAR_UPDATE_PENDING_INVITES')) then - self:ADDON_LOADED(event, 'Blizzard_TimeManager') - end -end + self:RegisterEvent('VARIABLES_LOADED') + self:Init() -function addon:CALENDAR_UPDATE_PENDING_INVITES() - if(CalendarGetNumPendingInvites() ~= 0) then - TimeManagerClockTicker:SetTextColor(0, 1, 0) - else - TimeManagerClockTicker:SetTextColor(1, 1, 1) - end + -- Don't let Blizzard fuck up things for me + InterfaceOptionsDisplayPanelShowClock:SetButtonState('DISABLED', true) end -function addon:UPDATE_INVENTORY_ALERTS() - local highstatus = 0 - for k in next, INVENTORY_ALERT_STATUS_SLOTS do - local status = GetInventoryAlertStatus(k) - highstatus = status > highstatus and status or highstatus - end - - local color = INVENTORY_ALERT_COLORS[highstatus] - if(color) then - Minimap:SetBackdropColor(color.r, color.g, color.b) - else - Minimap:SetBackdropColor(unpack(pMinimapDB.bordercolors)) - end +function pMinimap:VARIABLES_LOADED() + SetCVar('showClock', '1') end -function addon:ZONE_CHANGED_NEW_AREA() - SetMapToCurrentZone() +-- http://wowwiki.com/GetMinimapShape +function GetMinimapShape() + return 'SQUARE' end - --- http://www.wowwiki.com/GetMinimapShape -function GetMinimapShape() return 'SQUARE' end diff --git a/pMinimap.toc b/pMinimap.toc index 76f97a5..ba069ab 100644 --- a/pMinimap.toc +++ b/pMinimap.toc @@ -1,7 +1,7 @@ -## Interface: 30300 +## Interface: 40000 ## Author: p3lim -## Version: 30300.8-Release -## Title: |cffff6000p|rMinimap +## Version: Alpha +## Title: pMinimap ## Notes: Yet another square minimap addon ## SavedVariables: pMinimapDB ## OptionalDeps: LibSharedMedia-3.0, SharedMedia @@ -12,6 +12,8 @@ libs\LibSharedMedia-3.0.lua pMinimap.lua -libs\tekKonfig\tekKonfig.xml - -Config.lua +config\module.checkbox.lua +config\module.dropdown.lua +config\module.palette.lua +config\module.slider.lua +config\configuration.lua