예제 #1
0
 private static void CheckPluginComponent()
 {
     if (_pluginComponent == null)
     {
         _pluginComponent = UnityEngine.Object.FindObjectOfType <PluginComponent>();
     }
 }
예제 #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override async void LoadContent()
        {
            base.LoadContent();

            IO      = new IOComponent(this);
            Plugins = new PluginComponent(this);
            Network = new NetworkManager(this);

            await IO.Init();

            await IO.LoadConfig();

            await Network.Init();

            Content       = new ContentManager();
            TextureLoader = new TextureLoader(Graphics.GraphicsDevice);
            Content.LoadTextures(Path.Combine(IO.Directories["Content"], "Textures"), this);

            if (IO.Config.Client.Resolution.X == 0 && IO.Config.Client.Resolution.Y == 0)
            {
                Graphics.PreferredBackBufferWidth  = (int)(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width * .9);
                Graphics.PreferredBackBufferHeight =
                    (int)(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height * .8);
                Graphics.ApplyChanges();
                base.Window.Position =
                    new Point(
                        (GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width - Graphics.PreferredBackBufferWidth) /
                        2,
                        (GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height - Graphics.PreferredBackBufferHeight) /
                        2);
            }
            else
            {
                Graphics.PreferredBackBufferWidth  = IO.Config.Client.Resolution.X;
                Graphics.PreferredBackBufferHeight = IO.Config.Client.Resolution.Y;
                Graphics.ApplyChanges();
            }

            // Initialize MonoForce after loading skins.
            UI.Initialize();
            SpriteBatch = UI.Renderer.SpriteBatch; // Set the spritebatch to the Neoforce managed one


            // Create the main window for all content to be added to.
            Window = new MainWindow(UI, this);
            Window.Init();
            UI.Add(Window);
            Window.SendToBack();

            // Unlike the server, the clientside plugins must be loaded last.
            await Plugins.Init();

            // Now that all the textures have been loaded, set the block textures
            foreach (var block in BlockType.Blocks.Where(x => x.IsRenderable))
            {
                var str = "blocks." + (block.Category != null ? block.Category + "." : string.Empty) + block.Name;
                block.Texture = Content[str];
            }
        }
예제 #3
0
 private static void Bootstrapper_Destroyed()
 {
     // wait for plugins to finish loading
     pluginAsyncLoadTask.Wait();
     log.Debug("Plugins loaded");
     log.Debug(string.Join(", ", PluginLoader.PluginsMetadata));
     PluginComponent.Create();
 }
예제 #4
0
        private static void Bootstrapper_Destroyed()
        {
            // wait for plugins to finish loading
            pluginAsyncLoadTask?.Wait();
            permissionFixTask?.Wait();

            Default.Debug("Plugins loaded");
            Default.Debug(string.Join(", ", PluginLoader.PluginsMetadata.StrJP()));
            _ = PluginComponent.Create();
        }
예제 #5
0
        private static void Bootstrapper_Destroyed()
        {
            // wait for plugins to finish loading
            pluginAsyncLoadTask.Wait();
            permissionFixTask.Wait();

            BeatSaber.EnsureRuntimeGameVersion();

            log.Debug("Plugins loaded");
            log.Debug(string.Join(", ", PluginLoader.PluginsMetadata.StrJP()));
            PluginComponent.Create();
        }
예제 #6
0
        private static void Bootstrapper_Destroyed()
        {
            // wait for plugins to finish loading
            pluginAsyncLoadTask.Wait();
            permissionFixTask.Wait();

            log.Debug("Plugins loaded");
            log.Debug(string.Join(", ", PluginLoader.PluginsMetadata.StrJP()));
            PluginComponent.Create();

#if DEBUG
            Config.Stores.GeneratedStoreImpl.DebugSaveAssembly("GeneratedAssembly.dll");
#endif
        }
