diff --git a/Code/Configuracion.py b/Code/Configuracion.py index c14ac5c..52fab59 100644 --- a/Code/Configuracion.py +++ b/Code/Configuracion.py @@ -4,6 +4,7 @@ import os from PyQt4 import QtGui +from PyQt4.QtCore import Qt from Code import BaseConfig from Code import CajonDesastre @@ -110,6 +111,7 @@ def __init__(self, user): self.puntosTB = 11 self.boldTB = False + self.iconsTB = Qt.ToolButtonTextUnderIcon self.centipawns = False @@ -467,6 +469,7 @@ def graba(self, aplazamiento=None): dic["PUNTOSTB"] = self.puntosTB dic["BOLDTB"] = self.boldTB + dic["ICONSTB"] = self.iconsTB dic["COLOR_NAG1"] = self.color_nag1 dic["COLOR_NAG2"] = self.color_nag2 @@ -591,6 +594,7 @@ def lee(self): self.puntosTB = dg("PUNTOSTB", self.puntosTB) self.boldTB = dg("BOLDTB", self.boldTB) + self.iconsTB = dg("ICONSTB", self.iconsTB) self.color_nag1 = dg("COLOR_NAG1", self.color_nag1) self.color_nag2 = dg("COLOR_NAG2", self.color_nag2) diff --git a/Code/GM.py b/Code/GM.py index d3497c6..29d50f8 100644 --- a/Code/GM.py +++ b/Code/GM.py @@ -226,7 +226,10 @@ def listaGMpersonal(carpeta): siW = siB = False with open(os.path.join(carpeta, fich)) as f: for linea in f: - gmp = GMpartida(linea.strip()) + try: + gmp = GMpartida(linea.strip()) + except: + continue if not siW: siW = gmp.isWhite(True) if not siB: @@ -337,7 +340,10 @@ def masMaderaUno(self, dic, partida, xblancas, xnegras, tpResult): else: if not (siEmpate or (xblancas and siGanaBlancas) or (xnegras and siGanaNegras)): return - self.write("%s|%s|%s|%s|%s|%s|%s\n" % (pv2xpv(pk.strip()), event, oponente, date, eco, result, color)) + def nopipe(txt): + return txt.replace("|", " ").strip() if "|" in txt else txt + + self.write("%s|%s|%s|%s|%s|%s|%s\n" % (pv2xpv(pk.strip()), nopipe(event), nopipe(oponente), nopipe(date), eco, result, color)) def xprocesa(self): self.close() diff --git a/Code/Gestor.py b/Code/Gestor.py index 10cc782..e2335d7 100644 --- a/Code/Gestor.py +++ b/Code/Gestor.py @@ -97,6 +97,8 @@ def __init__(self, procesador): # Informacion self.informacionActivable = True + self.nonDistract = None + # x Control del tutor # asi sabemos si ha habido intento de analisis previo (por ejemplo el usuario mientras piensa decide activar el tutor) self.siIniAnalizaTutor = False @@ -127,6 +129,8 @@ def ponFinJuego(self): def finGestor(self): # se llama desde procesador.inicio, antes de borrar el gestor self.tablero.atajosRaton = None + if self.nonDistract: + self.pantalla.base.tb.setVisible(True) def atajosRatonReset(self): self.atajosRatonDestino = None @@ -711,7 +715,6 @@ def guardarPGN(self): "It is saved in the clipboard to paste it wherever you want."))) def guardarGanados(self, siGanado): - conf = self.configuracion if siGanado: @@ -758,6 +761,21 @@ def quitaCapturas(self): self.pantalla.activaCapturas(False) self.ponVista() + def rightMouse(self, siShift, siControl, siAlt): + if siControl: + self.capturas() + elif siAlt: + self.nonDistract = self.pantalla.base.nonDistractMode(self.nonDistract) + else: + self.pgnInformacion(None, None) + self.pantalla.ajustaTam() + + def boardRightMouse(self, siShift, siControl, siAlt): + self.rightMouse(siShift, siControl, siAlt) + + def gridRightMouse(self, siShift, siControl, siAlt): + self.rightMouse(siShift, siControl, siAlt) + def listado(self, tipo): if tipo == "pgn": return self.pgn.actual() diff --git a/Code/GestorEntPos.py b/Code/GestorEntPos.py index 7285e14..c79e835 100644 --- a/Code/GestorEntPos.py +++ b/Code/GestorEntPos.py @@ -1,6 +1,8 @@ import codecs import os +from PyQt4.QtCore import Qt + from Code import ControlPosicion from Code import Gestor from Code import Jugada @@ -239,15 +241,22 @@ def ent_siguiente(self, tipo): self.inicio(pos, self.numEntrenos, self.titEntreno, self.liEntrenos, self.siTutorActivado, self.jump) def controlTeclado(self, nkey): - if nkey in (43, 16777239): # pulsado + o avpag + if nkey in (Qt.Key_Plus, Qt.Key_PageDown): self.ent_siguiente(k_siguiente) - elif nkey in (45, 16777238): # pulsado - o repag + elif nkey in (Qt.Key_Minus, Qt.Key_PageUp): self.ent_siguiente(k_anterior) - elif nkey == 80: # P: salva + elif nkey == Qt.Key_T: li = self.fenInicial.split("|") li[2] = self.partida.pgnBaseRAW() self.saveSelectedPosition("|".join(li)) + def listHelpTeclado(self): + return [ + ("+/%s"%_("Page Down"), _("Next position")), + ("-/%s"%_("Page Up"), _("Previous position")), + ("T", _("Save position in 'Selected positions' file")), + ] + def finPartida(self): self.procesador.inicio() diff --git a/Code/GestorEntTac.py b/Code/GestorEntTac.py index ac87391..6c37790 100644 --- a/Code/GestorEntTac.py +++ b/Code/GestorEntTac.py @@ -1,5 +1,8 @@ import time +from PyQt4.QtCore import Qt + + from Code import ControlPosicion from Code import Gestor from Code import Jugada @@ -226,12 +229,18 @@ def procesarAccion(self, clave): Gestor.Gestor.rutinaAccionDef(self, clave) def controlTeclado(self, nkey): - if nkey in (43, 16777239): # pulsado + o avpag + if nkey in (Qt.Key_Plus, Qt.Key_PageDown): if self.estado == kFinJuego: self.ent_siguiente() - elif nkey == 80: + elif nkey == Qt.Key_T: self.saveSelectedPosition(self.fenInicial) + def listHelpTeclado(self): + return [ + ("+/%s"%_("Page Down"), _("Next position")), + ("T", _("Save position in 'Selected positions' file")), + ] + def reiniciar(self): cp = ControlPosicion.ControlPosicion() cp.leeFen(self.fen) diff --git a/Code/GestorPartida.py b/Code/GestorPartida.py index 2c2033b..09e5d49 100644 --- a/Code/GestorPartida.py +++ b/Code/GestorPartida.py @@ -1,5 +1,7 @@ import time +from PyQt4.QtCore import Qt + from Code import Partida from Code import ControlPosicion from Code import Gestor @@ -411,9 +413,14 @@ def configurarGS(self): self.reiniciar(dic) def controlTeclado(self, nkey): - if nkey in (86, 80): # V,P + if nkey in Qt.Key_V: # V self.paste(QTUtil.traePortapapeles()) + def listHelpTeclado(self): + return [ + ("V", _("Paste position")), + ] + def paste(self, texto): cp = ControlPosicion.ControlPosicion() try: diff --git a/Code/GestorSolo.py b/Code/GestorSolo.py index 1bf27eb..779387d 100644 --- a/Code/GestorSolo.py +++ b/Code/GestorSolo.py @@ -2,6 +2,8 @@ import sys import time +from PyQt4.QtCore import Qt + from Code import ControlPosicion from Code import Gestor from Code import PGN @@ -676,34 +678,7 @@ def configurarGS(self): 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() + self.startPosition() elif resp == "pasteposicion": texto = QTUtil.traePortapapeles() @@ -771,11 +746,50 @@ def configurarGS(self): self.reiniciar(dic) def controlTeclado(self, nkey): - if nkey == 86: # V + if nkey == Qt.Key_V: self.paste(QTUtil.traePortapapeles()) - elif nkey == 80: # P + elif nkey == Qt.Key_T: li = [self.fen if self.fen else ControlPosicion.FEN_INICIAL,"",self.partida.pgnBaseRAW()] self.saveSelectedPosition("|".join(li)) + elif nkey == Qt.Key_S: + self.startPosition() + + def listHelpTeclado(self): + return [ + ("V", _("Paste position")), + ("T", _("Save position in 'Selected positions' file")), + ("S", _("Set start position")) + ] + + def startPosition(self): + 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() def paste(self, texto): cp = ControlPosicion.ControlPosicion() diff --git a/Code/Init.py b/Code/Init.py index fdd64dd..d44c0c9 100644 --- a/Code/Init.py +++ b/Code/Init.py @@ -1,5 +1,5 @@ DEBUG = False -VERSION = "10.07.2" +VERSION = "10.08" import os import sys diff --git a/Code/Procesador.py b/Code/Procesador.py index a2e724b..e7d7c69 100644 --- a/Code/Procesador.py +++ b/Code/Procesador.py @@ -72,7 +72,7 @@ def iniciaConUsuario(self, user): self.web = "http://www-lucaschess.rhcloud.com" self.blog = "http://lucaschess.blogspot.com" - self.liOpcionesInicio = [k_terminar, k_play, k_competicion, k_elo, + self.liOpcionesInicio = [k_terminar, k_play, k_entrenamiento, k_tools, k_opciones, k_informacion] # Lo incluimos aqui porque sino no lo lee, en caso de aplazada self.configuracion = Configuracion.Configuracion(user) @@ -320,6 +320,12 @@ def menuPlay(self): menu.opcion(("free", None), _("Play against an engine of your choice"), Iconos.Libre()) menu.separador() + menu.opcion(("competition", None), _("Competition"), Iconos.NuevaPartida()) + menu.separador() + + menu.opcion(("elo", None), _("Elo-Rating"), Iconos.Elo()) + menu.separador() + # Principiantes ---------------------------------------------------------------------------------------- menu1 = menu.submenu(_("Opponents for young players"), Iconos.RivalesMP()) @@ -357,6 +363,12 @@ def menuPlay(self): if tipo == "free": self.procesarAccion(k_libre) + elif tipo == "competition": + self.competicion() + + elif tipo == "elo": + self.elo() + elif tipo == "person": self.playPerson(rival) elif tipo == "animales": @@ -440,9 +452,6 @@ def procesarAccion(self, clave): elif clave == k_libre: self.libre() - elif clave == k_competicion: - self.competicion() - elif clave == k_entrenamiento: self.entrenamientos.lanza() @@ -452,9 +461,6 @@ def procesarAccion(self, clave): elif clave == k_tools: self.tools() - elif clave == k_elo: - self.elo() - elif clave == k_informacion: self.informacion() diff --git a/Code/QT/PantallaConfig.py b/Code/QT/PantallaConfig.py index 5a34b19..347a857 100644 --- a/Code/QT/PantallaConfig.py +++ b/Code/QT/PantallaConfig.py @@ -1,3 +1,5 @@ +from PyQt4.QtCore import Qt + from Code import DGT from Code.QT import FormLayout from Code.QT import Iconos @@ -54,6 +56,15 @@ def opciones(parent, configuracion): liAsp.append((None, _("Toolbars") + ":")) liAsp.append((FormLayout.Spinbox(_("Font size"), 5, 64, 60), configuracion.puntosTB)) liAsp.append((_("Bold") + ":", configuracion.boldTB)) + li = ( + (_("Only display the icon"), Qt.ToolButtonIconOnly), + (_("Only display the text"), Qt.ToolButtonTextOnly), + (_("The text appears beside the icon"), Qt.ToolButtonTextBesideIcon), + (_("The text appears under the icon"), Qt.ToolButtonTextUnderIcon) + ) + config = FormLayout.Combobox(_("Icons"), li) + liAsp.append((config, configuracion.iconsTB)) + # PGN table liAsp.append(separador) @@ -171,7 +182,7 @@ def opciones(parent, configuracion): liGen, liSon, liTT, liT, liEng, liAsp, liSA, liNC = resp - configuracion.jugador, configuracion.estilo, configuracion.traductor = liGen + (configuracion.jugador, configuracion.estilo, configuracion.traductor) = liGen porDefecto = liAsp[0] if porDefecto: @@ -179,40 +190,39 @@ def opciones(parent, configuracion): else: del liAsp[0] - configuracion.familia, configuracion.puntosMenu, configuracion.boldMenu, \ - configuracion.puntosTB, configuracion.boldTB, \ - configuracion.anchoPGN, configuracion.altoFilaPGN, configuracion.puntosPGN, \ - configuracion.siNomPiezasEN, configuracion.figurinesPGN, \ - configuracion.tamFontRotulos = liAsp + (configuracion.familia, configuracion.puntosMenu, configuracion.boldMenu, + configuracion.puntosTB, configuracion.boldTB, configuracion.iconsTB, + configuracion.anchoPGN, configuracion.altoFilaPGN, configuracion.puntosPGN, + configuracion.siNomPiezasEN, configuracion.figurinesPGN, + configuracion.tamFontRotulos) = liAsp if configuracion.familia == "System": configuracion.familia = "" - configuracion.siSuenaBeep, configuracion.siSuenaResultados, configuracion.siSuenaJugada, \ - configuracion.siSuenaNuestro = liSon + (configuracion.siSuenaBeep, configuracion.siSuenaResultados, configuracion.siSuenaJugada, configuracion.siSuenaNuestro) = liSon - configuracion.tutor.clave, tiempoTutor, configuracion.tutorMultiPV, \ - configuracion.tutorActivoPorDefecto, configuracion.tutorDifPts, configuracion.tutorDifPorc = liTT + (configuracion.tutor.clave, tiempoTutor, configuracion.tutorMultiPV, + configuracion.tutorActivoPorDefecto, configuracion.tutorDifPts, configuracion.tutorDifPorc) = liTT configuracion.tiempoTutor = int(tiempoTutor * 1000) - configuracion.eloNC, configuracion.micheloNC, configuracion.ficsNC, configuracion.fideNC = liNC + (configuracion.eloNC, configuracion.micheloNC, configuracion.ficsNC, configuracion.fideNC) = liNC - configuracion.centipawns, configuracion.bmi2, configuracion.notbackground = liEng + (configuracion.centipawns, configuracion.bmi2, configuracion.notbackground) = liEng - configuracion.vistaTutor, \ - configuracion.efectosVisuales, rapidezMovPiezas, \ - configuracion.siAtajosRaton, configuracion.showCandidates, configuracion.showVariantes, \ - configuracion.siActivarCapturas, configuracion.tipoMaterial, \ - configuracion.siActivarInformacion, siDGT = liT + (configuracion.vistaTutor, + configuracion.efectosVisuales, rapidezMovPiezas, + configuracion.siAtajosRaton, configuracion.showCandidates, configuracion.showVariantes, + configuracion.siActivarCapturas, configuracion.tipoMaterial, + configuracion.siActivarInformacion, siDGT) = liT configuracion.rapidezMovPiezas = drap[rapidezMovPiezas] if configuracion.siDGT != siDGT: if siDGT: DGT.ponON() configuracion.siDGT = siDGT - configuracion.salvarFichero, configuracion.salvarGanados, configuracion.salvarPerdidos, \ - configuracion.salvarAbandonados, configuracion.guardarVariantesTutor, \ - configuracion.salvarCSV = liSA + (configuracion.salvarFichero, configuracion.salvarGanados, configuracion.salvarPerdidos, + configuracion.salvarAbandonados, configuracion.guardarVariantesTutor, + configuracion.salvarCSV) = liSA configuracion.salvarCSV = Util.dirRelativo(configuracion.salvarCSV) return True diff --git a/Code/QT/Tablero.py b/Code/QT/Tablero.py index 9f8791e..a1c0c53 100644 --- a/Code/QT/Tablero.py +++ b/Code/QT/Tablero.py @@ -4,6 +4,8 @@ import os from PyQt4 import QtCore, QtGui +from PyQt4.QtCore import Qt + from Code.QT import Colocacion from Code.QT import Controles @@ -22,17 +24,18 @@ from Code import VarGen from Code.Constantes import * + class RegKB: def __init__(self, key, flags): self.key = key self.flags = flags + class Tablero(QtGui.QGraphicsView): def __init__(self, parent, confTablero, siMenuVisual=True): super(Tablero, self).__init__(None) - self.setRenderHints( - QtGui.QPainter.Antialiasing | QtGui.QPainter.TextAntialiasing | QtGui.QPainter.SmoothPixmapTransform) + self.setRenderHints(QtGui.QPainter.Antialiasing | QtGui.QPainter.TextAntialiasing | QtGui.QPainter.SmoothPixmapTransform) self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.setDragMode(self.NoDrag) @@ -78,8 +81,8 @@ def init_kb_buffer(self): self.kb_buffer = [] def exec_kb_buffer(self, key, flags): - if 16777264 <= key <= 16777273: # F1..F10 - f = key - 16777263 + if Qt.Key_F1 <= key <= Qt.Key_F10: + f = key - Qt.Key_F1 + 1 if self.liMouse: if len(self.liMouse) >= 2: desde = self.liMouse[-2] @@ -94,11 +97,11 @@ def exec_kb_buffer(self, key, flags): self.init_kb_buffer() return - if key == 16777216: # ESC + if key == Qt.Key_Escape: self.init_kb_buffer() return - if key in (16777220, 16777221): # intros + if key in (Qt.Key_Enter, Qt.Key_Return): if self.kb_buffer: last = self.kb_buffer[-1] key = last.key @@ -106,36 +109,61 @@ def exec_kb_buffer(self, key, flags): else: return - # Operations -> needs Alt - if flags & QtCore.Qt.AltModifier: - siCtrl = (flags & QtCore.Qt.ControlModifier) > 0 - ok = True - if key == 67: # C salvar PGN - self.salvaPGN(siClipboard=siCtrl) - - elif key == 73: # I copiar tablero - self.salvaEnImagen(siCtrl=siCtrl) - elif key == 83: # S copiar tablero en fichero - resp = QTUtil2.salvaFichero(self, _("File to save"), self.configuracion.dirSalvados, - "%s PNG (*.png)" % _("File"), False) - if resp: - self.salvaEnImagen(resp, "png", siCtrl=siCtrl) - elif key == 70: # Alt-F girar tablero ALt-Ctrl-F = copy FEN to clipboard - if siCtrl: - QTUtil.ponPortapapeles(self.ultPosicion.fen()) - QTUtil2.mensajeTemporal(self.pantalla, _("FEN is in clipboard"), 1) - else: - self.intentaRotarTablero(None) + siAlt = (flags & QtCore.Qt.AltModifier) > 0 + siCtrl = (flags & QtCore.Qt.ControlModifier) > 0 - elif key == 68: # D director director - if not self.siTableroDirector(): - self.lanzaDirector() - else: - ok = False - if ok: - if self.kb_buffer: - self.kb_buffer = self.kb_buffer[:-1] - return + okseguir = False + + # CTRL-C : copy fen al clipboard + if siCtrl and key == Qt.Key_C: + QTUtil.ponPortapapeles(self.ultPosicion.fen()) + QTUtil2.mensajeTemporal(self.pantalla, _("FEN is in clipboard"), 1) + + # ALT-D -> Director + elif siAlt and key == Qt.Key_D: + if not self.siTableroDirector(): + self.lanzaDirector() + + # ALT-F -> Rota tablero + elif siAlt and key == Qt.Key_F: + self.intentaRotarTablero(None) + + # ALT-I Save image to clipboard (CTRL->no border) + elif key == Qt.Key_I: + self.salvaEnImagen(siCtrl=siCtrl) + QTUtil2.mensaje(self, _("Board image is in clipboard")) + + # ALT-J Save image to file (CTRL->no border) + elif key == Qt.Key_J: + path = QTUtil2.salvaFichero(self, _("File to save"), self.configuracion.dirSalvados, "%s PNG (*.png)" % _("File"), False) + if path: + self.salvaEnImagen(path, "png", siCtrl=siCtrl) + self.configuracion.dirSalvados = os.path.dirname(path) + self.configuracion.graba() + + # ALT-K + elif key == Qt.Key_K: + self.showKeys() + + elif hasattr(self.pantalla, "gestor") and self.pantalla.gestor and hasattr(self.pantalla.gestor, "rightMouse") \ + and key in (Qt.Key_P, Qt.Key_N, Qt.Key_C): + # P -> show information + if key == Qt.Key_P: + self.pantalla.gestor.rightMouse(False, False, False) + # ALT-N -> non distract mode + elif key == Qt.Key_N and siAlt: + self.pantalla.gestor.rightMouse(False, False, True) + # ALT-C -> show captures + elif key == Qt.Key_C and siAlt: + self.pantalla.gestor.rightMouse(False, True, False) + + else: + okseguir = True + + if not okseguir: + if self.kb_buffer: + self.kb_buffer = self.kb_buffer[:-1] + return if self.mensajero and self.siActivasPiezas: nk = len(self.kb_buffer) @@ -193,10 +221,7 @@ def exec_kb_buffer(self, key, flags): return def sizeHint(self): - return QtCore.QSize(self.ancho+6, self.ancho+6) - - # def adjustSize(self): - # return + return QtCore.QSize(self.ancho + 6, self.ancho + 6) def keyPressEvent(self, event): k = event.key() @@ -544,6 +569,41 @@ def norm(x): self.init_kb_buffer() + def showKeys(self): + liKeys = [ + (_("CTRL") + "-C", _("Copy FEN to clipboard")), + ("I", _("Copy board as image to clipboard")), + (_("CTRL") + "-I", _("Copy board as image to clipboard") + " (%s)" % _("without border")), + ("J", _("Copy board as image to a file")), + (_("CTRL") + "-J", _("Copy board as image to a file") + " (%s)" % _("without border")), + ] + if self.siActivasPiezas: + liKeys.append((None, None)) + liKeys.append(("a1 ... h8", _("To indicate origin and destination of a move"))) + + + if hasattr(self.pantalla, "gestor") and self.pantalla.gestor: + if hasattr(self.pantalla.gestor, "rightMouse"): + liKeys.append((None, None)) + liKeys.append(("P", _("Show/Hide PGN information"))) + liKeys.append((_("ALT") + "-C", _("Show/Hide captures"))) + liKeys.append((_("ALT") + "-N", _("Activate/Deactivate non distract mode"))) + + if hasattr(self.pantalla.gestor, "listHelpTeclado"): + liKeys.append((None, None)) + liKeys.extend(self.pantalla.gestor.listHelpTeclado()) + + rondo = QTVarios.rondoPuntos() + menu = QTVarios.LCMenu(self) + menu.opcion(None, _("Active keys"), Iconos.Rename()) + menu.separador() + for key, mess in liKeys: + if key is None: + menu.separador() + else: + menu.opcion(None, "%s [%s]" % (mess, key), rondo.otro()) + menu.lanza() + def lanzaMenuVisual(self, siIzquierdo): if not self.siMenuVisual: return @@ -577,6 +637,9 @@ def lanzaMenuVisual(self, siIzquierdo): smenu.separador() smenu.opcion("def_resto", _("The other"), Iconos.PuntoVerde()) + menu.separador() + menu.opcion("keys", _("Active keys")+ " [%s-K]" % _("ALT"), Iconos.Rename()) + resp = menu.lanza() if resp is None: return @@ -637,6 +700,9 @@ def lanzaMenuVisual(self, siIzquierdo): # w.exec_() # QTUtil.refreshGUI() + elif resp == "keys": + self.showKeys() + elif resp.startswith("def_"): self.confTablero.porDefecto(resp[4:]) self.confTablero.guardaEnDisco() @@ -727,6 +793,12 @@ def mousePressEvent(self, event): if event.button() == QtCore.Qt.RightButton: if not siDentro: self.lanzaMenuVisual(False) + elif hasattr(self.pantalla, "boardRightMouse"): + m = int(event.modifiers()) + siShift = (m & QtCore.Qt.ShiftModifier) > 0 + siControl = (m & QtCore.Qt.ControlModifier) > 0 + siAlt = (m & QtCore.Qt.AltModifier) > 0 + self.pantalla.boardRightMouse(siShift, siControl, siAlt) # QtGui.QGraphicsView.mousePressEvent(self,event) return if not siDentro: @@ -1175,8 +1247,8 @@ def num2alg(self, fila, columna): return chr(96 + columna) + str(fila) def alg2num(self, a1): - x = self.columna2punto(ord(a1[0])-96) - y = self.fila2punto(ord(a1[1])-48) + x = self.columna2punto(ord(a1[0]) - 96) + y = self.fila2punto(ord(a1[1]) - 48) return x, y def intentaMover(self, piezaSC, posCursor, eventButton): @@ -1443,15 +1515,10 @@ def salvaEnImagen(self, fichero=None, tipo=None, siCtrl=False): pm = QtGui.QPixmap.grabWidget(self) if fichero is None: QTUtil.ponPortapapeles(pm, tipo="p") + else: pm.save(fichero, tipo) - def salvaPGN(self, siClipboard=None): - if hasattr(self.pantalla, "gestor") and hasattr(self.pantalla.gestor, "salvaFEN_PGN"): - self.pantalla.gestor.salvaFEN_PGN("pgn", not siClipboard) - if siClipboard: - QTUtil2.mensajeTemporal(self, _("PGN is in clipboard"), 1) - def thumbnail(self, ancho): # escondemos piezas+flechas for pieza, piezaSC, siVisible in self.liPiezas: @@ -1646,6 +1713,7 @@ def fenActual(self): return "/".join(lineas) + " " + resto + class WTamTablero(QtGui.QDialog): def __init__(self, tablero): @@ -1780,6 +1848,7 @@ def closeEvent(self, event): if self.confTablero.siBase: self.tablero.permitidoResizeExterno(self.confTablero.siBase) + class PosTablero(Tablero): def activaTodas(self): for pieza, piezaSC, siActiva in self.liPiezas: @@ -1856,6 +1925,7 @@ def dropEvent(self, event): event.setDropAction(QtCore.Qt.IgnoreAction) event.ignore() + class TableroEstatico(Tablero): def mousePressEvent(self, event): pos = event.pos() @@ -1883,6 +1953,7 @@ def mousePressEvent(self, event): Tablero.mousePressEvent(self, event) + class TableroVisual(Tablero): EVENTO_DERECHO, EVENTO_DERECHO_PIEZA, EVENTO_DROP, EVENTO_BORRAR, EVENTO_FUNCION = range(5) @@ -2059,6 +2130,7 @@ def ponPosicion(self, posicion): self.baseCasillasSC.setAcceptDrops(True) self.activaTodas() + class TableroDirector(TableroVisual): def keyPressEvent(self, event): diff --git a/Code/QT/WBase.py b/Code/QT/WBase.py index d961a70..05528d8 100644 --- a/Code/QT/WBase.py +++ b/Code/QT/WBase.py @@ -20,7 +20,9 @@ def __init__(self, parent, gestor): self.gestor = gestor - self.centipawns = VarGen.configuracion.centipawns + self.configuracion = VarGen.configuracion + + self.centipawns = self.configuracion.centipawns self.procesandoEventos = None @@ -57,11 +59,11 @@ def ponGestor(self, gestor): def creaToolBar(self): self.tb = QtGui.QToolBar("BASICO", self) - self.tb.setIconSize(QtCore.QSize(32, 32)) - self.tb.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon) - # self.tb.setStyleSheet("QWidget { background: #AFC3D7 }") - # self.tb.setStyleSheet("QToolBar {background: #AFC3D7;border-bottom: 1px solid black; border-top: 1px solid black;}"); - + iconsTB = self.configuracion.iconsTB + self.tb.setToolButtonStyle(iconsTB) + sz = 32 if iconsTB == QtCore.Qt.ToolButtonTextUnderIcon else 16 + self.tb.setIconSize(QtCore.QSize(sz, sz)) + self.tb.setStyleSheet("QToolBar {border-bottom: 1px solid gray; border-top: 1px solid gray;}"); self.preparaTB() def creaTablero(self): @@ -174,9 +176,14 @@ def creaBloqueInformacion(self): # Ayudas lyAyudas = Colocacion.H().relleno().control(self.lbCredito).control(self.ayudasUD).relleno().ponSeparacion(1) + # Abajo + lyAbajo = Colocacion.V() + lyAbajo.setSizeConstraint(lyAbajo.SetFixedSize) + lyAbajo.control(self.lbRevision).otro(lyAyudas).control(self.btActivarTutor) + lyAbajo.control(self.lbRotulo1).control(self.lbRotulo2).control(self.lbRotulo3) + lyV = Colocacion.V().otro(lyColor).control(self.pgn) - lyV.control(self.lbRevision).otro(lyAyudas).control(self.btActivarTutor) - lyV.control(self.lbRotulo1).control(self.lbRotulo2).control(self.lbRotulo3) + lyV.otro(lyAbajo) return lyV @@ -186,8 +193,8 @@ def preparaTB(self): liOpciones = ((_("Quit"), Iconos.Terminar(), k_terminar), (_("Play"), Iconos.Libre(), k_play), - (_("Competition"), Iconos.NuevaPartida(), k_competicion), - (_("Elo-Rating"), Iconos.Elo(), k_elo), + # (_("Competition"), Iconos.NuevaPartida(), k_competicion), + # (_("Elo-Rating"), Iconos.Elo(), k_elo), (_("Training"), Iconos.Entrenamiento(), k_entrenamiento), (_("Options"), Iconos.Opciones(), k_opciones), (_("Information"), Iconos.Informacion(), k_informacion), @@ -306,11 +313,11 @@ def gridBotonIzquierdo(self, grid, fila, columna): def gridBotonDerecho(self, grid, fila, columna, modificadores): self.gestor.pgnMueveBase(fila, columna.clave) + self.gestor.rightMouse(modificadores.siShift, modificadores.siControl, modificadores.siAlt) - if modificadores.siControl: - self.gestor.capturas() - else: - self.gestor.pgnInformacion(fila, columna.clave) + def boardRightMouse(self, siShift, siControl, siAlt): + if hasattr(self.gestor, "boardRightMouse"): + self.gestor.boardRightMouse(siShift, siControl, siAlt) def gridDobleClick(self, grid, fila, columna): if columna.clave == "NUMERO": @@ -534,6 +541,31 @@ def activaJuego(self, siActivar, siReloj, siAyudas=None): self.lbRelojBlancas.setVisible(siReloj) self.lbRelojNegras.setVisible(siReloj) + def nonDistractMode(self, nonDistract): + if nonDistract: + for widget in nonDistract: + widget.setVisible(True) + nonDistract = None + else: + nonDistract = [] + for widget in (self.tb, + self.pgn, + self.lbRevision, + self.ayudasUD, + self.lbCredito, + self.btActivarTutor, + self.lbRotulo1, + self.lbRotulo2, + self.lbRotulo3, + self.lbJugBlancas, + self.lbJugNegras, + self.lbRelojBlancas, + self.lbRelojNegras ): + if widget.isVisible(): + nonDistract.append(widget) + widget.setVisible(False) + return nonDistract + def ponDatosReloj(self, bl, rb, ng, rn): self.lbJugBlancas.altoMinimo(0) self.lbJugNegras.altoMinimo(0) diff --git a/Locale/es/LC_MESSAGES/lucaschess.mo b/Locale/es/LC_MESSAGES/lucaschess.mo index 80991ed..a381d0d 100644 Binary files a/Locale/es/LC_MESSAGES/lucaschess.mo and b/Locale/es/LC_MESSAGES/lucaschess.mo differ diff --git a/Lucas.py b/Lucas.py index e88c5a4..6cc9a94 100644 --- a/Lucas.py +++ b/Lucas.py @@ -13,6 +13,8 @@ import sys + + reload(sys) sys.setdefaultencoding("latin-1") sys.path.insert(0, os.curdir) diff --git a/bug.log b/bug.log index bb7b0c8..f1b17a6 100644 --- a/bug.log +++ b/bug.log @@ -1 +1 @@ -Version 10.07.2 +Version 10.08