def run(self):
        g.init()
        if not self.journal: utils.load()
        self.chess=chess.Chess()
        g.cells=self.chess.cells
        load_save.retrieve()
        self.chess.setup() # having retrieved layout if any
        self.buttons_setup()
        if self.canvas<>None: self.canvas.grab_focus()
        ctrl=False
        pygame.key.set_repeat(600,120); key_ms=pygame.time.get_ticks()
        going=True
        while going:
            if self.journal:
                # Pump GTK messages.
                while gtk.events_pending(): gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type==pygame.QUIT:
                    if not self.journal: utils.save()
                    going=False
                elif event.type == pygame.MOUSEMOTION:
                    g.pos=event.pos
                    g.redraw=True
                    if self.canvas<>None: self.canvas.grab_focus()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw=True
                    if event.button==1:
                        if self.do_click():
                            pass
                        else:
                            bu=buttons.check()
                            if bu!='': self.do_button(bu); self.flush_queue()
                elif event.type == pygame.KEYDOWN:
                    # throttle keyboard repeat
                    if pygame.time.get_ticks()-key_ms>110:
                        key_ms=pygame.time.get_ticks()
                        if ctrl:
                            if event.key==pygame.K_q:
                                if not self.journal: utils.save()
                                going=False; break
                            else:
                                ctrl=False
                        if event.key in (pygame.K_LCTRL,pygame.K_RCTRL):
                            ctrl=True; break
                        self.do_key(event.key); g.redraw=True
                        self.flush_queue()
                elif event.type == pygame.KEYUP:
                    ctrl=False
            if not going: break
            if g.redraw:
                self.display()
                if g.version_display: utils.version_display()
                g.screen.blit(g.pointer,g.pos)
                pygame.display.flip()
                g.redraw=False
            self.update()
            g.clock.tick(40)
    def run(self):
        g.init()
        g.journal = self.journal
        if not self.journal:
            utils.load()
            self.best = g.best
        else:
            g.best = self.best
        buttons.Button('reset', (g.sx(15.6), g.yc), True)
        buttons.Button('new', (g.sx(18.8), g.yc), True)
        self.board = tra.Board()
        self.board.setup()
        if self.journal:  # Sugar only
            a, b, c, d = pygame.cursors.load_xbm('my_cursor.xbm',
                                                 'my_cursor_mask.xbm')
            pygame.mouse.set_cursor(a, b, c, d)
        going = True
        while going:
            g.mx, g.my = pygame.mouse.get_pos()
            # Pump GTK messages.
            while gtk.events_pending():
                gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    if not self.journal: utils.save()
                    going = False
                elif event.type == pygame.MOUSEMOTION:
                    g.redraw = True
                    if self.canvas <> None: self.canvas.grab_focus()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw = True
                    if event.button == 2:  # centre button
                        if not self.journal:
                            g.version_display = not g.version_display
                    if event.button == 1:
                        g.glow_ms = None
                        g.red_ms = None
                        bu = buttons.check()
                        if bu != '': self.do_button(bu)
                        else: self.board.click()
                elif event.type == pygame.KEYDOWN:
                    self.do_key(event.key)
                    g.redraw = True
            if not going: break
            self.update()
            #self.board.setup(); g.redraw=True###
            if g.redraw:
                self.display()
                if g.version_display: utils.version_display()
                pygame.display.flip()
                g.redraw = False
            if g.score > g.best: g.best = g.score
            self.best = g.best
            tf = False
            if pygame.mouse.get_focused(): tf = True
            pygame.mouse.set_visible(tf)
            g.clock.tick(40)
    def run(self):
        g.init()
        if not self.journal:
            utils.load()
            self.tess_n = g.tess_n
            self.max_n = g.max_n
        else:
            g.tess_n = self.tess_n
            g.max_n = self.max_n
        self.tessl = tess.Tess(g.tesses[g.tess_n - 1])
        dx = g.sy(2.4)
        bx = g.sx(16) - dx / 2
        by = g.sy(20.2)
        buttons.Button("back", (bx, by), True)
        bx += dx
        buttons.Button("fd", (bx, by), True)
        bx = g.sx(16)
        by = g.sy(11)
        buttons.Button("solve", (bx, by), True)
        if self.journal:  # Sugar only
            a, b, c, d = pygame.cursors.load_xbm('my_cursor.xbm',
                                                 'my_cursor_mask.xbm')
            pygame.mouse.set_cursor(a, b, c, d)
        going = True

        while going:
            # Pump GTK messages.
            while gtk.events_pending():
                gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    if not self.journal: utils.save()
                    going = False
                elif event.type == pygame.MOUSEMOTION:
                    g.redraw = True
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw = True
                    if event.button == 2:  # centre button
                        if not self.journal:
                            g.version_display = not g.version_display
                            break
                    bu = ''
                    if not self.tessl.carrying:
                        bu = buttons.check()
                    if bu <> '': self.do_button(bu)
                    else: self.tessl.click()
            self.tessl.update()
            if g.redraw:
                self.display()
                if g.version_display: utils.version_display()
                pygame.display.flip()
                g.redraw = False
            tf = False
            if pygame.mouse.get_focused(): tf = True
            pygame.mouse.set_visible(tf)
            g.clock.tick(40)
    def run(self):
        g.init()
        g.journal=self.journal
        if not self.journal:
            utils.load(); self.score=g.score; self.level=g.level
        else:
            g.score=self.score; g.level=self.level
        self.buttons_setup()
        if self.journal: # Sugar only
            a,b,c,d=pygame.cursors.load_xbm('my_cursor.xbm','my_cursor_mask.xbm')
            pygame.mouse.set_cursor(a,b,c,d)
        self.slider=slider.Slider(g.sx(16),g.sy(20.5),9,utils.GREEN)
        self.grid=ah.Grid()
        self.grid.new1(); self.grid.setup()
        going=True
        while going:
            # Pump GTK messages.
            while gtk.events_pending():
                gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type==pygame.QUIT:
                    if not self.journal: utils.save()
                    going=False
                elif event.type == pygame.MOUSEMOTION:
                    g.redraw=True
                    if self.canvas<>None: self.canvas.grab_focus()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw=True
                    if event.button==2: # centre button
                        if not self.journal:
                            g.version_display=not g.version_display
                    if event.button==1:
                        if self.grid.click():
                            pass
                        elif self.slider.mouse():
                            self.grid.new1(); self.grid.setup(); buttons.clear() # level changed
                        else:
                            bu=buttons.check()
                            if bu!='': self.do_button(bu)
                            else: self.grid.colour_ind=0
                elif event.type == pygame.KEYDOWN:
                    self.do_key(event.key); g.redraw=True
            if not going: break
            if self.grid.complete():
                buttons.clear()
            if g.redraw:
                self.display()
                if g.version_display: utils.version_display()
                pygame.display.flip()
                g.redraw=False
            self.score=g.score; self.level=g.level
            tf=False
            if pygame.mouse.get_focused(): tf=True
            pygame.mouse.set_visible(tf)
            g.clock.tick(40)
Exemple #5
0
    def run(self):
        g.init()
        if not self.journal: utils.load()
        self.board = sud.Board()
        self.board.setup()
        load_save.retrieve()
        self.board.check()
        self.buttons_setup()
        if self.journal:  # Sugar only
            a, b, c, d = pygame.cursors.load_xbm('my_cursor.xbm',
                                                 'my_cursor_mask.xbm')
            pygame.mouse.set_cursor(a, b, c, d)
        going = True
        while going:
            # Pump GTK messages.
            while gtk.events_pending():
                gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:  # only in standalone version
                    if not self.journal: utils.save()
                    going = False
                elif event.type == pygame.MOUSEMOTION:
                    g.redraw = True
                    if self.canvas <> None: self.canvas.grab_focus()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw = True
                    if event.button == 2:  # centre button
                        if not self.journal:
                            g.version_display = not g.version_display
                    if event.button == 1:
                        bu = buttons.check()
                        if bu != '':
                            self.do_button(bu)
                        elif not g.finished:
                            if not self.help_check():
                                self.board.click()
                                if g.finished:
                                    buttons.on('new')
                                    buttons.off('reset')
                    if event.button == 3:
                        if not g.finished:
                            self.board.right_click()
            if not going: break
            if g.redraw:
                self.display()
                if g.version_display: utils.version_display()
                #g.screen.blit(g.pointer,(g.mx,g.my))
                pygame.display.flip()
                g.redraw = False
            self.count = g.count
            tf = False
            if pygame.mouse.get_focused(): tf = True
            pygame.mouse.set_visible(tf)
            g.clock.tick(40)
    def run(self):
        g.init()
        if not self.journal: utils.load()
        self.oms = []
        for n in range(3, 8):
            omm = om.Om(n)
            omm.setup()
            self.oms.append(omm)
        load_save.retrieve()
        self.omm = self.oms[g.level - 1]
        self.buttons_setup()
        self.slider = slider.Slider(g.sx(10.5), g.sy(20), 5, utils.YELLOW)
        going = True
        while going:
            # Pump GTK messages.
            while gtk.events_pending():
                gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:  # only in standalone version
                    if not self.journal: utils.save()
                    going = False
                elif event.type == pygame.MOUSEMOTION:
                    g.pos = event.pos
                    self.omm.mouse_move()
                    g.redraw = True
                    if self.canvas <> None: self.canvas.grab_focus()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw = True
                    if event.button == 2:  # centre button
                        if not self.journal:
                            g.version_display = not g.version_display
                    if event.button == 1:
                        if self.do_click():
                            pass
                        elif self.slider.mouse():  # level changed
                            self.omm = self.oms[g.level - 1]
                        else:
                            bu = buttons.check()
                            if bu != '': self.do_button(bu)
                    if event.button == 3:  # right button
                        self.do_button('try')
                elif event.type == pygame.KEYDOWN:
                    self.do_key(event.key)
                    g.redraw = True
            if not going: break
            if g.redraw:
                self.display()
                if not self.journal:  # not on XO
                    if g.version_display: utils.version_display()
                g.screen.blit(g.pointer, g.pos)
                pygame.display.flip()
                g.redraw = False
            g.clock.tick(40)
Exemple #7
0
    def run(self):
        g.init()
        self.rects=rects.Rects()
        if not self.journal:
            utils.load()
        else:
            g.level=self.level
        self.slider=slider.Slider(g.sx(16),g.sy(20.5),10,utils.GREEN)
        self.new1()
        bx=g.sx(29.5); by=g.sy(12)
        buttons.Button("cyan",(bx,by),True)
        by=g.sy(16)
        buttons.Button("black",(bx,by),True)
        if self.journal: # Sugar only
            a,b,c,d=pygame.cursors.load_xbm('my_cursor.xbm','my_cursor_mask.xbm')
            pygame.mouse.set_cursor(a,b,c,d)
        going=True
        while going:
            # Pump GTK messages.
            while gtk.events_pending():
                gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type==pygame.QUIT:
                    if not self.journal: utils.save()
                    going=False
                elif event.type == pygame.MOUSEMOTION:
                    g.redraw=True
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw=True
                    if event.button==2: # centre button
                        if not self.journal:
                            g.version_display=not g.version_display; break
                    bu=buttons.check()
                    if bu<>'': self.button(bu); break
                    if self.slider.mouse(): self.new1(); break
                    if self.rects.click():
                        if not g.magic_show:
                            if self.rects.correct():
                                g.score+=g.level; g.magic_show=True
                                buttons.off("black")
            if not going: break
            if g.redraw:
                self.display()
                if g.version_display: utils.version_display()
                pygame.display.flip()
                g.redraw=False
            tf=False
            if pygame.mouse.get_focused(): tf=True
            pygame.mouse.set_visible(tf)
            g.clock.tick(40)
            # be ready for xo quit at any time
            self.level=g.level
Exemple #8
0
    def run(self):
        g.init()
        self.grid = grid.Grid(8, 8, g.sy(2.4), 2, (212, 212, 175), utils.CREAM,
                              g.x0, g.y0)
        if not self.journal: utils.load()
        # setup before retrieve
        self.grid.setup()
        load_save.retrieve()
        self.buttons_setup()
        going = True
        while going:
            # Pump GTK messages.
            while gtk.events_pending():
                gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:  # only in standalone version
                    if not self.journal: utils.save()
                    going = False
                elif event.type == pygame.MOUSEMOTION:
                    g.pos = event.pos
                    self.grid.check_mouse()
                    g.redraw = True
                    if self.canvas <> None: self.canvas.grab_focus()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw = True
                    if event.button == 2:  # centre button
                        if not self.journal:
                            g.version_display = not g.version_display
                    if event.button == 3:
                        g.ms = None
                        self.grid.right_click()
                    if event.button == 1:
                        g.ms = None
                        if self.do_click():
                            pass
                        else:
                            bu = buttons.check()
                            if bu != '': self.do_button(bu)
                elif event.type == pygame.KEYDOWN:
                    g.ms = None
                    self.do_key(event.key)
                    g.redraw = True
            if not going: break
            self.glow()
            if g.redraw:
                self.display()
                if not self.journal:  # not on XO
                    if g.version_display: utils.version_display()
                g.screen.blit(g.pointer, g.pos)
                pygame.display.flip()
                g.redraw = False
            g.clock.tick(40)
Exemple #9
0
    def run(self):
        g.init()
        if not self.journal: utils.load()
        load_save.retrieve()
        g.puzzle_n=g.solved
        if g.puzzle_n==10: g.puzzle_n=0
        iq1.init(); iq1.setup()
        if self.canvas<>None: self.canvas.grab_focus()
        ctrl=False
        pygame.key.set_repeat(600,120); key_ms=pygame.time.get_ticks()
        going=True
        while going:
            if self.journal:
                # Pump GTK messages.
                while Gtk.events_pending(): Gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type==pygame.QUIT:
                    if not self.journal: utils.save()
                    going=False
                elif event.type == pygame.MOUSEMOTION:
                    g.pos=event.pos
                    g.redraw=True
                    if self.canvas<>None: self.canvas.grab_focus()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw=True
                    if event.button==1: self.do_click(); self.flush_queue()
                elif event.type == pygame.KEYDOWN:
                    # throttle keyboard repeat
                    if pygame.time.get_ticks()-key_ms>110:
                        key_ms=pygame.time.get_ticks()
                        if ctrl:
                            if event.key==pygame.K_q:
                                if not self.journal: utils.save()
                                going=False; break
                            else:
                                ctrl=False
                        if event.key in (pygame.K_LCTRL,pygame.K_RCTRL):
                            ctrl=True; break
                        self.do_key(event.key); g.redraw=True
                        self.flush_queue()
                elif event.type == pygame.KEYUP:
                    ctrl=False
            if not going: break
            if g.redraw:
                self.display()
                if g.version_display: utils.version_display()
                g.screen.blit(g.pointer,g.pos)
                pygame.display.flip()
                g.redraw=False
                iq1.complete()
                if g.finished and not g.redrawn: g.redraw=True; g.redrawn=True
            g.clock.tick(40)
    def run(self):
        g.init()
        if not self.journal:
            utils.load(); self.level=g.level
        else:
            g.level=self.level
        x=g.sx(26); y=g.sy(11.2)
        buttons.Button("new",(x,y))
        x=g.sx(4); y=g.sy(10); dx=g.sy(4)
        buttons.Button("back",(x,y)); x+=dx
        buttons.Button("plus",(x,y)); x+=dx
        buttons.Button("times",(x,y)); x+=dx
        buttons.Button("equals",(x,y))
        self.slider=slider.Slider(g.sx(20.5),g.sy(20.5),10,utils.GREEN)
        if self.journal: # Sugar only
            a,b,c,d=pygame.cursors.load_xbm('my_cursor.xbm','my_cursor_mask.xbm')
            pygame.mouse.set_cursor(a,b,c,d)
        self.level1() # initial animation
        going=True
        while going:
            self.level=g.level
            # Pump GTK messages.
            while gtk.events_pending():
                gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type==pygame.QUIT:
                    if not self.journal: utils.save()
                    going=False
                elif event.type == pygame.MOUSEMOTION:
                    g.redraw=True
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw=True
                    if event.button==2: # centre button
                        if not self.journal:
                            g.version_display=not g.version_display; break
                    bu=buttons.check()
                    if bu=='':
                        if not self.check_numbers():
                            if self.slider.mouse(): self.level1()
                    else: self.do_button(bu) # eg do_button('plus')
            if not going: break
            if g.redraw:
                self.display()
                if g.version_display: utils.version_display()
                pygame.display.flip()
                g.redraw=False
            tf=False
            if pygame.mouse.get_focused(): tf=True
            pygame.mouse.set_visible(tf)
            g.clock.tick(40)
Exemple #11
0
    def run(self, restore=False):
        self.black = False
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                return
            elif event.type == pygame.VIDEORESIZE:
                pygame.display.set_mode(event.size, pygame.RESIZABLE)
                break
        g.init()
        if not self.journal:
            utils.load()
        load_save.retrieve()
        x = g.sx(26)
        y = g.sy(11.2)
        if not self.sugar:
            buttons.Button("new", (x, y))
        x, y = g.cxy2
        dx = g.sy(4)
        self.back_button = buttons.Button("back", (x, y))
        x += dx
        buttons.Button("plus", (x, y))
        x += dx
        buttons.Button("times", (x, y))
        x += dx
        buttons.Button("equals", (x, y))
        self.ops = ['back', 'plus', 'times', 'equals']
        if not self.sugar:
            self.slider = slider.Slider(g.sx(22.4), g.sy(20.5), 10,
                                        utils.GREEN)
        self.mouse_auto = True
        self.anim_ms = None

        self.level1()  # initial animation
        self.scored = False
        if restore:
            g.score = self.save_score
        ctrl = False
        pygame.key.set_repeat(600, 120)
        key_ms = pygame.time.get_ticks()
        going = True
        if self.canvas is not None:
            self.canvas.grab_focus()
        while going:
            if self.journal:
                # Pump GTK messages.
                while Gtk.events_pending():
                    Gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    if not self.journal:
                        utils.save()
                    going = False
                elif event.type == pygame.MOUSEMOTION:
                    g.pos = event.pos
                    g.redraw = True
                    if self.canvas is not None:
                        self.canvas.grab_focus()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw = True
                    self.anim_end()
                    if event.button == 1:
                        bu = buttons.check()
                        if bu == '':
                            if not self.check_numbers():
                                if not self.sugar:
                                    if self.slider.mouse():
                                        self.level1()
                        else:
                            self.do_button(bu)  # eg do_button('plus')
                    self.flush_queue()
                elif event.type == pygame.KEYDOWN:
                    self.anim_end()
                    # throttle keyboard repeat
                    if pygame.time.get_ticks() - key_ms > 110:
                        key_ms = pygame.time.get_ticks()
                        if ctrl:
                            if event.key == pygame.K_q:
                                if not self.journal:
                                    utils.save()
                                going = False
                                break
                            else:
                                ctrl = False
                        if event.key in (pygame.K_LCTRL, pygame.K_RCTRL):
                            ctrl = True
                            break
                        self.do_key(event.key)
                        g.redraw = True
                        self.flush_queue()
                elif event.type == pygame.KEYUP:
                    ctrl = False
            if not going:
                break
            self.animation()
            if g.redraw:
                self.display()
                if g.version_display:
                    utils.version_display()
                if not self.black:
                    g.screen.blit(g.pointer, g.pos)
                pygame.display.flip()
                g.redraw = False
            g.clock.tick(40)
Exemple #12
0
    def run(self):
        g.init()
        if not self.journal: utils.load()
        self.tr = [None, None, None, None]
        self.menu = menu.Menu(4, 4, g.sy(.2), g.sy(1.3), g.sy(.2))
        load_save.retrieve()
        self.buttons_setup()
        self.slider = [None, None]
        self.slider[0] = slider.Slider(g.sx(16), g.sy(20.8), 2, utils.GREEN)
        self.slider[1] = slider.Slider(g.sx(16), g.sy(20.8), 3, utils.GREEN)
        self.levels = [1] * 16
        if self.canvas <> None: self.canvas.grab_focus()
        ctrl = False
        pygame.key.set_repeat(600, 120)
        key_ms = pygame.time.get_ticks()
        going = True
        while going:
            if self.journal:
                # Pump GTK messages.
                while gtk.events_pending():
                    gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    if not self.journal: utils.save()
                    going = False
                elif event.type == pygame.MOUSEMOTION:
                    g.pos = event.pos
                    g.redraw = True
                    if self.canvas <> None: self.canvas.grab_focus()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw = True
                    if event.button == 1:
                        if self.do_click():
                            pass
                        else:
                            if g.state == 'jigsaw':
                                bu = buttons.check()
                                if bu != '':
                                    self.do_button(bu)
                                    self.flush_queue()
                elif event.type == pygame.KEYDOWN:
                    # throttle keyboard repeat
                    if pygame.time.get_ticks() - key_ms > 110:
                        key_ms = pygame.time.get_ticks()
                        if ctrl:
                            if event.key == pygame.K_q:
                                if not self.journal: utils.save()
                                going = False
                                break
                            else:
                                ctrl = False
                        if event.key in (pygame.K_LCTRL, pygame.K_RCTRL):
                            ctrl = True
                            break
                        self.do_key(event.key)
                        g.redraw = True
                        self.flush_queue()
                elif event.type == pygame.KEYUP:
                    ctrl = False
            if not going: break
            if g.redraw:
                self.display()
                if g.version_display: utils.version_display()
                g.screen.blit(g.pointer, g.pos)
                pygame.display.flip()
                g.redraw = False
            g.clock.tick(40)
    def run(self):
        g.init()
        g.journal = self.journal
        if not self.journal:
            utils.load()
            self.best = g.best
        else:
            g.best = self.best
        self.castle = cas.Castle(4)  # 4x4 - 3x3 is ok too
        self.castle.setup()
        self.bu_setup()
        going = True
        while going:
            ms = pygame.time.get_ticks()
            g.mx, g.my = pygame.mouse.get_pos()
            # Pump GTK messages.
            while gtk.events_pending():
                gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    if not self.journal: utils.save()
                    going = False
                elif event.type == pygame.MOUSEMOTION:
                    g.redraw = True
                    if self.canvas <> None: self.canvas.grab_focus()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw = True
                    if event.button == 2:  # centre button
                        g.version_display = not g.version_display
                        break
                    if g.state == 1:
                        if g.telep_ms <> None:
                            g.telep_ms = None
                            break  # stop teleporting
                        bu = buttons.check()
                        if bu != '':
                            self.do_button(bu)
                            break
                    if g.health > 0: self.click()
                elif event.type == pygame.MOUSEBUTTONUP:
                    g.redraw = True
                    if event.button == 1:
                        self.bu_clear()
                elif event.type == pygame.KEYDOWN:
                    if g.direction == '': self.do_key(event.key)
                elif event.type == pygame.KEYUP:
                    g.redraw = True
                    self.bu_clear()
            if not going: break
            self.castle.move(g.direction)
            self.castle.update()
            if g.health == 0: self.bus_off()
            if g.redraw:
                self.display()
                if g.version_display: utils.version_display()
                if g.my > g.pointer.get_height():
                    g.screen.blit(g.pointer, (g.mx, g.my))
                pygame.display.flip()
                g.redraw = False
            if g.best < g.score: g.best = g.score
            self.best = g.best
            g.clock.tick(40)
            d = pygame.time.get_ticks() - ms
            g.frame_rate = int(1000 / d)
Exemple #14
0
    def run(self):
        # g.init and self.manc require that we know the display size first
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                return
            elif event.type == pygame.VIDEORESIZE:
                pygame.display.set_mode(event.size, pygame.RESIZABLE)
                break
        g.init()
        if not self.journal: utils.load()
        self.manc = manc.Manc()
        self.manc.setup()
        load_save.retrieve()
        self.buttons_setup()
        if self.canvas <> None: self.canvas.grab_focus()
        ctrl = False
        pygame.key.set_repeat(600, 120)
        key_ms = pygame.time.get_ticks()
        going = True
        while going:
            if self.journal:
                # Pump GTK messages.
                while Gtk.events_pending():
                    Gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    if not self.journal: utils.save()
                    going = False
                elif event.type == pygame.MOUSEMOTION:
                    g.pos = event.pos
                    self.manc.check_mouse()
                    g.redraw = True
                    if self.canvas <> None: self.canvas.grab_focus()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw = True
                    if event.button == 1:
                        bu = buttons.check()
                        if bu != '': self.do_button(bu)
                        else: self.do_click()
                        self.flush_queue()
                elif event.type == pygame.KEYDOWN:
                    # throttle keyboard repeat
                    if pygame.time.get_ticks() - key_ms > 110:
                        key_ms = pygame.time.get_ticks()
                        if ctrl:
                            if event.key == pygame.K_q:
                                if not self.journal: utils.save()
                                going = False
                                break
                            else:
                                ctrl = False
                        if event.key in (pygame.K_LCTRL, pygame.K_RCTRL):
                            ctrl = True
                            break
                        self.do_key(event.key)
                        g.redraw = True
                        self.flush_queue()
                elif event.type == pygame.KEYUP:
                    ctrl = False
            if not going: break
            self.update()
            if g.redraw:
                self.display()
                if g.version_display: utils.version_display()
                g.screen.blit(g.pointer, g.pos)
                pygame.display.flip()
                g.redraw = False
            g.clock.tick(40)
    def run(self):
        g.init()
        if not self.journal: utils.load()
        self.sim=sim.Sim()
        load_save.retrieve()
        self.buttons_setup()
        if g.saved_n==0: buttons.off('cyan')
        self.slider=slider.Slider(g.sx(23.4),g.sy(20.2),5,utils.GREEN)
        if self.canvas<>None: self.canvas.grab_focus()
        ctrl=False
        pygame.key.set_repeat(600,120); key_ms=pygame.time.get_ticks()
        going=True
        while going:
            if self.journal:
                # Pump GTK messages.
                while gtk.events_pending(): gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type==pygame.QUIT:
                    if not self.journal: utils.save()
                    going=False
                elif event.type == pygame.MOUSEMOTION:
                    g.pos=event.pos
                    g.redraw=True
                    if self.canvas<>None: self.canvas.grab_focus()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw=True
                    if g.help_on: g.help_on=False 
                    elif event.button==1:
                        if self.do_click():
                            pass
                        elif self.slider.mouse():
                            pass # level changed
                        else:
                            bu=buttons.check()
                            if bu!='': self.do_button(bu); self.flush_queue()
                    elif event.button==3:
                        self.right_click()
                elif event.type == pygame.KEYDOWN:
                    # throttle keyboard repeat
                    if pygame.time.get_ticks()-key_ms>110:
                        key_ms=pygame.time.get_ticks()
                        if ctrl:
                            if event.key==pygame.K_q:
                                if not self.journal: utils.save()
                                going=False; break
                            else:
                                ctrl=False
                        if event.key in (pygame.K_LCTRL,pygame.K_RCTRL):
                            ctrl=True; break
                        self.do_key(event.key); g.redraw=True
                        self.flush_queue()
                elif event.type == pygame.KEYUP:
                    ctrl=False
            if not going: break
            self.update()
            if g.redraw:
                self.display()
                if g.version_display: utils.version_display()
                g.screen.blit(g.pointer,g.pos)
                pygame.display.flip()
                g.redraw=False
            g.clock.tick(40)
    def run(self, restore=False):
        for event in pygame.event.get():
            if event.type==pygame.QUIT:
                return
            elif event.type == pygame.VIDEORESIZE:
                pygame.display.set_mode(event.size, pygame.RESIZABLE)
                break
        self.g_init()
        if not self.journal:
            utils.load()
        load_save.retrieve()
        if restore:
            self.restore_pattern()
        else:
            g.delay = (3 - g.level) * 400
        self.tu = my_turtle.TurtleClass()
        self.tu.current = [1, 1, 1, 3, 2]
        self.get_goal()
        if g.pattern == 1:
            self.tu.current = utils.copy_list(g.goals[0])
        self.tu.setup(self.colors[0])
        g.numbers = utils.copy_list(self.tu.current)
        # buttons
        x = g.sx(7.3)
        y = g.sy(16.5)
        dx = g.sy(2.6)

        if not self.sugar:
            buttons.Button("cyan", (x, y), True)
            x += dx
            buttons.off('cyan')
            buttons.Button("green", (x, y), True)
            x += dx
            buttons.Button("red", (x, y), True)
            x += dx
            buttons.Button("black", (x, y), True)
            x += dx
            self.slider = slider.Slider(g.sx(23.5), g.sy(21), 3, utils.YELLOW)

        self.mouse_1st_no()  # to 1st number
        if self.canvas is not None:
            self.canvas.grab_focus()
        ctrl = False
        pygame.key.set_repeat(600, 120)
        key_ms = pygame.time.get_ticks()
        going = True
        while going:
            if self.journal:
                # Pump Gtk messages.
                while Gtk.events_pending():
                    Gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    if not self.journal:
                        utils.save()
                    going = False
                elif event.type == pygame.MOUSEMOTION:
                    g.pos = event.pos
                    g.redraw = True
                    if self.canvas is not None:
                        self.canvas.grab_focus()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw = True
                    if g.big:
                        g.big = False
                    else:
                        bu = buttons.check()
                        if bu != '':
                            self.do_button(bu)
                            self.flush_queue()
                        elif not self.sugar:
                            if utils.mouse_on_img1(g.magician, g.magician_c):
                                self.help2()
                            elif utils.mouse_in(g.x1, g.y0, g.x1 + g.bw,
                                                g.y0 + g.bw):
                                self.big_pic()
                            elif self.slider.mouse():
                                g.delay = (3 - g.level) * 400
                            else:
                                g.show_help = False
                                self.check_nos(event.button)
                        else:
                            g.show_help = False
                            self.check_nos(event.button)
                elif event.type == pygame.KEYDOWN:
                    # throttle keyboard repeat
                    if pygame.time.get_ticks() - key_ms > 110:
                        key_ms = pygame.time.get_ticks()
                        if ctrl:
                            if event.key == pygame.K_q:
                                if not self.journal:
                                    utils.save()
                                going = False
                                break
                            else:
                                ctrl = False
                        if event.key in (pygame.K_LCTRL, pygame.K_RCTRL):
                            ctrl = True
                            break
                        self.do_key(event.key)
                        g.redraw = True
                        self.flush_queue()
                elif event.type == pygame.KEYUP:
                    ctrl = False
            if not going:
                break
            if self.tu.running:
                self.tu.move()
            if not g.crash_drawn:
                g.crash_drawn = True
                g.redraw = True
            if g.redraw:
                self.display()
                if g.version_display:
                    utils.version_display()
                g.screen.blit(g.pointer, g.pos)
                pygame.display.flip()
                g.redraw = False
            g.clock.tick(40)
Exemple #17
0
    def run(self):
        g.init()
        if not self.journal:
            utils.load()
            g.xo = False
        load_save.retrieve()
        self.toc = layout.toc()
        self.layout = layout.Layout(g.w - 2 * g.offset, int(g.h * 19 / 24))
        self.render()
        self.jig = jig.Jig()
        self.buttons_setup()
        if self.canvas <> None: self.canvas.grab_focus()
        ctrl = False
        pygame.key.set_repeat(600, 120)
        key_ms = pygame.time.get_ticks()
        going = True
        while going:
            if self.journal:
                # Pump GTK messages.
                while gtk.events_pending():
                    gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    if not self.journal: utils.save()
                    going = False
                elif event.type == pygame.MOUSEMOTION:
                    g.pos = event.pos
                    g.redraw = True
                    if self.canvas <> None: self.canvas.grab_focus()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw = True
                    if event.button == 1:
                        bu = ''
                        if self.bu == None: bu = buttons.check()
                        if bu != '':
                            self.do_button(bu)
                            self.flush_queue()
                        else:
                            self.do_click()
                elif event.type == pygame.KEYDOWN:
                    # throttle keyboard repeat
                    if pygame.time.get_ticks() - key_ms > 110:
                        key_ms = pygame.time.get_ticks()
                        if ctrl:
                            if event.key == pygame.K_q:
                                if not self.journal: utils.save()
                                going = False
                                break
                            else:
                                ctrl = False
                        if event.key in (pygame.K_LCTRL, pygame.K_RCTRL):
                            ctrl = True
                            break
                        self.do_key(event.key)
                        g.redraw = True
                        self.flush_queue()
                elif event.type == pygame.KEYUP:
                    ctrl = False
            if not going: break
            if self.layout.movie != None: self.layout.movie.update()
            self.update()
            if g.redraw:
                self.display()
                if g.version_display: utils.version_display()
                g.screen.blit(g.pointer, g.pos)
                pygame.display.flip()
                g.redraw = False
            g.clock.tick(40)
Exemple #18
0
    def run(self):
        g.init()
        if not self.journal: utils.load()
        load_save.retrieve()
        self.buttons_setup()
        self.slider=slider.Slider(g.sx(16),g.sy(20.5),9,utils.GREEN)
        self.grid=ah.Grid()
        self.grid.new1(); self.grid.setup()
        if self.canvas!=None: 
            self.canvas.grab_focus()
        ctrl=False
        pygame.key.set_repeat(600,120); key_ms=pygame.time.get_ticks()
        going=True
        while going:
            if self.journal:
                # Pump GTK messages.
                while Gtk.events_pending(): Gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type==pygame.QUIT:
                    if not self.journal: utils.save()
                    going=False
                elif event.type == pygame.MOUSEMOTION:
                    g.pos=event.pos
                    g.redraw=True
                    if self.canvas!=None: self.canvas.grab_focus()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw=True
                    if event.button==1:
                        if self.grid.click():
                            pass
                        elif self.slider.mouse():
                            self.grid.new1(); self.grid.setup(); buttons.clear() # level changed
                        else:
                            bu=buttons.check()
                            if bu!='': self.do_button(bu)
                            else: self.grid.colour_ind=0
                        self.flush_queue()
                    elif event.button==3:
                        self.do_button('reset')
                elif event.type == pygame.KEYDOWN:
                    # throttle keyboard repeat
                    if pygame.time.get_ticks()-key_ms>110:
                        key_ms=pygame.time.get_ticks()
                        if ctrl:
                            if event.key==pygame.K_q:
                                if not self.journal: utils.save()
                                going=False; break
                            else:
                                ctrl=False
                        if event.key in (pygame.K_LCTRL,pygame.K_RCTRL):
                            ctrl=True; break
                        self.do_key(event.key); g.redraw=True
                        self.flush_queue()
                elif event.type == pygame.KEYUP:
                    ctrl=False
            if not going: break
            if self.grid.complete():
                buttons.clear()
            if g.redraw:
                self.display()
                if g.version_display: utils.version_display()
                g.screen.blit(g.pointer,g.pos)
                pygame.display.flip()
                g.redraw=False
            self.score=g.score; self.level=g.level
            g.clock.tick(40)
Exemple #19
0
    def run(self, restore=False):
        g.init()
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                return
            elif event.type == pygame.VIDEORESIZE:
                pygame.display.set_mode(event.size, pygame.RESIZABLE)
                break

        if not self.journal:
            utils.load()
        self.trip = trip.Trip(self.sugar, self.label, self.colors[0])
        self.trip.setup()
        load_save.retrieve()
        self.buttons_setup()
        if self.canvas is not None:
            self.canvas.grab_focus()
        ctrl = False
        pygame.key.set_repeat(600, 120)
        key_ms = pygame.time.get_ticks()
        going = True
        while going:
            if self.journal:
                # Pump GTK messages.
                while Gtk.events_pending():
                    Gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    # only in standalone version
                    if not self.journal:
                        utils.save()
                    going = False
                elif event.type == pygame.MOUSEMOTION:
                    g.pos = event.pos
                    self.trip.check_mouse()
                    g.redraw = True
                    if self.canvas is not None:
                        self.canvas.grab_focus()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw = True
                    if event.button == 1:
                        bu = buttons.check()
                        if bu != '':
                            self.do_button(bu)
                        else:
                            if self.trip.check_mouse():
                                self.do_click()
                        self.flush_queue()
                elif event.type == pygame.KEYDOWN:
                    # throttle keyboard repeat
                    if pygame.time.get_ticks() - key_ms > 110:
                        key_ms = pygame.time.get_ticks()
                        if ctrl:
                            if event.key == pygame.K_q:
                                if not self.journal:
                                    utils.save()
                                going = False
                                break
                            else:
                                ctrl = False
                        if event.key in (pygame.K_LCTRL, pygame.K_RCTRL):
                            ctrl = True
                            break
                        self.do_key(event.key)
                        g.redraw = True
                        self.flush_queue()
                elif event.type == pygame.KEYUP:
                    ctrl = False
            if not going:
                break
            if g.redraw:
                self.display()
                if g.version_display:
                    utils.version_display()
                g.screen.blit(g.pointer, g.pos)
                pygame.display.flip()
                g.redraw = False
                if self.trip.delay:
                    pygame.time.delay(1000)
                    self.trip.delay = False
                    self.trip.gone()
                    g.redraw = True
                    self.trip.complete()
            g.clock.tick(40)
Exemple #20
0
    def run(self):
        g.init()
        if not self.journal: utils.load()
        self.didg = didg.Didg()
        g.carry_shape = didg.shapes[0]
        self.didg.make_carry()
        load_save.retrieve()
        self.buttons_setup()
        if self.canvas <> None: self.canvas.grab_focus()
        ctrl = False
        pygame.key.set_repeat(600, 120)
        key_ms = pygame.time.get_ticks()
        need_carry = False
        going = True
        while going:
            if self.journal:
                # Pump GTK messages.
                while gtk.events_pending():
                    gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    if not self.journal: utils.save()
                    going = False
                elif event.type == pygame.MOUSEMOTION:
                    g.pos = event.pos
                    need_carry = True
                    if self.canvas <> None: self.canvas.grab_focus()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw = True
                    if event.button == 1:
                        if self.do_click(1):
                            pass
                        else:
                            bu = buttons.check()
                            if bu != '':
                                self.do_button(bu)
                                self.flush_queue()
                    if event.button == 3:
                        self.do_click(3)
                elif event.type == pygame.KEYDOWN:
                    # throttle keyboard repeat
                    if pygame.time.get_ticks() - key_ms > 110:
                        key_ms = pygame.time.get_ticks()
                        if ctrl:
                            if event.key == pygame.K_q:
                                if not self.journal: utils.save()
                                going = False
                                break
                            else:
                                ctrl = False
                        if event.key in (pygame.K_LCTRL, pygame.K_RCTRL):
                            ctrl = True
                            break
                        self.do_key(event.key)
                        g.redraw = True
                        self.flush_queue()
                elif event.type == pygame.KEYUP:
                    ctrl = False
            if not going: break
            if g.redraw:
                g.carry_save = False
                self.display()
                if g.version_display: utils.version_display()
                self.carry()
                need_carry = False
                pygame.display.flip()
                g.redraw = False
            elif need_carry:
                self.carry()
                pygame.display.flip()
                need_carry = False
            g.clock.tick(40)
Exemple #21
0
    def run(self, restore=False):
        g.init()
        if not self.journal:
            utils.load()
        self.let = let.Let()
        # setup before retrieve
        load_save.retrieve()
        self.buttons_setup()
        if self.canvas is not None:
            self.canvas.grab_focus()
        pygame.key.set_repeat(600, 120)
        going = True
        while going:
            if self.journal:
                # Pump GTK messages.
                while Gtk.events_pending():
                    Gtk.main_iteration()
                if not going:
                    break

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    if not self.journal:
                        utils.save()
                    return
                elif event.type == pygame.VIDEORESIZE:
                    pygame.display.set_mode(event.size, pygame.RESIZABLE)
                    g.redraw = True
                elif event.type == pygame.MOUSEMOTION:
                    g.pos = event.pos
                    g.redraw = True
                    if self.canvas is not None:
                        self.canvas.grab_focus()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw = True
                    if event.button == 1:
                        if not self.sugar and g.help_on:
                            g.help_on = False
                            buttons.on('help')
                        elif self.do_click():
                            pass
                        else:
                            bu = buttons.check()
                            if bu != '':
                                self.do_button(bu)
                    if not self.sugar and event.button == 3:
                        g.help_on = True
                        buttons.off('help')
                elif event.type == pygame.KEYDOWN:
                    if not self.sugar and event.key not in g.CIRCLE:
                        g.help_on = False
                        buttons.on('help')
                    self.do_key(event.key)
                    g.redraw = True
                elif event.type == pygame.KEYUP:
                    pass
            if not going:
                break

            if g.state == g.STATE_SETUP:
                self.let.choose()
            if g.redraw:
                self.display()
                if g.version_display:
                    utils.version_display()
                if g.state != g.STATE_SETUP:
                    g.screen.blit(g.pointer, g.pos)
                pygame.display.flip()
                g.redraw = False
            g.clock.tick(40)
Exemple #22
0
    def run(self, restore=False):
        self.black = False
        g.init()
        if not self.journal:
            utils.load()
        load_save.retrieve()
        x = g.sx(26)
        y = g.sy(11.2)
        if not self.sugar:
            buttons.Button("new", (x, y))
        x, y = g.cxy2
        dx = g.sy(4)
        self.back_button = buttons.Button("back", (x, y))
        x += dx
        buttons.Button("plus", (x, y))
        x += dx
        buttons.Button("times", (x, y))
        x += dx
        buttons.Button("equals", (x, y))
        self.ops = ['back', 'plus', 'times', 'equals']
        if not self.sugar:
            self.slider = slider.Slider(g.sx(22.4), g.sy(20.5), 10,
                                        utils.GREEN)
        self.mouse_auto = True
        self.anim_ms = None

        self.level1()  # initial animation
        self.scored = False
        if restore:
            g.score = self.save_score
        ctrl = False
        pygame.key.set_repeat(600, 120)
        key_ms = pygame.time.get_ticks()
        going = True
        if self.canvas is not None:
            self.canvas.grab_focus()
        while going:
            if self.journal:
                # Pump GTK messages.
                while gtk.events_pending():
                    gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    if not self.journal:
                        utils.save()
                    going = False
                elif event.type == pygame.MOUSEMOTION:
                    g.pos = event.pos
                    g.redraw = True
                    if self.canvas is not None:
                        self.canvas.grab_focus()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw = True
                    self.anim_end()
                    if event.button == 1:
                        bu = buttons.check()
                        if bu == '':
                            if not self.check_numbers():
                                if not self.sugar:
                                    if self.slider.mouse():
                                        self.level1()
                        else:
                            self.do_button(bu)  # eg do_button('plus')
                    self.flush_queue()
                elif event.type == pygame.KEYDOWN:
                    self.anim_end()
                    # throttle keyboard repeat
                    if pygame.time.get_ticks() - key_ms > 110:
                        key_ms = pygame.time.get_ticks()
                        if ctrl:
                            if event.key == pygame.K_q:
                                if not self.journal:
                                    utils.save()
                                going = False
                                break
                            else:
                                ctrl = False
                        if event.key in (pygame.K_LCTRL, pygame.K_RCTRL):
                            ctrl = True
                            break
                        self.do_key(event.key)
                        g.redraw = True
                        self.flush_queue()
                elif event.type == pygame.KEYUP:
                    ctrl = False
            if not going:
                break
            self.animation()
            if g.redraw:
                self.display()
                if g.version_display:
                    utils.version_display()
                if not self.black:
                    g.screen.blit(g.pointer, g.pos)
                pygame.display.flip()
                g.redraw = False
            g.clock.tick(40)
Exemple #23
0
    def run(self):
        g.init()
        if not self.journal: utils.load()
        self.jigsaw = jigsaw.Jigsaw()
        self.menu = menu.Menu(3, 4, g.sy(1), g.sy(1.5), g.sy(.32))
        load_save.retrieve()
        self.buttons_setup()
        self.slider = slider.Slider(g.sx(16), g.sy(20.5), len(jigsaw.rc),
                                    utils.GREEN)
        if self.canvas <> None: self.canvas.grab_focus()
        ctrl = False
        pygame.key.set_repeat(600, 120)
        key_ms = pygame.time.get_ticks()
        going = True
        while going:
            if self.journal:
                # Pump GTK messages.
                while gtk.events_pending():
                    gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:  # only in standalone version
                    if not self.journal: utils.save()
                    going = False
                elif event.type == pygame.MOUSEMOTION:
                    g.pos = event.pos
                    if g.state == 2: self.menu.check_mouse()
                    if g.state == 3: self.jigsaw.check_mouse()
                    g.redraw = True
                    if self.canvas <> None: self.canvas.grab_focus()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw = True
                    if event.button == 1:
                        bu = buttons.check()
                        if bu != '': self.do_button(bu)
                        else: self.do_click()
                    if event.button == 3:
                        self.jigsaw.moving = not self.jigsaw.moving
                    self.flush_queue()
                elif event.type == pygame.KEYDOWN:
                    # throttle keyboard repeat
                    if pygame.time.get_ticks() - key_ms > 110:
                        key_ms = pygame.time.get_ticks()
                        if ctrl:
                            if event.key == pygame.K_q:
                                if not self.journal: utils.save()
                                going = False
                                break
                            else:
                                ctrl = False
                        if event.key in (pygame.K_LCTRL, pygame.K_RCTRL):
                            ctrl = True
                            break
                        self.do_key(event.key)
                        g.redraw = True
                        self.flush_queue()
                elif event.type == pygame.KEYUP:
                    ctrl = False
            if not going: break
            if g.state == 3:
                self.jigsaw.update()
            if g.redraw:
                self.display()
                if g.version_display: utils.version_display()
                if g.state == 3:
                    g.screen.blit(g.negative, g.pos)
                else:
                    g.screen.blit(g.pointer, g.pos)
                pygame.display.flip()
                g.redraw = False
            g.clock.tick(40)
Exemple #24
0
    def run(self, restore=False):
        self.g_init()
        if not self.journal:
            utils.load()
        load_save.retrieve()
        self.aim = simon.Simon(1200)  # arg is glow time
        if self.sugar:
            self.set_delay(800)
        else:
            self.set_delay()
        self.player = simon.Simon(200)
        if restore:
            self.restore_pattern()
            self.aim.started = True
        if self.sugar:
            self.green_button.set_sensitive(True)
            self.back_button.set_sensitive(False)
        else:
            bx = g.sx(22.42)
            by = g.sy(20.8)
            buttons.Button('green', (bx, by), True)
            buttons.Button('back', (bx, by), True)
            buttons.off('back')
            self.slider = slider.Slider(g.sx(9), g.sy(20.8), 3, utils.BLUE)
        self.rc = rc_skip_last.RC(3, 5)
        if self.canvas is not None:
            self.canvas.grab_focus()
        ctrl = False
        pygame.key.set_repeat(600, 120)
        key_ms = pygame.time.get_ticks()
        going = True
        while going:
            if self.journal:
                # Pump GTK messages.
                while Gtk.events_pending():
                    Gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    if not self.journal:
                        utils.save()
                    going = False
                elif event.type == pygame.MOUSEMOTION:
                    g.pos = event.pos
                    g.redraw = True
                    if self.canvas is not None:
                        self.canvas.grab_focus()
                    self.mouse_set()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw = True
                    if event.button == 1:
                        self.do_click()
                        self.flush_queue()
                elif event.type == pygame.KEYDOWN:
                    # throttle keyboard repeat
                    if pygame.time.get_ticks() - key_ms > 110:
                        key_ms = pygame.time.get_ticks()
                        if ctrl:
                            if event.key == pygame.K_q:
                                if not self.journal:
                                    utils.save()
                                going = False
                                break
                            else:
                                ctrl = False
                        if event.key in (pygame.K_LCTRL, pygame.K_RCTRL):
                            ctrl = True
                            break
                        self.do_key(event.key)
                        g.redraw = True
                        self.flush_queue()
                elif event.type == pygame.KEYUP:
                    ctrl = False
            if not going:
                break
            if self.sugar:
                if g.player_n == 0 and not self.green_button.get_sensitive():
                    self.back_button.set_sensitive(True)
            else:
                if g.player_n == 0 and not buttons.active('green'):
                    buttons.on('back')
            self.player.do()
            self.aim.do()
            if g.redraw:
                self.display()
                if g.version_display:
                    utils.version_display()
                if self.aim.running or self.aim.glow_active:
                    pass
                else:
                    g.screen.blit(g.pointer, g.pos)
                pygame.display.flip()
                g.redraw = False
            g.clock.tick(40)
Exemple #25
0
    def run(self):
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                return
            elif event.type == pygame.VIDEORESIZE:
                pygame.display.set_mode(event.size, pygame.RESIZABLE)
                break

        g.init()
        if not self.journal:
            utils.load()
        self.pages = pages.Pages()
        self.map1 = map1.Map1()
        self.ctry = ctry.Ctry()
        load_save.retrieve()
        self.buttons_setup()
        if self.canvas is not None:
            self.canvas.grab_focus()
        ctrl = False
        going = True
        answer_input = False
        down_event = None

        while going:
            if self.journal:
                # Pump Gtk messages.
                while Gtk.events_pending():
                    Gtk.main_iteration()
            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    if not self.journal:
                        utils.save()
                    going = False
                elif event.type == pygame.MOUSEMOTION:
                    g.pos = event.pos
                    g.redraw = True
                    if self.canvas is not None:
                        self.canvas.grab_focus()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    # Store the latest MOUSEBUTTONDOWN event
                    if event.button == 1:
                        down_event = event
                elif event.type == pygame.MOUSEBUTTONUP:
                    g.redraw = True
                    self.ctry.message = None
                    g.pic = g.globe
                    if event.button == 1:
                        if self.proximity(
                                event, down_event) and answer_input is False:
                            if self.do_click():
                                pass
                            else:
                                bu = buttons.check()
                                if bu != '':
                                    value = self.do_button(bu)
                                    if value == 0:
                                        answer_input = True
                        elif self.proximity(
                                event, down_event) and answer_input is True:
                            res = self.ctry.which_oval()
                            if res == 'y':
                                self.check_response()
                            else:
                                self.ctry.message = "Sorry, " + self.ctry.answer +\
                                                " is not on my list"
                            self.ctry.answer = ''
                            answer_input = False
                        self.flush_queue()
                    if event.button == 3:
                        self.ctry.clear()
                elif event.type == pygame.KEYDOWN:
                    # throttle keyboard repeat
                    self.ctry.message = None
                    g.pic = g.globe
                    if ctrl:
                        if event.key == pygame.K_q:
                            if not self.journal:
                                utils.save()
                            going = False
                            break
                        else:
                            ctrl = False
                    if answer_input is False:
                        if event.key in (pygame.K_LCTRL, pygame.K_RCTRL):
                            ctrl = True
                            break
                        value = self.do_key(event.key)
                        if value == 0:
                            answer_input = True
                    else:
                        if event.key == g.YES:  # Value of 'y'
                            self.check_response()
                        else:
                            self.ctry.message = "Sorry, " + self.ctry.answer +\
                                                " is not on my list"
                        self.ctry.answer = ''
                        answer_input = False
                    g.redraw = True
                    self.flush_queue()
                elif event.type == pygame.KEYUP:
                    ctrl = False
            if not going:
                break
            if g.redraw:
                self.display()
                if g.version_display:
                    utils.version_display()
                g.screen.blit(g.pointer, g.pos)
                pygame.display.flip()
                g.redraw = False
            g.clock.tick(40)
Exemple #26
0
    def run(self, restore=False):
        self.g_init()
        if not self.journal:
            utils.load()
        load_save.retrieve()
        if restore:
            self.restore_pattern()
        else:
            g.delay = (3 - g.level) * 400
        self.tu = my_turtle.TurtleClass()
        self.tu.current = [1, 1, 1, 3, 2]
        self.get_goal()
        if g.pattern == 1:
            self.tu.current = utils.copy_list(g.goal)
        self.tu.setup(self.colors[0])
        g.numbers = utils.copy_list(self.tu.current)
        #buttons
        x = g.sx(7.3)
        y = g.sy(16.5)
        dx = g.sy(2.6)

        if not self.sugar:
            buttons.Button("cyan", (x, y), True)
            x += dx
            buttons.off('cyan')
            buttons.Button("green", (x, y), True)
            x += dx
            buttons.Button("red", (x, y), True)
            x += dx
            buttons.Button("black", (x, y), True)
            x += dx
            self.slider = slider.Slider(g.sx(23.5), g.sy(21), 3, utils.YELLOW)

        self.mouse_1st_no()  # to 1st number
        if self.canvas is not None:
            self.canvas.grab_focus()
        ctrl = False
        pygame.key.set_repeat(600, 120)
        key_ms = pygame.time.get_ticks()
        going = True
        while going:
            if self.journal:
                # Pump GTK messages.
                while gtk.events_pending():
                    gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    if not self.journal:
                        utils.save()
                    going = False
                elif event.type == pygame.MOUSEMOTION:
                    g.pos = event.pos
                    g.redraw = True
                    if self.canvas is not None:
                        self.canvas.grab_focus()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw = True
                    if g.big:
                        g.big = False
                    else:
                        bu = buttons.check()
                        if bu != '':
                            self.do_button(bu)
                            self.flush_queue()
                        elif not self.sugar:
                            if utils.mouse_on_img1(g.magician, g.magician_c):
                                self.help2()
                            elif utils.mouse_in(g.x1, g.y0, g.x1 + g.bw,
                                                g.y0 + g.bw):
                                self.big_pic()
                            elif self.slider.mouse():
                                g.delay = (3 - g.level) * 400
                            else:
                                g.show_help = False
                                self.check_nos(event.button)
                        else:
                            g.show_help = False
                            self.check_nos(event.button)
                elif event.type == pygame.KEYDOWN:
                    # throttle keyboard repeat
                    if pygame.time.get_ticks() - key_ms > 110:
                        key_ms = pygame.time.get_ticks()
                        if ctrl:
                            if event.key == pygame.K_q:
                                if not self.journal:
                                    utils.save()
                                going = False
                                break
                            else:
                                ctrl = False
                        if event.key in (pygame.K_LCTRL, pygame.K_RCTRL):
                            ctrl = True
                            break
                        self.do_key(event.key)
                        g.redraw = True
                        self.flush_queue()
                elif event.type == pygame.KEYUP:
                    ctrl = False
            if not going:
                break
            if self.tu.running:
                self.tu.move()
            if not g.crash_drawn:
                g.crash_drawn = True
                g.redraw = True
            if g.redraw:
                self.display()
                if g.version_display:
                    utils.version_display()
                g.screen.blit(g.pointer, g.pos)
                pygame.display.flip()
                g.redraw = False
            g.clock.tick(40)
Exemple #27
0
    def run(self):
        g.init()
        if not self.journal: utils.load()
        g.grid.setup()
        load_save.retrieve()
        bx = g.sx(3.3)
        by = g.sy(9)
        buttons.Button("cyan", (bx, by), True)
        buttons.off("cyan")
        if self.canvas <> None: self.canvas.grab_focus()
        ctrl = False
        pygame.key.set_repeat(600, 120)
        key_ms = pygame.time.get_ticks()
        going = True
        while going:
            if self.journal:
                # Pump GTK messages.
                while gtk.events_pending():
                    gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    if not self.journal: utils.save()
                    going = False
                elif event.type == pygame.MOUSEMOTION:
                    g.pos = event.pos
                    g.redraw = True
                    if self.canvas <> None: self.canvas.grab_focus()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw = True
                    if event.button == 1:
                        if self.click():
                            self.flush_queue()
                            break
                        bu = buttons.check()
                        if bu <> '':
                            g.result = None
                            g.state = 0
                            g.grid.setup()
                            buttons.off("cyan")
                            self.flush_queue()
                            break
                elif event.type == pygame.KEYDOWN:
                    # throttle keyboard repeat
                    if pygame.time.get_ticks() - key_ms > 110:
                        key_ms = pygame.time.get_ticks()
                        if ctrl:
                            if event.key == pygame.K_q:
                                if not self.journal: utils.save()
                                going = False
                                break
                            else:
                                ctrl = False
                        if event.key in (pygame.K_LCTRL, pygame.K_RCTRL):
                            ctrl = True
                            break
                        self.do_key(event.key)
                        g.redraw = True
                        self.flush_queue()
                elif event.type == pygame.KEYUP:
                    ctrl = False
            if not going: break
            self.process()
            g.grid.update()
            if g.redraw:
                self.display()
                if g.version_display: utils.version_display()
                g.screen.blit(g.pointer, g.pos)
                pygame.display.flip()
                g.redraw = False
            g.clock.tick(40)
Exemple #28
0
    def run(self):
        g.init()
        if not self.journal:
            utils.load()
        else:
            g.ok = self.ok
            g.rule = self.rule
        self.cards = cards.Cards()
        self.cards.ok = g.ok
        self.cards.rule = g.rule
        self.cards.redeal()
        bx = g.sx(17.4)
        by1 = g.sy(15.5)
        by2 = g.sy(18.5)
        self.yes_bu = []
        self.no_bu = []
        for i in range(3):
            bu = buttons.Button("yes", (bx, by1), True)
            bu.active = False
            self.yes_bu.append(bu)
            bu = buttons.Button("no", (bx, by2), True)
            bu.active = False
            self.no_bu.append(bu)
            bx += self.cards.width + g.sy(.5)
        bx = g.sx(29.9)
        by = g.sy(14.2)
        buttons.Button("redeal", (bx, by), True)
        if self.journal:  # Sugar only
            a, b, c, d = pygame.cursors.load_xbm('my_cursor.xbm',
                                                 'my_cursor_mask.xbm')
            pygame.mouse.set_cursor(a, b, c, d)
        going = True
        while going:
            # Pump GTK messages.
            while gtk.events_pending():
                gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    if not self.journal:
                        g.ok = self.cards.ok
                        g.rule = self.cards.rule
                        utils.save()
                    going = False
                elif event.type == pygame.MOUSEMOTION:
                    g.redraw = True
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw = True
                    if event.button == 2:  # centre button
                        if not self.journal:
                            g.version_display = not g.version_display
                            break
                    bu = buttons.check()
                    if bu <> '':
                        self.button(bu)
                        break
                    self.click()
            if not going: break
            self.update()
            if g.redraw:
                self.display()
                if g.version_display: utils.version_display()
                pygame.display.flip()
                g.redraw = False
            tf = False
            if pygame.mouse.get_focused(): tf = True
            pygame.mouse.set_visible(tf)
            g.clock.tick(40)
            # be ready for xo quit at any time
            self.ok = self.cards.ok
            self.rule = self.cards.rule
Exemple #29
0
    def run(self, restore=False):
        self.g_init()
        if not self.journal:
            utils.load()
        load_save.retrieve()
        self.aim = simon.Simon(1200)  # arg is glow time
        if self.sugar:
            self.set_delay(800)
        else:
            self.set_delay()
        self.player = simon.Simon(200)
        if restore:
            self.restore_pattern()
            self.aim.started = True
        if self.sugar:
            self.green_button.set_sensitive(True)
            self.back_button.set_sensitive(False)
        else:
            bx = g.sx(22.42)
            by = g.sy(20.8)
            buttons.Button('green', (bx, by), True)
            buttons.Button('back', (bx, by), True)
            buttons.off('back')
            self.slider = slider.Slider(g.sx(9), g.sy(20.8), 3, utils.BLUE)
        self.rc = rc_skip_last.RC(3, 5)
        if self.canvas is not None:
            self.canvas.grab_focus()
        ctrl = False
        pygame.key.set_repeat(600, 120)
        key_ms = pygame.time.get_ticks()
        going = True
        while going:
            if self.journal:
                # Pump GTK messages.
                while gtk.events_pending():
                    gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    if not self.journal:
                        utils.save()
                    going = False
                elif event.type == pygame.MOUSEMOTION:
                    g.pos = event.pos
                    g.redraw = True
                    if self.canvas is not None:
                        self.canvas.grab_focus()
                    self.mouse_set()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw = True
                    if event.button == 1:
                        self.do_click()
                        self.flush_queue()
                elif event.type == pygame.KEYDOWN:
                    # throttle keyboard repeat
                    if pygame.time.get_ticks() - key_ms > 110:
                        key_ms = pygame.time.get_ticks()
                        if ctrl:
                            if event.key == pygame.K_q:
                                if not self.journal:
                                    utils.save()
                                going = False
                                break
                            else:
                                ctrl = False
                        if event.key in (pygame.K_LCTRL, pygame.K_RCTRL):
                            ctrl = True
                            break
                        self.do_key(event.key)
                        g.redraw = True
                        self.flush_queue()
                elif event.type == pygame.KEYUP:
                    ctrl = False
            if not going:
                break
            if self.sugar:
                if g.player_n == 0 and not self.green_button.get_sensitive():
                    self.back_button.set_sensitive(True)
            else:
                if g.player_n == 0 and not buttons.active('green'):
                    buttons.on('back')
            self.player.do()
            self.aim.do()
            if g.redraw:
                self.display()
                if g.version_display:
                    utils.version_display()
                if self.aim.running or self.aim.glow_active:
                    pass
                else:
                    g.screen.blit(g.pointer, g.pos)
                pygame.display.flip()
                g.redraw = False
            g.clock.tick(40)
Exemple #30
0
    def run(self):
        g.init()
        g.journal = self.journal
        if not self.journal:
            utils.load()
            self.success = g.success
        else:
            g.success = self.success
        x = g.sx(3)
        y = g.sy(1.8)
        self.menu_bu = buttons.Button("menu", (x, y))
        self.menu_bu.off()
        self.pj = jigsaw.Jigsaw()
        going = True
        while going:
            ms = pygame.time.get_ticks()
            g.mx, g.my = pygame.mouse.get_pos()
            # Pump GTK messages.
            while gtk.events_pending():
                gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    if not self.journal: utils.save()
                    going = False
                elif event.type == pygame.MOUSEMOTION:
                    g.redraw = True
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw = True
                    if event.button == 2:  # centre button
                        g.version_display = not g.version_display
                        break
                    elif event.button == 1:  # left button
                        if g.state == 3:
                            bu = buttons.check()
                            if bu != '':
                                g.state = 1
                                break
                    if g.state == 1:
                        self.menu_click()
                        if g.state == 2:
                            if not self.setup():
                                going = False
                                break
                            g.state = 3
                    elif g.state == 3:
                        self.pj.click()
            if not going: break
            if g.redraw:
                self.display()
                if g.version_display: utils.version_display()
                if self.pj.carry:
                    g.screen.blit(g.negative, (g.mx, g.my))
                else:
                    g.screen.blit(g.pointer, (g.mx, g.my))
                pygame.display.flip()
                g.redraw = False
            self.success = g.success
            g.clock.tick(40)
            d = pygame.time.get_ticks() - ms
            g.frame_rate = int(1000 / d)
Exemple #31
0
    def run(self, restore=False):
        g.init()
        pygame.init()
        pygame.display.init()
        if not self.journal:
            utils.load()
        self.trip = trip.Trip(self.sugar, self.label, self.colors[0])
        self.trip.setup()
        load_save.retrieve()
        self.buttons_setup()
        if self.canvas is not None:
            self.canvas.grab_focus()
        ctrl = False
        pygame.key.set_repeat(600, 120)
        key_ms = pygame.time.get_ticks()
        going = True
        while going:
            if self.journal:
                # Pump GTK messages.
                while Gtk.events_pending():
                    Gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    # only in standalone version
                    if not self.journal:
                        utils.save()
                    going = False
                elif event.type == pygame.MOUSEMOTION:
                    g.pos = event.pos
                    self.trip.check_mouse()
                    g.redraw = True
                    if self.canvas is not None:
                        self.canvas.grab_focus()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw = True
                    if event.button == 1:
                        bu = buttons.check()
                        if bu != '':
                            self.do_button(bu)
                        else:
                            if self.trip.check_mouse():
                                self.do_click()
                        self.flush_queue()
                elif event.type == pygame.KEYDOWN:
                    # throttle keyboard repeat
                    if pygame.time.get_ticks() - key_ms > 110:
                        key_ms = pygame.time.get_ticks()
                        if ctrl:
                            if event.key == pygame.K_q:
                                if not self.journal:
                                    utils.save()
                                going = False
                                break
                            else:
                                ctrl = False
                        if event.key in (pygame.K_LCTRL, pygame.K_RCTRL):
                            ctrl = True
                            break
                        self.do_key(event.key)
                        g.redraw = True
                        self.flush_queue()
                elif event.type == pygame.KEYUP:
                    ctrl = False
            if not going:
                break
            if g.redraw:
                self.display()
                if g.version_display:
                    utils.version_display()
                g.screen.blit(g.pointer, g.pos)
                pygame.display.flip()
                g.redraw = False
                if self.trip.delay:
                    pygame.time.delay(1000)
                    self.trip.delay = False
                    self.trip.gone()
                    g.redraw = True
                    self.trip.complete()
            g.clock.tick(40)
Exemple #32
0
    def run(self, restore=False):
        g.init()
        if not self.journal:
            utils.load()
        self.let = let.Let()
        # setup before retrieve
        load_save.retrieve()
        self.buttons_setup()
        if self.canvas is not None:
            self.canvas.grab_focus()
        pygame.key.set_repeat(600, 120)
        going = True
        while going:
            if self.journal:
                # Pump GTK messages.
                while Gtk.events_pending():
                    Gtk.main_iteration()
                if not going:
                    break

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    if not self.journal:
                        utils.save()
                    return
                elif event.type == pygame.VIDEORESIZE:
                    pygame.display.set_mode(event.size, pygame.RESIZABLE)
                    g.redraw = True
                elif event.type == pygame.MOUSEMOTION:
                    g.pos = event.pos
                    g.redraw = True
                    if self.canvas is not None:
                        self.canvas.grab_focus()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw = True
                    if event.button == 1:
                        if not self.sugar and g.help_on:
                            g.help_on = False
                            buttons.on('help')
                        elif self.do_click():
                            pass
                        else:
                            bu = buttons.check()
                            if bu != '':
                                self.do_button(bu)
                    if not self.sugar and event.button == 3:
                        g.help_on = True
                        buttons.off('help')
                elif event.type == pygame.KEYDOWN:
                    if not self.sugar and event.key not in g.CIRCLE:
                        g.help_on = False
                        buttons.on('help')
                    self.do_key(event.key)
                    g.redraw = True
                elif event.type == pygame.KEYUP:
                    pass
            if not going:
                break

            if g.state == g.STATE_SETUP:
                self.let.choose()
            if g.redraw:
                self.display()
                if g.version_display:
                    utils.version_display()
                if g.state != g.STATE_SETUP:
                    g.screen.blit(g.pointer, g.pos)
                pygame.display.flip()
                g.redraw = False
            g.clock.tick(40)
    def run(self):
        for event in pygame.event.get():
            if event.type==pygame.QUIT:
                return
            elif event.type == pygame.VIDEORESIZE:
                pygame.display.set_mode(event.size, pygame.RESIZABLE)
                break
        g.init()
        if not self.journal: utils.load()
        self.acr=acr.Acr()
        load_save.retrieve()
        self.buttons_setup()
        if self.canvas<>None: self.canvas.grab_focus()
        ctrl=False
        pygame.key.set_repeat(600,120); key_ms=pygame.time.get_ticks()
        going=True
        while going:
            if self.journal:
                # Pump Gtk messages.
                while Gtk.events_pending(): Gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type==pygame.QUIT:
                    if not self.journal: utils.save()
                    going=False
                elif event.type == pygame.MOUSEMOTION:
                    g.pos=event.pos
                    g.redraw=True
                    if self.canvas<>None: self.canvas.grab_focus()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    self.acr.message=None
                    g.redraw=True
                    if event.button==1:
                        if g.help_on:
                            g.help_on=False
                        elif self.do_click():
                            pass
                        else:
                            bu=buttons.check()
                            if bu!='': self.do_button(bu); self.flush_queue()
                    if event.button==3: g.help_on=not g.help_on
                elif event.type == pygame.KEYDOWN:
                    if event.key not in g.CIRCLE: g.help_on=False
                    self.acr.message=None
                    # throttle keyboard repeat
                    if pygame.time.get_ticks()-key_ms>110:
                        key_ms=pygame.time.get_ticks()
                        if ctrl:
                            if event.key==pygame.K_q:
                                if not self.journal: utils.save()
                                going=False; break
                            else:
                                ctrl=False
                        if event.key in (pygame.K_LCTRL,pygame.K_RCTRL):
                            ctrl=True; break
                        self.do_key(event.key); g.redraw=True
                        self.flush_queue()
                elif event.type == pygame.KEYUP:
                    ctrl=False
            if not going: break
            self.acr.update()
            if g.redraw:
                self.display()
                if g.version_display: utils.version_display()
                g.screen.blit(g.pointer,g.pos)
                pygame.display.flip()
                g.redraw=False
            g.clock.tick(40)
Exemple #34
0
    def run(self, restore=False):
        g.init()
        if not self.journal:
            utils.load()
        self.let = let.Let()
        # setup before retrieve
        load_save.retrieve()
        self.buttons_setup()
        if self.canvas is not None:
            self.canvas.grab_focus()
        ctrl = False
        pygame.key.set_repeat(600, 120)
        key_ms = pygame.time.get_ticks()
        going = True
        while going:
            if self.journal:
                # Pump GTK messages.
                while Gtk.events_pending():
                    Gtk.main_iteration()
            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    if not self.journal:
                        utils.save()
                    going = False
                elif event.type == pygame.MOUSEMOTION:
                    g.pos = event.pos
                    g.redraw = True
                    if self.canvas is not None:
                        self.canvas.grab_focus()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw = True
                    if event.button == 1:
                        if not self.sugar and g.help_on:
                            g.help_on = False
                            buttons.on('help')
                        elif self.do_click():
                            pass
                        else:
                            bu = buttons.check()
                            if bu != '':
                                self.do_button(bu)
                                self.flush_queue()
                    if not self.sugar and event.button == 3:
                        g.help_on = True
                        buttons.off('help')
                elif event.type == pygame.KEYDOWN:
                    if not self.sugar and event.key not in g.CIRCLE:
                        g.help_on = False
                        buttons.on('help')
                    # throttle keyboard repeat
                    if pygame.time.get_ticks() - key_ms > 110:
                        key_ms = pygame.time.get_ticks()
                        if ctrl:
                            if event.key == pygame.K_q:
                                if not self.journal:
                                    utils.save()
                                going = False
                                break
                            else:
                                ctrl = False
                        if event.key in (pygame.K_LCTRL, pygame.K_RCTRL):
                            ctrl = True
                            break
                        self.do_key(event.key)
                        g.redraw = True
                        self.flush_queue()
                elif event.type == pygame.KEYUP:
                    ctrl = False
            if not going:
                break

            if g.state == 1:
                self.let.choose()
            if g.redraw:
                self.display()
                if g.version_display:
                    utils.version_display()
                if g.state != 1:
                    g.screen.blit(g.pointer, g.pos)
                pygame.display.flip()
                g.redraw = False
            g.clock.tick(40)
    def run(self):
        g.init()
        if not self.journal: utils.load()
        load_save.retrieve()
        self.buttons_setup()
        self.objects = jum.Objects()
        self.objects.setup()
        self.setup()
        if self.canvas <> None: self.canvas.grab_focus()
        ctrl = False
        pygame.key.set_repeat(600, 120)
        key_ms = pygame.time.get_ticks()
        going = True
        while going:
            if self.journal:
                # Pump GTK messages.
                while gtk.events_pending():
                    gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    if not self.journal: utils.save()
                    going = False
                elif event.type == pygame.MOUSEMOTION:
                    g.pos = event.pos
                    g.redraw = True
                    self.objects.update()
                    if self.canvas <> None: self.canvas.grab_focus()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw = True
                    if event.button == 1:
                        if self.objects.click():
                            if self.objects.complete:
                                buttons.off('next')
                        else:
                            self.display()
                            bu = buttons.check()
                            if bu != '': self.do_button(bu)
                    if event.button == 3:
                        if buttons.active('next'): self.do_button('next')
                    self.flush_queue()
                elif event.type == pygame.KEYDOWN:
                    # throttle keyboard repeat
                    if pygame.time.get_ticks() - key_ms > 110:
                        key_ms = pygame.time.get_ticks()
                        if ctrl:
                            if event.key == pygame.K_q:
                                if not self.journal: utils.save()
                                going = False
                                break
                            else:
                                ctrl = False
                        if event.key in (pygame.K_LCTRL, pygame.K_RCTRL):
                            ctrl = True
                            break
                        self.do_key(event.key)
                        g.redraw = True
                        self.flush_queue()
                elif event.type == pygame.KEYUP:
                    ctrl = False
            if not going: break
            if g.setup_on:
                self.objects.setup()
                g.redraw = True
                if (pygame.time.get_ticks() - self.setup_ms) > 2000:
                    g.setup_on = False
                    buttons.on('next')
            if g.redraw:
                self.display()
                if g.version_display: utils.version_display()
                g.screen.blit(g.pointer, g.pos)
                pygame.display.flip()
                g.redraw = False
            g.clock.tick(40)
Exemple #36
0
    def run(self):
        g.init()
        g.journal = self.journal
        if not self.journal:
            utils.load()
            self.count = g.count
        else:
            g.count = self.count
        self.buttons_setup()
        self.objects = jum.Objects()
        self.objects.setup()
        if self.journal:  # Sugar only
            a, b, c, d = pygame.cursors.load_xbm('my_cursor.xbm',
                                                 'my_cursor_mask.xbm')
            pygame.mouse.set_cursor(a, b, c, d)
        going = True
        self.setup()
        while going:
            g.mx, g.my = pygame.mouse.get_pos()
            # Pump GTK messages.
            while gtk.events_pending():
                gtk.main_iteration()

            # Pump PyGame messages.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    if not self.journal: utils.save()
                    going = False
                elif event.type == pygame.MOUSEMOTION:
                    g.redraw = True
                    self.objects.update()
                    if self.canvas <> None: self.canvas.grab_focus()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    g.redraw = True
                    if event.button == 2:  # centre button
                        if not self.journal:
                            g.version_display = not g.version_display
                    if event.button == 1:
                        if self.objects.click():
                            if self.objects.complete:
                                buttons.off('next')
                        else:
                            self.display()
                            bu = buttons.check()
                            if bu != '': self.do_button(bu)
                elif event.type == pygame.KEYDOWN:
                    self.do_key(event.key)
                    g.redraw = True
            if g.setup_on:
                self.objects.setup()
                g.redraw = True
                if (pygame.time.get_ticks() - self.setup_ms) > 2000:
                    g.setup_on = False
                    buttons.on('next')
            if not going: break
            if g.redraw:
                self.display()
                if g.version_display: utils.version_display()
                pygame.display.flip()
                g.redraw = False
            self.count = g.count
            tf = False
            if pygame.mouse.get_focused(): tf = True
            pygame.mouse.set_visible(tf)
            g.clock.tick(40)