120 lines
4.4 KiB
C#
120 lines
4.4 KiB
C#
using Thousandto.Code.Logic;
|
|
using Thousandto.SkillEditor;
|
|
using Thousandto.SkillEditor.DIY;
|
|
using Thousandto.SkillEditor.Support;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace Thousandto.SkillEditor.DIY
|
|
{
|
|
//技能创建和改名界面
|
|
public class SkillCreateAndChangeEditor : EditorWindow
|
|
{
|
|
public static void OpenCreate(SkillEditor editor)
|
|
{
|
|
var win = (SkillCreateAndChangeEditor)EditorWindow.GetWindow(typeof(SkillCreateAndChangeEditor), true);
|
|
win.minSize = new Vector2(200, 200);
|
|
win.maxSize = new Vector2(200, 200);
|
|
_isCreate = true;
|
|
_skillEditor = editor;
|
|
_isOpen = true;
|
|
_inputName = "skill_";
|
|
win.Show();
|
|
}
|
|
|
|
public static void OpenChange(SkillEditor editor, SkillVisualInfo skill)
|
|
{
|
|
_curChangeNameSkill = skill;
|
|
var win = (SkillCreateAndChangeEditor)EditorWindow.GetWindow(typeof(SkillCreateAndChangeEditor), true);
|
|
win.minSize = new Vector2(200, 200);
|
|
win.maxSize = new Vector2(200, 200);
|
|
_isCreate = false;
|
|
_skillEditor = editor;
|
|
_isOpen = true;
|
|
_inputName = _curChangeNameSkill.Name;
|
|
win.Show();
|
|
}
|
|
|
|
public static void Hide()
|
|
{
|
|
if (!_isOpen)
|
|
return;
|
|
var win = (SkillCreateAndChangeEditor)EditorWindow.GetWindow(typeof(SkillCreateAndChangeEditor), true);
|
|
win.Close();
|
|
_isOpen = false;
|
|
_curChangeNameSkill = null;
|
|
}
|
|
|
|
private void OnGUI()
|
|
{
|
|
Focus();
|
|
if(_isCreate)
|
|
{
|
|
EditorGUILayout.BeginVertical();
|
|
GUILayout.Label("请输入新技能名字");
|
|
_inputName = EditorGUILayout.TextField(_inputName);
|
|
if(GUILayout.Button("确定"))
|
|
{
|
|
if(!string.IsNullOrEmpty(_inputName) && _inputName.IndexOf(';') < 0 && _inputName.IndexOf('*') < 0 && _inputName.IndexOf(',') < 0)
|
|
{
|
|
if(_skillEditor.CreateNewSkill(_inputName))
|
|
{
|
|
Close();
|
|
}
|
|
else
|
|
{
|
|
EditorUtility.DisplayDialog("提示", "创建失败,技能重名", "确定");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
EditorUtility.DisplayDialog("提示", "技能名字中包含了限制字符", "确定");
|
|
}
|
|
}
|
|
EditorGUILayout.EndVertical();
|
|
}
|
|
else
|
|
{
|
|
EditorGUILayout.BeginVertical();
|
|
GUILayout.Label("请输入新技能名字");
|
|
_inputName = EditorGUILayout.TextField(_inputName);
|
|
if (GUILayout.Button("确定"))
|
|
{
|
|
if(_curChangeNameSkill.Name == _inputName)
|
|
{
|
|
EditorUtility.DisplayDialog("提示", "未检测到修改", "确定");
|
|
}
|
|
else if (!string.IsNullOrEmpty(_inputName) && _inputName.IndexOf(';') < 0 && _inputName.IndexOf('*') < 0 && _inputName.IndexOf(',') < 0)
|
|
{
|
|
if (_skillEditor.ChangeSkillName(_curChangeNameSkill, _inputName))
|
|
{
|
|
Close();
|
|
}
|
|
else
|
|
{
|
|
EditorUtility.DisplayDialog("提示", "修改失败,技能重名", "确定");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
EditorUtility.DisplayDialog("提示", "技能名字中包含了限制字符", "确定");
|
|
}
|
|
}
|
|
EditorGUILayout.EndVertical();
|
|
}
|
|
}
|
|
|
|
private static bool _isCreate = false;
|
|
private static string _inputName = string.Empty;
|
|
private static SkillEditor _skillEditor = null;
|
|
private static bool _isOpen = false;
|
|
private static SkillVisualInfo _curChangeNameSkill = null;
|
|
}
|
|
}
|