Пример #1
0
        private void DrawThingRow(ref float y, float width, Thing thing, bool inventory = false)
        {
            Rect rect = new Rect(0f, y, width, 28f);

            Widgets.InfoCardButton(rect.width - 24f, y, thing);
            rect.width -= 24f;
            bool flag = false;

            if (CanControl && (inventory || CanControlColonist || (SelPawnForGear.Spawned && !SelPawnForGear.Map.IsPlayerHome)))
            {
                Rect rect2 = new Rect(rect.width - 24f, y, 24f, 24f);
                bool flag2;
                if (SelPawnForGear.IsQuestLodger())
                {
                    if (inventory)
                    {
                        flag2 = true;
                    }
                    else
                    {
                        CompBiocodable compBiocodable = thing.TryGetComp <CompBiocodable>();
                        if (compBiocodable != null && compBiocodable.Biocoded)
                        {
                            flag2 = true;
                        }
                        else
                        {
                            CompBladelinkWeapon compBladelinkWeapon = thing.TryGetComp <CompBladelinkWeapon>();
                            flag2 = (compBladelinkWeapon != null && compBladelinkWeapon.bondedPawn == SelPawnForGear);
                        }
                    }
                }
                else
                {
                    flag2 = false;
                }
                Apparel apparel;
                bool    flag3 = (apparel = (thing as Apparel)) != null && SelPawnForGear.apparel != null && SelPawnForGear.apparel.IsLocked(apparel);
                flag = (flag2 | flag3);
                if (Mouse.IsOver(rect2))
                {
                    if (flag3)
                    {
                        TooltipHandler.TipRegion(rect2, "DropThingLocked".Translate());
                    }
                    else if (flag2)
                    {
                        TooltipHandler.TipRegion(rect2, "DropThingLodger".Translate());
                    }
                    else
                    {
                        TooltipHandler.TipRegion(rect2, "DropThing".Translate());
                    }
                }
                Color color          = flag ? Color.grey : Color.white;
                Color mouseoverColor = flag ? color : GenUI.MouseoverColor;
                if (Widgets.ButtonImage(rect2, TexButton.Drop, color, mouseoverColor, !flag) && !flag)
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera();
                    InterfaceDrop(thing);
                }
                rect.width -= 24f;
            }
            if (CanControlColonist)
            {
                if ((thing.def.IsNutritionGivingIngestible || thing.def.IsNonMedicalDrug) && thing.IngestibleNow && base.SelPawn.WillEat(thing))
                {
                    Rect rect3 = new Rect(rect.width - 24f, y, 24f, 24f);
                    TooltipHandler.TipRegionByKey(rect3, "ConsumeThing", thing.LabelNoCount, thing);
                    if (Widgets.ButtonImage(rect3, TexButton.Ingest))
                    {
                        SoundDefOf.Tick_High.PlayOneShotOnCamera();
                        InterfaceIngest(thing);
                    }
                }
                rect.width -= 24f;
            }
            Rect rect4 = rect;

            rect4.xMin = rect4.xMax - 60f;
            CaravanThingsTabUtility.DrawMass(thing, rect4);
            rect.width -= 60f;
            if (Mouse.IsOver(rect))
            {
                GUI.color = HighlightColor;
                GUI.DrawTexture(rect, TexUI.HighlightTex);
            }
            if (thing.def.DrawMatSingle != null && thing.def.DrawMatSingle.mainTexture != null)
            {
                Widgets.ThingIcon(new Rect(4f, y, 28f, 28f), thing);
            }
            Text.Anchor = TextAnchor.MiddleLeft;
            GUI.color   = ThingLabelColor;
            Rect    rect5    = new Rect(36f, y, rect.width - 36f, rect.height);
            string  text     = thing.LabelCap;
            Apparel apparel2 = thing as Apparel;

            if (apparel2 != null && SelPawnForGear.outfits != null && SelPawnForGear.outfits.forcedHandler.IsForced(apparel2))
            {
                text += ", " + "ApparelForcedLower".Translate();
            }
            if (flag)
            {
                text += " (" + "ApparelLockedLower".Translate() + ")";
            }
            Text.WordWrap = false;
            Widgets.Label(rect5, text.Truncate(rect5.width));
            Text.WordWrap = true;
            if (Mouse.IsOver(rect))
            {
                string text2 = thing.DescriptionDetailed;
                if (thing.def.useHitPoints)
                {
                    text2 = text2 + "\n" + thing.HitPoints + " / " + thing.MaxHitPoints;
                }
                TooltipHandler.TipRegion(rect, text2);
            }
            y += 28f;
        }
        static void DrawApparelStats(ExtendedOutfit selectedOutfit, Vector2 cur, Rect canvas)
        {
            // header
            Rect statsHeaderRect = new Rect(cur.x, cur.y, canvas.width, 30f);

            cur.y      += 30f;
            Text.Anchor = TextAnchor.LowerLeft;
            Text.Font   = GameFont.Small;
            Widgets.Label(statsHeaderRect, ResourceBank.Strings.PreferedStats);
            Text.Anchor = TextAnchor.UpperLeft;

            // add button
            Rect addStatRect = new Rect(statsHeaderRect.xMax - 16f, statsHeaderRect.yMin + marginVertical, 16f, 16f);

            if (Widgets.ButtonImage(addStatRect, ResourceBank.Textures.AddButton))
            {
                var options = new List <FloatMenuOption>();
                foreach (var def in selectedOutfit.UnassignedStats.OrderBy(i => i.label).OrderBy(i => i.category.displayOrder))
                {
                    FloatMenuOption option = new FloatMenuOption(def.LabelCap, delegate
                    {
                        selectedOutfit.AddStatPriority(def, 0f);
                    });
                    options.Add(option);
                }

                Find.WindowStack.Add(new FloatMenu(options));
            }

            TooltipHandler.TipRegion(addStatRect, ResourceBank.Strings.StatPriorityAdd);

            // line
            GUI.color = Color.grey;
            Widgets.DrawLineHorizontal(cur.x, cur.y, canvas.width);
            GUI.color = Color.white;

            // some padding
            cur.y += marginVertical;

            var stats = selectedOutfit.StatPriorities.ToList();

            // main content in scrolling view
            Rect contentRect = new Rect(cur.x, cur.y, canvas.width, canvas.height - cur.y);
            Rect viewRect    = new Rect(contentRect)
            {
                height = 30f * stats.Count
            };

            if (viewRect.height > contentRect.height)
            {
                viewRect.width -= 20f;
            }

            Widgets.BeginScrollView(contentRect, ref scrollPosition, viewRect);

            GUI.BeginGroup(viewRect);
            cur = Vector2.zero;

            // none label
            if (stats.Count > 0)
            {
                // legend kind of thingy.
                Rect legendRect = new Rect(cur.x + (viewRect.width - 24) / 2, cur.y, (viewRect.width - 24) / 2, 20f);
                Text.Font   = GameFont.Tiny;
                GUI.color   = Color.grey;
                Text.Anchor = TextAnchor.LowerLeft;
                Widgets.Label(legendRect, "-" + MaxValue.ToString("N1"));
                Text.Anchor = TextAnchor.LowerRight;
                Widgets.Label(legendRect, MaxValue.ToString("N1"));
                Text.Anchor = TextAnchor.UpperLeft;
                Text.Font   = GameFont.Small;
                GUI.color   = Color.white;
                cur.y      += 15f;

                // statPriority weight sliders
                foreach (var stat in stats)
                {
                    DrawStatRow(selectedOutfit, stat, ref cur, viewRect.width);
                }
            }
            else
            {
                Rect noneLabel = new Rect(cur.x, cur.y, viewRect.width, 30f);
                GUI.color   = Color.grey;
                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(noneLabel, ResourceBank.Strings.None);
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
                cur.y      += 30f;
            }

            GUI.EndGroup();
            Widgets.EndScrollView();
        }
    public void DoSettingsWindowContents(Rect inRect)
    {
        var listingStandard = new Listing_Standard();

        listingStandard.Begin(inRect);
        listingStandard.Label("CPT.combatpower.label".Translate());
        if (listingStandard.ButtonTextLabeled("CPT.reset.label".Translate(), "CPT.reset.button".Translate()))
        {
            foreach (var keyValue in CombatPowerTweakerMod.Settings.vanillaMemory)
            {
                CombatPowerTweakerMod.Settings.modifiedStats[keyValue.Key] = keyValue.Value;
            }
        }

        if (listingStandard.ButtonTextLabeled("CPT.percentup.label".Translate(), "CPT.percentup.button".Translate()))
        {
            foreach (var keyValue in CombatPowerTweakerMod.Settings.vanillaMemory)
            {
                CombatPowerTweakerMod.Settings.modifiedStats[keyValue.Key] *= 1.1f;
                if (CombatPowerTweakerMod.Settings.modifiedStats[keyValue.Key] > maxValue)
                {
                    CombatPowerTweakerMod.Settings.modifiedStats[keyValue.Key] = maxValue;
                }
            }
        }

        if (listingStandard.ButtonTextLabeled("CPT.percentdown.label".Translate(),
                                              "CPT.percentdown.button".Translate()))
        {
            foreach (var keyValue in CombatPowerTweakerMod.Settings.vanillaMemory)
            {
                CombatPowerTweakerMod.Settings.modifiedStats[keyValue.Key] *= 0.9f;
            }
        }

        var searchLabel = listingStandard.Label("CPT.search.label".Translate());

        searchText =
            Widgets.TextField(
                new Rect(searchLabel.position + new Vector2((inRect.width / 3 * 2) - (searchSize.x / 3 * 2), 0),
                         searchSize),
                searchText);
        TooltipHandler.TipRegion(new Rect(
                                     searchLabel.position + new Vector2((inRect.width / 2) - (searchSize.x / 2), 0),
                                     searchSize), "CPT.search.label".Translate());
        var keys = modifiedStats.Keys.ToList();

        if (!string.IsNullOrEmpty(searchText))
        {
            keys = keys.Where(s => s.ToLower().Contains(searchText.ToLower())).ToList();
        }

        listingStandard.GapLine();

        listingStandard.End();

        keys.Reverse();
        var rect  = new Rect(inRect.x, inRect.y + 160f, inRect.width, inRect.height - 160f);
        var rect2 = new Rect(0f, 0f, inRect.width - 30f, keys.Count * 35);

        Widgets.BeginScrollView(rect, ref scrollPosition, rect2);
        var listingScroll = new Listing_Standard();

        listingScroll.Begin(rect2);
        for (var num = keys.Count - 1; num >= 0; num--)
        {
            var test = modifiedStats[keys[num]];
            listingScroll.AddLabeledSlider(
                $"{pawnKindNames[keys[num]].CapitalizeFirst()} ({vanillaMemory[keys[num]]})", ref test, 1f,
                maxValue, test.ToString(), null, 1);
            modifiedStats[keys[num]] = test;
        }

        listingScroll.End();
        Widgets.EndScrollView();
        Write();
    }
Пример #4
0
        public override void DoWindowContents(Rect rect)
        {
            base.DoWindowContents(rect);
            var hostilityResponseRect = new Rect(rect.x + 20, rect.y + 25, 24, 24);

            HostilityResponseModeUtilityGroup.DrawResponseButton(hostilityResponseRect, this.colonistGroup, true);

            var medicalCareRect = new Rect(rect.x + 50, rect.y + 25, 24, 24);

            MedicalCareUtilityGroup.MedicalCareSelectButton(medicalCareRect, this.colonistGroup);

            if (ModsConfig.IdeologyActive)
            {
                var groupColorRect = new Rect(hostilityResponseRect.x, hostilityResponseRect.yMax + 7, 24, 24);
                GUI.DrawTexture(groupColorRect.ExpandedBy(5), ContentFinder <Texture2D> .Get("Things/Item/Dye/Dye_a"));
                if (Mouse.IsOver(groupColorRect))
                {
                    TooltipHandler.TipRegion(groupColorRect, Strings.GroupColorTooltip);
                    Widgets.DrawHighlight(groupColorRect);
                    if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                    {
                        var colorPicker = new Dialog_ColorPicker(this, colonistGroup, this.windowRect, Textures.DyeMenu);
                        Find.WindowStack.Add(colorPicker);
                        SoundDefOf.Tick_High.PlayOneShotOnCamera();
                    }
                }
            }
            var timeAssignmentSelectorGridRect = new Rect(rect.x + 80, rect.y + 20, 191f, 65f);

            TimeAssignmentSelector.DrawTimeAssignmentSelectorGrid(timeAssignmentSelectorGridRect);
            var timeTableHeaderRect = new Rect(rect.x + 10, rect.y + 85f, rect.width - 20f, 20f);

            DoTimeTableHeader(timeTableHeaderRect);
            var timeTableRect = new Rect(rect.x + 10, rect.y + 105, rect.width - 20f, 30f);

            DoTimeTableCell(timeTableRect);


            var policyButtonWidth = rect.width * 0.45f;
            var areaHeaderRect    = new Rect(rect.x + 10, rect.y + 195f, policyButtonWidth, 20f);

            DoAreaHeader(areaHeaderRect);

            var check = new Vector2(areaHeaderRect.xMax - 25f, areaHeaderRect.yMax - 34);

            Widgets.Checkbox(check, ref this.colonistGroup.groupAreaEnabled);
            var drawBoxRect = new Rect(check, new Vector2(24f, 24f));

            Widgets.DrawBox(drawBoxRect);
            TooltipHandler.TipRegion(drawBoxRect, Strings.GroupAreaTooltip);

            var areaRect = new Rect(rect.x + 10, rect.y + 205, policyButtonWidth, 30f);

            DoAreaCell(areaRect);

            var outfitHeaderRect = new Rect(rect.x + policyButtonWidth + 30, rect.y + 195f, policyButtonWidth, 20f);

            DoOutfitHeader(outfitHeaderRect);

            check = new Vector2(outfitHeaderRect.xMax - 26f, outfitHeaderRect.yMax - 33);
            Widgets.Checkbox(check, ref this.colonistGroup.groupOutfitEnabled);
            drawBoxRect = new Rect(check, new Vector2(24f, 24f));
            Widgets.DrawBox(drawBoxRect);
            TooltipHandler.TipRegion(drawBoxRect, Strings.GroupFoodTooltip);

            var outfitRect = new Rect(rect.x + policyButtonWidth + 30, rect.y + 205, policyButtonWidth, 30f);

            DoOutfitCell(outfitRect);

            var drugPolicyHeaderRect = new Rect(rect.x + 10, rect.y + 305f, policyButtonWidth, 20f);

            DoDrugPolicyHeader(drugPolicyHeaderRect);

            check = new Vector2(drugPolicyHeaderRect.xMax - 25f, drugPolicyHeaderRect.yMax - 33);
            Widgets.Checkbox(check, ref this.colonistGroup.groupDrugPolicyEnabled);
            drawBoxRect = new Rect(check, new Vector2(24f, 24f));
            Widgets.DrawBox(drawBoxRect);
            TooltipHandler.TipRegion(drawBoxRect, Strings.GroupDrugsTooltip);

            var drugPolicyRect = new Rect(rect.x + 10, rect.y + 315, policyButtonWidth, 30f);

            DoDrugPolicyCell(drugPolicyRect);

            var foodHeaderRect = new Rect(rect.x + policyButtonWidth + 30, rect.y + 305f, policyButtonWidth, 20f);

            DoFoodHeader(foodHeaderRect);

            check = new Vector2(foodHeaderRect.xMax - 26f, foodHeaderRect.yMax - 33);
            Widgets.Checkbox(check, ref this.colonistGroup.groupFoodRestrictionEnabled);
            drawBoxRect = new Rect(check, new Vector2(24f, 24f));
            Widgets.DrawBox(drawBoxRect);
            TooltipHandler.TipRegion(drawBoxRect, Strings.GroupFoodTooltip);

            var foodRect = new Rect(rect.x + policyButtonWidth + 30, rect.y + 315, policyButtonWidth, 30f);

            DoFoodCell(foodRect);

            if (!(ModCompatibility.assignManagerSaveCurrentStateMethod is null))
            {
                ModCompatibility.assignManagerSaveCurrentStateMethod.Invoke(null, new object[] { this.colonistGroup.pawns });
            }
            Text.Anchor = TextAnchor.MiddleCenter;
            var moodTexture = GetMoodTexture(out string moodLabel);
            var moodRect    = new Rect(rect.x + policyButtonWidth + 135f, rect.y + 25, moodTexture.width, moodTexture.height);

            GUI.DrawTexture(moodRect, moodTexture);
            var moodLabelRect = new Rect(moodRect.x, moodRect.y + moodTexture.height, 45, 24);

            Widgets.Label(moodLabelRect, moodLabel);
            TooltipHandler.TipRegion(moodRect, Strings.MoodIconTooltip);

            var healthTexture = GetHealthTexture(out string healthPercent);
            var healthRect    = new Rect(moodRect.x + 45f, moodRect.y, healthTexture.width, healthTexture.height);

            GUI.DrawTexture(healthRect, healthTexture);
            var healthLabelRect = new Rect(healthRect.x, healthRect.y + healthRect.height, 40, 24);

            Widgets.Label(healthLabelRect, healthPercent);
            TooltipHandler.TipRegion(healthRect, Strings.HealthIconTooltip);

            var restTexture = GetRestTexture(out string restPercent);
            var restRect    = new Rect(healthRect.x + 45f, healthRect.y, restTexture.width, restTexture.height);

            GUI.DrawTexture(restRect, restTexture);
            var restLabelRect = new Rect(restRect.x, restRect.y + restRect.height, 40, 24);

            Widgets.Label(restLabelRect, restPercent);
            TooltipHandler.TipRegion(restRect, Strings.RestIconTooltip);

            var foodTexture  = GetFoodTexture(out string foodPercent);
            var foodStatRect = new Rect(restRect.x + 45f, restRect.y, foodTexture.width, foodTexture.height);

            GUI.DrawTexture(foodStatRect, foodTexture);
            var foodLabelRect = new Rect(foodStatRect.x, foodStatRect.y + foodStatRect.height, 40, 24);

            Widgets.Label(foodLabelRect, foodPercent);
            TooltipHandler.TipRegion(foodStatRect, Strings.HungerIconTooltip);

            var   pawnRowRect = new Rect(rect.x + 15, rect.y + (rect.height - 110f), rect.width - 30f, TacticalColonistBar.DefaultBaseSize.y + 42f);
            var   pawnMargin  = 20f;
            float listWidth   = this.colonistGroup.pawns.Count * (TacticalColonistBar.DefaultBaseSize.x + pawnMargin);
            Rect  rect1       = new Rect(pawnRowRect.x, pawnRowRect.y, listWidth, pawnRowRect.height - 16f);

            Widgets.BeginScrollView(pawnRowRect, ref scrollPosition, rect1);

            for (var i = 0; i < this.colonistGroup.pawns.Count; i++)
            {
                var pawnRect = new Rect(pawnRowRect.x + 13f + (i * (TacticalColonistBar.DefaultBaseSize.x + pawnMargin)), pawnRowRect.y + 17, TacticalColonistBar.DefaultBaseSize.x, TacticalColonistBar.DefaultBaseSize.y);
                DrawColonist(pawnRect, this.colonistGroup.pawns[i], this.colonistGroup.pawns[i].Map, false, false);
                HandleClicks(pawnRect, this.colonistGroup.pawns[i]);
            }

            for (var i = 0; i < this.colonistGroup.pawns.Count; i++)
            {
                var pawnRect = new Rect(pawnRowRect.x + 13f + (i * (TacticalColonistBar.DefaultBaseSize.x + pawnMargin)), pawnRowRect.y + 17, TacticalColonistBar.DefaultBaseSize.x, TacticalColonistBar.DefaultBaseSize.y);
                DrawPawnArrows(pawnRect, this.colonistGroup.pawns[i]);
            }

            Widgets.EndScrollView();
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.color   = Color.white;
        }
Пример #5
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth, GizmoRenderParms parms)
        {
            Rect rect = new Rect(topLeft.x, topLeft.y, this.GetWidth(maxWidth), 75f);
            bool flag = false;

            if (Mouse.IsOver(rect))
            {
                flag      = true;
                GUI.color = GenUI.MouseoverColor;
            }
            Texture2D badTex = LockUtility.GetData(parent).WantedState.locked ? lockTexture : unlockTexture;

            if (badTex == null)
            {
                badTex = BaseContent.BadTex;
            }
            GUI.DrawTexture(rect, BGTex);
            GUI.DrawTexture(rect, badTex);
            MouseoverSounds.DoRegion(rect, SoundDefOf.Mouseover_Command);
            bool    flag2   = false;
            KeyCode keyCode = (this.hotKey != null) ? hotKey.MainKey : KeyCode.None;

            if (keyCode != KeyCode.None && !GizmoGridDrawer.drawnHotKeys.Contains(keyCode))
            {
                Rect rect2 = new Rect(rect.x + 5f, rect.y + 5f, rect.width - 10f, 18f);
                Widgets.Label(rect2, keyCode.ToStringReadable());
                GizmoGridDrawer.drawnHotKeys.Add(keyCode);
                if (hotKey.KeyDownEvent)
                {
                    flag2 = true;
                    Event.current.Use();
                }
            }
            if (Widgets.ButtonInvisible(rect, false))
            {
                flag2 = true;
            }
            string labelCap = LabelCap;

            if (!labelCap.NullOrEmpty())
            {
                float num   = Text.CalcHeight(labelCap, rect.width);
                Rect  rect3 = new Rect(rect.x, rect.yMax - num + 12f, rect.width, num);
                GUI.DrawTexture(rect3, TexUI.GrayTextBG);
                GUI.color   = Color.white;
                Text.Anchor = TextAnchor.UpperCenter;
                Widgets.Label(rect3, labelCap);
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
            }
            GUI.color = Color.white;
            if (DoTooltip)
            {
                TipSignal tip = Desc;
                if (disabled && !disabledReason.NullOrEmpty())
                {
                    string text = tip.text;
                    tip.text = string.Concat(new string[]
                    {
                        text,
                        "\n\n",
                        "DisabledCommand".Translate(),
                        ": ",
                        disabledReason
                    });
                }
                TooltipHandler.TipRegion(rect, tip);
            }
            if (!HighlightTag.NullOrEmpty() && (Find.WindowStack.FloatMenu == null || !Find.WindowStack.FloatMenu.windowRect.Overlaps(rect)))
            {
                UIHighlighter.HighlightOpportunity(rect, HighlightTag);
            }
            if (flag2)
            {
                if (disabled)
                {
                    if (!disabledReason.NullOrEmpty())
                    {
                        Messages.Message(disabledReason, MessageTypeDefOf.RejectInput);
                    }
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                if (!TutorSystem.AllowAction(TutorTagSelect))
                {
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                GizmoResult result = new GizmoResult(GizmoState.Interacted, Event.current);
                TutorSystem.Notify_Event(TutorTagSelect);
                return(result);
            }
            else
            {
                if (flag)
                {
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                return(new GizmoResult(GizmoState.Clear, null));
            }
        }
        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));
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            // start GUI.color is the transparency set by our floatmenu parent
            // store it, so we can apply it to all subsequent colours
            Color transparency = GUI.color;

            // below is 99% copypasta from Designator_Build, with minor naming changes and taking account of transparency.
            var buttonRect = new Rect(topLeft.x, topLeft.y, maxWidth, 75f);
            var mouseover  = false;

            if (Mouse.IsOver(buttonRect))
            {
                mouseover = true;
                GUI.color = GenUI.MouseoverColor * transparency;
            }
            Texture2D tex = icon;

            if (tex == null)
            {
                tex = BaseContent.BadTex;
            }
            GUI.DrawTexture(buttonRect, BGTex);
            MouseoverSounds.DoRegion(buttonRect, SoundDefOf.Mouseover_Command);
            GUI.color = IconDrawColor * transparency;
            Widgets.DrawTextureFitted(new Rect(buttonRect), tex, iconDrawScale * 0.85f, iconProportions,
                                      iconTexCoords);
            GUI.color = Color.white * transparency;
            var     clicked = false;
            KeyCode keyCode = hotKey != null ? hotKey.MainKey : KeyCode.None;

            if (keyCode != KeyCode.None && !GizmoGridDrawer.drawnHotKeys.Contains(keyCode))
            {
                Widgets.Label(new Rect(buttonRect.x + 5f, buttonRect.y + 5f, 16f, 18f), keyCode.ToString());
                GizmoGridDrawer.drawnHotKeys.Add(keyCode);
                if (hotKey.KeyDownEvent)
                {
                    clicked = true;
                    Event.current.Use();
                }
            }
            if (Widgets.ButtonInvisible(buttonRect))
            {
                clicked = true;
            }
            string labelCap = LabelCap;

            if (!labelCap.NullOrEmpty())
            {
                float height = Text.CalcHeight(labelCap, buttonRect.width) - 2f;
                var   rect2  = new Rect(buttonRect.x, (float)(buttonRect.yMax - (double)height + 12.0),
                                        buttonRect.width, height);
                GUI.DrawTexture(rect2, TexUI.GrayTextBG);
                GUI.color   = Color.white * transparency;
                Text.Anchor = TextAnchor.UpperCenter;
                Widgets.Label(rect2, labelCap);
                Text.Anchor = TextAnchor.UpperLeft;
            }
            GUI.color = Color.white;
            if (DoTooltip)
            {
                TipSignal tip = Desc;
                if (disabled && !disabledReason.NullOrEmpty())
                {
                    TipSignal local = tip;
                    local.text += "\n\nDISABLED: " + disabledReason;
                }
                TooltipHandler.TipRegion(buttonRect, tip);
            }
            // TODO: Reimplement tutor.
            //if( !tutorHighlightTag.NullOrEmpty() )
            //    TutorUIHighlighter.HighlightOpportunity( tutorHighlightTag, buttonRect );

            if (clicked)
            {
                if (!disabled)
                {
                    return(new GizmoResult(GizmoState.Interacted, Event.current));
                }
                if (!disabledReason.NullOrEmpty())
                {
                    Messages.Message(disabledReason, MessageTypeDefOf.RejectInput);
                }
                return(new GizmoResult(GizmoState.Mouseover, null));
            }

            if (mouseover)
            {
                return(new GizmoResult(GizmoState.Mouseover, null));
            }

            return(new GizmoResult(GizmoState.Clear, null));
        }
 /// <summary>
 /// This is a helper method inserted by the transpiler above.  This handles creating the tooltip since doing that in IL would be hard for others to maintain.
 /// </summary>
 /// <param name="area">Rect type which defines the area of the tooltip, same as the button graphic area.</param>
 /// <param name="pawn">Pawn type which is used to identify the tooltip object.</param>
 /// <param name="untranslated">string type which is an untranslated string such as "CE_Outfits" or "CE_Drugs"</param>
 /// <remarks>Makes direct use of PawnColumnWorker_Loadout.textGetter()  Because the call to this is being inserted, it must be public.</remarks>
 public static void DoToolTip(Rect area, Pawn pawn, string untranslated)
 {
     TooltipHandler.TipRegion(area, new TipSignal(PawnColumnWorker_Loadout.textGetter(untranslated), pawn.GetHashCode() * 613));
 }
Пример #9
0
        public void Draw()
        {
            TextAnchor saveAnchor = Text.Anchor;
            Color      saveColor  = GUI.color;
            GameFont   saveFont   = Text.Font;

            try {
                // Adjust the width of the rectangle if the field has next and previous buttons.
                Rect fieldRect = rect;
                if (previousAction != null)
                {
                    fieldRect.x     += 12;
                    fieldRect.width -= 12;
                }
                if (nextAction != null)
                {
                    fieldRect.width -= 12;
                }

                // If the field is not enabled, draw the disabled background and then return.
                if (!enabled)
                {
                    GUI.color = Style.ColorControlDisabled;
                    Widgets.DrawAtlas(fieldRect, Textures.TextureFieldAtlas);
                    return;
                }

                // Draw the field background.
                GUI.color = Color.white;
                Widgets.DrawAtlas(fieldRect, Textures.TextureFieldAtlas);

                // Draw the label.
                Text.Anchor = TextAnchor.MiddleCenter;
                Rect textRect = new Rect(rect.x, rect.y + 1, rect.width, rect.height);
                if (clickAction != null && fieldRect.Contains(Event.current.mousePosition))
                {
                    GUI.color = Color.white;
                }
                else
                {
                    GUI.color = this.Color;
                }
                if (label != null)
                {
                    Widgets.Label(textRect, label);
                }
                GUI.color = Color.white;

                // Handle the tooltip.
                if (tip != null)
                {
                    TooltipHandler.TipRegion(fieldRect, tip);
                }

                // Draw the previous button and handle any click events on it.
                if (previousAction != null)
                {
                    Rect buttonRect = new Rect(fieldRect.x - 17, fieldRect.MiddleY() - 8, 16, 16);
                    if (buttonRect.Contains(Event.current.mousePosition))
                    {
                        GUI.color = Style.ColorButtonHighlight;
                    }
                    else
                    {
                        GUI.color = Style.ColorButton;
                    }
                    GUI.DrawTexture(buttonRect, Textures.TextureButtonPrevious);
                    if (Widgets.ButtonInvisible(buttonRect, false))
                    {
                        // TODO SoundDefOf.Tick_Tiny.PlayOneShotOnCamera();
                        previousAction();
                    }
                }

                // Draw the next button and handle any click events on it.
                if (nextAction != null)
                {
                    Rect buttonRect = new Rect(fieldRect.xMax + 1, fieldRect.MiddleY() - 8, 16, 16);
                    if (buttonRect.Contains(Event.current.mousePosition))
                    {
                        GUI.color = Style.ColorButtonHighlight;
                    }
                    else
                    {
                        GUI.color = Style.ColorButton;
                    }
                    GUI.DrawTexture(buttonRect, Textures.TextureButtonNext);
                    if (Widgets.ButtonInvisible(buttonRect, false))
                    {
                        // TODO SoundDefOf.Tick_Tiny.PlayOneShotOnCamera();
                        nextAction();
                    }
                }

                // Handle any click event on the field.
                if (clickAction != null)
                {
                    if (ClickRect == null)
                    {
                        if (Widgets.ButtonInvisible(fieldRect, false))
                        {
                            clickAction();
                        }
                    }
                    else
                    {
                        if (Widgets.ButtonInvisible(ClickRect.Value, false))
                        {
                            clickAction();
                        }
                    }
                }
            }
            finally {
                Text.Anchor = saveAnchor;
                GUI.color   = saveColor;
                Text.Font   = saveFont;
            }
        }
Пример #10
0
        public override void PreOpen()
        {
            base.PreOpen();

            /*
             * note: this code is in PreOpen() rather than in the ctor because otherwise RimWorld would crash (more precisely, Unity crashes).
             * I can't remember exactly where, but it deals with Unity calculating the text size of a floating menu.
             * So better to let this code here rather than in the ctor.
             */
            if (Enumerable.Any(_bottomButtonsDescriptorList, buttonDesctipor => buttonDesctipor.Label == "Load / Save"))
            {
                return;
            }

            var buttonSaveLoadPreset = new ButtonDescriptor("Load / Save", "Load or Save Filter Presets");

            buttonSaveLoadPreset.AddFloatMenuOption("Save", delegate
            {
                //_userData.PresetManager.TestSave();
                var tab = TabController.TabById("LoadSave") as TabLoadSave;
                if (tab == null)
                {
                    return;
                }

                tab.LoadSaveMode = LoadSaveMode.Save;
                TabController.SetSelectedTabById("LoadSave");
            }, delegate
            {
                var mousePos = Event.current.mousePosition;
                var rect     = new Rect(mousePos.x, mousePos.y, 30f, 30f);

                TooltipHandler.TipRegion(rect, "Save current filter states to a preset.");
            }
                                                    );
            buttonSaveLoadPreset.AddFloatMenuOption("Load", delegate
            {
                //_userData.PresetManager.TestLoad();
                var tab = TabController.TabById("LoadSave") as TabLoadSave;
                if (tab == null)
                {
                    return;
                }

                tab.LoadSaveMode = LoadSaveMode.Load;
                TabController.SetSelectedTabById("LoadSave");
            }, delegate
            {
                var mousePos = Event.current.mousePosition;
                var rect     = new Rect(mousePos.x, mousePos.y, 30f, 30f);

                TooltipHandler.TipRegion(rect, "Load a preset.");
            }
                                                    );
            buttonSaveLoadPreset.AddFloatMenu("Select Action");
            _bottomButtonsDescriptorList.Add(buttonSaveLoadPreset);

            // do not display the "close" button while playing (the "World" button on bottom menu bar was clicked)
            //    otherwise there's no way to get the window back...
            if (Current.ProgramState == ProgramState.Playing)
            {
                if (_bottomButtonsDescriptorList.Contains(_buttonCloseDescriptor))
                {
                    _bottomButtonsDescriptorList.Remove(_buttonCloseDescriptor);
                }
            }
            else
            {
                if (!_bottomButtonsDescriptorList.Contains(_buttonCloseDescriptor))
                {
                    _bottomButtonsDescriptorList.Add(_buttonCloseDescriptor);
                }
            }
        }
Пример #11
0
        protected void AddMinimizedWindowContent(Listing_Standard listingStandard, Rect inRect)
        {
            /* constants used for GUI elements */

            // default line height
            const float gapLineHeight = 4f;
            // default visual element height
            const float elementHeight = 30f;

            //check if we have something to display (tiles)
            var matchingTiles      = PrepareLanding.Instance.TileFilter.AllMatchingTiles;
            var matchingTilesCount = matchingTiles.Count;

            if (matchingTilesCount == 0)
            {
                // revert to initial window size if needed
                MinimizedWindow.windowRect.height = MinimizedWindow.InitialSize.y;
                return;
            }

            /*
             * Buttons
             */

            if (listingStandard.ButtonText("Clear Filtered Tiles"))
            {
                // clear everything
                PrepareLanding.Instance.TileFilter.ClearMatchingTiles();

                // reset starting display index
                _tileDisplayIndexStart = 0;

                // reset selected index
                _selectedTileIndex = -1;

                // don't go further as there are no tile content to draw
                return;
            }

            var buttonsRectSpace = listingStandard.GetRect(30f);
            var splittedRect     = buttonsRectSpace.SplitRectWidthEvenly(_minimizedWindowButtonsDescriptorList.Count);

            for (var i = 0; i < _minimizedWindowButtonsDescriptorList.Count; i++)
            {
                // get button descriptor
                var buttonDescriptor = _minimizedWindowButtonsDescriptorList[i];

                // display button; if clicked: call the related action
                if (Widgets.ButtonText(splittedRect[i], buttonDescriptor.Label))
                {
                    buttonDescriptor.Action();
                }

                // display tool-tip (if any)
                if (!string.IsNullOrEmpty(buttonDescriptor.ToolTip))
                {
                    TooltipHandler.TipRegion(splittedRect[i], buttonDescriptor.ToolTip);
                }
            }

            /*
             * Display label (where we actually are in the tile list)
             */

            // number of elements (tiles) to display
            var itemsToDisplay = Math.Min(matchingTilesCount - _tileDisplayIndexStart, MaxDisplayedTileWhenMinimized);

            // label to display where we actually are in the tile list
            GenUI.SetLabelAlign(TextAnchor.MiddleCenter);
            var heightBefore = listingStandard.StartCaptureHeight();

            listingStandard.Label(
                $"{_tileDisplayIndexStart}: {_tileDisplayIndexStart + itemsToDisplay - 1} / {matchingTilesCount - 1}",
                elementHeight);
            GenUI.ResetLabelAlign();
            var counterLabelRect = listingStandard.EndCaptureHeight(heightBefore);

            Core.Gui.Widgets.DrawHighlightColor(counterLabelRect, Color.cyan, 0.50f);

            // add a gap before the scroll view
            listingStandard.Gap(gapLineHeight);

            /*
             * Calculate heights
             */

            // height of the scrollable outer Rect (visible portion of the scroll view, not the 'virtual' one)
            var maxScrollViewOuterHeight = inRect.height - listingStandard.CurHeight;

            // recalculate window height: initial size + visible scroll view height + current height of the listing standard (hence accounting for all buttons above)
            var newWindowHeight = MinimizedWindow.InitialSize.y + maxScrollViewOuterHeight + listingStandard.CurHeight;

            // minimized window height can't be more than 70% of the screen height
            MinimizedWindow.windowRect.height = Mathf.Min(newWindowHeight, UI.screenHeight * 0.70f);

            // height of the 'virtual' portion of the scroll view
            var scrollableViewHeight = itemsToDisplay * elementHeight + gapLineHeight * MaxDisplayedTileWhenMinimized;

            /*
             * Scroll view
             */
            var innerLs = listingStandard.BeginScrollView(maxScrollViewOuterHeight, scrollableViewHeight,
                                                          ref _scrollPosMatchingTiles, 16f);

            var endIndex = _tileDisplayIndexStart + itemsToDisplay;

            for (var i = _tileDisplayIndexStart; i < endIndex; i++)
            {
                var selectedTileId = matchingTiles[i];

                // get latitude & longitude for the tile
                var vector    = Find.WorldGrid.LongLatOf(selectedTileId);
                var labelText = $"{i}: {vector.y.ToStringLatitude()} {vector.x.ToStringLongitude()}";

                // display the label
                var labelRect = innerLs.GetRect(elementHeight);
                var selected  = i == _selectedTileIndex;
                if (Core.Gui.Widgets.LabelSelectable(labelRect, labelText, ref selected, TextAnchor.MiddleCenter))
                {
                    // go to the location of the selected tile
                    _selectedTileIndex = i;
                    Find.WorldInterface.SelectedTile = selectedTileId;
                    Find.WorldCameraDriver.JumpTo(Find.WorldGrid.GetTileCenter(Find.WorldInterface.SelectedTile));
                }
                // add a thin line between each label
                innerLs.GapLine(gapLineHeight);
            }

            listingStandard.EndScrollView(innerLs);
        }
Пример #12
0
        public static void DrawWorldList(ref Rect inRect, float margin, Vector2 closeButtonSize, List <UIEntry> worldEntries, List <UIEntry> saveGameEntries, Action <string> loadWorld, Action <string> deleteWorld, Action <string> convertWorld)
        {
            const int perRow = 3;
            var       gap    = (int)margin;

            inRect.width += gap;

            UITools.DrawBoxGridView(out _, out _, ref inRect, ref scrollPosition, perRow, gap,
                                    (i, boxRect) =>
            {
                var selectedList = i >= worldEntries.Count ? saveGameEntries : worldEntries;
                i = i >= worldEntries.Count ? i - worldEntries.Count : i;

                var isWorldEntries    = selectedList == worldEntries;
                var isSaveGameEntries = selectedList == saveGameEntries;

                var currentItem = selectedList[i];

                Widgets.DrawAltRect(boxRect);

                if (isWorldEntries)
                {
                    var deleteSize = boxRect.width / 8;

                    var deleteRect = new Rect(boxRect.x + boxRect.width - deleteSize, boxRect.y, deleteSize,
                                              deleteSize);

                    if (Widgets.ButtonImage(deleteRect, DeleteX))
                    {
                        deleteWorld(currentItem.Path);
                    }

                    TooltipHandler.TipRegion(deleteRect,
                                             "FilUnderscore.PersistentRimWorlds.Delete.World".Translate());

                    DrawTexture(boxRect, OpenFolder, out var textureRect, 0.3f, 0.2f);

                    const float nameMargin = 4f;

                    var worldNameRect = new Rect(boxRect.x + nameMargin, boxRect.y + nameMargin,
                                                 boxRect.width - nameMargin - deleteSize, textureRect.y - boxRect.y);

                    DrawLabel(worldNameRect, ((WorldUIEntry)currentItem).Name, currentItem);
                }
                else if (isSaveGameEntries)
                {
                    DrawTexture(boxRect, ConvertFile, out var textureRect, 0.48f, 0.42f);

                    const float nameMargin = 4f;

                    var saveNameRect = new Rect(boxRect.x + nameMargin, boxRect.y + nameMargin,
                                                boxRect.width - nameMargin, textureRect.y - boxRect.y);

                    DrawLabel(saveNameRect, Path.GetFileNameWithoutExtension(((SaveGameUIEntry)currentItem).Path),
                              currentItem);
                }

                Widgets.DrawHighlightIfMouseover(boxRect);

                if (!Widgets.ButtonInvisible(boxRect))
                {
                    return(true);
                }

                if (isWorldEntries)
                {
                    loadWorld(selectedList[i].Path);
                }
                else if (isSaveGameEntries)
                {
                    convertWorld(selectedList[i].Path);
                }

                return(true);
            }, worldEntries.Count + saveGameEntries.Count, null, closeButtonSize);
        }
Пример #13
0
        public static void DrawWorldSaveList(ref Rect inRect, float margin, Vector2 closeButtonSize, List <UIEntry> worldEntries,
                                             Action saveWorld, Action newWorld, Action <string> deleteWorld)
        {
            const int perRow = 3;
            var       gap    = (int)margin;

            inRect.width += gap;

            UITools.DrawBoxGridView(out _, out _, ref inRect, ref scrollPosition, perRow, gap, (i, boxRect) =>
            {
                if (i >= worldEntries.Count)
                {
                    return(false);
                }

                var currentItem = worldEntries[i];

                var currentWorld = new DirectoryInfo(currentItem.Path).FullName.EqualsIgnoreCase(
                    PersistentWorldManager.GetInstance().PersistentWorld.LoadSaver
                    .GetWorldFolderPath());

                if (currentWorld)
                {
                    Widgets.DrawHighlight(boxRect);
                }
                else
                {
                    Widgets.DrawAltRect(boxRect);
                }

                var deleteSize = 0f;

                if (!currentWorld)
                {
                    deleteSize = boxRect.width / 8;

                    var deleteRect = new Rect(boxRect.x + boxRect.width - deleteSize, boxRect.y, deleteSize,
                                              deleteSize);

                    if (Widgets.ButtonImage(deleteRect, DeleteX))
                    {
                        deleteWorld(currentItem.Path);
                    }

                    TooltipHandler.TipRegion(deleteRect,
                                             "FilUnderscore.PersistentRimWorlds.Delete.World".Translate());
                }

                DrawTexture(boxRect, OpenFolder, out var textureRect, 0.3f, 0.2f);

                const float nameMargin = 4f;

                var worldNameRect = new Rect(boxRect.x + nameMargin, boxRect.y + nameMargin,
                                             boxRect.width - nameMargin - deleteSize, textureRect.y - boxRect.y);

                DrawLabel(worldNameRect, ((WorldUIEntry)currentItem).Name, currentItem);

                if (!currentWorld)
                {
                    return(true);
                }

                Widgets.DrawHighlightIfMouseover(boxRect);

                if (Widgets.ButtonInvisible(boxRect))
                {
                    saveWorld();
                }

                return(true);
            }, worldEntries.Count + 1, (width, height) =>
            {
                var y = width * Mathf.Floor((float)worldEntries.Count / perRow) +
                        (worldEntries.Count / perRow) * gap;

                var boxRect = new Rect((width * (worldEntries.Count % perRow)) + (worldEntries.Count % perRow) * gap,
                                       y, width,
                                       width);

                Widgets.DrawHighlightIfMouseover(boxRect);
                Widgets.DrawAltRect(boxRect);

                if (Widgets.ButtonInvisible(boxRect))
                {
                    newWorld();
                }

                TooltipHandler.TipRegion(boxRect,
                                         "FilUnderscore.PersistentRimWorlds.Save.NewWorld".Translate());

                Widgets.DrawLine(new Vector2(boxRect.x + boxRect.width / 2, boxRect.y + boxRect.height / 3),
                                 new Vector2(boxRect.x + boxRect.width / 2, boxRect.y + boxRect.height * 0.66f), Color.white,
                                 1f);

                Widgets.DrawLine(new Vector2(boxRect.x + boxRect.width / 3, boxRect.y + boxRect.height / 2),
                                 new Vector2(boxRect.x + boxRect.width * 0.66f, boxRect.y + boxRect.height / 2), Color.white,
                                 1f);
            }, closeButtonSize);
        }
Пример #14
0
        internal MultiCheckboxState MultiCheckBoxLabel(MultiCheckboxState state, List <FloatMenuOption> floatMenuList, string keyGroup, string label = null, string infoText = null)
        {
            float lineHeight = Text.LineHeight;
            Rect  rect       = base.GetRect(lineHeight);

            base.Gap(this.verticalSpacing);
            rect.x     += 10f;
            rect.width -= 10f;

            Texture2D tex;

            if (state == MultiCheckboxState.On)
            {
                tex = Widgets.CheckboxOnTex;
            }
            else if (state == MultiCheckboxState.Off)
            {
                tex = Widgets.CheckboxOffTex;
            }
            else
            {
                tex = Widgets.CheckboxPartialTex;
            }

            Color color = Widgets.NormalOptionColor;

            // Checkbox
            Rect texRect = new Rect(rect.width - texSize.x, rect.y, texSize.x, texSize.y);

            MouseoverSounds.DoRegion(texRect);

            // Info Icon
            Rect      infoRect = new Rect(rect.x, rect.y, 22f, 22f);
            Texture2D infoTex  = ContentFinder <Texture2D> .Get("UI/Buttons/InfoButton", true);

            GUI.DrawTexture(infoRect, infoTex);

            // Text label
            Rect labelRect = new Rect(rect);

            labelRect.x = infoRect.width + 15f;
            Widgets.Label(labelRect, label);

            // InfoText, tooltip
            if (infoText != null)
            {
                TooltipHandler.TipRegion(infoRect, infoText);
            }

            // KeyGroup Button
            MakeFloatMenu(rect, keyGroup, floatMenuList);

            MultiCheckboxState stateCheck = (state != MultiCheckboxState.Off) ? MultiCheckboxState.Off : MultiCheckboxState.On;

            if (AnyPressed(Widgets.ButtonImageDraggable(texRect, tex)))
            {
                if (stateCheck == MultiCheckboxState.On)
                {
                    SoundDefOf.Checkbox_TurnedOn.PlayOneShotOnCamera(null);
                }
                else
                {
                    SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera(null);
                }
                return(stateCheck);
            }
            return(state);
        }
        public override void DoWindowContents(Rect rect)
        {
            base.DrawPageTitle(rect);
            GUI.BeginGroup(base.GetMainRect(rect, 0f, false));
            Text.Font = GameFont.Small;
            float num = 0f;

            Widgets.Label(new Rect(0f, num, 200f, 30f), "WorldSeed".Translate());
            Rect rect2 = new Rect(200f, num, 200f, 30f);

            this.seedString = Widgets.TextField(rect2, this.seedString);
            num            += 40f;
            Rect rect3 = new Rect(200f, num, 200f, 30f);

            if (Widgets.ButtonText(rect3, "RandomizeSeed".Translate(), true, false, true))
            {
                SoundDefOf.Tick_Tiny.PlayOneShotOnCamera(null);
                this.seedString = GenText.RandomSeedString();
            }
            num += 40f;
            Widgets.Label(new Rect(0f, num, 200f, 30f), "PlanetCoverage".Translate());
            Rect rect4 = new Rect(200f, num, 200f, 30f);

            if (Widgets.ButtonText(rect4, this.planetCoverage.ToStringPercent(), true, false, true))
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                float[] array = (!Prefs.DevMode) ? Page_CreateWorldParams.PlanetCoverages : Page_CreateWorldParams.PlanetCoveragesDev;
                for (int i = 0; i < array.Length; i++)
                {
                    float  coverage = array[i];
                    string text     = coverage.ToStringPercent();
                    if (coverage <= 0.1f)
                    {
                        text += " (dev)";
                    }
                    FloatMenuOption item = new FloatMenuOption(text, delegate()
                    {
                        if (this.planetCoverage != coverage)
                        {
                            this.planetCoverage = coverage;
                            if (this.planetCoverage == 1f)
                            {
                                Messages.Message("MessageMaxPlanetCoveragePerformanceWarning".Translate(), MessageTypeDefOf.CautionInput, false);
                            }
                        }
                    }, MenuOptionPriority.Default, null, null, 0f, null, null);
                    list.Add(item);
                }
                Find.WindowStack.Add(new FloatMenu(list));
            }
            TooltipHandler.TipRegion(new Rect(0f, num, rect4.xMax, rect4.height), "PlanetCoverageTip".Translate());
            num += 40f;
            Widgets.Label(new Rect(0f, num, 200f, 30f), "PlanetRainfall".Translate());
            Rect rect5 = new Rect(200f, num, 200f, 30f);

            this.rainfall = (OverallRainfall)Mathf.RoundToInt(Widgets.HorizontalSlider(rect5, (float)this.rainfall, 0f, (float)(OverallRainfallUtility.EnumValuesCount - 1), true, "PlanetRainfall_Normal".Translate(), "PlanetRainfall_Low".Translate(), "PlanetRainfall_High".Translate(), 1f));
            num          += 40f;
            Widgets.Label(new Rect(0f, num, 200f, 30f), "PlanetTemperature".Translate());
            Rect rect6 = new Rect(200f, num, 200f, 30f);

            this.temperature = (OverallTemperature)Mathf.RoundToInt(Widgets.HorizontalSlider(rect6, (float)this.temperature, 0f, (float)(OverallTemperatureUtility.EnumValuesCount - 1), true, "PlanetTemperature_Normal".Translate(), "PlanetTemperature_Low".Translate(), "PlanetTemperature_High".Translate(), 1f));
            GUI.EndGroup();
            base.DoBottomButtons(rect, "WorldGenerate".Translate(), "Reset".Translate(), new Action(this.Reset), true);
        }
Пример #16
0
        private static bool DrawIconForWeapon(ThingDef weapon, KeyValuePair <String, WeaponRecord> item, Rect contentRect, Vector2 iconOffset, int buttonID)
        {
            var     iconTex  = weapon.uiIcon;
            Color   color    = getColor(weapon);
            Color   colorTwo = getColor(weapon);
            Graphic g2       = null;

            if (weapon.graphicData != null && weapon.graphicData.Graphic != null)
            {
                Graphic g = weapon.graphicData.Graphic;
                g2 = weapon.graphicData.Graphic.GetColoredVersion(g.Shader, color, colorTwo);
            }

            var iconRect = new Rect(contentRect.x + iconOffset.x, contentRect.y + iconOffset.y, IconSize, IconSize);

            if (!contentRect.Contains(iconRect))
            {
                return(false);
            }

            string label = weapon.label;

            TooltipHandler.TipRegion(iconRect, label);

            MouseoverSounds.DoRegion(iconRect, SoundDefOf.Mouseover_Command);
            if (Mouse.IsOver(iconRect))
            {
                GUI.color = iconMouseOverColor;
                GUI.DrawTexture(iconRect, ContentFinder <Texture2D> .Get("square", true));
            }
            else if (item.Value.isException == true)
            {
                GUI.color = iconMouseOverColor;
                GUI.DrawTexture(iconRect, ContentFinder <Texture2D> .Get("square", true));
            }
            else
            {
                GUI.color = iconBaseColor;
                GUI.DrawTexture(iconRect, ContentFinder <Texture2D> .Get("square", true));
            }

            Texture resolvedIcon;

            if (!weapon.uiIconPath.NullOrEmpty())
            {
                resolvedIcon = weapon.uiIcon;
            }
            else if (g2 != null)
            {
                resolvedIcon = g2.MatSingle.mainTexture;
            }
            else
            {
                resolvedIcon = new Texture();
            }

            GUI.color = color;
            GUI.DrawTexture(iconRect, resolvedIcon);
            GUI.color = Color.white;

            if (Widgets.ButtonInvisible(iconRect, true))
            {
                Event.current.button = buttonID;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #17
0
        protected void DrawLoadPresetList(Rect inRect)
        {
            DrawEntryHeader("Preset Files: Load mode", backgroundColor: Color.green);

            var presetFiles = _userData.PresetManager.AllPresetFiles;

            if (presetFiles == null)
            {
                Log.ErrorOnce("[PrepareLanding] PresetManager.AllPresetFiles is null.", 0x1238cafe);
                return;
            }

            var presetFilesCount = presetFiles.Count;

            if (presetFiles.Count == 0)
            {
                ListingStandard.Label("No existing presets.");
                return;
            }

            // add a gap before the scroll view
            ListingStandard.Gap(DefaultGapLineHeight);

            /*
             * Buttons
             */

            var buttonsRectSpace = ListingStandard.GetRect(30f);
            var splittedRect     = buttonsRectSpace.SplitRectWidthEvenly(_buttonList.Count);

            for (var i = 0; i < _buttonList.Count; i++)
            {
                // get button descriptor
                var buttonDescriptor = _buttonList[i];

                // display button; if clicked: call the related action
                if (Widgets.ButtonText(splittedRect[i], buttonDescriptor.Label))
                {
                    buttonDescriptor.Action();
                }

                // display tool-tip (if any)
                if (!string.IsNullOrEmpty(buttonDescriptor.ToolTip))
                {
                    TooltipHandler.TipRegion(splittedRect[i], buttonDescriptor.ToolTip);
                }
            }

            /*
             * Label
             */

            // number of elements (tiles) to display
            var itemsToDisplay = Math.Min(presetFilesCount - _listDisplayStartIndex, MaxItemsToDisplay);

            // label to display where we actually are in the tile list
            GenUI.SetLabelAlign(TextAnchor.MiddleCenter);
            var heightBefore = ListingStandard.StartCaptureHeight();

            ListingStandard.Label(
                $"{_listDisplayStartIndex}: {_listDisplayStartIndex + itemsToDisplay - 1} / {presetFilesCount - 1}",
                DefaultElementHeight);
            GenUI.ResetLabelAlign();
            var counterLabelRect = ListingStandard.EndCaptureHeight(heightBefore);

            Core.Gui.Widgets.DrawHighlightColor(counterLabelRect, Color.cyan, 0.50f);

            // add a gap before the scroll view
            ListingStandard.Gap(DefaultGapLineHeight);

            /*
             * Calculate heights
             */

            // height of the scrollable outer Rect (visible portion of the scroll view, not the 'virtual' one)
            var maxScrollViewOuterHeight = InRect.height - ListingStandard.CurHeight - 30f;

            // height of the 'virtual' portion of the scroll view
            var scrollableViewHeight = itemsToDisplay * DefaultElementHeight + DefaultGapLineHeight * MaxItemsToDisplay;

            /*
             * Scroll view
             */
            var innerLs = ListingStandard.BeginScrollView(maxScrollViewOuterHeight, scrollableViewHeight,
                                                          ref _scrollPosPresetFiles, 16f);

            var endIndex = _listDisplayStartIndex + itemsToDisplay;

            for (var i = _listDisplayStartIndex; i < endIndex; i++)
            {
                var selectedPresetFile = presetFiles[i];
                var labelText          = Path.GetFileNameWithoutExtension(selectedPresetFile.Name);

                // display the label
                var labelRect = innerLs.GetRect(DefaultElementHeight);
                var selected  = i == _selectedItemIndex;
                if (Core.Gui.Widgets.LabelSelectable(labelRect, labelText, ref selected, TextAnchor.MiddleCenter))
                {
                    // save item index
                    _selectedItemIndex = i;
                    _selectedFileName  = labelText;
                }
                // add a thin line between each label
                innerLs.GapLine(DefaultGapLineHeight);
            }

            ListingStandard.EndScrollView(innerLs);
        }
        public void DrawSlots(Pawn wearer, CompSlotsToolbelt SlotsToolbeltComp, Rect inventoryRect)
        {
            // draw text message if no contents inside
            if (SlotsToolbeltComp.slots.Count == 0)
            {
                Text.Font   = GameFont.Medium;
                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(inventoryRect, "No Items");
                Text.Anchor = TextAnchor.UpperLeft;
                Text.Font   = GameFont.Tiny;
            }
            // draw slots
            else
            {
                Rect slotRect = new Rect(inventoryRect.x, inventoryRect.y, inventoryRect.width / iconsPerRow - 1f, Height / 2 - 1f);

                for (int currentSlotInd = 0; currentSlotInd < iconsPerRow * numOfRow; currentSlotInd++)
                {
                    if (currentSlotInd >= toolbelt.MaxItem)
                    {
                        slotRect.x = inventoryRect.x + inventoryRect.width / iconsPerRow * (currentSlotInd % iconsPerRow);
                        slotRect.y = inventoryRect.y + Height / 2 * (currentSlotInd / iconsPerRow);
                        Widgets.DrawTextureFitted(slotRect, NoAvailableTex, 1.0f);
                    }

                    if (currentSlotInd >= SlotsToolbeltComp.slots.Count)
                    {
                        slotRect.x = inventoryRect.x + inventoryRect.width / iconsPerRow * (currentSlotInd % iconsPerRow);
                        slotRect.y = inventoryRect.y + Height / 2 * (currentSlotInd / iconsPerRow);
                        Widgets.DrawTextureFitted(slotRect, EmptyTex, 1.0f);
                    }


                    // draw occupied slots
                    if (currentSlotInd < SlotsToolbeltComp.slots.Count)
                    {
                        slotRect.x = inventoryRect.x + inventoryRect.width / iconsPerRow * (currentSlotInd % iconsPerRow);
                        slotRect.y = inventoryRect.y + Height / 2 * (currentSlotInd / iconsPerRow);

                        Thing currentThing = SlotsToolbeltComp.slots[currentSlotInd];

                        // draws greyish slot background
                        Widgets.DrawTextureFitted(slotRect.ContractedBy(3f), texOccupiedSlotBG, 1f);

                        if (currentThing.def.IsMeleeWeapon)
                        {
                            Widgets.DrawTextureFitted(slotRect, MeleeWeaponTex, 1.0f);
                        }
                        if (currentThing.def.IsRangedWeapon)
                        {
                            Widgets.DrawTextureFitted(slotRect, RangedWeaponTex, 1.0f);
                        }
                        Widgets.DrawBox(slotRect);

                        // highlights slot if mouse over
                        Widgets.DrawHighlightIfMouseover(slotRect.ContractedBy(3f));

                        // tooltip if mouse over
                        TooltipHandler.TipRegion(slotRect, currentThing.def.LabelCap);

                        // draw thing texture
                        Widgets.ThingIcon(slotRect, currentThing);

                        // interaction with slots
                        if (Widgets.ButtonInvisible(slotRect))
                        {
                            // mouse button pressed
                            if (Event.current.button == 0)
                            {
                                //Weapon
                                if (currentThing != null && currentThing.def.equipmentType == EquipmentType.Primary && (currentThing.def.IsRangedWeapon || currentThing.def.IsMeleeWeapon))
                                {
                                    SlotsToolbeltComp.SwapEquipment(currentThing as ThingWithComps);
                                }

                                //// equip weapon in slot
                                //if (currentThing.def.equipmentType == EquipmentType.Primary)
                                //{
                                //    slotsComp.SwapEquipment(currentThing as ThingWithComps);
                                //}
                            }
                            // mouse button released
                            else if (Event.current.button == 1)
                            {
                                List <FloatMenuOption> options = new List <FloatMenuOption>
                                {
                                    new FloatMenuOption("Info",
                                                        () => { Find.WindowStack.Add(new Dialog_InfoCard(currentThing)); }),
                                    new FloatMenuOption("Drop", () =>
                                    {
                                        Thing resultThing;
                                        SlotsToolbeltComp.slots.TryDrop(currentThing, wearer.Position,
                                                                        ThingPlaceMode.Near, out resultThing);
                                    })
                                };
                                // get thing info card
                                // drop thing

                                // Else

                                //Weapon
                                if (currentThing != null && currentThing.def.equipmentType == EquipmentType.Primary)
                                {
                                    options.Add(new FloatMenuOption("Equip".Translate(currentThing.LabelCap), () =>
                                    {
                                        SlotsToolbeltComp.SwapEquipment(currentThing as ThingWithComps);
                                    }));
                                }



                                //Food
                                if (currentThing.def.thingCategories.Contains(DefDatabase <ThingCategoryDef> .GetNamed("FoodMeals")))
                                {
                                    //  if (compSlots.owner.needs.food.CurCategory != HungerCategory.Fed)
                                    options.Add(new FloatMenuOption("ConsumeThing".Translate(currentThing.def.LabelCap), () =>
                                    {
                                        Thing dummy;
                                        SlotsToolbeltComp.slots.TryDrop(currentThing, wearer.Position, ThingPlaceMode.Direct, currentThing.def.ingestible.maxNumToIngestAtOnce, out dummy);

                                        Job jobNew             = new Job(JobDefOf.Ingest, dummy);
                                        jobNew.maxNumToCarry   = currentThing.def.ingestible.maxNumToIngestAtOnce;
                                        jobNew.ignoreForbidden = true;
                                        wearer.drafter.TakeOrderedJob(jobNew);
                                    }));
                                }
                                // Drugs
                                if (currentThing.def.ingestible?.drugCategory >= DrugCategory.Any)
                                {
                                    options.Add(new FloatMenuOption("ConsumeThing".Translate(), () =>
                                    {
                                        Thing dummy;
                                        SlotsToolbeltComp.slots.TryDrop(currentThing, wearer.Position, ThingPlaceMode.Direct, currentThing.def.ingestible.maxNumToIngestAtOnce, out dummy);

                                        Job jobNew             = new Job(JobDefOf.Ingest, dummy);
                                        jobNew.maxNumToCarry   = dummy.def.ingestible.maxNumToIngestAtOnce;
                                        jobNew.ignoreForbidden = true;
                                        wearer.drafter.TakeOrderedJob(jobNew);
                                    }));
                                }



                                Find.WindowStack.Add(new FloatMenu(options, currentThing.LabelCap));
                            }

                            // plays click sound on each click
                            SoundDefOf.Click.PlayOneShotOnCamera();
                        }
                    }
                    slotRect.x = inventoryRect.x + Height / 2 * (currentSlotInd % iconsPerRow);
                    slotRect.y = inventoryRect.y + Height / 2 * (currentSlotInd / iconsPerRow);
                    //      slotRect.x += Height;
                }
            }
        }
Пример #19
0
        public override void DoWindowContents(Rect inRect)
        {
            bool flag = false;

            if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return)
            {
                flag = true;
                Event.current.Use();
            }
            bool flag2 = false;

            if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape)
            {
                flag2 = true;
                Event.current.Use();
            }
            Rect windowRect = inRect.ContractedBy(17f);
            Rect mainRect   = new Rect(windowRect.x, windowRect.y, windowRect.width, windowRect.height - 20f);
            Rect okRect     = new Rect(inRect.width / 4 - 20f, mainRect.yMax + 10f, inRect.width / 4f, 30f);
            Rect cancelRect = new Rect(okRect.xMax + 40f, mainRect.yMax + 10f, inRect.width / 4f, 30f);

            Text.Font = GameFont.Medium;
            Widgets.Label(mainRect, "PsycheEditor".Translate(pawn.LabelShort));
            mainRect.yMin += 35f;
            Text.Font      = GameFont.Small;
            float warningSize = Mathf.Max(50f, Text.CalcHeight("PersonalityNodeWarning".Translate(), mainRect.width));

            Widgets.Label(mainRect, "PersonalityNodeWarning".Translate());
            mainRect.yMin += warningSize;
            float labelSize         = Mathf.Max(26f, Text.CalcHeight("SexDrive".Translate(), mainRect.width));
            Rect  nodeRect          = new Rect(mainRect.x, mainRect.y, mainRect.width, mainRect.height - labelSize * 3 - 20f);
            Rect  sexDriveRect      = new Rect(mainRect.x, nodeRect.yMax + 10f, mainRect.width, labelSize);
            Rect  romanticDriveRect = new Rect(mainRect.x, sexDriveRect.yMax, mainRect.width, labelSize);
            Rect  kinseyRect        = new Rect(mainRect.x, romanticDriveRect.yMax, mainRect.width, labelSize + 10f);

            Widgets.DrawLineHorizontal(nodeRect.x, nodeRect.yMax, nodeRect.width);
            float num = 0f;

            foreach (PersonalityNode node in PsycheHelper.Comp(pawn).Psyche.PersonalityNodes)
            {
                num += Mathf.Max(26f, Text.CalcHeight(node.def.label, nodeRect.width));
            }
            Rect viewRect = new Rect(0f, 0f, nodeRect.width - 20f, num);

            Widgets.BeginScrollView(nodeRect, ref nodeScrollPosition, viewRect);
            float num3 = 0f;

            for (int i = 0; i < cachedList.Count; i++)
            {
                string label = cachedList[i].First;
                float  num4  = Mathf.Max(26f, Text.CalcHeight(label, viewRect.width));
                Rect   rect  = new Rect(10f, num3, viewRect.width / 3, num4);
                Rect   rect2 = new Rect(10f + viewRect.width / 3, num3, ((2 * viewRect.width) / 3) - 20f, num4);
                Widgets.DrawHighlightIfMouseover(rect);
                Widgets.Label(rect, label);
                TooltipHandler.TipRegion(rect, () => descriptions[label], 436532 + Mathf.RoundToInt(num3));
                float newVal = Widgets.HorizontalSlider(rect2, cachedList[i].Second, 0f, 1f, true);
                cachedList[i] = new Pair <string, float>(cachedList[i].First, newVal);
                num3         += num4;
            }
            Widgets.EndScrollView();
            if (PsychologyBase.ActivateKinsey())
            {
                Rect sexDriveLabelRect  = new Rect(sexDriveRect.x, sexDriveRect.y, sexDriveRect.width / 3, sexDriveRect.height);
                Rect sexDriveSliderRect = new Rect(sexDriveRect.x + (sexDriveRect.width / 3), sexDriveRect.y, (2 * sexDriveRect.width) / 3, sexDriveRect.height);
                Widgets.Label(sexDriveLabelRect, "SexDrive".Translate());
                pawnSexDrive = Widgets.HorizontalSlider(sexDriveSliderRect, pawnSexDrive, 0f, 1f, true);
                Rect romanticDriveLabelRect  = new Rect(romanticDriveRect.x, romanticDriveRect.y, romanticDriveRect.width / 3, romanticDriveRect.height);
                Rect romanticDriveSliderRect = new Rect(romanticDriveRect.x + (romanticDriveRect.width / 3), romanticDriveRect.y, (2 * romanticDriveRect.width) / 3, romanticDriveRect.height);
                Widgets.Label(romanticDriveLabelRect, "RomanticDrive".Translate());
                pawnRomanticDrive = Widgets.HorizontalSlider(romanticDriveSliderRect, pawnRomanticDrive, 0f, 1f, true);
                Rect kinseyRatingLabelRect  = new Rect(kinseyRect.x, kinseyRect.y, kinseyRect.width / 3, kinseyRect.height);
                Rect kinseyRatingSliderRect = new Rect(kinseyRect.x + (kinseyRect.width / 3), kinseyRect.y, (2 * kinseyRect.width) / 3, kinseyRect.height);
                Widgets.Label(kinseyRatingLabelRect, "KinseyRating".Translate());
                pawnKinseyRating = Mathf.RoundToInt(Widgets.HorizontalSlider(kinseyRatingSliderRect, pawnKinseyRating, 0f, 6f, true, leftAlignedLabel: "0", rightAlignedLabel: "6"));
            }
            else
            {
                GUI.color = Color.red;
                Rect warningRect = new Rect(mainRect.x, nodeRect.yMax + 10f, mainRect.width, labelSize * 3);
                Widgets.Label(warningRect, "SexualityDisabledWarning".Translate());
                GUI.color = Color.white;
            }
            if (Widgets.ButtonText(okRect, "AcceptButton".Translate(), true, false, true) || flag)
            {
                foreach (PersonalityNode node in PsycheHelper.Comp(pawn).Psyche.PersonalityNodes)
                {
                    node.rawRating = (from n in cachedList
                                      where n.First == node.def.label.CapitalizeFirst()
                                      select n).First().Second;
                }
                if (PsychologyBase.ActivateKinsey())
                {
                    PsycheHelper.Comp(pawn).Sexuality.sexDrive      = pawnSexDrive;
                    PsycheHelper.Comp(pawn).Sexuality.romanticDrive = pawnRomanticDrive;
                    PsycheHelper.Comp(pawn).Sexuality.kinseyRating  = pawnKinseyRating;
                }
                this.Close(false);
            }
            if (Widgets.ButtonText(cancelRect, "CancelButton".Translate(), true, false, true) || flag2)
            {
                this.Close(true);
            }
        }
        public override void DoCell(Rect rect, Pawn pawn, PawnTable table)
        {
            if (pawn.Dead || pawn.health?.hediffSet == null || !pawn.health.hediffSet.HasImmunizableNotImmuneHediff())
            {
                return;
            }

            HediffWithComps mostSevere = FindMostSevereHediff(pawn);

            if (mostSevere == null)
            {
                return;
            }

            float deltaSeverity = GetTextFor(mostSevere);

            GUI.color = GetPrettyColorFor(deltaSeverity);

            Rect rect2 = new Rect(rect.x, rect.y, rect.width, Mathf.Min(rect.height, 30f));

            Text.Font     = GameFont.Small;
            Text.Anchor   = TextAnchor.MiddleCenter;
            Text.WordWrap = false;
            Widgets.Label(rect2, GetTextFor(mostSevere).ToStringPercent());
            Text.WordWrap = true;
            Text.Anchor   = TextAnchor.UpperLeft;
            string tip = GetTip(pawn, mostSevere);

            if (!tip.NullOrEmpty())
            {
                TooltipHandler.TipRegion(rect2, tip);
            }

            float severityChangePerDayFromImmu = (float)AccessTools.Method(typeof(HediffComp_Immunizable), "SeverityChangePerDay")
                                                 .Invoke(mostSevere.TryGetComp <HediffComp_Immunizable>(), null);

            float severityChangePerDayFromTendD = 0f;

            if (mostSevere.TryGetComp <HediffComp_TendDuration>()?.IsTended ?? false)
            {
                severityChangePerDayFromTendD =
                    mostSevere.TryGetComp <HediffComp_TendDuration>().TProps.severityPerDayTended *
                    mostSevere.TryGetComp <HediffComp_TendDuration>().tendQuality;
            }

            float immunityPerDay = 0f;

            ImmunityRecord immunityRecord = pawn.health.immunity.GetImmunityRecord(mostSevere.def);

            if (immunityRecord != null)
            {
                immunityPerDay = immunityRecord.ImmunityChangePerTick(pawn, true, mostSevere) * GenDate.TicksPerDay;
            }

            GUI.color = Color.white;

            bool redFlag = !(severityChangePerDayFromTendD + severityChangePerDayFromImmu > immunityPerDay);

            Texture2D texture2D = redFlag ? StaticConstructorOnGameStart.SortingIcon : StaticConstructorOnGameStart.SortingDescendingIcon;

            GUI.color = redFlag ? HealthUtility.GoodConditionColor : HealthUtility.DarkRedColor;
            Rect position2 = new Rect(rect.xMax - texture2D.width - 1f, rect.yMax - texture2D.height - 1f, texture2D.width, texture2D.height);

            GUI.DrawTexture(position2, texture2D);
            GUI.color = Color.white;
        }
Пример #21
0
        private void DrawThingRow(ref float y, float width, Thing thing, bool showDropButtonIfPrisoner = false)
        {
            Rect rect = new Rect(0f, y, width, _thingRowHeight);

            Widgets.InfoCardButton(rect.width - 24f, y, thing);
            rect.width -= 24f;
            if (CanControl || (SelPawnForGear.Faction == Faction.OfPlayer && SelPawnForGear.RaceProps.packAnimal) || (showDropButtonIfPrisoner && SelPawnForGear.IsPrisonerOfColony))
            {
                var   dropForbidden  = SelPawnForGear.IsItemQuestLocked(thing);
                Color color          = dropForbidden ? Color.grey : Color.white;
                Color mouseoverColor = dropForbidden ? Color.grey : GenUI.MouseoverColor;
                Rect  dropRect       = new Rect(rect.width - 24f, y, 24f, 24f);
                TooltipHandler.TipRegion(dropRect, dropForbidden ? "DropThingLocked".Translate() : "DropThing".Translate());
                if (Widgets.ButtonImage(dropRect, TexButton.Drop, color, mouseoverColor) && !dropForbidden)
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera();
                    InterfaceDrop(thing);
                }
                rect.width -= 24f;
            }
            if (CanControlColonist)
            {
                if ((thing.def.IsNutritionGivingIngestible || thing.def.IsNonMedicalDrug) && thing.IngestibleNow && base.SelPawn.WillEat(thing, null) && (!SelPawnForGear.IsTeetotaler() || !thing.def.IsNonMedicalDrug))
                {
                    Rect rect3 = new Rect(rect.width - 24f, y, 24f, 24f);
                    TooltipHandler.TipRegion(rect3, "ConsumeThing".Translate(thing.LabelNoCount, thing));
                    if (Widgets.ButtonImage(rect3, TexButton.Ingest))
                    {
                        SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                        InterfaceIngest(thing);
                    }
                }
                rect.width -= 24f;
            }
            Rect rect4 = rect;

            rect4.xMin = rect4.xMax - 60f;
            CaravanThingsTabUtility.DrawMass(thing, rect4);
            rect.width -= 60f;
            if (Mouse.IsOver(rect))
            {
                GUI.color = _highlightColor;
                GUI.DrawTexture(rect, TexUI.HighlightTex);
            }

            if (thing.def.DrawMatSingle != null && thing.def.DrawMatSingle.mainTexture != null)
            {
                Widgets.ThingIcon(new Rect(4f, y, _thingIconSize, _thingIconSize), thing, 1f);
            }
            Text.Anchor = TextAnchor.MiddleLeft;
            GUI.color   = ThingLabelColor;
            Rect   thingLabelRect = new Rect(_thingLeftX, y, rect.width - _thingLeftX, _thingRowHeight);
            string thingLabel     = thing.LabelCap;

            if ((thing is Apparel && SelPawnForGear.outfits != null && SelPawnForGear.outfits.forcedHandler.IsForced((Apparel)thing)) ||
                (SelPawnForGear.inventory != null && SelPawnForGear.HoldTrackerIsHeld(thing)))
            {
                thingLabel = thingLabel + ", " + "ApparelForcedLower".Translate();
            }

            Text.WordWrap = false;
            Widgets.Label(thingLabelRect, thingLabel.Truncate(thingLabelRect.width, null));
            Text.WordWrap = true;
            string text2 = string.Concat(new object[]
            {
                thing.LabelCap,
                "\n",
                thing.DescriptionDetailed,
                "\n",
                thing.GetWeightAndBulkTip()
            });

            if (thing.def.useHitPoints)
            {
                string text3 = text2;
                text2 = string.Concat(new object[]
                {
                    text3,
                    "\n",
                    "HitPointsBasic".Translate().CapitalizeFirst(),
                    ": ",
                    thing.HitPoints,
                    " / ",
                    thing.MaxHitPoints
                });
            }
            TooltipHandler.TipRegion(thingLabelRect, text2);
            y += 28f;

            // RMB menu
            if (Widgets.ButtonInvisible(thingLabelRect) && Event.current.button == 1)
            {
                List <FloatMenuOption> floatOptionList = new List <FloatMenuOption>();
                floatOptionList.Add(new FloatMenuOption("ThingInfo".Translate(), delegate
                {
                    Find.WindowStack.Add(new Dialog_InfoCard(thing));
                }, MenuOptionPriority.Default, null, null));
                if (CanControl)
                {
                    // Equip option
                    ThingWithComps eq = thing as ThingWithComps;
                    if (eq != null && eq.TryGetComp <CompEquippable>() != null)
                    {
                        CompInventory  compInventory = SelPawnForGear.TryGetComp <CompInventory>();
                        CompBiocodable compBiocoded  = eq.TryGetComp <CompBiocodable>();
                        if (compInventory != null)
                        {
                            FloatMenuOption equipOption;
                            string          eqLabel = GenLabel.ThingLabel(eq.def, eq.Stuff, 1);
                            if (compBiocoded != null && compBiocoded.Biocoded && compBiocoded.CodedPawn != SelPawnForGear)
                            {
                                equipOption = new FloatMenuOption("CannotEquip".Translate(eqLabel) + ": " + "BiocodedCodedForSomeoneElse".Translate(), null);
                            }
                            else if (SelPawnForGear.IsQuestLodger() && !EquipmentUtility.QuestLodgerCanEquip(eq, SelPawnForGear))
                            {
                                var forbiddenEquipOrPutAway = SelPawnForGear.equipment.AllEquipmentListForReading.Contains(eq) ? "CE_CannotPutAway".Translate(eqLabel) : "CannotEquip".Translate(eqLabel);
                                equipOption = new FloatMenuOption(forbiddenEquipOrPutAway + ": " + "CE_CannotChangeEquipment".Translate(), null);
                            }
                            else if (SelPawnForGear.equipment.AllEquipmentListForReading.Contains(eq) && SelPawnForGear.inventory != null)
                            {
                                equipOption = new FloatMenuOption("CE_PutAway".Translate(eqLabel),
                                                                  new Action(delegate
                                {
                                    SelPawnForGear.equipment.TryTransferEquipmentToContainer(SelPawnForGear.equipment.Primary, SelPawnForGear.inventory.innerContainer);
                                }));
                            }
                            else if (!SelPawnForGear.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
                            {
                                equipOption = new FloatMenuOption("CannotEquip".Translate(eqLabel), null);
                            }
                            else
                            {
                                string equipOptionLabel = "Equip".Translate(eqLabel);
                                if (eq.def.IsRangedWeapon && SelPawnForGear.story != null && SelPawnForGear.story.traits.HasTrait(TraitDefOf.Brawler))
                                {
                                    equipOptionLabel = equipOptionLabel + " " + "EquipWarningBrawler".Translate();
                                }
                                equipOption = new FloatMenuOption(
                                    equipOptionLabel,
                                    (SelPawnForGear.story != null && SelPawnForGear.WorkTagIsDisabled(WorkTags.Violent))
                                    ? null
                                    : new Action(delegate
                                {
                                    compInventory.TrySwitchToWeapon(eq);
                                }));
                            }
                            floatOptionList.Add(equipOption);
                        }
                    }
                    //Reload apparel option
                    var worn_apparel = SelPawnForGear?.apparel?.WornApparel;
                    foreach (var apparel in worn_apparel)
                    {
                        var compReloadable = apparel.TryGetComp <CompReloadable>();
                        if (compReloadable != null && compReloadable.AmmoDef == thing.def && compReloadable.NeedsReload(true))
                        {
                            if (!SelPawnForGear.Drafted)    //TODO-1.2 This should be doable for drafted pawns as well, but the job does nothing. Figure out what's wrong and remove this condition.
                            {
                                FloatMenuOption reloadApparelOption = new FloatMenuOption(
                                    "CE_ReloadApparel".Translate(apparel.Label, thing.Label),
                                    new Action(delegate
                                {
                                    //var reloadJob = JobMaker.MakeJob(JobDefOf.Reload, apparel, thing);
                                    //SelPawnForGear.jobs.StartJob(reloadJob, JobCondition.InterruptForced, null, SelPawnForGear.CurJob?.def != reloadJob.def, true);

                                    SelPawnForGear.jobs.TryTakeOrderedJob(JobMaker.MakeJob(JobDefOf.Reload, apparel, thing));
                                })
                                    );
                                floatOptionList.Add(reloadApparelOption);
                            }
                        }
                    }
                    // Consume option
                    if (CanControl && thing.IngestibleNow && base.SelPawn.RaceProps.CanEverEat(thing))
                    {
                        Action eatFood = delegate
                        {
                            SoundDefOf.Tick_High.PlayOneShotOnCamera();
                            InterfaceIngest(thing);
                        };
                        string label = thing.def.ingestible.ingestCommandString.NullOrEmpty() ? (string)"ConsumeThing".Translate(thing.LabelShort, thing) : string.Format(thing.def.ingestible.ingestCommandString, thing.LabelShort);
                        if (SelPawnForGear.IsTeetotaler() && thing.def.IsNonMedicalDrug)
                        {
                            floatOptionList.Add(new FloatMenuOption(label + ": " + TraitDefOf.DrugDesire.degreeDatas.Where(x => x.degree == -1).First()?.label, null));
                        }
                        else
                        {
                            floatOptionList.Add(new FloatMenuOption(label, eatFood));
                        }
                    }
                    // Drop, and drop&haul options
                    if (SelPawnForGear.IsItemQuestLocked(eq))
                    {
                        floatOptionList.Add(new FloatMenuOption("CE_CannotDropThing".Translate() + ": " + "DropThingLocked".Translate(), null));
                        floatOptionList.Add(new FloatMenuOption("CE_CannotDropThingHaul".Translate() + ": " + "DropThingLocked".Translate(), null));
                    }
                    else
                    {
                        floatOptionList.Add(new FloatMenuOption("DropThing".Translate(), new Action(delegate
                        {
                            SoundDefOf.Tick_High.PlayOneShotOnCamera();
                            InterfaceDrop(thing);
                        })));
                        floatOptionList.Add(new FloatMenuOption("CE_DropThingHaul".Translate(), new Action(delegate
                        {
                            SoundDefOf.Tick_High.PlayOneShotOnCamera();
                            InterfaceDropHaul(thing);
                        })));
                    }
                    // Stop holding in inventory option
                    if (CanControl && SelPawnForGear.HoldTrackerIsHeld(thing))
                    {
                        Action forgetHoldTracker = delegate
                        {
                            SoundDefOf.Tick_High.PlayOneShotOnCamera();
                            SelPawnForGear.HoldTrackerForget(thing);
                        };
                        floatOptionList.Add(new FloatMenuOption("CE_HoldTrackerForget".Translate(), forgetHoldTracker));
                    }
                }
                FloatMenu window = new FloatMenu(floatOptionList, thing.LabelCap, false);
                Find.WindowStack.Add(window);
            }
            // end menu
        }
