private void Start()
        {
            InstallationPathWarning.Warn("SCANsatRPM");

            // Arrrgh.
            if (!string.IsNullOrEmpty(iconColorSelf))
            {
                iconColorSelfValue = ConfigNode.ParseColor32(iconColorSelf);
            }
            if (!string.IsNullOrEmpty(iconColorTarget))
            {
                iconColorTargetValue = ConfigNode.ParseColor32(iconColorTarget);
            }
            if (!string.IsNullOrEmpty(iconColorUnvisitedAnomaly))
            {
                iconColorUnvisitedAnomalyValue = ConfigNode.ParseColor32(iconColorUnvisitedAnomaly);
            }
            if (!string.IsNullOrEmpty(iconColorVisitedAnomaly))
            {
                iconColorVisitedAnomalyValue = ConfigNode.ParseColor32(iconColorVisitedAnomaly);
            }
            if (!string.IsNullOrEmpty(iconColorShadow))
            {
                iconColorShadowValue = ConfigNode.ParseColor32(iconColorShadow);
            }
            if (!string.IsNullOrEmpty(iconColorAP))
            {
                iconColorAPValue = ConfigNode.ParseColor32(iconColorAP);
            }
            if (!string.IsNullOrEmpty(iconColorPE))
            {
                iconColorPEValue = ConfigNode.ParseColor32(iconColorPE);
            }
            if (!string.IsNullOrEmpty(iconColorANDN))
            {
                iconColorANDNValue = ConfigNode.ParseColor32(iconColorANDN);
            }
            if (!string.IsNullOrEmpty(iconColorNode))
            {
                iconColorNodeValue = ConfigNode.ParseColor32(iconColorNode);
            }
            if (!string.IsNullOrEmpty(trailColor))
            {
                trailColorValue = ConfigNode.ParseColor32(trailColor);
            }

            // Referencing the parent project should work, shouldn't it.
            persistentVarName = "scansat" + internalProp.propID;
            persistence       = new PersistenceAccessor(part);

            showLines = persistence.GetBool(persistentVarName + "lines") ?? true;

            trailMaterial = JUtil.DrawLineMaterial();

            LeaveTrail();

            if (!string.IsNullOrEmpty(scaleBar) && !string.IsNullOrEmpty(scaleLabels) && !string.IsNullOrEmpty(scaleLevels))
            {
                scaleBarTexture   = GameDatabase.Instance.GetTexture(scaleBar, false);
                scaleLabelTexture = GameDatabase.Instance.GetTexture(scaleLabels, false);
                var scales = new List <float>();
                foreach (string scl in scaleLevels.Split(','))
                {
                    float scale;
                    if (float.TryParse(scl.Trim(), out scale))
                    {
                        scales.Add(scale / 1000);
                    }
                }
                scaleLevelValues = scales.ToArray();
                Array.Sort(scaleLevelValues);
                scaleLabelSpan = 1f / scaleLevelValues.Length;
            }

            // Now the fun bit: Locate all cfg files depicting map features anywhere.

            foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("JSISCANSATVECTORMARK"))
            {
                mapMarkup.Add(new MapMarkupLine(node));
            }
            startupComplete = true;
        }
Beispiel #2
0
        private void Start()
        {
            // Referencing the parent project should work, shouldn't it.
            persistentVarName = "scansat" + internalProp.propID;

            try {
                sat = part.FindModulesImplementing <SCANsat>().First();
            }
            catch {
                Debug.LogWarning("[SCANsatRPM] SCANsat module not attached to this IVA, check for Module Manager problems and make sure the RPMMapTraq.cfg file is in the SCANsat/MMconfigs folder");
                sat = null;
            }

            if (sat != null)
            {
                satModuleFound = true;
                if (sat.RPMList.Count > 0)
                {
                    foreach (RPMPersistence RPMProp in sat.RPMList)
                    {
                        if (RPMProp.RPMID == persistentVarName)
                        {
                            persist = RPMProp;
                            break;
                        }
                    }
                }
                if (persist == null)
                {
                    persist = new RPMPersistence(persistentVarName);
                    sat.RPMList.Add(persist);
                }
                showLines = persist.RPMLines;
            }
            else
            {
                satModuleFound = false;
            }

            // Arrrgh.
            if (!string.IsNullOrEmpty(iconColorSelf))
            {
                iconColorSelfValue = ConfigNode.ParseColor32(iconColorSelf);
            }
            if (!string.IsNullOrEmpty(iconColorTarget))
            {
                iconColorTargetValue = ConfigNode.ParseColor32(iconColorTarget);
            }
            if (!string.IsNullOrEmpty(iconColorUnvisitedAnomaly))
            {
                iconColorUnvisitedAnomalyValue = ConfigNode.ParseColor32(iconColorUnvisitedAnomaly);
            }
            if (!string.IsNullOrEmpty(iconColorVisitedAnomaly))
            {
                iconColorVisitedAnomalyValue = ConfigNode.ParseColor32(iconColorVisitedAnomaly);
            }
            if (!string.IsNullOrEmpty(iconColorShadow))
            {
                iconColorShadowValue = ConfigNode.ParseColor32(iconColorShadow);
            }
            if (!string.IsNullOrEmpty(iconColorAP))
            {
                iconColorAPValue = ConfigNode.ParseColor32(iconColorAP);
            }
            if (!string.IsNullOrEmpty(iconColorPE))
            {
                iconColorPEValue = ConfigNode.ParseColor32(iconColorPE);
            }
            if (!string.IsNullOrEmpty(iconColorANDN))
            {
                iconColorANDNValue = ConfigNode.ParseColor32(iconColorANDN);
            }
            if (!string.IsNullOrEmpty(iconColorNode))
            {
                iconColorNodeValue = ConfigNode.ParseColor32(iconColorNode);
            }
            if (!string.IsNullOrEmpty(trailColor))
            {
                trailColorValue = ConfigNode.ParseColor32(trailColor);
            }



            trailMaterial = JUtil.DrawLineMaterial();

            LeaveTrail();

            if (!string.IsNullOrEmpty(scaleBar) && !string.IsNullOrEmpty(scaleLabels) && !string.IsNullOrEmpty(scaleLevels))
            {
                scaleBarTexture   = GameDatabase.Instance.GetTexture(scaleBar, false);
                scaleLabelTexture = GameDatabase.Instance.GetTexture(scaleLabels, false);
                var scales = new List <float>();
                foreach (string scl in scaleLevels.Split(','))
                {
                    float scale;
                    if (float.TryParse(scl.Trim(), out scale))
                    {
                        scales.Add(scale / 1000);
                    }
                }
                scaleLevelValues = scales.ToArray();
                Array.Sort(scaleLevelValues);
                scaleLabelSpan = 1f / scaleLevelValues.Length;
            }

            // Now the fun bit: Locate all cfg files depicting map features anywhere.

            foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("JSISCANSATVECTORMARK"))
            {
                mapMarkup.Add(new MapMarkupLine(node));
            }
        }