ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   Save Guild Store Filter (https://www.esoui.com/forums/showthread.php?t=2093)

Maverick827 08/10/14 01:19 PM

Save Guild Store Filter
 
I'm looking into making a small addon that saves your search filter between guild store kiosks if possible (unless something already does this, please let me know).

Ideally all that it would need to do would be to save the filter values when you close a guild store and then load them when you open a guild store.

Looking at the list of functions, I see that SetTradingHouseFilter and SetTradingHouseFilterRange might be what I need to set the values, but I see no Getter for the current filters. Did they just not provide a Getter? Why would they leave this out? If it doesn't exist, can I accomplish getting the values another way?

It wouldn't be as great of a UX, but if I can't get the values, I could always provide a GUI for the user to save sets of filters and load them. But that brings me to the next point...

I can't even seem to get either of the setters to work. I have an event set up that calls those methods on the EVENT_OPEN_TRADING_HOUSE, but the GUI does not register the values in the drop downs/text boxes/etc.

Is it "too late" to try to set them on that event, e.g. the window is already opened so I can't change the component values? If so, when can I set them? I'm not getting any errors, there's just no result to the method call.

Code:

TestAddon= {}

TestAddon.name = "TestAddon"
       
function TestAddon:Initialize()
  EVENT_MANAGER:RegisterForEvent(self.name, EVENT_OPEN_TRADING_HOUSE, self.TradingHouseOpened)
end

function TestAddon.TradingHouseOpened(eventCode)
        d("Opened")
        SetTradingHouseFilterRange(TRADING_HOUSE_FILTER_TYPE_LEVEL, 11, 12)
        d("Filter set")
end

function TestAddon.OnAddOnLoaded(event, addonName)
        if addonName == TestAddon.name then
                TestAddon:Initialize()
        end
end

EVENT_MANAGER:RegisterForEvent(TestAddon.name, EVENT_ADD_ON_LOADED, TestAddon.OnAddOnLoaded)

"Opened" and "Filter set" both print out, no errors are generated.

zgrssd 08/11/14 08:29 AM

Asuming you cannot get the current filters (wich seems likely), there is an alternative:
Make extra UI elements (a small window plus Elements mirroring the search Filter). At any time the user can choose to apply those settings to the search store filters.

This would also allow you to save different "sets" of parameters and persist them in saved variables between sessions.
Just getting all those traits (and thier localised names) could be tricky. I look if libCosntantMapper could get you the data you need for the filters.

Edit:
Seems to be one straightfoward enumeration at least for the types of filter to be used:
TRADING_HOUSE_FILTER_TYPE_ARMOR = 3
TRADING_HOUSE_FILTER_TYPE_ENCHANTMENT = 9
TRADING_HOUSE_FILTER_TYPE_EQUIP = 0
TRADING_HOUSE_FILTER_TYPE_ITEM = 1
TRADING_HOUSE_FILTER_TYPE_LEVEL = 6
TRADING_HOUSE_FILTER_TYPE_PRICE = 7
TRADING_HOUSE_FILTER_TYPE_QUALITY = 5
TRADING_HOUSE_FILTER_TYPE_TRAIT = 4
TRADING_HOUSE_FILTER_TYPE_VETERAN_LEVEL = 8
TRADING_HOUSE_FILTER_TYPE_WEAPON = 2

merlight 08/11/14 09:10 AM

Quote:

Originally Posted by Maverick827 (Post 11346)
Looking at the list of functions, I see that SetTradingHouseFilter and SetTradingHouseFilterRange might be what I need to set the values, but I see no Getter for the current filters.

I don't think so. Those functions are used to apply values selected in UI controls to some internal filtering object, immediately before a call to ExecuteTradingHouseSearch. What you need to do is remember the state of UI controls, and restore that state when the window is re-opened.

Lua Code:
  1. TRADING_HOUSE_SCENE:RegisterCallback("StateChange",  SceneStateChange)

Their SceneStateChange resets all controls on SCENE_HIDDEN, so you'd probably need to save their state on SCENE_HIDING, and restore on SCENE_SHOWING.

Here are the controls that get reset. I'd start with price, level and quality, and if it works, dig into categories.

Lua Code:
  1. -- self is TRADING_HOUSE
  2.     self.m_minPriceEdit:SetText("")
  3.     self.m_maxPriceEdit:SetText("")
  4.     self.m_minLevelEdit:SetText("")
  5.     self.m_maxLevelEdit:SetText("")
  6.     self.m_qualityCombo:SelectFirstItem()
  7.     self.m_categoryCombo:SelectFirstItem()
  8.     self.m_categoryCombo:EnumerateEntries(ResetSearchFilter)

Garkin 08/11/14 12:39 PM

Just an untested idea - when you close trading house window, all filters gets reset using the TRADING_HOUSE:ResetAllSearchData() function.
As you want to keep old filters, what about hooking this function that it will not reset filters?
Something like:
Lua Code:
  1. ZO_PreHook(TRADING_HOUSE, "ResetAllSearchData", function(self)
  2.    self:ClearSearchResults() --you don't want to keep old search results, so clear them
  3.    return true --true means that origianl function won't be called
  4. end)

Maverick827 08/11/14 05:26 PM

Quote:

Originally Posted by Garkin (Post 11372)
Just an untested idea - when you close trading house window, all filters gets reset using the TRADING_HOUSE:ResetAllSearchData() function.
As you want to keep old filters, what about hooking this function that it will not reset filters?
Something like:
Lua Code:
  1. ZO_PreHook(TRADING_HOUSE, "ResetAllSearchData", function(self)
  2.    self:ClearSearchResults() --you don't want to keep old search results, so clear them
  3.    return true --true means that origianl function won't be called
  4. end

This worked great.

Thanks to everyone for the help.

Tonyleila 08/12/14 12:13 AM

So is this going to be a downloadable addon? Woud love it!
If not can anyone post the final code now so I can use it too?

sirinsidiator 08/12/14 05:13 AM

I started making an addon that will provide exactly that functionality and much more as I use the guild store a lot more often since 1.3 and am very disappointed with the default interface.
I'll see if I can upload something today.

Tonyleila 08/12/14 08:59 AM

Quote:

Originally Posted by sirinsidiator (Post 11396)
I started making an addon that will provide exactly that functionality and much more as I use the guild store a lot more often since 1.3 and am very disappointed with the default interface.
I'll see if I can upload something today.

Woud be awsome if you upload it. But please don't make a Guild Store Search Extended 2 out of it - my experience tells me that too much functionality into one addon ends up in a a short supported not working addon :/ Also It seams like that too many big addons overall give problems to the game...

sirinsidiator 08/12/14 10:48 AM

Here it is: AwesomeGuildStore
I do have plans to add more advanced stuff, but I don't plan to turn it into something unmanageable...


All times are GMT -6. The time now is 09:00 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI