Exemple #1
0
 def __init__(self):
   GameManager.__init__(self)
   
   self.humanView = HumanView()
   self.humanView.init("Planet 5521", "planet5521/data/graphics.xml")
   TextManager.loadFromFile("planet5521/data/fonts.xml")
   
   self._currentState = MainMenuState(self.humanView)
Exemple #2
0
 def init(self, title, graphicsFile):
   """Given the graphics element of the configuration file, parses the
   properties therein and sets them as properties of the View class."""
   XMLroot = ElementTree.parse(graphicsFile).getroot()
   for configNode in XMLroot:
     setattr(self, configNode.tag, Util.convert(configNode.text))
   
   Input.init(self)
   TextManager.init()
   
   # Creates screen
   self._window = sfml.RenderWindow(sfml.VideoMode(self.WINDOW_WIDTH, self.WINDOW_HEIGHT), title)
   self._pane = NGUIPane(0, 0, self.WINDOW_WIDTH, self.WINDOW_HEIGHT)
   self._pane.name = "HumanView"
   self.mouseFocus = None
Exemple #3
0
 def packToText(self, margin = 4):
   """Packs the box around the text default, with given margin."""
   self._margin = margin
   textSprite = TextManager.renderText(self.text, self.style)
   rect = textSprite.local_bounds
   self._w = rect.width + self._margin*2
   self._h = rect.height + self._margin*2
Exemple #4
0
  def drawButton(self, view, bacgroundColour, outlineColour, style):
    r = RectangleShape()
    r.outline_color = outlineColour
    r.outline_thickness = 1
    r.fill_color = bacgroundColour
    r.position = (self._ax, self._ay)
    r.size = (self._w, self._h)
    view.drawSprite(r)
    
    textSprite = TextManager.renderText(self.text, style)
    rect = textSprite.local_bounds
    # Needs rect.left and stuff because text local bounds are apparently non-0.
    # Something to do with text alignment, perhaps? :)
    textSprite.position = (self._ax + self._w // 2 - (rect.width // 2) - rect.left,
                           self._ay + self._h // 2 - (rect.height // 2) - rect.top)

    view.drawSprite(textSprite)