def new(self): si_expl = len(self.listaOpenings) < 4 if si_expl: QTUtil2.mensaje(self, _("First you must select the initial moves.")) w = PantallaAperturas.WAperturas(self, self.configuracion, None) if w.exec_(): ap = w.resultado() pv = ap.a1h8 if ap else "" name = ap.nombre if ap else "" else: return if si_expl: QTUtil2.mensaje(self, _("Secondly you have to choose a name for this opening studio.")) liGen = [(None, None)] liGen.append((_("Opening studio name") + ":", name)) resultado = FormLayout.fedit(liGen, title=_("Opening studio name"), parent=self, icon=Iconos.OpeningLines(), anchoMinimo=460) if resultado: accion, liResp = resultado name = liResp[0] if name: file = self.listaOpenings.select_filename(name) self.listaOpenings.new(file, pv, name) self.resultado = self.listaOpenings[-1] self.guardarVideo() self.accept()
def new(self): si_expl = len(self.listaOpenings) < 4 if si_expl: QTUtil2.mensaje(self, _("First you must select the initial moves.")) w = PantallaAperturas.WAperturas(self, self.configuracion, None) if w.exec_(): ap = w.resultado() pv = ap.a1h8 if ap else "" name = ap.nombre if ap else "" else: return if si_expl: QTUtil2.mensaje( 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.guardarVideo() self.accept()
def importarApertura(self, partida): partida.asignaApertura() w = PantallaAperturas.WAperturas(self, self.configuracion, partida.apertura) if w.exec_(): ap = w.resultado() partida = Partida.Partida() partida.leerPV(ap.a1h8) self.addPartida(partida)
def aperturas(self): w = PantallaAperturas.EntrenamientoAperturas(self.procesador) if w.exec_(): listaAperturasStd, ficheroDatos, lista, fila, jugamos, repeticiones = w.resultado self.procesador.gestor = GestorAperturas.GestorAperturas( self.procesador) self.procesador.gestor.inicio(listaAperturasStd, ficheroDatos, lista, fila, jugamos, repeticiones, 0)
def editarApertura(self): self.btApertura.setDisabled(True) # Puede tardar bastante tiempo me = QTUtil2.unMomento(self) w = PantallaAperturas.WAperturas(self, self.configuracion, self.bloqueApertura) me.final() self.btApertura.setDisabled(False) if w.exec_(): self.bloqueApertura = w.resultado() self.muestraApertura()
def opening(): me = QTUtil2.unMomento(self) import Code.QT.PantallaAperturas as PantallaAperturas w = PantallaAperturas.WAperturas(self, self.configuracion, self.last_opening) me.final() if w.exec_(): self.last_opening = ap = w.resultado() pv = getattr(ap, "a1h8", "") self.dbGames.filterPV(pv) self.numJugada = pv.count(" ") refresh()
def opening(): me = QTUtil2.unMomento(self) import Code.QT.PantallaAperturas as PantallaAperturas w = PantallaAperturas.WAperturas(self, self.configuracion, "") me.final() if w.exec_(): ap = w.resultado() pv = getattr(ap, "a1h8", "") self.dbGames.filterPV(pv) self.numJugada = pv.count(" ") self.grid.gotop() self.grid.refresh() self.updateStatus() self.gridCambiadoRegistro(None, 0, 0)
def aperturaspers(self): w = PantallaAperturas.AperturasPersonales(self) w.exec_()
def configurarGS(self): sep = (None, None, None) liMasOpciones = [ ("rotacion", _("Auto-rotate board"), Iconos.JS_Rotacion()), sep, ("apertura", _("Opening"), Iconos.Apertura()), sep, ("posicion", _("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, ("voyager", _("Voyager 2"), Iconos.Voyager1()), ] resp = self.configurar(liMasOpciones, siCambioTutor=True, siSonidos=True) if resp == "rotacion": self.siVolteoAutomatico = not self.siVolteoAutomatico siBlancas = self.partida.ultPosicion.siBlancas if self.siVolteoAutomatico: if siBlancas != self.tablero.siBlancasAbajo: self.tablero.rotaTablero() elif resp == "apertura": bl, ps = PantallaAperturas.dameApertura(self.pantalla, self.configuracion, self.bloqueApertura, self.posicApertura) if bl: self.bloqueApertura = bl self.posicApertura = ps self.fen = None self.reiniciar() elif resp == "posicion": resp = XVoyager.xVoyagerFEN(self.pantalla, self.configuracion, self.fen) if resp is not None: self.fen = resp self.bloqueApertura = None self.posicApertura = None if self.xpgn: siInicio = self.fen == ControlPosicion.FEN_INICIAL li = self.xpgn.split("\n") lin = [] siFen = False for linea in li: if linea.startswith("["): if "FEN " in linea: siFen = True if siInicio: continue linea = '[FEN "%s"]' % self.fen lin.append(linea) else: break if not siFen: linea = '[FEN "%s"]' % self.fen lin.append(linea) self.liPGN = lin self.xpgn = "\n".join(lin) + "\n\n*" self.reiniciar() elif resp == "pasteposicion": texto = QTUtil.traePortapapeles() if texto: cp = ControlPosicion.ControlPosicion() try: cp.leeFen(str(texto)) self.fen = cp.fen() self.bloqueApertura = None self.posicApertura = None self.reiniciar() except: pass elif resp == "leerpgn": unpgn = PantallaPGN.eligePartida(self.pantalla) if unpgn: self.bloqueApertura = None self.posicApertura = None self.fen = unpgn.dic.get("FEN", None) dic = self.creaDic() dic["PARTIDA"] = unpgn.partida.guardaEnTexto() dic["liPGN"] = unpgn.listaCabeceras() dic["FEN"] = self.fen dic["SIBLANCASABAJO"] = unpgn.partida.ultPosicion.siBlancas self.reiniciar(dic) elif resp == "pastepgn": texto = QTUtil.traePortapapeles() if texto: unpgn = PGN.UnPGN() unpgn.leeTexto(texto) if unpgn.siError: QTUtil2.mensError(self.pantalla, _("The text from the clipboard does not contain a chess game in PGN format")) return self.bloqueApertura = None self.posicApertura = None self.fen = unpgn.dic.get("FEN", None) dic = self.creaDic() dic["PARTIDA"] = unpgn.partida.guardaEnTexto() dic["liPGN"] = unpgn.listaCabeceras() dic["FEN"] = self.fen dic["SIBLANCASABAJO"] = unpgn.partida.ultPosicion.siBlancas self.reiniciar(dic) elif resp == "voyager": ptxt = XVoyager.xVoyager(self.pantalla, self.configuracion, partida=self.partida) if ptxt: dic = self.creaDic() dic["PARTIDA"] = ptxt p = self.partida.copia() p.recuperaDeTexto(ptxt) dic["FEN"] = None if p.siFenInicial() else p.iniPosicion.fen() dic["SIBLANCASABAJO"] = self.tablero.siBlancasAbajo self.reiniciar(dic)
def configurarGS(self): mt = _("Engine").lower() mt = _X(_("Disable %1"), mt) if self.siJuegaMotor else _X(_("Enable %1"), mt) sep = (None, None, None) liMasOpciones = [ ("rotacion", _("Auto-rotate board"), Iconos.JS_Rotacion()), sep, ("apertura", _("Opening"), Iconos.Apertura()), sep, ("posicion", _("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, ("motor", mt, Iconos.Motores()), sep, ("voyager", _("Voyager 2"), Iconos.Voyager1()), ] resp = self.configurar(liMasOpciones, siCambioTutor=True, siSonidos=True) if resp == "rotacion": self.siVolteoAutomatico = not self.siVolteoAutomatico siBlancas = self.partida.ultPosicion.siBlancas if self.siVolteoAutomatico: if siBlancas != self.tablero.siBlancasAbajo: self.tablero.rotaTablero() elif resp == "apertura": me = self.unMomento() w = PantallaAperturas.WAperturas(self.pantalla, self.configuracion, self.bloqueApertura) me.final() if w.exec_(): self.bloqueApertura = w.resultado() # self.posicApertura = ps self.fen = None self.reiniciar() elif resp == "posicion": self.startPosition() elif resp == "pasteposicion": texto = QTUtil.traePortapapeles() if texto: cp = ControlPosicion.ControlPosicion() try: cp.leeFen(str(texto)) self.fen = cp.fen() self.bloqueApertura = None self.posicApertura = None self.reiniciar() except: pass elif resp == "leerpgn": unpgn = PantallaPGN.eligePartida(self.pantalla) if unpgn: self.bloqueApertura = None self.posicApertura = None self.fen = unpgn.dic.get("FEN", None) dic = self.creaDic() dic["PARTIDA"] = unpgn.partida.guardaEnTexto() dic["liPGN"] = unpgn.listaCabeceras() dic["FEN"] = self.fen dic["SIBLANCASABAJO"] = unpgn.partida.ultPosicion.siBlancas self.reiniciar(dic) elif resp == "pastepgn": texto = QTUtil.traePortapapeles() if texto: unpgn = PGN.UnPGN() unpgn.leeTexto(texto) if unpgn.siError: QTUtil2.mensError(self.pantalla, _("The text from the clipboard does not contain a chess game in PGN format")) return self.bloqueApertura = None self.posicApertura = None self.fen = unpgn.dic.get("FEN", None) dic = self.creaDic() dic["PARTIDA"] = unpgn.partida.guardaEnTexto() dic["liPGN"] = unpgn.listaCabeceras() dic["FEN"] = self.fen dic["SIBLANCASABAJO"] = unpgn.partida.ultPosicion.siBlancas self.reiniciar(dic) elif resp == "motor": self.ponRotulo1("") if self.siJuegaMotor: if self.xrival: self.xrival.terminar() self.xrival = None self.siJuegaMotor = False else: self.cambioRival() elif resp == "voyager": ptxt = Voyager.voyagerPartida(self.pantalla, self.partida) if ptxt: dic = self.creaDic() dic["PARTIDA"] = ptxt p = self.partida.copia() p.recuperaDeTexto(ptxt) dic["FEN"] = None if p.siFenInicial() else p.iniPosicion.fen() dic["SIBLANCASABAJO"] = self.tablero.siBlancasAbajo self.reiniciar(dic)
def configurarGS(self): # self.test() # return mt = _("Engine").lower() mt = _X(_("Disable %1"), mt) if self.siJuegaMotor else _X(_("Enable %1"), mt) sep = ( None, None, None ) liMasOpciones = [ ( "rotacion", _("Auto-rotate board"), Iconos.JS_Rotacion() ), sep, ( "apertura", _("Opening"), Iconos.Apertura() ), sep, ( "posicion", _("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, ( "motor", mt, Iconos.Motores() ), sep, ( "voyager", _("Voyager 2").replace("2", "1"), Iconos.Voyager1() ), ] if self.configuracion.voice: liMasOpciones.append(sep) if self.activeVoice: liMasOpciones.append(( "desvoice", _("Deactivate voice"), Iconos.X_Microfono() )) else: liMasOpciones.append(( "actvoice", _("Activate voice"), Iconos.S_Microfono() )) resp = self.configurar(liMasOpciones, siCambioTutor=True, siSonidos=True) if resp == "rotacion": self.siVolteoAutomatico = not self.siVolteoAutomatico siBlancas = self.partida.ultPosicion.siBlancas if self.siVolteoAutomatico: if siBlancas != self.tablero.siBlancasAbajo: self.tablero.rotaTablero() elif resp == "apertura": bl, ps = PantallaAperturas.dameApertura(self.pantalla, self.configuracion, self.bloqueApertura, self.posicApertura) if bl: self.bloqueApertura = bl self.posicApertura = ps self.fen = None self.reiniciar() elif resp == "posicion": resp = WinPosition.editarPosicion(self.pantalla, self.configuracion, self.fen) if resp is not None: self.fen = resp self.bloqueApertura = None self.posicApertura = None if self.xpgn: siInicio = self.fen == ControlPosicion.FEN_INICIAL li = self.xpgn.split("\n") lin = [] siFen = False for linea in li: if linea.startswith("["): if "FEN " in linea: siFen = True if siInicio: continue linea = '[FEN "%s"]' % self.fen lin.append(linea) else: break if not siFen: linea = '[FEN "%s"]' % self.fen lin.append(linea) self.liPGN = lin self.xpgn = "\n".join(lin) + "\n\n*" self.reiniciar() elif resp == "pasteposicion": texto = QTUtil.traePortapapeles() if texto: cp = ControlPosicion.ControlPosicion() try: cp.leeFen(str(texto)) self.fen = cp.fen() self.bloqueApertura = None self.posicApertura = None self.reiniciar() except: pass elif resp == "leerpgn": unpgn = PantallaPGN.eligePartida(self.pantalla) if unpgn: self.bloqueApertura = None self.posicApertura = None self.fen = unpgn.dic.get("FEN", None) dic = self.creaDic() dic["PARTIDA"] = unpgn.partida.guardaEnTexto() dic["liPGN"] = unpgn.listaCabeceras() dic["FEN"] = self.fen dic["SIBLANCASABAJO"] = unpgn.partida.ultPosicion.siBlancas self.reiniciar(dic) elif resp == "pastepgn": texto = QTUtil.traePortapapeles() if texto: unpgn = PGN.UnPGN() unpgn.leeTexto(texto) if unpgn.siError: QTUtil2.mensError(self.pantalla, _("The text from the clipboard does not contain a chess game in PGN format")) return self.bloqueApertura = None self.posicApertura = None self.fen = unpgn.dic.get("FEN", None) dic = self.creaDic() dic["PARTIDA"] = unpgn.partida.guardaEnTexto() dic["liPGN"] = unpgn.listaCabeceras() dic["FEN"] = self.fen dic["SIBLANCASABAJO"] = unpgn.partida.ultPosicion.siBlancas self.reiniciar(dic) elif resp == "motor": self.ponRotulo1("") if self.siJuegaMotor: self.xrival.terminar() self.xrival = None self.siJuegaMotor = False else: self.cambioRival() elif resp == "voyager": ptxt = XVoyager.xVoyager(self.pantalla, self.configuracion, self.partida) if ptxt: dic = self.creaDic() dic["PARTIDA"] = ptxt p = self.partida.copia() p.recuperaDeTexto(ptxt) dic["FEN"] = None if p.siFenInicial() else p.iniPosicion.fen() dic["SIBLANCASABAJO"] = self.tablero.siBlancasAbajo self.reiniciar(dic) elif resp == "actvoice": self.setVoice( True ) elif resp == "desvoice": self.setVoice( False )