コード例 #1
0
        protected override void FillTab()
        {
            SaveablePawn pawnSave = this.SelPawnForGear.GetSaveablePawn();

            // Outfit + Status button
            Rect rectStatus = new Rect(20f, 15f, 380f, ButtonHeight);

            Rect outfitRect = new Rect(rectStatus.x, rectStatus.y, 392f / 3 - Margin, ButtonHeight);

            Rect outfitEditRect = new Rect(outfitRect.xMax + Margin, outfitRect.y, outfitRect.width, ButtonHeight);

            Rect outfitJobRect = new Rect(outfitEditRect.xMax + Margin, outfitRect.y, outfitRect.width, ButtonHeight);

            // select outfit
            if (Widgets.ButtonText(outfitRect, this.SelPawnForGear.outfits.CurrentOutfit.label))
            {
                List <FloatMenuOption> options = new List <FloatMenuOption>();

                foreach (Outfit current in Current.Game.outfitDatabase.AllOutfits)
                {
                    Outfit localOut = current;
                    options.Add(
                        new FloatMenuOption(
                            localOut.label,
                            delegate { this.SelPawnForGear.outfits.CurrentOutfit = localOut; }));
                }

                FloatMenu window = new FloatMenu(options, "SelectOutfit".Translate());

                Find.WindowStack.Add(window);
            }

            // edit outfit
            if (Widgets.ButtonText(
                    outfitEditRect,
                    "OutfitterEditOutfit".Translate() + " " + this.SelPawnForGear.outfits.CurrentOutfit.label + " ..."))
            {
                Find.WindowStack.Add(new Dialog_ManageOutfits(this.SelPawnForGear.outfits.CurrentOutfit));
            }

            // job outfit
            if (Widgets.ButtonText(
                    outfitJobRect,
                    pawnSave.MainJob == MainJob.Anything
                                       ? "MainJob".Translate()
                                       : "PreferedGear".Translate() + " " + pawnSave.MainJob.ToString()
                    .Replace("00", " - ")
                    .Replace("_", " ")))
            {
                List <FloatMenuOption> options = new List <FloatMenuOption>();
                foreach (MainJob mainJob in Enum.GetValues(typeof(MainJob)))
                {
                    options.Add(
                        new FloatMenuOption(
                            mainJob.ToString().Replace("00", " - ").Replace("_", " "),
                            delegate
                    {
                        pawnSave.MainJob         = mainJob;
                        pawnSave.ForceStatUpdate = true;

                        this.SelPawnForGear.mindState.Notify_OutfitChanged();

                        if (this.SelPawnForGear.jobs.curJob != null &&
                            this.SelPawnForGear.jobs.IsCurrentJobPlayerInterruptible())
                        {
                            this.SelPawnForGear.jobs.EndCurrentJob(JobCondition
                                                                   .InterruptForced);
                        }
                    }));
                }

                FloatMenu window = new FloatMenu(options, "MainJob".Translate());

                Find.WindowStack.Add(window);
            }

            // Status checkboxes
            Rect rectCheckboxes = new Rect(rectStatus.x, rectStatus.yMax + Margin, rectStatus.width, 72f);
            Rect check1         = new Rect(rectCheckboxes.x, rectCheckboxes.y, rectCheckboxes.width, 24f);
            Rect check2         = new Rect(rectCheckboxes.x, check1.yMax, rectCheckboxes.width, 24f);
            Rect check3         = new Rect(rectCheckboxes.x, check2.yMax, rectCheckboxes.width, 24f);

            bool pawnSaveAddWorkStats       = pawnSave.AddWorkStats;
            bool pawnSaveAddIndividualStats = pawnSave.AddIndividualStats;
            bool pawnSaveAddPersonalStats   = pawnSave.AddPersonalStats;

            Widgets.CheckboxLabeled(check1, "AddWorkStats".Translate(), ref pawnSaveAddWorkStats);
            Widgets.CheckboxLabeled(check2, "AddIndividualStats".Translate(), ref pawnSaveAddIndividualStats);
            Widgets.CheckboxLabeled(check3, "AddPersonalStats".Translate(), ref pawnSaveAddPersonalStats);

            if (GUI.changed)
            {
                pawnSave.AddWorkStats       = pawnSaveAddWorkStats;
                pawnSave.AddIndividualStats = pawnSaveAddIndividualStats;
                pawnSave.AddPersonalStats   = pawnSaveAddPersonalStats;
                pawnSave.ForceStatUpdate    = true;
            }

            // main canvas
            Rect canvas = new Rect(20f, rectCheckboxes.yMax, 392f, this.size.y - rectCheckboxes.yMax - 20f);

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

            this.DrawTemperatureStats(pawnSave, ref cur, canvas);
            cur.y += Margin;
            this.DrawApparelStats(cur, canvas);

            GUI.EndGroup();

            this.DrawApparelList();

            GUI.color   = Color.white;
            Text.Anchor = TextAnchor.UpperLeft;
        }
コード例 #2
0
        private void DrawThingRowModded(ref float y, float width, Apparel apparel)
        {
            if (apparel == null)
            {
                this.DrawThingRowVanilla(ref y, width, apparel);
                return;
            }

            Rect rect = new Rect(0f, y, width, ThingRowHeight);

            if (Mouse.IsOver(rect))
            {
                GUI.color = HighlightColor;
                GUI.DrawTexture(rect, TexUI.HighlightTex);
            }

            GUI.color = ThingLabelColor;

            // LMB doubleclick
            if (Widgets.ButtonInvisible(rect))
            {
                // Left Mouse Button Menu
                if (Event.current.button == 0)
                {
                    Find.WindowStack.Add(new Window_Pawn_ApparelDetail(this.SelPawn, apparel));
                }

                // RMB menu
                if (Event.current.button == 1)
                {
                    List <FloatMenuOption> floatOptionList =
                        new List <FloatMenuOption>
                    {
                        new FloatMenuOption(
                            "ThingInfo".Translate(),
                            delegate { Find.WindowStack.Add(new Dialog_InfoCard(apparel)); })
                    };

                    if (this.CanControl)
                    {
                        floatOptionList.Add(
                            new FloatMenuOption(
                                "OutfitterComparer".Translate(),
                                delegate
                        {
                            Find.WindowStack.Add(
                                new
                                Dialog_PawnApparelComparer(this.SelPawnForGear,
                                                           apparel));
                        }));

                        Action dropApparel = delegate
                        {
                            SoundDefOf.Tick_High.PlayOneShotOnCamera();
                            this.InterfaceDrop(apparel);
                        };
                        Action dropApparelHaul = delegate
                        {
                            SoundDefOf.Tick_High.PlayOneShotOnCamera();
                            this.InterfaceDropHaul(apparel);
                        };
                        floatOptionList.Add(new FloatMenuOption("DropThing".Translate(), dropApparel));
                        floatOptionList.Add(new FloatMenuOption("DropThingHaul".Translate(), dropApparelHaul));
                    }

                    FloatMenu window = new FloatMenu(floatOptionList, string.Empty);
                    Find.WindowStack.Add(window);
                }
            }

            if (apparel.def.DrawMatSingle != null && apparel.def.DrawMatSingle.mainTexture != null)
            {
                Widgets.ThingIcon(new Rect(4f, y + 5f, ThingIconSize, ThingIconSize), apparel);
            }

            Text.Anchor = TextAnchor.MiddleLeft;
            GUI.color   = ThingLabelColor;
            Rect textRect  = new Rect(ThingLeftX, y, width - ThingLeftX, ThingRowHeight - Text.LineHeight);
            Rect scoreRect = new Rect(ThingLeftX, textRect.yMax, width - ThingLeftX, Text.LineHeight);

            ApparelStatCache conf      = this.SelPawn.GetApparelStatCache();
            string           text      = apparel.LabelCap;
            string           textScore = Math.Round(conf.ApparelScoreRaw(apparel), 2).ToString("N2");

            if (apparel is Apparel && this.SelPawn.outfits != null &&
                this.SelPawn.outfits.forcedHandler.IsForced(apparel))
            {
                text = text + ", " + "ApparelForcedLower".Translate();
                Widgets.Label(textRect, text);
            }
            else
            {
                GUI.color = new Color(0.75f, 0.75f, 0.75f);
                if (apparel.def.useHitPoints)
                {
                    float x = apparel.HitPoints / (float)apparel.MaxHitPoints;
                    if (x < 0.5f)
                    {
                        GUI.color = Color.yellow;
                    }

                    if (x < 0.2f)
                    {
                        GUI.color = Color.red;
                    }
                }

                Widgets.Label(textRect, text);
                GUI.color = Color.white;
                Widgets.Label(scoreRect, textScore);
            }

            y += ThingRowHeight;
        }
コード例 #3
0
        private void DrawThingRow(ref float y, float width, Thing thing, bool equiped, Color thingColor, Saveable_Pawn pawnSave, PawnCalcForApparel pawnCalc)
        {
            Rect rect = new Rect(0f, y, width, 28f);
            if (Mouse.IsOver(rect))
            {
                GUI.color = ITab_Pawn_AutoEquip.HighlightColor;
                GUI.DrawTexture(rect, TexUI.HighlightTex);
            }
            if (Widgets.InvisibleButton(rect) && Event.current.button == 1)
            {
                List<FloatMenuOption> list = new List<FloatMenuOption>();
                list.Add(new FloatMenuOption("ThingInfo".Translate(), delegate
                {
                    Find.WindowStack.Add(new Dialog_InfoCard(thing));
                }, MenuOptionPriority.Medium, null, null));
                if (this.CanEdit && equiped)
                {
                    Action action = null;
                    ThingWithComps eq = thing as ThingWithComps;
                    Apparel ap = thing as Apparel;
                    if (ap != null)
                    {
                        Apparel unused;
                        action = delegate
                        {
                            this.SelPawnForGear.apparel.TryDrop(ap, out unused, this.SelPawnForGear.Position, true);
                        };
                    }
                    else if (eq != null && this.SelPawnForGear.equipment.AllEquipment.Contains(eq))
                    {
                        ThingWithComps unused;
                        action = delegate
                        {
                            this.SelPawnForGear.equipment.TryDropEquipment(eq, out unused, this.SelPawnForGear.Position, true);
                        };
                    }
                    else if (!thing.def.destroyOnDrop)
                    {
                        Thing unused;
                        action = delegate
                        {
                            this.SelPawnForGear.inventory.container.TryDrop(thing, this.SelPawnForGear.Position, ThingPlaceMode.Near, out unused);
                        };
                    }
                    list.Add(new FloatMenuOption("DropThing".Translate(), action, MenuOptionPriority.Medium, null, null));
                }

                if ((pawnSave != null) &&
                    (thing is Apparel))
                {
                    if (!equiped)
                        list.Add(new FloatMenuOption("Locate", delegate
                        {
                            Pawn apparelEquipedThing = null;

                            foreach (Pawn p in Find.ListerPawns.FreeColonists)
                            {
                                foreach (Apparel a in p.apparel.WornApparel)
                                    if (a == thing)
                                    {
                                        apparelEquipedThing = p;
                                        break;
                                    }
                                if (apparelEquipedThing != null)
                                    break;
                            }

                            if (apparelEquipedThing != null)
                            {
                                Find.CameraMap.JumpTo(apparelEquipedThing.PositionHeld);
                                Find.Selector.ClearSelection();
                                if (apparelEquipedThing.SpawnedInWorld)
                                    Find.Selector.Select(apparelEquipedThing, true, true);
                            }
                            else
                            {
                                Find.CameraMap.JumpTo(thing.PositionHeld);
                                Find.Selector.ClearSelection();
                                if (thing.SpawnedInWorld)
                                    Find.Selector.Select(thing, true, true);
                            }
                        }, MenuOptionPriority.Medium, null, null));
                    list.Add(new FloatMenuOption("AutoEquip Details", delegate
                    {
                        Find.WindowStack.Add(new Dialog_PawnApparelDetail(pawnSave.pawn, (Apparel)thing));
                    }, MenuOptionPriority.Medium, null, null));

                    list.Add(new FloatMenuOption("AutoEquip Comparer", delegate
                    {
                        Find.WindowStack.Add(new Dialog_PawnApparelComparer(pawnSave.pawn, (Apparel)thing));
                    }, MenuOptionPriority.Medium, null, null));
                }

                FloatMenu window = new FloatMenu(list, thing.LabelCap, false, false);
                Find.WindowStack.Add(window);
            }
            if (thing.def.DrawMatSingle != null && thing.def.DrawMatSingle.mainTexture != null)
            {
                Widgets.ThingIcon(new Rect(4f, y, 28f, 28f), thing);
            }
            Text.Anchor = TextAnchor.MiddleLeft;
            GUI.color = thingColor;
            Rect rect2 = new Rect(36f, y, width - 36f, 28f);
            string text = thing.LabelCap;
            if (thing is Apparel)
            {
                if ((pawnSave != null) &&
                    (pawnSave.targetApparel != null))
                    text = pawnCalc.CalculateApparelScoreRaw((Apparel)thing).ToString("N5") + "   " + text;

                if (this.SelPawnForGear.outfits != null && this.SelPawnForGear.outfits.forcedHandler.IsForced((Apparel)thing))
                    text = text + ", " + "ApparelForcedLower".Translate();
            }
            Widgets.Label(rect2, text);
            y += 28f;
        }
