Thread Tools Display Modes
04-28-16, 07:38 PM   #1
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Get your can of raid!

Attached is the zip of MyrroUI in progress, complete with libs and media.

I have a series of bugs, which I will address one post at a time to keep things sane. The first is why LibDBIcon won't hide or show the minimap icon. The checkbox remains in its default state of false, and clicking it does nothing, not even filling in the checkbox. I am guessing a typo somewhere, but I can't spot it. If it is not a typo, then I really have no explanation.

Please note that MyrroUI will set some CVars, so back up your config.wtf first. Also, it will first set all UI elememts to a horrid scale, but in the options there is a button called Pixel Perfection to fix that.

You can get to the options via:
  • Left click of the minimap icon
  • Left click of the icon in any Broker display or Titan Panel
  • The Interface .. AddOns .. MyrroUI method
  • Typing either /mui or /myrroui into chat

Posting the zip rather than the code is significantly easier as there are multiple files.

Once this has been fixed, I will move onto a LibWindow error, which people probably will spot anyway during install and adjusting settings.
Attached Files
File Type: zip MyrroUI.zip (232.7 KB, 118 views)

Last edited by myrroddin : 04-28-16 at 07:41 PM. Reason: How to get to options
  Reply With Quote
04-29-16, 07:49 AM   #2
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Time away sometimes does wonders. I fixed the minimap button. That was two typos.

Anyway, I still have a LibWindow error, and Bugger/BugGrabber spits out this error:
Lua Code:
  1. 3x ...LibWindow-1.1\LibWindow-1.1\LibWindow-1.1-8.lua:62: attempt to index field '?' (a nil value)
  2. ...LibWindow-1.1\LibWindow-1.1\LibWindow-1.1-8.lua:62: in function <...LibWindow-1.1\LibWindow-1.1\LibWindow-1.1.lua:61>
  3. ...LibWindow-1.1\LibWindow-1.1\LibWindow-1.1-8.lua:159: in function 'SavePosition'
  4. MyrroUI\MyrroUI-@project-version@.lua:162: in function <MyrroUI\MyrroUI.lua:60>
  5. (tail call): ?
  6. [C]:: ?
  7. [string "safecall Dispatcher[1]"]:9: in function <[string "safecall Dispatcher[1]"]:5>
  8. (tail call): ?
  9. Ace3\AceAddon-3.0\AceAddon-3.0-12.lua:529: in function 'InitializeAddon'
  10. Ace3\AceAddon-3.0\AceAddon-3.0-12.lua:644: in function <Ace3\AceAddon-3.0\AceAddon-3.0.lua:636>

