Migration from scratch de la version 2.10 NIHM
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
|
||||
def DefConfPathHome():
|
||||
import os
|
||||
#os.path.abspath(os.curdir)
|
||||
ParentOfPyr=os.path.abspath(os.curdir)
|
||||
#ParentOfPyr=(os.environ['HOME'] + "/pyrharckade_2")
|
||||
ConfRomFile=(ParentOfPyr + "/ROM_CONFIG_FILES.csv")
|
||||
AllMedia=(ParentOfPyr + "/MEDIA/")
|
||||
ConfigKeyboardFile=ParentOfPyr + "/CONF/KeyMapKeyBoard.py"
|
||||
return ParentOfPyr,ConfRomFile,AllMedia,ConfigKeyboardFile
|
||||
|
||||
|
||||
def DefConfPathEmu(Orientation):
|
||||
import os
|
||||
|
||||
ParentOfPyr=os.path.abspath(os.curdir)
|
||||
#ParentOfPyr=(os.environ['HOME'] + "/pyrharckade_2")
|
||||
Img=(ParentOfPyr + "/MEDIA/IMG/")
|
||||
BACKGROUNG=(ParentOfPyr + "/MEDIA/IMG/IMGY/SYS.png")
|
||||
if Orientation == "Y":
|
||||
BACKGROUNG_EMU=(ParentOfPyr + "/MEDIA/IMG/menu_Y.png")
|
||||
else:
|
||||
BACKGROUNG_EMU=(ParentOfPyr + "/MEDIA/IMG/menu_X.png")
|
||||
IMG_EMU = (ParentOfPyr + "/MEDIA/IMG/EMU/")
|
||||
BACKGROUNG_START=(ParentOfPyr + "/MEDIA/IMG/dpfe_welcom_X.png")
|
||||
BlackImg = (ParentOfPyr + "/MEDIA/IMG/black.png")
|
||||
SLEEP_BEFORE_START = 4
|
||||
if Orientation == "Y":
|
||||
BACKGROUNG_ORIG=(ParentOfPyr + "/MEDIA/IMG/IMGY/bg2_Y.png")
|
||||
else:
|
||||
BACKGROUNG_ORIG=(ParentOfPyr + "/MEDIA/IMG/IMGY/bg2_X.png")
|
||||
return Img,BACKGROUNG_ORIG,BACKGROUNG,IMG_EMU,BACKGROUNG_EMU
|
||||
|
||||
def DefConfPathGame(Orientation):
|
||||
import os
|
||||
ParentOfPyr=os.path.abspath(os.curdir)
|
||||
#ParentOfPyr=(os.environ['HOME'] + "/pyrharckade_2")
|
||||
BinOfPyr=(ParentOfPyr + "/BIN/")
|
||||
Wheel=(ParentOfPyr + "/MEDIA/Wheel/")
|
||||
Snap=(ParentOfPyr + "/MEDIA/SNAP/")
|
||||
Sound=(ParentOfPyr + "/MEDIA/SOUND/")
|
||||
IMG_EMU = (ParentOfPyr + "/MEDIA/IMG/EMU/")
|
||||
Roms=(ParentOfPyr + "/MEDIA/ROMS/")
|
||||
Docs=(ParentOfPyr + "/MEDIA/DOCS/")
|
||||
ImgY=(ParentOfPyr + "/MEDIA/IMG/IMGY/")
|
||||
ImgX=(ParentOfPyr + "/MEDIA/IMG/IMGX/")
|
||||
Img=(ParentOfPyr + "/MEDIA/IMG/")
|
||||
BlackImg = (ParentOfPyr + "/MEDIA/IMG/black.png")
|
||||
return ParentOfPyr,BinOfPyr,Wheel,Snap,Sound,Roms,Docs,ImgY,ImgX,Img,BlackImg,IMG_EMU
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import os
|
||||
|
||||
def DefCheckEnv ():
|
||||
|
||||
Sys=os.uname()
|
||||
return Sys
|
||||
@@ -0,0 +1,242 @@
|
||||
#!/usr/bin/env python
|
||||
#-*- coding: utf-8 -*-
|
||||
# pyrharckade 2 is a simple pygame front for PIMAME
|
||||
# version: 2.0A
|
||||
# guillaume@tuxme.net
|
||||
# GPL Licence
|
||||
|
||||
import os, sys, pygame, pygame.font, pygame.image,subprocess, sys, time
|
||||
from pygame.locals import *
|
||||
import urllib2
|
||||
import urllib
|
||||
from DefResAndSysFile import *
|
||||
from DefCheckEnvFile import DefCheckEnv
|
||||
Sys=DefSystem()
|
||||
import glob
|
||||
Resolution=DefResolution()
|
||||
|
||||
|
||||
def DownloadGraphical(Emu_Media,Media):
|
||||
|
||||
def getSize(filename):
|
||||
st = os.stat(filename)
|
||||
return st.st_size
|
||||
|
||||
finished = 0
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if Emu_Media == "BIOS":
|
||||
Ext_Media=".tar.bz2"
|
||||
|
||||
if Emu_Media == "FBA" or Emu_Media == "CPS3" or Emu_Media == "GNGEO" or Emu_Media == "MAME" or Emu_Media == "CPS3":
|
||||
Emu_Media_url = "ARCADE"
|
||||
else:
|
||||
Emu_Media_url=Emu_Media
|
||||
|
||||
|
||||
### PROD
|
||||
pygame.init()
|
||||
Y,X=Resolution
|
||||
PyrScreen = pygame.display.set_mode(Resolution,FULLSCREEN)
|
||||
|
||||
### TEST
|
||||
#Y,X=(800,600)
|
||||
#Resolution=(Y,X)
|
||||
#PyrScreen = pygame.display.set_mode(Resolution)
|
||||
|
||||
|
||||
|
||||
|
||||
Space_bar=20
|
||||
XBAR=(Y-(Y/Space_bar))
|
||||
YBAR=(X/10)
|
||||
WHERE_XBAR=Space_bar
|
||||
WHERE_YBAR=(Y/2) - (YBAR/2)
|
||||
|
||||
|
||||
if glob.glob("./BIN/download.png"):
|
||||
IMG_DL="./BIN/download.png"
|
||||
FONT_DL="./MEDIA/font.ttf"
|
||||
PATH_MEDIA="./MEDIA/"
|
||||
else:
|
||||
IMG_DL="download.png"
|
||||
FONT_DL="../MEDIA/font.ttf"
|
||||
PATH_MEDIA="../MEDIA/"
|
||||
|
||||
fond = pygame.transform.scale(pygame.image.load(IMG_DL).convert(),Resolution)
|
||||
PyrScreen.blit(fond, (0,0))
|
||||
time.sleep(0.8)
|
||||
pygame.draw.rect(PyrScreen,(200,200,200),((WHERE_XBAR,WHERE_YBAR),(XBAR,YBAR)),0)
|
||||
FontSize = (X/10)
|
||||
font = pygame.font.Font(FONT_DL, (FontSize+10))
|
||||
|
||||
|
||||
|
||||
|
||||
if Sys == "Darwin":
|
||||
Liste_media='SNAP','WHEEL','DOCS','ROMS'
|
||||
else :
|
||||
Liste_media='SNAP','WHEEL','DOCS','ROMS','VIDEO'
|
||||
print("SYSTEM : " + (Sys))
|
||||
|
||||
for Type_Media in (Liste_media):
|
||||
#for Type_Media in ('SNAP','WHEEL','DOCS'):
|
||||
|
||||
|
||||
|
||||
if Type_Media == "SNAP" or Type_Media == "WHEEL":
|
||||
Ext_Media=".png"
|
||||
if Type_Media == "VIDEO":
|
||||
Ext_Media=".mpg"
|
||||
if Type_Media == "ROMS":
|
||||
Ext_Media=".zip"
|
||||
if Type_Media == "DOCS":
|
||||
Ext_Media=".txt"
|
||||
if Emu_Media == "BIOS":
|
||||
Ext_Media=".tar.bz2"
|
||||
if Emu_Media == "NES" and Type_Media=="ROMS":
|
||||
Ext_Media=".nes"
|
||||
if Emu_Media == "GAMEBOY" and Type_Media=="ROMS":
|
||||
Ext_Media=".gb"
|
||||
|
||||
|
||||
|
||||
if Emu_Media == "FBA" or Emu_Media == "CPS3" or Emu_Media == "GNGEO" or Emu_Media == "MAME" or Emu_Media == "CPS3":
|
||||
Emu_Media_url = "ARCADE"
|
||||
else:
|
||||
Emu_Media_url=Emu_Media
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
text1 = "Check : " + Emu_Media_url + "/" + Type_Media+ "/" + Media + Ext_Media
|
||||
text2 = font.render(text1, True, pygame.Color("white"), pygame.Color("black"))
|
||||
#PyrScreen.blit(text2,((Y/2),(Y/2)))
|
||||
PyrScreen.blit(text2,((Space_bar),(X/2)))
|
||||
PyrScreen.blit(fond, (0,0))
|
||||
|
||||
url = "http://media.pyrharckade.io/"+ Emu_Media_url + "/" + Type_Media+ "/" + Media + Ext_Media
|
||||
|
||||
if Type_Media == "ROMS" and Emu_Media_url == "ARCADE":
|
||||
Ext_Media=".zip"
|
||||
url = "http://www.arcadehits.net/downloads/tool.php?am=berzerking&Fichier=mame/" + Media + Ext_Media
|
||||
|
||||
|
||||
|
||||
|
||||
if Emu_Media == "SYS" and Type_Media=="ROMS":
|
||||
Ext_media=".csv"
|
||||
url="http://media.pyrharckade.io/SYS/ROMS/ROM_CONFIG_FILES.csv"
|
||||
print(url)
|
||||
|
||||
file_name = url.split('/')[-1]
|
||||
print ( PATH_MEDIA + Emu_Media + '/' + Type_Media + "/" + Media + Ext_Media)
|
||||
|
||||
if not os.path.exists(PATH_MEDIA + Emu_Media + '/' + Type_Media + "/" + Media + Ext_Media):
|
||||
TestCodeUrl=urllib.urlopen(url).getcode()
|
||||
if TestCodeUrl == 200:
|
||||
#try:
|
||||
# urllib2.urlopen(url)
|
||||
ERR_TEST='OK'
|
||||
#except urllib2.HTTPError, e:
|
||||
# ERR_TEST=str(e.code)
|
||||
else:
|
||||
ERR_TEST='404'
|
||||
|
||||
|
||||
else:
|
||||
ERR_TEST = '404'
|
||||
print (PATH_MEDIA + Emu_Media + '/' + Type_Media + "/" + Media + Ext_Media)
|
||||
u = urllib2.urlopen(url)
|
||||
meta = u.info()
|
||||
file_size = int(meta.getheaders("Content-Length")[0])
|
||||
file_size_exist=getSize(PATH_MEDIA + Emu_Media + '/' + Type_Media + "/" + Media + Ext_Media)
|
||||
if str(file_size) == str(file_size_exist):
|
||||
ERR_TEST = '404'
|
||||
text1 = "Check : " + Emu_Media_url + "/" + Type_Media+ "/" + Media + Ext_Media + " : OK"
|
||||
text2 = font.render(text1, True, pygame.Color("white"), pygame.Color("black"))
|
||||
#PyrScreen.blit(text2,(Space_bar,WHERE_YBAR+(YBAR*2)))
|
||||
PyrScreen.blit(text2,((Space_bar),(X/2)))
|
||||
pygame.draw.rect(PyrScreen,(120,38,38),((WHERE_XBAR,WHERE_YBAR),(XBAR,YBAR)),0)
|
||||
pygame.display.update()
|
||||
time.sleep(0.8)
|
||||
|
||||
else:
|
||||
ERR_TEST = 'GO_TO_DL'
|
||||
print ("File Diff")
|
||||
|
||||
if ERR_TEST != '404':
|
||||
continuer = 1
|
||||
if not os.path.exists(PATH_MEDIA + Emu_Media + '/' + Type_Media):
|
||||
os.makedirs(PATH_MEDIA + Emu_Media + '/' + Type_Media)
|
||||
u = urllib.urlopen(url)
|
||||
|
||||
meta = u.info()
|
||||
file_size = int(meta.getheaders("Content-Length")[0])
|
||||
|
||||
f = open(PATH_MEDIA + Emu_Media + '/' + Type_Media + '/' + file_name, 'wb')
|
||||
meta = u.info()
|
||||
file_size_dl = 0
|
||||
block_sz = 8192
|
||||
buffer=0
|
||||
#entry_info = 'Download ' + Type_Media + " in " + Emu_Media + " for " + Media
|
||||
|
||||
|
||||
pygame.display.update()
|
||||
|
||||
|
||||
while finished == 0:
|
||||
if file_size_dl == file_size:
|
||||
text2 = font.render(entry_info, True, pygame.Color("green"),pygame.Color("black"))
|
||||
#PyrScreen.blit(text2,(Space_bar,WHERE_YBAR+(YBAR*2)))
|
||||
|
||||
PyrScreen.blit(text2,((Space_bar),(X/2)))
|
||||
# pygame.display.update()
|
||||
time.sleep(0.8)
|
||||
break
|
||||
finished=1
|
||||
buffer = u.read(block_sz)
|
||||
|
||||
file_size_dl += len(buffer)
|
||||
f.write(buffer)
|
||||
status = r"%10d [%3.2f%%]" % (file_size_dl, file_size_dl * 100. / file_size)
|
||||
status = status + chr(8)*(len(status)+1)
|
||||
Progress=((XBAR*file_size_dl)/file_size)
|
||||
pygame.draw.rect(PyrScreen,(200,200,200),((WHERE_XBAR,WHERE_YBAR),(XBAR,YBAR)),0)
|
||||
pygame.draw.rect(PyrScreen,(120,38,38),((WHERE_XBAR,WHERE_YBAR),(Progress,YBAR)),0)
|
||||
Pourcent=100*file_size_dl/file_size
|
||||
|
||||
# pygame.display.update()
|
||||
|
||||
entry_info = 'Download ' + Type_Media + " in " + Emu_Media + " for " + Media + " : " + str(Pourcent) + " %"
|
||||
|
||||
text1 = entry_info
|
||||
text2 = font.render(entry_info, True, pygame.Color("white"), pygame.Color("black"))
|
||||
|
||||
pygame.time.delay(40)
|
||||
|
||||
# pygame.draw.rect(PyrScreen,(200,200,200),((WHERE_XBAR,WHERE_YBAR),(XBAR,YBAR)),0)
|
||||
#PyrScreen.blit(fond, (0,0))
|
||||
# pygame.display.update()
|
||||
#PyrScreen.blit(text2,(Space_bar,WHERE_YBAR+(YBAR*2)))
|
||||
PyrScreen.blit(text2,((Space_bar),(X/2)))
|
||||
pygame.display.update()
|
||||
|
||||
else:
|
||||
print ( PATH_MEDIA + Emu_Media + '/' + Type_Media + "/" + Media + Ext_Media + ' : OK')
|
||||
f.close()
|
||||
#pygame.draw.rect(PyrScreen,(200,200,200),((WHERE_XBAR,WHERE_YBAR),(XBAR,YBAR)),0)
|
||||
PyrScreen.blit(fond, (0,0))
|
||||
# pygame.display.update()
|
||||
pygame.display.update()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
import pygame
|
||||
import sys
|
||||
|
||||
from pygame.locals import *
|
||||
from DefFrontEndGameMapFile import *
|
||||
from DefFrontEndEmuFile import *
|
||||
from ConfAllPath import *
|
||||
|
||||
|
||||
import os
|
||||
from ConfAllPath import *
|
||||
from KeyMapKeyBoard import *
|
||||
|
||||
def DefFrontEndEmu(Resolution,emu,MapingEmu,li,CptEmu,MAX_EMU,MAX,Orientation,JOY_TEST):
|
||||
|
||||
#one_debug = 0
|
||||
MAX_EMU = MAX_EMU -1
|
||||
pygame.key.set_repeat(400, 50)
|
||||
Img,BACKGROUNG_ORIG,BACKGROUNG,IMG_EMU,BACKGROUNG_EMU=DefConfPathEmu(Orientation)
|
||||
SIZE_BIN_1,SIZE_BIN_2,SIZE_BIN_3,WHERE_BIN_1,WHERE_BIN_2,WHERE_BIN_3=MapingEmu
|
||||
Resolution=Resolution
|
||||
pygame.init()
|
||||
PyrScreen = pygame.display.set_mode(Resolution,FULLSCREEN)
|
||||
fond = pygame.transform.scale(pygame.image.load(BACKGROUNG_EMU).convert(),Resolution)
|
||||
PyrScreen.blit(fond, (0,0))
|
||||
#pygame.joystick.init()
|
||||
if JOY_TEST == 1:
|
||||
mon_joystick = pygame.joystick.Joystick(0)
|
||||
mon_joystick.init
|
||||
if(CptEmu > MAX_EMU) or (CptEmu < - MAX_EMU):
|
||||
CptEmu = 0
|
||||
|
||||
if (CptEmu + 1) > MAX_EMU:
|
||||
CptRight = 0
|
||||
else:
|
||||
CptRight = CptEmu + 1
|
||||
|
||||
if (CptEmu - 1) < - MAX_EMU:
|
||||
CptLeft = 0
|
||||
else:
|
||||
CptLeft = CptEmu - 1
|
||||
|
||||
pygame.display.flip()
|
||||
KeepInEmu = 1
|
||||
FrontEndEmu = 1
|
||||
ExitStatus = 0
|
||||
while KeepInEmu == 1:
|
||||
BeepFile=Img + "../SOUND/blip.wav"
|
||||
BeepFileLoad=pygame.mixer.music.load(BeepFile)
|
||||
for event in pygame.event.get():
|
||||
if JOY_TEST == 0 :
|
||||
if event.type == KEYDOWN:
|
||||
# if event.key == K_LEFT:
|
||||
if event.key == LEFT_J1:
|
||||
CptEmu = CptEmu - 1
|
||||
# print "DEBUG : LEFT : " + str(LEFT_J1)
|
||||
# one_debug = 0
|
||||
# if event.key == K_RIGHT:
|
||||
if event.key == RIGHT_J1:
|
||||
CptEmu = CptEmu + 1
|
||||
# print "DEBUG : RIGHT : " + str(RIGHT_J1)
|
||||
# one_debug = 0
|
||||
if event.key == BTN_J1_1:
|
||||
FrontEndEmu = 0
|
||||
ExitStatus = 0
|
||||
KeepInEmu = 0
|
||||
FrontEndGame = 1
|
||||
EmuChoose = emu[CptEmu]
|
||||
#print "Play ... "
|
||||
if event.key == K_ESCAPE:
|
||||
FrontEndEmu = 0
|
||||
ExitStatus = 1
|
||||
FrontEndGame = 0
|
||||
EmuChoose = ""
|
||||
KeepInEmu=0
|
||||
pygame.mixer.Sound(BeepFile).play()
|
||||
if JOY_TEST == 1 :
|
||||
if event.type == JOYAXISMOTION:
|
||||
if event.axis == 0 and event.value > 0:
|
||||
CptEmu = CptEmu - 1
|
||||
if event.axis == 0 and event.value < 0:
|
||||
CptEmu = CptEmu + 1
|
||||
if event.type == JOYBUTTONDOWN and event.button == BTN_J1_1:
|
||||
FrontEndEmu = 0
|
||||
ExitStatus = 0
|
||||
KeepInEmu = 0
|
||||
FrontEndGame = 1
|
||||
EmuChoose = emu[CptEmu]
|
||||
pygame.mixer.Sound(BeepFile).play()
|
||||
|
||||
if (CptEmu > MAX_EMU) or (CptEmu < - MAX_EMU):
|
||||
CptEmu = 0
|
||||
|
||||
if (CptEmu + 1) > MAX_EMU:
|
||||
CptRight = 0
|
||||
else:
|
||||
CptRight = CptEmu + 1
|
||||
|
||||
if (CptEmu - 1) < - MAX_EMU:
|
||||
CptLeft = 0
|
||||
else:
|
||||
CptLeft = CptEmu - 1
|
||||
|
||||
#if one_debug == 0:
|
||||
# print "4. CptLeft -> " + str(CptLeft)
|
||||
|
||||
#if one_debug == 0:
|
||||
# print "2. CptEmu -> " + str(CptEmu)
|
||||
|
||||
#if one_debug == 0:
|
||||
# print "3. CptRight -> " + str(CptRight)
|
||||
|
||||
EmuRightPath=IMG_EMU+'/'+emu[CptRight]+ ".png"
|
||||
EmuLeftPath=IMG_EMU+'/'+emu[CptLeft]+ ".png"
|
||||
EmuCenterPath=IMG_EMU+'/'+emu[CptEmu]+ ".png"
|
||||
|
||||
#if one_debug == 0:
|
||||
# print "EmuLeftPath -> " + EmuLeftPath
|
||||
#if one_debug == 0:
|
||||
# print "EmuCenterPath -> " + EmuCenterPath
|
||||
#if one_debug == 0:
|
||||
# print "EmuRightPath -> " + EmuRightPath
|
||||
#if one_debug == 0:
|
||||
# print "5. " + str(CptEmu) + " : " + emu[CptEmu]
|
||||
#if one_debug == 0:
|
||||
# one_debug = 1;
|
||||
|
||||
if (os.path.isfile(IMG_EMU+'/'+emu[CptRight]+ ".png")):
|
||||
EmuRightPath=IMG_EMU+'/'+emu[CptRight]+ ".png"
|
||||
EmuRight=pygame.transform.scale(pygame.image.load(EmuRightPath).convert_alpha(),SIZE_BIN_3)
|
||||
else:
|
||||
muRightPath=IMG_EMU+'/no_emu.png'
|
||||
EmuRight=pygame.transform.scale(pygame.image.load(EmuRightPath).convert_alpha(),SIZE_BIN_3)
|
||||
|
||||
if (os.path.isfile(IMG_EMU+'/'+emu[CptLeft]+ ".png")):
|
||||
EmuLeftPath=IMG_EMU+'/'+emu[CptLeft]+ ".png"
|
||||
EmuLeft=pygame.transform.scale(pygame.image.load(EmuLeftPath).convert_alpha(),SIZE_BIN_2)
|
||||
else:
|
||||
EmuLeftPath=IMG_EMU+'/no_emu.png'
|
||||
EmuLeft=pygame.transform.scale(pygame.image.load(EmuLeftPath).convert_alpha(),SIZE_BIN_2)
|
||||
|
||||
if (os.path.isfile(IMG_EMU+'/'+emu[CptEmu]+ ".png")):
|
||||
EmuCenterPath=IMG_EMU+'/'+emu[CptEmu]+ ".png"
|
||||
EmuCenter=pygame.transform.scale(pygame.image.load(EmuCenterPath).convert_alpha(),SIZE_BIN_1)
|
||||
else:
|
||||
EmuCenterPath=IMG_EMU+'/no_emu.png'
|
||||
EmuCenter=pygame.transform.scale(pygame.image.load(EmuCenterPath).convert_alpha(),SIZE_BIN_1)
|
||||
|
||||
|
||||
PyrScreen.blit(fond, (0,0))
|
||||
PyrScreen.blit(EmuRight,WHERE_BIN_2),SIZE_BIN_3
|
||||
PyrScreen.blit(EmuLeft,WHERE_BIN_3),SIZE_BIN_1
|
||||
PyrScreen.blit(EmuCenter,WHERE_BIN_1),SIZE_BIN_1
|
||||
pygame.display.flip()
|
||||
return FrontEndEmu,ExitStatus,FrontEndGame,EmuChoose,CptEmu
|
||||
@@ -0,0 +1,80 @@
|
||||
from math import *
|
||||
|
||||
def DefFrontEndEmuMapX(resolution):
|
||||
SCREEN_W,SCREEN_H=resolution
|
||||
#print str(SCREEN_W) + "x" + str(SCREEN_H)
|
||||
## TAILLE DES MENU EMU
|
||||
|
||||
SIZE_BIN_X_1 = int(floor(SCREEN_W /4))
|
||||
SIZE_BIN_Y_1 = SIZE_BIN_X_1
|
||||
SIZE_BIN_1 = (SIZE_BIN_X_1,SIZE_BIN_Y_1)
|
||||
|
||||
SIZE_BIN_X_2 = int(floor(SIZE_BIN_X_1*2/3))
|
||||
SIZE_BIN_Y_2 = SIZE_BIN_X_2
|
||||
SIZE_BIN_2 = (SIZE_BIN_X_2,SIZE_BIN_Y_2)
|
||||
|
||||
SIZE_BIN_X_3 = SIZE_BIN_X_2
|
||||
SIZE_BIN_Y_3 = SIZE_BIN_X_3
|
||||
SIZE_BIN_3 = (SIZE_BIN_X_3,SIZE_BIN_Y_3)
|
||||
|
||||
##EMU CENTRE POSITION
|
||||
|
||||
WHERE_BIN_1_X=int(floor((SCREEN_W / 2)-(SIZE_BIN_X_1/2)))
|
||||
WHERE_BIN_1_Y=int(floor((SCREEN_H / 2) - (SIZE_BIN_X_1/2)))
|
||||
WHERE_BIN_1=(WHERE_BIN_1_X,WHERE_BIN_1_Y)
|
||||
|
||||
##EMU GAUCHE POSITION
|
||||
|
||||
WHERE_BIN_2_X=int(floor((SCREEN_W / 4)-(SIZE_BIN_X_2/2)))
|
||||
WHERE_BIN_2_Y=int(floor(SCREEN_H / 3))
|
||||
WHERE_BIN_2=(WHERE_BIN_2_X,WHERE_BIN_2_Y)
|
||||
|
||||
##EMU GAUCHE POSITION
|
||||
|
||||
WHERE_BIN_3_X=int(floor((SCREEN_W * 3 / 4)-(SIZE_BIN_X_3/2)))
|
||||
WHERE_BIN_3_Y=int(floor(SCREEN_H / 3))
|
||||
WHERE_BIN_3=(WHERE_BIN_3_X,WHERE_BIN_3_Y)
|
||||
|
||||
|
||||
return(SIZE_BIN_1,SIZE_BIN_2,SIZE_BIN_3,WHERE_BIN_1,WHERE_BIN_2,WHERE_BIN_3)
|
||||
|
||||
|
||||
|
||||
def DefFrontEndEmuMapY(resolution):
|
||||
SCREEN_W,SCREEN_H=resolution
|
||||
#print str(SCREEN_W) + "x" + str(SCREEN_H)
|
||||
SIZE_BIN_X_1 = int(floor(SCREEN_W /4))
|
||||
SIZE_BIN_Y_1 = SIZE_BIN_X_1
|
||||
SIZE_BIN_1 = (SIZE_BIN_X_1,SIZE_BIN_Y_1)
|
||||
|
||||
SIZE_BIN_X_2 = SIZE_BIN_X_1/2
|
||||
SIZE_BIN_Y_2 = SIZE_BIN_X_2
|
||||
SIZE_BIN_2 = (SIZE_BIN_X_2,SIZE_BIN_Y_2)
|
||||
|
||||
SIZE_BIN_X_3 = SIZE_BIN_X_2
|
||||
SIZE_BIN_Y_3 = SIZE_BIN_X_3
|
||||
SIZE_BIN_3 = (SIZE_BIN_X_3,SIZE_BIN_Y_3)
|
||||
|
||||
##EMU CENTRE POSITION
|
||||
|
||||
WHERE_BIN_1_X=int(floor((SCREEN_W / 2)-(SIZE_BIN_X_1/2)))
|
||||
WHERE_BIN_1_Y=int(floor((SCREEN_H / 2) - (SIZE_BIN_X_1/2)))
|
||||
WHERE_BIN_1=(WHERE_BIN_1_X,WHERE_BIN_1_Y)
|
||||
|
||||
##EMU GAUCHE POSITION
|
||||
|
||||
WHERE_BIN_2_X=WHERE_BIN_1_X+(SIZE_BIN_X_2/2)
|
||||
WHERE_BIN_2_Y=SCREEN_H/8
|
||||
WHERE_BIN_2=(WHERE_BIN_2_X,WHERE_BIN_2_Y)
|
||||
|
||||
##EMU GAUCHE POSITION
|
||||
|
||||
WHERE_BIN_3_X=WHERE_BIN_2_X
|
||||
WHERE_BIN_3_Y=SCREEN_H-SIZE_BIN_Y_3-SCREEN_H/8
|
||||
|
||||
WHERE_BIN_3=(WHERE_BIN_3_X,WHERE_BIN_3_Y)
|
||||
|
||||
|
||||
return(SIZE_BIN_1,SIZE_BIN_2,SIZE_BIN_3,WHERE_BIN_1,WHERE_BIN_2,WHERE_BIN_3)
|
||||
|
||||
|
||||
@@ -0,0 +1,350 @@
|
||||
import pygame
|
||||
import sys
|
||||
import time
|
||||
import subprocess
|
||||
import os
|
||||
from pygame.locals import *
|
||||
from pygame import *
|
||||
from pygame import movie
|
||||
#from pygame.movie import *
|
||||
from DefFrontEndEmuMapFile import *
|
||||
from DefFrontEndEmuFile import *
|
||||
from ConfAllPath import *
|
||||
from DefFrontEndGameMapFile import DefFrontEndGameMap
|
||||
from DefLaunchSomethingFile import DefLaunchSomething
|
||||
from DefDownladPerGame import DownloadGraphical
|
||||
from DefCheckEnvFile import DefCheckEnv
|
||||
from KeyMapKeyBoard import *
|
||||
from time import gmtime, strftime
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def DefFrontEndGame(EmuChoose,Resolution,emu,li,CptGame,MAX_EMU,MAX,CptEmu,GamePerEmu,MaxForThisEmu,Orientation,JOY_TEST):
|
||||
|
||||
Sys=DefCheckEnv()[0]
|
||||
pygame.key.set_repeat(400, 70)
|
||||
# Orientation='X'
|
||||
ParentOfPyr,ConfRomFile,AllMedia,ConfigKeyboardFile=DefConfPathHome()
|
||||
|
||||
|
||||
|
||||
font_path,font_size,max_carac,WHERE_TEXTE,WHERE_TEXTE_X,WHERE_TEXTE_Y,SIZE_TEXTE_W,SIZE_TEXTE_H,SIZE_TEXTE,WHERE_WHEEL,WHERE_SYS,SIZE_WHEEL_CONVERT,WHERE_SNAP,SIZE_SNAP_CONVERT,SIZE_SYS_CONVERT,UNIT_L,UNIT_H=DefFrontEndGameMap(Resolution,Orientation)
|
||||
font = pygame.font.Font(font_path, font_size)
|
||||
ParentOfPyr,BinOfPyr,Wheel,Snap,Sound,Roms,Docs,ImgY,ImgX,Img,BlackImg,IMG_EMU=DefConfPathGame(Orientation)
|
||||
BeepFileGame=ParentOfPyr + "/MEDIA/SOUND/blip.wav"
|
||||
MyBip=pygame.mixer.Sound(BeepFileGame)
|
||||
pygame.init()
|
||||
PyrScreen = pygame.display.set_mode(Resolution,FULLSCREEN)
|
||||
if Orientation=='Y':
|
||||
|
||||
### TODO
|
||||
if (os.path.isfile(ImgY + EmuChoose + ".png")):
|
||||
Background=Img + "/black.png"
|
||||
else:
|
||||
Background=Img + "/black.png"
|
||||
### ODOT
|
||||
else:
|
||||
if (os.path.isfile(ImgX + EmuChoose + ".png")):
|
||||
Background=ImgX + EmuChoose + ".png"
|
||||
else:
|
||||
Background=Img + "/menu_X.png"
|
||||
fond = pygame.transform.scale(pygame.image.load(Background).convert(),Resolution)
|
||||
PyrScreen.blit(fond, (0,0))
|
||||
|
||||
|
||||
PyrScreen.blit(pygame.transform.scale(pygame.image.load(BlackImg).convert(),(SIZE_SNAP_CONVERT)),WHERE_SNAP)
|
||||
PyrScreen.blit(pygame.transform.scale(pygame.image.load(BlackImg).convert(),(SIZE_SYS_CONVERT)),WHERE_SYS)
|
||||
PyrScreen.blit(pygame.transform.scale(pygame.image.load(BlackImg).convert(),(SIZE_WHEEL_CONVERT)),WHERE_WHEEL)
|
||||
|
||||
|
||||
GameSnapPath=AllMedia+EmuChoose+ "/SNAP/" + GamePerEmu[CptGame][0]+".png"
|
||||
GameWheelPath=AllMedia+EmuChoose+ "/WHEEL/" + GamePerEmu[CptGame][0]+".png"
|
||||
GameSysPath=AllMedia + "/IMG/EMU/LOGO/" + EmuChoose +".png"
|
||||
GameDocPath=AllMedia+EmuChoose+ "/DOCS/" + GamePerEmu[CptGame][0]+".txt"
|
||||
GameVideoPath=AllMedia+EmuChoose+ "/VIDEO/" + GamePerEmu[CptGame][0]+".mpg"
|
||||
|
||||
|
||||
|
||||
|
||||
if (os.path.isfile(GameSysPath)):
|
||||
GameSys=pygame.transform.scale(pygame.image.load(GameSysPath).convert_alpha(),SIZE_SYS_CONVERT)
|
||||
else:
|
||||
GameSysPath=AllMedia+"/no_sys.png"
|
||||
GameSys=pygame.transform.scale(pygame.image.load(GameSysPath).convert_alpha(),SIZE_SYS_CONVERT)
|
||||
|
||||
|
||||
|
||||
|
||||
if (os.path.isfile(GameSnapPath)):
|
||||
GameSnap=pygame.transform.scale(pygame.image.load(GameSnapPath).convert_alpha(),SIZE_SNAP_CONVERT)
|
||||
else:
|
||||
GameSnapPath=AllMedia+"/no_snap.png"
|
||||
GameSnap=pygame.transform.scale(pygame.image.load(GameSnapPath).convert_alpha(),SIZE_SNAP_CONVERT)
|
||||
|
||||
|
||||
if (os.path.isfile(GameWheelPath)):
|
||||
GameWheel=pygame.transform.scale(pygame.image.load(GameWheelPath).convert_alpha(),SIZE_WHEEL_CONVERT)
|
||||
else:
|
||||
GameWheelPath=AllMedia+"/no_wheel.png"
|
||||
GameWheel=pygame.transform.scale(pygame.image.load(GameWheelPath).convert_alpha(),SIZE_WHEEL_CONVERT)
|
||||
FILE_INFO=AllMedia+EmuChoose+ "/DOCS/" + GamePerEmu[CptGame][0]+".txt"
|
||||
if os.path.isfile(FILE_INFO):
|
||||
FILE_DOC = open(FILE_INFO,"r")
|
||||
text1 = FILE_DOC.read()
|
||||
LPLUS=0
|
||||
LPLUS=LPLUS + (font_size+3)
|
||||
WHERE_TEXTE=(WHERE_TEXTE_X,WHERE_TEXTE_Y)
|
||||
PyrScreen.blit(pygame.transform.scale(pygame.image.load(BlackImg).convert(),(SIZE_TEXTE)),(WHERE_TEXTE))
|
||||
PyrScreen.blit(pygame.transform.scale(pygame.image.load(BlackImg).convert(),(SIZE_TEXTE)),WHERE_TEXTE)
|
||||
for ligne in text1.splitlines():
|
||||
ligne=ligne[0:max_carac]
|
||||
x,y = PyrScreen.blit(font.render(ligne,10,pygame.Color("red")),(WHERE_TEXTE_X,WHERE_TEXTE_Y+LPLUS)).bottomleft
|
||||
LPLUS=LPLUS + (font_size+1)
|
||||
if ((WHERE_TEXTE_Y + LPLUS) > (SIZE_TEXTE_H*3 +(UNIT_H*2))):
|
||||
break
|
||||
FILE_DOC.close()
|
||||
else:
|
||||
text1 = "No DATA File : " #+ GamePerEmu[CptGame][MAX_EMU][0]
|
||||
text2 = font.render(text1, True, pygame.Color("red"))
|
||||
PyrScreen.blit(pygame.transform.scale(pygame.image.load(BlackImg).convert(),(SIZE_TEXTE_W,SIZE_TEXTE_H)),((WHERE_TEXTE_X,WHERE_TEXTE_Y)))
|
||||
|
||||
PyrScreen.blit(pygame.transform.scale(pygame.image.load(BlackImg).convert(),(SIZE_TEXTE)),WHERE_TEXTE)
|
||||
PyrScreen.blit(text2,(WHERE_TEXTE_X,WHERE_TEXTE_Y+50)).bottomleft
|
||||
|
||||
|
||||
|
||||
|
||||
PyrScreen.blit(GameSnap,WHERE_SNAP)
|
||||
PyrScreen.blit(GameSys,WHERE_SYS)
|
||||
PyrScreen.blit(GameWheel,WHERE_WHEEL)
|
||||
pygame.display.flip()
|
||||
|
||||
|
||||
KeepInGame = 1
|
||||
FrontEndGame = 1
|
||||
ExitStatus = 0
|
||||
T1=0
|
||||
while KeepInGame == 1:
|
||||
|
||||
for event in pygame.event.get():
|
||||
#T1=(time.time())
|
||||
T1=strftime("%H%M%S", gmtime())
|
||||
|
||||
PyrScreen.blit(pygame.transform.scale(pygame.image.load(BlackImg).convert(),(SIZE_TEXTE)),WHERE_TEXTE)
|
||||
if JOY_TEST == 1 :
|
||||
if event.type == JOYAXISMOTION:
|
||||
if event.axis == 0 and event.value > 0:
|
||||
CptGame = CptGame + 1
|
||||
if event.axis == 0 and event.value < 0:
|
||||
CptGame = CptGame - 1
|
||||
if event.axis == 1 and event.value < 0:
|
||||
ROM_L1 = GamePerEmu[CptGame][0][0]
|
||||
ROM_L2 = ROM_L1
|
||||
while (ROM_L1 == ROM_L2):
|
||||
CptGame = CptGame + 1
|
||||
if CptGame >= MaxForThisEmu:
|
||||
CptGame=0
|
||||
break
|
||||
ROM_L1 = GamePerEmu[CptGame][0][0]
|
||||
if event.axis == 1 and event.value > 0:
|
||||
ROM_L1 = GamePerEmu[CptGame][0][0]
|
||||
ROM_L2 = ROM_L1
|
||||
while (ROM_L1 == ROM_L2):
|
||||
CptGame = CptGame - 1
|
||||
if CptGame <= -MaxForThisEmu:
|
||||
CptGame=0
|
||||
break
|
||||
ROM_L1 = GamePerEmu[CptGame][0][0]
|
||||
if event.type == JOYBUTTONDOWN:
|
||||
if event.button == BTN_J1_2:
|
||||
FrontEndGame = 0
|
||||
ExitStatus = 0
|
||||
KeepInGame = 0
|
||||
FrontEndEmu = 1
|
||||
CptEmu = 0
|
||||
if event.button == BTN_J1_1:
|
||||
FrontEndGame = 0
|
||||
FrontEndGame = 1
|
||||
ExitStatus = 0
|
||||
KeepInGame= 1
|
||||
FrontEndEmu = 0
|
||||
GameChoose = GamePerEmu[CptGame][0]
|
||||
DefLaunchSomething(EmuChoose,GameChoose,AllMedia,font,Resolution,BlackImg,WHERE_TEXTE,SIZE_TEXTE,Background,Orientation)
|
||||
pygame.mixer.Sound(BeepFileGame).play()
|
||||
|
||||
if JOY_TEST == 0 :
|
||||
if event.type == KEYDOWN:
|
||||
if event.key == LEFT_J1:
|
||||
# if event.key == K_LEFT:
|
||||
CptGame = CptGame - 1
|
||||
# if event.key == K_RIGHT:
|
||||
if event.key == RIGHT_J1:
|
||||
CptGame = CptGame + 1
|
||||
# if event.key == K_UP:
|
||||
if event.key == UP_J1:
|
||||
ROM_L1 = GamePerEmu[CptGame][0][0]
|
||||
ROM_L2 = ROM_L1
|
||||
while (ROM_L1 == ROM_L2):
|
||||
CptGame = CptGame + 1
|
||||
if CptGame >= MaxForThisEmu:
|
||||
CptGame=0
|
||||
break
|
||||
ROM_L1 = GamePerEmu[CptGame][0][0]
|
||||
if event.key == DOWN_J1:
|
||||
# if event.key == K_DOWN:
|
||||
ROM_L1 = GamePerEmu[CptGame][0][0]
|
||||
ROM_L2 = ROM_L1
|
||||
while (ROM_L1 == ROM_L2):
|
||||
CptGame = CptGame - 1
|
||||
if CptGame <= -MaxForThisEmu:
|
||||
CptGame=0
|
||||
break
|
||||
ROM_L1 = GamePerEmu[CptGame][0][0]
|
||||
# LAUNCH GAME
|
||||
if event.key == BTN_J1_1:
|
||||
# if event.key == K_d:
|
||||
FrontEndGame = 1
|
||||
ExitStatus = 0
|
||||
KeepInGame= 1
|
||||
FrontEndEmu = 0
|
||||
GameChoose = GamePerEmu[CptGame][0]
|
||||
DefLaunchSomething(EmuChoose,GameChoose,AllMedia,font,Resolution,BlackImg,WHERE_TEXTE,SIZE_TEXTE,Background,Orientation)
|
||||
|
||||
|
||||
###################################################
|
||||
# DOWNLAOD MEDIA
|
||||
# if event.key == K_f:
|
||||
if event.key == BTN_J1_3:
|
||||
T1=0
|
||||
T2=0
|
||||
|
||||
DownloadGraphical(EmuChoose, GamePerEmu[CptGame][0])
|
||||
|
||||
PyrScreen.blit(fond, (0,0))
|
||||
|
||||
T1=0
|
||||
T2=0
|
||||
###################################################
|
||||
# ESCAPE (keyboard only)
|
||||
if event.key == K_ESCAPE:
|
||||
FrontEndGame = 0
|
||||
ExitStatus = 1
|
||||
KeepInGame=0
|
||||
FrontEndEmu = 0
|
||||
# Back to Emu Selector
|
||||
if event.key == BTN_J1_2:
|
||||
# if event.key == K_e:
|
||||
FrontEndGame = 0
|
||||
ExitStatus = 0
|
||||
KeepInGame = 0
|
||||
FrontEndEmu = 1
|
||||
CptEmu = 0
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
pygame.mixer.Sound(BeepFileGame).play()
|
||||
|
||||
|
||||
if CptGame >= MaxForThisEmu:
|
||||
CptGame = -MaxForThisEmu
|
||||
|
||||
if CptGame < -MaxForThisEmu:
|
||||
CptGame = MaxForThisEmu -1
|
||||
if MaxForThisEmu == 1:
|
||||
CptGame = 0
|
||||
GameSnapPath=AllMedia+EmuChoose+ "/SNAP/" + GamePerEmu[CptGame][0]+".png"
|
||||
if (os.path.isfile(GameSnapPath)):
|
||||
GameSnap=pygame.transform.scale(pygame.image.load(GameSnapPath).convert_alpha(),SIZE_SNAP_CONVERT)
|
||||
else:
|
||||
GameSnapPath=AllMedia+"/no_snap.png"
|
||||
GameWheelPath=AllMedia+EmuChoose+ "/WHEEL/" + GamePerEmu[CptGame][0]+".png"
|
||||
if (os.path.isfile(GameWheelPath)):
|
||||
GameWheel=pygame.transform.scale(pygame.image.load(GameWheelPath).convert_alpha(),SIZE_WHEEL_CONVERT)
|
||||
else:
|
||||
GameWheelPath=AllMedia+"/no_wheel.png"
|
||||
GameWheel=pygame.transform.scale(pygame.image.load(GameWheelPath).convert_alpha(),SIZE_WHEEL_CONVERT)
|
||||
|
||||
|
||||
GameSnap=pygame.transform.scale(pygame.image.load(GameSnapPath).convert_alpha(),SIZE_SNAP_CONVERT)
|
||||
|
||||
FILE_INFO=AllMedia+EmuChoose+ "/DOCS/" + GamePerEmu[CptGame][0]+".txt"
|
||||
if os.path.isfile(FILE_INFO):
|
||||
FILE_DOC = open(FILE_INFO,"r")
|
||||
text1 = FILE_DOC.read()
|
||||
LPLUS=0
|
||||
LPLUS=LPLUS + (font_size+3)
|
||||
WHERE_TEXTE=(WHERE_TEXTE_X,WHERE_TEXTE_Y)
|
||||
PyrScreen.blit(pygame.transform.scale(pygame.image.load(BlackImg).convert(),(SIZE_TEXTE)),(WHERE_TEXTE))
|
||||
PyrScreen.blit(pygame.transform.scale(pygame.image.load(BlackImg).convert(),(SIZE_TEXTE)),WHERE_TEXTE)
|
||||
for ligne in text1.splitlines():
|
||||
ligne=ligne[0:max_carac]
|
||||
x,y = PyrScreen.blit(font.render(ligne,1,pygame.Color("red")),(WHERE_TEXTE_X,WHERE_TEXTE_Y+LPLUS)).bottomleft
|
||||
LPLUS=LPLUS + (font_size+1)
|
||||
if ((WHERE_TEXTE_Y + LPLUS) > (SIZE_TEXTE_H*3 +(UNIT_H*2))):
|
||||
break
|
||||
|
||||
FILE_DOC.close()
|
||||
else:
|
||||
text1 = "No DATA File : " + GamePerEmu[CptGame][0]
|
||||
text2 = font.render(text1, True, pygame.Color("red"))
|
||||
PyrScreen.blit(pygame.transform.scale(pygame.image.load(BlackImg).convert(),(SIZE_TEXTE_W,SIZE_TEXTE_H)),((WHERE_TEXTE_X,WHERE_TEXTE_Y)))
|
||||
|
||||
PyrScreen.blit(pygame.transform.scale(pygame.image.load(BlackImg).convert(),(SIZE_TEXTE)),WHERE_TEXTE)
|
||||
PyrScreen.blit(text2,(WHERE_TEXTE_X,WHERE_TEXTE_Y+50)).bottomleft
|
||||
|
||||
|
||||
|
||||
PyrScreen.blit(pygame.transform.scale(pygame.image.load(BlackImg).convert(),(SIZE_SNAP_CONVERT)),WHERE_SNAP)
|
||||
PyrScreen.blit(pygame.transform.scale(pygame.image.load(BlackImg).convert(),(SIZE_SYS_CONVERT)),WHERE_SYS)
|
||||
PyrScreen.blit(pygame.transform.scale(pygame.image.load(BlackImg).convert(),(SIZE_WHEEL_CONVERT)),WHERE_WHEEL)
|
||||
|
||||
|
||||
PyrScreen.blit(GameSnap,WHERE_SNAP)
|
||||
PyrScreen.blit(GameSys,WHERE_SYS)
|
||||
PyrScreen.blit(GameWheel,WHERE_WHEEL)
|
||||
|
||||
if T1 == 0:
|
||||
T1=strftime("%H%M%S", gmtime())
|
||||
TDiff=int(strftime("%H%M%S", gmtime())) - int(T1)
|
||||
GameVideoPath=AllMedia+EmuChoose+ "/VIDEO/" + GamePerEmu[CptGame][0]+".mpg"
|
||||
|
||||
|
||||
if os.path.isfile(GameVideoPath):
|
||||
if TDiff > 2 and Sys != "Darwin":
|
||||
|
||||
FPS = 60
|
||||
|
||||
pygame.mixer.quit()
|
||||
|
||||
movie = pygame.movie.Movie(GameVideoPath)
|
||||
movie.set_volume(0.8)
|
||||
|
||||
#VIDE FULLSCREEN
|
||||
#mrect = pygame.Rect((0,0),Resolution)
|
||||
|
||||
mrect = pygame.Rect(WHERE_SNAP,SIZE_SNAP_CONVERT)
|
||||
movie.set_display(PyrScreen,mrect)
|
||||
|
||||
|
||||
movie.play()
|
||||
|
||||
while movie.get_busy():
|
||||
evt = pygame.event.wait()
|
||||
if any( [ evt.type == JOYAXISMOTION,evt.type == JOYBUTTONDOWN, evt.type == QUIT,evt.type == KEYDOWN] ):
|
||||
T1=0
|
||||
T2=0
|
||||
movie.stop()
|
||||
movie=None
|
||||
pygame.mixer.init()
|
||||
break
|
||||
pygame.display.flip()
|
||||
pygame.display.flip()
|
||||
return FrontEndGame,ExitStatus,FrontEndEmu,CptEmu
|
||||
@@ -0,0 +1,84 @@
|
||||
from math import *
|
||||
|
||||
|
||||
def DefFrontEndGameMap(resolution,Orientation):
|
||||
|
||||
if Orientation == "Y":
|
||||
SCREEN_W,SCREEN_H=resolution
|
||||
SIZE_SNAP_CONVERT_W = int(floor(SCREEN_W / 3))
|
||||
SIZE_SNAP_CONVERT_H = int(floor(SCREEN_H / 5))
|
||||
SIZE_SNAP_CONVERT=(SIZE_SNAP_CONVERT_W,SIZE_SNAP_CONVERT_H)
|
||||
SIZE_WHEEL_CONVERT_W = SIZE_SNAP_CONVERT_W
|
||||
SIZE_WHEEL_CONVERT_H = int(floor(SIZE_WHEEL_CONVERT_W / 4))
|
||||
SIZE_WHEEL_CONVERT=(SIZE_WHEEL_CONVERT_W,SIZE_WHEEL_CONVERT_H)
|
||||
WHERE_WHEEL_X = SIZE_WHEEL_CONVERT_W
|
||||
WHERE_WHEEL_Y = int(floor(SCREEN_H / 10))
|
||||
WHERE_WHEEL=(WHERE_WHEEL_X,WHERE_WHEEL_Y)
|
||||
WHERE_SNAP_X = SIZE_WHEEL_CONVERT_W
|
||||
WHERE_SNAP_Y = WHERE_WHEEL_Y + SIZE_WHEEL_CONVERT_H + SEPARATION_WHEEL_SNAP
|
||||
WHERE_SNAP=(WHERE_SNAP_X,WHERE_SNAP_Y)
|
||||
WHERE_TEXTE_X = WHERE_WHEEL_X
|
||||
WHERE_TEXTE_Y = int(floor(SCREEN_H / 2))
|
||||
SIZE_TEXTE_W = SIZE_SNAP_CONVERT_W
|
||||
SIZE_TEXTE_H = int(floor(SIZE_SNAP_CONVERT_H))
|
||||
WHERE_TEXTE=(WHERE_TEXTE_X,WHERE_TEXTE_Y)
|
||||
SIZE_TEXTE = (SIZE_TEXTE_W,SIZE_TEXTE_H)
|
||||
font_path = "./MEDIA/font.ttf"
|
||||
max_carac = 50
|
||||
font_path = "./MEDIA/font.ttf"
|
||||
max_carac = 30
|
||||
font_size=int(round(floor(SIZE_TEXTE_W / max_carac)))
|
||||
|
||||
# font_size = 20
|
||||
|
||||
|
||||
else:
|
||||
SCREEN_W,SCREEN_H=resolution
|
||||
UNIT_H=int(floor(SCREEN_H/20))
|
||||
UNIT_L=int(floor(SCREEN_W/30))
|
||||
|
||||
|
||||
######### SNAP ########
|
||||
SIZE_SNAP_CONVERT_W = (int(floor((SCREEN_W / 2)-((UNIT_L + UNIT_L/2)))))
|
||||
SIZE_SNAP_CONVERT_H = int(floor(SCREEN_H - (UNIT_H*2 + UNIT_H/2 )))
|
||||
SIZE_SNAP_CONVERT=(SIZE_SNAP_CONVERT_W,SIZE_SNAP_CONVERT_H)
|
||||
WHERE_SNAP_X = int(floor(((SCREEN_W / 2) + (UNIT_L/2))))
|
||||
WHERE_SNAP_Y = UNIT_H
|
||||
WHERE_SNAP=(WHERE_SNAP_X,WHERE_SNAP_Y)
|
||||
|
||||
######### WHEEL ########
|
||||
SIZE_WHEEL_CONVERT_W = SIZE_SNAP_CONVERT_W
|
||||
SIZE_WHEEL_CONVERT_H = int(floor((SCREEN_H /3)-( UNIT_H + UNIT_H/2) ))
|
||||
SIZE_WHEEL_CONVERT=(SIZE_WHEEL_CONVERT_W,SIZE_WHEEL_CONVERT_H)
|
||||
WHERE_WHEEL_X = UNIT_L
|
||||
WHERE_WHEEL_Y = SIZE_WHEEL_CONVERT_H + (UNIT_H * 2)
|
||||
WHERE_WHEEL = (WHERE_WHEEL_X,WHERE_WHEEL_Y)
|
||||
|
||||
########## SYS #########
|
||||
SIZE_SYS_W = SIZE_WHEEL_CONVERT_W
|
||||
SIZE_SYS_H = SIZE_WHEEL_CONVERT_H
|
||||
SIZE_SYS_CONVERT= (SIZE_SYS_W,SIZE_SYS_H)
|
||||
WHERE_SYS_X = UNIT_L
|
||||
WHERE_SYS_Y = UNIT_H
|
||||
WHERE_SYS=(WHERE_SYS_X,WHERE_SYS_Y)
|
||||
|
||||
######### TEXTE ########
|
||||
SIZE_TEXTE_W = SIZE_WHEEL_CONVERT_W
|
||||
SIZE_TEXTE_H = SIZE_WHEEL_CONVERT_H
|
||||
SIZE_TEXTE = (SIZE_TEXTE_W,SIZE_TEXTE_H)
|
||||
WHERE_TEXTE_X = UNIT_L
|
||||
WHERE_TEXTE_Y = (SIZE_WHEEL_CONVERT_H * 2) + (UNIT_H * 3)
|
||||
WHERE_TEXTE=(WHERE_TEXTE_X,WHERE_TEXTE_Y)
|
||||
|
||||
|
||||
|
||||
|
||||
font_path = "./MEDIA/font.ttf"
|
||||
max_carac = 54
|
||||
max_carac = int(floor((SCREEN_W/10) -( SCREEN_W/10 * 2/3)))
|
||||
font_size=int(round(floor((SIZE_TEXTE_W / max_carac))*2))
|
||||
#font_size = 35
|
||||
|
||||
|
||||
return font_path,font_size,max_carac,WHERE_TEXTE,WHERE_TEXTE_X,WHERE_TEXTE_Y,SIZE_TEXTE_W,SIZE_TEXTE_H,SIZE_TEXTE,WHERE_WHEEL,WHERE_SYS,SIZE_WHEEL_CONVERT,WHERE_SNAP,SIZE_SNAP_CONVERT,SIZE_SYS_CONVERT,UNIT_L,UNIT_H
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
def DefFrontEndGameReadDocs (Resolution,emu,MapingEmu,li,CptEmu,MAX_EMU,MAX):
|
||||
|
||||
|
||||
if os.path.isfile(FILE_INFO):
|
||||
FILE_DOC = open(FILE_INFO,"r")
|
||||
text1 = FILE_DOC.read()
|
||||
LPLUS=0
|
||||
LPLUS=LPLUS + (font_size+5)
|
||||
WHERE_TEXTE=(WHERE_TEXTE_X,WHERE_TEXTE_Y)
|
||||
fenetre.blit(pygame.transform.scale(pygame.image.load(BLACK).convert(),(SIZE_TEXTE)),(WHERE_TEXTE))
|
||||
for ligne in text1.splitlines():
|
||||
ligne=ligne[0:max_carac]
|
||||
x,y = fenetre.blit(font.render(ligne,5,pygame.Color("white")),(WHERE_TEXTE_X,WHERE_TEXTE_Y+LPLUS)).bottomleft
|
||||
LPLUS=LPLUS + (font_size+5)
|
||||
FILE_DOC.close()
|
||||
else:
|
||||
text1 = "No DATA File : " + li[CPT][0]
|
||||
text2 = font.render(text1, True, pygame.Color("white"))
|
||||
fenetre.blit(pygame.transform.scale(pygame.image.load(BLACK).convert(),(SIZE_TEXTE_W,SIZE_TEXTE_H)),((WHERE_TEXTE_X,WHERE_TEXTE_Y)))
|
||||
fenetre.blit(text2,(WHERE_TEXTE_X,WHERE_TEXTE_Y+50)).bottomleft
|
||||
# if not (os.path.isfile(IMG_WHEEL)):
|
||||
# IMG_WHEEL = SNAP_AND_WHEEL + "no_wheel.png"
|
||||
# if not (os.path.isfile(IMG_SNAP)):
|
||||
# IMG_SNAP = SNAP_AND_WHEEL + "no_snap.png"
|
||||
@@ -0,0 +1,44 @@
|
||||
import os
|
||||
import glob
|
||||
import pygame
|
||||
import subprocess
|
||||
import sys
|
||||
def DefLaunchSomething(EmuChoose,GameChoose,AllMedia,font,Resolution,BlackImg,WHERE_TEXTE,SIZE_TEXTE,Background,Orientation):
|
||||
PyrScreen = pygame.display.set_mode(Resolution)
|
||||
WHERE_TEXTE_W,WHERE_TEXTE_Y=WHERE_TEXTE
|
||||
fond = pygame.transform.scale(pygame.image.load(Background).convert(),Resolution)
|
||||
PyrScreen.blit(fond, (0,0))
|
||||
PyrScreen.blit(pygame.transform.scale(pygame.image.load(BlackImg).convert(),(SIZE_TEXTE)),(WHERE_TEXTE))
|
||||
|
||||
PathOfGame=AllMedia+EmuChoose+"/ROMS/"
|
||||
GameChooseJoker=GameChoose + ".*"
|
||||
FullPathJoker=glob.glob(os.path.join(PathOfGame, GameChooseJoker))
|
||||
PathOfBin=AllMedia + "../BIN/"
|
||||
BinCooseJoker=PathOfBin + EmuChoose +".*"
|
||||
FullPathJokerBin=glob.glob(os.path.join(PathOfBin, BinCooseJoker))
|
||||
if FullPathJokerBin:
|
||||
BinFullPathJoker=FullPathJokerBin[0]
|
||||
if EmuChoose == "SYS":
|
||||
##print "EmuChoose: " + EmuChoose + " | GameChoose : " + GameChoose
|
||||
APP=BinFullPathJoker + " " + GameChoose + " " + Orientation
|
||||
p = subprocess.Popen(APP, shell=True)
|
||||
sys.exit("GO play bitch ;)")
|
||||
else:
|
||||
if FullPathJoker:
|
||||
GameFullPathJoker=FullPathJoker[0]
|
||||
else:
|
||||
GameFullPathJoker="xxxxxxxxxxxxxxxxxxxxx"
|
||||
if (os.path.isfile(GameFullPathJoker)):
|
||||
##print "EmuChoose: " + EmuChoose + " | GameChoose : " + GameChoose
|
||||
APP="BIN/" + EmuChoose +".sh" + " " + GameChoose + " " + Orientation
|
||||
p = subprocess.Popen(APP, shell=True)
|
||||
sys.exit("GO play bitch ;)")
|
||||
|
||||
else:
|
||||
##print "Roms " + GameChoose + " NOT FOUND " + AllMedia+EmuChoose + "/ROMS/"
|
||||
text1 = "Roms " + GameChoose + " NOT FOUND"
|
||||
text2 = font.render(text1, True, pygame.Color("white"))
|
||||
PyrScreen.blit(pygame.transform.scale(pygame.image.load(BlackImg).convert(),(SIZE_TEXTE)),((WHERE_TEXTE)))
|
||||
PyrScreen.blit(text2,(WHERE_TEXTE_W,WHERE_TEXTE_Y)).bottomleft
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
#COMPTEUR et lecture du fichier conf
|
||||
import csv
|
||||
def DefReadConfGame(rom_config_file,EmuChoose,li):
|
||||
GamePerEmu = []
|
||||
MaxForThisEmu = 0
|
||||
for row2 in li:
|
||||
GameListe,EmuListe=row2
|
||||
if EmuListe == EmuChoose:
|
||||
GamePerEmu.append(row2)
|
||||
MaxForThisEmu=MaxForThisEmu+1
|
||||
def getKey(item):
|
||||
return item[0]
|
||||
sorted(GamePerEmu, key=getKey)
|
||||
GamePerEmu
|
||||
return GamePerEmu,MaxForThisEmu
|
||||
@@ -0,0 +1,24 @@
|
||||
#COMPTEUR et lecture du fichier conf
|
||||
import csv
|
||||
def DefReadConfRom(rom_config_file):
|
||||
reader = csv.reader(open(rom_config_file),delimiter=',')
|
||||
li = []
|
||||
emu = []
|
||||
GamePerEmu = []
|
||||
MAX = 0
|
||||
MAX_EMU = 0
|
||||
|
||||
for row in reader:
|
||||
if row:
|
||||
li.append(row)
|
||||
if not (li[MAX][1] in emu):
|
||||
emu.append(li[MAX][1])
|
||||
MAX_EMU=MAX_EMU +1
|
||||
|
||||
MAX = MAX +1
|
||||
def getKey(item):
|
||||
return item[1]
|
||||
sorted(li, key=getKey)
|
||||
|
||||
#return {'MAX':MAX, 'MAX_EMU':MAX_EMU,'li':li,'emu':emu}
|
||||
return MAX,MAX_EMU,li,emu
|
||||
@@ -0,0 +1,16 @@
|
||||
import pygame
|
||||
import subprocess
|
||||
|
||||
def DefResolution():
|
||||
screen = pygame.display.set_mode((0,0))
|
||||
screen.fill((0,0,180))
|
||||
size = screen.get_rect()
|
||||
SCREEN_W = size[2]
|
||||
SCREEN_H = size[3]
|
||||
return SCREEN_W,SCREEN_H
|
||||
#return 1280,1024
|
||||
|
||||
def DefSystem():
|
||||
p = subprocess.check_output(['uname'])
|
||||
sys_check = p.strip()
|
||||
return sys_check
|
||||
@@ -0,0 +1,39 @@
|
||||
import pygame
|
||||
import sys
|
||||
import time
|
||||
import subprocess
|
||||
import os
|
||||
from pygame.locals import *
|
||||
from DefFrontEndEmuMapFile import *
|
||||
from DefFrontEndEmuFile import *
|
||||
from ConfAllPath import *
|
||||
from DefFrontEndGameMapFile import DefFrontEndGameMap
|
||||
from DefLaunchSomethingFile import DefLaunchSomething
|
||||
from DefDownladPerGame import DownloadGraphical
|
||||
from DefCheckEnvFile import DefCheckEnv
|
||||
|
||||
|
||||
|
||||
def Transition(Resolution,emu,MapingEmu,li,CptEmu,MAX_EMU,MAX,Orientation):
|
||||
PyrScreen = pygame.display.set_mode(Resolution,FULLSCREEN)
|
||||
pygame.mixer.quit()
|
||||
movie = pygame.movie.Movie('MEDIA/boom.mpg')
|
||||
movie.set_volume(0.8)
|
||||
|
||||
#VIDE FULLSCREEN
|
||||
mrect = pygame.Rect((0,0),Resolution)
|
||||
|
||||
#mrect = pygame.Rect(WHERE_SNAP,SIZE_SNAP_CONVERT)
|
||||
movie.set_display(PyrScreen,mrect)
|
||||
movie.play()
|
||||
while movie.get_busy():
|
||||
evt = pygame.event.wait()
|
||||
if any( [ evt.type == JOYAXISMOTION,evt.type == JOYBUTTONDOWN, evt.type == QUIT,evt.type == KEYDOWN] ):
|
||||
T1=0
|
||||
T2=0
|
||||
movie.stop()
|
||||
movie=None
|
||||
pygame.mixer.init()
|
||||
break
|
||||
pygame.display.flip()
|
||||
|
||||
Reference in New Issue
Block a user