Commit 0ce57bd9 authored by ezechiel's avatar ezechiel

fix bug favorite IP address, add autoboot file

parent ef6aa700
###
# Script by Ezechiel
# Date : 2019/xx/xx
# Description : PiDimTouch button
# Date : 2019/05/26
# Description : PiDimBoot button
###
#Write Text on screen
......
###
# Script by Ezechiel
# Date : 2019/xx/xx
# Description : PiDimTouch constantes
# Date : 2019/05/26
# Description : PiDimBoot constantes
###
#Dir
ROM_DIR = '/boot/pidimtouch/roms/'
VIDEO_DIR = '/boot/pidimtouch/video/'
IMAGE_DIR = '/boot/pidimtouch/img/'
ROM_DIR = '/boot/pidimboot/roms/'
VIDEO_DIR = '/boot/pidimboot/video/'
IMAGE_DIR = '/boot/pidimboot/img/'
IMAGE_GAME_DIR = '/opt/pidimboot/img/games/'
AUTOBOOT_DIR = '/boot/pidimboot/autoboot.txt'
#Database
DATABASE = '/opt/pidimboot/database/pidimboot.db'
......@@ -35,6 +36,7 @@ SETTING_IMG = '/opt/pidimboot/img/src/setting.jpg'
LOGO_NAOMI = '/opt/pidimboot/img/src/naomi_small_logo.png'
LOGO_CHIHIRO = '/opt/pidimboot/img/src/chihiro_small_logo.png'
LOGO_TRIFORCE = '/opt/pidimboot/img/src/Triforce_small_logo.png'
BACKGROUND_WHITE = '/opt/pidimboot/img/src/background_white.jpg'
BACKGROUND_NOGAME = '/opt/pidimboot/img/src/background_no_game.jpg'
BACKGROUND_ATOMISWAVE = '/opt/pidimboot/img/src/background_atomiswave.jpg'
BACKGROUND_NAOMI = '/opt/pidimboot/img/src/background_naomi.jpg'
......
###
# Script by Ezechiel
# Date : 2019/xx/xx
# Description : PiDimTouch
# Date : 2019/05/26
# Description : PiDimBoot Gamelist
###
from const import *
GAMES_TYPES = [FIGHTING, ACTION, SPORT, HORI_SHOOTEMUP, VERT_SHOOTEMUP, PUZZLE, VARIOUS, RACING, SHOOTER]
GAMES_SYSTEMS = [ATOMISWAVE, NAOMI1, NAOMI2, CHIHIRO, TRIFORCE]
......
###
# Script by Ezechiel
# Date : 2019/xx/xx
# Description : PiDimTouch interaction
# Date : 2019/05/26
# Description : PiDimBoot interaction
###
import os , time, subprocess
......
###
# Script by Ezechiel
# Date : 2019/xx/xx
# Description : PiDimTouch
# Date : 2019/05/26
# Description : PiDimBoot
###
import pygame, os
......@@ -27,41 +27,73 @@ database = Database()
#start pygame
pygame.init()
pygame.mouse.set_visible(True)
pygame.mouse.set_visible(False)
screen = pygame.display.set_mode((480,320))
img_bg = pygame.image.load(MAIN_IMG).convert() #background img loaded
navigation = 'HOME' #start nav menu
while True:
navigation = Interaction().interaction(navigation, pygame)
#homepage interface
if navigation == 'HOME':
screen.blit(img_bg,(0,0)) #apply background
#Autoboot Rom
autoboot = False
file_autoboot = open(AUTOBOOT_DIR, "r")
value_autoboot = file_autoboot.readline()
value_autoboot = value_autoboot.replace(' ', '')
value_autoboot = value_autoboot.replace('\n', '')
file_autoboot.close
createButton(pygame, screen, BUTTON_BIG_BLUE, STARCRAFT_TTF, "SYSTEM", 30, 160, 130 , WHITE)
createButton(pygame, screen, BUTTON_BIG_BLUE, STARCRAFT_TTF, "FAVORITE", 28, 160, 200 , WHITE)
createButton(pygame, screen, BUTTON_BIG_BLUE, STARCRAFT_TTF, "SETTING", 30, 160, 270 , WHITE)
createButton(pygame, screen, BUTTON_POWEROFF, STARCRAFT_TTF, "", 30, 410, 255 , WHITE, 0, 0)
#System interface
if navigation == 'SYSTEM':
system = System()
system.createInterface(pygame, screen)
if len(value_autoboot) > 3:
if os.path.isfile(ROM_DIR + value_autoboot):
autoboot = True
while True:
if autoboot:
img_tmp = pygame.image.load(BACKGROUND_WHITE).convert()
screen.blit(img_tmp, (0,0))
#Favorite interface
if navigation == 'FAVORITE':
fontLabel(pygame, screen, STARCRAFT_TTF, "Autoboot", 50, 35, 120, RED)
fontLabel(pygame, screen, STARCRAFT_TTF, "Wait don't touch screen", 20, 15, 200, RED)
pygame.display.flip() #refresh screen
system = System()
system.createFavoriteInterface(pygame, screen)
system.setCurrentGame(value_autoboot)
system.setAutoboot(True)
system.sendingGame
system.setAutoboot(False)
#setting interface
if navigation == 'SETTINGS':
setting = Setting()
setting.createInterface(pygame, screen)
sleep(2)
else :
navigation = Interaction().interaction(navigation, pygame)
#homepage interface
if navigation == 'HOME':
screen.blit(img_bg,(0,0)) #apply background
createButton(pygame, screen, BUTTON_BIG_BLUE, STARCRAFT_TTF, "SYSTEM", 30, 160, 130 , WHITE)
createButton(pygame, screen, BUTTON_BIG_BLUE, STARCRAFT_TTF, "FAVORITE", 28, 160, 200 , WHITE)
createButton(pygame, screen, BUTTON_BIG_BLUE, STARCRAFT_TTF, "SETTING", 30, 160, 270 , WHITE)
createButton(pygame, screen, BUTTON_POWEROFF, STARCRAFT_TTF, "", 30, 410, 255 , WHITE, 0, 0)
#System interface
if navigation == 'SYSTEM':
system = System()
system.createInterface(pygame, screen)
#Favorite interface
if navigation == 'FAVORITE':
system = System()
system.createFavoriteInterface(pygame, screen)
#setting interface
if navigation == 'SETTINGS':
setting = Setting()
setting.createInterface(pygame, screen)
pygame.display.flip() #refresh screen
if not autoboot:
pygame.event.wait()
else:
autoboot = False
pygame.display.flip() #refresh screen
pygame.event.wait()
sleep(0.2)
\ No newline at end of file
###
# Script by Ezechiel
# Date : 2019/xx/xx
# Description : PiDimTouch settings
# Date : 2019/05/26
# Description : PiDimBoot settings
###
import time, os
......
###
# Script by Ezechiel
# Date : 2019/xx/xx
# Description : PiDimTouch
# Date : 2019/05/26
# Description : PiDimBoot
###
import os, triforcetools, time
......@@ -26,6 +26,8 @@ class System(object):
pygame = None
screen = None
autoboot = False
display_interface_game = False
display_genre = False
display_prevnext = False
......@@ -55,6 +57,7 @@ class System(object):
game_description = ""
game_editor = ""
game_genre = ""
game_button = ""
list_allGame_Atomisware = []
list_allgenre_Atomisware = []
......@@ -114,33 +117,7 @@ class System(object):
self.countSystemPresent
if self.count_system > 0:
self.system.sort()
# print("ATOMISWARE")
# print(self.list_allGame_Atomisware)
# print(self.list_allgenre_Atomisware)
# print(self.dict_GenreGame_Atomisware)
print("Naomi")
print(self.list_allGame_Naomi)
print(self.list_allgenre_Naomi)
print(self.dict_GenreGame_Naomi)
# print("Naomi2")
# print(self.list_allGame_Naomi2)
# print(self.list_allgenre_Naomi2)
# print(self.dict_GenreGame_Naomi2)
#
# print("Trifoce")
# print(self.list_allGame_Triforce)
# print(self.list_allgenre_Triforce)
# print(self.dict_GenreGame_Triforce)
#
# print("Chihiro")
# print(self.list_allGame_Chihiro)
# print(self.list_allgenre_Chihiro)
# print(self.dict_GenreGame_Chihiro)
#
#Generate list games by system
def sortExistRomsSystem(self, system):
......@@ -201,6 +178,11 @@ class System(object):
return respond
#set Current Game
def setCurrentGame(self, name_game):
self.current_game = name_game
#Add Game to Favorite Inteface
@property
def addFavorite(self):
......@@ -398,7 +380,6 @@ class System(object):
self.getInterfaceAllGames(self.list_allgenre_Atomisware)
elif self.sub_navigation == "genre_NAOMI":
print(self.dict_GenreGame_Naomi[self.current_genre])
self.getInterfaceAllGames(self.dict_GenreGame_Naomi[self.current_genre])
elif self.sub_navigation == "genre_NAOMI2":
......@@ -498,8 +479,8 @@ class System(object):
fontLabel(self.pygame, self.screen, None, "Genre :", 16, 20, 230, WHITE)
fontLabel(self.pygame, self.screen, None, self.game_genre, 16, 60, 230, WHITE)
fontLabel(self.pygame, self.screen, None, "Players :", 16, 150, 230, WHITE)
fontLabel(self.pygame, self.screen, None, self.game_player, 16, 200, 230, WHITE)
fontLabel(self.pygame, self.screen, None, "Players :", 16, 160, 230, WHITE)
fontLabel(self.pygame, self.screen, None, self.game_player, 16, 210, 230, WHITE)
fontLabel(self.pygame, self.screen, None, "Editor :", 16, 290, 230, WHITE)
fontLabel(self.pygame, self.screen, None, self.game_editor, 16, 340, 230, WHITE)
......@@ -507,6 +488,9 @@ class System(object):
fontLabel(self.pygame, self.screen, None, "System :", 16, 20, 260, WHITE)
fontLabel(self.pygame, self.screen, None, self.game_system, 16, 70, 260, WHITE)
fontLabel(self.pygame, self.screen, None, "Buttons :", 16, 140, 260, WHITE)
fontLabel(self.pygame, self.screen, None, self.game_button, 16, 195, 260, WHITE)
#button
if self.sub_navigation != "Favorite":
if self.getFavorite:
......@@ -588,6 +572,7 @@ class System(object):
self.game_description = req[5]
self.game_editor = req[6]
self.game_genre = req[7]
self.game_button = req[8]
else:
self.game_title = "No Information"
self.game_player = "No Information"
......@@ -595,6 +580,7 @@ class System(object):
self.game_description = "No Information"
self.game_editor = "No Information"
self.game_genre = "No Information"
self.game_button = "No Information"
#create covers games
......@@ -683,41 +669,65 @@ class System(object):
return self.display_prevnext
#Define True or False value for autoboot
def setAutoboot(self, value):
self.autoboot = value
#Send Game to Netdimm
@property
def sendingGame(self):
fontLabel(self.pygame, self.screen, MEGADRIVE_TTF, "SENDING...", 40, 20, 140, RED)
self.pygame.display.flip()
if not self.autoboot:
fontLabel(self.pygame, self.screen, MEGADRIVE_TTF, "SENDING...", 40, 20, 140, RED)
self.pygame.display.flip()
ip_value =(self.database.getcursor.execute("SELECT ip_naomi FROM setting").fetchone()[0], \
self.database.getcursor.execute("SELECT ip_triforce FROM setting").fetchone()[0], \
self.database.getcursor.execute("SELECT ip_chihiro FROM setting").fetchone()[0]
)
ip = ""
#Ip Address
if self.getCurrentSystem == "NAOMI" or self.getCurrentSystem == "NAOMI2" or self.getCurrentSystem == "ATOMISWARE":
ip = self.database.getcursor.execute("SELECT ip_naomi FROM setting").fetchone()[0]
elif self.getCurrentSystem == "TRIFORCE":
ip = self.database.getcursor.execute("SELECT ip_triforce FROM setting").fetchone()[0]
elif self.getCurrentSystem == "CHIHIRO":
ip = self.database.getcursor.execute("SELECT ip_chihiro FROM setting").fetchone()[0]
if os.system("ping -c 1 %s" % ip) == 0:
triforcetools.connect(ip, 10703)
triforcetools.HOST_SetMode(0, 1)
triforcetools.SECURITY_SetKeycode("\x00" * 8)
triforcetools.DIMM_UploadFile(ROM_DIR + self.current_game)
triforcetools.HOST_Restart()
triforcetools.TIME_SetLimit(10*60*1000)
if self.getPicZeroVirtualKey:
time.sleep(2)
if not self.getSubNavigation == 'Favorite' or self.autoboot :
req = self.database.getcursor.execute('''SELECT system FROM games WHERE name_game = ?''', [self.current_game]).fetchone()
if req == "Naomi" or req == "Naomi 2" or req == "Atomiswave":
ip = ip_value[0]
elif req == "Triforce":
ip = ip_value[1]
elif req == "Chihiro":
ip = ip_value[2]
else:
if self.getCurrentSystem == "NAOMI" or self.getCurrentSystem == "NAOMI2" or self.getCurrentSystem == "ATOMISWARE":
ip = ip_value[0]
elif self.getCurrentSystem == "TRIFORCE" or req == "":
ip = ip_value[1]
elif self.getCurrentSystem == "CHIHIRO":
ip = ip_value[2]
if len(ip) > 0:
if os.system("ping -c 1 %s" % ip) == 0:
triforcetools.connect(ip, 10703)
triforcetools.HOST_SetMode(0, 1)
triforcetools.SECURITY_SetKeycode("\x00" * 8)
triforcetools.DIMM_UploadFile(ROM_DIR + self.current_game)
triforcetools.HOST_Restart()
triforcetools.TIME_SetLimit(10*60*1000)
if self.getPicZeroVirtualKey:
time.sleep(2)
triforcetools.TIME_SetLimit(10*60*1000)
time.sleep(2)
triforcetools.disconnect()
else:
fontLabel(self.pygame, self.screen, MEGADRIVE_TTF, "FAIL..", 40, 20, 200, RED)
self.pygame.display.flip()
time.sleep(2)
triforcetools.disconnect()
else:
fontLabel(self.pygame, self.screen, MEGADRIVE_TTF, "FAIL..", 40, 20, 200, RED)
self.pygame.display.flip()
time.sleep(2)
time.sleep(1)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment