Ejemplo n.º 1
0
        private void DrawDay(Rect rect, int dayNumber)
        {
            Widgets.DrawBox(rect);

            Widgets.Label(rect.ContractedBy(6), dayNumber.ToString());
            ScheduledDay day = TaskManager.ScheduledDays.FirstOrDefault(x => x.DayNumber == dayNumber);

            if (day != null)
            {
                DrawDayInterFace(new Rect(rect.x + 6, rect.y + 30f, rect.width, rect.height * .75f), day);
            }

            if (Mouse.IsOver(rect))
            {
                Widgets.DrawBox(rect, 3);
                if (Input.GetMouseButtonDown(0))
                {
                    if (day == null)
                    {
                        TaskManager.AddDay(dayNumber);
                    }

                    var options = GetFloatMenuOptions(day);
                    if (!options.NullOrEmpty())
                    {
                        Find.WindowStack.Add((Window) new Dialog_ScheduleDayConfig(day, GetFloatMenuOptions(day)));
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void DrawHeader()
        {
            //Draw Settlement Header Highlight
            Widgets.DrawHighlight(new Rect(0, 0, 520, 60));
            Widgets.DrawBox(new Rect(0, 0, 520, 60));

            //Draw town level and shadow backing
            Text.Font   = GameFont.Medium;
            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.DrawShadowAround(new Rect(5, 15, 30, 30));
            Widgets.Label(new Rect(5, 15, 30, 30), settlement.settlementLevel.ToString());

            //Draw town name
            Text.Anchor = TextAnchor.MiddleLeft;
            Widgets.Label(new Rect(40, 0, 520, 30), settlement.name);

            //Draw town title
            Text.Font = GameFont.Tiny;
            Widgets.Label(new Rect(50, 25, 150, 20), settlement.title);             //returnSettlement().title);

            //Draw town location flabor text
            Text.Font = GameFont.Tiny;
            Widgets.Label(new Rect(55, 40, 470, 20), "Located".Translate() + " " + HillinessUtility.GetLabel(Find.WorldGrid.tiles[settlement.mapLocation].hilliness) + " " + "LandOf".Translate() + " " + Find.WorldGrid.tiles[settlement.mapLocation].biome.LabelCap.ToLower());             //returnSettlement().title);

            //Draw header Settings button
            if (Widgets.ButtonImage(new Rect(495, 5, 20, 20), texLoad.iconCustomize))
            {             //if click faction customize button
                Find.WindowStack.Add(new settlementCustomizeWindowFC(settlement));
                //Log.Message("Settlement customize clicked");
            }
        }
Ejemplo n.º 3
0
 public static void TipRegion(Rect rect, TipSignal tip)
 {
     if (Event.current.type != EventType.Repaint)
     {
         return;
     }
     if (tip.textGetter == null && tip.text.NullOrEmpty())
     {
         return;
     }
     if (!Mouse.IsOver(rect))
     {
         return;
     }
     if (DebugViewSettings.drawTooltipEdges)
     {
         Widgets.DrawBox(rect, 1);
     }
     if (!TooltipHandler.activeTips.ContainsKey(tip.uniqueId))
     {
         ActiveTip value = new ActiveTip(tip);
         TooltipHandler.activeTips.Add(tip.uniqueId, value);
         TooltipHandler.activeTips[tip.uniqueId].firstTriggerTime = (double)Time.realtimeSinceStartup;
     }
     TooltipHandler.activeTips[tip.uniqueId].lastTriggerFrame  = TooltipHandler.frame;
     TooltipHandler.activeTips[tip.uniqueId].signal.text       = tip.text;
     TooltipHandler.activeTips[tip.uniqueId].signal.textGetter = tip.textGetter;
 }
Ejemplo n.º 4
0
        // Token: 0x06000039 RID: 57 RVA: 0x00003F04 File Offset: 0x00002104
        private static void DrawTimeAssignmentSelectorFor(Rect rect, TimeAssignmentDef ta)
        {
            rect = rect.ContractedBy(2f);
            GUI.DrawTexture(rect, ta.ColorTexture);
            if (Widgets.ButtonInvisible(rect))
            {
                TimeAssignmentSelector.selectedAssignment = ta;
                SoundDefOf.Tick_High.PlayOneShotOnCamera();
            }

            GUI.color = Color.white;
            if (Mouse.IsOver(rect))
            {
                Widgets.DrawHighlight(rect);
            }

            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.MiddleCenter;
            GUI.color   = Color.white;
            Widgets.Label(rect, ta.LabelCap);
            Text.Anchor = TextAnchor.UpperLeft;
            if (TimeAssignmentSelector.selectedAssignment == ta)
            {
                Widgets.DrawBox(rect, 2);
            }
        }
Ejemplo n.º 5
0
        private static void DoTimeAssignment(Rect rect, TimetableBool table, int hour)
        {
            if (table == null)
            {
                Log.Error("Table must not be null.");
                return;
            }
            rect = rect.ContractedBy(1f);
            bool mouseButton = Input.GetMouseButton(0);
            bool assignment  = table.GetAssignment(hour);

            GUI.DrawTexture(rect, table.GetTexture(assignment));
            if (!mouseButton)
            {
                MouseoverSounds.DoRegion(rect);
            }

            if (!Mouse.IsOver(rect))
            {
                return;
            }

            if (!mouseButton)
            {
                lastAssignmentValue = !assignment;
            }

            Widgets.DrawBox(rect, 2);
            if (mouseButton && assignment != lastAssignmentValue)
            {
                SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera();
                table.SetAssignment(hour, lastAssignmentValue);
            }
        }
        private void DoTimeAssignment(Rect rect, Pawn p, int hour)
        {
            rect = rect.ContractedBy(1f);
            bool mouseButton             = Input.GetMouseButton(0);
            TimeAssignmentDef assignment = p.timetable.GetAssignment(hour);

            GUI.DrawTexture(rect, assignment.ColorTexture);
            if (!mouseButton)
            {
                MouseoverSounds.DoRegion(rect);
            }
            if (!Mouse.IsOver(rect))
            {
                return;
            }
            Widgets.DrawBox(rect, 2);
            if (mouseButton && assignment != TimeAssignmentSelector.selectedAssignment && TimeAssignmentSelector.selectedAssignment != null)
            {
                SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera();
                p.timetable.SetAssignment(hour, TimeAssignmentSelector.selectedAssignment);
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeAssignments, KnowledgeAmount.SmallInteraction);
                if (TimeAssignmentSelector.selectedAssignment == TimeAssignmentDefOf.Meditate)
                {
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.MeditationSchedule, KnowledgeAmount.Total);
                }
            }
        }
Ejemplo n.º 7
0
        // From RimWorld.AreaAllowedGUI, modified
        private static void DoAreaSelector(Rect rect, Pawn p, Area area, Func <Area, string> getLabel)
        {
            rect = rect.ContractedBy(1f);
            GUI.DrawTexture(rect, area == null ? BaseContent.GreyTex : area.ColorTexture);
            Text.Anchor = TextAnchor.MiddleLeft;
            string text  = getLabel(area);
            Rect   rect2 = rect;

            rect2.xMin += 3f;
            rect2.yMin += 2f;
            Widgets.Label(rect2, text);
            if (p.playerSettings.AreaRestriction == area)
            {
                Widgets.DrawBox(rect, 2);
            }
            if (Mouse.IsOver(rect))
            {
                area?.MarkForDraw();
                if (Input.GetMouseButton(0) && p.playerSettings.AreaRestriction != area)
                {
                    p.playerSettings.AreaRestriction = area;
                    SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera();
                }
            }
            Text.Anchor = TextAnchor.UpperLeft;
            TooltipHandler.TipRegion(rect, text);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Draws the default Job tab on GUI.
        /// </summary>
        /// <param name="tabRect">Area the Job tab got to work with.</param>
        public virtual void JobGUITab(Rect tabRect, bool isSelected)
        {
            //Display at a glance information.
            if (isSelected)
            {
                Widgets.DrawBoxSolid(tabRect, highlightColor);
            }
            else
            {
                Widgets.DrawBoxSolid(tabRect, Widgets.WindowBGFillColor);
            }

            Color color = GUI.color;

            if (isSelected)
            {
                GUI.color = highlightLineColor;
            }

            Widgets.DrawBox(tabRect);

            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperCenter;
            Widgets.Label(tabRect, def.LabelCap.WrapInBrackets());

            Text.Anchor = TextAnchor.LowerCenter;
            Widgets.Label(tabRect, $"{level + 1} / {def.maxLevel}");

            Text.Anchor = TextAnchor.UpperLeft;
            GUI.color   = color;
        }
Ejemplo n.º 9
0
        private static void DrawAreaAllowed(WidgetRow row, Pawn pawn)
        {
            if (pawn.playerSettings == null || !pawn.playerSettings.RespectsAllowedArea)
            {
                return;
            }
            row.Gap(6f);
            bool flag = pawn.playerSettings != null && pawn.playerSettings.EffectiveAreaRestriction != null;
            Rect rect = row.FillableBar(fillTex: (!flag) ? BaseContent.GreyTex : pawn.playerSettings.EffectiveAreaRestriction.ColorTexture, width: 93f, height: 16f, fillPct: 1f, label: AreaUtility.AreaAllowedLabel(pawn));

            if (Mouse.IsOver(rect))
            {
                if (flag)
                {
                    pawn.playerSettings.EffectiveAreaRestriction.MarkForDraw();
                }
                Widgets.DrawBox(rect.ContractedBy(-1f));
            }
            if (Widgets.ButtonInvisible(rect))
            {
                AreaUtility.MakeAllowedAreaListFloatMenu(delegate(Area a)
                {
                    pawn.playerSettings.AreaRestriction = a;
                }, addNullAreaOption: true, addManageOption: true, pawn.Map);
            }
        }
        public override void DoWindowContents(Rect inRect)
        {
            //grab before anchor/font
            GameFont   fontBefore   = Text.Font;
            TextAnchor anchorBefore = Text.Anchor;

            //Settlement Tax Collection Header
            Text.Anchor = TextAnchor.MiddleLeft;
            Text.Font   = GameFont.Medium;

            Widgets.Label(new Rect(2, 0, 300, 60), header);

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

            if (settlement.settlementLevel < maxSettlementLevel) //if settlement is not max level
            {
                if (Widgets.ButtonText(new Rect(xoffset + ((335 - 150) / 2), height + 10, 150, 40), "UpgradeSettlement".Translate() + ": " + settlementUpgradeCost))
                {
                    Messages.Message(UpgradeSettlement());
                }
            }
            else //if settlement is max level
            {
                desc = "CannotBeUpgradedPastMax".Translate() + ": " + maxSettlementLevel;
            }

            Widgets.Label(new Rect(xoffset + 2, yoffset - yspacing + 2, length - 4, height - 4 + yspacing * 2), desc);
            Widgets.DrawBox(new Rect(xoffset, yoffset - yspacing, length, height - yspacing * 2));

            //reset anchor/font
            Text.Font   = fontBefore;
            Text.Anchor = anchorBefore;
        }
Ejemplo n.º 11
0
        // RimWorld.AreaAllowedGUI
        private static void DoAreaSelector(Rect rect, ref Area areaAllowed, Area area)
        {
            rect = rect.ContractedBy(1f);
            GUI.DrawTexture(rect, area == null ? BaseContent.GreyTex : area.ColorTexture);
            Text.Anchor = TextAnchor.MiddleLeft;
            var text  = AreaUtility.AreaAllowedLabel_Area(area);
            var rect2 = rect;

            rect2.xMin += 3f;
            rect2.yMin += 2f;
            Widgets.Label(rect2, text);
            if (areaAllowed == area)
            {
                Widgets.DrawBox(rect, 2);
            }
            if (Mouse.IsOver(rect))
            {
                if (area != null)
                {
                    area.MarkForDraw();
                }
                if (Input.GetMouseButton(0) &&
                    areaAllowed != area)
                {
                    areaAllowed = area;
                    SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera();
                }
            }

            TooltipHandler.TipRegion(rect, text);
        }
Ejemplo n.º 12
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, typeof(MedicalCareUtility).GetStaticFieldViaReflection <Texture2D[]>("careTextures")[i]);
                if (Widgets.ButtonInvisible(rect2, false))
                {
                    medCare = mc;
                    SoundDefOf.TickHigh.PlayOneShotOnCamera();
                }
                if (medCare == mc)
                {
                    Widgets.DrawBox(rect2, 3);
                }
                TooltipHandler.TipRegion(rect2, () => mc.GetLabel(), 632165 + i * 17);
                rect2.x += rect2.width;
            }

            if (!HorribleHackWithinDefaultDialog)
            {
                rect2.x    += 15;
                rect2.width = 60;
                if (Widgets.ButtonText(rect2, "Defaults"))
                {
                    Find.WindowStack.Add(new Dialog_MedicalDefaults());
                }
            }
        }
