05-13-12, 03:55 PM | #1 |
Scroll Frame help
So this is (as I understand it) spost to make two frames, the first (rosterList) is a viewport into the second (rosterData) now I had no idea what type of frame to use for the data so for now its just a frame (which is probably half my issue)
Code:
-- Where to Hold the roster list local rosterList = CreateFrame("ScrollFrame", nil, rosterFrame, "FauxScrollFrameTemplate"); local rosterData = CreateFrame("Frame", nil, rosterList); rosterList:SetPoint("TOPLEFT", lvlButton, "BOTTOMLEFT", 5, -5) rosterList:SetWidth(rosterFrame:GetWidth()-12) rosterList:SetHeight(rosterFrame:GetHeight()-30) rosterList:SetScrollChild(rosterData) rosterData:SetWidth(rosterList:GetWidth()-25) rosterData:SetHeight(rosterList:GetHeight()*4) rosterList:SetScript('OnVerticalScroll', function() FauxScrollFrame_OnVerticalScroll(self, offset, 3, rosterList.UpdatePositionScrollFrame) end) rosterFrame.rosterList = rosterList; V |
|
05-14-12, 12:09 PM | #2 |
update
Ok so I've been working hard on getting the roster functioning even if its not perfect.
The problem I'm having (which is very visable in the screenshot) is that the template doesn't seem to hold with more then 3 players, (note that the grey people are off line) none of the names are longer the 20 characters so I'm not sure why %-20s isn't giving a solid block of twenty characters for every name ... Any hints on this would be awsome. (I also included all the code dealing with the roster if I missed anything please let me know) Thanks in advance, V Code:
GUILDROSTER_ROSTERTEMPLATE = "%3d %-20s %8s %-8s %-15s %4s/%-4s\n" -- Update the Roster function GRUpdateRoster () GuildRoster(); local totalMembers, numMembers = GetNumGuildMembers(); local roster = ""; roster = roster..format("%-3s %-25s %6s %-10s %-15s %4s %-4s\n", "Lvl", "Name", "Weekly", "Total", "Rank", "", ""); -- If we're showing offline members make sure we show them all if GetGuildRosterShowOffline() then numMembers = totalMembers; end for i=1, numMembers, 1 do local name, rank, _, level, class, zone, note, onote, online, isAway, _, _, _, _ = GetGuildRosterInfo(i) local classcolor = "|cFF0000FF"; local nocolor = "|r"; local weeklyXP, totalXP, weeklyRank, totalRank = GetGuildRosterContribution(i) -- If online set class color, else use light grey offline color if online then if class == MAGE then classcolor="|cFF69CCF0"; elseif class == DRUID then classcolor="|cFFFF7D0A"; elseif class == PRIEST then classcolor="|cFFFFFFFF"; elseif class == WARLOCK then classcolor="|cFF9482C9"; elseif class == WARRIOR then classcolor="|cFFFF7D0A"; elseif class == PALADIN then classcolor="|cFFF58CBA"; elseif class == ROGUE then classcolor="|cFFFFF569"; elseif class == DEATHKNIGHT then classcolor="|cFFC41F3B"; elseif class == SHAMAN then classcolor="|cFF0070DE"; elseif class == HUNTER then classcolor="|cFFABD473"; elseif class == MONK then classcolor="|cFF558A84"; end else classcolor="|cFFC7C7C7"; end prof1 = "Unkn"; prof2 = "Unkn"; roster = roster..classcolor..format(GUILDROSTER_ROSTERTEMPLATE, level, name, short(weeklyXP), short(totalXP), rank, prof1, prof2)..nocolor; end GRFrame.rosterFrame.rosterDataList:SetText(roster) end function short(value) if value >= 10000000 then return format("%4.1fm", value / 1000000) elseif value >= 1000000 then return format("%4.2fm", value / 1000000) elseif value >= 100000 then return format("%4.0fk", value / 1000) elseif value >= 10000 then return format("%4.1fk", value / 1000) else return format("%4.2fk", value / 1000) end end -- Where to Hold the roster list local rosterList = CreateFrame("ScrollFrame", nil, rosterFrame, "FauxScrollFrameTemplate"); local rosterData = CreateFrame("Frame", nil, rosterList); rosterList:SetPoint("TOP", 5, 0) rosterList:SetWidth(rosterFrame:GetWidth()-65) rosterList:SetHeight(rosterFrame:GetHeight()) rosterList:SetScrollChild(rosterData) rosterData:SetWidth(rosterList:GetWidth()-5) rosterData:SetHeight(rosterList:GetHeight()*4) rosterList:SetScript('OnVerticalScroll', function(self, event) FauxScrollFrame_OnVerticalScroll(self, offset, 3, rosterList.UpdatePositionScrollFrame); print("Scroll?"); end) rosterFrame.rosterList = rosterList; rosterData:CreateFontString("rosterDataList", "ARTWORK", "GameFontNormal") rosterDataList:SetPoint("TOP", 0, 0) rosterDataList:SetHeight(rosterData:GetHeight()) rosterDataList:SetWidth(rosterData:GetWidth()) rosterDataList:SetJustifyH("LEFT") rosterDataList:SetJustifyV("TOP") rosterDataList:SetFont("Fonts\\ARIALN.TTF", 11, "") rosterFrame.rosterDataList = rosterDataList; |
|
05-14-12, 12:43 PM | #3 |
This is not answer for your specific problem but maybe it will help you finish your addon.
Try using this library: http://www.wowace.com/addons/lib-st/ |
|
05-14-12, 01:00 PM | #4 | |
I'm fairly new to the addon world so if I missed something basic please fill me in. V |
||
05-14-12, 01:17 PM | #5 | |
|
||
05-17-12, 03:50 PM | #6 |
Updated question
ok so I've been looking into my problem and have come to 2 potential solutions:
1. destroy the code for the scroll frame, code a scroll bar and buttons to handle all the guild member data. using button's id's and the scroll bar to "move" up and down the list (rewriting the buttons text and id every time you move the vertical scroll up or down) 2. Figure out how to include Acidweb's suggestion on adding an ace lib into my addon (which is the only part I haven't figured out) and convert guild member data to a table/array letting the library do most of the work. So my questions are: in scenario 1 is that going to eat the heck out of the memory swapping all that info every time you scroll the guild frame? I am concerned that both solutions are going to make the addon more difficult to write however I want to make sure I'm not going to cause a massive memory overflow issue and effect game play. Any thoughts? |
|
05-17-12, 05:03 PM | #7 | |
On the Ace 3 homepage, click on the "Pages" tab, and then you might want to have a look at, among other things, the "AceGui-3.0 Tutorial" and "AceGUI-3.0 Widgets" pages. It might help you in your quest to make a scrolling frame. While I haven't been able to really understand the Lua programing language (or any other type of language, programing or spoken, for that matter) I remember seeing those tutorials when I was looking into writing an actual addon, which I never did get around to writing, instead of doing really, really, simple graphical plug-ins for real addons. So, I hope this will help you in some small way.
__________________
Ahhhh, the vagueries of the aging mind. Wait.... What was I saying? Carbonite <----- GitHub main module (Maps ONLY) download link. The other modules are also available on GitHub. Carbonite-CLASSIC<----- GitHub link to Carbonite Classic. Thanks to ircdirk for this! |
||
05-17-12, 05:13 PM | #8 | |
Since this is not actually creating new objects, it will actually use less memory (eg. only 10 buttons are visible at once, so you only create 10 button objects, instead of creating 100 button objects but having 90 of them being hidden). I'm not sure about the difference in CPU usage between calling, eg. :SetText() on each of 10 buttons, and moving and/or showing hiding each of 100 buttons, but it can't be significant either way. This method also has the advantage of having many more examples to work from, especially in the default UI. It's not an "Ace library". It's just a library. Back in 2006, yes, there were a lot of "Ace librarires" that required the Ace2 framework. Today, there is not even an Ace framework. There is an Ace3 "family", but each library (eg. AceAddon-3.0, AceDB-3.0, AceEvent-3.0) is separate. Each can be used with or without any others, have no dependencies on each other, and have little to no interaction between each other. Aside from a few specific libraries whose purpose is to extend one of the Ace3 libraries (such as AceGUI-SharedMediaWidgets, which adds SharedMedia-specific dropdown configuration widgets to AceGUI), there are no "Ace libraries", in the sense of being libraries that depend on some/all Ace libraries. Modern WoW libraries are framework-agnostic; they neither know nor care which other libraries you're using. Most of them are built on LibStub, which is a very tiny, very generic stub for embedded library versioning (eg. handling cases where Addon A ships with Lib X v2.4, Addon B ships with Lib X v2.1, and Addon C ships with Lib X v2.7). Anyway, if you need help using a library, your best bets are, in this order, to (a) read the documentation, or (b) read the code in addons that use the library, or (c) ask specific questions about things you don't understand or are having trouble with. |
||
05-24-12, 11:52 AM | #9 |
I didn't know it wasn't an ace lib, however it seems (from the documentation) to require Ace3, that being said I spent all weekend exploring and testing it, to no avail so I'm going to go with the faux scroll frame (thanks for telling me that the default ui uses my thought already will keep me from reinventing the wheel.... I hope)
I look forward to having a beta-ish version of my addon to upload for people to help bug test or what not, thanks everyone for the support and help! V |
|
WoWInterface » Developer Discussions » Lua/XML Help » Scroll Frame help |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|