Esempio n. 1
0
        private static void DrawStorageMarker(ResearchProjectDef tech, Rect rect, bool highlighted)
        {
            float   height      = rect.height;
            float   ribbon      = ResearchTree_Constants.push.x;
            Vector2 position    = new Vector2(rect.xMax, rect.y);
            Color   techColor   = ResearchTree_Assets.ColorCompleted[tech.techLevel];
            Color   shadedColor = highlighted ? ResearchTree_Patches.ShadedColor : ResearchTree_Assets.ColorAvailable[tech.techLevel];
            Color   backup      = GUI.color;

            if (unlocked.TechsArchived.ContainsKey(tech))
            {
                bool    cloud      = tech.IsOnline();
                bool    book       = tech.IsPhysicallyArchived();
                bool    twin       = cloud && book;
                Vector2 markerSize = new Vector2(ribbon, height);
                Rect    box        = new Rect(position, markerSize);
                Rect    inner      = box;
                inner.height = ribbon;
                if (twin)
                {
                    inner.y -= height * 0.08f;
                }
                else
                {
                    inner.y += (height - ribbon) / 2;
                }
                Widgets.DrawBoxSolid(box, shadedColor);
                if (cloud)
                {
                    GUI.DrawTexture(inner.ContractedBy(1f), ContentFinder <Texture2D> .Get("UI/cloud", true));
                    TooltipHandler.TipRegionByKey(inner, "bookInDatabase");
                }
                if (book)
                {
                    if (twin)
                    {
                        float reduction = 0.9f;
                        inner.width  *= reduction;
                        inner.height *= reduction;
                        inner.y       = box.yMax - inner.height - 1f;
                        inner.x      += (ribbon - inner.width) / 2;
                    }
                    var material = TechDefOf.TechBook.graphic.MatSingle;
                    material.color = techColor;
                    Graphics.DrawTexture(inner.ContractedBy(1f), ContentFinder <Texture2D> .Get("Things/Item/book", true), material, 0);
                    TooltipHandler.TipRegionByKey(inner, "bookInLibrary");
                }
            }
            //origin tooltip if necessary
            else if (tech.IsFinished)
            {
                bool   fromScenario = unlocked.scenarioTechs.Contains(tech);
                bool   fromFaction  = unlocked.factionTechs.Contains(tech);
                bool   startingTech = fromScenario || fromFaction;
                string source       = fromScenario ? Find.Scenario.name : Find.FactionManager.OfPlayer.Name;
                TooltipHandler.TipRegionByKey(rect, "bookFromStart", source);
            }
            GUI.color = backup;
            return;
        }
        public static void DrawExtras(this ResearchProjectDef tech, Rect rect, bool highlighted) 
        {
            //storage marker insertion
            float height = rect.height;
            float ribbon = ResearchTree_Constants.push.x;
            Vector2 position = new Vector2(rect.xMax, rect.y);
            Color techColor = ResearchTree_Assets.ColorCompleted[tech.techLevel];
            Color shadedColor = highlighted ? ResearchTree_Patches.ShadedColor : ResearchTree_Assets.ColorAvailable[tech.techLevel];
            Color backup = GUI.color;
            if (unlocked.TechsArchived.ContainsKey(tech))
            {
                bool cloud = tech.IsOnline();
                bool book = tech.IsPhysicallyArchived();
                bool twin = cloud && book;
                Vector2 markerSize = new Vector2(ribbon, height);
                Rect box = new Rect(position, markerSize);
                Rect inner = box;
                inner.height = ribbon;
                if (twin)
                {
                    inner.y -= height * 0.08f;
                }
                else
                {
                    inner.y += (height - ribbon) / 2;
                }
                Widgets.DrawBoxSolid(box, shadedColor);
                if (cloud)
                {
                    GUI.DrawTexture(inner.ContractedBy(1f), ContentFinder<Texture2D>.Get("UI/cloud", true));
                    TooltipHandler.TipRegionByKey(inner, "bookInDatabase".Translate());
                }
                if (book)
                {
                    if (twin)
                    {
                        float reduction = 0.9f;
                        inner.width *= reduction;
                        inner.height *= reduction;
                        inner.y = box.yMax - inner.height - 1f;
                        inner.x += (ribbon - inner.width) / 2;
                    }
                    var material = TechDefOf.TechBook.graphic.MatSingle;
                    material.color = techColor;
                    Graphics.DrawTexture(inner.ContractedBy(1f), ContentFinder<Texture2D>.Get("Things/Item/book", true), material, 0);
                    TooltipHandler.TipRegionByKey(inner, "bookInLibrary".Translate());
                }
            }
            //origin tooltip if necessary
            else if (tech.IsFinished)
            {
                bool fromScenario = unlocked.scenarioTechs.Contains(tech);
                bool fromFaction = unlocked.factionTechs.Contains(tech);
                bool startingTech = fromScenario || fromFaction;
                string source = fromScenario ? Find.Scenario.name : Find.FactionManager.OfPlayer.Name;
                TooltipHandler.TipRegionByKey(rect, "bookFromStart".Translate(source));
            }

            GUI.color = backup;

            //Pawn assignments
            Vector2 size = new Vector2(height, height);
            float frameOffset = height / 4;
            float startPos = rect.x - frameOffset;
            using (IEnumerator<Pawn> enumerator = currentPawns.Where(p => HasBeenAssigned(p, tech)).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    position = new Vector2(startPos, rect.y + (height / 3));
                    Rect box = new Rect(position, size);
                    Rect clickBox = new Rect(position.x + frameOffset, position.y, size.x - (2 * frameOffset), size.y);
                    Pawn pawn = enumerator.Current;
                    GUI.DrawTexture(box, PortraitsCache.Get(pawn, size, default, 1.2f));
Esempio n. 3
0
 public static bool HasBackup(this ResearchProjectDef tech, bool hardCopy)
 {
     return(hardCopy ? tech.IsOnline() : tech.IsPhysicallyArchived());
 }