Example #1
0
    def config(self):
        menu = QTVarios.LCMenu(self)
        if self.one_line:
            menu.opcion("change", _("Change options and create new training"),
                        Iconos.TOLchange())
            menu.separador()
        smenu = menu.submenu(_("What to do after solving"), Iconos.Tacticas())
        go_fast = self.tol.go_fast
        dico = {True: Iconos.Aceptar(), False: Iconos.PuntoAmarillo()}
        smenu.opcion("t_False", _("Stop"), dico[go_fast is False])
        smenu.opcion("t_True", _("Jump to the next"), dico[go_fast is True])
        smenu.opcion("t_None", _("Jump to the next from level 2"),
                     dico[go_fast is None])
        menu.separador()
        menu.opcion("remove", _("Remove all results of all levels"),
                    Iconos.Cancelar())

        resp = menu.lanza()
        if resp:
            if resp.startswith("t_"):
                self.tol.go_fast = eval(resp[2:])
                TurnOnLights.write_tol(self.tol)
            elif resp == "remove":
                self.rebuild()
            elif resp == "change":
                self.cambiar_one_line()
Example #2
0
    def turn_on_lights(self, name):
        if name.startswith("uned_easy"):
            title = "%s (%s)" % (_("UNED chess school"), _("Initial"))
            folder = "Trainings/Tactics by UNED chess school"
            icono = Iconos.Uned()
            li_tam_blocks = (4, 6, 9, 12, 18, 36)
        elif name.startswith("uned"):
            title = _("UNED chess school")
            folder = "Trainings/Tactics by UNED chess school"
            icono = Iconos.Uned()
            li_tam_blocks = (6, 12, 20, 30, 60)
        elif name.startswith("uwe_easy"):
            title = "%s (%s)" % (_("Uwe Auerswald"), _("Initial"))
            TurnOnLights.compruebaUweEasy(self.configuracion, name)
            folder = self.configuracion.carpetaTemporal()
            icono = Iconos.Uwe()
            li_tam_blocks = (4, 6, 9, 12, 18, 36)
        elif name.startswith("uwe"):
            title = _("Uwe Auerswald")
            folder = "Trainings/Tactics by Uwe Auerswald"
            icono = Iconos.Uwe()
            li_tam_blocks = (5, 10, 20, 40, 80)

        resp = PantallaTurnOnLights.pantallaTurnOnLigths(
            self.procesador, name, title, icono, folder, li_tam_blocks)
        if resp:
            num_theme, num_block, tol = resp
            self.procesador.tipoJuego = kJugEntLight
            self.procesador.estado = kJugando
            self.procesador.gestor = GestorTurnOnLights.GestorTurnOnLights(
                self.procesador)
            self.procesador.gestor.inicio(num_theme, num_block, tol)
Example #3
0
 def config(self):
     menu = QTVarios.LCMenu(self)
     smenu = menu.submenu(_("Tactics"), Iconos.Tacticas())
     go_fast = self.tol.go_fast
     dico = {True: Iconos.Aceptar(), False: Iconos.PuntoAmarillo()}
     smenu.opcion("t_false", _("Stop after solve"), dico[not go_fast])
     smenu.opcion("t_true", _("Jump to the next after solve"),
                  dico[go_fast])
     menu.separador()
     menu.opcion("remove", _("Remove all results of all levels"),
                 Iconos.Cancelar())
     resp = menu.lanza()
     if resp:
         if resp.startswith("t_"):
             self.tol.go_fast = resp == "t_true"
             TurnOnLights.write_tol(self.tol)
         elif resp == "remove":
             if not QTUtil2.pregunta(
                     self,
                     _("Are you sure you want to delete all results of all levels and start again from scratch?"
                       )):
                 return
             TurnOnLights.remove_tol(self.tol)
             self.reinit = True
             self.guardarVideo()
             self.accept()
 def reiniciar(self):
     if self.estado == kJugando:
         if self.ini_time:
             self.total_time_used += time.time() - self.ini_time
     if self.total_time_used:
         self.block.new_reinit(self.total_time_used)
         self.total_time_used = 0.0
         TurnOnLights.write_tol(self.tol)
     self.inicio(self.num_theme, self.num_block, self.tol)
