2019-08-01 23:47:35 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
2019-08-29 21:45:32 +02:00
|
|
|
|
using Toolbox.Library.Forms;
|
|
|
|
|
using WeifenLuo.WinFormsUI.Docking;
|
|
|
|
|
using WeifenLuo.WinFormsUI.ThemeVS2015;
|
|
|
|
|
using Toolbox.Library.IO;
|
|
|
|
|
using Toolbox.Library;
|
2019-08-30 00:05:44 +02:00
|
|
|
|
using FirstPlugin;
|
2019-09-01 19:02:48 +02:00
|
|
|
|
using LayoutBXLYT.Cafe;
|
2019-08-01 23:47:35 +02:00
|
|
|
|
|
2019-08-29 22:33:23 +02:00
|
|
|
|
namespace LayoutBXLYT
|
2019-08-01 23:47:35 +02:00
|
|
|
|
{
|
2019-08-29 21:45:32 +02:00
|
|
|
|
public partial class LayoutEditor : Form
|
2019-08-01 23:47:35 +02:00
|
|
|
|
{
|
2019-09-13 00:52:47 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Enables or disables legacy opengl support
|
|
|
|
|
/// Modern support is not quite finished yet so keep enabled!
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static bool UseLegacyGL = true;
|
|
|
|
|
|
2019-09-28 23:27:48 +02:00
|
|
|
|
public LayoutViewer GamePreviewWindow;
|
|
|
|
|
|
|
|
|
|
private LayoutCustomPaneMapper CustomMapper;
|
|
|
|
|
|
2019-08-31 00:53:45 +02:00
|
|
|
|
private Dictionary<string, STGenericTexture> Textures;
|
|
|
|
|
|
2019-08-29 23:17:24 +02:00
|
|
|
|
public List<BxlytHeader> LayoutFiles = new List<BxlytHeader>();
|
2019-09-11 00:42:48 +02:00
|
|
|
|
public List<BxlanHeader> AnimationFiles = new List<BxlanHeader>();
|
2019-10-05 19:25:28 +02:00
|
|
|
|
public List<BxlanHeader> SelectedAnimations = new List<BxlanHeader>();
|
2019-08-27 22:38:06 +02:00
|
|
|
|
|
2019-08-29 23:17:24 +02:00
|
|
|
|
private BxlytHeader ActiveLayout;
|
2019-09-11 00:42:48 +02:00
|
|
|
|
private BxlanHeader ActiveAnimation;
|
2019-08-28 03:14:37 +02:00
|
|
|
|
|
2019-08-27 22:38:06 +02:00
|
|
|
|
public enum DockLayout
|
|
|
|
|
{
|
|
|
|
|
Default,
|
|
|
|
|
Animation,
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-29 21:45:32 +02:00
|
|
|
|
public EventHandler ObjectSelected;
|
|
|
|
|
public EventHandler ObjectChanged;
|
|
|
|
|
|
2019-08-01 23:47:35 +02:00
|
|
|
|
public LayoutEditor()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2019-09-28 23:27:48 +02:00
|
|
|
|
CustomMapper = new LayoutCustomPaneMapper();
|
2019-08-29 21:45:32 +02:00
|
|
|
|
|
2019-08-31 00:53:45 +02:00
|
|
|
|
Textures = new Dictionary<string, STGenericTexture>();
|
|
|
|
|
|
2019-08-29 21:45:32 +02:00
|
|
|
|
var theme = new VS2015DarkTheme();
|
|
|
|
|
this.dockPanel1.Theme = theme;
|
|
|
|
|
this.dockPanel1.BackColor = FormThemes.BaseTheme.FormBackColor;
|
|
|
|
|
this.BackColor = FormThemes.BaseTheme.FormBackColor;
|
|
|
|
|
|
2019-10-05 19:25:28 +02:00
|
|
|
|
redoToolStripMenuItem.Enabled = false;
|
|
|
|
|
undoToolStripMenuItem.Enabled = false;
|
|
|
|
|
|
2019-08-29 21:45:32 +02:00
|
|
|
|
viewportBackColorCB.Items.Add("Back Color : Default");
|
|
|
|
|
viewportBackColorCB.Items.Add("Back Color : Custom");
|
2019-09-07 01:12:39 +02:00
|
|
|
|
orthographicViewToolStripMenuItem.Checked = true;
|
2019-08-29 21:45:32 +02:00
|
|
|
|
|
2019-09-06 00:14:15 +02:00
|
|
|
|
foreach (var type in Enum.GetValues(typeof(Runtime.LayoutEditor.DebugShading)).Cast<Runtime.LayoutEditor.DebugShading>())
|
|
|
|
|
debugShading.Items.Add(type);
|
|
|
|
|
|
|
|
|
|
debugShading.SelectedItem = Runtime.LayoutEditor.Shading;
|
2019-09-12 01:52:57 +02:00
|
|
|
|
displayNullPanesToolStripMenuItem.Checked = Runtime.LayoutEditor.DisplayNullPane;
|
|
|
|
|
displayyBoundryPanesToolStripMenuItem.Checked = Runtime.LayoutEditor.DisplayBoundryPane;
|
|
|
|
|
displayPicturePanesToolStripMenuItem.Checked = Runtime.LayoutEditor.DisplayPicturePane;
|
|
|
|
|
displayWindowPanesToolStripMenuItem.Checked = Runtime.LayoutEditor.DisplayWindowPane;
|
2019-09-17 03:02:00 +02:00
|
|
|
|
renderInGamePreviewToolStripMenuItem.Checked = Runtime.LayoutEditor.IsGamePreview;
|
|
|
|
|
displayGridToolStripMenuItem.Checked = Runtime.LayoutEditor.DisplayGrid;
|
2019-09-28 23:27:48 +02:00
|
|
|
|
displayTextPanesToolStripMenuItem.Checked = Runtime.LayoutEditor.DisplayTextPane;
|
2019-09-06 00:14:15 +02:00
|
|
|
|
|
2019-08-29 21:45:32 +02:00
|
|
|
|
ObjectSelected += OnObjectSelected;
|
|
|
|
|
ObjectChanged += OnObjectChanged;
|
2019-09-13 00:52:47 +02:00
|
|
|
|
|
|
|
|
|
if (Runtime.LayoutEditor.BackgroundColor != Color.FromArgb(130, 130, 130))
|
|
|
|
|
viewportBackColorCB.SelectedIndex = 1;
|
|
|
|
|
else
|
|
|
|
|
viewportBackColorCB.SelectedIndex = 0;
|
2019-08-01 23:47:35 +02:00
|
|
|
|
}
|
2019-08-27 22:38:06 +02:00
|
|
|
|
|
2019-08-29 21:45:32 +02:00
|
|
|
|
private List<LayoutViewer> Viewports = new List<LayoutViewer>();
|
2019-10-05 19:25:28 +02:00
|
|
|
|
private LayoutAnimEditor LayoutAnimEditor;
|
2019-08-29 21:45:32 +02:00
|
|
|
|
private LayoutViewer ActiveViewport;
|
2019-08-29 23:17:24 +02:00
|
|
|
|
private LayoutHierarchy LayoutHierarchy;
|
2019-10-05 19:25:28 +02:00
|
|
|
|
private LayoutAnimList LayoutAnimList;
|
2019-08-30 00:05:44 +02:00
|
|
|
|
private LayoutTextureList LayoutTextureList;
|
2019-08-30 01:01:47 +02:00
|
|
|
|
private LayoutProperties LayoutProperties;
|
2019-08-31 00:53:45 +02:00
|
|
|
|
private LayoutTextDocked TextConverter;
|
2019-09-05 22:24:03 +02:00
|
|
|
|
private LayoutPartsEditor LayoutPartsEditor;
|
2019-09-28 23:27:48 +02:00
|
|
|
|
private STAnimationPanel AnimationPanel;
|
2019-10-14 03:02:39 +02:00
|
|
|
|
private PaneEditor LayoutPaneEditor;
|
2019-08-29 21:45:32 +02:00
|
|
|
|
|
2019-08-28 03:14:37 +02:00
|
|
|
|
private bool isLoaded = false;
|
2019-09-11 00:42:48 +02:00
|
|
|
|
public void LoadBxlyt(BxlytHeader header)
|
2019-08-27 22:38:06 +02:00
|
|
|
|
{
|
2019-09-28 23:27:48 +02:00
|
|
|
|
/* if (PluginRuntime.BxfntFiles.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var result = MessageBox.Show("Found font files opened. Would you like to save character images to disk? " +
|
|
|
|
|
"(Allows for faster loading and won't need to be reopened)", "Layout Editor", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
|
|
|
if (result == DialogResult.Yes)
|
|
|
|
|
{
|
|
|
|
|
var cacheDir = $"{Runtime.ExecutableDir}/Cached/Font";
|
|
|
|
|
if (!System.IO.Directory.Exists(cacheDir))
|
|
|
|
|
System.IO.Directory.CreateDirectory(cacheDir);
|
|
|
|
|
|
|
|
|
|
foreach (var bffnt in PluginRuntime.BxfntFiles)
|
|
|
|
|
{
|
|
|
|
|
if (!System.IO.Directory.Exists($"{cacheDir}/{bffnt.Name}"))
|
|
|
|
|
System.IO.Directory.CreateDirectory($"{cacheDir}/{bffnt.Name}");
|
|
|
|
|
|
|
|
|
|
var fontBitmap = bffnt.GetBitmapFont(true);
|
|
|
|
|
foreach (var character in fontBitmap.Characters)
|
|
|
|
|
{
|
|
|
|
|
var charaMap = character.Value;
|
|
|
|
|
charaMap.CharBitmap.Save($"{cacheDir}/{bffnt.Name}/cmap_{Convert.ToUInt16(character.Key).ToString("x2")}_{charaMap.CharWidth}_{charaMap.GlyphWidth}_{charaMap.LeftOffset}.png");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fontBitmap.Dispose();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
|
2019-08-29 21:45:32 +02:00
|
|
|
|
LayoutFiles.Add(header);
|
|
|
|
|
ActiveLayout = header;
|
2019-08-28 03:14:37 +02:00
|
|
|
|
|
2019-09-29 00:12:12 +02:00
|
|
|
|
LayoutViewer Viewport = new LayoutViewer(this, header, Textures);
|
|
|
|
|
Viewport.DockContent = new DockContent();
|
|
|
|
|
Viewport.DockContent.Text = header.FileName;
|
|
|
|
|
Viewport.DockContent.Controls.Add(Viewport);
|
|
|
|
|
Viewport.Dock = DockStyle.Fill;
|
|
|
|
|
Viewport.DockContent.Show(dockPanel1, DockState.Document);
|
|
|
|
|
Viewport.DockContent.DockHandler.AllowEndUserDocking = false;
|
|
|
|
|
Viewports.Add(Viewport);
|
|
|
|
|
ActiveViewport = Viewport;
|
|
|
|
|
|
2019-10-05 19:25:28 +02:00
|
|
|
|
UpdateUndo();
|
2019-09-29 00:12:12 +02:00
|
|
|
|
/* if (ActiveViewport == null)
|
|
|
|
|
{
|
|
|
|
|
LayoutViewer Viewport = new LayoutViewer(this,header, Textures);
|
|
|
|
|
Viewport.DockContent = new DockContent();
|
|
|
|
|
Viewport.DockContent.Controls.Add(Viewport);
|
|
|
|
|
Viewport.Dock = DockStyle.Fill;
|
|
|
|
|
Viewport.DockContent.Show(dockPanel1, DockState.Document);
|
|
|
|
|
Viewport.DockContent.DockHandler.AllowEndUserDocking = false;
|
|
|
|
|
Viewports.Add(Viewport);
|
|
|
|
|
ActiveViewport = Viewport;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
ActiveViewport.LoadLayout(header);*/
|
2019-09-28 23:27:48 +02:00
|
|
|
|
|
|
|
|
|
orthographicViewToolStripMenuItem.Checked = Runtime.LayoutEditor.UseOrthographicView;
|
2019-08-29 21:45:32 +02:00
|
|
|
|
|
|
|
|
|
if (!isLoaded)
|
|
|
|
|
InitializeDockPanels();
|
2019-08-28 03:14:37 +02:00
|
|
|
|
|
2019-10-05 19:25:28 +02:00
|
|
|
|
LayoutAnimList?.SearchAnimations(header);
|
2019-09-24 00:16:50 +02:00
|
|
|
|
|
2019-09-28 23:27:48 +02:00
|
|
|
|
CustomMapper.LoadMK8DCharaSelect(Textures, header);
|
|
|
|
|
|
2019-08-28 03:14:37 +02:00
|
|
|
|
isLoaded = true;
|
2019-08-27 22:38:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 03:02:39 +02:00
|
|
|
|
public Dictionary<string, STGenericTexture> GetTextures()
|
|
|
|
|
{
|
|
|
|
|
return Textures;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-11 00:42:48 +02:00
|
|
|
|
public void LoadBxlan(BxlanHeader header)
|
|
|
|
|
{
|
|
|
|
|
AnimationFiles.Add(header);
|
|
|
|
|
ActiveAnimation = header;
|
|
|
|
|
|
|
|
|
|
ShowAnimationHierarchy();
|
|
|
|
|
ShowPropertiesPanel();
|
2019-10-05 19:25:28 +02:00
|
|
|
|
LayoutAnimList.LoadAnimation(ActiveAnimation);
|
2019-09-11 00:42:48 +02:00
|
|
|
|
|
|
|
|
|
isLoaded = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitializeDockPanels(bool isAnimation = false)
|
2019-08-29 21:45:32 +02:00
|
|
|
|
{
|
2019-09-24 00:16:50 +02:00
|
|
|
|
ShowAnimationHierarchy();
|
2019-08-29 21:45:32 +02:00
|
|
|
|
ShowTextureList();
|
2019-09-05 22:24:03 +02:00
|
|
|
|
ShowPartsEditor();
|
2019-08-29 21:45:32 +02:00
|
|
|
|
ShowPaneHierarchy();
|
|
|
|
|
ShowPropertiesPanel();
|
|
|
|
|
UpdateBackColor();
|
2019-09-28 23:27:48 +02:00
|
|
|
|
ShowAnimationPanel();
|
2019-08-29 23:17:24 +02:00
|
|
|
|
}
|
2019-08-29 21:45:32 +02:00
|
|
|
|
|
2019-08-30 01:01:47 +02:00
|
|
|
|
private void ResetEditors()
|
|
|
|
|
{
|
|
|
|
|
if (LayoutHierarchy != null)
|
|
|
|
|
LayoutHierarchy.Reset();
|
|
|
|
|
if (LayoutTextureList != null)
|
|
|
|
|
LayoutTextureList.Reset();
|
|
|
|
|
if (LayoutProperties != null)
|
|
|
|
|
LayoutProperties.Reset();
|
2019-08-31 00:53:45 +02:00
|
|
|
|
if (TextConverter != null)
|
|
|
|
|
TextConverter.Reset();
|
2019-10-14 03:02:39 +02:00
|
|
|
|
if (LayoutPaneEditor != null)
|
|
|
|
|
LayoutPaneEditor.Reset();
|
2019-08-30 01:01:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-29 23:17:24 +02:00
|
|
|
|
private void ReloadEditors(BxlytHeader activeLayout)
|
|
|
|
|
{
|
2019-08-30 01:01:47 +02:00
|
|
|
|
if (!isLoaded) return;
|
|
|
|
|
|
|
|
|
|
if (LayoutProperties != null)
|
|
|
|
|
LayoutProperties.Reset();
|
2019-08-29 23:17:24 +02:00
|
|
|
|
if (LayoutHierarchy != null)
|
|
|
|
|
LayoutHierarchy.LoadLayout(activeLayout, ObjectSelected);
|
2019-08-30 00:05:44 +02:00
|
|
|
|
if (LayoutTextureList != null)
|
2019-10-14 03:02:39 +02:00
|
|
|
|
LayoutTextureList.LoadTextures(this, activeLayout, Textures);
|
2019-08-31 00:53:45 +02:00
|
|
|
|
if (TextConverter != null)
|
|
|
|
|
{
|
|
|
|
|
if (ActiveLayout.FileInfo is BFLYT)
|
|
|
|
|
TextConverter.LoadLayout((BFLYT)ActiveLayout.FileInfo);
|
|
|
|
|
}
|
2019-08-29 21:45:32 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnObjectChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnProperyChanged()
|
|
|
|
|
{
|
2019-09-02 21:26:26 +02:00
|
|
|
|
Console.WriteLine("UpdateProperties");
|
|
|
|
|
|
|
|
|
|
if (LayoutProperties != null)
|
|
|
|
|
LayoutProperties.UpdateProperties();
|
|
|
|
|
|
2019-08-29 21:45:32 +02:00
|
|
|
|
if (ActiveViewport != null)
|
|
|
|
|
ActiveViewport.UpdateViewport();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool isChecked = false;
|
|
|
|
|
private void OnObjectSelected(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (isChecked) return;
|
|
|
|
|
|
2019-09-28 23:27:48 +02:00
|
|
|
|
if (AnimationPanel != null)
|
|
|
|
|
{
|
2019-10-05 19:25:28 +02:00
|
|
|
|
if (e is ListViewItemSelectionChangedEventArgs)
|
2019-09-28 23:27:48 +02:00
|
|
|
|
{
|
2019-10-05 19:25:28 +02:00
|
|
|
|
var node = ((ListViewItemSelectionChangedEventArgs)e).Item;
|
|
|
|
|
if (node.Tag is ArchiveFileInfo)
|
|
|
|
|
{
|
2019-09-28 23:27:48 +02:00
|
|
|
|
UpdateAnimationNode(node);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (node.Tag is BxlanHeader)
|
2019-10-05 19:25:28 +02:00
|
|
|
|
{
|
|
|
|
|
AnimationPanel?.Reset();
|
|
|
|
|
foreach (ListViewItem item in LayoutAnimList.GetSelectedAnimations)
|
|
|
|
|
UpdateAnimationPlayer((BxlanHeader)item.Tag);
|
|
|
|
|
}
|
2019-09-28 23:27:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-10-14 03:02:39 +02:00
|
|
|
|
if (LayoutPaneEditor != null && (string)sender == "Select")
|
2019-08-29 21:45:32 +02:00
|
|
|
|
{
|
2019-09-11 00:42:48 +02:00
|
|
|
|
ActiveViewport?.SelectedPanes.Clear();
|
2019-09-05 22:24:03 +02:00
|
|
|
|
|
2019-08-29 21:45:32 +02:00
|
|
|
|
if (e is TreeViewEventArgs) {
|
|
|
|
|
var node = ((TreeViewEventArgs)e).Node;
|
|
|
|
|
|
2019-09-04 20:10:17 +02:00
|
|
|
|
if (node.Tag is BasePane)
|
2019-10-14 03:02:39 +02:00
|
|
|
|
LoadPaneEditorOnSelect(node.Tag as BasePane);
|
|
|
|
|
else if (node.Tag is BxlytMaterial)
|
2019-09-04 20:10:17 +02:00
|
|
|
|
{
|
2019-10-14 03:02:39 +02:00
|
|
|
|
LayoutPaneEditor.Text = $"Properties [{((BxlytMaterial)node.Tag).Name}]";
|
|
|
|
|
LayoutPaneEditor.LoadMaterial((BxlytMaterial)node.Tag, this);
|
2019-09-04 20:10:17 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
2019-10-14 03:02:39 +02:00
|
|
|
|
{
|
|
|
|
|
LayoutPaneEditor.Text = $"Properties";
|
|
|
|
|
LayoutPaneEditor.LoadProperties(node.Tag);
|
|
|
|
|
}
|
2019-08-29 21:45:32 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (ActiveViewport != null)
|
|
|
|
|
{
|
|
|
|
|
if (e is TreeViewEventArgs && (string)sender == "Checked" && !isChecked) {
|
|
|
|
|
isChecked = true;
|
|
|
|
|
var node = ((TreeViewEventArgs)e).Node;
|
|
|
|
|
ToggleChildern(node, node.Checked);
|
|
|
|
|
isChecked = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ActiveViewport.UpdateViewport();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 03:02:39 +02:00
|
|
|
|
public void UpdateViewport() {
|
|
|
|
|
ActiveViewport?.UpdateViewport();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void LoadPaneEditorOnSelect(BasePane pane)
|
|
|
|
|
{
|
|
|
|
|
if (pane is IPicturePane)
|
|
|
|
|
LayoutPaneEditor.Text = $"Properties [{pane.Name}] | (Picture Pane)";
|
|
|
|
|
else if (pane is ITextPane)
|
|
|
|
|
LayoutPaneEditor.Text = $"Properties [{pane.Name}] | (Text Box Pane)";
|
|
|
|
|
else if (pane is IWindowPane)
|
|
|
|
|
LayoutPaneEditor.Text = $"Properties [{pane.Name}] | (Window Pane)";
|
|
|
|
|
else if (pane is IBoundryPane)
|
|
|
|
|
LayoutPaneEditor.Text = $"Properties [{pane.Name}] | (Boundry Pane)";
|
|
|
|
|
else if (pane is IPartPane)
|
|
|
|
|
LayoutPaneEditor.Text = $"Properties [{pane.Name}] | (Part Pane)";
|
|
|
|
|
else
|
|
|
|
|
LayoutPaneEditor.Text = $"Properties [{pane.Name}] | (Null Pane)";
|
|
|
|
|
|
|
|
|
|
LayoutPaneEditor.LoadPane(pane, this);
|
|
|
|
|
ActiveViewport?.SelectedPanes.Add(pane);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void RefreshEditors()
|
|
|
|
|
{
|
|
|
|
|
LayoutPaneEditor?.RefreshEditor();
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-05 19:25:28 +02:00
|
|
|
|
public void UpdateHiearchyNodeSelection(BasePane pane)
|
2019-09-28 23:27:48 +02:00
|
|
|
|
{
|
2019-10-05 19:25:28 +02:00
|
|
|
|
var nodeWrapper = pane.NodeWrapper;
|
|
|
|
|
if (nodeWrapper == null) return;
|
2019-09-28 23:27:48 +02:00
|
|
|
|
|
2019-10-05 19:25:28 +02:00
|
|
|
|
LayoutHierarchy?.SelectNode(nodeWrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateAnimationNode(ListViewItem node)
|
|
|
|
|
{
|
2019-09-28 23:27:48 +02:00
|
|
|
|
var archiveNode = node.Tag as ArchiveFileInfo;
|
|
|
|
|
var fileFormat = archiveNode.OpenFile();
|
|
|
|
|
|
|
|
|
|
//Update the tag so this doesn't run again
|
|
|
|
|
node.Tag = "Expanded";
|
|
|
|
|
|
|
|
|
|
if (fileFormat != null && fileFormat is BXLAN)
|
|
|
|
|
{
|
|
|
|
|
node.Tag = ((BXLAN)fileFormat).BxlanHeader;
|
|
|
|
|
AnimationFiles.Add(((BXLAN)fileFormat).BxlanHeader);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-29 21:45:32 +02:00
|
|
|
|
private void ToggleChildern(TreeNode node, bool isChecked)
|
|
|
|
|
{
|
2019-08-29 22:33:23 +02:00
|
|
|
|
if (node.Tag is BasePane)
|
|
|
|
|
((BasePane)node.Tag).DisplayInEditor = isChecked;
|
2019-08-29 21:45:32 +02:00
|
|
|
|
|
|
|
|
|
node.Checked = isChecked;
|
|
|
|
|
foreach (TreeNode child in node.Nodes)
|
|
|
|
|
ToggleChildern(child, isChecked);
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-28 23:27:48 +02:00
|
|
|
|
private void UpdateAnimationPlayer(BxlanHeader animHeader)
|
2019-08-27 22:38:06 +02:00
|
|
|
|
{
|
2019-09-28 23:27:48 +02:00
|
|
|
|
if (AnimationPanel == null) return;
|
2019-08-27 22:38:06 +02:00
|
|
|
|
|
2019-09-28 23:27:48 +02:00
|
|
|
|
if (ActiveLayout != null)
|
|
|
|
|
{
|
2019-10-05 19:25:28 +02:00
|
|
|
|
AnimationPanel.AddAnimation(animHeader.ToGenericAnimation(ActiveLayout), false);
|
2019-09-28 23:27:48 +02:00
|
|
|
|
// foreach (var anim in AnimationFiles)
|
|
|
|
|
// AnimationPanel.AddAnimation(anim.ToGenericAnimation(ActiveLayout), false);
|
|
|
|
|
}
|
2019-08-27 22:38:06 +02:00
|
|
|
|
}
|
2019-08-28 03:14:37 +02:00
|
|
|
|
|
|
|
|
|
private void LayoutEditor_ParentChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (this.ParentForm == null) return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-29 21:45:32 +02:00
|
|
|
|
private void textureListToolStripMenuItem_Click(object sender, EventArgs e) {
|
|
|
|
|
ShowTextureList();
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-05 22:24:03 +02:00
|
|
|
|
private void ShowPartsEditor()
|
|
|
|
|
{
|
2019-09-24 00:16:50 +02:00
|
|
|
|
if (LayoutPartsEditor != null)
|
|
|
|
|
return;
|
|
|
|
|
|
2019-09-05 22:24:03 +02:00
|
|
|
|
LayoutPartsEditor = new LayoutPartsEditor();
|
|
|
|
|
LayoutPartsEditor.Text = "Parts Editor";
|
|
|
|
|
LayoutPartsEditor.Show(dockPanel1, DockState.DockLeft);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-05 19:25:28 +02:00
|
|
|
|
public void ShowBxlanEditor(BxlanHeader bxlan)
|
|
|
|
|
{
|
|
|
|
|
LayoutAnimEditorBasic editor = new LayoutAnimEditorBasic();
|
|
|
|
|
editor.LoadAnim(bxlan);
|
|
|
|
|
editor.OnPropertyChanged += AnimPropertyChanged;
|
|
|
|
|
editor.Show(this);
|
|
|
|
|
|
|
|
|
|
/* if (LayoutAnimEditor != null) {
|
|
|
|
|
LayoutAnimEditor.LoadFile(bxlan.GetGenericAnimation());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LayoutAnimEditor = new LayoutAnimEditor();
|
|
|
|
|
AnimationPanel.OnNodeSelected = LayoutAnimEditor.OnNodeSelected;
|
|
|
|
|
LayoutAnimEditor.LoadFile(bxlan.GetGenericAnimation());
|
|
|
|
|
if (LayoutHierarchy != null)
|
|
|
|
|
LayoutAnimEditor.Show(LayoutHierarchy.Pane, DockAlignment.Bottom, 0.5);
|
|
|
|
|
else
|
|
|
|
|
LayoutAnimEditor.Show(dockPanel1, DockState.DockRight);*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AnimPropertyChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ActiveViewport?.UpdateViewport();
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-29 21:45:32 +02:00
|
|
|
|
private void ShowPropertiesPanel()
|
|
|
|
|
{
|
2019-10-14 03:02:39 +02:00
|
|
|
|
if (LayoutPaneEditor == null)
|
|
|
|
|
LayoutPaneEditor = new PaneEditor();
|
|
|
|
|
|
|
|
|
|
LayoutPaneEditor.Text = "Properties";
|
|
|
|
|
LayoutPaneEditor.PropertyChanged += OnPanePropertyChanged;
|
2019-09-24 00:16:50 +02:00
|
|
|
|
|
2019-09-01 20:09:02 +02:00
|
|
|
|
if (LayoutHierarchy != null)
|
2019-10-14 03:02:39 +02:00
|
|
|
|
LayoutPaneEditor.Show(LayoutHierarchy.Pane, DockAlignment.Bottom, 0.5);
|
2019-09-01 20:09:02 +02:00
|
|
|
|
else
|
2019-10-14 03:02:39 +02:00
|
|
|
|
LayoutPaneEditor.Show(dockPanel1, DockState.DockRight);
|
|
|
|
|
|
|
|
|
|
/* if (LayoutProperties != null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
LayoutProperties = new LayoutProperties();
|
|
|
|
|
LayoutProperties.Text = "Properties";
|
|
|
|
|
if (LayoutHierarchy != null)
|
|
|
|
|
LayoutProperties.Show(LayoutHierarchy.Pane, DockAlignment.Bottom, 0.5);
|
|
|
|
|
else
|
|
|
|
|
LayoutProperties.Show(dockPanel1, DockState.DockRight);*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ShowPaneEditor(BasePane pane)
|
|
|
|
|
{
|
|
|
|
|
/* if (LayoutPaneEditor == null)
|
|
|
|
|
LayoutPaneEditor = new PaneEditor();
|
|
|
|
|
|
|
|
|
|
LayoutPaneEditor.PropertyChanged += OnPanePropertyChanged;
|
|
|
|
|
LayoutPaneEditor.LoadPane(pane);
|
|
|
|
|
LayoutPaneEditor.Show();*/
|
2019-08-29 21:45:32 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-11 00:42:48 +02:00
|
|
|
|
public void ShowAnimationHierarchy()
|
|
|
|
|
{
|
2019-10-05 19:25:28 +02:00
|
|
|
|
if (LayoutAnimList != null)
|
2019-09-24 00:16:50 +02:00
|
|
|
|
return;
|
|
|
|
|
|
2019-10-05 19:25:28 +02:00
|
|
|
|
LayoutAnimList = new LayoutAnimList(this, ObjectSelected);
|
|
|
|
|
LayoutAnimList.Text = "Animation Hierarchy";
|
|
|
|
|
LayoutAnimList.Show(dockPanel1, DockState.DockLeft);
|
2019-09-11 00:42:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-29 21:45:32 +02:00
|
|
|
|
private void ShowPaneHierarchy()
|
|
|
|
|
{
|
2019-09-24 00:16:50 +02:00
|
|
|
|
if (LayoutHierarchy != null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
LayoutHierarchy = new LayoutHierarchy(this);
|
2019-08-30 01:01:47 +02:00
|
|
|
|
LayoutHierarchy.Text = "Hierarchy";
|
2019-08-29 23:17:24 +02:00
|
|
|
|
LayoutHierarchy.LoadLayout(ActiveLayout, ObjectSelected);
|
2019-08-30 01:01:47 +02:00
|
|
|
|
LayoutHierarchy.Show(dockPanel1, DockState.DockLeft);
|
2019-08-29 21:45:32 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ShowTextureList()
|
2019-08-28 03:14:37 +02:00
|
|
|
|
{
|
2019-09-24 00:16:50 +02:00
|
|
|
|
if (LayoutTextureList != null)
|
|
|
|
|
return;
|
|
|
|
|
|
2019-08-30 00:05:44 +02:00
|
|
|
|
LayoutTextureList = new LayoutTextureList();
|
2019-08-30 01:01:47 +02:00
|
|
|
|
LayoutTextureList.Text = "Texture List";
|
2019-10-14 03:02:39 +02:00
|
|
|
|
LayoutTextureList.LoadTextures(this, ActiveLayout, Textures);
|
2019-08-30 01:01:47 +02:00
|
|
|
|
LayoutTextureList.Show(dockPanel1, DockState.DockRight);
|
2019-08-29 21:45:32 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-28 23:27:48 +02:00
|
|
|
|
public void ShowAnimationPanel()
|
|
|
|
|
{
|
|
|
|
|
DockContent dockContent = new DockContent();
|
|
|
|
|
AnimationPanel = new STAnimationPanel();
|
|
|
|
|
AnimationPanel.Dock = DockStyle.Fill;
|
2019-10-05 19:25:28 +02:00
|
|
|
|
AnimationPanel.AnimationPlaying += OnAnimationPlaying;
|
2019-09-28 23:27:48 +02:00
|
|
|
|
AnimationPanel.SetViewport(ActiveViewport.GetGLControl());
|
|
|
|
|
dockContent.Controls.Add(AnimationPanel);
|
|
|
|
|
LayoutTextureList.Show(dockPanel1, DockState.DockRight);
|
|
|
|
|
|
|
|
|
|
if (ActiveViewport != null)
|
|
|
|
|
dockContent.Show(ActiveViewport.Pane, DockAlignment.Bottom, 0.2);
|
|
|
|
|
else
|
|
|
|
|
dockContent.Show(dockPanel1, DockState.DockBottom);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-06 00:37:28 +02:00
|
|
|
|
public void UpdateHiearchyTree()
|
|
|
|
|
{
|
|
|
|
|
LayoutHierarchy?.UpdateTree();
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 03:02:39 +02:00
|
|
|
|
public void UpdateLayoutTextureList()
|
|
|
|
|
{
|
|
|
|
|
LayoutTextureList?.LoadTextures(this, ActiveLayout, Textures);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-05 19:25:28 +02:00
|
|
|
|
private void OnAnimationPlaying(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (LayoutAnimEditor != null)
|
|
|
|
|
LayoutAnimEditor.OnAnimationPlaying();
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-29 21:45:32 +02:00
|
|
|
|
private void stComboBox1_MouseDoubleClick(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
2019-08-28 03:14:37 +02:00
|
|
|
|
|
2019-08-29 21:45:32 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool isBGUpdating = false;
|
|
|
|
|
private void viewportBackColorCB_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (ActiveViewport == null || isBGUpdating) return;
|
|
|
|
|
UpdateBackColor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateBackColor()
|
|
|
|
|
{
|
|
|
|
|
if (viewportBackColorCB.SelectedIndex == 0)
|
|
|
|
|
{
|
|
|
|
|
ActiveViewport.UpdateBackgroundColor(Color.FromArgb(130, 130, 130));
|
|
|
|
|
backColorDisplay.BackColor = Color.FromArgb(130, 130, 130);
|
|
|
|
|
}
|
2019-09-13 00:52:47 +02:00
|
|
|
|
else if (!isLoaded)
|
|
|
|
|
{
|
|
|
|
|
ActiveViewport.UpdateBackgroundColor(Runtime.LayoutEditor.BackgroundColor);
|
|
|
|
|
backColorDisplay.BackColor = Runtime.LayoutEditor.BackgroundColor;
|
|
|
|
|
}
|
2019-08-28 03:14:37 +02:00
|
|
|
|
else
|
2019-08-29 21:45:32 +02:00
|
|
|
|
{
|
|
|
|
|
ColorDialog dlg = new ColorDialog();
|
|
|
|
|
if (dlg.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
ActiveViewport.UpdateBackgroundColor(dlg.Color);
|
|
|
|
|
backColorDisplay.BackColor = dlg.Color;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
viewportBackColorCB.SelectedIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void backColorDisplay_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
isBGUpdating = true;
|
|
|
|
|
|
|
|
|
|
ColorDialog dlg = new ColorDialog();
|
|
|
|
|
if (dlg.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
ActiveViewport.UpdateBackgroundColor(dlg.Color);
|
|
|
|
|
backColorDisplay.BackColor = dlg.Color;
|
|
|
|
|
|
|
|
|
|
if (viewportBackColorCB.SelectedIndex == 0)
|
|
|
|
|
viewportBackColorCB.SelectedIndex = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
isBGUpdating = false;
|
2019-08-28 03:14:37 +02:00
|
|
|
|
}
|
2019-08-29 23:17:24 +02:00
|
|
|
|
|
|
|
|
|
private void dockPanel1_ActiveDocumentChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2019-09-29 01:13:32 +02:00
|
|
|
|
var dockContent = dockPanel1.ActiveDocument as DockContent;
|
|
|
|
|
if (dockContent == null) return;
|
|
|
|
|
|
|
|
|
|
LayoutViewer viewer = null;
|
|
|
|
|
foreach (var control in dockContent.Controls)
|
|
|
|
|
if (control is LayoutViewer)
|
|
|
|
|
viewer = control as LayoutViewer;
|
|
|
|
|
|
|
|
|
|
if (viewer != null)
|
2019-08-29 23:17:24 +02:00
|
|
|
|
{
|
2019-09-29 01:13:32 +02:00
|
|
|
|
var file = viewer.LayoutFile;
|
|
|
|
|
ActiveLayout = file;
|
2019-08-30 01:21:47 +02:00
|
|
|
|
ReloadEditors(file);
|
2019-09-29 01:13:32 +02:00
|
|
|
|
ActiveViewport = viewer;
|
2019-10-05 19:25:28 +02:00
|
|
|
|
UpdateUndo();
|
2019-09-29 01:13:32 +02:00
|
|
|
|
viewer.UpdateViewport();
|
2019-08-29 23:17:24 +02:00
|
|
|
|
|
2019-09-29 01:13:32 +02:00
|
|
|
|
Console.WriteLine("changed " + ActiveLayout.FileName);
|
2019-08-29 23:17:24 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-08-30 00:05:44 +02:00
|
|
|
|
|
|
|
|
|
private void LayoutEditor_DragDrop(object sender, DragEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Cursor.Current = Cursors.WaitCursor;
|
|
|
|
|
|
|
|
|
|
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
|
|
|
|
|
foreach (string filename in files)
|
|
|
|
|
OpenFile(filename);
|
|
|
|
|
|
|
|
|
|
Cursor.Current = Cursors.Default;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OpenFile(string fileName)
|
|
|
|
|
{
|
|
|
|
|
//Todo if an image is dropped, we should make a picture pane if a viewer is active
|
|
|
|
|
|
|
|
|
|
var file = STFileLoader.OpenFileFormat(fileName);
|
|
|
|
|
if (file == null) return;
|
|
|
|
|
|
|
|
|
|
if (file is BFLYT)
|
2019-09-11 00:42:48 +02:00
|
|
|
|
LoadBxlyt(((BFLYT)file).header);
|
2019-08-31 00:53:45 +02:00
|
|
|
|
else if (file is BCLYT)
|
2019-09-11 00:42:48 +02:00
|
|
|
|
LoadBxlyt(((BCLYT)file).header);
|
2019-08-31 23:24:05 +02:00
|
|
|
|
else if (file is BRLYT)
|
2019-09-11 00:42:48 +02:00
|
|
|
|
LoadBxlyt(((BRLYT)file).header);
|
2019-08-30 00:05:44 +02:00
|
|
|
|
else if (file is IArchiveFile)
|
2019-08-30 01:21:47 +02:00
|
|
|
|
{
|
|
|
|
|
var layouts = SearchLayoutFiles((IArchiveFile)file);
|
|
|
|
|
if (layouts.Count > 1)
|
|
|
|
|
{
|
|
|
|
|
var form = new FileSelector();
|
|
|
|
|
form.LoadLayoutFiles(layouts);
|
|
|
|
|
if (form.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
2019-08-30 01:48:07 +02:00
|
|
|
|
foreach (var layout in form.SelectedLayouts())
|
2019-08-30 01:21:47 +02:00
|
|
|
|
{
|
2019-08-31 00:53:45 +02:00
|
|
|
|
if (layout is BFLYT)
|
2019-09-11 00:42:48 +02:00
|
|
|
|
LoadBxlyt(((BFLYT)layout).header);
|
2019-08-31 00:53:45 +02:00
|
|
|
|
if (layout is BCLYT)
|
2019-09-11 00:42:48 +02:00
|
|
|
|
LoadBxlyt(((BCLYT)layout).header);
|
2019-08-31 23:24:05 +02:00
|
|
|
|
if (layout is BRLYT)
|
2019-09-11 00:42:48 +02:00
|
|
|
|
LoadBxlyt(((BRLYT)layout).header);
|
2019-08-30 01:21:47 +02:00
|
|
|
|
}
|
2019-09-01 19:29:24 +02:00
|
|
|
|
}
|
2019-08-30 01:21:47 +02:00
|
|
|
|
}
|
|
|
|
|
else if (layouts.Count > 0)
|
|
|
|
|
{
|
2019-08-31 00:53:45 +02:00
|
|
|
|
if (layouts[0] is BFLYT)
|
2019-09-11 00:42:48 +02:00
|
|
|
|
LoadBxlyt(((BFLYT)layouts[0]).header);
|
2019-08-31 00:53:45 +02:00
|
|
|
|
if (layouts[0] is BCLYT)
|
2019-09-11 00:42:48 +02:00
|
|
|
|
LoadBxlyt(((BCLYT)layouts[0]).header);
|
2019-08-31 23:24:05 +02:00
|
|
|
|
if (layouts[0] is BRLYT)
|
2019-09-11 00:42:48 +02:00
|
|
|
|
LoadBxlyt(((BRLYT)layouts[0]).header);
|
2019-08-30 01:21:47 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-08-30 00:05:44 +02:00
|
|
|
|
else if (file is BFLAN)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (file is BNTX)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-31 00:53:45 +02:00
|
|
|
|
private List<IFileFormat> SearchLayoutFiles(IArchiveFile archiveFile)
|
2019-08-30 00:05:44 +02:00
|
|
|
|
{
|
2019-08-31 00:53:45 +02:00
|
|
|
|
List<IFileFormat> layouts = new List<IFileFormat>();
|
2019-08-30 01:21:47 +02:00
|
|
|
|
|
2019-08-30 00:05:44 +02:00
|
|
|
|
foreach (var file in archiveFile.Files)
|
|
|
|
|
{
|
2019-08-30 01:01:47 +02:00
|
|
|
|
var fileFormat = STFileLoader.OpenFileFormat(file.FileName,
|
2019-08-31 23:24:05 +02:00
|
|
|
|
new Type[] { typeof(BFLYT), typeof(BCLYT), typeof(BRLYT), typeof(SARC) }, file.FileData);
|
2019-08-30 01:01:47 +02:00
|
|
|
|
|
|
|
|
|
if (fileFormat is BFLYT)
|
2019-08-30 00:05:44 +02:00
|
|
|
|
{
|
|
|
|
|
fileFormat.IFileInfo.ArchiveParent = archiveFile;
|
2019-08-31 00:53:45 +02:00
|
|
|
|
layouts.Add(fileFormat);
|
|
|
|
|
}
|
|
|
|
|
else if (fileFormat is BCLYT)
|
|
|
|
|
{
|
|
|
|
|
fileFormat.IFileInfo.ArchiveParent = archiveFile;
|
|
|
|
|
layouts.Add(fileFormat);
|
2019-08-30 00:05:44 +02:00
|
|
|
|
}
|
|
|
|
|
else if (Utils.GetExtension(file.FileName) == ".bntx")
|
|
|
|
|
{
|
2019-09-01 19:29:24 +02:00
|
|
|
|
|
2019-08-30 00:05:44 +02:00
|
|
|
|
}
|
|
|
|
|
else if (Utils.GetExtension(file.FileName) == ".bflim")
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
2019-08-30 01:01:47 +02:00
|
|
|
|
else if (fileFormat is SARC)
|
2019-08-30 00:05:44 +02:00
|
|
|
|
{
|
|
|
|
|
fileFormat.IFileInfo.ArchiveParent = archiveFile;
|
|
|
|
|
|
|
|
|
|
if (fileFormat is IArchiveFile)
|
2019-08-30 01:21:47 +02:00
|
|
|
|
return SearchLayoutFiles((IArchiveFile)fileFormat);
|
2019-08-30 00:05:44 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-08-30 01:21:47 +02:00
|
|
|
|
|
|
|
|
|
return layouts;
|
2019-08-30 00:05:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LayoutEditor_DragEnter(object sender, DragEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
|
|
|
|
e.Effect = DragDropEffects.All;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
String[] strGetFormats = e.Data.GetFormats();
|
|
|
|
|
e.Effect = DragDropEffects.None;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-08-30 01:01:47 +02:00
|
|
|
|
|
|
|
|
|
private void clearWorkspaceToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2019-08-30 02:51:41 +02:00
|
|
|
|
var docs = dockPanel1.DocumentsToArray();
|
|
|
|
|
for (int i = 0; i < docs.Length; i++)
|
|
|
|
|
docs[i].DockHandler.DockPanel = null;
|
2019-08-30 01:01:47 +02:00
|
|
|
|
|
|
|
|
|
ResetEditors();
|
2019-08-30 02:51:41 +02:00
|
|
|
|
|
|
|
|
|
GC.Collect();
|
2019-08-30 01:01:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void openToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
OpenFileDialog ofd = new OpenFileDialog();
|
|
|
|
|
ofd.Multiselect = true;
|
|
|
|
|
if (ofd.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
foreach (string filename in ofd.FileNames)
|
|
|
|
|
OpenFile(filename);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-08-31 00:53:45 +02:00
|
|
|
|
|
|
|
|
|
private void textConverterToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2019-09-02 21:26:26 +02:00
|
|
|
|
if (!textConverterToolStripMenuItem.Checked)
|
2019-08-31 00:53:45 +02:00
|
|
|
|
{
|
2019-09-02 21:26:26 +02:00
|
|
|
|
if (ActiveLayout.FileInfo is BFLYT)
|
|
|
|
|
{
|
|
|
|
|
if (TextConverter == null)
|
|
|
|
|
TextConverter = new LayoutTextDocked();
|
|
|
|
|
TextConverter.Text = "Text Converter";
|
2019-09-04 20:10:17 +02:00
|
|
|
|
TextConverter.TextCompiled += OnTextCompiled;
|
2019-09-02 21:26:26 +02:00
|
|
|
|
TextConverter.LoadLayout((BFLYT)ActiveLayout.FileInfo);
|
|
|
|
|
if (ActiveViewport != null)
|
|
|
|
|
TextConverter.Show(ActiveViewport.Pane, DockAlignment.Bottom, 0.4);
|
|
|
|
|
else
|
|
|
|
|
TextConverter.Show(dockPanel1, DockState.DockLeft);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
textConverterToolStripMenuItem.Checked = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
textConverterToolStripMenuItem.Checked = false;
|
2019-09-15 02:11:08 +02:00
|
|
|
|
TextConverter?.Hide();
|
2019-08-31 00:53:45 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-09-01 19:02:48 +02:00
|
|
|
|
|
2019-09-04 20:10:17 +02:00
|
|
|
|
private void OnTextCompiled(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var layout = TextConverter.GetLayout();
|
|
|
|
|
ActiveLayout = layout.header;
|
|
|
|
|
ReloadEditors(layout.header);
|
|
|
|
|
|
|
|
|
|
if (ActiveViewport != null)
|
|
|
|
|
ActiveViewport.ResetLayout(ActiveLayout);
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-01 19:02:48 +02:00
|
|
|
|
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2019-09-11 03:25:30 +02:00
|
|
|
|
if (ActiveAnimation != null && ActiveAnimation.FileInfo.CanSave)
|
|
|
|
|
{
|
|
|
|
|
SaveFileDialog sfd = new SaveFileDialog();
|
|
|
|
|
sfd.Filter = Utils.GetAllFilters(ActiveAnimation.FileInfo);
|
|
|
|
|
sfd.FileName = ActiveAnimation.FileInfo.FileName;
|
|
|
|
|
|
|
|
|
|
if (sfd.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
STFileSaver.SaveFileFormat(ActiveAnimation.FileInfo, sfd.FileName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-01 19:02:48 +02:00
|
|
|
|
if (ActiveLayout != null && ActiveLayout.FileInfo.CanSave)
|
|
|
|
|
{
|
|
|
|
|
SaveFileDialog sfd = new SaveFileDialog();
|
|
|
|
|
sfd.Filter = Utils.GetAllFilters(ActiveLayout.FileInfo);
|
|
|
|
|
sfd.FileName = ActiveLayout.FileInfo.FileName;
|
|
|
|
|
|
|
|
|
|
if (sfd.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
STFileSaver.SaveFileFormat(ActiveLayout.FileInfo, sfd.FileName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-09-01 19:29:24 +02:00
|
|
|
|
|
|
|
|
|
private void saveToolStripMenuItem1_Click(object sender, EventArgs e) {
|
2019-09-11 00:42:48 +02:00
|
|
|
|
if (ActiveLayout != null)
|
|
|
|
|
SaveActiveFile(ActiveLayout.FileInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void saveAnimationToolStripMenuItem_Click(object sender, EventArgs e) {
|
|
|
|
|
if (ActiveAnimation != null)
|
|
|
|
|
SaveActiveFile(ActiveAnimation.FileInfo);
|
2019-09-01 19:29:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-11 00:42:48 +02:00
|
|
|
|
private void SaveActiveFile(IFileFormat fileFormat, bool ForceDialog = false)
|
2019-09-01 19:29:24 +02:00
|
|
|
|
{
|
2019-09-11 00:42:48 +02:00
|
|
|
|
if (fileFormat.CanSave)
|
2019-09-01 19:29:24 +02:00
|
|
|
|
{
|
2019-09-28 23:27:48 +02:00
|
|
|
|
if (fileFormat.IFileInfo != null &&
|
2019-09-11 00:42:48 +02:00
|
|
|
|
fileFormat.IFileInfo.ArchiveParent != null && !ForceDialog)
|
2019-09-01 19:29:24 +02:00
|
|
|
|
{
|
2019-09-11 00:42:48 +02:00
|
|
|
|
if (fileFormat is IEditorFormParameters)
|
|
|
|
|
((IEditorFormParameters)fileFormat).OnSave.Invoke(fileFormat, new EventArgs());
|
|
|
|
|
|
|
|
|
|
MessageBox.Show($"Saved {fileFormat.FileName} to archive!");
|
2019-09-01 19:29:24 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-09-11 00:42:48 +02:00
|
|
|
|
STFileSaver.SaveFileFormat(fileFormat, fileFormat.FilePath);
|
2019-09-01 19:29:24 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LayoutEditor_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Control && e.Alt && e.KeyCode == Keys.S) // Ctrl + Alt + S Save As
|
|
|
|
|
{
|
|
|
|
|
e.SuppressKeyPress = true;
|
2019-09-11 00:42:48 +02:00
|
|
|
|
if (ActiveLayout != null)
|
|
|
|
|
SaveActiveFile(ActiveLayout.FileInfo, true);
|
|
|
|
|
if (ActiveAnimation != null)
|
|
|
|
|
SaveActiveFile(ActiveAnimation.FileInfo, true);
|
2019-09-01 19:29:24 +02:00
|
|
|
|
}
|
|
|
|
|
else if (e.Control && e.KeyCode == Keys.S) // Ctrl + S Save
|
|
|
|
|
{
|
|
|
|
|
e.SuppressKeyPress = true;
|
2019-09-11 00:42:48 +02:00
|
|
|
|
if (ActiveLayout != null)
|
|
|
|
|
SaveActiveFile(ActiveLayout.FileInfo, false);
|
|
|
|
|
if (ActiveAnimation != null)
|
|
|
|
|
SaveActiveFile(ActiveAnimation.FileInfo, false);
|
2019-09-01 19:29:24 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-06 00:14:15 +02:00
|
|
|
|
private void debugShading_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (debugShading.SelectedIndex < 0) return;
|
|
|
|
|
|
|
|
|
|
Runtime.LayoutEditor.Shading = (Runtime.LayoutEditor.DebugShading)debugShading.SelectedItem;
|
|
|
|
|
if (ActiveViewport != null)
|
|
|
|
|
ActiveViewport.UpdateViewport();
|
|
|
|
|
}
|
2019-09-07 01:12:39 +02:00
|
|
|
|
|
|
|
|
|
private void orthographicViewToolStripMenuItem_Click(object sender, EventArgs e) {
|
|
|
|
|
ToggleOrthMode();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void toolstripOrthoBtn_Click(object sender, EventArgs e) {
|
|
|
|
|
if (orthographicViewToolStripMenuItem.Checked)
|
|
|
|
|
orthographicViewToolStripMenuItem.Checked = false;
|
|
|
|
|
else
|
|
|
|
|
orthographicViewToolStripMenuItem.Checked = true;
|
2019-09-28 23:27:48 +02:00
|
|
|
|
|
2019-09-07 01:12:39 +02:00
|
|
|
|
ToggleOrthMode();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ToggleOrthMode()
|
|
|
|
|
{
|
|
|
|
|
if (ActiveViewport != null)
|
|
|
|
|
{
|
2019-09-28 23:27:48 +02:00
|
|
|
|
if (!orthographicViewToolStripMenuItem.Checked)
|
2019-09-07 01:12:39 +02:00
|
|
|
|
toolstripOrthoBtn.Image = BitmapExtension.GrayScale(FirstPlugin.Properties.Resources.OrthoView);
|
|
|
|
|
else
|
|
|
|
|
toolstripOrthoBtn.Image = FirstPlugin.Properties.Resources.OrthoView;
|
|
|
|
|
|
2019-09-28 23:27:48 +02:00
|
|
|
|
Runtime.LayoutEditor.UseOrthographicView = orthographicViewToolStripMenuItem.Checked;
|
2019-09-07 01:12:39 +02:00
|
|
|
|
ActiveViewport.ResetCamera();
|
|
|
|
|
ActiveViewport.UpdateViewport();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void toolStripButton1_Click(object sender, EventArgs e) {
|
2019-09-11 00:42:48 +02:00
|
|
|
|
if (ActiveLayout != null)
|
|
|
|
|
SaveActiveFile(ActiveLayout.FileInfo, false);
|
|
|
|
|
if (ActiveAnimation != null)
|
|
|
|
|
SaveActiveFile(ActiveAnimation.FileInfo, false);
|
2019-09-07 01:12:39 +02:00
|
|
|
|
}
|
2019-09-12 01:52:57 +02:00
|
|
|
|
|
|
|
|
|
private void displayPanesToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Runtime.LayoutEditor.DisplayNullPane = displayNullPanesToolStripMenuItem.Checked;
|
|
|
|
|
Runtime.LayoutEditor.DisplayBoundryPane = displayyBoundryPanesToolStripMenuItem.Checked;
|
|
|
|
|
Runtime.LayoutEditor.DisplayPicturePane = displayPicturePanesToolStripMenuItem.Checked;
|
|
|
|
|
Runtime.LayoutEditor.DisplayWindowPane = displayWindowPanesToolStripMenuItem.Checked;
|
2019-09-28 23:27:48 +02:00
|
|
|
|
Runtime.LayoutEditor.DisplayTextPane = displayTextPanesToolStripMenuItem.Checked;
|
2019-09-12 01:52:57 +02:00
|
|
|
|
|
2019-09-17 03:02:00 +02:00
|
|
|
|
ActiveViewport?.UpdateViewport();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void renderInGamePreviewToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Runtime.LayoutEditor.IsGamePreview = renderInGamePreviewToolStripMenuItem.Checked;
|
|
|
|
|
ActiveViewport?.UpdateViewport();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void displayGridToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Runtime.LayoutEditor.DisplayGrid = displayGridToolStripMenuItem.Checked;
|
|
|
|
|
ActiveViewport?.UpdateViewport();
|
2019-09-12 01:52:57 +02:00
|
|
|
|
}
|
2019-09-28 23:27:48 +02:00
|
|
|
|
|
|
|
|
|
private void resetToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
AnimationPanel?.Reset();
|
|
|
|
|
ActiveViewport?.UpdateViewport();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void showGameWindowToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (GamePreviewWindow == null || GamePreviewWindow.Disposing || GamePreviewWindow.IsDisposed)
|
|
|
|
|
{
|
|
|
|
|
GamePreviewWindow = new LayoutViewer(this,ActiveLayout, Textures);
|
|
|
|
|
GamePreviewWindow.GameWindow = true;
|
|
|
|
|
GamePreviewWindow.Dock = DockStyle.Fill;
|
|
|
|
|
STForm form = new STForm();
|
|
|
|
|
form.Text = "Game Preview";
|
|
|
|
|
form.AddControl(GamePreviewWindow);
|
2019-10-05 19:25:28 +02:00
|
|
|
|
form.Show(this);
|
2019-09-28 23:27:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LayoutEditor_FormClosed(object sender, FormClosedEventArgs e)
|
|
|
|
|
{
|
2019-09-29 02:24:20 +02:00
|
|
|
|
AnimationPanel?.OnControlClosing();
|
2019-09-28 23:27:48 +02:00
|
|
|
|
GamePreviewWindow?.OnControlClosing();
|
|
|
|
|
GamePreviewWindow?.Dispose();
|
2019-10-14 03:02:39 +02:00
|
|
|
|
LayoutPaneEditor?.Close();
|
|
|
|
|
LayoutAnimEditor?.Close();
|
|
|
|
|
LayoutHierarchy?.Close();
|
2019-09-28 23:27:48 +02:00
|
|
|
|
}
|
2019-10-05 19:25:28 +02:00
|
|
|
|
|
|
|
|
|
private void undoToolStripMenuItem_Click(object sender, EventArgs e) {
|
|
|
|
|
ActiveViewport?.UndoManger.Undo();
|
|
|
|
|
ActiveViewport?.UpdateViewport();
|
|
|
|
|
|
|
|
|
|
UpdateUndo();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void redoToolStripMenuItem_Click(object sender, EventArgs e) {
|
|
|
|
|
ActiveViewport?.UndoManger.Redo();
|
|
|
|
|
ActiveViewport?.UpdateViewport();
|
|
|
|
|
|
|
|
|
|
UpdateUndo();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateUndo()
|
|
|
|
|
{
|
|
|
|
|
if (ActiveViewport == null)
|
|
|
|
|
return;
|
|
|
|
|
|
2019-10-14 03:02:39 +02:00
|
|
|
|
RefreshEditors();
|
|
|
|
|
|
2019-10-05 19:25:28 +02:00
|
|
|
|
redoToolStripMenuItem.Enabled = false;
|
|
|
|
|
undoToolStripMenuItem.Enabled = false;
|
|
|
|
|
|
|
|
|
|
if (ActiveViewport.UndoManger.HasUndo)
|
|
|
|
|
undoToolStripMenuItem.Enabled = true;
|
|
|
|
|
if (ActiveViewport.UndoManger.HasRedo)
|
|
|
|
|
redoToolStripMenuItem.Enabled = true;
|
|
|
|
|
}
|
2019-10-05 20:05:37 +02:00
|
|
|
|
|
2019-10-14 03:02:39 +02:00
|
|
|
|
private void OnPanePropertyChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ActiveViewport?.UpdateViewport();
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-05 20:05:37 +02:00
|
|
|
|
private void viewPartsAsNullPanesToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Runtime.LayoutEditor.PartsAsNullPanes = viewPartsAsNullPanesToolStripMenuItem.Checked;
|
|
|
|
|
ActiveViewport?.UpdateViewport();
|
|
|
|
|
}
|
2019-10-06 03:15:19 +02:00
|
|
|
|
|
|
|
|
|
#region Pane Adding
|
|
|
|
|
|
2019-10-14 03:02:39 +02:00
|
|
|
|
public BasePane AddNewTextPane()
|
|
|
|
|
{
|
|
|
|
|
NewTextboxDialog newTextDlg = new NewTextboxDialog();
|
|
|
|
|
newTextDlg.LoadFonts(ActiveLayout.Fonts);
|
|
|
|
|
if (newTextDlg.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
string font = newTextDlg.GetFont();
|
|
|
|
|
int fontIndex = ActiveLayout.AddFont(font);
|
|
|
|
|
string text = newTextDlg.GetText();
|
|
|
|
|
|
|
|
|
|
BasePane pane = null;
|
|
|
|
|
if (ActiveLayout is BFLYT.Header)
|
|
|
|
|
pane = new BFLYT.TXT1((BFLYT.Header)ActiveLayout, RenamePane("T_text"));
|
|
|
|
|
|
|
|
|
|
if (pane != null)
|
|
|
|
|
{
|
|
|
|
|
((ITextPane)pane).FontIndex = (ushort)fontIndex;
|
|
|
|
|
((ITextPane)pane).FontName = font;
|
|
|
|
|
((ITextPane)pane).Text = text;
|
|
|
|
|
|
|
|
|
|
pane.NodeWrapper = LayoutHierarchy.CreatePaneWrapper(pane);
|
|
|
|
|
((ITextPane)pane).MaterialIndex = (ushort)ActiveLayout.AddMaterial(((ITextPane)pane).Material);
|
|
|
|
|
ActiveLayout.AddPane(pane, ActiveLayout.RootPane);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pane;
|
|
|
|
|
}
|
|
|
|
|
else return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BasePane AddNewBoundryPane()
|
|
|
|
|
{
|
|
|
|
|
BasePane pane = null;
|
|
|
|
|
if (ActiveLayout is BFLYT.Header)
|
|
|
|
|
pane = new BFLYT.BND1((BFLYT.Header)ActiveLayout, RenamePane("B_bound"));
|
|
|
|
|
|
|
|
|
|
if (pane != null)
|
|
|
|
|
{
|
|
|
|
|
pane.NodeWrapper = LayoutHierarchy.CreatePaneWrapper(pane);
|
|
|
|
|
ActiveLayout.AddPane(pane, ActiveLayout.RootPane);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pane;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BasePane AddNewWindowPane()
|
|
|
|
|
{
|
|
|
|
|
BasePane pane = null;
|
|
|
|
|
if (ActiveLayout is BFLYT.Header)
|
|
|
|
|
pane = new BFLYT.WND1((BFLYT.Header)ActiveLayout, RenamePane("W_window"));
|
|
|
|
|
|
|
|
|
|
if (pane != null)
|
|
|
|
|
{
|
|
|
|
|
pane.NodeWrapper = LayoutHierarchy.CreatePaneWrapper(pane);
|
|
|
|
|
ActiveLayout.AddPane(pane, ActiveLayout.RootPane);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pane;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BasePane AddNewPicturePane()
|
|
|
|
|
{
|
|
|
|
|
BasePane pane = null;
|
|
|
|
|
if (ActiveLayout is BFLYT.Header)
|
|
|
|
|
pane = new BFLYT.PIC1((BFLYT.Header)ActiveLayout, RenamePane("P_pict"));
|
|
|
|
|
|
|
|
|
|
if (pane != null)
|
|
|
|
|
{
|
|
|
|
|
pane.NodeWrapper = LayoutHierarchy.CreatePaneWrapper(pane);
|
|
|
|
|
((IPicturePane)pane).MaterialIndex = (ushort)ActiveLayout.AddMaterial(((IPicturePane)pane).Material);
|
|
|
|
|
ActiveLayout.AddPane(pane, ActiveLayout.RootPane);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pane;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-06 03:15:19 +02:00
|
|
|
|
public BasePane AddNewNullPane()
|
|
|
|
|
{
|
|
|
|
|
BasePane pane = null;
|
|
|
|
|
if (ActiveLayout is BFLYT.Header)
|
2019-10-14 03:02:39 +02:00
|
|
|
|
pane = new BFLYT.PAN1((BFLYT.Header)ActiveLayout, RenamePane("N_null"));
|
2019-10-06 03:15:19 +02:00
|
|
|
|
|
|
|
|
|
if (pane != null)
|
|
|
|
|
{
|
|
|
|
|
pane.NodeWrapper = LayoutHierarchy.CreatePaneWrapper(pane);
|
|
|
|
|
ActiveLayout.AddPane(pane, ActiveLayout.RootPane);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pane;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 03:02:39 +02:00
|
|
|
|
private string RenamePane(string name)
|
|
|
|
|
{
|
|
|
|
|
List<string> names = ActiveLayout.PaneLookup.Values.ToList().Select(o => o.Name).ToList();
|
|
|
|
|
return Utils.RenameDuplicateString(names, name); ;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-06 03:15:19 +02:00
|
|
|
|
#endregion
|
2019-08-01 23:47:35 +02:00
|
|
|
|
}
|
|
|
|
|
}
|