Quantcast WoWInterface - View Single Post - UIDropDownMenu Alternatives?
View Single Post
08-26-19, 02:06 PM   #5
mtp1032
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 20
When this code is executed, the player's bag slots are queried to see if they contain a bag (bg:getBag(slotNum). If a bag is not present then a checkbox is created for that bag. If not bag is installed, then no checkbox is created.

Just to recapitulate: the problem is that when the player adds, removes, or relocates a bag I would like to catch the interrupt and refresh this menu. If, for example, the player installed a new bag in slot 4, the menu would create a checkbox for that bag in slot 4 upon being refreshed.

Thanks for you time. I do appreciate it.

Lua Code:
  1. function cha:CHACHING_InitializeOptions()
  2.  
  3.     local versionString = string.format(L["ADDON_NAME_AND_VERSION"])
  4.     local ConfigurationPanel = CreateFrame("FRAME","CHACHING_MainFrame")
  5.     ConfigurationPanel.name = L["ADDON_NAME"]
  6.     InterfaceOptions_AddCategory(ConfigurationPanel)    -- Register the Configuration panel with LibUIDropDownMenu
  7.     -- Print a header at the top of the panel
  8.     local IntroMessageHeader = ConfigurationPanel:CreateFontString(nil, "ARTWORK","GameFontNormalLarge")
  9.     IntroMessageHeader:SetPoint("TOPLEFT", 10, -10)
  10.     IntroMessageHeader:SetText(versionString)
  11.  
  12.     local AuthorSubHeader = ConfigurationPanel:CreateFontString(nil, "ARTWORK","GameFontNormal")
  13.     AuthorSubHeader:SetPoint("TOPLEFT", 20, -30)
  14.     AuthorSubHeader:SetText("Author: [email protected]")
  15.  
  16.     local DescrSubHeader = ConfigurationPanel:CreateFontString(nil, "ARTWORK","GameFontNormalLarge")
  17.     DescrSubHeader:SetPoint("TOPLEFT", 20, -50)
  18.     DescrSubHeader:SetText("Enables the bulk selling of selected items in player's inventory.")
  19.        
  20.     -- Create two check buttons: one to sell grey iterms and one to sell white items
  21.     local GreyQualityButton = CreateFrame("CheckButton", "CHACHING_GreyQualityButton", ConfigurationPanel, "ChatConfigCheckButtonTemplate")
  22.     GreyQualityButton:SetPoint("TOPLEFT", 20, -80)
  23.     GreyQualityButton.tooltip = "Check to sell all poor (grey) items in your inventory."
  24.     getglobal(GreyQualityButton:GetName().."Text"):SetText("Sell Grey Items?")
  25.     GreyQualityButton:SetScript("OnClick",
  26.     function()
  27.         local isChecked = GreyQualityButton:GetChecked()
  28.         if isChecked then
  29.             sellGrey = true -- 1
  30.         else
  31.             sellGrey = false
  32.         end
  33.     end )
  34.  
  35.     local WhiteQualityButton = CreateFrame("CheckButton", "CHACHING_WhiteQualityButton", ConfigurationPanel, "ChatConfigCheckButtonTemplate")
  36.     WhiteQualityButton:SetPoint("TOPLEFT", 200, -80)
  37.     WhiteQualityButton.tooltip = L["TOOLTIP_CHECK_WHITE_BTN"]
  38.     getglobal(WhiteQualityButton:GetName().."Text"):SetText("Sell White Items (Only Armor and Weapons?")
  39.     WhiteQualityButton:SetScript("OnClick",
  40.     function()
  41.         local isChecked = WhiteQualityButton:GetChecked()
  42.         if isChecked then
  43.             sellWhite = true
  44.         else
  45.             sellWhite = false
  46.         end
  47.     end )
  48.  
  49.     -- SELECT BAG BUTTONS
  50.     local Bags = ConfigurationPanel:CreateFontString(nil, "ARTWORK","GameFontNormal")
  51.     Bags:SetPoint("TOPLEFT", 20, -200)
  52.     Bags:SetText("Select a bag. All items in the selected bag will be sold!")
  53.     local checkBoxLabel = nil
  54.     local xpos = 20
  55.     local ypos = -215
  56.     local delta_y = -20
  57.  
  58.     --**************************************************************************************************************************
  59.     --                                      BAG 1 (The player's backpack) will ALWAYS be present and available
  60.     --**************************************************************************************************************************
  61.     local bagOne = bg:getBag(0)
  62.     checkBoxLabel = string.format("Bag[1] - %s", bagOne:getName() )
  63.     local BagButtonOne = CreateFrame("CheckButton", "CHACHING_BagButtonOne", ConfigurationPanel, "ChatConfigCheckButtonTemplate")
  64.     BagButtonOne:SetPoint("TOPLEFT", xpos, ypos)
  65.     getglobal(BagButtonOne:GetName().."Text"):SetText(checkBoxLabel)
  66.        
  67.     BagButtonOne:SetScript("OnClick",
  68.     function()
  69.         local isChecked = BagButtonOne:GetChecked()
  70.         if isChecked then
  71.             isBagChecked[BAG1] = true
  72.         else
  73.             isBagChecked[BAG1] = false
  74.         end
  75.     end )
  76.    
  77.     --***************************************************************************************************************************
  78.     --                                          BAG 2
  79.     --***************************************************************************************************************************
  80.     local bagTwo = bg:getBag(1)
  81.     if bagTwo ~= nil then
  82.         checkBoxLabel = string.format("Bag[2] - %s", bagTwo:getName())
  83.            
  84.         ypos = ypos + delta_y
  85.         local BagButtonTwo = CreateFrame("CheckButton", "CHACHING_BagButtonTwo", ConfigurationPanel, "ChatConfigCheckButtonTemplate")
  86.         BagButtonTwo:SetPoint("TOPLEFT", xpos, ypos)
  87.         getglobal(BagButtonTwo:GetName().."Text"):SetText(checkBoxLabel)   
  88.  
  89.         BagButtonTwo:SetScript("OnClick",
  90.         function()
  91.             if bagTwo ~= nil then
  92.                 local isChecked = BagButtonTwo:GetChecked()
  93.                 if isChecked then
  94.                     isBagChecked[BAG2] = true
  95.                 else
  96.                     isBagChecked[BAG2] = false
  97.                 end
  98.             end
  99.         end )
  100.     end
  101.  
  102.     --**************************************************************************************************************************
  103.     --                                          BAG 3
  104.     --**************************************************************************************************************************
  105.     local bagThree = bg:getBag(2)
  106.     if bagThree ~= nil then
  107.         checkBoxLabel = string.format("Bag[3] - %s", bagThree:getName())
  108.  
  109.         ypos = ypos + delta_y
  110.         local BagButtonThree = CreateFrame("CheckButton", "CHACHING_BagButtonThree", ConfigurationPanel, "ChatConfigCheckButtonTemplate")
  111.         BagButtonThree:SetPoint("TOPLEFT", xpos, ypos)
  112.         getglobal(BagButtonThree:GetName().."Text"):SetText(checkBoxLabel)
  113.  
  114.         BagButtonThree:SetScript("OnClick",
  115.         function()
  116.             local isChecked = BagButtonThree:GetChecked()
  117.             if isChecked then
  118.                 isBagChecked[BAG3] = true
  119.             else
  120.                 isBagChecked[BAG3] = false
  121.             end
  122.         end )
  123.     end
  124.  
  125.     --**************************************************************************************************************************
  126.     --                                          BAG 4
  127.     --**************************************************************************************************************************
  128.     local bagFour = bg:getBag(3)
  129.     if bagFour ~= nil then
  130.         checkBoxLabel = string.format("Bag[4] - %s", bagFour:getName())
  131.  
  132.         ypos = ypos + delta_y
  133.         local BagButtonFour = CreateFrame("CheckButton", "CHACHING_BagButtonFour", ConfigurationPanel, "ChatConfigCheckButtonTemplate")
  134.         BagButtonFour:SetPoint("TOPLEFT", xpos, ypos)
  135.         local txt = string.format("Bag[4] - %s", bagFour:getName() )
  136.         getglobal(BagButtonFour:GetName().."Text"):SetText(txt)
  137.        
  138.         BagButtonFour:SetScript("OnClick",
  139.         function()
  140.             local isChecked = BagButtonFour:GetChecked()
  141.             if isChecked then
  142.                 isBagChecked[BAG4] = true
  143.             else
  144.                 isBagChecked[BAG4] = false
  145.             end
  146.         end )
  147.     end
  148.  
  149.     --**************************************************************************************************************************
  150.     --                                          BAG 5
  151.     --**************************************************************************************************************************
  152.     local bagFive = bg:getBag(4)
  153.     if bagFive ~= nil then
  154.         checkBoxLabel = string.format("Bag[5] - %s", bagFive:getName())
  155.        
  156.         ypos = ypos + delta_y
  157.         local BagButtonFive = CreateFrame("CheckButton", "CHACHING_BagButtonFive", ConfigurationPanel, "ChatConfigCheckButtonTemplate")
  158.         BagButtonFive:SetPoint("TOPLEFT", xpos, ypos)
  159.         getglobal(BagButtonFive:GetName().."Text"):SetText(checkBoxLabel)
  160.        
  161.         BagButtonFive:SetScript("OnClick",
  162.         function()
  163.             local isChecked = BagButtonFive:GetChecked()
  164.             if isChecked then
  165.                 isBagChecked[BAG5] = true
  166.             else
  167.                 isBagChecked[BAG5] = false
  168.             end
  169.         end )
  170.     end
  171.  
  172.     local readmeMsg1 = string.format("                    *** IMPORTANT ***                               \n")
  173.     local readmeMsg2 = string.format("The merchant buyback window only has 12 slots. However, the merchant\n")
  174.     local readmeMsg3 = string.format("will buy as many items as Cha-Ching is configured to sell. So, if more\n")
  175.     local readmeMsg4 = string.format("than 12 items were sold, you will only be able to buyback the last 12\n")
  176.    
  177.     local ReadmeMessageTitle = ConfigurationPanel:CreateFontString(nil, "ARTWORK","GameFontNormalLarge")
  178.     ReadmeMessageTitle:SetPoint("TOPLEFT", 10, -280)
  179.     ReadmeMessageTitle:SetText(readmeMsg1..readmeMsg2..readmeMsg3..readmeMsg4 )
  180. end
  Reply With Quote