Best approach to hiding / restoring all banners?

I’d like to implement full-screen popup windows in my game, using banners - the purpose is to have minigames in these popups, where the player doesn’t enter commands to the parser but uses keyboard shortcuts and/or links to play the game. The popup banner windows (using Eric Eve’s CustomBannerWindow extension) are created as transient, since they’re not supposed to be saved if a game is saved.

While the minigame is active, the player is not allowed to leave the current room (or to interact with anything outside the minigame), so I’d like to make sure that my banner is the only one visible on the screen (not, for example, the status bar on top that shows the current room, exits, etc.); I want to hide all banners before showing the minigame banner window.

When the minigame is over, I’d like to restore the view as it was before the minigame popped up - all banners that were previously on the screen, should be back to its original place and content.

I tried this:

local vector = new Vector ();

for (local o = firstObj(BannerWindow); o != nil;
  o = nextObj(o, BannerWindow))
{
  local bi = new BannerInfo ();

  bi.handle = o.handle_;
  bi.id = o.id_;
  bi.parentId = o.parentID_;
  bi.inited = o.inited_;
  bi.style = o.styleFlags_;

  vector.append (bannerInfo);
}

When I print out the vector contents, I get this:

Banner ID '', parent '', handle '1', init 'true', style '33'
Banner ID '', parent '', handle '', init 'true', style ''
Banner ID '', parent '', handle '', init 'true', style ''
Banner ID '', parent '', handle '', init 'true', style ''

The first banner is the status line, but I can’t identify the others, and I can’t tell if these are active objects or not (since firstObj() returns unreachable objects, if any) .

I planned on calling showForRestore() since hiding the banners (using removeBanner()) would be a temporary, in-memory operation, but I don’t know what parameters to pass for the parent, where and other parameters.

Is this possible to do? If not, what would be a better approach to this?

1 Like

I can’t guarantee that my code will meet your needs exactly but I did a lot of batch hiding/showing of banners in Prince Quisborne. Unfortunately I have a really important project I’m trying to get done right now and don’t have the leisure to go digging in my code right now.
Possibly later today, if someone else doesn’t get you squared away first…

1 Like

What you’re after here sounds similar to how the CustomBannerMenu extension handles the display of menus. Have you taken a look at how it modifies MenuItem.display()?

1 Like

No, it didn’t occur to me, thank you. I’ll take a look and may be back with more questions. :slight_smile:

Edit: @Eric_Eve where can I find that extension? Google doesn’t return anything for CustomBannerMenu.

1 Like

It turns out my code is a lot of removeBanner calls with customized show() routines to bring up appropriate content in certain situations. Probably not immediately portable to your situation.
But I’ll concur that the customBanner.t extension should do what you need. If you’re still unclear on parent, where, other check out the comments early in banner.t just before showBanner.
I had to treat the statusline specially in a few cases, but perhaps customBanner.t streamlines all that.

@xxbbcc

Looks like I had a senior moment there. I meant how customBanner.t modifies MenuItem.display().

3 Likes

Lol, thank you, I’ll take a look. Happy New Year!

1 Like

I ended up just hiding the status banner like this:

if (statuslineBanner.inited_)
{
	statuslineBanner.removeBanner ();
	statuslineBanner.inited_ = nil;
	isStatusBannerHidden = true;
}

and then later on restoring it like this:

if (isStatusBannerHidden)
	statuslineBanner.initBannerWindow ();

This seems to work reliably so far. I realized that my initial approach of trying to figure out every banner was unneeded, since my game only creates banners in very controlled situations, and only one at a time, so there’s no need to dynamically inspect banners.

Leaving this here, maybe it’ll be useful to others.

2 Likes

Would’ve been useful a short while ago for me, but considering my use case involved banners being deactivated after an inputManager.pauseForMore(true), it was easier just to set the size of the status line banner to 0.

1 Like

Hm, I wonder if my life would’ve been easier using that trick…

1 Like