コード例 #4
0
        private void DrawFactionButtons(Rect inRect, int buttonSize)         //Used to draw a list of buttons from the 'buttons' list
        {
            Text.Anchor = TextAnchor.MiddleCenter;
            Text.Font   = GameFont.Small;
            for (int i = 0; i < buttons.Count(); i++)
            {
                if (Widgets.ButtonText(new Rect(140, 110 + ((buttonSize + 5) * i), 170, buttonSize), buttons[i]))
                {
                    if (buttons[i] == "Policies-Traits".Translate())
                    {                     //if click trade policy button
                        //Log.Message(buttons[i]);
                        Find.WindowStack.Add(new traitWindowFC());
                    }


                    if (buttons[i] == "Military".Translate())
                    {
                        Find.WindowStack.Add(new militaryCustomizationWindowFC());
                    }

                    if (buttons[i] == "Actions".Translate())
                    {
                        List <FloatMenuOption> list = new List <FloatMenuOption>();

                        list.Add(new FloatMenuOption("TaxDeliveryMap".Translate(), delegate
                        {
                            List <FloatMenuOption> list2 = new List <FloatMenuOption>();


                            list2.Add(new FloatMenuOption("SetMap".Translate(), delegate
                            {
                                List <FloatMenuOption> settlementList = new List <FloatMenuOption>();

                                foreach (Map map in Find.Maps)
                                {
                                    if (map.IsPlayerHome == true)
                                    {
                                        settlementList.Add(new FloatMenuOption(map.Parent.LabelCap, delegate
                                        {
                                            faction.taxMap = map;
                                            Find.LetterStack.ReceiveLetter("Map Set!", "The tax delivery map has been set to the player colony of " + map.Parent.LabelCap + ".\n All taxes and other goods will be delivered there", LetterDefOf.NeutralEvent);
                                        }, MenuOptionPriority.Default, null, null, 0f, null, null
                                                                               ));
                                    }
                                }

                                if (settlementList.Count == 0)
                                {
                                    settlementList.Add(new FloatMenuOption("No valid settlements to use.", null));
                                }

                                FloatMenu floatMenu2            = new FloatMenu(settlementList);
                                floatMenu2.vanishIfMouseDistant = true;
                                Find.WindowStack.Add(floatMenu2);
                            }, MenuOptionPriority.Default, null, null, 0f, null, null));

                            FloatMenu floatMenu            = new FloatMenu(list2);
                            floatMenu.vanishIfMouseDistant = true;
                            Find.WindowStack.Add(floatMenu);
                        }));

                        list.Add(new FloatMenuOption("SetCapital".Translate(), delegate
                        {
                            faction.setCapital();
                        }));

                        list.Add(new FloatMenuOption("ActivateResearch".Translate(), delegate
                        {
                            faction.updateDailyResearch();
                        }));

                        list.Add(new FloatMenuOption("ResearchLevel".Translate(), delegate
                        {
                            Messages.Message(TranslatorFormattedStringExtensions.Translate("CurrentResearchLevel", faction.techLevel.ToString(), faction.returnNextTechToLevel()), MessageTypeDefOf.NeutralEvent);
                        }));


                        FloatMenu menu = new FloatMenu(list);
                        Find.WindowStack.Add(menu);
                    }
                }
            }
        }
コード例 #5
0
        protected void DrawUsableMinMaxFromRestrictedListItem <T>(MinMaxFromRestrictedListItem <T> item, string label, Func <T, string> itemToStringFunc = null)
            where T : struct, IConvertible
        {
            var tmpCheckedOn = item.Use;

            var textMin = "PLINT_UsableMinMaxNumFieldMin".Translate();
            var textMax = "PLINT_UsableMinMaxNumFieldMax".Translate();

            // Use
            ListingStandard.Gap();
            ListingStandard.CheckboxLabeled(label, ref tmpCheckedOn, $"{"PLINT_UsableMinMaxNumFieldUse".Translate()} {textMin}/{textMax} {label}");
            item.Use = tmpCheckedOn;

            // MIN
            if (ListingStandard.ButtonText($"{"PLINT_UsableMinMaxNumFieldMin".Translate()} {label}"))
            {
                var floatMenuOptions = new List <FloatMenuOption>();
                foreach (var itemOption in item.Options)
                {
                    var menuOptionString = itemToStringFunc == null
                        ? itemOption.ToString(CultureInfo.InvariantCulture)
                        : itemToStringFunc(itemOption);

                    var menuOption = new FloatMenuOption(menuOptionString, delegate { item.Min = itemOption; });
                    floatMenuOptions.Add(menuOption);
                }

                var floatMenu = new FloatMenu(floatMenuOptions, $"{"PLINT_MinMaxFromRestrictedListItemSelect".Translate()} {label}");
                Find.WindowStack.Add(floatMenu);
            }

            var minValueString = itemToStringFunc == null
                ? item.Min.ToString(CultureInfo.InvariantCulture)
                : itemToStringFunc(item.Min);

            ListingStandard.LabelDouble($"{"PLINT_UsableMinMaxNumFieldMin".Translate()} {label}:", minValueString);

            // MAX
            if (ListingStandard.ButtonText($"{"PLINT_UsableMinMaxNumFieldMax".Translate()} {label}"))
            {
                var floatMenuOptions = new List <FloatMenuOption>();
                foreach (var itemOption in item.Options)
                {
                    var menuOptionString = itemToStringFunc == null
                        ? itemOption.ToString(CultureInfo.InvariantCulture)
                        : itemToStringFunc(itemOption);

                    var menuOption = new FloatMenuOption(menuOptionString, delegate { item.Max = itemOption; });
                    floatMenuOptions.Add(menuOption);
                }

                var floatMenu = new FloatMenu(floatMenuOptions, $"{"PLINT_MinMaxFromRestrictedListItemSelect".Translate()} {label}");
                Find.WindowStack.Add(floatMenu);
            }

            var maxValueString = itemToStringFunc == null
                ? item.Min.ToString(CultureInfo.InvariantCulture)
                : itemToStringFunc(item.Max);

            ListingStandard.LabelDouble($"{"PLINT_UsableMinMaxNumFieldMax".Translate()} {label}:", maxValueString);
        }
コード例 #6
0
        private void DoGraphPage(Rect rect)
        {
            rect.yMin += 17f;
            GUI.BeginGroup(rect);
            Rect graphRect  = new Rect(0f, 0f, rect.width, 450f);
            Rect legendRect = new Rect(0f, graphRect.yMax, rect.width / 2f, 40f);
            Rect rect2      = new Rect(0f, legendRect.yMax, rect.width, 40f);

            if (historyAutoRecorderGroup != null)
            {
                marks.Clear();
                List <Tale> allTalesListForReading = Find.TaleManager.AllTalesListForReading;
                for (int i = 0; i < allTalesListForReading.Count; i++)
                {
                    Tale tale = allTalesListForReading[i];
                    if (tale.def.type == TaleType.PermanentHistorical)
                    {
                        float x = (float)GenDate.TickAbsToGame(tale.date) / 60000f;
                        marks.Add(new CurveMark(x, tale.ShortSummary, tale.def.historyGraphColor));
                    }
                }
                historyAutoRecorderGroup.DrawGraph(graphRect, legendRect, graphSection, marks);
            }
            Text.Font = GameFont.Small;
            float num = (float)Find.TickManager.TicksGame / 60000f;

            if (Widgets.ButtonText(new Rect(legendRect.xMin + legendRect.width, legendRect.yMin, 110f, 40f), "Last30Days".Translate()))
            {
                graphSection = new FloatRange(Mathf.Max(0f, num - 30f), num);
                SoundDefOf.Click.PlayOneShotOnCamera();
            }
            if (Widgets.ButtonText(new Rect(legendRect.xMin + legendRect.width + 110f + 4f, legendRect.yMin, 110f, 40f), "Last100Days".Translate()))
            {
                graphSection = new FloatRange(Mathf.Max(0f, num - 100f), num);
                SoundDefOf.Click.PlayOneShotOnCamera();
            }
            if (Widgets.ButtonText(new Rect(legendRect.xMin + legendRect.width + 228f, legendRect.yMin, 110f, 40f), "Last300Days".Translate()))
            {
                graphSection = new FloatRange(Mathf.Max(0f, num - 300f), num);
                SoundDefOf.Click.PlayOneShotOnCamera();
            }
            if (Widgets.ButtonText(new Rect(legendRect.xMin + legendRect.width + 342f, legendRect.yMin, 110f, 40f), "AllDays".Translate()))
            {
                graphSection = new FloatRange(0f, num);
                SoundDefOf.Click.PlayOneShotOnCamera();
            }
            if (Widgets.ButtonText(new Rect(rect2.x, rect2.y, 110f, 40f), "SelectGraph".Translate()))
            {
                List <FloatMenuOption>          list  = new List <FloatMenuOption>();
                List <HistoryAutoRecorderGroup> list2 = Find.History.Groups();
                for (int j = 0; j < list2.Count; j++)
                {
                    HistoryAutoRecorderGroup groupLocal = list2[j];
                    if (!groupLocal.def.devModeOnly || Prefs.DevMode)
                    {
                        list.Add(new FloatMenuOption(groupLocal.def.LabelCap, delegate
                        {
                            historyAutoRecorderGroup = groupLocal;
                        }));
                    }
                }
                FloatMenu window = new FloatMenu(list, "SelectGraph".Translate());
                Find.WindowStack.Add(window);
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.HistoryTab, KnowledgeAmount.Total);
            }
            GUI.EndGroup();
        }
