Quantcast

Initial Commit

p3lim-52096 [07-28-08 - 03:28]
Initial Commit

git-svn-id: svn://svn.wowinterface.com/pMinimap-54/trunk@2 ae24c21f-2f0c-4c94-9256-0092abe71e0d
Filename
font.ttf
pMinimap.lua
pMinimap.toc
pMinimapConfig.lua
diff --git a/font.ttf b/font.ttf
new file mode 100644
index 0000000..04ce123
Binary files /dev/null and b/font.ttf differ
diff --git a/pMinimap.lua b/pMinimap.lua
new file mode 100644
index 0000000..55e9f4e
--- /dev/null
+++ b/pMinimap.lua
@@ -0,0 +1,122 @@
+--[[-------------------------------------------------------------------------
+  Copyright (c) 2006, Trond A Ekseth
+  Copyright (c) 2008, Adrian L Lange
+  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions are
+  met:
+
+      * Redistributions of source code must retain the above copyright
+        notice, this list of conditions and the following disclaimer.
+      * Redistributions in binary form must reproduce the above
+        copyright notice, this list of conditions and the following
+        disclaimer in the documentation and/or other materials provided
+        with the distribution.
+      * Neither the name of pMinimap nor the names of its contributors
+        may be used to endorse or promote products derived from this
+        software without specific prior written permission.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+---------------------------------------------------------------------------]]
+
+
+-- global function
+function GetMinimapShape() return "SQUARE" end
+
+-- addon fluff
+local addon = CreateFrame("Frame", "pMinimap", Minimap)
+local frames = {
+	MinimapNorthTag,
+	MinimapBorder,
+	MinimapBorderTop,
+	MinimapToggleButton,
+	MinimapZoomIn,
+	MinimapZoomOut,
+	MinimapZoneText,
+	MinimapZoneTextButton,
+	MiniMapTrackingBorder,
+	MiniMapTrackingBackground,
+	MiniMapBattlefieldBorder,
+	MiniMapMeetingStoneFrame,
+	MiniMapVoiceChatFrame,
+	MiniMapWorldMapButton,
+	MiniMapMailBorder,
+	MiniMapMailIcon,
+	BattlegroundShine,
+	DurabilityFrame,
+	GameTimeFrame,
+}
+
+function addon.PLAYER_LOGIN(self)
+	Minimap:EnableMouseWheel(true)
+	Minimap:SetScript("OnMouseWheel", function()
+		if(arg1 > 0) then
+			Minimap_ZoomIn()
+		else
+			Minimap_ZoomOut()
+		end
+	end)
+
+	MiniMapTrackingIcon:SetTexCoord(0.065, 0.935, 0.065, 0.935) -- bloody hell
+	MiniMapTracking:SetParent(Minimap)
+	MiniMapTracking:ClearAllPoints()
+	MiniMapTracking:SetPoint("TOPLEFT", -2, 2)
+
+	MiniMapBattlefieldFrame:SetParent(Minimap)
+	MiniMapBattlefieldFrame:ClearAllPoints()
+	MiniMapBattlefieldFrame:SetPoint("TOPRIGHT", -2, -2)
+
+	MiniMapMailFrame:SetParent(Minimap)
+	MiniMapMailFrame:ClearAllPoints()
+	MiniMapMailFrame:SetPoint("TOP")
+	MiniMapMailFrame:SetHeight(8)
+
+	MiniMapMailText = MiniMapMailFrame:CreateFontString(nil, "OVERLAY")
+	MiniMapMailText:SetFont("Interface\\AddOns\\pMinimap\\font.ttf", 13, "OUTLINE")
+	MiniMapMailText:SetPoint("BOTTOM", 0, 2)
+	MiniMapMailText:SetText("New Mail!")
+	MiniMapMailText:SetTextColor(1, 1, 1)
+
+	Minimap:SetMaskTexture("Interface\\ChatFrame\\ChatFrameBackground")
+
+	self:SetFrameLevel(0)
+	self:SetAllPoints(Minimap)
+	self:SetBackdrop({bgFile = "Interface\\ChatFrame\\ChatFrameBackground", insets = {top = -1, left = -1, bottom = -1, right = -1}})
+	self:SetBackdropColor(0, 0, 0)
+
+	-- hide all listed frames
+	for _,obj in pairs(frames) do obj:Hide(); obj.Show = function() end end
+end
+
+-- durability backdrop recoloring (props to Malreth of WoWAce)
+function addon.UPDATE_INVENTORY_ALERTS(self)
+	local maxStatus = 0
+	for id in pairs(INVENTORY_ALERT_STATUS_SLOTS) do
+		local status = GetInventoryAlertStatus(id)
+		if(status > maxStatus) then
+			maxStatus = status
+		end
+	end
+
+	local color = INVENTORY_ALERT_COLORS[maxStatus]
+	if(color) then
+		self:SetBackdropColor(color.r, color.g, color.b)
+	else
+		self:SetBackdropColor(0, 0, 0)
+	end
+end
+
+addon:SetScript("OnEvent", function(self, event, ...) self[event](self) end)
+addon:RegisterEvent("UPDATE_INVENTORY_ALERTS")
+addon:RegisterEvent("PLAYER_LOGIN")
\ No newline at end of file
diff --git a/pMinimap.toc b/pMinimap.toc
new file mode 100644
index 0000000..52a54cd
--- /dev/null
+++ b/pMinimap.toc
@@ -0,0 +1,12 @@
+## Interface: 20400
+## Author: p3lim
+## Title: |cffff6000p|rMinimap
+## Notes: Yet another square minimap addon
+## OptionalDeps: LibSimpleOptions-1.0
+## SavedVariablesPerCharacter: pMinimapDB
+
+libs\LibSimpleOptions-1.0\LibStub\LibStub.lua
+libs\LibSimpleOptions-1.0\LibSimpleOptions-1.0.lua
+
+pMinimap.lua
+pMinimapConfig.lua
diff --git a/pMinimapConfig.lua b/pMinimapConfig.lua
new file mode 100644
index 0000000..55d22e0
--- /dev/null
+++ b/pMinimapConfig.lua
@@ -0,0 +1,106 @@
+local db
+local _G = getfenv(0)
+local LibSimpleOptions = LibStub("LibSimpleOptions-1.0")
+
+local function Greenie(anchor)
+	anchor:SetWidth(Minimap:GetWidth() * db.scale)
+	anchor:SetHeight(Minimap:GetHeight() * db.scale)
+end
+
+local function Options(self, anchor)
+	local title, subText = self:MakeTitleTextAndSubText("pMinimap", "These options allow you to change the position of pMinimap")
+
+	local lock = self:MakeToggle(
+		'name', "Toggle Minimap Locked State",
+		'description', "Set whether Minimap is locked or not",
+		'default', true,
+		'current', db.locked,
+		'setFunc', function(value)
+			db.locked = value
+			if(value) then
+				anchor:SetAlpha(0)
+				anchor:SetMovable(false)
+				anchor:SetFrameStrata("BACKGROUND")
+				local p1, _, p2, x, y = anchor:GetPoint()
+				db.p1 = p1
+				db.p2 = p2
+				db.x = x
+				db.y = y
+			else
+				anchor:SetAlpha(1)
+				anchor:SetMovable(true)
+				anchor:SetFrameStrata("DIALOG")
+			end
+		end)
+	lock:SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -8)
+
+	local reset = self:MakeButton(
+		'name', "Reset Position",
+		'description', "Reset Minimap position to default",
+		'func', function()
+			db.p1 = "TOPRIGHT"
+			db.p2 = "TOPRIGHT"
+			db.x = -15
+			db.y = -15
+			db.locked = true
+			anchor:ClearAllPoints()
+			anchor:SetPoint(db.p1, UIParent, db.p2, db.x, db.y)
+			self:Refresh()
+		end)
+	reset:SetPoint("TOPLEFT", lock, "BOTTOMLEFT", 0, -8)
+
+	local scale = self:MakeSlider(
+		'name', "Minimap Scale",
+		'description', "Drag to change the Minimap scale",
+		'minText', "0.4",
+		'maxText', "2.4",
+		'minValue', 0.4,
+		'maxValue', 2.4,
+		'step', 0.1,
+		'default', 0.9,
+		'current', db.scale,
+		'setFunc', function(value) Minimap:SetScale(value) db.scale = value Greenie(anchor) end,
+		'currentTextFunc', function(num) return ("%.1f"):format(num) end)
+	scale:SetPoint("TOPLEFT", reset, "BOTTOMLEFT", 0, -16)
+end
+
+local function OnEvent(self, name)
+	if(name == "pMinimap") then
+		db = _G.pMinimapDB
+		if(not db) then
+			db = { p1 = "TOPRIGHT", p2 = "TOPRIGHT", x = -15, y = -15, scale = 0.9, locked = true }
+			_G.pMinimapDB = db
+		end
+
+		-- reset lock on load
+		db.locked = true
+
+		-- fix up an anchor
+		local anchor = CreateFrame("Frame", nil, UIParent)
+		anchor:SetFrameStrata("BACKGROUND")
+		anchor:SetWidth(Minimap:GetWidth() * db.scale)
+		anchor:SetHeight(Minimap:GetHeight() * db.scale)
+		anchor:SetAlpha(0)
+		anchor:SetBackdrop({bgFile="Interface\\ChatFrame\\ChatFrameBackground"})
+		anchor:SetBackdropColor(0, 1, 0, 0.5)
+		anchor:SetScript("OnMouseDown", function(self) self:StartMoving() end)
+		anchor:SetScript("OnMouseUp", function(self) self:StopMovingOrSizing() end)
+		anchor:SetPoint(db.p1, UIParent, db.p2, db.x, db.y)
+		anchor:EnableMouse(db.locked and false or true)
+
+		-- add minimap placement and scale
+		Minimap:ClearAllPoints()
+		Minimap:SetPoint("CENTER", anchor)
+		Minimap:SetScale(db.scale)
+
+		-- setup options
+		LibSimpleOptions.AddOptionsPanel("pMinimap", function(self) Options(self, anchor) end)
+		LibSimpleOptions.AddSlashCommand("pMinimap", "/pminimap", "/pmm")
+
+		self:UnregisterEvent("ADDON_LOADED")
+	end
+end
+
+local event = CreateFrame("Frame")
+event:RegisterEvent("ADDON_LOADED")
+event:SetScript("OnEvent", function(self, event, ...) OnEvent(self, ...) end)
\ No newline at end of file