Beispiel #1
0
        static void Main(string[] args)
        {
            UserConfig.Init();
            Library.Init();

            Library.AddGameEntry("Minecraft", new GameEntry())
            .AddConfig(new LaunchConfig()
            {
                Type          = "local",
                LaunchCommand = "C:/"
            });
            Library.SaveChanges();

            Console.WriteLine("Backend Test!");
            Console.WriteLine("Finding dlls..");

            List <Plugin> plugins = new List <Plugin>();
            List <string> dlls    = new List <string>();

            foreach (string d in Directory.GetDirectories(Directory.GetCurrentDirectory() + "/plugins/"))
            {
                dlls.AddRange(Directory.GetFiles(d, "*.dll"));
            }

            foreach (string path in dlls)
            {
                //Console.WriteLine("Loading: " + path);

                try
                {
                    Assembly dll    = Assembly.LoadFrom(path);
                    Plugin   plugin = (Plugin)dll.CreateInstance("plugin.PluginDLL");

                    if (plugin == null)
                    {
                        //Console.WriteLine("Plugin failed to load: Could not find entry point.");
                    }
                    else
                    {
                        Console.WriteLine("Loading: " + path);
                        Task setup = new Task(async() =>
                        {
                            bool loaded = await plugin.Load();
                            await plugin.Sync();
                        });
                        setup.Start();
                        plugins.Add(plugin);

                        Console.WriteLine("Registered: " + plugin.getName());
                    }
                }
                catch (BadImageFormatException)
                {
                    Console.WriteLine("Skipping invalid dll..");
                }
            }

            Console.WriteLine("Press any key.");
            Console.ReadKey();
        }
Beispiel #2
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            Splash splash = new Splash();

            splash.ShowInTaskbar = false;
            splash.Show();

            UserConfig.Init();
            Library.Init();
            Metadata.Init();

            PluginManager.LoadPlugins();

            MainWindow wnd = new MainWindow();

            wnd.IsEnabled = false;
            wnd.Show();

            // hide splash when we've loaded everything
            wnd.ContentRendered += (s, x) => {
                wnd.IsEnabled = true;
                splash.Hide();
            };

            // exit app on window close
            wnd.Closed += (s, x) => {
                Environment.Exit(0);
            };

            // refresh app content when our library changes
            Library.OnSaveChanges += () => wnd.RefreshContent();
        }