Thread Tools Display Modes
03-23-12, 08:55 AM   #1
lerb
A Frostmaul Preserver
 
lerb's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 264
Moving the LootFrame

Hey guys and girls, requesting some help.

I've re-written !beautyLoot to fit my own visual style and needs, but I can't for the love of god move it. Here's the LUA for those willing to give a hand

Ps. As you'll see in the code I've tried positioning the lootframe with ClearAllPoints() and then SetPoint(), but it isn't working. Below is a screenshot of where it spawns aswell.

Also, the lootframe is draggable when spawned, I can't remember if this is default by Blizzard because it's been years since I used the default UI. If it isn't, could that be what is interfering with me changing spawnpoint?

Code:
local _G = _G

-- LerbLoot, by Lerb @ WoWInterface.com 
-- Original code taken from "AftermathhUI" by Game92 @ WoWInterface.com

----------------------
-- Move closebutton --
----------------------

_G["LootCloseButton"]:ClearAllPoints()
_G["LootCloseButton"]:SetPoint('TOPRIGHT', _G['LootFrame'], 'TOPRIGHT', -69, -10)

--------------------
-- Move lootitems --
--------------------

_G["LootButton1"]:ClearAllPoints()
_G['LootButton1']:SetPoint('TOPLEFT', _G['LootFrame'], 'TOPLEFT', 9, -34)

----------------------------
-- Hide fugly 2D portrait --
----------------------------

_G["LootFramePortraitOverlay"]:SetAlpha(0)

------------------------
-- Move the lootframe --
------------------------

_G["LootFrame"]:ClearAllPoints()
_G["LootFrame"]:SetPoint('TOPLEFT', UIparent, 50, -230)

--------------------------------------
-- Create our own stylish lootframe --
--------------------------------------

local LootBG = CreateFrame('Frame', nil, _G["LootFrame"])
LootBG:SetPoint('TOPLEFT', 1, -1)
LootBG:SetPoint('RIGHT', -1, 1)
LootBG:SetFrameStrata("LOW")	
LootBG:SetBackdrop({			
    bgFile = LeUI.media.blank,
	insets = {top = 12, left = 2, bottom = 4, right = 70},
})
LootBG:SetBackdropColor(unpack(LeUI.media.backdropcolor))
CreateBorderLight(LootBG, LeUI.media.bordersize, LeUI.bordercolor, LeUI.bordercolor, LeUI.bordercolor, -1, -11, -70, -11, -1, -2, -70, -2)

--------------------------------------------
-- Change font for lootname and lootcount --
--------------------------------------------

for i = 1, 4 do
    for _, lootfont in pairs({
       _G['LootButton'..i..'Text'],
    }) do
        lootfont:SetFont(LeUI.media.font, 12, LeUI.media.fontflag)
    end
	for _, lootcount in pairs({
	    _G['LootButton'..i..'Count'],
	}) do
	    lootcount:SetFont(LeUI.media.font, 12, LeUI.media.fontflag)
		lootcount:SetPoint('BOTTOMRIGHT', -2, 3)
	end
end

---------------------------------------------------------------------
-- Change borders for lootitems and set bordercolor for questitems --
---------------------------------------------------------------------

hooksecurefunc("LootFrame_UpdateButton", function(index)
	local texture, item, quantity, quality, locked, isQuestItem, questId, isActive = GetLootSlotInfo(index)
	CreateBorderLight(_G["LootButton"..index], LeUI.media.bordersize, LeUI.bordercolor, LeUI.bordercolor, LeUI.bordercolor, 1)
	_G["LootButton"..index.."IconQuestTexture"]:SetAlpha(0) -- Hides quest item texture
	_G["LootButton"..index.."NameFrame"]:SetAlpha(0) -- Hides frame behind lootname
	if isQuestItem then
	    ColorBorder(_G["LootButton"..index], 1.0, 0.82, 0)
	else
        ColorBorder(_G["LootButton"..index], LeUI.bordercolor, LeUI.bordercolor, LeUI.bordercolor)	
	end	
end)

------------------------------------------------------------------------------------------------------------
-- Improved Loot Frame - http://www.curse.com/addons/wow/improved-loot-frame -- by Cybeloras of Mal'Ganis --
------------------------------------------------------------------------------------------------------------

