Bug - Fixed Custom buttons at top of non-combat adventures vanish when using CAB

Bale

Minion
When not using the CAB mafia will (if enabled) put custom buttons at the top of fight pages. It also puts a button at the top of non-combat adventures which says "again" or "auto" depending on the circumstance. I really like the ability to click "auto" and have mafia answer the choice adventures according to my preferences.

Unfortunately when the CAB is enabled, mafia will offer no automation for non-combat adventures. That seems strangely lacking.

I cannot imagine this is on purpose to remove an already existing feature under that circumstance, so I'm posting this as a bug.
 

lostcalpolydude

Developer
Staff member
I've used the CAB for so long that I don't know the answer to this, but can those custom buttons be triggered with keyboard commands? If so, they would override choice-adventure manual controls. Though every time I'm in the louvre I wish I didn't have to move the mouse to the mafia-added goal button.
 

Veracity

Developer
Staff member
With the stationary buttons come hotkeys, I believe, although I have never configured any.

As coded, if you have the CAB enabled, we add a "script" button to the left of fights - and do nothing for non-fights, as this report indicates. I can make it prefer the CAB - if enabled - for fights, and insert stationary buttons for choices and noncombats, as suggested. I can also make it not load the hotkeys.js helper file unless you've actually defined some hotkeys.

I'll look at this, by and by.
 

Bale

Minion
Thank you for considering.

Or if you want to continue the CAB's look and feel, you could create an non-combat action bar (nCAB) for choice adventures... Though that would obviously take a bit more work. Just throwing it out there.
 

Bale

Minion
I'm continuing to clumsily teach myself some java to satisfy a few of my personal wishes. Does anyone know a really good resource for learning java?

I can make it prefer the CAB - if enabled - for fights, and insert stationary buttons for choices and noncombats, as suggested.

This proved to be shockingly simple to implement, at least in the most basic way, so I've made a patch for this.

Note that this adds the mafia style stationary button for choice adventures. I'd prefer if it was CAB style button when the CAB is enabled, but my java comprehension isn't yet that good. Maybe I'll work my way up to figuring that out.
 

Attachments

  • UseNCstationaryButtonEvenWhenCABenabled.patch
    681 bytes · Views: 26

Veracity

Developer
Staff member
I'll try your patch tomorrow - I'm out of turns for today - but it looks like if you have the CAB enabled, it will use it for anything which is not choice.php, and stationary buttons if you don't have the CAB enabled OR if it is choice.php.

What about noncombats? Does KoL insert a CAB for those? If not, it looks to me like you won't get stationary buttons, although those of us who do not use the CAB do get them.
 

Winterbay

Active member
KOL does not. In a NC you get the text of it and then you need to click the link at the bottom to adventure again in the same spot or go somewhere else.
 

Bale

Minion
As Winterbay say. It sucks a bit to have to keep going to the bottom of the page after every non-combat. Especially when it is a long non-combat so you have to scroll down to the adventure link.

I'll try your patch tomorrow - I'm out of turns for today - but it looks like if you have the CAB enabled, it will use it for anything which is not choice.php, and stationary buttons if you don't have the CAB enabled OR if it is choice.php.

Throw away that patch. I've just finished something MUCH better. (Thanks to StDoodle for helping me with the html.) I'm not sure how you like mafia's code to handle large blocks of text so I expect you would want to either reformat my patch or else tell me what it should look like so that I can reformat it. (I'd be glad to reformat it if you tell me how it should be.)

I now present the NonCombatActionBar! This does exactly what everyone should want. It adds a CAB interface to the top of your non-combats with a single button.
 

Attachments

  • NonCombatActionBar.patch
    3.3 KB · Views: 30
Last edited:

Bale

Minion
I just want to say that this screenshot made me happy. No more needing to scroll all the way down just to buy that darn photograph for 500 meat. I love my new patch!

 

Bale

Minion
Wow. I see. That's not quite like either of the other two approaches I was considering.

It seems you've entirely rebuilt my patch so I won't need to do it. I'll will try to do it that way if I do something like this again.

Bug with this patch so far: It does not work in the daily dungeon and it does not work on Dvorak's Revenge. I'm a long way from figuring out why since much of mafia is still a mystery to me.
 

Veracity

Developer
Staff member
When I'm generating an HTML table, I like to make it very obvious what goes in each row, that every row I start, I end, and, basically, that every start tag has a matching end tag at the appropriate place. Aside from making it easier to validate by inspection, it makes it easier to change things later. Building it up in a new StringBuffer makes that easy and appending to a StringBuffer is reasonably efficient, since it just adds to the end of pre-allocated space and grows it as needed, as opposed to repeatedly inserting into the middle of an existing StringBuffer, which has to shift around the current content to make room for the new content after every insert().

Regarding the pseudo-CAB not appearing in other locations, you should look at RequestEditorKit.java and see where it calls StationaryButtonDecorator.decorate. It's called if you are in adventure.php (which you stay in if it does not redirect to choice.php or fight.php - i.e., for a straight Noncombat), for choice.php, and for fight.php. The Daily Dungeon is dungeon.php. Dvorak's revenge is tiles.php. Both of those call their own custom decorators, but it's perfectly fine to call multiple decorators, as you will see when you look at RequestEditorKit ...

