private void RecountRows(TimeableList <BudgetEntryXml> config, int?stopsCount) { UVMBudgetEditorLine[] currentLines = m_entryListContainer.GetComponentsInChildren <UVMBudgetEditorLine>(); m_timeRows = new List <UVMBudgetEditorLine>(); int count = 0; for (int i = 0; i < stopsCount; i++, count++) { if (i < currentLines.Length) { currentLines[i].SetLegendInfo(GetColorForNumber(i)); m_timeRows.Add(currentLines[i]); currentLines[i].Entry = config[i]; } else { UVMBudgetEditorLine line = KlyteMonoUtils.CreateElement <UVMBudgetEditorLine>(m_entryListContainer.transform); line.Entry = config[i]; line.SetLegendInfo(GetColorForNumber(i)); line.OnTimeChanged += ValidateTime; line.OnDie += RemoveTime; line.OnBudgetChanged += SetBudget; m_timeRows.Add(line); } } for (int i = count; i < currentLines.Length; i++) { GameObject.Destroy(currentLines[i].gameObject); } }
private void RedrawList() { uint[] values = new uint[m_timeRows.Count]; bool invalid = false; for (int i = 0; i < m_timeRows.Count; i++) { UVMBudgetEditorLine textField = m_timeRows[i]; if (!uint.TryParse(textField.GetCurrentVal(), out uint res) || res < 0 || res > 23) { textField.SetTextColor(Color.red); values[i] = 1000; invalid = true; } else { textField.SetTextColor(Color.white); values[i] = res; } } if (!invalid) { var sortedValues = new List <uint>(values); sortedValues.Sort(); var updateInfo = new List <Tuple <int, int, Color, UVMBudgetEditorLine> >(); for (int i = 0; i < m_timeRows.Count; i++) { int zOrder = sortedValues.IndexOf(values[i]); updateInfo.Add(Tuple.New(zOrder, (int)values[i], GetColorForNumber(i), m_timeRows[i])); } updateInfo.Sort((x, y) => x.First - y.First); for (int i = 0; i < updateInfo.Count; i++) { float start = updateInfo[i].Second; float end = updateInfo[(i + 1) % updateInfo.Count].Second; if (end < start) { end += 24; } float angle = (start + end) / 2f; updateInfo[i].Fourth.ZOrder = updateInfo[i].First; } m_clockChart.SetValues(updateInfo.Select(x => Tuple.New(x.Second, x.Third, x.Fourth.Entry.Value)).ToList()); } }