2019-05-11 17:10:39 +00: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;
|
|
|
|
|
using Switch_Toolbox.Library.Forms;
|
|
|
|
|
using Switch_Toolbox.Library;
|
|
|
|
|
using GL_EditorFramework.Interfaces;
|
|
|
|
|
using GL_EditorFramework.EditorDrawables;
|
|
|
|
|
|
|
|
|
|
namespace FirstPlugin.Forms
|
|
|
|
|
{
|
|
|
|
|
public partial class BcresEditor : STUserControl, IViewportContainer
|
|
|
|
|
{
|
|
|
|
|
private bool _displayViewport = true;
|
|
|
|
|
|
|
|
|
|
public bool DisplayViewport
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _displayViewport;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_displayViewport = value;
|
|
|
|
|
SetupViewport();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetupViewport()
|
|
|
|
|
{
|
|
|
|
|
if (DisplayViewport == true && Runtime.UseOpenGL)
|
|
|
|
|
{
|
|
|
|
|
stPanel3.Controls.Add(viewport);
|
|
|
|
|
splitContainer1.Panel1Collapsed = false;
|
|
|
|
|
toggleViewportToolStripBtn.Image = Properties.Resources.ViewportIcon;
|
|
|
|
|
|
|
|
|
|
if (viewport != null)
|
|
|
|
|
OnLoadedTab();
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-06-06 19:40:32 +00:00
|
|
|
|
viewport = new Viewport(ObjectEditor.GetDrawableContainers());
|
2019-05-11 17:10:39 +00:00
|
|
|
|
viewport.Dock = DockStyle.Fill;
|
|
|
|
|
OnLoadedTab();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
stPanel3.Controls.Clear();
|
|
|
|
|
splitContainer1.Panel1Collapsed = true;
|
|
|
|
|
toggleViewportToolStripBtn.Image = Properties.Resources.ViewportIconDisable;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Viewport viewport
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (!Runtime.UseOpenGL || !DisplayViewport)
|
|
|
|
|
return null;
|
|
|
|
|
|
2019-07-11 21:22:59 +00:00
|
|
|
|
var editor = LibraryGUI.GetObjectEditor();
|
2019-05-11 17:10:39 +00:00
|
|
|
|
return editor.GetViewport();
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
2019-07-11 21:22:59 +00:00
|
|
|
|
var editor = LibraryGUI.GetObjectEditor();
|
2019-05-11 17:10:39 +00:00
|
|
|
|
editor.LoadViewport(value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BcresEditor(bool HasModels)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
//Always create an instance of the viewport unless opengl is disabled
|
|
|
|
|
if (viewport == null && Runtime.UseOpenGL)
|
|
|
|
|
{
|
2019-06-06 19:40:32 +00:00
|
|
|
|
viewport = new Viewport(ObjectEditor.GetDrawableContainers());
|
2019-05-11 17:10:39 +00:00
|
|
|
|
viewport.Dock = DockStyle.Fill;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//If the option is enabled by settings, and it has models display the viewport
|
|
|
|
|
if (Runtime.UseOpenGL && Runtime.DisplayViewport && HasModels)
|
|
|
|
|
{
|
|
|
|
|
stPanel3.Controls.Add(viewport);
|
|
|
|
|
DisplayViewport = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DisplayViewport = false;
|
|
|
|
|
splitContainer1.Panel1Collapsed = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public UserControl GetActiveEditor(Type type)
|
|
|
|
|
{
|
|
|
|
|
foreach (var ctrl in splitContainer1.Panel2.Controls)
|
|
|
|
|
{
|
|
|
|
|
if (type == null)
|
|
|
|
|
{
|
|
|
|
|
return (UserControl)ctrl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ctrl.GetType() == type)
|
|
|
|
|
{
|
|
|
|
|
return (UserControl)ctrl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void LoadEditor(UserControl Control)
|
|
|
|
|
{
|
|
|
|
|
Control.Dock = DockStyle.Fill;
|
|
|
|
|
|
|
|
|
|
splitContainer1.Panel2.Controls.Clear();
|
|
|
|
|
splitContainer1.Panel2.Controls.Add(Control);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public AnimationPanel GetAnimationPanel() => null;
|
|
|
|
|
|
|
|
|
|
public Viewport GetViewport() => viewport;
|
|
|
|
|
|
|
|
|
|
public void UpdateViewport()
|
|
|
|
|
{
|
|
|
|
|
if (viewport != null && Runtime.UseOpenGL && Runtime.DisplayViewport)
|
|
|
|
|
viewport.UpdateViewport();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public bool IsLoaded = false;
|
2019-06-06 19:40:32 +00:00
|
|
|
|
private BCRES ActiveBcres;
|
2019-05-11 17:10:39 +00:00
|
|
|
|
|
2019-06-06 19:40:32 +00:00
|
|
|
|
public void LoadViewport(BCRES bcres, DrawableContainer ActiveDrawable, List<ToolStripMenuItem> customContextMenus = null)
|
2019-05-11 17:10:39 +00:00
|
|
|
|
{
|
2019-06-06 19:40:32 +00:00
|
|
|
|
ActiveBcres = bcres;
|
2019-05-11 17:10:39 +00:00
|
|
|
|
|
|
|
|
|
if (!Runtime.UseOpenGL || !DisplayViewport)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (customContextMenus != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var menu in customContextMenus)
|
|
|
|
|
viewport.LoadCustomMenuItem(menu);
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-06 19:40:32 +00:00
|
|
|
|
viewport.ReloadDrawables(ActiveDrawable);
|
2019-05-11 17:10:39 +00:00
|
|
|
|
|
2019-06-06 19:40:32 +00:00
|
|
|
|
OnLoadedTab();
|
2019-05-11 17:10:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnControlClosing()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnLoadedTab()
|
|
|
|
|
{
|
|
|
|
|
//If a model was loaded we don't need to load the drawables again
|
2019-06-06 19:40:32 +00:00
|
|
|
|
if (IsLoaded ||!Runtime.UseOpenGL || !Runtime.DisplayViewport)
|
2019-05-11 17:10:39 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
viewport.LoadObjects();
|
|
|
|
|
|
|
|
|
|
IsLoaded = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void stTabControl1_TabIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void stTabControl1_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool IsTimelineVisable = true;
|
|
|
|
|
int controlHeight = 0;
|
|
|
|
|
private void stPanel1_DoubleClick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void toggleViewportToolStripBtn_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Runtime.DisplayViewport)
|
|
|
|
|
{
|
|
|
|
|
Runtime.DisplayViewport = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Runtime.DisplayViewport = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DisplayViewport = Runtime.DisplayViewport;
|
|
|
|
|
Config.Save();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|