def show_festival_info(cls): if cls.festival_dynamic_sign_info is None: return ui_info = cls.festival_dynamic_sign_info festival_info = UI_pb2.DynamicSignView() festival_info.drama_node_guid = cls.guid64 festival_info.name = ui_info.festival_name lot_id = cls.get_travel_lot_id() persistence_service = services.get_persistence_service() zone_id = persistence_service.resolve_lot_id_into_zone_id(lot_id, ignore_neighborhood_id=True) zone_protobuff = persistence_service.get_zone_proto_buff(zone_id) if zone_protobuff is not None: festival_info.venue = LocalizationHelperTuning.get_raw_text(zone_protobuff.name) festival_info.time = ui_info.festival_time festival_info.image = sims4.resources.get_protobuff_for_key(ui_info.display_image) festival_info.background_image = sims4.resources.get_protobuff_for_key(ui_info.background_image) festival_info.action_label = ui_info.travel_to_festival_text running_nodes = services.drama_scheduler_service().get_running_nodes_by_class(cls) active_sim_info = services.active_sim_info() if all(active_node.is_during_pre_festival() for active_node in running_nodes): festival_info.disabled_tooltip = ui_info.festival_not_started_tooltip elif any(active_node.is_on_festival_street() for active_node in running_nodes): festival_info.disabled_tooltip = ui_info.on_street_tooltip elif active_sim_info.is_in_travel_group(): festival_info.disabled_tooltip = ui_info.on_vacation_tooltip for activity in ui_info.activity_info: with ProtocolBufferRollback(festival_info.activities) as activity_msg: activity_msg.name = activity.activity_name activity_msg.description = activity.activity_description activity_msg.icon = create_icon_info_msg(IconInfoData(activity.icon)) distributor = Distributor.instance() distributor.add_op(active_sim_info, GenericProtocolBufferOp(Operation.DYNAMIC_SIGN_VIEW, festival_info))
def perform(self, subject, target, resolver): if subject is None: logger.error( 'Trying to perform UniversityDynamicSignView op but subject is None. Resolver {}.', resolver) return if not subject.is_sim: logger.error( 'Trying to perform UniversityDynamicSignView op but subject {} is not Sim. Resolver {}.', subject, resolver) return sign_info = UI_pb2.DynamicSignView() sign_info.name = self.title sign_info.image = sims4.resources.get_protobuff_for_key( self.display_image) sign_info.background_image = sims4.resources.get_protobuff_for_key( self.background_image) for sub_info in self.sub_infos: with ProtocolBufferRollback( sign_info.activities) as activity_msg: activity_msg.name = sub_info.name activity_msg.description = sub_info.desc.get_string( subject.sim_info) activity_msg.icon = create_icon_info_msg( IconInfoData(sub_info.icon)) distributor = Distributor.instance() distributor.add_op( subject.sim_info, GenericProtocolBufferOp(Operation.DYNAMIC_SIGN_VIEW, sign_info))
def unlock_save(self, lock_holder, send_event=True): if lock_holder in self._save_locks: self._save_locks.remove(lock_holder) if send_event: if not self.is_save_locked(): msg = UI_pb2.GameSaveLockUnlock() msg.is_locked = False distributor = Distributor.instance() distributor.add_event(MSG_GAME_SAVE_LOCK_UNLOCK, msg) else: new_lock_holder = self._save_locks[-1] msg = UI_pb2.GameSaveLockUnlock() msg.is_locked = True msg.lock_reason = new_lock_holder.get_lock_save_reason() distributor = Distributor.instance() distributor.add_event(MSG_GAME_SAVE_LOCK_UNLOCK, msg)
def lock_save(self, lock_holder): self._save_locks.append(lock_holder) msg = UI_pb2.GameSaveLockUnlock() msg.is_locked = True msg.lock_reason = lock_holder.get_lock_save_reason() distributor = Distributor.instance() distributor.add_event(MSG_GAME_SAVE_LOCK_UNLOCK, msg)
def handle_community_board(community_board_response: str, _connection=None): proto = UI_pb2.CommunityBoardResponse() text_format.Merge(community_board_response, proto) sim_info = services.sim_info_manager().get(proto.sim_id) if sim_info is None: return if proto.provider_type == StreetProvider.provider_type_id: street_civic_policy_service = services.street_service() if street_civic_policy_service is None: sims4.commands.automation_output('Pack not loaded', _connection) sims4.commands.cheat_output('Pack not loaded', _connection) return world_id = sim_info.household.get_home_world_id() street = world.street.get_street_instance_from_world_id(world_id) provider = street_civic_policy_service.get_provider(street) else: source_venue = services.venue_service().source_venue if source_venue is None: return provider = source_venue.civic_policy_provider if provider is not None: for policy in proto.balloted_policies: policy_instance = provider.get_policy_instance_for_tuning( policy.policy_id) if policy_instance is None: continue provider.add_to_ballot(policy_instance) provider.vote_by_instance(policy_instance, policy.count, user_directed=True) provider.modify_influence(sim_info, -proto.influence_points) provider.handle_vote_interaction(sim_info, proto.target_id, bool(proto.balloted_policies))
def _send_lock_save_message(self, reason_provider): distributor = Distributor.instance() if distributor is not None and distributor.client is not None: msg = UI_pb2.GameSaveLockUnlock() msg.is_locked = True msg.lock_reason = reason_provider() distributor.add_event(MSG_GAME_SAVE_LOCK_UNLOCK, msg)
def display_scholarship_info(self, subject): if self.SCHOLARSHIP_INFORMATION_SIGN.display_image is None or self.SCHOLARSHIP_INFORMATION_SIGN.background_image is None: logger.error( 'Attempting to show scholarship sign to ({}) when content is None.', subject) return sign_info = UI_pb2.DynamicSignView() sign_info.name = self.SCHOLARSHIP_INFORMATION_SIGN.title sign_info.image = sims4.resources.get_protobuff_for_key( self.SCHOLARSHIP_INFORMATION_SIGN.display_image) sign_info.background_image = sims4.resources.get_protobuff_for_key( self.SCHOLARSHIP_INFORMATION_SIGN.background_image) for sub_info in self.SCHOLARSHIP_INFORMATION_SIGN.sub_infos: with ProtocolBufferRollback(sign_info.activities) as activity_msg: if sub_info.icon is None: logger.error( 'Attempting to show scholarship sign to ({}) when sub_info icon is None.', subject) continue activity_msg.name = sub_info.name activity_msg.description = sub_info.desc activity_msg.icon = create_icon_info_msg( IconInfoData(sub_info.icon)) distributor = Distributor.instance() distributor.add_op( subject.sim_info, GenericProtocolBufferOp(Operation.DYNAMIC_SIGN_VIEW, sign_info)) services.get_event_manager().process_event( TestEvent.ScholarshipInfoSignShown, sim_info=subject)
def open_ui_panel(self, obj): if not self._allow_ui: return False msg = UI_pb2.OpenInventory() msg.object_id = obj.id msg.inventory_id = self._get_inventory_id() msg.inventory_type = self._get_inventory_ui_type() op = GenericProtocolBufferOp(Operation.OPEN_INVENTORY, msg) Distributor.instance().add_op_with_no_owner(op) return True
def _send_calendary_entry(self, drama_node, update_type): if drama_node.ui_display_type == DramaNodeUiDisplayType.ALERTS_ONLY: return calendar_entry = drama_node.create_calendar_entry() calendar_msg = UI_pb2.CalendarUpdate() calendar_msg.updated_entry = calendar_entry calendar_msg.update_type = update_type op = GenericProtocolBufferOp(Operation.MSG_CALENDAR_UPDATE, calendar_msg) Distributor.instance().add_op_with_no_owner(op)
def send_markup_multiplier_message(self): if not self.is_active_household_and_zone(): return markup_msg = UI_pb2.RetailMarkupMultiplierMessage() for markup_multiplier in self.tuning_data.markup_multiplier_data: with ProtocolBufferRollback(markup_msg.markup_multipliers) as multiplier_entry: multiplier_entry.name = markup_multiplier.name multiplier_entry.multiplier = markup_multiplier.markup_multiplier multiplier_entry.is_selected = markup_multiplier.markup_multiplier == self._markup_multiplier op = distributor.shared_messages.create_message_op(markup_msg, Consts_pb2.MSG_RETAIL_MARKUP_MULTIPLIER) Distributor.instance().add_op_with_no_owner(op)
def save_game_gen(self, timeline, save_game_data, send_save_message=True, check_cooldown=False): (result_code, failure_reason) = yield self._save_game_gen(timeline, save_game_data, check_cooldown=check_cooldown) if send_save_message: msg = UI_pb2.GameSaveComplete() msg.return_status = result_code msg.save_cooldown = self._get_cooldown() if failure_reason is not None: msg.failure_reason = failure_reason msg.slot_id = save_game_data.slot_id distributor = Distributor.instance() distributor.add_event(MSG_GAME_SAVE_COMPLETE, msg) return result_code
def build_msg(self, additional_tokens=(), icon_override=DEFAULT, event_id=None, **kwargs): msg = UI_pb2.ShowMapView() msg.actor_sim_id = self.owner.id if self.traveling_sims is not None: msg.traveling_sim_ids.extend( [sim.id for sim in self.traveling_sims]) msg.lot_ids_for_travel.extend( [row.zone_id for row in self.picker_rows]) msg.dialog_id = self.dialog_id return msg
def get_owned_retail_lot_count_message(_connection=None): lot_count = 0 active_household = services.active_household() if active_household is not None: retail_tracker = services.business_service( ).get_business_tracker_for_household(active_household.id, BusinessType.RETAIL) if retail_tracker is not None: lot_count = len(retail_tracker.business_managers) lot_count_msg = UI_pb2.OwnedRetailLotCountMessage() lot_count_msg.owned_lot_count = lot_count op = shared_messages.create_message_op( lot_count_msg, Consts_pb2.MSG_RETAIL_OWNED_LOT_COUNT) Distributor.instance().add_op_with_no_owner(op)
def get_household_display_info(lot_id, _connection=None): persistence_service = services.get_persistence_service() household_display_info = UI_pb2.HouseholdDisplayInfo() household_id = persistence_service.get_household_id_from_lot_id(lot_id) if household_id is None: household_id = 0 household = services.household_manager().get(household_id) if household is None: household_id = 0 else: household_display_info.at_home_sim_ids.extend( household.get_sims_at_home()) household_display_info.household_id = household_id household_display_info.lot_id = lot_id op = shared_messages.create_message_op( household_display_info, Consts_pb2.MSG_UI_HOUSEHOLD_DISPLAY_INFO) Distributor.instance().add_op_with_no_owner(op)
def send_collection_msg(self, msg_type, collectable_id, household_id, obj_def_id, obj_id=None): msg = UI_pb2.CollectibleItemUpdate() msg.type = msg_type msg.collection_id = collectable_id msg.household_id = household_id if obj_id is not None: msg.object_id = obj_id msg.object_def_id = obj_def_id distributor = Distributor.instance() distributor.add_op_with_no_owner( GenericProtocolBufferOp(Operation.SIM_COLLECTIBLE_ITEM_UPDATE, msg))
def sim_inventory_sell_multiple(msg:str, _connection=None): proto = UI_pb2.InventorySellRequest() text_format.Merge(msg, proto) if proto is None: return sim_info = services.sim_info_manager().get(proto.sim_id) if sim_info is None: return inventory_component = sim_info.get_sim_instance().inventory_component if inventory_component is None: return sell_value = 0 objs = [] inventory_stack_items = inventory_component.get_stack_items_map(proto.stacks) if proto.stacks is not None: for stack_id in proto.stacks: stack_items = inventory_stack_items.get(stack_id, None) if stack_items is None: continue for item in stack_items: if item.non_deletable_by_user: break sell_value += item.current_value*item.stack_count() objs.append(item) if proto.items is not None: inventory_manager = services.inventory_manager() for item_data in proto.items: if item_data not in inventory_component: continue item = inventory_manager.get(item_data.id) if item is None: continue if item.non_deletable_by_user: continue sell_value += item.current_value*item_data.count item.update_stack_count(-item_data.count) if item.stack_count() < 1: objs.append(item) else: inventory_component.push_inventory_item_update_msg(item) if objs: services.active_household().funds.add(sell_value, Consts_pb2.TELEMETRY_OBJECT_SELL, sim_info) services.get_reset_and_delete_service().trigger_batch_destroy(objs) op = SendUIMessage('InventorySellItemsComplete') Distributor.instance().add_op_with_no_owner(op)
def send_travel_view_household_info(_connection=None): msg = UI_pb2.TravelViewHouseholdsInfo() for household in tuple(services.household_manager().values()): with ProtocolBufferRollback( msg.household_locations) as household_location_data: household_location_data.household_id = household.id household_location_data.household_name = household.name household_location_data.home_zone_id = household.home_zone_id for sim_info in household: with ProtocolBufferRollback( household_location_data.sim_info_status ) as sim_info_location_status: sim_info_location_status.sim_id = sim_info.id sim_info_location_status.age = sim_info.age sim_info_location_status.is_at_home = sim_info.is_at_home distributor = Distributor.instance() distributor.add_op_with_no_owner( GenericProtocolBufferOp(Operation.TRAVEL_VIEW_HOUSEHOLDS_INFO, msg))
def generate_notebook_information(self, initial_selected_category=None): msg = UI_pb2.NotebookView() if self._notebook_entries: ingredient_cache = StartCraftingMixin.get_default_candidate_ingredients(self._owner.get_sim_instance()) for (index, category_id) in enumerate(self._notebook_entry_catsubcat_cache.keys()): if initial_selected_category is not None: if category_id == initial_selected_category: msg.selected_category_index = index with ProtocolBufferRollback(msg.categories) as notebook_category_message: category_tuning = NotebookTuning.NOTEBOOK_CATEGORY_MAPPING[category_id] notebook_category_message.category_name = category_tuning.category_name if category_tuning.category_description is not None: notebook_category_message.category_description = category_tuning.category_description notebook_category_message.category_icon = create_icon_info_msg(IconInfoData(icon_resource=category_tuning.category_icon)) valid_subcategories = self._notebook_entry_catsubcat_cache[category_id] for subcategory_id in valid_subcategories: with ProtocolBufferRollback(notebook_category_message.subcategories) as notebook_subcategory_message: subcategory_tuning = category_tuning.subcategories[subcategory_id] notebook_subcategory_message.subcategory_id = subcategory_id notebook_subcategory_message.subcategory_name = subcategory_tuning.subcategory_name notebook_subcategory_message.subcategory_icon = create_icon_info_msg(IconInfoData(icon_resource=subcategory_tuning.subcategory_icon)) notebook_subcategory_message.subcategory_tooltip = subcategory_tuning.subcategory_tooltip notebook_subcategory_message.entry_type = subcategory_tuning.format_type if subcategory_tuning.show_max_entries is not None: notebook_subcategory_message.max_num_entries = subcategory_tuning.show_max_entries if subcategory_tuning.is_sortable is None: notebook_subcategory_message.is_sortable = False notebook_subcategory_message.is_new_entry_sortable = False else: notebook_subcategory_message.is_sortable = True notebook_subcategory_message.is_new_entry_sortable = subcategory_tuning.is_sortable.include_new_entry subcategory_entries = self._notebook_entries[subcategory_id] for entry in reversed(subcategory_entries): if entry is None: continue if entry.is_definition_based(): definition_data = entry.get_definition_notebook_data(ingredient_cache=ingredient_cache) if definition_data is not None: self._fill_notebook_entry_data(notebook_subcategory_message, subcategory_tuning, definition_data, entry.entry_object_definition_id, True, entry.new_entry) else: self._fill_notebook_entry_data(notebook_subcategory_message, subcategory_tuning, entry, entry.entry_object_definition_id, False, entry.new_entry) entry.new_entry = False op = GenericProtocolBufferOp(Operation.NOTEBOOK_VIEW, msg) Distributor.instance().add_op(self._owner, op)
def _get_interrogation_op(self, msg_type): if self._target_sim is None or self._initiating_sim is None: return if self._interrogation_callback is None: self._initialize_interrogate_group() stat_tracker = self._initiating_sim.get_tracker(self.interrogation_statistic) stat_instance = stat_tracker.get_statistic(self.interrogation_statistic) if stat_instance is None: decay_rate = 0 stat_value = 0 else: decay_rate = stat_instance.get_change_rate() stat_value = stat_instance._value interrogation_update = UI_pb2.InterrogationProgressUpdate() interrogation_update.type = msg_type interrogation_update.target_id = self._target_sim.id interrogation_update.value = stat_value interrogation_update.decay_rate = decay_rate return GenericProtocolBufferOp(DistributorOps_pb2.Operation.INTERROGATION_PROGRESS_UPDATE, interrogation_update)
def get_sims_available_for_travel(opt_sim_id: OptionalTargetParam = None, _connection=None): actor_sim = get_optional_target(opt_sim_id, _connection) if actor_sim is not None: actor_sim_info = actor_sim.sim_info else: if not opt_sim_id: sims4.commands.output( 'No sim_info id specified for travel.get_sims_available', _connection) return False actor_sim_info = services.sim_info_manager().get(opt_sim_id) if actor_sim_info is None: sims4.commands.output('Invalid sim_info id: {}'.format(opt_sim_id), _connection) return False sim_filter = TravelTuning.TRAVEL_AVAILABILITY_SIM_FILTER filtered_sims = services.sim_filter_service().submit_filter( sim_filter, None, sim_constraints=None, requesting_sim_info=actor_sim_info, blacklist_sim_ids=EMPTY_SET, allow_yielding=False) msg = UI_pb2.AvailableSimsForTravel() msg.actor_sim_id = actor_sim_info.id msg.sim_ids_for_travel.extend( [filter_result.sim_info.id for filter_result in filtered_sims]) active_household_id = services.active_household_id() for filter_result in filtered_sims: with ProtocolBufferRollback(msg.available_sims) as sim_data: sim_info = filter_result.sim_info sim_data.sim_id = sim_info.id sim_data.is_active_household = sim_info.household_id == active_household_id sim_data.household_id = sim_info.household_id sim_data.is_at_work = sim_info.career_tracker.currently_at_work sim_data.zone_id = sim_info.zone_id sim_data.age = sim_info.age op = shared_messages.create_message_op( msg, Consts_pb2.MSG_AVAILABLE_SIMS_FOR_TRAVEL) Distributor.instance().add_op_with_no_owner(op) return True
def send_travel_view_household_info(_connection=None): msg = UI_pb2.TravelViewHouseholdsInfo() for household in tuple(services.household_manager().values()): with ProtocolBufferRollback(msg.household_locations) as household_location_data: household_location_data.household_id = household.id household_location_data.household_name = household.name household_location_data.home_zone_id = household.home_zone_id household_location_data.is_played = household.is_player_household for sim_info in household: with ProtocolBufferRollback(household_location_data.sim_info_status) as sim_info_location_status: sim_info_location_status.sim_id = sim_info.id sim_info_location_status.age = sim_info.age sim_info_location_status.is_at_home = sim_info.is_at_home sim_info_location_status.zone_id = sim_info.zone_id distributor = Distributor.instance() distributor.add_op_with_no_owner(GenericProtocolBufferOp(Operation.TRAVEL_VIEW_HOUSEHOLDS_INFO, msg)) travel_group_list_msg = FileSerialization_pb2.TravelGroupList() for travel_group in tuple(services.travel_group_manager().values()): with ProtocolBufferRollback(travel_group_list_msg.travel_groups) as travel_group_data: travel_group.save_data(travel_group_data) distributor.add_op_with_no_owner(GenericProtocolBufferOp(Operation.TRAVEL_GROUP_LIST, travel_group_list_msg))
def send_lot_display_info(self): lot_name = self.get_lot_name() household = self.get_household() if household is not None: owner_household_name = household.name else: owner_household_name = None msg = UI_pb2.LotDisplayInfo() if lot_name is not None: msg.lot_name = lot_name if owner_household_name is not None: msg.household_name = owner_household_name zone_modifier_display_infos = services.get_zone_modifier_service( ).get_zone_modifier_display_infos(self.zone_id) for display_info in zone_modifier_display_infos: msg.icon_infos.append( create_icon_info_msg( IconInfoData( icon_resource=display_info.zone_modifier_icon))) op = distributor.shared_messages.create_message_op( msg, Consts_pb2.MSG_UI_LOT_DISPLAY_INFO) Distributor.instance().add_op_with_no_owner(op)
def send_lot_display_info(self): persistence = services.get_persistence_service() lot_owner_data = persistence.get_lot_proto_buff(self.lot_id) lot_name = None if lot_owner_data is not None: zone_data = persistence.get_zone_proto_buff( lot_owner_data.zone_instance_id) if zone_data is not None: lot_name = zone_data.name household = self.get_household() if household is not None: owner_household_name = household.name else: owner_household_name = None msg = UI_pb2.LotDisplayInfo() if lot_name is not None: msg.lot_name = lot_name if owner_household_name is not None: msg.household_name = owner_household_name op = distributor.shared_messages.create_message_op( msg, Consts_pb2.MSG_UI_LOT_DISPLAY_INFO) Distributor.instance().add_op_with_no_owner(op)
def show_extend_vacation_dialog(self): if services.current_zone().ui_dialog_service.auto_respond: self.end_vacation() else: msg = UI_pb2.ExtendVacation() msg.travel_group_id = self.id msg.zone_id = self.zone_id for sim_info in self: msg.sim_ids.append(sim_info.id) delta_time = self.end_timestamp - services.time_service().sim_now delta_time = delta_time if delta_time > TimeSpan.ZERO else TimeSpan.ZERO days_remaining = float(delta_time.in_days()) msg.days_remaining = days_remaining persistence_service = services.get_persistence_service() zone_data = persistence_service.get_zone_proto_buff(self.zone_id) msg.household_description_id = persistence_service.get_house_description_id( self.zone_id) msg.lot_name = zone_data.name msg.lot_daily_cost = services.current_zone( ).lot.furnished_lot_value op = shared_messages.create_message_op( msg, Consts_pb2.MSG_EXTEND_VACATION) Distributor.instance().add_op_with_no_owner(op)
def load_data(self, household_msg): self._collections.clear() if self.owner.all_sims_skip_load(): return for collection in household_msg.gameplay_data.collection_data: base = ObjectCollectionData.is_base_object_of_collection( collection.collectible_def_id, collection.collection_id) fallback_definition_id = build_buy.get_vetted_object_defn_guid( 0, collection.collectible_def_id) if fallback_definition_id != collection.collectible_def_id: continue if collection.HasField('icon_info'): icon_info = ui_protocols.IconInfo() icon_info.CopyFrom(collection.icon_info) else: icon_info = None collection_tracker_data = CollectionTrackerData( collection.collection_id, collection.new, base, quality=collection.quality, icon_info=icon_info) self._collections[ collection.collectible_def_id] = collection_tracker_data
def _get_inventory_update_message(self, update_type, obj, obj_id=None, allow_while_zone_not_running=False): if not self._allow_ui: return if not services.current_zone( ).is_zone_running and not allow_while_zone_not_running: return if services.current_zone().is_zone_shutting_down: return msg = UI_pb2.InventoryItemUpdate() msg.type = update_type msg.inventory_id = self._get_inventory_id() msg.inventory_type = self._get_inventory_ui_type() msg.stack_id = obj.inventoryitem_component.get_stack_id() if obj_id is None: msg.object_id = obj.id else: msg.object_id = obj_id if update_type == UI_pb2.InventoryItemUpdate.TYPE_ADD: add_data = UI_pb2.InventoryItemData() add_data.definition_id = obj.definition.id msg.add_data = add_data if update_type == UI_pb2.InventoryItemUpdate.TYPE_ADD or update_type == UI_pb2.InventoryItemUpdate.TYPE_UPDATE: dynamic_data = UI_pb2.DynamicInventoryItemData() dynamic_data.value = obj.current_value dynamic_data.count = obj.stack_count() dynamic_data.new_object_id = obj.id dynamic_data.is_new = obj.new_in_inventory dynamic_data.sort_order = obj.get_stack_sort_order() icon_info = obj.get_icon_info_data() build_icon_info_msg(icon_info, None, dynamic_data.icon_info) recipe_name = obj.get_tooltip_field( TooltipFieldsComplete.recipe_name ) or obj.get_craftable_property(GameObjectProperty.RECIPE_NAME) if recipe_name is not None: dynamic_data.recipe_name = recipe_name if obj.custom_name is not None: dynamic_data.custom_name = obj.custom_name if InventoryStorage.UI_SORT_TYPES: sort_type = 0 for sort_type_data in InventoryStorage.UI_SORT_TYPES: value = None try: abs_value = None state_component = obj.state_component if state_component is None: continue for state in sort_type_data.object_data: if state_component.has_state(state): test_value = float( state_component.get_state(state).value) abs_test_value = abs(test_value) if value is None: value = test_value elif abs_value < abs_test_value: value = test_value abs_value = abs_test_value except TypeError: pass if value is not None: sort_data_item = UI_pb2.InventoryItemSortData() sort_data_item.type = sort_type sort_data_item.value = value dynamic_data.sort_data.append(sort_data_item) sort_type += 1 if update_type == UI_pb2.InventoryItemUpdate.TYPE_ADD: msg.add_data.dynamic_data = dynamic_data else: msg.update_data = dynamic_data if update_type == UI_pb2.InventoryItemUpdate.TYPE_SET_STACK_OPTION: dynamic_data = UI_pb2.DynamicInventoryItemData() if obj.inventoryitem_component.has_stack_option: obj.inventoryitem_component.populate_stack_icon_info_data( dynamic_data.icon_info) obj_owner = obj.inventoryitem_component.get_inventory().owner if obj_owner.is_sim: favorites_tracker = obj_owner.sim_info.favorites_tracker if favorites_tracker is not None: if favorites_tracker.is_favorite_stack(obj): dynamic_data.is_favorite = True msg.update_data = dynamic_data return msg
def __init__(self, msg_type, target_id, value=None): super().__init__() self.op = UI_pb2.ObjectRelationshipUpdate() self.op.type = msg_type self.op.target_id = target_id self.op.value = value
def __init__(self, season_type, season_content): super().__init__() self.op = UI_pb2.SeasonUpdate() self.op.season_type = season_type.value self.op.season_guid = season_content.guid64 self.op.season_start_time = season_content.start_time
def _send_unlock_save_message(self): distributor = Distributor.instance() if distributor is not None and distributor.client is not None: msg = UI_pb2.GameSaveLockUnlock() msg.is_locked = False distributor.add_event(MSG_GAME_SAVE_LOCK_UNLOCK, msg)