public void Draw(Rect inrect, GeneralInformation?currentInformation)
        {
            if (currentInformation == null)
            {
                return;
            }
            inrect = inrect.ContractedBy(4);

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

            x = 0;

            var viewrect = inrect;

            viewrect.x     += 10;
            viewrect.width -= 28;
            viewrect.height = y;

            var row = viewrect;

            row.height = 40;
            row.width  = Mathf.Max(x, viewrect.width);

            Widgets.BeginScrollView(inrect, ref scroll, viewrect);

            foreach (var patch in currentInformation?.patches)
            {
                var meth = $"{patch.typeName} : {patch.methodName}";
                row.width = meth.GetWidthCached();

                if (row.width > x)
                {
                    x = row.width;
                }

                Widgets.Label(row, meth);

                Widgets.DrawHighlightIfMouseover(row);

                if (Mouse.IsOver(row))
                {
                    TooltipHandler.TipRegion(row, $"{Strings.panel_mod_name}: {patch.modName}\n{Strings.panel_patch_type}: {patch.patchType}");
                }

                if (Input.GetMouseButtonDown(1) && row.Contains(Event.current.mousePosition)) // mouse button right
                {
                    var options = new List <FloatMenuOption>()
                    {
                        new FloatMenuOption(Strings.panel_opengithub, () => Panel_BottomRow.OpenGithub($"{patch.typeName}.{patch.methodName}")),
                        new FloatMenuOption(Strings.panel_opendnspy, () => Panel_BottomRow.OpenDnspy(patch.method))
                    };

                    Find.WindowStack.Add(new FloatMenu(options));
                }

                row.y = row.yMax;

                y = row.yMax;
            }

            Widgets.EndScrollView();

            DubGUI.ResetFont();
        }
Exemple #2
0
        public override void DoWindowContents(Rect inRect)
        {
            Text.Font = GameFont.Small;

            Widgets.Label(new Rect(inRect.center.x - 60, 0, 250, 20), Translator.Translate("FactionCreatorTitle"));
            WidgetRow row = new WidgetRow(330, 25);

            if (row.ButtonText(Translator.Translate("RandomizeFaction")))
            {
                newFaction = GenerateFaction();
            }
            if (row.ButtonText(Translator.Translate("RandomizeName")))
            {
                GenerateName(newFaction);
            }
            if (row.ButtonText(Translator.Translate("ClearFaction")))
            {
                newFaction      = null;
                selectedFaction = null;
            }

            int  factionDefSize     = avaliableFactions.Count * 25;
            Rect scrollRectFact     = new Rect(0, 25, 320, inRect.height - 100);
            Rect scrollVertRectFact = new Rect(0, 0, scrollRectFact.x, factionDefSize);

            Widgets.BeginScrollView(scrollRectFact, ref scrollPositionFact, scrollVertRectFact);

            int yButtonPos = 5;

            if (Widgets.ButtonText(new Rect(0, yButtonPos, 320, 20), Translator.Translate("NoText")))
            {
                selectedFaction = null;
            }
            yButtonPos += 25;
            foreach (FactionDef def in avaliableFactions)
            {
                if (Widgets.ButtonText(new Rect(0, yButtonPos, 320, 20), def.label))
                {
                    selectedFaction = def;

                    if (newFaction == null)
                    {
                        newFaction = GenerateFaction();
                    }
                }
                yButtonPos += 22;
            }
            Widgets.EndScrollView();

            Rect scrollRectGlobalFact     = new Rect(330, 50, 380, inRect.height - 20);
            Rect scrollVertRectGlobalFact = new Rect(0, 0, scrollRectGlobalFact.x, 600);

            Widgets.BeginScrollView(scrollRectGlobalFact, ref scrollFieldsPos, scrollVertRectGlobalFact);
            if (newFaction != null)
            {
                Widgets.Label(new Rect(0, 5, 330, 30), $"{Translator.Translate("FactionDefName")} {selectedFaction.label}");

                Widgets.Label(new Rect(0, 35, 150, 30), Translator.Translate("FactionName"));
                newFaction.Name = Widgets.TextField(new Rect(160, 35, 180, 30), newFaction.Name);

                Widgets.Label(new Rect(0, 73, 150, 30), Translator.Translate("FactionDefeated"));
                if (newFaction.defeated)
                {
                    if (Widgets.ButtonText(new Rect(160, 73, 180, 30), Translator.Translate("isDefeatedYES")))
                    {
                        newFaction.defeated = false;
                    }
                }
                else
                {
                    if (Widgets.ButtonText(new Rect(160, 73, 180, 30), Translator.Translate("isDefeatedNO")))
                    {
                        newFaction.defeated = true;
                    }
                }

                Widgets.Label(new Rect(0, 105, 180, 30), Translator.Translate("FactionRelative"));
                int  y                 = 15;
                int  boxY              = 5;
                Rect scrollRectRel     = new Rect(0, 130, 370, 160);
                Rect scrollVertRectRel = new Rect(0, 0, scrollRectRel.x, newFactionRelation.Count * 140);
                Widgets.DrawBox(new Rect(0, 130, 350, 160));
                Widgets.BeginScrollView(scrollRectRel, ref scrollRel, scrollVertRectRel);
                for (int i = 0; i < newFactionRelation.Count; i++)
                {
                    FactionRelation rel = newFactionRelation[i];

                    Widgets.DrawBox(new Rect(2, boxY, 340, 130));

                    Widgets.Label(new Rect(5, y, 315, 30), $"{Translator.Translate("FactionInfoName")} {rel.other.Name}");

                    y += 35;
                    Widgets.Label(new Rect(5, y, 140, 30), Translator.Translate("FactionGoodness"));
                    Widgets.TextFieldNumeric(new Rect(150, y, 130, 30), ref rel.goodwill, ref newFactionGoodwillBuff[i], -10000000000f);

                    y += 35;
                    switch (rel.kind)
                    {
                    case FactionRelationKind.Ally:
                    {
                        if (Widgets.ButtonText(new Rect(5, y, 180, 30), rel.kind.GetLabel()))
                        {
                            rel.kind = FactionRelationKind.Neutral;
                        }
                        break;
                    }

                    case FactionRelationKind.Neutral:
                    {
                        if (Widgets.ButtonText(new Rect(5, y, 180, 30), rel.kind.GetLabel()))
                        {
                            rel.kind = FactionRelationKind.Hostile;
                        }
                        break;
                    }

                    case FactionRelationKind.Hostile:
                    {
                        if (Widgets.ButtonText(new Rect(5, y, 180, 30), rel.kind.GetLabel()))
                        {
                            rel.kind = FactionRelationKind.Ally;
                        }
                        break;
                    }
                    }

                    boxY += 140;
                    y     = boxY + 10;
                }
                Widgets.EndScrollView();

                Widgets.Label(new Rect(0, 315, 180, 30), Translator.Translate("FactionIcon"));
                Widgets.DrawTextureFitted(new Rect(195, 315, 160, 30), selectedFaction.FactionIcon, 1.0f);
                //float.TryParse(Widgets.TextField(new Rect(195, 315, 160, 30), newFaction.centralMelanin.ToString()), out newFaction.centralMelanin);

                Widgets.Label(new Rect(0, 360, 160, 30), Translator.Translate("ColorSpectrum"));
                Widgets.FloatRange(new Rect(195, 360, 130, 30), 42, ref color, 0, 1);
                if (newFaction.def.colorSpectrum != null)
                {
                    Widgets.DrawBoxSolid(new Rect(165, 360, 20, 20), ColorsFromSpectrum.Get(newFaction.def.colorSpectrum, color.max));
                }

                Widgets.Label(new Rect(0, 400, 120, 30), Translator.Translate("FactionLeaderName"));
                leaderName = Widgets.TextField(new Rect(135, 400, 220, 30), leaderName);
            }
            Widgets.EndScrollView();

            if (Widgets.ButtonText(new Rect(0, inRect.height - 30, 320, 20), Translator.Translate("CreateNewFaction")))
            {
                CreateFaction();
            }
        }
Exemple #3
0
        private void DrawChat(Rect inRect)
        {
            Rect outRect  = new Rect(0f, 0f, inRect.width, inRect.height - 30f);
            Rect viewRect = new Rect(0f, 0f, inRect.width - 16f, messagesHeight + 10f);

            float width     = viewRect.width;
            Rect  textField = new Rect(20f, outRect.yMax + 5f, width - 70f, 25f);

            GUI.BeginGroup(inRect);

            GUI.SetNextControlName("chat_input");
            currentMsg = Widgets.TextField(textField, currentMsg);
            currentMsg = currentMsg.Substring(0, Math.Min(currentMsg.Length, ServerPlayingState.MaxChatMsgLength));

            Widgets.BeginScrollView(outRect, ref chatScroll, viewRect);

            float yPos = 0;

            GUI.color = Color.white;

            int i = 0;

            foreach (ChatMsg msg in Multiplayer.session.messages)
            {
                float height    = Text.CalcHeight(msg.Msg, width - 20f);
                float textWidth = Text.CalcSize(msg.Msg).x + 15;
                Rect  msgRect   = new Rect(20f, yPos, width - 20f, height);

                if (Mouse.IsOver(msgRect))
                {
                    GUI.DrawTexture(msgRect, SelectedMsg);

                    if (msg.TimeStamp != null)
                    {
                        TooltipHandler.TipRegion(msgRect, msg.TimeStamp.ToLongTimeString());
                    }
                }

                Color cursorColor = GUI.skin.settings.cursorColor;
                GUI.skin.settings.cursorColor = new Color(0, 0, 0, 0);

                msgRect.width = Math.Min(textWidth, msgRect.width);
                bool mouseOver = Mouse.IsOver(msgRect);

                if (mouseOver && msg.Clickable)
                {
                    GUI.color = new Color(0.8f, 0.8f, 1);
                }

                GUI.SetNextControlName("chat_msg_" + i++);
                Widgets.TextArea(msgRect, msg.Msg, true);

                if (mouseOver && msg.Clickable)
                {
                    GUI.color = Color.white;

                    if (Event.current.type == EventType.MouseUp)
                    {
                        msg.Click();
                    }
                }

                GUI.skin.settings.cursorColor = cursorColor;

                yPos += height;
            }

            if (Event.current.type == EventType.layout)
            {
                messagesHeight = yPos;
            }

            Widgets.EndScrollView();

            if (Widgets.ButtonText(new Rect(textField.xMax + 5f, textField.y, 55f, textField.height), "MpSend".Translate()))
            {
                SendMsg();
            }

            GUI.EndGroup();

            if (Event.current.type == EventType.mouseDown && !GUI.GetNameOfFocusedControl().NullOrEmpty())
            {
                UI.UnfocusCurrentControl();
            }

            if (!hasBeenFocused)
            {
                chatScroll.y = messagesHeight;

                GUI.FocusControl("chat_input");
                TextEditor editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
                editor.OnFocus();
                editor.MoveTextEnd();
                hasBeenFocused = true;
            }
        }
        public override void DoWindowContents(Rect inRect)
        {
            var  contentRect      = new Rect(0, 0, inRect.width, inRect.height - (CloseButSize.y + 10f)).ContractedBy(10f);
            bool scrollBarVisible = totalContentHeight > contentRect.height;
            var  scrollViewTotal  = new Rect(0f, 0f, contentRect.width - (scrollBarVisible ? ScrollBarWidthMargin : 0), totalContentHeight);

            Widgets.DrawHighlight(contentRect);
            Widgets.BeginScrollView(contentRect, ref scrollPosition, scrollViewTotal);
            float curY = 0f;
            Rect  r    = new Rect(0, curY, scrollViewTotal.width, LabelHeight);

            Widgets.CheckboxLabeled(r, "LWMDSperDSUturnOn".Translate(), ref Settings.allowPerDSUSettings);//TODO
            TooltipHandler.TipRegion(r, "LWMDSperDSUturnOnDesc".Translate());
            curY += LabelHeight + 1f;
            if (!Settings.allowPerDSUSettings)
            {
                r = new Rect(5f, curY, scrollViewTotal.width - 10f, LabelHeight);
                Widgets.Label(r, "LWMDSperDSUWarning".Translate());
                curY += LabelHeight;
            }
            Widgets.DrawLineHorizontal(0f, curY, scrollViewTotal.width);
            curY += 10f;

            // todo: make this static?
            //List<ThingDef> l=DefDatabase<ThingDef>.AllDefsListForReading.Where(ThingDef d => d.Has

            // Roll my own buttons, because dammit, I want left-justified buttons:
            //   (mirroring Widgets.ButtonTextWorker)
            GenUI.SetLabelAlign(TextAnchor.MiddleLeft);
            var bg = ContentFinder <Texture2D> .Get("UI/Widgets/ButtonBG", true);

            var bgmouseover = ContentFinder <Texture2D> .Get("UI/Widgets/ButtonBGMouseover", true);

            var bgclick = ContentFinder <Texture2D> .Get("UI/Widgets/ButtonBGClick", true);

            //  note: make own list b/c this can modify what's in the DefDatabase.
            foreach (ThingDef u in Settings.AllDeepStorageUnits.ToList())
            {
                //////////////// Disble button: //////////////////
                // disabled if it's already been disabled previously
                //   or if it's slated to be disabled on window close
                bool isEnabled = !tracker.HasDefaultValueFor(u.defName, "def") &&
                                 (this.unitsToBeDisabled == null || !unitsToBeDisabled.Contains(u));
                bool wasEnabled  = isEnabled;
                Rect disableRect = new Rect(5f, curY, LabelHeight, LabelHeight);
                TooltipHandler.TipRegion(disableRect, "TODO: Add description. But basically, you can disable some units and they won't show up in game.\n\nVERY likely to cause unimportant errors in saved games.");
                Widgets.Checkbox(disableRect.x, disableRect.y, ref isEnabled, LabelHeight, false, true, null, null);
                if (!isEnabled && wasEnabled)   // newly disabled
                {
                    Utils.Warn(Utils.DBF.Settings, "Marking unit for disabling: " + u.defName);
                    if (unitsToBeDisabled == null)
                    {
                        unitsToBeDisabled = new HashSet <ThingDef>();
                    }
                    unitsToBeDisabled.Add(u); // hash sets don't care if it's already there!
                }
                if (isEnabled && !wasEnabled) // add back:
                {
                    Utils.Warn(Utils.DBF.Settings, "Restoring disabled unit: " + u.defName);
                    if (unitsToBeDisabled != null && unitsToBeDisabled.Contains(u))
                    {
                        unitsToBeDisabled.Remove(u);
                    }
                    if (tracker.HasDefaultValueFor(u.defName, "def"))
                    {
                        tracker.Remove(u.defName, "def");
                    }
                    if (!DefDatabase <ThingDef> .AllDefsListForReading.Contains(u))
                    {
                        ReturnDefToUse(u);
                    }
                }
                //////////////// Select def: //////////////////
                r = new Rect(10f + LabelHeight, curY, (scrollViewTotal.width) * 2 / 3 - 12f - LabelHeight, LabelHeight);
                // Draw button-ish background:
                Texture2D atlas = bg;
                if (Mouse.IsOver(r))
                {
                    atlas = bgmouseover;
                    if (Input.GetMouseButton(0))
                    {
                        atlas = bgclick;
                    }
                }
                Widgets.DrawAtlas(r, atlas);
                // button text:
                Widgets.Label(r, u.label + " (defName: " + u.defName + ")");
                // button clickiness:
                if (Widgets.ButtonInvisible(r))
                {
                    Find.WindowStack.Add(new Dialog_DSU_Settings(u));
                }
                //////////////// Reset button: //////////////////
                r = new Rect((scrollViewTotal.width) * 2 / 3 + 2f, curY, (scrollViewTotal.width) / 3 - 7f, LabelHeight);
                if (tracker.IsChanged(u.defName) && Widgets.ButtonText(r, "ResetBinding".Translate()))
                {
                    ResetDSUToDefaults(u.defName);
                }
                curY += LabelHeight + 2f;
            }
            GenUI.ResetLabelAlign();
            // end buttons

            Widgets.EndScrollView();
            // close button:
            r = new Rect(inRect.width / 2 - (CloseButSize.x / 2), inRect.height - CloseButSize.y - 5f, CloseButSize.x, CloseButSize.y);
            if (Widgets.ButtonText(r, "CloseButton".Translate()))
            {
                if (unitsToBeDisabled != null && unitsToBeDisabled.Count > 0)
                {
                    //TODO: add out-of-order flag.
                    foreach (ThingDef d in unitsToBeDisabled)
                    {
                        Utils.Warn(Utils.DBF.Settings, "Closing Window: Removing def: " + d.defName);
                        RemoveDefFromUse(d);
                        tracker.AddDefaultValue(d.defName, "def", d);
                    }
                    unitsToBeDisabled = null;
                }
                Close();
            }
            r = new Rect(10f, inRect.height - CloseButSize.y - 5f, 2 * CloseButSize.x, CloseButSize.y);
            if (tracker.HasAnyDefaultValues && Widgets.ButtonText(r, "LWM.ResetAllToDefault".Translate()))
            {
                Utils.Mess(Utils.DBF.Settings, "Resetting all per-building storage settings to default:");
                ResetAllToDefaults();
            }
            totalContentHeight = curY;
        }
Exemple #5
0
        private void DrawSteam(Rect inRect)
        {
            string info = null;

            if (!SteamManager.Initialized)
            {
                info = "MpNotConnectedToSteam".Translate();
            }
            else if (friends.Count == 0)
            {
                info = "MpNoFriendsPlaying".Translate();
            }

            if (info != null)
            {
                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(new Rect(0, 8, inRect.width, 40f), info);

                Text.Anchor  = TextAnchor.UpperLeft;
                inRect.yMin += 40f;
            }

            float margin  = 80;
            Rect  outRect = new Rect(margin, inRect.yMin + 10, inRect.width - 2 * margin, inRect.height - 20);

            float height   = friends.Count * 40;
            Rect  viewRect = new Rect(0, 0, outRect.width - 16f, height);

            Widgets.BeginScrollView(outRect, ref steamScroll, viewRect, true);

            float y = 0;
            int   i = 0;

            foreach (SteamPersona friend in friends)
            {
                Rect entryRect = new Rect(0, y, viewRect.width, 40);
                if (i % 2 == 0)
                {
                    Widgets.DrawAltRect(entryRect);
                }

                if (Event.current.type == EventType.repaint)
                {
                    GUI.DrawTextureWithTexCoords(new Rect(5, entryRect.y + 4, 32, 32), SteamImages.GetTexture(friend.avatar), new Rect(0, 1, 1, -1));
                }

                Text.Anchor = TextAnchor.MiddleLeft;
                Widgets.Label(entryRect.Right(45).Up(5), friend.username);

                GUI.color = SteamGreen;
                Text.Font = GameFont.Tiny;
                Widgets.Label(entryRect.Right(45).Down(8), "MpPlayingRimWorld".Translate());
                Text.Font = GameFont.Small;
                GUI.color = Color.white;

                Text.Anchor = TextAnchor.MiddleCenter;

                if (friend.serverHost != CSteamID.Nil)
                {
                    Rect playButton = new Rect(entryRect.xMax - 85, entryRect.y + 5, 80, 40 - 10);
                    if (Widgets.ButtonText(playButton, "MpJoinButton".Translate()))
                    {
                        Close(false);

                        Log.Message("Connecting through Steam");

                        Find.WindowStack.Add(new SteamConnectingWindow(friend.serverHost)
                        {
                            returnToServerBrowser = true
                        });

                        var conn = new SteamClientConn(friend.serverHost);
                        conn.username       = Multiplayer.username;
                        Multiplayer.session = new MultiplayerSession();

                        Multiplayer.session.client = conn;
                        Multiplayer.session.ReapplyPrefs();

                        conn.State = ConnectionStateEnum.ClientSteam;
                    }
                }
                else
                {
                    Rect playButton = new Rect(entryRect.xMax - 125, entryRect.y + 5, 120, 40 - 10);
                    Widgets.ButtonText(playButton, "MpNotInMultiplayer".Translate(), false, false, false);
                }

                Text.Anchor = TextAnchor.UpperLeft;

                y += entryRect.height;
                i++;
            }

            Widgets.EndScrollView();
        }
        private void DrawLeftRect(Rect leftOutRect)
        {
            Rect position = leftOutRect;

            GUI.BeginGroup(position);
            if (this.selectedProject != null)
            {
                Rect outRect  = new Rect(0f, 0f, position.width, 500f);
                Rect viewRect = new Rect(0f, 0f, outRect.width - 16f, this.leftScrollViewHeight);
                Widgets.BeginScrollView(outRect, ref this.leftScrollPosition, viewRect, true);
                float num = 0f;
                Text.Font = GameFont.Medium;
                GenUI.SetLabelAlign(TextAnchor.MiddleLeft);
                Rect rect = new Rect(0f, num, viewRect.width, 50f);
                Widgets.LabelCacheHeight(ref rect, this.selectedProject.LabelCap, true, false);
                GenUI.ResetLabelAlign();
                Text.Font = GameFont.Small;
                num      += rect.height;
                Rect rect2 = new Rect(0f, num, viewRect.width, 0f);
                Widgets.LabelCacheHeight(ref rect2, this.selectedProject.description, true, false);
                num += rect2.height + 10f;
                string text = string.Concat(new string[]
                {
                    "ProjectTechLevel".Translate().CapitalizeFirst(),
                    ": ",
                    this.selectedProject.techLevel.ToStringHuman().CapitalizeFirst(),
                    "\n",
                    "YourTechLevel".Translate().CapitalizeFirst(),
                    ": ",
                    Faction.OfPlayer.def.techLevel.ToStringHuman().CapitalizeFirst()
                });
                float num2 = this.selectedProject.CostFactor(Faction.OfPlayer.def.techLevel);
                if (num2 != 1f)
                {
                    string text2 = text;
                    text = string.Concat(new string[]
                    {
                        text2,
                        "\n\n",
                        "ResearchCostMultiplier".Translate().CapitalizeFirst(),
                        ": ",
                        num2.ToStringPercent(),
                        "\n",
                        "ResearchCostComparison".Translate(new object[]
                        {
                            this.selectedProject.baseCost.ToString("F0"),
                            this.selectedProject.CostApparent.ToString("F0")
                        })
                    });
                }
                Rect rect3 = new Rect(0f, num, viewRect.width, 0f);
                Widgets.LabelCacheHeight(ref rect3, text, true, false);
                num = rect3.yMax + 10f;
                Rect  rect4 = new Rect(0f, num, viewRect.width, 500f);
                float num3  = this.DrawResearchPrereqs(this.selectedProject, rect4);
                if (num3 > 0f)
                {
                    num += num3 + 15f;
                }
                Rect rect5 = new Rect(0f, num, viewRect.width, 500f);
                num += this.DrawResearchBenchRequirements(this.selectedProject, rect5);
                num += 3f;
                this.leftScrollViewHeight = num;
                Widgets.EndScrollView();
                bool flag  = Prefs.DevMode && this.selectedProject != Find.ResearchManager.currentProj && !this.selectedProject.IsFinished;
                Rect rect6 = new Rect(0f, 0f, 90f, 50f);
                if (flag)
                {
                    rect6.x = (outRect.width - (rect6.width * 2f + 20f)) / 2f;
                }
                else
                {
                    rect6.x = (outRect.width - rect6.width) / 2f;
                }
                rect6.y = outRect.y + outRect.height + 20f;
                if (this.selectedProject.IsFinished)
                {
                    Widgets.DrawMenuSection(rect6);
                    Text.Anchor = TextAnchor.MiddleCenter;
                    Widgets.Label(rect6, "Finished".Translate());
                    Text.Anchor = TextAnchor.UpperLeft;
                }
                else if (this.selectedProject == Find.ResearchManager.currentProj)
                {
                    Widgets.DrawMenuSection(rect6);
                    Text.Anchor = TextAnchor.MiddleCenter;
                    Widgets.Label(rect6, "InProgress".Translate());
                    Text.Anchor = TextAnchor.UpperLeft;
                }
                else if (!this.selectedProject.CanStartNow)
                {
                    Widgets.DrawMenuSection(rect6);
                    Text.Anchor = TextAnchor.MiddleCenter;
                    Widgets.Label(rect6, "Locked".Translate());
                    Text.Anchor = TextAnchor.UpperLeft;
                }
                else if (Widgets.ButtonText(rect6, "Research".Translate(), true, false, true))
                {
                    SoundDefOf.ResearchStart.PlayOneShotOnCamera(null);
                    Find.ResearchManager.currentProj = this.selectedProject;
                    TutorSystem.Notify_Event("StartResearchProject");
                }
                if (flag)
                {
                    Rect rect7 = rect6;
                    rect7.x += rect7.width + 20f;
                    if (Widgets.ButtonText(rect7, "Debug Insta-finish", true, false, true))
                    {
                        Find.ResearchManager.currentProj = this.selectedProject;
                        Find.ResearchManager.FinishProject(this.selectedProject, false, null);
                    }
                }
                Rect rect8 = new Rect(15f, rect6.y + rect6.height + 20f, position.width - 30f, 35f);
                Widgets.FillableBar(rect8, this.selectedProject.ProgressPercent, MainTabWindow_Research.ResearchBarFillTex, MainTabWindow_Research.ResearchBarBGTex, true);
                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(rect8, this.selectedProject.ProgressApparent.ToString("F0") + " / " + this.selectedProject.CostApparent.ToString("F0"));
                Text.Anchor = TextAnchor.UpperLeft;
            }
            GUI.EndGroup();
        }
Exemple #7
0
        public override void DoWindowContents(Rect inRect)
        {
            Text.Font = GameFont.Small;

            Widgets.Label(new Rect(0, 0, 290, 20), Translator.Translate("PreciousLumpMenuTitle"));

            Widgets.Label(new Rect(0, 40, 80, 20), Translator.Translate("ResourceType"));
            if (Widgets.ButtonText(new Rect(90, 40, 200, 20), resource.label))
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                foreach (var thing in DefDatabase <ThingDef> .AllDefsListForReading)
                {
                    if (thing.mineable)
                    {
                        list.Add(new FloatMenuOption(thing.defName, delegate
                        {
                            resource = thing;
                        }));
                    }
                }
                Find.WindowStack.Add(new FloatMenu(list));
            }

            Widgets.Label(new Rect(0, 70, 290, 20), Translator.Translate("DurationTimeDaysLump"));
            time = Widgets.TextField(new Rect(0, 95, 280, 20), time);

            Widgets.Label(new Rect(0, 125, 80, 20), Translator.Translate("ThreatType"));
            if (Widgets.ButtonText(new Rect(90, 125, 200, 20), part.defName))
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                foreach (var p in DefDatabase <SitePartDef> .AllDefsListForReading)
                {
                    list.Add(new FloatMenuOption(p.defName, delegate
                    {
                        part = p;
                    }));
                }
                Find.WindowStack.Add(new FloatMenu(list));
            }

            int  factionDefSize      = Find.FactionManager.AllFactionsListForReading.Count * 25;
            Rect scrollRectFact3     = new Rect(310, 40, 280, 200);
            Rect scrollVertRectFact3 = new Rect(0, 0, scrollRectFact3.x, factionDefSize);

            Widgets.BeginScrollView(scrollRectFact3, ref scroll2, scrollVertRectFact3);
            int x = 0;

            foreach (var spawnedFaction in Find.FactionManager.AllFactionsListForReading)
            {
                if (Widgets.ButtonText(new Rect(0, x, 290, 20), spawnedFaction.Name))
                {
                    selectedFaction = spawnedFaction;
                }
                x += 22;
            }
            Widgets.EndScrollView();

            Widgets.Label(new Rect(0, 155, 100, 40), Translator.Translate("ThreatPoint"));
            Widgets.TextFieldNumeric(new Rect(110, 155, 170, 20), ref threatsFloat, ref threats, 0, 2000000);

            Widgets.Label(new Rect(0, 210, 290, 20), $"Selected tile ID: {Find.WorldSelector.selectedTile}");

            if (Widgets.ButtonText(new Rect(0, 240, 620, 20), Translator.Translate("AddNewItemStash")))
            {
                AddLump();
            }
        }
        public override void DoWindowContents(Rect inRect)
        {
            Vector2 vector    = new Vector2(120f, 40f);
            float   y         = vector.y;
            float   num       = 600f;
            float   num2      = (inRect.width - num) / 2f;
            Rect    position  = new Rect(num2 + inRect.x, inRect.y, num, inRect.height - (y + 10f)).ContractedBy(10f);
            Rect    position2 = new Rect(position.x, position.y + position.height + 10f, position.width, y);

            GUI.BeginGroup(position);
            Rect rect = new Rect(0f, 0f, position.width, 40f);

            Text.Font = GameFont.Medium;
            GenUI.SetLabelAlign(TextAnchor.MiddleCenter);
            Widgets.Label(rect, "KeyboardConfig".Translate());
            GenUI.ResetLabelAlign();
            Text.Font = GameFont.Small;
            Rect outRect = new Rect(0f, rect.height, position.width, position.height - rect.height);
            Rect rect2   = new Rect(0f, 0f, outRect.width - 16f, this.contentHeight);

            Widgets.BeginScrollView(outRect, ref this.scrollPosition, rect2, true);
            float num3 = 0f;
            KeyBindingCategoryDef keyBindingCategoryDef = null;

            Dialog_KeyBindings.keyBindingsWorkingList.Clear();
            Dialog_KeyBindings.keyBindingsWorkingList.AddRange(DefDatabase <KeyBindingDef> .AllDefs);
            Dialog_KeyBindings.keyBindingsWorkingList.SortBy((KeyBindingDef x) => x.category.index, (KeyBindingDef x) => x.index);
            for (int i = 0; i < Dialog_KeyBindings.keyBindingsWorkingList.Count; i++)
            {
                KeyBindingDef keyBindingDef = Dialog_KeyBindings.keyBindingsWorkingList[i];
                if (keyBindingCategoryDef != keyBindingDef.category)
                {
                    bool skipDrawing = num3 - this.scrollPosition.y + 40f < 0f || num3 - this.scrollPosition.y > outRect.height;
                    keyBindingCategoryDef = keyBindingDef.category;
                    this.DrawCategoryEntry(keyBindingCategoryDef, rect2.width, ref num3, skipDrawing);
                }
                bool skipDrawing2 = num3 - this.scrollPosition.y + 34f < 0f || num3 - this.scrollPosition.y > outRect.height;
                this.DrawKeyEntry(keyBindingDef, rect2, ref num3, skipDrawing2);
            }
            Widgets.EndScrollView();
            GUI.EndGroup();
            GUI.BeginGroup(position2);
            int   num4  = 3;
            float num5  = vector.x * (float)num4 + 10f * (float)(num4 - 1);
            float num6  = (position2.width - num5) / 2f;
            float num7  = vector.x + 10f;
            Rect  rect3 = new Rect(num6, 0f, vector.x, vector.y);
            Rect  rect4 = new Rect(num6 + num7, 0f, vector.x, vector.y);
            Rect  rect5 = new Rect(num6 + num7 * 2f, 0f, vector.x, vector.y);

            if (Widgets.ButtonText(rect3, "ResetButton".Translate(), true, false, true))
            {
                this.keyPrefsData.ResetToDefaults();
                this.keyPrefsData.ErrorCheck();
                SoundDefOf.Tick_Low.PlayOneShotOnCamera(null);
                Event.current.Use();
            }
            if (Widgets.ButtonText(rect4, "CancelButton".Translate(), true, false, true))
            {
                this.Close(true);
                Event.current.Use();
            }
            if (Widgets.ButtonText(rect5, "OK".Translate(), true, false, true))
            {
                KeyPrefs.KeyPrefsData = this.keyPrefsData;
                KeyPrefs.Save();
                this.Close(true);
                this.keyPrefsData.ErrorCheck();
                Event.current.Use();
            }
            GUI.EndGroup();
        }