-- Woah, nice coding, blizz. Anchor something positioned at the top of the frame to the center of the frame instead, and make it an anonymous font string so I have to work to find it
local i, t = 1, "Interface\\LootFrame\\UI-LootPanel"
while true do
	local r = select(i, _G["LootFrame"]:GetRegions())
	if not r then break end
	if r.GetText and r:GetText() == ITEMS then
		r:ClearAllPoints()
		r:SetPoint("TOP", -32, -18)
	elseif r.GetTexture and r:GetTexture() == t then
		r:Hide()
	end
	i = i + 1
end

local p, r, x, y = "TOP", "BOTTOM", 0, -4
local buttonHeight = _G["LootButton1"]:GetHeight() + abs(y)
local baseHeight = _G["LootFrame"]:GetHeight() - (buttonHeight * LOOTFRAME_NUMBUTTONS) - 50

local old_LootFrame_Show = LootFrame_Show
function LootFrame_Show(self, ...)
	_G["LootFrame"]:SetHeight(baseHeight + (GetNumLootItems() * buttonHeight))
	local num = GetNumLootItems()
	for i = 1, GetNumLootItems() do
		if i > LOOTFRAME_NUMBUTTONS then
			if not _G["LootButton"..i] then
				_G["LootButton"..i] = CreateFrame("Button", "LootButton"..i, LootFrame, "LootButtonTemplate", i)
			end
			LOOTFRAME_NUMBUTTONS = i
		end
		if i > 1 then
			_G["LootButton"..i]:ClearAllPoints()
			_G["LootButton"..i]:SetPoint(p, "LootButton"..(i-1), r, x, y)
		end
	end
	
	return old_LootFrame_Show(self, ...)
end

-------------------------------------------------------------------------------------------------------
-- The following is inspired by http://us.battle.net/wow/en/forum/topic/2353268564 and is hacktastic --
-------------------------------------------------------------------------------------------------------

local framesRegistered = {}
local function populateframesRegistered(...)
	wipe(framesRegistered)
	for i = 1, select("#", ...) do
		framesRegistered[i] = select(i, ...)
	end
end

local old_LootButton_OnClick = LootButton_OnClick
function LootButton_OnClick(self, ...)
	populateframesRegistered(GetFramesRegisteredForEvent("ADDON_ACTION_BLOCKED"))
	
	for i, frame in pairs(framesRegistered) do
		frame:UnregisterEvent("ADDON_ACTION_BLOCKED") -- F*ck the rice-a-roni! (Blizzard throws a false taint error when attemping to loot the coins from a mob when the coins are the only loot on the mob)
	end
	old_LootButton_OnClick(self, ...)
	
	for i, frame in pairs(framesRegistered) do
		frame:RegisterEvent("ADDON_ACTION_BLOCKED")
	end
end
  Reply With Quote
03-23-12, 09:16 AM   #2
Xruptor
A Flamescale Wyrmkin
 
Xruptor's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 137
I'm not sure exactly what is the problem your referring to. Can you be a little more specific? Judging from the screenshot it looks like it's working just fine. If you can explain the issues in detail I may be able to help you.

If you want to move the group loot frames you can use my LootRollMover addon. It's been around for years.
http://www.wowinterface.com/download...RollMover.html
__________________
Click HERE for the ultimate idiot test.

if (sizeof(sadness) > sizeof(happiness)) { initDepression(); }

Last edited by Xruptor : 03-23-12 at 09:20 AM.
  Reply With Quote
03-23-12, 09:20 AM   #3
lerb
A Frostmaul Preserver
 
lerb's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 264
Originally Posted by Xruptor View Post
Neat you should put this together as a simple addon for those wanting to move the looting frame

If you want to move the group loot frames you can use my LootRollMover addon. It's been around for years.
http://www.wowinterface.com/download...RollMover.html
I have my own lootroll frames and they're just where I need them to be Your addon description states that's what it moves, while I need to move the lootframe that pops up when looting in solo etc. I'd prefer using code to do it, since my UI is LUA-based and I'd like to keep it that way
  Reply With Quote
03-23-12, 09:21 AM   #4
Xruptor
A Flamescale Wyrmkin
 
Xruptor's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 137
Originally Posted by lerb View Post
I have my own lootroll frames and they're just where I need them to be Your addon description states that's what it moves, while I need to move the lootframe that pops up when looting in solo etc. I'd prefer using code to do it, since my UI is LUA-based and I'd like to keep it that way

