private ENUM_SELECT_TYPE RefreshOfficers(List <UIOfficerInfo> officers_, GameLoopUIContainer grid_, ENUM_SELECT_TYPE selected_type_) { int totalCount = officers_.Count; grid_.EnsureSize <ToggleIconItem>(totalCount); ENUM_SELECT_TYPE cur_type = selected_type_; if (0 == totalCount) { grid_.Visible = false; return(cur_type); } grid_.Visible = true; for (int i = 0; i < totalCount; i++) { ConfOfficer prop = officers_[i].m_data; ToggleIconItem toggle_item = grid_.GetChild <ToggleIconItem>(i); toggle_item.Visible = false; toggle_item.Visible = true; bool be_selected = false; if (ENUM_SELECT_TYPE.NONE == cur_type) { be_selected = 0 == i; } else if (ENUM_SELECT_TYPE.SELECTED == cur_type) { be_selected = false; } else if (ENUM_SELECT_TYPE.RESELECT == cur_type) { be_selected = prop.id == this.m_choose_officer_id; } if (be_selected && ENUM_SELECT_TYPE.SELECTED != cur_type) { cur_type = ENUM_SELECT_TYPE.SELECTED; } toggle_item.Refresh(i, prop.icon, prop.id, be_selected, (clicked_, index_) => { if (clicked_) { if (-1 != this.m_last_choose_officer_id) { EngineCoreEvents.AudioEvents.PlayAudio.SafeInvoke(Audio.AudioType.UISound, EngineCommonAudioKey.table_change.ToString()); } OnPoliceItemClicked(index_); } }, null); toggle_item.LockVisible = 0 == officers_[i].m_lvl; } return(cur_type); }
private Transform GetPoliceItemById(long id) { for (int i = 0; i < m_lock_grid.ChildCount; i++) { ToggleIconItem iconItem = m_lock_grid.GetChild <ToggleIconItem>(i); if (iconItem != null) { if ((long)iconItem.Info == id) { return(iconItem.Widget); } } } return(null); }