<commit_before>﻿using Scripts.Model.Interfaces;
using Scripts.Model.Pages;
using Scripts.Model.Processes;
using Scripts.Model.Characters;
using Scripts.Presenter;
using UnityEngine;
using Scripts.View.Effects;
using Scripts.View.ObjectPool;
using Scripts.Game.Defined.Characters;
using System;
using Scripts.Game.Defined.Spells;
using Scripts.Game.Defined.Serialized.Spells;
using System.Collections.Generic;
using Scripts.Game.Undefined.Characters;
using Scripts.Model.TextBoxes;
using Scripts.Model.Acts;
using Scripts.Model.Stats;
using Scripts.Game.Defined.Serialized.Statistics;
using Scripts.Game.Serialized;
using Scripts.Game.Serialization;
using Scripts.Model.SaveLoad;

namespace Scripts.Game.Pages {

    public class Menus : PageGroup {
        public const int DEBUGGING = 1;
        public const int CREDITS = 2;
        public const int NEW_GAME = 3;
        public const int INTRO_SCENE = 4;

        private string name;

        public Menus() : base(new Page("Main Menu")) {
            Register(DEBUGGING, new Page("Debug"));
            Register(CREDITS, new Page("Credits"));
            Register(NEW_GAME, new Page("New Game"));
            Register(INTRO_SCENE, new Page("Unknown"));
            StartPage();
            DebugPage();
            CreditsPage();
            SetupIntro();
            NewGameNameInputPage();
        }

        private string Name {
            get {
                return name;
            }
        }

        private void StartPage() {
            Page start = Get(ROOT_INDEX);
            start.OnEnter = () => {
                start.Actions = new IButtonable[] {
                Get(NEW_GAME),
                Get(CREDITS),
                new LoadPages(start),
                Get(DEBUGGING)
                };
            };
        }

        private void SetupIntro() {
            Page page = Get(INTRO_SCENE);
            page.OnEnter = () => {
                ActUtil.SetupScene(page,
                        IntroVoice("{0}...", Name),
                        IntroVoice("Fallen hero of humanity..."),
                        IntroVoice("Your time on this world is not yet over."),
                        IntroVoice("Arise once more and bring us to egress..."),
                        new TextAct("You feel like you are being dragged off somewhere..."),
                        new ActionAct(() => {
                            Party party = new Party();
                            Flags flags = new Flags();
                            party.AddMember(new Hero(name));
                            Camp camp = new Camp(party, flags);
                            camp.Root.OnEnter += () => {
                                ActUtil.SetupScene(camp.Root,
                                    new TextAct("You wake up in the middle of a nicely set up campsite with a tent, fire, and backpack."),
                                    new TextAct("As you scan your surroundings for who brought you here, a <color=magenta>moving figure</color> far away catches your eye."),
                                    new TextAct("You stand up to get a better view of them, but they have already disappeared."),
                                    new TextAct("Near where you initially spotted them, you see the ruins of some town.")
                                    );
                                camp.Root.OnEnter = () => { };
                            };
                            camp.Root.Invoke();
                        })
                    );
            };
        }

        private TextAct IntroVoice(string message, object arg = null) {
            return new TextAct(new AvatarBox(Side.RIGHT, Util.GetSprite("holy-symbol"), Color.yellow, string.Format(message, arg)));
        }

        private void DebugPage() {
            Page debug = Get(DEBUGGING);
            Grid submenu = new Grid("Go to submenu");
            Grid mainDebug = new Grid("Return to main menu");<commit_msg>Fixed a bug where Camp from menus was removing its OnEnters.<commit_after>﻿using Scripts.Model.Interfaces;
using Scripts.Model.Pages;
using Scripts.Model.Processes;
using Scripts.Model.Characters;
using Scripts.Presenter;
using UnityEngine;
using Scripts.View.Effects;
using Scripts.View.ObjectPool;
using Scripts.Game.Defined.Characters;
using System;
using Scripts.Game.Defined.Spells;
using Scripts.Game.Defined.Serialized.Spells;
using System.Collections.Generic;
using Scripts.Game.Undefined.Characters;
using Scripts.Model.TextBoxes;
using Scripts.Model.Acts;
using Scripts.Model.Stats;
using Scripts.Game.Defined.Serialized.Statistics;
using Scripts.Game.Serialized;
using Scripts.Game.Serialization;
using Scripts.Model.SaveLoad;

namespace Scripts.Game.Pages {

    public class Menus : PageGroup {
        public const int DEBUGGING = 1;
        public const int CREDITS = 2;
        public const int NEW_GAME = 3;
        public const int INTRO_SCENE = 4;

        private string name;

        public Menus() : base(new Page("Main Menu")) {
            Register(DEBUGGING, new Page("Debug"));
            Register(CREDITS, new Page("Credits"));
            Register(NEW_GAME, new Page("New Game"));
            Register(INTRO_SCENE, new Page("Unknown"));
            StartPage();
            DebugPage();
            CreditsPage();
            SetupIntro();
            NewGameNameInputPage();
        }

        private string Name {
            get {
                return name;
            }
        }

        private void StartPage() {
            Page start = Get(ROOT_INDEX);
            start.OnEnter = () => {
                start.Actions = new IButtonable[] {
                Get(NEW_GAME),
                Get(CREDITS),
                new LoadPages(start),
                Get(DEBUGGING)
                };
            };
        }

        private void SetupIntro() {
            Page page = Get(INTRO_SCENE);
            page.OnEnter = () => {
                ActUtil.SetupScene(page,
                        IntroVoice("{0}...", Name),
                        IntroVoice("Fallen hero of humanity..."),
                        IntroVoice("Your time on this world is not yet over."),
                        IntroVoice("Arise once more and bring us to egress..."),
                        new TextAct("You feel like you are being dragged off somewhere..."),
                        new ActionAct(() => {
                            Party party = new Party();
                            Flags flags = new Flags();
                            party.AddMember(new Hero(name));
                            Camp camp = new Camp(party, flags);
                            bool wasCalled = false;
                            camp.Root.OnEnter += () => {
                                if (!wasCalled) {
                                    wasCalled = true;
                                    ActUtil.SetupScene(camp.Root,
                                        new TextAct("You wake up in the middle of a nicely set up campsite with a tent, fire, and backpack."),
                                        new TextAct("As you scan your surroundings for who brought you here, a <color=magenta>moving figure</color> far away catches your eye."),
                                        new TextAct("You stand up to get a better view of them, but they have already disappeared."),
                                        new TextAct("Near where you initially spotted them, you see the ruins of some town.")
                                        );
                                }
                            };
                            camp.Root.Invoke();
                        })
                    );
            };
        }

        private TextAct IntroVoice(string message, object arg = null) {
            return new TextAct(new AvatarBox(Side.RIGHT, Util.GetSprite("holy-symbol"), Color.yellow, string.Format(message, arg)));
        }

        private void DebugPage() {
            Page debug = Get(DEBUGGING);
            Grid submenu = new Grid("Go to submenu");
            Grid mainDebug = new Grid("Return to main menu");
{'fraction_non_alphanumeric': 0.09394982784062961, 'fraction_numerical': 0.0012297097884899164, 'mean_word_length': 1.4879167941266442, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 17, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6483495', 'n_tokens_mistral': 2043, 'n_tokens_neox': 1965, 'n_words': 573}