Example #5
0
 def reiniciar(self):
     if self.state == ST_PLAYING:
         if self.ini_time:
             self.total_time_used += time.time() - self.ini_time
     if self.total_time_used:
         self.block.new_reinit(self.total_time_used, self.errores,
                               self.ayudas)
         self.total_time_used = 0.0
         TurnOnLights.write_tol(self.tol)
     self.inicio(self.num_theme, self.num_block, self.tol)
Example #6
0
 def rebuild(self):
     if not QTUtil2.pregunta(self, _(
             "Are you sure you want to delete all results of all levels and start again from scratch?")):
         return
     if self.one_line:
         self.tol.new()
     else:
         TurnOnLights.remove_tol(self.tol)
         if self.tol.name.startswith("uwe_easy"):
             TurnOnLights.compruebaUweEasy(self.procesador.configuracion, self.tol.name)
     self.reinit = True
     self.guardarVideo()
     self.accept()
Example #7
0
 def rebuild(self):
     if not QTUtil2.pregunta(
             self,
             _("Are you sure you want to delete all results of all levels and start again from scratch?"
               )):
         return
     if self.one_line:
         self.tol.new()
     else:
         TurnOnLights.remove_tol(self.tol)
     self.reinit = True
     self.guardarVideo()
     self.accept()
Example #8
0
    def right_button_block(self, num_theme, num_block):
        block = self.tol.get_block(num_theme, num_block)
        litimes = block.times
        nmoves = block.num_moves()
        if not litimes and not block.reinits:
            return
        menu = QTVarios.LCMenu(self)
        menu.ponTipoLetra(name="Courier New", puntos=10)
        tt = 0
        te = 0
        ta = 0
        mixed_results = False
        for dato in litimes:
            segs, fecha, time_used, errores, ayudas = dato
            txt, ico = TurnOnLights.qualification(
                segs, self.tol.is_calculation_mode())
            menu.opcion(
                None,
                "%d-%02d-%02d %02d:%02d %6.02f  %6.02f  %s" %
                (fecha.year, fecha.month, fecha.day, fecha.hour, fecha.minute,
                 segs, time_used, txt),
                self.dicIconos[ico],
            )
            tt += time_used
            te += errores
            ta += ayudas

        if litimes:
            menu.separador()
            menu.opcion(
                None,
                "%16s %6.02f" % (_("Average"), tt / (nmoves * len(litimes))))
            menu.separador()
        plant = "%16s %15.02f  %s"
        if block.reinits:
            tr = 0.0
            for dato in block.reinits:
                segs, fecha, errores, ayudas = dato
                tr += segs
                tt += segs
                te += errores
                ta += ayudas
            menu.separador()
            menu.opcion(
                None, plant % (_("Restarts"), tr,
                               time.strftime("%H:%M:%S", time.gmtime(tr))))
        if not mixed_results:
            menu.separador()
            menu.opcion(None, "%16s %6d" % (_("Errors"), te))
            menu.separador()
            menu.opcion(None, "%16s %6d" % (_("Hints"), ta))
        menu.separador()
        menu.opcion(
            None, plant %
            (_("Total time"), tt, time.strftime("%H:%M:%S", time.gmtime(tt))))

        menu.lanza()
