示例#1
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)
示例#2
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)
示例#3
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)