Пример #1
0
    def draw(self, surf, gameStateObj):
        self.write_index = 6
        if not self.surf:
            bg_surf = MenuFunctions.CreateBaseMenuSurf(
                self.size, 'BaseMenuBackgroundOpaque')
            self.surf = Engine.create_surface(
                (self.size[0] + 2, self.size[1] + 4),
                convert=True,
                transparent=True)
            self.surf.blit(bg_surf, (2, 4))
            self.surf.blit(GC.IMAGESDICT['SmallGem'], (0, 0))
            Image_Modification.flickerImageTranslucent(self.surf, 10)
        BGSurf = self.surf.copy()

        # Center it
        pos = surf.get_width() // 2 - self.size[0] // 2 - 2, surf.get_height(
        ) // 2 - self.size[1] // 2 - 4
        # Blit words
        for index, word in enumerate(self.banner):
            word_width = GC.FONT[self.banner_font[index]].size(word)[0]
            GC.FONT[self.banner_font[index]].blit(
                word, BGSurf, (self.write_index,
                               self.size[1] // 2 - self.font_height // 2 + 4))
            self.write_index += word_width
        # Blit item icon
        if self.item:
            self.item.draw(BGSurf, (self.size[0] - 6 - 16 - 2, 4 + 4),
                           cooldown=False)
        surf.blit(BGSurf, pos)
Пример #2
0
 def update(self):
     new_time = float(Engine.get_time() - self.start_time)
     # Totally transparent start_up
     if self.state == -1:
         if new_time > self.init_time:
             self.state = 0
     # Initial bouncing and fading in
     if self.state == 0:
         state_time = new_time - self.init_time
         # Position
         self.top_pos = 10 * math.exp(-state_time/250) * math.sin(state_time/25)
         # Transparency
         new_transparency = max(0, (200 - state_time)/2)
         if new_transparency > 0:
             self.image = Image_Modification.flickerImageTranslucent(self.true_image, new_transparency)
         else:
             self.image = self.true_image
         if state_time > 400:
             self.state = 1
             self.top_pos = 0
     # Pause
     if self.state == 1:
         if new_time - self.init_time > 1000:
             self.state = 2
     # Fade out and up
     if self.state == 2:
         state_time = new_time - self.init_time - 1000
         # Position
         self.top_pos = state_time/10
         # Transparency
         new_transparency = state_time/2
         self.image = Image_Modification.flickerImageTranslucent(self.true_image, new_transparency)
         if new_time > 1200:
             self.done = True
Пример #3
0
    def begin(self, gameStateObj, metaDataObj):
        if not self.started:
            # Get units to display
            self.units = [unit for unit in gameStateObj.allunits if unit.position and unit.team == 'player']

            self.bg_surf = Image_Modification.flickerImageTranslucent(GC.IMAGESDICT['UnitMenuBackground'], 10)
            self.title_bg = Image_Modification.flickerImageTranslucent(GC.IMAGESDICT['TitleBar'], 10)
            self.background = MenuFunctions.MovingBackground(GC.IMAGESDICT['RuneBackground'])
            self.states = [('Character', ['Class', 'Lv', 'Exp', 'HP', 'Max'], [4, 66, 89, 113, 133]),
                           ('Fighting Skill', ['STR', 'MAG', 'SKL', 'SPD', 'LCK', 'DEF', 'RES'], [4, 26, 48, 71, 94, 119, 142]),
                           ('Equipment', ['Equip', 'Atk', 'Hit', 'Avoid'], [16, 72, 103, 136]),
                           ('Personal Data', ['MOV', 'CON', 'Aid', 'Rat', 'Trv'], [4, 33, 60, 82, 106]),
                           ('Weapon Level', Weapons.TRIANGLE.types, [9 + idx*16 for idx in range(len(Weapons.TRIANGLE.types))])]
            if cf.CONSTANTS['support']:
                self.states.append(('Support Chance', ['Ally'], [0]))
            self.state_index = 0
            self.prev_state_index = 0
            self.unit_index = 1 # 0 means on banner
            self.scroll_index = 1
            self.banner_index = 0
            self.num_per_page = 6

            self.state_scroll = 0
            self.scroll_direction = 0

            self.weapon_icons = [Weapons.Icon(weapon) for weapon in Weapons.TRIANGLE.types]
            self.help_boxes = []
            self.info = False

            self.scroll_bar = GUIObjects.ScrollBar((233, 59))
            self.left_arrow = GUIObjects.ScrollArrow('left', (7, 41))
            self.right_arrow = GUIObjects.ScrollArrow('right', (GC.WINWIDTH - 7 - 8, 41), 0.5)

            # For sort
            self.current_sort = 'Name'
            self.descending = False
            self.sort_surf = MenuFunctions.CreateBaseMenuSurf((64, 24))
            self.sort_surf = Image_Modification.flickerImageTranslucent(self.sort_surf, 10)
            self.sort_arrow_counter = Counters.ArrowCounter()
            self.sort_arrow_counter.arrow_anim = [0, 1, 2]
            self.sort()

            # Transition in:
            gameStateObj.stateMachine.changeState("transition_in")
            return 'repeat'
        else:
            chosen_unit = gameStateObj.info_menu_struct['chosen_unit']
            if chosen_unit and chosen_unit in self.units:
                self.move_to_unit(chosen_unit)
            gameStateObj.info_menu_struct['chosen_unit'] = None
Пример #4
0
    def draw(self, gameStateObj):
        text_lines = self.split_string(self.eval_string(self.display_name_string, gameStateObj))

        longest_surf_width = self.get_size(text_lines)

        if longest_surf_width != self.surf_width or len(text_lines) != self.num_lines:
            self.num_lines = len(text_lines)
            self.surf_width = longest_surf_width
            surf_height = 16 * self.num_lines + 8

            # Blit background
            BGSurf = MenuFunctions.CreateBaseMenuSurf((self.surf_width + 16, surf_height), 'BaseMenuBackgroundOpaque')
            if self.num_lines == 1:
                BGSurf.blit(GC.IMAGESDICT['Shimmer1'], (BGSurf.get_width() - 1 - GC.IMAGESDICT['Shimmer1'].get_width(), 4))
            elif self.num_lines == 2:
                BGSurf.blit(GC.IMAGESDICT['Shimmer2'], (BGSurf.get_width() - 1 - GC.IMAGESDICT['Shimmer2'].get_width(), 4))
            self.BGSurf = Engine.create_surface((BGSurf.get_width(), BGSurf.get_height() + 3), transparent=True, convert=True)
            self.BGSurf.blit(BGSurf, (0, 3))
            gem = GC.IMAGESDICT['BlueCombatGem']
            self.BGSurf.blit(gem, (BGSurf.get_width()//2 - gem.get_width()//2, 0))
            # Now make translucent
            self.BGSurf = Image_Modification.flickerImageTranslucent(self.BGSurf, 20)

        temp_surf = self.BGSurf.copy()
        for index, line in enumerate(text_lines):
            position = temp_surf.get_width()//2 - GC.FONT['text_white'].size(line)[0]//2, 16 * index + 6
            GC.FONT['text_white'].blit(line, temp_surf, position)

        return temp_surf
Пример #5
0
 def drawInvalid(self, surf):
     size_of_text = GC.FONT['text_white'].size("Invalid Choice!")
     width = size_of_text[0]
     height = size_of_text[1]
     pop_up_surf = MenuFunctions.CreateBaseMenuSurf((width + 16 - width%8, height + 16 - height%8))
     surf.blit(Image_Modification.flickerImageTranslucent(GC.IMAGESDICT['BlackBackground'].copy(), 60), (0, 0))
     topleft = (GC.WINWIDTH//2 - pop_up_surf.get_width()//2, GC.WINHEIGHT//2 - pop_up_surf.get_height()//2)
     surf.blit(pop_up_surf, topleft)
     position = (GC.WINWIDTH//2 - width//2, GC.WINHEIGHT//2 - height//2)
     GC.FONT['text_white'].blit(cf.WORDS["Invalid Choice"], surf, position)
Пример #6
0
 def drawInvalid(self, surf):
     size_of_text = FONT['text_white'].size("Invalid Choice!")
     width = size_of_text[0]
     height = size_of_text[1]
     pop_up_surf = MenuFunctions.CreateBaseMenuSurf((width + 16 - width%8, height + 16 - height%8))
     surf.blit(Image_Modification.flickerImageTranslucent(IMAGESDICT['BlackBackground'].copy(), 60), (0, 0))
     pop_up_rect = pop_up_surf.get_rect()
     pop_up_rect.center = (WINWIDTH/2, WINHEIGHT/2)
     surf.blit(pop_up_surf, pop_up_rect)
     position = (WINWIDTH/2 - width/2, WINHEIGHT/2 - height/2)
     FONT['text_white'].blit("Invalid Choice!", surf, position)
Пример #7
0
    def draw(self, surf):
        currentTime = Engine.get_time()
        time_passed = currentTime - self.start_time
        if cf.OPTIONS['debug'] and time_passed < 0:
            logger.error('This phase has a negative time_passed! %s %s %s', time_passed, currentTime, self.start_time)
        max_opaque = 160

        # Blit the banner
        # position
        if time_passed < 100:
            offset = self.topleft[0] + 100 - time_passed
            trans = 100 - time_passed
        elif time_passed > self.display_time - 100:
            offset = self.topleft[0] + self.display_time - 100 - time_passed 
            trans = -(self.display_time - 100 - time_passed)
        else:
            offset = self.topleft[0]
            trans = 0
        # transparency
        image = Image_Modification.flickerImageTranslucent(self.image.copy(), trans)
        surf.blit(image, (offset, self.topleft[1]))
        
        # === Handle the transition
        most_dark_surf = Engine.subsurface(self.transition, (8*self.transition_size[0], 0, self.transition_size[0], self.transition_size[1])).copy()
        half_display_time = self.display_time//2
        # If we're in the first half
        if time_passed < half_display_time:
            transition_space = Engine.create_surface((GC.WINWIDTH, GC.WINHEIGHT//2 - 75//2 + time_passed//(half_display_time//20)), transparent=True)
            # Make more transparent based on time.
            alpha = int(max_opaque * time_passed/float(half_display_time))
            Engine.fill(most_dark_surf, (255, 255, 255, alpha), None, Engine.BLEND_RGBA_MULT)
        # If we're in the second half
        else:
            # Clamp time_passed at display time
            time_passed = min(self.display_time, time_passed)
            pos = (GC.WINWIDTH, GC.WINHEIGHT//2 - 75//2 + 40//2 - (time_passed - half_display_time)//(half_display_time//20))
            transition_space = Engine.create_surface(pos, transparent=True)
            # Make less transparent based on time.
            alpha = int(max_opaque - max_opaque*(time_passed - half_display_time)/float(half_display_time))
            alpha = min(255, max(0, alpha))
            Engine.fill(most_dark_surf, (255, 255, 255, alpha), None, Engine.BLEND_RGBA_MULT)
        # transition_space.convert_alpha()
        # Tile
        for x in range(0, transition_space.get_width(), 16):
            for y in range(0, transition_space.get_height(), 16):
                transition_space.blit(most_dark_surf, (x, y))

        # Now blit transition space
        surf.blit(transition_space, (0, 0))
        # Other transition_space
        surf.blit(transition_space, (0, GC.WINHEIGHT - transition_space.get_height()))
    def draw(self, surf):
        currentTime = Engine.get_time()
        time_passed = min(currentTime - self.start_time, self.display_time)
        if cf.OPTIONS['debug'] and time_passed < 0:
            logger.error('This phase has a negative time_passed! %s %s %s',
                         time_passed, currentTime, self.start_time)
        max_opaque = 118

        # Blit the banner
        # position
        if time_passed < self.begin_time:
            diff = time_passed / float(self.begin_time)
            offset = self.topleft[0] + self.begin_time * (1 - diff)
            trans = 100. * (1 - diff)**2
        elif time_passed < self.begin_time + self.main_time:
            offset = self.topleft[0]
            trans = 0
        else:  # 367 milliseconds
            diff = (time_passed -
                    (self.begin_time + self.main_time)) / float(self.end_time)
            offset = self.topleft[0] - self.end_time * diff
            trans = 100. * diff**2

        # transparency
        image = Image_Modification.flickerImageTranslucent(
            self.image.copy(), trans)
        surf.blit(image, (offset, self.topleft[1]))

        transition_space1 = self.transition_space.copy()
        transition_space2 = self.transition_space.copy()

        # === Handle the transition
        half_display_time = self.display_time // 2
        if time_passed < half_display_time:
            diff = time_passed / float(half_display_time)
            height = (GC.WINHEIGHT // 2 - 16) * diff
            alpha = int(max_opaque *
                        math.sqrt(time_passed / float(half_display_time)))
        else:
            diff = -(half_display_time -
                     time_passed) / float(half_display_time)
            height = (GC.WINHEIGHT // 2 - 16) * (1 - diff)
            alpha = int(max_opaque - max_opaque *
                        ((time_passed - half_display_time) /
                         float(half_display_time))**2)
            alpha = Utility.clamp(alpha, 0, 255)

        if time_passed < half_display_time:
            t = int(2 +
                    diff * 16)  # Starts a little ways along at the beginning
        else:
            t = int(diff * 16)

        for x in range(0, GC.WINWIDTH, 16):
            for y in range(0, 64, 16):
                i, j = x / 16, y / 16
                k = int(t * 1.5 - (i - j % 2) / 2 + j / 2 - 4)
                if time_passed < half_display_time:
                    frame = Utility.clamp(8 - abs(max(k, 8) - 8), 0, 8)
                else:
                    frame = Utility.clamp(k, 0, 8)
                # frame = Utility.clamp(min(k, 8) + min(8 - k, 0), 0, 8)
                square_surf = Engine.subsurface(
                    self.transition, (frame * 16, 0, 16, 16)).copy()
                transition_space1.blit(square_surf, (x, y))

        for x in range(0, GC.WINWIDTH, 16):
            for y in range(0, 64, 16):
                i, j = x / 16, y / 16
                k = int(t * 1.5 - (i - j % 2) / 2 + j / 2 - 1)
                if time_passed < half_display_time:
                    frame = Utility.clamp(8 - abs(max(k, 8) - 8), 0, 8)
                else:
                    frame = Utility.clamp(k, 0, 8)
                # frame = Utility.clamp(min(k, 8) + min(8 - k, 0), 0, 8)
                square_surf = Engine.subsurface(
                    self.transition, (frame * 16, 0, 16, 16)).copy()
                transition_space2.blit(square_surf, (x, y))

        # height = 64  # remove later
        transition_space1 = Engine.subsurface(transition_space1,
                                              (0, 0, GC.WINWIDTH, height))
        transition_space2 = Engine.subsurface(
            transition_space2, (0, self.transition_space.get_height() - height,
                                GC.WINWIDTH, height))

        # Fill with correct alpha
        # alpha = 255  # Remove later
        Engine.fill(transition_space1, (255, 255, 255, alpha), None,
                    Engine.BLEND_RGBA_MULT)
        Engine.fill(transition_space2, (255, 255, 255, alpha), None,
                    Engine.BLEND_RGBA_MULT)
        # Now blit transition space
        surf.blit(transition_space1, (0, 0))
        # Other transition_space
        surf.blit(transition_space2,
                  (0, GC.WINHEIGHT - transition_space2.get_height()))
Пример #9
0
 def draw(self, surf):
     surf.blit(Image_Modification.flickerImageTranslucent(self.sprite, self.transparency), (self.x, self.y))
Пример #10
0
 def draw(self, surf):
     self.update()
     image = Image_Modification.flickerImageTranslucent(self.sprite.copy(), self.trans_value)
     surf.blit(image, (0, 0))
Пример #11
0
 def draw(self, surf):
     surf.blit(
         Image_Modification.flickerImageTranslucent(self.sprite,
                                                    self.transparency),
         (self.x, self.y))
Пример #12
0
 def draw(self, surf):
     self.update()
     image = Image_Modification.flickerImageTranslucent(Engine.copy_surface(self.sprite), self.trans_value)
     surf.blit(image, (0, 0))