public RollingDialog(Page_ConfigureStartingPawns page, MethodBase randomizeMethod)
 {
     this.closeOnClickedOutside = true;
     this.iterations            = 0;
     this.page            = page;
     this.randomizeMethod = randomizeMethod;
 }
        public static void Postfix(Page_ConfigureStartingPawns __instance, MethodBase __originalMethod, Pawn ___curPawn)
        {
            // Just skip everything if there is no filter.
            if (PrepareModerately.Instance.currentFilter.parts.Count < 1)
            {
                return;
            }

            // Update current pawn so that it's accessible elsewhere.
            PrepareModerately.Instance.currentPawn = ___curPawn;

            // Don't do complex stuff if the pawn already works.
            if (PrepareModerately.Instance.currentFilter.Matches(___curPawn))
            {
                return;
            }

            // Ensure randomizing dialog doesn't get added twice.
            if (PrepareModerately.Instance.currentlyRandomizing)
            {
                return;
            }

            // Add randomizing dialog.
            Find.WindowStack.Add(new RollingDialog(__instance, __originalMethod));
            PrepareModerately.Instance.currentlyRandomizing = true;
        }
        public static bool ConfigureStartingPawnsDoNextPrefix(Page_ConfigureStartingPawns __instance, Pawn ___curPawn)
        {
            MethodInfo runMe = AccessTools.Method(typeof(Page_ConfigureStartingPawns), "DoNext");

            List <Pawn> tmpList = new List <Pawn>(Find.GameInitData.startingPawnCount);

            tmpList.AddRange(Find.GameInitData.startingAndOptionalPawns.Take(Find.GameInitData.startingPawnCount));
            if (!tmpList.Contains(___curPawn))
            {
                Find.WindowStack.Add(
                    Dialog_MessageBox.CreateConfirmation(
                        text: "M4_HaveNotDraggedColonist".Translate(___curPawn.LabelCap),
                        confirmedAct: () => {
                    returnvalue = true;
                    runMe.Invoke(__instance, new object[] { });
                }
                        )
                    );
            }
            else
            {
                returnvalue = true;
            }
            tmpList.Clear();
            return(returnvalue);
        }
Esempio n. 4
0
 public Page_VerifyStartAutoRoll(Page_ConfigureStartingPawns callingPage)
 {
     this.callingPage = callingPage;
     this.FillFlavorText();
     this.timer = new Timer(delegate(object e) {
         this.ChangeFlavorText();
     }, null, 0, this.flavorTextChange);
 }
Esempio n. 5
0
        private void StartGame(int tile)
        {
            var init = Current.Game.InitData;

            if (WorldEditor.LoadedTemplate.PawnSelectMode == PawnSelectMode.Standart)
            {
                foreach (var scenPart in Find.Scenario.AllParts)
                {
                    ScenPart_ConfigPage_ConfigureStartingPawns part = scenPart as ScenPart_ConfigPage_ConfigureStartingPawns;
                    if (part != null)
                    {
                        init.startingAndOptionalPawns = new List <Pawn>(part.pawnChoiceCount);
                        init.startingPawnCount        = part.pawnCount;
                        for (int i = 0; i < init.startingPawnCount; i++)
                        {
                            Pawn p = PawnGenerator.GeneratePawn(PawnKindDefOf.Colonist, init.playerFaction);
                            init.startingAndOptionalPawns.Add(p);
                        }

                        break;
                    }
                }
            }

            init.startingTile = tile;
            Find.World.renderer.wantedMode = WorldRenderMode.None;

            if (WorldEditor.LoadedTemplate.PawnSelectMode == PawnSelectMode.None)
            {
                Action preLoadLevelAction = delegate
                {
                    Find.GameInitData.PrepForMapGen();
                    Find.GameInitData.startedFromEntry = true;
                    Find.Scenario.PreMapGenerate();
                };
                LongEventHandler.QueueLongEvent(preLoadLevelAction, "Play", "GeneratingMap", doAsynchronously: true, null);

                return;
            }

            //if (WorldEdit.EdbLoaded)
            //    EdbConfigurator();

            var page = new Page_ConfigureStartingPawns();

            page.nextAct = nextAct = delegate
            {
                Action preLoadLevelAction = delegate
                {
                    Find.GameInitData.PrepForMapGen();
                    Find.GameInitData.startedFromEntry = true;
                    Find.Scenario.PreMapGenerate();
                };
                LongEventHandler.QueueLongEvent(preLoadLevelAction, "Play", "GeneratingMap", doAsynchronously: true, null);
            };
            Find.WindowStack.Add(page);
        }
        /// <summary>
        /// Перед запуском удалить всех колонистов игрока
        /// </summary>
        /// <param name="pawnsCount"></param>
        /// <param name="result"></param>
        public static void ShowDialog(int pawnsCount, Action <List <Pawn> > result)
        {
            List <Pawn> oldPawns = null;
            //запоминаем текущее
            var gameIsNull = Current.Game == null || Current.Game.InitData == null;

            if (gameIsNull)
            {
                GameUtils.ShortSetupForQuickTestPlay();
            }
            else
            {
                oldPawns = Current.Game.InitData.startingAndOptionalPawns.ToList();
            }

            //тяп-ляп и новые пешки
            Current.Game.InitData.startingAndOptionalPawns.Clear();
            for (int i = 0; i < pawnsCount; i++)
            {
                Current.Game.InitData.startingAndOptionalPawns.Add(PawnGenerateRandom());
            }
            //if (MainHelper.DebugMode) File.WriteAllText(Loger.PathLog + @"SrvTest.txt", DevelopTest.TextObj(Current.Game.InitData.startingPawns, true), Encoding.UTF8);
            for (int i = 0; i < pawnsCount; i++)
            {
                StartingPawnUtility.RandomizeInPlace(Current.Game.InitData.startingAndOptionalPawns[i]);
            }

            //запускаем форму редактирования
            var form = new Page_ConfigureStartingPawns();

            form.nextAct = () =>
            {
                var pawns = Current.Game.InitData.startingAndOptionalPawns.ToList();

                //восстанавливаем значеня
                if (gameIsNull)
                {
                    Current.Game = null;
                }
                else
                {
                    Current.Game.InitData.startingAndOptionalPawns.Clear();
                    for (int i = 0; i < oldPawns.Count; i++)
                    {
                        Current.Game.InitData.startingAndOptionalPawns.Add(oldPawns[i]);
                    }
                }

                result(pawns);
            };
            Find.WindowStack.Add(form);
        }
        public static void Postfix(Rect rect, Page_ConfigureStartingPawns __instance)
        {
            PrepareModerately.Instance.originalPage = __instance;
            Vector2 buttonDimensions = new Vector2(150, 38);             // Equivalent to the dimensions of the Prepare Carefully button.

            if (Widgets.ButtonText(new Rect((rect.x + rect.width) / 2 - buttonDimensions.x / 2, rect.y - 45, buttonDimensions.x, buttonDimensions.y), "Prepare Moderately"))
            {
                try {
                    Find.WindowStack.Add(PrepareModerately.Instance.page);
                    __instance.Close();
                } catch (Exception e) {
                    Log.Warning("Failed to make window for Prepare Moderately (unexpected exception).\n" + e.StackTrace);
                }
            }
        }
Esempio n. 8
0
        public static bool ConfigureStartingPawnsDoNextPrefix(Page_ConfigureStartingPawns __instance, Pawn ___curPawn)
        {
            MethodInfo runMe = AccessTools.Method(typeof(Page_ConfigureStartingPawns), "DoNext");

            List <Pawn> tmpList = new List <Pawn>(Find.GameInitData.startingPawnCount);

            tmpList.AddRange(Find.GameInitData.startingAndOptionalPawns.Take(Find.GameInitData.startingPawnCount));
            if (!tmpList.Contains(___curPawn))
            {
                Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation($"Currently viewed colonist is not selected for landing. Are you sure you wish to embark without {___curPawn.LabelCap}?",
                                                                          () => { returnvalue = true; runMe.Invoke(__instance, new object[] { }); }));
            }
            else
            {
                returnvalue = true;
            }
            tmpList.Clear();
            return(returnvalue);
        }
 public Page_VerifyStartFailed(Page_ConfigureStartingPawns callingPage = null)
 {
     this.layer                 = WindowLayer.Dialog;
     this.doCloseX              = false;
     this.doCloseButton         = true;
     this.closeOnClickedOutside = false;
     this.resizeable            = false;
     this.draggable             = false;
     this.originalPage          = callingPage;
     if (VerifyStart.Instance.CheckColonists())
     {
         this.soundAppear = SoundDefOf.MessageBenefit;
         this.areWeHappy  = true;
     }
     else
     {
         this.soundAppear = SoundDefOf.MessageSeriousAlert;
         this.areWeHappy  = false;
     }
 }
        //   public static void StartPath_Postfix(Pawn_PathFollower __instance)
        //   {
        //       Pawn pawn = (Pawn)AccessTools.Field(typeof(Pawn_PathFollower), "pawn").GetValue(__instance);
        //       if (pawn.GetCompAnim(out CompBodyAnimator animator))
        //       {
        //           animator.IsMoving = true;
        //       }
        //   }
        //
        //   public static void PatherArrived_Postfix(Pawn_PathFollower __instance)
        //   {
        //       Pawn pawn = (Pawn)AccessTools.Field(typeof(Pawn_PathFollower), "pawn").GetValue(__instance);
        //       if (pawn.GetCompAnim(out CompBodyAnimator animator))
        //       {
        //           animator.IsMoving = false;
        //       }
        //   }

        public static void AddFaceEditButton(Page_ConfigureStartingPawns __instance, Rect rect)
        {
            FieldInfo PawnFieldInfo =
                typeof(Page_ConfigureStartingPawns).GetField("curPawn", BindingFlags.NonPublic | BindingFlags.Instance);

            Pawn pawn = (Pawn)PawnFieldInfo?.GetValue(__instance);

            if (!pawn.GetCompFace(out CompFace compFace))
            {
                return;
            }

            // Shitty Transpiler, doin' it on my own
            Rect rect2 = new Rect(rect.x + 500f, rect.y, 25f, 25f);

            if (rect2.Contains(Event.current.mousePosition))
            {
                GUI.color = Color.cyan;

                // GUI.color = new Color(0.97647f, 0.97647f, 0.97647f);
            }
            else
            {
                GUI.color = new Color(0.623529f, 0.623529f, 0.623529f);
            }

            GUI.DrawTexture(rect2, ContentFinder <Texture2D> .Get("Buttons/ButtonFace", true));
            GUI.color = Color.white;
            string tip = "FacialStuffEditor.EditFace".Translate();

            TooltipHandler.TipRegion(rect2, tip);

            // ReSharper disable once InvertIf
            if (Widgets.ButtonInvisible(rect2, false))
            {
                SoundDefOf.Tick_Low.PlayOneShotOnCamera(null);
                OpenStylingWindow(pawn);
            }
        }
Esempio n. 11
0
            static void Postfix(Page_ConfigureStartingPawns __instance, ref Rect rect)
            {
                Vector2 BottomButSize = new Vector2(150f, 38f);
                float   num           = rect.height + 45f;
                Rect    rect4         = new Rect(rect.x + rect.width / 2f - BottomButSize.x / 2f, num, BottomButSize.x, BottomButSize.y);

                if (Widgets.ButtonText(rect4, "EdB.PC.Page.Button.PrepareCarefully".Translate(), true, false, true))
                {
                    try {
                        ReflectionCache.Instance.Initialize();

                        PrepareCarefully prepareCarefully = PrepareCarefully.Instance;
                        if (prepareCarefully == null)
                        {
                            Log.Error("Could not open Prepare Carefully screen, because we failed to get the Prepare Carefully singleton.");
                            return;
                        }
                        prepareCarefully.Initialize();
                        prepareCarefully.OriginalPage = __instance;
                        Page_PrepareCarefully page = new Page_PrepareCarefully();

                        State state = prepareCarefully.State;
                        if (state == null)
                        {
                            Log.Error("Could not open Prepare Carefully screen, because the Prepare Carefully state was null.");
                            return;
                        }
                        state.Page = page;
                        Find.WindowStack.Add(page);
                    }
                    catch (Exception e) {
                        Find.WindowStack.Add(new DialogInitializationError(e));
                        SoundDefOf.ClickReject.PlayOneShot(null);
                        throw new InitializationException("Prepare Carefully failed to initialize", e);
                    }
                }
            }