Feature - Implemented Make Maximizer Filters checkboxes instead of radio buttons

MCroft

Developer
Staff member
Hope your weekend was good, I spent mine deep in the maximizer and the maximizer frame.

View attachment Maximixer_multi-select.patch enhances the maximizer by allowing the user to select checkboxes in the GUI instead of a single filter.

Notes:
Tested GUI and gCLI maximizing with combinations of checkboxes (including none, one, some, and all checkboxes). Checkboxes do not affect gCLI (no changes), do affect GUI.

Changed method signature of maximize to use an EnumMap instead of an Integer for filter, made wrapper function for old signature in case something other than MaximizerFrame calls it.

Moved prefs note from maximizer JTextArea to a tooltip on the filters label.

Did not save checkbox state. It's refreshed every time.

By default, Booze, Food, and Spleen are turned off if you can't use them (e.g. Teetotal) or are full. Can still be turned back on.

Screen Shot 2020-10-19 at 12.05.58 PM.pngScreen Shot 2020-10-19 at 12.06.20 PM.pngScreen Shot 2020-10-19 at 12.07.10 PM.png
 
Last edited:

MCroft

Developer
Staff member
Also things I didn't do, but may want to do after this lands:
convert giant set of "if (cmd.startsWith("chew") to a giant case statement for readability purposes.
 

fronobulax

Developer
Staff member
Why? Not looking at anything, including the current UI, radio buttons are mutually exclusive options and checkboxes are and/or. So why were there radio buttons to begin with? Were things required to be mutually exclusive in the maximizer at some point in the past but no more?

Just buying time since I need to get the Debug Log patch off my plate first :)
 

Ryo_Sangnoir

