Пример #1
0
 protected void ConfirmExit()
 {
     Find.WindowStack.Add(new Dialog_Confirm("EdB.PC.Page.ConfirmExit".Translate(), delegate {
         PrepareCarefully.Instance.Clear();
         PrepareCarefully.ClearOriginalScenario();
         this.Close(true);
     }, true, null, true));
 }
 // Removes the customized scenario (with PrepareCarefully-specific scenario parts) and replaces
 // it with a vanilla-friendly version that was prepared earlier.  This is a workaround to avoid
 // creating a dependency between a saved game and the mod.  See Controller.PrepareGame() for
 // more details.
 public static void InitNewGamePostfix()
 {
     if (PrepareCarefully.OriginalScenario != null)
     {
         Current.Game.Scenario = PrepareCarefully.OriginalScenario;
         PrepareCarefully.ClearOriginalScenario();
     }
 }
 public override void Generate(Map map)
 {
     if (PrepareCarefully.OriginalScenario != null)
     {
         Current.Game.Scenario = PrepareCarefully.OriginalScenario;
         PrepareCarefully.ClearOriginalScenario();
     }
 }
Пример #4
0
        public override void DoWindowContents(Rect inRect)
        {
            base.DrawPageTitle(inRect);
            Rect mainRect = base.GetMainRect(inRect, 30f, false);

            Widgets.DrawMenuSection(mainRect);

            // This approach to drawing tabs differs a bit from the vanilla approach.  Instead instantiating
            // brand new TabRecord instances every frame, we re-use the same instances and updated their
            // selected field value every frame.
            TabDrawer.DrawTabs(mainRect, tabViews.Select((ITabView t) => {
                t.TabRecord.selected = State.CurrentTab == t;
                return(t.TabRecord);
            }));

            // Determine the size of the tab view and draw the current tab.
            Vector2 SizePageMargins = new Vector2(16, 16);
            Rect    tabViewRect     = new Rect(mainRect.x + SizePageMargins.x, mainRect.y + SizePageMargins.y,
                                               mainRect.width - (SizePageMargins.x * 2), mainRect.height - (SizePageMargins.y * 2));

            State.CurrentTab.Draw(State, tabViewRect);

            // Display any pending messages.
            if (State.Messages.Count() > 0)
            {
                foreach (var message in State.Messages)
                {
                    Messages.Message(message, MessageTypeDefOf.NeutralEvent);
                }
                State.ClearMessages();
            }

            // Display any pending errors.
            if (State.Errors.Count() > 0)
            {
                foreach (var message in State.Errors)
                {
                    Messages.Message(message, MessageTypeDefOf.RejectInput);
                }
                State.ClearErrors();
            }

            // Draw other controls.
            DrawPresetButtons();
            DrawPoints(mainRect);
            DoNextBackButtons(inRect, "Start".Translate(),
                              delegate {
                if (controller.ValidateStartGame())
                {
                    ShowStartConfirmation();
                }
            },
                              delegate {
                Find.WindowStack.Add(new Dialog_Confirm("EdB.PC.Page.ConfirmExit".Translate(), delegate {
                    PrepareCarefully.Instance.Clear();
                    PrepareCarefully.ClearOriginalScenario();
                    this.Close(true);
                }, true, null, true));
            }
                              );
        }
Пример #5
0
 // Clear the original scenario when opening the Configure Starting Pawns page.  This makes
 // sure that the workaround static variable gets cleared if you quit to the main menu from
 // gameplay and then start a new game.
 public static void PreOpenPostfix()
 {
     PrepareCarefully.ClearOriginalScenario();
 }