public override void DoEditInterface(Listing_ScenEdit listing)
        {
            Rect rect = listing.GetScenPartRect(this, RowHeight * 5 + 31f);

            Rect[] rows = rect.SplitRows(RowHeight, 31f, 4 * RowHeight);

            if (Widgets.ButtonText(rows[0], hediff.LabelCap, true, false, true))
            {
                FloatMenuUtility.MakeMenu(DefDatabase <HediffDef> .AllDefs.Where((HediffDef x) => x.scenarioCanAdd), (x) => x.LabelCap, (x) => () =>
                {
                    hediff          = x;
                    var maxSeverity = getMaxSeverity(x);
                    if (severityRange.max > maxSeverity)
                    {
                        severityRange.max = maxSeverity;
                    }

                    if (severityRange.min > maxSeverity)
                    {
                        severityRange.min = maxSeverity;
                    }
                });
            }

            Widgets.FloatRange(rows[1], listing.CurHeight.GetHashCode(), ref severityRange, 0, getMaxSeverity(hediff), R.String.Keys.MSP_HediffSeverity);
            DoContextEditInterface(rows[2]);

            if (context == PawnModifierContext.PlayerStarter)
            {
                Rect r = rows[2].BottomPart(0.25f);
                Widgets.CheckboxLabeled(r, "on map only (defered)", ref hideOffMap);
            }
        }
        /// <summary>
        /// Do the ui elements for this scenario part.
        /// </summary>
        /// <param name="listing"></param>
        public override void DoEditInterface(Listing_ScenEdit listing)
        {
            Rect scenPartRect = listing.GetScenPartRect(this, RowHeight * 3f + 31f);

            if (Widgets.ButtonText(scenPartRect.TopPartPixels(RowHeight), aspectDef.LabelCap))
            {
                FloatMenuUtility.MakeMenu(PossibleAspects(), (AspectDef ad) => ad.LabelCap, (AspectDef ad) => delegate()
                {
                    aspectDef = ad;
                    if (stageIndex >= aspectDef.stages.Count())
                    {
                        stageIndex = aspectDef.stages.Count() - 1;
                    }
                    if (stageIndex < 0)
                    {
                        stageIndex = 0;
                    }
                });
            }
            if (Widgets.ButtonText(new Rect(scenPartRect.x, scenPartRect.y + RowHeight, scenPartRect.width, 31f), aspectDef.stages[stageIndex].LabelCap ?? aspectDef.LabelCap))
            {
                FloatMenuUtility.MakeMenu(aspectDef.stages, (AspectStage stage) => stage.LabelCap ?? aspectDef.LabelCap, (AspectStage stage) => delegate()
                {
                    stageIndex = aspectDef.stages.IndexOf(stage);
                });
            }
            DoPawnModifierEditInterface(scenPartRect.BottomPartPixels(RowHeight * 2f));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Draw window contents.
        /// </summary>
        /// <param name="inRect"> Rect for drawing. </param>
        public override void DoWindowContents(Rect inRect)
        {
            Rect labelRect = inRect.ReplaceHeight(GenUI.ListSpacing * 2);

            Widgets.TextArea(labelRect, UIText.GlobalOutfitSettingWarning.TranslateSimple(), true);

            Rect importRect = labelRect.ReplaceY(labelRect.yMax).ReplaceHeight(GenUI.ListSpacing);

            if (Widgets.ButtonText(importRect, UIText.ImportLoadout.TranslateSimple()))
            {
                FloatMenuUtility.MakeMenu(
                    LoadoutManager.Loadouts.Where(t => t.GetType() == typeof(AwesomeInventoryLoadout))
                    , (loadout) => loadout.label
                    , (loadout) => () => { _filter.CopyAllowancesFrom(loadout.filter); });
            }

            ThingFilterUI.DoThingFilterConfigWindow(
                inRect.ReplaceyMin(importRect.yMax + GenUI.GapSmall)
                , ref _scrollPosition
                , _filter
                , _apparelGlobalFilter
                , 16
                , null
                , new[] { SpecialThingFilterDefOf.AllowNonDeadmansApparel });
        }
        public override float DoEditInterface(PawnFilterListing list)
        {
            float rectHeight = RowHeight * 2 + this.filterPartListHeight;
            Rect  rect       = list.GetPawnFilterPartRect(this, rectHeight);

            // Logic gate type list.
            Rect gateTypeRect = new Rect(rect.x, rect.y, rect.width, RowHeight);

            if (Widgets.ButtonText(gateTypeRect, this.logicGateType.ToString()))
            {
                FloatMenuUtility.MakeMenu((LogicGateType[])Enum.GetValues(typeof(LogicGateType)), type => type.ToString(), type => () => this.logicGateType = type);
            }

            // Add part button.
            Rect addPartButtonRect = new Rect(rect.x, rect.y + gateTypeRect.height, rect.width, RowHeight);

            if (Widgets.ButtonText(addPartButtonRect, "Add part"))
            {
                FloatMenuUtility.MakeMenu(PawnFilter.allFilterParts, def => def.label, def => () => {
                    PawnFilterPart part = (PawnFilterPart)Activator.CreateInstance(def.partClass);
                    part.def            = def;
                    this.innerFilter.parts.Add(part);
                });
            }

            // Build filter field.
            Rect filterFieldRect = new Rect(rect.x, rect.y + gateTypeRect.height + addPartButtonRect.height, rect.width, this.filterPartListHeight).Rounded();

            Widgets.DrawMenuSection(filterFieldRect);
            filterFieldRect = filterFieldRect.GetInnerRect();

            // Draw filter parts.
            this.filterPartListHeight = filterPartListHeightBuffer;
            PawnFilterListing filterPartList = new PawnFilterListing()
            {
                ColumnWidth = filterFieldRect.width
            };

            filterPartList.Begin(filterFieldRect);
            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 this.innerFilter.parts)
            {
                if (part.toRemove)
                {
                    partsToRemove.Add(part);
                }
                else
                {
                    this.filterPartListHeight += part.DoEditInterface(filterPartList) + RowHeight + PawnFilterListing.gapSize;
                }
            }
            foreach (PawnFilterPart part in partsToRemove)
            {
                _ = this.innerFilter.parts.Remove(part);
            }
            filterPartList.End();

            return(rectHeight);
        }
Exemplo n.º 5
0
        public void WikiButtonClicked()
        {
            // Choose which wiki to open.
            var wikis = ModWiki.AllWikis;

            if (wikis.Count == 0)
            {
                Log.Warning("There are no wikis loaded.");
                return;
            }

            if (wikis.Count == 1)
            {
                // There is only 1 wiki, just open that one.
                wikis[0].Show();
            }
            else
            {
                // Yeah this is some pretty slick C# right here.
                Func <ModWiki, string> labelGetter  = (w) => w.Mod.Content.Name;
                Func <ModWiki, Action> actionGetter = (w) => w.Show;

                FloatMenuUtility.MakeMenu(wikis, labelGetter, actionGetter);
            }
        }
Exemplo n.º 6
0
        public override void DoEditInterface(Listing_ScenEdit listing)
        {
            var scenPartRect = listing.GetScenPartRect(this, RowHeight * 3 + 31);

            if (Widgets.ButtonText(scenPartRect.TopPartPixels(RowHeight), inhabitantKind.ToString()))
            {
                FloatMenuUtility.MakeMenu(System.Enum.GetNames(typeof(InhabitantKind)), s => (s + "CityKind").Translate(), s => { return(() => inhabitantKind = (InhabitantKind)System.Enum.Parse(typeof(InhabitantKind), s)); });
            }
        }
Exemplo n.º 7
0
        public static void PresentMenu()
        {
            var elements = calls.Values.ToList();

            calls.Clear();

            if (elements.Count == 0)
            {
                return;
            }
            elements.Sort(new Element.Comparer());

            var mouse = UI.MousePositionOnUI;

            FloatMenuUtility.MakeMenu(elements.AsEnumerable(), element => element.GetPath(GUILocator.Settings.numberOfMethodsToDisplay), element => delegate()
            {
                var options = element.trace
                              .GetFrames()
                              .Skip(1)
                              .Select(f => f.GetRealMethod())
                              .Select(member =>
                {
                    var path = member.DeclaringType.Assembly.Location;
                    if (path == null || path.Length == 0)
                    {
                        var contentPack = LoadedModManager.RunningMods.FirstOrDefault(m => m.assemblies.loadedAssemblies.Contains(member.DeclaringType.Assembly));
                        if (contentPack != null)
                        {
                            path = ModContentPack.GetAllFilesForModPreserveOrder(contentPack, "Assemblies/", p => p.ToLower() == ".dll", null)
                                   .Select(fileInfo => fileInfo.Item2.FullName)
                                   .First(dll =>
                            {
                                var assembly = Assembly.ReflectionOnlyLoadFrom(dll);
                                return(assembly.GetType(member.DeclaringType.FullName) != null);
                            });
                        }
                    }

                    var option = Misc.FloatMenuOption(Element.MethodString(member), delegate()
                    {
                        var token = member.MetadataToken;
                        if (token != 0)
                        {
                            _ = Process.Start(GUILocator.Settings.dnSpyPath, $"\"{path}\" --select 0x{token:X8}");
                        }
                    });
                    option.Disabled = member.MetadataToken == 0;
                    return(option);
                });
                if (options.Any())
                {
                    Find.WindowStack.Add(new FloatMenu(options.ToList()));
                }
            });
        }
Exemplo n.º 8
0
        public override void DoEditInterface(Listing_ScenEdit listing)
        {
            Rect rect = listing.GetScenPartRect(this, RowHeight * 5 + 31f);

            Rect[] rows = rect.SplitRows(RowHeight, 31f, 4 * RowHeight);

            if (Widgets.ButtonText(rows[0], need.LabelCap, true, false, true))
            {
                FloatMenuUtility.MakeMenu(DefDatabase <NeedDef> .AllDefs.Where((NeedDef x) => x.major), (x) => x.LabelCap, (x) => () => need = x);
            }

            Widgets.FloatRange(rows[1], listing.CurHeight.GetHashCode(), ref levelRange, 0, 1, R.String.Keys.MSP_NeedLevel.CapitalizeFirst());
            DoContextEditInterface(rows[2]);
        }
Exemplo n.º 9
0
        public override void DoEditInterface(Listing_ScenEdit listing)
        {
            Rect scenPartRect = listing.GetScenPartRect(this, RowHeight * 4f + 31f);

            if (Widgets.ButtonText(scenPartRect.TopPartPixels(RowHeight), this?.bloodline?.LabelCap ?? "ROMV_UnknownBloodline".Translate()))
            {
                FloatMenuUtility.MakeMenu(PossibleBloodlines(), (BloodlineDef bl) => bl.LabelCap, (BloodlineDef bl) => delegate
                {
                    bloodline = bl;
                });
            }
            //Widgets.IntRange(new Rect(scenPartRect.x, scenPartRect.y + ScenPart.RowHeight, scenPartRect.width, 31f), listing.CurHeight.GetHashCode(), ref this.generationRange, 4, this.maxGeneration, "ROMV_VampireGeneration");
            DoVampModifierEditInterface(new Rect(scenPartRect.x, scenPartRect.y, scenPartRect.width, 31f));
        }
Exemplo n.º 10
0
        private void DrawRowAdd(Rect rect, Action postAddAction)
        {
            GUI.BeginGroup(rect);

            Rect rectName = rect.AtZero();

            rectName.width -= COL_MARGIN * 4 + BTN_SEASON_WIDTH + LBL_DATE_WIDTH + BTN_DURATION_WIDTH + BTN_ADD_WIDTH;
            rectName.xMin  += COL_MARGIN;

            Rect rectSeason   = new Rect(rectName.xMax + COL_MARGIN, 0f, BTN_SEASON_WIDTH, rect.height);
            Rect rectDate     = new Rect(rectSeason.xMax + COL_MARGIN, 0f, LBL_DATE_WIDTH, rect.height);
            Rect rectDuration = new Rect(rectDate.xMax + COL_MARGIN, 0f, BTN_DURATION_WIDTH, rect.height);
            Rect btnAddRect   = new Rect(rectDuration.xMax + COL_MARGIN, 0f, BTN_ADD_WIDTH, rect.height);

            _newEventName = Widgets.TextField(rectName, _newEventName);
            Widgets.TextFieldNumeric(rectDate, ref _newEventDay, ref _newEventDateBuffer, 1, 15);

            if (Widgets.ButtonText(rectSeason, _newEventQuadrum.Label()))
            {
                FloatMenuUtility.MakeMenu(QUADRUMS, quadrum => quadrum.Label(), quadrum => delegate
                {
                    _newEventQuadrum = quadrum;
                });
            }

            if (Widgets.ButtonText(rectDuration, _newEventDuration.Label()))
            {
                FloatMenuUtility.MakeMenu(Enum.GetValues(typeof(Duration)).Cast <Duration>(), duration => duration.Label(), duration => delegate
                {
                    _newEventDuration = duration;
                });
            }

            if (Widgets.ButtonText(btnAddRect, "DM.Tab.AddCustomDay".Translate()))
            {
                if (_newEventName == "")
                {
                    _newEventName = "DM.Tab.CustomDayDefaultName".Translate();
                }
                _store.MatteredDays.Add(new MatteredDay(_newEventName, _newEventQuadrum, _newEventDay, _newEventDuration));
                _newEventName = "";
                SoundDefOf.Click.PlayOneShotOnCamera();
                postAddAction();
            }

            GUI.EndGroup();
        }
        public override void DoEditInterface(Listing_ScenEdit listing)
        {
            Rect rect = listing.GetScenPartRect(this, RowHeight * 4);

            bool isFaction = context == PawnModifierContext.Faction;

            Rect[] rows = rect.SplitRows(1, 1, 1, 1);

            Rect[] rect_gender  = rows[0].SplitCols(1, 2);
            Rect[] rect_chance  = rows[1].SplitCols(1, 2);
            Rect[] rect_context = rows[2].SplitCols(1, 2);
            Rect[] rect_faction = rows[3].SplitCols(1, 2);

            //Text.Anchor = TextAnchor.MiddleRight;
            Widgets.Label(rect_chance[0], R.String.MSP_Chance.CapitalizeFirst());
            //Text.Anchor = TextAnchor.UpperLeft;
            Widgets.TextFieldPercent(rect_chance[1], ref chance, ref chanceBuf, 0f, 1f);

            //Text.Anchor = TextAnchor.MiddleRight;
            Widgets.Label(rect_gender[0], R.String.MSP_Gender.CapitalizeFirst());
            //Text.Anchor = TextAnchor.UpperLeft;
            if (Widgets.ButtonText(rect_gender[1], gender.Translate()))
            {
                FloatMenuUtility.MakeMenu(Extensions.GetEnumValues <PawnModifierGender>(), Extensions.Translate, (g) => () => gender = g);
            }

            //Text.Anchor = TextAnchor.MiddleRight;
            Widgets.Label(rect_context[0], R.String.MSP_Context.CapitalizeFirst());
            //Text.Anchor = TextAnchor.UpperLeft;
            if (Widgets.ButtonText(rect_context[1], context.Translate(), true, false, true))
            {
                FloatMenuUtility.MakeMenu(Extensions.GetEnumValues <PawnModifierContext>(), Extensions.Translate, (c) => () => context = c);
            }

            if (isFaction)
            {
                //Text.Anchor = TextAnchor.MiddleRight;
                Widgets.Label(rect_faction[0], R.String.MSP_Faction.CapitalizeFirst());
                //Text.Anchor = TextAnchor.UpperLeft;

                if (Widgets.ButtonText(rect_faction[1], faction.LabelCap, true, false, true))
                {
                    FloatMenuUtility.MakeMenu(DefDatabase <FactionDef> .AllDefs.Where((d) => !d.isPlayer), (f) => f.LabelCap, (f) => () => faction = f);
                }
            }
        }
Exemplo n.º 12
0
        public override void DoEditInterface(Listing_ScenEdit listing)
        {
            Rect scenPartRect = listing.GetScenPartRect(this, ScenPart.RowHeight * 3f + 31f);

            if (Widgets.ButtonText(scenPartRect.TopPartPixels(ScenPart.RowHeight), need.LabelCap))
            {
                FloatMenuUtility.MakeMenu(PossibleNeeds(), (NeedDef hd) => hd.LabelCap, delegate(NeedDef n)
                {
                    ScenPart_ForcedSapience scenPart_ForcedSapience = this;
                    return(delegate
                    {
                        scenPart_ForcedSapience.need = n;
                    });
                });
            }
            Widgets.FloatRange(new Rect(scenPartRect.x, scenPartRect.y + ScenPart.RowHeight, scenPartRect.width, 31f), listing.CurHeight.GetHashCode(), ref levelRange, 0f, 1f, "ConfigurableLevel");
            DoPawnModifierEditInterface(scenPartRect.BottomPartPixels(ScenPart.RowHeight * 2f));
        }
Exemplo n.º 13
0
        public override void DoEditInterface(Listing_ScenEdit listing)
        {
            Rect rect = listing.GetScenPartRect(this, RowHeight * 6);

            Rect[] rows  = rect.SplitRows(1, 1, 4);
            Rect[] r_rad = rows[1].SplitCols(1, 2);

            if (Widgets.ButtonText(rows[0], damage.LabelCap, true, false, true))
            {
                FloatMenuUtility.MakeMenu(PossibleDamageDefs(), (DamageDef d) => d.LabelCap, (d) => () => damage = d);
            }

            // Text.Anchor = TextAnchor.MiddleRight;
            Widgets.Label(r_rad[0], R.String.MSP_Radius.CapitalizeFirst());
            // Text.Anchor = TextAnchor.UpperLeft;
            Widgets.TextFieldNumeric(r_rad[1], ref radius, ref radiusBuf, 1);

            DoContextEditInterface(rows[2]);
        }
Exemplo n.º 14
0
        public override void DoEditInterface(Listing_ScenEdit listing)
        {
            Rect rect = listing.GetScenPartRect(this, RowHeight * 5);

            Rect[] rows = rect.SplitRows(1, 4);

            if (Widgets.ButtonText(rows[0], trait.DataAtDegree(degree).label.CapitalizeFirst(), true, false, true))
            {
                var defs = from def in DefDatabase <TraitDef> .AllDefs
                           from deg in def.degreeDatas
                           orderby def.label ascending
                           select new { Trait = def, Degree = deg };

                FloatMenuUtility.MakeMenu(defs, (x) => x.Degree.label.CapitalizeFirst(), (x) => () =>
                {
                    trait  = x.Trait;
                    degree = x.Degree.degree;
                });
            }
            DoContextEditInterface(rows[1]);
        }
Exemplo n.º 15
0
        protected void DoContextEditInterface(Rect rect)
        {
            bool isFaction = context == PawnModifierContext.Faction;

            Rect[] rows = rect.SplitRows(1, 1, 1);

            Rect[] rect_gender  = rows[0].SplitCols(1, 2);
            Rect[] rect_context = rows[1].SplitCols(1, 2);
            Rect[] rect_faction = rows[2].SplitCols(1, 2);

            // Text.Anchor = TextAnchor.MiddleRight;
            Widgets.Label(rect_gender[0], R.String.MSP_Gender.CapitalizeFirst());
            // Text.Anchor = TextAnchor.UpperLeft;
            if (Widgets.ButtonText(rect_gender[1], gender.Translate()))
            {
                FloatMenuUtility.MakeMenu(Extensions.GetEnumValues <PawnModifierGender>(), Extensions.Translate, (g) => () => gender = g);
            }

            // Text.Anchor = TextAnchor.MiddleRight;
            Widgets.Label(rect_context[0], R.String.MSP_Context.CapitalizeFirst());
            // Text.Anchor = TextAnchor.UpperLeft;
            if (Widgets.ButtonText(rect_context[1], context.Translate(), true, false, true))
            {
                FloatMenuUtility.MakeMenu(Extensions.GetEnumValues <PawnModifierContext>(), Extensions.Translate, (c) => () => context = c);
            }

            if (isFaction)
            {
                // Text.Anchor = TextAnchor.MiddleRight;
                Widgets.Label(rect_faction[0], R.String.MSP_Faction.CapitalizeFirst());
                // Text.Anchor = TextAnchor.UpperLeft;

                if (Widgets.ButtonText(rect_faction[1], faction.LabelCap, true, false, true))
                {
                    FloatMenuUtility.MakeMenu(DefDatabase <FactionDef> .AllDefs.Where((d) => !d.isPlayer), (f) => f.LabelCap, (f) => () => faction = f);
                }
            }
        }
Exemplo n.º 16
0
        public override void DoSettingsWindowContents(Rect inRect)
        {
            Listing_Standard listing = new Listing_Standard {
                ColumnWidth = inRect.width / 3
            };

            listing.Begin(inRect);
            listing.CheckboxLabeled(UIText.ShowInspiredPawn.TranslateSimple(), ref ModSettings.ShowInspiredPawn);
            listing.CheckboxLabeled(UIText.ShowGuestPawn.TranslateSimple(), ref ModSettings.ShowGuestPawn);
            listing.CheckboxLabeled(UIText.ShowSickPawn.TranslateSimple(), ref ModSettings.ShowSickPawn);
            listing.CheckboxLabeled(UIText.ShowDraftedPawn.TranslateSimple(), ref ModSettings.ShowDraftedPawn);
            listing.CheckboxLabeled(UIText.AutoHide.TranslateSimple(), ref ModSettings.AutoHide);

            listing.GapLine();

            listing.CheckboxLabeled(UIText.SortPawnByBleeding.TranslateSimple(), ref ModSettings.SortBleedingPawn);

            const float lineHeight = GenUI.ListSpacing * 2;

            listing.Gap();
            Draw.IntegerSetting($"{UIText.MoodUpdateInterval.TranslateSimple()}:", listing.GetRect(lineHeight), ref ModSettings.MoodUpdateInterval, tooltip: UIText.TickExplaination.TranslateSimple());

            listing.Gap();
            Draw.IntegerSetting($"{UIText.StatusUpdateInterval.TranslateSimple()}:", listing.GetRect(lineHeight), ref ModSettings.StatusUpdateInterval, tooltip: UIText.TickExplaination.TranslateSimple());

            listing.Gap();
            int seconds = ModSettings.AutoHideButtonTime.Seconds;

            Draw.IntegerSetting($"{UIText.TimeToAutoHide.TranslateSimple()}:", listing.GetRect(lineHeight), ref seconds);
            if (ModSettings.AutoHideButtonTime.Seconds != seconds)
            {
                ModSettings.AutoHideButtonTime = new TimeSpan(0, 0, seconds);
            }

            listing.NewColumn();

            DrawColorOption(listing, MoodLevel.Satisfied);
            DrawColorOption(listing, MoodLevel.Minor);
            DrawColorOption(listing, MoodLevel.Major);
            DrawColorOption(listing, MoodLevel.Extreme);
            if (listing.ButtonText(ModSettings.ShownMoodLevel.ToString()))
            {
                FloatMenuUtility.MakeMenu(
                    Enum.GetValues(typeof(MoodLevel)).Cast <MoodLevel>().Where(e => e != MoodLevel.Undefined)
                    , m => m.ToString()
                    , m => () => ModSettings.ShownMoodLevel = m);
            }

            listing.GapLine();

            DrawColorOption(listing, UIText.BackgroundColor.TranslateSimple(), ModSettings.BgColor, (color) => ModSettings.BgColor = color);
            DrawColorOption(listing, UIText.ThrehsoldMarker.TranslateSimple(), ModSettings.ThresholdMarker, (color) => ModSettings.ThresholdMarker = color);
            DrawColorOption(listing, UIText.CurrMoodLevel.TranslateSimple(), ModSettings.CurrMoodLevel, color => ModSettings.CurrMoodLevel         = color);

            listing.GapLine();
            Draw.IntegerSetting(
                $"{UIText.ThrehsoldMarkerThickness.TranslateSimple()}:"
                , listing.GetRect(lineHeight)
                , ref ModSettings.ThresholdMarkerThickness
                , i => ModSettings.UISettingsChanged = true);

            listing.Gap();
            Draw.IntegerSetting(
                $"{UIText.CurrMoodLevelThickness.TranslateSimple()}:"
                , listing.GetRect(lineHeight)
                , ref ModSettings.CurrMoodLevelThickness
                , i => ModSettings.UISettingsChanged = true);

            int yOffset = Mathf.RoundToInt(ModSettings.YOffset);

            listing.Gap();
            Draw.IntegerSetting(
                $"{UIText.YOffset.TranslateSimple()}:"
                , listing.GetRect(lineHeight)
                , ref yOffset
                , i =>
            {
                ModSettings.YOffset = yOffset;
                Find.ColonistBar.MarkColonistsDirty();
                BCBManager.ModColonistBarDirty = true;
            });

            listing.NewColumn();

            Rect      rowRect   = listing.GetRect(GenUI.ListSpacing);
            WidgetRow widgetRow = new WidgetRow(rowRect.x, rowRect.y, UIDirection.RightThenDown, rowRect.width);

            widgetRow.Label($"{UIText.Hotkey.TranslateSimple()}: ");
            Rect labelRect = widgetRow.Label(
                ModSettings.CtrlKey ? $"Ctrl + {ModSettings.HotKey}"
                                       : $"{ModSettings.HotKey}");

            widgetRow.GapButtonIcon();
            if (widgetRow.ButtonText(UIText.Record.TranslateSimple()))
            {
                _recordingHotkey = true;
            }

            if (_recordingHotkey)
            {
                Widgets.DrawHighlightSelected(labelRect);
                if (Event.current.type == EventType.KeyUp || Event.current.isMouse)
                {
                    ModSettings.CtrlKey = Event.current.control;
                    if (Event.current.keyCode != KeyCode.LeftControl && Event.current.keyCode != KeyCode.RightControl)
                    {
                        ModSettings.HotKey = Event.current.keyCode;
                        _recordingHotkey   = false;
                    }
                    else
                    {
                        ModSettings.HotKey = KeyCode.None;
                    }
                }
            }

            listing.End();
        }
Exemplo n.º 17
0
        public override void DoEditInterface(Listing_ScenEdit listing)
        {
            Rect rect = listing.GetScenPartRect(this, RowHeight * 8 + 31f);

            Rect[] a    = rect.SplitRows(5, 4);
            Rect[] rows = a[0].SplitRows(RowHeight, RowHeight, RowHeight, 31f, RowHeight);

            Rect[] r_kind   = rows[0].SplitCols(1, 2);
            Rect[] r_thing  = rows[1].SplitCols(1, 2);
            Rect[] r_stuff  = rows[2].SplitCols(1, 2);
            Rect[] r_amount = rows[3].SplitCols(1, 2);
            Rect   r_equip  = rows[4];

            // Text.Anchor = TextAnchor.MiddleRight;
            Widgets.Label(r_kind[0], R.String.MSP_ThingKind.CapitalizeFirst());
            // Text.Anchor = TextAnchor.UpperLeft;
            if (Widgets.ButtonText(r_kind[1], thingKind.Translate()))
            {
                FloatMenuUtility.MakeMenu(Extensions.GetEnumValues <ThingKind>(), Extensions.Translate, (k) => () =>
                {
                    thingKind = k;
                    thing     = GetThings().RandomElement();
                    if (thing.MadeFromStuff)
                    {
                        stuff = GetStuffsForThing().RandomElement();
                    }
                });
            }

            // Text.Anchor = TextAnchor.MiddleRight;
            Widgets.Label(r_thing[0], R.String.MSP_Thing.CapitalizeFirst());
            // Text.Anchor = TextAnchor.UpperLeft;
            if (Widgets.ButtonText(r_thing[1], thing.LabelCap))
            {
                FloatMenuUtility.MakeMenu(GetThings(), (t) => t.LabelCap, (t) => () =>
                {
                    thing = t;
                    if (t.MadeFromStuff)
                    {
                        stuff = GenStuff.DefaultStuffFor(thing);
                    }
                    else
                    {
                        stuff = null;
                    }
                });
            }

            // Text.Anchor = TextAnchor.MiddleRight;
            Widgets.Label(r_stuff[0], R.String.MSP_Stuff.CapitalizeFirst());
            // Text.Anchor = TextAnchor.UpperLeft;
            if (thing.MadeFromStuff && Widgets.ButtonText(r_stuff[1], stuff.LabelCap))
            {
                FloatMenuUtility.MakeMenu(GetStuffsForThing(), (s) => s.LabelCap, (s) => () =>
                {
                    stuff = s;
                });
            }

            if (amount.max > thing.stackLimit)
            {
                amount.max = thing.stackLimit;
            }

            if (amount.min > amount.max)
            {
                amount.min = amount.max;
            }

            if (amount.min != 1 && amount.max != 1)
            {
                equip = false;
            }

            // Text.Anchor = TextAnchor.MiddleRight;
            Widgets.Label(r_amount[0], R.String.MSP_Amount.CapitalizeFirst());
            // Text.Anchor = TextAnchor.UpperLeft;

            if (thing.stackLimit == 1)
            {
                // Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(r_amount[1], thing.stackLimit.ToStringCached());
                // Text.Anchor = TextAnchor.UpperLeft;
            }
            else
            {
                Widgets.IntRange(r_amount[1], listing.CurHeight.GetHashCode(), ref amount, 1, thing.stackLimit);
            }

            if (thingKind == ThingKind.Aparrel || thingKind == ThingKind.Weapon)
            {
                bool oldValue = equip;
                Widgets.CheckboxLabeled(r_equip, R.String.MSP_Equip.CapitalizeFirst(), ref equip);
                if (!oldValue && equip)
                {
                    amount.min = amount.max = 1;
                }
            }

            DoContextEditInterface(a[1]);
        }
Exemplo n.º 18
0
        public override void DoWindowContents(Rect inRect)
        {
            if (refreshWarframePortrait)
            {
                // this.newWF.Drawer.renderer.graphics.ResolveAllGraphics();
                // PortraitsCache.SetDirty(this.newWF);
                //  PortraitsCache.PortraitsCacheUpdate();
                refreshWarframePortrait = false;
            }

            var rect27 = new Rect(inRect)
            {
                width  = 240f + 16f,
                height = 200f + 16f
            };

            rect27    = rect27.CenteredOnXIn(inRect);
            rect27    = rect27.CenteredOnYIn(inRect);
            rect27.x -= 88f;
            rect27.y -= 32f;
            if (newWF != null)
            {
                //picture
                GUI.DrawTexture(rect27,
                                ContentFinder <Texture2D> .Get("WFPicture/" + nowWarframeKind.defName.Replace("Warframe_", "")),
                                ScaleMode.ScaleToFit);
                //  Widgets.InfoCardButton(position.xMax - 16f, position.y, this.newWF);

                var rectsk = new Rect(rect27.x + rect27.width + 16, rect27.y, 50, 50);
                var recttx = new Rect(rectsk.x + 56, rectsk.y + 6, 160, 50);
                for (var i = 0; i < 4; i++)
                {
                    var arect = new Rect(rectsk.x, rectsk.y + (i * 54f), 50, 50);
                    Widgets.ButtonImage(arect,
                                        ContentFinder <Texture2D> .Get("Skills/" + nowWarframeKind.defName.Replace("Warframe_", "") +
                                                                       "Skill" + (i + 1)));
                    var trect = new Rect(recttx.x, recttx.y + (i * 54f), 160, 50);
                    Text.Font = GameFont.Medium;
                    Widgets.Label(trect,
                                  (nowWarframeKind.defName.Replace("Warframe_", "") + "Skill" + (i + 1) + ".name").Translate());
                    Text.Font = GameFont.Small;
                    TooltipHandler.TipRegion(arect,
                                             (nowWarframeKind.defName.Replace("Warframe_", "") + "Skill" + (i + 1) + ".desc").Translate());
                }

                //title
                Text.Anchor = TextAnchor.MiddleCenter;
                Text.Font   = GameFont.Medium;
                Widgets.Label(new Rect(0f, 0f, inRect.width, 32f), "CraftWarframe".Translate());
                Text.Anchor = TextAnchor.UpperLeft;


                Text.Font   = GameFont.Small;
                Text.Anchor = TextAnchor.MiddleCenter;
                var rect10 = new Rect(0 + 120, inRect.height * 0.75f, 240f, 24f);
                if (Widgets.ButtonText(rect10, nowWarframeKind.label, true, false))
                {
                    FloatMenuUtility.MakeMenu(WarframeStaticMethods.GetAllWarframeKind(), Kind => Kind.label, Kind =>
                                              delegate
                    {
                        nowWarframeKind = Kind;
                        newWF           = getNewWF();
                        RefreshCosts();
                    });
                }

                Text.Anchor = TextAnchor.UpperLeft;


                //click craft
                //float num2 = rect27.x + rect27.width + 16f + (inRect.width - 1);
                var rect9 = new Rect((inRect.width / 2) - 60, inRect.height - 32, 120, 32);
                Text.Font = GameFont.Medium;
                // Text.Anchor = TextAnchor.LowerCenter;
                if (Widgets.ButtonText(rect9, "WarframeStartCraft".Translate(), true, false))
                {
                    WFCraft.nowCraftKind = nowWarframeKind;

                    WFCraft.tryDropAllParts();
                    WFCraft.fuelCost = fuelCost;
                    WFCraft.curState = Building_WarframeCrafter.CraftState.Filling;
                    Close();
                }

                var recttime = new Rect(rect9.x, rect9.y - 60, 30, 30);
                Widgets.ButtonImage(recttime, ContentFinder <Texture2D> .Get("UI/Icons/ColonistBar/Idle"));
                var recttimec = new Rect(recttime.x + 30, recttime.y, 30, 30);
                Text.Font = GameFont.Small;
                Widgets.Label(recttimec, timeCost + "DaysLower".Translate());
                TooltipHandler.TipRegion(recttime, "Time Cost");


                var rectcostbase = new Rect(recttimec.x + 30, recttime.y, 30, 30);
                for (var j = 0; j < 3; j++)
                {
                    var rrrect  = new Rect(rectcostbase.x + (j * 30), rectcostbase.y, 30, 30);
                    var nowpart = "";
                    switch (j)
                    {
                    case 0:
                        nowpart = "_Head";
                        break;

                    case 1:
                        nowpart = "_Body";
                        break;

                    case 2:
                        nowpart = "_Inside";
                        break;
                    }

                    var apartDef =
                        ThingDef.Named("WFPart_" + nowWarframeKind.defName.Replace("Warframe_", "") + nowpart);
                    Widgets.ButtonImage(rrrect, apartDef.uiIcon);
                    TooltipHandler.TipRegion(rrrect, apartDef.label + "\n" + apartDef.description);
                }

                //orokin cell icon draw
                var fuelRect  = new Rect(rectcostbase.x + (3 * 30), rectcostbase.y, 30, 30);
                var ocpartDef = ThingDef.Named("WFItem_OrokinCell");
                Widgets.ButtonImage(fuelRect, ocpartDef.uiIcon);
                TooltipHandler.TipRegion(fuelRect, ocpartDef.label + "\n" + ocpartDef.description);


                Text.Font = GameFont.Small;
                var costRect = new Rect(fuelRect.x + 30, fuelRect.y, 30, 30);
                Widgets.Label(costRect, fuelCost + "");
                TooltipHandler.TipRegion(costRect, ocpartDef.label + "\n" + ocpartDef.description);

                if (Widgets.CloseButtonFor(new Rect(inRect.width - 30, 0, 30, 30)))
                {
                    Close();
                }
            }

            Text.Anchor = TextAnchor.UpperLeft;
        }
Exemplo n.º 19
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();
        }
Exemplo n.º 20
0
        private void DrawRow(Rect rect, MatteredDay matteredDay, int index)
        {
            GUI.BeginGroup(rect);

            Rect rectName = rect.AtZero();

            rectName.width -= COL_MARGIN * 4 + BTN_SEASON_WIDTH + LBL_DATE_WIDTH + BTN_DURATION_WIDTH + BTN_DELETE_WIDTH;
            rectName.xMin  += COL_MARGIN;

            Rect rectSeason = new Rect(rectName.xMax + COL_MARGIN, 2f, BTN_SEASON_WIDTH, rect.height - 4f);

            Rect rectDateMinus = new Rect(rectSeason.xMax + COL_MARGIN, (rect.height - BTN_DATE_CONTROL_WIDTH) / 2f, BTN_DATE_CONTROL_WIDTH, BTN_DATE_CONTROL_WIDTH);
            Rect rectDate      = new Rect(rectDateMinus.xMax, 0f, LBL_DATE_WIDTH - BTN_DATE_CONTROL_WIDTH * 2, rect.height);
            Rect rectDatePlus  = new Rect(rectDate.xMax, (rect.height - BTN_DATE_CONTROL_WIDTH) / 2f, BTN_DATE_CONTROL_WIDTH, BTN_DATE_CONTROL_WIDTH);

            Rect rectDuration  = new Rect(rectDatePlus.xMax + COL_MARGIN, 2f, BTN_DURATION_WIDTH, rect.height - 4f);
            Rect btnDeleteRect = new Rect(rectDuration.xMax + COL_MARGIN, Mathf.RoundToInt((ROW_HEIGHT - BTN_DELETE_HEIGHT) / 2f), BTN_DELETE_WIDTH, BTN_DELETE_HEIGHT);

            Text.Anchor = TextAnchor.MiddleLeft;
            Widgets.Label(rectName, matteredDay.Name);
            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.Label(rectDate, matteredDay.DayOfQuadrum.ToString());
            Text.Anchor = TextAnchor.UpperLeft;

            if (Widgets.ButtonText(rectSeason, matteredDay.Quadrum.Label()))
            {
                FloatMenuUtility.MakeMenu(QUADRUMS, quadrum => quadrum.Label(), quadrum => delegate
                {
                    matteredDay.Quadrum = quadrum;
                });
            }

            if (Widgets.ButtonText(rectDuration, matteredDay.Duration.Label()))
            {
                FloatMenuUtility.MakeMenu(Enum.GetValues(typeof(Duration)).Cast <Duration>(), duration => duration.Label(), duration => delegate
                {
                    matteredDay.Duration = duration;
                });
            }

            if (Widgets.ButtonImage(btnDeleteRect, Textures.ROW_DELETE))
            {
                _store.MatteredDays.RemoveAt(index);
                SoundDefOf.Click.PlayOneShotOnCamera();
            }

            if (Widgets.ButtonImage(rectDateMinus, Textures.DAY_MINUS))
            {
                int tmp = matteredDay.DayOfQuadrum - 1;
                if (tmp < 1)
                {
                    tmp = 1;
                }
                matteredDay.DayOfQuadrum = tmp;
                SoundDefOf.Click.PlayOneShotOnCamera();
            }

            if (Widgets.ButtonImage(rectDatePlus, Textures.DAY_PLUS))
            {
                int tmp = matteredDay.DayOfQuadrum + 1;
                if (tmp > 15)
                {
                    tmp = 15;
                }
                matteredDay.DayOfQuadrum = tmp;
                SoundDefOf.Click.PlayOneShotOnCamera();
            }

            var interactingName = Mouse.IsOver(rectName);

            if (interactingName)
            {
                if (Event.current.control && Event.current.type == EventType.MouseDown && Event.current.button == 0)
                {
                    Find.WindowStack.Add(new DialogRename(matteredDay));
                    return;
                }
                TooltipHandler.ClearTooltipsFrom(rectName);
                TooltipHandler.TipRegion(rectName, "DM.Tab.RenameCustomDay".Translate());
            }

            GUI.EndGroup();
        }
Exemplo n.º 21
0
        // Token: 0x06000032 RID: 50 RVA: 0x00003078 File Offset: 0x00001278
        public override void DoWindowContents(Rect inRect)
        {
            var crafterProperties = pawnCrafter.def.GetModExtension <PawnCrafterProperties>();

            if (newChildhoodBackstory != null)
            {
                newPawn.story.childhood = newChildhoodBackstory;
                newChildhoodBackstory   = null;
                RefreshPawn();
            }

            if (newAdulthoodBackstory != null)
            {
                newPawn.story.adulthood = newAdulthoodBackstory;
                newAdulthoodBackstory   = null;
                RefreshPawn();
            }

            if (traitsChanged)
            {
                var first  = newTrait.First;
                var second = newTrait.Second;
                if (first < newPawn.story.traits.allTraits.Count)
                {
                    newPawn.story.traits.allTraits.RemoveAt(first);
                    newPawn.story.traits.allTraits.Insert(first, second);
                    if (newPawn.workSettings != null)
                    {
                        newPawn.workSettings.Notify_DisabledWorkTypesChanged();
                    }

                    if (newPawn.skills != null)
                    {
                        newPawn.skills.Notify_SkillDisablesChanged();
                    }

                    if (!newPawn.Dead && newPawn.RaceProps.Humanlike)
                    {
                        newPawn.needs.mood.thoughts.situational.Notify_SituationalThoughtsDirty();
                    }
                }
                else
                {
                    newPawn.story.traits.GainTrait(second);
                }

                newTrait      = default;
                traitsChanged = false;
                traitPos      = -1;
                RefreshPawn();
            }

            var rect = new Rect(inRect)
            {
                width  = PawnPortraitSize.x + 16f,
                height = PawnPortraitSize.y + 16f
            };

            rect    = rect.CenteredOnXIn(inRect);
            rect    = rect.CenteredOnYIn(inRect);
            rect.x += 16f;
            rect.y += 16f;
            if (newPawn != null)
            {
                var rect2 = new Rect(rect.xMin + ((rect.width - PawnPortraitSize.x) / 2f) - 10f, rect.yMin + 20f,
                                     PawnPortraitSize.x, PawnPortraitSize.y);
                GUI.DrawTexture(rect2, PortraitsCache.Get(newPawn, PawnPortraitSize, Rot4.South));
                Widgets.InfoCardButton(rect2.xMax - 16f, rect2.y, newPawn);
                Text.Font   = GameFont.Medium;
                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(new Rect(0f, 0f, inRect.width, 32f),
                              crafterProperties.crafterPawnCustomizationTitle.Translate());
                Text.Font   = GameFont.Small;
                Text.Anchor = TextAnchor.MiddleLeft;
                var num   = 32f;
                var rect3 = new Rect(32f, num, 240f, 24f);
                if (newPawn.Name is NameTriple nameTriple)
                {
                    var rect4 = new Rect(rect3);
                    rect4.width *= 0.333f;
                    var rect5 = new Rect(rect3);
                    rect5.width *= 0.333f;
                    rect5.x     += rect5.width;
                    var rect6 = new Rect(rect3);
                    rect6.width *= 0.333f;
                    rect6.x     += rect5.width * 2f;
                    var first2 = nameTriple.First;
                    var nick   = nameTriple.Nick;
                    var last   = nameTriple.Last;
                    CharacterCardUtility.DoNameInputRect(rect4, ref first2, 12);
                    if (nameTriple.Nick == nameTriple.First || nameTriple.Nick == nameTriple.Last)
                    {
                        GUI.color = new Color(1f, 1f, 1f, 0.5f);
                    }

                    CharacterCardUtility.DoNameInputRect(rect5, ref nick, 9);
                    GUI.color = Color.white;
                    CharacterCardUtility.DoNameInputRect(rect6, ref last, 12);
                    if (nameTriple.First != first2 || nameTriple.Nick != nick || nameTriple.Last != last)
                    {
                        newPawn.Name = new NameTriple(first2, nick, last);
                    }

                    TooltipHandler.TipRegion(rect4, "FirstNameDesc".Translate());
                    TooltipHandler.TipRegion(rect5, "ShortIdentifierDesc".Translate());
                    TooltipHandler.TipRegion(rect6, "LastNameDesc".Translate());
                }
                else
                {
                    rect3.width = 999f;
                    Text.Font   = GameFont.Medium;
                    Widgets.Label(rect3, newPawn.Name.ToStringFull);
                    Text.Font = GameFont.Small;
                }

                var rect7 = new Rect(rect.x + rect.width + 16f, rect.y + 32f,
                                     inRect.width - (rect.x + rect.width + 16f), 32f);
                Text.Font = GameFont.Medium;
                if (Widgets.ButtonText(rect7, crafterProperties.crafterPawnCustomizationCraftButton.Translate(), true,
                                       false))
                {
                    pawnCrafter.pawnBeingCrafted = newPawn;
                    pawnCrafter.crafterStatus    = CrafterStatus.Filling;
                    Close();
                }

                Text.Font = GameFont.Small;
                if (Widgets.ButtonText(new Rect(304f, num, 120f, 24f),
                                       crafterProperties.crafterPawnCustomizationCraftRollFemaleButton.Translate(), true, false))
                {
                    newPawn.Destroy();
                    newPawn = GetNewPawn();
                }

                if (Widgets.ButtonText(new Rect(424f, num, 120f, 24f),
                                       crafterProperties.crafterPawnCustomizationCraftRollMaleButton.Translate(), true, false))
                {
                    newPawn.Destroy();
                    newPawn = GetNewPawn(Gender.Male);
                }

                num += 26f;
                var rect8 = new Rect(32f, num, 240f, 24f);
                Widgets.DrawBox(rect8);
                Widgets.DrawHighlightIfMouseover(rect8);
                string text;
                if (newPawn.story.childhood != null)
                {
                    text = crafterProperties.crafterPawnCustomizationCraftChildhoodBackstoryButton.Translate() + " " +
                           newPawn.story.childhood.titleShort;
                }
                else
                {
                    text = crafterProperties.crafterPawnCustomizationCraftChildhoodBackstoryButton.Translate() + " " +
                           crafterProperties.crafterPawnCustomizationNone.Translate();
                }

                if (Widgets.ButtonText(rect8, text, true, false))
                {
                    FloatMenuUtility.MakeMenu(from backstory in BackstoryDatabase.allBackstories.Select(
                                                  delegate(KeyValuePair <string, Backstory> backstoryPair)
                    {
                        var keyValuePair = backstoryPair;
                        return(keyValuePair.Value);
                    })
                                              where backstory.spawnCategories.Contains(crafterProperties
                                                                                       .crafterPawnCustomizationPawnBackstoryTag) && backstory.slot == BackstorySlot.Childhood
                                              select backstory, backstory => backstory.titleShort,
                                              backstory => delegate { newChildhoodBackstory = backstory; });
                }

                if (newPawn.story.childhood != null)
                {
                    TooltipHandler.TipRegion(rect8, newPawn.story.childhood.FullDescriptionFor(newPawn));
                }

                var rect9 = new Rect(304f, num, 240f, 24f);
                Widgets.DrawBox(rect9);
                Widgets.DrawHighlightIfMouseover(rect9);
                string text2;
                if (newPawn.story.adulthood != null)
                {
                    text2 = crafterProperties.crafterPawnCustomizationCraftAdulthoodBackstoryButton.Translate() + " " +
                            newPawn.story.adulthood.titleShort;
                }
                else
                {
                    text2 = crafterProperties.crafterPawnCustomizationCraftAdulthoodBackstoryButton.Translate() + " " +
                            crafterProperties.crafterPawnCustomizationNone.Translate();
                }

                if (Widgets.ButtonText(rect9, text2, true, false))
                {
                    FloatMenuUtility.MakeMenu(from backstory in BackstoryDatabase.allBackstories.Select(
                                                  delegate(KeyValuePair <string, Backstory> backstoryPair)
                    {
                        var keyValuePair = backstoryPair;
                        return(keyValuePair.Value);
                    })
                                              where backstory.spawnCategories.Contains(crafterProperties
                                                                                       .crafterPawnCustomizationPawnBackstoryTag) && backstory.slot == BackstorySlot.Adulthood
                                              select backstory, backstory => backstory.titleShort,
                                              backstory => delegate { newAdulthoodBackstory = backstory; });
                }

                if (newPawn.story.adulthood != null)
                {
                    TooltipHandler.TipRegion(rect9, newPawn.story.adulthood.FullDescriptionFor(newPawn));
                }

                num += 48f;
                var vector = new Vector2(32f, num);
                SkillUI.DrawSkillsOf(newPawn, vector, SkillUI.SkillDrawMode.Gameplay);
                num = rect.y + rect.height;
                var num2 = rect.x + 24f;
                Text.Anchor = TextAnchor.MiddleCenter;
                foreach (var trait in newPawn.story.traits.allTraits)
                {
                    var rect10 = new Rect(num2, num, 256f, 24f);
                    Widgets.DrawBox(rect10);
                    Widgets.DrawHighlightIfMouseover(rect10);
                    Widgets.Label(rect10, trait.LabelCap);
                    TooltipHandler.TipRegion(rect10, trait.TipString(newPawn));
                    num += 26f;
                }
            }

            Text.Anchor = 0;
        }
Exemplo n.º 22
0
        public override void DoWindowContents(Rect rect)
        {
            const float scrollRectOffsetTop = ROW_HEIGHT * 2 + ROW_ADD_GAP;

            Text.Font = GameFont.Small;

            // draw event add row
            Rect rectAdd = new Rect(0f, 0f, ROW_ADD_WIDTH, ROW_HEIGHT);

            DrawRowAdd(rectAdd, () =>
            {
                _scrollPosition = new Vector2(0, ROW_HEIGHT * _store.MatteredDays.Count + ROW_HEIGHT * STATIC_ROW_COUNT - (rect.height - scrollRectOffsetTop));
            });

            // draw header
            Rect rectHeader = new Rect(0f, ROW_HEIGHT + ROW_ADD_GAP, rect.width - SCROLLBAR_WIDTH, ROW_HEIGHT);

            DrawHeader(rectHeader);

            // draw list
            if (_store.MatteredDays == null)
            {
                _store.MatteredDays = new List <MatteredDay>();
            }
            List <MatteredDay> list = _store.MatteredDays;

            Rect scrollRect = new Rect(0f, scrollRectOffsetTop, rect.width, rect.height - scrollRectOffsetTop);
            Rect viewRect   = new Rect(0f, 0f, scrollRect.width - SCROLLBAR_WIDTH, ROW_HEIGHT * list.Count + ROW_HEIGHT * STATIC_ROW_COUNT);

            Widgets.BeginScrollView(scrollRect, ref _scrollPosition, viewRect);
            Vector2 cur = Vector2.zero;

            // settlement
            int     startTicks        = Find.TickManager.gameStartAbsTick;
            Quadrum settlementQuadrum = GenDate.Quadrum(startTicks, 0);
            int     settlementDay     = GenDate.DayOfQuadrum(startTicks, 0) + 1;

            DrawRowWithFixedDate(new Rect(0f, cur.y, viewRect.width, ROW_HEIGHT), ref cur, "DM.Tab.BuiltIn.Settlement".Translate(), settlementQuadrum, settlementDay, _store.Settlement, () =>
            {
                FloatMenuUtility.MakeMenu(Enum.GetValues(typeof(Duration)).Cast <Duration>(), duration => duration.Label(), duration => delegate
                {
                    _store.Settlement = duration;
                });
            });

            // birthdays
            DrawRowWithNoDate(new Rect(0f, cur.y, viewRect.width, ROW_HEIGHT), ref cur, "DM.Tab.BuiltIn.ChronologicalBirthday".Translate(), _store.Birthdays, () =>
            {
                FloatMenuUtility.MakeMenu(Enum.GetValues(typeof(Duration)).Cast <Duration>(), duration => duration.Label(), duration => delegate
                {
                    _store.Birthdays = duration;
                });
            }, "DM.Tab.Misc.ShowAll".Translate(), () =>
            {
                Find.WindowStack.Add(new DialogList(DialogList.ListType.Birthdays));
            });

            // lovers anniversaries
            DrawRowWithNoDate(new Rect(0f, cur.y, viewRect.width, ROW_HEIGHT), ref cur, "DM.Tab.BuiltIn.RelationshipAnniversary".Translate(), _store.LoversAnniversaries, () =>
            {
                FloatMenuUtility.MakeMenu(Enum.GetValues(typeof(Duration)).Cast <Duration>(), duration => duration.Label(), duration => delegate
                {
                    _store.LoversAnniversaries = duration;
                });
            }, "DM.Tab.Misc.ShowAll".Translate(), () =>
            {
                Find.WindowStack.Add(new DialogList(DialogList.ListType.Relationships));
            });

            // marriage anniversaries
            DrawRowWithNoDate(new Rect(0f, cur.y, viewRect.width, ROW_HEIGHT), ref cur, "DM.Tab.BuiltIn.MarriageAnniversary".Translate(), _store.MarriageAnniversaries, () =>
            {
                FloatMenuUtility.MakeMenu(Enum.GetValues(typeof(Duration)).Cast <Duration>(), duration => duration.Label(), duration => delegate
                {
                    _store.MarriageAnniversaries = duration;
                });
            }, "DM.Tab.Misc.ShowAll".Translate(), () =>
            {
                Find.WindowStack.Add(new DialogList(DialogList.ListType.Marriages));
            });

            for (int index = 0; index < list.Count; index++)
            {
                if (list.Count <= index)
                {
                    break;
                }

                var row = new Rect(0f, cur.y, viewRect.width, ROW_HEIGHT);

                Widgets.DrawHighlightIfMouseover(row);
                GUI.color = new Color(1f, 1f, 1f, 0.2f);
                Widgets.DrawLineHorizontal(0f, cur.y, viewRect.width);
                GUI.color = Color.white;

                DrawRow(row, list[index], index);

                cur.y += ROW_HEIGHT;
            }
            Widgets.EndScrollView();
        }
Exemplo n.º 23
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            foreach (var item in base.GetGizmos())
            {
                yield return(item);
            }

            yield return(new Command_Action()
            {
                defaultLabel = "RF.DL.ChangeShellLabel".Translate(),
                defaultDesc = "RF.DL.ChangeShellDesc".Translate(),
                action = () =>
                {
                    Func <ThingDef, string> labelGetter = shell => shell.LabelCap;
                    Func <ThingDef, Action> actionGetter = shell =>
                    {
                        if (shell == CurrentShellDef)
                        {
                            return null;
                        }
                        return () =>
                        {
                            EjectLoadedShells();
                            CurrentShellDef = shell;
                        };
                    };
                    FloatMenuUtility.MakeMenu(LoadableBombs, labelGetter, actionGetter);
                },
                icon = CurrentShellDef?.uiIcon
            });

            yield return(new Command_TargetCustom()
            {
                times = 2,
                defaultLabel = "RF.DL.TargetLabel".Translate(),
                defaultDesc = "RF.DL.TargetDesc".Translate(),
                icon = Content.MissilesIcon,
                defaultIconColor = Color.yellow,
                disabled = drawAffectedCells || isBlocked || LoadedShellCount < 1,
                disabledReason = LoadedShellCount < 1 ? "RF.DL.NoShells".Translate() : isBlocked ? "RF.DL.Blocked".Translate(blockedBy) : "RF.DL.AlreadyTargeting".Translate(),
                continueCheck = () => keepGoing,
                action = (t, i) =>
                {
                    if (!t.IsValid)
                    {
                        return;
                    }

                    if (LoadedShellCount == 1)
                    {
                        firstPosition = t.Cell;
                        secondPosition = t.Cell;
                        keepGoing = false;
                    }
                    else
                    {
                        if (i == 0)
                        {
                            firstPosition = t.Cell;
                            keepGoing = true;
                        }
                        else
                        {
                            secondPosition = t.Cell;
                        }
                    }

                    if (i == 1 || LoadedShellCount == 1)
                    {
                        const float MIN_DST = 5f;
                        bool hasDistance = LoadedShellCount == 1 || (firstPosition.Value - secondPosition.Value).LengthHorizontal >= MIN_DST;

                        if (hasDistance)
                        {
                            DoStrike();
                        }
                        else
                        {
                            Messages.Message("RF.DL.NotEnoughDistance".Translate(MIN_DST), MessageTypeDefOf.RejectInput, false);
                        }

                        firstPosition = null;
                        secondPosition = null;
                    }
                },
                user = this,
                targetingParams = new TargetingParameters()
                {
                    canTargetLocations = true,
                    canTargetPawns = false,
                    canTargetFires = false,
                    mapObjectTargetsMustBeAutoAttackable = false
                }
            });
        }
        public override void DoWindowContents(Rect inRect)
        {
            //Detect changes
            if (refreshAndroidPortrait)
            {
                newSleeve.Drawer.renderer.graphics.ResolveAllGraphics();
                PortraitsCache.SetDirty(newSleeve);
                PortraitsCache.PortraitsCacheUpdate();
                refreshAndroidPortrait = false;
            }

            Rect pawnRect = new Rect(inRect);

            pawnRect.width  = PawnPortraitSize.x + 16f;
            pawnRect.height = PawnPortraitSize.y + 16f;
            pawnRect        = inRect.RightHalf();
            pawnRect        = inRect.RightHalf();
            pawnRect.x     += 16f;
            pawnRect.y     += 16f;

            //Draw Pawn stuff.
            if (newSleeve != null)
            {
                //Pawn
                Rect pawnRenderRect = new Rect(pawnRect.xMin + (pawnRect.width - PawnPortraitSize.x) / 2f - 10f, pawnRect.yMin + 20f, PawnPortraitSize.x, PawnPortraitSize.y);
                //GUI.DrawTexture(pawnRenderRect, PortraitsCache.Get(newSleeve, PawnPortraitSize, default(Vector3), 1f));

                Text.Font = GameFont.Medium;

                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(new Rect(0f, 0f, inRect.width, 32f), "AlteredCarbon.SleeveCustomization".Translate());

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

                //Saakra's Code

                //Gender
                Text.Anchor = TextAnchor.MiddleLeft;
                Widgets.Label(lblGender, "Gender".Translate() + ":");
                if (Widgets.ButtonText(btnGenderMale, "Male".Translate().CapitalizeFirst()))
                {
                    newSleeve = GetNewPawn(Gender.Male);
                }
                if (Widgets.ButtonText(btnGenderFemale, "Female".Translate().CapitalizeFirst()))
                {
                    newSleeve = GetNewPawn(Gender.Female);
                }

                //Skin Colour
                Text.Anchor = TextAnchor.MiddleLeft;
                Widgets.Label(lblSkinColour, "SkinColour".Translate().CapitalizeFirst() + ":");
                Widgets.DrawMenuSection(btnSkinColourOutline);
                Widgets.DrawShadowAround(btnSkinColourOutline);
                if (Widgets.ButtonInvisible(btnSkinColour1))
                {
                    newSleeve.story.melanin = 0.1f;
                    UpdateSleeveGraphic();
                }
                Widgets.DrawBoxSolid(btnSkinColour1, rgbConvert(242, 237, 224));

                if (Widgets.ButtonInvisible(btnSkinColour2))
                {
                    newSleeve.story.melanin = 0.3f;
                    UpdateSleeveGraphic();
                }
                Widgets.DrawBoxSolid(btnSkinColour2, rgbConvert(255, 239, 213));

                if (Widgets.ButtonInvisible(btnSkinColour3))
                {
                    newSleeve.story.melanin = 0.5f;
                    UpdateSleeveGraphic();
                }
                Widgets.DrawBoxSolid(btnSkinColour3, rgbConvert(255, 239, 189));

                if (Widgets.ButtonInvisible(btnSkinColour4))
                {
                    newSleeve.story.melanin = 0.7f;
                    UpdateSleeveGraphic();
                }
                Widgets.DrawBoxSolid(btnSkinColour4, rgbConvert(228, 158, 90));

                if (Widgets.ButtonInvisible(btnSkinColour5))
                {
                    newSleeve.story.melanin = 0.9f;
                    UpdateSleeveGraphic();
                }
                Widgets.DrawBoxSolid(btnSkinColour5, rgbConvert(130, 91, 48));

                //Head Shape
                Widgets.Label(lblHeadShape, "HeadShape".Translate().CapitalizeFirst() + ":");
                Widgets.DrawHighlight(btnHeadShapeOutline);
                if (ButtonTextSubtleCentered(btnHeadShapeArrowLeft, "<"))
                {
                    if (newSleeve.gender == Gender.Male)
                    {
                        if (maleHeadTypeIndex == 0)
                        {
                            maleHeadTypeIndex = GraphicDatabaseHeadRecords.maleHeads.Count - 1;
                        }
                        else
                        {
                            maleHeadTypeIndex--;
                        }

                        typeof(Pawn_StoryTracker).GetField("headGraphicPath", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(newSleeve.story,
                                                                                                                                       GraphicDatabaseHeadRecords.maleHeads.ElementAt(maleHeadTypeIndex).graphicPath);
                    }
                    else if (newSleeve.gender == Gender.Female)
                    {
                        if (femaleHeadTypeIndex == 0)
                        {
                            femaleHeadTypeIndex = GraphicDatabaseHeadRecords.femaleHeads.Count - 1;
                        }
                        else
                        {
                            femaleHeadTypeIndex--;
                        }

                        typeof(Pawn_StoryTracker).GetField("headGraphicPath", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(newSleeve.story,
                                                                                                                                       GraphicDatabaseHeadRecords.femaleHeads.ElementAt(femaleHeadTypeIndex).graphicPath);
                    }

                    UpdateSleeveGraphic();
                }
                if (ButtonTextSubtleCentered(btnHeadShapeSelection, "HeadTypeReplace".Translate()))
                {
                    if (newSleeve.gender == Gender.Male)
                    {
                        FloatMenuUtility.MakeMenu <GraphicDatabaseHeadRecords.HeadGraphicRecord>(GraphicDatabaseHeadRecords.maleHeads, head => ExtractHeadLabels(head.graphicPath),
                                                                                                 (GraphicDatabaseHeadRecords.HeadGraphicRecord head) => delegate
                        {
                            typeof(Pawn_StoryTracker).GetField("headGraphicPath", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(newSleeve.story,
                                                                                                                                           head.graphicPath);
                            UpdateSleeveGraphic();
                        });
                    }
                    else if (newSleeve.gender == Gender.Female)
                    {
                        FloatMenuUtility.MakeMenu <GraphicDatabaseHeadRecords.HeadGraphicRecord>(GraphicDatabaseHeadRecords.femaleHeads, head => ExtractHeadLabels(head.graphicPath),
                                                                                                 (GraphicDatabaseHeadRecords.HeadGraphicRecord head) => delegate
                        {
                            typeof(Pawn_StoryTracker).GetField("headGraphicPath", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(newSleeve.story,
                                                                                                                                           head.graphicPath);
                            UpdateSleeveGraphic();
                        });
                    }
                }
                if (ButtonTextSubtleCentered(btnHeadShapeArrowRight, ">"))
                {
                    if (newSleeve.gender == Gender.Male)
                    {
                        if (maleHeadTypeIndex == GraphicDatabaseHeadRecords.maleHeads.Count - 1)
                        {
                            maleHeadTypeIndex = 0;
                        }
                        else
                        {
                            maleHeadTypeIndex++;
                        }
                        typeof(Pawn_StoryTracker).GetField("headGraphicPath", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(newSleeve.story,
                                                                                                                                       GraphicDatabaseHeadRecords.maleHeads.ElementAt(maleHeadTypeIndex).graphicPath);
                    }
                    else if (newSleeve.gender == Gender.Female)
                    {
                        if (femaleHeadTypeIndex == GraphicDatabaseHeadRecords.femaleHeads.Count - 1)
                        {
                            femaleHeadTypeIndex = 0;
                        }
                        else
                        {
                            femaleHeadTypeIndex++;
                        }
                        typeof(Pawn_StoryTracker).GetField("headGraphicPath", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(newSleeve.story,
                                                                                                                                       GraphicDatabaseHeadRecords.femaleHeads.ElementAt(femaleHeadTypeIndex).graphicPath);
                    }
                    UpdateSleeveGraphic();
                }


                //Body Shape
                Widgets.Label(lblBodyShape, "BodyShape".Translate().CapitalizeFirst() + ":");
                Widgets.DrawHighlight(btnBodyShapeOutline);
                if (ButtonTextSubtleCentered(btnBodyShapeArrowLeft, "<"))
                {
                    if (newSleeve.gender == Gender.Male)
                    {
                        if (maleBodyTypeIndex == 0)
                        {
                            maleBodyTypeIndex = DefDatabase <BodyTypeDef> .AllDefs.Where(x => x != BodyTypeDefOf.Female).Count() - 1;
                        }
                        else
                        {
                            maleBodyTypeIndex--;
                        }
                        newSleeve.story.bodyType = DefDatabase <BodyTypeDef> .AllDefs.Where(x => x != BodyTypeDefOf.Female).ElementAt(maleBodyTypeIndex);
                    }
                    else if (newSleeve.gender == Gender.Female)
                    {
                        if (femaleBodyTypeIndex == 0)
                        {
                            femaleBodyTypeIndex = DefDatabase <BodyTypeDef> .AllDefs.Where(x => x != BodyTypeDefOf.Male).Count() - 1;
                        }
                        else
                        {
                            femaleBodyTypeIndex--;
                        }
                        newSleeve.story.bodyType = DefDatabase <BodyTypeDef> .AllDefs.Where(x => x != BodyTypeDefOf.Male).ElementAt(femaleBodyTypeIndex);
                    }

                    UpdateSleeveGraphic();
                }
                if (ButtonTextSubtleCentered(btnBodyShapeSelection, "BodyTypeReplace".Translate()))
                {
                    if (newSleeve.gender == Gender.Male)
                    {
                        IEnumerable <BodyTypeDef> bodyTypes = from bodyType in DefDatabase <BodyTypeDef>
                                                              .AllDefs.Where(x => x != BodyTypeDefOf.Female) select bodyType;

                        FloatMenuUtility.MakeMenu <BodyTypeDef>(bodyTypes, bodyType => bodyType.defName, (BodyTypeDef bodyType) => delegate
                        {
                            newSleeve.story.bodyType = bodyType;
                            UpdateSleeveGraphic();
                        });
                    }
                    else if (newSleeve.gender == Gender.Female)
                    {
                        IEnumerable <BodyTypeDef> bodyTypes = from bodyType in DefDatabase <BodyTypeDef>
                                                              .AllDefs.Where(x => x != BodyTypeDefOf.Male)
                                                              select bodyType;

                        FloatMenuUtility.MakeMenu <BodyTypeDef>(bodyTypes, bodyType => bodyType.defName, (BodyTypeDef bodyType) => delegate
                        {
                            newSleeve.story.bodyType = bodyType;
                            UpdateSleeveGraphic();
                        });
                    }
                }
                if (ButtonTextSubtleCentered(btnBodyShapeArrowRight, ">"))
                {
                    if (newSleeve.gender == Gender.Male)
                    {
                        if (maleBodyTypeIndex == DefDatabase <BodyTypeDef> .AllDefs.Where(x => x != BodyTypeDefOf.Female).Count() - 1)
                        {
                            maleBodyTypeIndex = 0;
                        }
                        else
                        {
                            maleBodyTypeIndex++;
                        }
                        newSleeve.story.bodyType = DefDatabase <BodyTypeDef> .AllDefs.Where(x => x != BodyTypeDefOf.Female).ElementAt(maleBodyTypeIndex);
                    }
                    else if (newSleeve.gender == Gender.Female)
                    {
                        if (femaleBodyTypeIndex == DefDatabase <BodyTypeDef> .AllDefs.Where(x => x != BodyTypeDefOf.Male).Count() - 1)
                        {
                            femaleBodyTypeIndex = 0;
                        }
                        else
                        {
                            femaleBodyTypeIndex++;
                        }
                        newSleeve.story.bodyType = DefDatabase <BodyTypeDef> .AllDefs.Where(x => x != BodyTypeDefOf.Male).ElementAt(femaleBodyTypeIndex);
                    }
                    UpdateSleeveGraphic();
                }


                //Hair Colour
                Text.Anchor = TextAnchor.MiddleLeft;
                Widgets.Label(lblHairColour, "HairColour".Translate().CapitalizeFirst() + ":");

                Widgets.DrawMenuSection(btnHairColourOutlinePremade);
                Widgets.DrawShadowAround(btnHairColourOutlinePremade);


                Widgets.DrawBoxSolid(btnHairColour1, rgbConvert(51, 51, 51));
                Widgets.DrawBoxSolid(btnHairColour2, rgbConvert(79, 71, 66));
                Widgets.DrawBoxSolid(btnHairColour3, rgbConvert(64, 51, 38));
                Widgets.DrawBoxSolid(btnHairColour4, rgbConvert(77, 51, 26));
                Widgets.DrawBoxSolid(btnHairColour5, rgbConvert(90, 58, 32));
                Widgets.DrawBoxSolid(btnHairColour6, rgbConvert(132, 83, 47));
                Widgets.DrawBoxSolid(btnHairColour7, rgbConvert(193, 146, 85));
                Widgets.DrawBoxSolid(btnHairColour8, rgbConvert(237, 202, 156));



                if (Widgets.ButtonInvisible(btnHairColour1))
                {
                    setHair(rgbConvert(51, 51, 51));
                }
                else
                if (Widgets.ButtonInvisible(btnHairColour2))
                {
                    setHair(rgbConvert(79, 71, 66));
                }
                else
                if (Widgets.ButtonInvisible(btnHairColour3))
                {
                    setHair(rgbConvert(64, 51, 38));
                }
                else
                if (Widgets.ButtonInvisible(btnHairColour4))
                {
                    setHair(rgbConvert(77, 51, 26));
                }
                else
                if (Widgets.ButtonInvisible(btnHairColour5))
                {
                    setHair(rgbConvert(90, 58, 32));
                }
                else
                if (Widgets.ButtonInvisible(btnHairColour6))
                {
                    setHair(rgbConvert(132, 83, 47));
                }
                else
                if (Widgets.ButtonInvisible(btnHairColour7))
                {
                    setHair(rgbConvert(193, 146, 85));
                }
                else
                if (Widgets.ButtonInvisible(btnHairColour8))
                {
                    setHair(rgbConvert(237, 202, 156));
                }

                Widgets.DrawMenuSection(btnHairColourOutline);
                Widgets.DrawTextureFitted(btnHairColourOutline, texColor, 1);
                Widgets.DrawMenuSection(btnHairColourOutline2);
                Widgets.DrawTextureFitted(btnHairColourOutline2, texDarkness, 1);

                //if click in texColour box
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Mouse.IsOver(btnHairColourOutline))
                {
                    Vector2 mPos = Event.current.mousePosition;
                    float   x    = mPos.x - btnHairColourOutline.x;
                    float   y    = mPos.y - btnHairColourOutline.y;
                    //Log.Message(x.ToString());
                    //Log.Message(y.ToString());

                    setHair(texColor.GetPixel(Convert.ToInt32(x), Convert.ToInt32(btnHairColourOutline.height - y)));
                    Event.current.Use();
                }

                //if click in Darkness box
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Mouse.IsOver(btnHairColourOutline2))
                {
                    Vector2 mPos = Event.current.mousePosition;
                    float   x    = mPos.x - btnHairColourOutline2.x;
                    float   y    = mPos.y - btnHairColourOutline2.y;
                    //Log.Message(x.ToString());
                    //Log.Message(y.ToString());

                    selectedColorFinal = texDarkness.GetPixel(Convert.ToInt32(x), Convert.ToInt32(btnHairColourOutline2.height - y));
                    updateColors();
                    newSleeve.story.hairColor = selectedColorFinal;
                    refreshAndroidPortrait    = true;
                    Event.current.Use();
                }

                //Hair Type
                Text.Anchor = TextAnchor.MiddleLeft;
                Widgets.Label(lblHairType, "HairType".Translate().CapitalizeFirst() + ":");
                Widgets.DrawHighlight(btnHairTypeOutline);
                if (ButtonTextSubtleCentered(btnHairTypeArrowLeft, "<"))
                {
                    if (hairTypeIndex == 0)
                    {
                        hairTypeIndex = DefDatabase <HairDef> .AllDefs.Count() - 1;
                    }
                    else
                    {
                        hairTypeIndex--;
                    }
                    newSleeve.story.hairDef = DefDatabase <HairDef> .AllDefs.ElementAt(hairTypeIndex);

                    UpdateSleeveGraphic();
                }
                if (ButtonTextSubtleCentered(btnHairTypeSelection, newSleeve.story.hairDef.LabelCap))
                {
                    IEnumerable <HairDef> hairs =
                        from hairdef in DefDatabase <HairDef> .AllDefs select hairdef;
                    FloatMenuUtility.MakeMenu <HairDef>(hairs, hairDef => hairDef.LabelCap, (HairDef hairDef) => delegate
                    {
                        newSleeve.story.hairDef = hairDef;
                        UpdateSleeveGraphic();
                    });
                }
                if (ButtonTextSubtleCentered(btnHairTypeArrowRight, ">"))
                {
                    if (hairTypeIndex == DefDatabase <HairDef> .AllDefs.Count() - 1)
                    {
                        hairTypeIndex = 0;
                    }
                    else
                    {
                        hairTypeIndex++;
                    }
                    newSleeve.story.hairDef = DefDatabase <HairDef> .AllDefs.ElementAt(hairTypeIndex);

                    UpdateSleeveGraphic();
                }

                //Time to Grow
                Widgets.Label(lblTimeToGrow, "TimeToGrow".Translate().CapitalizeFirst() + ": " + GenDate.ToStringTicksToDays(baseTicksToGrow + baseTicksToGrow2 + baseTicksToGrow3));//PUT TIME TO GROW INFO HERE

                //Require Biomass
                Widgets.Label(lblRequireBiomass, "RequireBiomass".Translate().CapitalizeFirst() + ": " + (baseMeatCost + baseMeatCost2 + baseMeatCost3));//PUT REQUIRED BIOMASS HERE

                //Vertical Divider
                //Widgets.DrawLineVertical((pawnBox.x + (btnGenderFemale.x + btnGenderFemale.width)) / 2, pawnBox.y, InitialSize.y - pawnBox.y - (buttonHeight + 53));

                //Pawn Box
                Widgets.DrawMenuSection(pawnBox);
                Widgets.DrawShadowAround(pawnBox);
                GUI.DrawTexture(pawnBoxPawn, PortraitsCache.Get(newSleeve, pawnBoxPawn.size, default(Vector3), 1f));

                //Levels of Beauty
                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(lblLevelOfBeauty, "LevelOfBeauty".Translate().CapitalizeFirst() + ": " + beautyLevel);
                if (Widgets.ButtonText(btnLevelOfBeauty1, "1"))
                {
                    RemoveAllTraits(newSleeve);
                    newSleeve.story.traits.GainTrait(new Trait(TraitDefOf.Beauty, -2));
                    baseTicksToGrow2 = -420000;
                    baseMeatCost2    = -50;
                    beautyLevel      = 1;
                }
                if (Widgets.ButtonText(btnLevelOfBeauty2, "2"))
                {
                    RemoveAllTraits(newSleeve);
                    baseTicksToGrow2 = 0;
                    baseMeatCost2    = 0;
                    beautyLevel      = 2;
                }
                if (Widgets.ButtonText(btnLevelOfBeauty3, "3"))
                {
                    RemoveAllTraits(newSleeve);
                    newSleeve.story.traits.GainTrait(new Trait(TraitDefOf.Beauty, 2));
                    baseTicksToGrow2 = 420000;
                    baseTicksToGrow2 = 420;

                    baseMeatCost2 = 50;
                    beautyLevel   = 3;
                }

                //Levels of Quality

                Widgets.Label(lblLevelOfQuality, "LevelofQuality".Translate().CapitalizeFirst() + ": " + qualityLevel);
                if (Widgets.ButtonText(btnLevelOfQuality1, "1"))
                {
                    baseTicksToGrow3 = -420000;
                    baseMeatCost3    = -50;
                    RemoveAllHediffs(newSleeve);
                    newSleeve.health.AddHediff(AlteredCarbonDefOf.AC_Sleeve_Quality_Low, null);
                    qualityLevel = 1;
                }
                if (Widgets.ButtonText(btnLevelOfQuality2, "2"))
                {
                    baseTicksToGrow3 = 0;
                    baseMeatCost3    = 0;
                    RemoveAllHediffs(newSleeve);
                    newSleeve.health.AddHediff(AlteredCarbonDefOf.AC_Sleeve_Quality_Standart, null);
                    qualityLevel = 2;
                }
                if (Widgets.ButtonText(btnLevelOfQuality3, "3"))
                {
                    baseTicksToGrow3 = 420000;
                    baseTicksToGrow3 = 420;
                    baseMeatCost3    = 50;
                    RemoveAllHediffs(newSleeve);
                    newSleeve.health.AddHediff(AlteredCarbonDefOf.AC_Sleeve_Quality_High, null);
                    qualityLevel = 3;
                }

                if (Widgets.ButtonText(btnAccept, "Accept".Translate().CapitalizeFirst()))
                {
                    sleeveGrower.StartGrowth(newSleeve, baseTicksToGrow + baseTicksToGrow2 + baseTicksToGrow3, baseMeatCost + baseMeatCost2 + baseMeatCost3);
                    this.Close();
                }
                if (Widgets.ButtonText(btnCancel, "Cancel".Translate().CapitalizeFirst()))
                {
                    this.Close();
                }
            }
            Text.Anchor = TextAnchor.UpperLeft;
        }
Exemplo n.º 25
0
        protected override void FillTab()
        {
            Rect  mainRect = new Rect(0f, 0f, WinSize.x, WinSize.y);
            float rowY     = mainRect.y;

            //Title
            Text.Anchor = TextAnchor.UpperCenter;
            Text.Font   = GameFont.Medium;
            Rect titleRect = new Rect(mainRect);

            titleRect.y     += Text.LineHeight;
            titleRect.height = Text.LineHeight;
            Widgets.Label(titleRect, "RunesRuneBills".Translate());
            //rowY = Text.LineHeight + 2f;
            Text.Anchor = TextAnchor.UpperLeft;
            Text.Font   = GameFont.Small;

            //Bills & Add Bill
            Rect outerBillsRect = new Rect(mainRect);

            outerBillsRect.y      = titleRect.yMax + 2f;
            outerBillsRect.height = mainRect.height - outerBillsRect.y - 4f;
            outerBillsRect.x     += 4f;
            outerBillsRect.width -= 8f;

            Widgets.DrawWindowBackground(outerBillsRect);

            Rect  innerBillsRect = new Rect(outerBillsRect);
            float billHeightSize = outerBillsRect.height / 2.5f;

            innerBillsRect.height = billHeightSize * (1 + SelTable.billStack.bills.Count);

            Widgets.BeginScrollView(outerBillsRect, ref billsScrollPosition, innerBillsRect);

            rowY = outerBillsRect.y;

            //Do Bills
            int      index      = 0;
            RuneBill billToMove = null;
            RuneBill deleteBill = null;

            foreach (RuneBill bill in SelTable.billStack.bills)
            {
                Rect billRect = new Rect(innerBillsRect);
                billRect.y      = rowY;
                billRect.height = billHeightSize;

                if (index % 2 == 0)
                {
                    Widgets.DrawAltRect(billRect);
                }

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

                Rect billTitleRect = new Rect(billRect);
                billTitleRect.x     += 26f;
                billTitleRect.width -= 26f;
                Widgets.Label(billTitleRect, bill.recipeDef.label);

                if (bill.assignedPawn != null)
                {
                    Text.Anchor = TextAnchor.LowerLeft;
                    Text.Font   = GameFont.Tiny;
                    Widgets.Label(billRect, "RunesBillAuthor".Translate(bill.assignedPawn.Name.ToString()));
                    Text.Anchor = TextAnchor.UpperLeft;
                    Text.Font   = GameFont.Small;
                }

                //bill.recipeDef.Worker.DoWorkerGUI(billRect, bill);
                bill.DoGUI(billRect);

                if (bill.moveBill != 0)
                {
                    billToMove = bill;
                }

                if (bill.deleted)
                {
                    deleteBill = bill;
                }

                rowY += billHeightSize;
                index++;
            }

            //Do Add Bill
            Rect addBillRect = new Rect(innerBillsRect);

            addBillRect.y      = rowY;
            addBillRect.height = billHeightSize;

            if (index % 2 == 0)
            {
                Widgets.DrawAltRect(addBillRect);
            }

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

            Widgets.Label(addBillRect, "RunesAddRuneBill".Translate());

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

            Widgets.DrawHighlightIfMouseover(addBillRect);
            if (Widgets.ButtonInvisible(addBillRect))
            {
                FloatMenuUtility.MakeMenu <RuneRecipeDef>(
                    DefDatabase <RuneRecipeDef> .AllDefs,
                    (recipeDef) => recipeDef.label,
                    (RuneRecipeDef recipeDef) => delegate()
                {
                    RuneBill bill  = new RuneBill();
                    bill.recipeDef = recipeDef;

                    SelTable.billStack.AddBill(bill);
                });
            }

            Widgets.EndScrollView();

            //Manipulate
            if (billToMove != null)
            {
                //SelTable.billStack.bills

                /*int oldIndex = SelTable.billStack.bills.IndexOf(billToMove);
                 *
                 * SelTable.billStack.bills.Remove(billToMove);
                 * SelTable.billStack.bills.Insert(oldIndex + billToMove.moveBill, billToMove);
                 * billToMove.moveBill = 0;*/
                SelTable.billStack.RearrangeBill(billToMove);
            }

            //Delete
            if (deleteBill != null)
            {
                SelTable.billStack.RemoveBill(deleteBill);
            }
        }