I'm trying to add some extra text in a custon fonstring to PitBull unitframes but for some reason I can't seem to get the text to overlap the unitframes.
local f = PitBull4_Frames_target:CreateFontString(nil, "OVERLAY")
f:SetPoint("CENTER", PitBull4_Frames_target, "CENTER")
f:SetFontObject(GameFontNormalLarge)
f:SetText("Test")
This works but my fonstring ends up behind the unitframes, if I try to create it on a frame "higher" up like this
local f = PitBull4_Frames_target.Portrait:CreateFontString()
I get an error that it doesnt exists
if I just put the frame in wowlua it prints
PitBull4_Frames_target.Portrait
> nil
but if I target something and then clear my target it shows
PitBull4_Frames_target.Portrait
> table: xxxxxxx
So I can't use the portrait frame until it's created, and it only appears to be created when you target something. Not like Blizzards TargetFramePortrait, So what should I do? register to PLAYER_TARGET_CHANGED and then create my font when it fires? Is that the only way or what
So I'm making an addon that is gonna create a button on your screen with your currently equipped weapon and if you mouseover it you will get a menu displaying all your weapons in your bag for easy swapping. As I was working on it I realized that blizzard already has this functionality if you hold down ALT while mouseovering your character frame slots, aka PaperdollFrame.
So my question is how can I use this function on my frames? Or should I just write my own?
edit: nvm I decided to make my own function, I got most of it working except 1 part, the positioning or docking of the button menu.
function addon.CreatePopupButton(idx, itemID)
local buttonName = "PopupButton"..idx
local button = _G[buttonName]
if not button then
button = CreateFrame("Button", buttonName, UIParent, "ActionButtonTemplate")
button:SetScript("OnClick",function(self)
EquipItemByName(self.ID, 16)
addon.Button_OnLeave()
end)
print("created: " .. button:GetName())
end
_G[buttonName.."Icon"]:SetTexture(select(10, GetItemInfo(itemID)))
button.ID = itemID
button:ClearAllPoints()
button:Show()
if idx == 1 then
button:SetPoint("LEFT", addon.weaponIcon, "RIGHT")
else
button:SetPoint("LEFT", _G["PopupButton"..(idx - 1)], "RIGHT")
end
end
That last part is the best I can do, the buttons are alligned one after another in a long row, I would like the menu to have perhaps 2 rows instead but how?? ???
Ok wait I'm a bit confused, I need 3 tables? 2 local (defaults, addon.db) and 1 global (NameOfAddonDBPC) ? or is addon.db just pointing to the global table? I got it working but I made a slightly different version since the code posted above was a bit hard to understand for me.
Does this look alright?
function addon.InitializeDB()
if not FriendFrames_DB then
print("found no db, creating one..")
FriendFrames_DB = {}
end
addon.db = {}
for k, v in pairs(defaults) do
print("checking for: " .. k .. " in db")
if FriendFrames_DB[k] ~= nil then
print("found: " .. k .. " in db")
else
print("cant find: " .. k .. " in db, copying from defaults")
FriendFrames_DB[k] = v
end
end
addon.db = FriendFrames_DB
end
I added a table with all my settings for my addon in by using SavedVariablesPerCharacter in my toc file. After I loaded up my addon I checked in the savedvariables folder for the addon file and found it with all the settings in it, ok so far so good.
But later I made some changes to my addon and added a few more settings to the table but when I try to load up my addon it still uses the old table info and as such gives an error about not finding specific table entries.
So my only option is to manually delete the file in savedvariables folder everytime I want to make a change to the addon that involves adding new entries to my settings table. Is this how it's supposed to be? Why wont my settings overwrite the old lua file?
I got it working with custom fonts, and it didn't set that font on the entire menu. You just have to create a font object for each font, unless one already exists. May be another way; didn't really try.
Just another question, I made a list with a couple of fonts. How can I make the dropdown list show the font name written in it's own font? I can't find anywhere to change the font of the list.
I'm about to create my first addon using drop down menus, I've been reading a few guides and tutorials and managed to put together a working piece of code. But before I go ahead and add it to my main addon I would like to know what you experienced coders think about this way of adding menus.
--not included: addon is a table, addon.panel is the interface options frame
-- create the dropdown frame
addon.dropdown1 = CreateFrame("Frame", addonName.."dropdown1", addon.panel, "UIDropDownMenuTemplate")
addon.dropdown1:SetPoint("TOPLEFT", addon.checkbox1, "BOTTOMLEFT", -15, -20)
addon.dropdown1:SetWidth(50)
_G[addon.dropdown1:GetName().."Button"]:SetScript("OnClick", function(self, button, down)
print("clicked")
ToggleDropDownMenu(1, nil, addon.dropdown1, self:GetName(), -100 ,0)
end)
-- some tables to store data in
local currentItem -- will be inside an options DB later
local info = {}
local itemsTbl = {
"Item 1",
"Item 2",
"Item 3",
"Item 4",
}
-- function to create the menus
function addon.dropdown1.initialize(self, level)
if not level then return end
wipe(info)
if level == 1 then
addon.CreateMenu(info)
end
end
-- looped function for creating lots of menus, will be adding more than 4
function addon.CreateMenu(info)
for i = 1, 4 do
info.text = "Menu " .. itemsTbl[i]
info.isTitle = nil
info.notCheckable = nil
info.checked = addon.isCurrent(i)
info.func = function()
print("seleced " ..itemsTbl[i])
currentItem = i
_G[addon.dropdown1:GetName().."Text"]:SetText("Menu " .. itemsTbl[i])
end
UIDropDownMenu_AddButton(info)
end
end
-- function to check if current menu item is the selected one
function addon.isCurrent(num)
if currentItem == num then
return true
else
return false
end
end
0
This works but my fonstring ends up behind the unitframes, if I try to create it on a frame "higher" up like this
I get an error that it doesnt exists
if I just put the frame in wowlua it prints
PitBull4_Frames_target.Portrait
> nil
but if I target something and then clear my target it shows
PitBull4_Frames_target.Portrait
> table: xxxxxxx
So I can't use the portrait frame until it's created, and it only appears to be created when you target something. Not like Blizzards TargetFramePortrait, So what should I do? register to PLAYER_TARGET_CHANGED and then create my font when it fires? Is that the only way or what
0
0
But I have no idea how to do it, any help would be appreciated
0
edit: nvm I decided to make my own function, I got most of it working except 1 part, the positioning or docking of the button menu.
That last part is the best I can do, the buttons are alligned one after another in a long row, I would like the menu to have perhaps 2 rows instead but how?? ???
0
0
Does this look alright?
0
But later I made some changes to my addon and added a few more settings to the table but when I try to load up my addon it still uses the old table info and as such gives an error about not finding specific table entries.
So my only option is to manually delete the file in savedvariables folder everytime I want to make a change to the addon that involves adding new entries to my settings table. Is this how it's supposed to be? Why wont my settings overwrite the old lua file?
In my saved variables file I only have "locked" until I delete it and relog and then it updates.
0
?
0
Hmm that's actually a pretty good idea, thanks!
0
0
But that don't work for custom fonts and it makes the entire list in that fontonject. The effect im looking for is this
0
0
0
0