public static void Drawtab(Rect r, ProfileInfoMode i, string lab)
        {
            r.height += 1;
            r.width  += 1;
            Widgets.DrawMenuSection(r);
            if (ProfileInfoTab == i)
            {
                var hang = r.ContractedBy(1f);
                hang.y += 2;
                Widgets.DrawBoxSolid(hang, Widgets.MenuSectionBGFillColor);
            }

            Widgets.Label(r, lab);

            if (Widgets.ButtonInvisible(r))
            {
                ProfileInfoTab = i;
                Modbase.Settings.Write();
            }
        }
    public override void DoCell(Rect rect, Pawn pawn, PawnTable table)
    {
        base.DoCell(rect, pawn, table);
        var rect2 = new Rect(rect.x, rect.y, rect.width, Mathf.Min(rect.height, 30f));

        if (Widgets.ButtonInvisible(rect2))
        {
            CameraJumper.TryJumpAndSelect(pawn);
            if (Current.ProgramState == ProgramState.Playing && Event.current.button == 0)
            {
                Find.MainTabsRoot.EscapeCurrentTab(false);
            }
        }
        else
        {
            var tooltip = pawn.GetTooltip();
            tooltip.text = "ClickToJumpTo".Translate() + "\n\n" + tooltip.text;
            TooltipHandler.TipRegion(rect2, tooltip);
        }
    }
Ejemplo n.º 3
0
        public static void AddPsycheEditButton(EdB.PrepareCarefully.PanelBackstory __instance, EdB.PrepareCarefully.State state)
        {
            Rect           panelRect = __instance.PanelRect;
            PsychologyPawn pawn      = state.CurrentPawn.Pawn as PsychologyPawn;

            if (pawn != null)
            {
                if (pawn.psyche == null || pawn.psyche.PersonalityNodes == null)
                {
                    pawn.psyche = new Pawn_PsycheTracker(pawn);
                    pawn.psyche.Initialize();
                    foreach (PersonalityNode node in pawn.psyche.PersonalityNodes)
                    {
                        if (node.rawRating < 0)
                        {
                            node.Initialize();
                        }
                    }
                }
                if (pawn.sexuality == null && PsychologyBase.ActivateKinsey())
                {
                    pawn.sexuality = new Pawn_SexualityTracker(pawn);
                    pawn.sexuality.GenerateSexuality();
                }
                Rect rect = new Rect(panelRect.width - 60f, 9f, 22f, 22f);
                if (rect.Contains(Event.current.mousePosition))
                {
                    GUI.color = new Color(0.97647f, 0.97647f, 0.97647f);
                }
                else
                {
                    GUI.color = new Color(0.623529f, 0.623529f, 0.623529f);
                }
                GUI.DrawTexture(rect, ContentFinder <Texture2D> .Get("Buttons/ButtonPsyche", true));
                if (Widgets.ButtonInvisible(rect, false))
                {
                    SoundDefOf.TickLow.PlayOneShotOnCamera(null);
                    Find.WindowStack.Add(new Dialog_EditPsyche(pawn));
                }
            }
        }
Ejemplo n.º 4
0
        private bool DrawZoneInfo(Rect rect, Rect headerRect, ref float singleInfoWidth, SingleZoneGrowingData data)
        {
            bool result = true;

            try
            {
                Rect rect1 = new Rect(rect.x, rect.y, headerRect.xMin, rect.height);
                GUI.color = Color.white;
                //write plant name
                Text.Anchor = TextAnchor.MiddleLeft;
                Text.Font   = GameFont.Small;
                Widgets.Label(rect1, data.zone.GetPlantDefToGrow().label);
                //write numbers
                Text.Anchor = TextAnchor.MiddleCenter;
                Text.Font   = GameFont.Tiny;
                Rect emptyCellRectLabel          = new Rect(headerRect.x, rect1.y, singleInfoWidth, rect.height);
                Rect nonEmptyCellRectLabel       = new Rect(emptyCellRectLabel.xMax, emptyCellRectLabel.y, singleInfoWidth, rect.height);
                Rect nonHarvestableCellRectLabel = new Rect(nonEmptyCellRectLabel.xMax, emptyCellRectLabel.y, singleInfoWidth, rect.height);
                Rect harvestableCellRectLabel    = new Rect(nonHarvestableCellRectLabel.xMax, emptyCellRectLabel.y, singleInfoWidth, rect.height);
                Rect fullyGrownCellRectLabel     = new Rect(harvestableCellRectLabel.xMax, emptyCellRectLabel.y, singleInfoWidth, rect.height);
                Widgets.Label(emptyCellRectLabel, "x" + (data.zone.Cells.Count - data.totalPlantedCount));
                Widgets.Label(nonEmptyCellRectLabel, "x" + data.totalPlantedCount);
                Widgets.Label(nonHarvestableCellRectLabel, "x" + (data.totalPlantedCount - data.harvestablePlants.Count));
                Widgets.Label(harvestableCellRectLabel, "x" + data.harvestablePlants.Count);
                Widgets.Label(fullyGrownCellRectLabel, "x" + data.fullyGrownPlants.Count);
                //additional feature
                Widgets.DrawHighlightIfMouseover(rect);
                if (Widgets.ButtonInvisible(rect))
                {
                    Find.Selector.ClearSelection();
                    Find.Selector.Select(data.zone);
                }
            }
            catch (Exception e)
            {
                result = false;
                Log.Error("EXCEPTION in drawing data row: " + data.zone.GetPlantDefToGrow() + " .. " + e.Message);
            }

            return(result);
        }
