icon_pool.py 693 B

1234567891011121314151617181920212223242526272829
  1. # -*- coding: utf-8 -*-
  2. import pygame
  3. from pygame.locals import *
  4. from sys import exit
  5. import os
  6. import sys
  7. from util_funcs import SkinMap
  8. ##pool only store surfaces
  9. class IconPool(object):
  10. _GameShellIconPath = SkinMap("gameshell/icons/")
  11. _Icons = {}
  12. def __init__(self):
  13. self._Icons= {}
  14. def Init(self):
  15. files = os.listdir(self._GameShellIconPath)
  16. for i in files:
  17. if os.path.isfile(self._GameShellIconPath+"/"+i) and i.endswith(".png"):
  18. keyname = i.split(".")[0]
  19. self._Icons[keyname] = pygame.image.load(self._GameShellIconPath+"/"+i).convert_alpha()
  20. MyIconPool = IconPool()