Thread Tools Display Modes
08/10/14, 01:19 PM   #1
Maverick827
Join Date: Aug 2014
Posts: 6
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.
  Reply With Quote
08/11/14, 08:29 AM   #2
zgrssd
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 280
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

Last edited by zgrssd : 08/11/14 at 08:33 AM.
  Reply With Quote
08/11/14, 09:10 AM   #3
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Originally Posted by Maverick827 View Post
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)
  Reply With Quote
08/11/14, 12:39 PM   #4
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
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)

Last edited by Garkin : 08/11/14 at 06:01 PM. Reason: missing bracket
  Reply With Quote
08/11/14, 05:26 PM   #5
Maverick827
Join Date: Aug 2014
Posts: 6
Originally Posted by Garkin View Post
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.
  Reply With Quote
08/12/14, 12:13 AM   #6
Tonyleila
 
Tonyleila's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 288
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?
  Reply With Quote
08/12/14, 05:13 AM   #7
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,578
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.
  Reply With Quote
08/12/14, 08:59 AM   #8
Tonyleila
 
Tonyleila's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 288
Originally Posted by sirinsidiator View Post
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...
  Reply With Quote
08/12/14, 10:48 AM   #9
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,578
Here it is: AwesomeGuildStore
I do have plans to add more advanced stuff, but I don't plan to turn it into something unmanageable...
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Save Guild Store Filter


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