Add drawing all Ui elems in on screen init

This commit is contained in:
Michał Czekański 2020-04-05 22:58:32 +02:00
parent c822a1bfd4
commit 967146e45c

View File

@ -2,6 +2,7 @@ import math
from enum import Enum from enum import Enum
import pygame import pygame
from src.ui.Ui import Ui
# minimum UI width # minimum UI width
MARGIN = 300 MARGIN = 300
@ -31,6 +32,8 @@ class Screen:
# draw a white rect to resemble map # draw a white rect to resemble map
pygame.draw.rect(self.pygameScreen, (255, 255, 255), [self.mapCoord, 0, self.mapSize, self.mapSize]) pygame.draw.rect(self.pygameScreen, (255, 255, 255), [self.mapCoord, 0, self.mapSize, self.mapSize])
self.__initUi__()
def calculateMapDimensions(self): def calculateMapDimensions(self):
result = 0 result = 0
expectedSize = self.winY expectedSize = self.winY
@ -60,3 +63,18 @@ class Screen:
return self.mapCoord return self.mapCoord
elif location is Locations.MAP: elif location is Locations.MAP:
return self.mapSize return self.mapSize
def __initUi__(self):
self.ui = Ui(self.getUiWidth(Locations.RIGHT_UI), self.getUiWidth(Locations.LEFT_UI), self.winY,
self.gameObject.ingameTimer)
self.draw(self.ui.timerTextView, Locations.LEFT_UI, 0, 0)
self.draw(self.ui.isDayTextView, Locations.LEFT_UI, 0, 0)
self.draw(self.ui.console, Locations.LEFT_UI, 0, 0)
self.draw(self.ui.healthTextView, Locations.RIGHT_UI, 0, 0)
self.draw(self.ui.healthBar, Locations.RIGHT_UI, 0, 0)
self.draw(self.ui.hungerTextView, Locations.RIGHT_UI, 0, 0)
self.draw(self.ui.hungerBar, Locations.RIGHT_UI, 0, 0)
self.draw(self.ui.staminaTextView, Locations.RIGHT_UI, 0, 0)
self.draw(self.ui.staminaBar, Locations.RIGHT_UI, 0, 0)
self.draw(self.ui.thirstTextView, Locations.RIGHT_UI, 0, 0)
self.draw(self.ui.thirstBar, Locations.RIGHT_UI, 0, 0)