PDA

View Full Version : is it possible to change sortby to descending?



mozmonar
August 22nd, 2019, 03:53
I'm doing a very half-assed job of trying to modify goldendase's Fall of Delta Green extension into something I can use for Mutant City Blues 2E. One of the issues is that the addition of Mutant abilities, some general and some investigative adds a bunch a more skills that you don't necessarily want to scroll through. One thing I am try to do is break out the mutations to another tab which I have sort of halfway done. The other is to try to sort the list of abilities by rating (points invested) rather than label (name).

This line seems to sort the abilities as they display.

<sortby><control>rating</control></sortby>

However it sorts it Ascending meaning that abilities with ratings in them sort to the bottom of the list not the top as I would like. Is there a way to change it to descending?

Trenloe
August 22nd, 2019, 04:00
Have a look at the definition of sortyby in the windowlist control API: https://www.fantasygrounds.com/refdoc/windowlist.xcp You'll see that you can add a "desc" parameter.

mozmonar
August 22nd, 2019, 04:05
At the risk of sounding dense, in the case of the given parameters <sortby desc="..." case="..." > would that be "<sortby desc="1" or "True"?

Trenloe
August 22nd, 2019, 04:07
Search in most of the FG rulesets for desc="true" for examples.

mozmonar
August 22nd, 2019, 04:24
I only found one example in searching and it was to do with rolled dice results.

<sortby>
<control desc="true">rolled</control>
<control>total</control>
</sortby>

I tried various iterations of...
<sortby>
<control desc="true">rating</control>
<control>rating</control>
</sortby>

But still sorts ascending. I can't make heads or tails of it. Time to walk away for awhile.

Trenloe
August 22nd, 2019, 04:43
That example is using two controls - rolled and total. rolled is descending, then total would be ascending.

The XML you've posted would first do "rating" as descending and then "rating" as ascending - so you're overriding the descending with the ascending.

mozmonar
August 22nd, 2019, 17:29
<sortby>
<control desc="true">rating</control>
</sortby>

Still sorts "rating" ascending.

Trenloe
August 22nd, 2019, 17:41
What kind of list is this? Is it a windowlist control within XML or is it a grouped list (built in list functionality in CoreRPG based rulesets that are accessed via buttons from the campaign data list)?

Please post some XML to show where you're doing this and give context to the issue.

Trenloe
August 22nd, 2019, 17:44
Additionally? Is rating the name of the control or the field in the database?

Based off the API documentation, you could also try something like this:

<sortby desc="true">
<control>rating</control>
</sortby>

mozmonar
August 22nd, 2019, 18:05
Additionally? Is rating the name of the control or the field in the database?


Short answer is I don't know. I am altering something already functional.

There is a list of abilities/skills.
In this case from the skills_manager.lua

local minvestigation_skills = {
["Analytic Taste"] = { rating = 0, pool = 0, id = "analytic_taste" },
["Environmental Awareness"] = { rating = 0, pool = 0, id = "environmental_awareness" },
["Hearing"] = { rating = 0, pool = 0, id = "hearing" },
["Microvision"] = { rating = 0, pool = 0, id = "microvision" },
["Observe Dreams"] = { rating = 0, pool = 0, id = "observe_dreams" },
["Olfactory Center"] = { rating = 0, pool = 0, id = "olfactory_center" },
["Plant Communication"] = { rating = 0, pool = 0, id = "plant_communication" },
["Read Minds"] = { rating = 0, pool = 0, id = "read_minds" },
["Spatial Awareness"] = { rating = 0, pool = 0, id = "spatial_awareness" },
["Technopathy"] = { rating = 0, pool = 0, id = "technopathy" },
["Thermal Vision"] = { rating = 0, pool = 0, id = "thermal_vision" },
["Touch"] = { rating = 0, pool = 0, id = "touch" },
["Translation"] = { rating = 0, pool = 0, id = "translation" },
["X-Ray Vision"] = { rating = 0, pool = 0, id = "x_ray_vision" },
}

I want to sort on the rating number rather than the label (which seems to be name) so that the abilities with ratings float to the top.

I am trying to make a separate tab with the Mutation "skills" but running into trouble there...anyway the xml for that tab is this...

<?xml version="1.0" encoding="iso-8859-1"?>

<!--
Please see the license.html file included with this distribution for
attribution and copyright information.
-->

<root>
<windowclass name="charsheet_skills_mutations">
<sheetdata>
<label name="mgeneral_lbl">
<bounds>20,0,475,20</bounds>
<default>General Mutant Abilities</default>
</label>
<frame_char name="mgeneral_skillframe">
<anchored to="mgeneral_skills_lbl" position="below" height="380"/>
</frame_char>

<windowlist name="mgeneral_skills">
<anchored to="mgeneral_skillframe">
<top offset="20" />
<left offset="15" />
<right offset="-20" />
<bottom offset="-20" />
</anchored>
<child></child>
<child><backcolor>1A40301E</backcolor></child>
<allowcreate/>
<allowdelete/>
<datasource>.mgeneral_skills</datasource>
<class>char_skill</class>
<sortby>
<control desc="true">rating</control>
</sortby>
<columns width="220" filldown="true" />
</windowlist>
<scrollbar>
<anchored to="mgeneral_skills" />
<target>mgeneral_skills</target>
</scrollbar>

