Example #1
0
File: gui.py Project: CryoSky/pySLG
    def switch_turn(self, turn_team):
        rect = pygame.Surface(
            (self.current_map.map_width, self.current_map.map_height))
        rect.set_alpha(150)
        if turn_team == 2:
            rect.fill((255, 0, 0))
        elif turn_team == 0:
            rect.fill((255, 100, 0))
        elif turn_team == 1:
            rect.fill((0, 0, 255))
        self.turn_switch_wait += config.clock
        if self.turn_switch_wait > 1000:
            self.turn_switch_wait = 0
            return True
        render_queue.append((-2, rect, (0, 0)))

        if turn_team == 2:
            text = self.switch_turn_font.render(u'我军回合', 1, (250, 250, 250))
        elif turn_team == 0:
            text = self.switch_turn_font.render(u'友军回合', 1, (250, 250, 250))
        elif turn_team == 1:
            text = self.switch_turn_font.render(u'敌军回合', 1, (250, 250, 250))
        render_queue.append(
            (-3, text, (self.current_map.map_width / 2 - text.get_width() / 2,
                        self.current_map.map_height / 2 - text.get_height())))
        return False
Example #2
0
 def display(self):
     rect = pygame.Surface(self.size)
     rect.set_alpha(255)
     rect.fill(Menu.MENU_BACKGROUND_COLOC)
     render_queue.append( (-11 , rect , self.position) )
     text = self.gui.in_game_menu_font.render(self.text , 1 , (240,240,240))
     render_queue.append((-13,text , (self.position[0] + self.size[0]/2 - text.get_width()/2 , self.position[1] +10) ))
Example #3
0
File: gui.py Project: CryoSky/pySLG
    def draw_health_bar(self, current_health, max_health):
        if current_health * 2 >= max_health:
            G = 255
            R = (255 * (max_health - current_health) * 2) / max_health
        else:
            R = 255
            G = (255 * (current_health) * 2 / max_health)

        R = max(0, R)
        G = max(0, G)
        B = 0

        rect = pygame.Surface((max(1, 100 * current_health / max_health), 20))
        rect.fill((R, G, B))

        if current_health > 0:
            render_queue.append(
                (0, rect, (self.side_menu_attribute_health_postion[0] + 40,
                           self.side_menu_attribute_health_postion[1] + 3)))
        text = self.side_menu_font.render(
            str(current_health) + '/' + str(max_health), 1, (10, 10, 10))

        render_queue.append(
            (0, text, (self.side_menu_attribute_health_postion[0] + 45 +
                       rect.get_width(),
                       self.side_menu_attribute_health_postion[1] + 5)))
Example #4
0
File: gui.py Project: CryoSky/pySLG
 def draw_selection_frame(self):
     grid = self.get_grid_on_mouse()
     if 0 <= grid[0] < self.main_window_row_number and 0 <= grid[
             1] < self.main_window_col_number:
         render_queue.append((-1, self.selection_frame,
                              self.get_grid_render_position(grid)))
         text = self.lvl_font.render(str(grid), 1, (0, 0, 0))
         render_queue.append((-1, text, self.get_grid_render_position(
             (0, 5))))
Example #5
0
File: gui.py Project: CryoSky/pySLG
    def display(self, selecting=False):

        height = 30 * len(self.menu_items)
        rect = pygame.Surface((150, height))
        rect.set_alpha(255)
        rect.fill((127, 140, 141))
        render_queue.append((-10, rect, self.position))
        for item in self.menu_items:
            item.display()
        self.gui.selected_menu_item = self.get_selected_item(selecting)
Example #6
0
 def selected(self, selecting = False):
     rect = pygame.Surface(self.size)
     rect.set_alpha(255)
     if selecting:
         rect.fill((255, 57, 43))
     else:
         rect.fill((162, 57, 43))
     render_queue.append( (-12 , rect , self.position) )
     text = self.gui.in_game_menu_font.render(self.text , 1 , (240,240,240))
     render_queue.append((-13,text , (self.position[0] + self.size[0]/2 - text.get_width()/2 , self.position[1] +10) ))
