private static bool DrawButton(Rect rect, string str, bool enabled, bool doborder = true)
        {
            if (doborder)
            {
                rect.y += 4;
                rect.height -= 8;

                GUI.color = Color.grey*0.7f;
                Widgets.DrawBox(rect);
                GUI.color = Color.white;
            }

            Text.Font = GameFont.Tiny;

            if (!enabled) GUI.color = Color.grey;

            Widgets.Label(rect, str);

            GUI.color = Color.white;

            Widgets.DrawHighlightIfMouseover(rect);
            Text.Font = GameFont.Small;

            if (Widgets.ButtonInvisible(rect))
            {
                return !enabled;
            }

            return enabled;
        }
        public override void DoCell(Rect rect, Pawn pawn, PawnTable table)
        {
            if (pawn.training == null)
            {
                return;
            }

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

            if (!visible)
            {
                return;
            }

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

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

            GUI.DrawTexture(checkboxRect, Resources.Background_Dark);

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

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


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

            // interaction
            Widgets.DrawHighlightIfMouseover(checkboxRect);
            if (Widgets.ButtonInvisible(checkboxRect))
            {
                pawn.training.SetWantedRecursive(def.trainable, !wanted);
            }
        }
Beispiel #3
0
        private static void DrawHeadingCheckBox(IEntityFilter filter, string label, string description, ref Rect baseRect)
        {
            Text.Font = GameFont.Medium;
            Rect rect = new Rect(baseRect.x, baseRect.y, baseRect.width, Text.LineHeight);

            Widgets.DrawHighlightIfMouseover(rect);
            if (!description.NullOrEmpty())
            {
                if (Mouse.IsOver(rect))
                {
                    GUI.DrawTexture(rect, TexUI.HighlightTex);
                }
                TooltipHandler.TipRegion(rect, description);
            }
            Text.Anchor = TextAnchor.MiddleCenter;

            Widgets.Label(rect, label);
            bool flag  = filter.IsVaild();
            bool flag2 = flag;

            Widgets.Checkbox(new Vector2(baseRect.x + rect.width - 26f, baseRect.y + 4f), ref flag);
            if (flag != flag2)
            {
                filter.SetVaild(flag);
            }
            baseRect.y += rect.height;
            Text.Anchor = TextAnchor.UpperLeft;
        }
Beispiel #4
0
        private void DrawDaysUntilRot(Rect rect, TransferableOneWay trad)
        {
            if (!trad.HasAnyThing)
            {
                return;
            }
            if (!trad.ThingDef.IsNutritionGivingIngestible)
            {
                return;
            }
            int num = int.MaxValue;

            for (int i = 0; i < trad.things.Count; i++)
            {
                CompRottable compRottable = trad.things[i].TryGetComp <CompRottable>();
                if (compRottable != null)
                {
                    num = Mathf.Min(num, DaysUntilRotCalculator.ApproxTicksUntilRot_AssumeTimePassesBy(compRottable, this.tile, null));
                }
            }
            if (num >= 36000000)
            {
                return;
            }
            Widgets.DrawHighlightIfMouseover(rect);
            float num2 = (float)num / 60000f;

            GUI.color = Color.yellow;
            Widgets.Label(rect, num2.ToString("0.#"));
            GUI.color = Color.white;
            TooltipHandler.TipRegion(rect, "DaysUntilRotTip".Translate());
        }
Beispiel #5
0
        private void DrawForagedFoodPerDay(Rect rect, TransferableOneWay trad)
        {
            if (!trad.HasAnyThing)
            {
                return;
            }
            Pawn p = trad.AnyThing as Pawn;

            if (p == null)
            {
                return;
            }
            bool  flag;
            float foragedNutritionPerDay = ForagedFoodPerDayCalculator.GetBaseForagedNutritionPerDay(p, out flag);

            if (flag)
            {
                return;
            }
            Widgets.DrawHighlightIfMouseover(rect);
            GUI.color = ((foragedNutritionPerDay != 0f) ? Color.green : Color.gray);
            Widgets.Label(rect, "+" + foragedNutritionPerDay.ToString("0.##"));
            GUI.color = Color.white;
            TooltipHandler.TipRegion(rect, () => "NutritionForagedPerDayTip".Translate(new object[]
            {
                StatDefOf.ForagedNutritionPerDay.Worker.GetExplanationFull(StatRequest.For(p), StatDefOf.ForagedNutritionPerDay.toStringNumberSense, foragedNutritionPerDay)
            }), trad.GetHashCode() ^ 1958671422);
        }
