321 lines
13 KiB
C#
321 lines
13 KiB
C#
|
//============= Copyright (c) Ludic GmbH, All rights reserved. ==============
|
|||
|
//
|
|||
|
// Purpose: Part of the My Behaviour Tree Code
|
|||
|
//
|
|||
|
//=============================================================================
|
|||
|
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
#if UNITY_EDITOR
|
|||
|
using UnityEditor;
|
|||
|
#endif
|
|||
|
using System.IO;
|
|||
|
using System;
|
|||
|
using System.Runtime.Serialization.Formatters.Binary;
|
|||
|
|
|||
|
namespace MyBT {
|
|||
|
|
|||
|
public static class MyBtResources {
|
|||
|
public static float defaultGuiHeight = 16f;
|
|||
|
public static float defaultGuiIconWidth = 14;
|
|||
|
|
|||
|
|
|||
|
public static readonly Dictionary<NodeState, string> NodeStateLabels = new Dictionary<NodeState, string>() {
|
|||
|
{ NodeState.FirstRun, "FirR" },
|
|||
|
{ NodeState.Running, "Run" },
|
|||
|
{ NodeState.Aborting, "Abrt" },
|
|||
|
{ NodeState.NotRunning, "NotR" },
|
|||
|
};
|
|||
|
|
|||
|
public static readonly Dictionary<NodeResult, string> NodeResultLabels = new Dictionary<NodeResult, string>() {
|
|||
|
{ NodeResult.Undefined, "Und"},
|
|||
|
{ NodeResult.Continue, "Cnt"},
|
|||
|
{ NodeResult.Succeeded, "Suc"},
|
|||
|
{ NodeResult.Failed, "Fal"},
|
|||
|
{ NodeResult.Error, "Err"},
|
|||
|
};
|
|||
|
|
|||
|
public static readonly Dictionary<NodeState, string> NodeStateDescriptions = new Dictionary<NodeState, string>() {
|
|||
|
{ NodeState.FirstRun, "FirstRun" },
|
|||
|
{ NodeState.Running, "Running" },
|
|||
|
{ NodeState.Aborting, "Aborting" },
|
|||
|
{ NodeState.NotRunning, "NotRunning" },
|
|||
|
};
|
|||
|
|
|||
|
public static readonly Dictionary<NodeResult, string> NodeResultDescriptions = new Dictionary<NodeResult, string>() {
|
|||
|
{ NodeResult.Undefined, "Undefined"},
|
|||
|
{ NodeResult.Continue, "Continue"},
|
|||
|
{ NodeResult.Succeeded, "Succeeded"},
|
|||
|
{ NodeResult.Failed, "Failed"},
|
|||
|
{ NodeResult.Error, "Error"},
|
|||
|
};
|
|||
|
|
|||
|
public static readonly Dictionary<NodeState, Color> NodeStateColors = new Dictionary<NodeState, Color>() {
|
|||
|
{ NodeState.FirstRun, new Color(0, 1.0f, 0) }, // light green
|
|||
|
{ NodeState.Running, new Color(0, 0.5f, 0.5f) }, // cyan
|
|||
|
{ NodeState.Aborting, new Color(0.5f, 0.5f, 0) }, // yellow
|
|||
|
{ NodeState.NotRunning, new Color(1.0f, 0.0f, 0) }, // reddish
|
|||
|
};
|
|||
|
|
|||
|
public static readonly Dictionary<NodeResult, Color> NodeResultColors = new Dictionary<NodeResult, Color>() {
|
|||
|
{ NodeResult.Undefined, Color.gray},
|
|||
|
{ NodeResult.Continue, Color.green },
|
|||
|
{ NodeResult.Succeeded, Color.cyan },
|
|||
|
{ NodeResult.Failed, Color.magenta },
|
|||
|
{ NodeResult.Error, new Color(0.5f, 0, 0.5f) },
|
|||
|
};
|
|||
|
#if UNITY_EDITOR
|
|||
|
public static Texture2D alertIcon = EditorGUIUtility.Load("MyBT/Alert16.png") as Texture2D;
|
|||
|
public static Texture2D arrowIcon = EditorGUIUtility.Load("MyBT/Arrow16.png") as Texture2D;
|
|||
|
public static Texture2D breakIcon = EditorGUIUtility.Load("MyBT/Break16.png") as Texture2D;
|
|||
|
public static Texture2D bugIcon = EditorGUIUtility.Load("MyBT/Bug16.png") as Texture2D;
|
|||
|
|
|||
|
public static Texture2D continueIcon = EditorGUIUtility.Load("MyBT/Continue16.png") as Texture2D;
|
|||
|
public static Texture2D cubeIcon = EditorGUIUtility.Load("MyBT/Cube16.png") as Texture2D;
|
|||
|
public static Texture2D falseIcon = EditorGUIUtility.Load("MyBT/False16.png") as Texture2D;
|
|||
|
public static Texture2D fastforwardIcon = EditorGUIUtility.Load("MyBT/FastForward16.png") as Texture2D;
|
|||
|
|
|||
|
public static Texture2D oneIcon = EditorGUIUtility.Load("MyBT/One16.png") as Texture2D;
|
|||
|
public static Texture2D pauseIcon = EditorGUIUtility.Load("MyBT/Pause16.png") as Texture2D;
|
|||
|
public static Texture2D playIcon = EditorGUIUtility.Load("MyBT/Play16.png") as Texture2D;
|
|||
|
public static Texture2D repeatIcon = EditorGUIUtility.Load("MyBT/Repeat16.png") as Texture2D;
|
|||
|
|
|||
|
public static Texture2D sleepIcon = EditorGUIUtility.Load("MyBT/Sleep16.png") as Texture2D;
|
|||
|
public static Texture2D stopIcon = EditorGUIUtility.Load("MyBT/Stop16.png") as Texture2D;
|
|||
|
public static Texture2D trueIcon = EditorGUIUtility.Load("MyBT/True16.png") as Texture2D;
|
|||
|
public static Texture2D zeroIcon = EditorGUIUtility.Load("MyBT/Zero16.png") as Texture2D;
|
|||
|
|
|||
|
public static Texture2D emptyIcon = EditorGUIUtility.Load("MyBT/Empty16.png") as Texture2D;
|
|||
|
|
|||
|
#endif
|
|||
|
|
|||
|
#if UNITY_EDITOR
|
|||
|
public static readonly Dictionary<NodeState, Texture2D> NodeStateIcons = new Dictionary<NodeState, Texture2D>() {
|
|||
|
{ NodeState.NotRunning, pauseIcon },
|
|||
|
{ NodeState.FirstRun, continueIcon },
|
|||
|
{ NodeState.Running, playIcon },
|
|||
|
{ NodeState.Aborting, breakIcon },
|
|||
|
};
|
|||
|
|
|||
|
public static readonly Dictionary<NodeResult, Texture2D> NodeResultIcons = new Dictionary<NodeResult, Texture2D>() {
|
|||
|
{ NodeResult.Undefined, emptyIcon},
|
|||
|
{ NodeResult.Continue, repeatIcon },
|
|||
|
{ NodeResult.Succeeded, trueIcon },
|
|||
|
{ NodeResult.Failed, falseIcon },
|
|||
|
{ NodeResult.Error, bugIcon },
|
|||
|
};
|
|||
|
|
|||
|
public static readonly Dictionary<NodeState, string> NodeStateEditorGuiLayout = new Dictionary<NodeState, string>() {
|
|||
|
{ NodeState.NotRunning, "NodeStateNotRunning" },
|
|||
|
{ NodeState.FirstRun, "NodeStateFirstRun" },
|
|||
|
{ NodeState.Running, "NodeStateRunning" },
|
|||
|
{ NodeState.Aborting, "NodeStateAborting" },
|
|||
|
};
|
|||
|
|
|||
|
static GUISkin _myBtGuiSkin;
|
|||
|
public static GUISkin myBtGuiSkin {
|
|||
|
get {
|
|||
|
if (_myBtGuiSkin == null) {
|
|||
|
_myBtGuiSkin = (GUISkin)AssetDatabase.LoadAssetAtPath("Assets/Editor Default Resources/MyBT/MyBTSkin.guiskin", typeof(GUISkin));
|
|||
|
}
|
|||
|
return _myBtGuiSkin;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public static readonly Dictionary<NodeResult, string> NodeResultEditorGuiLayoutName = new Dictionary<NodeResult, string>() {
|
|||
|
{ NodeResult.Undefined, "NodeResultUndefined"},
|
|||
|
{ NodeResult.Continue, "NodeResultContinue" },
|
|||
|
{ NodeResult.Succeeded, "NodeResultSucceeded" },
|
|||
|
{ NodeResult.Failed, "NodeResultFailed" },
|
|||
|
{ NodeResult.Error, "NodeResultError" },
|
|||
|
};
|
|||
|
|
|||
|
static GUIStyle _nodeResultUndefinedGuiStyle;
|
|||
|
public static GUIStyle nodeResultUndefinedGuiStyle {
|
|||
|
get {
|
|||
|
if (_nodeResultUndefinedGuiStyle == null) {
|
|||
|
_nodeResultUndefinedGuiStyle = myBtGuiSkin.GetStyle("NodeResultUndefined");
|
|||
|
}
|
|||
|
return _nodeResultUndefinedGuiStyle;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
static GUIStyle _nodeResultContinueGuiStyle;
|
|||
|
public static GUIStyle nodeResultContinueGuiStyle {
|
|||
|
get {
|
|||
|
if (_nodeResultContinueGuiStyle == null) {
|
|||
|
_nodeResultContinueGuiStyle = myBtGuiSkin.GetStyle("NodeResultContinue");
|
|||
|
}
|
|||
|
return _nodeResultContinueGuiStyle;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
static GUIStyle _nodeResultSucceededGuiStyle;
|
|||
|
public static GUIStyle nodeResultSucceededGuiStyle {
|
|||
|
get {
|
|||
|
if (_nodeResultSucceededGuiStyle == null) {
|
|||
|
_nodeResultSucceededGuiStyle = myBtGuiSkin.GetStyle("NodeResultSucceeded");
|
|||
|
}
|
|||
|
return _nodeResultSucceededGuiStyle;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
static GUIStyle _nodeResultFailedGuiStyle;
|
|||
|
public static GUIStyle nodeResultFailedGuiStyle {
|
|||
|
get {
|
|||
|
if (_nodeResultFailedGuiStyle == null) {
|
|||
|
_nodeResultFailedGuiStyle = myBtGuiSkin.GetStyle("NodeResultFailed");
|
|||
|
}
|
|||
|
return _nodeResultFailedGuiStyle;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
static GUIStyle _nodeResultErrorGuiStyle;
|
|||
|
public static GUIStyle nodeResultErrorGuiStyle {
|
|||
|
get {
|
|||
|
if (_nodeResultErrorGuiStyle == null) {
|
|||
|
_nodeResultErrorGuiStyle = myBtGuiSkin.GetStyle("NodeResultError");
|
|||
|
}
|
|||
|
return _nodeResultErrorGuiStyle;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
static GUIStyle _nodeUninitializedState;
|
|||
|
public static GUIStyle nodeUninitializedState {
|
|||
|
get {
|
|||
|
if (_nodeUninitializedState == null) {
|
|||
|
_nodeUninitializedState = myBtGuiSkin.GetStyle("UninitializedState");
|
|||
|
}
|
|||
|
return _nodeUninitializedState;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public static readonly Dictionary<NodeResult, GUIStyle> NodeResultGuiStyle = new Dictionary<NodeResult, GUIStyle>() {
|
|||
|
{ NodeResult.Undefined, nodeResultUndefinedGuiStyle},
|
|||
|
{ NodeResult.Continue, nodeResultContinueGuiStyle},
|
|||
|
{ NodeResult.Succeeded, nodeResultSucceededGuiStyle},
|
|||
|
{ NodeResult.Failed, nodeResultFailedGuiStyle},
|
|||
|
{ NodeResult.Error, nodeResultErrorGuiStyle },
|
|||
|
};
|
|||
|
|
|||
|
public static readonly Dictionary<NodeState, string> NodeStateEditorGuiLayoutName = new Dictionary<NodeState, string>() {
|
|||
|
{ NodeState.NotRunning, "NodeStateNotRunning" },
|
|||
|
{ NodeState.FirstRun, "NodeStateFirstRun" },
|
|||
|
{ NodeState.Running, "NodeStateRunning" },
|
|||
|
{ NodeState.Aborting, "NodeStateAborting" },
|
|||
|
};
|
|||
|
|
|||
|
|
|||
|
static GUIStyle _nodeStateNotRunningGuiStyle;
|
|||
|
public static GUIStyle nodeStateNotRunningGuiStyle {
|
|||
|
get {
|
|||
|
if (_nodeStateNotRunningGuiStyle == null) {
|
|||
|
_nodeStateNotRunningGuiStyle = myBtGuiSkin.GetStyle("NodeStateNotRunning");
|
|||
|
}
|
|||
|
return _nodeStateNotRunningGuiStyle;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
static GUIStyle _nodeStateFirstRunGuiStyle;
|
|||
|
public static GUIStyle nodeStateFirstRunGuiStyle {
|
|||
|
get {
|
|||
|
if (_nodeStateFirstRunGuiStyle == null) {
|
|||
|
_nodeStateFirstRunGuiStyle = myBtGuiSkin.GetStyle("NodeStateFirstRun");
|
|||
|
}
|
|||
|
return _nodeStateFirstRunGuiStyle;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
static GUIStyle _nodeStateRunningGuiStyle;
|
|||
|
public static GUIStyle nodeStateRunningGuiStyle {
|
|||
|
get {
|
|||
|
if (_nodeStateRunningGuiStyle == null) {
|
|||
|
_nodeStateRunningGuiStyle = myBtGuiSkin.GetStyle("NodeStateRunning");
|
|||
|
}
|
|||
|
return _nodeStateRunningGuiStyle;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
static GUIStyle _nodeStateAbortingGuiStyle;
|
|||
|
public static GUIStyle nodeStateAbortingGuiStyle {
|
|||
|
get {
|
|||
|
if (_nodeStateAbortingGuiStyle == null) {
|
|||
|
_nodeStateAbortingGuiStyle = myBtGuiSkin.GetStyle("NodeStateAborting");
|
|||
|
}
|
|||
|
return _nodeStateAbortingGuiStyle;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public static readonly Dictionary<NodeState, GUIStyle> NodeStateGuiStyle = new Dictionary<NodeState, GUIStyle>() {
|
|||
|
{ NodeState.NotRunning, nodeStateNotRunningGuiStyle},
|
|||
|
{ NodeState.FirstRun, nodeStateFirstRunGuiStyle},
|
|||
|
{ NodeState.Running, nodeStateRunningGuiStyle},
|
|||
|
{ NodeState.Aborting, nodeStateAbortingGuiStyle},
|
|||
|
};
|
|||
|
|
|||
|
static GUIStyle _logStringToggleGuiStyle;
|
|||
|
public static GUIStyle logStringToggleGuiStyle {
|
|||
|
get {
|
|||
|
if (_logStringToggleGuiStyle == null) {
|
|||
|
_logStringToggleGuiStyle = myBtGuiSkin.GetStyle("LogStringToggle");
|
|||
|
}
|
|||
|
return _logStringToggleGuiStyle;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
static GUIStyle _popoutToggleGuiStyle;
|
|||
|
public static GUIStyle popoutToggleGuiStyle {
|
|||
|
get {
|
|||
|
if (_popoutToggleGuiStyle == null) {
|
|||
|
_popoutToggleGuiStyle = myBtGuiSkin.GetStyle("PopoutToggle");
|
|||
|
}
|
|||
|
return _popoutToggleGuiStyle;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
static GUIStyle _emptyGuiStyle;
|
|||
|
public static GUIStyle emptyGuiStyle {
|
|||
|
get {
|
|||
|
if (_emptyGuiStyle == null) {
|
|||
|
_emptyGuiStyle = myBtGuiSkin.GetStyle("Empty");
|
|||
|
}
|
|||
|
return _emptyGuiStyle;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
static GUIStyle _alertToggleGuiStyle;
|
|||
|
public static GUIStyle alertToggleGuiStyle {
|
|||
|
get {
|
|||
|
if (_alertToggleGuiStyle == null) {
|
|||
|
_alertToggleGuiStyle = myBtGuiSkin.GetStyle("AlertToggle");
|
|||
|
}
|
|||
|
return _alertToggleGuiStyle;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
static GUIStyle _debugToggleGuiStyle;
|
|||
|
public static GUIStyle debugToggleGuiStyle {
|
|||
|
get {
|
|||
|
if (_debugToggleGuiStyle == null) {
|
|||
|
_debugToggleGuiStyle = myBtGuiSkin.GetStyle("DebugToggle");
|
|||
|
}
|
|||
|
return _debugToggleGuiStyle;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
static GUIStyle _helpButtonGuiStyle;
|
|||
|
public static GUIStyle helpButtonGuiStyle {
|
|||
|
get {
|
|||
|
if (_helpButtonGuiStyle == null) {
|
|||
|
_helpButtonGuiStyle = myBtGuiSkin.GetStyle("HelpButton");
|
|||
|
}
|
|||
|
return _helpButtonGuiStyle;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public static Texture2D debugIcon = EditorGUIUtility.Load("MyBT/Bug16.png") as Texture2D;
|
|||
|
#endif
|
|||
|
}
|
|||
|
}
|