View Single Post
11-25-14, 04:05 PM   #13
Zireko
An Aku'mai Servant
Join Date: Nov 2014
Posts: 38
Ok, I have my code working pretty good now. I just need to add in one last thing. I want it to save if someone selects to lock the frame from my checkboxes and if they select to hide it with the checkboxes.

So can someone explain to me the way I'll need to save variables like this with the wow api? The elder scrolls online saving is very different in a way I think.

Here is my full code currently.

LUA

Lua Code:
  1. --Want to add Show Hide function for each window. ( barQWindow, barAWindow, barMWindow, barCWindow )
  2. --With the Show Hide I want to add this in an addon options window.
  3. --Want to add a lock frame for each window.
  4. --With lock frame I want to add this in an addon options window.
  5.  
  6. --Create a button using lua that pulls up a window for ZBar Options.
  7.  
  8. -- creates a generic button in the middle of the screen --
  9. ZBarButton = CreateFrame("Button","ZBarButton",UIParent,"UIPanelButtonTemplate")
  10. ZBarButton:SetPoint("CENTER",0,0)
  11. ZBarButton:SetWidth(30)
  12. ZBarButton:SetHeight(30)
  13. ZBarButton:SetText("ZB")
  14. ZBarButton:SetMovable(true)
  15. ZBarButton:RegisterForDrag("LeftButton")
  16. ZBarButton:SetScript("OnDragStart",ZBarButton.StartMoving)
  17. ZBarButton:SetScript("OnDragStop",ZBarButton.StopMovingOrSizing)
  18.  
  19. ZBarOptionFrame = CreateFrame("Frame")
  20. ZBarOptionFrame:ClearAllPoints()
  21. ZBarOptionFrame:SetBackdrop(StaticPopup1:GetBackdrop())
  22. ZBarOptionFrame:SetHeight(300)
  23. ZBarOptionFrame:SetWidth(300)
  24. ZBarOptionFrame:Hide(true)
  25.  
  26. ZBarOptionFrame.text = ZBarOptionFrame:CreateFontString(nil, "BACKGROUND", "GameFontNormal")
  27. ZBarOptionFrame.text:SetPoint("CENTER", 0, 125)
  28. ZBarOptionFrame.text:SetText("ZBar Options Verison 1.0")
  29. ZBarOptionFrame:SetPoint("CENTER", 0, 0)
  30.  
  31. ZBarButton:RegisterForClicks("AnyUp")
  32. ZBarButton:SetScript("OnClick", function(self, button, ...)
  33.     if (button == "RightButton") then
  34.         if ZBarOptionFrame:IsShown() then
  35.             ZBarOptionFrame:Hide()
  36.         else
  37.             ZBarOptionFrame:Show()
  38.         end
  39.     end
  40. end)
  41.  
  42. -- My window Names are barQWindow (name frame 1), barCWindow (name frame 2), barMWindow (name frame 3), barAWindow (name frame 4)
  43.  
  44. --Frame 1 (barQWindow)
  45. barQWindowCheckButton = CreateFrame("CheckButton", "barQWindowCheckButton_GlobalName", ZBarOptionFrame, "ChatConfigCheckButtonTemplate");
  46. barQWindowCheckButton:SetPoint("TOPLEFT", 25, -65);
  47. barQWindowCheckButton_GlobalNameText:SetText("Frame 1 Hide");
  48. barQWindowCheckButton.tooltip = "This is will hide the frame.";
  49. barQWindowCheckButton:SetScript("OnClick",
  50.   function()
  51.     if barQWindow:IsShown() then
  52.         barQWindow:Hide()
  53.     else
  54.         barQWindow:Show()
  55.     end
  56.   end
  57. );
  58.  
  59. --Frame 2(barCWindow)
  60. barCWindowCheckButton = CreateFrame("CheckButton", "barCWindowCheckButton_GlobalName", ZBarOptionFrame, "ChatConfigCheckButtonTemplate");
  61. barCWindowCheckButton:SetPoint("TOPLEFT", 25, -85);
  62. barCWindowCheckButton_GlobalNameText:SetText("Frame 2 Hide");
  63. barCWindowCheckButton.tooltip = "This is will hide the frame.";
  64. barCWindowCheckButton:SetScript("OnClick",
  65.   function()
  66.     if barCWindow:IsShown() then
  67.         barCWindow:Hide()
  68.     else
  69.         barCWindow:Show()
  70.     end
  71.   end
  72. );
  73.  
  74. --Frame 3 (barMWindow)
  75. barMWindowCheckButton = CreateFrame("CheckButton", "barMWindowCheckButton_GlobalName", ZBarOptionFrame, "ChatConfigCheckButtonTemplate");
  76. barMWindowCheckButton:SetPoint("TOPLEFT", 25, -105);
  77. barMWindowCheckButton_GlobalNameText:SetText("Frame 3 Hide");
  78. barMWindowCheckButton.tooltip = "This is will hide the frame.";
  79. barMWindowCheckButton:SetScript("OnClick",
  80.   function()
  81.     if barMWindow:IsShown() then
  82.         barMWindow:Hide()
  83.     else
  84.         barMWindow:Show()
  85.     end
  86.   end
  87. );
  88.  
  89. --Frame 4 (barAWindow)
  90. barAWindowCheckButton = CreateFrame("CheckButton", "barAWindowCheckButton_GlobalName", ZBarOptionFrame, "ChatConfigCheckButtonTemplate");
  91. barAWindowCheckButton:SetPoint("TOPLEFT", 25, -125);
  92. barAWindowCheckButton_GlobalNameText:SetText("Frame 4 Hide");
  93. barAWindowCheckButton.tooltip = "This is will hide the frame.";
  94. barAWindowCheckButton:SetScript("OnClick",
  95.   function()
  96.     if barAWindow:IsShown() then
  97.         barAWindow:Hide()
  98.     else
  99.         barAWindow:Show()
  100.     end
  101.   end
  102. );
  103.  
  104. --This will be to lock the frame into place
  105.  
  106. --Frame 1 (barQWindow)
  107. barQWindowLockCheckButton = CreateFrame("CheckButton", "barQWindowLockCheckButton_GlobalName", ZBarOptionFrame, "ChatConfigCheckButtonTemplate");
  108. barQWindowLockCheckButton:SetPoint("TOPLEFT", 150, -65);
  109. barQWindowLockCheckButton_GlobalNameText:SetText("Frame 1 Lock");
  110. barQWindowLockCheckButton.tooltip = "This is will lock the frame in place.";
  111. barQWindowLockCheckButton:SetScript("OnClick",
  112.   function()
  113.     if barQWindow:IsMovable() then
  114.         barQWindow:SetMovable(false)
  115.     else
  116.         barQWindow:SetMovable(true)
  117.     end
  118.   end
  119. );
  120.  
  121. --Frame 2 (barCWindow)
  122. barCWindowLockCheckButton = CreateFrame("CheckButton", "barCWindowLockCheckButton_GlobalName", ZBarOptionFrame, "ChatConfigCheckButtonTemplate");
  123. barCWindowLockCheckButton:SetPoint("TOPLEFT", 150, -85);
  124. barCWindowLockCheckButton_GlobalNameText:SetText("Frame 2 Lock");
  125. barCWindowLockCheckButton.tooltip = "This is will lock the frame in place.";
  126. barCWindowLockCheckButton:SetScript("OnClick",
  127.   function()
  128.     if barCWindow:IsMovable() then
  129.         barCWindow:SetMovable(false)
  130.     else
  131.         barCWindow:SetMovable(true)
  132.     end
  133.   end
  134. );
  135.  
  136. --Frame 3 (barMWindow)
  137. barMWindowLockCheckButton = CreateFrame("CheckButton", "barMWindowLockCheckButton_GlobalName", ZBarOptionFrame, "ChatConfigCheckButtonTemplate");
  138. barMWindowLockCheckButton:SetPoint("TOPLEFT", 150, -105);
  139. barMWindowLockCheckButton_GlobalNameText:SetText("Frame 3 Lock");
  140. barMWindowLockCheckButton.tooltip = "This is will lock the frame in place.";
  141. barMWindowLockCheckButton:SetScript("OnClick",
  142.   function()
  143.     if barMWindow:IsMovable() then
  144.         barMWindow:SetMovable(false)
  145.     else
  146.         barMWindow:SetMovable(true)
  147.     end
  148.   end
  149. );
  150.  
  151. --Frame 4 (barMWindow)
  152. barAWindowLockCheckButton = CreateFrame("CheckButton", "barAWindowLockCheckButton_GlobalName", ZBarOptionFrame, "ChatConfigCheckButtonTemplate");
  153. barAWindowLockCheckButton:SetPoint("TOPLEFT", 150, -125);
  154. barAWindowLockCheckButton_GlobalNameText:SetText("Frame 4 Lock");
  155. barAWindowLockCheckButton.tooltip = "This is will lock the frame in place.";
  156. barAWindowLockCheckButton:SetScript("OnClick",
  157.   function()
  158.     if barAWindow:IsMovable() then
  159.         barAWindow:SetMovable(false)
  160.     else
  161.         barAWindow:SetMovable(true)
  162.     end
  163.   end
  164. );