Example #9
0
 def gridBotonDerecho(self, grid, fila, oColumna, modificadores):
     col = oColumna.clave
     if not col.startswith("BLOCK"):
         return
     num_block = int(col[5:])
     num_theme = fila
     block = self.tol.get_block(num_theme, num_block)
     litimes = block.times
     nmoves = block.num_moves()
     if not litimes and not block.reinits:
         return
     menu = QTVarios.LCMenu(self)
     menu.ponTipoLetra(nombre="Courier New", puntos=10)
     tt = 0
     d = {
         "0": Iconos.Gris32(),
         "1": Iconos.Amarillo32(),
         "2": Iconos.Naranja32(),
         "3": Iconos.Verde32(),
         "4": Iconos.Azul32(),
         "5": Iconos.Magenta32(),
         "6": Iconos.Rojo32(),
         "7": Iconos.Light32()
     }
     for segs, fecha in litimes:
         txt, ico = TurnOnLights.qualification(
             segs, self.tol.is_calculation_mode())
         menu.opcion(
             None, "%d-%02d-%02d %02d:%02d %6.02f  %6.02f  %s" %
             (fecha.year, fecha.month, fecha.day, fecha.hour, fecha.minute,
              segs, segs * nmoves, txt), d[ico])
         tt += segs * nmoves
     if litimes:
         menu.separador()
         menu.opcion(
             None,
             "%16s %6.02f" % (_("Average"), tt / (nmoves * len(litimes))))
         menu.separador()
     plant = "%16s %15.02f  %s"
     menu.opcion(
         None, plant %
         (_("Total time"), tt, time.strftime("%H:%M:%S", time.gmtime(tt))))
     if block.reinits:
         tr = 0.0
         for segs, fecha in block.reinits:
             tr += segs
         menu.separador()
         menu.opcion(
             None, plant % (_("Restarts"), tr,
                            time.strftime("%H:%M:%S", time.gmtime(tr))))
         menu.separador()
         menu.opcion(
             None,
             plant % (_("Working time"), tt + tr,
                      time.strftime("%H:%M:%S", time.gmtime(tt + tr))))
     menu.lanza()
Example #10
0
    def config(self):
        menu = QTVarios.LCMenu(self)
        smenu = menu.submenu(_("Tactics"), Iconos.Tacticas())
        go_fast = self.tol.go_fast
        dico = {True: Iconos.Aceptar(), False: Iconos.PuntoAmarillo()}
        smenu.opcion("t_false", _("Stop after solve"), dico[not go_fast])
        smenu.opcion("t_true", _("Jump to the next after solve"),
                     dico[go_fast])
        menu.separador()
        menu.opcion("remove", _("Remove all results of all levels"),
                    Iconos.Cancelar())

        resp = menu.lanza()
        if resp:
            if resp.startswith("t_"):
                self.tol.go_fast = resp == "t_true"
                TurnOnLights.write_tol(self.tol)
            elif resp == "remove":
                self.rebuild()
Example #11
0
    def turn_on_lights(self, name):
        one_line = False
        if name.startswith("uned_easy"):
            title = "%s (%s)" % (_("UNED chess school"), _("Initial"))
            folder = Code.path_resource("Trainings",
                                        "Tactics by UNED chess school")
            icono = Iconos.Uned()
            li_tam_blocks = (4, 6, 9, 12, 18, 36)
        elif name.startswith("uned"):
            title = _("UNED chess school")
            folder = Code.path_resource("Trainings",
                                        "Tactics by UNED chess school")
            icono = Iconos.Uned()
            li_tam_blocks = (6, 12, 20, 30, 60)
        elif name.startswith("uwe_easy"):
            title = "%s (%s)" % (_("Uwe Auerswald"), _("Initial"))
            TurnOnLights.compruebaUweEasy(self.configuracion, name)
            folder = self.configuracion.carpetaTemporal()
            icono = Iconos.Uwe()
            li_tam_blocks = (4, 6, 9, 12, 18, 36)
        elif name.startswith("uwe"):
            title = _("Uwe Auerswald")
            folder = Code.path_resource("Trainings",
                                        "Tactics by Uwe Auerswald")
            icono = Iconos.Uwe()
            li_tam_blocks = (5, 10, 20, 40, 80)
        elif name == "oneline":
            title = _("In one line")
            folder = None
            icono = Iconos.TOLline()
            li_tam_blocks = None
            one_line = True

        resp = PantallaTurnOnLights.pantallaTurnOnLigths(
            self.procesador, name, title, icono, folder, li_tam_blocks,
            one_line)
        if resp:
            num_theme, num_block, tol = resp
            self.procesador.game_type = GT_TURN_ON_LIGHTS
            self.procesador.state = ST_PLAYING
            self.procesador.gestor = GestorTurnOnLights.GestorTurnOnLights(
                self.procesador)
            self.procesador.gestor.inicio(num_theme, num_block, tol)
