Esempio n. 1
0
 def drawSelectionScreen(self, section):
     hover = False
     self.screen.blit(self.background,(0, 0))
     pos = [vinfo.space, vinfo.space]
     if self.character_image:
         scaled_image = positionhelper.scalePropotional(self.character_image, 
                                                        (self.screen.get_width(),
                                                    self.screen.get_height() / 3))
         self.screen.blit(scaled_image, pos)
         pos[1] = pos[1] + scaled_image.get_height() + vinfo.space
     for question in self.dialog[section]:
         show = True
         text = vinfo.default_font.render(question, True, 
                                          vinfo.verb_question_color)
         text_hover = vinfo.default_font.render(question, True, 
                                          vinfo.verb_question_color_hover)
         if "once" in self.dialog[section][question]:
             if self.dialog[section][question]["once"]:
                 h = question
                 if "video" in self.dialog[section][question]:
                     h = h + self.dialog[section][question]["video"]
                 elif "audio" in  self.dialog[section][question]:
                     h = h + self.dialog[section][question]["audio"]
                 h = hashlib.md5(h.encode("utf-8")).hexdigest()
                 if h in self.parent.previous_dialogs[self.character]["answers"]:
                     show = False
         if show:
             self.dialog[section][question]["ui_element"] = self.screen.blit(text, pos)
             x,y = pygame.mouse.get_pos()
             if self.dialog[section][question]["ui_element"].collidepoint(x,y) and not android:
                 self.dialog[section][question]["ui_element"] = self.screen.blit(text_hover, pos)
                 hover = True
             pos[1] = pos[1] + text.get_height() + vinfo.space
     self.section = section
     if hover:
         pygame.mouse.set_cursor(*self.parent.action_mouse_cursor)
     else:
         pygame.mouse.set_cursor(*self.parent.default_mouse_cursor)
     pygame.display.flip()
def showInventar(parent):
    if len(parent.inventory) == 0:
        return
    inventar_offen = True
    images = []
    fadein = 0
    for item in parent.inventory:
        image = os.path.join(parent.image_dir, item["image"])
        image = parent.cache.preloadImage(image)
            
        image = positionhelper.scalePropotional(image, (100, 100))
        images.append(image)
    while inventar_offen:
        pos = [30, 30]
        if android:
            if android.check_pause():
                android.wait_for_resume()
        click_items = []
        container = pygame.surface.Surface(vinfo.screen_size)
        parent.screen.fill(vinfo.black)
        i = 0
        if fadein < 255:
            fadein += 25
        else:
            fadein = 255
        for item in parent.inventory:
            image = images[i]
            image.set_alpha(fadein)
            blitted_item = container.blit(image, pos)
            click_items.append(blitted_item)
            if pos[0] + blitted_item.width >= vinfo.screen_size[0] - 120:
                pos[0] = 30
                pos[1] += blitted_item.height + 10
            else:
                pos[0] += 30 + blitted_item.width
            i += 1
        container.set_alpha(fadein)
        parent.screen.blit(container, (0,0))
        hover = False
        mouse_pos = pygame.mouse.get_pos()
        for item in click_items:
            if item.collidepoint(mouse_pos):
                hover = True

        if hover:
            pygame.mouse.set_cursor(*vinfo.drag_cursor)
        else:
            pygame.mouse.set_cursor(*vinfo.default_cursor)

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                sys.exit()
            elif event.type == pygame.MOUSEBUTTONDOWN:
                x,y = event.pos[0], event.pos[1]
                if event.button == 1:
                    i = 0
                    for item in click_items:
                        if item.collidepoint((x,y)):
                            parent.mouse_inventar_object = {"name": None,
                                "index": i,
                                "image" : images[i]
                                }
                                
                        i += 1
                            
                    inventar_offen = False
            elif event.type == pygame.KEYDOWN:
                if event.key == pygame.K_F11 and not vinfo.kiosk_mode:
                    parent.toggleFullscreen()
                elif event.key == pygame.K_F2:
                    parent.keydown = "musiclower"
                elif event.key == pygame.K_F3:
                    parent.keydown = "musiclouder"
                elif event.key == pygame.K_LCTRL or event.key == pygame.K_RCTRL:
                    parent.ctrldown = True
                elif event.key == pygame.K_q and parent.ctrldown and not vinfo.kiosk_mode and not vinfo.kiosk_mode:
                    parent.executeScriptlines(["quitnow"])
                else:
                    inventar_offen = False
    
        parent.update()