Ejemplo n.º 13
0
 private static void DrawAreaAllowed(WidgetRow row, Pawn pawn)
 {
     if (pawn.playerSettings != null && pawn.playerSettings.RespectsAllowedArea)
     {
         row.Gap(6f);
         bool      flag    = pawn.playerSettings != null && pawn.playerSettings.AreaRestriction != null;
         Texture2D fillTex = (!flag) ? BaseContent.GreyTex : pawn.playerSettings.AreaRestriction.ColorTexture;
         Rect      rect    = row.FillableBar(93f, 16f, 1f, AreaUtility.AreaAllowedLabel(pawn), fillTex, null);
         if (Mouse.IsOver(rect))
         {
             if (flag)
             {
                 pawn.playerSettings.AreaRestriction.MarkForDraw();
             }
             Rect rect2 = rect.ContractedBy(-1f);
             Widgets.DrawBox(rect2, 1);
         }
         if (Widgets.ButtonInvisible(rect, false))
         {
             AllowedAreaMode mode = (AllowedAreaMode)(pawn.RaceProps.Humanlike ? 1 : 2);
             AreaUtility.MakeAllowedAreaListFloatMenu(delegate(Area a)
             {
                 pawn.playerSettings.AreaRestriction = a;
             }, mode, true, true, pawn.Map);
         }
     }
 }
Ejemplo n.º 14
0
            public override GizmoResult GizmoOnGUI(Vector2 topLeft)
            {
                var overRect = new Rect(topLeft.x, topLeft.y, Width, Height);

                Widgets.DrawBox(overRect);
                GUI.DrawTexture(overRect, BGTex);

                var inRect = overRect.ContractedBy(6);

                //Item label
                var textRect = inRect;

                textRect.height = overRect.height / 2;
                Text.Font       = GameFont.Tiny;
                Widgets.Label(textRect, compAmmo.parent.def.LabelCap);

                //Bar
                var barRect = inRect;

                barRect.yMin = overRect.y + overRect.height / 2f;
                var ePct = (float)compAmmo.count / compAmmo.reloaderProp.roundPerMag;

                Widgets.FillableBar(barRect, ePct, FullTex, EmptyTex, false);
                Text.Font   = GameFont.Small;
                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(barRect, compAmmo.count + " / " + compAmmo.reloaderProp.roundPerMag);
                Text.Anchor = TextAnchor.UpperLeft;

                return(new GizmoResult(GizmoState.Clear));
            }
Ejemplo n.º 15
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++;
            }
        }
Ejemplo n.º 16
0
        private static void DoTimeAssignment(Rect rect, int day, Building_TeachingSpot spot)
        {
            rect = rect.ContractedBy(1f);
            Texture2D texture = TimeAssignmentDefOf.Anything.ColorTexture;

            if (spot.seasonSchedule[day] == 1)
            {
                texture = ModTextures.RedColor;
            }
            else if (spot.seasonSchedule[day] == 2)
            {
                texture = ModTextures.BlueColor;
            }
            else if (spot.seasonSchedule[day] == 3)
            {
                texture = ModTextures.YellowColor;
            }

            GUI.DrawTexture(rect, texture);
            if (Mouse.IsOver(rect))
            {
                Widgets.DrawBox(rect, 2);
                //if (Input.GetMouseButton(0))
                if (Widgets.ButtonInvisible(rect))
                {
                    spot.seasonSchedule[day] = (spot.seasonSchedule[day] % 4) + 1;
                    SoundDefOf.DesignateDragStandardChanged.PlayOneShotOnCamera();
                    //p.timetable.SetAssignment(hour, this.selectedAssignment);
                }
            }
        }
