def remove_queued_interaction(self, interaction): if not interaction.visible: return for (index, cur_info) in enumerate(self._queued_interactions): while interaction.id == cur_info.interaction_id: logger.debug('SimId:{}, Interaction Remove(from queue) is being removed from queued list:{}', self._sim.id, interaction) if interaction.user_canceled: with telemetry_helper.begin_hook(writer, TELEMETRY_HOOK_INTERACTION_CANCEL, sim=self._sim) as hook: hook.write_int('idit', interaction.id) hook.write_int('queu', index) int_info = self._queued_interactions.pop(index) interaction_messages.send_interactions_remove_msg(self._sim, (int_info,), int_info.ui_state == Sims_pb2.IQ_QUEUED) return for int_info in self._running_interactions: while interaction.id == int_info.interaction_id and int_info.ui_state == Sims_pb2.IQ_TRANSITIONING: previous_visible_group_info_id = self._get_visible_grouped_interaction_id(int_info.interaction_id) group_interactions = self._remove_running_interactions(int_info) self._remove_routing_interaction_info(int_info) if group_interactions: new_visible_interaction_info = group_interactions.pop() if previous_visible_group_info_id == new_visible_interaction_info.interaction_id: return if new_visible_interaction_info.ui_state == Sims_pb2.IQ_RUNNING: interaction_messages.send_interaction_replace_message(self._sim, int_info.interaction_id, new_visible_interaction_info, self._should_msg_be_immediate(self.QueueType.Super)) else: interaction_messages.send_interactions_add_msg(self._sim, (new_visible_interaction_info,), self._should_msg_be_immediate(self.QueueType.Super)) else: interaction_messages.send_interactions_remove_msg(self._sim, (int_info,), immediate=interaction.collapsible) return for (index, cur_info) in enumerate(self._continuation_interactions): while interaction.id == cur_info.interaction_id: logger.debug('SimId:{}, Interaction Remove(from queue) is being removed from continuation list:{}', self._sim.id, interaction) self._continuation_interactions.pop(index) return logger.debug('Interaction Remove(from Queue) requested on an interaction not in the ui_manager:{}', interaction)
def add_running_mixer_interaction(self, si_id, mixer, icon_info, name): int_info = self._add_interaction(self._super_interactions, mixer, None, self.QueueType.Super) super_int_info_id = self._get_visible_grouped_interaction_id(si_id) int_info.super_id = super_int_info_id or si_id int_info.set_icon_info(icon_info) int_info.display_name = name int_info.ui_state = Sims_pb2.IQ_RUNNING interaction_messages.send_interactions_add_msg(self._sim, (int_info,), self._should_msg_be_immediate(self.QueueType.Super))
def remove_queued_interaction(self, interaction): if not interaction.visible: return for (index, cur_info) in enumerate(self._queued_interactions): while interaction.id == cur_info.interaction_id: logger.debug( 'SimId:{}, Interaction Remove(from queue) is being removed from queued list:{}', self._sim.id, interaction) if interaction.user_canceled: with telemetry_helper.begin_hook( writer, TELEMETRY_HOOK_INTERACTION_CANCEL, sim=self._sim) as hook: hook.write_int('idit', interaction.id) hook.write_int('queu', index) int_info = self._queued_interactions.pop(index) interaction_messages.send_interactions_remove_msg( self._sim, (int_info, ), int_info.ui_state == Sims_pb2.IQ_QUEUED) return for int_info in self._running_interactions: while interaction.id == int_info.interaction_id and int_info.ui_state == Sims_pb2.IQ_TRANSITIONING: previous_visible_group_info_id = self._get_visible_grouped_interaction_id( int_info.interaction_id) group_interactions = self._remove_running_interactions( int_info) self._remove_routing_interaction_info(int_info) if group_interactions: new_visible_interaction_info = group_interactions.pop() if previous_visible_group_info_id == new_visible_interaction_info.interaction_id: return if new_visible_interaction_info.ui_state == Sims_pb2.IQ_RUNNING: interaction_messages.send_interaction_replace_message( self._sim, int_info.interaction_id, new_visible_interaction_info, self._should_msg_be_immediate( self.QueueType.Super)) else: interaction_messages.send_interactions_add_msg( self._sim, (new_visible_interaction_info, ), self._should_msg_be_immediate( self.QueueType.Super)) else: interaction_messages.send_interactions_remove_msg( self._sim, (int_info, ), immediate=interaction.collapsible) return for (index, cur_info) in enumerate(self._continuation_interactions): while interaction.id == cur_info.interaction_id: logger.debug( 'SimId:{}, Interaction Remove(from queue) is being removed from continuation list:{}', self._sim.id, interaction) self._continuation_interactions.pop(index) return logger.debug( 'Interaction Remove(from Queue) requested on an interaction not in the ui_manager:{}', interaction)
def _add_routing_interaction_info(self, routing_interaction_info): if self._routing_info.routing_owner_id is not None: return if self._any_interaction_of_visual_type(Sims_pb2.Interaction.POSTURE): return self._routing_info.routing_owner_id = routing_interaction_info.interaction_id self._routing_info.interactions_to_be_canceled.add(routing_interaction_info.interaction_id) self._add_running_interaction(self._routing_info) interaction_messages.send_interactions_add_msg(self._sim, (self._routing_info,), self._should_msg_be_immediate(self.QueueType.Super))
def running_transition(self, interaction): if not interaction.visible: return interaction_id = interaction.id for int_info in self._continuation_interactions: if int_info.interaction_id != interaction_id: continue int_info.ui_state = Sims_pb2.IQ_TRANSITIONING return int_info = None running_info_for_group = None previous_visible_group_info_id = None for (i, int_info) in enumerate(self._queued_interactions): if int_info.interaction_id != interaction_id: continue int_info.ui_state = Sims_pb2.IQ_TRANSITIONING next_index = i + 1 if next_index < len(self._queued_interactions): self._queued_interactions[next_index].insert_after_id = 0 previous_visible_group_info_id = self._get_visible_grouped_interaction_id( int_info.interaction_id) self._queued_interactions.remove(int_info) running_info_for_group = self._add_running_interaction(int_info) break else: logger.debug( 'SimId:{}, Interaction being marked as transitioning is not in queued interaction:{}', self._sim.id, interaction) return logger.debug('SimId:{}, Interaction being marked as transitioning:{}', self._sim.id, interaction) should_be_immediate = self._should_msg_be_immediate( self.QueueType.Super) if running_info_for_group is None or previous_visible_group_info_id is None: self._add_routing_interaction_info(int_info) if int_info.client_notified: interaction_messages.send_interactions_update_msg( self._sim, (int_info, ), should_be_immediate) else: interaction_messages.send_interactions_add_msg( self._sim, (int_info, ), should_be_immediate) int_info.client_notified = True else: visible_int_info = running_info_for_group.pop() if int_info.client_notified: if visible_int_info is int_info: self._update_mixers(previous_visible_group_info_id, visible_int_info.interaction_id) interaction_messages.send_interactions_remove_msg( self._sim, (int_info, ), should_be_immediate) if visible_int_info is int_info: interaction_messages.send_interaction_replace_message( self._sim, previous_visible_group_info_id, int_info, should_be_immediate) int_info.client_notified = True
def transferred_to_si_state(self, interaction): self._update_skillbar_info(interaction) if not interaction.visible: return int_info = None if interaction.is_super: for cur_info in self._running_interactions: if cur_info.interaction_id == interaction.id: int_info = cur_info break if int_info is None: for cur_info in self._queued_interactions: if cur_info.interaction_id != interaction.id: continue if interaction.is_super: self.running_transition(interaction) else: self._queued_interactions.remove(cur_info) if cur_info.super_id != 0: cur_info.super_id = self._get_visible_grouped_interaction_id( cur_info.super_id) or cur_info.super_id self._add_running_interaction(cur_info) int_info = cur_info break if int_info is None: logger.debug( 'SimId:{}, Interaction Transfer To SI State could not find interaction to update:{}', self._sim.id, interaction) return logger.debug( 'SimId:{}, Interaction Transfer To SI State being marked as running:{}', self._sim.id, interaction) int_info.ui_state = Sims_pb2.IQ_RUNNING (int_info.ui_visual_type, visual_type_data) = interaction.get_interaction_queue_visual_type() if visual_type_data.icon is not None: int_info.set_icon_info( IconInfoData(icon_resource=visual_type_data.icon)) if visual_type_data.tooltip_text is not None: int_info.display_name = interaction.create_localized_string( visual_type_data.tooltip_text) force_remove = int_info.ui_visual_type == Sims_pb2.Interaction.POSTURE self._remove_routing_interaction_info(int_info, force_remove=force_remove) if int_info.visual_group_tag is None or self._get_visible_grouped_interaction_id( int_info.interaction_id) == int_info.interaction_id: if int_info.client_notified: interaction_messages.send_interactions_update_msg( self._sim, (int_info, ), False) else: interaction_messages.send_interactions_add_msg( self._sim, (int_info, ), False) int_info.client_notified = True self._update_interaction_for_potential_cancel()
def add_running_mixer_interaction(self, si_id, mixer, icon_info, name): int_info = self._add_interaction(self._super_interactions, mixer, None, self.QueueType.Super) super_int_info_id = self._get_visible_grouped_interaction_id(si_id) int_info.super_id = super_int_info_id or si_id int_info.set_icon_info(icon_info) int_info.display_name = name int_info.ui_state = Sims_pb2.IQ_RUNNING interaction_messages.send_interactions_add_msg( self._sim, (int_info, ), self._should_msg_be_immediate(self.QueueType.Super))
def add_queued_interaction(self, interaction, interaction_id_to_insert_after=None, notify_client=True): if interaction.visual_continuation_id is not None and interaction.is_super: (interaction_info, _) = self._find_interaction(interaction.visual_continuation_id) if interaction_info is not None and interaction_info.ui_state != Sims_pb2.IQ_QUEUED: self.add_continuation_interaction(interaction) return logger.debug('SimId:{}, Interaction added to queue:{}', self._sim.id, interaction) int_info = self._add_interaction(self._queued_interactions, interaction, interaction_id_to_insert_after, self.QueueType.Queue) if interaction.visible and notify_client: interaction_messages.send_interactions_add_msg(self._sim, (int_info,), self._should_msg_be_immediate(self.QueueType.Queue)) int_info.client_notified = True
def _add_routing_interaction_info(self, routing_interaction_info): if self._routing_info.routing_owner_id is not None: return if self._any_interaction_of_visual_type(Sims_pb2.Interaction.POSTURE): return self._routing_info.routing_owner_id = routing_interaction_info.interaction_id self._routing_info.interactions_to_be_canceled.add( routing_interaction_info.interaction_id) self._add_running_interaction(self._routing_info) interaction_messages.send_interactions_add_msg( self._sim, (self._routing_info, ), self._should_msg_be_immediate(self.QueueType.Super))
def transferred_to_si_state(self, interaction): self._update_skillbar_info(interaction) if not interaction.visible: return int_info = None if interaction.is_super: for cur_info in self._running_interactions: while cur_info.interaction_id == interaction.id: int_info = cur_info break if int_info is None: for cur_info in self._queued_interactions: if cur_info.interaction_id != interaction.id: pass if interaction.is_super: self.running_transition(interaction) else: self._queued_interactions.remove(cur_info) if cur_info.super_id != 0: cur_info.super_id = self._get_visible_grouped_interaction_id(cur_info.super_id) or cur_info.super_id self._add_running_interaction(cur_info) int_info = cur_info break if int_info is None: logger.debug('SimId:{}, Interaction Transfer To SI State could not find interaction to update:{}', self._sim.id, interaction) return logger.debug('SimId:{}, Interaction Transfer To SI State being marked as running:{}', self._sim.id, interaction) int_info.ui_state = Sims_pb2.IQ_RUNNING (int_info.ui_visual_type, visual_type_data) = interaction.get_interaction_queue_visual_type() if visual_type_data.icon is not None: int_info.set_icon_info((visual_type_data.icon, None)) if visual_type_data.tooltip_text is not None: int_info.display_name = interaction.create_localized_string(visual_type_data.tooltip_text) force_remove = int_info.ui_visual_type == Sims_pb2.Interaction.POSTURE self._remove_routing_interaction_info(int_info, force_remove=force_remove) if int_info.visual_group_tag is None or self._get_visible_grouped_interaction_id(int_info.interaction_id) == int_info.interaction_id: if int_info.client_notified: interaction_messages.send_interactions_update_msg(self._sim, (int_info,), False) else: interaction_messages.send_interactions_add_msg(self._sim, (int_info,), False) int_info.client_notified = True self._update_interaction_for_potential_cancel()
def running_transition(self, interaction): if not interaction.visible: return interaction_id = interaction.id for int_info in self._continuation_interactions: if int_info.interaction_id != interaction_id: pass int_info.ui_state = Sims_pb2.IQ_TRANSITIONING int_info = None running_info_for_group = None previous_visible_group_info_id = None for (i, int_info) in enumerate(self._queued_interactions): if int_info.interaction_id != interaction_id: pass int_info.ui_state = Sims_pb2.IQ_TRANSITIONING next_index = i + 1 if next_index < len(self._queued_interactions): self._queued_interactions[next_index].insert_after_id = 0 previous_visible_group_info_id = self._get_visible_grouped_interaction_id(int_info.interaction_id) self._queued_interactions.remove(int_info) running_info_for_group = self._add_running_interaction(int_info) break logger.debug('SimId:{}, Interaction being marked as transitioning is not in queued interaction:{}', self._sim.id, interaction) return logger.debug('SimId:{}, Interaction being marked as transitioning:{}', self._sim.id, interaction) should_be_immediate = self._should_msg_be_immediate(self.QueueType.Super) if running_info_for_group is None or previous_visible_group_info_id is None: self._add_routing_interaction_info(int_info) if int_info.client_notified: interaction_messages.send_interactions_update_msg(self._sim, (int_info,), should_be_immediate) else: interaction_messages.send_interactions_add_msg(self._sim, (int_info,), should_be_immediate) int_info.client_notified = True else: visible_int_info = running_info_for_group.pop() if int_info.client_notified: if visible_int_info is int_info: self._update_mixers(previous_visible_group_info_id, visible_int_info.interaction_id) interaction_messages.send_interactions_remove_msg(self._sim, (int_info,), should_be_immediate) if visible_int_info is int_info: interaction_messages.send_interaction_replace_message(self._sim, previous_visible_group_info_id, int_info, should_be_immediate) int_info.client_notified = True
def add_queued_interaction(self, interaction, interaction_id_to_insert_after=None, notify_client=True): if interaction.visual_continuation_id is not None and interaction.is_super: (interaction_info, _) = self._find_interaction(interaction.visual_continuation_id) if interaction_info is not None and interaction_info.ui_state != Sims_pb2.IQ_QUEUED: self.add_continuation_interaction(interaction) return logger.debug('SimId:{}, Interaction added to queue:{}', self._sim.id, interaction) int_info = self._add_interaction(self._queued_interactions, interaction, interaction_id_to_insert_after, self.QueueType.Queue) if interaction.visible and notify_client: interaction_messages.send_interactions_add_msg( self._sim, (int_info, ), self._should_msg_be_immediate(self.QueueType.Queue)) int_info.client_notified = True
def remove_from_si_state(self, interaction): self._update_skillbar_info(interaction, from_remove=True) interaction_id = interaction.id if not interaction.visible: return logger.debug('SimId:{}, Interaction Remove From SI State attempting to remove:{}', self._sim.id, interaction) for cur_info in self._running_interactions: if interaction_id != cur_info.interaction_id: pass int_info = cur_info group_interactions = self._remove_running_interactions(int_info) continuation_info = self._find_continuation(int_info.interaction_id) if continuation_info: logger.debug('=== Continuation Replace In Remove: ({0} => {1})', int_info.interaction_id, continuation_info.interaction_id) if continuation_info.client_notified: logger.error('Trying to replace an interaction that client is already notified. {}, {}', int_info, continuation_info) else: if continuation_info.ui_state == Sims_pb2.IQ_TRANSITIONING: self._add_running_interaction(int_info) else: self._queued_interactions.insert(0, continuation_info) interaction = self._sim.queue.find_interaction_by_id(continuation_info.interaction_id) if interaction is not None and not interaction.get_sims_with_invalid_paths(): continuation_info.ui_state = Sims_pb2.IQ_TRANSITIONING interaction_messages.send_interaction_replace_message(self._sim, int_info.interaction_id, continuation_info, self._should_msg_be_immediate(self.QueueType.Super)) else: interaction_messages.send_interactions_remove_msg(self._sim, (int_info,), self._should_msg_be_immediate(self.QueueType.Super)) interaction_messages.send_interactions_add_msg(self._sim, (continuation_info,), self._should_msg_be_immediate(self.QueueType.Super)) continuation_info.client_notified = True for interaction_info in tuple(self._continuation_interactions): while interaction_info.source_id == interaction_id: if interaction_info.ui_state == Sims_pb2.IQ_TRANSITIONING: self._add_running_interaction(interaction_info) else: self._queued_interactions.insert(0, interaction_info) interaction_info.ui_state = Sims_pb2.IQ_TRANSITIONING self._continuation_interactions.remove(interaction_info) interaction_messages.send_interactions_add_msg(self._sim, (interaction_info,), self._should_msg_be_immediate(self.QueueType.Super)) interaction_info.client_notified = True else: logger.debug('=== SimId:{}, Sending Remove MSG for:{}', self._sim.id, interaction) self._remove_routing_interaction_info(int_info) self._update_routing_interaction_info(int_info) if self._last_running_interaction_id == int_info.interaction_id: self._last_running_interaction_id = 0 interaction_messages.send_interactions_remove_msg(self._sim, (int_info,), self._should_msg_be_immediate(self.QueueType.Super)) if group_interactions: interaction_messages.send_interactions_add_msg(self._sim, (group_interactions.pop(),), self._should_msg_be_immediate(self.QueueType.Super)) logger.debug('=== Interaction Remove(from SI state) requested on an interaction not in the running interaction list')
def remove_from_si_state(self, interaction): self._update_skillbar_info(interaction, from_remove=True) interaction_id = interaction.id if not interaction.visible: return logger.debug( 'SimId:{}, Interaction Remove From SI State attempting to remove:{}', self._sim.id, interaction) for cur_info in self._running_interactions: if interaction_id != cur_info.interaction_id: continue int_info = cur_info replace_id = self._get_visible_grouped_interaction_id( int_info.interaction_id) or int_info.interaction_id group_interactions = self._remove_running_interactions(int_info) continuation_info = self._find_continuation( int_info.interaction_id) if continuation_info: logger.debug( '=== Continuation Replace In Remove: ({0} => {1})', int_info.interaction_id, continuation_info.interaction_id) if continuation_info.client_notified: logger.error( 'Trying to replace an interaction that client is already notified. {}, {}', int_info, continuation_info) else: if continuation_info.ui_state == Sims_pb2.IQ_TRANSITIONING: self._add_running_interaction(continuation_info) else: self._queued_interactions.insert(0, continuation_info) interaction = self._sim.queue.find_interaction_by_id( continuation_info.interaction_id) if interaction is not None and not interaction.get_sims_with_invalid_paths( ): continuation_info.ui_state = Sims_pb2.IQ_TRANSITIONING interaction_messages.send_interaction_replace_message( self._sim, replace_id, continuation_info, self._should_msg_be_immediate( self.QueueType.Super)) continuation_info.client_notified = True for interaction_info in tuple( self._continuation_interactions): if interaction_info.source_id == interaction_id: if interaction_info.ui_state == Sims_pb2.IQ_TRANSITIONING: self._add_running_interaction(interaction_info) else: self._queued_interactions.insert( 0, interaction_info) interaction_info.ui_state = Sims_pb2.IQ_TRANSITIONING self._continuation_interactions.remove( interaction_info) interaction_messages.send_interactions_add_msg( self._sim, (interaction_info, ), self._should_msg_be_immediate( self.QueueType.Super)) interaction_info.client_notified = True else: logger.debug('=== SimId:{}, Sending Remove MSG for:{}', self._sim.id, interaction) self._remove_routing_interaction_info(int_info) self._update_routing_interaction_info(int_info) if self._last_running_interaction_id == int_info.interaction_id: self._last_running_interaction_id = 0 interaction_messages.send_interactions_remove_msg( self._sim, (int_info, ), self._should_msg_be_immediate(self.QueueType.Super)) if group_interactions: interaction_messages.send_interactions_add_msg( self._sim, (group_interactions.pop(), ), self._should_msg_be_immediate(self.QueueType.Super)) return if self._remove_continuation_interaction(interaction.id): logger.debug( 'SimId:{}, Interaction Remove(from si_state) is being removed from continuation list:{}', self._sim.id, interaction) return logger.debug( '=== Interaction Remove(from SI state) requested on an interaction not in the running interaction list' )