Beispiel #1
0
    def set_frame(self, event):
        """
        Sets the frame index property of all currently selected states.
        """

        self.undo_add()

        window = self.FindWindowById(event.GetId())
        value = utils.validate_numeric(window)

        # Clamp to a valid index.
        if value < 0:
            value = 0
        elif value >= config.MAX_SPRITE_FRAME:
            value = config.MAX_SPRITE_FRAME - 1

        if window.GetValue() != str(value):
            window.ChangeValue(str(value))

        # Manually update all selected states so that the lit frame index flag can be retained.
        for list_index in self.selected:
            state = self.filter_states[list_index]
            state['spriteFrame'] = value | (state['spriteFrame'] & self.FRAMEFLAG_LIT)

        self.statelist_update_selected_rows()
        self.update_sprite_preview()
        self.is_modified(True)
Beispiel #2
0
    def set_sound(self, event):
        """
        Sets the currently selected thing's sound index.

        Which sound to change is determined by the text control's id and the PROPS_SOUNDS lookup table.
        """

        self.undo_add()

        window_id = event.GetId()
        window = self.FindWindowById(window_id)
        value = utils.validate_numeric(window)

        thing = self.patch.things[self.selected_index]

        # Clamp to valid sound indices.
        if value < 0:
            value = 0
        if value > len(self.patch.sounds):
            value = len(self.patch.sounds)

        if str(value) != window.GetValue():
            window.ChangeValue(str(value))

        key = self.PROPS_SOUNDS[window_id]
        thing['sound' + key] = value
        self.__dict__['ThingSound' + key + 'Name'].SetLabel(self.patch.get_sound_name(value))
        self.is_modified(True)
Beispiel #3
0
    def set_sound(self, event):
        """
        Sets the currently selected thing's sound index.

        Which sound to change is determined by the text control's id and the PROPS_SOUNDS lookup table.
        """

        self.undo_add()

        window_id = event.GetId()
        window = self.FindWindowById(window_id)
        value = utils.validate_numeric(window)

        thing = self.patch.things[self.selected_index]

        # Clamp to valid sound indices.
        if value < 0:
            value = 0
        if value > len(self.patch.sounds):
            value = len(self.patch.sounds)

        if str(value) != window.GetValue():
            window.ChangeValue(str(value))

        key = self.PROPS_SOUNDS[window_id]
        thing['sound' + key] = value
        self.__dict__['ThingSound' + key + 'Name'].SetLabel(
            self.patch.get_sound_name(value))
        self.is_modified(True)
Beispiel #4
0
    def set_state(self, event):
        """
        Sets the currently selected thing's property value.

        Which thing property to change is determined by the text control's id and the PROPS_VALUES lookup table.
        """

        self.undo_add()

        window_id = event.GetId()
        window = self.FindWindowById(window_id)
        value = utils.validate_numeric(window)

        thing = self.patch.things[self.selected_index]

        # Clamp to valid state indices.
        if value < 0:
            value = 0
        if value >= len(self.patch.states):
            value = len(self.patch.states) - 1

        if str(value) != window.GetValue():
            window.ChangeValue(str(value))

        key = self.PROPS_STATES[window_id]
        thing['state' + key] = value
        self.__dict__['ThingState' + key + 'Name'].SetLabel(self.patch.get_state_name(value))
        self.is_modified(True)
        self.update_is_projectile()
        self.update_properties()
Beispiel #5
0
    def set_value(self, event):
        """
        Validates and sets a property.
        """

        self.undo_add()

        window_id = event.GetId()
        window = self.FindWindowById(window_id)

        key = self.PROPS_VALUES[window_id]
        value = utils.validate_numeric(window)

        # Clamp values so that they make sense.
        if key == 'episode':
            if value < 0:
                value = 0
            elif value > 9:
                value = 9
        elif key == 'map':
            if value < 0:
                value = 0
            elif value > 99:
                value = 99
        elif key == 'seconds':
            if value < 0:
                value = 0
        window.ChangeValue(str(value))

        self.patch.pars[self.selected_index][key] = value

        self.parlist_update_row(self.selected_index)
        self.is_modified(True)
Beispiel #6
0
    def set_value(self, event):
        """
        Sets the currently selected thing's property value.

        Which thing property to change is determined by the text control's id and the PROPS_VALUES lookup table.
        """

        self.undo_add()

        window_id = event.GetId()
        window = self.FindWindowById(window_id)
        value_type = self.PROPS_VALUE_TYPES[window_id]
        if value_type == 'int':
            value = utils.validate_numeric(window)
        elif value_type == 'float' or value_type == 'fixed':
            value = utils.validate_numeric_float(window)
        else:
            value = window.GetValue()

        thing = self.patch.things[self.selected_index]

        # Apply fixed point divisor if the value needs it.
        # This is also necessary for the speed property if the thing has it's MISSILE flag set.
        key = self.PROPS_VALUES[window_id]
        if value_type == 'fixed':
            value *= self.FIXED_UNIT
        elif key == 'speed' and 'MISSILE' in thing['flags']:
            value *= self.FIXED_UNIT

        thing[key] = value

        self.thinglist_update_row(self.selected_index)
        self.is_modified(True)
Beispiel #7
0
    def set_frame(self, event):
        """
        Sets the frame index property of all currently selected states.
        """

        self.undo_add()

        window = self.FindWindowById(event.GetId())
        value = utils.validate_numeric(window)

        # Clamp to a valid index.
        if value < 0:
            value = 0
        elif value > config.MAX_SPRITE_FRAME:
            value = config.MAX_SPRITE_FRAME

        if window.GetValue() != str(value):
            window.ChangeValue(str(value))

        # Manually update all selected states so that the lit frame index flag can be retained.
        for list_index in self.selected:
            state = self.filter.states[list_index]
            state['spriteFrame'] = value | (state['spriteFrame']
                                            & self.FRAMEFLAG_LIT)

        self.statelist_update_selected_rows()
        self.update_sprite_preview()
        self.is_modified(True)
Beispiel #8
0
    def set_state_index(self, event):
        """
        Sets the currently selected weapon's state.
        """

        self.undo_add()

        window_id = event.GetId()
        window = self.FindWindowById(window_id)
        value = utils.validate_numeric(window)

        weapon = self.patch.weapons[self.selected_index]

        # Clamp to valid state indices.
        if value < 0:
            value = 0
        if value >= len(self.patch.states):
            value = len(self.patch.states) - 1

        if str(value) != window.GetValue():
            window.ChangeValue(str(value))

        key = self.PROPS_STATES[window_id]
        weapon['state' + key] = value
        self.__dict__['WeaponState' + key + 'Name'].SetLabel(
            self.patch.get_state_name(value))
        self.is_modified(True)
Beispiel #9
0
    def set_value(self, event):
        """
        Sets the currently selected thing's property value.

        Which thing property to change is determined by the text control's id and the PROPS_VALUES lookup table.
        """

        self.undo_add()

        window_id = event.GetId()
        window = self.FindWindowById(window_id)
        value_type = self.PROPS_VALUE_TYPES[window_id]
        if value_type == 'int':
            value = utils.validate_numeric(window)
        elif value_type == 'float' or value_type == 'fixed':
            value = utils.validate_numeric_float(window)
        else:
            value = window.GetValue()

        thing = self.patch.things[self.selected_index]

        # Apply fixed point divisor if the value needs it.
        # This is also necessary for the speed property if the thing has it's MISSILE flag set.
        key = self.PROPS_VALUES[window_id]
        if value_type == 'fixed':
            value *= self.FIXED_UNIT
        elif key == 'speed' and 'MISSILE' in thing['flags']:
            value *= self.FIXED_UNIT

        thing[key] = value

        self.thinglist_update_row(self.selected_index)
        self.is_modified(True)
Beispiel #10
0
    def set_state_index(self, event):
        """
        Sets the currently selected weapon's state.
        """

        self.undo_add()

        window_id = event.GetId()
        window = self.FindWindowById(window_id)
        value = utils.validate_numeric(window)

        weapon = self.patch.weapons[self.selected_index]

        # Clamp to valid state indices.
        if value < 0:
            value = 0
        if value >= len(self.patch.states):
            value = len(self.patch.states) - 1

        if str(value) != window.GetValue():
            window.ChangeValue(str(value))

        key = self.PROPS_STATES[window_id]
        weapon['state' + key] = value
        self.__dict__['WeaponState' + key + 'Name'].SetLabel(self.patch.get_state_name(value))
        self.is_modified(True)
