Exemplo n.º 1
0
        private void RebuildList()
        {
            AdrAzimuthEditorLineNeighbor[] currentLines = m_uiHelperNeighbors.Self.GetComponentsInChildren <AdrAzimuthEditorLineNeighbor>();
            int stopsCount = AdrNeighborhoodExtension.GetStopsCount();

            if (stopsCount == 0)
            {
                stopsCount = 1;
            }

            m_borderCities = new List <AdrAzimuthEditorLineNeighbor>();
            int count = 0;

            for (int i = 0; i < stopsCount; i++, count++)
            {
                if (i < currentLines.Length)
                {
                    currentLines[i].SetLegendInfo(GetColorForNumber(i), i + 1);
                    m_borderCities.Add(currentLines[i]);
                }
                else
                {
                    AdrAzimuthEditorLineNeighbor line = KlyteMonoUtils.CreateElement <AdrAzimuthEditorLineNeighbor>(m_uiHelperNeighbors.Self.transform);
                    line.SetLegendInfo(GetColorForNumber(i), i + 1);
                    line.OnValueChange += ValidateAngleStr;
                    m_borderCities.Add(line);
                }
            }
            for (int i = count; i < currentLines.Length; i++)
            {
                GameObject.Destroy(currentLines[i].gameObject);
            }
            ReordenateFields();
        }
Exemplo n.º 2
0
        private void ReordenateFields()
        {
            uint[] values  = new uint[m_borderCities.Count];
            bool   invalid = false;

            for (int i = 0; i < m_borderCities.Count; i++)
            {
                AdrAzimuthEditorLineNeighbor textField = m_borderCities[i];
                if (!uint.TryParse(textField.GetCurrentVal(), out uint res) || res < 0 || res > 360)
                {
                    textField.SetTextColor(Color.red);
                    values[i] = 1000;
                    invalid   = true;
                }
                else
                {
                    textField.SetTextColor(Color.white);
                    values[i] = res;
                }
            }
            if (!invalid)
            {
                List <uint> sortedValues = new List <uint>(values);
                sortedValues.Sort();
                List <Tuple <int, int, Color, AdrAzimuthEditorLineNeighbor> > updateInfo = new List <Tuple <int, int, Color, AdrAzimuthEditorLineNeighbor> >();
                for (int i = 0; i < m_borderCities.Count; i++)
                {
                    int zOrder = sortedValues.IndexOf(values[i]);
                    updateInfo.Add(Tuple.New(zOrder, (int)values[i], GetColorForNumber(i), m_borderCities[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 += 360;
                    }

                    float angle = (start + end) / 2f;
                    updateInfo[i].Fourth.SetData();
                }
                m_borderChart.SetValues(updateInfo.Select(x => Tuple.New(x.Second, x.Third)).ToList());
            }
            SegmentUtils.UpdateSegmentNamesView();
        }
Exemplo n.º 3
0
        private void RebuildList()
        {
            m_isLoading = true;
            AdrAzimuthEditorLineNeighbor[] currentLines = m_neighborsList?.GetComponentsInChildren <AdrAzimuthEditorLineNeighbor>();
            if (currentLines is null)
            {
                return;
            }

            int stopsCount = AdrNeighborhoodExtension.GetStopsCount();

            if (stopsCount == 0)
            {
                stopsCount = 1;
            }

            m_borderCities = new List <AdrAzimuthEditorLineNeighbor>();
            int count = 0;

            for (int i = 0; i < stopsCount; i++, count++)
            {
                if (i < currentLines.Length)
                {
                    currentLines[i].SetLegendInfo(GetColorForNumber(i), i + 1);
                    m_borderCities.Add(currentLines[i]);
                }
                else
                {
                    KlyteMonoUtils.CreateUIElement(out UIPanel newEntry, m_neighborsList.transform, "NeighborhoodEntry");
                    AdrAzimuthEditorLineNeighbor line = newEntry.gameObject.AddComponent <AdrAzimuthEditorLineNeighbor>();
                    line.SetLegendInfo(GetColorForNumber(i), i + 1);
                    line.OnValueChange     += ValidateAngleStr;
                    line.OnFixedNameChange += SetFixedName;
                    m_borderCities.Add(line);
                }
            }
            for (int i = count; i < currentLines.Length; i++)
            {
                GameObject.Destroy(currentLines[i].gameObject);
            }
            m_isLoading = false;
            ReordenateFields();
        }