untitled_icon.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 datetime import datetime
  8. import base64
  9. from beeprint import pp
  10. from util_funcs import midRect, SkinMap
  11. from fonts import fonts
  12. from skin_manager import MySkinManager
  13. BlankPng = SkinMap("gameshell/blank.png") # 80x80
  14. ## use blank circle as bg, Two alpha As Icon Label
  15. #Upper and Lower
  16. class UntitledIcon(object):
  17. _PosX = 0
  18. _PosY = 0
  19. _Width = 80
  20. _Height = 80
  21. _Words = ["G", "s"]
  22. _FontObj = fonts["varela40"]
  23. _BG = None # initial surface
  24. _Color = MySkinManager.GiveColor('Text')
  25. def __init__(self):
  26. self._Words = ["G", "s"]
  27. def Init(self):
  28. self._BG = pygame.image.load(BlankPng).convert_alpha()
  29. def SetWords(self, TwoWords):
  30. if len(TwoWords) == 1:
  31. self._Words[0] = TwoWords[0].upper()
  32. if len(TwoWords) == 2:
  33. self._Words[0] = TwoWords[0].upper()
  34. self._Words[1] = TwoWords[1].lower()
  35. self._Text = self._FontObj.render("".join(self._Words),True,self._Color)
  36. def Draw(self):
  37. if self._BG != None:
  38. w_ = self._Text.get_width()
  39. h_ = self._Text.get_height()
  40. self._BG.blit(self._Text,midRect(self._Width/2,self._Height/2,w_,h_,self._Width,self._Height))
  41. def Surface(self):
  42. self.Draw()
  43. return self._BG