Exemple #9
0
        public override void DoWindowContents(Rect inRect)
        {
            Text.Font = GameFont.Small;

            Widgets.Label(new Rect(0, 0, 290, 20), Translator.Translate("DownedRefugeeMenuTitle"));

            Widgets.Label(new Rect(0, 40, 400, 20), Translator.Translate("ThreatTypes"));
            int  size2              = DefDatabase <SitePartDef> .AllDefsListForReading.Count * 25;
            Rect scrollRectFact     = new Rect(0, 65, 485, 200);
            Rect scrollVertRectFact = new Rect(0, 0, scrollRectFact.x, size2);

            Widgets.BeginScrollView(scrollRectFact, ref scroll, scrollVertRectFact);
            int x = 0;

            foreach (var sitePart in DefDatabase <SitePartDef> .AllDefsListForReading)
            {
                if (Widgets.RadioButtonLabeled(new Rect(0, x, 480, 20), sitePart.defName, parts.Contains(sitePart)))
                {
                    if (parts.Contains(sitePart))
                    {
                        parts.Remove(sitePart);
                    }
                    else
                    {
                        parts.Add(sitePart);
                    }
                }
                x += 22;
            }
            Widgets.EndScrollView();

            if (Widgets.ButtonText(new Rect(0, 240, 490, 20), Translator.Translate("OpenPawnMenu")))
            {
                DrawPawnMenu();
            }
            Widgets.Label(new Rect(0, 270, 490, 20), $"Pawns: {pawnList.Count}");

            Widgets.Label(new Rect(0, 300, 490, 20), Translator.Translate("DurationTimeDaysLump"));
            time = Widgets.TextField(new Rect(0, 300, 480, 20), time);

            Widgets.Label(new Rect(0, 330, 100, 40), Translator.Translate("ThreatPoint"));
            Widgets.TextFieldNumeric(new Rect(110, 330, 370, 20), ref threatsFloat, ref threats, 0, 2000000);

            Widgets.Label(new Rect(0, 365, 290, 20), Translator.Translate("FactionForSort"));
            int  factionDefSize      = Find.FactionManager.AllFactionsListForReading.Count * 25;
            Rect scrollRectFact3     = new Rect(0, 390, 490, 110);
            Rect scrollVertRectFact3 = new Rect(0, 0, scrollRectFact3.x, factionDefSize);

            Widgets.BeginScrollView(scrollRectFact3, ref scroll2, scrollVertRectFact3);
            x = 0;
            foreach (var spawnedFaction in Find.FactionManager.AllFactionsListForReading)
            {
                if (Widgets.ButtonText(new Rect(0, x, 485, 20), spawnedFaction.Name))
                {
                    selectedFaction = spawnedFaction;
                }
                x += 22;
            }
            Widgets.EndScrollView();

            Widgets.Label(new Rect(0, 510, 290, 20), $"Selected tile ID: {Find.WorldSelector.selectedTile}");

            if (Widgets.ButtonText(new Rect(0, 550, 490, 20), Translator.Translate("AddNewDownedRefugee")))
            {
                AddNewDownedRefugee();
            }
        }
Exemple #10
0
        public void DrawOverview(Rect rect)
        {
            if (Jobs.NullOrEmpty())
            {
                Text.Anchor = TextAnchor.MiddleCenter;
                GUI.color   = Color.grey;
                Widgets.Label(rect, "FM.NoJobs".Translate());
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
            }
            else
            {
                Rect viewRect    = rect;
                Rect contentRect = viewRect.AtZero();
                contentRect.height = OverviewHeight;
                if (OverviewHeight > viewRect.height)
                {
                    contentRect.width -= ScrollbarWidth;
                }

                GUI.BeginGroup(viewRect);
                Widgets.BeginScrollView(viewRect, ref _overviewScrollPosition, contentRect);

                Vector2 cur = Vector2.zero;

                for (var i = 0; i < Jobs.Count; i++)
                {
                    var row = new Rect(cur.x, cur.y, contentRect.width, 50f);

                    // highlights
                    if (i % 2 == 1)
                    {
                        Widgets.DrawAltRect(row);
                    }
                    if (Jobs[i] == Selected)
                    {
                        Widgets.DrawHighlightSelected(row);
                    }

                    // go to job icon
                    var iconRect = new Rect(Margin, row.yMin + (LargeListEntryHeight - LargeIconSize) / 2, LargeIconSize, LargeIconSize);
                    if (Widgets.ButtonImage(iconRect, Jobs[i].Tab.Icon))
                    {
                        MainTabWindow_Manager.GoTo(Jobs[i].Tab, Jobs[i]);
                    }

                    // order buttons
                    DrawOrderButtons(new Rect(row.xMax - 50f, row.yMin, 50f, 50f), Manager.For(manager), Jobs[i]);

                    // job specific overview.
                    Rect jobRect = row;
                    jobRect.width -= LargeListEntryHeight + LargeIconSize + 2 * Margin; // - (a + b)?
                    jobRect.x     += LargeIconSize + 2 * Margin;
                    Jobs[i].DrawListEntry(jobRect, true, true);
                    Widgets.DrawHighlightIfMouseover(row);
                    if (Widgets.ButtonInvisible(jobRect))
                    {
                        Selected = Jobs[i];
                    }

                    cur.y += 50f;
                }

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

                OverviewHeight = cur.y;
            }
        }
Exemple #11
0
        public void DrawPawnOverview(Rect rect)
        {
            // table body viewport
            var tableOutRect  = new Rect(0f, ListEntryHeight, rect.width, rect.height - ListEntryHeight).RoundToInt();
            var tableViewRect = new Rect(0f, ListEntryHeight, rect.width, Workers.Count * ListEntryHeight).RoundToInt();

            if (tableViewRect.height > tableOutRect.height)
            {
                tableViewRect.width -= ScrollbarWidth;
            }

            // column width
            float colWidth = tableViewRect.width / 4 - Margin;

            // column headers
            var nameColumnHeaderRect     = new Rect(colWidth * 0, 0f, colWidth, ListEntryHeight).RoundToInt();
            var activityColumnHeaderRect = new Rect(colWidth * 1, 0f, colWidth * 2.5f, ListEntryHeight).RoundToInt();
            var priorityColumnHeaderRect = new Rect(colWidth * 3.5f, 0f, colWidth * .5f, ListEntryHeight).RoundToInt();

            // label for priority column
            string workLabel = Find.PlaySettings.useWorkPriorities
                                   ? "FM.Priority".Translate()
                                   : "FM.Enabled".Translate();

            // begin drawing
            GUI.BeginGroup(rect);

            // draw labels
            Widgets_Labels.Label(nameColumnHeaderRect, WorkTypeDef.pawnLabel + "FM.PluralSuffix".Translate(), TextAnchor.LowerCenter);
            Widgets_Labels.Label(activityColumnHeaderRect, "FM.Activity".Translate(), TextAnchor.LowerCenter);
            Widgets_Labels.Label(priorityColumnHeaderRect, workLabel, TextAnchor.LowerCenter);

            // begin scrolling area
            Widgets.BeginScrollView(tableOutRect, ref _workersScrollPosition, tableViewRect);
            GUI.BeginGroup(tableViewRect);

            // draw pawn rows
            Vector2 cur = Vector2.zero;

            for (var i = 0; i < Workers.Count; i++)
            {
                var row = new Rect(cur.x, cur.y, tableViewRect.width, ListEntryHeight);
                if (i % 2 == 0)
                {
                    Widgets.DrawAltRect(row);
                }
                try
                {
                    DrawPawnOverviewRow(Workers[i], row);
                }
                catch // pawn death, etc.
                {
                    // rehresh the list and skip drawing untill the next GUI tick.
                    RefreshWorkers();
                    Widgets.EndScrollView();
                    return;
                }

                cur.y += ListEntryHeight;
            }

            // end scrolling area
            GUI.EndGroup();
            Widgets.EndScrollView();

            // done!
            GUI.EndGroup();
        }
    public override void DoWindowContents(Rect inRect)
    {
        if (TabSortingMod.instance.Settings.ManualTabIcons == null)
        {
            TabSortingMod.instance.Settings.ManualTabIcons = new Dictionary <string, string>();
        }

        GUI.contentColor = Color.green;
        Widgets.Label(new Rect(inRect), "TabSorting.ChooseTabIcon".Translate());
        GUI.contentColor = Color.white;
        Widgets.DrawLineHorizontal(inRect.x, inRect.y + 25f, inRect.width);
        if (TabSortingMod.instance.Settings.ManualTabIcons.ContainsKey(currentTabDef) && Widgets.ButtonText(
                new Rect(inRect.position + new Vector2(inRect.width - TabSortingMod.buttonSize.x, 0),
                         TabSortingMod.buttonSize),
                "TabSorting.Reset".Translate()))
        {
            TabSortingMod.instance.Settings.ManualTabIcons.Remove(currentTabDef);
            Find.WindowStack.TryRemove(this, false);
            return;
        }

        var viewRect = inRect;

        viewRect.y += 40f;
        var contentRect = viewRect;

        contentRect.width -= 20;
        contentRect.x      = 0;
        contentRect.y      = 0f;
        contentRect.height = TabSorting.iconsCache.Count / ItemsPerRow * 50f;
        Widgets.BeginScrollView(viewRect, ref scrollPosition, contentRect);

        var spacer = contentRect.width / (ItemsPerRow + 1);
        var i      = 0;
        var y      = -50f;
        var x      = 0f;

        foreach (var textureName in TabSorting.iconsCache.Keys.OrderBy(s => s))
        {
            if (i % (ItemsPerRow + 1) == 0)
            {
                y += 50f;
                x  = 0;
            }
            else
            {
                x += spacer;
            }

            if (ListingExtension.TabIconSelectable(new Rect(new Vector2(x, y), TabSortingMod.tabIconSize * 2),
                                                   textureName, null, textureName == TabSorting.GetCustomTabIcon(currentTabDef)))
            {
                if (currentTabDef == textureName)
                {
                    TabSortingMod.instance.Settings.ManualTabIcons.Remove(textureName);
                }
                else
                {
                    TabSortingMod.instance.Settings.ManualTabIcons[currentTabDef] = textureName;
                }

                Widgets.EndScrollView();
                TabSortingMod.selectedDef = currentTabDef;
                Find.WindowStack.TryRemove(this, false);
                return;
            }

            i++;
        }

        Widgets.EndScrollView();
    }
Exemple #13
0
        public void DrawFilters(Rect canvas)
        {
            GUI.BeginGroup(canvas);
            var listing  = new Listing_Standard();
            var viewPort = new Rect(canvas.x, canvas.y, canvas.width - 16f, _filters.Sum(f => f.Height));

            Widgets.BeginScrollView(canvas, ref _scrollPos, viewPort);
            listing.Begin(viewPort);

            foreach (ThingItemFilterCategory category in _filters)
            {
                Rect lineRect = listing.GetRect(Text.LineHeight);

                if (!lineRect.IsVisible(viewPort, _scrollPos) && !category.Expanded)
                {
                    continue;
                }

                Rect arrowIconRect  = new Rect(lineRect.x, lineRect.y, lineRect.height, lineRect.height).ContractedBy(4f);
                Rect checkStateRect = new Rect(arrowIconRect.x + arrowIconRect.width, lineRect.y, lineRect.height, lineRect.height).ContractedBy(4f);

                var categoryTextRect = new Rect(
                    checkStateRect.x + checkStateRect.width + 5f,
                    lineRect.y,
                    lineRect.width - 5f - arrowIconRect.width - checkStateRect.width,
                    lineRect.height
                    );

                GUI.DrawTexture(arrowIconRect.ContractedBy(2f), category.Expanded ? Textures.ExpandedArrow : Textures.CollapsedArrow);

                MultiCheckboxState state = Widgets.CheckboxMulti(checkStateRect, category.CheckState, true);

                if (state != category.CheckState)
                {
                    category.CheckState = state;

                    foreach (ThingItemFilter filter in category.Filters)
                    {
                        switch (category.CheckState)
                        {
                        case MultiCheckboxState.Off:
                            filter.Active = false;

                            break;

                        case MultiCheckboxState.On:
                            filter.Active = true;

                            break;
                        }
                    }
                }

                UiHelper.Label(categoryTextRect, $"TKUtils.FilterTypes.{category.FilterType}".TranslateSimple());

                if (Widgets.ButtonInvisible(arrowIconRect))
                {
                    category.Expanded = !category.Expanded;
                }

                if (category.Expanded)
                {
                    DrawFiltersFor(category, listing, viewPort);
                }
            }

            GUI.EndGroup();
            listing.End();
            Widgets.EndScrollView();
        }
