Пример #1
0
        private void OnRDTreeSpawn(KSP.UI.Screens.RDController rd)
        {
            Util.Log("Call: OnRDTreeSpawn");

            SetPartIcons();
            SetNodeIcon(rd);
        }
Пример #2
0
        /// <summary>
        /// Set the tech tree node icon for the new node.
        /// </summary>
        /// <param name="rd"></param>
        /// <param name="iconName"></param>
        private void SetNodeIcon(KSP.UI.Screens.RDController rd)
        {
            string refname = "RD_node_icon_simplesurvivalbasic";
            // This file has the .truecolor extension in order to force KSP
            // to use this icon without mipmaps. The stock toolbar and RnD icons
            // do not scale down with lower user-set texture resolutions,
            // so neither should this.
            Texture2D texture = GameDatabase.Instance.GetTexture($"SimpleSurvival/Tech/{refname}", false);

            RUI.Icons.Simple.Icon icon = new RUI.Icons.Simple.Icon(refname, texture);

            rd.iconLoader.iconDictionary.Add(refname, icon);

            // Custom nodes will be last on the list.
            // Speed up load time by beginning iteration backwards.
            for (int i = rd.nodes.Count - 1; i >= 0; i--)
            {
                KSP.UI.Screens.RDNode node = rd.nodes[i];

                // This is the "id" field in the tech tree config
                if (node.tech.techID == "simplesurvivalBasic")
                {
                    Util.Log("Found SimpleSurvival Basic tech node");

                    // Sets the large icon in the righthand info panel
                    node.icon    = icon;
                    node.iconRef = refname;

                    // Sets the tree icon
                    node.graphics.SetIcon(icon);

                    node.UpdateGraphics();
                    return;
                }
            }
        }