So, somewhere in my main file, I am not using LibWindow correctly, but I am lost.
Lua Code:
  1. local MyrroUI = LibStub("AceAddon-3.0"):NewAddon("MyrroUI", "AceConsole-3.0", "AceEvent-3.0", "LibUtilities-1.0")
  2. MyrroUI:SetDefaultModuleLibraries("AceConsole-3.0", "AceEvent-3.0", "LibUtilities-1.0")
  3. local L = LibStub("AceLocale-3.0"):GetLocale("MyrroUI", true)
  4. local version = GetAddOnMetadata("MyrroUI", "Version")
  5.  
  6. -- if SVN checkout, replace version text --------
  7. if version:match("@") then
  8.     version = L["Developer"]
  9. end
  10. -- upvalues & calculations ----------------------
  11. local installerWidth = UIParent:GetWidth() / 2
  12. local installerHeight = UIParent:GetHeight() / 2
  13. local addonName = "MyrroUI " .. version
  14.  
  15. -- load additional libraries --------------------
  16. local LSM = LibStub("LibSharedMedia-3.0")
  17. local LDB = LibStub("LibDataBroker-1.1")
  18. local DBI = LibStub("LibDBIcon-1.0")
  19. local LWD = LibStub("LibWindow-1.1")
  20.  
  21. -- register Roman font with SharedMedia ---------
  22. LSM:Register("font", "Roman", "Interface\\AddOns\\MyrroUI\\Fonts\\Roman SD.ttf")
  23.  
  24. -- create defaults ------------------------------
  25. local defaults = {
  26.     profile = {
  27.         enabled = true,
  28.         firstRun = true,
  29.         uiScale = 1,
  30.         modules = {
  31.             ["**"] = {
  32.                 enabled = true
  33.             }
  34.         },
  35.         installer = {
  36.             x = 0,
  37.             y = 0,
  38.             scale = 1
  39.         }
  40.     },
  41.    
  42.     global = {
  43.         pixelPerfect = false,
  44.         minimap = {
  45.             hide = false,
  46.             lock = false,
  47.             minimapPos = 205,
  48.             radius = 80
  49.         }
  50.     }
  51. }
  52.  
  53. -- run with OnInitialize ------------------------
  54. local function SetUglyScale()
  55.     SetCVar("useUiScale", "1")
  56.     SetCVar("uiScale", "1")
  57.     UIParent:SetScale(1)
  58. end
  59.  
  60. function MyrroUI:OnInitialize()
  61.     self.db = LibStub("AceDB-3.0"):New("MyrroUI_DB", defaults, true)
  62.     self.db.RegisterCallback(self, "OnProfileChanged", "RefreshConfig")
  63.     self.db.RegisterCallback(self, "OnProfileCopied", "RefreshConfig")
  64.     self.db.RegisterCallback(self, "OnProfileReset", "RefreshConfig")
  65.    
  66.     -- set enabled state for MyrroUI and any modules
  67.     self:SetEnabledState(self.db.profile.enabled)
  68.    
  69.     self.options = self:OptionsTable() -- see MUI_Options.lua
  70.    
  71.     self.options.args.profilesTab = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db)
  72.     self.options.args.profilesTab.order = 1
  73.  
  74.     -- Register your options with AceConfigRegistry
  75.     LibStub("AceConfig-3.0"):RegisterOptionsTable("MyrroUI", self.options, {"mui", "myrroui"})
  76.    
  77.     -- slash commands ---------------------------
  78.     self:RegisterChatCommand("mui", "SlashHandler")
  79.     self:RegisterChatCommand("myrroui", "SlashHandler")
  80.  
  81.     -- Add your options to the Blizz options window using AceConfigDialog
  82.     self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("MyrroUI", "MyrroUI")
  83.    
  84.     -- support for LibAboutPanel
  85.     self.optionsFrame[L["About"]] = LibStub("LibAboutPanel").new("MyrroUI", "MyrroUI")
  86.    
  87.     -- create Data Broker -----------------------
  88.     local MyrroUIBroker = LDB:NewDataObject("MyrroUI", {
  89.         type = "launcher",
  90.         label = "MyrroUI",
  91.         icon = "Interface\\AddOns\\MyrroUI\\Icons\\CogWheel.tga",
  92.         OnClick = function(_, button)
  93.             if button == "LeftButton" then             
  94.                 if LibStub("AceConfigDialog-3.0").OpenFrames["MyrroUI"] then
  95.                     LibStub("AceConfigDialog-3.0"):Close("MyrroUI")
  96.                 else
  97.                     LibStub("AceConfigDialog-3.0"):Open("MyrroUI")
  98.                 end
  99.             elseif button == "RightButton" then
  100.                 if self.installer:IsShown() then
  101.                     self.installer:Hide()
  102.                 else
  103.                     self.installer:Show()
  104.                 end
  105.             end
  106.         end,
  107.         OnTooltipShow = function(tooltip)
  108.             if not tooltip or not tooltip.AddLine then return end
  109.             tooltip:AddLine("MyrroUI")
  110.             tooltip:AddLine(L["Left click to open options."])
  111.             tooltip:AddLine(L["Right click to show/hide installer."])
  112.         end,
  113.     })
  114.     DBI:Register("MyrroUI", MyrroUIBroker, self.db.global.minimap)
  115.    
  116.     -- compliments of Phanx ---------------------
  117.     -- auto expand the sub panels ---------------
  118.     do
  119.         self.optionsFrame:HookScript("OnShow", function(self)
  120.             if InCombatLockdown() then return end
  121.             local target = self.parent or self.name
  122.             local i = 1
  123.             local button = _G["InterfaceOptionsFrameAddOnsButton"..i]
  124.             while button do
  125.                 local element = button.element
  126.                 if element.name == target then
  127.                     if element.hasChildren and element.collapsed then
  128.                         _G["InterfaceOptionsFrameAddOnsButton"..i.."Toggle"]:Click()
  129.                     end
  130.                     return
  131.                 end
  132.                 i = i + 1
  133.                 button = _G["InterfaceOptionsFrameAddOnsButton"..i]
  134.             end
  135.         end)
  136.         local function OnClose(self)
  137.             if InCombatLockdown() then return end
  138.             local target = self.parent or self.name
  139.             local i = 1
  140.             local button = _G["InterfaceOptionsFrameAddOnsButton"..i]
  141.             while button do
  142.                 local element = button.element
  143.                 if element.name == target then
  144.                     if element.hasChildren and not element.collapsed then
  145.                         local selection = InterfaceOptionsFrameAddOns.selection
  146.                         if not selection or selection.parent ~= target then
  147.                             _G["InterfaceOptionsFrameAddOnsButton"..i.."Toggle"]:Click()
  148.                         end
  149.                     end
  150.                     return
  151.                 end
  152.                 i = i + 1
  153.                 button = _G["InterfaceOptionsFrameAddOnsButton"..i]
  154.             end
  155.         end
  156.         hooksecurefunc(self.optionsFrame, "okay", OnClose)
  157.         hooksecurefunc(self.optionsFrame, "cancel", OnClose)
  158.     end
  159.    
  160.     self.installer = self.installer or self:CreateInstaller()
  161.     self.installer:Hide()
  162.     LWD.SavePosition(self.installer)
  163.    
  164.     SetCVar("useUiScale", "1")
  165. end
  166.  
  167. function MyrroUI:OnEnable()
  168.    
  169.     -- set ugly ass UI pixel so it purposely looks bad
  170.     -- will fix it very soon!
  171.     if self.db.profile.firstRun then
  172.         SetUglyScale()
  173.         self.installer:Show()
  174.         self.db.profile.firstRun = false
  175.     else
  176.         SetCVar("uiScale", tostring(self.db.profile.uiScale))
  177.     end
  178.    
  179.     for name, module in self:IterateModules() do
  180.         module:SetEnabledState(self.db.profile.modules["**"].enabled)
  181.     end
  182.    
  183.     -- LibWindow stuff --------------------------
  184.     LWD.RegisterConfig(self.installer, self.db.profile.installer)
  185.     LWD.SetScale(self.installer, self.db.profile.installer.scale)
  186.     LWD.MakeDraggable(self.installer)
  187.     LWD.EnableMouseOnAlt(self.installer)
  188.     local p = self.db.profile.installer
  189.     if not p.libWindowed then
  190.         p.x = p.x / UIParent:GetScale()
  191.         p.y = p.y / UIParent:GetScale()
  192.         p.libWindowed = true
  193.     end
  194.     LWD.RestorePosition(self.installer)
  195. end
  196.  
  197. function MyrroUI:OnDisable()
  198.     for name, module in self:IterateModules() do
  199.         module:SetEnabledState(false)
  200.     end
  201.    
  202.     self.installer:Hide()
  203.     LWD.SavePosition(self.installer)
  204. end
  205.  
  206. -- profile callbacks ----------------------------
  207. function MyrroUI:RefreshConfig()
  208.     LWD.RegisterConfig(self.installer, self.db.profile.installer)
  209.     LWD.RestorePosition(self.installer)
  210. end
  211.  
  212. -- slash commands -------------------------------
  213. function MyrroUI:SlashHandler(input)
  214.     if InCombatLockdown() then
  215.         self:Print(L["Cannot access options during combat."])
  216.         return
  217.     end
  218.     if not input or input:trim() == "" then
  219.         LibStub("AceConfigDialog-3.0"):Open("MyrroUI")
  220.     else
  221.         LibStub("AceConfigCmd-3.0").HandleCommand(MyrroUI, "mui", "myrroui", input)
  222.     end
  223. end
  224.  
  225. function MyrroUI:Pixel()
  226.     if self.db.global.pixelPerfect then
  227.         return
  228.     end
  229.     local uiScale, resX, resY = self:VisualData()
  230.     self.db.profile.uiScale = uiScale
  231.     self.db.profile.resX = resX
  232.     self.db.profile.resY = resY
  233.    
  234.     SetCVar("uiScale", tostring(uiScale))
  235.     SetCVar("useUiScale", "1")
  236.     -- WoW's scale doesn't go below 0.64 --------
  237.     -- so we force the issue on larger screens --
  238.     if resY >= 1200 then
  239.         UIParent:SetScale(uiScale)
  240.     end
  241.    
  242.     LWD.SetScale(self.installer, uiScale)
  243.     LWD.SavePosition(self.installer)
  244.     --LWD.RestorePosition(self.installer)
  245.    
  246.     self.db.global.pixelPerfect = true
  247. end
  Reply With Quote
04-29-16, 07:57 AM   #3
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
Since people are generally not inclined to buy a pig in a poke, you should provide screenshots of your compilation if you want people to test it out. Especially if it's riddled with errors.
__________________
  Reply With Quote
04-29-16, 08:05 AM   #4
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
I did think about that, but since I haven't altered any of the UI frames yet, at this stage people could use whatever they want, whether default frames or AddOn replacements.

The only thing MyrroUI does at this point is pixel perfection and set up some CVars.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Get your can of raid!


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off