Пример #22
0
        private static bool DrawIconForWeaponMemory(GoldfishModule pawnMemory, ThingDef weapon, Rect contentRect, Vector2 iconOffset)
        {
            var     iconTex  = weapon.uiIcon;
            Graphic g        = weapon.graphicData.Graphic;
            Color   color    = getColor(weapon);
            Color   colorTwo = getColor(weapon);
            Graphic g2       = weapon.graphicData.Graphic.GetColoredVersion(g.Shader, color, colorTwo);

            var iconRect = new Rect(contentRect.x + iconOffset.x, contentRect.y + iconOffset.y, IconSize, IconSize);

            string label = weapon.label;

            Texture2D drawPocket;

            if (pawnMemory.IsCurrentPrimary(weapon.defName))
            {
                drawPocket = TextureResources.drawPocketMemoryPrimary;
            }
            else
            {
                drawPocket = TextureResources.drawPocketMemory;
            }

            TooltipHandler.TipRegion(iconRect, string.Format("DrawSidearm_gizmoTooltipMemory".Translate(), weapon.label));
            MouseoverSounds.DoRegion(iconRect, SoundDefOf.Mouseover_Command);
            if (Mouse.IsOver(iconRect))
            {
                LessonAutoActivator.TeachOpportunity(SidearmsDefOf.Concept_SidearmsMissing, OpportunityType.GoodToKnow);
                if (pawnMemory.IsCurrentPrimary(weapon.defName))
                {
                    LessonAutoActivator.TeachOpportunity(SidearmsDefOf.Concept_SidearmsPrimary, OpportunityType.GoodToKnow);
                }
                GUI.color = iconMouseOverColor;
                GUI.DrawTexture(iconRect, drawPocket);
            }
            else
            {
                GUI.color = iconBaseColor;
                GUI.DrawTexture(iconRect, drawPocket);
            }

            Texture resolvedIcon;

            if (!weapon.uiIconPath.NullOrEmpty())
            {
                resolvedIcon = weapon.uiIcon;
            }
            else
            {
                resolvedIcon = g2.MatSingle.mainTexture;
            }
            GUI.color = color;
            GUI.DrawTexture(iconRect, resolvedIcon);
            GUI.color = Color.white;

            UIHighlighter.HighlightOpportunity(iconRect, "SidearmMissing");
            if (pawnMemory.IsCurrentPrimary(weapon.defName))
            {
                UIHighlighter.HighlightOpportunity(iconRect, "SidearmPrimary");
            }

            if (Widgets.ButtonInvisible(iconRect, true))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// Fills the bottom left corner of the window
        /// </summary>
        /// <param name="rect">The rect to draw into</param>
        private static void DoBottomLeftWindowContents(Rect rect)
        {
            // Backup Button
            Rect BackupRect = new Rect((rect.xMin - 1) + BottomLeftContentOffset, rect.yMax - 37f, ButtonBigWidth, BottomHeight);

            TooltipHandler.TipRegion(BackupRect, "Button_Backup_Tooltip".Translate());
            if (Widgets.ButtonText(BackupRect, "Button_Backup_Text".Translate()))
            {
                BackupModList();
            }

            // '>>' Label
            Text.Anchor = TextAnchor.MiddleCenter;
            Rect toRect = new Rect(BackupRect.xMax + Padding, BackupRect.y, LabelWidth, BottomHeight);

            Widgets.Label(toRect, ">>");

            // State button and Float menu
            Rect StateRect = new Rect(toRect.xMax + Padding, BackupRect.y, ButtonSmallWidth, BottomHeight);

            TooltipHandler.TipRegion(StateRect, "Button_State_Select_Tooltip".Translate());
            if (Widgets.ButtonText(StateRect, string.Format("{0}{1}", selectedState.ToString(), (ModsConfigHandler.StateIsSet(selectedState)) ? null : "*")))
            {
                List <FloatMenuOption> options = new List <FloatMenuOption>();

                for (int i = 1; i <= SettingsHandler.STATE_LIMIT; i++)
                {
                    //set a new variable here, otherwise the selected state and button text will change when int i next iterates
                    int n = i;
                    options.Add(new FloatMenuOption(GetStateName(i), (Action)(() => { selectedState = n; }), MenuOptionPriority.Default, (Action)null, (Thing)null, 0.0f, (Func <Rect, bool>)null, (WorldObject)null));
                }

                options.Add(new FloatMenuOption("Edit Names...", (Action)(() => { Find.WindowStack.Add(new Dialogs.Dialog_EditNames()); }), MenuOptionPriority.Default, (Action)null, (Thing)null, 0f, null, null));

                Find.WindowStack.Add((Window) new FloatMenu(options));
            }

            // '<<' Label
            Rect fromRect = new Rect(StateRect.xMax + Padding, StateRect.y, LabelWidth, BottomHeight);

            Widgets.Label(fromRect, "<<");

            // Restore Button
            Rect RestoreRect = new Rect(fromRect.xMax + Padding, StateRect.y, ButtonBigWidth, BottomHeight);

            TooltipHandler.TipRegion(RestoreRect, "Button_Restore_Tooltip".Translate());
            if (Widgets.ButtonText(RestoreRect, "Button_Restore_Text".Translate()))
            {
                RestoreModList();
            }

            // Undo Button
            Rect UndoRect = new Rect(RestoreRect.xMax + Padding, RestoreRect.y, ButtonSmallWidth, BottomHeight);

            TooltipHandler.TipRegion(UndoRect, "Button_Undo_Tooltip".Translate());
            if (CustomWidgets.ButtonImage(UndoRect, Textures.Undo))
            {
                if (ModsConfigHandler.CanUndo)
                {
                    if (ModsConfigHandler.DoUndoAction())
                    {
                        SetStatus("Status_Message_Undone".Translate());
                    }
                }
            }

            // Status Label
            UpdateStatus();
            Text.Font = GameFont.Tiny;
            Rect StatusRect = new Rect(StateRect.x - 25f, StateRect.yMax - 58f, LabelStatusWidth, LabelStatusHeight);

            Widgets.Label(StatusRect, StatusMessage);

            //Reset text
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;
        }
Пример #24
0
        private bool DrawIconForWeapon(GoldfishModule pawnMemory, Thing weapon, Rect contentRect, Vector2 iconOffset)
        {
            var   iconTex = weapon.def.uiIcon;
            Color color   = weapon.DrawColor;

            var iconRect = new Rect(contentRect.x + iconOffset.x, contentRect.y + iconOffset.y, IconSize, IconSize);

            //var iconColor = iconBaseColor;

            TooltipHandler.TipRegion(iconRect, string.Format("DrawSidearm_gizmoTooltip".Translate(), weapon.LabelShort));
            MouseoverSounds.DoRegion(iconRect, SoundDefOf.Mouseover_Command);

            Texture2D drawPocket;

            if (pawnMemory != null && pawnMemory.IsCurrentPrimary(weapon.def.defName))
            {
                drawPocket = TextureResources.drawPocketPrimary;
            }
            else
            {
                drawPocket = TextureResources.drawPocket;
            }

            if (Mouse.IsOver(iconRect))
            {
                LessonAutoActivator.TeachOpportunity(SidearmsDefOf.Concept_SidearmsInInventory, OpportunityType.GoodToKnow);
                if (pawnMemory != null && pawnMemory.IsCurrentPrimary(weapon.def.defName))
                {
                    LessonAutoActivator.TeachOpportunity(SidearmsDefOf.Concept_SidearmsPrimary, OpportunityType.GoodToKnow);
                }
                GUI.color = iconMouseOverColor;
                GUI.DrawTexture(iconRect, drawPocket);
                //Graphics.DrawTexture(iconRect, TextureResources.drawPocket, new Rect(0, 0, 1f, 1f), 0, 0, 0, 0, iconMouseOverColor);
            }
            else
            {
                GUI.color = iconBaseColor;
                GUI.DrawTexture(iconRect, drawPocket);
                //Graphics.DrawTexture(iconRect, TextureResources.drawPocket, new Rect(0, 0, 1f, 1f), 0, 0, 0, 0, iconBaseColor);
            }

            Texture resolvedIcon;

            if (!weapon.def.uiIconPath.NullOrEmpty())
            {
                resolvedIcon = weapon.def.uiIcon;
            }
            else
            {
                resolvedIcon = weapon.Graphic.ExtractInnerGraphicFor(weapon).MatSingle.mainTexture;
            }
            GUI.color = weapon.DrawColor;
            GUI.DrawTexture(iconRect, resolvedIcon);
            GUI.color = Color.white;

            UIHighlighter.HighlightOpportunity(iconRect, "SidearmInInventory");
            if (pawnMemory != null && pawnMemory.IsCurrentPrimary(weapon.def.defName))
            {
                UIHighlighter.HighlightOpportunity(iconRect, "SidearmPrimary");
            }

            if (Widgets.ButtonInvisible(iconRect, true))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public static void DrawTempleCard(Rect rect, Building_SacrificialAltar altar)
        {
            GUI.BeginGroup(rect);
            Rect rect3 = new Rect(2f, 0f, ITab_AltarSacrificesCardUtility.ColumnSize, ITab_AltarSacrificesCardUtility.ButtonSize);

            Widgets.Label(rect3, "Deity".Translate() + ": ");
            rect3.xMin = rect3.center.x - 15f;
            string label2 = ITab_AltarCardUtility.DeityLabel(altar, ITab_AltarCardUtility.DeityType.SacrificeDeity);

            if (Widgets.ButtonText(rect3, label2, true, false, true))
            {
                ITab_AltarCardUtility.OpenDeitySelectMenu(altar, ITab_AltarCardUtility.DeityType.SacrificeDeity);
            }
            TooltipHandler.TipRegion(rect3, "DeityDesc".Translate());

            ITab_AltarCardUtility.DrawDeity(altar.tempCurrentSacrificeDeity, rect3, SpellDescription(altar));

            Rect rect4 = rect3;

            rect4.y    += ITab_AltarSacrificesCardUtility.ButtonSize + 15f;
            rect4.width = ITab_AltarSacrificesCardUtility.ColumnSize;
            rect4.x    -= (rect3.x);
            rect4.x    += 2f;
            Widgets.Label(rect4, "Executioner".Translate() + ": ");
            rect4.xMin = rect4.center.x - 15f;
            string label3 = ITab_AltarCardUtility.ExecutionerLabel(altar);

            if (Widgets.ButtonText(rect4, label3, true, false, true))
            {
                ITab_AltarCardUtility.OpenActorSelectMenu(altar, ITab_AltarCardUtility.ActorType.executioner);
            }
            TooltipHandler.TipRegion(rect4, "ExecutionerDesc".Translate());

            Rect rect5 = rect4;

            rect5.y    += ITab_AltarSacrificesCardUtility.ButtonSize + 15f;
            rect5.x    -= (rect4.x);
            rect5.x    += 2f;
            rect5.width = ITab_AltarSacrificesCardUtility.ColumnSize;
            Widgets.Label(rect5, "Sacrifice".Translate() + ": ");
            rect5.xMin = rect5.center.x - 15f;
            string label4 = ITab_AltarCardUtility.SacrificeLabel(altar);

            if (Widgets.ButtonText(rect5, label4, true, false, true))
            {
                ITab_AltarCardUtility.OpenActorSelectMenu(altar, ITab_AltarCardUtility.ActorType.prisoner);
            }
            TooltipHandler.TipRegion(rect5, "SacrificeDesc".Translate());

            Rect rect6 = rect5;

            rect6.y    += ITab_AltarSacrificesCardUtility.ButtonSize + 15f;
            rect6.x    -= (rect5.x);
            rect6.x    += 2f;
            rect6.width = ITab_AltarSacrificesCardUtility.ColumnSize;
            rect6.yMax += ITab_AltarSacrificesCardUtility.ButtonSize + 15f;
            Widgets.Label(rect6, "Cults_Spell".Translate() + ": ");
            rect6.xMin = rect6.center.x - 15f;
            string label5 = SpellLabel(altar);

            if (Widgets.ButtonText(rect6, label5, true, false, true))
            {
                ITab_AltarHumanSacrificeCardUtility.OpenSpellSelectMenu(altar);
            }
            TooltipHandler.TipRegion(rect6, "Cults_SpellDesc".Translate());

            GUI.EndGroup();
        }
Пример #26
0
        public static void DateOnGUI(Rect dateRect)
        {
            Vector2 location;

            if (WorldRendererUtility.WorldRenderedNow && Find.WorldSelector.selectedTile >= 0)
            {
                location = Find.WorldGrid.LongLatOf(Find.WorldSelector.selectedTile);
            }
            else if (WorldRendererUtility.WorldRenderedNow && Find.WorldSelector.NumSelectedObjects > 0)
            {
                location = Find.WorldGrid.LongLatOf(Find.WorldSelector.FirstSelectedObject.Tile);
            }
            else
            {
                if (Find.CurrentMap == null)
                {
                    return;
                }
                location = Find.WorldGrid.LongLatOf(Find.CurrentMap.Tile);
            }
            int     index   = GenDate.HourInteger(Find.TickManager.TicksAbs, location.x);
            int     num     = GenDate.DayOfTwelfth(Find.TickManager.TicksAbs, location.x);
            Season  season  = GenDate.Season(Find.TickManager.TicksAbs, location);
            Quadrum quadrum = GenDate.Quadrum(Find.TickManager.TicksAbs, location.x);
            int     num2    = GenDate.Year(Find.TickManager.TicksAbs, location.x);
            string  text    = (!SeasonLabelVisible) ? string.Empty : season.LabelCap();

            if (num != dateStringDay || season != dateStringSeason || quadrum != dateStringQuadrum || num2 != dateStringYear)
            {
                dateString        = GenDate.DateReadoutStringAt(Find.TickManager.TicksAbs, location);
                dateStringDay     = num;
                dateStringSeason  = season;
                dateStringQuadrum = quadrum;
                dateStringYear    = num2;
            }
            Text.Font = GameFont.Small;
            Vector2 vector  = Text.CalcSize(fastHourStrings[index]);
            float   x       = vector.x;
            Vector2 vector2 = Text.CalcSize(dateString);
            float   a       = Mathf.Max(x, vector2.x);
            Vector2 vector3 = Text.CalcSize(text);
            float   num3    = Mathf.Max(a, vector3.x) + 7f;

            dateRect.xMin = dateRect.xMax - num3;
            if (Mouse.IsOver(dateRect))
            {
                Widgets.DrawHighlight(dateRect);
            }
            GUI.BeginGroup(dateRect);
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperRight;
            Rect rect = dateRect.AtZero();

            rect.xMax -= 7f;
            Widgets.Label(rect, fastHourStrings[index]);
            rect.yMin += 26f;
            Widgets.Label(rect, dateString);
            rect.yMin += 26f;
            if (!text.NullOrEmpty())
            {
                Widgets.Label(rect, text);
            }
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.EndGroup();
            TooltipHandler.TipRegion(dateRect, new TipSignal(delegate
            {
                StringBuilder stringBuilder = new StringBuilder();
                for (int i = 0; i < 4; i++)
                {
                    Quadrum quadrum2 = (Quadrum)i;
                    stringBuilder.AppendLine(quadrum2.Label() + " - " + quadrum2.GetSeason(location.y).LabelCap());
                }
                return("DateReadoutTip".Translate(GenDate.DaysPassed, 15, season.LabelCap(), 15, GenDate.Quadrum(GenTicks.TicksAbs, location.x).Label(), stringBuilder.ToString()));
            }, 86423));
        }
        static void DrawStatRow(ExtendedOutfit selectedOutfit, StatPriority statPriority, ref Vector2 cur, float width)
        {
            // set up rects
            Rect labelRect  = new Rect(cur.x, cur.y, (width - 24) / 2f, 30f);
            Rect sliderRect = new Rect(labelRect.xMax + 4f, cur.y + 5f, labelRect.width, 25f);
            Rect buttonRect = new Rect(sliderRect.xMax + 4f, cur.y + 3f, 16f, 16f);

            // draw label
            Text.Font = Text.CalcHeight(statPriority.Stat.LabelCap, labelRect.width) > labelRect.height
                            ? GameFont.Tiny
                            : GameFont.Small;

            GUI.color = AssigmentColor(statPriority);

            Widgets.Label(labelRect, statPriority.Stat.LabelCap);
            Text.Font = GameFont.Small;

            // draw button
            // if manually added, delete the priority
            string buttonTooltip = string.Empty;

            if (statPriority.IsManual)
            {
                buttonTooltip = ResourceBank.Strings.StatPriorityDelete(statPriority.Stat.LabelCap);
                if (Widgets.ButtonImage(buttonRect, ResourceBank.Textures.DeleteButton))
                {
                    selectedOutfit.RemoveStatPriority(statPriority.Stat);
                }
            }
            // if overridden auto assignment, reset to auto
            else if (statPriority.IsOverride)
            {
                buttonTooltip = ResourceBank.Strings.StatPriorityReset(statPriority.Stat.LabelCap);
                if (Widgets.ButtonImage(buttonRect, ResourceBank.Textures.ResetButton))
                {
                    statPriority.Weight = statPriority.Default;

                    if (MPApi.IsInMultiplayer)
                    {
                        ExtendedOutfitProxy.SetStatPriority(statPriority.Stat, statPriority.Default);
                    }
                }
            }

            // draw line behind slider
            GUI.color = new Color(.3f, .3f, .3f);
            for (int y = (int)cur.y; y < cur.y + 30; y += 5)
            {
                Widgets.DrawLineVertical((sliderRect.xMin + sliderRect.xMax) / 2f, y, 3f);
            }

            // draw slider
            GUI.color = AssigmentColor(statPriority);

            float weight = GUI.HorizontalSlider(sliderRect, statPriority.Weight, -MaxValue, MaxValue);

            if (Mathf.Abs(weight - statPriority.Weight) > 1e-4)
            {
                statPriority.Weight = weight;

                if (MPApi.IsInMultiplayer)
                {
                    ExtendedOutfitProxy.SetStatPriority(statPriority.Stat, weight);
                }
            }

            GUI.color = Color.white;

            // tooltips
            TooltipHandler.TipRegion(labelRect, statPriority.Stat.LabelCap + "\n\n" + statPriority.Stat.description);
            if (buttonTooltip != string.Empty)
            {
                TooltipHandler.TipRegion(buttonRect, buttonTooltip);
            }

            TooltipHandler.TipRegion(sliderRect, statPriority.Weight.ToStringByStyle(ToStringStyle.FloatTwo));

            // advance row
            cur.y += 30f;
        }
        private void DrawPawnList(Rect rect)
        {
            Rect rect2 = rect;

            rect2.height = 60f;
            rect2        = rect2.ContractedBy(4f);
            int groupID = ReorderableWidget.NewGroup(delegate(int from, int to)
            {
                if (!TutorSystem.AllowAction("ReorderPawn"))
                {
                    return;
                }
                Pawn item = Find.GameInitData.startingPawns[from];
                Find.GameInitData.startingPawns.RemoveAt(from);
                Find.GameInitData.startingPawns.Insert(to, item);
                TutorSystem.Notify_Event("ReorderPawn");
            });

            rect2.y += 15f;
            this.DrawPawnListLabelAbove(rect2, "StartingPawnsSelected".Translate());
            for (int i = 0; i < Find.GameInitData.startingPawns.Count; i++)
            {
                if (i == Find.GameInitData.startingPawnCount)
                {
                    rect2.y += 30f;
                    this.DrawPawnListLabelAbove(rect2, "StartingPawnsLeftBehind".Translate());
                }
                Pawn pawn = Find.GameInitData.startingPawns[i];
                GUI.BeginGroup(rect2);
                Rect rect3 = new Rect(Vector2.zero, rect2.size);
                Widgets.DrawOptionBackground(rect3, this.curPawn == pawn);
                MouseoverSounds.DoRegion(rect3);
                GUI.color = new Color(1f, 1f, 1f, 0.2f);
                GUI.DrawTexture(new Rect(110f - Page_ConfigureStartingPawns.PawnSelectorPortraitSize.x / 2f, 40f - Page_ConfigureStartingPawns.PawnSelectorPortraitSize.y / 2f, Page_ConfigureStartingPawns.PawnSelectorPortraitSize.x, Page_ConfigureStartingPawns.PawnSelectorPortraitSize.y), PortraitsCache.Get(pawn, Page_ConfigureStartingPawns.PawnSelectorPortraitSize, default(Vector3), 1f));
                GUI.color = Color.white;
                Rect       rect4      = rect3.ContractedBy(4f).Rounded();
                NameTriple nameTriple = pawn.Name as NameTriple;
                string     label;
                if (nameTriple != null)
                {
                    label = ((!string.IsNullOrEmpty(nameTriple.Nick)) ? nameTriple.Nick : nameTriple.First);
                }
                else
                {
                    label = pawn.LabelShort;
                }
                Widgets.Label(rect4.TopPart(0.5f).Rounded(), label);
                if (Text.CalcSize(pawn.story.Title).x > rect4.width)
                {
                    Widgets.Label(rect4.BottomPart(0.5f).Rounded(), pawn.story.TitleShort);
                }
                else
                {
                    Widgets.Label(rect4.BottomPart(0.5f).Rounded(), pawn.story.Title);
                }
                if (Event.current.type == EventType.MouseDown && Mouse.IsOver(rect3))
                {
                    this.curPawn = pawn;
                    SoundDefOf.TickTiny.PlayOneShotOnCamera(null);
                }
                GUI.EndGroup();
                if (ReorderableWidget.Reorderable(groupID, rect2.ExpandedBy(4f)))
                {
                    Widgets.DrawRectFast(rect2, Widgets.WindowBGFillColor * new Color(1f, 1f, 1f, 0.5f), null);
                }
                TooltipHandler.TipRegion(rect2, new TipSignal("DragToReorder".Translate(), pawn.GetHashCode() * 3499));
                rect2.y += 60f;
            }
        }
Пример #29
0
        static void DrawTimelineWindow()
        {
            if (Multiplayer.Client == null)
            {
                return;
            }

            Rect rect = new Rect(0, 30f, UI.screenWidth - TimelineMargin * 2, TimelineHeight);

            Widgets.DrawBoxSolid(rect, new Color(0.6f, 0.6f, 0.6f, 0.8f));

            int timerStart = Multiplayer.session.replayTimerStart >= 0 ? Multiplayer.session.replayTimerStart : OnMainThread.cachedAtTime;
            int timerEnd   = Multiplayer.session.replayTimerEnd >= 0 ? Multiplayer.session.replayTimerEnd : TickPatch.tickUntil;
            int timeLen    = timerEnd - timerStart;

            Widgets.DrawLine(new Vector2(rect.xMin + 2f, rect.yMin), new Vector2(rect.xMin + 2f, rect.yMax), Color.white, 4f);
            Widgets.DrawLine(new Vector2(rect.xMax - 2f, rect.yMin), new Vector2(rect.xMax - 2f, rect.yMax), Color.white, 4f);

            float progress  = (TickPatch.Timer - timerStart) / (float)timeLen;
            float progressX = rect.xMin + progress * rect.width;

            Widgets.DrawLine(new Vector2(progressX, rect.yMin), new Vector2(progressX, rect.yMax), Color.green, 7f);

            float       mouseX     = Event.current.mousePosition.x;
            ReplayEvent mouseEvent = null;

            foreach (var ev in Multiplayer.session.events)
            {
                if (ev.time < timerStart || ev.time > timerEnd)
                {
                    continue;
                }

                var pointX = rect.xMin + (ev.time - timerStart) / (float)timeLen * rect.width;

                //GUI.DrawTexture(new Rect(pointX - 12f, rect.yMin - 24f, 24f, 24f), texture);
                Widgets.DrawLine(new Vector2(pointX, rect.yMin), new Vector2(pointX, rect.yMax), ev.color, 5f);

                if (Mouse.IsOver(rect) && Math.Abs(mouseX - pointX) < 10)
                {
                    mouseX     = pointX;
                    mouseEvent = ev;
                }
            }

            if (Mouse.IsOver(rect))
            {
                float mouseProgress = (mouseX - rect.xMin) / rect.width;
                int   mouseTimer    = timerStart + (int)(timeLen * mouseProgress);

                Widgets.DrawLine(new Vector2(mouseX, rect.yMin), new Vector2(mouseX, rect.yMax), Color.blue, 3f);

                if (Event.current.type == EventType.MouseUp)
                {
                    TickPatch.SkipTo(mouseTimer, canESC: true);

                    if (mouseTimer < TickPatch.Timer)
                    {
                        ClientJoiningState.ReloadGame(OnMainThread.cachedMapData.Keys.ToList(), false);
                    }
                }

                if (Event.current.isMouse)
                {
                    Event.current.Use();
                }

                string tooltip = $"Tick {mouseTimer}";
                if (mouseEvent != null)
                {
                    tooltip = $"{mouseEvent.name}\n{tooltip}";
                }

                TooltipHandler.TipRegion(rect, new TipSignal(tooltip, 215462143));
                // No delay between the mouseover and showing
                if (TooltipHandler.activeTips.TryGetValue(215462143, out ActiveTip tip))
                {
                    tip.firstTriggerTime = 0;
                }
            }

            if (TickPatch.Skipping)
            {
                float pct     = (TickPatch.skipTo - timerStart) / (float)timeLen;
                float skipToX = rect.xMin + rect.width * pct;
                Widgets.DrawLine(new Vector2(skipToX, rect.yMin), new Vector2(skipToX, rect.yMax), Color.yellow, 4f);
            }
        }
Пример #30
0
        private void DrawSidePanel(Rect rect)
        {
            var font = Text.Font;

            Text.Font = GameFont.Small;

            Widgets.Label(rect, "SideBarInfo".Translate());

            rect.y += 40;

            Text.Font = GameFont.Medium;
            Widgets.Label(rect, "StorytellerPoints".Translate());

            rect.y += 40;

            Text.Font = GameFont.Small;
            Rect iconRect  = new Rect(rect.x, rect.y, 30, 30);
            Rect labelRect = new Rect(rect.x + 40, rect.y + 5f, rect.width, rect.height);

            Widgets.DrawTextureFitted(iconRect, AchievementTex.PointsIcon, 1f);
            Widgets.Label(labelRect, "PointsAvailable".Translate(APM.availablePoints));

            rect.y      += 35;
            iconRect.y  += 35;
            labelRect.y += 35;
            Widgets.DrawTextureFitted(iconRect, AchievementTex.PointsIconDark, 1f);
            Widgets.Label(labelRect, "PointsEarned".Translate(APM.totalEarnedPoints));

            rect.y += 40;

            var unlockCountTotal = $"{APM.achievementList.Where(a => a.unlocked).Count()} / {APM.achievementList.Count}";

            Widgets.Label(rect, "AchievementsTotalUnlocked".Translate(unlockCountTotal));

            rect.y   += 60;
            Text.Font = GameFont.Medium;
            Widgets.Label(rect, "PointsRedeem".Translate());

            rect.y         += 35;
            iconRect.width  = rect.width * 0.1f;
            labelRect.width = rect.width * 0.2f;
            var color = GUI.color;

            Rect buttonContainerRect = new Rect(iconRect.x, rect.y, rect.width - 10, rect.height);
            var  height         = rect.y + Mathf.CeilToInt(Rewards.Count) * 35;
            Rect buttonViewRect = new Rect(buttonContainerRect.x, buttonContainerRect.y, buttonContainerRect.width, height);

            Widgets.BeginScrollView(buttonContainerRect, ref sidebarScrollPosition, buttonViewRect);
            foreach (AchievementReward reward in Rewards.OrderBy(r => r.cost))
            {
                iconRect.y  = rect.y;
                labelRect.y = rect.y;
                bool disabled   = !string.IsNullOrEmpty(reward.Disabled);
                Rect buttonRect = new Rect(iconRect.x + 90, rect.y, rect.width - (iconRect.width + labelRect.width) - 20, 30);
                Text.Font = GameFont.Medium;
                Widgets.DrawTextureFitted(iconRect, AchievementTex.PointsIcon, 1f);
                Widgets.Label(labelRect, reward.cost.ToString());
                Text.Font = GameFont.Small;
                if (disabled)
                {
                    GUI.color = Color.gray;
                    TooltipHandler.TipRegion(buttonRect, reward.Disabled);
                }
                if (Widgets.ButtonText(buttonRect, reward.label) && !disabled)
                {
                    if (reward.PurchaseReward())
                    {
                        if (!reward.TryExecuteEvent())
                        {
                            reward.RefundPoints();
                        }
                        else
                        {
                            Close(false);
                        }
                    }
                }
                rect.y   += 35f;
                GUI.color = color;
            }
            Widgets.EndScrollView();
            Text.Font = font;
        }