public void ChangeSelectedProcess(int processIndex) { if (foregroundProcess != null) { foregroundProcess.inputEntities.ChangeAny -= UpdateUI; foregroundProcess.nonHumanEntities.ChangeAny -= UpdateUI; foregroundProcess.OnFinishProgressEvent -= UpdateUI; } foregroundProcess = GetConnected <Processor>().GetProcess(processIndex); SubscribableList <UseableEntity> input = foregroundProcess.inputEntities; SubscribableList <UseableEntity> output = foregroundProcess.nonHumanEntities; inputListUI.Init(input); nonHumanListUI.Init(output); input.ChangeAny += UpdateUI; output.ChangeAny += UpdateUI; foregroundProcess.OnFinishProgressEvent += UpdateUI; progressBarUI.Init(foregroundProcess); startButton.onClick.RemoveAllListeners(); startButton.onClick.AddListener(TryStartCurrentProcess); loopToggle.onValueChanged.RemoveAllListeners(); loopToggle.onValueChanged.AddListener(foregroundProcess.SetLoop); uIHeaderProcesses.HighlightElement = processIndex; UpdateUI(); }
/// <summary> /// Initialize the visualization by saving the list and subscribing to change events. /// </summary> /// <param name="obj">the object to connect with.</param> public virtual void Init(SubscribableList <T> obj) { //hide visualized elements that were there before HideAll(); connectedList = obj; connectedList.Change += OnChange; connectedList.ChangeAdd += OnChangeAdd; connectedList.ChangeRemove += OnChangeRemove; foreach (T item in connectedList) { OnChangeAdd(item); } }
public void InitToList(SubscribableList <T> list, T source, System.Action <UIListElement <T> > clickAction, params IUIConnectable[] connectables) { Debug.Log("create new element with " + connectables.Length + " connectables."); List = list; OnClick = clickAction; foreach (IUIConnectable connectable in connectables) { connectable.UpdateUI(source); if (connectable as IUIClickable != null) { (connectable as IUIClickable).SetClickMethod(ClickedOn); } this.connectables.Add(connectable); } Source = source; }
public UseableEntity[] GetToRemove(SubscribableList <UseableEntity> inputEntities) { List <UseableEntity> toRemove = new List <UseableEntity>(); List <string> inputToRemove = new List <string>(); foreach (var item in input.Where(d => !d.allwaysOutput)) { inputToRemove.Add(item.entity.type); } foreach (UseableEntity input in inputEntities) { string inputType = input.GetData().type; if (inputToRemove.Contains(inputType)) { inputToRemove.Remove(inputType); toRemove.Add(input); } } return(toRemove.ToArray()); }
public bool IsDifferentList(SubscribableList <T> list) { return(connectedList != list); }