Example #7
0
    def display(self , selecting = False):

        height = 30 * len(self.menu_items)
        rect = pygame.Surface((150 , height))
        rect.set_alpha(255)
        rect.fill((127, 140, 141))
        render_queue.append( (-10,rect,self.position) )
        for item in self.menu_items:
            item.display()
        self.gui.selected_menu_item = self.get_selected_item(selecting)
Example #8
0
File: gui.py Project: CryoSky/pySLG
 def display(self):
     rect = pygame.Surface(self.size)
     rect.set_alpha(255)
     rect.fill(Menu.MENU_BACKGROUND_COLOC)
     render_queue.append((-11, rect, self.position))
     text = self.gui.in_game_menu_font.render(self.text, 1,
                                              (240, 240, 240))
     render_queue.append(
         (-13, text,
          (self.position[0] + self.size[0] / 2 - text.get_width() / 2,
           self.position[1] + 10)))
Example #9
0
    def highlight_taunting_target(self , grids):
        if not grids:
            return

        taunt_image = skill_image[skill.SKILL_IMAGE_TAUNT]
        self.cycletime += config.clock
        if self.cycletime < 350:
            for grid in grids:
                render_queue.append((-1, taunt_image , self.get_grid_render_position(grid)))
        elif self.cycletime > 700:
            self.cycletime = 0
Example #10
0
File: gui.py Project: CryoSky/pySLG
    def highlight_taunting_target(self, grids):
        if not grids:
            return

        taunt_image = skill_image[skill.SKILL_IMAGE_TAUNT]
        self.cycletime += config.clock
        if self.cycletime < 350:
            for grid in grids:
                render_queue.append(
                    (-1, taunt_image, self.get_grid_render_position(grid)))
        elif self.cycletime > 700:
            self.cycletime = 0
Example #11
0
    def draw_attribute_bar(self, type, value , buff_value):

        text = self.side_menu_font.render( str(value) , 1 , (10,10,10) )
        pos = self.attributes_icon_pos[type]
        buff_text = None
        if buff_value > 0:
            buff_text = self.side_menu_font.render( '(+' + str(buff_value) + ')' , 1 , (1,100,1))
        elif buff_value < 0:
            buff_text = self.side_menu_font.render( ' ( - ' + str(buff_value) + ')', 1 , (255,10,10))
        render_queue.append((0, text, (pos[0] + 14, pos[1] + 10)))
        if buff_text:
            render_queue.append((0, buff_text, (pos[0] + 14  , pos[1] + 10 + text.get_height() + 3)))
Example #12
0
File: gui.py Project: CryoSky/pySLG
 def selected(self, selecting=False):
     rect = pygame.Surface(self.size)
     rect.set_alpha(255)
     if selecting:
         rect.fill((255, 57, 43))
     else:
         rect.fill((162, 57, 43))
     render_queue.append((-12, rect, self.position))
     text = self.gui.in_game_menu_font.render(self.text, 1,
                                              (240, 240, 240))
     render_queue.append(
         (-13, text,
          (self.position[0] + self.size[0] / 2 - text.get_width() / 2,
           self.position[1] + 10)))
Example #13
0
File: gui.py Project: CryoSky/pySLG
    def draw_attribute_bar(self, type, value, buff_value):

        text = self.side_menu_font.render(str(value), 1, (10, 10, 10))
        pos = self.attributes_icon_pos[type]
        buff_text = None
        if buff_value > 0:
            buff_text = self.side_menu_font.render(
                '(+' + str(buff_value) + ')', 1, (1, 100, 1))
        elif buff_value < 0:
            buff_text = self.side_menu_font.render(
                ' ( - ' + str(buff_value) + ')', 1, (255, 10, 10))
        render_queue.append((0, text, (pos[0] + 14, pos[1] + 10)))
        if buff_text:
            render_queue.append(
                (0, buff_text, (pos[0] + 14,
                                pos[1] + 10 + text.get_height() + 3)))
Example #14
0
    def draw_health_bar(self, current_health, max_health):
        if current_health * 2 >= max_health:
            G = 255
            R = (255 * (max_health - current_health) * 2) / max_health
        else:
            R = 255
            G = (255 * (current_health) * 2 / max_health)

        R = max(0 , R)
        G = max(0 , G)
        B = 0

        rect = pygame.Surface((max(1,100 * current_health / max_health), 20))
        rect.fill((R, G, B))

        if current_health > 0:
            render_queue.append((
            0, rect, (self.side_menu_attribute_health_postion[0] + 40, self.side_menu_attribute_health_postion[1] + 3)))
        text = self.side_menu_font.render(str(current_health) + '/' + str(max_health), 1, (10, 10, 10))

        render_queue.append((0, text, (self.side_menu_attribute_health_postion[0] + 45 + rect.get_width(),
                                       self.side_menu_attribute_health_postion[1] + 5)))
