def new(self): si_expl = len(self.listaOpenings) < 4 if si_expl: QTUtil2.message_bold(self, _("First you must select the initial moves.")) w = WindowOpenings.WOpenings(self, self.configuration, None) if w.exec_(): ap = w.resultado() pv = ap.a1h8 if ap else "" name = ap.name if ap else "" else: return if si_expl: QTUtil2.message_bold( self, _("Secondly you have to choose a name for this opening studio." )) name = self.get_nombre(name) if name: file = self.listaOpenings.select_filename(name) self.listaOpenings.new(file, pv, name) self.resultado = self.listaOpenings[-1] self.save_video() self.accept()
def importarOpening(self, game): game.assign_opening() w = WindowOpenings.WOpenings(self, self.configuration, game.opening) if w.exec_(): ap = w.resultado() game = Game.Game() game.read_pv(ap.a1h8) self.addPartida(game)
def aperturasEditar(self): self.btOpening.setDisabled(True) # Puede tardar bastante vtime me = QTUtil2.unMomento(self) w = WindowOpenings.WOpenings(self, self.configuration, self.opening_block) me.final() self.btOpening.setDisabled(False) if w.exec_(): self.opening_block = w.resultado() self.aperturaMuestra()
def utilities_gs(self): mt = _("Engine").lower() mt = _X(_("Disable %1"), mt) if self.play_against_engine else _X( _("Enable %1"), mt) sep = (None, None, None) liMasOpciones = ( (None, _("Change the initial position"), Iconos.PGN()), sep, ("position", _("Edit start position") + " [S]", Iconos.Datos()), sep, ("initial", _("Basic position") + " [B]", Iconos.Board()), sep, ("opening", _("Opening"), Iconos.Opening()), sep, ("pasteposicion", _("Paste FEN position") + " [V]", Iconos.Pegar16()), sep, ("leerpgn", _("Read PGN file"), Iconos.PGN_Importar()), sep, ("pastepgn", _("Paste PGN") + " [V]", Iconos.Pegar16()), sep, ("voyager", _("Voyager 2"), Iconos.Voyager()), (None, None, True), sep, ("books", _("Consult a book"), Iconos.Libros()), sep, ("engine", mt, Iconos.Motores()), sep, ) resp = self.utilidades(liMasOpciones) if resp == "books": liMovs = self.librosConsulta(True) if liMovs: for x in range(len(liMovs) - 1, -1, -1): from_sq, to_sq, promotion = liMovs[x] self.player_has_moved(from_sq, to_sq, promotion) elif resp == "initial": self.basic_initial_position() elif resp == "opening": me = self.unMomento() w = WindowOpenings.WOpenings(self.main_window, self.configuration, self.opening_block) me.final() if w.exec_(): self.opening_block = w.resultado() self.xfichero = None self.xpgn = None self.xjugadaInicial = None self.reiniciar() elif resp == "position": self.startPosition() elif resp == "pasteposicion": texto = QTUtil.traePortapapeles() if texto: cp = Position.Position() try: cp.read_fen(str(texto)) self.xfichero = None self.xpgn = None self.xjugadaInicial = None self.new_game() self.game.set_position(first_position=cp) self.opening_block = None self.reiniciar() except: pass elif resp == "leerpgn": self.leerpgn() elif resp == "pastepgn": texto = QTUtil.traePortapapeles() if texto: ok, game = Game.pgn_game(texto) if not ok: QTUtil2.message_error( self.main_window, _("The text from the clipboard does not contain a chess game in PGN format" )) return self.xfichero = None self.xpgn = None self.xjugadaInicial = None self.opening_block = None dic = self.creaDic() dic["GAME"] = game.save() dic["WHITEBOTTOM"] = game.first_position.is_white self.reiniciar(dic) elif resp == "engine": self.set_label1("") if self.play_against_engine: if self.xrival: self.xrival.terminar() self.xrival = None self.play_against_engine = False else: self.cambioRival() elif resp == "voyager": ptxt = Voyager.voyagerPartida(self.main_window, self.game) if ptxt: self.xfichero = None self.xpgn = None self.xjugadaInicial = None dic = self.creaDic() dic["GAME"] = ptxt dic["WHITEBOTTOM"] = self.board.is_white_bottom self.reiniciar(dic)
def configurarGS(self): mt = _("Engine").lower() mt = _X(_("Disable %1"), mt) if self.play_against_engine else _X( _("Enable %1"), mt) sep = (None, None, None) liMasOpciones = [ ("rotacion", _("Auto-rotate board"), Iconos.JS_Rotacion()), sep, ("opening", _("Opening"), Iconos.Opening()), sep, ("position", _("Edit start position"), Iconos.Datos()), sep, ("pasteposicion", _("Paste FEN position"), Iconos.Pegar16()), sep, ("leerpgn", _("Read PGN"), Iconos.PGN_Importar()), sep, ("pastepgn", _("Paste PGN"), Iconos.Pegar16()), sep, ("engine", mt, Iconos.Motores()), sep, ("voyager", _("Voyager 2"), Iconos.Voyager()), ] resp = self.configurar(liMasOpciones, siCambioTutor=True, siSonidos=True) if resp == "rotacion": self.auto_rotate = not self.auto_rotate is_white = self.game.last_position.is_white if self.auto_rotate: if is_white != self.board.is_white_bottom: self.board.rotaBoard() elif resp == "opening": me = self.unMomento() w = WindowOpenings.WOpenings(self.main_window, self.configuration, self.opening_block) me.final() if w.exec_(): self.opening_block = w.resultado() self.xfichero = None self.xpgn = None self.xjugadaInicial = None self.reiniciar() elif resp == "position": self.startPosition() elif resp == "pasteposicion": texto = QTUtil.traePortapapeles() if texto: cp = Position.Position() try: cp.read_fen(str(texto)) self.xfichero = None self.xpgn = None self.xjugadaInicial = None self.new_game() self.game.set_position(first_position=cp) self.opening_block = None self.reiniciar() except: pass elif resp == "leerpgn": self.leerpgn() elif resp == "pastepgn": texto = QTUtil.traePortapapeles() if texto: ok, game = Game.pgn_game(texto) if not ok: QTUtil2.message_error( self.main_window, _("The text from the clipboard does not contain a chess game in PGN format" )) return self.xfichero = None self.xpgn = None self.xjugadaInicial = None self.opening_block = None dic = self.creaDic() dic["GAME"] = game.save() dic["WHITEBOTTOM"] = game.first_position.is_white self.reiniciar(dic) elif resp == "engine": self.set_label1("") if self.play_against_engine: if self.xrival: self.xrival.terminar() self.xrival = None self.play_against_engine = False else: self.cambioRival() elif resp == "voyager": ptxt = Voyager.voyagerPartida(self.main_window, self.game) if ptxt: self.xfichero = None self.xpgn = None self.xjugadaInicial = None dic = self.creaDic() dic["GAME"] = ptxt dic["WHITEBOTTOM"] = self.board.is_white_bottom self.reiniciar(dic)