Exemple #14
0
        /// <inheritdoc cref="Window.DoWindowContents"/>
        public override void DoWindowContents(Rect inRect)
        {
            if (Event.current.type == EventType.Layout)
            {
                return;
            }

            GUI.BeginGroup(inRect);
            Text.Font = GameFont.Small;

            ProcessShortcutKeys();
            Rect pawnRect    = new Rect(0f, 0f, inRect.width * 0.3333f, 152f + Text.LineHeight).Rounded();
            var  contentRect = new Rect(pawnRect.width + 10f, 0f, inRect.width - pawnRect.width - Margin, pawnRect.height);
            var  queueRect   = new Rect(0f, pawnRect.height + 50f, inRect.width, inRect.height - pawnRect.height - 50f);

            GUI.BeginGroup(pawnRect);
            DrawPawnSection(pawnRect);
            GUI.EndGroup();


            GUI.BeginGroup(contentRect);
            DrawContent(contentRect.AtZero());
            GUI.EndGroup();

            GUI.BeginGroup(queueRect);
            var listing        = new Listing_Standard();
            var noticeRect     = new Rect(0f, 0f, queueRect.width - Text.LineHeight - 5f, Text.LineHeight);
            var randomRect     = new Rect(queueRect.width - Text.LineHeight, noticeRect.y, Text.LineHeight, Text.LineHeight);
            var nameQueueRect  = new Rect(0f, noticeRect.height + 5f, queueRect.width, queueRect.height - Text.LineHeight - 5f);
            var queueInnerRect = new Rect(0f, 0f, nameQueueRect.width, nameQueueRect.height);
            var queueView      = new Rect(0f, 0f, nameQueueRect.width - 16f, Text.LineHeight * _pawnComponent.viewerNameQueue.Count);

            if (queueView.height <= nameQueueRect.height)
            {
                queueView.height += 16;
            }

            if (_pawnComponent.ViewerNameQueue.Count <= 0)
            {
                Widgets.Label(noticeRect, _emptyQueueText);
                GUI.EndGroup();

                return;
            }

            Widgets.Label(noticeRect, $"{_pawnComponent.ViewerNameQueue.Count:N0} {_countText}");
            TooltipHandler.TipRegion(randomRect, _randomTooltip);

            if (Widgets.ButtonImage(randomRect, _currentDiceSide))
            {
                _username       = _pawnComponent.ViewerNameQueue.RandomElement();
                _userFromButton = true;
                _viewer         = Viewers.GetViewer(_username);
                UpdateLastSeenText();
            }

            GUI.BeginGroup(nameQueueRect);
            Widgets.BeginScrollView(queueInnerRect, ref _scrollPos, queueView);
            listing.Begin(queueView);
            DrawNameQueue(listing);

            GUI.EndGroup();
            listing.End();
            Widgets.EndScrollView();
            GUI.EndGroup();
            GUI.EndGroup();
        }
Exemple #15
0
        public static void DrawStorytellerSelectionInterface(Rect rect, ref StorytellerDef chosenStoryteller, ref DifficultyDef difficulty, Listing_Standard infoListing)
        {
            GUI.BeginGroup(rect);
            if (chosenStoryteller != null && chosenStoryteller.listVisible)
            {
                float   height            = rect.height;
                Vector2 portraitSizeLarge = Storyteller.PortraitSizeLarge;
                float   y = height - portraitSizeLarge.y - 1f;
                Vector2 portraitSizeLarge2 = Storyteller.PortraitSizeLarge;
                float   x = portraitSizeLarge2.x;
                Vector2 portraitSizeLarge3 = Storyteller.PortraitSizeLarge;
                Rect    position           = new Rect(390f, y, x, portraitSizeLarge3.y);
                GUI.DrawTexture(position, chosenStoryteller.portraitLargeTex);
                Widgets.DrawLineHorizontal(0f, rect.height, rect.width);
            }
            Vector2 portraitSizeTiny  = Storyteller.PortraitSizeTiny;
            Rect    outRect           = new Rect(0f, 0f, portraitSizeTiny.x + 16f, rect.height);
            Vector2 portraitSizeTiny2 = Storyteller.PortraitSizeTiny;
            float   x2  = portraitSizeTiny2.x;
            float   num = (float)DefDatabase <StorytellerDef> .AllDefs.Count();

            Vector2 portraitSizeTiny3 = Storyteller.PortraitSizeTiny;
            Rect    viewRect          = new Rect(0f, 0f, x2, num * (portraitSizeTiny3.y + 10f));

            Widgets.BeginScrollView(outRect, ref scrollPosition, viewRect);
            Vector2 portraitSizeTiny4 = Storyteller.PortraitSizeTiny;
            float   x3 = portraitSizeTiny4.x;
            Vector2 portraitSizeTiny5 = Storyteller.PortraitSizeTiny;
            Rect    rect2             = new Rect(0f, 0f, x3, portraitSizeTiny5.y);

            foreach (StorytellerDef item in from tel in DefDatabase <StorytellerDef> .AllDefs
                     orderby tel.listOrder
                     select tel)
            {
                if (item.listVisible)
                {
                    if (Widgets.ButtonImage(rect2, item.portraitTinyTex))
                    {
                        TutorSystem.Notify_Event("ChooseStoryteller");
                        chosenStoryteller = item;
                    }
                    if (chosenStoryteller == item)
                    {
                        GUI.DrawTexture(rect2, StorytellerHighlightTex);
                    }
                    rect2.y += rect2.height + 8f;
                }
            }
            Widgets.EndScrollView();
            Text.Font = GameFont.Small;
            Rect rect3 = new Rect(outRect.xMax + 8f, 0f, 300f, 999f);

            Widgets.Label(rect3, "HowStorytellersWork".Translate());
            if (chosenStoryteller != null && chosenStoryteller.listVisible)
            {
                Rect rect4 = new Rect(outRect.xMax + 8f, outRect.yMin + 160f, 290f, 0f);
                rect4.height = rect.height - rect4.y;
                Text.Font    = GameFont.Medium;
                Rect rect5 = new Rect(rect4.x + 15f, rect4.y - 40f, 9999f, 40f);
                Widgets.Label(rect5, chosenStoryteller.label);
                Text.Anchor = TextAnchor.UpperLeft;
                Text.Font   = GameFont.Small;
                infoListing.Begin(rect4);
                infoListing.Label(chosenStoryteller.description, 160f);
                infoListing.Gap(6f);
                foreach (DifficultyDef allDef in DefDatabase <DifficultyDef> .AllDefs)
                {
                    if (!allDef.isExtreme || Prefs.ExtremeDifficultyUnlocked)
                    {
                        GUI.color = allDef.drawColor;
                        string labelCap    = allDef.LabelCap;
                        bool   active      = difficulty == allDef;
                        string description = allDef.description;
                        if (infoListing.RadioButton(labelCap, active, 0f, description))
                        {
                            difficulty = allDef;
                        }
                        infoListing.Gap(3f);
                    }
                }
                GUI.color = Color.white;
                if (Current.ProgramState == ProgramState.Entry)
                {
                    infoListing.Gap(25f);
                    bool   flag        = Find.GameInitData.permadeathChosen && Find.GameInitData.permadeath;
                    bool   flag2       = Find.GameInitData.permadeathChosen && !Find.GameInitData.permadeath;
                    string description = "ReloadAnytimeMode".Translate();
                    bool   active      = flag2;
                    string labelCap    = "ReloadAnytimeModeInfo".Translate();
                    if (infoListing.RadioButton(description, active, 0f, labelCap))
                    {
                        Find.GameInitData.permadeathChosen = true;
                        Find.GameInitData.permadeath       = false;
                    }
                    infoListing.Gap(3f);
                    labelCap    = "CommitmentMode".TranslateWithBackup("PermadeathMode");
                    active      = flag;
                    description = "PermadeathModeInfo".Translate();
                    if (infoListing.RadioButton(labelCap, active, 0f, description))
                    {
                        Find.GameInitData.permadeathChosen = true;
                        Find.GameInitData.permadeath       = true;
                    }
                }
                infoListing.End();
            }
            GUI.EndGroup();
        }
Exemple #16
0
        private void DrawLoadScreen(Rect canvas)
        {
            if (_isIndexing)
            {
                UiHelper.Label(canvas, _indexingLabel, TextAnchor.MiddleCenter, GameFont.Medium);

                return;
            }

            var listing  = new Listing_Standard();
            var viewport = new Rect(0f, 0f, canvas.width - 16f, Text.SmallFontHeight * _files.Count);

            GUI.BeginGroup(canvas);
            listing.Begin(canvas);
            Widgets.BeginScrollView(canvas, ref _scrollPos, viewport);
            FileData <T> toDelete = null;

            foreach (FileData <T> file in _files)
            {
                Rect lineRect = listing.GetRect(Text.SmallFontHeight);

                if (!lineRect.IsVisible(canvas, _scrollPos))
                {
                    continue;
                }

                var nameRect   = new Rect(lineRect.x, lineRect.y, lineRect.width - lineRect.height * 2f, lineRect.height);
                var loadRect   = new Rect(nameRect.x + nameRect.width, nameRect.y, lineRect.height, lineRect.height);
                var deleteRect = new Rect(loadRect.x + loadRect.width, nameRect.y, loadRect.width, loadRect.height);

                UiHelper.Label(nameRect, file.Name);

                if (Widgets.ButtonImage(loadRect, TexCommand.Install))
                {
                    _selectedFile = file;
                    _cancelled    = false;
                    Close();
                }

                if (Widgets.ButtonImage(deleteRect, Widgets.CheckboxOffTex))
                {
                    toDelete = file;
                }

                nameRect.TipRegion(file.Description);
                loadRect.TipRegion(_loadPartialTooltip);
                deleteRect.TipRegion(_deletePartialTooltip);
            }

            Widgets.EndScrollView();
            listing.End();
            GUI.EndGroup();

            if (toDelete == null)
            {
                return;
            }

            _files.Remove(toDelete);

            try
            {
                File.Delete(toDelete.Path);
            }
            catch (Exception e)
            {
                TkUtils.Logger.Error($"Couldn't remove the partial file @ {toDelete.Path}", e);
            }
        }
        public override void DoWindowContents(Rect inRect)
        {
            Text.Font = GameFont.Medium;
            Widgets.Label(new Rect(0f, 0f, InitialSize.x / 2f, 40f), "ChooseRewards".Translate());
            Text.Font = GameFont.Small;
            string text   = "ChooseRewardsDesc".Translate();
            float  height = Text.CalcHeight(text, inRect.width);
            Rect   rect   = new Rect(0f, 40f, inRect.width, height);

            Widgets.Label(rect, text);
            IEnumerable <Faction> allFactionsVisibleInViewOrder = Find.FactionManager.AllFactionsVisibleInViewOrder;
            Rect outRect = new Rect(inRect);

            outRect.yMax -= CloseButSize.y;
            outRect.yMin += 44f + rect.height + 4f;
            float curY  = 0f;
            Rect  rect2 = new Rect(0f, curY, outRect.width - 16f, viewRectHeight);

            Widgets.BeginScrollView(outRect, ref scrollPosition, rect2);
            int index = 0;

            foreach (Faction item in allFactionsVisibleInViewOrder)
            {
                if (item.IsPlayer)
                {
                    continue;
                }
                float curX = 0f;
                if (item.def.HasRoyalTitles)
                {
                    DoFactionInfo(rect2, item, ref curX, ref curY, ref index);
                    TaggedString label = "AcceptRoyalFavor".Translate(item.Named("FACTION")).CapitalizeFirst();
                    Rect         rect3 = new Rect(curX, curY, label.GetWidthCached(), 45f);
                    Text.Anchor = TextAnchor.MiddleLeft;
                    Widgets.Label(rect3, label);
                    Text.Anchor = TextAnchor.UpperLeft;
                    if (Mouse.IsOver(rect3))
                    {
                        TooltipHandler.TipRegion(rect3, "AcceptRoyalFavorDesc".Translate(item.Named("FACTION")));
                        Widgets.DrawHighlight(rect3);
                    }
                    Widgets.Checkbox(rect2.width - 150f, curY + 12f, ref item.allowRoyalFavorRewards);
                    curY += 45f;
                }
                if (item.CanEverGiveGoodwillRewards)
                {
                    curX = 0f;
                    DoFactionInfo(rect2, item, ref curX, ref curY, ref index);
                    TaggedString label2 = "AcceptGoodwill".Translate().CapitalizeFirst();
                    Rect         rect4  = new Rect(curX, curY, label2.GetWidthCached(), 45f);
                    Text.Anchor = TextAnchor.MiddleLeft;
                    Widgets.Label(rect4, label2);
                    Text.Anchor = TextAnchor.UpperLeft;
                    if (Mouse.IsOver(rect4))
                    {
                        TooltipHandler.TipRegion(rect4, "AcceptGoodwillDesc".Translate(item.Named("FACTION")));
                        Widgets.DrawHighlight(rect4);
                    }
                    Widgets.Checkbox(rect2.width - 150f, curY + 12f, ref item.allowGoodwillRewards);
                    Widgets.Label(new Rect(rect2.width - 100f, curY, 100f, 35f), (item.PlayerGoodwill.ToStringWithSign() + "\n" + item.PlayerRelationKind.GetLabel()).Colorize(item.PlayerRelationKind.GetColor()));
                    curY += 45f;
                }
            }
            if (Event.current.type == EventType.Layout)
            {
                viewRectHeight = curY;
            }
            Widgets.EndScrollView();
        }
