예제 #1
0
        public override void DoSettingsWindowContents(Rect inRect)
        {
            base.DoSettingsWindowContents(inRect);
            Listing_Standard listingStandard = new Listing_Standard();

            Rect menuRect = inRect.ContractedBy(10f);

            menuRect.y      += 20f;
            menuRect.height -= 20f;

            Widgets.DrawMenuSection(menuRect);
            TabDrawer.DrawTabs(menuRect, tabs, 200f);

            CurrentSection.DrawSection(menuRect);

            /* Reset Buttons */
            float padding        = ResetImageSize + 5;
            Rect  resetAllButton = new Rect(menuRect.width - padding, menuRect.y + 15, ResetImageSize, ResetImageSize);
            Rect  resetButton    = new Rect(resetAllButton.x - padding, resetAllButton.y, ResetImageSize, ResetImageSize);

            listingStandard.Begin(resetAllButton);
            if (listingStandard.ButtonImage(VehicleTex.ResetPage, ResetImageSize, ResetImageSize))
            {
                List <FloatMenuOption> options = CurrentSection.ResetOptions.ToList();
                FloatMenu floatMenu            = new FloatMenu(options)
                {
                    vanishIfMouseDistant = true
                };
                //floatMenu.onCloseCallback...
                Find.WindowStack.Add(floatMenu);
            }
            listingStandard.End();
        }
예제 #2
0
        public override void DoWindowContents(Rect inRect)
        {
            inRect.yMin += 15f;
            inRect.yMax -= 15f;
            var defaultColumnWidth = (inRect.width - 50);
            Listing_Standard list  = new Listing_Standard()
            {
                ColumnWidth = defaultColumnWidth - 20
            };

            //Image logo
            Widgets.ButtonImage(new Rect(0, 0, inRect.width, 80), Tex.TexUISkillLogo, Color.white, Color.white);

            var outRect    = new Rect(inRect.x, inRect.y + 100, inRect.width, inRect.height - 245);
            var scrollRect = new Rect(0f, 100f, inRect.width - 16f, inRect.height * 2.5f + 50);

            Widgets.BeginScrollView(outRect, ref scrollPosition, scrollRect, true);

            list.Begin(scrollRect);

            GUI.color = Color.yellow;
            list.Label("=> " + android.LabelShort);
            GUI.color = Color.white;
            list.Gap();

            SkillRecord sr;
            int         availableSkillPoints = Utils.GCATPP.getNbSkillPoints();
            int         nbPointsBuyable      = 0;

            if (pointsNeededPerSkill != 0)
            {
                nbPointsBuyable = (int)Math.Floor((double)(availableSkillPoints / pointsNeededPerSkill));
            }

            //Controles de selection des points a acheter
            for (int i = 0; i != sd.Count; i++)
            {
                int    p    = points[i];
                string comp = "";
                sr = android.skills.GetSkill(sd[i]);
                if (sr != null && !sr.TotallyDisabled)
                {
                    if (points[i] != 0)
                    {
                        comp = "+" + points[i];
                    }

                    if (comp != "")
                    {
                        GUI.color = Color.green;
                    }
                    list.Label(libs[i] + " " + sr.levelInt + "/20 " + comp);
                    if (comp != null)
                    {
                        GUI.color = Color.white;
                    }

                    p = (int)list.Slider(p, 0, 20);

                    //Check possibilité action
                    if (p + sr.levelInt < 20 && (p + getNbPointsWantedToBuy(i)) <= nbPointsBuyable)
                    {
                        //On peut les acheter
                        points[i] = p;
                    }

                    //Partie gestion des passions
                    if (passionsState[i] == -1)
                    {
                        list.ButtonImage(Tex.PassionDisabled, 24, 24);
                    }
                    else
                    {
                        Texture2D tex = Tex.NoPassion;
                        bool      max = false;

                        if (passionsState[i] == (int)Passion.Minor)
                        {
                            tex = Tex.MinorPassion;
                        }
                        else if (passionsState[i] == (int)Passion.Major)
                        {
                            tex = Tex.MajorPassion;
                            max = true;
                        }

                        if (list.ButtonImage(tex, 24, 24))
                        {
                            if (!max)
                            {
                                //Check player a les moyens
                                int locNbWantedPoints  = getNbPointsWantedToBuy();
                                int locAvailablePoints = nbPointsBuyable - locNbWantedPoints;

                                if (locAvailablePoints - pointsNeededToIncreasePassion >= 0)
                                {
                                    passionsState[i]++;
                                }
                                else
                                {
                                    passionsState[i] = (int)sr.passion;
                                    Messages.Message("ATPP_NotEnoughtSkillPoints".Translate(pointsNeededToIncreasePassion), MessageTypeDefOf.NegativeEvent);
                                }
                            }
                            else
                            {
                                passionsState[i] = (int)sr.passion;
                            }
                        }
                    }

                    list.GapLine();
                }
            }


            int nbWantedPoints  = getNbPointsWantedToBuy();
            int availablePoints = nbPointsBuyable - nbWantedPoints;

            list.End();
            Widgets.EndScrollView();

            //Affichage nb points
            if (availablePoints > 0)
            {
                GUI.color = Color.green;
            }
            Widgets.Label(new Rect(0, inRect.height - 115f, inRect.width - 30f, 35f), "ATPP_SkillsWorkshopAvailablePoints".Translate(availablePoints));

            GUI.color = Color.cyan;
            Widgets.Label(new Rect(0, inRect.height - 95f, inRect.width - 30f, 45f), "ATPP_SkillsWorkshopAvailablePointsNote".Translate(pointsNeededPerSkill));
            GUI.color = Color.white;

            //Validation
            if (nbWantedPoints != 0)
            {
                GUI.color = Color.green;
            }
            else
            {
                GUI.color = Color.gray;
            }

            if (Widgets.ButtonText(new Rect(0, inRect.height - 45f, inRect.width, 35f), "OK".Translate(), true, false, true))
            {
                if (nbWantedPoints == 0)
                {
                    return;
                }

                GUI.color = Color.white;

                //Decrementation des points de skills
                Utils.GCATPP.decSkillPoints(nbWantedPoints * pointsNeededPerSkill);

                //Incrementation effective des points
                for (int i = 0; i != sd.Count; i++)
                {
                    sr = android.skills.GetSkill(sd[i]);
                    if (sr != null)
                    {
                        sr.levelInt += points[i];

                        int diff = passionsState[i] - (int)sr.passion;
                        if (diff > 0)
                        {
                            sr.passion = (Passion)passionsState[i];
                        }
                    }
                }

                Messages.Message("ATPP_SkillsWorkshopPointsConverted".Translate(nbWantedPoints, android.LabelShortCap), MessageTypeDefOf.PositiveEvent);

                Find.WindowStack.TryRemove(this, true);
            }
            GUI.color = Color.white;
            //Annulation
            GUI.color = Color.red;
            if (Widgets.ButtonText(new Rect(0, inRect.height - 10f, inRect.width, 35f), "Back".Translate(), true, false, true))
            {
                GUI.color = Color.white;
                Find.WindowStack.TryRemove(this, true);
            }
            GUI.color = Color.white;
        }