Ejemplo n.º 17
0
 static void Prefix(Rect rect)
 {
     if (Input.GetKey(KeyCode.End))
     {
         Widgets.DrawBox(rect);
     }
 }
Ejemplo n.º 18
0
        public void Draw()
        {
            float cursor = 0;

            DrawHeader();
            GUI.color = Page_ConfigureStartingPawnsCarefully.PortraitTabInactiveColor;
            Widgets.DrawBox(RectBorder, 1);
            GUI.color = Color.white;
            GUI.BeginGroup(RectContent);
            scrollView.Begin(RectScroll);

            cursor = DrawCustomBodyParts(cursor);

            scrollView.End(cursor);
            GUI.EndGroup();

            DrawRandomOption();

            CustomPawn customPawn = PrepareCarefully.Instance.State.CurrentPawn;

            if (partRemovalList.Count > 0)
            {
                foreach (var x in partRemovalList)
                {
                    customPawn.RemoveCustomBodyParts(x);
                }
                partRemovalList.Clear();
            }
        }
Ejemplo n.º 19
0
        public static Rect AddPortraitWidget(float left, float top, DresserDTO dresserDto)
        {
            // Portrait
            Rect rect = new Rect(left, top, PortraitSize.x, PortraitSize.y);

            // Draw the pawn's portrait
            GUI.BeginGroup(rect);
            Vector2       size     = new Vector2(128f, 180f);
            Rect          position = new Rect(rect.width * 0.5f - size.x * 0.5f, 10f + rect.height * 0.5f - size.y * 0.5f, size.x, size.y);
            RenderTexture image    = PortraitsCache.Get(dresserDto.Pawn, size, new Vector3(0f, 0f, 0f), 1f);

            GUI.DrawTexture(position, image);
            GUI.EndGroup();

            GUI.color = Color.white;
            Widgets.DrawBox(rect, 1);

            for (int x = 0; x < ColorPreset.width; ++x)
            {
                for (int y = 0; y < ColorPreset.height; ++y)
                {
                    ColorPreset.SetPixel(x, y, Color.white);
                }
            }

            return(rect);
        }
Ejemplo n.º 20
0
        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;
        }
Ejemplo n.º 21
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;
            }
        }
        public override void DrawProgressBar(Rect rect, bool active)
        {
            // bar always goes a little beyond the actual target
            int max = Math.Max((int)(TargetCount * 1.2f), CurrentCount);

            // draw a box for the bar
            GUI.color = Color.gray;
            Widgets.DrawBox(rect.ContractedBy(1f));
            GUI.color = Color.white;

            // get the bar rect
            Rect  barRect    = rect.ContractedBy(2f);
            float unit       = barRect.height / max;
            float markHeight = barRect.yMin + (max - TargetCount) * unit;

            barRect.yMin += (max - CurrentCount) * unit;

            // draw the bar
            // if the job is active and pending, make the bar blueish green - otherwise white.
            Texture2D barTex = active
                                   ? Resources.BarBackgroundActiveTexture
                                   : Resources.BarBackgroundInactiveTexture;

            GUI.DrawTexture(barRect, barTex);

            // draw a mark at the treshold
            Widgets.DrawLineHorizontal(rect.xMin, markHeight, rect.width);

            TooltipHandler.TipRegion(rect, StatusTooltip);
        }
Ejemplo n.º 23
0
 public DebugTool(string label, Action clickAction, IntVec3 firstRectCorner)
 {
     this.label       = label;
     this.clickAction = clickAction;
     onGUIAction      = delegate
     {
         IntVec3 intVec = UI.MouseCell();
         Vector3 v      = firstRectCorner.ToVector3Shifted();
         Vector3 v2     = intVec.ToVector3Shifted();
         if (v.x < v2.x)
         {
             v.x  -= 0.5f;
             v2.x += 0.5f;
         }
         else
         {
             v.x  += 0.5f;
             v2.x -= 0.5f;
         }
         if (v.z < v2.z)
         {
             v.z  -= 0.5f;
             v2.z += 0.5f;
         }
         else
         {
             v.z  += 0.5f;
             v2.z -= 0.5f;
         }
         Vector2 vector  = v.MapToUIPosition();
         Vector2 vector2 = v2.MapToUIPosition();
         Widgets.DrawBox(new Rect(vector.x, vector.y, vector2.x - vector.x, vector2.y - vector.y), 3);
     };
 }
