97 lines
3.0 KiB
C#
97 lines
3.0 KiB
C#
/*
|
|
* @Author: 白哉
|
|
* @Description: 成就 编辑器
|
|
* @Date: 2025年04月22日 星期二 15:04:14
|
|
* @Modify:
|
|
*/
|
|
|
|
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using Logic.Achievement;
|
|
using Logic.HeroTask;
|
|
using Logic.Multilingual;
|
|
using RuntimeData;
|
|
using TH1_Logic.HeroTask;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
|
|
namespace Logic.Editor
|
|
{
|
|
public class InputConfigEditorWindow : EditorWindow
|
|
{
|
|
// 滑条
|
|
private Vector2 _barPosition;
|
|
|
|
// 背景
|
|
private GUIStyle _redBoxStyle;
|
|
private GUIStyle _whiteBoxStyle;
|
|
|
|
|
|
[MenuItem("Tools/输入编辑器")]
|
|
private static void ShowWindow()
|
|
{
|
|
var window = CreateWindow<InputConfigEditorWindow>();
|
|
window.titleContent = new GUIContent("输入编辑器");
|
|
window.Show();
|
|
}
|
|
|
|
protected virtual void OnEnable()
|
|
{
|
|
EditorApplication.update += OnEditorUpdate;
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
EditorApplication.update -= OnEditorUpdate;
|
|
}
|
|
|
|
private void OnEditorUpdate()
|
|
{
|
|
// 每帧刷新窗口
|
|
Repaint();
|
|
}
|
|
|
|
private void OnGUI()
|
|
{
|
|
if (InputConfigManager.Instance.Config == null) return;
|
|
if (_redBoxStyle == null)
|
|
{
|
|
_redBoxStyle = InspectorUtils.GetHelpBoxStyle();
|
|
InspectorUtils.AddBorder(_redBoxStyle, new Color(0.5f, 0.4f, 0.4f, 0.6f));
|
|
}
|
|
if (_whiteBoxStyle == null)
|
|
{
|
|
_whiteBoxStyle = InspectorUtils.GetHelpBoxStyle();
|
|
InspectorUtils.AddBorder(_whiteBoxStyle, new Color(1f, 1f, 1f, 0.2f));
|
|
}
|
|
|
|
GUI.skin.button.wordWrap = true;
|
|
_barPosition = EditorGUILayout.BeginScrollView(_barPosition);
|
|
|
|
foreach (var keyConfig in InputConfigManager.Instance.Config.InputKeyConfigs)
|
|
{
|
|
OnGUIHeroTaskItem(keyConfig);
|
|
}
|
|
|
|
EditorGUILayout.EndScrollView();
|
|
}
|
|
|
|
private void OnGUIHeroTaskItem(InputKeyConfig keyConfig)
|
|
{
|
|
if (keyConfig.IsConflict) EditorGUILayout.BeginVertical(_redBoxStyle);
|
|
else EditorGUILayout.BeginVertical(_whiteBoxStyle);
|
|
|
|
InspectorUtils.InspectorTextWidthRich($"<b> 功能: </b> {keyConfig.InputType} ");
|
|
InspectorUtils.InspectorTextWidthRich($"<b> 按键: </b> {keyConfig.GetKeyCombinationString()} ");
|
|
InspectorUtils.InspectorTextWidthRich($"<b> 激活: </b> {keyConfig.IsActive} ");
|
|
InspectorUtils.InspectorTextWidthRich($"<b> 冲突: </b> {keyConfig.IsConflict} ");
|
|
if (!InputConfigManager.Instance.IsListening && InspectorUtils.InspectorButtonWithTextWidth($"输入"))
|
|
{
|
|
InputConfigManager.Instance.StartRecordInput(keyConfig.InputType);
|
|
}
|
|
EditorGUILayout.EndVertical();
|
|
}
|
|
}
|
|
} |