def __init__(self): BuilderContainer.__init__(self) self.position = (20, MovesetNameEntryBox._Y_POS + 60) title_position = (300, MovesetNameEntryBox._Y_POS + 60) self.title = MovesetBuilderLabel(title_position,"Create Attacks",(255,255,255),25) self.ValidationTree = InputTree() self.draw_tab = True attack_types = [(AttackTypes.KICK, "Kick"), (AttackTypes.PUNCH, "Punch")] self.animation_select_container = AttackSelectContainer( (20, self.position[1] + self.title.height + 15), "Select Attack Type", attack_types ) self.key_select_container = KeySetContainer( (300, self.position[1] + self.title.height + 15), "Select Attack Commands" ) self.key_select_container.inactivate() self.add_children([ self.title, self.animation_select_container, self.key_select_container ]) self.width = 750
class AttackBuilderContainer(BuilderContainer): def __init__(self): BuilderContainer.__init__(self) self.position = (20, MovesetNameEntryBox._Y_POS + 60) title_position = (300, MovesetNameEntryBox._Y_POS + 60) self.title = MovesetBuilderLabel(title_position,"Create Attacks",(255,255,255),25) self.ValidationTree = InputTree() self.draw_tab = True attack_types = [(AttackTypes.KICK, "Kick"), (AttackTypes.PUNCH, "Punch")] self.animation_select_container = AttackSelectContainer( (20, self.position[1] + self.title.height + 15), "Select Attack Type", attack_types ) self.key_select_container = KeySetContainer( (300, self.position[1] + self.title.height + 15), "Select Attack Commands" ) self.key_select_container.inactivate() self.add_children([ self.title, self.animation_select_container, self.key_select_container ]) self.width = 750 def set_moveset(self, moveset): self.animation_select_container.set_moveset(moveset) def save(self): self.animation_select_container.save_to_moveset() def sync_to_moveset(self): self.animation_select_container.sync_to_moveset() def expand(self): BuilderContainer.expand(self) self.draw_tab = True def collapse(self): BuilderContainer.collapse(self) self.draw_tab = False def draw(self, surface): BuilderContainer.draw(self, surface) if self.draw_tab: point1 = (self.position[0], self.title.bottom_left()[1]) title_bottom_left = self.title.bottom_left() point2 = (title_bottom_left[0] - 10, title_bottom_left[1]) title_top_left = self.title.position point3 = (title_top_left[0] - 10, title_top_left[1] - 10) title_top_right = self.title.top_right() point4 = (title_top_right[0] + 10, title_top_left[1] - 10) title_bottom_right = self.title.bottom_right() point5 = (title_bottom_right[0] + 10, title_bottom_right[1]) point6 = (self.top_right()[0], title_bottom_right[1]) pygame.draw.line(surface, (255,255,255), point1, point2) pygame.draw.line(surface, (255,255,255), point2, point3) pygame.draw.line(surface, (255,255,255), point3, point4) pygame.draw.line(surface, (255,255,255), point4, point5) pygame.draw.line(surface, (255,255,255), point5, point6) def handle_events(self): self.animation_select_container.handle_events() self.key_select_container.handle_events() animation = self.animation_select_container.selected_animation() if animation != None: label_combination = self.animation_select_container.get_key_combination( animation.name ) if not self.key_select_container.active: self.key_select_container.activate() self.key_select_container.set_key_combination( label_combination ) if self.key_select_container.thumbnail == None: thumbnail = self.animation_select_container.get_thumbnail( animation.name ) self.key_select_container.set_thumbnail(thumbnail) self.key_select_container.set_key_combination( self.animation_select_container.get_key_combination( animation.name ) ) elif self.key_select_container.thumbnail.animation.name != animation.name: thumbnail = self.animation_select_container.get_thumbnail( animation.name ) self.key_select_container.set_thumbnail(thumbnail) self.key_select_container.set_key_combination( self.animation_select_container.get_key_combination( animation.name ) ) key_select_text = self.key_select_container.key_combination_label.text key_select_combination = self.key_select_container.key_combination label = self.animation_select_container.get_attack_label(animation.name) if (label != None and len(key_select_text) != len(label.key_combination_label.text)): if self.animation_select_container.is_valid_command(key_select_combination): if len(key_select_combination) == 0: self.animation_select_container.set_key_combination( label.attack_name, key_select_combination ) else: if self.animation_select_container.command_in_use(key_select_combination): self.key_select_container.command_in_use_label.show() else: if self.key_select_container.command_in_use_label.visible: self.key_select_container.command_in_use_label.hide() self.animation_select_container.set_key_combination( label.attack_name, key_select_combination ) else: if len(key_select_combination) == 0: if self.key_select_container.command_in_use_label.visible: self.key_select_container.command_in_use_label.hide() else: if self.key_select_container.active: self.key_select_container.inactivate() self.key_select_container.set_key_combination([]) if self.key_select_container.thumbnail != None: self.key_select_container.remove_thumbnail()