Yeah I edited my original post Please re-read it. I accidentally posted it without previewing it first.. go figure!
__________________
Click HERE for the ultimate idiot test.

if (sizeof(sadness) > sizeof(happiness)) { initDepression(); }
  Reply With Quote
03-23-12, 09:28 AM   #5
lerb
A Frostmaul Preserver
 
lerb's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 264
Ah, I see

Well yeah, it looks pretty okay, but it overlaps the chat just a tiny pit and it's making my eyes itch. I'd just want to move it about 20-30 pixels down so that it's clear of the chat and the chat editbox (if someone is a born multitasker an writes messages and loots at the same time ).
  Reply With Quote
03-23-12, 10:42 AM   #6
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Isn't this
Code:
------------------------
-- Move the lootframe --
------------------------

_G["LootFrame"]:ClearAllPoints()
_G["LootFrame"]:SetPoint('TOPLEFT', UIparent, 50, -230)
exactly where it is in your screenshot?
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
03-23-12, 12:13 PM   #7
lerb
A Frostmaul Preserver
 
lerb's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 264
Originally Posted by Seerah View Post
Isn't this
Code:
------------------------
-- Move the lootframe --
------------------------

_G["LootFrame"]:ClearAllPoints()
_G["LootFrame"]:SetPoint('TOPLEFT', UIparent, 50, -230)
exactly where it is in your screenshot?
Haha, good point Seerah

But no, and it doesn't matter what I change those coordinates to, the loot frame won't budge
  Reply With Quote
03-23-12, 12:34 PM   #8
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Perhaps you are trying to move the loot frame before the UI places it? What happens when you run that code while in-game?
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
03-23-12, 12:44 PM   #9
lerb
A Frostmaul Preserver
 
lerb's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 264
Originally Posted by Seerah View Post
Perhaps you are trying to move the loot frame before the UI places it? What happens when you run that code while in-game?
Don't know how to run commands in game, sorry How do I do that?

Thing is, I posted the whole module that handles the lootwindow at the top of the thread. Those two lines are the only ones in that module that handles positioning of the LootFrame.

I've searched every other module within my UI and nothing touches the LootFrame, so I must be doing something wrong here. Something really obvious :P
  Reply With Quote
03-23-12, 12:54 PM   #10
Waky
A Cobalt Mageweaver
 
Waky's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2010
Posts: 200
Originally Posted by lerb View Post
Don't know how to run commands in game, sorry How do I do that?
You can run commands (scripts) in game by typing

Code:
/script [Code goes right her]
Or you could use, one of my favorite addons, _DevPad. Invaluable for testing code in-game, in my opinion!
  Reply With Quote
03-23-12, 12:58 PM   #11
lerb
A Frostmaul Preserver
 
lerb's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 264
Originally Posted by Waky View Post
You can run commands (scripts) in game by typing

Code:
/script [Code goes right her]
Or you could use, one of my favorite addons, _DevPad. Invaluable for testing code in-game, in my opinion!
Alright! Sweet I'll surely look up that later because while I had the lootframe on the screen (i.e looting) I ran that command and it moved the lootframe.

I'm guessing it has something to do with.. Erm.. Events? Like the event that has to do with the lootframe appearing? I'm really no master at this, just learning

If anyone could point me in the right direction, I'll loot you forever!
  Reply With Quote
03-23-12, 01:12 PM   #12
Waky
A Cobalt Mageweaver
 
Waky's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2010
Posts: 200
I just looked at WoWProgramming's Event List and found

LOOT_OPENED

Fires when the player begins interaction with a lootable corpse or object
I would presume this is what you need to register in order to know when to re-position the frame.

I've never modded the LootFrame, so I'm not entirely sure how it works in the default UI though.
  Reply With Quote
03-24-12, 11:18 PM   #13
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Whenever you're trying to modify a Blizzard UI object (like the loot frame) you should look at the Blizzard UI code that creates and controls that object. In this case, you should look at FrameXML\LootFrame.lua:

http://wowprogramming.com/utils/xmlb.../LootFrame.lua

If you search for SetPoint in the code, you can see exactly when the UI sets the position of the loot frame, and this will tell you when you need to run your own code to move the loot frame where you want it.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Moving the LootFrame


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