def on_key_press(self, button, modifiers): if button == self.last_key_pressed: self.repeat = True else: self.repeat = False if button in number_keys: control_group_index = number_keys.index(button) if modifiers & key.LCTRL: self.control_groups[ control_group_index] = self.get_selected_units() else: self.to_select = self.control_groups[number_keys.index( button)][:] if self.repeat and self.key_repeat_timer <= 3.: self.notify(tools.get_average_location(self.to_select), "CENTER CAMERA") self.run_selection() self.key_repeat_timer = 0 if button == key.S: for u in self.get_selected_units(): u.arrive() if button == key.DELETE: to_delete = [] for u in self.get_selected_units(): if u.team == "Player": to_delete.append(u) self.kill_units(to_delete) self.last_key_pressed = button
def on_key_press(self, button, modifiers): if button == self.last_key_pressed: self.repeat = True else: self.repeat = False if button in number_keys: control_group_index = number_keys.index(button) if modifiers & key.LCTRL: self.control_groups[control_group_index] = self.get_selected_units() else: self.to_select = self.control_groups[number_keys.index(button)][:] if self.repeat and self.key_repeat_timer <= 3.: self.notify(tools.get_average_location(self.to_select), "CENTER CAMERA") self.run_selection() self.key_repeat_timer = 0 if button == key.S: for u in self.get_selected_units(): u.arrive() if button == key.DELETE: to_delete = [] for u in self.get_selected_units(): if u.team == "Player": to_delete.append(u) self.kill_units(to_delete) self.last_key_pressed = button
def on_mouse_press(self, x, y, buttons, modifiers): x += self.wx y += self.wy if buttons & mouse.RIGHT: if self.controlled_window.cam.mode == 3: x -= self.wx y -= self.wy x, y = self.controlled_window.mouse_selector.get_plane_from_xy(x, y) units_to_order = self.get_selected_units() if units_to_order: origin = tools.get_average_location(units_to_order) if modifiers & key.MOD_SHIFT: self.give_move_command(self.get_selected_units(), origin, (x, y), shift=True) else: self.give_move_command(self.get_selected_units(), origin, (x, y))
def on_mouse_press(self, x, y, buttons, modifiers): x += self.wx y += self.wy if buttons & mouse.RIGHT: if self.controlled_window.cam.mode == 3: x -= self.wx y -= self.wy x, y = self.controlled_window.mouse_selector.get_plane_from_xy( x, y) units_to_order = self.get_selected_units() if units_to_order: origin = tools.get_average_location(units_to_order) if modifiers & key.MOD_SHIFT: self.give_move_command(self.get_selected_units(), origin, (x, y), shift=True) else: self.give_move_command(self.get_selected_units(), origin, (x, y))