View Single Post
02-15-13, 01:58 AM   #26
gmarco
An Onyxian Warder
 
gmarco's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 362
Thanks Phanx and Seerah for answers.

I have checked the Phanx code and it works nicely (the 2nd bigger one) but I think I'll leave the button as they are now, because it doesn't work with all buttons templates or with no template at all.
Btw finally I understood how it works. As usual it was a little bit more complicated then I thought :-)

Ok. In the meantime I have solved also the question nr.3 I asked:

3) Is possible to have the scrollframe "bordered" like the input box below ?
I checked the rtest by Zork (thanks) and I have discovered the Templates world :-)

Now I am investigating why the scrollframe works nicely in the test addon I make following the Lombra suggestion/code posted at the beginning of this thread, while it have the problem I have pointed out with the picture when I build the scrollist array from my data.

If I used something like:

Lua Code:
  1. RemGankLS = { "qui", "quo", "qua", etc etc }

It works as expected and I don't have the iussue shown in the picture.

But I have a table in this way saved:

Lua Code:
  1. RemGankDB = {
  2.     ["qui"] = {
  3.         ["name"] = "qui",
  4.         ["date"] = "06.01.2013 19:28:24",
  5.         ["desc"] = "generic ganker",
  6.         ["lastloc"] = "Massiccio del Kun-Lai/Presidio del Fuoco Yongqi",
  7.         ["nrkill"] = 1,
  8.     },
  9.     ["quo"] = {
  10.         ["name"] = "quo",
  11.         ["date"] = "03.02.2013 17:35:10",
  12.         ["desc"] = "generic ganker",
  13.         ["lastloc"] = "Vallata dell'Eterna Primavera/Volta di Guo-Lai",
  14.         ["nrkill"] = 1,
  15.     },
  16.     ["qua"] = {
  17.         ["name"] = "qua",
  18.         ["date"] = "09.02.2013 10:57:16",
  19.         ["desc"] = "generic ganker",
  20.         ["lastloc"] = "Valle dei Quattro Venti/Mezzocolle",
  21.         ["nrkill"] = 1,
  22.     },
  23.        
  24.       --- etc etc
  25. }

So to use a number reference to the records for the scrollframe I was not able to find a better solution of doing something like this:

Lua Code:
  1. function RemGank_DB_Dump()
  2.     RemGankLS = {}
  3.     for name in pairs(RemGankDB) do    
  4.         name = name:lower()
  5.         if RemGankDB[name]["name"] then
  6.             table.insert(RemGankLS, RemGankDB[name]["name"])
  7.         end
  8.     end
  9.     -- Sort the list alphabetically
  10.     table.sort(RemGankLS)  
  11. end

And everything works but the slider have the problem I show.

Someone have an idea on why it happens or if the problem is the dumping how to call this code :

Lua Code:
  1. function RemGank_ListFrame_Update(self)
  2.     local numItems = #RemGankLS
  3.     FauxScrollFrame_Update(self, numItems, NUM_BUTTONS, BUTTON_HEIGHT)
  4.     local offset = FauxScrollFrame_GetOffset(self)
  5.     for line = 1, NUM_BUTTONS do
  6.         local lineplusoffset = line + offset
  7.         local button = buttons[line]
  8.         if lineplusoffset <= numItems then
  9.             button:SetText(RemGankLS[lineplusoffset])
  10.             button:Show()
  11.         else
  12.             button:Hide()
  13.         end
  14.     end
  15. end
  16.  
  17. -- [...]
  18.  
  19. for i = 1, NUM_BUTTONS do
  20.     local button = CreateFrame("Button", nil, scrollFrame:GetParent(), "UIPanelButtonTemplate")
  21.     if i == 1 then
  22.         button:SetPoint("TOP", scrollFrame)
  23.     else
  24.         button:SetPoint("TOP", buttons[i - 1], "BOTTOM")
  25.     end
  26.     button:SetNormalFontObject("GameFontNormal")
  27.     button:SetSize(BUTTON_WIDTH, BUTTON_HEIGHT)
  28.     button:SetText(RemGankLS[i])
  29.     button:SetScript("OnClick", function(self)
  30.         RemGank_Input_eb2:SetText(button:GetText())
  31.         info_name:SetText(button:GetText())
  32.         info_desc:SetText(RemGankDB[button:GetText()]["desc"])
  33.         info_loc_title:SetText("Last Kill:")
  34.         info_date:SetText(RemGankDB[button:GetText()]["date"])
  35.         info_loc:SetText(RemGankDB[button:GetText()]["lastloc"])
  36.         info_kills_title:SetText("Tot.Kills:")
  37.         info_kills:SetText(RemGankDB[button:GetText()]["nrkill"])
  38.     end)
  39.     buttons[i] = button
  40. end

without the need of dumping the first table RemGankDB (referenced by name) to RemGankLS (indexed by numbers) ?

Thanks for patience and sorry again about all these questions.
__________________
This is Unix-Land. In quiet nights, you can hear the Windows machines reboot.

Last edited by gmarco : 02-15-13 at 02:10 AM.
  Reply With Quote