Example #12
0
    def __init__(self, owner, name, title, icono, folder, li_tam_blocks):

        self.tol = TurnOnLights.read_tol(name, title, folder, li_tam_blocks)
        self.reinit = False

        titulo = _("Turn on the lights") + ": " + title
        extparam = "tol%s-%d" % (name, self.tol.work_level)
        QTVarios.WDialogo.__init__(self, owner, titulo, icono, extparam)

        self.colorTheme = QTUtil.qtColor("#F0F0F0")

        # Toolbar
        tb = Controles.TBrutina(self)
        tb.new(_("Close"), Iconos.MainMenu(), self.terminar)
        anterior, siguiente = self.tol.prev_next()
        if anterior:
            tb.new(_("Previous"), Iconos.Anterior(), self.goto_previous)
        if siguiente:
            tb.new(_("Next"), Iconos.Siguiente(), self.goto_next)
        tb.new(_("Config"), Iconos.Configurar(), self.config)
        tb.new(_("Information"), Iconos.Informacion(), self.colors)

        # Lista
        oColumnas = Columnas.ListaColumnas()
        work_level = self.tol.work_level + 1
        oColumnas.nueva("THEME",
                        _("Level %d/%d") % (work_level, self.tol.num_levels),
                        175)
        for x in range(self.tol.num_blocks):
            oColumnas.nueva("BLOCK%d" % x,
                            "%d" % (x + 1, ),
                            42,
                            siCentrado=True,
                            edicion=Delegados.PmIconosColor())

        self.grid = grid = Grid.Grid(self,
                                     oColumnas,
                                     altoFila=42,
                                     background="white")
        self.grid.setAlternatingRowColors(False)
        self.grid.tipoLetra(puntos=10, peso=500)
        nAnchoPgn = self.grid.anchoColumnas() + 20
        self.grid.setMinimumWidth(nAnchoPgn)
        self.registrarGrid(grid)

        # Colocamos ---------------------------------------------------------------
        ly = Colocacion.V().control(tb).control(self.grid)

        self.setLayout(ly)

        alto = self.tol.num_themes * 42 + 116
        self.recuperarVideo(siTam=True,
                            altoDefecto=alto,
                            anchoDefecto=nAnchoPgn)
Example #13
0
 def colors(self):
     menu = QTVarios.LCMenu(self)
     num, ultimo = TurnOnLights.numColorMinimum(self.tol)
     snum = str(num)
     thinkMode = self.tol.is_calculation_mode()
     for txt, key, secs, secsThink in TurnOnLights.QUALIFICATIONS:
         rotulo = "%s < %0.2f\"" % (_F(txt), secsThink if thinkMode else secs )
         if key == snum and not ultimo:
             rotulo += " = %s" % _("Minimum to access next level")
         menu.opcion(None, rotulo, self.dicIconos[key])
         menu.separador()
     menu.lanza()
