Skip to content

Commit f373688

Browse files
committed
Version 2.20b
1 parent ff7fa6c commit f373688

File tree

22 files changed

+85
-82
lines changed

22 files changed

+85
-82
lines changed

bin/Code/Databases/WDB_Games.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ def show_current(self):
431431
if recno >= 0:
432432
self.grid_cambiado_registro(None, recno, None)
433433
else:
434-
self.infoMove.modoPartida(Game.Game(), 0)
434+
self.infoMove.game_mode(Game.Game(), 0)
435435

436436
def grid_cambiado_registro(self, grid, row, oCol):
437437
if self.grid_num_datos(grid) > row >= 0:
@@ -442,13 +442,13 @@ def grid_cambiado_registro(self, grid, row, oCol):
442442
p = Game.Game(fen=fen)
443443
p.read_pv(pv)
444444
p.is_finished()
445-
self.infoMove.modoFEN(p, fen, -1)
445+
self.infoMove.fen_mode(p, fen, -1)
446446
else:
447447
p = Game.Game()
448448
p.read_pv(pv)
449449
p.assign_opening()
450450
p.is_finished()
451-
self.infoMove.modoPartida(p, 0)
451+
self.infoMove.game_mode(p, 0)
452452

453453
def tw_gobottom(self):
454454
self.grid.gobottom()

bin/Code/Databases/WDB_InfoMove.py

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ def mouseDoubleClickEvent(self, event):
4747

4848

4949
class 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-\u2060O-\u2060O").replace("O-O", "O\u2060-\u2060O")
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()

bin/Code/Databases/WDB_Players.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ def grid_cambiado_registro(self, grid, nfila, oCol):
320320
pv = dt[nfila]["pv"]
321321
game = Game.Game()
322322
game.read_pv(pv)
323-
self.infoMove.modoPartida(game, len(game) - 1)
323+
self.infoMove.game_mode(game, len(game) - 1)
324324
grid.setFocus()
325325

326326
def grid_color_fondo(self, grid, nfila, ocol):

bin/Code/Databases/WDB_Summary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ def cambiaInfoMove(self):
374374
p.read_pv(pv)
375375
p.is_finished()
376376
p.assign_opening()
377-
self.infoMove.modoPartida(p, 9999)
377+
self.infoMove.game_mode(p, 9999)
378378
self.setFocus()
379379
self.grid.setFocus()
380380

bin/Code/GM/WindowGM.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ def preferred_openings(self):
518518
menu.set_font(f)
519519
n_pos = 0
520520
for nli, bloque in enumerate(self.li_preferred_openings):
521-
if type(bloque) == tuple: # compatibilidad con versiones anteriores
521+
if isinstance(bloque, tuple): # compatibilidad con versiones anteriores
522522
bloque = bloque[0]
523523
self.li_preferred_openings[nli] = bloque
524524
menu.opcion((n_pos, bloque), bloque.tr_name, Iconos.PuntoVerde())

bin/Code/Kibitzers/WKibDatabases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class InfoMoveReplace:
1515
board = None
1616

17-
def modoPartida(self, x, y):
17+
def game_mode(self, x, y):
1818
return True
1919

2020

bin/Code/MainWindow/WInformation.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,15 @@ def link_variation_pressed(self, selected_link):
352352
board.put_arrow_sc(var_move.from_sq, var_move.to_sq)
353353
if Code.configuration.x_show_rating:
354354
self.get_manager().show_rating(var_move)
355+
if var_move.analysis and Code.configuration.x_show_bestmove:
356+
self.get_manager().show_bestmove(var_move)
355357
self.mostrar()
356358

357359
if variation is not None:
358360
manager = self.get_manager()
359361
manager.show_bar_kibitzers_variation(variation.copia(num_var_move))
362+
else:
363+
self.get_manager().put_view()
360364

361365
def link_variation_edit(self, num_variation):
362366
self.edit(num_variation)

