def haz_menu(frommenu, game_base, all=True): if all: liOp = self.dbop.getOtras(self.configuration, game_base) if liOp: otra = frommenu.submenu(_("Other opening lines"), Iconos.OpeningLines()) for file, titulo in liOp: otra.opcion(("ol", (file, game_base)), titulo, Iconos.PuntoVerde()) frommenu.separador() frommenu.opcion(("pgn", game_base), _("PGN with variations"), Iconos.Board()) frommenu.separador() frommenu.opcion(("polyglot", game_base), _("Polyglot book"), Iconos.Libros()) frommenu.separador() frommenu.opcion(("summary", game_base), _("Database summary"), Iconos.Database()) if all: frommenu.separador() frommenu.opcion(("voyager2", game_base), _("Voyager 2"), Iconos.Voyager()) frommenu.separador() frommenu.opcion(("opening", game_base), _("Opening"), Iconos.Opening())
def importar(self): menu = QTVarios.LCMenu(self.wpolyglot) menu.opcion("pgn", _("PGN"), Iconos.Board()) menu.separador() menu.opcion("database", _("Database"), Iconos.Database()) menu.separador() menu.opcion("polyglot", _("Polyglot book"), Iconos.Libros()) menu.separador() resp = menu.lanza() if resp == "pgn": self.import_pgn() elif resp == "database": self.import_db() elif resp == "polyglot": self.import_polyglot()
def utilidades(self): menu = QTVarios.LCMenu(self) submenu = menu.submenu(_("Import"), Iconos.Import8()) submenu.opcion("examples", _("Examples"), Iconos.Gafas()) submenu.separador() submenu.opcion("pgn", _("PGN"), Iconos.Board()) submenu.separador() submenu.opcion("database", _("Database"), Iconos.Database()) submenu.separador() submenu.opcion("fns", _("Text file"), Iconos.Fichero()) menu.separador() submenu = menu.submenu(_("Remove"), Iconos.Delete()) submenusubmenu1 = submenu.submenu(_("Positions"), Iconos.TrainPositions()) submenusubmenu1.opcion("remp_all", _("Remove all positions"), Iconos.PuntoRojo()) submenusubmenu1.opcion("remp_all_group", _("Remove all positions of current group"), Iconos.PuntoRojo()) submenu.separador() submenusubmenu2 = submenu.submenu(_("Results"), Iconos.Reciclar()) submenusubmenu2.opcion("remr_all", _("Remove results of all positions"), Iconos.PuntoNaranja()) submenusubmenu2.opcion( "remr_all_group", _("Remove results of all positions of current group"), Iconos.PuntoNaranja()) menu.separador() resp = menu.lanza() if resp is None: return if resp == "pgn": self.import_pgn() elif resp == "database": self.import_db() elif resp == "examples": self.import_examples() elif resp == "fns": self.import_fns() elif resp.startswith("remr"): self.remove_all_results(resp[9:]) elif resp.startswith("remp"): self.remove_all_positions(resp[9:])
def __init__(self, owner, dicdatos): self.dicdatos = dicdatos site = dicdatos["SITE"] self.level = dicdatos["LEVEL"] self.intervalo = dicdatos["INTERVAL"] self.intervaloPorPieza = dicdatos["INTERVALPIECE"] self.esatacada = dicdatos["ISATTACKED"] self.esatacante = dicdatos["ISATTACKING"] self.position = dicdatos["POSITION"] self.color = dicdatos["COLOR"] self.errors = dicdatos["ERRORS"] self.time = dicdatos["TIME"] self.liFENs = dicdatos["FENS"] mas = "x" if self.intervaloPorPieza else "" titulo = '%s (%s%d")' % (site, mas, self.intervalo) super(WPlay, self).__init__(owner, titulo, Iconos.Gafas(), "visualplay") self.procesador = owner.procesador self.configuration = self.procesador.configuration # Tiempo en board intervaloMax = self.intervalo if self.intervaloPorPieza: intervaloMax *= 32 # Board config_board = self.configuration.config_board("VISUALPLAY", 48) self.board = Board.Board(self, config_board) self.board.crea() lyT = Colocacion.V().control(self.board) self.gbBoard = Controles.GB(self, "", lyT) # entradas ly = Colocacion.G() self.posPosicion = None self.posColor = None self.posIsAttacked = None self.posIsAttacking = None lista = [_("Piece")] if self.position: lista.append(_("Position")) if self.color: lista.append(_("Square color")) if self.esatacada: lista.append(_("Is attacked?")) if self.esatacante: lista.append(_("Is attacking?")) self.liLB2 = [] for col, eti in enumerate(lista): ly.control(Controles.LB(self, eti), 0, col + 1) lb2 = Controles.LB(self, eti) ly.control(lb2, 0, col + len(lista) + 2) self.liLB2.append(lb2) elementos = len(lista) + 1 liComboPieces = [] for c in "PNBRQKpnbrqk": liComboPieces.append(("", c, self.board.piezas.icono(c))) self.pmBien = Iconos.pmAceptarPeque() self.pmMal = Iconos.pmCancelarPeque() self.pmNada = Iconos.pmPuntoAmarillo() self.liBloques = [] for x in range(32): row = x % 16 + 1 colPos = elementos if x > 15 else 0 unBloque = [] self.liBloques.append(unBloque) # # Solucion lb = Controles.LB(self, "").ponImagen(self.pmNada) ly.control(lb, row, colPos) unBloque.append(lb) # # Piezas colPos += 1 cb = Controles.CB(self, liComboPieces, "P") # cb.setStyleSheet("* { min-height:32px }") cb.setIconSize(QtCore.QSize(20, 20)) ly.control(cb, row, colPos) unBloque.append(cb) if self.position: ec = Controles.ED(self, "").caracteres(2).controlrx("(|[a-h][1-8])").anchoFijo(24).align_center() colPos += 1 ly.controlc(ec, row, colPos) unBloque.append(ec) if self.color: cl = QTVarios.TwoImages(Iconos.pmBlancas(), Iconos.pmNegras()) colPos += 1 ly.controlc(cl, row, colPos) unBloque.append(cl) if self.esatacada: isat = QTVarios.TwoImages(Iconos.pmAtacada().scaledToWidth(24), Iconos.pmPuntoNegro()) colPos += 1 ly.controlc(isat, row, colPos) unBloque.append(isat) if self.esatacante: at = QTVarios.TwoImages(Iconos.pmAtacante().scaledToWidth(24), Iconos.pmPuntoNegro()) colPos += 1 ly.controlc(at, row, colPos) unBloque.append(at) ly1 = Colocacion.H().otro(ly).relleno() ly2 = Colocacion.V().otro(ly1).relleno() self.gbSolucion = Controles.GB(self, "", ly2) f = Controles.TipoLetra("", 11, 80, False, False, False, None) bt = Controles.PB(self, _("Close"), self.terminar, plano=False).ponIcono(Iconos.MainMenu()).ponFuente(f) self.btBoard = Controles.PB(self, _("Go to board"), self.activaBoard, plano=False).ponIcono(Iconos.Board()).ponFuente(f) self.btComprueba = ( Controles.PB(self, _("Test the solution"), self.compruebaSolucion, plano=False).ponIcono(Iconos.Check()).ponFuente(f) ) self.btGotoNextLevel = ( Controles.PB(self, _("Go to next level"), self.gotoNextLevel, plano=False).ponIcono(Iconos.GoToNext()).ponFuente(f) ) ly0 = Colocacion.H().control(bt).relleno().control(self.btBoard).control(self.btComprueba).control(self.btGotoNextLevel) lyBase = Colocacion.H().control(self.gbBoard).control(self.gbSolucion) layout = Colocacion.V().otro(ly0).otro(lyBase) self.setLayout(layout) self.restore_video() self.gotoNextLevel()
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)