using System;
using System.Runtime.CompilerServices;
using BansheeEngine;
namespace BansheeEditor
{
///
/// Contains all supported external code editors
///
public enum CodeEditorType // Note: Must match C++ CodeEditorType enum
{
VS2008,
VS2010,
VS2012,
VS2013,
VS2015
}
///
/// Handles interaction with the external application used for editing scripts.
///
public static class CodeEditor
{
///
/// Contains resource types that are relevant to the code editor.
///
public static readonly ResourceType[] CodeTypes =
{
ResourceType.ScriptCode,
ResourceType.PlainText,
ResourceType.Shader,
ResourceType.ShaderInclude
};
private static bool isSolutionDirty;
///
/// Currently active code editor.
///
public static CodeEditorType ActiveEditor
{
set { Internal_SetActiveEditor(value); }
}
///
/// Checks if the code editor's solution requires updating.
///
internal static bool IsSolutionDirty
{
get { return isSolutionDirty; }
}
///
/// Returns a list of all code editors available on this machine.
///
public static CodeEditorType[] AvailableEditors
{
get { return Internal_GetAvailableEditors(); }
}
///
/// Opens a script file in the currently active code editor.
///
/// Path to the script file to open, either absolute or relative to the project resources folder.
/// Line in the file to focus the editor on.
public static void OpenFile(string path, UInt32 line)
{
if (IsSolutionDirty)
SyncSolution();
Internal_OpenFile(path, line);
}
///
/// Generates a solution file for the active editor, which includes all scripts in the project.
///
public static void SyncSolution()
{
Internal_SyncSolution();
isSolutionDirty = false;
}
///
/// Notifies the code editor that code file structure has changed and the solution needs to be rebuilt.
///
internal static void MarkSolutionDirty()
{
isSolutionDirty = true;
}
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern void Internal_SetActiveEditor(CodeEditorType type);
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern CodeEditorType[] Internal_GetAvailableEditors();
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern void Internal_OpenFile(string path, UInt32 line);
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern void Internal_SyncSolution();
}
}