View Single Post
04/02/15, 04:27 PM   #12
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
I glanced at the code, don't have much time have to leave for work soon...but will look at it later when I get home.
I only glanced at it and didn't have time to look for the thing you actually asked about....but I can say a couple of things I noticed so far:
I did not test any of this and didn't have much time to look at the code, so I might have overlooked something or made a type-o.

Lua Code:
  1. registerGuildBankSelectionTweaks
This entire function seems desgined to determine if there is more than one guild in the popup guild selector drop down box and if so to enable your addons selection tweaks. Correct?

Couldn't this replace that entire function?
Lua Code:
  1. GetNumGuilds()
The number of guilds that they are in, will be the number of guilds in that pop-up box right?

This might also make your life easier. I see a lot of manipulation with the combo box & other things to mess with getting/setting the selected guild. You don't need to do any of that, I believe this will allow you to eliminate a LOT of code...you can use:
Lua Code:
  1. GetSelectedGuildBankId()
  2. SelectGuildBank(guildId)

Again I only glanced at it, but I think those few things could take place of several functions it looks like. Here are a coupld of examples:
Lua Code:
  1. -- Instead of all of the code in: registerGuildBankSelectionTweaks
  2. -- Notice this code does so little it may (or may not i didn't look where its called from) not even be necessary:
  3. -- also note:
  4. -- I used < 2, because if there is only 1 guild to select from, theres no need to scroll or select anything
  5. -- The 1 & ONLY guild your in will already be selected and there is no other guild to select so there is
  6. -- no need for your code to be running
  7. -- I left out the doOverride, because I didn't see it get called anywhere with doOverride == true
  8. -- and I didn't have enough time to look at it further.
  9. local function registerGuildBankSelectionTweaks(doRegister)
  10.    if GetNumGuilds() < 2 then
  11.        FCOGuildBankQuickSelect_ChangeTweaks(false)
  12.    return false
  13.    end
  14.  
  15.    --Enable or disable the tweaks now
  16.    FCOGuildBankQuickSelect_ChangeTweaks(true)
  17. end

I see a lot of code dealing with the last index of the combo box. I'm guessing that allows the user to scroll from the last guild in the list to the first. You could probably get rid of that function entirely...and replace it with something like this:
Lua Code:
  1. -- I would just pass the scroll wheels delta directly to this function (or just get rid of it entirely).
  2. -- Note: For keypresses you can just call SelectGuildBank(guildId) inside of  FCOGuildBankQuickSelect_HandleKeyboardEvents
  3. --    Where the guildId's are the order they appear in, the same numbers your grabbing anyhow: 1, 2, 3, 4
  4. -- GetSelectedGuildBankId() gives us the currently selected guild bank id. They are numberd 1 to GetNumGuilds()
  5. -- GetSelectedGuildBankId-1 changes the table indices to start at 0 (to match the modulus results)
  6. -- The delta, can just be added to that selected guild id
  7. -- the % is the modulus symbol:   a % b, divides a by b and then gives us the remainder.
  8. -- It would handle scrolling from the end of the list to the beginning of the list, and vice-versa, for you.
  9. -- the +1 on the end switches it back to base 1, giving us a range from 1 to numGuilds
  10. local function FCOGuildBankQuickSelect_SelectGuildEntry(delta)
  11.     local numGuilds = GetNumGuilds()
  12.     local newIndex = (GetSelectedGuildBankId() - 1  + delta) % numGuilds + 1
  13.  
  14.     SelectGuildBank(newIndex)
  15. end

Last edited by circonian : 04/02/15 at 04:31 PM.
  Reply With Quote