예제 #1
0
        private static void UIRootOnGUI()
        {
            if (!shouldDrawSurgeryRect)
            {
                return;
            }
            else
            {
                CameraZoomRange zoom = Find.CameraDriver.CurrentZoom;
                if (!(zoom == CameraZoomRange.Closest || zoom == CameraZoomRange.Close))
                {
                    return;
                }

                Vector2 pawnPosScreenSpace = patient.DrawPos.MapToUIPosition();

                Rect surgeryRect = new Rect(pawnPosScreenSpace.x - InfoboxWidth / 2f, (pawnPosScreenSpace.y - (InfoboxHeight / 2f)) - InfoboxVerticalOffset, InfoboxWidth, InfoboxHeight);

                WidgetsExtensions.DrawWindowBackgroundTransparent(surgeryRect, 0.75f);
                float bottom;
                WidgetsExtensions.DrawGadgetWindowLabel("SurgeryEstimateWindowLabel".Translate(), surgeryRect, Color.white, out bottom);
                WidgetsExtensions.DrawHorizontalDivider(surgeryRect, bottom);
                Rect innerRect = new Rect(surgeryRect);
                innerRect.y      += bottom;
                innerRect.height -= bottom;
                innerRect         = innerRect.ContractedBy(1f);

                Rect medicineRect = new Rect(innerRect);
                medicineRect.width = 42;
                Rect reportRect = new Rect(innerRect);
                reportRect.width = reportRect.width - InfoboxItemWidth;
                reportRect.x     = reportRect.x + InfoboxItemWidth;

                WidgetsExtensions.DrawGadgetWindowLabel("UsingMedicineKind".Translate(), medicineRect, Color.white, out bottom);

                GUI.color = Color.white;
                Rect itemIconRect = new Rect(medicineRect.x + 5, medicineRect.yMax - ((InfoboxItemWidth - 10) + 5), 32, 32);
                if (cachedMedicine != null)
                {
                    Widgets.ThingIcon(itemIconRect, cachedMedicine.def);
                }
                else
                {
                    GUI.DrawTexture(itemIconRect, TextureResources.missingMedicine);
                }

                WidgetsExtensions.DrawVerticalDivider(reportRect, 0);

                DrawReport(reportRect);
            }
        }