Example #14
0
    def __init__(self, owner, procesador):

        title = _("In one line")
        titulo = _("Turn on the lights") + ": " + title
        extparam = "tolconfoneline"
        icono = Iconos.TOLchange()
        QTVarios.WDialogo.__init__(self, owner, titulo, icono, extparam)

        self.tol = TurnOnLights.read_oneline_tol()
        self.procesador = procesador

        lbNumPos = Controles.LB2P(self, _("Number of positions"))
        liBlocks = [(str(x), x) for x in range(6, 60, 6)]
        self.cbNumPos = Controles.CB(self, liBlocks, self.tol.num_pos)

        lbtipo = Controles.LB2P(self, _("Mode"))
        liTipos = [(_("Calculation mode"), True), (_("Memory mode"), False)]
        self.cbTipo = Controles.CB(self, liTipos, self.tol.calculation_mode)

        lbfile = Controles.LB2P(self, _("File"))
        pbfile = Controles.PB(self, "", self.newfile).ponIcono(Iconos.Buscar())
        self.lbshowfile = Controles.LB(self, self.tol.fns)
        lyfile = Colocacion.H().control(pbfile).control(
            self.lbshowfile).relleno(1)

        self.chbauto = Controles.CHB(self, _("Redo each day automatically"),
                                     self.tol.auto_day)

        tb = Controles.TBrutina(self)
        tb.new(_("Accept"), Iconos.Aceptar(), self.aceptar)
        tb.new(_("Cancel"), Iconos.Cancelar(), self.cancelar)

        # Colocamos ---------------------------------------------------------------
        ly = Colocacion.G()
        ly.controld(lbNumPos, 1, 0).control(self.cbNumPos, 1, 1)
        ly.controld(lbtipo, 2, 0).control(self.cbTipo, 2, 1)
        ly.controld(lbfile, 3, 0).otro(lyfile, 3, 1)
        ly.control(self.chbauto, 4, 0, 1, 2)

        layout = Colocacion.V().control(tb).espacio(10).otro(ly)

        self.setLayout(layout)

        self.recuperarVideo(siTam=True)
 def colors(self):
     menu = QTVarios.LCMenu(self)
     d = {
         "0": Iconos.Gris32(),
         "1": Iconos.Amarillo32(),
         "2": Iconos.Naranja32(),
         "3": Iconos.Verde32(),
         "4": Iconos.Azul32(),
         "5": Iconos.Magenta32(),
         "6": Iconos.Rojo32(),
         "7": Iconos.Light32()
     }
     num, ultimo = TurnOnLights.numColorMinimum(self.tol)
     snum = str(num)
     for txt, key, secs in TurnOnLights.QUALIFICATIONS:
         rotulo = "%s < %0.2f\"" % (_F(txt), secs)
         if key == snum and not ultimo:
             rotulo += " = %s" % _("Minimum to access next level")
         menu.opcion(None, rotulo, d[key])
         menu.separador()
     menu.lanza()
Example #16
0
 def goto_next(self):
     self.tol.work_level += 1
     TurnOnLights.write_tol(self.tol)
     self.reinit = True
     self.guardarVideo()
     self.accept()
Example #17
0
    def gridBotonDerecho(self, grid, fila, oColumna, modificadores):
        col = oColumna.clave
        if not col.startswith("BLOCK"):
            return
        num_block = int(col[5:])
        num_theme = fila
        block = self.tol.get_block(num_theme, num_block)
        litimes = block.times
        nmoves = block.num_moves()
        if not litimes and not block.reinits:
            return
        menu = QTVarios.LCMenu(self)
        menu.ponTipoLetra(nombre="Courier New", puntos=10)
        tt = 0
        te = 0
        ta = 0
        mixed_results = False
        for dato in litimes:
            if len(dato) == 2:  # version antigua
                segs, fecha = dato
                time_used = segs * nmoves
                errores = 0
                ayudas = 0
                mixed_results = True
            else:
                segs, fecha, time_used, errores, ayudas = dato
            txt, ico = TurnOnLights.qualification(
                segs, self.tol.is_calculation_mode())
            menu.opcion(
                None, "%d-%02d-%02d %02d:%02d %6.02f  %6.02f  %s" %
                (fecha.year, fecha.month, fecha.day, fecha.hour, fecha.minute,
                 segs, time_used, txt), self.dicIconos[ico])
            tt += time_used
            te += errores
            ta += ayudas

        if litimes:
            menu.separador()
            menu.opcion(
                None,
                "%16s %6.02f" % (_("Average"), tt / (nmoves * len(litimes))))
            menu.separador()
        plant = "%16s %15.02f  %s"
        if block.reinits:
            tr = 0.0
            for dato in block.reinits:
                if len(dato) == 2:  # version antigua
                    segs, fecha = dato
                    errores = 0
                    ayudas = 0
                else:
                    segs, fecha, errores, ayudas = dato
                tr += segs
                tt += segs
                te += errores
                ta += ayudas
            menu.separador()
            menu.opcion(
                None, plant % (_("Restarts"), tr,
                               time.strftime("%H:%M:%S", time.gmtime(tr))))
        if not mixed_results:
            menu.separador()
            menu.opcion(None, "%16s %6d" % (_("Errors"), te))
            menu.separador()
            menu.opcion(None, "%16s %6d" % (_("Hints"), ta))
        menu.separador()
        menu.opcion(
            None, plant %
            (_("Total time"), tt, time.strftime("%H:%M:%S", time.gmtime(tt))))

        menu.lanza()
