untitled_icon.py 1.4 KB

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