-
January 7th, 2022, 18:57 #1
- Join Date
- Jan 2020
- Posts
- 280
Party inventory control only rendering for host
Hello,
I am extending my search extension to add a search control to the party inventory ("ps_inventory"). I am merging my windowclass with that one, and it works well from the host side. The weird thing is that connected clients do not get the search input box, but they do see the empty text placeholder ("Search"). The code is straightforward:
Code:<?xml version="1.0" encoding="iso-8859-1"?> <root> <windowclass name="ps_inventory" merge="join"> <script file="scripts/inventory_search.lua"/> <sheetdata> <basicstring name="inv_search_input"> <anchored to="itemlist" position="aboveleft" offset="5,25" width="100"/> <empty> <textres>search</textres> </empty> <tabtarget next="inv_search_input" prev="itemlist"/> </basicstring> <buttoncontrol name="inv_search_clear_btn"> <anchored to="inv_search_input" position="right" offset="10,0" relation="relative" width="20"/> <icon normal="button_clear" pressed="button_clear_down"/> <invisible/> <tooltip textres="tooltip_clear"/> </buttoncontrol> </sheetdata> </windowclass> </root>
host.jpg
This is the client view:
client.jpg
-
January 7th, 2022, 19:07 #2
What is your scripts/inventory_search.lua <script> doing? This will be overriding the ps/scripts/ps_inv.lua script that is set for the base ps_inventory windowclass. You may need to add some super code to the inventory_search.lua code to call the ps_inv.lua code.
Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
January 7th, 2022, 19:11 #3
- Join Date
- Jan 2020
- Posts
- 280
Not very much, but it's not calling any super. You can see it here.
If I'm doing a merge, are you sure it's overriding? The same script is used for normal inventory search and it's not interrupting the char_inventory that's in that merge target.
-
January 7th, 2022, 19:17 #4
I can't access that.
Scripts don't fully merge, they form a layered hierarchy if the function names are the same - with the earlier defined script functions accessible through the super variable - see here: https://fantasygroundsunity.atlassia...pt-Block-ScopePrivate Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
January 7th, 2022, 19:22 #5
- Join Date
- Jan 2020
- Posts
- 280
-
January 7th, 2022, 19:27 #6
You should have this at the beginning of your onInit function:
Code:if super and super.onInit then super.onInit(); end
Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
January 7th, 2022, 20:48 #7
- Join Date
- Jan 2020
- Posts
- 280
After adding that snippet, and only that, it's actually worse The placeholder text shows up in the middle of the window now:
client2.jpg
-
January 7th, 2022, 21:46 #8
That's because the campaign setting Game (GM) - Party:Show inventory to client is set to Off. The code for that option is ran as part of the original onInit code - so now that you're running that code using super.onInit it's reading the campaign option and not showing the party coins or party items. You can see this code in onOptionChanged in the original ps_inv.lua. So you will have to code in your extension to take into account showing the search controls on the player side only if that campaign option is on.
Now we've got the correct init code running, let's see what the issue is with that search appearing correctly for the player...Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
January 7th, 2022, 22:45 #9
So, the issue is that the string template used (basicstring) is actually a stringfield control (database bound). As players can't change the database area where that control is bound, then it is shown as read only for the players.
To make it work, the control needs to be changed to a stringcontrol (no stringfield). Unfortunately there's no basicstring control (not field) template so the frame code from basicstring needs to be included in the XML and the base template needs to be changed to simplestringc.
So, try this:
Code:<simplestringc name="inv_search_input"> <anchored to="itemlist" position="aboveleft" offset="5,25" width="100"/> <empty> <textres>search</textres> </empty> <tabtarget next="inv_search_input" prev="itemlist"/> <frame mergerule="replace" name="fielddark" offset="7,5,7,5" hidereadonly="true" /> <stateframe> <keyedit name="fieldfocus" offset="7,5,7,5" /> <hover name="fieldfocus" offset="7,5,7,5" hidereadonly="true" /> <drophilight name="fieldfocus" offset="7,5,7,5" hidereadonly="true" /> </stateframe> </simplestringc>
Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
January 7th, 2022, 22:47 #10
Note - the earlier comments about the script layering is still very valid - without this the campaign option won't be applied; also if the extension is enabled for a new campaign the coin categories won't be set in the party sheet, as these are built in the base onInit function.
And you also need to code to hide that search field on the player side if the Party:Show inventory campaign option is set to off, as it makes no sense to show it if the players can't see the party inventory.Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks