def __init__(self, position, value, values, width, height, puck_radius, text, text_colour, text_font, text_box_width, text_box_height, slider_type="default"): self.__value = value self.values = values self.timer = 0 position = position + Vector(0, text_box_height / 2) Rectangle.__init__(self, width, height, position) self.puck = Circle(puck_radius, position) self.states = {} for state in ["active", "hover", "normal"]: self.puck.load_avatar( r"GUI/Slider/{0}/{1}.png".format(slider_type, state)) self.puck.scale_avatar( self.puck.radius * 2, self.puck.radius * 2) self.states[state] = self.puck.image_master self.sound_effect = SoundEffect(r"slider_{0}.wav".format(slider_type)) self.state = "normal" self.text_box = TextBox( text_box_width, text_box_height, position + Vector(0, -max(self.puck.radius, height / 2) - text_box_height / 2), text, text_colour, text_font) self.left_fill = (253, 238, 0) self.right_fill = (0, 0, 0) self.slider_type = slider_type self.sync_puck()
def __init__(self, width, height, position, text, text_colour, text_font, background=None): Rectangle.__init__(self, width, height, position) self.text = text self.text_colour = text_colour self.text_font = text_font self.background = background self.create_text_avatar()
def __init__(self, width, height, position, title, title_colour, title_font, title_box_width, title_box_height, menu_type="default"): Rectangle.__init__(self, width, height, position) self.load_avatar(r"GUI/Menu/{0}.jpg".format(menu_type)) self.elements = [TextBox( title_box_width, title_box_height, Vector(width / 2, title_box_height / 2 + 10), title, title_colour, title_font)] self.frame = ((0, 0, 0), 10) self.menu_type = menu_type
def __init__(self, position, width, height, text, text_colour, text_font, button_type="default"): Rectangle.__init__(self, width, height, position) self.states = {} for state in ["active", "hover", "normal"]: self.load_avatar( r"GUI/Button/{0}/{1}.png".format(button_type, state)) self.scale_avatar(self.width, self.height) self.states[state] = self.image_master self.state = "normal" self.clicked = False self.sound_effect = SoundEffect(r"button_{0}.wav".format(button_type)) self.text_box = TextBox(width, height, position, text, text_colour, text_font) self.button_type = button_type
def __init__(self, position, value, width, height, text, text_colour, text_font, text_box_width, text_box_height, checkbox_type="default"): Rectangle.__init__(self, width, height, position + Vector( -text_box_width / 2, 0)) self.states = {} for state in ["checked", "unchecked", "checked_hover", "unchecked_hover"]: self.load_avatar( r"GUI/Checkbox/{0}/{1}.png".format(checkbox_type, state)) self.scale_avatar(self.width, self.height) self.states[state] = self.image_master if value: self.state = "checked" else: self.state = "unchecked" self.sound_effect = SoundEffect( r"checkbox_{0}.wav".format(checkbox_type)) self.text_box = TextBox( text_box_width, text_box_height, self.position + Vector((self.width + text_box_width) / 2, 0), text, text_colour, text_font) self.checkbox_type = checkbox_type