Ejemplo n.º 5
0
        private void DrawCurrentJobList(Rect outRect, Rect viewRect)
        {
            // set sizes
            viewRect.height = _currentJobs.Count * LargeListEntryHeight;
            if (viewRect.height > outRect.height)
            {
                viewRect.width -= ScrollbarWidth;
            }

            Widgets.BeginScrollView(outRect, ref _scrollPosition, viewRect);
            GUI.BeginGroup(viewRect);

            for (var i = 0; i < _currentJobs.Count; i++)
            {
                // set up rect
                var row = new Rect(0f, LargeListEntryHeight * i, viewRect.width, LargeListEntryHeight);

                // highlights
                Widgets.DrawHighlightIfMouseover(row);
                if (i % 2 == 0)
                {
                    Widgets.DrawAltRect(row);
                }
                if (_currentJobs[i] == _selectedCurrent)
                {
                    Widgets.DrawHighlightSelected(row);
                }

                // draw label
                _currentJobs[i].DrawListEntry(row, false, true);

                // button
                if (Widgets.ButtonInvisible(row))
                {
                    Selected = _currentJobs[i];
                }
            }

            GUI.EndGroup();
            Widgets.EndScrollView();
        }
Ejemplo n.º 6
0
        private void DrawPawnOverviewRow(Pawn pawn, Rect rect)
        {
            // column width
            float colWidth = rect.width / 4 - Margin;

            // cell rects
            var nameRect     = new Rect(colWidth * 0, rect.yMin, colWidth, RowHeightPawnOverview);
            var activityRect = new Rect(colWidth * 1, rect.yMin, colWidth * 2.5f, RowHeightPawnOverview);
            var priorityRect = new Rect(colWidth * 3.5f, rect.yMin, colWidth * .5f, RowHeightPawnOverview);

            // name
            Widgets.DrawHighlightIfMouseover(nameRect);

            // on click select and jump to location
            if (Widgets.ButtonInvisible(nameRect))
            {
                Find.MainTabsRoot.EscapeCurrentTab();
                Find.CameraDriver.JumpTo(pawn.PositionHeld);
                Find.Selector.ClearSelection();
                if (pawn.Spawned)
                {
                    Find.Selector.Select(pawn);
                }
            }
            Utilities.Label(nameRect, pawn.NameStringShort, "FM.ClickToJumpTo".Translate(pawn.LabelCap),
                            TextAnchor.MiddleLeft, Margin);

            // current activity (if curDriver != null)
            string activityString = pawn.jobs.curDriver?.GetReport() ?? "FM.NoCurJob".Translate();

            Utilities.Label(activityRect, activityString, pawn.jobs.curDriver?.GetReport(), TextAnchor.MiddleCenter,
                            Margin, font: GameFont.Tiny);

            // priority button
            Rect priorityPosition = new Rect(0f, 0f, 24f, 24f).CenteredOnXIn(priorityRect)
                                    .CenteredOnYIn(priorityRect);

            Text.Font = GameFont.Medium;
            WidgetsWork.DrawWorkBoxFor(priorityPosition.xMin, priorityPosition.yMin, pawn, WorkTypeDef, false);
            Text.Font = GameFont.Small;
        }
        public void DoConditionsUI(Rect rect)
        {
            GUI.BeginGroup(rect);
            float num = 0f;

            for (int i = 0; i < activeConditions.Count; i++)
            {
                string labelCap = activeConditions[i].LabelCap;
                Rect   rect2    = new Rect(0f, num, rect.width, Text.CalcHeight(labelCap, rect.width - 6f));
                Text.Font   = GameFont.Small;
                Text.Anchor = TextAnchor.MiddleRight;
                Widgets.DrawHighlightIfMouseover(rect2);
                Rect rect3 = rect2;
                rect3.width -= 6f;
                Widgets.Label(rect3, labelCap);
                if (Mouse.IsOver(rect2))
                {
                    TooltipHandler.TipRegion(rect2, new TipSignal(activeConditions[i].TooltipString, 0x3A2DF42A ^ i));
                }
                if (Widgets.ButtonInvisible(rect2))
                {
                    if (activeConditions[i].conditionCauser != null && CameraJumper.CanJump(activeConditions[i].conditionCauser))
                    {
                        CameraJumper.TryJumpAndSelect(activeConditions[i].conditionCauser);
                    }
                    else if (activeConditions[i].quest != null)
                    {
                        Find.MainTabsRoot.SetCurrentTab(MainButtonDefOf.Quests);
                        ((MainTabWindow_Quests)MainButtonDefOf.Quests.TabWindow).Select(activeConditions[i].quest);
                    }
                }
                num += rect2.height;
            }
            rect.yMin += num;
            GUI.EndGroup();
            Text.Anchor = TextAnchor.UpperLeft;
            if (Parent != null)
            {
                Parent.DoConditionsUI(rect);
            }
        }