예제 #2
0
        private static void DrawReport(Rect reportRect)
        {
            GameFont activeFont = Text.Font;

            Text.Font = GameFont.Small;

            bool detailed = false;

            switch (QOLTweaksPack.SurgeryEstimationMode.Value)
            {
            case QOLTweaksPack.SurgeryEstimateMode.AlwaysAccurate:
                detailed = true;
                break;

            case QOLTweaksPack.SurgeryEstimateMode.AccurateIfDoctor:
                detailed = (surgeon.skills.GetSkill(SkillDefOf.Medicine).Level >= 5) ? true : false;
                break;

            case QOLTweaksPack.SurgeryEstimateMode.AccurateIfGoodDoctor:
                detailed = (surgeon.skills.GetSkill(SkillDefOf.Medicine).Level >= 10) ? true : false;
                break;

            case QOLTweaksPack.SurgeryEstimateMode.AccurateIfAmazingDoctor:
                detailed = (surgeon.skills.GetSkill(SkillDefOf.Medicine).Level >= 15) ? true : false;
                break;

            case QOLTweaksPack.SurgeryEstimateMode.NeverAccurate:
                detailed = false;
                break;
            }

            //Log.Message("chances:" + surgeryOdds.chanceSuccess + " " + surgeryOdds.chanceFailMinor + " " + surgeryOdds.chanceFailCatastrophic + " " + surgeryOdds.chanceFailRidiculous + " " + surgeryOdds.chanceFailDeadly);

            Color  textColor;
            string text;
            bool   usesSpecialText;
            bool   usesSpecialColor;

            SurgeryOdds surgeryOdds = ModifiedOdds(sentSurgeryOdds, surgeon, patient, out usesSpecialText, out usesSpecialColor, out text, out textColor);

            if (detailed)
            {
                float acc  = 0;
                float diff = reportRect.width - ReportBarStart - ReportBarEnd;

                Rect  reportTextRect = new Rect(reportRect.x, reportRect.y, reportRect.width, reportRect.height - (ReportBarHeight + ReportBarOffset * 2));
                float oneTextWidth   = (reportTextRect.width - 4) / 3f;
                float oneTextHeight  = (reportTextRect.height - 4) / 2f;

                if (surgeryOdds.chanceSuccess > 0.0f)
                {
                    GUI.color = BarColorSuccess;
                    GUI.DrawTexture(new Rect(reportRect.x + ReportBarStart + (diff * acc), reportRect.yMax - (ReportBarHeight + ReportBarOffset), diff * surgeryOdds.chanceSuccess, ReportBarHeight), BaseContent.WhiteTex);
                    GUI.color = TextColorSuccess;
                    Rect localRect = new Rect(reportTextRect.x + ReportTextOffsetHori, reportTextRect.y + ReportTextOffsetVert, oneTextWidth, oneTextHeight);
                    GUI.Label(localRect, ((Mathf.Round(surgeryOdds.chanceSuccess * 100)).ToString("F0") + "%"));
                    TooltipHandler.TipRegion(localRect, "Surgery_detailedMouseover_OddsOfSuccess".Translate());
                    acc += surgeryOdds.chanceSuccess;
                }
                if (surgeryOdds.chanceFailMinor > 0.0f)
                {
                    GUI.color = BarColorFailMinor;
                    GUI.DrawTexture(new Rect(reportRect.x + ReportBarStart + (diff * acc), reportRect.yMax - (ReportBarHeight + ReportBarOffset), diff * surgeryOdds.chanceFailMinor, ReportBarHeight), BaseContent.WhiteTex);
                    GUI.color = TextColorFailMinor;
                    Rect localRect = new Rect(reportTextRect.x + ReportTextOffsetHori + oneTextWidth, reportTextRect.y + ReportTextOffsetVert, oneTextWidth, oneTextHeight);
                    GUI.Label(localRect, ((Mathf.Round(surgeryOdds.chanceFailMinor * 100)).ToString("F0") + "%"));
                    TooltipHandler.TipRegion(localRect, "Surgery_detailedMouseover_OddsOfFailMinor".Translate());
                    acc += surgeryOdds.chanceFailMinor;
                }
                if (surgeryOdds.chanceFailCatastrophic > 0.0f)
                {
                    GUI.color = BarColorFailCatastrophic;
                    GUI.DrawTexture(new Rect(reportRect.x + ReportBarStart + (diff * acc), reportRect.yMax - (ReportBarHeight + ReportBarOffset), diff * surgeryOdds.chanceFailCatastrophic, ReportBarHeight), BaseContent.WhiteTex);
                    GUI.color = TextColorFailCatastrophic;
                    Rect localRect = new Rect(reportTextRect.x + ReportTextOffsetHori + oneTextWidth * 2, reportTextRect.y + ReportTextOffsetVert, oneTextWidth, oneTextHeight);
                    GUI.Label(localRect, ((Mathf.Round(surgeryOdds.chanceFailCatastrophic * 100)).ToString("F0") + "%"));
                    TooltipHandler.TipRegion(localRect, "Surgery_detailedMouseover_OddsOfFailCatastrophic".Translate());
                    acc += surgeryOdds.chanceFailCatastrophic;
                }
                if (surgeryOdds.chanceFailRidiculous > 0.0f)
                {
                    GUI.color = BarColorFailRidiculous;
                    GUI.DrawTexture(new Rect(reportRect.x + ReportBarStart + (diff * acc), reportRect.yMax - (ReportBarHeight + ReportBarOffset), diff * surgeryOdds.chanceFailRidiculous, ReportBarHeight), BaseContent.WhiteTex);
                    GUI.color = TextColorFailRidiculous;
                    Rect localRect = new Rect(reportTextRect.x + ReportTextOffsetHori + oneTextWidth, reportTextRect.y + ReportTextOffsetVert + oneTextHeight, oneTextWidth, oneTextHeight);
                    GUI.Label(localRect, ((Mathf.Round(surgeryOdds.chanceFailRidiculous * 100)).ToString("F0") + "%"));
                    TooltipHandler.TipRegion(localRect, "Surgery_detailedMouseover_OddsOfFailRidiculous".Translate());
                    acc += surgeryOdds.chanceFailRidiculous;
                }
                if (surgeryOdds.chanceFailDeadly > 0.0f)
                {
                    GUI.color = BarColorFailDeadly;
                    GUI.DrawTexture(new Rect(reportRect.x + ReportBarStart + (diff * acc), reportRect.yMax - (ReportBarHeight + ReportBarOffset), diff * surgeryOdds.chanceFailDeadly, ReportBarHeight), BaseContent.WhiteTex);
                    GUI.color = TextColorFailDeadly;
                    Rect localRect = new Rect(reportTextRect.x + ReportTextOffsetHori + oneTextWidth * 2, reportTextRect.y + ReportTextOffsetVert + oneTextHeight, oneTextWidth, oneTextHeight);
                    GUI.Label(localRect, ((Mathf.Round(surgeryOdds.chanceFailDeadly * 100)).ToString("F0") + "%"));
                    TooltipHandler.TipRegion(localRect, "Surgery_detailedMouseover_OddsOfFailDeadly".Translate());
                    acc += surgeryOdds.chanceFailDeadly;
                }


                GUI.color = Color.white;
            }
            else
            {
                float assumedOdds = surgeryOdds.chanceSuccess + surgeryOdds.chanceFailMinor * MinorFailAllowanceMult;

                if (assumedOdds < ImpossibleOdds)
                {
                    if (!usesSpecialText)
                    {
                        text = ImpossibleOddsText;
                    }
                    if (!usesSpecialColor)
                    {
                        textColor = ImpossibleOddsColor;
                    }
                }
                else if (assumedOdds < TerribleOdds)
                {
                    if (!usesSpecialText)
                    {
                        text = TerribleOddsText;
                    }
                    if (!usesSpecialColor)
                    {
                        textColor = TerribleOddsColor;
                    }
                }
                else if (assumedOdds < BadOdds)
                {
                    if (!usesSpecialText)
                    {
                        text = BadOddsText;
                    }
                    if (!usesSpecialColor)
                    {
                        textColor = BadOddsColor;
                    }
                }
                else if (assumedOdds < AcceptableOdds)
                {
                    if (!usesSpecialText)
                    {
                        text = AcceptableOddsText;
                    }
                    if (!usesSpecialColor)
                    {
                        textColor = AcceptableOddsColor;
                    }
                }
                else if (assumedOdds < GoodOdds)
                {
                    if (!usesSpecialText)
                    {
                        text = GoodOddsText;
                    }
                    if (!usesSpecialColor)
                    {
                        textColor = GoodOddsColor;
                    }
                }
                else if (assumedOdds < GreatOdds)
                {
                    if (!usesSpecialText)
                    {
                        text = GreatOddsText;
                    }
                    if (!usesSpecialColor)
                    {
                        textColor = GreatOddsColor;
                    }
                }
                else
                {
                    if (!usesSpecialText)
                    {
                        text = AmazingOddsText;
                    }
                    if (!usesSpecialColor)
                    {
                        textColor = AmazingOddsColor;
                    }
                }
                float bottom;

                reportRect = reportRect.ContractedBy(2f);

                WidgetsExtensions.DrawGadgetWindowLabel(text.Translate(), reportRect, textColor, out bottom);
            }

            Text.Font = activeFont;
        }