@@ -47,6 +47,8 @@ def mouseDoubleClickEvent(self, event):
4747
4848
4949class WInfomove (QtWidgets .QWidget ):
50+ game : None
51+
5052 def __init__ (self , wb_database ):
5153 QtWidgets .QWidget .__init__ (self )
5254
@@ -71,15 +73,15 @@ def __init__(self, wb_database):
7173 lybt , bt = QTVarios .ly_mini_buttons (self , "" , siTiempo = True , siLibre = False , icon_size = 24 , siJugar = True )
7274
7375 self .lbPGN = LBKey (self ).anchoFijo (self .board .ancho ).set_wrap ()
74- self .lbPGN .setTextInteractionFlags (Qt .LinksAccessibleByMouse | Qt .LinksAccessibleByKeyboard )
76+ self .lbPGN .setTextInteractionFlags (Qt .LinksAccessibleByMouse | Qt .LinksAccessibleByKeyboard )
7577 self .lbPGN .wowner = self
7678 self .lbPGN .set_font_type (puntos = configuration .x_pgn_fontpoints )
7779 Code .configuration .set_property (self .lbPGN , "pgn" )
7880 self .lbPGN .setOpenExternalLinks (False )
7981 self .lbPGN .setAlignment (QtCore .Qt .AlignTop )
8082
8183 def muestra_pos (txt ):
82- self .colocatePartida (int (txt ))
84+ self .goto_move_num (int (txt ))
8385
8486 self .lbPGN .linkActivated .connect (muestra_pos )
8587
@@ -122,7 +124,7 @@ def cambiado_board(self):
122124 def process_toolbar (self ):
123125 getattr (self , self .sender ().key )()
124126
125- def modoPartida (self , game , move ):
127+ def game_mode (self , game , move ):
126128 self .game = game
127129 if game .opening :
128130 txt = game .opening .tr_name
@@ -131,14 +133,14 @@ def modoPartida(self, game, move):
131133 self .lb_opening .set_text (txt )
132134 else :
133135 self .lb_opening .set_text ("" )
134- self .colocatePartida (move )
136+ self .goto_move_num (move )
135137
136- def modoFEN (self , game , fen , move ):
138+ def fen_mode (self , game , fen , move ):
137139 self .game = game
138140 self .lb_opening .set_text (fen )
139- self .colocatePartida (move )
141+ self .goto_move_num (move )
140142
141- def colocatePartida (self , pos ):
143+ def goto_move_num (self , pos ):
142144 if not len (self .game ):
143145 self .lbPGN .game = None
144146 self .lbPGN .set_text ("" )
@@ -152,29 +154,31 @@ def colocatePartida(self, pos):
152154 p = self .game
153155
154156 movenum = p .primeraJugada ()
155- pgn = ""
156- style_number = " color:%s; font-weight: bold;" % Code .dic_colors ["PGN_NUMBER" ]
157- style_select = " color:%s;font-weight: bold;" % Code .dic_colors ["PGN_SELECT" ]
158- style_moves = " color:%s;" % Code .dic_colors ["PGN_MOVES" ]
157+ li_pgn = []
158+ style_number = f' color:{ Code .dic_colors ["PGN_NUMBER" ]} '
159+ style_select = f' color:{ Code .dic_colors ["PGN_SELECT" ]} ;font-weight:bold;'
160+ style_moves = f' color:{ Code .dic_colors ["PGN_MOVES" ]} '
159161 if p .starts_with_black :
160- pgn += '<span style="%s">%d ...</span>' % ( style_number , movenum )
162+ li_pgn . append ( f '<span style="{ style_number } "> { movenum } ...</span>' )
161163 movenum += 1
162164 salta = 1
163165 else :
164166 salta = 0
165167 for n , move in enumerate (p .li_moves ):
166168 if n % 2 == salta :
167- pgn += '<span style="%s">%d .</span>' % ( style_number , movenum )
169+ li_pgn . append ( f '<span style="{ style_number } "> { movenum } .</span>' )
168170 movenum += 1
169-
170171 xp = move .pgn_html (self .with_figurines )
171172 if n == pos :
172- xp = '<span style="%s">%s </span>' % ( style_select , xp )
173+ xp = f '<span style="{ style_select } "> { xp } </span>'
173174 else :
174- xp = '<span style="%s">%s</span>' % (style_moves , xp )
175-
176- pgn += '<nobr><a href="%d" style="text-decoration:none;">%s</a></nobr> ' % (n , xp )
175+ xp = f'<span style="{ style_moves } ">{ xp } </span>'
177176
177+ li_pgn .append (f'<a href="{ n } " style="text-decoration:none;">{ xp } </a> ' )
178+ pgn = "" .join (li_pgn )
179+ if "O-" in pgn :
180+ pgn = pgn .replace ("O-O-O" , "O\u2060 -\u2060 O-\u2060 O" ).replace ("O-O" , "O\u2060 -\u2060 O" )
181+ self .lbPGN .set_text ("" ) # necesario para que no aparezca la selección
178182 self .lbPGN .set_text (pgn )
179183 self .lbPGN .game = self .game
180184 self .lbPGN .pos_move = pos
@@ -212,10 +216,10 @@ def MoverInicio(self):
212216 self .board .set_position (position )
213217
214218 def MoverAtras (self ):
215- self .colocatePartida (self .pos_move - 1 )
219+ self .goto_move_num (self .pos_move - 1 )
216220
217221 def MoverAdelante (self ):
218- self .colocatePartida (self .pos_move + 1 )
222+ self .goto_move_num (self .pos_move + 1 )
219223
220224 def analizar_actual (self ):
221225 lh = len (self .game )
@@ -232,11 +236,11 @@ def analizar_actual(self):
232236 self .board .is_white_bottom , self .pos_move , main_window = self ,
233237 must_save = False
234238 )
235- self .lbPGN .set_text ("" ) # necesario para que desaparezca la selección
236- self .colocatePartida (self .pos_move )
239+ self .lbPGN .set_text ("" ) # necesario para que desaparezca la selección
240+ self .goto_move_num (self .pos_move )
237241
238242 def MoverFinal (self ):
239- self .colocatePartida (99999 )
243+ self .goto_move_num (99999 )
240244
241245 def MoverJugar (self ):
242246 self .board .play_current_position ()
0 commit comments