Пример #1
0
        public override void OnAwake()
        {
            base.OnAwake();

            if (lineMaterial == null)
            {
                lineMaterial = JUtil.DrawLineMaterial();
            }
        }
Пример #2
0
        public void Start()
        {
            if (HighLogic.LoadedSceneIsEditor)
            {
                return;
            }

            try
            {
                rpmComp = RasterPropMonitorComputer.Instantiate(internalProp, true);

                if (lineMaterial == null)
                {
                    lineMaterial = JUtil.DrawLineMaterial();
                }

                if (!string.IsNullOrEmpty(borderColor))
                {
                    borderColorValue = ConfigNode.ParseColor32(borderColor);
                }
                if (!string.IsNullOrEmpty(backgroundColor))
                {
                    backgroundColorValue = ConfigNode.ParseColor32(backgroundColor);
                }

                //comp = RasterPropMonitorComputer.Instantiate(internalProp);
                graphSpace      = new Rect();
                graphSpace.xMin = graphRect.x;
                graphSpace.yMin = graphRect.y;
                graphSpace.xMax = graphRect.z;
                graphSpace.yMax = graphRect.w;
                xGraphSpan      = xSpan;
                interval        = secondsBetweenSamples;
                if (GameDatabase.Instance.ExistsTexture(backgroundTextureURL.EnforceSlashes()))
                {
                    backgroundTexture = GameDatabase.Instance.GetTexture(backgroundTextureURL.EnforceSlashes(), false);
                }

                var bottomLeft  = new Vector2(graphSpace.xMin, graphSpace.yMin);
                var bottomRight = new Vector2(graphSpace.xMax, graphSpace.yMin);
                var topLeft     = new Vector2(graphSpace.xMin, graphSpace.yMax);
                var topRight    = new Vector2(graphSpace.xMax, graphSpace.yMax);


                switch (borders)
                {
                case 2:
                    borderVertices.Add(bottomRight);
                    borderVertices.Add(bottomLeft);
                    borderVertices.Add(topLeft);
                    break;

                case 4:
                    borderVertices.Add(bottomLeft);
                    borderVertices.Add(topLeft);
                    borderVertices.Add(topRight);
                    borderVertices.Add(bottomRight);
                    borderVertices.Add(bottomLeft);
                    break;
                }

                foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("JSIGRAPHSET"))
                {
                    if (node.HasValue("name") && node.GetValue("name") == graphSet)
                    {
                        foreach (ConfigNode graphNode in node.GetNodes("GRAPH"))
                        {
                            graphs.Add(new GraphLine(graphNode, rpmComp, xGraphSpan, ySpan, interval));
                        }
                    }
                }
                JUtil.LogMessage(this, "Graphing {0} values.", graphs.Count);
                startupComplete = true;
            }
            catch
            {
                JUtil.AnnoyUser(this);
                throw;
            }
        }
Пример #3
0
        public void Start()
        {
            if (HighLogic.LoadedSceneIsEditor)
            {
                return;
            }
            try
            {
                rpmComp = RasterPropMonitorComputer.Instantiate(internalProp, true);

                if (lineMaterial == null)
                {
                    lineMaterial = JUtil.DrawLineMaterial();
                }

                if (string.IsNullOrEmpty(layout))
                {
                    throw new ArgumentNullException("layout");
                }

                foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("RPM_GRAPHING_BACKGROUND"))
                {
                    if (node.GetValue("layout") == layout)
                    {
                        if (!node.HasValue("backgroundColor"))
                        {
                            JUtil.LogErrorMessage(this, "?!? no backgroundColor");
                        }
                        string s = node.GetValue("backgroundColor");
                        if (string.IsNullOrEmpty(s))
                        {
                            JUtil.LogErrorMessage(this, "backgroundColor is missing?");
                        }
                        backgroundColorValue = ConfigNode.ParseColor32(node.GetValue("backgroundColor"));

                        ConfigNode[] dataNodes = node.GetNodes("DATA_SET");

                        for (int i = 0; i < dataNodes.Length; i++)
                        {
                            try
                            {
                                dataSets.Add(new DataSet(dataNodes[i], rpmComp));
                            }
                            catch (ArgumentException e)
                            {
                                JUtil.LogErrorMessage(this, "Error in building prop number {1} - {0}", e.Message, internalProp.propID);
                                throw;
                            }
                        }
                        break;
                    }
                }

                startupComplete = true;
            }

            catch
            {
                JUtil.AnnoyUser(this);
                throw;
            }
        }