Example #18
0
    def end_line(self):
        self.num_line += 1
        islast_line = self.num_line == self.num_lines
        if islast_line:

            # Previous
            ant_tm = self.block.av_seconds()
            ant_done = self.tol.done_level()
            ant_cat_level, nada = self.tol.cat_num_level()
            ant_cat_global = self.tol.cat_global()

            num_moves = self.block.num_moves()
            ta = self.total_time_used + self.errores * self.penaltyError + self.ayudas * self.penaltyHelp
            tm = ta / num_moves
            self.block.new_result(tm, self.total_time_used, self.errores,
                                  self.ayudas)
            TurnOnLights.write_tol(self.tol)
            cat_block, ico = TurnOnLights.qualification(
                tm, self.calculation_mode)
            cat_level, ico = self.tol.cat_num_level()
            cat_global = self.tol.cat_global()

            txt_more_time = ""
            txt_more_cat = ""
            txt_more_line = ""
            txt_more_global = ""
            if ant_tm is None or tm < ant_tm:
                txt_more_time = '<span style="color:red">%s</span>' % _(
                    "New record")
                done = self.tol.done_level()
                if done and (not ant_done):
                    if not self.tol.islast_level():
                        txt_more_line = "%s<hr>" % _("Open the next level")
                if cat_level != ant_cat_level:
                    txt_more_cat = '<span style="color:red">%s</span>' % _(
                        "New")
                if cat_global != ant_cat_global:
                    txt_more_global = '<span style="color:red">%s</span>' % _(
                        "New")

            cErrores = (
                '<tr><td align=right> %s </td><td> %d (x%d"=%d")</td></tr>' %
                (_("Errors"), self.errores, self.penaltyError,
                 self.errores * self.penaltyError) if self.errores else "")
            cAyudas = (
                '<tr><td align=right> %s </td><td> %d (x%d"=%d")</td></tr>' %
                (_("Hints"), self.ayudas, self.penaltyHelp,
                 self.ayudas * self.penaltyHelp) if self.ayudas else "")
            mens = ("<hr><center><big>" +
                    _("You have finished this block of positions") +
                    "<hr><table>" +
                    '<tr><td align=right> %s </td><td> %0.2f"</td></tr>' %
                    (_("Time used"), self.total_time_used) + cErrores +
                    cAyudas +
                    '<tr><td align=right> %s: </td><td> %0.2f" %s</td></tr>' %
                    (_("Time assigned"), ta, txt_more_time) +
                    "<tr><td align=right> %s: </td><td> %d</td></tr>" %
                    (_("Total moves"), num_moves) +
                    '<tr><td align=right> %s: </td><td> %0.2f"</td></tr>' %
                    (_("Average time"), tm) +
                    "<tr><td align=right> %s: </td><td> %s</td></tr>" %
                    (_("Block qualification"), cat_block) +
                    "<tr><td align=right> %s: </td><td> %s %s</td></tr>" %
                    (_("Level qualification"), cat_level, txt_more_cat) +
                    "<tr><td align=right> %s: </td><td> %s %s</td></tr>" %
                    (_("Global qualification"), cat_global, txt_more_global) +
                    "</table></center></big><hr>" + txt_more_line)
            self.pon_rotulos(None)
            QTUtil2.message_bold(self.main_window, mens,
                                 _("Result of training"))
            self.total_time_used = 0

        else:
            if (self.tol.go_fast is True) or ((self.tol.go_fast is None)
                                              and self.tol.work_level > 0):
                self.next_line_run()
                return
            QTUtil2.mensajeTemporal(self.main_window,
                                    _("This line training is completed."), 1.3)
            self.pon_rotulos(0)

        self.state = ST_ENDGAME
        self.disable_all()

        li_options = [TB_CLOSE, TB_REINIT, TB_CONFIG, TB_UTILITIES]

        if not islast_line:
            li_options.append(TB_NEXT)

        self.main_window.pon_toolbar(li_options)