XML

Lua Code:
  1. <Ui xmlns="http://www.blizzard.com/wow/ui/"
  2.                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3.                    xsi:schemaLocation="http://www.blizzard.com/wow/ui/
  4.                   ..\..\FrameXML\UI.xsd">
  5.     <Frame name="barQWindow" frameStrata="BACKGROUND" parent="UIParent" movable="true" alpha="0.8">
  6.         <Size x="300" y="900"/>
  7.             <Anchors>
  8.                 <Anchor point="BOTTOM"/>
  9.             </Anchors>
  10.             <Layers>
  11.                 <Layer level="BACKGROUND">
  12.                     <Texture file="Interface\AddOns\ZBar\ZBarImgs\barA.blp" setAllPoints="true"/>
  13.                 </Layer>
  14.             </Layers>
  15.     <Scripts>
  16.         <OnMouseDown>
  17.             self:StartMoving()
  18.         </OnMouseDown>
  19.         <OnMouseUp>
  20.             self:StopMovingOrSizing()
  21.         </OnMouseUp>
  22.     </Scripts>
  23.     </Frame>
  24.     <Frame name="barCWindow" frameStrata="BACKGROUND" parent="UIParent" movable="true" alpha="0.8">
  25.         <Size x="600" y="300"/>
  26.             <Anchors>
  27.                 <Anchor point="BOTTOM"/>
  28.             </Anchors>
  29.             <Layers>
  30.                 <Layer level="BACKGROUND">
  31.                     <Texture file="Interface\AddOns\ZBar\ZBarImgs\barA.blp" setAllPoints="true"/>
  32.                 </Layer>
  33.             </Layers>
  34.     <Scripts>
  35.         <OnMouseDown>
  36.             self:StartMoving()
  37.         </OnMouseDown>
  38.         <OnMouseUp>
  39.             self:StopMovingOrSizing()
  40.         </OnMouseUp>
  41.     </Scripts>
  42.     </Frame>
  43.     <Frame name="barMWindow" frameStrata="BACKGROUND" parent="UIParent" movable="true" alpha="0.8">
  44.         <Size x="600" y="300"/>
  45.             <Anchors>
  46.                 <Anchor point="BOTTOM"/>
  47.             </Anchors>
  48.             <Layers>
  49.                 <Layer level="BACKGROUND">
  50.                     <Texture file="Interface\AddOns\ZBar\ZBarImgs\barA.blp" setAllPoints="true"/>
  51.                 </Layer>
  52.             </Layers>
  53.     <Scripts>
  54.         <OnMouseDown>
  55.             self:StartMoving()
  56.         </OnMouseDown>
  57.         <OnMouseUp>
  58.             self:StopMovingOrSizing()
  59.         </OnMouseUp>
  60.     </Scripts>
  61.     </Frame>
  62.     <Frame name="barAWindow" frameStrata="BACKGROUND" parent="UIParent" movable="true" alpha="0.8">
  63.         <Size x="2000" y="300"/>
  64.             <Anchors>
  65.                 <Anchor point="BOTTOM"/>
  66.             </Anchors>
  67.             <Layers>
  68.                 <Layer level="BACKGROUND">
  69.                     <Texture file="Interface\AddOns\ZBar\ZBarImgs\barA.blp" setAllPoints="true"/>
  70.                 </Layer>
  71.             </Layers>
  72.     <Scripts>
  73.         <OnMouseDown>
  74.             self:StartMoving()
  75.         </OnMouseDown>
  76.         <OnMouseUp>
  77.             self:StopMovingOrSizing()
  78.         </OnMouseUp>
  79.     </Scripts>
  80.     </Frame>
  81. </Ui>

Toc

Lua Code:
  1. ## Interface: 60000
  2. ## Title: ZBar
  3. ## Notes: A simple skin addon that allows you to place your ui into it.
  4. ## Author: Zireko
  5. ## Version: 1.0
  6.  
  7. ZBar.xml
  8. ZBar.lua
  Reply With Quote