bin/Code/Manager.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -519,10 +519,7 @@ def put_view(self):
519519
move_check = None
520520
if move_check:
521521
if move_check.analysis and self.configuration.x_show_bestmove:
522-
mrm, pos = move_check.analysis
523-
if pos: # no se muestra la mejor move si es la realizada
524-
rm0 = mrm.best_rm_ordered()
525-
self.board.put_arrow_scvar([(rm0.from_sq, rm0.to_sq)])
522+
self.show_bestmove(move_check)
526523

527524
if self.configuration.x_show_rating:
528525
self.show_rating(move_check)
@@ -586,6 +583,12 @@ def show_rating(self, move_check):
586583
poscelda = 1 if poscelda == 0 else 0
587584
self.board.put_rating(move_check.from_sq, move_check.to_sq, 1000, poscelda)
588585

586+
def show_bestmove(self, move_check):
587+
mrm, pos = move_check.analysis
588+
if pos: # no se muestra la mejor move si es la realizada
589+
rm0 = mrm.best_rm_ordered()
590+
self.board.put_arrow_scvar([(rm0.from_sq, rm0.to_sq)])
591+
589592
def si_check_kibitzers(self):
590593
return (self.state == ST_ENDGAME) or (not self.is_competitive)
591594

@@ -854,18 +857,6 @@ def goto_firstposition(self):
854857
self.refresh_pgn() # No se puede usar pgn_refresh, ya que se usa con gobottom en otros lados y aqui eso no funciona
855858
self.put_view()
856859

857-
# def ponteAlPrincipioColor(self):
858-
# if self.game.li_moves:
859-
# move = self.game.move(0)
860-
# self.set_position(move.position)
861-
# self.main_window.base.pgn.goto(0, 2 if move.position.is_white else 1)
862-
# self.board.put_arrow_sc(move.from_sq, move.to_sq)
863-
# self.refresh_pgn() # No se puede usar pgn_refresh, ya que se usa con gobottom en otros lados
864-
# # y aqui eso no funciona
865-
# self.put_view()
866-
# else:
867-
# self.goto_firstposition()
868-
869860
def pgnMueve(self, row, is_white):
870861
self.pgn.mueve(row, is_white)
871862
self.put_view()

bin/Code/Openings/POLAnalisis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ def __init__(self, owner):
493493
self.tab_database = owner
494494
self.board = self.tab_database.tabsAnalisis.panelOpening.pboard.board
495495

496-
def modoPartida(self, x, y):
496+
def game_mode(self, x, y):
497497
return True
498498

499499

bin/Code/Openings/POLBoard.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def __init__(self, panelOpening, configuration):
8181
self.lbPGN.setOpenExternalLinks(False)
8282

8383
def muestra_pos(txt):
84-
self.colocatePartida(int(txt))
84+
self.goto_move_num(int(txt))
8585

8686
self.lbPGN.linkActivated.connect(muestra_pos)
8787

@@ -210,7 +210,7 @@ def resetValues(self):
210210
self.cbVentaja.set_value(V_SIN)
211211
self.emComentario.set_text("")
212212

213-
def colocatePartida(self, pos):
213+
def goto_move_num(self, pos):
214214
self.fenm2 = None
215215
num_jugadas = len(self.game)
216216
if num_jugadas == 0:
@@ -294,16 +294,16 @@ def activaPiezas(self):
294294
self.board.activate_side(color)
295295

296296
def MoverInicio(self):
297-
self.colocatePartida(0)
297+
self.goto_move_num(0)
298298

299299
def MoverAtras(self):
300-
self.colocatePartida(self.pos_move - 1)
300+
self.goto_move_num(self.pos_move - 1)
301301

302302
def MoverAdelante(self):
303-
self.colocatePartida(self.pos_move + 1)
303+
self.goto_move_num(self.pos_move + 1)
304304

305305
def MoverFinal(self):
306-
self.colocatePartida(99999)
306+
self.goto_move_num(99999)
307307

308308
def MoverTiempo(self):
309309
if self.clock_running:

0 commit comments

Comments
 (0)