Exemple #18
0
        protected override void FillTab()
        {
            var          storageBuilding = SelThing as Building_Storage; // don't attach this to other things, 'k?
            List <Thing> storedItems;

//TODO: set fonts ize, etc.
            Text.Font = GameFont.Small;
            // 10f border:
            var frame = new Rect(10f, 10f, size.x - 10, size.y - 10);

            GUI.BeginGroup(frame);
            Text.Font = GameFont.Small;
            GUI.color = Color.white;

            /*******  Title *******/
            var curY = 0f;

            Widgets.ListSeparator(ref curY, frame.width, labelKey.Translate()
#if DEBUG
                                  + "    (" + storageBuilding.ToString() + ")"                        // extra info for debugging
#endif
                                  );
            curY += 5f;
            /****************** Header: Show count of contents, mass, etc: ****************/
            //TODO: handle each cell separately?
            string header, headerTooltip;
            var    cds = storageBuilding.GetComp <CompDeepStorage>();
            if (cds != null)
            {
                storedItems = cds.getContentsHeader(out header, out headerTooltip);
            }
            else
            {
                storedItems = CompDeepStorage.genericContentsHeader(storageBuilding, out header, out headerTooltip);
            }
            var tmpRect = new Rect(8f, curY, frame.width - 16, Text.CalcHeight(header, frame.width - 16));
            Widgets.Label(tmpRect, header);
            // TODO: tooltip.  Not that it's anything but null now
            curY += tmpRect.height; //todo?

            /*************          ScrollView              ************/
            /*************          (contents)              ************/
            storedItems = storedItems.OrderBy(x => x.def.defName).ThenByDescending(x =>
            {
                QualityCategory c;
                x.TryGetQuality(out c);
                return((int)c);
            }).ThenByDescending(x => x.HitPoints / x.MaxHitPoints).ToList();
            // outRect is the is the rectangle that is visible on the screen:
            var outRect = new Rect(0f, 10f + curY, frame.width, frame.height - curY);
            // viewRect is inside the ScrollView, so it starts at y=0f
            var viewRect = new Rect(0f, 0f, frame.width - 16f, scrollViewHeight); //TODO: scrollbars are slightly too far to the right
            // 16f ensures plenty of room for scrollbars.
            // scrollViewHeight is set at the end of this call (via layout?); it is the proper
            //   size the next time through, so it all works out.
            Widgets.BeginScrollView(outRect, ref scrollPosition, viewRect);

            curY = 0f; // now inside ScrollView
            if (storedItems.Count < 1)
            {
                Widgets.Label(viewRect, "NoItemsAreStoredHere".Translate());
                curY += 22;
            }

            for (var i = 0; i < storedItems.Count; i++)
            {
                DrawThingRow(ref curY, viewRect.width, storedItems[i]);
            }

            if (Event.current.type == EventType.Layout)
            {
                scrollViewHeight = curY + 25f;                                         //25f buffer   -- ??
            }
            Widgets.EndScrollView();
            GUI.EndGroup();
            //TODO: this should get stored at top and set here.
            GUI.color = Color.white;
            //TODO: this should get stored at top and set here.
            // it should get set to whatever draw-row uses at top
            Text.Anchor = TextAnchor.UpperLeft;
        }
        private void DrawRightRect(Rect rightOutRect)
        {
            rightOutRect.yMin += 32f;
            Widgets.DrawMenuSection(rightOutRect);
            List <TabRecord> list = new List <TabRecord>();

            foreach (ResearchTabDef localTabDef2 in DefDatabase <ResearchTabDef> .AllDefs)
            {
                ResearchTabDef localTabDef = localTabDef2;
                list.Add(new TabRecord(localTabDef.LabelCap, delegate()
                {
                    this.CurTab = localTabDef;
                }, this.CurTab == localTabDef));
            }
            TabDrawer.DrawTabs(rightOutRect, list, 200f);
            if (Prefs.DevMode)
            {
                Rect rect = rightOutRect;
                rect.yMax = rect.yMin + 20f;
                rect.xMin = rect.xMax - 80f;
                Rect butRect = rect.RightPartPixels(30f);
                rect = rect.LeftPartPixels(rect.width - 30f);
                Widgets.CheckboxLabeled(rect, "Edit", ref this.editMode, false, null, null, false);
                if (Widgets.ButtonImageFitted(butRect, TexButton.Copy))
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    foreach (ResearchProjectDef researchProjectDef in from def in DefDatabase <ResearchProjectDef> .AllDefsListForReading
                             where def.Debug_IsPositionModified()
                             select def)
                    {
                        stringBuilder.AppendLine(researchProjectDef.defName);
                        stringBuilder.AppendLine(string.Format("  <researchViewX>{0}</researchViewX>", researchProjectDef.ResearchViewX.ToString("F2")));
                        stringBuilder.AppendLine(string.Format("  <researchViewY>{0}</researchViewY>", researchProjectDef.ResearchViewY.ToString("F2")));
                        stringBuilder.AppendLine();
                    }
                    GUIUtility.systemCopyBuffer = stringBuilder.ToString();
                    Messages.Message("Modified data copied to clipboard.", MessageTypeDefOf.SituationResolved, false);
                }
            }
            else
            {
                this.editMode = false;
            }
            Rect outRect  = rightOutRect.ContractedBy(10f);
            Rect rect2    = new Rect(0f, 0f, this.rightViewWidth, this.rightViewHeight);
            Rect position = rect2.ContractedBy(10f);

            rect2.width = this.rightViewWidth;
            position    = rect2.ContractedBy(10f);
            Vector2 start = default(Vector2);
            Vector2 end   = default(Vector2);

            Widgets.ScrollHorizontal(outRect, ref this.rightScrollPosition, rect2, 20f);
            Widgets.BeginScrollView(outRect, ref this.rightScrollPosition, rect2, true);
            GUI.BeginGroup(position);
            List <ResearchProjectDef> allDefsListForReading = DefDatabase <ResearchProjectDef> .AllDefsListForReading;

            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < allDefsListForReading.Count; j++)
                {
                    ResearchProjectDef researchProjectDef2 = allDefsListForReading[j];
                    if (researchProjectDef2.tab == this.CurTab)
                    {
                        start.x = this.PosX(researchProjectDef2);
                        start.y = this.PosY(researchProjectDef2) + 25f;
                        for (int k = 0; k < researchProjectDef2.prerequisites.CountAllowNull <ResearchProjectDef>(); k++)
                        {
                            ResearchProjectDef researchProjectDef3 = researchProjectDef2.prerequisites[k];
                            if (researchProjectDef3 != null && researchProjectDef3.tab == this.CurTab)
                            {
                                end.x = this.PosX(researchProjectDef3) + 140f;
                                end.y = this.PosY(researchProjectDef3) + 25f;
                                if (this.selectedProject == researchProjectDef2 || this.selectedProject == researchProjectDef3)
                                {
                                    if (i == 1)
                                    {
                                        Widgets.DrawLine(start, end, TexUI.HighlightLineResearchColor, 4f);
                                    }
                                }
                                else if (i == 0)
                                {
                                    Widgets.DrawLine(start, end, TexUI.DefaultLineResearchColor, 2f);
                                }
                            }
                        }
                    }
                }
            }
            for (int l = 0; l < allDefsListForReading.Count; l++)
            {
                ResearchProjectDef researchProjectDef4 = allDefsListForReading[l];
                if (researchProjectDef4.tab == this.CurTab)
                {
                    Rect   source      = new Rect(this.PosX(researchProjectDef4), this.PosY(researchProjectDef4), 140f, 50f);
                    string label       = this.GetLabel(researchProjectDef4);
                    Rect   rect3       = new Rect(source);
                    Color  textColor   = Widgets.NormalOptionColor;
                    Color  color       = default(Color);
                    Color  borderColor = default(Color);
                    bool   flag        = !researchProjectDef4.IsFinished && !researchProjectDef4.CanStartNow;
                    if (researchProjectDef4 == Find.ResearchManager.currentProj)
                    {
                        color = TexUI.ActiveResearchColor;
                    }
                    else if (researchProjectDef4.IsFinished)
                    {
                        color = TexUI.FinishedResearchColor;
                    }
                    else if (flag)
                    {
                        color = TexUI.LockedResearchColor;
                    }
                    else if (researchProjectDef4.CanStartNow)
                    {
                        color = TexUI.AvailResearchColor;
                    }
                    if (this.selectedProject == researchProjectDef4)
                    {
                        color      += TexUI.HighlightBgResearchColor;
                        borderColor = TexUI.HighlightBorderResearchColor;
                    }
                    else
                    {
                        borderColor = TexUI.DefaultBorderResearchColor;
                    }
                    if (flag)
                    {
                        textColor = MainTabWindow_Research.ProjectWithMissingPrerequisiteLabelColor;
                    }
                    for (int m = 0; m < researchProjectDef4.prerequisites.CountAllowNull <ResearchProjectDef>(); m++)
                    {
                        ResearchProjectDef researchProjectDef5 = researchProjectDef4.prerequisites[m];
                        if (researchProjectDef5 != null && this.selectedProject == researchProjectDef5)
                        {
                            borderColor = TexUI.HighlightLineResearchColor;
                        }
                    }
                    if (this.requiredByThisFound)
                    {
                        for (int n = 0; n < researchProjectDef4.requiredByThis.CountAllowNull <ResearchProjectDef>(); n++)
                        {
                            ResearchProjectDef researchProjectDef6 = researchProjectDef4.requiredByThis[n];
                            if (this.selectedProject == researchProjectDef6)
                            {
                                borderColor = TexUI.HighlightLineResearchColor;
                            }
                        }
                    }
                    if (Widgets.CustomButtonText(ref rect3, label, color, textColor, borderColor, true, 1, true, true))
                    {
                        SoundDefOf.Click.PlayOneShotOnCamera(null);
                        this.selectedProject = researchProjectDef4;
                    }
                    if (this.editMode && Mouse.IsOver(rect3) && Input.GetMouseButtonDown(0))
                    {
                        this.draggingTab = researchProjectDef4;
                    }
                }
            }
            GUI.EndGroup();
            Widgets.EndScrollView();
            if (!Input.GetMouseButton(0))
            {
                this.draggingTab = null;
            }
            if (this.draggingTab != null && !Input.GetMouseButtonDown(0) && Event.current.type == EventType.Layout)
            {
                this.draggingTab.Debug_ApplyPositionDelta(new Vector2(this.PixelsToCoordX(Event.current.delta.x), this.PixelsToCoordY(Event.current.delta.y)));
            }
        }