Ejemplo n.º 8
0
        public static void Drawtab(Rect r, int i, string lab)
        {
            r.height += 1;
            r.width  += 1;
            Widgets.DrawMenuSection(r);
            if (PatchTab == i)
            {
                var hang = r.ContractedBy(1f);
                hang.y += 2;
                Widgets.DrawBoxSolid(hang, Widgets.MenuSectionBGFillColor);
            }

            Text.Anchor = TextAnchor.MiddleCenter;
            Text.Font   = GameFont.Tiny;
            Widgets.Label(r, lab);
            DubGUI.ResetFont();
            if (Widgets.ButtonInvisible(r))
            {
                PatchTab = i;
            }
        }
Ejemplo n.º 9
0
        private static float DrawUnpatch(ref Rect rect, MethodInfo meth)
        {
            var width = "   Disable   ".GetWidthCached();
            var box   = rect.LeftPartPixels(width);

            if (Widgets.ButtonInvisible(box))
            {
                Modbase.Harmony.CreateProcessor(meth).Unpatch(postfix);
                currentlyTracking = false;
            }

            Widgets.DrawHighlightIfMouseover(box);

            var anch = Text.Anchor;

            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.Label(box, "Disable");
            Text.Anchor = anch;

            return(width);
        }
Ejemplo n.º 10
0
        public static void Postfix(Rect rect, Dialog_WombStatus __instance)
        {
            Rect buttonRect = new Rect(rect.x, rect.yMax - ICONSIZE, ICONSIZE, ICONSIZE).ContractedBy(2f);

            if (__instance.Comp.DoCleanWomb)
            {
                Widgets.DrawTextureFitted(buttonRect, TextureCache.GatherCum_Bucket, 1.0f);
                TooltipHandler.TipRegion(buttonRect, Translations.Dialog_DoCleanWomb_Tooltip);
            }
            else
            {
                Widgets.DrawTextureFitted(buttonRect, TextureCache.GatherCum_Pussy, 1.0f);
                TooltipHandler.TipRegion(buttonRect, Translations.Dialog_DontCleanWomb_Tooltip);
            }

            if (Widgets.ButtonInvisible(buttonRect))
            {
                SoundDefOf.Click.PlayOneShotOnCamera();
                __instance.Comp.DoCleanWomb = !__instance.Comp.DoCleanWomb;
            }
        }
        public static void DrawAddRow(Listing_StandardIndent listing, FindDescription owner, List <ListFilter> filters = null)
        {
            Rect addRow = listing.GetRect(Text.LineHeight);

            listing.Gap(listing.verticalSpacing);

            Rect butRect = addRow; butRect.width = Text.LineHeight;

            Widgets.DrawTextureFitted(butRect, TexButton.Plus, 1.0f);

            Rect textRect = addRow; textRect.xMin += Text.LineHeight + WidgetRow.DefaultGap;

            Widgets.Label(textRect, "TD.AddNewFilter...".Translate());

            Widgets.DrawHighlightIfMouseover(addRow);

            if (Widgets.ButtonInvisible(addRow))
            {
                AddFilterFloat(owner, filters);
            }
        }
Ejemplo n.º 12
0
        private static bool ButtonTextureHover(Rect clickRect, Rect rect, Texture texture, Texture hoverTexture, Color color, Color mouseoverColor, Color onColor, bool on, bool doMouseoverSound = true)
        {
            GUI.color = color;
            GUI.DrawTexture(rect, texture);
            GUI.color = Color.white;

            if (on && !Mouse.IsOver(clickRect))
            {
                GUI.color = onColor;
                GUI.DrawTexture(rect, hoverTexture);
                GUI.color = Color.white;
            }
            else if (Mouse.IsOver(clickRect))
            {
                GUI.color = mouseoverColor;
                GUI.DrawTexture(rect, hoverTexture);
                GUI.color = Color.white;
            }

            return(Widgets.ButtonInvisible(clickRect, doMouseoverSound));
        }
        private void DrawLetter(Rect originalRect, Letter curLetter, float topY)
        {
            //Draw letter box
            Rect letRect = new Rect(originalRect.x, topY, Letter.DrawWidth, Letter.DrawHeight);

            //Draw letter icon on letter box
            GUI.color = curLetter.def.color;
            GUI.DrawTexture(letRect, curLetter.def.Icon);

            //Draw letter info
            GUI.color = Color.white;
            Text.Font = GameFont.Small;
            string text     = curLetter.label;
            Rect   infoRect = new Rect(letRect.x + Letter.DrawWidth * 1.5f, topY, originalRect.width - Letter.DrawWidth * 1.5f, letRect.height);

            Text.Anchor = TextAnchor.MiddleLeft;
            Widgets.Label(infoRect, text);
            Text.Anchor = TextAnchor.UpperLeft;             //Reset TextAnchor as per RimWorld standard

            //Highlight and button
            Rect buttonRect = new Rect(letRect.x, letRect.y, originalRect.width, letRect.height);

            Widgets.DrawHighlightIfMouseover(buttonRect);
            var curChoiceLetter = curLetter as ChoiceLetter;

            if (curChoiceLetter != null)             //Tooltip with some of the notification text for quality of life
            {
                string tooltipText = curChoiceLetter.text;
                if (tooltipText.Length > 100)
                {
                    tooltipText = tooltipText.TrimmedToLength(100) + "...";
                }
                TooltipHandler.TipRegion(buttonRect, tooltipText);
            }

            if (Widgets.ButtonInvisible(buttonRect, false))
            {
                curLetter.OpenLetter();
            }
        }
        private static void DrawColumnHeader(ref Rect inRect, Column c)
        {
            Widgets.DrawOptionBackground(inRect, false);

            var rect = inRect.LeftPartPixels(NUMERIC_WIDTH);

            if (c.total != 0)
            {
                Widgets.Label(rect.TopHalf(), c.Name);
                Widgets.Label(rect.BottomHalf(), $"{c.total:0.000}ms");
            }
            else
            {
                Widgets.Label(rect, (c.sortBy == SortBy.Name ? "    " : "") + c.Name);
            }

            if (Analyzer.SortBy == c.sortBy)
            {
                Widgets.DrawHighlight(rect);
            }

            if (Widgets.ButtonInvisible(rect))
            {
                if (Event.current.button == 0) // left click, change sort by
                {
                    Analyzer.SortBy = Analyzer.SortBy == c.sortBy ? DEFAULT_SORTBY : c.sortBy;
                }
            }

            TooltipHandler.TipRegion(rect, c.Desc);

            if (c.sortBy != SortBy.Name)
            {
                inRect.AdjustHorizonallyBy(NUMERIC_WIDTH);

                GUI.color = Color.grey;
                Widgets.DrawLineVertical(inRect.x, rect.y, rect.height);
                GUI.color = Color.white;
            }
        }
Ejemplo n.º 15
0
 public override void FillContents(Listing_Standard standard, Rect inRect)
 {
     if (Find.Selector.selected.Count == 0)
     {
         Close();
         return;
     }
     {
         var rect = standard.GetRect(30);
         Text.Font = GameFont.Tiny;
         var searchRect = new Rect(0, 0, rect.width, 20);
         if (Widgets.ButtonImage(searchRect.LeftPartPixels(20), TexButton.CloseXSmall))
         {
             Close();
         }
         searchString = Widgets.TextField(new Rect(searchRect.position + new Vector2(25, 0), searchRect.size - new Vector2(55, 0)), searchString).ToLower();
     }
     {
         standard.Gap(5);
         var scrollRect = new Rect(inRect.position + new Vector2(0, 50), inRect.size - new Vector2(0, 50));
         var section    = standard.BeginSection_NewTemp(scrollRect.height);
         standard.EndSection(section);
         standard.BeginScrollView(new Rect(scrollRect.position + new Vector2(5, 0), scrollRect.size - new Vector2(10, 10)), ref scrollPosition, ref viewRect);
         Text.Font = GameFont.Tiny;
         foreach (Def def in defs)
         {
             if (def.label.ToLower().Contains(searchString))
             {
                 var rect = standard.GetRect(50);
                 Widgets.DefLabelWithIcon(rect, def);
                 if (Widgets.ButtonInvisible(rect))
                 {
                     onSelect(def);
                     Close();
                 }
             }
         }
         standard.EndScrollView(ref viewRect);
     }
 }
