martedì 30 giugno 2009

Atlantide Media Center: menù di partenza

Un po' di brainstorming per il media center:
  • ogni menù ha una voce 'setup' che permette di configurare gli aspetti di quel menù, come ad esempio il percorso dove trovare i file multimediali, o il comando da impostare per riprodurli
  • ogni menù ha una voce 'indietro' ('esci' su quello principale)
  • dati possono essere directory e file, che si possono rinominare, cancellare, copiare, spostare; si possono creare directory nuove
  • se evidenziata una cartella, ti dice il numero di file e la data del più recente
  • se evidenziato un file ti dice dimensione, data e lunghezza (e magari copertina e info IMDB o equivalente italiano!)
  • nel menù 'Guarda TV' la funzione 'Setup' attiva la funzione di popolamento dei canali, e il comando per la visualizzazione dei canali stessi
  • i programmi registrati vanno in 'Registra TV', si possono poi spostare a piacere; in quel menù sono presenti le programmazioni
E ora un po' di codice python...

#!/usr/bin/python
########################################################
# Note sul nome delle variabili e funzioni :
# iniziano tutte con una sequenza che indica il tipo
#
# i = intero
# s = surface
# str = stringa
# font = font
# r = rect
########################################################
# Imports
########################################################
import pygame, sys, os
from pygame.locals import *
########################################################
# Inizializzazione variabili
########################################################
pygame.init()
iiResolution = (800, 600)
fontDefault = pygame.font.Font(None, 36)
# set screen resolution
pygame.display.set_mode(iiResolution, 0, 32)
sScreen = pygame.display.get_surface()
strBackgroundFile = os.path.join(".","Atlantis_by_aksu.jpg")
sBackground = pygame.image.load(strBackgroundFile)
strCurrentMenu = os.path.join(".","main.mnu")
########################################################
# Functions
########################################################
def drawMenu(menuFile, iSelected):
# Disegna il contenuto del menuFile ed evidenzia il selected
global sForeground, fontDefault
##################################
file = open(menuFile, 'r')
i=0
centerx = sForeground.get_rect().centerx
offsy = sForeground.get_rect().centery/2
for line in file:
line = line.replace ( "\n", "" )
sText = fontDefault.render(line, 1, (255, 255, 255))
rText = sText.get_rect()
rText.centerx = centerx
rText.y = i*32+offsy
if i == iSelected:
rText2 = rText.inflate(118,4)
rText2.centerx = centerx
sBox = pygame.Surface.convert_alpha(pygame.Surface((rText2.width, rText2.height)))
sBox.fill((0, 255, 255, 100))
sForeground.blit(sBox, rText2)
sForeground.blit(sText, rText)
i=i+1
# Setup string
sText = fontDefault.render("Setup", 1, (255, 255, 255))
rText = sText.get_rect()
rText.centerx = sForeground.get_rect().centerx
rText.y = i*32+offsy
sForeground.blit(sText, rText)
# Exit/back string
i=i+1
sText = fontDefault.render("Exit", 1, (255, 255, 255))
rText = sText.get_rect()
rText.centerx = sForeground.get_rect().centerx
rText.y = i*32+offsy
sForeground.blit(sText, rText)
##################################
def input(events):
# Gestisce gli eventi di input
global iItemSelected
##################################
for event in events:
if event.type == KEYDOWN:
if event.key == K_UP:
iItemSelected -= 1
elif event.key == K_DOWN:
iItemSelected += 1
elif event.key == K_ESCAPE:
sys.exit(0)
else:
print event
########################################################
# Main
########################################################
iItemSelected =0

# Main loop
while True:
sForeground = pygame.transform.scale(sBackground, iiResolution)
input(pygame.event.get())
pygame.display.flip()
drawMenu(strCurrentMenu, iItemSelected)
sScreen.blit(sForeground, (0,0))

Nessun commento:

Posta un commento