Author Topic: Atlas and font swapping for deactivated sprites and labels  (Read 2684 times)

Alan Gray

  • Guest
Atlas and font swapping for deactivated sprites and labels
« on: July 01, 2012, 01:00:06 AM »
We have a pretty elaborate UI. For many of our UI scenes, there are alternate panels - only one of which is visible/active at a time. Also we have lots of alternate sprites that get activated/deactivated based on the state of the game. The bottom line is that we start our scenes with lots of UI elements strategically deactivated. The issue I'm running into is that the atlas and font swapping (for multiple resolution support) only does the swapping on active UISprites and UILabels. How are others handling this?

I guess one option would be to use the recursive panel activate, do the swapping, then programmatically deactivate all the stuff that needs to be deactivated. This approach would be a lot of work for us due to the alternate sprites which would need to be selectively deactivated.

Another approach that I'm considering is to traverse the hierarchy, record and activate any UISprites and UILabels, do the swapping, go back and deactivate the temporarily activated sprites and labels. Is this crazy?

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Atlas and font swapping for deactivated sprites and labels
« Reply #1 on: July 01, 2012, 09:33:25 AM »
If you are manually changing every sprite and label, then this will be an issue. You should rather use a reference font and reference atlas, then you just change what atlas the reference atlas is pointing to, and all your sprites and fonts using those respective atlases will change, no recursiveness or anything.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile

Alan Gray

  • Guest
Re: Atlas and font swapping for deactivated sprites and labels
« Reply #3 on: July 01, 2012, 02:01:08 PM »
Sorry if I wasn't clear. Yes, we are using reference atlases and fonts to do the resolution swapping. The issue is that we have lots of UI elements inactive in the default state (how we save our scenes). If we do the atlas/font swapping in the default state, all the inactive sprites/labels don't get updated to the new atlas/font. Last night, I implemented the crazy scheme I was asking about (traversing the hierarchy, finding all the inactive sprites/labels, recording the inactive sprites/labels to Lists and activating them, doing the atlas/font swap, the returning those sprites/labels to inactive). It takes a few millisecs when the scene is loaded - but everything gets updated properly.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Atlas and font swapping for deactivated sprites and labels
« Reply #4 on: July 01, 2012, 04:43:53 PM »
They don't need to be updated to the new font. They should be using a reference atlas -- all your widgets should be using the reference atlas. All you have to do to switch your atlas, is change what the reference atlas points to.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Atlas and font swapping for deactivated sprites and labels
« Reply #5 on: July 01, 2012, 05:24:27 PM »
Further expounding on it.

Having these fonts
Times10 --real font size 10
Times20 -- font size 20
Times --reference font referencing either Times10 or 20, whichever you edit in (SD or HD).

You make your widget use the "Times" font, and change the "myFont.replacement" to the real font you want to use, then all widgets are automatically updated, inactive or active, or not even loaded yet.

Same deal with atlases.