<label name="minvestigation_label">
<!-- <bounds>20,190,475,20</bounds> -->
<bounds>20,380,475,20</bounds>
<default>Investigative Mutant Abilities</default>
</label>

<frame_char name="minvestigation_skillframe">
<anchored to="minvestigation_label" position="below" height="175" offset="0,5" />
</frame_char>
<windowlist name="minvestigation_skills">
<anchored to="minvestigation_skillframe">
<top offset="20" />
<left offset="15" />
<right offset="-20" />
<bottom offset="-10" />
</anchored>
<child></child>
<child><backcolor>1A40301E</backcolor></child>
<allowcreate/>
<allowdelete/>
<datasource>.minvestigation_skills</datasource>
<class>char_skill</class>
<sortby><control>rating</control></sortby>
<columns width="220" filldown="true" />
</windowlist>
<scrollbar>
<anchored to="mgeneral_skills" />
<target>minvestigation_skills</target>
</scrollbar>

<!-- <label name="tech_label">
<bounds>20,370,475,20</bounds>
<default>Technical Abilities</default>
</label> -->

<!-- <frame_char name="tech_skillframe">
<anchored to="tech_label" position="below" height="185" offset="0,5" />
</frame_char>
<windowlist name="tech_skills">
<anchored to="tech_skillframe">
<top offset="20" />
<left offset="15" />
<right offset="-20" />
<bottom offset="-20" />
</anchored>
<child></child>
<child><backcolor>1A40301E</backcolor></child>
<allowcreate/>
<allowdelete/>
<datasource>.technical_skills</datasource>
<class>char_skill</class>
<sortby><control>label</control></sortby>
<columns width="220" filldown="true" />
</windowlist>
<scrollbar>
<anchored to="mgeneral_skills" />
<target>interp_skills</target>
</scrollbar> -->

<subwindow name="spend_win">
<bounds>15,-100,450,90</bounds>
<class>spend_window</class>
<datasource>.meta</datasource>
<activate />
</subwindow>
</sheetdata>
</windowclass>
</root>
28600

mozmonar
August 22nd, 2019, 18:11
Another, probably better, approach would be to have a toggle that just doesn't display skills with no rating. But that seems beyond my capabilities at this point and I was opting for what seemed simpler in the short term.

mozmonar
August 22nd, 2019, 18:57
I resolved the issue of General Mutant Abilities frame not working. Not sure why the Tab name is not displaying.

mozmonar
August 22nd, 2019, 18:59
And figured out why the sortby wasn't working. I was changing the sortby in the mgeneral area which wasn't displaying and not the minvestigative area. Dumbness on my part.

Trenloe
August 22nd, 2019, 19:00
Please also provide the XML for the char_skill windowclass - this is what the windowlist uses for each row in the list and will determine what controls are available to sort on.

mozmonar
August 22nd, 2019, 19:09
Please also provide the XML for the char_skill windowclass - this is what the windowlist uses for each row in the list and will determine what controls are available to sort on.

I'm afraid I don't know where or what that is. Think of me as one of the proverbial infinite monkeys banging away on the typewriter.

LordEntrails
August 22nd, 2019, 19:36
I'm afraid I don't know where or what that is. Think of me as one of the proverbial infinite monkeys banging away on the typewriter.
If you are using Notepad++, and have all the files in a single folder or open, you can do a Find In Files and select a folder and Npp will search all of the files there. You can search for "char_skill_ and it will find all occurrences of it and tell you what file they are found in. I can post screenshots of how to do this if needed.

mozmonar
August 22nd, 2019, 19:40
If you are using Notepad++, and have all the files in a single folder or open, you can do a Find In Files and select a folder and Npp will search all of the files there. You can search for "char_skill_ and it will find all occurrences of it and tell you what file they are found in. I can post screenshots of how to do this if needed.

Yeah I use Notepad++ and use the Find in Files pretty frequently. I will take a look at that when I get home. Unfortunately I ran out of time to mess with it for now. Actual work beckons.

Trenloe
August 22nd, 2019, 20:20
It looks like this may be an issue with either: a) the API documentation, b) the underlying FG code, or c) both. I've reached out to a dev to get an answer...

mozmonar
August 22nd, 2019, 20:37
Oh I figured out the sorting issue. I was making changes in the mgeneral_skills section which wasn't displaying. And I was testing it in the minvestigation_skills. When I set the descending flag in the proper place it worked fine. Sorry, I posted that earlier in the thread.

Trenloe
August 22nd, 2019, 21:04
Oh I figured out the sorting issue. I was making changes in the mgeneral_skills section which wasn't displaying. And I was testing it in the minvestigation_skills. When I set the descending flag in the proper place it worked fine. Sorry, I posted that earlier in the thread.
That's good you got it working. What syntax did you use?

mozmonar
August 22nd, 2019, 21:31
That's good you got it working. What syntax did you use?

Have to look when I get home. At work currently.

mozmonar
August 23rd, 2019, 19:17
That's good you got it working. What syntax did you use?

This worked once I implemented the changes in the proper location...



<sortby>
<control desc="true">rating</control>
</sortby>

Thanks for the help!