Example #15
0
    def switch_turn(self, turn_team):
        rect = pygame.Surface((self.current_map.map_width, self.current_map.map_height))
        rect.set_alpha(150)
        if turn_team == 2:
            rect.fill((255,0,0))
        elif turn_team == 0:
            rect.fill((255,100,0))
        elif turn_team == 1:
            rect.fill((0,0,255))
        self.turn_switch_wait += config.clock
        if self.turn_switch_wait > 1000:
            self.turn_switch_wait = 0
            return True
        render_queue.append((-2 , rect , (0,0)))

        if turn_team == 2:
            text = self.switch_turn_font.render(u'我军回合', 1, (250, 250, 250))
        elif turn_team == 0:
            text = self.switch_turn_font.render(u'友军回合', 1, (250, 250, 250))
        elif turn_team == 1:
            text = self.switch_turn_font.render(u'敌军回合', 1, (250, 250, 250))
        render_queue.append((-3 , text , (self.current_map.map_width/2 - text.get_width()/2 , self.current_map.map_height/2 - text.get_height())))
        return False
Example #16
0
    def side_menu(self, pawn_info):
        render_queue.append(
            (3, self.side_menu_background, (self.face_border_position[0], self.face_border_position[1])))
        if pawn_info:

            if pawn_info.hero.health_decrease and pawn_info.hero.current_health > 0:
                pawn_info.hero.current_health -= 1
                pawn_info.hero.health_decrease -= 1
            render_queue.append((2, face_image_cache[pawn_info.face_resource_id], self.face_position))
            render_queue.append((1, self.face_frame, self.face_border_position))
            self.draw_level(pawn_info.hero.level)
            self.side_menu_attributes(pawn_info)
            self.draw_quote(pawn_info.hero.quote)
Example #17
0
File: gui.py Project: CryoSky/pySLG
    def side_menu(self, pawn_info):
        render_queue.append(
            (3, self.side_menu_background, (self.face_border_position[0],
                                            self.face_border_position[1])))
        if pawn_info:

            if pawn_info.hero.health_decrease and pawn_info.hero.current_health > 0:
                pawn_info.hero.current_health -= 1
                pawn_info.hero.health_decrease -= 1
            render_queue.append(
                (2, face_image_cache[pawn_info.face_resource_id],
                 self.face_position))
            render_queue.append(
                (1, self.face_frame, self.face_border_position))
            self.draw_level(pawn_info.hero.level)
            self.side_menu_attributes(pawn_info)
            self.draw_quote(pawn_info.hero.quote)
Example #18
0
File: gui.py Project: CryoSky/pySLG
 def highlight_grid(self, grid, color, alpha):
     rect = pygame.Surface((48, 48))
     rect.set_alpha(alpha)
     rect.fill(color)
     render_queue.append((1, rect, self.get_grid_render_position(grid)))