コード例 #7
0
        public void DrawButtons(int x, int y, int length, int size, int set)
        {
            Text.Anchor = TextAnchor.MiddleCenter;
            Text.Font   = GameFont.Tiny;

            if (set == 1)
            {
                for (int i = 0; i < buttons.Count(); i++)
                {
                    if (Widgets.ButtonText(new Rect(x, y + ((size + 10) * i), length, size), buttons[i]))
                    {
                        //If click a button button
                        if (buttons[i] == "UpgradeTown".Translate())
                        {
                            //if click upgrade town button
                            Find.WindowStack.Add(new SettlementUpgradeWindowFc(settlement));
                            //Log.Message(buttons[i]);
                        }

                        if (buttons[i] == "AreYouSureRemove".Translate())
                        {
                            //if click to delete colony
                            Find.WindowStack.TryRemove(this);
                            FactionColonies.removePlayerSettlement(settlement);
                        }

                        if (buttons[i] == "DeleteSettlement".Translate())
                        {
                            //if click town log button
                            //Log.Message(buttons[i]);
                            buttons[i] = "AreYouSureRemove".Translate();
                        }

                        if (buttons[i] == "FCSpecialActions".Translate())
                        {
                            List <FloatMenuOption> list = new List <FloatMenuOption>();
                            //Add to all
                            list.Add(new FloatMenuOption("GoToLocation".Translate(), delegate
                            {
                                Find.WindowStack.TryRemove(this);
                                settlement.goTo();
                            }));


                            if (factionfc.hasPolicy(FCPolicyDefOf.authoritarian))
                            {
                                list.Add(new FloatMenuOption("FCBuyLoyalty".Translate(),
                                                             delegate { Find.WindowStack.Add(new FCWindow_Pay_Silver(settlement)); }));
                            }

                            if (factionfc.hasPolicy(FCPolicyDefOf.egalitarian))
                            {
                                list.Add(new FloatMenuOption("FCGiveTaxBreak".Translate(), delegate
                                {
                                    if (settlement.trait_Egalitarian_TaxBreak_Enabled == false)
                                    {
                                        Find.WindowStack.Add(new FCWindow_Confirm_TaxBreak(settlement));
                                    }
                                    else
                                    {
                                        Messages.Message(
                                            "FCAlreadyGivingTaxBreak".Translate(Math.Round(
                                                                                    (settlement.trait_Egalitarian_TaxBreak_Tick +
                                                                                     GenDate.TicksPerDay * 10 -
                                                                                     Find.TickManager.TicksGame) / (double)GenDate.TicksPerDay, 1)),
                                            MessageTypeDefOf.RejectInput);
                                    }
                                }));
                            }

                            if (list.Count() == 0)
                            {
                                list.Add(new FloatMenuOption("No special actions to take", delegate { }));
                            }
                            Find.WindowStack.Add(new FloatMenu(list));
                        }

                        if (buttons[i] == "PrisonersMenu".Translate())
                        {
                            Find.WindowStack.Add(new FCPrisonerMenu(settlement)); //put prisoner window here.
                        }

                        if (buttons[i] == "Military".Translate())
                        {
                            List <FloatMenuOption> list = new List <FloatMenuOption>();
                            list.Add(new FloatMenuOption(
                                         "ToggleAutoDefend".Translate(settlement.autoDefend.ToString()),
                                         delegate { settlement.autoDefend = !settlement.autoDefend; }));

                            if (settlement.isUnderAttack)
                            {
                                FCEvent evt = MilitaryUtilFC.returnMilitaryEventByLocation(settlement.mapLocation);

                                list.Add(new FloatMenuOption(
                                             "SettlementDefendingInformation".Translate(
                                                 evt.militaryForceDefending.homeSettlement.name,
                                                 evt.militaryForceDefending.militaryLevel), null, MenuOptionPriority.High));
                                list.Add(new FloatMenuOption("ChangeDefendingForce".Translate(), delegate
                                {
                                    List <FloatMenuOption> settlementList = new List <FloatMenuOption>();
                                    SettlementFC homeSettlement           = settlement;

                                    settlementList.Add(new FloatMenuOption(
                                                           "ResetToHomeSettlement".Translate(homeSettlement.settlementMilitaryLevel),
                                                           delegate { MilitaryUtilFC.changeDefendingMilitaryForce(evt, homeSettlement); },
                                                           MenuOptionPriority.High));

                                    foreach (SettlementFC settlement in Find.World.GetComponent <FactionFC>().settlements
                                             )
                                    {
                                        if (settlement.isMilitaryValid() && settlement != homeSettlement)
                                        {
                                            //if military is valid to use.

                                            settlementList.Add(new FloatMenuOption(
                                                                   settlement.name + " " + "ShortMilitary".Translate() + " " +
                                                                   settlement.settlementMilitaryLevel + " - " + "FCAvailable".Translate() +
                                                                   ": " + (!settlement.isMilitaryBusySilent()).ToString(), delegate
                                            {
                                                if (settlement.isMilitaryBusy())
                                                {
                                                    //military is busy
                                                }
                                                else
                                                {
                                                    MilitaryUtilFC.changeDefendingMilitaryForce(evt, settlement);
                                                }
                                            }
                                                                   ));
                                        }
                                    }

                                    if (settlementList.Count == 0)
                                    {
                                        settlementList.Add(new FloatMenuOption("NoValidMilitaries".Translate(), null));
                                    }

                                    FloatMenu floatMenu2 = new FloatMenu(settlementList)
                                    {
                                        vanishIfMouseDistant = true
                                    };
                                    Find.WindowStack.Add(floatMenu2);


                                    //set to raid settlement here
                                }));


                                FloatMenu floatMenu = new FloatMenu(list)
                                {
                                    vanishIfMouseDistant = true
                                };
                                Find.WindowStack.Add(floatMenu);
                            }
                            else
                            {
                                list.Add(new FloatMenuOption("SettlementNotBeingAttacked".Translate(), null));
                                FloatMenu menu = new FloatMenu(list);
                                Find.WindowStack.Add(menu);
                            }
                        }
                    }
                }
            }

            //set two buttons
        }
コード例 #8
0
ファイル: FCBillWindow.cs プロジェクト: BigBadE/Empire-Mod
        public override void DoWindowContents(Rect inRect)
        {
            //grab before anchor/font
            GameFont   fontBefore   = Text.Font;
            TextAnchor anchorBefore = Text.Anchor;

            //top label
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.MiddleCenter;

            //build outline
            Widgets.DrawMenuSection(billsBox);


            //loop through each bill
            //GoTo Here if change
Reset:

            int i = 0;

            Text.Anchor = TextAnchor.MiddleCenter;
            foreach (BillFC bill in bills)
            {
                i++;
                Rect settlement = new Rect();
                Rect date       = new Rect();
                Rect amount     = new Rect();
                Rect tithe      = new Rect();
                Rect resolve    = new Rect();
                Rect highlight  = new Rect();


                settlement = billNameBase;
                date       = billDescBase;
                amount     = billLocationBase;
                tithe      = billTimeRemaining;
                resolve    = billResolveBase;

                settlement.y = scroll + billHeight * i;
                date.y       = scroll + billHeight * i;
                amount.y     = scroll + billHeight * i;
                tithe.y      = scroll + billHeight * i;
                resolve.y    = scroll + billHeight * i;

                highlight = new Rect(settlement.x, settlement.y, resolve.x + resolve.width, billHeight);



                if (i % 2 == 0)
                {
                    Widgets.DrawHighlight(highlight);
                }
                String settlementName;
                if (bill.settlement != null)
                {
                    settlementName = bill.settlement.name;
                }
                else
                {
                    settlementName = "Null";
                }
                if (Widgets.ButtonText(settlement, settlementName))
                {
                    if (bill.settlement != null)
                    {
                        Find.WindowStack.Add(new SettlementWindowFc(bill.settlement));
                    }
                }
                //
                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(date, (bill.dueTick - Find.TickManager.TicksGame).ToStringTicksToDays());

                //
                Widgets.Label(amount, bill.taxes.silverAmount.ToString());
                //
                bool bul;
                bul = (bill.taxes.itemTithes.Count > 0);
                Widgets.Checkbox(new Vector2(tithe.x + tithe.width / 2 - 12, tithe.y), ref bul);

                if (Widgets.ButtonText(resolve, "ResolveBill".Translate()))
                {
                    if (PaymentUtil.getSilver() >= -1 * (bill.taxes.silverAmount) || bill.taxes.silverAmount >= 0)
                    { //if have enough silver on the current map to pay  & map belongs to player
                        FCEventMaker.createTaxEvent(bill);
                        if (bill.taxes.researchCompleted != 0)
                        {
                            faction.researchPointPool += bill.taxes.researchCompleted;
                            Messages.Message("PointsAddedToResearchPool".Translate(bill.taxes.researchCompleted), MessageTypeDefOf.PositiveEvent);
                        }
                        if (bill.taxes.electricityAllotted != 0)
                        {
                            faction.powerPool += bill.taxes.electricityAllotted;
                        }
                        goto Reset;
                    }

                    Messages.Message("NotEnoughSilverOnMapToPayBill".Translate() + "!", MessageTypeDefOf.RejectInput);
                }
            }



            //Top label
            Widgets.ButtonTextSubtle(billNameBase, "Settlement".Translate());
            Widgets.ButtonTextSubtle(billDescBase, "DueFC".Translate());
            Widgets.ButtonTextSubtle(billLocationBase, "Amount".Translate());
            Widgets.ButtonTextSubtle(billTimeRemaining, "HasTithe".Translate());
            if (Widgets.ButtonTextSubtle(billResolveBase, "Auto-Resolve"))
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();

                FloatMenuOption option = new FloatMenuOption("Auto-Resolving : " + faction.autoResolveBills, delegate
                {
                    faction.autoResolveBills = !faction.autoResolveBills;
                    switch (faction.autoResolveBills)
                    {
                    case true:
                        Messages.Message("Bills are now autoresolving!", MessageTypeDefOf.NeutralEvent);
                        PaymentUtil.autoresolveBills(bills);
                        break;

                    case false:
                        Messages.Message("Bills are now not autoresolving.", MessageTypeDefOf.NeutralEvent);
                        break;
                    }
                });
                list.Add(option);


                FloatMenu menu = new FloatMenu(list);
                Find.WindowStack.Add(menu);
            }
            Widgets.Checkbox(new Vector2(billResolveBase.x + billResolveBase.width - 30, billResolveBase.y + 3), ref faction.autoResolveBills, 24, true);

            //Menu Outline
            Widgets.DrawBox(billsBox);


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


            if (Event.current.type == EventType.ScrollWheel)
            {
                scrollWindow(Event.current.delta.y);
            }
        }
コード例 #9
0
        private void PlayerItemMenu(ListBoxPlayerItem item)
        {
            if (item.GroupTitle)
            {
                return;
            }

            var listMenu = new List <FloatMenuOption>();
            var myLogin  = SessionClientController.My.Login;

            ///Личное сообщение
            if (item.Login != myLogin)
            {
                listMenu.Add(new FloatMenuOption("OCity_Dialog_PrivateMessage".Translate(), () =>
                {
                    var privateChat = String.Compare(myLogin, item.Login) < 0
                        ? myLogin + " · " + item.Login
                        : item.Login + " · " + myLogin;
                    var index = lbCannals.DataSource.IndexOf(privateChat);
                    if (index >= 0)
                    {
                        lbCannals.SelectedIndex = index;
                        return;
                    }
                    //создаем канал
                    var mainCannal = SessionClientController.Data.Chats[0];
                    SessionClientController.Command((connect) =>
                    {
                        connect.PostingChat(mainCannal.Id, "/createChat '" + privateChat.Replace("'", "''") + "' '" + item.Login.Replace("'", "''") + "'");
                    });

                    lbCannalsGoToChat = privateChat;
                }));
            }

            ///Добавить участника
            if (lbCannals.SelectedIndex > 0 && SessionClientController.Data.Chats.Count > lbCannals.SelectedIndex)
            {
                var selectCannal = SessionClientController.Data.Chats[lbCannals.SelectedIndex];

                if (!item.InChat)
                {
                    listMenu.Add(new FloatMenuOption("OCity_Dialog_ChennelAddUser".Translate(), () =>
                    {
                        SessionClientController.Command((connect) =>
                        {
                            connect.PostingChat(selectCannal.Id, "/addPlayer '" + item.Login.Replace("'", "''") + "'");
                        });
                    }));
                }
            }

            if (SessionClientController.Data.Players.ContainsKey(item.Login))
            {
                listMenu.Add(new FloatMenuOption("OCity_Dialog_ChennelPlayerInfo".Translate(), () =>
                {
                    var pl       = SessionClientController.Data.Players[item.Login];
                    InfoTabTitle = "OCity_Dialog_ChennelPlayerInfoTitle".Translate() + item.Login;
                    InfoBox.Text = pl.GetTextInfo();
                    TabIndex     = 1;
                }));
            }

            if (listMenu.Count == 0)
            {
                return;
            }
            var menu = new FloatMenu(listMenu);

            Find.WindowStack.Add(menu);
        }
コード例 #10
0
        public void DrawProductionHeaderLower(int x, int y, int spacing)
        {
            Text.Anchor = TextAnchor.MiddleRight;
            Text.Font   = GameFont.Small;

            //Assigned workers
            Widgets.Label(new Rect(x, y, 410, 30),
                          "AssignedWorkers".Translate() + ": " + settlement.getTotalWorkers().ToString() + " / " +
                          settlement.workersMax.ToString() + " / " + settlement.workersUltraMax.ToString());


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

            //Item Headers
            Widgets.DrawHighlight(new Rect(x, y + 30, 40, 40));
            Widgets.Label(new Rect(x, y + 30, 40, 40), "IsTithe".Translate() + "?");

            Widgets.DrawHighlight(new Rect(x + 80, y + 30, 100, 40));
            Widgets.Label(new Rect(x + 80, y + 30, 100, 40), "ProductionEfficiency".Translate());

            Widgets.DrawHighlight(new Rect(x + 195, y + 30, 45, 40));
            Widgets.Label(new Rect(x + 195, y + 30, 45, 40), "Base".Translate());

            Widgets.DrawHighlight(new Rect(x + 250, y + 30, 50, 40));
            Widgets.Label(new Rect(x + 250, y + 30, 50, 40), "Modifier".Translate());

            Widgets.DrawHighlight(new Rect(x + 310, y + 30, 45, 40));
            Widgets.Label(new Rect(x + 310, y + 30, 45, 40), "Final".Translate());

            Widgets.DrawHighlight(new Rect(x + 365, y + 30, 45, 40));
            Widgets.Label(new Rect(x + 365, y + 30, 45, 40), "EstimatedProfit".Translate());

            Widgets.DrawHighlight(new Rect(x + 420, y + 30, 45, 40));
            Widgets.Label(new Rect(x + 420, y + 30, 45, 40), "TaxPercentage".Translate());


            //Per resource
            foreach (ResourceType resourceType in ResourceUtils.resourceTypes)
            {
                ResourceFC resource = settlement.getResource(resourceType);
                if ((int)resourceType * ScrollSpacing + scroll < 0)
                {
                    //if outside view
                }
                else
                {
                    //loop through each resource
                    //isTithe
                    bool disabled = false;
                    switch (resourceType)
                    {
                    case ResourceType.Research:
                    case ResourceType.Power:
                        disabled = true;
                        break;

                    default:
                        if (Widgets.ButtonImage(new Rect(x - 15,
                                                         scroll + y + 65 + (int)resourceType * (45 + spacing) + 8,
                                                         20, 20), TexLoad.iconCustomize))
                        {
                            //if click faction customize button
                            if (resource.filter == null)
                            {
                                resource.filter = new ThingFilter();
                                PaymentUtil.resetThingFilter(settlement, resourceType);
                            }

                            List <FloatMenuOption> options = new List <FloatMenuOption>();
                            options.Add(new FloatMenuOption("Enable All",
                                                            delegate
                            {
                                PaymentUtil.resetThingFilter(settlement, resourceType);
                                resource.returnLowestCost();
                            }));
                            options.Add(new FloatMenuOption("Disable All",
                                                            delegate
                            {
                                resource.filter.SetDisallowAll();
                                resource.returnLowestCost();
                            }));
                            List <ThingDef> things = PaymentUtil.debugGenerateTithe(resourceType);

                            foreach (ThingDef thing in things)
                            {
                                FloatMenuOption option;
                                if (!FactionColonies.canCraftItem(thing))
                                {
                                    resource.filter.SetAllow(thing, false);
                                }
                                else
                                {
                                    option = new FloatMenuOption(thing.LabelCap + " - Cost - "
                                                                 + thing.BaseMarketValue + " | Allowed: " + resource.filter.Allows(thing),
                                                                 delegate
                                    {
                                        resource.filter.SetAllow(thing, !resource.filter.Allows(thing));
                                        resource.returnLowestCost();
                                    }, thing);
                                    options.Add(option);
                                }
                            }

                            FloatMenu menu = new FloatMenu(options);
                            Find.WindowStack.Add(menu);
                            //Log.Message("Settlement customize clicked");
                        }

                        break;
                    }

                    Widgets.Checkbox(new Vector2(x + 8, scroll + y + 65 + (int)resourceType * (45 + spacing) + 8),
                                     ref resource.isTithe, 24, disabled);

                    if (resource.isTithe != resource.isTitheBool)
                    {
                        resource.isTitheBool = resource.isTithe;
                        //Log.Message("changed tithe");
                        settlement.updateProfitAndProduction();
                        windowUpdateFc();
                    }

                    //Icon
                    if (Widgets.ButtonImage(new Rect(x + 45, scroll + y + 75 + (int)resourceType * (45 + spacing),
                                                     30, 30), resource.getIcon()))
                    {
                        Find.WindowStack.Add(new DescWindowFc("SettlementProductionOf".Translate() + ": "
                                                              + resource.label,
                                                              char.ToUpper(resource.label[0])
                                                              + resource.label.Substring(1)));
                    }

                    //Production Efficiency
                    Widgets.DrawBox(new Rect(x + 80, scroll + y + 70 + (int)resourceType * (45 + spacing),
                                             100, 20));
                    Widgets.FillableBar(new Rect(x + 80, scroll + y + 70 + (int)resourceType * (45 + spacing),
                                                 100, 20),
                                        (float)Math.Min(resource.baseProductionMultiplier, 1.0));
                    Widgets.Label(new Rect(x + 80, scroll + y + 90 + (int)resourceType * (45 + spacing),
                                           100, 20),
                                  "Workers".Translate() + ": " + resource.assignedWorkers.ToString());
                    if (Widgets.ButtonText(new Rect(x + 80, scroll + y + 90 + (int)resourceType * (45 + spacing),
                                                    20, 20), "<"))
                    {
                        if (settlement.isUnderAttack)
                        {
                            Messages.Message("SettlementUnderAttack".Translate(), MessageTypeDefOf.RejectInput);
                            return;
                        }
                        //if clicked to lower amount of workers
                        settlement.increaseWorkers(resourceType, -1);
                        windowUpdateFc();
                    }

                    if (Widgets.ButtonText(new Rect(x + 160, scroll + y + 90 + (int)resourceType * (45 + spacing),
                                                    20, 20), ">"))
                    {
                        if (settlement.isUnderAttack)
                        {
                            Messages.Message("SettlementUnderAttack".Translate(), MessageTypeDefOf.RejectInput);
                            return;
                        }
                        //if clicked to lower amount of workers
                        settlement.increaseWorkers(resourceType, 1);
                        windowUpdateFc();
                    }

                    //Base Production
                    Widgets.Label(new Rect(x + 195, scroll + y + 70 + (int)resourceType * (45 + spacing), 45, 40),
                                  FactionColonies.FloorStat(resource.baseProduction));

                    //Final Modifier
                    Widgets.Label(new Rect(x + 250, scroll + y + 70 + (int)resourceType * (45 + spacing), 50, 40),
                                  FactionColonies.FloorStat(resource.endProductionMultiplier));

                    //Final Base
                    Widgets.Label(new Rect(x + 310, scroll + y + 70 + (int)resourceType * (45 + spacing), 45, 40),
                                  (FactionColonies.FloorStat(resource.endProduction)));

                    //Est Income
                    Widgets.Label(new Rect(x + 365, scroll + y + 70 + (int)resourceType * (45 + spacing), 45, 40),
                                  (FactionColonies.FloorStat(resource.endProduction * LoadedModManager
                                                             .GetMod <FactionColoniesMod>().GetSettings <FactionColonies>().silverPerResource)));

                    //Tithe Percentage
                    Widgets.Label(new Rect(x + 420, scroll + y + 70 + (int)resourceType * (45 + spacing), 45, 40),
                                  FactionColonies.FloorStat(resource.taxPercentage) + "%");
                }
            }

            //Scroll window for resources
            if (Event.current.type == EventType.ScrollWheel)
            {
                scrollWindow(Event.current.delta.y);
            }
        }
コード例 #11
0
        private void DrawFactionButtons(int buttonSize)         //Used to draw a list of buttons from the 'buttons' list
        {
            Text.Anchor = TextAnchor.MiddleCenter;
            Text.Font   = GameFont.Small;
            for (int i = 0; i < buttons.Count; i++)
            {
                if (Widgets.ButtonText(new Rect(140, 110 + ((buttonSize + 5) * i), 170, buttonSize), buttons[i]))
                {
                    if (buttons[i] == "FCOverview".Translate())
                    {
                        Find.WindowStack.Add(new FCWindow_Overview());
                    }


                    if (buttons[i] == "Military".Translate())
                    {
                        if (FactionColonies.getPlayerColonyFaction() == null)
                        {
                            Messages.Message(new Message("NoFactionForMilitary".Translate(), MessageTypeDefOf.RejectInput));
                        }
                        else
                        {
                            Find.WindowStack.Add(new MilitaryCustomizationWindowFc());
                        }
                    }

                    if (buttons[i] == "Actions".Translate())
                    {
                        List <FloatMenuOption> list = new List <FloatMenuOption>
                        {
                            new FloatMenuOption("TaxDeliveryMap".Translate(), delegate
                            {
                                List <FloatMenuOption> list2 = new List <FloatMenuOption> {
                                    new FloatMenuOption("SetMap".Translate(), delegate
                                    {
                                        List <FloatMenuOption> settlementList = new List <FloatMenuOption>();

                                        foreach (Map map in Find.Maps)
                                        {
                                            if (map.IsPlayerHome)
                                            {
                                                settlementList.Add(new FloatMenuOption(map.Parent.LabelCap, delegate
                                                {
                                                    faction.taxMap = map;
                                                    Find.LetterStack.ReceiveLetter("Map Set!", "The tax delivery map has been set to the player colony of " + map.Parent.LabelCap + ".\n All taxes and other goods will be delivered there", LetterDefOf.NeutralEvent);
                                                }
                                                                                       ));
                                            }
                                        }

                                        if (settlementList.Count == 0)
                                        {
                                            settlementList.Add(new FloatMenuOption("No valid settlements to use.", null));
                                        }

                                        FloatMenu floatMenu2 = new FloatMenu(settlementList);
                                        Find.WindowStack.Add(floatMenu2);
                                    })
                                };

                                FloatMenu floatMenu = new FloatMenu(list2);
                                Find.WindowStack.Add(floatMenu);
                            }),

                            new FloatMenuOption("SetCapital".Translate(), delegate
                            {
                                faction.setCapital();
                            }),

                            new FloatMenuOption("ActivateResearch".Translate(), delegate
                            {
                                faction.updateDailyResearch();
                            }),

                            new FloatMenuOption("ResearchLevel".Translate(), delegate
                            {
                                Messages.Message("CurrentResearchLevel".Translate(faction.techLevel.ToString(), faction.returnNextTechToLevel()), MessageTypeDefOf.NeutralEvent);
                            }),

                            new FloatMenuOption("FCOpenPatchNotes".Translate(), () => DebugActionsMisc.PatchNotesDisplayWindow())
                        };

                        if (faction.hasPolicy(FCPolicyDefOf.technocratic))
                        {
                            list.Add(new FloatMenuOption("FCSendResearchItems".Translate(), delegate
                            {
                                if (Find.ColonistBar.GetColonistsInOrder().Count > 0)
                                {
                                    Pawn playerNegotiator = Find.ColonistBar.GetColonistsInOrder()[0];
                                    //Log.Message(playerNegotiator.Name + " Negotiator");

                                    FCTrader_Research trader = new FCTrader_Research();

                                    Find.WindowStack.Add(new Dialog_Trade(playerNegotiator, trader));
                                }
                                else
                                {
                                    Log.Error("Couldn't find any colonists to trade with");
                                }
                            }));
                        }

                        if (faction.hasPolicy(FCPolicyDefOf.feudal))
                        {
                            list.Add(new FloatMenuOption("FCRequestMercenary".Translate(), delegate
                            {
                                if (faction.traitFeudalBoolCanUseMercenary)
                                {
                                    faction.traitFeudalBoolCanUseMercenary   = false;
                                    faction.traitFeudalTickLastUsedMercenary = Find.TickManager.TicksGame;

                                    PawnGenerationRequest request        = FCPawnGenerator.WorkerOrMilitaryRequest();
                                    request.ColonistRelationChanceFactor = 20f;
                                    Pawn pawn = PawnGenerator.GeneratePawn(request);

                                    IncidentParms parms = new IncidentParms
                                    {
                                        target  = Find.CurrentMap,
                                        faction = FactionColonies.getPlayerColonyFaction(),
                                        points  = 999,
                                        raidArrivalModeForQuickMilitaryAid = true,
                                        raidNeverFleeIndividual            = true,
                                        raidForceOneIncap = true,
                                        raidArrivalMode   = PawnsArrivalModeDefOf.CenterDrop,
                                        raidStrategy      = RaidStrategyDefOf.ImmediateAttackFriendly
                                    };
                                    parms.raidArrivalModeForQuickMilitaryAid = true;
                                    PawnsArrivalModeWorker_EdgeWalkIn worker = new PawnsArrivalModeWorker_EdgeWalkIn();
                                    worker.TryResolveRaidSpawnCenter(parms);
                                    worker.Arrive(new List <Pawn> {
                                        pawn
                                    }, parms);

                                    Find.LetterStack.ReceiveLetter("FCMercenaryJoined".Translate(), "FCMercenaryJoinedText".Translate(pawn.NameFullColored), LetterDefOf.PositiveEvent, new LookTargets(pawn));
                                    pawn.SetFaction(Faction.OfPlayer);
                                }
                                else
                                {
                                    Messages.Message("FCActionMercenaryOnCooldown".Translate(((faction.traitFeudalTickLastUsedMercenary + GenDate.TicksPerSeason) - Find.TickManager.TicksGame).ToTimeString()), MessageTypeDefOf.RejectInput);
                                }
                            }));
                        }


                        FloatMenu menu = new FloatMenu(list);
                        Find.WindowStack.Add(menu);
                    }
                }
            }
        }
コード例 #12
0
        protected Vector2 DrawResources(float width, List <InventoryRecord> records, Vector2 position, Vector2 iconSize, Vector2 offset, Vector2 slotSize, InventoryPreferences prefs)
        {
            if (this.equipmentAssignmentFloatMenu != null && Find.WindowStack[0] != this.equipmentAssignmentFloatMenu)
            {
                this.equipmentAssignmentFloatMenu = null;
            }
            Vector2 result = new Vector2(position.x, position.y);

            foreach (InventoryRecord current in records)
            {
                if (current.count != 0 || (current.compressedCount != 0 && prefs.CompressedStorage.Value) || (current.unfinishedCount != 0 && prefs.IncludeUnfinished.Value))
                {
                    if (result.x + slotSize.x > width)
                    {
                        result.y += slotSize.y;
                        result.y += InventoryTab.SlotRowPadding;
                        result.x  = InventoryTab.SectionPaddingSides;
                    }
                    if (current.texture != null)
                    {
                        Vector2 vector = new Vector2(0f, 0f);
                        if (current.thingDef.apparel != null && current.thingDef.apparel.LastLayer == ApparelLayer.Overhead)
                        {
                            vector.y += 10f;
                        }
                        Rect rect = new Rect(result.x + offset.x + vector.x, result.y + offset.y + vector.y, iconSize.x, iconSize.y);
                        GUI.color = current.color;
                        if (current.thingDef.building == null)
                        {
                            GUI.DrawTexture(rect, current.thingDef.uiIcon);
                            if (current.availableCount > 0 && this.equipmentAssignmentFloatMenu == null && Widgets.InvisibleButton(rect) && Event.current.button == 1)
                            {
                                List <FloatMenuOption> list = new List <FloatMenuOption>();
                                foreach (Pawn current2 in Find.ListerPawns.FreeColonists)
                                {
                                    if (current2.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
                                    {
                                        InventoryRecord assignedRecord = current;
                                        Pawn            assignedPawn   = current2;
                                        list.Add(new FloatMenuOption(current2.LabelBaseShort, delegate
                                        {
                                            this.AssignEquipmentToPawn(assignedRecord, assignedPawn);
                                        }, MenuOptionPriority.Medium, null, null));
                                    }
                                }
                                this.equipmentAssignmentFloatMenu = new FloatMenu(list, "EdB.Inventory.Equipment.Assign".Translate(), false, false);
                                Find.WindowStack.Add(this.equipmentAssignmentFloatMenu);
                            }
                        }
                        else
                        {
                            if (current.texture == null)
                            {
                                Log.Warning("No texture for building: " + current.thingDef.defName);
                            }
                            Widgets.DrawTextureFitted(rect, current.texture as Texture2D, current.buildingScale, current.proportions, new Rect(0f, 0f, 1f, 1f));
                        }
                        if (this.equipmentAssignmentFloatMenu == null)
                        {
                            string tooltipText = GenLabel.ThingLabel(current.thingDef, current.stuffDef, 1).CapitalizeFirst() + (string.IsNullOrEmpty(current.thingDef.description) ? string.Empty : ("\n\n" + current.thingDef.description));
                            if (current.availableCount > -1)
                            {
                                tooltipText = string.Concat(new string[]
                                {
                                    tooltipText,
                                    "\n\n",
                                    "EdB.Inventory.Equipment.Equipped".Translate(new object[]
                                    {
                                        current.count - current.reservedCount - current.availableCount
                                    }),
                                    "\n",
                                    "EdB.Inventory.Equipment.Reserved".Translate(new object[]
                                    {
                                        current.reservedCount
                                    }),
                                    "\n",
                                    "EdB.Inventory.Equipment.Available".Translate(new object[]
                                    {
                                        current.availableCount
                                    })
                                });
                            }
                            TipSignal tip = new TipSignal(tooltipText, tooltipText.GetHashCode());
                            TooltipHandler.TipRegion(rect, tip);
                        }
                        Text.Anchor = TextAnchor.UpperCenter;
                        GUI.color   = Color.white;
                        Text.Font   = GameFont.Tiny;
                        string label;
                        if (prefs.IncludeUnfinished.Value && current.thingDef.building != null)
                        {
                            label = string.Empty + current.count + ((current.unfinishedCount <= 0) ? string.Empty : (" / " + (current.count + current.unfinishedCount)));
                        }
                        else if (prefs.CompressedStorage.Value && current.compressedCount > 0)
                        {
                            label = string.Concat(new object[]
                            {
                                string.Empty,
                                current.count,
                                " / ",
                                current.count + current.compressedCount
                            });
                        }
                        else
                        {
                            label = string.Empty + current.count;
                        }
                        Widgets.Label(new Rect(result.x, result.y + slotSize.y - InventoryTab.LabelOffset.y, slotSize.x, slotSize.y), label);
                        result.x += slotSize.x;
                    }
                }
            }
            return(result);
        }
コード例 #13
0
        private void DrawThingRow(ref float y, float width, Thing thing)
        {
            Rect   rect = new Rect(36f, y + 2f, width - 38f, 28f);
            string text = thing.LabelCap;

            if (thing is Apparel && this.SelPawnForGear.outfits != null && this.SelPawnForGear.outfits.forcedHandler.IsForced((Apparel)thing))
            {
                text = text + ", " + "ApparelForcedLower".Translate();
            }
            float num = Text.CalcHeight(text, rect.width);

            rect.height = ((num >= 28f) ? num : 28f);
            Rect rect2 = new Rect(0f, y, width, rect.height + 4f);

            if (rect2.Contains(Event.current.mousePosition))
            {
                GUI.color = ITab_Pawn_Gear_Alternate.HighlightColor;
                GUI.DrawTexture(rect2, TexUI.HighlightTex);
            }
            if (Widgets.InvisibleButton(rect2) && Event.current.button == 1)
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                list.Add(new FloatMenuOption("ThingInfo".Translate(), delegate
                {
                    Find.WindowStack.Add(new Dialog_InfoCard(thing));
                }, MenuOptionPriority.Medium, null, null));
                if (this.CanEdit)
                {
                    Action         action = null;
                    ThingWithComps eq     = thing as ThingWithComps;
                    Apparel        ap     = thing as Apparel;
                    if (ap != null)
                    {
                        Apparel unused;
                        action = delegate
                        {
                            this.SelPawnForGear.apparel.TryDrop(ap, out unused, this.SelPawnForGear.Position, true);
                        };
                    }
                    else if (eq != null && this.SelPawnForGear.equipment.AllEquipment.Contains(eq))
                    {
                        ThingWithComps unused;
                        action = delegate
                        {
                            this.SelPawnForGear.equipment.TryDropEquipment(eq, out unused, this.SelPawnForGear.Position, true);
                        };
                    }
                    else if (!thing.def.destroyOnDrop)
                    {
                        Thing unused;
                        action = delegate
                        {
                            this.SelPawnForGear.inventory.container.TryDrop(thing, this.SelPawnForGear.Position, ThingPlaceMode.Near, out unused);
                        };
                    }
                    list.Add(new FloatMenuOption("DropThing".Translate(), action, MenuOptionPriority.Medium, null, null));
                }
                FloatMenu window = new FloatMenu(list, thing.LabelCap, false, false);
                Find.WindowStack.Add(window);
            }
            if (thing.def.DrawMatSingle != null && thing.def.DrawMatSingle.mainTexture != null)
            {
                Widgets.ThingIcon(new Rect(2f, y + 2f, 28f, 28f), thing);
            }
            Text.Anchor = TextAnchor.MiddleLeft;
            GUI.color   = ITab_Pawn_Gear_Alternate.ThingLabelColor;
            rect.y     += 1f;
            Widgets.Label(rect, text);
            y += rect.height + 4f;
        }
コード例 #14
0
        public override void DoWindowContents(Rect inRect)
        {
            //grab before anchor/font
            GameFont   fontBefore   = Text.Font;
            TextAnchor anchorBefore = Text.Anchor;



            //Buildings
            int i = 0;

            foreach (BuildingFCDef building in buildingList)
            {
                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);
                            tmpEvt.def          = FCEventDefOf.constructBuilding;
                            tmpEvt.source       = settlement.mapLocation;
                            tmpEvt.planetName   = settlement.planetName;
                            tmpEvt.building     = building;
                            tmpEvt.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).ToStringTicksToDays(), 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);



                i++;
            }


            //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);
            }
        }
コード例 #15
0
        private void DrawThingRow(ref float y, float width, Thing thing)
        {
            Rect rect = new Rect(0f, y, width, _thingRowHeight);

            Widgets.InfoCardButton(rect.width - 24f, y, thing);
            rect.width -= 24f;
            if (CanControl)
            {
                Rect dropRect = new Rect(rect.width - 24f, y, 24f, 24f);
                TooltipHandler.TipRegion(dropRect, "DropThing".Translate());
                if (Widgets.ButtonImage(dropRect, TexButton.Drop))
                {
                    SoundDefOf.TickHigh.PlayOneShotOnCamera();
                    InterfaceDrop(thing);
                }
                rect.width -= 24f;
            }
            if (this.CanControl && thing.def.IsNutritionGivingIngestible && thing.IngestibleNow && base.SelPawn.RaceProps.CanEverEat(thing))
            {
                Rect rect3 = new Rect(rect.width - 24f, y, 24f, 24f);
                TooltipHandler.TipRegion(rect3, "ConsumeThing".Translate(new object[]
                {
                    thing.LabelNoCount
                }));
                if (Widgets.ButtonImage(rect3, TexButton.Ingest))
                {
                    SoundDefOf.TickHigh.PlayOneShotOnCamera();
                    this.InterfaceEatThis(thing);
                }
                rect.width -= 24f;
            }
            if (Mouse.IsOver(rect))
            {
                GUI.color = _highlightColor;
                GUI.DrawTexture(rect, TexUI.HighlightTex);
            }

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

            if (thing is Apparel && SelPawnForGear.outfits != null && SelPawnForGear.outfits.forcedHandler.IsForced((Apparel)thing))
            {
                thingLabel = thingLabel + ", " + "ApparelForcedLower".Translate();
            }
            Widgets.Label(thingLabelRect, thingLabel);
            y += _thingRowHeight;

            TooltipHandler.TipRegion(thingLabelRect, thing.GetWeightAndBulkTip());
            // RMB menu
            if (Widgets.ButtonInvisible(thingLabelRect) && Event.current.button == 1)
            {
                List <FloatMenuOption> floatOptionList = new List <FloatMenuOption>();
                floatOptionList.Add(new FloatMenuOption("ThingInfo".Translate(), delegate
                {
                    Find.WindowStack.Add(new Dialog_InfoCard(thing));
                }, MenuOptionPriority.Default, null, null));
                if (CanControl)
                {
                    // Equip option
                    ThingWithComps eq = thing as ThingWithComps;
                    if (eq != null && eq.TryGetComp <CompEquippable>() != null)
                    {
                        CompInventory compInventory = SelPawnForGear.TryGetComp <CompInventory>();
                        if (compInventory != null)
                        {
                            FloatMenuOption equipOption;
                            string          eqLabel = GenLabel.ThingLabel(eq.def, eq.Stuff, 1);
                            if (SelPawnForGear.equipment.AllEquipment.Contains(eq) && SelPawnForGear.inventory != null)
                            {
                                equipOption = new FloatMenuOption("CR_PutAway".Translate(new object[] { eqLabel }),
                                                                  new Action(delegate
                                {
                                    ThingWithComps oldEq;
                                    SelPawnForGear.equipment.TryTransferEquipmentToContainer(SelPawnForGear.equipment.Primary, SelPawnForGear.inventory.innerContainer, out oldEq);
                                }));
                            }
                            else if (!SelPawnForGear.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
                            {
                                equipOption = new FloatMenuOption("CannotEquip".Translate(new object[] { eqLabel }), null);
                            }
                            else
                            {
                                string equipOptionLabel = "Equip".Translate(new object[] { eqLabel });
                                if (eq.def.IsRangedWeapon && SelPawnForGear.story != null && SelPawnForGear.story.traits.HasTrait(TraitDefOf.Brawler))
                                {
                                    equipOptionLabel = equipOptionLabel + " " + "EquipWarningBrawler".Translate();
                                }
                                equipOption = new FloatMenuOption(equipOptionLabel, new Action(delegate
                                {
                                    compInventory.TrySwitchToWeapon(eq);
                                }));
                            }
                            floatOptionList.Add(equipOption);
                        }
                    }
                    // Drop option
                    Action dropApparel = delegate
                    {
                        SoundDefOf.TickHigh.PlayOneShotOnCamera();
                        InterfaceDrop(thing);
                    };
                    Action dropApparelHaul = delegate
                    {
                        SoundDefOf.TickHigh.PlayOneShotOnCamera();
                        InterfaceDropHaul(thing);
                    };
                    if (this.CanControl && thing.def.IsNutritionGivingIngestible && thing.IngestibleNow && base.SelPawn.RaceProps.CanEverEat(thing))
                    {
                        Action eatFood = delegate
                        {
                            SoundDefOf.TickHigh.PlayOneShotOnCamera();
                            InterfaceEatThis(thing);
                        };
                        floatOptionList.Add(new FloatMenuOption("CR_Eat".Translate(), eatFood));
                    }
                    floatOptionList.Add(new FloatMenuOption("DropThing".Translate(), dropApparel));
                    floatOptionList.Add(new FloatMenuOption("CR_DropThingHaul".Translate(), dropApparelHaul));
                }
                FloatMenu window = new FloatMenu(floatOptionList, thing.LabelCap, false);
                Find.WindowStack.Add(window);
            }
            // end menu
        }
コード例 #16
0
        private void DrawThingRow(ref float y, float width, Thing thing, bool showDropButtonIfPrisoner = false)
        {
            Rect rect = new Rect(0f, y, width, _thingRowHeight);

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

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

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

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

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

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

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

                                    SelPawnForGear.jobs.TryTakeOrderedJob(JobMaker.MakeJob(JobDefOf.Reload, apparel, thing));
                                })
                                    );
                                floatOptionList.Add(reloadApparelOption);
                            }
                        }
                    }
                    // Consume option
                    if (CanControl && thing.IngestibleNow && base.SelPawn.RaceProps.CanEverEat(thing))
                    {
                        Action eatFood = delegate
                        {
                            SoundDefOf.Tick_High.PlayOneShotOnCamera();
                            InterfaceIngest(thing);
                        };
                        string label = thing.def.ingestible.ingestCommandString.NullOrEmpty() ? (string)"ConsumeThing".Translate(thing.LabelShort, thing) : string.Format(thing.def.ingestible.ingestCommandString, thing.LabelShort);
                        if (SelPawnForGear.IsTeetotaler() && thing.def.IsNonMedicalDrug)
                        {
                            floatOptionList.Add(new FloatMenuOption(label + ": " + TraitDefOf.DrugDesire.degreeDatas.Where(x => x.degree == -1).First()?.label, null));
                        }
                        else
                        {
                            floatOptionList.Add(new FloatMenuOption(label, eatFood));
                        }
                    }
                    // Drop, and drop&haul options
                    if (IsItemDropForbidden(eq))
                    {
                        floatOptionList.Add(new FloatMenuOption("CE_CannotDropThing".Translate() + ": " + "DropThingLocked".Translate(), null));
                        floatOptionList.Add(new FloatMenuOption("CE_CannotDropThingHaul".Translate() + ": " + "DropThingLocked".Translate(), null));
                    }
                    else
                    {
                        floatOptionList.Add(new FloatMenuOption("DropThing".Translate(), new Action(delegate
                        {
                            SoundDefOf.Tick_High.PlayOneShotOnCamera();
                            InterfaceDrop(thing);
                        })));
                        floatOptionList.Add(new FloatMenuOption("CE_DropThingHaul".Translate(), new Action(delegate
                        {
                            SoundDefOf.Tick_High.PlayOneShotOnCamera();
                            InterfaceDropHaul(thing);
                        })));
                    }
                    // Stop holding in inventory option
                    if (CanControl && SelPawnForGear.HoldTrackerIsHeld(thing))
                    {
                        Action forgetHoldTracker = delegate
                        {
                            SoundDefOf.Tick_High.PlayOneShotOnCamera();
                            SelPawnForGear.HoldTrackerForget(thing);
                        };
                        floatOptionList.Add(new FloatMenuOption("CE_HoldTrackerForget".Translate(), forgetHoldTracker));
                    }
                }
                FloatMenu window = new FloatMenu(floatOptionList, thing.LabelCap, false);
                Find.WindowStack.Add(window);
            }
            // end menu
        }
コード例 #17
0
 public static bool IsTracked(FloatMenu fm)
 {
     return(trackedFM.Contains(fm));
 }
コード例 #18
0
ファイル: ITab_Beds.cs プロジェクト: isistoy/DevLib
        private void DrawThingRow(ref float y, float width, Thing thing)
        {
            Rect rect = new Rect(0f, y, width, 28f);
            if (rect.Contains(Event.current.mousePosition))
            {
                GUI.color = ITab_BedContent.HighlightColor;
                GUI.DrawTexture(rect, TexUI.HighlightTex);
            }
            if (Widgets.InvisibleButton(rect) && Event.current.button == 1)
            {
                List<FloatMenuOption> list = new List<FloatMenuOption>();

                if (this.CanEdit)
                {
                    Action action = null;
                    ThingWithComps eq = thing as ThingWithComps;
                    if (eq != null)
                    {
                        action = delegate
                        {
                            DropStuff(eq);
                        };
                    }

                    list.Add(new FloatMenuOption("DropThing".Translate(), action, MenuOptionPriority.Medium, null, null));
                }

                FloatMenu window = new FloatMenu(list, thing.LabelCap, false, false);
                Find.WindowStack.Add(window);

            }
            if (thing.def.DrawMatSingle != null && thing.def.DrawMatSingle.mainTexture != null)
            {
                Widgets.ThingIcon(new Rect(4f, y, 28f, 28f), thing);
            }
            Text.Anchor = TextAnchor.MiddleLeft;
            GUI.color = ITab_BedContent.ThingLabelColor;
            Rect rect2 = new Rect(36f, y, width - 36f, 28f);
            string text = thing.LabelCap;
            Widgets.Label(rect2, text);
            y += 28f;
        }
コード例 #19
0
 public static void Untrack(FloatMenu fm)
 {
     trackedFM.Remove(fm);
 }
コード例 #20
0
        private void DrawBiomeTypesSelection() // TODO : factorize this function with the one from TabTerrain
        {
            DrawEntryHeader("Biome Types", backgroundColor: ColorLibrary.RoyalPurple);

            var biomeDefs = _gameData.DefData.BiomeDefs;

            // "Select" button
            if (ListingStandard.ButtonText("Select Biome"))
            {
                var floatMenuOptions = new List <FloatMenuOption>();

                // add a dummy 'Any' fake biome type. This sets the chosen biome to null.
                Action actionClick = delegate { _gameData.GodModeData.Biome = null; };

                // tool-tip when hovering above the 'Any' biome name on the floating menu
                // TODO: check passed rect
                Action <Rect> mouseOverAction = delegate
                {
                    var mousePos = Event.current.mousePosition;
                    var rect     = new Rect(mousePos.x, mousePos.y, DefaultElementHeight, DefaultElementHeight);

                    TooltipHandler.TipRegion(rect, "Any Biome");
                };
                var menuOption = new FloatMenuOption("Any", actionClick, MenuOptionPriority.Default, mouseOverAction);
                floatMenuOptions.Add(menuOption);

                // loop through all known biomes
                foreach (var currentBiomeDef in biomeDefs)
                {
                    // clicking on the floating menu saves the selected biome
                    actionClick = delegate { _gameData.GodModeData.Biome = currentBiomeDef; };
                    // tool-tip when hovering above the biome name on the floating menu
                    mouseOverAction = delegate
                    {
                        var mousePos = Event.current.mousePosition;
                        var rect     = new Rect(mousePos.x, mousePos.y, DefaultElementHeight, DefaultElementHeight);

                        TooltipHandler.TipRegion(rect, currentBiomeDef.description);
                    };

                    //create the floating menu
                    menuOption = new FloatMenuOption(currentBiomeDef.LabelCap, actionClick, MenuOptionPriority.Default,
                                                     mouseOverAction);
                    // add it to the list of floating menu options
                    floatMenuOptions.Add(menuOption);
                }

                // create the floating menu
                var floatMenu = new FloatMenu(floatMenuOptions, "Select Biome Type");

                // add it to the window stack to display it
                Find.WindowStack.Add(floatMenu);
            }

            var currHeightBefore = ListingStandard.CurHeight;

            var rightLabel = _gameData.GodModeData.Biome != null ? (string)_gameData.GodModeData.Biome.LabelCap : "Any";

            ListingStandard.LabelDouble("Biome:", rightLabel);

            var currHeightAfter = ListingStandard.CurHeight;

            // display tool-tip over label
            if (_gameData.GodModeData.Biome != null)
            {
                var currentRect = ListingStandard.GetRect(0f);
                currentRect.height = currHeightAfter - currHeightBefore;
                if (!string.IsNullOrEmpty(_gameData.GodModeData.Biome.description))
                {
                    TooltipHandler.TipRegion(currentRect, _gameData.GodModeData.Biome.description);
                }
            }
        }
