Author Topic: Icons disapearing on resolution change.  (Read 981 times)

Offline LJ

  • Retired Staff
  • Posts: 1661
  • Cookies: 1139
Icons disapearing on resolution change.
« on: September 06, 2007, 11:28:41 AM »
Hey Guys,

I basically want to know if any of you have had problems with (custom loaded) icons disappearing (going invisible) when you change resolution?  This doesn't seem to effect the stock icons,  only the icons in my icon manager instance.

The only thing I can think of that is different about they way mine are done is that they are loaded dynamically at runtime rather than at loadtime.  I would rather not have to reload all the icons every time the resolution changes, but if needs must...  I'm crossing my fingers it's just something stupid that I've done!

Here is my (badly commented) icon manager code;
Code: [Select]
class IconManager:

def __init__(self, sName):

self.__dIcons   = {}
self.__sName = sName
self.__iPointer = 0
self.__pNode = App.g_kIconManager.GetIconGroup(self.__sName)

if not self.__pNode:
App.g_kIconManager.RegisterIconGroup(self.__sName, __name__, "Dummy")
self.__pNode = App.g_kIconManager.CreateIconGroup(self.__sName)
App.g_kIconManager.AddIconGroup(self.__pNode)
loddebug("Icons:\t" + "Created the Icon Group for " + self.__sName)

def __str__(self):
""" Return a the icon groups name as a string. """
return str(self.__sName)

def VerboseGetName(self):
""" Get the name of this icon mananger. """
return str(self.__sName)

def AddIcon(self,sPath, W, H, X=0, Y=0):
""" Add (and load) an icon into the icon manager.  Cache it under it's file path. """
iIconID = self.GetIcon(sPath)
if (iIconID is None):
self.__iPointer = self.__iPointer + 1
pTextureHandle  = self.__pNode.LoadIconTexture(sPath)
self.__pNode.SetIconLocation(self.__iPointer,pTextureHandle, X, Y, W, H)
self.__dIcons[sPath] = self.__iPointer
iIconID = self.__iPointer
loddebug("Icons:\t" + "Loading Icon at " + sPath)
return iIconID

def GetIcon(self,sPath):
""" Get the icon number from the cache. """
if self.__dIcons.has_key(sPath):
return self.__dIcons[sPath]
else:
return None

def Delete(self):
""" Delete this icon manager. """
loddebug("Icons:\t" + "Destroying the Icon Group for " + self.__sName)
App.g_kIconManager.DeleteIconGroup(self.__sName)

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Icons disapearing on resolution change.
« Reply #1 on: September 06, 2007, 11:34:38 AM »
Potentially it's the RegisterIconGroup line, since it actually wants to run a file.

Atleast, that's how I've seen it.

[EDIT] Meaning, if you register it, then it will reload on resolution change, meaning that the other icons get reloaded as well.
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.

Offline LJ

  • Retired Staff
  • Posts: 1661
  • Cookies: 1139
Re: Icons disapearing on resolution change.
« Reply #2 on: September 06, 2007, 11:41:55 AM »
Brilliant!  It seems to obvious now!  I'll update the manager to reload the icons on the UI res change in App.

Thanks Mleo!

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Icons disapearing on resolution change.
« Reply #3 on: September 06, 2007, 11:45:13 AM »
Brilliant!  It seems to obvious now!  I'll update the manager to reload the icons on the UI res change in App.

Thanks Mleo!
Isn't that something you wanted to avoid?
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.

Offline LJ

  • Retired Staff
  • Posts: 1661
  • Cookies: 1139
Re: Icons disapearing on resolution change.
« Reply #4 on: September 06, 2007, 11:51:35 AM »
Of course, yes. However I would much rather have the code in a working state first. 

That being said I can't see a simple solution via scripts to stop it needing to reload. I wonder why they chose to make the icon reloading compulsory on res change.. I mean i can understand fonts and LCARS, but you would think it would be optional.

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Icons disapearing on resolution change.
« Reply #5 on: September 06, 2007, 11:54:45 AM »
Well, DirectX loses everything after a window change (yes, that's just DirectX).
So it has to reload, but I didn't know that it went through that.
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.