If you want a CAB for Dvorak's revenge, I suggest you look at DvorakDecorator.decorate to see what it generates for the Solve! button. Did you notice that StationaryButtonDecorator.decorate is given the location? You can generate custom buttons for tiles.php, choice.php, or whatever, if you want. Now, if you wanted custom per-choice buttons, you would need to look into the buffer itself to see whichchoice=xxx.

Edit: I just uploaded a new version of my patch which tweaks a few things in the interest of code clarity.
Edit 2: if you make tiles.php and dungeon.php call the StationaryButtonDecorator, don't forget that people will see it even if they don't use the CAB and thus your code. Unless you want to generate KoLmafia-style stationary buttons for such people, you should make the function bail out (or is that Bale out? ;)) for those locations.
 

Attachments

  • NCAB.patch
    3.9 KB · Views: 20
Last edited:

Bale

Minion
Thanks for the lesson in good programming practice. (That was absolutely serious, so please don't think I was sarcastic.)

I'm going to have to take a good look at RequestEditorKit. It's so big and complicated that it's a little scary, but I'll persevere.

Edit 2: if you make tiles.php and dungeon.php call the StationaryButtonDecorator, don't forget that people will see it even if they don't use the CAB and thus your code. Unless you want to generate KoLmafia-style stationary buttons for such people, you should make the function bail out (or is that Bale out? ;)) for those locations.

Would it be bad to generate mafia-style buttons for those locations? I know that adventure.php is not being called for the zone, but I figure that since the area is non-combats alternating with combats it seems odd for the buttons on the top to vanish between fights.
 

Veracity

Developer
Staff member
Thanks for the lesson in good programming practice. (That was absolutely serious, so please don't think I was sarcastic.)
You are welcome. It was a response to your comment that it was unlike what you'd been considering - so I explained my reasoning for doing things the way I did.

I'm going to have to take a good look at RequestEditorKit. It's so big and complicated that it's a little scary, but I'll persevere.
It is scary. If I want to check when various functions in it are called, I have to relearn every time. Fortunately, simply adding a new decorator or whatever can be done by seeing where similar decorators are added.

Would it be bad to generate mafia-style buttons for those locations? I know that adventure.php is not being called for the zone, but I figure that since the area is non-combats alternating with combats it seems odd for the buttons on the top to vanish between fights.
No problem with adding mafia-style buttons. I just wanted to make sure you didn't just let fight.php combat buttons get generated. :)

I just tried enabling the CAB and trying this out. It seems to work well. Revision 8717. If you are thinking of playing with dungeon.php and tiles.php, I'll leave this open for now. Otherwise, I'll mark it Fixed.
 

Bale

Minion
It is scary. If I want to check when various functions in it are called, I have to relearn every time. Fortunately, simply adding a new decorator or whatever can be done by seeing where similar decorators are added.

Yeah, that's what I always do to find a place to get started figuring things out. Still, it's tough cause there's so much code there I don't understand yet.


No problem with adding mafia-style buttons. I just wanted to make sure you didn't just let fight.php combat buttons get generated. :)

I just tried enabling the CAB and trying this out. It seems to work well. Revision 8717. If you are thinking of playing with dungeon.php and tiles.php, I'll leave this open for now. Otherwise, I'll mark it Fixed.

I'd thought that if I called StationaryButtonDecorator it'd automatically chose between mafia-style and CAB style buttons? I'll be careful in case it doesn't work out. I think I'm gonna try to check out tiles.php and dungeon.php eventually, so you can leave this open if you like. Or else close it and I'll open a bug report when I make another patch to improve this feature. I'm good either way! :)

I'm kinda thrilled I managed to add something worthwhile to KoLmafia. I feel much better about fixing a problem than I feel about reporting it. Thanks to StDoodle for helping me with the html. (Without that help I'd have had a lot of trouble making this work.)
 

Veracity

Developer
Staff member
I'd thought that if I called StationaryButtonDecorator it'd automatically chose between mafia-style and CAB style buttons? I'll be careful in case it doesn't work out. I think I'm gonna try to check out tiles.php and dungeon.php eventually, so you can leave this open if you like. Or else close it and I'll open a bug report when I make another patch to improve this feature. I'm good either way! :)
Yes...but now that I look at it, the code to add mafia-style buttons actually always adds fight buttons; it simply chooses what to call the first one - and what action to give it - based on whether it is choice.php or not. In other words, it was coded with fight.php in mind, was modified slightly to add choice.php - and could probably stand to be revisited, if we now want additional pages to be decorated.

I'm going to close this one, for now, since the original issue has been addressed.

I'm kinda thrilled I managed to add something worthwhile to KoLmafia. I feel much better about fixing a problem than I feel about reporting it. Thanks to StDoodle for helping me with the html. (Without that help I'd have had a lot of trouble making this work.)
Congratulations!
 
Top