Ejemplo n.º 16
0
        public void Draw(int xOffset, int yOffset)
        {
            Rect rect = this.CalculateRect((float)xOffset, (float)yOffset);

            Find.WindowStack.ImmediateWindow(Gen.HashCombineInt(this.ID, 45574281), rect, WindowLayer.Super, delegate
            {
                Text.Font   = GameFont.Small;
                Text.Anchor = TextAnchor.MiddleLeft;
                Rect rect   = rect.AtZero();
                float alpha = this.Alpha;
                GUI.color   = new Color(1f, 1f, 1f, alpha);
                if (Message.ShouldDrawBackground)
                {
                    GUI.color = new Color(0.15f, 0.15f, 0.15f, 0.8f * alpha);
                    GUI.DrawTexture(rect, BaseContent.WhiteTex);
                    GUI.color = new Color(1f, 1f, 1f, alpha);
                }
                if (CameraJumper.CanJump(this.lookTargets.TryGetPrimaryTarget()))
                {
                    UIHighlighter.HighlightOpportunity(rect, "Messages");
                    Widgets.DrawHighlightIfMouseover(rect);
                }
                Rect rect2 = new Rect(2f, 0f, rect.width - 2f, rect.height);
                Widgets.Label(rect2, this.text);
                if (Current.ProgramState == ProgramState.Playing && CameraJumper.CanJump(this.lookTargets.TryGetPrimaryTarget()))
                {
                    if (Widgets.ButtonInvisible(rect, false))
                    {
                        CameraJumper.TryJumpAndSelect(this.lookTargets.TryGetPrimaryTarget());
                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.ClickingMessages, KnowledgeAmount.Total);
                    }
                }
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
                if (Mouse.IsOver(rect))
                {
                    Messages.Notify_Mouseover(this);
                }
            }, false, false, 0f);
        }
Ejemplo n.º 17
0
        private void DrawThing(Rect rect, Thing thing, Pawn selPawn)
        {
            if (Widgets.ButtonInvisible(rect) && Event.current.button == 1)
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>
                {
                    new FloatMenuOption("ThingInfo".Translate(), () => Find.WindowStack.Add(new Dialog_InfoCard(thing)))
                };

                //leans heavily on ITab_Pawn_Gear
                if (selPawn.IsColonistPlayerControlled)
                {
                    Action         action = null;
                    ThingWithComps eq     = thing as ThingWithComps;
                    if (thing is Apparel ap && selPawn.apparel != null && selPawn.apparel.WornApparel.Contains(ap))
                    {
                        action = delegate
                        {
                            selPawn.jobs.TryTakeOrderedJob(new Job(JobDefOf.RemoveApparel, ap));
                        };
                    }
                    else if (eq != null && selPawn.equipment.AllEquipmentListForReading.Contains(eq))
                    {
                        action = delegate
                        {
                            selPawn.jobs.TryTakeOrderedJob(new Job(JobDefOf.DropEquipment, eq));
                        };
                    }
                    else if (!thing.def.destroyOnDrop)
                    {
                        action = delegate
                        {
                            selPawn.inventory.innerContainer.TryDrop(thing, selPawn.Position, selPawn.Map, ThingPlaceMode.Near, out Thing unused);
                        };
                    }
                    list.Add(new FloatMenuOption("DropThing".Translate(), action));
                }
                FloatMenu window = new FloatMenu(list, thing.LabelCap, false);
                Find.WindowStack.Add(window);
            }
Ejemplo n.º 18
0
        public virtual void Interactions()
        {
            // on mouse down, reset the drag check
            if (Event.current.type == EventType.MouseDown)
            {
                wasDragged = false;
            }

            // hover and drag handlers
            if (Mouse.IsOver(slot))
            {
                // hover
                OnHover?.Invoke();

                // on left mouse drag, move node, freeze location, and restart graph so other nodes react
                if (Event.current.button == 0 && Event.current.type == EventType.MouseDrag)
                {
                    position  += Event.current.delta;
                    frozen     = true;
                    wasDragged = true;
                    graph.Restart();
                }
            }

            // clicks
            if (Widgets.ButtonInvisible(slot) && !wasDragged)
            {
                // on right click
                if (Event.current.button == 1 && OnRightClick != null)
                {
                    OnRightClick();
                }

                // on left click
                if (Event.current.button == 0 && OnLeftClick != null)
                {
                    OnLeftClick();
                }
            }
        }
Ejemplo n.º 19
0
        public override void DoCell(Rect rect, Pawn pawn, PawnTable table)
        {
            Rect rect2 = new Rect(rect.x, rect.y, rect.width, Mathf.Min(rect.height, 30f));

            if (Mouse.IsOver(rect2))
            {
                GUI.DrawTexture(rect2, TexUI.HighlightTex);
            }
            var kind = pawn.kindDef as CustomPawnKindDef;

            string str   = kind.objectClass.GetObjectClassString();
            Rect   rect4 = rect2;

            rect4.xMin += 3f;
            if (rect4.width != labelCacheForWidth)
            {
                labelCacheForWidth = rect4.width;
                labelCache.Clear();
            }
            Text.Font     = GameFont.Small;
            Text.Anchor   = TextAnchor.MiddleLeft;
            Text.WordWrap = false;
            Widgets.Label(rect4, str.Truncate(rect4.width, labelCache));
            Text.WordWrap = true;
            Text.Anchor   = TextAnchor.UpperLeft;
            if (Widgets.ButtonInvisible(rect2))
            {
                CameraJumper.TryJumpAndSelect(pawn);
                if (Current.ProgramState == ProgramState.Playing && Event.current.button == 0)
                {
                    Find.MainTabsRoot.EscapeCurrentTab(playSound: false);
                }
            }
            else
            {
                TipSignal tooltip = pawn.GetTooltip();
                tooltip.text = kind.objectClass.GetObjectClassDesc();
                TooltipHandler.TipRegion(rect2, tooltip);
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Pass an enum by ref to create a RadioButtonList. Must be cast to object before, then cast back to the enum type afterwards.
        /// Example:
        /// DietCategory diet = DietCategory.Omnivorous;
        /// var dietTemp = (object)diet;
        /// ModWindowHelper.MakeRadioButtonList("Diet", ref dietTemp);
        /// diet = (DietCategory)dietTemp;
        /// </summary>
        /// <param name="_listLabel">Group Label</param>
        /// <param name="_enumInstance">enum instance (don't forget to ref)</param>
        static public void MakeRadioButtonList(string _listLabel, ref object _enumInstance)
        {
            // Shape the list label
            Vector2 vectLabelSize = Text.CalcSize(_listLabel);
            Vector2 vectLabelPos  = vectCurPos;

            vectCurPos.y += vectLabelSize.y;
            Rect rectLabel = new Rect(vectLabelPos + rectMain.position, vectLabelSize);

            // Draw the list label
            Widgets.Label(rectLabel, _listLabel);

            //var enumValues = Enum.GetValues(_Enum.GetType());
            var enumValues = Enum.GetValues(_enumInstance.GetType());

            foreach (var e in enumValues)
            {
                // Shape the radiobutton
                Vector2 vectRBLabelSize = Text.CalcSize(e.ToString());
                Vector2 vectRBLabelPos  = vectCurPos;
                vectCurPos.y += vectRBLabelSize.y;
                Rect rectRBLabel  = new Rect(vectRBLabelPos + rectMain.position, vectRBLabelSize);
                Rect rectRBButton = new Rect(rectRBLabel.x + rectRBLabel.width, rectRBLabel.y, vectRBLabelSize.y, vectRBLabelSize.y);
                Rect rectRB       = new Rect(rectRBLabel.x, rectRBLabel.y, rectRBLabel.width + rectRBButton.width, rectRBLabel.height);

                // Draw the radiobutton label
                Widgets.Label(rectRBLabel, e.ToString());

                // Draw the invisible button
                bool flag  = Widgets.ButtonInvisible(rectRB, true);
                bool flag2 = e.Equals(_enumInstance);

                if (flag && !flag2)
                {
                    SoundDefOf.RadioButtonClicked.PlayOneShotOnCamera(null);
                    _enumInstance = (object)e;
                }
                RadioButtonDraw(rectRBButton, flag2);
            }
        }
Ejemplo n.º 21
0
        private void DrawSlotSelection(Rect canvas)
        {
            GUI.DrawTexture(canvas, _darkBackground);

            if (_source.NullOrEmpty())
            {
                return;
            }

            Rect viewRect = new Rect(canvas);

            viewRect.width -= 16f;
            viewRect.height = _source.Count * _rowHeight;

            Widgets.BeginScrollView(canvas, ref _availableScrollPosition, viewRect.AtZero());
            for (int i = 0; i < _source.Count; i++)
            {
                Rect row       = new Rect(0f, i * _rowHeight, canvas.width, _rowHeight);
                Rect labelRect = new Rect(row);
                TooltipHandler.TipRegion(row, _source[i].GetWeightAndBulkTip());

                labelRect.xMin += _margin;
                if (i % 2 == 0)
                {
                    GUI.DrawTexture(row, _darkBackground);
                }

                Text.Anchor = TextAnchor.MiddleLeft;
                Widgets.Label(labelRect, _source[i].LabelCap);
                Text.Anchor = TextAnchor.UpperLeft;

                Widgets.DrawHighlightIfMouseover(row);
                if (Widgets.ButtonInvisible(row))
                {
                    var slot = new LoadoutSlot(_source[i], 1);
                    CurrentLoadout.AddSlot(slot);
                }
            }
            Widgets.EndScrollView();
        }
Ejemplo n.º 22
0
        private bool DrawLocklock(SwapControlsHandler handler, Rect rect)
        {
            Texture2D lockTex;

            if (handler.autoLockOnManualSwap)
            {
                lockTex = TextureResources.autolockOn;
                TooltipHandler.TipRegion(rect, "WeaponSwitchAutolockOn".Translate());
            }
            else
            {
                lockTex = TextureResources.autolockOff;
                TooltipHandler.TipRegion(rect, "WeaponSwitchAutolockOff".Translate());
            }
            MouseoverSounds.DoRegion(rect, SoundDefOf.MouseoverCommand);

            if (Mouse.IsOver(rect))
            {
                LessonAutoActivator.TeachOpportunity(SidearmsDefOf.Concept_SimpleSidearmsAdvanced, OpportunityType.GoodToKnow);
                GUI.color = iconMouseOverColor;
            }
            else
            {
                GUI.color = iconBaseColor;
            }

            GUI.DrawTexture(rect, lockTex);
            GUI.color = Color.white;

            if (Widgets.ButtonInvisible(rect, true))
            {
                handler.autoLockOnManualSwap = !handler.autoLockOnManualSwap;
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SimpleSidearmsAdvanced, KnowledgeAmount.SpecificInteraction);
                return(true);
            }
            else
            {
                return(false);
            }
        }
        //   public static void StartPath_Postfix(Pawn_PathFollower __instance)
        //   {
        //       Pawn pawn = (Pawn)AccessTools.Field(typeof(Pawn_PathFollower), "pawn").GetValue(__instance);
        //       if (pawn.GetCompAnim(out CompBodyAnimator animator))
        //       {
        //           animator.IsMoving = true;
        //       }
        //   }
        //
        //   public static void PatherArrived_Postfix(Pawn_PathFollower __instance)
        //   {
        //       Pawn pawn = (Pawn)AccessTools.Field(typeof(Pawn_PathFollower), "pawn").GetValue(__instance);
        //       if (pawn.GetCompAnim(out CompBodyAnimator animator))
        //       {
        //           animator.IsMoving = false;
        //       }
        //   }

        public static void AddFaceEditButton(Page_ConfigureStartingPawns __instance, Rect rect)
        {
            FieldInfo PawnFieldInfo =
                typeof(Page_ConfigureStartingPawns).GetField("curPawn", BindingFlags.NonPublic | BindingFlags.Instance);

            Pawn pawn = (Pawn)PawnFieldInfo?.GetValue(__instance);

            if (!pawn.GetCompFace(out CompFace compFace))
            {
                return;
            }

            // Shitty Transpiler, doin' it on my own
            Rect rect2 = new Rect(rect.x + 500f, rect.y, 25f, 25f);

            if (rect2.Contains(Event.current.mousePosition))
            {
                GUI.color = Color.cyan;

                // GUI.color = new Color(0.97647f, 0.97647f, 0.97647f);
            }
            else
            {
                GUI.color = new Color(0.623529f, 0.623529f, 0.623529f);
            }

            GUI.DrawTexture(rect2, ContentFinder <Texture2D> .Get("Buttons/ButtonFace", true));
            GUI.color = Color.white;
            string tip = "FacialStuffEditor.EditFace".Translate();

            TooltipHandler.TipRegion(rect2, tip);

            // ReSharper disable once InvertIf
            if (Widgets.ButtonInvisible(rect2, false))
            {
                SoundDefOf.Tick_Low.PlayOneShotOnCamera(null);
                OpenStylingWindow(pawn);
            }
        }
        public static bool ButtonIcon(ref Rect rect, Texture2D icon, string tooltip = null, Texture2D iconAddon   = null,
                                      Direction8Way addonLocation = Direction8Way.NorthEast, Color?mouseOverColor = null,
                                      Color?baseColor             = null, int gapSize = SmallMargin, UIDirection direction = UIDirection.LeftThenDown)
        {
            if (Mouse.IsOver(rect))
            {
                GUI.color = mouseOverColor ?? GenUI.MouseoverColor;
            }
            else
            {
                GUI.color = baseColor ?? Color.white;
            }

            GUI.DrawTexture(rect, icon);
            if (iconAddon != null)
            {
                GUI.DrawTexture(AddonRect(rect, addonLocation), iconAddon);
            }
            if (!tooltip.NullOrEmpty())
            {
                TooltipHandler.TipRegion(rect, tooltip);
            }

            var clicked = Widgets.ButtonInvisible(rect);

            switch (direction)
            {
            case UIDirection.LeftThenDown:
            case UIDirection.LeftThenUp:
                rect.x -= rect.width + gapSize;
                break;

            case UIDirection.RightThenDown:
            case UIDirection.RightThenUp:
                rect.x += rect.width + gapSize;
                break;
            }
            return(clicked);
        }
Ejemplo n.º 25
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);
                GUI.DrawTexture(rect2, MedicalCareUtility.careTextures[i]);
                if (Widgets.ButtonInvisible(rect2, false))
                {
                    medCare = mc;
                    SoundDefOf.TickHigh.PlayOneShotOnCamera(null);
                }
                if (medCare == mc)
                {
                    Widgets.DrawBox(rect2, 3);
                }
                TooltipHandler.TipRegion(rect2, () => mc.GetLabel(), 632165 + i * 17);
                rect2.x += rect2.width;
            }
        }
Ejemplo n.º 26
0
        private static void DrawTabs(Tab tab)
        {
            DubGUI.ResetFont();
            yOffset += 40f;

            Rect row = listing.GetRect(30f);

            if (tab.category == Category.Settings)
            {
                if (Widgets.ButtonInvisible(row))
                {
                    tab.onClick();
                }
            }
            else
            {
                if (Widgets.ButtonImage(row.RightPartPixels(row.height), tab.collapsed ? DubGUI.DropDown : DubGUI.FoldUp))
                {
                    tab.collapsed = !tab.collapsed;
                }
            }
            row.x += 5f;
            Widgets.Label(row, tab.Label);

            TooltipHandler.TipRegion(row, tab.Tip);

            Text.Anchor = TextAnchor.MiddleLeft;
            Text.Font   = GameFont.Tiny;

            if (tab.collapsed)
            {
                return;
            }

            foreach (KeyValuePair <Entry, Type> entry in tab.entries)
            {
                DrawEntry(ref row, entry);
            }
        }
            public override void Draw(float position, float width, LogDrawData data)
            {
                float height = GetHeight(width);
                float width2 = width - 29f;
                Rect  rect   = new Rect(0f, position, width, height);

                if (log == data.highlightEntry)
                {
                    Widgets.DrawRectFast(rect, new Color(1f, 1f, 1f, HighlightAlpha * data.highlightIntensity));
                    data.highlightIntensity = Mathf.Max(0f, data.highlightIntensity - Time.deltaTime / HighlightDuration);
                }
                else if (data.alternatingBackground)
                {
                    Widgets.DrawRectFast(rect, new Color(1f, 1f, 1f, AlternateAlpha));
                }
                data.alternatingBackground = !data.alternatingBackground;
                TaggedString label = log.ToGameStringFromPOV(pawn);

                Widgets.Label(new Rect(29f, position, width2, height), label);
                Texture2D texture2D = log.IconFromPOV(pawn);

                if (texture2D != null)
                {
                    GUI.DrawTexture(new Rect(0f, position + (height - 26f) / 2f, 26f, 26f), texture2D);
                }
                if (Mouse.IsOver(rect))
                {
                    TooltipHandler.TipRegion(rect, () => log.GetTipString(), 613261 + log.LogID * 2063);
                    Widgets.DrawHighlight(rect);
                }
                if (Widgets.ButtonInvisible(rect, log.CanBeClickedFromPOV(pawn)))
                {
                    log.ClickedFromPOV(pawn);
                }
                if (DebugViewSettings.logCombatLogMouseover && Mouse.IsOver(rect))
                {
                    log.ToGameStringFromPOV(pawn, forceLog: true);
                }
            }
