From: adrianna Date: Sat, 10 Sep 2016 22:05:39 +0000 (+0200) Subject: splash screen X-Git-Tag: tabakrolletjie-v1.0.0~26^2 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=b14bf81dd990b26eb646c6a4cfee4469926dd651;p=tabakrolletjie.git splash screen --- diff --git a/data/images/Makefile b/data/images/Makefile index 08ea9db..a223f47 100644 --- a/data/images/Makefile +++ b/data/images/Makefile @@ -8,6 +8,7 @@ LIGHT=spotlight lamp laser LIGHT_MASK=light_mask_2_1 light_mask_2_2 light_mask_3_1 light_mask_3_2 light_mask_3_3 CONTROLS=night default_cursor exit pause play day BLANKS=circle square +SPLASH=splash new_game continue_retry help quit IMG16=$(MOULD_BODY) IMG32=$(MOULD_BODY) $(MOULD) $(LIGHT) $(SEED) $(LIGHT_MASK) $(CONTROLS) @@ -21,8 +22,9 @@ PNG32=$(patsubst %, 32/%.png, $(IMG32)) PNG48=$(patsubst %, 48/%.png, $(IMG48)) PNG64=$(patsubst %, 64/%.png, $(IMG64)) PNG_CURSORS=$(patsubst %, cursors/%.png, $(CURSORS)) +PNG_SPLASH=$(patsubst %, splash/%.png, $(SPLASH)) -all: $(PNG16) $(PNG32) $(PNG48) $(PNG64) $(PNG_CURSORS) +all: $(PNG16) $(PNG32) $(PNG48) $(PNG64) $(PNG_CURSORS) $(PNG_SPLASH) 16/%.png: %.svg @mkdir -p `dirname $@` @@ -40,5 +42,9 @@ all: $(PNG16) $(PNG32) $(PNG48) $(PNG64) $(PNG_CURSORS) @mkdir -p `dirname $@` @inkscape -z -e $@ -w 64 -h 64 $< +splash/%.png: %.svg + @mkdir -p `dirname $@` + @inkscape -z -e $@ $< + cursors/%.png: 32/%.png @cp $< $@ diff --git a/data/images/splash/continue_retry.png b/data/images/splash/continue_retry.png new file mode 100644 index 0000000..d832bc4 Binary files /dev/null and b/data/images/splash/continue_retry.png differ diff --git a/data/images/splash/help.png b/data/images/splash/help.png new file mode 100644 index 0000000..e569df4 Binary files /dev/null and b/data/images/splash/help.png differ diff --git a/data/images/splash/new_game.png b/data/images/splash/new_game.png new file mode 100644 index 0000000..c0295f5 Binary files /dev/null and b/data/images/splash/new_game.png differ diff --git a/data/images/splash/quit.png b/data/images/splash/quit.png new file mode 100644 index 0000000..ae3302a Binary files /dev/null and b/data/images/splash/quit.png differ diff --git a/data/images/splash/splash.png b/data/images/splash/splash.png new file mode 100644 index 0000000..02d674e Binary files /dev/null and b/data/images/splash/splash.png differ diff --git a/sources/vector/continue_retry.svg b/sources/vector/continue_retry.svg new file mode 100644 index 0000000..d65382e --- /dev/null +++ b/sources/vector/continue_retry.svg @@ -0,0 +1,73 @@ + + + + + + + + + + image/svg+xml + + + + + + + Continue / Retry + + diff --git a/sources/vector/help.svg b/sources/vector/help.svg new file mode 100644 index 0000000..1272faa --- /dev/null +++ b/sources/vector/help.svg @@ -0,0 +1,73 @@ + + + + + + + + + + image/svg+xml + + + + + + + Help + + diff --git a/sources/vector/new_game.svg b/sources/vector/new_game.svg new file mode 100644 index 0000000..cfa4edc --- /dev/null +++ b/sources/vector/new_game.svg @@ -0,0 +1,73 @@ + + + + + + + + + + image/svg+xml + + + + + + + New game + + diff --git a/sources/vector/quit.svg b/sources/vector/quit.svg new file mode 100644 index 0000000..aa39059 --- /dev/null +++ b/sources/vector/quit.svg @@ -0,0 +1,75 @@ + + + + + + + + + + image/svg+xml + + + + + + + Quit + + diff --git a/sources/vector/splash.svg b/sources/vector/splash.svg new file mode 100644 index 0000000..4fae646 --- /dev/null +++ b/sources/vector/splash.svg @@ -0,0 +1,390 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Attack of the + giant space mould + giant space mould + Attack of the + + diff --git a/tabakrolletjie/scenes/menu.py b/tabakrolletjie/scenes/menu.py index 89b531e..9cf0557 100644 --- a/tabakrolletjie/scenes/menu.py +++ b/tabakrolletjie/scenes/menu.py @@ -1,48 +1,58 @@ """ Menu scene. """ import pygame.locals as pgl +import pygame.surface from .base import BaseScene from ..events import QuitEvent, SceneChangeEvent from ..loader import loader -from ..constants import FONTS -from ..widgets import TextButton, SpacerButton from ..utils import save_file_exists, get_save_data +from ..widgets import ImageButton +from ..transforms import Overlay + +class SplashButton(ImageButton): + def __init__(self, name, pos): + super(SplashButton, self).__init__("splash", "%s.png" % name, name=name, + pos=pos, disabled_colour=(50, 50, 50)) + w, h = self._img.get_size() + img = pygame.surface.Surface((w+8, h+4), pgl.SWSURFACE).convert_alpha() + img.fill((0, 0, 0, 0)) + img.blit(self._img, (8, 4), None) + img.fill((0, 0, 0, 255), None, pgl.BLEND_RGBA_MULT) + img.blit(self._img, (0, 0), None) + self._img = img class MenuScene(BaseScene): + + BRIGHTNESS = Overlay(colour=(255, 255, 255, 50)) + def enter(self, gamestate): if gamestate.station is None: print "Loading Station Alpha ..." gamestate.set_station(loader.load_station("station-alpha.json")) - font_title = loader.load_font(FONTS['bold'], size=32) - self._title = font_title.render('A Game with a title', True, - (255, 255, 255)) - self._cont_but = TextButton("Continue / Retry", (255, 255, 255), - name='continue') + + self._cont_but = SplashButton("continue_retry", (500, 210)) if not save_file_exists(): self._cont_but.disable() self._menu = [ - TextButton("New Game", (255, 255, 255), name='new game'), + SplashButton("new_game", (600, 150)), self._cont_but, - TextButton("Help", (255, 255, 255), name='help'), - SpacerButton((50, 30)), - TextButton("Quit", (255, 255, 255), name='quit'), + SplashButton("help", (700, 270)), + SplashButton("quit", (800, 330)), ] + + # Background + self._soil = loader.load_image( + "textures", "soil.png", transform=self.BRIGHTNESS).convert_alpha() + splash = loader.load_image("splash", "splash.png").convert_alpha() + self._soil.blit(splash, (0, 0), None) def render(self, surface, gamestate): - surface.fill((0, 128, 0)) - - pos = ((surface.get_width() - self._title.get_width()) / 2, 50) - surface.blit(self._title, pos, None) + surface.blit(self._soil, (0, 0), None) - height = 150 for item in self._menu: - if not item.position: - item.position = ((surface.get_width() - item.get_width()) / 2, - height) item.render(surface) - height += item.get_height() + 30 def _get_pressed(self, ev): for button in self._menu: @@ -78,9 +88,9 @@ class MenuScene(BaseScene): self._do_help() elif ev.type == pgl.MOUSEBUTTONDOWN: pressed = self._get_pressed(ev) - if pressed == 'new game': + if pressed == 'new_game': self._start_new_game() - elif pressed == 'continue': + elif pressed == 'continue_retry': self._do_load_save(gamestate) elif pressed == 'help': self._do_help() diff --git a/tabakrolletjie/widgets.py b/tabakrolletjie/widgets.py index 99966ef..4341c70 100644 --- a/tabakrolletjie/widgets.py +++ b/tabakrolletjie/widgets.py @@ -96,6 +96,9 @@ class ImageButton(Button): self._img = kwargs.pop("image", None) if self._img is None: self._img = loader.load_image(*imgparts, transform=transform) + self._disabled_img = self._img.copy() + disabled_colour = kwargs.pop("disabled_colour", (80, 80, 80)) + Multiply(colour=disabled_colour).apply(self._disabled_img) name = kwargs.get('name') pos = kwargs.get('pos') padding = kwargs.get('padding', 0) @@ -107,4 +110,7 @@ class ImageButton(Button): self._img = loader.load_image(*imgparts, transform=transform) def render(self, surface): - surface.blit(self._img, self._pos, None) + if self.enabled: + surface.blit(self._img, self._pos, None) + else: + surface.blit(self._disabled_img, self._pos, None)