Example #19
0
    def __init__(self, procesador, name, title, icono, folder, li_tam_blocks,
                 one_line):
        self.one_line = one_line
        if one_line:
            self.tol = TurnOnLights.read_oneline_tol()
        else:
            self.tol = TurnOnLights.read_tol(name, title, folder,
                                             li_tam_blocks)
        self.reinit = False

        titulo = _("Turn on the lights") + ": " + title
        if self.tol.is_calculation_mode():
            tipo = _("Calculation mode")
            background = "#88AA3A"
        else:
            tipo = _("Memory mode")
            background = "#BDDBE8"

        self.procesador = procesador
        extparam = "tol%s-%d" % (name, self.tol.work_level)

        QTVarios.WDialogo.__init__(self, procesador.pantalla, titulo, icono,
                                   extparam)

        self.colorTheme = QTUtil.qtColor("#F0F0F0")

        lb = Controles.LB(self, tipo)
        lb.ponFondoN(background).alinCentrado().ponTipoLetra(puntos=14)

        # Toolbar
        tb = Controles.TBrutina(self)
        tb.new(_("Close"), Iconos.MainMenu(), self.terminar)
        anterior, siguiente, terminado = self.tol.prev_next()
        if terminado:
            tb.new(_("Rebuild"), Iconos.Reindexar(), self.rebuild)
        if anterior:
            tb.new(_("Previous"), Iconos.Anterior(), self.goto_previous)
        if siguiente:
            tb.new(_("Next"), Iconos.Siguiente(), self.goto_next)
        if one_line:
            tb.new(_("Change"), Iconos.TOLchange(), self.cambiar_one_line)
        tb.new(_("Config"), Iconos.Configurar(), self.config)
        tb.new(_("Information"), Iconos.Informacion(), self.colors)

        # Lista
        oColumnas = Columnas.ListaColumnas()
        work_level = self.tol.work_level + 1
        oColumnas.nueva("THEME",
                        _("Level %d/%d") % (work_level, self.tol.num_levels),
                        175)

        edicionIconos = Delegados.PmIconosColor()
        self.dicIconos = {}
        for k, pm in edicionIconos.dicpmIconos.iteritems():
            self.dicIconos[k] = QtGui.QIcon(pm)

        for x in range(self.tol.num_blocks):
            oColumnas.nueva("BLOCK%d" % x,
                            "%d" % (x + 1, ),
                            42,
                            siCentrado=True,
                            edicion=edicionIconos)

        self.grid = grid = Grid.Grid(self,
                                     oColumnas,
                                     altoFila=42,
                                     background="white")
        self.grid.setAlternatingRowColors(False)
        self.grid.tipoLetra(puntos=10, peso=500)
        nAnchoPgn = self.grid.anchoColumnas() + 20
        self.grid.setMinimumWidth(nAnchoPgn)
        self.registrarGrid(grid)

        # Colocamos ---------------------------------------------------------------
        ly = Colocacion.V().control(lb).control(tb).control(self.grid)

        self.setLayout(ly)

        alto = self.tol.num_themes * 42 + 146
        self.recuperarVideo(siTam=True,
                            altoDefecto=alto,
                            anchoDefecto=max(nAnchoPgn, 480))