예제 #3
0
        public override void DoWindowContents(Rect inRect)
        {
            inRect.yMin += 15f;
            inRect.yMax -= 15f;
            var defaultColumnWidth = inRect.width - 50;
            var list = new Listing_Standard {
                ColumnWidth = defaultColumnWidth - 20
            };


            Widgets.ButtonImage(new Rect(0, 0, inRect.width, 80), Tex.TexUISkillLogo, Color.white, Color.white);

            var outRect    = new Rect(inRect.x, inRect.y + 100, inRect.width, inRect.height - 245);
            var scrollRect = new Rect(0f, 100f, inRect.width - 16f, inRect.height * 2.5f + 50);

            Widgets.BeginScrollView(outRect, ref scrollPosition, scrollRect);

            list.Begin(scrollRect);

            GUI.color = Color.yellow;
            list.Label("=> " + android.LabelShort);
            GUI.color = Color.white;
            list.Gap();

            SkillRecord sr;
            var         availableSkillPoints = Utils.GCATPP.getNbSkillPoints();
            var         nbPointsBuyable      = 0;

            if (pointsNeededPerSkill != 0)
            {
                nbPointsBuyable = (int)Math.Floor((double)(availableSkillPoints / pointsNeededPerSkill));
            }


            for (var i = 0; i != sd.Count; i++)
            {
                var p    = points[i];
                var comp = "";
                sr = android.skills.GetSkill(sd[i]);
                if (sr == null || sr.TotallyDisabled)
                {
                    continue;
                }

                if (points[i] != 0)
                {
                    comp = "+" + points[i];
                }

                if (comp != "")
                {
                    GUI.color = Color.green;
                }
                list.Label(libs[i] + " " + sr.levelInt + "/20 " + comp);
                GUI.color = Color.white;

                p = (int)list.Slider(p, 0, 20);


                if (p + sr.levelInt < 20 && p + getNbPointsWantedToBuy(i) <= nbPointsBuyable)
                {
                    points[i] = p;
                }


                if (passionsState[i] == -1)
                {
                    list.ButtonImage(Tex.PassionDisabled, 24, 24);
                }
                else
                {
                    var tex = Tex.NoPassion;
                    var max = false;

                    switch (passionsState[i])
                    {
                    case (int)Passion.Minor:
                        tex = Tex.MinorPassion;
                        break;

                    case (int)Passion.Major:
                        tex = Tex.MajorPassion;
                        max = true;
                        break;
                    }

                    if (list.ButtonImage(tex, 24, 24))
                    {
                        if (!max)
                        {
                            var locNbWantedPoints  = getNbPointsWantedToBuy();
                            var locAvailablePoints = nbPointsBuyable - locNbWantedPoints;

                            if (locAvailablePoints - pointsNeededToIncreasePassion >= 0)
                            {
                                passionsState[i]++;
                            }
                            else
                            {
                                passionsState[i] = (int)sr.passion;
                                Messages.Message("ATPP_NotEnoughtSkillPoints".Translate(pointsNeededToIncreasePassion), MessageTypeDefOf.NegativeEvent);
                            }
                        }
                        else
                        {
                            passionsState[i] = (int)sr.passion;
                        }
                    }
                }

                list.GapLine();
            }


            var nbWantedPoints  = getNbPointsWantedToBuy();
            var availablePoints = nbPointsBuyable - nbWantedPoints;

            list.End();
            Widgets.EndScrollView();


            if (availablePoints > 0)
            {
                GUI.color = Color.green;
            }
            Widgets.Label(new Rect(0, inRect.height - 115f, inRect.width - 30f, 35f), "ATPP_SkillsWorkshopAvailablePoints".Translate(availablePoints));

            GUI.color = Color.cyan;
            Widgets.Label(new Rect(0, inRect.height - 95f, inRect.width - 30f, 45f), "ATPP_SkillsWorkshopAvailablePointsNote".Translate(pointsNeededPerSkill));
            GUI.color = Color.white;


            GUI.color = nbWantedPoints != 0 ? Color.green : Color.gray;

            if (Widgets.ButtonText(new Rect(0, inRect.height - 45f, inRect.width, 35f), "OK".Translate(), true, false))
            {
                if (nbWantedPoints == 0)
                {
                    return;
                }

                GUI.color = Color.white;


                Utils.GCATPP.decSkillPoints(nbWantedPoints * pointsNeededPerSkill);


                for (var i = 0; i != sd.Count; i++)
                {
                    sr = android.skills.GetSkill(sd[i]);
                    if (sr != null)
                    {
                        sr.levelInt += points[i];

                        var diff = passionsState[i] - (int)sr.passion;
                        if (diff > 0)
                        {
                            sr.passion = (Passion)passionsState[i];
                        }
                    }
                }

                Messages.Message("ATPP_SkillsWorkshopPointsConverted".Translate(nbWantedPoints, android.LabelShortCap), MessageTypeDefOf.PositiveEvent);

                Find.WindowStack.TryRemove(this);
            }

            GUI.color = Color.white;

            GUI.color = Color.red;
            if (Widgets.ButtonText(new Rect(0, inRect.height - 10f, inRect.width, 35f), "Back".Translate(), true, false))
            {
                GUI.color = Color.white;
                Find.WindowStack.TryRemove(this);
            }

            GUI.color = Color.white;
        }
예제 #4
0
        public void DrawWindow(Rect rect)
        {
            // Draw all settings.
            Listing_Standard listing = new Listing_Standard();

            listing.Begin(new Rect(rect.x, rect.y, Mathf.Min(rect.width, 320), rect.height));

            listing.Label("<color=yellow>" + "WTM_RequireRestart".Translate() + "</color>");
            listing.GapLine();

            listing.CheckboxLabeled("WTM_FlagVanilla".Translate(), ref FlagVanilla, "WTM_FlagVanilla_Desc".Translate(VanillaName.Trim()));
            VanillaName = listing.TextEntryLabeled("WTM_VanillaName".Translate(), VanillaName);
            listing.Gap();

            listing.Label("<b>" + "WTM_VisualOptions".Translate() + "</b>");

            listing.Label("WTM_Format".Translate(), tooltip: "WTM_Format_Desc".Translate());
            Format = listing.TextEntry(Format);
            if (!Format.Contains("{0}"))
            {
                listing.Label("<color=red>" + "WTM_Format_MissingTag".Translate() + "</color>");
            }
            try
            {
                _ = string.Format(Format.Replace('[', '(').Replace(']', ')'), "ExampleModName");
            }
            catch (Exception e)
            {
                _ = e;
                listing.Label("<color=red>" + "WTM_Format_FormatError".Translate() + "</color>");
            }

            listing.CheckboxLabeled("WTM_Italics".Translate(), ref Italics, "WTM_Italics_Desc".Translate());
            listing.CheckboxLabeled("WTM_Bold".Translate(), ref Bold, "WTM_Bold_Desc".Translate());

            listing.Label("WTM_CustomSize".Translate(CustomSize), tooltip: "WTM_CustomSize_Desc".Translate());
            listing.IntEntry(ref CustomSize, ref fontSizeBuffer);
            CustomSize     = Mathf.Clamp(CustomSize, 0, 64);
            fontSizeBuffer = CustomSize.ToString();

            listing.Label("WTM_BlankLines".Translate(BlankLines), tooltip: "WTM_BlankLines_Desc".Translate());
            listing.IntEntry(ref BlankLines, ref blankLinesBuffer);
            BlankLines       = Mathf.Clamp(BlankLines, 0, 12);
            blankLinesBuffer = BlankLines.ToString();

            listing.Label("WTM_SelectFontColor".Translate(), tooltip: "WTM_SelectFontColor_Desc".Translate());
            bool openColorPicker = listing.ButtonImage(GetCurrentColorTexture(), 100, 32);

            if (openColorPicker)
            {
                OpenColorPicker();
            }

            // Do preview box.
            float y          = listing.CurHeight + rect.y - 30;
            Rect  previewBox = new Rect(rect.x, y, 310, 170);

            Widgets.DrawBox(previewBox);
            previewBox = previewBox.ExpandedBy(-5);
            string rawText  = "WTM_ExampleDescription".Translate();
            string template = ModCore.MakeTemplate(this);
            string text     = ModCore.MakeNewDescription(rawText, "Example Mod", template, false);

            Widgets.Label(previewBox, text);

            listing.End();

            listing = new Listing_Standard();
            listing.Begin(new Rect(rect.x + 350, rect.y, 320, rect.height));
            if (listing.ButtonText($"{(showAdvanced ? "WTM_Hide".Translate() : "WTM_Show".Translate())} {"WTM_AdvancedSettings".Translate()}"))
            {
                showAdvanced = !showAdvanced;
            }

            if (showAdvanced)
            {
                // Draw advanced settings.
                listing.GapLine();

                listing.CheckboxLabeled("WTM_CECompat".Translate(), ref CECompat, "WTM_CECompat_Desc".Translate());
                listing.CheckboxLabeled("WTM_DetectPatched".Translate(), ref DetectPatched, "WTM_DetectPatched_Desc".Translate());

                if (!DetectPatched)
                {
                    GUI.enabled = false;
                }
                listing.CheckboxLabeled("WTM_UltraDeepMode".Translate(), ref UltraDeepMode, "WTM_UltraDeepMode_Desc".Translate());
                GUI.enabled = true;

                listing.CheckboxLabeled("WTM_ZooLabel".Translate(), ref ZooModeEnabled, "WTM_ZooDesc".Translate());
                if (ZooModeEnabled)
                {
                    listing.CheckboxLabeled("WTM_ZooMultiLabel".Translate(), ref ZooModeMultithread, "WTM_ZooMultiDesc".Translate());
                }

                listing.Label("WTM_ExcludedMods".Translate(), tooltip: "WTM_ExcludedMods_Desc".Translate());
                bool addNew      = listing.ButtonText("WTM_AddNew".Translate());
                bool removeBlank = listing.ButtonText("WTM_RemoveBlank".Translate());
                listing.Gap();

                if (addNew)
                {
                    ExcludedMods.Add("");
                }
                if (removeBlank)
                {
                    for (int i = 0; i < ExcludedMods.Count; i++)
                    {
                        string txt = ExcludedMods[i];
                        if (string.IsNullOrWhiteSpace(txt))
                        {
                            ExcludedMods.RemoveAt(i);
                            i--;
                        }
                    }
                }
                for (int i = 0; i < ExcludedMods.Count; i++)
                {
                    var mod = ExcludedMods[i];
                    mod             = listing.TextEntry(mod);
                    ExcludedMods[i] = mod;

                    string final = mod.Trim();
                    var    meta  = ModLister.GetModWithIdentifier(final, true);
                    string msg   = meta == null ? "WTM_ModNotFound".Translate() : "WTM_ModFound".Translate(meta.Name);
                    string color = meta == null ? "red" : "green";
                    listing.Label($"<color={color}>{msg}</color>");
                    listing.GapLine();
                }
            }

            listing.End();
        }