• 0

    posted a message on Better way than localized text to detect item class/subclass
    Quote from Farmbuyer
    Yeah, I had some misgivings about recommending this route when I pasted that code.



    This is the kind of thing that I personally prefer. The code is essentially self-correcting in the face of changes. For example, if Blizzard announces to make the game more accessible to the Facebook image-meme generation, the labels "food and drink" will all be replaced by "noms" then your code won't need any changes. You'll still be getting a known-to-be-good string extracted from your base item, and comparing against that string in the wild. Same if Blizzard releases a game client localized for a new language.

    The only hitch is that GetItemInfo will return nils for items which aren't in the client's local cache. Basically, as long as your base food has been seen by any of the player's toons previously in this game session, or is in the bags/bank of the first toon to log in, then the item will be in the cache.

    The chances of that happening may be slim, so you might have to have a list of several "known to be food" item IDs, and GetItemInfo on all of them. This certainly isn't the only way to handle this situation, it's just a starting point for thinking.

    Another thing you might do is, once you've extracted the string to use for comparisons, store it in your SavedVariables along with the current client locale. For future logins, you continue doing the scan-and-extract thing (because the strings might have changed for some locale), but even if GetItemInfo returns nil for everything, you can still fall back on a previously extracted string as "this is better than nothing".


    Hm, that's really unfortunate. That could work too, but what about if I use the functions such as :

    GetAuctionItemSubClasses() -- http://wowprogramming.com/docs/api/GetAuctionItemSubClasses
    


    To get and store the proper current localized strings table, and then keep a premade set of variables with the indexes for the types, so for instance:

    function CoreLoot:OnInitialize()
        CoreLoot.ItemSubtypes = GetAuctionItemSubClasses(4) -- assuming 4 is consumable
    end
    


    Then to check:
    if subclass == CoreLoot.ItemSubtypes[CoreLoot.ItemSubtypeIds.FoodAndDrink] ...
    


    It's a bit verbose, and I'm not sure how much that subclass/class table will change, but if they don't then that could be fairly reliable (unless they too are based on having seen something this session)
    Posted in: Lua Code Discussion
  • 0

    posted a message on Better way than localized text to detect item class/subclass
    Quote from Elkano
    if the global string is obviously used for something else, e.g. minimap tracking as in this case, and not for the situation you're looking for, I wouldn't count on the translation matching in all languages though...


    Ah, is there an alternative to that then, which would?

    Edit: Honestly it seems kind of odd to me that there wouldn't be a way to do this without using strings at all. Via getting a class/subclass number ID, and then comparing it with the items, eg:

    local classId, subclassId = GetItemClassInfo(itemId)
    if subclassId == ITEM_SUBCLASSID_FOOD then ...


    Edit 2:

    I suppose if I really needed to, I could go get the ID of an item that matches the class I want, then use that as a base with GetItemInfo() to compare against the class/subclass localized strings... Storing those initial "base" strings at the start of the addon for use later.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Better way than localized text to detect item class/subclass
    Ah, I hadn't thought to look in the default UI. Derp.

    Thank you! That helps a lot.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Better way than localized text to detect item class/subclass
    So, I'm making an inventory filtering addon, and one of the things it does is detects food below a certain level to trash or sell it. The problem I'm having is, API functions like

    GetItemInfo()
    GetAuctionItemClass()
    GetAuctionItemSubClass()
    


    All return localized strings. Currently I'm using what's returned by GetItemInfo() like this:

    if subclass == "Food & Drink" and CoreLoot.db.EnableTrashFood then
    


    Because I can't seem to find a way to get some sort of global identifier for a subclass instead of a localized string, and I really don't like doing it like this.

    Is there an alternative I've been missing somewhere, or?

    Thanks!
    Posted in: Lua Code Discussion
  • 0

    posted a message on Problem with Ace 3 heading and invisible elements.
    Quote from Seerah
    You mean this one? http://www.wowace.com/addons/ace3/pages/ace-config-3-0-options-tables/#w-multiselect

    (/edit: granted I haven't used multiselect in any addons of mine, so I don't recall if it presents itself as a dropdown without looking at the code...)


    I had looked at this one, but it doesn't do the same thing I'm after. That one is multiple checkboxes, I think it puts a border around them too, to separate them. What I'm after is a dropdown list that you can also multi-select in, kind of like the default AceGUI Dropdown widget with Multiselect set to true. The reason for this is that the addon will have a lot of things in this list.

    Thanks though!
    Posted in: AddOn HELP!
  • 0

    posted a message on At a loss on multi-select dropdowns.
    Should be noted I got this fixed.

    The actual signature for all callbacks is apparently: func(widget, event, ... callback specific args ...)
    Posted in: Need Help?
  • 0

    posted a message on Need some help with dropdown multiselect.
    Well, that makes a LOT more sense. I thought the callback documentation was simply being used on something that passed a widget as the first argument lol.

    Thanks for that info, that clears up a lot. I was totally confused. I actually will need that first parameter, because I'm going to have a reusable function for that callback ultimately (there's three different lists that will all have similar logic except for a table name), so actually pretty much what you described it being used as.
    Posted in: AddOn HELP!
  • 0

    posted a message on Problem with Ace 3 heading and invisible elements.
    Alright so I set the layout on MFrame to fill and that didn't do it, but that did make everything after the heading stop becoming invisible too. Then I figured I'd try setting SetFullWidth(true) on the heading and now the heading shows up.

    Thanks!
    Posted in: AddOn HELP!
  • 0

    posted a message on Problem with Ace 3 heading and invisible elements.
    Quote from Nevcairiel
    In your paste, MFrame for example doesn't. Judging from the code, you probably want a Fill layout on that one.

    All your InlineGroups also don't.


    Oh, my bad. I actually set all the layouts on the inline groups not too long after making the post, as it defaults to list when I wanted flow anyway. That's why I thought they were.

    As for MFrame I'll have to try setting that as well in a bit. I forgot about that one.
    Posted in: AddOn HELP!
  • 0

    posted a message on At a loss on multi-select dropdowns.
    Basically, I'm making an inventory management addon, and one of the things it will do is have a blacklist and autosell list. They will be managed via multiselect dropdown, where selecting the item means it will be counted in the filter, and deselecting it means it will be ignored (Intended to be a sort of temporarily removing it from the list, but one that will get it's state saved to the DB)

    I'm finding it a bit tricky to do this - the logic in my head makes sense, but the API doesn't seem to support this very easily (that I can tell.) Example of the code: http://pastebin.com/34TJe8c3

    This has really unexpected results, as it looks like it's printing something out of a hashtable or a memory address for the key parameter, and checked prints "OnValueChanged".

    So my first question: How might I go about getting an OnChecked sort of event, with the key that had the state-change (checked/unchecked), so I can handle that?

    Second question: Given that the table doesn't seem to contain a checked-state anywhere (It's just a KeyValuePair table where the value is what is printed), I don't see how the state could be saved.

    Thanks for any help/advice, and apologies for all the questions today :)
    Posted in: Need Help?
  • 0

    posted a message on Problem with Ace 3 heading and invisible elements.
    Quote from Nevcairiel
    Everytime your create a container, you should probably call SetLayout on it. The most common choice that mimicks AceConfig behavior would be "Flow". Other options would be "List" which just stacks widgets on top of each other, or "Fill", which is a special layout where one child fills the entire container (usually a container inside a container, ie. a scrollframe inside a frame)



    All the container elements actually have SetLayout called on it I believe.
    Posted in: AddOn HELP!
  • 0

    posted a message on Need some help with dropdown multiselect.
    Basically, I'm making an inventory management addon, and one of the things it will do is have a blacklist and autosell list. They will be managed via multiselect dropdown, where selecting the item means it will be counted in the filter, and deselecting it means it will be ignored (Intended to be a sort of temporarily removing it from the list, but one that will get it's state saved to the DB)

    I'm finding it a bit tricky to do this - the logic in my head makes sense, but the API doesn't seem to support this very easily (that I can tell.) Example of the code: http://pastebin.com/34TJe8c3

    This has really unexpected results, as it looks like it's printing something out of a hashtable or a memory address for the key parameter, and checked prints "OnValueChanged".

    So my first question: How might I go about getting an OnChecked sort of event, with the key that had the state-change (checked/unchecked), so I can handle that?

    Second question: Given that the table doesn't seem to contain a checked-state anywhere (It's just a KeyValuePair table where the value is what is printed), I don't see how the state could be saved.

    Thanks for any help/advice, and apologies for all the questions today :)

    edit: As I had said in another thread, I somehow got this concept working with AceConfig in a version of this addon I made in the past and lost, but I can't for the life of me remember how I got this working. I know I didn't make a custom widget or anything like that. I do remember I had two lists for each "list", one with all the items in it, and one with all the items that were excluded (unchecked)
    Posted in: AddOn HELP!
  • 0

    posted a message on Problem with Ace 3 heading and invisible elements.
    Honestly the AceConfig looks like it will be more tedious to manage than just doing it in AceGUI. So far I prefer this, but the main factor is the fact that AceConfig doesn't have a dropdown multiselect box.

    I'm remaking an inventory managing addon I made before but lost due to drive failure. It had a multiselect dropdown box in it where you could check items to disable from a list temporarily (Like temporarily disabling a blacklisted item, so you can keep them). I can't for the life of me remember how I got that to work with AceConfig, but somehow I did.

    edit: That being said, I am having some weirdness with the Dropdown that's making me wonder if it wouldn't be easier to figure out how I got AceConfig to work, lol. Though I'm almost done with this, layout wise, and it was fairly easy to get working.
    Posted in: AddOn HELP!
  • 0

    posted a message on Problem with Ace 3 heading and invisible elements.
    Even clearing out everything except for the main Frame element (MFrame), and just adding a heading as a child to that and nothing else, the heading is still invisible.

    Really odd, any idea what layout options I might need to put on anything?
    Posted in: AddOn HELP!
  • 0

    posted a message on Problem with Ace 3 heading and invisible elements.
    I'm creating a GUI for my addon, I've posted the code here: http://pastebin.com/aQB4svjV


    You'll notice on line 79 I generate a GUI heading which should have the title "Autosell List". Whenever I use this, the elements after don't show up, but they take up space (The inline group they are contained in are as tall as if the elements were there, but they are just invisible.) The heading itself also does not show up.

    It does this regardless of using the GetGuiHeading utility function I made, or manually doing it with GUI:Create().

    Thanks, hopefully this is something pretty simple that I'm missing lol.
    Posted in: AddOn HELP!
  • To post a comment, please or register a new account.