Ejemplo n.º 1
0
        private void DockPanel1ActiveDocumentChanged(object sender, EventArgs e)
        {
            // show properties of document if active document changed
            FrmTableEditor tableEditor = this.dockPanel1.ActiveDocument as FrmTableEditor;

            if (tableEditor != null)
            {
                this.Text = $"Freelancer Mod Studio - {tableEditor.File}";
                if (this.systemEditorForm != null &&
                    (!tableEditor.CanDisplay3DViewer() || this.systemEditorForm.IsHidden))
                {
                    this.CloseSystemEditor();
                }
                else
                {
                    this.ShowSystemEditor(tableEditor);
                }

                // update property window after changing active document
                this.propertiesFormForm.ShowData(tableEditor.GetSelectedBlocks(), tableEditor.Data.TemplateIndex);
            }
            else
            {
                this.Text = $"Freelancer Mod Studio";
                this.propertiesFormForm.ClearData();

                if (this.systemEditorForm != null)
                {
                    this.CloseSystemEditor();
                }
            }

            this.SetDocumentMenus(tableEditor);
            this.SetContentMenus(tableEditor);
        }
Ejemplo n.º 2
0
        private void SettingsChanged()
        {
            this.uiCultureChanger.ApplyCulture(new CultureInfo(Helper.Settings.ShortLanguage));
            this.uiCultureChanger.ApplyCultureToForm(this);

            foreach (IDockContent dockContent in this.dockPanel1.Contents)
            {
                FrmTableEditor tableEditor = dockContent as FrmTableEditor;
                if (tableEditor != null)
                {
                    this.uiCultureChanger.ApplyCultureToForm(tableEditor);

                    // refresh settings after language change
                    tableEditor.RefreshSettings();
                }
            }

            this.propertiesFormForm?.RefreshSettings();

            this.systemEditorForm?.RefreshSettings();

            // if (solutionExplorerForm != null)
            // solutionExplorerForm.RefreshSettings();
            this.SetDocumentMenus(this.GetDocument());
        }
Ejemplo n.º 3
0
        private void SystemEditorFileOpen(string path)
        {
            FrmTableEditor tableEditor = this.dockPanel1.ActiveDocument as FrmTableEditor;

            if (tableEditor != null)
            {
                string file = string.Empty;

                try
                {
                    string directory = Path.GetDirectoryName(tableEditor.File);
                    if (directory != null)
                    {
                        file = Path.Combine(directory, path);
                        if (File.Exists(file))
                        {
                            this.OpenFile(file, Helper.Template.Data.SystemFile);
                        }
                        else
                        {
                            throw new FileNotFoundException();
                        }
                    }
                }
                catch (Exception ex)
                {
                    Helper.Exceptions.Show(string.Format(Strings.FileErrorOpen, file), ex);
                }
            }
        }
Ejemplo n.º 4
0
 private void MnuSaveAllClick(object sender, EventArgs e)
 {
     foreach (IDockContent document in this.dockPanel1.Documents)
     {
         FrmTableEditor tableEditor = document as FrmTableEditor;
         tableEditor?.Save();
     }
 }
Ejemplo n.º 5
0
        private void DefaultEditorFormClosed(object sender, FormClosedEventArgs e)
        {
            if (e.CloseReason != CloseReason.UserClosing)
            {
                return;
            }

            FrmTableEditor tableEditor = sender as FrmTableEditor;

            if (tableEditor != null)
            {
                this.AddToRecentFiles(tableEditor.File, tableEditor.Data.TemplateIndex);
            }
        }
Ejemplo n.º 6
0
        public FrmTableEditor(int templateIndex, string file)
        {
            FrmTableEditor.Instance = this;
            this.InitializeComponent();

            this.LoadIcons();
            this.undoManager.DataChanged += this.UndoManagerDataChanged;
            Helper.Settings.LoadTemplates();

            if (file != null)
            {
                FileManager fileManager = new FileManager(file)
                {
                    ReadWriteComments = true,     // always read comments
                };
                EditorIniData iniContent = fileManager.Read(FileEncoding.Automatic, templateIndex);

                this.Data   = new TableData(iniContent);
                this.isBini = fileManager.IsBini;

                this.SetFile(file);
            }
            else
            {
                this.Data = new TableData
                {
                    TemplateIndex = templateIndex
                };

                this.SetFile(string.Empty);
            }

            this.SetTheme();

            SimpleDropSink dropSink = this.objectListView1.DropSink as SimpleDropSink;

            if (dropSink != null)
            {
                dropSink.CanDropBetween = true;
                dropSink.CanDropOnItem  = false;
            }

            this.RefreshSettings();
        }
Ejemplo n.º 7
0
        private void Open3DSystemEditor(FrmTableEditor tableEditor = null)
        {
            if (this.systemEditorForm == null)
            {
                this.InitSystemEditor();
            }

            this.systemEditorForm.Show(this.dockPanel1);

            if (tableEditor is null)
            {
                tableEditor = this.dockPanel1.ActiveDocument as FrmTableEditor;
            }

            if (tableEditor != null)
            {
                this.ShowSystemEditor(tableEditor);
            }
        }
Ejemplo n.º 8
0
        private int FileOpened(string file)
        {
            int i = 0;

            foreach (IDockContent document in this.dockPanel1.Documents)
            {
                FrmTableEditor tableEditor = document as FrmTableEditor;
                if (tableEditor != null)
                {
                    if (tableEditor.File.Equals(file, StringComparison.OrdinalIgnoreCase))
                    {
                        return(i);
                    }
                }

                ++i;
            }

            return(-1);
        }
Ejemplo n.º 9
0
        private FrmTableEditor DisplayFile(string file, int templateIndex)
        {
            this.Text = $"Freelancer Mod Studio - {file}";
            FrmTableEditor tableEditor = new FrmTableEditor(templateIndex, file);

            tableEditor.ShowData();
            tableEditor.TabPageContextMenuStrip = this.contextMenuStrip1;

            tableEditor.DataChanged           += this.DefaultEditorDataChanged;
            tableEditor.SelectionChanged      += this.DefaultEditorSelectionChanged;
            tableEditor.DataVisibilityChanged += this.DefaultEditorDataVisibilityChanged;
            tableEditor.DocumentChanged       += this.DefaultEditorDocumentChanged;
            tableEditor.FormClosed            += this.DefaultEditorFormClosed;
            tableEditor.Show(this.dockPanel1, DockState.Document);

            if (tableEditor.CanDisplay3DViewer() && Helper.Settings.Data.Data.General.AutomaticallyOpen3DEditor)
            {
                this.Open3DSystemEditor(tableEditor);
            }

            return(tableEditor);
        }
Ejemplo n.º 10
0
        private void MnuCloseAllUnchanged_Click(object sender, EventArgs e)
        {
            List <Form> forms = new List <Form>();

            foreach (var badForm in this.MdiChildren)
            {
                FrmTableEditor form = (FrmTableEditor)badForm;
                if (form.undoManager.IsModified())
                {
                    continue;
                }

                forms.Add(form);
            }

            foreach (var form in forms)
            {
                form.Close();
                if (!form.IsDisposed)
                {
                    return;
                }
            }
        }
Ejemplo n.º 11
0
        private void ShowSystemEditor(FrmTableEditor tableEditor)
        {
            if (this.systemEditorForm != null)
            {
                this.systemEditorForm.ShowViewer(tableEditor.ViewerType);

                // set data path before showing the models
                this.systemEditorForm.DataPath = tableEditor.DataPath;

                switch (tableEditor.ViewerType)
                {
                case ViewerType.System:
                    // set model mode as it was reset if the editor was closed
                    this.systemEditorForm.IsModelMode = this.mnuShowModels.Checked || Helper.Settings.Data.Data.General.AutomaticallyDisplay3DModels;
                    this.systemEditorForm.ShowData(tableEditor.Data);
                    break;

                case ViewerType.Universe:
                    this.systemEditorForm.IsModelMode = false;
                    this.systemEditorForm.ShowData(tableEditor.Data);
                    this.systemEditorForm.ShowUniverseConnections(
                        tableEditor.File,
                        tableEditor.Data.Blocks,
                        tableEditor.Archetype);
                    break;

                case ViewerType.SolarArchetype:
                case ViewerType.ModelPreview:
                    this.systemEditorForm.IsModelMode = true;
                    break;
                }

                // set manipulation mode as it was reset if the editor was closed
                if (this.mnuManipulationTranslate.Checked)
                {
                    this.systemEditorForm.ManipulationMode = ManipulationMode.Translate;
                }
                else if (this.mnuManipulationRotate.Checked)
                {
                    this.systemEditorForm.ManipulationMode = ManipulationMode.Rotate;
                }
                else if (this.mnuManipulationScale.Checked)
                {
                    this.systemEditorForm.ManipulationMode = ManipulationMode.Scale;
                }
                else
                {
                    this.systemEditorForm.ManipulationMode = ManipulationMode.None;
                }

                // select initially
                List <TableBlock> blocks = tableEditor.GetSelectedBlocks();
                if (blocks != null)
                {
                    foreach (TableBlock block in blocks)
                    {
                        this.systemEditorForm.Select(block);
                    }
                }
            }
        }
Ejemplo n.º 12
0
        private void PropertiesOptionsChanged(PropertyBlock[] blocks)
        {
            FrmTableEditor tableEditor = this.dockPanel1.ActiveDocument as FrmTableEditor;

            tableEditor?.ChangeBlocks(blocks);
        }
Ejemplo n.º 13
0
        private void SystemEditorDataManipulated(List <TableBlock> newBlock, List <TableBlock> oldBlock)
        {
            FrmTableEditor tableEditor = this.dockPanel1.ActiveDocument as FrmTableEditor;

            tableEditor?.ChangeBlocks(newBlock, oldBlock);
        }
Ejemplo n.º 14
0
        private void SystemEditorSelectionChanged(TableBlock block, bool toggle)
        {
            FrmTableEditor tableEditor = this.dockPanel1.ActiveDocument as FrmTableEditor;

            tableEditor?.Select(block, toggle);
        }