Ejemplo n.º 1
0
 def add_module(self, index, typeid, state=None):
     type = dogma_attrs.get_slottype(typeid)
     preset = self.presets[self.active_preset_id]
     if index in preset.modules[type]:
         self.remove_module(index, preset.modules[type][index]['typeid'])
     (is_activable, _) = dogma_attrs.get_states(typeid)
     if state is None:
         state = STATE_ACTIVE if is_activable and slottypes[type][2] else STATE_ONLINE
     dogma_index = self.dogma_context.add_module(typeid, state=state)
     preset.modules[type][index] = {
         'typeid': typeid,
         'typename': dogma_attrs.get_typename(typeid),
         'state': state,
         'dogma_index': dogma_index,
     }
Ejemplo n.º 2
0
    def remove_module(self, index, typeid):
        type = dogma_attrs.get_slottype(typeid)
        preset = self.presets[self.active_preset_id]

        # remove charge in current preset
        charge_preset = preset.charge_presets[self.active_charge_preset_id]
        if (type in charge_preset['charges'] and
                index in charge_preset['charges'][type]):
            self.remove_charge(type, index)

        # remove charge in all presets
        for charge_preset in preset.charge_presets:
            if (type in charge_preset['charges'] and
                    index in charge_preset['charges'][type]):
                del charge_preset['charges'][type][index]

        self.dogma_context.remove_module(preset.modules[type][index]['dogma_index'])
        del preset.modules[type][index]