Beispiel #11
0
    def set_value(self, event):
        """
        Validates and sets a property.
        """

        self.undo_add()

        window_id = event.GetId()
        window = self.FindWindowById(window_id)

        key = self.PROPS_VALUES[window_id]
        value = utils.validate_numeric(window)

        # Clamp values so that they make sense.
        if key == 'episode':
            if value < 0:
                value = 0
            elif value > 9:
                value = 9
        elif key == 'map':
            if value < 0:
                value = 0
            elif value > 99:
                value = 99
        elif key == 'seconds':
            if value < 0:
                value = 0
        window.ChangeValue(str(value))

        self.patch.pars[self.selected_index][key] = value

        self.parlist_update_row(self.selected_index)
        self.is_modified(True)
Beispiel #12
0
    def set_value(self, event):
        """
        Sets the currently selected ammo entry's property value.
        """

        self.undo_add()

        window_id = event.GetId()
        window = self.FindWindowById(window_id)
        value = utils.validate_numeric(window)

        key = self.PROPS_VALUES[window_id]
        self.patch.ammo[self.selected_index][key] = value

        self.ammolist_update_row(self.selected_index)
        self.is_modified(True)
Beispiel #13
0
    def set_value(self, event):
        """
        Sets the currently selected ammo entry's property value.
        """

        self.undo_add()

        window_id = event.GetId()
        window = self.FindWindowById(window_id)
        value = utils.validate_numeric(window)

        key = self.PROPS_VALUES[window_id]
        self.patch.ammo[self.selected_index][key] = value

        self.ammolist_update_row(self.selected_index)
        self.is_modified(True)
Beispiel #14
0
    def set_value(self, event):
        """
        Sets the currently selected weapon entry's property value.
        """

        self.undo_add()

        window_id = event.GetId()
        window = self.FindWindowById(window_id)
        if window_id == windows.WEAPON_VAL_DECAL:
            value = window.GetValue()
        else:
            value = utils.validate_numeric(window)

        key = self.PROPS_VALUES[window_id]
        self.patch.weapons[self.selected_index][key] = value

        self.weaponlist_update_row(self.selected_index)
        self.is_modified(True)
Beispiel #15
0
    def set_value(self, event):
        """
        Validates and sets a property of all currently selected states.
        """

        window_id = event.GetId()
        window = self.FindWindowById(window_id)
        value = utils.validate_numeric(window)

        # Clamp sprite index and update sprite name.
        if window_id == windows.STATES_SPRITE:
            if value < 0:
                value = 0
            elif value >= len(self.patch.sprite_names):
                value = len(self.patch.sprite_names) - 1
            self.SpriteName.SetLabel(self.patch.sprite_names[value])
            window.ChangeValue(str(value))

        # Clamp next state index and update state name.
        elif window_id == windows.STATES_NEXT:
            if value < 0:
                value = 0
            elif value >= len(self.patch.states):
                value = len(self.patch.states) - 1
            self.NextStateName.SetLabel(self.patch.get_state_name(value))
            window.ChangeValue(str(value))

        # Clamp duration.
        elif window_id == windows.STATES_DURATION:
            if value < -1:
                value = 0
                window.ChangeValue(str(value))

        key = self.PROPS_STATE[window_id]
        self.set_selected_property(key, value)

        self.statelist_update_selected_rows()
        self.update_sprite_preview()
        self.is_modified(True)

        # Update sprite index colour coding.
        if window_id == windows.STATES_SPRITE:
            self.update_colours()
Beispiel #16
0
    def set_value(self, event):
        """
        Validates and sets a property of all currently selected states.
        """

        window_id = event.GetId()
        window = self.FindWindowById(window_id)
        value = utils.validate_numeric(window)

        # Clamp sprite index and update sprite name.
        if window_id == windows.STATES_SPRITE:
            if value < 0:
                value = 0
            elif value >= len(self.patch.sprite_names):
                value = len(self.patch.sprite_names) - 1
            self.SpriteName.SetLabel(self.patch.sprite_names[value])
            window.ChangeValue(str(value))

        # Clamp next state index and update state name.
        elif window_id == windows.STATES_NEXT:
            if value < 0:
                value = 0
            elif value >= len(self.patch.states):
                value = len(self.patch.states) - 1
            self.NextStateName.SetLabel(self.patch.get_state_name(value))
            window.ChangeValue(str(value))

        # Clamp duration.
        elif window_id == windows.STATES_DURATION:
            if value < -1:
                value = 0
                window.ChangeValue(str(value))

        key = self.PROPS_STATE[window_id]
        self.set_selected_property(key, value)

        self.statelist_update_selected_rows()
        self.update_sprite_preview()
        self.is_modified(True)

        # Update sprite index colour coding.
        if window_id == windows.STATES_SPRITE:
            self.update_colours()
