import pygame.locals as pgl
from .base import BaseScene
+from ..constants import SCREEN_SIZE
from ..events import SceneChangeEvent
from ..widgets import TextButton
from ..loader import loader
def enter(self, gamestate):
"""Construct list of stations"""
- height = 50
- width = 30
+ width = SCREEN_SIZE[0] / 2
+ self._title = TextButton(
+ 'Select a planet:', (255, 255, 255), pos=(width, 75),
+ size=32, font='bold', centre=True)
+ height = 150
self._buttons = []
for station in self._list_stations():
title = station["config"]["name"]
pos = (width, height)
- button = TextButton(title, (255, 255, 255), None, pos)
+ button = TextButton(title, (255, 255, 255), pos=pos, centre=True)
button.station = station
- if width < 400:
- width += 350
- else:
- width = 30
- height += button.get_height() + 20
+ height += button.get_height() + 20
self._buttons.append(button)
def render(self, surface, gamestate):
surface.fill((0, 128, 128))
+ self._title.render(surface)
for button in self._buttons:
button.render(surface)
def event(self, ev, gamestate):
if ev.type == pgl.KEYDOWN:
- if ev.key == pgl.K_l:
- self._do_load("station_alpha.json", gamestate)
+ if ev.key in (pgl.K_q, pgl.K_ESCAPE):
+ from .menu import MenuScene
+ SceneChangeEvent.post(scene=MenuScene())
elif ev.type == pgl.MOUSEBUTTONDOWN:
pressed = self._get_pressed(ev)
if pressed: