编辑器扩展:消息窗口

前言

自定义和扩展消息窗口

image-20210809102920800

image-20210108110520787

消息窗口

先看两个枚举

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
namespace EAppMsgType
{
/**
* Enumerates supported message dialog button types.
*/
enum Type
{
Ok,
YesNo,
OkCancel,
YesNoCancel,
CancelRetryContinue,
YesNoYesAllNoAll,
YesNoYesAllNoAllCancel,
YesNoYesAll,
};

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
namespace EAppReturnType
{
/**
* Enumerates message dialog return types.
*/
enum Type
{
No,
Yes,
YesAll,
NoAll,
Cancel,
Ok,
Retry,
Continue,
};

前者为输入,后者会返回

可以通过返回类型的不同来做不同的逻辑

1
EAppReturnType::Type ReturnType = FMessageDialog::Open(EAppMsgType::OkCancel, DialogText);
  • 强行封装蓝图库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
UENUM(BlueprintType)
enum class EMsgType : uint8
{
Ok,
YesNo,
OkCancel,
YesNoCancel,
CancelRetryContinue,
YesNoYesAllNoAll,
YesNoYesAllNoAllCancel,
YesNoYesAll,

};
UENUM(BlueprintType)
enum class EMsgRetType : uint8
{
No,
Yes,
YesAll,
NoAll,
Cancel,
Ok,
Retry,
Continue,

};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
EMsgRetType UFlib_IO::OpenMessageWindow(EMsgType Type, FText Msg)
{
EAppMsgType::Type tp;
switch (Type)
{
case EMsgType::Ok:
tp = EAppMsgType::Ok;
break;
case EMsgType::YesNo:
tp = EAppMsgType::YesNo;
break;
case EMsgType::OkCancel:
tp = EAppMsgType::OkCancel;
break;
case EMsgType::YesNoCancel:
tp = EAppMsgType::YesNoCancel;
break;
case EMsgType::CancelRetryContinue:
tp = EAppMsgType::CancelRetryContinue;
break;
case EMsgType::YesNoYesAllNoAll:
tp = EAppMsgType::YesNoYesAllNoAll;
break;
case EMsgType::YesNoYesAllNoAllCancel:
tp = EAppMsgType::YesNoYesAllNoAllCancel;
break;
case EMsgType::YesNoYesAll:
tp = EAppMsgType::YesNoYesAll;
break;
}
EAppReturnType::Type retType = FMessageDialog::Open(tp, Msg);
EMsgRetType returnType = EMsgRetType::Ok;
switch (retType)
{
case EAppReturnType::No:
returnType = EMsgRetType::No;
break;
case EAppReturnType::Yes:
returnType = EMsgRetType::Yes;
break;
case EAppReturnType::YesAll:
returnType = EMsgRetType::YesAll;
break;
case EAppReturnType::NoAll:
returnType = EMsgRetType::NoAll;
break;
case EAppReturnType::Cancel:
returnType = EMsgRetType::Cancel;
break;
case EAppReturnType::Ok:
returnType = EMsgRetType::Ok;
break;
case EAppReturnType::Retry:
returnType = EMsgRetType::Retry;
break;
case EAppReturnType::Continue:
returnType = EMsgRetType::Continue;
break;
}
return returnType;
}

image-20210108110520787