Thread Tools Display Modes
05-13-12, 03:55 PM   #1
venoabyss
A Deviate Faerie Dragon
Join Date: Apr 2011
Posts: 13
Question 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;
so at this point rosterList displays its scroll bar but as far as I can tell does nothing else, now for each entry in rosterdata I will need to make a fontobject I guess that will display the formated text, or do I only need one font object I'm seriously lost in how to make this scroll frame and rosterdata frame, any information or a point in the right direction would help. I really was this to work for guilds of 47 or 4,700 but this is basicly the last hurtle (by tonight the news, perks and info should be finished) and I hope everyone will help bug test the heck out of it.

V
  Reply With Quote
05-14-12, 12:09 PM   #2
venoabyss
A Deviate Faerie Dragon
Join Date: Apr 2011
Posts: 13
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;
Attached Thumbnails
Click image for larger version

Name:	guildroster.jpg
Views:	791
Size:	108.8 KB
ID:	6932  
  Reply With Quote
05-14-12, 12:43 PM   #3
AcidWeb
A Theradrim Guardian
 
AcidWeb's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 69
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/
  Reply With Quote
05-14-12, 01:00 PM   #4
venoabyss
A Deviate Faerie Dragon
Join Date: Apr 2011
Posts: 13
Originally Posted by AcidWeb View Post
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/
Ok am looking at this and it looks wonderful, what I don't see is documentation on how to use it and/or include it with my addon...

I'm fairly new to the addon world so if I missed something basic please fill me in.

V
  Reply With Quote
05-14-12, 01:17 PM   #5
AcidWeb
A Theradrim Guardian
 
AcidWeb's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 69
Originally Posted by venoabyss View Post
Ok am looking at this and it looks wonderful, what I don't see is documentation on how to use it and/or include it with my addon...

I'm fairly new to the addon world so if I missed something basic please fill me in.

V
http://www.wowace.com/addons/lib-st/...rolling-table/
  Reply With Quote
05-17-12, 03:50 PM   #6
venoabyss
A Deviate Faerie Dragon
Join Date: Apr 2011
Posts: 13
Question 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?
  Reply With Quote
05-17-12, 05:03 PM   #7
jeffy162
A Pyroguard Emberseer
 
jeffy162's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 2,364
Originally Posted by venoabyss View Post
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)
Except that lib-ScrollingTable is not an actual "ace lib". While it is hosted on WoWAce, that alone does not make it an "ace lib". See Here for the "official" Ace 3 libraries.

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!
  Reply With Quote
05-17-12, 05:13 PM   #8
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by venoabyss View Post
... 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) ... is that going to eat the heck out of the memory swapping all that info every time you scroll the guild frame?
No. This is the same method that many frames in the default UI use, including the friends frame, ignore frame, and guild roster frame. There are a set number of buttons. When the scroll bar is moved, the text, icons, and/or properties on each button are changed. This is called a "faux scroll frame" and the default UI provides a number of templates related to it.

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.

Originally Posted by venoabyss View Post
... adding an ace lib into my addon
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.
  Reply With Quote
05-24-12, 11:52 AM   #9
venoabyss
A Deviate Faerie Dragon
Join Date: Apr 2011
Posts: 13
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
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Scroll Frame help


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