diff --git a/src/main/python/game_gui.py b/src/main/python/game_gui.py index 41ca5ec..d0066b4 100644 --- a/src/main/python/game_gui.py +++ b/src/main/python/game_gui.py @@ -7,6 +7,7 @@ import itertools import locale import os import time +import functools from PyQt5 import QtWidgets, QtCore, QtGui, QtMultimedia QtCore.Signal = QtCore.pyqtSignal @@ -588,6 +589,7 @@ class Stats(QtWidgets.QWidget): self.mini_t_spin_total = 0 self.nb_back_to_back = 0 self.back_to_back_scores = None + self.max_back_to_back_score = 0 self.combo = -1 self.combos_total = 0 self.max_combo = 0 @@ -691,6 +693,7 @@ class Stats(QtWidgets.QWidget): self.temporary_text.emit( self.tr("BACK TO BACK\n{:n}").format(b2b_score) ) + self.max_back_to_back_score = max(self.max_back_to_back_score, b2b_score) self.back_to_back_scores = None self.high_score = max(self.score_total, self.high_score) @@ -717,56 +720,38 @@ class Stats(QtWidgets.QWidget): painter.drawText( QtCore.QRectF(self.rect()), self.text(sep="\n\n"), self.text_options ) + + """ + Returns a strings representing number with the locale thousand separator + """ + thousand_separated = functools.partial(locale.format, "%i", grouping=True, monetary=True) def text(self, full_stats=False, sep="\n"): text = ( - self.tr("Score: ") - + locale.format("%i", self.score_total, grouping=True, monetary=True) - + sep - + self.tr("High score: ") - + locale.format("%i", self.high_score, grouping=True, monetary=True) - + sep + self.tr("Score: ") + self.thousand_separated(self.score_total) + sep + + self.tr("High score: ") + self.thousand_separated(self.high_score) + sep + self.tr("Time: {}\n").format( time.strftime("%H:%M:%S", time.gmtime(self.chronometer)) - ) - + sep - + self.tr("Level: ") - + locale.format("%i", self.level, grouping=True, monetary=True) - + sep - + self.tr("Goal: ") - + locale.format("%i", self.goal, grouping=True, monetary=True) - + sep - + self.tr("Lines: ") - + locale.format( - "%i", self.complete_lines_total, grouping=True, monetary=True - ) - + sep - + self.tr("Mini T-Spins: ") - + locale.format("%i", self.mini_t_spin_total, grouping=True, monetary=True) - + sep - + self.tr("T-Spins: ") - + locale.format("%i", self.t_spin_total, grouping=True, monetary=True) - + sep - + self.tr("Back-to-back: ") - + locale.format("%i", self.nb_back_to_back, grouping=True, monetary=True) - + sep - + self.tr("Max combo: ") - + locale.format("%i", self.max_combo, grouping=True, monetary=True) - + sep - + self.tr("Combos: ") - + locale.format("%i", self.combos_total, grouping=True, monetary=True) + ) + sep + + self.tr("Level: ") + self.thousand_separated(self.level) + sep + + self.tr("Goal: ") + self.thousand_separated(self.goal) + sep + + self.tr("Lines: ") + self.thousand_separated(self.complete_lines_total) + sep + + self.tr("Mini T-Spins: ") + self.thousand_separated(self.mini_t_spin_total) + sep + + self.tr("T-Spins: ") + self.thousand_separated(self.t_spin_total) + sep + + self.tr("Back-to-backs: ") + self.thousand_separated(self.nb_back_to_back) + sep + + self.tr("Max back-to-back score: ") + self.thousand_separated(self.max_back_to_back_score) + sep + + self.tr("Max combo: ") + self.thousand_separated(self.max_combo) + sep + + self.tr("Combos: ") + self.thousand_separated(self.combos_total) ) if full_stats: minutes = self.chronometer / 60 text += ( - "\n" - + sep + "\n" + sep + self.tr("Lines per minute: {:.1f}").format( self.complete_lines_total / minutes - ) - + sep + ) + sep + self.tr("Tetrominos locked down: ") - + locale.format("%i", self.nb_tetro, grouping=True, monetary=True) + + self.thousand_separated(self.nb_tetro) + sep + self.tr("Tetrominos per minute: {:.1f}").format( self.nb_tetro / minutes @@ -774,9 +759,7 @@ class Stats(QtWidgets.QWidget): + sep ) text += sep.join( - score_type["name"] - + self.tr(": ") - + locale.format("%i", nb, grouping=True, monetary=True) + score_type["name"] + self.tr(": ") + self.thousand_separated(nb) for score_type, nb in tuple(zip(consts.SCORES, self.lines_stats))[1:] ) return text diff --git a/src/main/python/main.py b/src/main/python/main.py index e8bff34..007a750 100644 --- a/src/main/python/main.py +++ b/src/main/python/main.py @@ -8,11 +8,11 @@ Parts of comments issued from 2009 Tetris Design Guideline """ +import sys + from fbs_runtime.application_context import ApplicationContext from game_gui import Window -import sys - class AppContext(ApplicationContext): # 1. Subclass ApplicationContext def run(self): # 2. Implement run() win = Window(self) diff --git a/src/main/python/tetromino.py b/src/main/python/tetromino.py index f70949c..4ac054e 100644 --- a/src/main/python/tetromino.py +++ b/src/main/python/tetromino.py @@ -162,7 +162,7 @@ class TetroI(Tetromino, metaclass=MetaTetro): four minoes in a straight line """ - COORDS = (L, 0), (0, 0), (R, 0), (2 * R, 0) + COORDS = (0, 0), (L, 0), (R, 0), (2 * R, 0) SUPER_ROTATION_SYSTEM = ( { COUNTERCLOCKWISE: ((0, D), (L, D), (2 * R, D), (L, U), (2 * R, 2 * D)), diff --git a/src/main/resources/base/locale/Tetris2000.ts b/src/main/resources/base/locale/Tetris2000.ts index 8d1486a..5dbd1b7 100644 --- a/src/main/resources/base/locale/Tetris2000.ts +++ b/src/main/resources/base/locale/Tetris2000.ts @@ -3,39 +3,39 @@ Frames - + New game - + A game is in progress. Do you want to abord it? - + Start level: - + High score - + Game over - + Congratulations! You have the high score: {} - + Score: {} High score: {} @@ -44,13 +44,13 @@ High score: {} Matrix - + Level - + PAUSE Press %s @@ -58,7 +58,7 @@ to resume - + GAME OVER @@ -67,97 +67,97 @@ OVER SettingStrings - + Keyboard settings - + Move left - + Move right - + Rotate clockwise - + Rotate counterclockwise - + Soft drop - + Hard drop - + Hold - + Pause - + Other settings - + Delays - + Auto-shift delay - + Auto-repeat rate - + Sound - + Music volume - + Effects volume - + Show ghost piece - + Show next queue - + Hold enabled @@ -165,7 +165,7 @@ OVER SettingsDialog - + Settings @@ -173,137 +173,148 @@ OVER Stats - + High score - + COMBO x{:n} {:n} - + BACK TO BACK {:n} - + Score: - + High score: - + Time: {} - + Level: - + Goal: - + Lines: - + Mini T-Spins: - + T-Spins: - - Back-to-back: - - - - + Max combo: - + Combos: - + Lines per minute: {:.1f} - + Tetrominos locked down: - + Tetrominos per minute: {:.1f} - + : + + + COMBO +{:n} + + + + + Back-to-backs: + + + + + Max back-to-back score: + + Window - + &New game - + &Settings - + &About - + Quit game? - + A game is in progress. Do you want to abord it? - + High score - - Tetris® clone by Adrien Malingrey + + Tetris® clone by Adrien Malingrey -Tetris Game Design by Alekseï Pajitnov +Tetris Game Design by Alekseï Pajitnov Graphism inspired by Tetris Effect Window style sheet: qdarkstyle by Colin Duquesnoy Fonts by Markus Koellmann, Peter Wiegel @@ -313,7 +324,7 @@ Pexels.com by Min An, Jaymantri, Felix Mittermeier Pixabay.com by LoganArt Pixnio.com by Adrian Pelletier Unsplash.com by Aron, Patrick Fore, Ilnur Kalimullin, Gabriel Garcia Marengo, Adnanta Raharja -StockSnap.io by Nathan Anderson, José Ignacio Pompé +StockSnap.io by Nathan Anderson, José Ignacio Pompé Musics from ocremix.org by: CheDDer Nardz, djpretzel, MkVaff, Sir_NutS, R3FORGED, Sir_NutS Sound effects made with voc-one by Simple-Media diff --git a/src/main/resources/base/locale/fr.qm b/src/main/resources/base/locale/fr.qm index 4077ed7..1012407 100644 Binary files a/src/main/resources/base/locale/fr.qm and b/src/main/resources/base/locale/fr.qm differ diff --git a/src/main/resources/base/locale/fr.ts b/src/main/resources/base/locale/fr.ts index fff7efc..b26e59f 100644 --- a/src/main/resources/base/locale/fr.ts +++ b/src/main/resources/base/locale/fr.ts @@ -1,44 +1,44 @@ - + Frames - + New game Nouvelle partie - + A game is in progress. Do you want to abord it? Une partie est en cours. Voulez-vous l'abandonner ? - + Start level: Commencer au niveau : - + High score Meilleur score - + Game over Partie terminée - + Congratulations! You have the high score: {} Bravo ! Vous avez atteint le meilleur score : {} - + Score: {} High score: {} Score : {} @@ -48,14 +48,14 @@ Meilleur score : {} Matrix - + Level Niveau - + PAUSE Press %s @@ -67,7 +67,7 @@ Appuyez sur pour reprendre - + GAME OVER PARTIE @@ -77,97 +77,97 @@ TERMINÉE SettingStrings - + Keyboard settings Configuration du clavier - + Move left Déplacer à gauche - + Move right Déplacer à droite - + Rotate clockwise Tourner dans le sens horaire - + Rotate counterclockwise Tourner dans le sens anti-horaire - + Soft drop Chute lente - + Hard drop Chute rapide - + Hold Réserve - + Pause Pause - + Other settings Autres paramètres - + Delays Temporisation - + Auto-shift delay Délai avant répétition - + Auto-repeat rate Vitesse de répétition - + Sound Son - + Music volume Volume de la musique - + Effects volume Volume des effets sonores - + Show ghost piece Afficher la pièce fantôme - + Show next queue Afficher les 6 prochaines pièces - + Hold enabled Activer la réserve @@ -175,7 +175,7 @@ TERMINÉE SettingsDialog - + Settings Préférences @@ -183,133 +183,150 @@ TERMINÉE Stats - + High score Meilleur score - + COMBO x{:n} {:n} COMBO x{:n} {:n} - + BACK TO BACK {:n} BACK TO BACK {:n} - + Time: {} Temps : {} - + Lines per minute: {:.1f} Lignes par minute : {:.1f} - + Tetrominos per minute: {:.1f} Tétrominos par minute : {:.1f} - + Score: Score : - + High score: Meilleur score : - + Level: Niveau : - + Goal: Objectif : - + Lines: Lignes : - + Mini T-Spins: Mini T-Spins : - + T-Spins: T-Spins : Back-to-back: - Back-to-back : + Back-to-back : - + Max combo: Combo max : - + Combos: Combos : - + Tetrominos locked down: Tétrominos bloqués : - + : : + + + COMBO +{:n} + COMBO +{:n} + + + + Back-to-backs: + Back-to-backs : + + + + Max back-to-back score: + Score max back-to-back : + Window - + High score Meilleur score - + &New game &Nouvelle partie - + &Settings &Préférences - + &About &À propos - + A game is in progress. Do you want to abord it? Une partie est en cours. Voulez-vous l'abandonner ? - + Quit game? Quitter la partie ? @@ -331,7 +348,7 @@ StockSnap.io by Nathan Anderson, José Ignacio Pompé Musics from ocremix.org by: CheDDer Nardz, djpretzel, MkVaff, Sir_NutS, R3FORGED, Sir_NutS Sound effects made with voc-one by Simple-Media - Clone de Tetris® par Adrien Malingrey + Clone de Tetris® par Adrien Malingrey Conception du jeu : Alekseï Pajitnov Graphismes inspirés de Tetris Effect @@ -348,5 +365,25 @@ Musiques issues de ocremix.org par : CheDDer Nardz, djpretzel, MkVaff, Sir_NutS, R3FORGED, Sir_NutS Effets sonores réalisés avec voc-one de Simple-Media + + + Tetris® clone by Adrien Malingrey + +Tetris Game Design by Alekseï Pajitnov +Graphism inspired by Tetris Effect +Window style sheet: qdarkstyle by Colin Duquesnoy +Fonts by Markus Koellmann, Peter Wiegel +Images from: +OpenGameArt.org by beren77, Duion +Pexels.com by Min An, Jaymantri, Felix Mittermeier +Pixabay.com by LoganArt +Pixnio.com by Adrian Pelletier +Unsplash.com by Aron, Patrick Fore, Ilnur Kalimullin, Gabriel Garcia Marengo, Adnanta Raharja +StockSnap.io by Nathan Anderson, José Ignacio Pompé +Musics from ocremix.org by: +CheDDer Nardz, djpretzel, MkVaff, Sir_NutS, R3FORGED, Sir_NutS +Sound effects made with voc-one by Simple-Media + + diff --git a/src/main/resources/base/locale/update_ts.bat b/src/main/resources/base/locale/update_ts.bat index 3d63f31..d42e3f0 100644 --- a/src/main/resources/base/locale/update_ts.bat +++ b/src/main/resources/base/locale/update_ts.bat @@ -1,3 +1,3 @@ -for /F %%n in ('dir /B *.ts') do pylupdate5 -verbose ..\window.py ..\settings.py ..\stats.py ..\matrix.py ..\frames.py -ts %%n +for /F %%n in ('dir /B *.ts') do pylupdate5 -verbose ..\..\..\python\game_gui.py -ts %%n echo You may need to edit *.ts files with a text editor to correct special characters pause diff --git a/src/main/resources/base/locale/update_ts_noobsolete.bat b/src/main/resources/base/locale/update_ts_noobsolete.bat index ec5e66d..ccb9f3b 100644 --- a/src/main/resources/base/locale/update_ts_noobsolete.bat +++ b/src/main/resources/base/locale/update_ts_noobsolete.bat @@ -1,3 +1,3 @@ -for /F %%n in ('dir /B *.ts') do pylupdate5 -verbose ..\window.py ..\settings.py ..\stats.py ..\matrix.py ..\frames.py -ts -noobsolete %%n +for /F %%n in ('dir /B *.ts') do pylupdate5 -verbose ..\..\..\python\game_gui.py -ts -noobsolete %%n echo You may need to edit *.ts files with a text editor to correct special characters pause