Beispiel #17
0
    def update_frame(self, event):
        """
        Called when the frame index text control is updated.

        Updates the frame index value, ensuring it is a valid integer.
        """

        window_id = event.GetId()
        window = self.FindWindowById(window_id)
        value = utils.validate_numeric(window)

        if value < 0:
            value = 0
        elif value > config.MAX_SPRITE_FRAME:
            value = config.MAX_SPRITE_FRAME

        if str(value) != window.GetValue():
            window.ChangeValue(str(value))

        self.update_preview()
Beispiel #18
0
    def update_frame(self, event):
        """
        Called when the frame index text control is updated.

        Updates the frame index value, ensuring it is a valid integer.
        """

        window_id = event.GetId()
        window = self.FindWindowById(window_id)
        value = utils.validate_numeric(window)

        if value < 0:
            value = 0
        elif value > config.MAX_SPRITE_FRAME:
            value = config.MAX_SPRITE_FRAME

        if str(value) != window.GetValue():
            window.ChangeValue(str(value))

        self.update_preview()
Beispiel #19
0
    def set_value(self, event):
        """
        Sets the currently selected weapon entry's property value.
        """

        self.undo_add()

        window_id = event.GetId()
        window = self.FindWindowById(window_id)
        if window_id == windows.WEAPON_VAL_DECAL:
            value = window.GetValue()
        else:
            value = utils.validate_numeric(window)

        if str(value) != window.GetValue():
            window.ChangeValue(str(value))

        key = self.PROPS_VALUES[window_id]
        self.patch.weapons[self.selected_index][key] = value

        self.weaponlist_update_row(self.selected_index)
        self.is_modified(True)
Beispiel #20
0
    def set_value(self, event):
        """
        Validates and sets a misc. property.
        """

        self.undo_add()

        window_id = event.GetId()
        window = self.FindWindowById(window_id)

        if self.data_type == 'int' or self.data_type == 'byte':
            value = utils.validate_numeric(window)
        elif self.data_type == 'float':
            value = utils.validate_numeric_float(window)
        else:
            value = window.GetValue()

        key = self.patch.engine.misc_data.keys()[self.selected_index]

        # Clamp values to their data type range.
        if self.data_type == 'int':
            if value < -0x80000000:
                value = -0x80000000
            elif value > 0x80000000:
                value = 0x80000000
            window.ChangeValue(str(value))

        elif self.data_type == 'byte':
            if value < 0:
                value = 0
            elif value > 255:
                value = 255
            window.ChangeValue(str(value))

        self.patch.misc[key] = value

        self.is_modified(True)
        self.misclist_update_row(self.selected_index)
Beispiel #21
0
    def set_priority(self, event):
        """
        Validates and sets a property of the current sound.
        """

        self.undo_add()

        window = self.FindWindowById(windows.SOUNDS_PRIORITY)
        value = utils.validate_numeric(window)

        # Clamp sprite to valid range.
        if value < 0:
            value = 0
        elif value >= 127:
            value = 127
        if window.GetValue() != value:
            window.ChangeValue(str(value))

        sound = self.patch.sounds[self.selected_index]
        sound['priority'] = value

        self.soundlist_update_row(self.selected_row, self.selected_index)
        self.is_modified(True)
Beispiel #22
0
    def set_priority(self, event):
        """
        Validates and sets a property of the current sound.
        """

        self.undo_add()

        window = self.FindWindowById(windows.SOUNDS_PRIORITY)
        value = utils.validate_numeric(window)

        # Clamp sprite to valid range.
        if value < 0:
            value = 0
        elif value >= 127:
            value = 127
        if window.GetValue() != value:
            window.ChangeValue(str(value))

        sound = self.patch.sounds[self.selected_index]
        sound['priority'] = value

        self.soundlist_update_row(self.selected_row, self.selected_index)
        self.is_modified(True)