Ejemplo n.º 1
0
        public static void HediffTab(
            Rect inRect
            )
        {
            int hediffcount = SettingsCache.GetAllHediffs.Count;

            if (DrawSettings._numberOfCustomHediffs == null)
            {
                DrawSettings._numberOfCustomHediffs =
                    Storage.HediffLightMods.Count(hlm => hlm.Value.IntSetting == VisionType.NVCustom);
            }

            inRect = inRect.AtZero();

            SettingsHelpers.DrawLightModifiersHeader(
                ref inRect,
                "NVHediffs".Translate(),
                "NVHediffNote".Translate() + "NVHediffNoteCont".Translate()
                );

            float num = inRect.y + 3f;

            var viewRect = new Rect(
                inRect.x,
                inRect.y,
                inRect.width * 0.9f,
                hediffcount
                * (Constants.RowHeight + Constants.RowGap)
                + (float)DrawSettings._numberOfCustomHediffs * 100f
                );

            var rowRect = new Rect(inRect.x + 6f, num, inRect.width - 12f, Constants.RowHeight);

            Widgets.BeginScrollView(inRect, ref DrawSettings._hediffScrollPosition, viewRect);

            for (var i = 0; i < hediffcount; i++)
            {
                HediffDef hediffdef = SettingsCache.GetAllHediffs[i];
                rowRect.y = num;

                if (Storage.HediffLightMods.TryGetValue(hediffdef, out Hediff_LightModifiers hediffmods))
                {
                    DrawSettings._numberOfCustomHediffs +=
                        SettingsHelpers.DrawLightModifiersRow(
                            hediffdef,
                            hediffmods,
                            rowRect,
                            ref num,
                            false
                            );
                }
                else
                {
                    Hediff_LightModifiers temp = Storage.AllEyeHediffs.Contains(hediffdef)
                                ? new Hediff_LightModifiers {
                        AffectsEye = true
                    }
                                : new Hediff_LightModifiers();

                    DrawSettings._numberOfCustomHediffs +=
                        SettingsHelpers.DrawLightModifiersRow(
                            hediffdef,
                            temp,
                            rowRect,
                            ref num,
                            false
                            );

                    if (temp.IntSetting != VisionType.NVNone)
                    {
                        temp.InitialiseNewFromSettings(hediffdef);
                        Storage.HediffLightMods[hediffdef] = temp;
                    }
                }

                num += Constants.RowHeight + Constants.RowGap;

                if (i < hediffcount)
                {
                    Widgets.DrawLineHorizontal(
                        rowRect.x + 6f,
                        num - (Constants.RowGap / 2 - 0.5f),
                        rowRect.width - 12f
                        );
                }
            }

            Widgets.EndScrollView();
        }
Ejemplo n.º 2
0
        public void DrawTab(Rect inRect)
        {
            var raceCount = Settings.Store.RaceLightMods.Count;

            if (_numberOfCustomRaces == null)
            {
                _numberOfCustomRaces =
                    Settings.Store.RaceLightMods.Count(rlm => rlm.Value.IntSetting == VisionType.NVCustom);
            }

            inRect = inRect.AtZero();
            SettingsHelpers.DrawLightModifiersHeader(ref inRect, "NVRaces".Translate(), "NVRaceNote".Translate());

            var heightMarker = inRect.y + 3f;

            var viewRect = new Rect(
                inRect.x,
                inRect.y,
                inRect.width * 0.9f,
                raceCount
                * (Constants.ROW_HEIGHT + Constants.ROW_GAP)
                + (float)_numberOfCustomRaces * 100f
                );

            var rowRect = new Rect(inRect.x + 6f, heightMarker, inRect.width - 12f, Constants.ROW_HEIGHT);

            Widgets.BeginScrollView(inRect, ref _raceScrollPosition, viewRect);
            var count = 0;

            foreach (KeyValuePair <ThingDef, Race_LightModifiers> kvp in Settings.Store.RaceLightMods)
            {
                var givenColor = GUI.color;
                rowRect.y = heightMarker;

                if (!kvp.Value.ShouldShowInSettings)
                {
                    if (!Prefs.DevMode)
                    {
                        continue;
                    }

                    GUI.color = Color.grey;
                    Widgets.Label(rowRect.TopPartPixels(20f), "NVDevModeOnly".Translate());
                    rowRect.y    += 20;
                    heightMarker += 20;
                }

                _numberOfCustomRaces +=
                    SettingsHelpers.DrawLightModifiersRow(kvp.Key, kvp.Value, rowRect, ref heightMarker, true);

                if (!kvp.Value.ShouldShowInSettings)
                {
                    GUI.color = givenColor;
                }

                count++;
                heightMarker += Constants.ROW_HEIGHT + Constants.ROW_GAP;

                if (count < raceCount)
                {
                    Widgets.DrawLineHorizontal(rowRect.x + 6f, heightMarker - 5.5f, rowRect.width - 12f);
                }
            }

            Widgets.EndScrollView();
        }
Ejemplo n.º 3
0
        public static void RaceTab(
            Rect inRect
            )
        {
            int raceCount = Storage.RaceLightMods.Count;

            if (DrawSettings._numberOfCustomRaces == null)
            {
                DrawSettings._numberOfCustomRaces =
                    Storage.RaceLightMods.Count(rlm => rlm.Value.IntSetting == VisionType.NVCustom);
            }

            inRect = inRect.AtZero();
            SettingsHelpers.DrawLightModifiersHeader(ref inRect, "NVRaces".Translate(), "NVRaceNote".Translate());

            //#region Tweaks

            //Constants.RowHeight = Widgets.HorizontalSlider(new Rect(inRect.x, inRect.y, inRect.width, Constants.RowHeight),
            //    Constants.RowHeight,
            //    -100f,
            //    +100f,
            //    true,
            //    $"Tweak RowHeight: {Constants.RowHeight}");
            //inRect.y += 50f;


            //#endregion
            float num = inRect.y + 3f;

            var viewRect = new Rect(
                inRect.x,
                inRect.y,
                inRect.width * 0.9f,
                raceCount
                * (Constants.RowHeight + Constants.RowGap)
                + (float)DrawSettings._numberOfCustomRaces * 100f
                );

            var rowRect = new Rect(inRect.x + 6f, num, inRect.width - 12f, Constants.RowHeight);

            Widgets.BeginScrollView(inRect, ref DrawSettings._raceScrollPosition, viewRect);
            var count = 0;

            foreach (KeyValuePair <ThingDef, Race_LightModifiers> kvp in Storage.RaceLightMods)
            {
                Color givenColor = GUI.color;
                rowRect.y = num;

                if (!kvp.Value.ShouldShowInSettings)
                {
                    if (!Prefs.DevMode)
                    {
                        continue;
                    }

                    GUI.color = Color.grey;
                    Widgets.Label(rowRect.TopPartPixels(20f), "NVDevModeOnly".Translate());
                    rowRect.y += 20;
                    num       += 20;
                }

                DrawSettings._numberOfCustomRaces +=
                    SettingsHelpers.DrawLightModifiersRow(kvp.Key, kvp.Value, rowRect, ref num, true);

                if (!kvp.Value.ShouldShowInSettings)
                {
                    GUI.color = givenColor;
                }

                count++;
                num += Constants.RowHeight + Constants.RowGap;

                if (count < raceCount)
                {
                    Widgets.DrawLineHorizontal(rowRect.x + 6f, num - 5.5f, rowRect.width - 12f);
                }
            }

            Widgets.EndScrollView();
        }