Beispiel #6
0
        public static void DoCheckbox(Rect rect, ref bool value, Func <string> tipGetter = null, bool background = true,
                                      bool mouseover    = true, Texture2D backgroundTexture = null,
                                      Texture2D checkOn = null, Texture2D checkOff          = null)
        {
            // background and hover
            if (background)
            {
                DrawCheckboxBackground(rect, backgroundTexture);
            }
            if (mouseover)
            {
                Widgets.DrawHighlightIfMouseover(rect);
            }
            if (tipGetter != null)
            {
                TooltipHandler.TipRegion(rect, tipGetter, DesignationDefOf.Slaughter.shortHash ^ rect.GetHashCode());
            }

            // draw textures and click
            if (value || checkOff != null)
            {
                GUI.DrawTexture(rect, value ? checkOn ?? Widgets.CheckboxOnTex : checkOff);
            }
            if (Widgets.ButtonInvisible(rect))
            {
                value = !value;
            }
        }
 private void DrawDaysUntilRot(Rect rect, TransferableOneWay trad)
 {
     if (!trad.HasAnyThing || !trad.ThingDef.IsNutritionGivingIngestible)
     {
         return;
     }
     if (!cachedTicksUntilRot.TryGetValue(trad, out var value))
     {
         value = int.MaxValue;
         for (int i = 0; i < trad.things.Count; i++)
         {
             CompRottable compRottable = trad.things[i].TryGetComp <CompRottable>();
             if (compRottable != null)
             {
                 value = Mathf.Min(value, DaysUntilRotCalculator.ApproxTicksUntilRot_AssumeTimePassesBy(compRottable, tile));
             }
         }
         cachedTicksUntilRot.Add(trad, value);
     }
     if (value < 36000000 && !((float)value >= 3.6E+07f))
     {
         Widgets.DrawHighlightIfMouseover(rect);
         float num = (float)value / 60000f;
         GUI.color = Color.yellow;
         Widgets.Label(rect, num.ToString("0.#"));
         GUI.color = Color.white;
         TooltipHandler.TipRegionByKey(rect, "DaysUntilRotTip");
     }
 }
Beispiel #8
0
        /// <inheritdoc/>
        protected override void DrawArmorStatsRow(WidgetRow row, Pawn pawn, StatDef stat, string label, bool apparelChanged)
        {
            ValidateArg.NotNull(row, nameof(row));

            Tuple <float, string> tuple = this.GetArmorStat(pawn, stat, apparelChanged);

            row.Label(label);
            row.Gap((WidgetRow.LabelGap * 120) - row.FinalX);

            if (stat == StatDefOf.ArmorRating_Blunt)
            {
                row.Label(Utility.FormatArmorValue(tuple.Item1, CEStrings.MPa.TranslateSimple()));
            }
            else if (stat == StatDefOf.ArmorRating_Sharp)
            {
                row.Label(Utility.FormatArmorValue(tuple.Item1, CEStrings.mmRHA.TranslateSimple()));
            }
            else if (stat == StatDefOf.ArmorRating_Heat)
            {
                row.Label(Utility.FormatArmorValue(tuple.Item1, UIText.ArmorHeat.TranslateSimple()));
            }

            Rect tipRegion = new Rect(0, row.FinalY, row.FinalX, WidgetRow.IconSize);

            row.Gap(int.MaxValue);

            TooltipHandler.TipRegion(tipRegion, tuple.Item2);
            Widgets.DrawHighlightIfMouseover(tipRegion);
        }
Beispiel #9
0
        private void DrawWarRect(Rect rect, ref int y, War war)
        {
            Text.Anchor = TextAnchor.UpperLeft;
            Text.Font   = GameFont.Small;

            Rect r         = new Rect(10, y, rect.width - 20, 70);
            Rect titleRect = new Rect(15, y, rect.width - 20, 50);

            Widgets.Label(titleRect, war.WarName);
            Text.Font = GameFont.Tiny;
            Rect rect2 = new Rect(15, y + 22, rect.width - 30, 50);

            Widgets.Label(rect2, "WarManager_Factions".Translate(war.WarGoalDef.LabelCap, war.AssaultFactions.Count, war.AttackedAlliance == null ? "WarManager_NoAlliance".Translate().ToString() : war.AttackedAlliance.Name, war.DefendingFactions.Count,
                                                                 war.DefendAlliance == null ? "WarManager_NoAlliance".Translate().ToString() : war.DefendAlliance.Name));

            Text.Anchor = TextAnchor.UpperLeft;
            Text.Font   = GameFont.Small;

            if (Widgets.ButtonInvisible(r))
            {
                if (war != currentWar)
                {
                    currentWar = war;
                    stat       = currentWar.StatWorker.GetStat();
                }
            }

            GUI.color = war.WarGoalDef.MenuColor;
            Widgets.DrawHighlight(r);
            GUI.color = Color.white;

            Widgets.DrawHighlightIfMouseover(r);

            y += 85;
        }
        public static void LabeledIntRange(Listing_Standard listing, ref IntRange range, int min, int max, string label, string tooltip = null)
        {
            Rect rect = new Rect(listing.GetRect(44f));

            Widgets.DrawHighlightIfMouseover(rect);

            Rect innerRect = rect;

            innerRect.yMin += 8f;
            innerRect.yMax -= 8f;

            Rect leftSide  = innerRect;
            Rect rightSide = innerRect;

            leftSide.xMax  -= 0.76f * innerRect.width;
            rightSide.xMin += 0.26f * innerRect.width;

            Widgets.Label(leftSide, label);

            Widgets.IntRange(rightSide, (int)listing.CurHeight, ref range, min, max, null, 0);

            if (tooltip != null)
            {
                TooltipHandler.TipRegion(rect, tooltip);
            }
        }
        public static float AnglePicker(Listing_Standard listing, float val, string label, int spinnerType = 1, bool fullCircle = false, bool snap = true)
        {
            Rect rect = new Rect(listing.GetRect(44f));

            Widgets.DrawHighlightIfMouseover(rect);
            Rect leftSide  = rect;
            Rect rightSide = rect;

            leftSide.xMax  -= 0.76f * rect.width;
            rightSide.xMin += 0.26f * rect.width;
            Rect sliderRect = rightSide;

            sliderRect.yMin += 16f;

            Widgets.Label(leftSide, String.Format("{0}: {1}°", label, val));

            Rect spinnerRect = new Rect(leftSide);

            spinnerRect.xMax -= 10f;
            spinnerRect.xMin  = spinnerRect.xMax - 44f;

            string    texPath = String.Format("GUI/ZMD_spinner{0}", spinnerType);
            Texture2D spinner = ContentFinder <Texture2D> .Get(texPath, true);

            Widgets.DrawTextureRotated(spinnerRect, spinner, val);

            float result = val;
            float max    = fullCircle ? 36f : 18f;

            result = 10f * (float)Math.Round(GUI.HorizontalSlider(sliderRect, val * 0.1f, 0f, max));
            return(result);
        }
Beispiel #12
0
        private void DoRow(Rect rect, StoreIncident thingDef, int index)
        {
            Widgets.DrawHighlightIfMouseover(rect);
            TooltipHandler.TipRegion(rect, thingDef.description);
            GUI.BeginGroup(rect);
            Rect rect2 = new Rect(4f, (rect.height - 20f) / 2f, 20f, 20f);
            //Widgets.ThingIcon(rect2, thingDef);
            Rect rect3 = new Rect(rect2.xMax + 4f, 0f, rect.width - 60, 24f);

            Text.Anchor   = TextAnchor.MiddleLeft;
            Text.WordWrap = false;

            if (thingDef.cost < 1 && thingDef.defName != "Item")
            {
                GUI.color = Color.grey;
            }

            Widgets.Label(rect3, thingDef.label.CapitalizeFirst());
            Rect rect4 = new Rect(rect3.width, rect3.y, 60, rect3.height);

            if (Widgets.ButtonText(rect4, "Edit"))
            {
                Type type = typeof(StoreIncidentEditor);
                Find.WindowStack.TryRemove(type);
                StoreIncidentEditor window = new StoreIncidentEditor(thingDef);
                Find.WindowStack.Add(window);
            }
            Text.Anchor   = TextAnchor.UpperLeft;
            Text.WordWrap = true;
            GUI.color     = Color.white;
            GUI.EndGroup();
        }
Beispiel #13
0
        public static void Dialog_ToolTip(this Listing_Standard list, string help)
        {
            var rectLine = list.GetRect(Text.LineHeight);

            Widgets.DrawHighlightIfMouseover(rectLine);
            TooltipHandler.TipRegion(rectLine, help.SafeTranslate());
        }
        public static void DoWindowContents(Rect rect)
        {
            var options = new Listing_Standard();

            options.Begin(rect);
            var optionRect = options.GetRect(Text.LineHeight);
            var fieldRect  = optionRect;
            var labelRect  = optionRect;

            fieldRect.xMin = optionRect.xMax - optionRect.width * (1 / 8f);
            labelRect.xMax = fieldRect.xMin;
            TooltipHandler.TipRegion(optionRect, Resources.Strings.UpdateIntervalTooltip);
            Widgets.DrawHighlightIfMouseover(optionRect);
            Widgets.Label(labelRect, Resources.Strings.UpdateInterval);
            var updateFrequencyBuffer = UpdateFrequency.ToString();

            Widgets.TextFieldNumeric(fieldRect, ref UpdateFrequency, ref updateFrequencyBuffer, 1, 120);
            options.Gap(options.verticalSpacing);
            options.CheckboxLabeled(Resources.Strings.AssignMultipleDoctors, ref AssignMultipleDoctors,
                                    Resources.Strings.AssignMultipleDoctorsTooltip);
            options.CheckboxLabeled(Resources.Strings.AssignAllWorkTypes, ref AssignAllWorkTypes,
                                    Resources.Strings.AssignAllWorkTypesTooltip);
            options.CheckboxLabeled(Resources.Strings.AllHaulers, ref AllHaulers, Resources.Strings.AllHaulersTooltip);
            options.CheckboxLabeled(Resources.Strings.AllCleaners, ref AllCleaners,
                                    Resources.Strings.AllCleanersTooltip);
            options.End();
        }
Beispiel #15
0
        public static void MedicalCareSetter(Rect rect, ref MedicalCareCategory medCare)
        {
            Rect rect2 = new Rect(rect.x, rect.y, rect.width / 5f, rect.height);

            for (int i = 0; i < 5; i++)
            {
                MedicalCareCategory mc = (MedicalCareCategory)i;
                Widgets.DrawHighlightIfMouseover(rect2);
                MouseoverSounds.DoRegion(rect2);
                GUI.DrawTexture(rect2, careTextures[i]);
                Widgets.DraggableResult draggableResult = Widgets.ButtonInvisibleDraggable(rect2);
                if (draggableResult == Widgets.DraggableResult.Dragged)
                {
                    medicalCarePainting = true;
                }
                if ((medicalCarePainting && Mouse.IsOver(rect2) && medCare != mc) || draggableResult.AnyPressed())
                {
                    medCare = mc;
                    SoundDefOf.Tick_High.PlayOneShotOnCamera();
                }
                if (medCare == mc)
                {
                    Widgets.DrawBox(rect2, 3);
                }
                if (Mouse.IsOver(rect2))
                {
                    TooltipHandler.TipRegion(rect2, () => mc.GetLabel(), 632165 + i * 17);
                }
                rect2.x += rect2.width;
            }
            if (!Input.GetMouseButton(0))
            {
                medicalCarePainting = false;
            }
        }
Beispiel #16
0
        public void OnGUI(Rect graphRect)
        {
            Widgets.DrawMenuSection(graphRect);

            //Columns
            float spaceBetweenColumn = graphRect.width / maxX;
            float columnWidth        = spaceBetweenColumn * 0.6f;

            int current = 0;

            foreach (double pointY in targetData)
            {
                {
                    float columnPositionX = (spaceBetweenColumn * 0.5f) + spaceBetweenColumn * current;
                    float columnHeight    = (float)(pointY / maxY) * graphRect.height;
                    Rect  columnRect      = new Rect(graphRect.x + columnPositionX, graphRect.y + graphRect.height - columnHeight, columnWidth / 2f, columnHeight);

                    Widgets.DrawBoxSolid(columnRect, Color.green);
                    Widgets.DrawBox(columnRect);
                    Rect highlightRect = columnRect.ExpandedBy(3f);
                    Widgets.DrawHighlightIfMouseover(highlightRect);

                    if (Mouse.IsOver(highlightRect))
                    {
                        TooltipHandler.TipRegion(highlightRect, $"{current}: {pointY}");
                    }
                }

                current++;
            }
        }
Beispiel #17
0
            public override void Draw(float position, float width, ITab_Pawn_Log_Utility.LogDrawData data)
            {
                float height = base.GetHeight(width);
                float width2 = width - 29f;
                Rect  rect   = new Rect(0f, position, width, height);

                if (this.log == data.highlightEntry)
                {
                    Widgets.DrawRectFast(rect, new Color(1f, 1f, 1f, ITab_Pawn_Log_Utility.HighlightAlpha * data.highlightIntensity), null);
                    data.highlightIntensity = Mathf.Max(0f, data.highlightIntensity - Time.deltaTime / ITab_Pawn_Log_Utility.HighlightDuration);
                }
                else if (data.alternatingBackground)
                {
                    Widgets.DrawRectFast(rect, new Color(1f, 1f, 1f, ITab_Pawn_Log_Utility.AlternateAlpha), null);
                }
                data.alternatingBackground = !data.alternatingBackground;
                Widgets.Label(new Rect(29f, position, width2, height), this.log.ToGameStringFromPOV(this.pawn, false));
                Texture2D texture2D = this.log.IconFromPOV(this.pawn);

                if (texture2D != null)
                {
                    Rect position2 = new Rect(0f, position + (height - 26f) / 2f, 26f, 26f);
                    GUI.DrawTexture(position2, texture2D);
                }
                Widgets.DrawHighlightIfMouseover(rect);
                TooltipHandler.TipRegion(rect, () => this.log.GetTipString(), 613261 + this.log.LogID * 2063);
                if (Widgets.ButtonInvisible(rect, false))
                {
                    this.log.ClickedFromPOV(this.pawn);
                }
                if (DebugViewSettings.logCombatLogMouseover && Mouse.IsOver(rect))
                {
                    this.log.ToGameStringFromPOV(this.pawn, true);
                }
            }
        /// <summary>
        /// Draw a lable which doubles as a button.
        /// </summary>
        /// <param name="rect"> Rect for drawing. </param>
        /// <param name="label"> Label to draw in <paramref name="rect"/>. </param>
        /// <param name="action"> Action to take when it is clicked. </param>
        /// <param name="toggleable"> Indicates if button can be toggled and uses a selected texture if true. </param>
        public static void DrawLabelButton(Rect rect, string label, Action action, bool toggleable)
        {
            Text.WordWrap = false;
            Text.Anchor   = TextAnchor.MiddleLeft;

            Widgets.Label(rect, label);
            if (toggleable)
            {
                if (Mouse.IsOver(rect))
                {
                    Widgets.DrawHighlightSelected(rect);
                }
            }
            else
            {
                Widgets.DrawHighlightIfMouseover(rect);
            }

            if (Widgets.ButtonInvisible(rect))
            {
                action?.Invoke();
            }

            Text.Anchor   = TextAnchor.UpperLeft;
            Text.WordWrap = true;
        }
Beispiel #19
0
            private float DoGenePreferences(Vector2 position, float width)
            {
                var rect = new Rect(position, new Vector2(width, 1000));

                var listingStandard = new Listing_Standard();

                listingStandard.Begin(rect);

                Text.Font = GameFont.Tiny;

                foreach (var gene in Constants.affectedStats)
                {
                    var label       = Constants.GetLabel(gene);
                    var description = Constants.GetDescription(gene);

                    var highlightRect = listingStandard.Label(label, -1f, description);

                    highlightRect.height += DoSlider(listingStandard, gene);

                    Widgets.DrawHighlightIfMouseover(highlightRect);
                }

                listingStandard.End();

                return(listingStandard.CurHeight);
            }
Beispiel #20
0
        public static void DrawToggle(Rect rect, string label, string tooltip, bool checkOn, bool checkOff, Action on,
                                      Action off, bool expensive = false, float size = SmallIconSize,
                                      float margin = Margin, bool wrap = true)
        {
            // set up rects
            var labelRect = rect;
            var iconRect  = new Rect(rect.xMax - size - margin, 0f, size, size);

            labelRect.xMax = iconRect.xMin - Margin / 2f;

            // finetune rects
            iconRect = iconRect.CenteredOnYIn(labelRect);

            // draw label
            Label(rect, label, TextAnchor.MiddleLeft, GameFont.Small, margin: margin, wrap: wrap);

            // tooltip
            if (!tooltip.NullOrEmpty())
            {
                TooltipHandler.TipRegion(rect, tooltip);
            }

            // draw check
            if (checkOn)
            {
                GUI.DrawTexture(iconRect, Widgets.CheckboxOnTex);
            }
            else if (checkOff)
            {
                GUI.DrawTexture(iconRect, Widgets.CheckboxOffTex);
            }
            else
            {
                GUI.DrawTexture(iconRect, Widgets.CheckboxPartialTex);
            }

            // draw expensive icon
            if (expensive)
            {
                iconRect.x -= size + margin;
                TooltipHandler.TipRegion(iconRect, "FM.Expensive.Tip".Translate());
                GUI.color = checkOn ? Resources.Orange : Color.grey;
                GUI.DrawTexture(iconRect, Resources.Stopwatch);
                GUI.color = Color.white;
            }

            // interactivity
            Widgets.DrawHighlightIfMouseover(rect);
            if (Widgets.ButtonInvisible(rect))
            {
                if (!checkOn)
                {
                    on();
                }
                else
                {
                    off();
                }
            }
        }
        private void DrawNutritionEatenPerDay(Rect rect, TransferableOneWay trad)
        {
            if (!trad.HasAnyThing)
            {
                return;
            }
            Pawn p = trad.AnyThing as Pawn;

            if (p == null || !p.RaceProps.EatsFood || p.Dead || p.needs.food == null)
            {
                return;
            }
            Widgets.DrawHighlightIfMouseover(rect);
            string       text = (p.needs.food.FoodFallPerTickAssumingCategory(HungerCategory.Fed, ignoreMalnutrition: true) * 60000f).ToString("0.##");
            DietCategory resolvedDietCategory = p.RaceProps.ResolvedDietCategory;

            if (resolvedDietCategory != DietCategory.Omnivorous)
            {
                text = text + " (" + resolvedDietCategory.ToStringHumanShort() + ")";
            }
            GUI.color = new Color(1f, 0.5f, 0f);
            Widgets.Label(rect, text);
            GUI.color = Color.white;
            if (Mouse.IsOver(rect))
            {
                TooltipHandler.TipRegion(rect, () => RaceProperties.NutritionEatenPerDayExplanation_NewTemp(p, showDiet: true, showLegend: true, showCalculations: false), trad.GetHashCode() ^ 0x17016B3E);
            }
        }
Beispiel #22
0
        public static void DrawToggle(Rect rect, string label, ref bool checkOn, float size = 24f,
                                      float margin = Margin, GameFont font = GameFont.Small)
        {
            // set up rects
            Rect labelRect = rect;
            var  checkRect = new Rect(rect.xMax - size - margin * 2, 0f, size, size);

            // finetune rects
            checkRect = checkRect.CenteredOnYIn(labelRect);

            // draw label
            Label(rect, label, null, TextAnchor.MiddleLeft, margin, font: font);

            // draw check
            if (checkOn)
            {
                GUI.DrawTexture(checkRect, Widgets.CheckboxOnTex);
            }
            else
            {
                GUI.DrawTexture(checkRect, Widgets.CheckboxOffTex);
            }

            // interactivity
            Widgets.DrawHighlightIfMouseover(rect);
            if (Widgets.ButtonInvisible(rect))
            {
                checkOn = !checkOn;
            }
        }
Beispiel #23
0
        private bool DrawGrazeability(Rect rect, TransferableOneWay trad)
        {
            if (!trad.HasAnyThing)
            {
                return(false);
            }
            Pawn pawn = trad.AnyThing as Pawn;

            if (pawn == null || !VirtualPlantsUtility.CanEverEatVirtualPlants(pawn))
            {
                return(false);
            }
            rect.width = 40f;
            Rect position = new Rect(rect.x + (float)((int)((rect.width - 28f) / 2f)), rect.y + (float)((int)((rect.height - 28f) / 2f)), 28f, 28f);

            Widgets.DrawHighlightIfMouseover(rect);
            GUI.DrawTexture(position, TransferableOneWayWidget.CanGrazeIcon);
            TooltipHandler.TipRegion(rect, delegate()
            {
                string text = "AnimalCanGrazeTip".Translate();
                if (this.tile != -1)
                {
                    text = text + "\n\n" + VirtualPlantsUtility.GetVirtualPlantsStatusExplanationAt(this.tile, Find.TickManager.TicksAbs);
                }
                return(text);
            }, trad.GetHashCode() ^ 1948571634);
            return(true);
        }
Beispiel #24
0
        private void DrawLine(WealthItem wi, float lineWidth, float lineHeight, ref float y)
        {
            if (wi.MarketValueAll < 1f)
            {
                return;
            }

            GUI.BeginGroup(new Rect(x: 0f, y: y, width: lineWidth, height: lineHeight));

            float nameColumnWidth = lineWidth - lineHeight - DefaultColumnWidth * 3; // height(icon)
            Rect  elementRect     = new Rect(x: 0f, y: 0f, width: lineWidth, height: lineHeight);

            Widgets.DrawHighlightIfMouseover(elementRect);
            TooltipHandler.TipRegion(elementRect, wi.thing.DescriptionFlavor);

            // icon, lambda because Widgets.ThingIcon has 3 arguments with default float value 1
            DrawElementOfLine(ref elementRect, lineHeight, (rect, thing) => Widgets.ThingIcon(rect, thing), wi.thing);
            // label
            DrawElementOfLine(ref elementRect, nameColumnWidth, Widgets.Label, wi.Name);
            // count
            DrawElementOfLine(ref elementRect, DefaultColumnWidth, Widgets.Label, $"x{wi.Count}");
            // marketValue
            DrawElementOfLine(ref elementRect, DefaultColumnWidth, Widgets.Label, Mathf.RoundToInt(wi.MarketValueAll).ToString());
            // infoCardButton
            Widgets.InfoCardButton(elementRect.x, elementRect.y, wi.thing);

            GUI.EndGroup();
            y += lineHeight;
        }
        public override void DoHeader( Rect rect, PawnTable table )
        {
            // make sure we're at the correct font size
            Text.Font = GameFont.Small;
            Rect labelRect = rect;

            if ( Settings.verticalLabels )
                DrawVerticalHeader( rect, table );
            else
                DrawHorizontalHeader( rect, table, out labelRect );

            // handle interactions (click + scroll)
            HeaderInteractions( labelRect, table );

            // mouseover stuff
            Widgets.DrawHighlightIfMouseover( labelRect );
            TooltipHandler.TipRegion( labelRect, GetHeaderTip( table ) );

            // sort icon
            if ( table.SortingBy == def )
            {
                Texture2D sortIcon = ( !table.SortingDescending ) ? SortingIcon : SortingDescendingIcon;
                Rect bottomRight = new Rect( rect.xMax - sortIcon.width - 1f, rect.yMax - sortIcon.height - 1f,
                                             sortIcon.width, sortIcon.height );
                GUI.DrawTexture( bottomRight, sortIcon );
            }
        }
Beispiel #26
0
        private void DrawNewsImportanceSpace(TaleNews news)
        {
            Rect boundingRect = new Rect(320, 0, 80, EntryHeight);

            Widgets.DrawHighlightIfMouseover(boundingRect);
            if (subjectPawn != null)
            {
                // Individual pawn
                Rect textRect = boundingRect;
                textRect.xMin += 10;
                textRect.xMax -= 10;
                float importance = subjectPawn.GetNewsKnowledgeTracker().AttemptToObtainExistingReference(news).NewsImportance;
                Widgets.Label(textRect, Math.Round(importance, 2).ToString());
                StringBuilder builder = new StringBuilder("Importance score of this news: ");
                builder.Append(importance);
                builder.AppendLine();
                builder.Append("News with higher importance score will be more likely to be passed on.");
                TooltipHandler.TipRegion(boundingRect, builder.ToString());
            }
            else
            {
                // All pawns
                TooltipHandler.TipRegion(boundingRect, "(Reserved.)");
            }
        }
        private static void DrawFavouriteStar(Rect rect, PersistentColony colony)
        {
            var favoured = colony.ColonyData.Favoured;

            var size          = rect.size.x;
            var starRect      = new Rect(rect.x, rect.y, size, size);
            var starImageRect = new Rect(starRect.x + size * 0.1f, starRect.y + size * 0.05f, starRect.width * 0.9f, starRect.height * 0.9f);

            if (!favoured)
            {
                Widgets.DrawAltRect(starRect);
            }
            else
            {
                Widgets.DrawHighlight(starRect);
            }

            Widgets.DrawHighlightIfMouseover(starRect);

            if (ButtonTextureHover(starRect, starImageRect, FavouriteStar, FavouriteStarToBe,
                                   Color.gray, favoured ? Color.red : Color.green, GenUI.MouseoverColor, favoured))
            {
                colony.ColonyData.Favoured = !favoured;
                _sorted = null; // Reset favourites list
            }

            TooltipHandler.TipRegion(starRect, !favoured ? "FilUnderscore.PersistentRimWorlds.Colony.Favourite.Add".Translate() :
                                     "FilUnderscore.PersistentRimWorlds.Colony.Favourite.Remove".Translate());
        }
