View Single Post
03-03-16, 03:01 PM   #14
EvilMaddness
An Aku'mai Servant
 
EvilMaddness's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2015
Posts: 33
Getting close to getting flat screen minimap

Lua Code:
  1. -- minimap default position - you can move it ingame by holding down ALT!
  2. position = "TOPRIGHT"      
  3. position_x = -200              
  4. position_y = -200              
  5.  
  6. -- achievement/quest tracker position
  7. moveWatchFrame = false          -- enable/disable positioning, set to false if you are using a different addon to move it
  8. qparent = UIParent        
  9. qanchor = "TOPRIGHT"     
  10. qposition_x = -60          
  11. qposition_y = -260        
  12. qheight = 400            
  13.  
  14. local useInfoPanel = true       -- enable disable fps/latency and clock
  15. local showclock = false         -- ONLY show clock - makes sense to set useInfoPanel to false if you only want to show the clock ^^
  16. local AddonNumb = 30            -- maximum number of addons shown in tooltip (will always show set number of top memory usage addons)
  17.  
  18. local mediaFolder = "Interface\\AddOns\\dMedia\\"   -- don't touch this ...
  19. local texture = "Interface\\Buttons\\WHITE8x8"
  20. --local backdrop = {bgFile = texture, edgeFile = texture, edgeSize = 1, insets = { left = -1, right = -1, top = -1, bottom = -1}}
  21. local backdrop = {edgeFile = texture, edgeSize = 1}
  22.    
  23. local mailicon = mediaFolder.."mail"
  24. local font = mediaFolder.."big_noodle_titling.ttf"
  25. local fontSize = 12
  26. local fontFlag = "THINOUTLINE"          -- "THINOUTLINE", "OUTLINE MONOCHROME", "OUTLINE" or nil (no outline)
  27.  
  28. local backdropcolor = {26/255, 25/255, 31/255}      -- backdrop color  
  29. local brdcolor = {0/255, 0/255, 0/255}              -- backdrop border color
  30. local infocolor = {29/255, 63/255, 72/255}          -- info panel color
  31. local IpanelBGalpha = 0.3                           -- info panel background alpha
  32.  
  33. local classColoredBorder = false                    -- color border by class
  34. local scale = 1
  35.  
  36. local enableCombatFade = true                       -- enable/disable fade out in combat
  37. local inCombatAlpha = 0.3                           -- in combat alpha
  38. local outCombatAlpha = 1.0                          -- ooc alpha
  39.  
  40. -----------
  41. -- style --
  42. -----------
  43. local _, class = UnitClass('player')
  44. local color = CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS[class] or RAID_CLASS_COLORS[class]           
  45.  
  46. Minimap:SetSize(253*scale, 253*scale)
  47. Minimap:SetMaskTexture(mediaFolder.."rectangle")
  48. Minimap:SetHitRectInsets(30, 25, 75*scale, 75*scale)
  49. Minimap:ClearAllPoints()
  50. Minimap:SetPoint(position, UIParent, position_x, position_y)
  51. Minimap:SetScale(scale)
  52. Minimap:SetFrameLevel(8)
  53.  
  54. BorderFrame = CreateFrame("Frame", nil, UIParent)
  55. BorderFrame:SetPoint("TOPLEFT", Minimap, "TOPLEFT", 23, -(75*scale))
  56. BorderFrame:SetPoint("BOTTOMRIGHT", Minimap, "BOTTOMRIGHT", -23, (75*scale))
  57.    
  58. BorderFrame:SetBackdrop(backdrop)
  59. if not classColoredBorder then
  60.     BorderFrame:SetBackdropBorderColor(unpack(brdcolor))
  61. else
  62.     BorderFrame:SetBackdropBorderColor(color.r, color.g, color.b)
  63. end
  64. BorderFrame:SetBackdropColor(unpack(backdropcolor))
  65. BorderFrame:SetFrameLevel(6)       
  66.  
  67. ------------------------
  68. -- fps latency memory --
  69. ------------------------
  70. if useInfoPanel then   
  71.  
  72. local FLMframe = CreateFrame("Button", "FLMframe", UIParent)
  73. FLMframe:SetPoint("TOP", Minimap, "BOTTOM", 0, 20*scale)
  74. FLMframe:SetSize((Minimap:GetWidth()+2)*scale, fontSize+6)
  75. FLMframe:SetFrameLevel(4)
  76. FLMframe:SetBackdrop(backdrop)
  77. if not classColoredBorder then
  78.     FLMframe:SetBackdropBorderColor(unpack(brdcolor))
  79. else
  80.     FLMframe:SetBackdropBorderColor(color.r, color.g, color.b)
  81. end
  82. FLMframe:SetBackdropColor(unpack(backdropcolor))
  83.  
  84. local FLMframeT = FLMframe:CreateTexture(nil, "ARTWORK")
  85. FLMframeT:SetPoint("TOPLEFT", FLMframe, "TOPLEFT", 1, -1)
  86. FLMframeT:SetPoint("BOTTOMRIGHT", FLMframe, "BOTTOMRIGHT", -1, 1)  
  87. --FLMframeT:SetTexture(mediaFolder.."dO")
  88. FLMframeT:SetTexture(texture)
  89. FLMframeT:SetVertexColor(unpack(infocolor))
  90. FLMframeT:SetAlpha(IpanelBGalpha)
  91.  
  92. local text = FLMframe:CreateFontString(nil, "OVERLAY")
  93. text:SetPoint("CENTER", FLMframe, 4, 0)
  94. text:SetFont(font, fontSize, fontFlag)
  95. --text:SetShadowOffset(1, -1)
  96. text:SetTextColor(color.r, color.g, color.b)
  97.    
  98.     --========[ important functions ]========--
  99. local function Addoncompare(a, b)
  100.     return a.memory > b.memory
  101. end
  102.  
  103. local function MemFormat(v)
  104.     if (v > 1024) then
  105.         return string.format("%.2f MiB", v / 1024)
  106.     else
  107.         return string.format("%.2f KiB", v)
  108.     end
  109. end
  110.  
  111. local function ColorGradient(perc, ...)
  112.     if (perc > 1) then
  113.         local r, g, b = select(select('#', ...) - 2, ...)
  114.         return r, g, b
  115.     elseif (perc < 0) then
  116.         local r, g, b = ...
  117.         return r, g, b
  118.     end
  119.    
  120.     local num = select('#', ...) / 3
  121.  
  122.     local segment, relperc = math.modf(perc*(num-1))
  123.     local r1, g1, b1, r2, g2, b2 = select((segment*3)+1, ...)
  124.  
  125.     return r1 + (r2-r1)*relperc, g1 + (g2-g1)*relperc, b1 + (b2-b1)*relperc
  126. end
  127.  
  128. local function TimeFormat(time)
  129.     local t = format("%.1ds",floor(mod(time,60)))
  130.     if (time > 60) then
  131.         time = floor(time / 60)
  132.         t = format("%.1dm ",mod(time,60))..t
  133.         if (time > 60) then
  134.             time = floor(time / 60)
  135.             t = format("%.1dh ",mod(time,24))..t
  136.             if (time > 24) then
  137.                 time = floor(time / 24)
  138.                 t = format("%dd ",time)..t
  139.             end
  140.         end
  141.     end
  142.     return t
  143. end
  144.  
  145. local function ColorizeLatency(v)
  146.     if (v < 100) then
  147.         return {r = 0, g = 1, b = 0}
  148.     elseif (v < 300) then
  149.         return {r = 1, g = 1, b = 0}
  150.     else
  151.         return {r = 1, g = 0, b = 0}
  152.     end
  153. end
  154.  
  155. local function ColorizeFramerate(v)
  156.     if (v < 10) then
  157.         return {r = 1, g = 0, b = 0}
  158.     elseif (v < 30) then
  159.         return {r = 1, g = 1, b = 0}
  160.     else
  161.         return {r = 0, g = 1, b = 0}
  162.     end
  163. end
  164.    
  165.     --========[ update ]========--
  166. local lastUpdate = 0
  167. local updateDelay = 1
  168. FLMframe:SetScript("OnUpdate", function(self, elapsed)
  169.     lastUpdate = lastUpdate + elapsed
  170.     if (lastUpdate > updateDelay) then
  171.         lastUpdate = 0
  172.         local time = date("|c00ffffff%H|r:|c00ffffff%M|r")
  173.         fps = GetFramerate()
  174.         fps = "|c00ffffff"..floor(fps+0.5).."|r fps   "
  175.         lag = select(4, GetNetStats())
  176.         lag = "|c00ffffff"..lag.."|r ms   "
  177.         text:SetText(lag..fps..time)
  178.     end
  179. end)
  180.  
  181. FLMframe:SetScript("OnEnter", function()
  182.     GameTooltip:SetOwner(FLMframe)
  183.     collectgarbage()
  184.     local memory, i, addons, total, entry, total
  185.     local latencycolor = ColorizeLatency(select(3, GetNetStats()))
  186.     local fpscolor = ColorizeFramerate(GetFramerate())
  187.        
  188.     GameTooltip:AddLine(date("%A, %d %B, %Y"), 1, 1, 1)
  189.     GameTooltip:AddDoubleLine("Framerate:", format("%.1f fps", GetFramerate()), color.r, color.g, color.b, fpscolor.r, fpscolor.g, fpscolor.b)
  190.     GameTooltip:AddDoubleLine("Latency:", format("%d ms", select(3, GetNetStats())), color.r, color.g, color.b, latencycolor.r, latencycolor.g, latencycolor.b)
  191.     GameTooltip:AddDoubleLine("System Uptime:", TimeFormat(GetTime()), color.r, color.g, color.b, 1, 1, 1)
  192.     GameTooltip:AddDoubleLine(". . . . . . . . . . .", ". . . . . . . . . . .", 1, 1, 1, 1, 1, 1)
  193.    
  194.     addons = {}
  195.     total = 0
  196.     UpdateAddOnMemoryUsage()
  197.     for i = 1, GetNumAddOns(), 1 do
  198.         if GetAddOnMemoryUsage(i) > 0 then
  199.             memory = GetAddOnMemoryUsage(i)
  200.             entry = {name = GetAddOnInfo(i), memory = memory}
  201.             table.insert(addons, entry)
  202.             total = total + memory
  203.         end
  204.     end
  205.    
  206.     table.sort(addons, Addoncompare)
  207.  
  208.     i = 0
  209.     for _,entry in pairs(addons) do
  210.         local cr, cg, cb = ColorGradient((entry.memory / 800), 0, 1, 0, 1, 1, 0, 1, 0, 0)
  211.         GameTooltip:AddDoubleLine(entry.name, MemFormat(entry.memory), 1, 1, 1, cr, cg, cb)
  212.    
  213.         i = i + 1
  214.         if i >= AddonNumb then
  215.             break
  216.         end    
  217.     end
  218.    
  219.     local cr, cg, cb = ColorGradient((entry.memory / 800), 0, 1, 0, 1, 1, 0, 1, 0, 0)
  220.     GameTooltip:AddDoubleLine(". . . . . . . . . . .", ". . . . . . . . . . .", 1, 1, 1, 1, 1, 1)
  221.     GameTooltip:AddDoubleLine("Total", MemFormat(total), color.r, color.g, color.b, cr, cg, cb)
  222.     GameTooltip:AddDoubleLine("..with Blizzard", MemFormat(collectgarbage("count")), color.r, color.g, color.b, cr, cg, cb)
  223.     GameTooltip:Show()
  224. end)
  225.  
  226. FLMframe:SetScript("OnLeave", function()
  227.     GameTooltip:Hide()
  228. end)
  229.  
  230.     --========[ mem cleanup ]========--
  231. FLMframe:SetScript("OnClick", function()
  232.     if (not IsAltKeyDown()) then
  233.         UpdateAddOnMemoryUsage()
  234.         local memBefore = gcinfo()
  235.         collectgarbage()
  236.         UpdateAddOnMemoryUsage()
  237.         local memAfter = gcinfo()
  238.         DEFAULT_CHAT_FRAME:AddMessage("Memory cleaned: |cff00FF00"..MemFormat(memBefore - memAfter))
  239.     end
  240. end)
  241.    
  242. end
  243.    
  244. ---------------------
  245. -- hide some stuff --
  246. ---------------------
  247. MinimapBackdrop:Hide()
  248. MinimapBorder:Hide()
  249. MinimapBorderTop:Hide()
  250. MinimapZoomIn:Show()
  251. MinimapZoomOut:Show()
  252. MiniMapVoiceChatFrame:Hide()
  253. GameTimeFrame:Hide()
  254. MinimapZoneTextButton:Show()
  255. MiniMapTracking:Show()
  256. MiniMapMailBorder:Hide()
  257. MinimapNorthTag:SetAlpha(50)
  258. MiniMapInstanceDifficulty:SetAlpha(50)
  259. GuildInstanceDifficulty:SetAlpha(50)
  260.  
  261. if showclock then
  262.     LoadAddOn('Blizzard_TimeManager')
  263.     local clockFrame, clockTime = TimeManagerClockButton:GetRegions()
  264.     clockFrame:Hide()
  265.     clockTime:Show()
  266.     clockTime:SetFont(font, fontSize, fontFlag)
  267.     TimeManagerClockButton:SetPoint("BOTTOM", Minimap, 0, -6)
  268. else
  269.     LoadAddOn('Blizzard_TimeManager')
  270.     TimeManagerClockButton.Show = TimeManagerClockButton.Hide
  271.     local region = TimeManagerClockButton:GetRegions()
  272.     region:Hide()  
  273.     TimeManagerClockButton:ClearAllPoints()
  274.     TimeManagerClockButton:Hide()  
  275. end
  276.  
  277. ---------------------
  278. -- move some stuff --
  279. ---------------------
  280. if moveWatchFrame then
  281.     WatchFrame:ClearAllPoints()
  282.     WatchFrame.ClearAllPoints = function() end
  283.     WatchFrame:SetPoint(qanchor, qparent, qanchor, qposition_x, qposition_y)
  284.     WatchFrame.SetPoint = function() end
  285.     WatchFrame:SetClampedToScreen(true)
  286.     WatchFrame:SetHeight(qheight)
  287. end
  288.  
  289. MiniMapMailFrame:ClearAllPoints()
  290. MiniMapMailFrame:SetPoint("TOPRIGHT", Minimap, 4, -20)
  291. MiniMapMailIcon:SetTexture(mailicon)
  292.  
  293. MiniMapWorldMapButton:Hide()
  294. MiniMapInstanceDifficulty:ClearAllPoints()
  295. MiniMapInstanceDifficulty:SetParent(Minimap)
  296. MiniMapInstanceDifficulty:SetPoint("TOPLEFT", Minimap, "TOPLEFT", 0, -22)
  297. DropDownList1:SetClampedToScreen(true)
  298.  
  299. MiniMapMailFrame:SetFrameLevel(10)
  300. MiniMapInstanceDifficulty:SetFrameLevel(10)
  301.  
  302. QueueStatusMinimapButton:SetSize(20, 20)
  303. QueueStatusMinimapButton:ClearAllPoints()
  304. QueueStatusMinimapButton:SetParent(Minimap)
  305. QueueStatusMinimapButton:SetPoint("BOTTOMLEFT", Minimap, "BOTTOMLEFT", 0, 22)
  306. QueueStatusMinimapButton:SetFrameLevel(10)
  307. QueueStatusMinimapButtonBorder:Hide()
  308.  
  309. ---------------------
  310. -- mousewheel zoom --
  311. ---------------------
  312. Minimap:EnableMouseWheel(true)
  313. Minimap:SetScript("OnMouseWheel", function(self, direction)
  314.     if(direction > 0) then
  315.         Minimap_ZoomIn()
  316.     else
  317.         Minimap_ZoomOut()
  318.     end
  319. end)
  320.  
  321. ------------------------
  322. -- move and clickable --
  323. ------------------------
  324. Minimap:SetMovable(true)
  325. Minimap:SetUserPlaced(true)
  326. Minimap:SetScript("OnMouseDown", function()
  327.     if (IsAltKeyDown()) then
  328.         Minimap:ClearAllPoints()
  329.         Minimap:StartMoving()
  330.     end
  331. end)
  332.  
  333. Minimap:SetScript('OnMouseUp', function(self, button)
  334. Minimap:StopMovingOrSizing()
  335.     if (button == 'RightButton') then
  336.         ToggleDropDownMenu(1, nil, MiniMapTrackingDropDown, self, - (Minimap:GetWidth() * 0.7), -3)
  337.     elseif (button == 'MiddleButton') then
  338.         ToggleCalendar()
  339.     else
  340.         Minimap_OnClick(self)
  341.     end
  342. end)
  343.  
  344. -- calendar slashcmd
  345. SlashCmdList["CALENDAR"] = function()
  346.     ToggleCalendar()
  347. end
  348. SLASH_CALENDAR1 = "/cl"
  349. SLASH_CALENDAR2 = "/calendar"
  350.  
  351. function GetMinimapShape() return 'SQUARE' end
  352.  
  353. -------------------
  354. -- combat fading --
  355. -------------------
  356. if enableCombatFade then
  357. function Minimap_OnEvent(self, event)
  358.         if event == "PLAYER_REGEN_DISABLED" then
  359.             MinimapCluster:SetAlpha(inCombatAlpha)
  360.             if useInfoPanel then   
  361.                 FLMframe:SetAlpha(inCombatAlpha)
  362.             end
  363.         elseif event == "PLAYER_REGEN_ENABLED" then
  364.             MinimapCluster:SetAlpha(outCombatAlpha)
  365.             if useInfoPanel then   
  366.                 FLMframe:SetAlpha(outCombatAlpha)
  367.             end    
  368.         end
  369. end
  370.    
  371. Minimap:HookScript("OnEvent", Minimap_OnEvent)
  372.  
  373. Minimap:RegisterEvent("PLAYER_REGEN_DISABLED")
  374. Minimap:RegisterEvent("PLAYER_REGEN_ENABLED")
  375. end
  376.  
  377. -------------------------------
  378. -- style Battlefield Minimap --
  379. -------------------------------
  380. local function hide(f)
  381.     f:SetTexture()
  382.     f.SetTexture = function() end
  383. end
  384.  
  385. hooksecurefunc("LoadAddOn", function(addon)
  386.     if addon ~= "Blizzard_BattlefieldMinimap" then return end
  387.  
  388.     BattlefieldMinimapBackground:Hide()
  389.     BattlefieldMinimapCorner:Hide()
  390.     BattlefieldMinimapCloseButton:Hide()
  391.     BattlefieldMinimapTab:Hide()
  392.    
  393.     BBorderFrame = CreateFrame("Frame", nil, BattlefieldMinimap)
  394.     BBorderFrame:SetPoint("TOPLEFT", BattlefieldMinimap, "TOPLEFT", -1, 1)
  395.     BBorderFrame:SetPoint("BOTTOMRIGHT", BattlefieldMinimap, "BOTTOMRIGHT", -5, 3) 
  396.     BBorderFrame:SetBackdrop(backdrop)
  397.     if not classColoredBorder then
  398.         BBorderFrame:SetBackdropBorderColor(unpack(brdcolor))
  399.     else
  400.         BBorderFrame:SetBackdropBorderColor(color.r, color.g, color.b)
  401.     end
  402.     BBorderFrame:SetBackdropColor(unpack(backdropcolor))
  403.     BBorderFrame:SetFrameLevel(6)      
  404. end)

I used the dRecMap add-on. There's a folder named dMedia to add your tga file in. I used the size 256-128 for the mask with a Width 200-Height 100 rectangle in the middle but I'm also going to try a 128-256. At first it was showing up green for the size 128-256 so I thought I couldn't use it. You need to exit fully out and back on first for it to register the size.

I'm getting really close making it work after countless hours messing with the settings. The only part getting in my way now is trying to make a hidden minimap circle small enough to where the border touches the edges of the rectangle. Least that's what it seems like.
__________________
The Maddness Within lua
  Reply With Quote