예제 #1
0
        private static void DownloadMGDB(object o, EventArgs e)
        {
            if (Directory.Exists(MGDatabasePath))
            {
                var result = WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "MGDB already exists!", "Update MGDB?");
                if (result != DialogResult.Yes)
                {
                    return;
                }
                DeleteDirectory(MGDatabasePath); // Adding events will be handled by the next conditional
            }
            if (Directory.Exists(MGDatabasePath))
            {
                return;
            }

            var prompt = WinFormsUtil.Prompt(MessageBoxButtons.YesNo,
                                             "Download entire database?",
                                             "Download the entire database, which includes past generation events?",
                                             "Selecting No will download only the public release of the database.");

            var entire = prompt == DialogResult.Yes;

            EventsGallery.DownloadMGDBFromGitHub(MGDatabasePath, entire);
            WinFormsUtil.Alert("Download Finished");
            EncounterEvent.RefreshMGDB(MGDatabasePath);
        }
예제 #2
0
        public static void RunLivingDexTests()
        {
            EncounterEvent.RefreshMGDB(Path.Combine(Directory.GetCurrentDirectory(), "mgdb"));
            RibbonStrings.ResetDictionary(GameInfo.Strings.ribbons);
            var  dir = Directory.GetCurrentDirectory();
            bool legalizer_settings = Legalizer.EnableEasterEggs;
            bool ribbon_settings    = APILegality.SetAllLegalRibbons;
            int  set_timeout        = APILegality.Timeout;
            bool inc_forms          = ModLogic.IncludeForms;
            bool set_shiny          = ModLogic.SetShiny;

            Legalizer.EnableEasterEggs     = false;
            APILegality.SetAllLegalRibbons = false;
            APILegality.Timeout            = 99999;
            var result_f_f = TestLivingDex(false, false, out bool p1);
            var result_f_t = TestLivingDex(false, true, out bool p2);
            var result_t_f = TestLivingDex(true, false, out bool p3);
            var result_t_t = TestLivingDex(true, true, out bool p4);
            var passed     = p1 && p2 && p3 && p4;

            Legalizer.EnableEasterEggs     = legalizer_settings;
            APILegality.SetAllLegalRibbons = ribbon_settings;
            APILegality.Timeout            = set_timeout;
            ModLogic.IncludeForms          = inc_forms;
            ModLogic.SetShiny = set_shiny;
            Directory.CreateDirectory(Path.Combine(dir, "logs"));

            var res = Status(result_f_f, false, false) + Environment.NewLine +
                      Status(result_t_f, true, false) + Environment.NewLine +
                      Status(result_f_t, false, true) + Environment.NewLine +
                      Status(result_t_t, true, true);

            File.WriteAllText(Path.Combine(dir, "logs", "output_livingdex.txt"), res);
            passed.Should().BeTrue($"Living Dex Successfully Genned (Output: \n\n{res}\n\n)");
        }
예제 #3
0
 static GeneratorTests()
 {
     if (!EncounterEvent.Initialized)
     {
         EncounterEvent.RefreshMGDB();
     }
 }
예제 #4
0
 static EncounterLearn()
 {
     if (!EncounterEvent.Initialized)
     {
         EncounterEvent.RefreshMGDB();
     }
 }
예제 #5
0
 static ShowdownSetTests()
 {
     if (!EncounterEvent.Initialized)
     {
         EncounterEvent.RefreshMGDB();
     }
 }
예제 #6
0
        private void LoadDatabase()
        {
            var db = EncounterEvent.GetAllEvents();

            // when all sprites in new size are available, remove this filter
            db = SAV is SAV8SWSH?db.Where(z => ((PersonalInfoSWSH)PersonalTable.SWSH.GetFormeEntry(z.Species, z.Form)).IsPresentInGame) : db.Where(z => !(z is WC8));

            RawDB = new List <MysteryGift>(db);
            foreach (var mg in RawDB)
            {
                mg.GiftUsed = false;
            }

            try
            {
                while (!IsHandleCreated)
                {
                }
                BeginInvoke(new MethodInvoker(delegate
                {
                    SetResults(RawDB);
                    PopulateComboBoxes();
                }));
            }
#pragma warning disable CA1031 // Do not catch general exception types
            catch { /* Window Closed? */ }
#pragma warning restore CA1031 // Do not catch general exception types
        }
예제 #7
0
 private static void InitializeAutoLegality(LegalitySettings cfg)
 {
     Task.Run(InitializeCoreStrings);
     Task.Run(() => EncounterEvent.RefreshMGDB());
     InitializeTrainerDatabase(cfg);
     InitializeSettings(cfg);
 }
예제 #8
0
 static LegalityTest()
 {
     if (!EncounterEvent.Initialized)
     {
         EncounterEvent.RefreshMGDB();
     }
 }
    private async Task InitializeAsync(CancellationToken cancellationToken)
    {
        await Task.WhenAll(
            Task.Run(() => EncounterEvent.RefreshMGDB("./mgdb"), cancellationToken),
            Task.Run(InitializeTrainerDatabase, cancellationToken));

        Initialized = true;
    }
예제 #10
0
 private static void InitializePKHeXEnvironment()
 {
     if (!EncounterEvent.Initialized)
     {
         EncounterEvent.RefreshMGDB();
     }
     RibbonStrings.ResetDictionary(GameInfo.Strings.ribbons);
 }
        private static void InitializeAutoLegality(PokeTradeHubConfig cfg)
        {
            Task.Run(InitializeCoreStrings);
            Task.Run(() => EncounterEvent.RefreshMGDB());
            InitializeTrainerDatabase(cfg);
            InitializeSettings(cfg);

            // Legalizer.AllowBruteForce = false;
        }
 private static void InitializeAutoLegality(LegalitySettings cfg)
 {
     InitializeCoreStrings();
     if (!EncounterEvent.Initialized)
     {
         EncounterEvent.RefreshMGDB(cfg.MGDBPath);
     }
     InitializeTrainerDatabase(cfg);
     InitializeSettings(cfg);
 }
예제 #13
0
        public void SetActiveEncounter(EncounterEvent pEncounter)
        {
            // Do any necessary cleanup
            if (pEncounter == null)
            {
                EndActiveEncounter();
            }

            activeEncounter = Instantiate(pEncounter);
        }
예제 #14
0
        static LegalityTest()
        {
            if (EncounterEvent.Initialized)
            {
                return;
            }

            RibbonStrings.ResetDictionary(GameInfo.Strings.ribbons);
            EncounterEvent.RefreshMGDB();
        }
예제 #15
0
 private static void InitializeAutoLegality(LegalitySettings cfg)
 {
     InitializeCoreStrings();
     if (!EncounterEvent.Initialized)
     {
         EncounterEvent.RefreshMGDB();
     }
     InitializeTrainerDatabase(cfg);
     InitializeSettings(cfg);
     // Legalizer.AllowBruteForce = false;
 }
예제 #16
0
        //[Theory]
        //[InlineData(B2, true, true)]
        //[InlineData(B, true, true)]
        //[InlineData(Pt, true, true)]
#pragma warning disable xUnit1013 // Only for internal debugging
        public static void VerifyManually(GameVersion s, bool includeforms, bool shiny)
#pragma warning restore xUnit1013 // Only for internal debugging
        {
            EncounterEvent.RefreshMGDB(Path.Combine(Directory.GetCurrentDirectory(), "mgdb"));
            RibbonStrings.ResetDictionary(GameInfo.Strings.ribbons);
            APILegality.Timeout = 99999;
            var passed = true;
            var res    = s.SingleSaveTest(includeforms, shiny, ref passed);

            passed.Should().BeTrue();
        }
예제 #17
0
        public Notification(TaskType pType, EncounterEvent pEvent, string pLabel, int pDayLimit = 0, MercenaryData pMercenary = null, HexTile pTile = null)
        {
            mercenary = pMercenary;
            tile      = pTile;
            type      = pType;
            myEvent   = pEvent;

            dayLimit = pDayLimit;

            label = pLabel;
        }
예제 #18
0
        public void InitializeNewEncounter(EncounterEvent e, MercenaryData m)
        {
            // Swap to the Encounter ui page
            AppUI.Instance.SwitchPage(5);

            // Set up the encounter UI
            SetActiveEncounter(e);
            SetActiveMercenary(m);

            currentEncounterStep = 0;
            LoadEncounterStep(currentEncounterStep);
        }
예제 #19
0
 public static void InitializePKHeXEnvironment()
 {
     if (Initialized)
     {
         return;
     }
     if (!EncounterEvent.Initialized)
     {
         EncounterEvent.RefreshMGDB();
     }
     RibbonStrings.ResetDictionary(GameInfo.Strings.ribbons);
     Initialized = true;
 }
예제 #20
0
 private void LoadDatabase()
 {
     RawDB = new List <MysteryGift>(EncounterEvent.GetAllEvents());
     foreach (var mg in RawDB)
     {
         mg.GiftUsed = false;
     }
     BeginInvoke(new MethodInvoker(delegate
     {
         SetResults(RawDB);
         PopulateComboBoxes();
     }));
 }
예제 #21
0
        public Startup(IConfiguration configuration)
        {
            // Initalize everything needed
            Helpers.MoveType.MT = File.ReadAllLines("./Moves.csv").Skip(1).Select(m => Helpers.MoveType.ReadCsv(m)).ToList();
            Helpers.Sprite.loadJSON();
            EncounterEvent.RefreshMGDB(string.Empty);
            RibbonStrings.ResetDictionary(GameInfo.Strings.ribbons);

            /*LegalityAnalysis.ChangeLocalizationStrings.
             * LegalityAnalysis.MoveStrings = GameInfo.Strings.movelist;
             * LegalityAnalysis.SpeciesStrings = GameInfo.Strings.specieslist;*/

            Configuration = configuration;
        }
예제 #22
0
        public Tuple <GameDirector, Canvas, CollisionManager> makeGame(GraphicsDevice graphicsDevice, Controller controller)
        {
            xmlParser        = new XMLParser("test.xml");
            director         = new GameDirector();
            canvas           = new Canvas(new SpriteBatch(graphicsDevice));
            collisionManager = new CollisionManager();
            try
            {
                graphicsLoader = GraphicsLoader.makeGraphicsLoader(graphicsDevice);
            }
            catch (ArgumentException)
            {
                graphicsLoader = GraphicsLoader.getGraphicsLoader();
            }
            EnemyFactory enemyFactory = new EnemyFactory();

            xmlParser.Parse();
            List <Encounter> encounters = xmlParser.getEncounterList();
            int lastTime = 0;

            foreach (var encounter in encounters)
            {
                EncounterEvent encounterEvent = new EncounterEvent(collisionManager, canvas, encounter, director);
                lastTime = encounter.timeInMS;
                director.addEvent(encounter.timeInMS, encounterEvent);
            }


            SCREEN_WIDTH  = graphicsDevice.Viewport.Bounds.Width;
            SCREEN_HEIGHT = graphicsDevice.Viewport.Bounds.Height;


            int     offset    = 50;
            Vector2 topMiddle = new Vector2(SCREEN_WIDTH / 2 - offset, -100);
            Vector2 topLeft   = new Vector2(SCREEN_WIDTH / 4 - offset, -100);
            Vector2 topRight  = new Vector2(3 * SCREEN_WIDTH / 4 - offset, -100);

            // sin.healthbar = new HealthBar(sin.Location, new Vector2(8, 0), 85, 90, sin.Health);

            Player player = MakePlayer(controller);

            player.invulnerable = hasCheatMode;
            director.addEvent(0, new PlayerEnter(canvas, player));
            player.DeathEvent += canvas.OnPlayerDeath;

            //director.addEvent(0, new PlayerEnter(canvas, player));

            return(new Tuple <GameDirector, Canvas, CollisionManager>(director, canvas, collisionManager));
        }
예제 #23
0
        public void EndActiveEncounter()
        {
            // Clear the old options
            foreach (RectTransform r in ActionUIParentRect.GetComponentsInChildren <RectTransform>())
            {
                if (r != ActionUIParentRect)
                {
                    Destroy(r.gameObject);
                }
            }

            AppUI.Instance.SwitchPage(0);

            activeEncounter = null;
        }
예제 #24
0
        public Main()
        {
            Form splash = null; // popup a splash screen in another thread

            new Task(() => (splash = new SplashScreen()).ShowDialog()).Start();
            new Task(() => EncounterEvent.RefreshMGDB(MGDatabasePath)).Start();
            string[] args = Environment.GetCommandLineArgs();
            FormLoadInitialSettings(args, out bool showChangelog, out bool BAKprompt);

            InitializeComponent();
            C_SAV.SetEditEnvironment(new SaveDataEditor <PictureBox>(null, PKME_Tabs));
            FormLoadAddEvents();
            #if DEBUG // translation updater -- all controls are added at this point -- call translate now
            if (DevUtil.IsUpdatingTranslations)
            {
                WinFormsUtil.TranslateInterface(this, CurrentLanguage); // Translate the UI to language.
            }
            #endif
            FormInitializeSecond();

            FormLoadCustomBackupPaths();
            FormLoadInitialFiles(args);
            FormLoadCheckForUpdates();
            FormLoadPlugins();

            BringToFront();
            WindowState = FormWindowState.Minimized;
            Show();
            WindowState = FormWindowState.Normal;
            splash.Invoke((MethodInvoker)(() => splash.Close())); // splash closes
            if (HaX)
            {
                PKMConverter.AllowIncompatibleConversion = true;
                WinFormsUtil.Alert(MsgProgramIllegalModeActive, MsgProgramIllegalModeBehave);
            }
            else if (showChangelog)
            {
                ShowAboutDialog(1);
            }

            if (BAKprompt && !Directory.Exists(BackupPath))
            {
                PromptBackup();
            }
        }
예제 #25
0
        private void LoadDatabase()
        {
            var db = EncounterEvent.GetAllEvents();

            // when all sprites in new size are available, remove this filter
            db = SAV is SAV8SWSH?db.Where(z => ((PersonalInfoSWSH)PersonalTable.SWSH.GetFormeEntry(z.Species, z.Form)).IsPresentInGame) : db.Where(z => !(z is WC8));

            RawDB = new List <MysteryGift>(db);
            foreach (var mg in RawDB)
            {
                mg.GiftUsed = false;
            }
            BeginInvoke(new MethodInvoker(delegate
            {
                SetResults(RawDB);
                PopulateComboBoxes();
            }));
        }
예제 #26
0
        private void LoadDatabase()
        {
            var db = EncounterEvent.GetAllEvents();

            // when PK7->PK8 conversion is possible (and sprites in new size are available, remove this filter)
            db = SAV is SAV8SWSH?db.OfType <WC8>() : db.Where(z => !(z is WC8));

            RawDB = new List <MysteryGift>(db);
            foreach (var mg in RawDB)
            {
                mg.GiftUsed = false;
            }
            BeginInvoke(new MethodInvoker(delegate
            {
                SetResults(RawDB);
                PopulateComboBoxes();
            }));
        }
예제 #27
0
    public static EncounterEvent Serdes(EncounterEvent e, ISerializer s)
    {
        if (s == null)
        {
            throw new ArgumentNullException(nameof(s));
        }
        e ??= new EncounterEvent();
        int zeroes = s.UInt8(null, 0);

        zeroes += s.UInt8(null, 0);
        zeroes += s.UInt8(null, 0);
        zeroes += s.UInt8(null, 0);
        zeroes += s.UInt8(null, 0);
        e.Unk6  = s.UInt16(nameof(Unk6), e.Unk6);
        e.Unk8  = s.UInt16(nameof(Unk8), e.Unk8);
        s.Assert(zeroes == 0, "EncounterEvent: Expected fields 1-5 to be 0");
        return(e);
    }
예제 #28
0
 public static void InitializePKHeXEnvironment()
 {
     lock (_lock)
     {
         if (Initialized)
         {
             return;
         }
         if (!EncounterEvent.Initialized)
         {
             EncounterEvent.RefreshMGDB();
         }
         RibbonStrings.ResetDictionary(GameInfo.Strings.ribbons);
         Legalizer.EnableEasterEggs     = false;
         APILegality.SetAllLegalRibbons = false;
         APILegality.Timeout            = 99999;
         Initialized = true;
     }
 }
예제 #29
0
        private static void Main()
        {
#if !DEBUG
            // Add the event handler for handling UI thread exceptions to the event.
            Application.ThreadException += UIThreadException;

            // Set the unhandled exception mode to force all Windows Forms errors to go through our handler.
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            // Add the event handler for handling non-UI thread exceptions to the event.
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
#endif
            // Run the application
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            var splash = new SplashScreen();
            new Task(() => splash.ShowDialog()).Start();
            new Task(() => EncounterEvent.RefreshMGDB(WinForms.Main.MGDatabasePath)).Start();
            var main = new Main();
            splash.Invoke(() => splash.ForceClose());
            Application.Run(main);
        }
예제 #30
0
        /// <summary>
        /// Given a task type, mercenary, and tile, generate a notification that can be parsed and sent to the UI.
        /// </summary>
        /// <returns>Notification object containing an event.</returns>
        public Notification GenerateNotification(TaskType pType, MercenaryData pMercenary, HexTile pTile, EncounterEvent pEndEvent = null)
        {
            // Get a random event object from the event manifest for the given type. It should contain information as to
            // whether the event is clear-required.

            int lDayLimit = 0;

            foreach (HexTile t in pMercenary.CurrentPath)
            {
                lDayLimit += HexFunctions.Instance.GetRoughTerrainFactor(t.Type);
            }

            if (pType.Equals(TaskType.DUNGEONEER))
            {
                return(new Notification(pType, EncounterController.Instance.DungeoneeringEvent, ParseNotificationLabel(pType, pMercenary), lDayLimit, pMercenary, pTile));
            }

            // Return the generated notification.
            return(new Notification(pType, pEndEvent, ParseNotificationLabel(pType, pMercenary), lDayLimit, pMercenary, pTile));
        }