Ejemplo n.º 1
0
        public static bool DrawTableHeader(Rect backgroundRect, Rect iconRect, Texture2D icon, bool vertical = false)
        {
            if (vertical)
            {
                backgroundRect.y += backgroundRect.width;
                GUIUtility.RotateAroundPivot(-90f, backgroundRect.position);
            }

            GUI.color = new Color(0.62f, 0.65f, 0.66f);
            Widgets.DrawHighlight(backgroundRect);
            GUI.color = Color.white;

            if (Mouse.IsOver(backgroundRect))
            {
                GUI.color = Color.grey;
                Widgets.DrawLightHighlight(backgroundRect);
                GUI.color = Color.white;
            }

            GUI.DrawTexture(iconRect, icon);
            bool pressed = Widgets.ButtonInvisible(backgroundRect);

            if (vertical)
            {
                GUI.matrix = Matrix4x4.identity;
            }

            return(pressed);
        }
Ejemplo n.º 2
0
        private void DrawAffectedViewers(Rect inRect)
        {
            if (_affectedViewers == null)
            {
                return;
            }

            var  listing  = new Listing_Standard();
            Rect viewRect = new Rect(0f, 0f, inRect.width - 16f, LineHeight * _affectedViewersCount).Rounded();

            Widgets.BeginScrollView(inRect, ref _affectedScrollPos, viewRect);
            listing.Begin(viewRect);

            for (var i = 0; i < _affectedViewersCount; i++)
            {
                Rect lineRect = listing.GetRect(LineHeight);

                if (!lineRect.IsVisible(viewRect, _affectedScrollPos))
                {
                    continue;
                }

                if (i % 2 == 0)
                {
                    Widgets.DrawLightHighlight(lineRect);
                }


                Viewer viewer     = _affectedViewers ![i];
        private void DrawMainRect(Rect inRect, List <Slot> slots)
        {
            Rect mainRect = new Rect(inRect.x, inRect.y + 37f + (_slotHeight * 3), inRect.width, inRect.height - 37f);
            //Creats slots for all the items; combines, sorts into catergorys and checks for searches all in one line
            List <Slot> categorizedSlots = GetSearchForList(slots);

            //Sort based on market value
            categorizedSlots.Sort();

            //This is for the scrolling
            Rect viewRect = new Rect(0, 0, mainRect.width - 16f, categorizedSlots.Count * _slotHeight + 6f + (_slotHeight * 3));

            Widgets.BeginScrollView(mainRect, ref _scrollPosition, viewRect);
            {
                for (int i = 0; i < categorizedSlots.Count; i++)
                {
                    Rect slotRect = new Rect(0, i * _slotHeight, viewRect.width, _slotHeight);

                    //For every second slot hightlight it to make it a bit easier to see
                    if (i % 2 == 1)
                    {
                        Widgets.DrawLightHighlight(slotRect);
                    }

                    Widgets.DrawHighlightIfMouseover(slotRect);

                    //Draw the slot
                    DrawThingSlot(categorizedSlots[i], slotRect);
                }
            }
            Widgets.EndScrollView();
        }
Ejemplo n.º 4
0
        private void DrawVehicleSelect(Rect rect)
        {
            Text.Anchor = TextAnchor.MiddleLeft;

            Rect viewRect = new Rect(0f, rect.yMin, rect.width - ButtonPadding * 2, rect.yMax);

            Widgets.BeginScrollView(rect, ref scrollPosition, viewRect, true);
            float num  = scrollPosition.y - 30f;
            float num2 = scrollPosition.y + rect.height;
            float num3 = 30f;

            for (int i = 0; i < availableVehicles.Count; i++)
            {
                VehiclePawn vehicle = availableVehicles[i];

                Rect iconRect = new Rect(5f, num3 + 5f, 30f, 30f);
                Rect rowRect  = new Rect(iconRect.x, iconRect.y, rect.width, 30f);

                if (i % 2 == 1)
                {
                    Widgets.DrawLightHighlight(rowRect);
                }
                rowRect.x = iconRect.width + 10f;

                if (vehicle.VehicleDef.properties.generateThingIcon)
                {
                    Rect    texCoords      = new Rect(0, 0, 1, 1);
                    Vector2 texProportions = vehicle.VehicleDef.graphicData.drawSize;
                    float   x = texProportions.x;
                    texProportions.x = texProportions.y;
                    texProportions.y = x;
                    Widgets.DrawTextureFitted(iconRect, VehicleTex.VehicleTexture(vehicle.VehicleDef, Rot8.East), GenUI.IconDrawScale(vehicle.VehicleDef), texProportions,
                                              texCoords, 0, vehicle.VehicleGraphic.MatAt(Rot8.East, vehicle.pattern));
                }
                else
                {
                    Widgets.ButtonImageFitted(iconRect, VehicleTex.CachedTextureIcons[vehicle.VehicleDef]);
                }

                Widgets.Label(rowRect, vehicle.LabelShortCap);

                bool flag = storedVehicles.Contains(vehicle);

                Vector2 checkposition = new Vector2(rect.width - iconRect.width * 1.5f, rowRect.y + 5f);
                Widgets.Checkbox(checkposition, ref flag);
                if (flag && !storedVehicles.Contains(vehicle))
                {
                    storedVehicles.Add(vehicle);
                }
                else if (!flag && storedVehicles.Contains(vehicle))
                {
                    storedVehicles.Remove(vehicle);
                }

                num3 += rowRect.height;
            }

            Widgets.EndScrollView();
            Text.Anchor = TextAnchor.UpperLeft;
        }
Ejemplo n.º 5
0
        private void DoGeneralRect(Rect rect)
        {
            string generalLabel = I18n.GeneralSettingsLabel;

            Widgets.Label(rect, generalLabel.Bolded());
            Widgets.DrawLightHighlight(rect);
            if (Widgets.ButtonInvisible(rect))
            {
                SoundDefOf.Click.PlayOneShotOnCamera();
                if (selected == GeneralSettingsContent)
                {
                    selected = Drawer.Empty;
                }
                else
                {
                    selected = GeneralSettingsContent;
                }
            }

            if (selected == GeneralSettingsContent)
            {
                Widgets.DrawHighlightSelected(rect);
            }
            else if (Mouse.IsOver(rect))
            {
                Widgets.DrawHighlight(rect);
            }
        }
        public static void DoRoomInfo(Room room, ref float curY, Rect windowRect)
        {
            Rect rect = new Rect(12f, curY, windowRect.width - 24f, 100f);

            GUI.color = Color.white;
            Text.Font = GameFont.Medium;
            Widgets.Label(new Rect(rect.x + 10f, curY, rect.width - 10f, rect.height), GetRoomRoleLabel(room));
            curY         += 30f;
            Text.Font     = GameFont.Small;
            Text.WordWrap = false;
            int  num  = 0;
            bool flag = false;

            for (int i = 0; i < DefDatabase <RoomStatDef> .AllDefsListForReading.Count; i++)
            {
                RoomStatDef roomStatDef = DefDatabase <RoomStatDef> .AllDefsListForReading[i];
                if (!roomStatDef.isHidden || DebugViewSettings.showAllRoomStats)
                {
                    float stat = room.GetStat(roomStatDef);
                    RoomStatScoreStage scoreStage = roomStatDef.GetScoreStage(stat);
                    GUI.color = Color.white;
                    Rect rect2 = new Rect(rect.x, curY, rect.width, 23f);
                    if (num % 2 == 1)
                    {
                        Widgets.DrawLightHighlight(rect2);
                    }
                    Rect rect3 = new Rect(rect.x, curY, 10f, 23f);
                    if (room.Role.IsStatRelated(roomStatDef))
                    {
                        flag = true;
                        Widgets.Label(rect3, "*");
                        GUI.color = RelatedStatColor;
                    }
                    else
                    {
                        GUI.color = UnrelatedStatColor;
                    }
                    Rect rect4 = new Rect(rect3.xMax, curY, 100f, 23f);
                    Widgets.Label(rect4, roomStatDef.LabelCap);
                    Rect   rect5 = new Rect(rect4.xMax + 35f, curY, 50f, 23f);
                    string label = roomStatDef.ScoreToString(stat);
                    Widgets.Label(rect5, label);
                    Widgets.Label(new Rect(rect5.xMax + 35f, curY, 160f, 23f), (scoreStage == null) ? "" : scoreStage.label.CapitalizeFirst());
                    curY += 25f;
                    num++;
                }
            }
            if (flag)
            {
                GUI.color = Color.grey;
                Text.Font = GameFont.Tiny;
                Widgets.Label(new Rect(rect.x, curY, rect.width, 23f), "* " + "StatRelatesToCurrentRoom".Translate());
                GUI.color = Color.white;
                Text.Font = GameFont.Small;
            }
            Text.WordWrap = true;
        }
Ejemplo n.º 7
0
        private void DrawMutatorMenu(Rect canvas)
        {
            var addRect      = new Rect(0f, 0f, _addMutatorTextSize.x + 16f, Text.LineHeight);
            var applyRect    = new Rect(canvas.width - (_applyTextSize.x + 16f), 0f, _applyTextSize.x + 16f, Text.LineHeight);
            var mutatorsRect = new Rect(0f, addRect.height, canvas.width, canvas.height - addRect.height);
            var viewPort     = new Rect(0f, 0f, mutatorsRect.width - 16f, _mutators.Count * Text.LineHeight);

            if (Widgets.ButtonText(addRect, _addMutatorText))
            {
                Find.WindowStack.Add(new FloatMenu(_mutateAdders));
            }

            if (Widgets.ButtonText(applyRect, _applyText))
            {
                ExecuteMutators();
            }

            _mutatorScrollPos = GUI.BeginScrollView(mutatorsRect, _mutatorScrollPos, viewPort);
            IMutatorBase <TU> toRemove = null;

            for (var i = 0; i < _mutators.Count; i++)
            {
                IMutatorBase <TU> mutator = _mutators[i];
                var lineRect = new Rect(0f, Text.LineHeight * i, mutatorsRect.width, Text.LineHeight);

                if (!lineRect.IsVisible(mutatorsRect, _mutatorScrollPos))
                {
                    continue;
                }

                if (i % 2 == 0)
                {
                    Widgets.DrawLightHighlight(lineRect);
                }

                Rect mutatorRect = lineRect.Trim(Direction8Way.East, Text.LineHeight - 2f);
                mutator.Draw(mutatorRect);

                if (UiHelper.FieldButton(lineRect, Widgets.CheckboxOffTex))
                {
                    toRemove = mutator;
                }
            }

            GUI.EndScrollView();

            if (toRemove == null)
            {
                return;
            }

            _mutators.Remove(toRemove);
            UpdateView(true);
        }
Ejemplo n.º 8
0
        /// <inheritdoc cref="TableWorkerBase.DrawTableContents"/>
        protected override void DrawTableContents(Rect region)
        {
            float expectedLines = Data.Where(i => !i.IsHidden).Sum(i => i.SettingsVisible ? ExpandedLineSpan + 1f : 1f);
            var   viewPort      = new Rect(0f, 0f, region.width - 16f, RowLineHeight * expectedLines);

            var index     = 0;
            var expanded  = 0;
            var alternate = false;

            GUI.BeginGroup(region);
            _scrollPos = GUI.BeginScrollView(region, _scrollPos, viewPort);

            foreach (TableSettingsItem <ThingItem> item in Data.Where(i => !i.IsHidden))
            {
                var lineRect = new Rect(
                    0f,
                    index * RowLineHeight + RowLineHeight * ExpandedLineSpan * expanded,
                    region.width - 16f,
                    RowLineHeight * (item.SettingsVisible ? ExpandedLineSpan + 1f : 1f)
                    );

                if (!lineRect.IsVisible(region, _scrollPos))
                {
                    index++;
                    alternate = !alternate;
                    expanded += item.SettingsVisible ? 1 : 0;

                    continue;
                }

                GUI.BeginGroup(lineRect);
                Rect rect = lineRect.AtZero();

                if (alternate)
                {
                    Widgets.DrawLightHighlight(rect);
                }

                DrawItem(rect, item);
                GUI.EndGroup();

                alternate = !alternate;
                index++;

                if (item.SettingsVisible)
                {
                    expanded++;
                }
            }

            GUI.EndScrollView();
            GUI.EndGroup();
        }
Ejemplo n.º 9
0
        public void DoMainList(Rect canvas, float itemHeight)
        {
            int   profileCount = ProfileManager.profiles.Count();
            float viewHeight   = (float)profileCount * itemHeight;

            Rect topLabel = new Rect(canvas.x, canvas.y, canvas.width, itemHeight);

            Widgets.Label(topLabel, "Profiles:");

            Rect addNameRect = new Rect(topLabel.x, topLabel.yMax, canvas.width, Text.LineHeight);

            currentAddText = Widgets.TextField(addNameRect, currentAddText);

            Rect outRect  = new Rect(addNameRect.x, addNameRect.yMax + 5f, addNameRect.width, canvas.height);
            Rect viewRect = new Rect(addNameRect.x, addNameRect.yMax + 5f, addNameRect.width - 16f, viewHeight);

            float curHeight = 0f;

            Widgets.BeginScrollView(outRect, ref fileScrollPosition, viewRect, true);
            using (var enumerator = ProfileManager.profiles.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Profile current = enumerator.Current;
                    Rect    rowRect = new Rect(outRect.x, outRect.y + curHeight, canvas.width, itemHeight);
                    if (selectedProfile == current)
                    {
                        Widgets.DrawHighlightSelected(rowRect);
                    }
                    else if (Mouse.IsOver(rowRect))
                    {
                        Widgets.DrawHighlight(rowRect);
                    }
                    else
                    {
                        Widgets.DrawLightHighlight(rowRect);
                    }
                    GUI.BeginGroup(rowRect);
                    Rect labelRect = new Rect(0f, 0f, canvas.width, itemHeight);
                    Widgets.Label(labelRect, current.ToString());
                    GUI.EndGroup();
                    if (Mouse.IsOver(rowRect) && Event.current.type == EventType.MouseDown && Event.current.button == 0)
                    {
                        SelectProfile(current);
                    }
                    curHeight += itemHeight;
                }
            }
            Widgets.EndScrollView();
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Draws the header row, along with its white separation line.
        /// </summary>
        /// <param name="givenArea"></param>
        private void DrawHeaderRow(Rect givenArea)
        {
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.MiddleLeft;
            Widgets.DrawLightHighlight(givenArea);
            GUI.BeginGroup(givenArea);
            DrawNewsID_Header();
            DrawNewsType_Header();
            // reserved 80px for future use
            DrawNewsImportance_Header();
            DrawNewsDetails_Header();
            GUI.EndGroup();

            GUI.color = Color.gray;
            Widgets.DrawLineHorizontal(0, EntryHeight + givenArea.yMin, EntryWidth);
            GUI.color = Color.white;
        }
Ejemplo n.º 11
0
        private static void DrawPawnWorkTab(Rect canvas)
        {
            GUI.BeginGroup(canvas);

            var listing = new Listing_Standard();
            var content = new Rect(0f, 0f, canvas.width, canvas.height);
            var view    = new Rect(0f, 0f, canvas.width - 16f, _workTypeDefs.Length * Text.LineHeight);

            Widgets.BeginScrollView(content, ref _workScrollPos, view);
            listing.Begin(view);

            for (var index = 0; index < _workTypeDefs.Length; index++)
            {
                WorkTypeDef workType    = _workTypeDefs[index];
                WorkSetting workSetting = WorkSettings.FirstOrDefault(w => w.WorkTypeDef.EqualsIgnoreCase(workType.defName));

                if (workSetting == null)
                {
                    workSetting = new WorkSetting {
                        Enabled = true, WorkTypeDef = workType.defName
                    };

                    WorkSettings.Add(workSetting);
                }

                Rect line = listing.GetRect(Text.LineHeight);

                if (!line.IsVisible(content, _workScrollPos))
                {
                    continue;
                }

                if (index % 2 == 0)
                {
                    Widgets.DrawLightHighlight(line);
                }

                Widgets.CheckboxLabeled(line, workSetting.WorkTypeDef, ref workSetting.Enabled);

                Widgets.DrawHighlightIfMouseover(line);
            }

            GUI.EndGroup();
            Widgets.EndScrollView();
            listing.End();
        }
Ejemplo n.º 12
0
        private void DrawHealthReport(Rect region, [NotNull] HealthReport report, bool alternate = false)
        {
            var iconRect    = new Rect(0f, 0f, 16f, region.height);
            var closeRect   = new Rect(region.x + region.width - 16f, 0f, 16f, region.height);
            var messageRect = new Rect(iconRect.x + iconRect.width + 2f, 0f, region.width - iconRect.width - closeRect.width - 4f, region.height);

            if (alternate)
            {
                Widgets.DrawLightHighlight(region);
            }

            Widgets.DrawLightHighlight(iconRect);

            Texture2D texture     = GetTextureFor(report.Type);
            Color     color       = GetColorFor(report.Type);
            string    iconTooltip = GetTooltipFor(report.Type);

            if (texture != null)
            {
                UiHelper.Icon(iconRect, texture, color);
                iconRect.TipRegion(iconTooltip);
            }

            UiHelper.Label(messageRect, report.Message, color, TextAnchor.MiddleLeft, GameFont.Small);

            if (!Mouse.IsOver(messageRect))
            {
                report.OccurredAtString = GetTextString(DateTime.Now - report.OccurredAt);
            }

            messageRect.TipRegion("TKUtils.MainTabTooltips.Report".LocalizeKeyed(report.Reporter, report.OccurredAtString));

            if (!report.Stacktrace.NullOrEmpty() && messageRect.LeftClicked())
            {
                GUIUtility.systemCopyBuffer = report.Stacktrace;
            }

            UiHelper.Icon(closeRect, Widgets.CheckboxOffTex, Color.red);
            closeRect.TipRegion(_closeTooltip);

            if (closeRect.LeftClicked())
            {
                Data.RemoveHealthReport(report);
            }
        }
Ejemplo n.º 13
0
        private void DrawRow(Rect givenArea, int index, TaleNews news)
        {
            // Determine if highlight is needed
            if (index % 2 == 1)
            {
                Widgets.DrawLightHighlight(givenArea);
            }

            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.MiddleLeft;
            GUI.BeginGroup(givenArea);
            DrawNewsID(news);
            DrawNewsType(news);
            // reserved 80px for future use
            DrawNewsImportanceSpace(news);
            DrawNewsDetails(news);
            GUI.EndGroup();
        }
Ejemplo n.º 14
0
        private void DrawConstraints(Rect inRect)
        {
            ConstraintBase toRemove         = null;
            var            listing          = new Listing_Standard();
            int            totalConstraints = _constraints.Count;
            Rect           viewRect         = new Rect(0f, 0f, inRect.width - 16f, LineHeight * totalConstraints).Rounded();

            Widgets.BeginScrollView(inRect, ref _constraintsScrollPos, viewRect);
            listing.Begin(viewRect);

            for (var i = 0; i < _constraints.Count; i++)
            {
                ConstraintBase constraint = _constraints[i];
                Rect           lineRect   = listing.GetRect(LineHeight);

                if (!lineRect.IsVisible(viewRect, _constraintsScrollPos))
                {
                    continue;
                }

                if (i % 2 == 0)
                {
                    Widgets.DrawLightHighlight(lineRect);
                }

                var constraintRect = new Rect(lineRect.x, lineRect.y, lineRect.width - _removeButtonWidth - 20f, lineRect.height);
                var removeRect     = new Rect(lineRect.width - _removeButtonWidth, lineRect.y, _removeButtonWidth, lineRect.height);

                constraint.Draw(constraintRect);

                if (Widgets.ButtonText(removeRect, _removeText))
                {
                    toRemove = constraint;
                }
            }

            if (toRemove != null)
            {
                _constraints.Remove(toRemove);
            }

            listing.End();
            Widgets.EndScrollView();
        }
Ejemplo n.º 15
0
        public static bool DrawTableHeader(
            Rect backgroundRect,
            Rect textRect,
            string text,
            TextAnchor anchor  = TextAnchor.MiddleLeft,
            GameFont fontScale = GameFont.Small,
            bool vertical      = false
            )
        {
            Text.Anchor = anchor;
            Text.Font   = fontScale;

            if (vertical)
            {
                backgroundRect.y += backgroundRect.width;
                GUIUtility.RotateAroundPivot(-90f, backgroundRect.position);
            }

            GUI.color = new Color(0.62f, 0.65f, 0.66f);
            Widgets.DrawHighlight(backgroundRect);
            GUI.color = Color.white;

            if (Mouse.IsOver(backgroundRect))
            {
                GUI.color = Color.grey;
                Widgets.DrawLightHighlight(backgroundRect);
                GUI.color = Color.white;
            }

            Widgets.Label(textRect, text);
            bool pressed = Widgets.ButtonInvisible(backgroundRect);

            if (vertical)
            {
                GUI.matrix = Matrix4x4.identity;
            }

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

            return(pressed);
        }
Ejemplo n.º 16
0
        public bool DrawPawnStats(Rect rect)
        {
            // header [ Prev ] [ Current Pawn Name ] [ Next ]
            //          Render of Pawn with Clothes
            var topPartRect = rect.PopTopPartPixels(ModGUIUtility.SPACED_HEIGHT);

            var lhs = topPartRect.PopLeftPartPixels(ModGUIUtility.SPACED_HEIGHT);
            var rhs = topPartRect.PopRightPartPixels(ModGUIUtility.SPACED_HEIGHT);

            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.Label(topPartRect, $"{selectedUnit.name}");
            Text.Anchor = TextAnchor.UpperLeft;

            rect.PopRightPartPixels(GenUI.GapTiny);
            rect.PopTopPartPixels(GenUI.GapTiny);

            ModGUIUtility.ListSeperator(ref rect, "ApparelWhichCanBeWorn".Translate());

            var wornApparel     = selectedUnit.loadout.HypotheticalWornApparel(pawn.RaceProps.body).ToList();
            var apparels        = ApparelUtility.ApparelCanFitOnBody(pawn.RaceProps.body, wornApparel.Select(td => td.Def).ToList()).ToList();
            var allocatedHeight = apparels.Count * ModGUIUtility.DEFAULT_HEIGHT;

            var viewRect = new Rect(rect.x, rect.y, rect.width - 16f, allocatedHeight);

            Widgets.BeginScrollView(rect, ref wearableApparelScroll, viewRect);
            int aIdx = 0;

            foreach (var apparel in apparels)
            {
                var apparelRect = viewRect.PopTopPartPixels(ModGUIUtility.DEFAULT_HEIGHT);
                if (aIdx++ % 2 == 0)
                {
                    Widgets.DrawLightHighlight(apparelRect);
                }
                Widgets.DefIcon(apparelRect.LeftPart(.15f), apparel);
                Widgets.Label(apparelRect.RightPart(.85f), apparel.LabelCap);
            }

            Widgets.EndScrollView();

            return(false);
        }
Ejemplo n.º 17
0
        /// <inheritdoc cref="TableWorkerBase.DrawTableContents"/>
        protected override void DrawTableContents(Rect region)
        {
            float expectedLine = Data.Where(i => !i.IsHidden).Sum(GetLineSpan);
            var   viewPort     = new Rect(0f, 0f, region.width - 16f, RowLineHeight * expectedLine);

            var alternate        = false;
            var expandedLineSpan = 0;

            GUI.BeginGroup(region);
            _scrollPos = GUI.BeginScrollView(region, _scrollPos, viewPort);

            foreach (TableSettingsItem <EventItem> ev in Data.Where(i => !i.IsHidden))
            {
                var lineRect = new Rect(0f, RowLineHeight * expandedLineSpan, region.width - 16f, RowLineHeight * (ev.SettingsVisible ? GetLineSpan(ev) : 1f));

                if (!lineRect.IsVisible(region, _scrollPos))
                {
                    alternate         = !alternate;
                    expandedLineSpan += GetLineSpan(ev);

                    continue;
                }

                GUI.BeginGroup(lineRect);
                Rect rect = lineRect.AtZero();

                if (alternate)
                {
                    Widgets.DrawLightHighlight(rect);
                }

                DrawEvent(rect, ev);
                GUI.EndGroup();

                alternate         = !alternate;
                expandedLineSpan += GetLineSpan(ev);
            }

            GUI.EndScrollView();
            GUI.EndGroup();
        }
        private void DoFactionInfo(Rect rect, Faction faction, ref float curX, ref float curY, ref int index)
        {
            if (index % 2 == 1)
            {
                Widgets.DrawLightHighlight(new Rect(curX, curY, rect.width, 45f));
            }
            FactionUIUtility.DrawFactionIconWithTooltip(new Rect(curX, curY + 5f, 35f, 35f), faction);
            curX += 45f;
            Rect rect2 = new Rect(curX, curY, 250f, 45f);

            Text.Anchor = TextAnchor.MiddleLeft;
            Widgets.Label(rect2, faction.Name);
            Text.Anchor = TextAnchor.UpperLeft;
            curX       += 250f;
            if (Mouse.IsOver(rect2))
            {
                TipSignal tip = new TipSignal(() => faction.Name + "\n\n" + faction.def.description + "\n\n" + faction.PlayerRelationKind.GetLabel().Colorize(faction.PlayerRelationKind.GetColor()), faction.loadID ^ 0x4468077);
                TooltipHandler.TipRegion(rect2, tip);
                Widgets.DrawHighlight(rect2);
            }
            index++;
        }
Ejemplo n.º 19
0
        private void DrawNameQueue(Listing listing)
        {
            for (var index = 0; index < _pawnComponent.ViewerNameQueue.Count; index++)
            {
                string name = _pawnComponent.ViewerNameQueue[index];

                Rect line       = listing.GetRect(Text.LineHeight);
                var  buttonRect = new Rect(line.x + line.width - line.height * 3f, line.y, line.height * 3f, line.height);
                var  nameRect   = new Rect(line.x, line.y, line.width - buttonRect.width - 5f, line.height);

                if (index % 2 == 0)
                {
                    Widgets.DrawLightHighlight(line);
                }

                if (name.EqualsIgnoreCase(_username))
                {
                    Widgets.DrawHighlightSelected(line);
                }

                Widgets.DrawHighlightIfMouseover(line);
                DrawNameFromQueue(nameRect, name, buttonRect, index);
            }
        }
Ejemplo n.º 20
0
        public override void DoWindowContents(Rect inRect)
        {
            var font      = Text.Font;
            var anchor    = Text.Anchor;
            var iconRect  = new Rect(inRect.x, inRect.y, 50f, 50f);
            var titleRect = inRect.TakeTopPart(50f);

            titleRect.xMin += 60f;
            Text.Anchor     = TextAnchor.MiddleLeft;
            Text.Font       = GameFont.Medium;
            Widgets.Label(titleRect, "VEF.ContractTitle".Translate((contract.factionDef?.label ?? contract.hireable.Key).CapitalizeFirst()));
            if (contract.factionDef != null)
            {
                Widgets.DrawLightHighlight(iconRect);
                GUI.color = contract.factionDef.Color;
                Widgets.DrawTextureFitted(iconRect, contract.factionDef.Texture, 1f);
                GUI.color = Color.white;
            }

            var pawnsRect = inRect.LeftHalf().ContractedBy(3f);
            var infoRect  = inRect.RightHalf().ContractedBy(3f);

            infoRect.yMin += 20f;
            Text.Font      = GameFont.Small;
            Widgets.Label(pawnsRect.TakeTopPart(20f), "VEF.PawnsList".Translate());
            Widgets.DrawMenuSection(pawnsRect);
            pawnsRect = pawnsRect.ContractedBy(5f);
            var viewRect = new Rect(0, 0, pawnsRect.width - 20f, contract.pawns.Count * 40f);

            Widgets.BeginScrollView(pawnsRect, ref pawnsScrollPos, viewRect);
            foreach (var pawn in contract.pawns)
            {
                var pawnRect = viewRect.TakeTopPart(33f);
                if (pawn != contract.pawns[contract.pawns.Count - 1])
                {
                    Widgets.DrawLineHorizontal(pawnRect.x, pawnRect.yMax, pawnRect.width);
                }
                Widgets.DrawHighlightIfMouseover(pawnRect);
                if (Widgets.ButtonInvisible(pawnRect))
                {
                    Close(false);
                    CameraJumper.TryJumpAndSelect(pawn);
                }

                Widgets.ThingIcon(new Rect(pawnRect.x + 3f, pawnRect.y + 3f, 27f, 27f), pawn, 1f, Rot4.South);
                pawnRect.xMin += 35f;
                Widgets.Label(pawnRect.LeftHalf(), pawn.NameFullColored);
                Widgets.Label(pawnRect.RightHalf(), pawn.health.summaryHealth.SummaryHealthPercent.ToStringPercent());
            }

            Widgets.EndScrollView();

            Text.Anchor = TextAnchor.MiddleLeft;
            Text.Font   = GameFont.Small;
            var textRect = infoRect.TakeTopPart(30f);

            Widgets.Label(textRect.LeftHalf(), "VEF.Spent".Translate());
            Widgets.Label(textRect.RightHalf(), contract.price.ToStringMoney().Colorize(ColoredText.CurrencyColor));
            Widgets.DrawLineHorizontal(textRect.x, textRect.y + 30f, textRect.width);
            textRect.y    += 30;
            infoRect.yMin += 30;
            Widgets.Label(textRect.LeftHalf(), "VEF.TimeLeft".Translate());
            int remainingTicks = (this.contract.endTicks - Find.TickManager.TicksAbs);

            Widgets.Label(textRect.RightHalf(), (remainingTicks < 0 ? 0 : remainingTicks).ToStringTicksToPeriodVerbose().Colorize(ColoredText.DateTimeColor));
            if (Widgets.ButtonText(infoRect.TakeBottomPart(40f), "VEF.CancelContract".Translate()))
            {
                Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("VEF.NoRefund".Translate(), () =>
                {
                    Close();
                    this.contract.endTicks = Find.TickManager.TicksAbs;
                }, true, "VEF.CancelContract".Translate()));
            }
            Text.Anchor = anchor;
            Text.Font   = font;
        }
Ejemplo n.º 21
0
        private void DoArchivableRow(Rect rect, IArchivable archivable, int index)
        {
            if (index % 2 == 1)
            {
                Widgets.DrawLightHighlight(rect);
            }
            Widgets.DrawHighlightIfMouseover(rect);
            Text.Font     = GameFont.Small;
            Text.Anchor   = TextAnchor.MiddleLeft;
            Text.WordWrap = false;
            Rect rect2 = rect;
            Rect rect3 = rect2;

            rect3.width = 30f;
            rect2.xMin += 40f;
            float num;

            if (Find.Archive.IsPinned(archivable))
            {
                num = 1f;
            }
            else if (Mouse.IsOver(rect3))
            {
                num = 0.25f;
            }
            else
            {
                num = 0f;
            }
            if (num > 0f)
            {
                GUI.color = new Color(1f, 1f, 1f, num);
                GUI.DrawTexture(new Rect(rect3.x + (rect3.width - 22f) / 2f, rect3.y + (rect3.height - 22f) / 2f, 22f, 22f).Rounded(), MainTabWindow_History.PinTex);
                GUI.color = Color.white;
            }
            Rect rect4     = rect2;
            Rect outerRect = rect2;

            outerRect.width = 30f;
            rect2.xMin     += 40f;
            Texture archivedIcon = archivable.ArchivedIcon;

            if (archivedIcon != null)
            {
                GUI.color = archivable.ArchivedIconColor;
                Widgets.DrawTextureFitted(outerRect, archivedIcon, 0.8f);
                GUI.color = Color.white;
            }
            Rect rect5 = rect2;

            rect5.width = 200f;
            rect2.xMin += 210f;
            Vector2 location = (Find.CurrentMap == null) ? default(Vector2) : Find.WorldGrid.LongLatOf(Find.CurrentMap.Tile);

            GUI.color = new Color(0.75f, 0.75f, 0.75f);
            int    num2 = GenDate.TickGameToAbs(archivable.CreatedTicksGame);
            string str  = string.Concat(new object[]
            {
                GenDate.DateFullStringAt((long)num2, location),
                ", ",
                GenDate.HourInteger((long)num2, location.x),
                "LetterHour".Translate()
            });

            Widgets.Label(rect5, str.Truncate(rect5.width, null));
            GUI.color = Color.white;
            Rect rect6 = rect2;

            Widgets.Label(rect6, archivable.ArchivedLabel.Truncate(rect6.width, null));
            GenUI.ResetLabelAlign();
            Text.WordWrap = true;
            TooltipHandler.TipRegion(rect3, "PinArchivableTip".Translate(200));
            if (Mouse.IsOver(rect4))
            {
                TooltipHandler.TipRegion(rect4, archivable.ArchivedTooltip);
            }
            if (Widgets.ButtonInvisible(rect3, false))
            {
                if (Find.Archive.IsPinned(archivable))
                {
                    Find.Archive.Unpin(archivable);
                    SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera(null);
                }
                else
                {
                    Find.Archive.Pin(archivable);
                    SoundDefOf.Checkbox_TurnedOn.PlayOneShotOnCamera(null);
                }
            }
            if (Widgets.ButtonInvisible(rect4, false))
            {
                if (Event.current.button == 1)
                {
                    LookTargets lookTargets = archivable.LookTargets;
                    if (CameraJumper.CanJump(lookTargets.TryGetPrimaryTarget()))
                    {
                        CameraJumper.TryJumpAndSelect(lookTargets.TryGetPrimaryTarget());
                        Find.MainTabsRoot.EscapeCurrentTab(true);
                    }
                }
                else
                {
                    archivable.OpenArchived();
                }
            }
        }
Ejemplo n.º 22
0
        private void DoRow(Rect rect, TransferableOneWay trad, int index, float availableMass)
        {
            if (index % 2 == 1)
            {
                Widgets.DrawLightHighlight(rect);
            }
            Text.Font = GameFont.Small;
            GUI.BeginGroup(rect);
            float num      = rect.width;
            int   maxCount = trad.MaxCount;
            Rect  rect2    = new Rect(num - 240f, 0f, 240f, rect.height);

            TransferableOneWayWidget.stoppingPoints.Clear();
            if (this.availableMassGetter != null && (!(trad.AnyThing is Pawn) || this.includePawnsMassInMassUsage))
            {
                float num2      = availableMass + this.GetMass(trad.AnyThing) * (float)trad.CountToTransfer;
                int   threshold = (num2 > 0f) ? Mathf.FloorToInt(num2 / this.GetMass(trad.AnyThing)) : 0;
                TransferableOneWayWidget.stoppingPoints.Add(new TransferableCountToTransferStoppingPoint(threshold, "M<", ">M"));
            }
            Pawn pawn  = trad.AnyThing as Pawn;
            bool flag  = pawn != null && (pawn.IsColonist || pawn.IsPrisonerOfColony);
            Rect rect3 = rect2;
            int  min   = 0;
            int  max   = maxCount;
            List <TransferableCountToTransferStoppingPoint> extraStoppingPoints = TransferableOneWayWidget.stoppingPoints;

            TransferableUIUtility.DoCountAdjustInterface(rect3, trad, index, min, max, false, extraStoppingPoints, this.playerPawnsReadOnly && flag);
            num -= 240f;
            if (this.drawMarketValue)
            {
                Rect rect4 = new Rect(num - 100f, 0f, 100f, rect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                this.DrawMarketValue(rect4, trad);
                num -= 100f;
            }
            if (this.drawMass)
            {
                Rect rect5 = new Rect(num - 100f, 0f, 100f, rect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                this.DrawMass(rect5, trad, availableMass);
                num -= 100f;
            }
            if (this.drawDaysUntilRot)
            {
                Rect rect6 = new Rect(num - 75f, 0f, 75f, rect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                this.DrawDaysUntilRot(rect6, trad);
                num -= 75f;
            }
            if (this.drawItemNutrition)
            {
                Rect rect7 = new Rect(num - 75f, 0f, 75f, rect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                this.DrawItemNutrition(rect7, trad);
                num -= 75f;
            }
            if (this.drawForagedFoodPerDay)
            {
                Rect rect8 = new Rect(num - 75f, 0f, 75f, rect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                if (!this.DrawGrazeability(rect8, trad))
                {
                    this.DrawForagedFoodPerDay(rect8, trad);
                }
                num -= 75f;
            }
            if (this.drawNutritionEatenPerDay)
            {
                Rect rect9 = new Rect(num - 75f, 0f, 75f, rect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                this.DrawNutritionEatenPerDay(rect9, trad);
                num -= 75f;
            }
            if (this.ShouldShowCount(trad))
            {
                Rect rect10 = new Rect(num - 75f, 0f, 75f, rect.height);
                Widgets.DrawHighlightIfMouseover(rect10);
                Text.Anchor = TextAnchor.MiddleLeft;
                Rect rect11 = rect10;
                rect11.xMin += 5f;
                rect11.xMax -= 5f;
                Widgets.Label(rect11, maxCount.ToStringCached());
                TooltipHandler.TipRegion(rect10, this.sourceCountDesc);
            }
            num -= 75f;
            if (this.drawEquippedWeapon)
            {
                Rect rect12   = new Rect(num - 30f, 0f, 30f, rect.height);
                Rect iconRect = new Rect(num - 30f, (rect.height - 30f) / 2f, 30f, 30f);
                this.DrawEquippedWeapon(rect12, iconRect, trad);
                num -= 30f;
            }
            Pawn pawn2 = trad.AnyThing as Pawn;

            if (pawn2 != null && pawn2.def.race.Animal)
            {
                Rect rect13 = new Rect(num - TransferableOneWayWidget.BondIconWidth, (rect.height - TransferableOneWayWidget.BondIconWidth) / 2f, TransferableOneWayWidget.BondIconWidth, TransferableOneWayWidget.BondIconWidth);
                num -= TransferableOneWayWidget.BondIconWidth;
                Rect rect14 = new Rect(num - TransferableOneWayWidget.PregnancyIconWidth, (rect.height - TransferableOneWayWidget.PregnancyIconWidth) / 2f, TransferableOneWayWidget.PregnancyIconWidth, TransferableOneWayWidget.PregnancyIconWidth);
                num -= TransferableOneWayWidget.PregnancyIconWidth;
                string iconTooltipText = TrainableUtility.GetIconTooltipText(pawn2);
                if (!iconTooltipText.NullOrEmpty())
                {
                    TooltipHandler.TipRegion(rect13, iconTooltipText);
                }
                if (pawn2.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Bond, null) != null)
                {
                    GUI.DrawTexture(rect13, TransferableOneWayWidget.BondIcon);
                }
                if (pawn2.health.hediffSet.HasHediff(HediffDefOf.Pregnant, true))
                {
                    TooltipHandler.TipRegion(rect14, PawnColumnWorker_Pregnant.GetTooltipText(pawn2));
                    GUI.DrawTexture(rect14, TransferableOneWayWidget.PregnantIcon);
                }
            }
            Rect idRect = new Rect(0f, 0f, num, rect.height);

            TransferableUIUtility.DrawTransferableInfo(trad, idRect, Color.white);
            GenUI.ResetLabelAlign();
            GUI.EndGroup();
        }
        private void DoRow(Rect rect, TransferableOneWay trad, int index, float availableMass)
        {
            if (index % 2 == 1)
            {
                Widgets.DrawLightHighlight(rect);
            }
            Text.Font = GameFont.Small;
            GUI.BeginGroup(rect);
            float width    = rect.width;
            int   maxCount = trad.MaxCount;
            Rect  rect2    = new Rect(width - 240f, 0f, 240f, rect.height);

            stoppingPoints.Clear();
            if (availableMassGetter != null && (!(trad.AnyThing is Pawn) || includePawnsMassInMassUsage))
            {
                float num       = availableMass + GetMass(trad.AnyThing) * (float)trad.CountToTransfer;
                int   threshold = ((!(num <= 0f)) ? Mathf.FloorToInt(num / GetMass(trad.AnyThing)) : 0);
                stoppingPoints.Add(new TransferableCountToTransferStoppingPoint(threshold, "M<", ">M"));
            }
            Pawn pawn = trad.AnyThing as Pawn;
            bool flag = pawn != null && (pawn.IsColonist || pawn.IsPrisonerOfColony);

            TransferableUIUtility.DoCountAdjustInterface(rect2, trad, index, 0, maxCount, flash: false, stoppingPoints, (playerPawnsReadOnly && flag) || readOnly);
            width -= 240f;
            if (drawMarketValue)
            {
                Rect rect3 = new Rect(width - 100f, 0f, 100f, rect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                DrawMarketValue(rect3, trad);
                width -= 100f;
            }
            if (drawMass)
            {
                Rect rect4 = new Rect(width - 100f, 0f, 100f, rect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                DrawMass(rect4, trad, availableMass);
                width -= 100f;
            }
            if (drawDaysUntilRot)
            {
                Rect rect5 = new Rect(width - 75f, 0f, 75f, rect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                DrawDaysUntilRot(rect5, trad);
                width -= 75f;
            }
            if (drawItemNutrition)
            {
                Rect rect6 = new Rect(width - 75f, 0f, 75f, rect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                DrawItemNutrition(rect6, trad);
                width -= 75f;
            }
            if (drawForagedFoodPerDay)
            {
                Rect rect7 = new Rect(width - 75f, 0f, 75f, rect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                if (!DrawGrazeability(rect7, trad))
                {
                    DrawForagedFoodPerDay(rect7, trad);
                }
                width -= 75f;
            }
            if (drawNutritionEatenPerDay)
            {
                Rect rect8 = new Rect(width - 75f, 0f, 75f, rect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                DrawNutritionEatenPerDay(rect8, trad);
                width -= 75f;
            }
            if (ShouldShowCount(trad))
            {
                Rect rect9 = new Rect(width - 75f, 0f, 75f, rect.height);
                Widgets.DrawHighlightIfMouseover(rect9);
                Text.Anchor = TextAnchor.MiddleLeft;
                Rect rect10 = rect9;
                rect10.xMin += 5f;
                rect10.xMax -= 5f;
                Widgets.Label(rect10, maxCount.ToStringCached());
                TooltipHandler.TipRegion(rect9, sourceCountDesc);
            }
            width -= 75f;
            if (drawEquippedWeapon)
            {
                Rect rect11   = new Rect(width - 30f, 0f, 30f, rect.height);
                Rect iconRect = new Rect(width - 30f, (rect.height - 30f) / 2f, 30f, 30f);
                DrawEquippedWeapon(rect11, iconRect, trad);
                width -= 30f;
            }
            TransferableUIUtility.DoExtraAnimalIcons(trad, rect, ref width);
            Rect idRect = new Rect(0f, 0f, width, rect.height);

            TransferableUIUtility.DrawTransferableInfo(trad, idRect, Color.white);
            GenUI.ResetLabelAlign();
            GUI.EndGroup();
        }
Ejemplo n.º 24
0
        private void DrawItemRow(Rect rect, ThingDef thing, int index)
        {
            if (index % 2 == 1)
            {
                Widgets.DrawLightHighlight(rect);
            }

            Color white = GUI.color;

            if (tradeablesPrices[index] < 1)
            {
                GUI.color = ColorLibrary.Grey;
            }

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

            Rect rect1 = new Rect(num - 100f, 0f, 100f, rect.height);

            rect1 = rect1.Rounded();
            int    newPrice = tradeablesPrices[index];
            string label    = newPrice.ToString();

            rect1.xMax -= 5f;
            rect1.xMin += 5f;
            if (Text.Anchor == TextAnchor.MiddleLeft)
            {
                rect1.xMax += 300f;
            }
            if (Text.Anchor == TextAnchor.MiddleRight)
            {
                rect1.xMin -= 300f;
            }

            Rect rect2 = new Rect(num - 560f, 0f, 240f, rect.height);

            if (newPrice > 0)
            {
                if (Widgets.ButtonText(rect1, "Disable"))
                {
                    newPrice = -10;
                }
                tradeablesPrices[index] = newPrice;
            }

            if (newPrice > 0)
            {
                Widgets.IntEntry(rect2, ref newPrice, ref label, 50);
                tradeablesPrices[index] = newPrice;
            }
            else
            {
                if (Widgets.ButtonText(rect2, "Reset"))
                {
                    tradeablesPrices[index] = Convert.ToInt32(thing.BaseMarketValue * 10 / 6);
                }
            }

            Rect categoryLabel = new Rect(num - 300, 0f, 200f, rect.height);

            Widgets.Label(categoryLabel, thing.FirstThingCategory.LabelCap);

            Rect rect3 = new Rect(0f, 0f, 27f, 27f);

            Widgets.ThingIcon(rect3, thing);
            Widgets.InfoCardButton(40f, 0f, thing);

            Text.Anchor = TextAnchor.MiddleLeft;
            Rect rect4 = new Rect(80f, 0f, rect.width - 80f, rect.height);

            Text.WordWrap = false;
            GUI.color     = Color.white;
            Widgets.Label(rect4, thing.LabelCap);
            Text.WordWrap = true;

            GenUI.ResetLabelAlign();
            GUI.EndGroup();

            GUI.color = white;
        }
Ejemplo n.º 25
0
        public void DrawTradeableRow(Rect rect, Tradeable trad, int index)
        {
            if (index == 1)
            {
                Widgets.DrawLightHighlight(rect);
            }
            Text.Font = GameFont.Small;
            GUI.BeginGroup(rect);
            float width = rect.width;
            int   num   = trad.CountHeldBy(Transactor.Trader);

            if (num != 0)
            {
                Rect rect2 = new Rect(width - 75f, 0f, 75f, rect.height);
                if (Mouse.IsOver(rect2))
                {
                    Widgets.DrawHighlight(rect2);
                }
                Text.Anchor = TextAnchor.MiddleRight;
                Rect rect3 = rect2;
                rect3.xMin += 5f;
                rect3.xMax -= 5f;
                Widgets.Label(rect3, num.ToStringCached());
                TooltipHandler.TipRegion(rect2, "TraderCount".Translate());
            }
            width -= 85f;
            Rect rect4 = new Rect(width - 240f, 0f, 240f, rect.height);

            if (index == 2 && notesTradeable.CountHeldBy(Transactor.Colony) == 0 && notesTradeable.CountHeldBy(Transactor.Trader) == 0)
            {
                Text.Anchor = TextAnchor.MiddleCenter;
                Color color = GUI.color;
                GUI.color = Color.gray;
                Widgets.Label(rect4, "NoNotes".Translate());
                GUI.color = color;
            }
            else if (index == 1 && isVirtual && VirtualTrader.SilverAlsoAdjustable)
            {
                ExtUtil.DoCountAdjustInterfaceForSilver(rect4, trad, index, -trad.CountHeldBy(Transactor.Colony), trad.CountHeldBy(Transactor.Trader), flash: false);
            }
            else
            {
                TransferableUIUtility.DoCountAdjustInterface(rect4, trad, index, -trad.CountHeldBy(Transactor.Colony), trad.CountHeldBy(Transactor.Trader));
            }
            width -= 240f;
            int num2 = trad.CountHeldBy(Transactor.Colony);

            if (num2 != 0)
            {
                Rect rect5 = new Rect(width - 75f - 10f, 0f, 75f, rect.height);
                if (Mouse.IsOver(rect5))
                {
                    Widgets.DrawHighlight(rect5);
                }
                Text.Anchor = TextAnchor.MiddleLeft;
                Rect rect6 = rect5;
                rect6.xMin += 5f;
                rect6.xMax -= 5f;
                Widgets.Label(rect6, num2.ToStringCached());
                TooltipHandler.TipRegion(rect5, "ColonyCount".Translate());
            }
            GenUI.ResetLabelAlign();
            GUI.EndGroup();
        }
Ejemplo n.º 26
0
        public static void DrawTradeableRow(Rect rect, Tradeable trad, int index)
        {
            if (index % 2 == 1)
            {
                Widgets.DrawLightHighlight(rect);
            }
            Text.Font = GameFont.Small;
            GUI.BeginGroup(rect);
            float num  = rect.width;
            int   num2 = trad.CountHeldBy(Transactor.Trader);

            if (num2 != 0)
            {
                Rect rect2 = new Rect(num - 75f, 0f, 75f, rect.height);
                if (Mouse.IsOver(rect2))
                {
                    Widgets.DrawHighlight(rect2);
                }
                Text.Anchor = TextAnchor.MiddleRight;
                Rect rect3 = rect2;
                rect3.xMin += 5f;
                rect3.xMax -= 5f;
                Widgets.Label(rect3, num2.ToStringCached());
                TooltipHandler.TipRegion(rect2, "TraderCount".Translate());
                Rect rect4 = new Rect(rect2.x - 100f, 0f, 100f, rect.height);
                Text.Anchor = TextAnchor.MiddleRight;
                TradeUI.DrawPrice(rect4, trad, TradeAction.PlayerBuys);
            }
            num -= 175f;
            Rect rect5 = new Rect(num - 240f, 0f, 240f, rect.height);

            if (trad.TraderWillTrade)
            {
                bool flash = Time.time - Dialog_Trade.lastCurrencyFlashTime < 1f && trad.IsCurrency;
                TransferableUIUtility.DoCountAdjustInterface(rect5, trad, index, trad.GetMinimumToTransfer(), trad.GetMaximumToTransfer(), flash, null, false);
            }
            else
            {
                TradeUI.DrawWillNotTradeIndication(rect5, trad);
            }
            num -= 240f;
            int num3 = trad.CountHeldBy(Transactor.Colony);

            if (num3 != 0)
            {
                Rect rect6 = new Rect(num - 100f, 0f, 100f, rect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                TradeUI.DrawPrice(rect6, trad, TradeAction.PlayerSells);
                Rect rect7 = new Rect(rect6.x - 75f, 0f, 75f, rect.height);
                if (Mouse.IsOver(rect7))
                {
                    Widgets.DrawHighlight(rect7);
                }
                Text.Anchor = TextAnchor.MiddleLeft;
                Rect rect8 = rect7;
                rect8.xMin += 5f;
                rect8.xMax -= 5f;
                Widgets.Label(rect8, num3.ToStringCached());
                TooltipHandler.TipRegion(rect7, "ColonyCount".Translate());
            }
            num -= 175f;
            Rect idRect = new Rect(0f, 0f, num, rect.height);

            TransferableUIUtility.DrawTransferableInfo(trad, idRect, (!trad.TraderWillTrade) ? TradeUI.NoTradeColor : Color.white);
            GenUI.ResetLabelAlign();
            GUI.EndGroup();
        }
Ejemplo n.º 27
0
        private void DrawItemRow(Rect rect, CommandOption commandOption, int index)
        {
            // Highlight every other row

            if (index % 2 == 1)
            {
                Widgets.DrawLightHighlight(rect);
            }

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

            Rect rect1 = new Rect(num - 100f, 0f, 100f, rect.height);

            rect1 = rect1.Rounded();

            // TextAnchor Fix

            rect1.xMax -= 5f;
            rect1.xMin += 5f;

            if (Text.Anchor == TextAnchor.MiddleLeft)
            {
                rect1.xMax += 300f;
            }
            if (Text.Anchor == TextAnchor.MiddleRight)
            {
                rect1.xMin -= 300f;
            }

            Rect rect2 = new Rect(num - 560f, 0f, 75f, rect.height);

            // Store value for reference
            int    newPrice   = commandOption.costSilverStore;
            string priceLabel = newPrice.ToString();

            int    newLocalCooldown   = commandOption.localCooldownMs / 1000;
            string localCooldownLabel = newLocalCooldown.ToString();

            int    newGlobalCooldown   = commandOption.globalCooldownMs / 1000;
            string globalCooldownLabel = newGlobalCooldown.ToString();

            // Silver Cost
            Widgets.TextFieldNumeric(rect2, ref newPrice, ref priceLabel, -1f);
            filteredRows[index].costSilverStore = newPrice;

            // Local Cooldown

            rect2.x += rect2.width + 75f;

            Widgets.TextFieldNumeric(rect2, ref newLocalCooldown, ref localCooldownLabel, 0f);
            filteredRows[index].localCooldownMs = newLocalCooldown * 1000;

            // Global Cooldown

            rect2.x += rect2.width + 100f;

            Widgets.TextFieldNumeric(rect2, ref newGlobalCooldown, ref globalCooldownLabel, 0f);
            filteredRows[index].globalCooldownMs = newGlobalCooldown * 1000;

            // Icons for ItemDefs
            Rect rect3 = new Rect(0f, 0f, 27f, 27f);

            if (commandOption.Action() is ItemAction)
            {
                ItemAction itemAction = (ItemAction)commandOption.Action();
                ThingDef   thingDef   = itemAction.thingDef;
                Widgets.ThingIcon(rect3, thingDef);
                Widgets.InfoCardButton(40f, 0f, thingDef);
            }

            // Label for item/event

            Text.Anchor = TextAnchor.MiddleLeft;
            Rect rect4 = new Rect(80f, 0f, rect.width - 80f, rect.height);

            Text.WordWrap = false;
            GUI.color     = Color.white;
            Widgets.Label(rect4, commandOption.Action().Name.CapitalizeFirst());
            Text.WordWrap = true;

            GenUI.ResetLabelAlign();
            GUI.EndGroup();
        }
Ejemplo n.º 28
0
        public override void DoWindowContents(Rect inRect)
        {
            //grab before anchor/font
            GameFont   fontBefore   = Text.Font;
            TextAnchor anchorBefore = Text.Anchor;

            //Buildings
            for (int i = 0; i < buildingList.Count; i++)
            {
                BuildingFCDef building = buildingList[i];
                newBuildingWindow = new Rect(BaseBuildingWindow.x, BaseBuildingWindow.y + (i * (rowHeight)) + scroll, BaseBuildingWindow.width, BaseBuildingWindow.height);
                newBuildingIcon   = new Rect(BaseBuildingIcon.x, BaseBuildingIcon.y + (i * (rowHeight)) + scroll, BaseBuildingIcon.width, BaseBuildingIcon.height);
                newBuildingLabel  = new Rect(BaseBuildingLabel.x, BaseBuildingLabel.y + (i * (rowHeight)) + scroll, BaseBuildingLabel.width, BaseBuildingLabel.height);
                newBuildingDesc   = new Rect(BaseBuildingDesc.x, BaseBuildingDesc.y + (i * (rowHeight)) + scroll, BaseBuildingDesc.width, BaseBuildingDesc.height);

                if (Widgets.ButtonInvisible(newBuildingWindow))
                {
                    //If click on building
                    List <FloatMenuOption> list = new List <FloatMenuOption>();

                    if (building == buildingDef)
                    {
                        //if the same building
                        list.Add(new FloatMenuOption("Destroy".Translate(), delegate
                        {
                            settlement.deconstructBuilding(buildingSlot);
                            Find.WindowStack.TryRemove(this);
                            Find.WindowStack.WindowOfType <SettlementWindowFc>().windowUpdateFc();
                        }));
                    }
                    else
                    {
                        //if not the same building
                        list.Add(new FloatMenuOption("Build".Translate(), delegate
                        {
                            if (!settlement.validConstructBuilding(building, buildingSlot, settlement))
                            {
                                return;
                            }
                            FCEvent tmpEvt = new FCEvent(true)
                            {
                                def          = FCEventDefOf.constructBuilding,
                                source       = settlement.mapLocation,
                                planetName   = settlement.planetName,
                                building     = building,
                                buildingSlot = buildingSlot
                            };


                            int triggerTime = building.constructionDuration;
                            if (factionfc.hasPolicy(FCPolicyDefOf.isolationist))
                            {
                                triggerTime /= 2;
                            }

                            tmpEvt.timeTillTrigger = Find.TickManager.TicksGame + triggerTime;
                            Find.World.GetComponent <FactionFC>().addEvent(tmpEvt);

                            PaymentUtil.paySilver(Convert.ToInt32(building.cost));
                            settlement.deconstructBuilding(buildingSlot);
                            Messages.Message(building.label + " " + "WillBeConstructedIn".Translate() + " " + (tmpEvt.timeTillTrigger - Find.TickManager.TicksGame).ToTimeString(), MessageTypeDefOf.PositiveEvent);
                            settlement.buildings[buildingSlot] = BuildingFCDefOf.Construction;
                            Find.WindowStack.TryRemove(this);
                            Find.WindowStack.WindowOfType <SettlementWindowFc>().windowUpdateFc();
                        }));
                    }



                    FloatMenu menu = new FloatMenu(list);
                    Find.WindowStack.Add(menu);
                }


                Widgets.DrawMenuSection(newBuildingWindow);
                Widgets.DrawMenuSection(newBuildingIcon);
                Widgets.DrawLightHighlight(newBuildingIcon);
                Widgets.ButtonImage(newBuildingIcon, building.Icon);

                Text.Font = GameFont.Small;
                Widgets.ButtonTextSubtle(newBuildingLabel, "");
                Widgets.Label(newBuildingLabel, "  " + building.LabelCap + " - " + "Cost".Translate() + ": " + building.cost);

                Text.Font = GameFont.Tiny;
                Widgets.Label(newBuildingDesc, building.desc);
            }


            //Top Window
            Widgets.DrawMenuSection(TopWindow);
            Widgets.DrawHighlight(TopWindow);
            Widgets.DrawMenuSection(TopIcon);
            Widgets.DrawLightHighlight(TopIcon);

            Widgets.DrawBox(new Rect(0, 0, 400, 500));
            Widgets.ButtonImage(TopIcon, buildingDef.Icon);

            Widgets.ButtonTextSubtle(TopName, "");
            Text.Font   = GameFont.Medium;
            Text.Anchor = TextAnchor.UpperLeft;
            Widgets.Label(new Rect(TopName.x + 5, TopName.y, TopName.width, TopName.height), buildingDef.LabelCap);

            Widgets.DrawMenuSection(new Rect(TopDescription.x - 5, TopDescription.y - 5, TopDescription.width, TopDescription.height));
            Text.Font = GameFont.Small;
            Widgets.Label(TopDescription, buildingDef.desc);

            Widgets.DrawLineHorizontal(0, TopWindow.y + TopWindow.height, 400);

            //reset anchor/font
            Text.Font   = fontBefore;
            Text.Anchor = anchorBefore;

            if (Event.current.type == EventType.ScrollWheel)
            {
                scrollWindow(Event.current.delta.y);
            }
        }
        private void DoReminderRow(Rect rect, Reminder reminder, bool zebra, List <Reminder> listToRemoveFrom)
        {
            if (zebra)
            {
                Widgets.DrawLightHighlight(rect);
            }
            Widgets.DrawHighlightIfMouseover(rect);

            var deleteRect = rect;

            deleteRect.width = 30f;


            var deletePressed = Widgets.ButtonImage(deleteRect, DeleteX);

            if (deletePressed)
            {
                Dialog_MessageBox confirmDelete = Dialog_MessageBox.CreateConfirmation(
                    I18n.Translate("ConfirmDelete.Body"),
                    () => listToRemoveFrom.Remove(reminder),
                    destructive: true,
                    I18n.Translate("ConfirmDelete.Title")
                    );
                Find.WindowStack.Add(confirmDelete);
            }

            var iconRect = rect;

            iconRect.xMin += 35f;
            iconRect.width = 30f;

            var icon = reminder.LetterDef.Icon;

            if (icon != null)
            {
                var iconColor = reminder.LetterDef.color;
                GUI.color = iconColor;
                Widgets.DrawTextureFitted(iconRect, icon, .8f);
                if (reminder.RecurEvery.HasValue)
                {
                    Widgets.DrawTextureFitted(iconRect, RecurArrow, .5f);
                }
            }

            var fromNowRect = rect;

            fromNowRect.xMin  = iconRect.xMax + 5f;
            fromNowRect.width = 80f;
            GUI.color         = new Color(.75f, .75f, .75f);
            Widgets.Label(fromNowRect, reminder.FromNow.Truncate(fromNowRect.width));

            var titleRect = rect;

            titleRect.xMin  = fromNowRect.xMax + 5f;
            titleRect.width = 300f;

            GUI.color = Color.white;
            Widgets.Label(titleRect, reminder.Title.Truncate(titleRect.width));

            var bodyRect = rect;

            bodyRect.xMin = titleRect.xMax + 5f;
            Widgets.Label(bodyRect, reminder.Body.Replace('\n', ' ').Truncate(bodyRect.width));

            var rowRect = rect;

            rowRect.xMin = deleteRect.xMax;
            if (Widgets.ButtonInvisible(rowRect))
            {
                Find.WindowStack.Add(new Window_EditReminder(reminder, reminder.FireOnTick == -1));
            }
        }
        public override void DoWindowContents(Rect inRect)
        {
            Color      prevColor  = GUI.color;
            GameFont   prevFont   = Text.Font;
            TextAnchor prevAnchor = Text.Anchor;

            GUI.color = Color.black;
            Widgets.DrawBoxSolid(imageRect, GUI.color);
            Widgets.DrawBox(descriptionRect, 4);
            GUI.color = prevColor;

            Widgets.DrawWindowBackground(descriptionRect.ContractedBy(4f));
            Widgets.DrawLightHighlight(descriptionRect.ContractedBy(4f + commonMargin));

            Text.Font = GameFont.Small;
            Rect contracted     = descriptionRect.ContractedBy(4f + commonMargin * 2f);
            Rect nextButtonRect = contracted.RightPartPixels(100f).TopPartPixels((contracted.height - commonMargin) / 2f);
            Rect lastButtonRect = nextButtonRect.CopyAndShift(0f, nextButtonRect.height + commonMargin);

            Widgets.LabelScrollable(contracted.LeftPartPixels(contracted.width - 100f - commonMargin), patchNoteDef.PatchNoteImageDescriptions[displayedImage], ref scrollPos);

            Text.Font   = GameFont.Medium;
            Text.Anchor = TextAnchor.MiddleCenter;
            if (displayedImage < patchNoteDef.PatchNoteImages.Count - 1)
            {
                Widgets.DrawBoxSolid(nextButtonRect, Color.black);
                Widgets.Label(nextButtonRect, ">");

                if (Widgets.ButtonInvisible(nextButtonRect))
                {
                    displayedImage++;
                    SoundDefOf.Click.PlayOneShotOnCamera();
                }
            }

            if (displayedImage > 0)
            {
                Widgets.DrawBoxSolid(lastButtonRect, Color.black);
                Widgets.Label(lastButtonRect, "<");

                if (Widgets.ButtonInvisible(lastButtonRect))
                {
                    displayedImage--;
                    SoundDefOf.Click.PlayOneShotOnCamera();
                }
            }

            //Make images look better if they are 16/9
            Texture2D tex = patchNoteDef.PatchNoteImages[displayedImage];

            if (GenMath.RoundedHundredth((float)tex.width / tex.height / (16f / 9f)) == 1f)
            {
                GUI.DrawTexture(imageRect.ContractedBy(4f), tex);
            }
            else
            {
                GUI.DrawTexture(imageRect.ContractedBy(4f), tex, ScaleMode.ScaleToFit);
            }


            Text.Anchor = prevAnchor;
            Text.Font   = prevFont;
            if (Widgets.ButtonInvisible(windowRect) && !Mouse.IsOver(imageRect) && !Mouse.IsOver(descriptionRect))
            {
                Close();
            }
        }