Developer
Staff member
While I appreciate that this is a somewhat rare concern, I do sometimes want to check only the things I can "cast" (that for example enhance meat or item drops, when I'm looking to burn mana and want to check what buffs I can add). This patch would turn that from one click on the "cast" button to six, unchecking everything but "cast".

Could you add an "uncheck all" button or something like that?
 

MCroft

Developer
Staff member
While I appreciate that this is a somewhat rare concern, I do sometimes want to check only the things I can "cast" (that for example enhance meat or item drops, when I'm looking to burn mana and want to check what buffs I can add). This patch would turn that from one click on the "cast" button to six, unchecking everything but "cast".

Could you add an "uncheck all" button or something like that?

Good thought, and there's clearly room in the UI for it.

Do you think it should be two buttons (Check All/Uncheck All) or one button that changes between those two labels? (e.g. "Uncheck All unless nothing is checked, then display Check All and do that...")
 

fronobulax

Developer
Staff member
It's a change from 2018, in r18392, AlbinoRhino wrote the original version. Maybe they can tell us what their design thoughts were.

Here's the original thread: https://kolmafia.us/showthread.php?21909-Maximizer-Filters

While waiting it does seem as checkboxes could have a speed impact - more things to check.

I can't think of anything this takes away from what I do now but it will be interesting to see the sort options when I can use spells or potions. I'm not sure which one I want to see first if they are both +5 but one is 5,000 meat for 5 turns and one is 50 mp for 10 turns. My answer will be different for HC, SC (ronin) and aftercore.
 

MCroft

Developer
Staff member
While waiting it does seem as checkboxes could have a speed impact - more things to check.

I was concerned about performance and that's why I switched to EnumMap from HashMap (also data integrity), but it seems like it wasn't that important. It's faster (in my unmeasured experience) if you leave off equipment, because it doesn't have to look up prices on things you aren't equipping. If you do add equip to the filter set, then it has to do the lookup, once. That's not changing, but you may not have to use equip as frequently...

This is new Filter code for the core piece (there are a few "if Horsery/if equip and nothing else/..." things):
Code:
// Check filters

	String basecommand = cmd.trim().contains(" ") ? cmd.split(" ")[0] : cmd;
	switch (basecommand)
	{
	case "cast":
		if ( !filter.getOrDefault( KoLConstants.filterType.CAST , false) ) continue;
		break;
	case "chew":
		if ( !filter.getOrDefault( KoLConstants.filterType.SPLEEN , false) ) continue;
		break;
	case "drink":
		if ( !filter.getOrDefault( KoLConstants.filterType.BOOZE, false ) ) continue;
		break;
	case "eat":
		if ( !filter.getOrDefault( KoLConstants.filterType.FOOD, false ) ) continue;
		break;
	case "use":
		if ( !filter.getOrDefault( KoLConstants.filterType.USEABLE, false ) ) continue;
		break;
	default:
		if ( !filter.getOrDefault( KoLConstants.filterType.OTHER, false ) ) continue;
	}

That replaces this:
Code:
// Check filters
	if	( filterLevel != 0 )
	{
		if ( cmd.startsWith( "cast " ) )
		{
			if ( filterLevel != 2 )
			{
				continue;
			}
		}
		else if ( cmd.startsWith( "chew " ) )
		{
			if ( filterLevel != 6 )
			{
				continue;
			}
		}
		else if ( cmd.startsWith( "drink " ) )
		{
			if ( filterLevel != 4 )
			{
				continue;
			}
		}
		else if ( cmd.startsWith( "eat " ) )
		{
			if ( filterLevel != 5 )
			{
				continue;
			}
		}
		else if ( cmd.startsWith( "use " ) )
		{
			if ( filterLevel != 3 )
			{
				continue;
			}
		}
		else if ( filterLevel != 7 )
		{
			continue;
		}
	}
 
Last edited:

MCroft

Developer
Staff member
I can't think of anything this takes away from what I do now but it will be interesting to see the sort options when I can use spells or potions. I'm not sure which one I want to see first if they are both +5 but one is 5,000 meat for 5 turns and one is 50 mp for 10 turns. My answer will be different for HC, SC (ronin) and aftercore.

I didn't do anything with sort order, it's the same (equip-on-top-then-by-plus-then-I-don't-know) as it is now, it just filters some things in or out. That said, it would be a reasonable future improvement to add a user results
filter (like the item manager) or even convert to a table and let the user do column sorting.
 

AlbinoRhino

Active member
filter (like the item manager) or even convert to a table and let the user do column sorting.

That would be amazing!

No particular reason for choosing the radio buttons that I know. Adding the filters in the first place was focused on excluding some of the enormous number of results that are possible...so I guess I just tended toward being the most ​exclusive.
 
Last edited:

gausie

D̰͕̝͚̤̥̙̐̇̑͗̒e͍͔͎͈͔ͥ̉̔̅́̈l̠̪̜͓̲ͧ̍̈́͛v̻̾ͤe͗̃ͥ̐̊ͬp̔͒ͪ
Staff member
While we're on this, I'd also like a filter for those other effect sources not described by any of the existing radios - things like spacegate vaccines and such that are not "cast"able per se, but act like it.
 

MCroft

Developer
Staff member
While we're on this, I'd also like a filter for those other effect sources not described by any of the existing radios - things like spacegate vaccines and such that are not "cast"able per se, but act like it.

It's there. But it's not usable.

If, due to Laf sizing, it overflows the box it's in, it's not visible. I didn't even know it existed when I used the MacOS Look and Feel, so it was a surprise to me when I found it working with the FlatMap Dark Laf. It's why I switched the checkboxes to two lines.

You can see it in Nimbus Laf, or you can apply my dark mode patch, or you can apply my checkboxes patch...

screenshots from unmodified r20474...
Screen Shot 2020-10-20 at 9.05.26 AM.pngScreen Shot 2020-10-20 at 9.03.57 AM.png
 
Last edited:

AlbinoRhino

Active member
Huh...it's always been there for me (non-Mac). Hard to believe it's never been realized before now that some of you can't see it!
 
Last edited:

gausie

D̰͕̝͚̤̥̙̐̇̑͗̒e͍͔͎͈͔ͥ̉̔̅́̈l̠̪̜͓̲ͧ̍̈́͛v̻̾ͤe͗̃ͥ̐̊ͬp̔͒ͪ
Staff member
I've never seen it in my life!! Never having been a Windows user. Now I look at the code I'm also missing the "pullable/buyable" radio in the maximizer entirely when its too small, but then once it renders it is clipped (see ridiculously sized gif below)

gCb6ulH.gif
 

Ryo_Sangnoir

Developer
Staff member
Do you think it should be two buttons (Check All/Uncheck All) or one button that changes between those two labels? (e.g. "Uncheck All unless nothing is checked, then display Check All and do that...")

In my initial suggestion, I assumed you'd just flip away and back to check all because state wasn't saved.

I don't have a real preference between the two options: I think having two buttons presents a clearer interface (if three are checked, would you expect "Check All" or "Uncheck All"?), at the expense of taking more room.
 

MCroft

Developer
Staff member
Yeah, it probably needs a fresh layout. Swing is pixel-based, and not natively good at being size-aware.
 

MCroft

Developer
Staff member
In my initial suggestion, I assumed you'd just flip away and back to check all because state wasn't saved.

I don't have a real preference between the two options: I think having two buttons presents a clearer interface (if three are checked, would you expect "Check All" or "Uncheck All"?), at the expense of taking more room.

I agree, but there is room (because I saved some by pulling out the "Other Options" text to a tool tip).

It stays with what you have until you close the window/tab (depending on how you use it). So if, like me, you leave it open most of the time, it stays on whatever you had selected until you close or close-via-exit.

Is this what you're thinking? It does make it three clicks ("Filter None", "cast", "update") instead of your current two.
Screen Shot 2020-10-20 at 2.17.51 PM.png
 

Ryo_Sangnoir

Developer
Staff member
Is this what you're thinking? It does make it three clicks ("Filter None", "cast", "update") instead of your current two.

Yeah, looks nice. I think "Check All" is clearer than "Filter All", though -- I'd interpret "Filter All" as filtering everything out: that is, having everything unchecked. Maybe "Include All" and "Exclude All", to separate it from the implementation.
 

MCroft

Developer
Staff member
Well the good news is that's easy to change.

The bad news is that I'm not a UI expert, so these are just my best guesses. I wibbled on this one, because I'm not checking the checkmarks on the page that are not in this group, but the group doesn't have a box around it (because that's not the visual style in use here). But I take your point that this isn't the verb "Filter".

I can make them wordier, like "Clear Filters/Set All Fliters". I can add tooltips. If you try to update and have no filters set, it doesn't make sense, so I'd be happy to hear suggestions for correct behavior (either "what matches the rest of the app?" or "what does the most user-intuitive thing?")
 

MCroft

Developer
Staff member
Please review patch

Patch for review: View attachment Maximizer_Filter_Multi-Select_v3.patch

Done: add filter checkboxes and add set all filters/clear filters buttons.

Done: Add filter field to results, so it's more like other panes.
Not sure if it's useful, but it's easy and might help. My best use case for it is "show me all the +20 ML results". Change to Scrollable Filtered Panel also affects Museum, but not in a bad way.​

Done: Removing the Equipment: none radio button, since it's redundant with unchecking the equipment checkbox.
This may solve gausie's problem of not seeing "pullable/buyable" by making that row shorter. Downside of that: Removing the checkbox in the MaximizerFrame changes the Index of the options in the radio button. MaximizerFrame talks to the Maximizer by sending it that index as "equipLevel".

While I'd love to go in and rip out all of the "equipLevel" code and pass an Enum ("Enums are Integers, except when they're not") that's not on the plate for tonight, and I don't want to mess up the gCLI/ASH by changing the all those "if equipLevel == 1" lines to 0, or other fun things.

Immediate inelegant solution is to send RadioButtonGroupIndex+1...


Out of Scope: Anything about changing sort order
Out of Scope: Fixing the existing bug I'm about to report on text field focus when starting with a frame open.
 
Last edited:
Top