Beispiel #1
0
        public FormObjectBrowser(IEditorPlugin editorPlugin)
        {
            InitializeComponent();

            this.editorPlugin = editorPlugin;
            ini = editorPlugin.GetConfig();

            CreateSettings();
            ini.Load();

            Width  = ini.GetInt("ObjectBrowser", "width");
            Height = ini.GetInt("ObjectBrowser", "height");
            chkKeepOnTop.Checked = ini.GetBool("ObjectBrowser", "keepOnTop");

            tvDirectories.BackColor = Colors.PrimaryHighlight();
            lbFiles.BackColor       = Colors.PrimaryHighlight();

            tvDirectories.ForeColor = Colors.Font();
            lbFiles.ForeColor       = Colors.Font();

            tvDirectories.BorderStyle = BorderStyle.None;
            lbFiles.BorderStyle       = BorderStyle.None;

            Task loadRepo = LoadRepo();

            GameDragDropEventHandlers.OnDragDrop  += OnDragDrop;
            GameDragDropEventHandlers.OnDragEnter += OnDragEnter;
            GameDragDropEventHandlers.OnDragOver  += OnDragOver;

            lbFiles.QueryContinueDrag += lbFiles_QueryContinueDrag;

            editorPlugin.GetHotkeyManager().Add(new Hotkey("ToggleObjectBrowserKeepOnTop", "Toggle Object Browser KeepOnTop", "Shift, Control + T", ToggleKeepOnTop, false));
        }
        public WorldSnapshotImpl(ISnapshotPanel snapshotPanel, IEditorPlugin editorPlugin, HotkeyManager hotkeyManager)
        {
            this.snapshotPanel = snapshotPanel;
            this.editorPlugin  = editorPlugin;
            this.hotkeyManager = hotkeyManager;

            GameCallbacks.AddInstallCallback(OnInstallCallback);
            GameCallbacks.AddSetupSceneCall(OnSetupSceneCallback);
            GameCallbacks.AddCleanupSceneCall(OnCleanupCallback);
            ObjectCallbacks.AddOnTargetCallback(OnTarget);

            ImGuiCallbacks.AddOnEnabledCallback(OnGizmoEnabled);
            ImGuiCallbacks.AddOnDisabledCallback(OnGizmoDisabled);
            ImGuiCallbacks.AddOnPositionChangedCallback(OnPositionChanged);
            ImGuiCallbacks.AddOnRotationChangedCallback(OnRotationChanged);

            hotkeyManager.Add(new Hotkey("ToggleSnapshotNodeEditingMode", "Toggle Snapshot Node Editing Mode", "Oemtilde", ToggleNodeEditing, true));
            hotkeyManager.Add(new Hotkey("SaveSnapshot", "Save Snapshot", "Control + S", Save, true));
            hotkeyManager.Add(new Hotkey("CopySnapshotNode", "Copy Snapshot Node", "Control + C", CopyNode, true, true, true));
            hotkeyManager.Add(new Hotkey("PasteSnapshotNode", "Paste Snapshot Node", "Control + V", PasteNode, true, true, true));
            hotkeyManager.Add(new Hotkey("DuplicateSnapshotNode", "Duplicate Snapshot Node", "Control + D", DuplicateNode, true, true, true));
            hotkeyManager.Add(new Hotkey("DeleteSnapshotNode", "Delete Snapshot Node", "Delete", RemoveNode, true, true, true));

            hotkeyManager.Add(new Hotkey("SetGizmoTranslateOperationMode", "Set Gizmo Operation Mode to Translate", "Control + Q", SetOperationModeToTranslateHotkey, true, false, true));
            hotkeyManager.Add(new Hotkey("SetGizmoRotationOperationMode", "Set Gizmo Operation Mode to Rotation", "Control + E", SetOperationModeToRotationHotkey, true, false, true));
            hotkeyManager.Add(new Hotkey("ToggleGizmoSnap", "Toggle Gizmo Snap", "Control + B", ToggleGizmoSnapHotkey, true, false, true));
        }
        private void LoadAssemblies()
        {
            String        _pluginDirectory = Path.Combine(Application.StartupPath, "Plugins");
            DirectoryInfo _directory       = new DirectoryInfo(_pluginDirectory);

            if (!_directory.Exists)
            {
                return;
            }

            FileInfo[] _files = _directory.GetFiles("*.dll");

            foreach (FileInfo file in _files)
            {
                Assembly _assembly = Assembly.LoadFrom(file.FullName);
                Type[]   _types    = _assembly.GetTypes();
                foreach (Type type in _types)
                {
                    if (!Utils.HasInterface(type, typeof(IEditorPlugin)))
                    {
                        continue;
                    }

                    IEditorPlugin   _plugin    = Activator.CreateInstance(type) as IEditorPlugin;
                    PluginContainer _pluginref = new PluginContainer(_plugin, _plugin.Id.ToString());
                    _Plugins.Add(_pluginref);
                }
            }
        }
Beispiel #4
0
        private void Apply(IEditorPlugin plugin)
        {
            Range _line = txt.GetLine(txt.Selection.Start.iLine);

            SelInfo _selInfo = new SelInfo()
            {
                Text         = txt.Text,
                SelectedText = txt.SelectedText,
                CurrentLine  = _line.Text
            };

            try
            {
                if (!plugin.OmitResult)
                {
                    plugin.Apply(_selInfo);
                    txt.SelectedText = _selInfo.SelectedText;
                }
                else
                {
                    plugin.Apply(_selInfo);
                }
            }
            catch (Exception)
            {
            }
        }
Beispiel #5
0
        public void AddPlugin(IEditorPlugin editorPlugin)
        {
            _imageList.Images.Add(editorPlugin.Name, editorPlugin.ToolboxImage.Picture);

            ListViewItem listViewItem = _listView.Items.Add(editorPlugin.Name, editorPlugin.Name);

            listViewItem.Tag = editorPlugin.GetType();
        }
        public void AddPlugin(IEditorPlugin editorPlugin)
        {
            _imageList.Images.Add( editorPlugin.Name, editorPlugin.ToolboxImage.Picture ) ;

            ListViewItem listViewItem = _listView.Items.Add( editorPlugin.Name, editorPlugin.Name ) ;

            listViewItem.Tag = editorPlugin.GetType();
        }
Beispiel #7
0
 public PluginContainer(IEditorPlugin plugin, string id)
 {
     _plugin            = plugin;
     _pluginHelper      = new PluginHelper(_plugin);
     _id                = id;
     Category           = plugin.Category;
     CustomShortcutKeys = _plugin.ShortcutKeys;
     IsExtension        = plugin.IsExtension;
 }
        public ExampleEditorSubPanel(IEditorPlugin editorPlugin) : base(editorPlugin.Information.Name)
        {
            InitializeComponent();
            this.editorPlugin = editorPlugin;

            ObjectCallbacks.AddOnTargetCallback(OnTarget);
            ImGuiCallbacks.AddOnPositionChangedCallback(OnPositionChanged);
            ImGuiCallbacks.AddOnRotationChangedCallback(OnRotationChanged);

            Task updateNodePositionLabel = UpdateNodePositionLabel();
        }
Beispiel #9
0
        public ScenePanel(IEditorPlugin editorPlugin, HotkeyManager hotkeyManager, UtINI ini) : base("Scene", false)
        {
            InitializeComponent();

            groundScene = new GroundSceneImpl(this, hotkeyManager);

            this.ini = ini;

            CreateSettings();
            ini.Load();

            txtAvatarObjectFilename.Text = ini.GetString("Scene", "defaultAvatarFilename");
        }
        /// <summary>
        /// Registers a plugin, calling <see cref="IEditorPlugin.RegisterPlugin(IServiceRegistry)"/>.
        /// </summary>
        /// <param name="plugin"></param>
        public void Register(IEditorPlugin plugin)
        {
            if (activePlugins.ContainsKey(plugin.GetType()))
            {
                throw new InvalidOperationException($"Plugin of type '{plugin.GetType()}' is already registered.");
            }

            Logger.Debug($"Registering plugin '{plugin.GetType().FullName}'...");

            plugin.RegisterPlugin(Services);
            activePlugins.Add(plugin.GetType(), plugin);

            Logger.Info($"Registered plugin '{plugin.GetType().FullName}'.");
        }
Beispiel #11
0
        void buildTab( IEditorPlugin editorPlugin )
        {
            var tabPage = new TabPage
                {
                    Text = editorPlugin.Name
                } ;

            Control control = editorPlugin.ControlForAboutBox ;

            control.Dock=DockStyle.Fill;

            tabPage.Controls.Add( control );

            uiTabs.TabPages.Add( tabPage );
        }
Beispiel #12
0
        void buildTab(IEditorPlugin editorPlugin)
        {
            var tabPage = new TabPage
            {
                Text = editorPlugin.Name
            };

            Control control = editorPlugin.ControlForAboutBox;

            control.Dock = DockStyle.Fill;

            tabPage.Controls.Add(control);

            uiTabs.TabPages.Add(tabPage);
        }
Beispiel #13
0
        public void AddUndoCommand(IEditorPlugin editorPlugin)
        {
            editorPlugin.AddUndoCommand += (sender, args) =>
            {
                RedoCommands.Clear();
                if (UndoCommands.Count > 0 && UndoCommands.Peek().Merge(args.UndoCommand))
                {
                    return;
                }

                UndoCommands.Push(args.UndoCommand);

                onUpdateCommandsCallback();
            };
        }
Beispiel #14
0
        public SnapshotPanel(IEditorPlugin editorPlugin, HotkeyManager hotkeyManager, UtINI ini) : base("Snapshot")
        {
            InitializeComponent();

            worldSnapshot = new WorldSnapshotImpl(this, editorPlugin, hotkeyManager);

            this.ini = ini;

            CreateSettings();
            ini.Load();

            txtNewNodeFilename.Text          = ini.GetString("Snapshot", "defaultNodeObjectFilename");
            chkEnableNodeEditing.Checked     = ini.GetBool("Snapshot", "autoEnableSnapshotEditing");
            chkAllowTargetEverything.Checked = ini.GetBool("Snapshot", "autoAllowTargetEverything");
        }
        private void _menuItem_LeftClick(object sender, EventArgs e)
        {
            ToolStripItem _menuItem = sender as ToolStripItem;
            string        key       = _menuItem.Tag as string;
            IEditorPlugin _plugin   = _Plugins.Get(key).GetPlugin();

            PluginHelper _pluginSettingsHelper = new PluginHelper(_plugin);

            _pluginSettingsHelper.LoadSettings();

            if (_plugin.IsExtension)
            {
                bool _result = _plugin.Configure();
                if (!_result)
                {
                    return;
                }

                _pluginSettingsHelper.SaveSettings();
            }

            _pluginSettingsHelper.LoadSettings();

            SelInfo _selInfo = new SelInfo()
            {
                Text         = editor.Editor.Text,
                SelectedText = editor.Editor.SelectedText,
                CurrentLine  = editor.Editor.CurrentLine()
            };

            try
            {
                if (!_plugin.OmitResult)
                {
                    _plugin.Apply(_selInfo);
                    editor.Editor.SelectedText = _selInfo.SelectedText;
                }
                else
                {
                    _plugin.Apply(_selInfo);
                }
            }
            catch (Exception)
            {
            }

            _pluginSettingsHelper.SaveSettings();
        }
Beispiel #16
0
        private void PanelGame_KeyDown(object sender, KeyEventArgs e)
        {
            foreach (IPlugin plugin in pluginLoader.Plugins)
            {
                IEditorPlugin editorPlugin = (IEditorPlugin)plugin;
                if (editorPlugin != null)
                {
                    HotkeyManager hotkeyManager = editorPlugin.GetHotkeyManager();

                    if (hotkeyManager != null && hotkeyManager.OnGameFocusOnly)
                    {
                        hotkeyManager.ProcessInput(e.Modifiers, e.KeyCode);
                    }
                }
            }
        }
Beispiel #17
0
        public Form Create(IEditorPlugin editorPlugin, List <Form> parentChildren)
        {
            // Check if the form is already open
            foreach (Form form in parentChildren)
            {
                if (form.GetType() == typeof(FormObjectBrowser))
                {
                    form.Activate();
                    return(null);
                }
            }

            // If not, create a new one
            FormObjectBrowser formObjectBrowser = new FormObjectBrowser(editorPlugin);

            formObjectBrowser.Show();
            parentChildren.Add(formObjectBrowser);
            return(formObjectBrowser);
        }
        public void Unregister(IEditorPlugin plugin)
        {
            if (!activePlugins.ContainsKey(plugin.GetType()))
            {
                throw new InvalidOperationException($"Plugin of type '{plugin.GetType()}' has not been registered.");
            }

            Logger.Debug($"Unregistering plugin '{plugin.GetType().FullName}'...");

            var rplugin = activePlugins[plugin.GetType()];

            if (plugin != rplugin)
            {
                Logger.Warning($"A different instance of plugin '{plugin.GetType()}' has been registered and unregistered. Make sure the plugin has no state.");
            }

            plugin.UnregisterPlugin(Services);
            activePlugins.Remove(plugin.GetType());

            Logger.Info($"Unregistered plugin '{plugin.GetType().FullName}'.");
        }
        private void _menuItem_RightClick(object sender, EventArgs e)
        {
            ToolStripItem _menuItem = sender as ToolStripItem;
            string        key       = _menuItem.Tag as string;
            IEditorPlugin _plugin   = _Plugins.Get(key).GetPlugin();

            if (_plugin.IsExtension)
            {
                return;
            }

            PluginHelper _pluginSettingsHelper = new PluginHelper(_plugin);

            _pluginSettingsHelper.LoadSettings();

            bool _result = _plugin.Configure();

            if (!_result)
            {
                return;
            }

            _pluginSettingsHelper.SaveSettings();
        }
Beispiel #20
0
        public FormMain(PluginLoader pluginLoader)
        {
            InitializeComponent();

            Width  = UtinniCore.Utinni.utinni.GetConfig().GetInt("Editor", "width");
            Height = UtinniCore.Utinni.utinni.GetConfig().GetInt("Editor", "height");

            undoRedoManager = new UndoRedoManager(OnUpdateCommandsCallback, OnUndo, OnRedo);

            foreach (IPlugin plugin in pluginLoader.Plugins)
            {
                IEditorPlugin editorPlugin = (IEditorPlugin)plugin;
                if (editorPlugin != null)
                {
                    editorPlugins.Add(editorPlugin);
                }
            }

            game = new PanelGame(pluginLoader);
            pnlGame.Controls.Add(game);

            pnlPlugins.BackColor = Colors.Primary();
            pnlPlugins.ForeColor = Colors.Font();

            tbddWindows = new UtinniTitlebarDropDownButton("Open...");

            ToolStripDropDownItem tsddItem = new ToolStripMenuItem("Log");

            tsddItem.Click += (sender, args) =>
            {
                OpenLogWindow();
            };

            tbddWindows.Menu.Items.Add(tsddItem);

            CreatePluginControls();

            tbbtnUndo = new UndoRedoTitlebarButton(this, "Undo", Resources.undo, undoRedoManager.Undo);
            tbbtnRedo = new UndoRedoTitlebarButton(this, "Redo", Resources.redo, undoRedoManager.Redo);

            tbbtnUndo.Click += TbbtnUndo_Click;
            tbbtnRedo.Click += TbbtnRedo_Click;

            LeftTitleBarButtons.Add(tbddWindows);
            LeftTitleBarButtons.Add(tbbtnUndo);
            LeftTitleBarButtons.Add(tbbtnRedo);

            formHotkeyManager.Add(new Hotkey("Undo", "Undo", "Control + Z", undoRedoManager.Undo, true));
            formHotkeyManager.Add(new Hotkey("Redo", "Redo", "Control + Y", undoRedoManager.Redo, true));
            formHotkeyManager.Add(new Hotkey("ToggleUI", "Toggle UI", "Shift + Oemtilde", ToggleFullWindowGame, true));

            formHotkeyManager.CreateSettings();
            formHotkeyManager.Load();

            InitializeEditorCallbacks(); // Initialize callbacks that are purely editor related


            UtinniTitlebarButton tbbtnHotkeyEditor = new UtinniTitlebarButton("Hotkey Editor");

            tbbtnHotkeyEditor.Click += (sender, args) =>
            {
                FormHotkeyEditor form = new FormHotkeyEditor(formHotkeyManager, editorPlugins);
                form.Show();
            };

            RightTitleBarButtons.Add(tbbtnHotkeyEditor);

            if (UtinniCore.Utinni.utinni.GetConfig().GetBool("Editor", "autoOpenLogWindow"))
            {
                OpenLogWindow();
                this.BringToFront();
                this.Focus();
            }
        }
Beispiel #21
0
 public void AddPlugin(IEditorPlugin editorPlugin)
 {
 }
Beispiel #22
0
 public PluginHelper(IEditorPlugin plugin)
 {
     _plugin = plugin;
 }
Beispiel #23
0
        public ItemEditor GetNewEditor(Type pluginType)
        {
            IEditorPlugin plugin = FindPluginInstanceForType(pluginType);

            return((ItemEditor)Activator.CreateInstance(plugin.EditorType));
        }