Exemple #20
0
        public override void DoWindowContents(Rect inRect)
        {
            var windowButtonSize = CloseButSize;
            var contentRect      = new Rect(0, 0, inRect.width, inRect.height - (windowButtonSize.y + 10f)).ContractedBy(10f);

            GUI.BeginGroup(contentRect);
            var titleRect = new Rect(0f, 0f, contentRect.width, TitleLabelHeight);

            Text.Font = GameFont.Medium;
            GenUI.SetLabelAlign(TextAnchor.MiddleCenter);
            Widgets.Label(titleRect, "HugsLib_settings_windowTitle".Translate());
            GenUI.ResetLabelAlign();
            Text.Font = GameFont.Small;
            if (listedMods.Count > 0)
            {
                var scrollViewVisible = new Rect(0f, titleRect.height, contentRect.width, contentRect.height - titleRect.height);
                var scrollBarVisible  = totalContentHeight > scrollViewVisible.height;
                var scrollViewTotal   = new Rect(0f, 0f, scrollViewVisible.width - (scrollBarVisible ? ScrollBarWidthMargin : 0), totalContentHeight);
                Widgets.BeginScrollView(scrollViewVisible, ref scrollPosition, scrollViewTotal);
                var curY = 0f;
                for (int i = 0; i < listedMods.Count; i++)
                {
                    var entry = listedMods[i];
                    if (!entry.Visible)
                    {
                        continue;
                    }
                    currentlyDrawnEntry = entry.ModName;
                    DrawModEntryHeader(entry, scrollViewTotal.width, ref curY);
                    if ((entry.SettingsPack != null && entry.SettingsPack.AlwaysExpandEntry) || expandedModEntries.Contains(entry))
                    {
                        for (int j = 0; j < entry.Handles.Count; j++)
                        {
                            var handle = entry.Handles[j];
                            if (handle.VisibilityPredicate != null)
                            {
                                try {
                                    if (!handle.VisibilityPredicate())
                                    {
                                        continue;
                                    }
                                } catch (Exception e) {
                                    HugsLibController.Logger.ReportException(e, currentlyDrawnEntry, true, "SettingsHandle.VisibilityPredicate");
                                }
                            }
                            DrawHandleEntry(handle, scrollViewTotal, ref curY, scrollViewVisible.height);
                        }
                    }
                    currentlyDrawnEntry = null;
                }
                Widgets.EndScrollView();
                totalContentHeight = curY;
            }
            else
            {
                Widgets.Label(new Rect(0, titleRect.height, contentRect.width, titleRect.height), "HugsLib_settings_noSettings".Translate());
            }
            GUI.EndGroup();
            Text.Font = GameFont.Small;
            var resetButtonRect = new Rect(0, inRect.height - windowButtonSize.y, windowButtonSize.x, windowButtonSize.y);

            if (Widgets.ButtonText(resetButtonRect, "HugsLib_settings_resetAll".Translate()))
            {
                Find.WindowStack.Add(new Dialog_Confirm("HugsLib_settings_resetAll_prompt".Translate(), ResetAllSettings, true));
            }
            var closeButtonRect = new Rect(inRect.width - windowButtonSize.x, inRect.height - windowButtonSize.y, windowButtonSize.x, windowButtonSize.y);

            if (closingScheduled)
            {
                closingScheduled = false;
                Close();
            }
            if (Widgets.ButtonText(closeButtonRect, "CloseButton".Translate()))
            {
                GUI.FocusControl(null);                 // unfocus, so that a focused text field may commit its value
                closingScheduled = true;
            }
        }
            public override void DoWindowContents(Rect inRect) // For a specific DSU
            {
                // for the record, Listing_Standards kind of suck. Convenient enough, but no flexibility
                // TODO when I'm bored: switch to manual, add red background for disabled units
                // Bonus problem with Listing_Standard: nested scrolling windows do not work
                //   well - specifically the ThingFilter UI insisde a Listing_Standard
                // We are able to get around that problem by having our ScrollView be outside
                //   the Listing_S... (instead of using the L_S's .ScrollView) and having the
                //   ThingFilter's UI after the L_S ends.

                // First: Set up a ScrollView:
                // outer window (with room for buttons at bottom:
                Rect s = new Rect(inRect.x, inRect.y, inRect.width, inRect.height - CloseButSize.y - 5f);

                // inner window that has entire content:
                y = y + 200; // this is to ensure the Listing_Standard does not run out of height,
                //                and can fully display everything - giving a proper length 'y' at
                //                its .End() call.
                //          Worst case scenario: y starts as 0, and the L_S gets to a CurHeight of
                //            200, and then updates at 400 the next time.  Because of the way RW's
                //            windows work, this will rapidly converge on a large enough value.
                Rect inner = new Rect(0, 0, s.width - 20, this.y);

                Widgets.BeginScrollView(s, ref DSUScrollPosition, inner);
                // We cannot do the scrollview inside the L_S:
                // l.BeginScrollView(s, ref DSUScrollPosition, ref v); // Does not allow filter UI
                var l = new Listing_Standard();

                l.Begin(inner);
                l.Label(def.label);
                l.GapLine();
                // Much TODO, so wow:
                tmpLabel = l.TextEntryLabeled("LWMDSpDSUlabel".Translate(), tmpLabel);
                string tmpstring = null;

                l.TextFieldNumericLabeled("LWM_DS_maxNumStacks".Translate().CapitalizeFirst() + " "
                                          + "LWM_DS_Default".Translate(tracker.GetDefaultValue(def.defName, "maxNumStacks",
                                                                                               tmpMaxNumStacks)),
                                          ref tmpMaxNumStacks, ref tmpstring, 0);
                tmpstring = null;
                l.TextFieldNumericLabeled <float>("LWM_DS_maxTotalMass".Translate().CapitalizeFirst() + " " +
                                                  "LWM_DS_Default".Translate(tracker.GetDefaultValue(def.defName,
                                                                                                     "maxTotalMass", tmpMaxTotalMass).ToString()),
                                                  ref tmpMaxTotalMass, ref tmpstring, 0f);
                tmpstring = null;
                l.TextFieldNumericLabeled <float>("LWM_DS_maxMassOfStoredItem".Translate().CapitalizeFirst() + " " +
                                                  "LWM_DS_Default".Translate(tracker.GetDefaultValue(def.defName,
                                                                                                     "maxMassStoredItem", tmpMaxMassStoredItem).ToString()),
                                                  ref tmpMaxMassStoredItem, ref tmpstring, 0f);
                l.CheckboxLabeled("LWMDSpDSUshowContents".Translate(), ref tmpShowContents);
                l.GapLine();
                l.EnumRadioButton(ref tmpOverlayType, "LWMDSpDSUoverlay".Translate());
                l.GapLine();
                l.EnumRadioButton(ref tmpStoragePriority, "LWMDSpDSUstoragePriority".Translate());
                l.GapLine();
                l.CheckboxLabeled("LWMDSpDSUchangeFilterQ".Translate(), ref useCustomThingFilter,
                                  "LWMDSpDSUchangeFilterQDesc".Translate());
                y = l.CurHeight;
                l.End();
                if (useCustomThingFilter)
                {
                    if (customThingFilter == null)
                    {
                        customThingFilter = new ThingFilter();
                        customThingFilter.CopyAllowancesFrom(def.building.fixedStorageSettings.filter);
                        Utils.Mess(Utils.DBF.Settings, "Created new filter for " + def.defName + ": " + customThingFilter);
//                        Log.Error("Old filter has: "+def.building.fixedStorageSettings.filter.AllowedDefCount);
//                        Log.Warning("New filter has: "+customThingFilter.AllowedDefCount);
                    }
                    // Since this is outside the L_S, we make our own rectangle and use it:
                    //   Nope: Rect r=l.GetRect(CustomThingFilterHeight); // this fails
                    Rect r = new Rect(20, y, (inner.width - 40) * 3 / 4, CustomThingFilterHeight);
                    y += CustomThingFilterHeight;
                    ThingFilterUI.DoThingFilterConfigWindow(r, thingFilterState, customThingFilter);
                }
                else     // not using custom thing filter:
                {
                    if (customThingFilter != null || tracker.HasDefaultValueFor(this.def.defName, "filter"))
                    {
                        customThingFilter = null;
                        if (tracker.HasDefaultValueFor(this.def.defName, "filter"))
                        {
                            Utils.Mess(Utils.DBF.Settings, "  Removing filter for " + def.defName);
                            def.building.fixedStorageSettings.filter = (ThingFilter)tracker
                                                                       .GetDefaultValue <ThingFilter>(def.defName, "filter", null);
                            tracker.Remove(def.defName, "filter");
                        }
                    }
                }

                // This fails: l.EndScrollView(ref v);
                Widgets.EndScrollView();

                // Cancel button
                var closeRect = new Rect(inRect.width - CloseButSize.x, inRect.height - CloseButSize.y, CloseButSize.x, CloseButSize.y);

                if (Widgets.ButtonText(closeRect, "CancelButton".Translate()))
                {
                    Utils.Mess(Utils.DBF.Settings, "Cancel button selected - no changes made");
                    Close();
                }
                // Accept button - with accompanying logic
                closeRect = new Rect(inRect.width - (2 * CloseButSize.x + 5f), inRect.height - CloseButSize.y, CloseButSize.x, CloseButSize.y);
                if (Widgets.ButtonText(closeRect, "AcceptButton".Translate()))
                {
                    LWM.DeepStorage.Properties props = def.GetCompProperties <Properties>();
                    GUI.FocusControl(null); // unfocus, so that a focused text field may commit its value
                    Utils.Warn(Utils.DBF.Settings, "\"Accept\" button selected: changing values for " + def.defName);
                    tracker.UpdateToNewValue(def.defName, "label", tmpLabel, ref def.label);
                    tracker.UpdateToNewValue(def.defName,
                                             "maxNumStacks", tmpMaxNumStacks, ref props.maxNumberStacks);
                    tracker.UpdateToNewValue(def.defName,
                                             "maxTotalMass", tmpMaxTotalMass, ref props.maxTotalMass);
                    tracker.UpdateToNewValue(def.defName,
                                             "maxMassStoredItem", tmpMaxMassStoredItem, ref props.maxMassOfStoredItem);
                    tracker.UpdateToNewValue(def.defName,
                                             "showContents", tmpShowContents, ref props.showContents);
                    tracker.UpdateToNewValue(def.defName,
                                             "overlayType", tmpOverlayType, ref props.overlayType);
                    StoragePriority tmpSP = def.building.defaultStorageSettings.Priority; // hard to access private field directly
                    tracker.UpdateToNewValue(def.defName, "storagePriority", tmpStoragePriority, ref tmpSP);
                    def.building.defaultStorageSettings.Priority = tmpSP;
                    if (useCustomThingFilter)   // danger ahead - automatically use it, even if stupidly set up
                    {
                        if (!tracker.HasDefaultValueFor(def.defName, "filter"))
                        {
                            Utils.Mess(Utils.DBF.Settings, "Creating default filter record for item " + def.defName);
                            tracker.AddDefaultValue(def.defName, "filter", def.building.fixedStorageSettings.filter);
                        }
                        def.building.fixedStorageSettings.filter = customThingFilter;
                    }
                    else
                    {
                        // restore default filter:
                        if (tracker.HasDefaultValueFor(def.defName, "filter"))
                        {
                            // we need to remove it
                            Utils.Mess(Utils.DBF.Settings, "Removing default filter record for item " + def.defName);
                            def.building.fixedStorageSettings.filter = (ThingFilter)tracker
                                                                       .GetDefaultValue <ThingFilter>(def.defName, "filter", null);
                            tracker.Remove(def.defName, "filter");
                        }
                    }
                    Close();
                }
                // Reset to Defaults
                closeRect = new Rect(inRect.width - (4 * CloseButSize.x + 10f), inRect.height - CloseButSize.y, 2 * CloseButSize.x, CloseButSize.y);
                if (!AreTempVarsDefaults() && Widgets.ButtonText(closeRect, "ResetBinding".Translate()))
                {
                    SetTempVarsToDefaults();
                }
            }
Exemple #22
0
        public override void DoWindowContents(Rect rect)
        {
            // Setup page.
            this.DrawPageTitle(rect);
            Rect mainRect = this.GetMainRect(rect);

            UnityEngine.GUI.BeginGroup(mainRect);

            // Build control column.
            Rect             controlColumn     = new Rect(0, 0, mainRect.width * 0.20f, mainRect.height).Rounded();
            Listing_Standard controlButtonList = new Listing_Standard {
                ColumnWidth = controlColumn.width
            };

            controlButtonList.Begin(controlColumn);

            // Back button.
            if (controlButtonList.ButtonText("Close"))
            {
                this.Close();
                Find.WindowStack.Add(PrepareModerately.Instance.originalPage);
            }

            // Add part button.
            if (controlButtonList.ButtonText("Add part"))
            {
                FloatMenuUtility.MakeMenu(PawnFilter.allFilterParts, def => def.label, def => () => {
                    PawnFilterPart part = (PawnFilterPart)Activator.CreateInstance(def.partClass);
                    part.def            = def;
                    PrepareModerately.Instance.currentFilter.parts.Add(part);
                });
            }

            // Filter name input field.
            PrepareModerately.Instance.currentFilter.name = controlButtonList.TextEntry(PrepareModerately.Instance.currentFilter.name);

            // Save filter button.
            if (controlButtonList.ButtonText("Save"))
            {
                PrepareModerately.Instance.currentFilter.Save(PrepareModerately.dataPath + "\\" + PrepareModerately.Instance.currentFilter.name + ".xml");
            }

            // Load filter button.
            if (controlButtonList.ButtonText("Load"))
            {
                string[] filePaths = Directory.GetFiles(PrepareModerately.dataPath);
                if (filePaths.Length > 0)
                {
                    FloatMenuUtility.MakeMenu(filePaths, path => {
                        int start = path.LastIndexOf("\\") + 1;
                        int end   = path.LastIndexOf(".xml");
                        return(path.Substring(start, end - start));
                    }, path => () => PrepareModerately.Instance.currentFilter.Load(path));
                }
                else
                {
                    FloatMenuUtility.MakeMenu(new string[] { "N/A" }, _ => _, _ => () => { });
                }
            }

            // Randomize multiplier input field.
            controlButtonList.TextFieldNumericLabeled("Multiplier ", ref this.randomizeMultiplier, ref this.randomizeMultiplierBuffer);

            // Randomize modulus input field.
            controlButtonList.TextFieldNumericLabeled("Modulus ", ref this.randomizeModulus, ref this.randomizeModulusBuffer);

            // Multiplier and modulus help labels.
            controlButtonList.Label("Pawn randomization speed is multiplied by the multiplier and divided by the modulus.");
            if (this.randomizeMultiplier < 1 || this.randomizeModulus < 1)
            {
                _ = controlButtonList.Label("Multiplier and modulus values less than 1 will be set to 1.");
            }
            if (this.randomizeMultiplier > 5)
            {
                _ = controlButtonList.Label("Randomization speed will still be limited by your computer's hardware. Use high multiplier values at your own risk.");
            }
            if (this.randomizeModulus > 1)
            {
                _ = controlButtonList.Label("Higher modulus values will not make randomization easier on your computer.");
            }

            // End control column.
            controlButtonList.End();

            // Build filter column.
            Rect filterColumn = new Rect(controlColumn.xMax + dividerWidth, 0, mainRect.width - controlColumn.width - dividerWidth, mainRect.height).Rounded();

            Widgets.DrawMenuSection(filterColumn);
            filterColumn = filterColumn.GetInnerRect();
            Rect filterViewRect = new Rect(0, 0, filterColumn.width - (dividerWidth - 1), this.partViewHeight);

            Widgets.BeginScrollView(filterColumn, ref this.scrollPosition, filterViewRect);
            Rect filterViewInnerRect = new Rect(0, 0, filterViewRect.width, 99999);

            // Draw filter parts.
            PawnFilterListing filterPartList = new PawnFilterListing()
            {
                ColumnWidth = filterViewInnerRect.width
            };

            filterPartList.Begin(filterViewInnerRect);
            _ = filterPartList.Label("Filters");
            List <PawnFilterPart> partsToRemove = new List <PawnFilterPart>();           // Remove parts that should be removed here in order to avoid modifying enumerable during foreach.

            foreach (PawnFilterPart part in PrepareModerately.Instance.currentFilter.parts)
            {
                if (part.toRemove)
                {
                    partsToRemove.Add(part);
                }
                else
                {
                    part.DoEditInterface(filterPartList);
                }
            }
            foreach (PawnFilterPart part in partsToRemove)
            {
                _ = PrepareModerately.Instance.currentFilter.parts.Remove(part);
            }
            filterPartList.End();
            this.partViewHeight = filterPartList.CurHeight + 100;

            // End filter column.
            Widgets.EndScrollView();
            UnityEngine.GUI.EndGroup();
        }
Exemple #23
0
        private void DrawHost(Rect inRect)
        {
            if (!filesRead)
            {
                ReloadFiles();
                filesRead = true;
            }

            inRect.y += 8;

            float margin   = 80;
            Rect  outRect  = new Rect(margin, inRect.yMin + 10, inRect.width - 2 * margin, inRect.height - 80);
            Rect  viewRect = new Rect(0, 0, outRect.width - 16f, hostHeight);

            Widgets.BeginScrollView(outRect, ref hostScroll, viewRect, true);

            Rect collapseRect = new Rect(0, 4f, 18f, 18f);

            if (Widgets.ButtonImage(collapseRect, mpCollapsed ? TexButton.Reveal : TexButton.Collapse))
            {
                mpCollapsed = !mpCollapsed;
            }

            float y = 0;

            Text.Font = GameFont.Medium;
            float textHeight1 = Text.CalcHeight("MpMultiplayer".Translate(), inRect.width);

            Widgets.Label(viewRect.Right(18f), "MpMultiplayer".Translate());
            Text.Font = GameFont.Small;
            y        += textHeight1 + 10;

            if (!mpCollapsed)
            {
                DrawSaveList(mpReplays, viewRect.width, ref y);
                y += 25;
            }

            collapseRect.y += y;

            if (Widgets.ButtonImage(collapseRect, spCollapsed ? TexButton.Reveal : TexButton.Collapse))
            {
                spCollapsed = !spCollapsed;
            }

            viewRect.y = y;
            Text.Font  = GameFont.Medium;
            float textHeight2 = Text.CalcHeight("MpSingleplayer".Translate(), inRect.width);

            Widgets.Label(viewRect.Right(18), "MpSingleplayer".Translate());
            Text.Font = GameFont.Small;
            y        += textHeight2 + 10;

            if (!spCollapsed)
            {
                DrawSaveList(spSaves, viewRect.width, ref y);
            }

            if (Event.current.type == EventType.layout)
            {
                hostHeight = y;
            }

            Widgets.EndScrollView();

            if (selectedFile == null)
            {
                Text.Anchor = TextAnchor.MiddleCenter;

                bool noSaves = spSaves.Count == 0 && mpReplays.Count == 0;
                Widgets.Label(new Rect(outRect.x, outRect.yMax, outRect.width, 80), noSaves ? "MpNoSaves".Translate() : "MpNothingSelected".Translate());

                Text.Anchor = TextAnchor.UpperLeft;
            }
            else
            {
                float width = 0;

                GUI.BeginGroup(new Rect(outRect.x + (outRect.width - fileButtonsWidth) / 2, outRect.yMax + 20, fileButtonsWidth, 40));
                DrawFileButtons(selectedFile, ref width);
                GUI.EndGroup();

                if (Event.current.type == EventType.layout)
                {
                    fileButtonsWidth = width;
                }
            }
        }
Exemple #24
0
        private void DrawDataSettings(Rect region)
        {
            var view    = new Rect(0f, 0f, region.width - 16f, Text.LineHeight * 32f);
            var listing = new Listing_Standard();

            GUI.BeginGroup(region);
            Widgets.BeginScrollView(region.AtZero(), ref _dataScrollPos, view);
            listing.Begin(view);

            listing.GroupHeader(_filesGroupHeader, false);

            (Rect dumpLabel, Rect dumpBtn) = listing.Split();
            UiHelper.Label(dumpLabel, _dumpStyleLabel);
            listing.DrawDescription(_dumpStyleDescription);

            if (Widgets.ButtonText(dumpBtn, $"TKUtils.DumpStyle.{TkSettings.DumpStyle}".Translate()))
            {
                Find.WindowStack.Add(_dumpStyleMenu);
            }

            listing.CheckboxLabeled(_minifyDataLabel, ref TkSettings.MinifyData);
            listing.DrawDescription(_minifyDataDescription);

            listing.CheckboxLabeled(_offloadShopLabel, ref TkSettings.Offload);
            listing.DrawDescription(_offloadShopDescription);
            listing.DrawExperimentalNotice();

            listing.CheckboxLabeled(_asapPurchasesLabel, ref TkSettings.AsapPurchases);
            listing.DrawDescription(_asapPurchasesDescription);
            listing.DrawExperimentalNotice();

            listing.CheckboxLabeled(_trueNeutralLabel, ref TkSettings.TrueNeutral);
            listing.DrawDescription(_trueNeutralDescription);
            listing.DrawExperimentalNotice();

            (Rect coinTypeLabel, Rect coinTypeField) = listing.Split();
            UiHelper.Label(coinTypeLabel, _broadcasterTypeLabel);
            listing.DrawDescription(_broadcasterTypeDescription);
            listing.DrawExperimentalNotice();

            if (Widgets.ButtonText(coinTypeField, $"TKUtils.BroadcasterUserType.{TkSettings.BroadcasterCoinType}".Translate()))
            {
                Find.WindowStack.Add(_broadcasterUserTypeMenu);
            }


            listing.GroupHeader(_lazyProcessGroupHeader);

            (Rect storeLabel, Rect storeField) = listing.Split();
            UiHelper.Label(storeLabel, _storeRateLabel);
            listing.DrawDescription(_storeRateDescription);

            if (UiHelper.NumberField(storeField, out int value, ref _buildRateBuffer, ref _buildRateBufferValid))
            {
                TkSettings.StoreBuildRate = value;
            }

            listing.End();
            Widgets.EndScrollView();
            GUI.EndGroup();
        }
        protected override void FillTab()
        {
            Text.Font = GameFont.Small;
            var curY  = 0f;
            var frame = new Rect(10f, 10f, size.x - 10f, size.y - 10f);

            GUI.BeginGroup(frame);
            Widgets.ListSeparator(ref curY, frame.width, labelKey.Translate());
            curY += 5f;

            // Sniper: t.Label also contains the count (Rice x20) do we want that?
            // Rider: This new search method is REALLLYYYYYY FAST
            // This is meant to stop a possible spam call of the Fuzzy Search
            if (itemsToShow == null || searchQuery != oldSearchQuery || SelectedMassStorageUnit.StoredItemsCount != itemsToShow.Count || oldSelectedMassStorageUnit == null || oldSelectedMassStorageUnit != SelectedMassStorageUnit)
            {
                itemsToShow = new List <Thing>(from Thing t in SelectedMassStorageUnit.StoredItems
                                               where string.IsNullOrEmpty(searchQuery) || t.Label.ToLower().NormalizedFuzzyStrength(searchQuery.ToLower()) <
                                               FuzzySearch.Strength.Strong
                                               orderby t.Label descending
                                               select t);
                oldSearchQuery = searchQuery;
            }
            oldSelectedMassStorageUnit = SelectedMassStorageUnit;

            var text        = SelectedMassStorageUnit.GetITabString(itemsToShow.Count);
            var MainTabText = new Rect(8f, curY, frame.width - 16f, Text.CalcHeight(text, frame.width - 16f));

            Widgets.Label(MainTabText, text);
            curY       += MainTabText.height;
            searchQuery = Widgets.TextField(new Rect(frame.x, curY, MainTabText.width - 16f, 25f),
                                            oldSearchQuery);
            curY += 28f;

            GUI.color = Color.white;
            var outRect  = new Rect(0f, curY, frame.width, frame.height - curY);
            var viewRect = new Rect(0f, 0f, outRect.width - 16f, scrollViewHeight);

            // Scrollview Start
            Widgets.BeginScrollView(outRect, ref scrollPos, viewRect);
            curY = 0f;
            if (itemsToShow.Count < 1)
            {
                Widgets.Label(viewRect, "PRFItemsTabLabel_Empty".Translate());
                curY += 22f;
            }

            // Iterate backwards to compensate for removing elements from enumerable
            // Learned this is an issue with List-like structures in AP CS 1A

            List <Pawn> pawns = SelectedMassStorageUnit.Map.mapPawns.FreeColonists;


            //Do it once as they are all on the same spot in the DSU
            //Even if is where to have multible sport's that way should work I think
            pawnCanReach_Touch_Deadly  = pawns.Where(p => p.CanReach(SelectedMassStorageUnit, PathEndMode.ClosestTouch, Danger.Deadly)).ToList();
            pawnCanReach_Oncell_Deadly = pawns.Where(p => p.CanReach(SelectedMassStorageUnit, PathEndMode.OnCell, Danger.Deadly)).ToList();



            for (var i = itemsToShow.Count - 1; i >= 0; i--)
            {
                //Check if we need to display it
                if (!itemIsVisible(curY, outRect.height, scrollPos.y))
                {
                    curY += 28;
                    continue;
                }

                Thing thing = itemsToShow[i];

                //Construct cache
                if (!canBeConsumedby.ContainsKey(thing))
                {
                    canBeConsumedby.Add(thing, pawns.Where(p => p.RaceProps.CanEverEat(thing) == true).ToList());
                }
                if (!thing_MaxHitPoints.ContainsKey(thing))
                {
                    thing_MaxHitPoints.Add(thing, thing.MaxHitPoints);
                }
                if (!thingIconCache.ContainsKey(thing))
                {
                    Color   color;
                    Texture texture = CommonGUIFunctions.GetThingTextue(new Rect(4f, curY, 28f, 28f), thing, out color);

                    thingIconCache.Add(thing, new thingIconTextureData(texture, color));
                }

                DrawThingRow(ref curY, viewRect.width, thing, pawns);
            }
            if (Event.current.type == EventType.Layout)
            {
                scrollViewHeight = curY + 30f;
            }
            //Scrollview End
            Widgets.EndScrollView();
            GUI.EndGroup();
            GUI.color   = Color.white;
            Text.Anchor = TextAnchor.UpperLeft;
        }
Exemple #26
0
        private void DrawCommandTweakSettings(Rect region)
        {
            var listing  = new Listing_Standard();
            var viewPort = new Rect(0f, 0f, region.width - 16f, Text.LineHeight * 48f);

            GUI.BeginGroup(region);
            Widgets.BeginScrollView(region.AtZero(), ref _commandTweakPos, viewPort);
            listing.Begin(viewPort);

            listing.GroupHeader(_balanceGroupHeader, false);
            listing.CheckboxLabeled(_coinRateLabel, ref TkSettings.ShowCoinRate);
            listing.DrawDescription(_coinRateDescription);


            listing.GroupHeader(_commandHandlerGroupHeader);

            if (TkSettings.Commands)
            {
                (Rect prefixLabel, Rect prefixField) = listing.Split();
                UiHelper.Label(prefixLabel, _commandPrefixLabel);
                listing.DrawDescription(_commandPrefixDescription);
                TkSettings.Prefix = CommandHelper.ValidatePrefix(Widgets.TextField(prefixField, TkSettings.Prefix));

                (Rect buyPrefixLabel, Rect buyPrefixField) = listing.Split();
                UiHelper.Label(buyPrefixLabel, _purchasePrefixLabel);
                listing.DrawDescription(_purchasePrefixDescription);
                TkSettings.BuyPrefix = CommandHelper.ValidatePrefix(Widgets.TextField(buyPrefixField, TkSettings.BuyPrefix));
            }

            listing.CheckboxLabeled(_commandParserLabel, ref TkSettings.Commands);
            listing.DrawDescription(_commandParserDescription);

            if (TkSettings.Commands)
            {
                listing.CheckboxLabeled(_toolkitStyleLabel, ref TkSettings.ToolkitStyleCommands);
                listing.DrawDescription(_toolkitStyleDescription);
            }

            if (UiHelper.LabeledPaintableCheckbox(listing.GetRect(Text.LineHeight), _commandRouterLabel, ref TkSettings.CommandRouter))
            {
                RuntimeChecker.ValidateTicker();
            }

            listing.DrawDescription(_commandRouterDescription);
            listing.DrawExperimentalNotice();

            listing.GroupHeader(_installedModsGroupHeader);
            listing.CheckboxLabeled(_decorateUtilsLabel, ref TkSettings.DecorateMods);
            listing.DrawDescription(_decorateUtilsDescription);

            listing.CheckboxLabeled(_versionedModListLabel, ref TkSettings.VersionedModList);
            listing.DrawDescription(_versionedModListDescription);


            listing.GroupHeader(_buyItemGroupHeader);
            listing.CheckboxLabeled(_buyItemBalanceLabel, ref TkSettings.BuyItemBalance);
            listing.DrawDescription(_buyItemBalanceDescription);
            listing.CheckboxLabeled(_itemSyntaxLabel, ref TkSettings.ForceFullItem);
            listing.DrawDescription(_itemSyntaxDescription);


            listing.GroupHeader(_lookupGroupHeader);

            (Rect limitLabel, Rect limitField) = listing.Split();
            var buffer = TkSettings.LookupLimit.ToString();

            UiHelper.Label(limitLabel, _lookupLimitLabel);
            Widgets.TextFieldNumeric(limitField, ref TkSettings.LookupLimit, ref buffer);
            listing.DrawDescription(_lookupLimitDescription);

            GUI.EndGroup();
            Widgets.EndScrollView();
            listing.End();
        }
Exemple #27
0
        private void DrawList <T>(string label, IList <T> entries, Func <T, string> entryString, ref Rect inRect, ref Vector2 scroll, Action <T> click = null, bool hideEmpty = false, string tooltip = null, Action <T, Rect> extra = null, Func <T, Color?> entryLabelColor = null)
        {
            if (hideEmpty && entries.Count == 0)
            {
                return;
            }

            Widgets.Label(inRect, label);
            inRect.yMin += 20f;

            float entryHeight = 24f;
            float height      = entries.Count * entryHeight;

            Rect outRect  = new Rect(0, inRect.yMin, inRect.width, Math.Min(height, Math.Min(230, inRect.height)));
            Rect viewRect = new Rect(0, 0, outRect.width - 16f, height);

            if (viewRect.height <= outRect.height)
            {
                viewRect.width += 16f;
            }

            Widgets.BeginScrollView(outRect, ref scroll, viewRect, true);
            GUI.color = new Color(1, 1, 1, 0.8f);

            float y = height;

            for (int i = entries.Count - 1; i >= 0; i--)
            {
                y -= entryHeight;

                T      entry      = entries[i];
                string entryLabel = entryString(entry);

                var entryRect = new Rect(0, y, viewRect.width, entryHeight);
                GUI.BeginGroup(entryRect);
                entryRect = entryRect.AtZero();

                if (i % 2 == 0)
                {
                    Widgets.DrawAltRect(entryRect);
                }

                if (Mouse.IsOver(entryRect))
                {
                    GUI.DrawTexture(entryRect, SelectedMsg);
                    if (click != null && Event.current.type == EventType.MouseUp)
                    {
                        click(entry);
                        Event.current.Use();
                    }
                }

                if (tooltip != null)
                {
                    TooltipHandler.TipRegion(entryRect, tooltip);
                }

                var prevColor  = GUI.color;
                var labelColor = entryLabelColor?.Invoke(entry);
                if (labelColor != null)
                {
                    GUI.color = labelColor.Value;
                }

                Text.Anchor = TextAnchor.MiddleLeft;
                Widgets.Label(entryRect, entryLabel);
                Text.Anchor = TextAnchor.UpperLeft;

                if (labelColor != null)
                {
                    GUI.color = prevColor;
                }

                extra?.Invoke(entry, entryRect);

                GUI.EndGroup();
            }

            GUI.color = Color.white;
            Widgets.EndScrollView();

            inRect.yMin += outRect.height;
        }
