Advertisement
Lildry

RiftLoot

Oct 27th, 2011
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.66 KB | None | 0 0
  1. -- This will run in Rift but it has no real function yet
  2. -- I would like to make it known where I learned and some of the code I used for this add-on.
  3. -- A large part of the code was created useing RuneCraft Helper as a guide.
  4. -- I learned several of the function from Marru, the creater of RiftCount many thanks to you for given me idea's and helping me learn.
  5.  
  6. -- Create context for UIFrames
  7. local context = UI.CreateContext("RiftLoot")
  8. local riftlootwindow = UI.CreateFrame("RiftWindow", "RiftLoot", context)
  9. local rlclosebutton = UI.CreateFrame("RiftButton", "RLClosebutton", riftlootwindow)
  10. local clickOffset = {x = 0, y = 0}
  11.  
  12.  
  13.  
  14.  
  15. -- used for the button to close riftlootwindow.
  16.  
  17. local function rlHideWindow()
  18.     riftlootwindow:SetVisible(false)
  19.     rlwindowState = 'hide'
  20. end
  21.  
  22.  -- used for the button to open riftlootwindow
  23.  
  24. local function rlShowWindow()
  25.     riftlootwindow:SetVisible(true)
  26.     rlwindowState = 'show'
  27. end
  28.  
  29.  
  30. -- this creates the window for riftloot, this will be where you make loot information selections.
  31.    
  32.     function rlcreatewindow()
  33.  
  34.     riftlootwindow:SetVisible(false)
  35.     riftlootwindow:SetWidth(800)
  36.     riftlootwindow:SetHeight(800)
  37.     riftlootwindow:SetPoint("CENTER", UIParent, "CENTER")
  38.     riftlootwindow:SetTitle("RiftLoot")
  39.     riftlootwindow:SetLayer(1)
  40.  
  41.     local rldropdown = UI.CreateFrame("Text", "rldropdown", riftlootwindow)
  42.     rldropdown:SetText("Select Instance")
  43.     rldropdown:SetPoint("CENTER", riftlootwindow, "TOPLEFT", 50, 100)
  44.     rldropdown:SetBackgroundColor(0,0,0,0)
  45.  
  46.    
  47.     rlclosebutton:SetText("Close")
  48.     rlclosebutton:SetPoint("BOTTOMCENTER", riftlootwindow, "BOTTOMCENTER", 0, -24) 
  49.         function rlclosebutton.Event:LeftPress()
  50.         riftlootwindow:SetVisible(false)
  51.     end
  52.    
  53.     end
  54.    
  55.  
  56.    
  57.  
  58. -- Create riftloot visual button with image riftbutton3.PNG
  59.  
  60.     function rlcreateButton()
  61.     riftlootbutton = UI.CreateFrame("Texture", "RiftLoot", context)
  62.     riftlootbutton:SetVisible(true)
  63.     riftlootbutton:SetWidth(34)
  64.     riftlootbutton:SetHeight(34)
  65.     riftlootbutton:SetTexture("RiftLoot", "image/riftbutton1.PNG")
  66.     riftlootbutton:SetPoint("TOPLEFT", UIParent, "TOPLEFT", locbutton["x"], locbutton["y"])
  67.     riftlootbutton:SetMouseMasking("limited")
  68.     riftlootbutton:SetLayer(2)
  69.    
  70.     -- Create riftloot button that you click, this button will not be seen.
  71.    
  72.     riftlootRealButton = UI.CreateFrame("Texture", "riftloot Real Button", riftlootbutton)
  73.     riftlootRealButton:SetWidth(34)
  74.     riftlootRealButton:SetHeight(34)
  75.     riftlootRealButton:SetPoint("CENTER", riftlootbutton, "CENTER", 0, 0)
  76.     riftlootRealButton.pressed = false
  77.     riftlootRealButton.dragActive = false
  78.    
  79.     -- Create frame for the tooltip, this will hold the tooltip.
  80.    
  81.     local rlbuttonTooltip = UI.CreateFrame("Frame",  "Tooltip", context)
  82.     rlbuttonTooltip:SetWidth(220)
  83.     rlbuttonTooltip:SetHeight(100)
  84.     rlbuttonTooltip:SetPoint("BOTTOMLEFT", riftlootRealButton, "BOTTOMLEFT", -130, 70)
  85.     rlbuttonTooltip:SetVisible(false)
  86.    
  87.     -- Create text for the tooltip frame, This is text that will go in the frame.
  88.    
  89.     local rlbuttonTooltipText = UI.CreateFrame("Text", "window", rlbuttonTooltip)
  90.     rlbuttonTooltipText:SetLayer(4)
  91.     rlbuttonTooltipText:SetText("Rift Loot")
  92.     rlbuttonTooltipText:SetPoint("TOPLEFT", rlbuttonTooltip, "TOPLEFT", 10, 8)
  93.     rlbuttonTooltipText:SetFontColor(0.5, 0.78, 0.19)
  94.     rlbuttonTooltipText:SetFontSize(15)
  95.     rlbuttonTooltipText:ResizeToText()
  96.    
  97.     local rlseparator = UI.CreateFrame("Mask", "RiftLootSeperator", context)
  98.     rlseparator:SetParent(rlbuttonTooltip)
  99.     rlseparator:SetPoint("CENTERX", rlbuttonTooltip, "CENTERX")
  100.     rlseparator:SetPoint("TOP", rlbuttonTooltipText, "BOTTOM")
  101.     rlseparator:SetWidth(200)
  102.     rlseparator:SetHeight(3)
  103.     rlseparator:SetLayer(4)
  104.    
  105.     local rlbuttonTooltipBody = UI.CreateFrame("Text", "Rift Loot", rlbuttonTooltip)
  106.     rlbuttonTooltipBody:SetLayer(4)
  107.     rlbuttonTooltipBody:SetText("Left click to open Rift Loot. Right click to drag button")
  108.     rlbuttonTooltipBody:SetPoint("TOPLEFT", rlseparator, "BOTTOMLEFT")
  109.     rlbuttonTooltipBody:SetPoint("BOTTOMRIGHT", rlbuttonTooltip, "TOPLEFT", 200, 70)
  110.     rlbuttonTooltipBody:SetFontColor(1, 1, 1)
  111.     rlbuttonTooltipBody:SetFontSize(13)
  112.     rlbuttonTooltipBody:SetWordwrap(true)
  113.    
  114.    
  115.  
  116.     function riftlootRealButton.Event:MouseIn()
  117.         rlbuttonTooltip:SetVisible(true)
  118.     end
  119.    
  120.     function riftlootRealButton.Event:MouseOut()
  121.         rlbuttonTooltip:SetVisible(false)
  122.     end
  123.    
  124.     function riftlootRealButton.Event:LeftDown()
  125.         riftlootRealButton.pressed = true
  126.     end
  127.    
  128.     function riftlootRealButton.Event:LeftUp()
  129.         if riftlootRealButton.pressed == true then
  130.             if rlwindowState then
  131.                 if rlwindowState == 'hide' then
  132.                     rlShowWindow()
  133.                 else
  134.                     rlwindowState = 'show'
  135.                     print ("Rift Loot has been closed")
  136.                     rlHideWindow()
  137.                 end
  138.             end
  139.         riftlootRealButton.pressed = false
  140.         end
  141.     end
  142.  
  143.    
  144.     function riftlootRealButton.Event:LeftUpoutside()
  145.         riftlootRealButton.pressed = false
  146.         riftlootbutton:SetTexture("RiftLoot", "riftbutton.PNG")
  147.     end
  148.    
  149.     -- right click and drag button on screen
  150.    
  151. function riftlootRealButton.Event:RightDown()
  152.         riftlootRealButton.dragActive = true
  153.         local mouseStatus = Inspect.Mouse()
  154.         clickOffset["x"] = mouseStatus.x - locbutton["x"]
  155.         clickOffset["y"] = mouseStatus.y - locbutton["y"]
  156.     end
  157.  
  158.     function riftlootRealButton.Event:RightUp()
  159.         riftlootRealButton.dragActive = false
  160.     end
  161.  
  162.     function riftlootRealButton.Event:RightUpoutside()
  163.         riftlootRealButton.dragActive = false
  164.     end
  165.  
  166.     function riftlootRealButton.Event:MouseMove(x,y)
  167.         if riftlootRealButton.dragActive == true then
  168.             locbutton["x"] = x - clickOffset["x"]
  169.             locbutton["y"] = y - clickOffset["y"]  
  170.             riftlootbutton:SetPoint("TOPLEFT", context, "TOPLEFT", locbutton["x"], locbutton["y"])
  171.         end
  172.     end
  173.  
  174.  
  175.  
  176. end
  177.  
  178.  
  179. -- this loads the Addon setting
  180.  
  181. local function loadSettings()
  182.     print ("RiftLoot is loaded")
  183.     if rlwindowState then
  184.         if rlwindowState == 'hide' then
  185.             print ("Welcome to RiftLoot vers 1.2")
  186.         end
  187.     else
  188.         rlwindowState = 'show'
  189.     end
  190.    
  191.     if locbutton == nil then
  192.         locbutton = {x = ((UIParent:GetRight() / 2) - 32), y = ((UIParent:GetBottom() / 2) - 32)}
  193.     end
  194.     rlcreateButton()
  195.     rlcreatewindow()
  196. end
  197.  
  198. function LoadVariables()
  199. end
  200.  
  201. local function rlSlashCommand(params)
  202.     if rlwindowState then
  203.         if rlwindowState == 'hide' then
  204.             rlShowWindow()
  205.         else
  206.             rlwindowState = 'show'
  207.             print ("L")
  208.             rlHideWindow()
  209.         end
  210.     end
  211. end
  212.  
  213. table.insert (Event.Addon.Startup.End, {loadSettings, "RiftLoot", "loadSettings"}) 
  214. table.insert (Command.Slash.Register("rlb"), {riftlootbutton1, "RiftLoot", "Slash command"})
  215. table.insert (Command.Slash.Register("rlc"), {riftlootwindow2, "RiftLoot", "Slash command"})       
  216. table.insert (Command.Slash.Register("rl"), {riftlootwindow1, "RiftLoot", "Slash command"})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement