예제 #1
0
파일: EDSystem.cs 프로젝트: Nexam/NexHud
        public EDBody addOrUpdateBody(SpanshBody _spanshDatas)
        {
            if (_spanshDatas.edsm_id == null)
            {
                throw new Exception("Missing edsm id for body " + _spanshDatas.name);
            }
            if (!m_Bodys.ContainsKey((int)_spanshDatas.edsm_id))
            {
                m_Bodys.Add((int)_spanshDatas.edsm_id, new EDBody(this));
            }

            m_Bodys[(int)_spanshDatas.edsm_id].update(_spanshDatas);

            return(m_Bodys[(int)_spanshDatas.edsm_id]);
        }
예제 #2
0
        private void OnClickResult(object sender, EventArgs e)
        {
            if (sender is UiSearchResultLine)
            {
                SpanshSystem system = ((UiSearchResultLine)sender).LastSystem;
                SpanshBody   body   = ((UiSearchResultLine)sender).LastBody;

                if (system != null)
                {
                    displayMessage(string.Format("{0} has been copied to your clipboard!", system.name.ToString()), EDColors.BLUE);
                    Clipboard.SetText(system.name.ToString());
                }
                else if (body != null)
                {
                    displayMessage(string.Format("{0} has been copied to your clipboard!", body.system_name.ToString()), EDColors.BLUE);
                    Clipboard.SetText(body.system_name.ToString());
                }
            }
        }
