コード例 #1
0
        public static void MedicalCareSetter(Rect rect, ref MedicalCareCategory medCare)
        {
            Rect rect2 = new Rect(rect.x, rect.y, rect.width / 5f, rect.height);

            for (int i = 0; i < 5; i++)
            {
                MedicalCareCategory mc = (MedicalCareCategory)i;
                Widgets.DrawHighlightIfMouseover(rect2);
                MouseoverSounds.DoRegion(rect2);
                GUI.DrawTexture(rect2, careTextures[i]);
                Widgets.DraggableResult draggableResult = Widgets.ButtonInvisibleDraggable(rect2);
                if (draggableResult == Widgets.DraggableResult.Dragged)
                {
                    medicalCarePainting = true;
                }
                if ((medicalCarePainting && Mouse.IsOver(rect2) && medCare != mc) || draggableResult.AnyPressed())
                {
                    medCare = mc;
                    SoundDefOf.Tick_High.PlayOneShotOnCamera();
                }
                if (medCare == mc)
                {
                    Widgets.DrawBox(rect2, 3);
                }
                if (Mouse.IsOver(rect2))
                {
                    TooltipHandler.TipRegion(rect2, () => mc.GetLabel(), 632165 + i * 17);
                }
                rect2.x += rect2.width;
            }
            if (!Input.GetMouseButton(0))
            {
                medicalCarePainting = false;
            }
        }
コード例 #2
0
        public static void DynamicMedicalCareSetter(Rect rect, ref MedicalCareCategory medCare)
        {
            //modified CareSetter/UI panel
            float scaleFacV = 0.5f;
            float scaleFacH = 5.0f / (medList.Count);
            int   nFirstRow = (int)Mathf.Ceil(0.5f * medList.Count);
            bool  row       = (scaleFacV > scaleFacH);

            if (row)
            {
                scaleFacH = 5.0f / nFirstRow;
            }
            float scaleFac = Mathf.Max(scaleFacV, scaleFacH);



            Rect rect2 = new Rect(rect.x, rect.y + (row ? scaleFac * -0.5f * rect.height : (1f - scaleFac) * rect.height * 0.5f), rect.width * scaleFac / 5, rect.height * scaleFac);

            for (int i = 0; i < medList.Count; i++)
            {
                ModMedicine med = medList[i];

                Widgets.DrawHighlightIfMouseover(rect2);
                GUI.DrawTexture(rect2, med.tex);

                Widgets.DraggableResult draggableResult = Widgets.ButtonInvisibleDraggable(rect2, false);
                if (draggableResult == Widgets.DraggableResult.Dragged)
                {
                    medicalCarePainting = true;
                }
                if ((medicalCarePainting && Mouse.IsOver(rect2) && medCare != med.care) || (draggableResult == Widgets.DraggableResult.Pressed || draggableResult == Widgets.DraggableResult.DraggedThenPressed))
                {
                    medCare = med.care;
                    SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                }
                if (medCare == med.care)
                {
                    Widgets.DrawBox(rect2, 1);
                }
                TooltipHandler.TipRegion(rect2, () => med.care.GetLabel(), 632165 + (int)med.care * 17);

                rect2.x += rect2.width;
                if (row)
                {
                    if (i == nFirstRow - 1)
                    {
                        rect2.y += rect2.height;
                        rect2.x  = rect.x;
                    }
                }
            }
            if (!Input.GetMouseButton(0))
            {
                medicalCarePainting = false;
            }
        }
コード例 #3
0
        public static void CurveEditor(this Listing_Standard instance, ref SimpleCurve curve)
        {
            var rect = instance.GetRect(100f);

            Widgets.DrawBoxSolid(rect, Color.black);
            var innerRect = rect.ContractedBy(2f);

            //SimpleCurveDrawer.DrawCurve(innerRect, curve);
            Widgets.ButtonInvisibleDraggable(innerRect);
        }
コード例 #4
0
        private void DoBadgeDisplay(int i, IList <Rect> badgeRects, CompBadge cb)
        {
            Rect    outRect  = new Rect(badgeRects[i].ContractedBy(12f));
            string  title    = "PawnBadge.BadgeNumber".Translate(i + 1);
            Vector2 textSize = Text.CalcSize(title);

            Widgets.Label(new Rect(outRect.x, outRect.y, outRect.width, textSize.y), title);
            outRect.y      += textSize.y;
            outRect.height -= textSize.y;

            Rect badgeRect = outRect;

            badgeRect.width -= 16f;
            badgeRect.height = 9999f;

            Widgets.BeginScrollView(outRect, ref scrollPositions[i], badgeRect, true);



            LayoutManager layout = new LayoutManager(badgeRect, 40f, 30f);

            List <BadgeDef> defs = new List <BadgeDef>(DefDatabase <BadgeDef> .AllDefsListForReading);

            defs.Insert(0, new BadgeDef("", Mod.GreyTex));

            foreach (BadgeDef def in defs)
            {
                Rect brect = layout.CurRect;

                Widgets.DrawHighlightIfMouseover(brect);
                GUI.DrawTexture(brect, def.Symbol, ScaleMode.ScaleToFit);
                Widgets.DraggableResult draggableResult = Widgets.ButtonInvisibleDraggable(brect, false);
                if (draggableResult == Widgets.DraggableResult.Dragged)
                {
                    badgePainting[i] = true;
                }
                if ((badgePainting[i] && Mouse.IsOver(brect) && def.defName != cb.badges[i]) || AnyPressed(draggableResult))
                {
                    cb.badges[i] = def.defName;
                    SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                }
                if (cb.badges[i] == def.defName)
                {
                    Widgets.DrawBox(brect, 3);
                }
                TooltipHandler.TipRegion(brect, () => def.description, 3882382 + (int)brect.y * 17);
                layout.Next();
            }
            if (!Input.GetMouseButton(0))
            {
                badgePainting[i] = false;
            }
            Widgets.EndScrollView();
        }
コード例 #5
0
        public static void Checkbox(float x, float y, ref bool checkOn, float size = 24f, bool disabled = false, Texture2D texChecked = null, Texture2D texUnchecked = null, Texture2D texDisabled = null)
        {
            Rect rect = new Rect(x, y, size, size);

            WhoreCheckbox.CheckboxDraw(x, y, checkOn, disabled, size, texChecked, texUnchecked, texDisabled);
            if (!disabled)
            {
                MouseoverSounds.DoRegion(rect);
                bool flag = false;
                Widgets.DraggableResult draggableResult = Widgets.ButtonInvisibleDraggable(rect, false);
                if (draggableResult == Widgets.DraggableResult.Pressed)
                {
                    checkOn = !checkOn;
                    flag    = true;
                }
                else if (draggableResult == Widgets.DraggableResult.Dragged)
                {
                    checkOn = !checkOn;
                    flag    = true;
                    WhoreCheckbox.checkboxPainting      = true;
                    WhoreCheckbox.checkboxPaintingState = checkOn;
                }
                if (Mouse.IsOver(rect) && WhoreCheckbox.checkboxPainting && Input.GetMouseButton(0) && checkOn != WhoreCheckbox.checkboxPaintingState)
                {
                    checkOn = WhoreCheckbox.checkboxPaintingState;
                    flag    = true;
                }
                if (flag)
                {
                    if (checkOn)
                    {
                        SoundDefOf.Checkbox_TurnedOn.PlayOneShotOnCamera(null);
                    }
                    else
                    {
                        SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera(null);
                    }
                }
            }
        }
コード例 #6
0
            public static bool Listener(Rect rect, ref MedicalCareCategory medCare)
            {
                List <object> obj = Find.Selector.SelectedObjects;

                try {
                    if (obj.Count == 1 && (obj[0] is Pawn))
                    {
                        Pawn pawn = (Pawn)obj[0];

                        if (Utils.ExceptionAndroidList.Contains(pawn.def.defName) || pawn.IsCyberAnimal())
                        {
                            Rect rect2 = new Rect(rect.x, rect.y, rect.width / 5f, rect.height);
                            for (int i = 0; i < 5; i++)
                            {
                                MedicalCareCategory mc = (MedicalCareCategory)i;
                                Widgets.DrawHighlightIfMouseover(rect2);
                                Texture2D tex;
                                string    text;

                                if (i == 0)
                                {
                                    tex  = Tex.NoCare;
                                    text = "ATPP_NanoKitsNoCare".Translate();
                                }
                                else if (i == 1)
                                {
                                    tex  = Tex.NoMed;
                                    text = "ATPP_NanoKitsNoKitJustVisit".Translate();
                                }
                                else if (i == 2)
                                {
                                    tex  = Tex.NanoKitBasic;
                                    text = "ATPP_NanoKitsBasic".Translate();
                                }
                                else if (i == 3)
                                {
                                    tex  = Tex.NanoKitIntermediate;
                                    text = "ATPP_NanoKitsIntermediate".Translate();
                                }
                                else
                                {
                                    tex  = Tex.NanoKitAdvanced;
                                    text = "ATPP_NanoKitsAdvanced".Translate();
                                }

                                GUI.DrawTexture(rect2, tex);
                                Widgets.DraggableResult draggableResult = Widgets.ButtonInvisibleDraggable(rect2, false);
                                if (draggableResult == Widgets.DraggableResult.Dragged)
                                {
                                    medicalCarePainting = true;
                                }
                                if ((medicalCarePainting && Mouse.IsOver(rect2) && medCare != mc) || draggableResult.AnyPressed())
                                {
                                    medCare = mc;
                                    SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                                }
                                if (medCare == mc)
                                {
                                    Widgets.DrawBox(rect2, 3);
                                }
                                TooltipHandler.TipRegion(rect2, () => text, 632165 + i * 17);
                                rect2.x += rect2.width;
                            }
                            if (!Input.GetMouseButton(0))
                            {
                                medicalCarePainting = false;
                            }

                            return(false);
                        }
                        else
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        return(true);
                    }
                }
                catch (Exception e) {
                    Log.Message("[ATPP] MedicalCareUtility.MedicalCareSetter(Error) : " + e.Message + " - " + e.StackTrace);
                    return(true);
                }
            }
