Correction du launcher retrobat, et ajout de la vitesse de téléchargement
This commit is contained in:
@@ -779,6 +779,14 @@ async def main():
|
|||||||
await asyncio.sleep(0.01)
|
await asyncio.sleep(0.01)
|
||||||
|
|
||||||
pygame.mixer.music.stop()
|
pygame.mixer.music.stop()
|
||||||
|
|
||||||
|
process_name = "emulatorLauncher.exe"
|
||||||
|
result = os.system(f"taskkill /f /im {process_name}")
|
||||||
|
if result == 0:
|
||||||
|
logger.debug(f"Quitté avec succès: {process_name}")
|
||||||
|
else:
|
||||||
|
logger.debug("Error en essayant de quitter emulatorlauncher.")
|
||||||
|
|
||||||
pygame.quit()
|
pygame.quit()
|
||||||
logger.debug("Application terminée")
|
logger.debug("Application terminée")
|
||||||
|
|
||||||
|
|||||||
+30
-10
@@ -663,6 +663,25 @@ def draw_history_list(screen):
|
|||||||
history = config.history if hasattr(config, 'history') else load_history()
|
history = config.history if hasattr(config, 'history') else load_history()
|
||||||
history_count = len(history)
|
history_count = len(history)
|
||||||
|
|
||||||
|
# Cherche une entrée en cours de téléchargement pour afficher la vitesse
|
||||||
|
speed_str = ""
|
||||||
|
for entry in history:
|
||||||
|
if entry.get("status") in ["Téléchargement", "downloading"]:
|
||||||
|
speed = entry.get("speed", 0.0)
|
||||||
|
if speed and speed > 0:
|
||||||
|
speed_str = f" - Téléchargement : {speed:.2f} Mo/s"
|
||||||
|
break
|
||||||
|
|
||||||
|
screen.blit(OVERLAY, (0, 0))
|
||||||
|
title_text = _("history_title").format(history_count) + speed_str
|
||||||
|
title_surface = config.title_font.render(title_text, True, THEME_COLORS["text"])
|
||||||
|
title_rect = title_surface.get_rect(center=(config.screen_width // 2, title_surface.get_height() // 2 + 20))
|
||||||
|
title_rect_inflated = title_rect.inflate(60, 30)
|
||||||
|
title_rect_inflated.topleft = ((config.screen_width - title_rect_inflated.width) // 2, 10)
|
||||||
|
pygame.draw.rect(screen, THEME_COLORS["button_idle"], title_rect_inflated, border_radius=12) # fond opaque
|
||||||
|
pygame.draw.rect(screen, THEME_COLORS["border"], title_rect_inflated, 2, border_radius=12)
|
||||||
|
screen.blit(title_surface, title_rect)
|
||||||
|
|
||||||
# Define column widths as percentages of available space
|
# Define column widths as percentages of available space
|
||||||
column_width_percentages = {
|
column_width_percentages = {
|
||||||
"platform": 0.25, # platform column
|
"platform": 0.25, # platform column
|
||||||
@@ -682,6 +701,17 @@ def draw_history_list(screen):
|
|||||||
extra_margin_bottom = 80
|
extra_margin_bottom = 80
|
||||||
title_height = config.title_font.get_height() + 20
|
title_height = config.title_font.get_height() + 20
|
||||||
|
|
||||||
|
speed = 0.0
|
||||||
|
if history and history[config.current_history_item].get("status") in ["Téléchargement", "downloading"]:
|
||||||
|
speed = history[config.current_history_item].get("speed", 0.0)
|
||||||
|
if speed > 0:
|
||||||
|
speed_str = f"{speed:.2f} Mo/s"
|
||||||
|
title_text = _("history_title").format(history_count) + f" - Téléchargement : {speed_str}"
|
||||||
|
else:
|
||||||
|
title_text = _("history_title").format(history_count)
|
||||||
|
title_surface = config.title_font.render(title_text, True, THEME_COLORS["text"])
|
||||||
|
|
||||||
|
|
||||||
if not history:
|
if not history:
|
||||||
logger.debug("Aucun historique disponible")
|
logger.debug("Aucun historique disponible")
|
||||||
message = _("history_empty")
|
message = _("history_empty")
|
||||||
@@ -717,16 +747,6 @@ def draw_history_list(screen):
|
|||||||
elif config.current_history_item >= config.history_scroll_offset + items_per_page:
|
elif config.current_history_item >= config.history_scroll_offset + items_per_page:
|
||||||
config.history_scroll_offset = config.current_history_item - items_per_page + 1
|
config.history_scroll_offset = config.current_history_item - items_per_page + 1
|
||||||
|
|
||||||
screen.blit(OVERLAY, (0, 0))
|
|
||||||
|
|
||||||
title_text = _("history_title").format(history_count)
|
|
||||||
title_surface = config.title_font.render(title_text, True, THEME_COLORS["text"])
|
|
||||||
title_rect = title_surface.get_rect(center=(config.screen_width // 2, title_surface.get_height() // 2 + 20))
|
|
||||||
title_rect_inflated = title_rect.inflate(60, 30)
|
|
||||||
title_rect_inflated.topleft = ((config.screen_width - title_rect_inflated.width) // 2, 10)
|
|
||||||
pygame.draw.rect(screen, THEME_COLORS["button_idle"], title_rect_inflated, border_radius=12)
|
|
||||||
pygame.draw.rect(screen, THEME_COLORS["border"], title_rect_inflated, 2, border_radius=12)
|
|
||||||
screen.blit(title_surface, title_rect)
|
|
||||||
|
|
||||||
pygame.draw.rect(screen, THEME_COLORS["button_idle"], (rect_x, rect_y, rect_width, rect_height), border_radius=12)
|
pygame.draw.rect(screen, THEME_COLORS["button_idle"], (rect_x, rect_y, rect_width, rect_height), border_radius=12)
|
||||||
pygame.draw.rect(screen, THEME_COLORS["border"], (rect_x, rect_y, rect_width, rect_height), 2, border_radius=12)
|
pygame.draw.rect(screen, THEME_COLORS["border"], (rect_x, rect_y, rect_width, rect_height), 2, border_radius=12)
|
||||||
|
|||||||
+15
-4
@@ -223,6 +223,7 @@ async def download_rom(url, platform, game_name, is_zip_non_supported=False, tas
|
|||||||
downloaded = 0
|
downloaded = 0
|
||||||
chunk_size = 4096
|
chunk_size = 4096
|
||||||
last_update_time = time.time()
|
last_update_time = time.time()
|
||||||
|
last_downloaded = 0
|
||||||
update_interval = 0.1 # Mettre à jour toutes les 0,1 secondes
|
update_interval = 0.1 # Mettre à jour toutes les 0,1 secondes
|
||||||
with open(dest_path, 'wb') as f:
|
with open(dest_path, 'wb') as f:
|
||||||
for chunk in response.iter_content(chunk_size=chunk_size):
|
for chunk in response.iter_content(chunk_size=chunk_size):
|
||||||
@@ -232,8 +233,13 @@ async def download_rom(url, platform, game_name, is_zip_non_supported=False, tas
|
|||||||
downloaded += size_received
|
downloaded += size_received
|
||||||
current_time = time.time()
|
current_time = time.time()
|
||||||
if current_time - last_update_time >= update_interval:
|
if current_time - last_update_time >= update_interval:
|
||||||
progress_queues[task_id].put((task_id, downloaded, total_size))
|
# Calcul de la vitesse en Mo/s
|
||||||
|
delta = downloaded - last_downloaded
|
||||||
|
speed = delta / (current_time - last_update_time) / (1024 * 1024)
|
||||||
|
last_downloaded = downloaded
|
||||||
last_update_time = current_time
|
last_update_time = current_time
|
||||||
|
progress_queues[task_id].put((task_id, downloaded, total_size, speed))
|
||||||
|
|
||||||
|
|
||||||
os.chmod(dest_path, 0o644)
|
os.chmod(dest_path, 0o644)
|
||||||
logger.debug(f"Téléchargement terminé: {dest_path}")
|
logger.debug(f"Téléchargement terminé: {dest_path}")
|
||||||
@@ -321,10 +327,14 @@ async def download_rom(url, platform, game_name, is_zip_non_supported=False, tas
|
|||||||
logger.debug(f"Final update in history: status={entry['status']}, progress={entry['progress']}%, message={message}, task_id={task_id}")
|
logger.debug(f"Final update in history: status={entry['status']}, progress={entry['progress']}%, message={message}, task_id={task_id}")
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
downloaded, total_size = data[1], data[2]
|
if len(data) >= 4:
|
||||||
|
downloaded, total_size, speed = data[1], data[2], data[3]
|
||||||
|
else:
|
||||||
|
downloaded, total_size = data[1], data[2]
|
||||||
|
speed = 0.0
|
||||||
progress_percent = int(downloaded / total_size * 100) if total_size > 0 else 0
|
progress_percent = int(downloaded / total_size * 100) if total_size > 0 else 0
|
||||||
progress_percent = max(0, min(100, progress_percent))
|
progress_percent = max(0, min(100, progress_percent))
|
||||||
|
|
||||||
if isinstance(config.history, list):
|
if isinstance(config.history, list):
|
||||||
for entry in config.history:
|
for entry in config.history:
|
||||||
if "url" in entry and entry["url"] == url and entry["status"] in ["downloading", "Téléchargement"]:
|
if "url" in entry and entry["url"] == url and entry["status"] in ["downloading", "Téléchargement"]:
|
||||||
@@ -332,8 +342,9 @@ async def download_rom(url, platform, game_name, is_zip_non_supported=False, tas
|
|||||||
entry["status"] = "Téléchargement"
|
entry["status"] = "Téléchargement"
|
||||||
entry["downloaded_size"] = downloaded
|
entry["downloaded_size"] = downloaded
|
||||||
entry["total_size"] = total_size
|
entry["total_size"] = total_size
|
||||||
|
entry["speed"] = speed # Ajout de la vitesse
|
||||||
config.needs_redraw = True
|
config.needs_redraw = True
|
||||||
break
|
break
|
||||||
await asyncio.sleep(0.1)
|
await asyncio.sleep(0.1)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Erreur mise à jour progression: {str(e)}")
|
logger.error(f"Erreur mise à jour progression: {str(e)}")
|
||||||
|
|||||||
@@ -0,0 +1,119 @@
|
|||||||
|
@echo on
|
||||||
|
setlocal EnableDelayedExpansion
|
||||||
|
|
||||||
|
:: Définir le fichier de log
|
||||||
|
if not exist %CD%\logs MD %CD%\logs
|
||||||
|
set LOG_FILE=%CD%\logs\Retrobat_RGSX_log.txt
|
||||||
|
|
||||||
|
:: Ajouter un horodatage au début du log
|
||||||
|
echo [%DATE% %TIME%] Démarrage du script >> "%LOG_FILE%"
|
||||||
|
|
||||||
|
:: Afficher un message de démarrage
|
||||||
|
cls
|
||||||
|
echo Exécution de __main__.py pour RetroBat...
|
||||||
|
echo [%DATE% %TIME%] Exécution de __main__.py pour RetroBat >> "%LOG_FILE%"
|
||||||
|
|
||||||
|
:: Définir les chemins relatifs
|
||||||
|
set TOOLS_FOLDER=..\..\..\system\tools
|
||||||
|
set PYTHON_EXE=python.exe
|
||||||
|
set MAIN_SCRIPT=__main__.py
|
||||||
|
set CURRENT_DIR=%CD%
|
||||||
|
set "PYTHON_EXE_FULL=%CURRENT_DIR%\!TOOLS_FOLDER!\Python\!PYTHON_EXE!"
|
||||||
|
set "MAIN_SCRIPT_FULL=%CURRENT_DIR%\..\ports\RGSX\!MAIN_SCRIPT!"
|
||||||
|
|
||||||
|
:: Afficher et logger les variables
|
||||||
|
echo TOOLS_FOLDER : !TOOLS_FOLDER!
|
||||||
|
echo [%DATE% %TIME%] TOOLS_FOLDER : !TOOLS_FOLDER! >> "%LOG_FILE%"
|
||||||
|
echo PYTHON_EXE : !PYTHON_EXE!
|
||||||
|
echo [%DATE% %TIME%] PYTHON_EXE : !PYTHON_EXE! >> "%LOG_FILE%"
|
||||||
|
echo MAIN_SCRIPT : !MAIN_SCRIPT!
|
||||||
|
echo [%DATE% %TIME%] MAIN_SCRIPT : !MAIN_SCRIPT! >> "%LOG_FILE%"
|
||||||
|
echo CURRENT_DIR : !CURRENT_DIR!
|
||||||
|
echo [%DATE% %TIME%] CURRENT_DIR : !CURRENT_DIR! >> "%LOG_FILE%"
|
||||||
|
echo PYTHON_EXE_FULL : !PYTHON_EXE_FULL!
|
||||||
|
echo [%DATE% %TIME%] PYTHON_EXE_FULL : !PYTHON_EXE_FULL! >> "%LOG_FILE%"
|
||||||
|
echo MAIN_SCRIPT_FULL : !MAIN_SCRIPT_FULL!
|
||||||
|
echo [%DATE% %TIME%] MAIN_SCRIPT_FULL : !MAIN_SCRIPT_FULL! >> "%LOG_FILE%"
|
||||||
|
|
||||||
|
:: Vérifier si l'exécutable Python existe
|
||||||
|
echo Vérification de python.exe...
|
||||||
|
echo [%DATE% %TIME%] Vérification de python.exe à !PYTHON_EXE_FULL! >> "%LOG_FILE%"
|
||||||
|
if not exist "!PYTHON_EXE_FULL!" (
|
||||||
|
echo Python.exe non trouvé. Préparation du téléchargement...
|
||||||
|
echo [%DATE% %TIME%] Python.exe non trouvé. Préparation du téléchargement... >> "%LOG_FILE%"
|
||||||
|
:: Définir les chemins pour le téléchargement et l'extraction
|
||||||
|
set ZIP_URL=https://retrogamesets.fr/softs/python.zip
|
||||||
|
echo ZIP_URL : !ZIP_URL!
|
||||||
|
echo [%DATE% %TIME%] ZIP_URL : !ZIP_URL! >> "%LOG_FILE%"
|
||||||
|
if not exist "!TOOLS_FOLDER!\Python" (
|
||||||
|
echo Création du dossier !TOOLS_FOLDER!\Python...
|
||||||
|
echo [%DATE% %TIME%] Création du dossier !TOOLS_FOLDER!\Python... >> "%LOG_FILE%"
|
||||||
|
mkdir "!TOOLS_FOLDER!\Python"
|
||||||
|
)
|
||||||
|
set ZIP_FILE=!TOOLS_FOLDER!\python.zip
|
||||||
|
echo ZIP_FILE : !ZIP_FILE!
|
||||||
|
echo [%DATE% %TIME%] ZIP_FILE : !ZIP_FILE! >> "%LOG_FILE%"
|
||||||
|
echo Téléchargement de python.zip...
|
||||||
|
echo [%DATE% %TIME%] Téléchargement de python.zip depuis !ZIP_URL!... >> "%LOG_FILE%"
|
||||||
|
:: Afficher un message de progression pendant le téléchargement
|
||||||
|
echo Téléchargement en cours...
|
||||||
|
curl -L "!ZIP_URL!" -o "!ZIP_FILE!"
|
||||||
|
if exist "!ZIP_FILE!" (
|
||||||
|
echo Téléchargement terminé. Extraction de python.zip...
|
||||||
|
echo [%DATE% %TIME%] Téléchargement terminé. Extraction de python.zip vers !TOOLS_FOLDER!\Python... >> "%LOG_FILE%"
|
||||||
|
:: Afficher des messages de progression pendant l'extraction
|
||||||
|
echo Extraction en cours...
|
||||||
|
tar -xf "!ZIP_FILE!" -C "!TOOLS_FOLDER!" --strip-components=0
|
||||||
|
echo Extraction terminée.
|
||||||
|
echo [%DATE% %TIME%] Extraction terminée. >> "%LOG_FILE%"
|
||||||
|
del /q "!ZIP_FILE!"
|
||||||
|
echo Fichier python.zip supprimé.
|
||||||
|
echo [%DATE% %TIME%] Fichier python.zip supprimé. >> "%LOG_FILE%"
|
||||||
|
) else (
|
||||||
|
echo Erreur : Échec du téléchargement de python.zip.
|
||||||
|
echo [%DATE% %TIME%] Erreur : Échec du téléchargement de python.zip. >> "%LOG_FILE%"
|
||||||
|
goto :error
|
||||||
|
)
|
||||||
|
:: Vérifier à nouveau si python.exe existe après extraction
|
||||||
|
if not exist "!PYTHON_EXE_FULL!" (
|
||||||
|
echo Erreur : python.exe n'a pas été trouvé après extraction à !PYTHON_EXE_FULL!.
|
||||||
|
echo [%DATE% %TIME%] Erreur : python.exe n'a pas été trouvé après extraction à !PYTHON_EXE_FULL! >> "%LOG_FILE%"
|
||||||
|
goto :error
|
||||||
|
)
|
||||||
|
)
|
||||||
|
echo python.exe trouvé.
|
||||||
|
echo [%DATE% %TIME%] python.exe trouvé. >> "%LOG_FILE%"
|
||||||
|
|
||||||
|
:: Vérifier si le script Python existe
|
||||||
|
echo Vérification de __main__.py...
|
||||||
|
echo [%DATE% %TIME%] Vérification de __main__.py à !MAIN_SCRIPT_FULL! >> "%LOG_FILE%"
|
||||||
|
if not exist "!MAIN_SCRIPT_FULL!" (
|
||||||
|
echo Erreur : __main__.py n'a pas été trouvé à !MAIN_SCRIPT_FULL!.
|
||||||
|
echo [%DATE% %TIME%] Erreur : __main__.py n'a pas été trouvé à !MAIN_SCRIPT_FULL! >> "%LOG_FILE%"
|
||||||
|
goto :error
|
||||||
|
)
|
||||||
|
echo __main__.py trouvé.
|
||||||
|
echo [%DATE% %TIME%] __main__.py trouvé. >> "%LOG_FILE%"
|
||||||
|
|
||||||
|
:: Exécuter le script Python
|
||||||
|
echo Exécution de __main__.py...
|
||||||
|
echo [%DATE% %TIME%] Exécution de __main__.py avec !PYTHON_EXE_FULL! >> "%LOG_FILE%"
|
||||||
|
"!PYTHON_EXE_FULL!" "!MAIN_SCRIPT_FULL!"
|
||||||
|
if %ERRORLEVEL% equ 0 (
|
||||||
|
echo Exécution terminée avec succès.
|
||||||
|
echo [%DATE% %TIME%] Exécution de __main__.py terminée avec succès. >> "%LOG_FILE%"
|
||||||
|
) else (
|
||||||
|
echo Erreur : Échec de l'exécution de __main__.py (code %ERRORLEVEL%).
|
||||||
|
echo [%DATE% %TIME%] Erreur : Échec de l'exécution de __main__.py avec code d'erreur %ERRORLEVEL%. >> "%LOG_FILE%"
|
||||||
|
goto :error
|
||||||
|
)
|
||||||
|
|
||||||
|
:end
|
||||||
|
echo Tâche terminée.
|
||||||
|
echo [%DATE% %TIME%] Tâche terminée avec succès. >> "%LOG_FILE%"
|
||||||
|
exit /b 0
|
||||||
|
|
||||||
|
:error
|
||||||
|
echo Une erreur s'est produite.
|
||||||
|
echo [%DATE% %TIME%] Une erreur s'est produite. >> "%LOG_FILE%"
|
||||||
|
exit /b 1
|
||||||
@@ -1 +0,0 @@
|
|||||||
python
|
|
||||||
Binary file not shown.
Reference in New Issue
Block a user