예제 #3
0
파일: EDBody.cs 프로젝트: Nexam/NexHud
        public void update(SpanshBody _datas)
        {
            if (_datas.arg_of_periapsis != null)
            {
                arg_of_periapsis = (double)_datas.arg_of_periapsis;
            }
            atmosphere = _datas.atmosphere;
            if (_datas.axial_tilt != null)
            {
                axial_tilt = (double)_datas.axial_tilt;
            }
            if (_datas.body_id != null)
            {
                bodyId = (int)_datas.body_id;
            }
            if (_datas.distance_to_arrival != null)
            {
                distance_to_arrival = (int)_datas.distance_to_arrival;
            }
            if (_datas.earth_masses != null)
            {
                earth_masses = (double)_datas.earth_masses;
            }
            if (_datas.edsm_id != null)
            {
                edsmId = (int)_datas.edsm_id;
            }
            if (_datas.estimated_mapping_value != null)
            {
                estimated_mapping_value = (int)_datas.estimated_mapping_value;
            }
            if (_datas.estimated_scan_value != null)
            {
                estimated_scan_value = (int)_datas.estimated_scan_value;
            }
            if (_datas.gravity != null)
            {
                gravity = (double)_datas.gravity;
            }
            if (_datas.is_landable != null)
            {
                isLandable = (bool)_datas.is_landable;
            }
            name              = _datas.name.Replace(m_system.name, "").Trim();
            subtype           = _datas.subtype;
            type              = _datas.type;
            terraformingState = _datas.terraforming_state;
            volcanismType     = _datas.volcanism_type;

            materials = new KeyValuePair <string, double> [_datas.materials.Length];
            int i = 0;

            foreach (SpanshMaterial _md in _datas.materials)
            {
                materials[i++] = new KeyValuePair <string, double>(_md.name, (double)_md.share);
            }

            solid_composition = new KeyValuePair <string, double> [_datas.materials.Length];
            i = 0;
            foreach (SpanshMaterial _md in _datas.solid_composition)
            {
                solid_composition[i++] = new KeyValuePair <string, double>(_md.name, (double)_md.share);
            }
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="result"></param>
        /// <param name="index">if (index == -1) display title</param>
        public void SetDatas(SpanshSystemsResult result, int index = -1)
        {
            m_background.width  = width;
            m_background.height = height;


            isSelectable = index != -1;
            isEnable     = index != -1;
            Selected     = false;

            LastSystem = null;
            LastBody   = null;

            List <string> fields = new List <string>();

            if (result.search.filters.primary_economy != null)
            {
                fields.Add(nameof(result.search.filters.primary_economy));
            }
            if (result.search.filters.state != null)
            {
                fields.Add(nameof(result.search.filters.state));
            }
            if (result.search.filters.government != null)
            {
                fields.Add(nameof(result.search.filters.government));
            }
            if (result.search.filters.population != null)
            {
                fields.Add(nameof(result.search.filters.population));
            }
            if (result.search.filters.power != null)
            {
                fields.Add(nameof(result.search.filters.power));
            }
            if (result.search.filters.power_state != null)
            {
                fields.Add(nameof(result.search.filters.power_state));
            }
            if (result.search.filters.secondary_economy != null)
            {
                fields.Add(nameof(result.search.filters.secondary_economy));
            }

            //Always display !
            fields.Add(nameof(result.search.filters.allegiance));
            fields.Add(nameof(result.search.filters.security));

            //Additionnal fields
            if (fields.Count < 10 && !fields.Contains(nameof(result.search.filters.primary_economy)))
            {
                fields.Add(nameof(result.search.filters.primary_economy));
            }
            if (fields.Count < 10 && !fields.Contains(nameof(result.search.filters.state)))
            {
                fields.Add(nameof(result.search.filters.state));
            }
            if (fields.Count < 10 && !fields.Contains(nameof(result.search.filters.government)))
            {
                fields.Add(nameof(result.search.filters.government));
            }
            if (fields.Count < 10 && !fields.Contains(nameof(result.search.filters.population)))
            {
                fields.Add(nameof(result.search.filters.population));
            }
            if (fields.Count < 10 && !fields.Contains(nameof(result.search.filters.power)))
            {
                fields.Add(nameof(result.search.filters.power));
            }
            if (fields.Count < 10 && !fields.Contains(nameof(result.search.filters.power_state)))
            {
                fields.Add(nameof(result.search.filters.power_state));
            }

            //Visibilitys
            for (int i = 2; i < m_props.Length - 2; i++)
            {
                if (i - 2 < fields.Count)
                {
                    m_props[i].isVisible      = true;
                    m_separators[i].isVisible = true;
                }
                else
                {
                    m_props[i].isVisible      = false;
                    m_separators[i].isVisible = false;
                }
            }

            if (index == -1)
            {
                m_props[0].text = "Dist.";
                m_props[1].text = "System name";

                for (int i = 2; i < m_props.Length - 2; i++)
                {
                    if (i - 2 < fields.Count)
                    {
                        m_props[i].text = SpanshFilterSystems.getNameOf(fields[i - 2]);
                    }
                }
            }
            else if (index < result.count)
            {
                LastSystem      = result.results[index];
                m_props[0].text = Math.Round(result.results[index].distance, 1).ToString();
                m_props[1].text = result.results[index].name;

                for (int i = 2; i < m_props.Length - 2; i++)
                {
                    if (i - 2 < fields.Count)
                    {
                        switch (fields[i - 2])
                        {
                        case nameof(SpanshSearchSystems.filters.allegiance): m_props[i].text = result.results[index].allegiance; break;

                        case nameof(SpanshSearchSystems.filters.government): m_props[i].text = result.results[index].government; break;

                        case nameof(SpanshSearchSystems.filters.population): m_props[i].text = result.results[index].population.ToString(); break;

                        case nameof(SpanshSearchSystems.filters.power):
                            m_props[i].text = "";
                            if (result.results[index].power != null)
                            {
                                foreach (string p in result.results[index].power)
                                {
                                    m_props[i].text += p + ", ";
                                }
                                m_props[i].text = m_props[i].text.Substring(0, m_props[i].text.Length - 2);
                            }
                            break;

                        case nameof(SpanshSearchSystems.filters.power_state): m_props[i].text = result.results[index].power_state; break;

                        case nameof(SpanshSearchSystems.filters.primary_economy): m_props[i].text = result.results[index].primary_economy; break;

                        case nameof(SpanshSearchSystems.filters.secondary_economy): m_props[i].text = result.results[index].secondary_economy; break;

                        case nameof(SpanshSearchSystems.filters.security): m_props[i].text = result.results[index].security; break;

                        case nameof(SpanshSearchSystems.filters.state): m_props[i].text = result.results[index].state; break;
                        }
                    }
                }
            }

            m_registerWidth = true;

            m_background.Color = isEnable ? Color.Orange : Color.White;
        }
예제 #5
0
        public void SetDatas(SpanshBodiesResult result, string material_name, int index = -1)
        {
            m_background.width  = width;
            m_background.height = height;


            isSelectable = index != -1;
            isEnable     = index != -1;
            Selected     = false;

            LastSystem = null;
            LastBody   = null;
            //datas



            //Visibilitys
            for (int i = 0; i < m_props.Length; i++)
            {
                if (i < 6)
                {
                    m_props[i].isVisible      = true;
                    m_separators[i].isVisible = true;
                }
                else
                {
                    m_props[i].isVisible      = false;
                    m_separators[i].isVisible = false;
                }
            }

            if (index == -1)
            {
                m_props[0].text = "Dist.";
                m_props[1].text = "System name";

                m_props[2].text = "Body";
                m_props[3].text = "Dist. to arrival";
                m_props[4].text = "Gravity";
                m_props[5].text = material_name; //??? Nom material
            }
            else if (index < result.count)
            {
                LastBody = result.results[index];
                //distance from system to system
                m_props[0].text = Math.Round((double)result.results[index].distance, 1).ToString();
                //System name
                m_props[1].text = result.results[index].system_name;
                //Body
                m_props[2].text = result.results[index].name;
                //Distance to arrival
                m_props[3].text = Math.Round((double)result.results[index].distance_to_arrival, 0).ToString();
                //Gravity
                m_props[4].text = Math.Round((double)result.results[index].gravity, 2).ToString();

                //Material
                foreach (SpanshMaterial mat in result.results[index].materials)
                {
                    if (mat.name.ToLower() == material_name.ToLower())
                    {
                        m_props[5].text = Math.Round((double)mat.share, 2).ToString() + " %";
                    }
                }
            }

            ///

            m_registerWidth = true;

            m_background.Color = isEnable ? Color.Orange : Color.White;
        }