예제 #7
0
        public PluginViewModel(
            IPluginDataAccessLayer dataAccessLayer,
            IEventPublisher publisher,
            INavigationService navigationService,
            ComponentViewModelFactory componentViewModelFactory)
        {
            _dataAccessLayer           = dataAccessLayer;
            _publisher                 = publisher;
            _componentViewModelFactory = componentViewModelFactory;
            _component                 = _dataAccessLayer.CreateComponent();
            _navigationService         = navigationService;
            _elements = new ObservableCollection <PluginElementViewModel>(_component.Elements.Select(CreatePluginElementViewModel));
            _effects  = new ObservableCollection <PluginEffectViewModel>(_component.Effects.Select(CreatePluginEffectViewModel));

            AddCommand = new ActionCommand(async() => await AddEffectAsync(), () => true);
        }
예제 #8
0
        /// <summary>
        /// Used for plugin event
        /// </summary>
        public void Plugin_Event(object sender, EventArgs e, PluginComponent component)
        {
            /**
             * Toolstrip Section
             */
            if (component == PluginComponent.ToolStripButton)
            {
                ToolStripButton toolstripbtn = sender as ToolStripButton;

                if (toolstripbtn != null)
                {
                    //....Dev Plugin...toolstrip code.
                    string dkey = toolstripbtn.Text.ToString();
                    Plugin_Common(dkey, component);
                }
                //End ToolStrip Section
            }
            else if (component == PluginComponent.ToolStripMenuItem)
            {
                ToolStripMenuItem toolstripbtn = sender as ToolStripMenuItem;

                if (toolstripbtn != null)
                {
                    //....Dev Plugin...toolstrip code.
                    string dkey = toolstripbtn.Text.ToString();
                    Plugin_Common(dkey, component);
                }
                //End ToolStrip Section
            }
            else if (component == PluginComponent.TopToolStripMenu)
            {
                ToolStripMenuItem toolstripbtn = sender as ToolStripMenuItem;

                if (toolstripbtn != null)
                {
                    //....Dev Plugin...toolstrip code.
                    string dkey = toolstripbtn.Name.ToString();
                    Plugin_Common(dkey, component);
                }
                //End ToolStrip Section
            }
        }
예제 #9
0
        /// <summary>
        /// Constructor: 
        /// </summary>
        /// <param name="host">Plugin owning this data</param>
        /// <param name="guid">Guid of the node owning this data</param>
        public ControlPanelData(PluginComponent host, string guid)
            : base(host, guid)
        {
            InitDataAtViewTime = false;
            HardwareState = HARDWARE_STATE.DETACHED;
            settings = new Settings();
            commLog = new ArrayList();
            deviceInfo = new DEVICE_INFO();

            // query remote device info.
            DeviceDatbaseItem item = Host.DeviceDatabase.FindByGuid(Host.DeviceConnection.Guid);
            RemotePlatform = item.Platform;
            RemoteDescription = item.Description;
            RemoteVersion = string.Format("{0}.{1:00}", item.OsMajor, item.OsMinor);
            RemoteCPU = item.CPU;
            
            // restore settings from file.
            settingsPath = host.SettingsPath;
            settings.Deserialize(settingsPath);            
        }
예제 #10
0
 public PluginMediator()
     : base(NAME)
 {
     ViewComponent = new PluginComponent();
     View.PluginSelectedHandler += new PluginComponent.PluginSelected(PluginSelected);
 }
예제 #11
0
        /// <summary>
        /// Plugin Common Code
        /// </summary>
        public void Plugin_Common(string dkey, PluginComponent component)
        {
            if (PluginUtility._StandardIOPlugins.ContainsKey(dkey))
            {
                //get GetRichTextBox() value
                string editorValue = GetRichTextBox().Text;

                StandardIO dplugin = PluginUtility._StandardIOPlugins[dkey];
                //dplugin.Start();

                dynamic devType = dplugin.GetType();
                dynamic dev     = Activator.CreateInstance(devType);

                dynamic property = devType.GetProperty("GetEditorText");
                if (property != null)
                {
                    property.SetValue(dev, editorValue);
                }


                dynamic eventProperty = devType.GetProperty("GetEditorText");
                if (eventProperty != null)
                {
                    dynamic eventval = eventProperty.GetValue(dev);
                }


                //setting file extension
                dynamic extension = devType.GetProperty("FileExtension");
                if (extension != null)
                {
                    extension.SetValue(dev, FileExtension);
                }

                //dynamic ext = extension.GetValue(dev);
                //setting file address
                if (String.IsNullOrEmpty(FileAddress))
                {
                }
                else
                {
                    try
                    {
                        string  getileurl = FileAddress.ToString();
                        dynamic fileurl   = devType.GetProperty("FileAddress");

                        if (fileurl != null)
                        {
                            fileurl.SetValue(dev, getileurl);
                        }
                        //dynamic Getfileurl = fileurl.GetValue(dev);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }


                if (component == PluginComponent.TopToolStripMenu)
                {
                    // invoke custom method
                    dynamic actionProperty = devType.GetProperty("command");
                    if (actionProperty != null)
                    {
                        Dictionary <string, Action <string> > actionVal = actionProperty.GetValue(dev);
                        foreach (var action in actionVal)
                        {
                            action.Value.DynamicInvoke("");
                        }
                    }
                }
                else
                {
                    dynamic methodStart = devType.GetMethod("Start");
                    methodStart.Invoke(dev, new object[] { });
                }

                //MessageBox.Show(eventval);
            }
        }
예제 #12
0
        internal async Task Start()
        {
            Logger.Server = this;
            Events        = new EventManager();
            Players       = new List <Player>();
            Levels        = new List <Level>();

            // Setup server
            Console.BackgroundColor = ConsoleColor.Black;
            Console.Clear();
            start = DateTime.Now;
            input = string.Empty;
            clear = new string(' ', Console.WindowWidth);
            var stopwatch = Stopwatch.StartNew();

            Logger.WriteLine($"{Constants.Strings.ServerTitle}");
            Logger.WriteLine($"Server is starting now, on {DateTime.Now.ToString("U", new CultureInfo("en-US"))}");

            // Initialize Properties
            Commands = CommandParser.CreateNew().UsePrefix(string.Empty).OnError(OnParseError);
            RegisterCommands();

            // Initialize Components
            IO       = new IOComponent(this);
            Plugins  = new PluginComponent(this);
            Database = new DatabaseComponent(this);
            Net      = new NetworkComponent(this);

            await IO.Init();

            await Plugins.Init();

            await Database.Init();

            await Net.Init();

            // Create save timer
            saveTimer          = new Timer(IO.Config.Server.AutoSaveTime * 1000 * 60);
            saveTimer.Elapsed += async(sender, args) => await SaveAll();

            saveTimer.Start();

            stopwatch.Stop();
            Logger.WriteBreak();
            Logger.WriteLine("Ready. ({0}s) Type /help for commands.", Math.Round(stopwatch.Elapsed.TotalSeconds, 2));
            Logger.WriteBreak();

            WriteHeader();

            while (true) // Parse commands now that messaging has been handed off to another thread
            {
                input = string.Empty;
                WriteCommandCursor();

                // Read input and parse commands
                while (true)
                {
                    var key = Console.ReadKey(true);
                    if (key.Key == ConsoleKey.Backspace)
                    {
                        if (input.Length - 1 >= 0)
                        {
                            input = input.Substring(0, input.Length - 1);
                            Console.CursorLeft = 3 + input.Length - 1;
                            Console.Write(' ');
                            Console.CursorLeft = 3 + input.Length - 1;
                        }
                        continue;
                    }
                    if (key.Key == ConsoleKey.Enter)
                    {
                        Console.WriteLine("");
                        break;
                    }
                    input += key.KeyChar;
                    Console.Write(key.KeyChar);
                }

                Commands.Parse(input.Trim());

                WriteHeader();
            }
            // ReSharper disable once FunctionNeverReturns
        }
예제 #13
0
/*
 *      [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
 *      [return: MarshalAs(UnmanagedType.Bool)]
 *      static extern bool SetDllDirectory(string lpPathName);
 */

        private static void Bootstrapper_Destroyed()
        {
            PluginComponent.Create();
        }