コード例 #21
0
 private static void Postfix(FloatMenuOption __instance, bool colonistOrdering, FloatMenu floatMenu)
 {
     if (__instance.Label == "GoDown".Translate() || __instance.Label == "GoUP".Translate())
     {
         if (Find.Selector.SelectedObjects.Where(x => x is Pawn).Count() > 1)
         {
             Thing thing;
             foreach (var pawn in Find.Selector.SelectedObjects.Where(x => x is Pawn))
             {
                 if (__instance.Label == "GoDown".Translate())
                 {
                     thing = GenClosest.ClosestThing_Global_Reachable(UI.MouseMapPosition().ToIntVec3()
                                                                      , ((Pawn)pawn).Map, ((Pawn)pawn).Map.listerThings.AllThings
                                                                      .Where(x => x is Building_StairsDown), PathEndMode.OnCell,
                                                                      TraverseParms.For(TraverseMode.ByPawn, Danger.Deadly, false), 9999f);
                     Job job = JobMaker.MakeJob(ZLevelsDefOf.ZL_GoToStairs, thing);
                     ((Pawn)pawn).jobs.StartJob(job, JobCondition.InterruptForced);
                 }
                 else
                 {
                     thing = GenClosest.ClosestThing_Global_Reachable(UI.MouseMapPosition().ToIntVec3()
                                                                      , ((Pawn)pawn).Map, ((Pawn)pawn).Map.listerThings.AllThings
                                                                      .Where(x => x is Building_StairsUp), PathEndMode.OnCell,
                                                                      TraverseParms.For(TraverseMode.ByPawn, Danger.Deadly, false), 9999f);
                     Job job = JobMaker.MakeJob(ZLevelsDefOf.ZL_GoToStairs, thing);
                     ((Pawn)pawn).jobs.StartJob(job, JobCondition.InterruptForced);
                 }
             }
             ZLogger.Message("Choosen");
         }
     }
 }
コード例 #22
0
        public static void QEE_BuildingPawnVatGrower_GetGizmosPostfix(ref IEnumerable <Gizmo> __result, Building __instance)
        {
            try
            {
                //Affichage controles que VAT en mode idle
                int status = (int)Traverse.Create(__instance).Field("status").GetValue();

                if (status != 0)
                {
                    return;
                }

                List <Gizmo> ret = new List <Gizmo>();


                string BUID = __instance.GetUniqueLoadID();

                QEE_CheckInitData(__instance);


                HairDef ch = DefDatabase <HairDef> .GetNamed(Utils.GCATPP.QEEAndroidHair[BUID], false);

                Color    hairColor = Utils.getHairColor(Utils.GCATPP.QEEAndroidHairColor[BUID]);
                Material baseMat   = GraphicDatabase.Get <Graphic_Multi>(ch.texPath, ShaderDatabase.Cutout, Vector2.one, hairColor).MatAt(Rot4.South);

                Gizmo b = new Command_Action()
                {
                    defaultLabel = ch.LabelCap,
                    defaultDesc  = "",
                    icon         = (Texture2D)baseMat.mainTexture,
                    action       = delegate()
                    {
                        List <FloatMenuOption> opts = new List <FloatMenuOption>();
                        FloatMenu floatMenuMap;

                        foreach (var h in DefDatabase <HairDef> .AllDefs)
                        {
                            opts.Add(new FloatMenuOption(h.LabelCap, delegate()
                            {
                                Utils.GCATPP.QEEAndroidHair[BUID] = h.defName;
                            }));
                        }
                        opts.SortBy((x) => x.Label);

                        floatMenuMap = new FloatMenu(opts, "");
                        Find.WindowStack.Add(floatMenuMap);
                    }
                };

                ret.Add(b);

                b = new Command_Action()
                {
                    defaultLabel = ("ATPP_HairColor".Translate()) + " : " + ("ATPP_HairColor" + Utils.GCATPP.QEEAndroidHairColor[BUID].CapitalizeFirst()).Translate(),
                    defaultDesc  = "",
                    icon         = Tex.ColorPicker,
                    action       = delegate()
                    {
                        List <FloatMenuOption> opts = new List <FloatMenuOption>();
                        FloatMenu floatMenuMap;

                        foreach (var h in Utils.ExceptionHairColors)
                        {
                            opts.Add(new FloatMenuOption(("ATPP_HairColor" + h).Translate(), delegate()
                            {
                                Utils.GCATPP.QEEAndroidHairColor[BUID] = h.ToLower();
                            }));
                        }
                        opts.SortBy((x) => x.Label);

                        floatMenuMap = new FloatMenu(opts, "");
                        Find.WindowStack.Add(floatMenuMap);
                    }
                };

                ret.Add(b);

                b = new Command_Action()
                {
                    defaultLabel = ("ATPP_SkinColor".Translate()) + " : " + ("ATPP_SkinColor" + Utils.GCATPP.QEESkinColor[BUID].CapitalizeFirst()).Translate(),
                    defaultDesc  = "",
                    icon         = Tex.ColorPicker,
                    action       = delegate()
                    {
                        List <FloatMenuOption> opts = new List <FloatMenuOption>();
                        FloatMenu floatMenuMap;

                        foreach (var h in Utils.ExceptionSkinColors)
                        {
                            opts.Add(new FloatMenuOption(("ATPP_SkinColor" + h).Translate(), delegate()
                            {
                                Utils.GCATPP.QEESkinColor[BUID] = h.ToLower();
                            }));
                        }
                        opts.SortBy((x) => x.Label);

                        floatMenuMap = new FloatMenu(opts, "");
                        Find.WindowStack.Add(floatMenuMap);
                    }
                };

                ret.Add(b);

                if (__result != null)
                {
                    __result = __result.Concat(ret);
                }
            }
            catch (Exception e)
            {
                Log.Message("[ATPP] QEE_BuildingPawnVatGrower_GetGizmosPostfix " + e.Message + " " + e.StackTrace);
            }
        }
コード例 #23
0
        private void DrawThingRow(ref float y, float width, Thing thing, bool showDropButtonIfPrisoner = false)
        {
            Rect rect = new Rect(0f, y, width, _thingRowHeight);

            Widgets.InfoCardButton(rect.width - 24f, y, thing);
            rect.width -= 24f;
            if (CanControl || (SelPawnForGear.Faction == Faction.OfPlayer && SelPawnForGear.RaceProps.packAnimal) || (showDropButtonIfPrisoner && SelPawnForGear.IsPrisonerOfColony))
            {
                Rect dropRect = new Rect(rect.width - 24f, y, 24f, 24f);
                TooltipHandler.TipRegion(dropRect, "DropThing".Translate());
                if (Widgets.ButtonImage(dropRect, TexButton.Drop))
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera();
                    InterfaceDrop(thing);
                }
                rect.width -= 24f;
            }
            if (CanControlColonist)
            {
                if ((thing.def.IsNutritionGivingIngestible || thing.def.IsNonMedicalDrug) && thing.IngestibleNow && base.SelPawn.WillEat(thing, null))
                {
                    Rect rect3 = new Rect(rect.width - 24f, y, 24f, 24f);
                    TooltipHandler.TipRegion(rect3, "ConsumeThing".Translate(thing.LabelNoCount, thing));
                    if (Widgets.ButtonImage(rect3, TexButton.Ingest))
                    {
                        SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                        InterfaceIngest(thing);
                    }
                }
                rect.width -= 24f;
            }
            Rect rect4 = rect;

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

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

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

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

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

            // RMB menu
            if (Widgets.ButtonInvisible(thingLabelRect) && Event.current.button == 1)
            {
                List <FloatMenuOption> floatOptionList = new List <FloatMenuOption>();
                floatOptionList.Add(new FloatMenuOption("ThingInfo".Translate(), delegate
                {
                    Find.WindowStack.Add(new Dialog_InfoCard(thing));
                }, MenuOptionPriority.Default, null, null));
                if (CanControl)
                {
                    // Equip option
                    ThingWithComps eq = thing as ThingWithComps;
                    if (eq != null && eq.TryGetComp <CompEquippable>() != null)
                    {
                        CompInventory compInventory = SelPawnForGear.TryGetComp <CompInventory>();
                        if (compInventory != null)
                        {
                            FloatMenuOption equipOption;
                            string          eqLabel = GenLabel.ThingLabel(eq.def, eq.Stuff, 1);
                            if (SelPawnForGear.equipment.AllEquipmentListForReading.Contains(eq) && SelPawnForGear.inventory != null)
                            {
                                equipOption = new FloatMenuOption("CE_PutAway".Translate(eqLabel),
                                                                  new Action(delegate
                                {
                                    SelPawnForGear.equipment.TryTransferEquipmentToContainer(SelPawnForGear.equipment.Primary, SelPawnForGear.inventory.innerContainer);
                                }));
                            }
                            else if (!SelPawnForGear.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
                            {
                                equipOption = new FloatMenuOption("CannotEquip".Translate(eqLabel), null);
                            }
                            else
                            {
                                string equipOptionLabel = "Equip".Translate(eqLabel);
                                if (eq.def.IsRangedWeapon && SelPawnForGear.story != null && SelPawnForGear.story.traits.HasTrait(TraitDefOf.Brawler))
                                {
                                    equipOptionLabel = equipOptionLabel + " " + "EquipWarningBrawler".Translate();
                                }
                                equipOption = new FloatMenuOption(
                                    equipOptionLabel,
                                    (SelPawnForGear.story != null && SelPawnForGear.WorkTagIsDisabled(WorkTags.Violent))
                                    ? null
                                    : new Action(delegate
                                {
                                    compInventory.TrySwitchToWeapon(eq);
                                }));
                            }
                            floatOptionList.Add(equipOption);
                        }
                    }
                    // Drop option
                    Action dropApparel = delegate
                    {
                        SoundDefOf.Tick_High.PlayOneShotOnCamera();
                        InterfaceDrop(thing);
                    };
                    Action dropApparelHaul = delegate
                    {
                        SoundDefOf.Tick_High.PlayOneShotOnCamera();
                        InterfaceDropHaul(thing);
                    };
                    if (CanControl && thing.IngestibleNow && base.SelPawn.RaceProps.CanEverEat(thing))
                    {
                        Action eatFood = delegate
                        {
                            SoundDefOf.Tick_High.PlayOneShotOnCamera();
                            InterfaceIngest(thing);
                        };
                        string label = thing.def.ingestible.ingestCommandString.NullOrEmpty() ? (string)"ConsumeThing".Translate(thing.LabelShort, thing) : string.Format(thing.def.ingestible.ingestCommandString, thing.LabelShort);
                        floatOptionList.Add(new FloatMenuOption(label, eatFood));
                    }
                    floatOptionList.Add(new FloatMenuOption("DropThing".Translate(), dropApparel));
                    floatOptionList.Add(new FloatMenuOption("CE_DropThingHaul".Translate(), dropApparelHaul));
                    if (CanControl && SelPawnForGear.HoldTrackerIsHeld(thing))
                    {
                        Action forgetHoldTracker = delegate
                        {
                            SoundDefOf.Tick_High.PlayOneShotOnCamera();
                            SelPawnForGear.HoldTrackerForget(thing);
                        };
                        floatOptionList.Add(new FloatMenuOption("CE_HoldTrackerForget".Translate(), forgetHoldTracker));
                    }
                }
                FloatMenu window = new FloatMenu(floatOptionList, thing.LabelCap, false);
                Find.WindowStack.Add(window);
            }
            // end menu
        }
