Forum > Miscellaneous
How would I create a new menu?
(1/1)
Kobiesan:
I want to create a new menu called "Collection" or something like that and put it next to the mounts/pets tabs. How would I go about making something like that?
Grymskvll:
Look at Blizzard's XML+Lua to get an idea of how it's done.
It might be a little easier to make it a standalone frame, rather than making it part of CharacterFrame. It's understandable if you want to make it part of CharacterFrame, but consider that (in WotLK) there's no room left under the frame for another tab.
If you're talking about changing CharacterFrame, look at these files for a start:
--- Code: ---Interface\FrameXML\CharacterFrame.xml Interface\FrameXML\CharacterFrame.lua Interface\FrameXML\CharacterFrameTemplates.xml
--- End code ---
CharacterFrame.xml sets up the frames, CharacterFrame.lua handles the logic and CharacterFrameTemplates.xml has the template for tab buttons.
Taking a quick look at CharacterFrame.lua, there's this function that handles switching tabs:
--- Code: ---function CharacterFrameTab_OnClick (self, button) local name = self:GetName(); if ( name == "CharacterFrameTab1" ) then ToggleCharacter("PaperDollFrame"); elseif ( name == "CharacterFrameTab2" ) then ToggleCharacter("PetPaperDollFrame"); elseif ( name == "CharacterFrameTab3" ) then ToggleCharacter("ReputationFrame"); elseif ( name == "CharacterFrameTab4" ) then ToggleCharacter("SkillFrame"); elseif ( name == "CharacterFrameTab5" ) then ToggleCharacter("TokenFrame"); end PlaySound("igCharacterInfoTab"); end --- End code ---
You could overwrite this, or just have a new function handle the OnClick for your new tab, but then you can't use the same tab button template (or you have to overwrite the onclick script).
The actual contents of the tabs are just child frames of CharacterFrame.
function ToggleCharacter (tab) is defined in CharacterFrame.lua, and calls this function:
--- Code: ---function CharacterFrame_ShowSubFrame (frameName) for index, value in pairs(CHARACTERFRAME_SUBFRAMES) do if ( value == frameName ) then getglobal(value):Show() else getglobal(value):Hide(); end end end
--- End code ---
CHARACTERFRAME_SUBFRAMES is defined right at the top, it's just a list of string names of the subframes:
--- Code: ---CHARACTERFRAME_SUBFRAMES = { "PaperDollFrame", "PetPaperDollFrame", "SkillFrame", "ReputationFrame", "TokenFrame" }; --- End code ---
I don't know what kind of collections you had in mind, but if you intend to ask the server for data you can use AIO to give the client a way to do it.
For example, in Blizzard_TokenUI.lua (which handles the logic for the currency tab of CharacterFrame):
--- Code: ---TokenFrameHonorFrameHonor:SetText(GetHonorCurrency()); TokenFrameHonorFrameArena:SetText(GetArenaCurrency()); --- End code ---
You can add functions similar to GetHonorCurrency and GetArenaCurrency to the client, but for whatever you're trying to ask the server about. You could make a GetCollection function to the client which gets called when your frames are done setting up which asks the server to get your character's collection info and sends it back. Then the client listens for a message back, and when it's received you can populate/update your menu. You'll need to set up a table for all characters' collection info in your CharDB and put it in memory using Eluna's CharDBQuery on server start, and save changes using CharDBExecute.
Eluna supports database queries. Look at the PingPong.lua example in AIO for back-and-forth communication.
Navigation
[0] Message Index
|