コード例 #7
0
        public override void DoCell(Rect rect, Pawn pawn, PawnTable table)
        {
            if (pawn.training == null)
            {
                return;
            }

            AcceptanceReport canTrain = pawn.training.CanAssignToTrain(def.trainable, out bool visible);

            if (!visible)
            {
                return;
            }

            // basic stuff
            Rect checkboxRect = Utilities.GetCheckboxRect(rect);

            if (!canTrain.Accepted)
            {
                Utilities.DoTrainableTooltip(checkboxRect, pawn, def.trainable, canTrain);
                return;
            }

            Utilities.DrawCheckboxBackground(checkboxRect);

            var steps     = Utilities.GetTrainingProgress(pawn, def.trainable);
            var completed = pawn.training.HasLearned(def.trainable);
            var wanted    = pawn.training.GetWanted(def.trainable);

            Utilities.DoTrainableTooltip(checkboxRect, pawn, def.trainable, canTrain, wanted, completed, steps);


            if (wanted)
            {
                Utilities.DrawCheckColoured(checkboxRect, completed ? Color.white : Color.green);
                if (steps.min < steps.max)
                {
                    Utilities.DrawTrainingProgress(checkboxRect, pawn, def.trainable, completed ? Color.white : Color.green);
                }
            }
            // not wanted anymore
            if (!wanted)
            {
                if (completed)
                {
                    Utilities.DrawCheckColoured(checkboxRect, Color.grey);
                }
                if (steps.min > 0 && steps.min < steps.max)
                {
                    Utilities.DrawTrainingProgress(checkboxRect, pawn, def.trainable, Color.grey);
                }
            }

            // interaction
            Widgets.DrawHighlightIfMouseover(checkboxRect);
            var button = Widgets.ButtonInvisibleDraggable(checkboxRect);

            if (button == Widgets.DraggableResult.Pressed)
            {
                pawn.training.SetWantedRecursive(def.trainable, !wanted);
            }

            if (button == Widgets.DraggableResult.Dragged)
            {
                pawn.training.SetWantedRecursive(def.trainable, !wanted);
                Utilities.CheckboxPainting      = true;
                Utilities.CheckboxPaintingState = !wanted;
            }

            if (Mouse.IsOver(checkboxRect) && Utilities.CheckboxPainting && Input.GetMouseButton(0) &&
                wanted != Utilities.CheckboxPaintingState)
            {
                pawn.training.SetWantedRecursive(def.trainable, Utilities.CheckboxPaintingState);
            }
            if (Widgets.ButtonInvisible(checkboxRect))
            {
                pawn.training.SetWantedRecursive(def.trainable, !wanted);
            }
        }