Example #19
0
    def side_menu_attributes(self, pawn_info):

        hero = pawn_info.hero
        render_queue.append((0, self.attribute_health_icon, (
            self.attributes_icon_pos[ATTRIBUTE_HEALTH][0] - 40,
            self.attributes_icon_pos[ATTRIBUTE_HEALTH][1])))

        self.draw_health_bar(hero.current_health, hero.max_health)

        render_queue.append((0, self.attribute_attack_icon, (
            self.attributes_icon_pos[ATTRIBUTE_ATTACK][0] - 40,
            self.attributes_icon_pos[ATTRIBUTE_ATTACK][1])))

        self.draw_attribute_bar(ATTRIBUTE_ATTACK, hero.attack , hero.attack_buff)


        render_queue.append((0, self.attribute_defence_icon, (
            self.attributes_icon_pos[ATTRIBUTE_DEFENCE][0] - 40,
            self.attributes_icon_pos[ATTRIBUTE_DEFENCE][1])))

        self.draw_attribute_bar(ATTRIBUTE_DEFENCE, hero.defence , hero.defence_buff)


        render_queue.append((0, self.attribute_speed_icon, (
            self.attributes_icon_pos[ATTRIBUTE_SPEED][0] - 40,
            self.attributes_icon_pos[ATTRIBUTE_SPEED][1])))
        self.draw_attribute_bar(ATTRIBUTE_SPEED, hero.speed , hero.speed_buff)


        render_queue.append((0, self.attribute_strategy_icon, (
            self.attributes_icon_pos[ATTRIBUTE_STRATEGY][0] - 40,
            self.attributes_icon_pos[ATTRIBUTE_STRATEGY][1])))

        self.draw_attribute_bar(ATTRIBUTE_STRATEGY, hero.strategy , hero.strategy_buff)


        render_queue.append((0, self.attribute_skill_icon, (
            self.attributes_icon_pos[ATTRIBUTE_SKILL][0] - 40,
            self.attributes_icon_pos[ATTRIBUTE_SKILL][1])))

        margin = 0
        for skill in pawn_info.hero.skills:
            text = self.side_menu_font.render(skill.name , 1 , (10,10,10))
            render_queue.append((0 , text , (
                self.attributes_icon_pos[ATTRIBUTE_SKILL][0] ,
                self.attributes_icon_pos[ATTRIBUTE_SKILL][1] + margin)))
            margin = self.side_menu_font.get_height()
Example #20
0
 def highlight_grid(self, grid, color, alpha):
     rect = pygame.Surface((48, 48))
     rect.set_alpha(alpha)
     rect.fill(color)
     render_queue.append((1, rect, self.get_grid_render_position(grid)))
Example #21
0
File: gui.py Project: CryoSky/pySLG
    def side_menu_attributes(self, pawn_info):

        hero = pawn_info.hero
        render_queue.append(
            (0, self.attribute_health_icon,
             (self.attributes_icon_pos[ATTRIBUTE_HEALTH][0] - 40,
              self.attributes_icon_pos[ATTRIBUTE_HEALTH][1])))

        self.draw_health_bar(hero.current_health, hero.max_health)

        render_queue.append(
            (0, self.attribute_attack_icon,
             (self.attributes_icon_pos[ATTRIBUTE_ATTACK][0] - 40,
              self.attributes_icon_pos[ATTRIBUTE_ATTACK][1])))

        self.draw_attribute_bar(ATTRIBUTE_ATTACK, hero.attack,
                                hero.attack_buff)

        render_queue.append(
            (0, self.attribute_defence_icon,
             (self.attributes_icon_pos[ATTRIBUTE_DEFENCE][0] - 40,
              self.attributes_icon_pos[ATTRIBUTE_DEFENCE][1])))

        self.draw_attribute_bar(ATTRIBUTE_DEFENCE, hero.defence,
                                hero.defence_buff)

        render_queue.append(
            (0, self.attribute_speed_icon,
             (self.attributes_icon_pos[ATTRIBUTE_SPEED][0] - 40,
              self.attributes_icon_pos[ATTRIBUTE_SPEED][1])))
        self.draw_attribute_bar(ATTRIBUTE_SPEED, hero.speed, hero.speed_buff)

        render_queue.append(
            (0, self.attribute_strategy_icon,
             (self.attributes_icon_pos[ATTRIBUTE_STRATEGY][0] - 40,
              self.attributes_icon_pos[ATTRIBUTE_STRATEGY][1])))

        self.draw_attribute_bar(ATTRIBUTE_STRATEGY, hero.strategy,
                                hero.strategy_buff)

        render_queue.append(
            (0, self.attribute_skill_icon,
             (self.attributes_icon_pos[ATTRIBUTE_SKILL][0] - 40,
              self.attributes_icon_pos[ATTRIBUTE_SKILL][1])))

        margin = 0
        for skill in pawn_info.hero.skills:
            text = self.side_menu_font.render(skill.name, 1, (10, 10, 10))
            render_queue.append(
                (0, text,
                 (self.attributes_icon_pos[ATTRIBUTE_SKILL][0],
                  self.attributes_icon_pos[ATTRIBUTE_SKILL][1] + margin)))
            margin = self.side_menu_font.get_height()