コード例 #24
0
ファイル: KListObject.cs プロジェクト: SteaNN/Hardcore-SK
 private void DrawThing(Rect rect, Thing thing, Pawn selPawn)
 {
     
     if (Mouse.IsOver(rect))
     {
         GUI.color = HighlightColor;
         GUI.DrawTexture(rect, TexUI.HighlightTex);
     }
     if (Widgets.ButtonInvisible(rect) && Event.current.button == 1)
     {
         List<FloatMenuOption> list = new List<FloatMenuOption>();
         list.Add(new FloatMenuOption("ThingInfo".Translate(), delegate
         {
             Find.WindowStack.Add(new Dialog_InfoCard(thing));
         }, MenuOptionPriority.Medium, null, null));
         if (selPawn.IsColonistPlayerControlled)
         {
             Action action = null;
             ThingWithComps eq = thing as ThingWithComps;
             Apparel ap = thing as Apparel;
             if (ap != null)
             {
                 Apparel unused;
                 action = delegate
                 {
                     selPawn.apparel.TryDrop(ap, out unused, selPawn.Position, true);
                 };
             }
             else if (eq != null && selPawn.equipment.AllEquipment.Contains(eq))
             {
                 ThingWithComps unused;
                 action = delegate
                 {
                     selPawn.equipment.TryDropEquipment(eq, out unused, selPawn.Position, true);
                 };
             }
             else if (!thing.def.destroyOnDrop)
             {
                 Thing unused;
                 action = delegate
                 {
                     selPawn.inventory.container.TryDrop(thing, selPawn.Position, ThingPlaceMode.Near, out unused);
                 };
             }
             list.Add(new FloatMenuOption("DropThing".Translate(), action, MenuOptionPriority.Medium, null, null));
         }
         FloatMenu window = new FloatMenu(list, thing.LabelCap, false);
         Find.WindowStack.Add(window);
     }
     GUI.BeginGroup(rect);
     if (thing.def.DrawMatSingle != null && thing.def.DrawMatSingle.mainTexture != null)
     {
         Widgets.ThingIcon(new Rect(3f, 3f, 27f, 27f), thing);
     }
     GUI.EndGroup();
     TooltipHandler.TipRegion(rect, new TipSignal(thing.LabelCap));
 }
コード例 #25
0
ファイル: QuarryMod.cs プロジェクト: mesmorizer/Quarry
        public override void DoSettingsWindowContents(Rect rect)
        {
            Listing_Standard list = new Listing_Standard()
            {
                ColumnWidth = rect.width
            };

            list.Begin(rect);
            list.Gap(10);
            {
                Rect fullRect  = list.GetRect(Text.LineHeight);
                Rect leftRect  = fullRect.LeftHalf().Rounded();
                Rect rightRect = fullRect.RightHalf().Rounded();

                if (QuarrySettings.quarryMaxHealth <= 10000)
                {
                    Widgets.Label(leftRect, "QRY_DepletionLabel".Translate(QuarrySettings.quarryMaxHealth.ToString("N0")));
                }
                else
                {
                    Widgets.Label(leftRect, "QRY_DepletionLabel".Translate("Infinite"));
                }

                //Increment timer value by -100 (button).
                if (Widgets.ButtonText(new Rect(rightRect.xMin, rightRect.y, rightRect.height, rightRect.height), "-", true, false, true))
                {
                    if (QuarrySettings.quarryMaxHealth >= 200)
                    {
                        QuarrySettings.quarryMaxHealth -= 100;
                    }
                }

                QuarrySettings.quarryMaxHealth = Widgets.HorizontalSlider(
                    new Rect(rightRect.xMin + rightRect.height + 10f, rightRect.y, rightRect.width - ((rightRect.height * 2) + 20f), rightRect.height),
                    QuarrySettings.quarryMaxHealth, 100f, 10100f, true).RoundToAsInt(100);

                //Increment timer value by +100 (button).
                if (Widgets.ButtonText(new Rect(rightRect.xMax - rightRect.height, rightRect.y, rightRect.height, rightRect.height), "+", true, false, true))
                {
                    if (QuarrySettings.quarryMaxHealth < 10100)
                    {
                        QuarrySettings.quarryMaxHealth += 100;
                    }
                }

                list.Gap(25);

                {
                    Rect letterRect = list.GetRect(Text.LineHeight).LeftHalf().Rounded();

                    Widgets.CheckboxLabeled(letterRect, Static.LetterSent, ref QuarrySettings.letterSent);
                    if (Mouse.IsOver(letterRect))
                    {
                        Widgets.DrawHighlight(letterRect);
                    }
                    TooltipHandler.TipRegion(letterRect, Static.ToolTipLetter);
                }

                list.Gap(25);

                {
                    Rect junkRect         = list.GetRect(Text.LineHeight).LeftHalf().Rounded();
                    Rect junkSliderOffset = junkRect.RightHalf().Rounded().RightPartPixels(200);

                    Widgets.Label(junkRect, "QRY_SettingsJunkChance".Translate(QuarrySettings.junkChance));
                    QuarrySettings.junkChance = Widgets.HorizontalSlider(
                        junkSliderOffset,
                        QuarrySettings.junkChance, 0f, 100f, true).RoundToAsInt(5);
                    if (Mouse.IsOver(junkRect))
                    {
                        Widgets.DrawHighlight(junkRect);
                    }
                    TooltipHandler.TipRegion(junkRect, Static.ToolTipJunkChance);
                }

                list.Gap(25);

                {
                    Rect chunkRect         = list.GetRect(Text.LineHeight).LeftHalf().Rounded();
                    Rect chunkSliderOffset = chunkRect.RightHalf().Rounded().RightPartPixels(200);

                    Widgets.Label(chunkRect, "QRY_SettingsChunkChance".Translate(QuarrySettings.chunkChance));
                    QuarrySettings.chunkChance = Widgets.HorizontalSlider(
                        chunkSliderOffset,
                        QuarrySettings.chunkChance, 0f, 100f, true).RoundToAsInt(5);
                    if (Mouse.IsOver(chunkRect))
                    {
                        Widgets.DrawHighlight(chunkRect);
                    }
                    TooltipHandler.TipRegion(chunkRect, Static.ToolTipChunkChance);
                }

                list.Gap(15);
                {
                    Rect labelRect = list.GetRect(32).Rounded();
                    Text.Font   = GameFont.Medium;
                    Text.Anchor = TextAnchor.MiddleCenter;
                    Widgets.Label(labelRect, Static.LabelDictionary);
                    Text.Font   = GameFont.Small;
                    Text.Anchor = TextAnchor.UpperLeft;
                }
                list.Gap(1);

                {
                    Rect buttonsRect = list.GetRect(Text.LineHeight).Rounded();
                    Rect addRect     = buttonsRect.LeftThird();
                    Rect rmvRect     = buttonsRect.MiddleThird();
                    Rect resRect     = buttonsRect.RightThird();

                    // Add an entry to the dictionary
                    if (Widgets.ButtonText(addRect, Static.LabelAddThing))
                    {
                        List <FloatMenuOption> thingList = new List <FloatMenuOption>();
                        foreach (ThingDef current in from t in QuarryUtility.PossibleThingDefs()
                                 orderby t.label
                                 select t)
                        {
                            bool skip = false;
                            for (int i = 0; i < QuarrySettings.oreDictionary.Count; i++)
                            {
                                if (QuarrySettings.oreDictionary[i].thingDef == current)
                                {
                                    skip = true;
                                    break;
                                }
                            }
                            ;
                            if (skip)
                            {
                                continue;
                            }

                            thingList.Add(new FloatMenuOption(current.LabelCap, delegate {
                                QuarrySettings.oreDictionary.Add(new ThingCountExposable(current, 1));
                            }));
                        }
                        FloatMenu menu = new FloatMenu(thingList);
                        Find.WindowStack.Add(menu);
                    }

                    // Remove an entry from the dictionary
                    if (Widgets.ButtonText(rmvRect, Static.LabelRemoveThing) && QuarrySettings.oreDictionary.Count >= 2)
                    {
                        List <FloatMenuOption> thingList = new List <FloatMenuOption>();
                        foreach (ThingCountExposable current in from t in QuarrySettings.oreDictionary
                                 orderby t.thingDef.label
                                 select t)
                        {
                            ThingDef localTd = current.thingDef;
                            thingList.Add(new FloatMenuOption(localTd.LabelCap, delegate {
                                for (int i = 0; i < QuarrySettings.oreDictionary.Count; i++)
                                {
                                    if (QuarrySettings.oreDictionary[i].thingDef == localTd)
                                    {
                                        QuarrySettings.oreDictionary.Remove(QuarrySettings.oreDictionary[i]);
                                        break;
                                    }
                                }
                                ;
                            }));
                        }
                        FloatMenu menu = new FloatMenu(thingList);
                        Find.WindowStack.Add(menu);
                    }

                    // Reset the dictionary
                    if (Widgets.ButtonText(resRect, Static.LabelResetList))
                    {
                        OreDictionary.Build();
                    }
                }

                list.Gap(5);
                {
                    Rect listRect = list.GetRect(300f).Rounded();
                    Rect cRect    = listRect.ContractedBy(10f);
                    Rect position = new Rect(cRect.x, cRect.y, cRect.width, cRect.height);
                    Rect outRect  = new Rect(0f, 0f, position.width, position.height);
                    Rect viewRect = new Rect(0f, 0f, position.width - 16f, scrollViewHeight);

                    float num = 0f;
                    List <ThingCountExposable> dict = new List <ThingCountExposable>(QuarrySettings.oreDictionary);

                    GUI.BeginGroup(position);
                    Widgets.BeginScrollView(outRect, ref scrollPosition, viewRect, true);

                    foreach (var tc in dict.Select((value, index) => new { index, value }))
                    {
                        Rect entryRect    = new Rect(0f, num, viewRect.width, 32);
                        Rect iconRect     = entryRect.LeftPartPixels(32);
                        Rect labelRect    = new Rect(entryRect.LeftThird().x + 33f, entryRect.y, entryRect.LeftThird().width - 33f, entryRect.height);
                        Rect texEntryRect = new Rect(entryRect.LeftHalf().RightPartPixels(103).x, entryRect.y, 60f, entryRect.height);
                        Rect pctRect      = new Rect(entryRect.LeftHalf().RightPartPixels(41).x, entryRect.y, 40f, entryRect.height);
                        Rect sliderRect   = new Rect(entryRect.RightHalf().x, entryRect.y, entryRect.RightHalf().width, entryRect.height);

                        Widgets.ThingIcon(iconRect, tc.value.thingDef);
                        Widgets.Label(labelRect, tc.value.thingDef.LabelCap);
                        Widgets.Label(pctRect, $"{QuarrySettings.oreDictionary.WeightAsPercentageOf(tc.value.count).ToStringDecimal()}%");
                        int    val        = tc.value.count;
                        string nullString = null;
                        Widgets.TextFieldNumeric(
                            texEntryRect,
                            ref QuarrySettings.oreDictionary[tc.index].count,
                            ref nullString,
                            0, OreDictionary.MaxWeight);
                        val = Widgets.HorizontalSlider(
                            sliderRect,
                            QuarrySettings.oreDictionary[tc.index].count, 0f, OreDictionary.MaxWeight, true
                            ).RoundToAsInt(1);
                        if (val != QuarrySettings.oreDictionary[tc.index].count)
                        {
                            QuarrySettings.oreDictionary[tc.index].count = val;
                        }

                        if (Mouse.IsOver(entryRect))
                        {
                            Widgets.DrawHighlight(entryRect);
                        }
                        TooltipHandler.TipRegion(entryRect.LeftThird(), tc.value.thingDef.description);

                        num += 32f;
                        scrollViewHeight = num;
                    }

                    Widgets.EndScrollView();
                    GUI.EndGroup();
                }

                list.End();
            }
        }