コード例 #8
0
        protected override void FillTab()
        {
            CompBadge cb = SelPawnForBadgeInfo.GetComp <CompBadge>();

            if (cb == null)
            {
                return;
            }

            Rect rect = new Rect(0f, 0f, this.size.x, this.size.y);

            Rect[] badgeRects = new Rect[] {
                new Rect(rect.x, rect.y, rect.width, rect.height / 2),
                new Rect(rect.x, (rect.height / 2) + 1, rect.width, rect.height / 2),
            };

            GUI.BeginGroup(rect);
            Text.Font = GameFont.Small;

            GUI.color = new Color(1f, 1f, 1f, 0.5f);
            Widgets.DrawLineHorizontal(badgeRects[0].x, badgeRects[0].yMax, badgeRects[0].width);
            GUI.color = Color.white;

            for (int i = 0; i < 2; i++)
            {
                Rect badgeRect = new Rect(badgeRects[i].ContractedBy(12f));

                string  title    = "PawnBadge.BadgeNumber".Translate(i + 1);
                Vector2 textSize = Text.CalcSize(title);

                Widgets.Label(new Rect(badgeRect.x, badgeRect.y, badgeRect.width, textSize.y), title);
                badgeRect.y += textSize.y;

                LayoutManager layout = new LayoutManager(badgeRect, 40f, 30f);

                List <BadgeDef> defs = new List <BadgeDef>(DefDatabase <BadgeDef> .AllDefsListForReading);
                defs.Insert(0, new BadgeDef("", Mod.GreyTex));

                foreach (BadgeDef def in defs)
                {
                    Rect brect = layout.CurRect;

                    Widgets.DrawHighlightIfMouseover(brect);
                    GUI.DrawTexture(brect, def.Symbol, ScaleMode.ScaleToFit);
                    Widgets.DraggableResult draggableResult = Widgets.ButtonInvisibleDraggable(brect, false);
                    if (draggableResult == Widgets.DraggableResult.Dragged)
                    {
                        badgePainting[i] = true;
                    }
                    if ((badgePainting[i] && Mouse.IsOver(brect) && def.defName != cb.badges[i]) || AnyPressed(draggableResult))
                    {
                        cb.badges[i] = def.defName;
                        SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                    }
                    if (cb.badges[i] == def.defName)
                    {
                        Widgets.DrawBox(brect, 3);
                    }
                    TooltipHandler.TipRegion(brect, () => def.description, 3882382 + (int)brect.y * 17);
                    layout.Next();
                }
                if (!Input.GetMouseButton(0))
                {
                    badgePainting[i] = false;
                }
            }

            GUI.EndGroup();
        }
コード例 #9
0
        public static void DynamicMedicalCareSetter(Rect rect, ref MedicalCareCategory medCare)
        {
            //modified CareSetter/UI panel
            Widgets.DrawHighlightIfMouseover(rect);

            //aspect = number of squares rect fits along the width that are height x height
            int aspect = Mathf.FloorToInt(rect.width / rect.height);

            //initialScaleFac is how much to scale the texture to make it the height of the rect
            float initialScaleFac = medList[0].tex.height / rect.height;

            List <ModMedicine> localMedList = medList;

            if (androids && currentMedCarePawn != null)
            {
                localMedList = GetAndroidCompatMedList(currentMedCarePawn);
            }

            int nRows  = 1;
            int nInRow = 0;

            if (localMedList.Count > aspect * 2)
            {
                nRows = Mathf.CeilToInt(Mathf.Sqrt((float)localMedList.Count / (float)aspect));
            }
            int nPerRow = Mathf.CeilToInt((float)localMedList.Count / (float)nRows);


            float scaleFac = Mathf.Min((float)aspect / (localMedList.Count), 1.0f);

            if (nRows > 1)
            {
                scaleFac = 1.0f / nRows;
            }
            //scaleFac *= initialScaleFac;

            Rect rect2 = new Rect(rect.x + 0.5f * (rect.width - (nPerRow * scaleFac * rect.height)), rect.y + (1 - scaleFac * nRows) * 0.5f * rect.height, rect.height * scaleFac, rect.height * scaleFac);

            for (int i = 0; i < localMedList.Count; i++)
            {
                ModMedicine med = localMedList[i];

                //if (medCare == med.care)
                if ((i > 1 && med.potency == indexedMedList[(int)medCare].potency) || medCare == med.care)
                {
                    Widgets.DrawBox(rect2, 1);
                }

                if ((med.potency <= indexedMedList[(int)medCare].potency && i != 0 && (int)medCare != 0) || medCare == med.care)
                {
                    Widgets.DrawBoxSolid(rect2, new Color(0, 1, 1, 0.3f));
                }

                Widgets.DrawHighlightIfMouseover(rect2);
                GUI.DrawTexture(rect2, med.tex);

                Widgets.DraggableResult draggableResult = Widgets.ButtonInvisibleDraggable(rect2, false);
                if (draggableResult == Widgets.DraggableResult.Dragged)
                {
                    medicalCarePainting = true;
                }
                if ((medicalCarePainting && Mouse.IsOver(rect2) && medCare != med.care) || (draggableResult == Widgets.DraggableResult.Pressed || draggableResult == Widgets.DraggableResult.DraggedThenPressed))
                {
                    medCare = med.care;
                    SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                }
                TooltipHandler.TipRegion(rect2, () => med.care.GetLabel(), 632165 + (int)med.care * 17);

                nInRow++;

                rect2.x += rect2.width;
                if (nInRow == nPerRow)
                {
                    nInRow   = 0;
                    rect2.y += rect2.height;
                    rect2.x  = rect.x + 0.5f * (rect.width - (nPerRow * scaleFac * rect.height));
                }
            }
            if (!Input.GetMouseButton(0))
            {
                medicalCarePainting = false;
            }
        }