Example #20
0
    def finLinea(self):
        self.num_line += 1
        islast_line = self.num_line == self.num_lines
        if islast_line:

            #Previous
            ant_tm = self.block.av_seconds()
            ant_done = self.tol.done_level()
            ant_cat_level, nada = self.tol.cat_num_level()
            ant_cat_global = self.tol.cat_global()

            num_moves = self.block.num_moves()
            ta = self.total_time_used + self.errores * 5.0 + self.ayudas * 10.0
            tm = ta / num_moves
            self.block.new_result(tm)
            TurnOnLights.write_tol(self.tol)
            cat_block, ico = TurnOnLights.qualification(tm)
            cat_level, ico = self.tol.cat_num_level()
            cat_global = self.tol.cat_global()

            txt_more_time = ""
            txt_more_cat = ""
            txt_more_line = ""
            txt_more_global = ""
            if ant_tm is None or tm < ant_tm:
                txt_more_time = '<span style="color:red">%s</span>' % _(
                    "New record")
                done = self.tol.done_level()
                if done and (not ant_done):
                    if not self.tol.islast_level():
                        txt_more_line = "%s<hr>" % _("Open the next level")
                if cat_level != ant_cat_level:
                    txt_more_cat = '<span style="color:red">%s</span>' % _(
                        "New")
                if cat_global != ant_cat_global:
                    txt_more_global = '<span style="color:red">%s</span>' % _(
                        "New")

            cErrores = '<tr><td align=right> %s </td><td> %d (x5"=%d")</td></tr>' % (
                _('Errors'), self.errores,
                self.errores * 5) if self.errores else ""
            cAyudas = '<tr><td align=right> %s </td><td> %d (x10"=%d")</td></tr>' % (
                _('Hints'), self.ayudas,
                self.ayudas * 10) if self.ayudas else ""
            mens = ('<hr><center><big>' +
                    _('You have finished this block of positions') +
                    '<hr><table>' +
                    '<tr><td align=right> %s </td><td> %0.2f"</td></tr>' %
                    (_('Time used'), self.total_time_used) + cErrores +
                    cAyudas +
                    '<tr><td align=right> %s: </td><td> %0.2f" %s</td></tr>' %
                    (_('Time assigned'), ta, txt_more_time) +
                    '<tr><td align=right> %s: </td><td> %d</td></tr>' %
                    (_('Total moves'), num_moves) +
                    '<tr><td align=right> %s: </td><td> %0.2f"</td></tr>' %
                    (_('Average time'), tm) +
                    '<tr><td align=right> %s: </td><td> %s</td></tr>' %
                    (_('Block qualification'), cat_block) +
                    '<tr><td align=right> %s: </td><td> %s %s</td></tr>' %
                    (_('Level qualification'), cat_level, txt_more_cat) +
                    '<tr><td align=right> %s: </td><td> %s %s</td></tr>' %
                    (_('Global qualification'), cat_global, txt_more_global) +
                    '</table></center></big><hr>' + txt_more_line)
            QTUtil2.mensaje(self.pantalla, mens, _("Result of training"))

        else:
            if self.tol.go_fast:
                self.next_line_run()
                return
            QTUtil2.mensajeTemporal(self.pantalla,
                                    _("This line training is completed."), 1.3)

        self.estado = kFinJuego
        self.desactivaTodas()

        liOpciones = [k_mainmenu, k_reiniciar, k_configurar, k_utilidades]

        if not islast_line:
            liOpciones.append(k_siguiente)

        self.pantalla.ponToolBar(liOpciones)
Example #21
0
 def goto_previous(self):
     self.tol.work_level -= 1
     TurnOnLights.write_tol(self.tol)
     self.reinit = True
     self.save_video()
     self.accept()