Beispiel #28
0
        private void DrawTabRow(Rect rect, Pawn pawn, PawnRowViewModel viewModel, ViewMode viewMode)
        {
            Rect nameRect   = rect.ReplaceWidth(_pawnNameWidth).ReplaceHeight(GenUI.ListSpacing);
            Rect selectRect = nameRect.ReplaceHeight(GenUI.ListSpacing * 2);

            if (Widgets.ButtonInvisible(selectRect))
            {
                Selector selector = Find.Selector;
                selector.ClearSelection();
                selector.Select(pawn);
            }

            Widgets.DrawHighlightIfMouseover(selectRect);
            Widgets.Label(nameRect, pawn.NameFullColored);
            Widgets.Label(nameRect.ReplaceY(nameRect.yMax), pawn.LabelNoCountColored);

            rect = rect.ReplaceX(nameRect.xMax).ReplaceWidth((rect.width - _pawnNameWidth) / 2);
            if (viewMode == ViewMode.Loadout)
            {
                this.DrawLoadoutRow(rect, pawn, viewModel);
            }
            else if (viewMode == ViewMode.Inventory)
            {
                this.DrawInventoryRow(rect, pawn, viewModel);
            }
        }
Beispiel #29
0
        private static void DoRow(Rect rect, TransferableImmutable thing, Caravan caravan)
        {
            GUI.BeginGroup(rect);
            Rect rect2 = rect.AtZero();

            if (thing.TotalStackCount != 1)
            {
                CaravanThingsTabUtility.DoAbandonSpecificCountButton(rect2, thing, caravan);
            }
            rect2.width -= 24f;
            CaravanThingsTabUtility.DoAbandonButton(rect2, thing, caravan);
            rect2.width -= 24f;
            Widgets.InfoCardButton(rect2.width - 24f, (rect.height - 24f) / 2f, thing.AnyThing);
            rect2.width -= 24f;
            Rect rect3 = rect2;

            rect3.xMin = rect3.xMax - 60f;
            CaravanThingsTabUtility.DrawMass(thing, rect3);
            rect2.width -= 60f;
            Widgets.DrawHighlightIfMouseover(rect2);
            Rect rect4 = new Rect(4f, (rect.height - 27f) / 2f, 27f, 27f);

            Widgets.ThingIcon(rect4, thing.AnyThing, 1f);
            Rect rect5 = new Rect(rect4.xMax + 4f, 0f, 300f, 30f);

            Text.Anchor   = TextAnchor.MiddleLeft;
            Text.WordWrap = false;
            Widgets.Label(rect5, thing.LabelCapWithTotalStackCount.Truncate(rect5.width, null));
            Text.Anchor   = TextAnchor.UpperLeft;
            Text.WordWrap = true;
            GUI.EndGroup();
        }
Beispiel #30
0
        private void DoDrives(Rect rect)
        {
            //Widgets.DrawBox(rect);
            Widgets.DrawBoxSolid(rect, this.drivesBackgroundColor);
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.MiddleLeft;

            float buttonHeight = 24;
            Rect  rectView     = new Rect(0, 0, rect.width - this.scrollBarWidth, buttonHeight * this.drives.Count());

            Widgets.BeginScrollView(rect, ref this.drivesScrollPos, rectView);
            int index = 0;

            foreach (string drive in this.drives)
            {
                Rect rectButton = new Rect(rectView.x, rectView.y + index * buttonHeight, rectView.width + this.scrollBarWidth, buttonHeight);
                if (Widgets.ButtonText(rectButton, $" {drive}", false, false, true))
                {
                    this.currentPath  = drive;
                    this.dirInfoDirty = true;
                    this.soundAmbient.PlayOneShotOnCamera(null);
                }
                if (drive == Path.GetPathRoot(this.currentPath))
                {
                    Widgets.DrawHighlightSelected(rectButton);
                }
                else
                {
                    Widgets.DrawHighlightIfMouseover(rectButton);
                }
                index++;
            }
            Widgets.EndScrollView();
        }