Feature Refresh topmenu on ascension

Bale

Minion
After ascending, it would be nice if the top menu was refreshed.

It's not a huge thing. There is a handy refresh button after all and I can always click there. It would just be nice to have all the high level locations and stuff flushed from the top menu so I can see it as it is supposed to be at level 1.
 
It's true - but we can insert code to do so into some appropriate page so that the browser will do it.

Take a look at RequestEditorKit.addTopmenuRefresh. We do that in FightRequest.decorateMonster when you win a fight that drops the volcano map, so that you'll be able to see the "volcano" link in the topmenu, which is present and available, even though KoL did not refresh the topmenu to show you.

We could do something similar here. The trick is to decide which page to decorate. I'd say the first time we show you the main map after you ascend, although I'm not sure how to recognize that.
 
My guess is that native KoL doesn't give a topmenu refresh either, otherwise mafia would follow it.

Heck, yes. That's why this is a feature request, not a bug fix.

The trick is to decide which page to decorate. I'd say the first time we show you the main map after you ascend, although I'm not sure how to recognize that.

Actually, what I was thinking is that there is already code in place to run a postAscensionScript. The relay browser stops at that point waiting on refreshing the mainpane until the script is done running. Then when it finally sends KoL's reply to the relay browser you could decorate that page, whatever it is.

For One Crazy Random Summer, that is the page where it gives you your auto-pulled dice gear.

Since there is already code in place regarding this moment in the game where you have just finished ascending, it seems to me to be a good time to refresh the top menu. Of course it is possible that I am making bad assumptions about how mafia works.
 
In GenericRequest, at the end of the block starting with
Code:
if ( this.formURLString.startsWith( "afterlife.php" ) )
I expect that
Code:
this.responseText = this.responseText.replaceFirst( "</body>", "</body><script>top.menupane.location.href=\"topmenu.php\";</script>" );
would handle it, though that would modify the page even for people not using the browser. RequestEditorKit.addTopmenuRefresh wants to modify a StringBuffer, and I'm not sure when the conversion from String to StringBuffer happens.

Since my topmenu is a relay override and I never actually care about it refreshing, I'm not likely to remember to test anything.
 
Since my topmenu is a relay override and I never actually care about it refreshing, I'm not likely to remember to test anything.

It is BECAUSE my topmenu is a relay override that this is particularly relevant. When I click on the "guild" link I don't want to go to the wrong guild.
 
There may be other places where it is useful. I noticed for example that a manual refresh is needed after unlocking Desert.
 
I guess it's worth throwing in after every time a new location is unlocked, which we already have code to recognize happening.
 
I think implementing this change natively would takes its toll one way or another. If KoLMafia decides we need to preform some sort of operation, rather than some sort of expensive change like running an Ajax request every 2 seconds from game.php, I think a good solution is to edit charpane.php, since we're editing it already to add effect "up" buttons and a refresh link etc, then just insert a line of JavaScript to refresh the menupane when we need to. As far as logic, I think as soon as KolMafia detects we've unlocked a new zone, we can set a variable, perhaps _reloadMenuPane, for the next time charpane.php loads, and then when it charpane.php loads next, we'd update _reloadMenuPane to read false and write <script>top.menupane.location.reload();</script> to the page. I see no reason we can't simply add it in if we're already editing the page natively.
 
I think implementing this change natively would takes its toll one way or another. If KoLMafia decides we need to preform some sort of operation, rather than some sort of expensive change like running an Ajax request every 2 seconds from game.php, I think a good solution is to edit charpane.php, since we're editing it already to add effect "up" buttons and a refresh link etc, then just insert a line of JavaScript to refresh the menupane when we need to. As far as logic, I think as soon as KolMafia detects we've unlocked a new zone, we can set a variable, perhaps _reloadMenuPane, for the next time charpane.php loads, and then when it charpane.php loads next, we'd update _reloadMenuPane to read false and write <script>top.menupane.location.reload();</script> to the page. I see no reason we can't simply add it in if we're already editing the page natively.

I think you completely misunderstood me. KoLmafia is doing lots of text parsing on every page you load, no matter what (less on pages that can't have anything worth parsing, but that's not relevant here). If a page has New Location Unlocked (or whatever the exact KoL phrasing is), KoLmafia makes the location name a link (unless it's an unknown location). All that would need to be added is some javascript that tells your browser to reload the topmenu, the same javascript (or similar enough anyway) to what KoL sometimes adds.
 
I think you're the one which misunderstood me, I understood you perfectly. I'm suggesting the line of JavaScript, that you mentioned, which needs to be added somewhere, I think it would be good to add it to the charpane.php, since that page is constantly reloading as we adventure, so a simple instruction to reload topmenu.php would be very suitable there in contrast to trying to edit several mainpane pages and step on each other's toes by allowing the JavaScript to appear on almost any page. My post before is concerned with the best approach to add in the line of JavaScript. I think you're confused why I mentioned the _reloadMenuPane variable. I believe it would be useful to have such a variable accessible to override scripts, which is the reason I suggested it, in case it's possible to reload the topmenu earlier when the user is browsing around but before spending an adventure.
 
I'm pretty sure it's just as complicated to only add that javascript to charpane when needed as it is to add it other places only when needed, probably more complicated. Override scripts don't need to know when they are being told to refresh, it will just happen.
 
Back
Top