From c16983cc8cad3d96b168ca673324e50ed77f0f1b Mon Sep 17 00:00:00 2001 From: skymike03 Date: Thu, 31 Jul 2025 16:19:36 +0200 Subject: [PATCH] =?UTF-8?q?Correction=20du=20launcher=20retrobat,=20et=20a?= =?UTF-8?q?jout=20de=20la=20vitesse=20de=20t=C3=A9l=C3=A9chargement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ports/RGSX/__main__.py | 8 +++ ports/RGSX/display.py | 40 +++++++++--- ports/RGSX/network.py | 19 ++++-- windows/RGSX Retrobat.bat | 119 ++++++++++++++++++++++++++++++++++ windows/RGSX Retrobat.gameexe | 1 - windows/RGSX Retrobat.lnk | Bin 1939 -> 0 bytes 6 files changed, 172 insertions(+), 15 deletions(-) create mode 100644 windows/RGSX Retrobat.bat delete mode 100644 windows/RGSX Retrobat.gameexe delete mode 100644 windows/RGSX Retrobat.lnk diff --git a/ports/RGSX/__main__.py b/ports/RGSX/__main__.py index a3aa4c2..3ed29a2 100644 --- a/ports/RGSX/__main__.py +++ b/ports/RGSX/__main__.py @@ -779,6 +779,14 @@ async def main(): await asyncio.sleep(0.01) 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() logger.debug("Application terminée") diff --git a/ports/RGSX/display.py b/ports/RGSX/display.py index fcfcad4..c5a039f 100644 --- a/ports/RGSX/display.py +++ b/ports/RGSX/display.py @@ -663,6 +663,25 @@ def draw_history_list(screen): history = config.history if hasattr(config, 'history') else load_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 column_width_percentages = { "platform": 0.25, # platform column @@ -682,6 +701,17 @@ def draw_history_list(screen): extra_margin_bottom = 80 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: logger.debug("Aucun historique disponible") message = _("history_empty") @@ -717,16 +747,6 @@ def draw_history_list(screen): elif config.current_history_item >= config.history_scroll_offset + items_per_page: 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["border"], (rect_x, rect_y, rect_width, rect_height), 2, border_radius=12) diff --git a/ports/RGSX/network.py b/ports/RGSX/network.py index 2ce9435..b802c2f 100644 --- a/ports/RGSX/network.py +++ b/ports/RGSX/network.py @@ -223,6 +223,7 @@ async def download_rom(url, platform, game_name, is_zip_non_supported=False, tas downloaded = 0 chunk_size = 4096 last_update_time = time.time() + last_downloaded = 0 update_interval = 0.1 # Mettre à jour toutes les 0,1 secondes with open(dest_path, 'wb') as f: 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 current_time = time.time() 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 + progress_queues[task_id].put((task_id, downloaded, total_size, speed)) + os.chmod(dest_path, 0o644) 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}") break 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 = max(0, min(100, progress_percent)) - + if isinstance(config.history, list): for entry in config.history: 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["downloaded_size"] = downloaded entry["total_size"] = total_size + entry["speed"] = speed # Ajout de la vitesse config.needs_redraw = True - break + break await asyncio.sleep(0.1) except Exception as e: logger.error(f"Erreur mise à jour progression: {str(e)}") diff --git a/windows/RGSX Retrobat.bat b/windows/RGSX Retrobat.bat new file mode 100644 index 0000000..dfcdc12 --- /dev/null +++ b/windows/RGSX Retrobat.bat @@ -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 \ No newline at end of file diff --git a/windows/RGSX Retrobat.gameexe b/windows/RGSX Retrobat.gameexe deleted file mode 100644 index d8654aa..0000000 --- a/windows/RGSX Retrobat.gameexe +++ /dev/null @@ -1 +0,0 @@ -python \ No newline at end of file diff --git a/windows/RGSX Retrobat.lnk b/windows/RGSX Retrobat.lnk deleted file mode 100644 index dd34a4665019defe7702eb23ae0df086826d3038..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1939 zcmd^9Ur1A76#s21XiBYGW~I4S1EpG|SKi%mcftA6OHYzf z5Is~BQkD<}`A|J2KK3|zh%Bk-DU>k#1N{-|_uYB7h$4LUjNduuJKx!N&iTG`?qL8n zr=1*_GC5jq+Kb_$emZf-e!w-ctl-Xx&moxr%^;}hi4qPp`EBe<*zb=c61+Nen=P4u$ZNrwO2v=v|WH62y8hAt*|0BnpTh z+Wxl=N=XX(>*^5<$YI6MwWg>c>zbO9lbUX%N5d31A!CjOm5UEJO|l zQq;p}Wu;xeY2CCb+|}vT%lHQWla+4tWHTA(kNCMqf$&kw#{ zy#MpUmvn8tvP=E2cH-#N!*5Tvxc|5BVCR$oqj4VRmpY~QzQ-?`G2A--HM4#!)#pA! z`*9Jfn%GKM>AO(FXA78RSjjh;$;)OTs#$El@LF*QX_^p$d<&jO^R1g5w-)R@BiHBd z?xTH`a1epk5mumo-wv>WerpIe9cjF{KymWj1ctX6NQUMP&>c=6mVh$Du6a?u(t z7O9ZO_yj6{Q6!cu5qbz+!yqfl9=e*+3~3FNSPv7Tu-hkNH4T@Zu6^(fQ=#dKj7qz> zI5V;shUMJa^4dj20S*!(k%@9Oc<)@YZM?0~JJygMsiM7KIJ6Ni|4Z=_B+=h_az-C%2|>_?4110J^gpI??0aUCnRNHHNroQWNj fX9)56DCN5F^Vv_$RUex!7M*xiTC=!a>lgsOL