예제 #1
0
        public void UpdateWindowTitle()
        {
            EditorElement ee = GetCurrentEditorElement();
            string        outString;

            if (ee == null)
            {
                outString = "SPEdit";
                Program.discordClient.SetPresence(new RichPresence()
                {
                    State      = "Idle",
                    Timestamps = Program.discordTime,
                    Assets     = new Assets()
                    {
                        LargeImageKey = "immagine",
                    }
                });
            }
            else
            {
                outString = ee.FullFilePath + " - SPEdit";
            }
            if (ServerIsRunning)
            {
                outString = $"{outString} ({Program.Translations.GetLanguage("ServerRunning")})";
            }
            Title = outString;
        }
예제 #2
0
        private void ParseDistributorTimer_Elapsed(object sender, ElapsedEventArgs args)
        {
            if (currentSMDefUID == 0)
            {
                return;
            }
            EditorElement[] ee = null;
            EditorElement   ce = null;

            Dispatcher?.Invoke(() =>
            {
                ee = GetAllEditorElements();
                ce = GetCurrentEditorElement();
            });
            if (ee == null || ce == null)
            {
                return;
            }                                                     //this can happen!
            foreach (var e in ee)
            {
                if (e.LastSMDefUpdateUID < currentSMDefUID)                 //wants an update of the SMDefintion
                {
                    if (e == ce)
                    {
                        if (ce.ISAC_Open)
                        {
                            continue;
                        }
                    }
                    e.InterruptLoadAutoCompletes(currentSMDef.FunctionStrings, currentSMFunctions, currentACNodes, currentISNodes);
                    e.LastSMDefUpdateUID = currentSMDefUID;
                }
            }
        }
예제 #3
0
        private void EditMenu_Open(object sender, RoutedEventArgs e)
        {
            EditorElement ee   = GetCurrentEditorElement();
            MenuItem      menu = (MenuItem)sender;

            if (ee == null)
            {
                foreach (var item in menu.Items)
                {
                    if (item is MenuItem menuItem)
                    {
                        menuItem.IsEnabled = false;
                    }
                }
            }
            else
            {
                MenuI_Undo.IsEnabled = ee.editor.CanUndo;
                MenuI_Redo.IsEnabled = ee.editor.CanRedo;
                for (int i = 2; i < menu.Items.Count; ++i)
                {
                    if (menu.Items[i] is MenuItem)
                    {
                        ((MenuItem)menu.Items[i]).IsEnabled = true;
                    }
                }
            }
        }
예제 #4
0
        private void DockingManager_ActiveContentChanged(object sender, EventArgs e)
        {
            UpdateWindowTitle();
            EditorElement ee = GetCurrentEditorElement();

            ee?.editor.Focus();
        }
예제 #5
0
        private EditorElement[] GetEditorElementsForFRAction(out int editorIndex)
        {
            int editorStartIndex = 0;

            EditorElement[] editors = null;
            if (FindDestinies.SelectedIndex == 0)
            {
                editors = new EditorElement[] { GetCurrentEditorElement() };
            }
            else
            {
                editors = GetAllEditorElements();
                if (DockingPane.SelectedContent != null)
                {
                    object checkElement = DockingPane.SelectedContent.Content;
                    if (checkElement != null)
                    {
                        if (checkElement is EditorElement)
                        {
                            for (int i = 0; i < editors.Length; ++i)
                            {
                                if (editors[i] == checkElement)
                                {
                                    editorStartIndex = i;
                                }
                            }
                        }
                    }
                }
            }
            editorIndex = editorStartIndex;
            return(editors);
        }
예제 #6
0
        public void ToggleSearchField()
        {
            EditorElement ee = GetCurrentEditorElement();

            if (IsSearchFieldOpen)
            {
                if (ee != null)
                {
                    if (ee.IsKeyboardFocusWithin)
                    {
                        if (ee.editor.SelectionLength > 0)
                        {
                            FindBox.Text = ee.editor.SelectedText;
                        }
                        FindBox.SelectAll();
                        FindBox.Focus();
                        return;
                    }
                }
                IsSearchFieldOpen = false;
                FindReplaceGrid.IsHitTestVisible = false;
                if (Program.OptionsObject.UI_Animations)
                {
                    FadeFindReplaceGridOut.Begin();
                }
                else
                {
                    FindReplaceGrid.Opacity = 0.0;
                }
                if (ee == null)
                {
                    return;
                }
                ee.editor.Focus();
            }
            else
            {
                IsSearchFieldOpen = true;
                FindReplaceGrid.IsHitTestVisible = true;
                if (ee == null)
                {
                    return;
                }
                if (ee.editor.SelectionLength > 0)
                {
                    FindBox.Text = ee.editor.SelectedText;
                }
                FindBox.SelectAll();
                if (Program.OptionsObject.UI_Animations)
                {
                    FadeFindReplaceGridIn.Begin();
                }
                else
                {
                    FindReplaceGrid.Opacity = 1.0;
                }
                FindBox.Focus();
            }
        }
예제 #7
0
        private void Command_Close()
        {
            EditorElement ee = GetCurrentEditorElement();

            if (ee != null)
            {
                ee.Close();
            }
        }
예제 #8
0
        private void Command_Paste()
        {
            EditorElement ee = GetCurrentEditorElement();

            if (ee != null)
            {
                ee.editor.Paste();
            }
        }
예제 #9
0
        private void Command_JumpTo()
        {
            EditorElement ee = GetCurrentEditorElement();

            if (ee != null)
            {
                ee.ToggleJumpGrid();
            }
        }
예제 #10
0
        private void Command_Redo()
        {
            EditorElement ee = GetCurrentEditorElement();

            if (ee?.editor.CanRedo == true)
            {
                ee.editor.Redo();
            }
        }
예제 #11
0
    /// <summary>
    /// Изменяет элемент на новый, в зависимости от того, какой элемент выбран.
    /// </summary>
    public void ChangeElement()
    {
        if (typeElement == 0 && editor.TypeSelectElement.typeGameObject != 0 && !thisLandingPlatform)
        {
            Transform nowPosition = gameObject.transform;

            GameObject instanceNewElement = Instantiate(editor.SelectElement, nowPosition.position + new Vector3(0, 5, 0), Quaternion.identity);

            EditorElement edElement = instanceNewElement.AddComponent <EditorElement>();
            edElement.typeElement = editor.TypeSelectElement.typeGameObject;

            if (elementOn != null)
            {
                instanceNewElement.GetComponent <EditorElement>().nameElement = elementOn.name;
                Destroy(elementOn);
            }

            elementOn = instanceNewElement;



            if (elementOn.GetComponent <EditorElement>().typeElement == 1)
            {
                mirrorPlatform.ItemOnPlatform = new Item
                {
                    TypeItem = (TypesItem)editor.TypeSelectElement.universalType
                };
            }
            else if (elementOn.GetComponent <EditorElement>().typeElement == 2)
            {
                mirrorPlatform.TankOnPlatform = new Tank
                {
                    TypeTank   = (TypesTank)editor.TypeSelectElement.universalType,
                    RotateTank = (int)elementOn.transform.rotation.y
                };
            }
        }

        if (editor.TypeSelectElement.typeGameObject == typeElement)
        {
            Transform nowPosition = gameObject.transform;

            GameObject instNewElement = Instantiate(editor.SelectElement, nowPosition.position, Quaternion.identity);

            EditorElement edElement = instNewElement.AddComponent <EditorElement>();
            edElement.typeElement = typeElement;
            edElement.elementOn   = elementOn;
            edElement.nameElement = nameElement;

            Platform mirrorPlatform = FindObjectOfType <LevelData>().Platforms.Find(platform => platform.NamePlatform == nameElement);
            mirrorPlatform.TypePlatform = (TypesPlatform)editor.TypeSelectElement.universalType;

            Debug.Log(mirrorPlatform.NamePlatform + " " + (TypesPlatform)editor.TypeSelectElement.universalType);

            Destroy(gameObject);
        }
    }
예제 #12
0
        private void Command_SelectAll()
        {
            EditorElement ee = GetCurrentEditorElement();

            if (ee != null)
            {
                ee.editor.SelectAll();
            }
        }
예제 #13
0
        private void Command_ToggleCommentLine()
        {
            EditorElement ee = GetCurrentEditorElement();

            if (ee != null)
            {
                ee.ToggleCommentOnLine();
            }
        }
예제 #14
0
        private void Command_Save()
        {
            EditorElement ee = GetCurrentEditorElement();

            if (ee != null)
            {
                ee.Save(true);
                BlendOverEffect.Begin();
            }
        }
예제 #15
0
        private void SelectOBFile(object sender, RoutedEventArgs e)
        {
            EditorElement ee = GetCurrentEditorElement();

            if (ee != null)
            {
                FileInfo fInfo = new FileInfo(ee.FullFilePath);
                ChangeObjectBrowserToDirectory(fInfo.DirectoryName);
            }
            //ObjectBrowserButtonHolder.SelectedIndex = -1;
        }
예제 #16
0
        private void Command_Redo()
        {
            EditorElement ee = GetCurrentEditorElement();

            if (ee != null)
            {
                if (ee.editor.CanRedo)
                {
                    ee.editor.Redo();
                }
            }
        }
예제 #17
0
        private void Command_FlushFoldingState(bool state)
        {
            EditorElement ee = GetCurrentEditorElement();

            if (ee?.foldingManager != null)
            {
                var foldings = ee.foldingManager.AllFoldings;
                foreach (var folding in foldings)
                {
                    folding.IsFolded = state;
                }
            }
        }
예제 #18
0
 private void ListViewOBItem_SelectFile(object sender, RoutedEventArgs e)
 {
     if (sender is ListViewItem)
     {
         EditorElement ee = GetCurrentEditorElement();
         if (ee != null)
         {
             FileInfo fInfo = new FileInfo(ee.FullFilePath);
             ChangeObjectBrowserToDirectory(fInfo.DirectoryName);
         }
         ((ListViewItem)sender).IsSelected       = false;
         ObjectBrowserButtonHolder.SelectedIndex = -1;
     }
 }
예제 #19
0
        public EditorElement GetCurrentEditorElement()
        {
            EditorElement outElement = null;

            if (DockingPane.SelectedContent?.Content != null)
            {
                var possElement = DockingManager.ActiveContent;
                if (possElement is EditorElement element)
                {
                    outElement = element;
                }
            }
            return(outElement);
        }
예제 #20
0
        /// <summary>
        /// Вызывает окно редактирования атрибутов игрового элемента.
        /// </summary>
        /// <param name="element">Игровой элемент</param>
        public static void CallAttributeEditor(EditorElement element)
        {
            if (element.typeElement == 0)
            {
                GameObject panel = GameObject.FindObjectOfType <EditorManager>().PanelEditAttributesElement;

                panel.SetActive(true);
                GameObject.Find("InputFieldNamePlatform").GetComponent <InputField>().text = element.nameElement;

                Button saveButton = GameObject.Find("ButtonEditorSaveAttributesPlatform").GetComponent <Button>();
                saveButton.onClick.RemoveAllListeners();
                saveButton.onClick.AddListener(delegate { ButtonAttributeSave_Click(element); });
            }
        }
        public void ToggleSearchField()
        {
            EditorElement ee = GetCurrentEditorElement();

            if (IsSearchFieldOpen)
            {
                if (ee != null)
                {
                    if (ee.IsKeyboardFocusWithin)
                    {
                        if (ee.editor.SelectionLength > 0)
                        {
                            FindBox.Text = ee.editor.SelectedText;
                        }
                        FindBox.SelectAll();
                        FindBox.Focus();
                        return;
                    }
                }
                IsSearchFieldOpen = false;
                FindReplaceGrid.IsHitTestVisible = false;
                FindReplaceGrid.Height           = 0;
                if (ee == null)
                {
                    return;
                }
                ee.editor.Focus();
            }
            else
            {
                IsSearchFieldOpen = true;
                FindReplaceGrid.IsHitTestVisible = true;
                if (ee == null)
                {
                    return;
                }
                if (ee.editor.SelectionLength > 0)
                {
                    FindBox.Text = ee.editor.SelectedText;
                }
                FindBox.SelectAll();
                FindReplaceGrid.Height = double.NaN;

                FindBox.Focus();
            }
        }
예제 #22
0
        public void AddEditorElement(string filePath, string name, bool SelectMe)
        {
            LayoutDocument layoutDocument = new LayoutDocument();

            layoutDocument.Title    = name;
            layoutDocument.Closing += layoutDocument_Closing;
            layoutDocument.ToolTip  = filePath;
            EditorElement editor = new EditorElement(filePath);

            editor.Parent          = layoutDocument;
            layoutDocument.Content = editor;
            EditorsReferences.Add(editor);
            DockingPane.Children.Add(layoutDocument);
            if (SelectMe)
            {
                layoutDocument.IsSelected = true;
            }
        }
예제 #23
0
        private void UpdateWindowTitle()
        {
            EditorElement ee = GetCurrentEditorElement();
            string        outString;

            if (ee == null)
            {
                outString = "SPEdit";
            }
            else
            {
                outString = ee.FullFilePath + " - SPEdit";
            }
            if (ServerIsRunning)
            {
                outString = $"{outString} ({Program.Translations.ServerRunning})";
            }
            this.Title = outString;
        }
예제 #24
0
        private void UpdateWindowTitle()
        {
            EditorElement ee = GetCurrentEditorElement();
            string        outString;

            if (ee == null)
            {
                outString = "SPEdit";
            }
            else
            {
                outString = ee.FullFilePath + " - SPEdit";
            }
            if (ServerIsRunning)
            {
                outString = outString + " (Server running)";
            }
            this.Title = outString;
        }
예제 #25
0
        private void UpdateWindowTitle()
        {
            EditorElement ee = GetCurrentEditorElement();
            string        outString;

            if (ee == null)
            {
                outString = "SPEdit";
            }
            else
            {
                outString = ee.FullFilePath + " - SPEdit";
            }
            if (ServerIsRunning)
            {
                outString = $"{outString} ({Properties.Resources.ServerRunning})";
            }
            Title = outString;
        }
예제 #26
0
        private void ParseDistributorTimer_Elapsed(object sender, ElapsedEventArgs args)
        {
            if (currentSMDefUID == 0)
            {
                return;
            }

            EditorElement[] ee = null;
            EditorElement   ce = null;

            Dispatcher?.Invoke(() =>
            {
                ee = GetAllEditorElements();
                ce = GetCurrentEditorElement();
            });
            if (ee == null || ce == null)
            {
                return;
            }

            Debug.Assert(ee != null, nameof(ee) + " != null");
            // ReSharper disable once PossibleNullReferenceException
            foreach (var e in ee)
            {
                if (e.LastSMDefUpdateUID < currentSMDefUID) //wants an update of the SMDefinition
                {
                    if (e == ce)
                    {
                        Debug.Assert(ce != null, nameof(ce) + " != null");
                        // ReSharper disable once PossibleNullReferenceException
                        if (ce.ISAC_Open)
                        {
                            continue;
                        }
                    }

                    e.InterruptLoadAutoCompletes(currentSMDef.FunctionStrings, currentSMFunctions, currentACNodes,
                                                 currentISNodes, currentSMDef.Methodmaps.ToArray(), currentSMDef.Variables.ToArray());
                    e.LastSMDefUpdateUID = currentSMDefUID;
                }
            }
        }
예제 #27
0
        private void AddEditorElement(string filePath, string name, bool SelectMe)
        {
            var layoutDocument = new LayoutDocument {
                Title = name
            };

            layoutDocument.ToolTip = filePath;
            var editor = new EditorElement(filePath)
            {
                Parent = layoutDocument
            };

            layoutDocument.Content = editor;
            EditorsReferences.Add(editor);
            DockingPane.Children.Add(layoutDocument);
            if (SelectMe)
            {
                layoutDocument.IsSelected = true;
            }
        }
예제 #28
0
        private void DockingManager_ActiveContentChanged(object sender, EventArgs e)
        {
            UpdateWindowTitle();
            EditorElement ee = GetCurrentEditorElement();

            if (ee != null)
            {
                ee.editor.Focus();
                Program.discordClient.SetPresence(new RichPresence()
                {
                    Timestamps = Program.discordTime,
                    State      = $"Editing {Path.GetFileName(ee.FullFilePath)}",
                    Assets     = new Assets()
                    {
                        LargeImageKey  = "immagine",
                        LargeImageText = $"Editing {Path.GetFileName(ee.FullFilePath)}",
                    }
                });
            }
        }
예제 #29
0
        public void AddEditorElement(string filePath, string name, bool SelectMe)
        {
            LayoutDocument layoutDocument = new LayoutDocument {
                Title = name
            };

            layoutDocument.Closing += layoutDocument_Closing;
            layoutDocument.ToolTip  = filePath;
            bool          compileChecked = filePath.EndsWith(".sma");
            EditorElement editor         = new EditorElement(filePath, compileChecked, this)
            {
                Parent = layoutDocument
            };

            layoutDocument.Content = editor;
            EditorsReferences.Add(editor);
            DockingPane.Children.Add(layoutDocument);
            if (SelectMe)
            {
                layoutDocument.IsSelected = true;
            }
        }
예제 #30
0
        private void Command_SaveAs()
        {
            EditorElement ee = GetCurrentEditorElement();

            if (ee != null)
            {
                SaveFileDialog sfd = new SaveFileDialog
                {
                    AddExtension    = true,
                    Filter          = @"AMXXPawn Files|*.sma;*.inc;*.cfg;*.json;*.txt;*.ini|All Files (*.*)|*.*",
                    OverwritePrompt = true,
                    Title           = Properties.Resources.SaveFileAs,
                    FileName        = ee.Parent.Title.Trim('*')
                };
                var result = sfd.ShowDialog(this);
                if (result.Value && !string.IsNullOrWhiteSpace(sfd.FileName))
                {
                    ee.FullFilePath = sfd.FileName;
                    ee.Save(true);
                }
            }
        }