Ejemplo n.º 28
0
        private bool DrawIconForUnarmed(Pawn pawn, Rect contentRect, Vector2 iconOffset)
        {
            var iconRect = new Rect(contentRect.x + iconOffset.x, contentRect.y + iconOffset.y, IconSize, IconSize);

            //var iconColor = iconBaseColor;

            TooltipHandler.TipRegion(iconRect, "DrawSidearm_gizmoTooltipUnarmed".Translate());
            MouseoverSounds.DoRegion(iconRect, SoundDefOf.MouseoverCommand);

            Texture2D drawPocket = TextureResources.drawPocket;

            if (Mouse.IsOver(iconRect))
            {
                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 = TextureResources.unarmedIcon;

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

            if (Widgets.ButtonInvisible(iconRect, true))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 29
0
        private void DrawDevToolsMenuWidget(Rect titleRect, float widgetOffset, UpdateFeatureDef forDef)
        {
            var widgetSize = titleRect.height;
            var widgetRect = new Rect(titleRect.width - widgetOffset - widgetSize,
                                      titleRect.y, widgetSize, widgetSize);

            if (Mouse.IsOver(widgetRect))
            {
                Widgets.DrawHighlight(widgetRect);
            }
            var buttonTexture = HugsLibTextures.HLMenuIcon;
            var textureRect   = new Rect(
                widgetRect.center.x - buttonTexture.width / 2f, widgetRect.center.y - buttonTexture.height / 2f,
                buttonTexture.width, buttonTexture.height
                );

            Widgets.DrawTextureFitted(textureRect, buttonTexture, 1f);
            if (Widgets.ButtonInvisible(widgetRect))
            {
                OpenDevToolsDropdownMenu(forDef);
            }
        }
        private void DrawMessage(Rect originalRect, ArchivedMessage message, float topY)
        {
            //Draw message rect
            Rect msgRect = new Rect(originalRect.x, topY, originalRect.width, Text.LineHeight * 2f);

            //Draw message content
            Text.Anchor = TextAnchor.MiddleLeft;
            Widgets.Label(msgRect, message.text);
            Text.Anchor = TextAnchor.UpperLeft;             //Reset to RimWorld default

            //Thing target button and highlight if lookTarget exists
            if (message.lookTarget.IsValid)
            {
                Widgets.DrawHighlightIfMouseover(msgRect);
                TooltipHandler.TipRegion(msgRect, "Notifications_Archiver_TargetedMessage_Tooltip".Translate());

                if (Widgets.ButtonInvisible(msgRect, false))
                {
                    CameraJumper.TryJumpAndSelect(message.lookTarget);
                }
            }
        }