Example #22
0
 def draw_attack_frame_on_target(self, grids):
     if not grids:
         return
     for grid in grids:
         render_queue.append((0, self.attack_frame, self.get_grid_render_position(grid)))
Example #23
0
 def draw_selection_frame(self):
     grid = self.get_grid_on_mouse()
     if 0 <= grid[0] < self.main_window_row_number and 0 <= grid[1] < self.main_window_col_number:
         render_queue.append((-1, self.selection_frame, self.get_grid_render_position(grid)))
         text = self.lvl_font.render( str(grid) , 1 , (0,0,0) )
         render_queue.append((-1, text, self.get_grid_render_position(  (0,5)  )))
Example #24
0
 def draw_level(self, lvl):
     text = self.lvl_font.render(str(lvl), 1, (200, 230, 190))
     render_queue.append((0, text, self.lvl_icon_position))
Example #25
0
File: gui.py Project: CryoSky/pySLG
 def draw_quote(self, quote):
     text = self.quote_font.render(quote, 1, (10, 10, 10))
     render_queue.append((0, text, self.quote_position))
Example #26
0
File: gui.py Project: CryoSky/pySLG
 def draw_level(self, lvl):
     text = self.lvl_font.render(str(lvl), 1, (200, 230, 190))
     render_queue.append((0, text, self.lvl_icon_position))
Example #27
0
 def draw_quote(self, quote):
     text = self.quote_font.render(quote, 1, (10, 10, 10))
     render_queue.append((0, text, self.quote_position))
Example #28
0
File: gui.py Project: CryoSky/pySLG
 def draw_attack_frame_on_target(self, grids):
     if not grids:
         return
     for grid in grids:
         render_queue.append(
             (0, self.attack_frame, self.get_grid_render_position(grid)))
Example #29
0
    def animate(self,
                direction,
                position,
                repeat,
                special_render_item,
                render_single_frame=None,
                finished=False):

        if not self.finished and not finished:
            if special_render_item and 'sound' in special_render_item:
                if self.sound_playing != sound_cache[
                        special_render_item['sound']]:
                    self.sound_play_start = 9999999999
                self.sound_playing = sound_cache[special_render_item['sound']]
                self.play_animation_sound(
                    sound_cache[special_render_item['sound']])
            else:
                if self.sound_playing != self.sound:
                    self.sound_play_start = 9999999999
                self.sound_playing = self.sound
                self.play_animation_sound(self.sound)

        self.cycletime += config.clock

        animation_size = len(self.image_list[direction])
        if animation_size > 0:
            if self.cycletime > self.interval[self.render_idx]:
                self.cycletime = 0

                if self.render_idx + 1 == animation_size:
                    if repeat == -1:
                        self.render_idx = (self.render_idx +
                                           1) % animation_size
                    elif self.repeat + 1 < repeat:
                        self.render_idx = (self.render_idx +
                                           1) % animation_size
                        self.repeat += 1
                    elif self.repeat + 1 == repeat:
                        self.repeat = 0
                        self.finish()
                else:
                    self.render_idx = (self.render_idx + 1) % animation_size
            render_image = None
            if render_single_frame is not None:
                self.render_idx = render_single_frame
            if self.image_list[direction][self.render_idx] is not None:
                render_image = self.image_list[direction][
                    self.render_idx].copy()
                if finished:
                    tmp = image.load("image/mask/finished.bmp").convert()
                    render_image.blit(tmp, (0, 0), None, BLEND_RGBA_MULT)
                if special_render_item and 'mask' in special_render_item:
                    pixel_array = PixelArray(
                        map_image_cache[special_render_item['mask']])
                    render_image_pixel_array = PixelArray(render_image)

                    for i in range(len(render_image_pixel_array)):
                        for j in range(len(render_image_pixel_array[0])):
                            if pixel_array[i][j] != map_image_cache[
                                    special_render_item['mask']].map_rgb(
                                        247, 0, 255):
                                render_image_pixel_array[i][j] = Color(
                                    247, 0, 255, 0)
                    render_image = render_image.convert_alpha()
                    render_image.set_colorkey(self.color_key)
            render_queue.append((0, render_image, position))
Example #30
0
 def render(self):
     render_queue.append((2, self.map_image_file, (0,0)))