Exemple #28
0
        public void DoWindowContents(Rect inRect)
        {
            Listing_Standard listingStandard = new Listing_Standard();

            var scrollContainer = inRect.ContractedBy(10);

            scrollContainer.height -= listingStandard.CurHeight;
            scrollContainer.y      += listingStandard.CurHeight;
            Widgets.DrawBoxSolid(scrollContainer, Color.grey);
            var innerContainer = scrollContainer.ContractedBy(1);

            Widgets.DrawBoxSolid(innerContainer, new ColorInt(42, 43, 44).ToColor);
            var frameRect = innerContainer.ContractedBy(5);

            frameRect.y      += 15;
            frameRect.height -= 15;
            var contentRect = frameRect;

            contentRect.x      = 0;
            contentRect.y      = 0;
            contentRect.width -= 20;



            contentRect.height = 950f;


            Widgets.BeginScrollView(frameRect, ref scrollPosition, contentRect, true);
            listingStandard.Begin(contentRect.AtZero());


            //listingStandard.Begin(inRect);
            listingStandard.CheckboxLabeled("GR_DisableOldAgeDiseases".Translate(), ref GR_DisableOldAgeDiseases, "GR_DisableOldAgeDiseasesTooltip".Translate());
            listingStandard.CheckboxLabeled("GR_DisableHybridRaids".Translate(), ref GR_DisableHybridRaids, "GR_DisableHybridRaidsTooltip".Translate());
            listingStandard.CheckboxLabeled("GR_MakeAllHybridsFertile".Translate(), ref GR_MakeAllHybridsFertile, "GR_MakeAllHybridsFertileTooltip".Translate());
            listingStandard.CheckboxLabeled("GR_MakeAllHybridsControllable".Translate(), ref GR_MakeAllHybridsControllable, "GR_MakeAllHybridsControllableTooltip".Translate());
            listingStandard.CheckboxLabeled("GR_DisableGrowthCellAlerts".Translate(), ref GR_DisableGrowthCellAlerts, "GR_DisableGrowthCellAlertsTooltip".Translate());
            listingStandard.CheckboxLabeled("GR_DisableWombAlerts".Translate(), ref GR_DisableWombAlerts, "GR_DisableWombAlertsTooltip".Translate());
            listingStandard.CheckboxLabeled("GR_DisableMechanoidIFF".Translate(), ref GR_DisableMechanoidIFF, "GR_DisableMechanoidIFFTooltip".Translate());
            listingStandard.CheckboxLabeled("GR_DisableGreaterScariaRotting".Translate(), ref GR_DisableGreaterScariaRotting, "GR_DisableGreaterScariaRottingTooltip".Translate());


            listingStandard.GapLine();
            var GenomorpherSpeedMultiplierLabel = listingStandard.LabelPlusButton("GR_GenomorpherSpeedMultiplier".Translate() + ": " + GR_GenomorpherSpeedMultiplier, "GR_GenomorpherSpeedMultiplierTooltip".Translate());

            GR_GenomorpherSpeedMultiplier = (float)Math.Round(listingStandard.Slider(GR_GenomorpherSpeedMultiplier, 0.1f, 2f), 2);
            if (listingStandard.Settings_Button("GR_Reset".Translate(), new Rect(0f, GenomorpherSpeedMultiplierLabel.position.y + 35, 180f, 29f)))
            {
                GR_GenomorpherSpeedMultiplier = GR_GenomorpherSpeedMultiplierBase;
            }

            var WombSpeedMultiplierLabel = listingStandard.LabelPlusButton("GR_WombSpeedMultiplier".Translate() + ": " + GR_WombSpeedMultiplier, "GR_WombMultiplierTooltip".Translate());

            GR_WombSpeedMultiplier = (float)Math.Round(listingStandard.Slider(GR_WombSpeedMultiplier, 0.1f, 2f), 2);
            if (listingStandard.Settings_Button("GR_Reset".Translate(), new Rect(0f, WombSpeedMultiplierLabel.position.y + 35, 180f, 29f)))
            {
                GR_WombSpeedMultiplier = GR_WombSpeedMultiplierBase;
            }

            var FailureRateLabel = listingStandard.LabelPlusButton("GR_FailureRate".Translate() + ": " + GR_FailureRate + "%", "GR_FailureRateTooltip".Translate());

            GR_FailureRate = (float)Math.Round(listingStandard.Slider(GR_FailureRate, -50f, 100f), 1);
            if (listingStandard.Settings_Button("GR_Reset".Translate(), new Rect(0f, FailureRateLabel.position.y + 35, 180f, 29f)))
            {
                GR_FailureRate = GR_FailureRateBase;
            }

            var QuestRateLabel = listingStandard.LabelPlusButton("GR_QuestRate".Translate() + ": " + GR_QuestRate, "GR_QuestRateTooltip".Translate());

            GR_QuestRate = (float)Math.Round(listingStandard.Slider(GR_QuestRate, 0.1f, 5f), 1);
            if (listingStandard.Settings_Button("GR_Reset".Translate(), new Rect(0f, QuestRateLabel.position.y + 35, 180f, 29f)))
            {
                GR_QuestRate = GR_QuestRateBase;
            }

            var RaidsRateLabel = listingStandard.LabelPlusButton("GR_RaidsRate".Translate() + ": " + GR_RaidsRate, "GR_RaidsRateTooltip".Translate());

            GR_RaidsRate = (float)Math.Round(listingStandard.Slider(GR_RaidsRate, 0.1f, 5f), 1);
            if (listingStandard.Settings_Button("GR_Reset".Translate(), new Rect(0f, RaidsRateLabel.position.y + 35, 180f, 29f)))
            {
                GR_RaidsRate = GR_RaidsRateBase;
            }

            var HybridsPerAntennaLabel = listingStandard.LabelPlusButton("GR_HybridsPerAntenna".Translate() + ": " + GR_HybridsPerAntenna, "GR_HybridsPerAntennaTooltip".Translate());

            GR_HybridsPerAntenna = (int)(listingStandard.Slider(GR_HybridsPerAntenna, 1f, 50f));
            if (listingStandard.Settings_Button("GR_Reset".Translate(), new Rect(0f, HybridsPerAntennaLabel.position.y + 35, 180f, 29f)))
            {
                GR_HybridsPerAntenna = GR_HybridsPerAntennaBase;
            }

            var HybridSpawnerRadiusLabel = listingStandard.LabelPlusButton("GR_HybridSpawnerRadius".Translate() + ": " + GR_HybridSpawnerRadius, "GR_HybridSpawnerRadiusTooltip".Translate());

            GR_HybridSpawnerRadius = (int)(listingStandard.Slider(GR_HybridSpawnerRadius, 5f, 40f));
            if (listingStandard.Settings_Button("GR_Reset".Translate(), new Rect(0f, HybridSpawnerRadiusLabel.position.y + 35, 180f, 29f)))
            {
                GR_HybridSpawnerRadius = GR_HybridSpawnerRadiusBase;
            }


            listingStandard.End();
            Widgets.EndScrollView();

            base.Write();
        }
        public override void DoWindowContents(Rect inRect)
        {
            Vector2 vector  = new Vector2(inRect.width - 16, 36);
            Vector2 vector2 = new Vector2(100, vector.y - 6);

            inRect.height -= 45;
            List <FileInfo> list     = PresetFiles.AllFiles.ToList <FileInfo>();
            float           num      = vector.y + 3;
            float           height   = (float)list.Count * num;
            Rect            viewRect = new Rect(0, 0, inRect.width - 16, height);
            Rect            outRect  = new Rect(inRect.AtZero());

            outRect.height -= this.bottomAreaHeight;
            Widgets.BeginScrollView(outRect, ref this.scrollPosition, viewRect);
            float num2 = 0;
            int   num3 = 0;

            foreach (FileInfo current in list)
            {
                Rect rect = new Rect(0, num2, vector.x, vector.y);
                if (num3 % 2 == 0)
                {
                    GUI.DrawTexture(rect, Textures.TextureAlternateRow);
                }
                Rect innerRect = rect.ContractedBy(3);
                GUI.BeginGroup(innerRect);
                string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(current.Name);
                GUI.color = ManualSaveTextColor;
                Rect rect2 = new Rect(15, 0, innerRect.width, innerRect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                Text.Font   = GameFont.Small;
                Widgets.Label(rect2, fileNameWithoutExtension);
                GUI.color = Color.white;
                Rect rect3 = new Rect(250, 0, innerRect.width, innerRect.height);
                Text.Font = GameFont.Tiny;
                GUI.color = new Color(1, 1, 1, 0.5f);
                Widgets.Label(rect3, current.LastWriteTime.ToString("g"));
                GUI.color   = Color.white;
                Text.Anchor = TextAnchor.UpperLeft;
                Text.Font   = GameFont.Small;
                float num4    = vector.x - 6 - vector2.x - vector2.y;
                Rect  butRect = new Rect(num4, 0, vector2.x, vector2.y);
                if (Widgets.ButtonText(butRect, this.interactButLabel, true, false, true))
                {
                    this.DoMapEntryInteraction(Path.GetFileNameWithoutExtension(current.Name));
                }
                Rect rect4 = new Rect(num4 + vector2.x + 5, 0, vector2.y, vector2.y);
                if (Widgets.ButtonImage(rect4, Textures.TextureDeleteX))
                {
                    FileInfo localFile = current;
                    Find.UIRoot.windows.Add(new Dialog_Confirm("EdB.PC.Dialog.Preset.ConfirmDelete".Translate(new object[] {
                        localFile.Name
                    }), delegate {
                        localFile.Delete();
                    }, true, null, true));
                }
                TooltipHandler.TipRegion(rect4, "EdB.PC.Dialog.Preset.DeleteTooltip".Translate());
                GUI.EndGroup();
                num2 += vector.y + 3;
                num3++;
            }
            Widgets.EndScrollView();
            this.DoSpecialSaveLoadGUI(inRect.AtZero());
        }
        protected override void FillTab()
        {
            Rect outRect = new Rect(0f, 0f, WinSize.x, WinSize.y).ContractedBy(10f);
            Rect rect    = new Rect(0f, 0f, outRect.width - 16f, Mathf.Max(lastDrawnHeight, outRect.height));

            Widgets.BeginScrollView(outRect, ref scrollPosition, rect);
            Text.Font = GameFont.Medium;
            Widgets.Label(rect, base.SelTile.biome.LabelCap);
            Rect rect2 = rect;

            rect2.yMin  += 35f;
            rect2.height = 99999f;
            Text.Font    = GameFont.Small;
            Listing_Standard listing_Standard = new Listing_Standard();

            listing_Standard.verticalSpacing = 0f;
            listing_Standard.Begin(rect2);
            Tile selTile   = base.SelTile;
            int  selTileID = base.SelTileID;

            listing_Standard.Label(selTile.biome.description);
            listing_Standard.Gap(8f);
            listing_Standard.GapLine();
            if (!selTile.biome.implemented)
            {
                listing_Standard.Label(selTile.biome.LabelCap + " " + "BiomeNotImplemented".Translate());
            }
            listing_Standard.LabelDouble("Terrain".Translate(), selTile.hilliness.GetLabelCap());
            if (selTile.Roads != null)
            {
                listing_Standard.LabelDouble("Road".Translate(), selTile.Roads.Select((Tile.RoadLink roadlink) => roadlink.road.label).Distinct().ToCommaList(useAnd: true)
                                             .CapitalizeFirst());
            }
            if (selTile.Rivers != null)
            {
                listing_Standard.LabelDouble("River".Translate(), selTile.Rivers.MaxBy((Tile.RiverLink riverlink) => riverlink.river.degradeThreshold).river.LabelCap);
            }
            if (!Find.World.Impassable(selTileID))
            {
                StringBuilder stringBuilder = new StringBuilder();
                string        rightLabel    = (WorldPathGrid.CalculatedMovementDifficultyAt(selTileID, perceivedStatic: false, null, stringBuilder) * Find.WorldGrid.GetRoadMovementDifficultyMultiplier(selTileID, -1, stringBuilder)).ToString("0.#");
                if (WorldPathGrid.WillWinterEverAffectMovementDifficulty(selTileID) && WorldPathGrid.GetCurrentWinterMovementDifficultyOffset(selTileID) < 2f)
                {
                    stringBuilder.AppendLine();
                    stringBuilder.AppendLine();
                    stringBuilder.Append(" (");
                    stringBuilder.Append("MovementDifficultyOffsetInWinter".Translate("+" + 2f.ToString("0.#")));
                    stringBuilder.Append(")");
                }
                listing_Standard.LabelDouble("MovementDifficulty".Translate(), rightLabel, stringBuilder.ToString());
            }
            if (selTile.biome.canBuildBase)
            {
                listing_Standard.LabelDouble("StoneTypesHere".Translate(), (from rt in Find.World.NaturalRockTypesIn(selTileID)
                                                                            select rt.label).ToCommaList(useAnd: true).CapitalizeFirst());
            }
            listing_Standard.LabelDouble("Elevation".Translate(), selTile.elevation.ToString("F0") + "m");
            listing_Standard.GapLine();
            listing_Standard.LabelDouble("AvgTemp".Translate(), GenTemperature.GetAverageTemperatureLabel(selTileID));
            listing_Standard.LabelDouble("OutdoorGrowingPeriod".Translate(), Zone_Growing.GrowingQuadrumsDescription(selTileID));
            listing_Standard.LabelDouble("Rainfall".Translate(), selTile.rainfall.ToString("F0") + "mm");
            if (selTile.biome.foragedFood != null && selTile.biome.forageability > 0f)
            {
                listing_Standard.LabelDouble("Forageability".Translate(), selTile.biome.forageability.ToStringPercent() + " (" + selTile.biome.foragedFood.label + ")");
            }
            else
            {
                listing_Standard.LabelDouble("Forageability".Translate(), "0%");
            }
            listing_Standard.LabelDouble("AnimalsCanGrazeNow".Translate(), VirtualPlantsUtility.EnvironmentAllowsEatingVirtualPlantsNowAt(selTileID) ? "Yes".Translate() : "No".Translate());
            listing_Standard.GapLine();
            listing_Standard.LabelDouble("AverageDiseaseFrequency".Translate(), string.Format("{0} {1}", (60f / selTile.biome.diseaseMtbDays).ToString("F1"), "PerYear".Translate()));
            listing_Standard.LabelDouble("TimeZone".Translate(), GenDate.TimeZoneAt(Find.WorldGrid.LongLatOf(selTileID).x).ToStringWithSign());
            StringBuilder stringBuilder2 = new StringBuilder();
            Rot4          rot            = Find.World.CoastDirectionAt(selTileID);

            if (rot.IsValid)
            {
                stringBuilder2.AppendWithComma(("HasCoast" + rot.ToString()).Translate());
            }
            if (Find.World.HasCaves(selTileID))
            {
                stringBuilder2.AppendWithComma("HasCaves".Translate());
            }
            if (stringBuilder2.Length > 0)
            {
                listing_Standard.LabelDouble("SpecialFeatures".Translate(), stringBuilder2.ToString().CapitalizeFirst());
            }
            if (Prefs.DevMode)
            {
                listing_Standard.LabelDouble("Debug world tile ID", selTileID.ToString());
            }
            lastDrawnHeight = rect2.y + listing_Standard.CurHeight;
            listing_Standard.End();
            Widgets.EndScrollView();
        }