def editAnalisis(self, item, mov): # Hay un analysis -> se muestra en variantes # Analisis.show_analysis( self.procesador, self.xtutor, move, is_white, max_recursion, pos ) fen = mov.game.last_position.fen() rm = mov.analysis() if rm is None: return game = Game.Game(mov.game.last_position) game.read_pv(rm.pv) lineaPGN = game.pgnBaseRAW() wowner = self.owner board = wowner.infoMove.board import Code.Variations as Variations Variations.edit_variation_moves( self.procesador, wowner, board.is_white_bottom, fen, lineaPGN, titulo=mov.titulo + " - " + mov.etiPuntos(True), )
def edit_variations(self, item, mov): import Code.Variations as Variations if mov.variantes: menu = QTVarios.LCMenu(self) for num, una in enumerate(mov.variantes): menu.opcion(num, una[:40], Iconos.PuntoAzul()) menu.separador() menu.opcion(-1, _("New variation"), Iconos.Mas()) menu.separador() menub = menu.submenu(_("Remove"), Iconos.Delete()) for num, una in enumerate(mov.variantes): menub.opcion(-num - 2, una[:40], Iconos.PuntoNaranja()) resp = menu.lanza() if resp is None: return None if resp == -1: num = None lineaPGN = "" elif resp >= 0: num = resp lineaPGN = mov.variantes[num] else: num = -resp - 2 una = mov.variantes[num] if QTUtil2.pregunta(self, _X(_("Delete %1?"), una[:40])): del mov.variantes[num] self.ponVariations(mov) return else: lineaPGN = "" num = None fen = mov.game.last_position.fen() wowner = self.owner board = wowner.infoMove.board resp = Variations.edit_variation_moves(self.procesador, wowner, board.is_white_bottom, fen, lineaPGN) if resp: una = resp[0] if num is None: mov.variantes.append(una) self.ponVariations(mov) else: mov.variantes[num] = una
def edit(self, number, with_engine_active=False): game = None if number > -1: li_variations = self.li_variations() if li_variations: game = li_variations[number] else: number = -1 if number == -1: game = Game.Game(ini_posicion=self.move.position_before) change_game = Variations.edit_variation( Code.procesador, game, with_engine_active=with_engine_active, is_white_bottom=self.get_board().is_white_bottom ) if change_game: self.move.variations.change(number, change_game) self.mostrar()
def edit(self, row): if row is None: name = "" eco = "" pgn = "" estandar = True titulo = _("New opening") else: reg = self.lista[row] name = reg["NOMBRE"] eco = reg["ECO"] pgn = reg["PGN"] estandar = reg["ESTANDAR"] titulo = name # Datos liGen = [(None, None)] liGen.append((_("Name") + ":", name)) config = FormLayout.Editbox("ECO", ancho=30, rx="[A-Z, a-z][0-9][0-9]") liGen.append((config, eco)) liGen.append((_("Add to standard list") + ":", estandar)) # Editamos resultado = FormLayout.fedit(liGen, title=titulo, parent=self, anchoMinimo=460, icon=Iconos.Opening()) if resultado is None: return accion, liResp = resultado name = liResp[0].strip() if not name: return eco = liResp[1].upper() estandar = liResp[2] fen = FEN_INITIAL self.procesador.procesador = self.procesador # ya que edit_variation espera un manager if pgn: ok, game = Game.pgn_game(pgn) if not ok: game = Game.Game() else: game = Game.Game() resp = Variations.edit_variation(self.procesador, game, titulo=name, is_white_bottom=True) if resp: game = resp reg = {} reg["NOMBRE"] = name reg["ECO"] = eco reg["PGN"] = game.pgnBaseRAW() reg["A1H8"] = game.pv() reg["ESTANDAR"] = estandar if row is None: self.lista.append(reg) self.grid.refresh() self.grabar() else: self.lista[row] = reg self.grid.refresh() self.grabar()