Ejemplo n.º 24
0
            internal void <> m__0()
            {
                IntVec3 intVec = UI.MouseCell();
                Vector3 v      = this.firstRectCorner.ToVector3Shifted();
                Vector3 v2     = intVec.ToVector3Shifted();

                if (v.x < v2.x)
                {
                    v.x  -= 0.5f;
                    v2.x += 0.5f;
                }
                else
                {
                    v.x  += 0.5f;
                    v2.x -= 0.5f;
                }
                if (v.z < v2.z)
                {
                    v.z  -= 0.5f;
                    v2.z += 0.5f;
                }
                else
                {
                    v.z  += 0.5f;
                    v2.z -= 0.5f;
                }
                Vector2 vector  = v.MapToUIPosition();
                Vector2 vector2 = v2.MapToUIPosition();

                Widgets.DrawBox(new Rect(vector.x, vector.y, vector2.x - vector.x, vector2.y - vector.y), 3);
            }
Ejemplo n.º 25
0
 public void DragBoxOnGUI()
 {
     if (this.IsValidAndActive)
     {
         Widgets.DrawBox(this.ScreenRect, 2);
     }
 }
Ejemplo n.º 26
0
        // RimWorld.AreaAllowedGUI
        private static void DoZoneSelector(Rect rect, ref Zone_Stockpile zoneAllowed, Zone_Stockpile zone,
                                           Texture2D tex)
        {
            rect = rect.ContractedBy(1f);
            GUI.DrawTexture(rect, tex);
            Text.Anchor = TextAnchor.MiddleLeft;
            string label     = zone?.label ?? "Any stockpile";
            Rect   innerRect = rect;

            innerRect.xMin += 3f;
            innerRect.yMin += 2f;
            Widgets.Label(innerRect, label);
            if (zoneAllowed == zone)
            {
                Widgets.DrawBox(rect, 2);
            }
            if (Mouse.IsOver(rect))
            {
                if (zone != null)
                {
                    if (zone.AllSlotCellsList() != null && zone.AllSlotCellsList().Count > 0)
                    {
                        CameraJumper.TryJump(zone.Cells.First(), zone.Map);
                    }
                }
                if (Input.GetMouseButton(0) &&
                    zoneAllowed != zone)
                {
                    zoneAllowed = zone;
                    SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera();
                }
            }
            TooltipHandler.TipRegion(rect, label);
            Text.Anchor = TextAnchor.UpperLeft;
        }
Ejemplo n.º 27
0
        public bool SelectableDef(string name, bool selected, Action deleteCallback)
        {
            Text.Font = GameFont.Tiny;
            float width = this.listingRect.width - 21f;

            Text.Anchor = TextAnchor.MiddleLeft;
            Rect rect = new Rect(this.curX, this.curY, width, 21f);

            if (selected)
            {
                Widgets.DrawHighlight(rect);
            }
            if (Mouse.IsOver(rect))
            {
                Widgets.DrawBox(rect, 1);
            }
            Text.WordWrap = false;
            Widgets.Label(rect, name);
            Text.WordWrap = true;
            if (deleteCallback != null)
            {
                Rect butRect = new Rect(rect.xMax, rect.y, 21f, 21f);
                if (Widgets.ButtonImage(butRect, TexButton.DeleteX, Color.white, GenUI.SubtleMouseoverColor))
                {
                    deleteCallback();
                }
            }
            Text.Anchor = TextAnchor.UpperLeft;
            this.curY  += 21f;
            return(Widgets.ButtonInvisible(rect, false));
        }
Ejemplo n.º 28
0
        public override void DoWindowContents(Rect inRect)
        {
            Rect warRect            = new Rect(inRect.x, inRect.y, 400, inRect.height);
            Rect scrollVertRectFact = new Rect(0, 0, warRect.x, wars.Count * 85);
            int  y = 10;

            Widgets.BeginScrollView(warRect, ref warsSlider, scrollVertRectFact, false);
            for (int i = 0; i < wars.Count; i++)
            {
                War war = wars[i];

                DrawWarRect(warRect, ref y, war);
            }
            Widgets.EndScrollView();

            GUI.color = GUIUtils.MenuSectionBGBorderColor;
            Widgets.DrawBox(warRect);
            Widgets.DrawLineHorizontal(0, 0, inRect.width);
            GUI.color = Color.white;

            if (currentWar != null)
            {
                Rect mainInfoWarRect = new Rect(inRect.x + 410, inRect.y, inRect.width - 420, inRect.height);

                DrawWarInfo(mainInfoWarRect);
            }
        }
Ejemplo n.º 29
0
        public static void DrawQuestCard(Quest quest, List <Quest> quests, Rect rect)
        {
            bgCardColor.a = 150;
            Widgets.DrawBoxSolid(rect, bgCardColor);

            GUI.color = GUIUtils.CommBorderColor;
            Widgets.DrawBox(rect);
            GUI.color = Color.white;

            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.Label(new Rect(rect.x + 8, rect.y + 8, rect.width - 88, 25), quest.CardLabel);

            Text.Anchor = TextAnchor.UpperLeft;

            GUIUtils.DrawLineHorizontal(rect.x + 8, rect.y + 34, rect.width - 88, Color.gray);
            float y = rect.y + 36;

            Widgets.Label(new Rect(rect.x + 8, y, rect.width - 88, 150), quest.Description);

            Text.Anchor = TextAnchor.MiddleCenter;
            if (GUIUtils.DrawCustomButton(new Rect(rect.x + (rect.width - 200) / 2, rect.y + 175, 200, 25), "DarkNetButtons_TakeQuest".Translate(), Color.white))
            {
                quest.TakeQuestByQuester(null);

                quests.Remove(quest);
            }
            Text.Anchor = TextAnchor.UpperLeft;

            if (Mouse.IsOver(rect))
            {
                TooltipHandler.TipRegion(rect, quest.GetRewardsString());
            }
        }
Ejemplo n.º 30
0
        public override void DoWindowContents(Rect inRect)
        {
            if (SequenceWeights == null)
            {
                Core.Error("Null sequence weights, closing dialog.");
                Close();
                return;
            }

            buffer ??= new string[SequenceWeights.Count];
            weights ??= new float[SequenceWeights.Count];

            Rect rect = inRect;

            Widgets.BeginScrollView(rect, ref scroll, new Rect(rect.x, rect.y, rect.width - 25, height));
            height = 0;

            rect.width -= 25;
            rect.height = 70;

            Text.Font = GameFont.Medium;

            int i = 0;

            foreach (var pair in SequenceWeights)
            {
                string label  = pair.Key.label;
                float  weight = pair.Value;
                weights[i] = weight;

                Widgets.DrawBox(rect, 1);
                Rect inner = rect.ContractedBy(3);
                rect.y   += 80;
                height   += 80;
                GUI.color = weight <= 0f ? Color.grey : Color.green;
                Widgets.Label(inner, label);
                GUI.color    = Color.white;
                inner.y     += 30;
                inner.height = 28;

                string buff = buffer[i];
                buff ??= weight.ToString(CultureInfo.InvariantCulture);
                Widgets.TextFieldNumericLabeled(inner, "DSC.WeightReadout".Translate(), ref weight, ref buff);
                if (weight < 0 && !float.IsNaN(weight) && !float.IsInfinity(weight))
                {
                    weight = 0;
                    buff   = "0";
                }
                weights[i]  = weight;
                buffer[i++] = buff;
            }

            i = 0;
            foreach (var key in SequenceWeights.Keys.ToArray())
            {
                SequenceWeights[key] = weights[i++];
            }

            Widgets.EndScrollView();
        }