Skip to content

Commit db4c021

Browse files
committed
向新UI回调模式迁移
1 parent a29f7c5 commit db4c021

33 files changed

Lines changed: 883 additions & 868 deletions

File tree

16.5 KB
Binary file not shown.

bin/MulNX/CS2Injector/UISystem/Config/MulNXUIConfig.ini

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,33 @@ Size=400,400
44
Collapsed=0
55

66
[Window][首页]
7-
Pos=148,223
8-
Size=503,487
7+
Pos=0,0
8+
Size=1898,1144
99
Collapsed=0
10-
DockId=0x00000005,1
10+
DockId=0x633F05CB,1
1111

1212
[Window][MulNX控制]
13-
Pos=148,223
14-
Size=503,487
13+
Pos=0,0
14+
Size=1898,1144
1515
Collapsed=0
16-
DockId=0x00000005,2
16+
DockId=0x633F05CB,2
1717

1818
[Window][UI个性配置]
19-
Pos=148,223
20-
Size=503,487
19+
Pos=0,0
20+
Size=1898,1144
2121
Collapsed=0
22-
DockId=0x00000005,0
22+
DockId=0x633F05CB,0
2323

2424
[Window][调试器]
2525
Pos=467,78
2626
Size=1322,966
2727
Collapsed=0
2828

2929
[Window][CS2 Boot Loader]
30-
Pos=148,223
31-
Size=503,487
30+
Pos=0,0
31+
Size=1898,1144
3232
Collapsed=0
33-
DockId=0x00000005,3
33+
DockId=0x633F05CB,3
3434

3535
[Window][UICoordinator]
3636
Pos=1271,131
@@ -43,6 +43,5 @@ Size=469,308
4343
Collapsed=0
4444

4545
[Docking][Data]
46-
DockNode ID=0x00000005 Pos=148,223 Size=503,487 Selected=0xC6EE3AFB
47-
DockSpace ID=0x633F05CB Window=0xFB32D03B Pos=0,0 Size=1898,1144 CentralNode=1
46+
DockSpace ID=0x633F05CB Window=0xFB32D03B Pos=0,0 Size=1898,1144 CentralNode=1 Selected=0xC6EE3AFB
4847

0 Bytes
Binary file not shown.

bin/MulNX/CS2OBTool/CS2OBTool.dll

-82.5 KB
Binary file not shown.

bin/MulNX/CS2OBTool/UISystem/Config/MulNXUIConfig.ini

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Collapsed=0
1515
DockId=0x00000002,3
1616

1717
[Window][玩家信息管理]
18-
Pos=562,527
18+
Pos=749,564
1919
Size=685,394
2020
Collapsed=0
2121
DockId=0x0000000B,0
@@ -96,19 +96,19 @@ Size=1920,1080
9696
Collapsed=0
9797

9898
[Window][UI个性配置]
99-
Pos=1485,556
99+
Pos=1447,704
100100
Size=433,378
101101
Collapsed=0
102102
DockId=0x0000000D,0
103103

104104
[Window][摄像机系统]
105-
Pos=1485,556
105+
Pos=1447,704
106106
Size=433,378
107107
Collapsed=0
108108
DockId=0x0000000D,2
109109

110110
[Window][游戏设置]
111-
Pos=1485,556
111+
Pos=1447,704
112112
Size=433,378
113113
Collapsed=0
114114
DockId=0x0000000D,3
@@ -120,13 +120,13 @@ Collapsed=0
120120
DockId=0x00000002,3
121121

122122
[Window][MulNX控制]
123-
Pos=1485,556
123+
Pos=1447,704
124124
Size=433,378
125125
Collapsed=0
126126
DockId=0x0000000D,10
127127

128128
[Window][首页]
129-
Pos=1485,556
129+
Pos=1447,704
130130
Size=433,378
131131
Collapsed=0
132132
DockId=0x0000000D,1
@@ -149,19 +149,19 @@ Size=1159,801
149149
Collapsed=0
150150

151151
[Window][2D视觉]
152-
Pos=1485,556
152+
Pos=1447,704
153153
Size=433,378
154154
Collapsed=0
155155
DockId=0x0000000D,4
156156

157157
[Window][3D视觉]
158-
Pos=1485,556
158+
Pos=1447,704
159159
Size=433,378
160160
Collapsed=0
161161
DockId=0x0000000D,5
162162

163163
[Window][镜头参数]
164-
Pos=1485,556
164+
Pos=1447,704
165165
Size=433,378
166166
Collapsed=0
167167
DockId=0x0000000D,9
@@ -173,13 +173,13 @@ Collapsed=0
173173
DockId=0x00000002,4
174174

175175
[Window][视角视图]
176-
Pos=1485,556
176+
Pos=1447,704
177177
Size=433,378
178178
Collapsed=0
179179
DockId=0x0000000D,6
180180

181181
[Window][声音控制]
182-
Pos=1485,556
182+
Pos=1447,704
183183
Size=433,378
184184
Collapsed=0
185185
DockId=0x0000000D,7
@@ -219,18 +219,18 @@ Collapsed=0
219219
DockId=0x00000009,0
220220

221221
[Window][音视频]
222-
Pos=1409,88
222+
Pos=1561,145
223223
Size=406,434
224224
Collapsed=0
225225

226226
[Window][实体列表探测器]
227-
Pos=1485,556
227+
Pos=1447,704
228228
Size=433,378
229229
Collapsed=0
230230
DockId=0x0000000D,11
231231

232232
[Window][高级功能]
233-
Pos=1485,556
233+
Pos=1447,704
234234
Size=433,378
235235
Collapsed=0
236236
DockId=0x0000000D,8
@@ -283,10 +283,10 @@ DockNode ID=0x00000003 Pos=464,428 Size=1378,716 Split=X Selected=0x448D10F
283283
DockNode ID=0x00000007 Parent=0x00000003 SizeRef=729,992 Split=Y Selected=0x8538678F
284284
DockNode ID=0x00000008 Parent=0x00000007 SizeRef=729,644 Selected=0x3C0020BC
285285
DockNode ID=0x00000009 Parent=0x00000007 SizeRef=729,238 Selected=0x8538678F
286-
DockNode ID=0x0000000A Pos=562,527 Size=685,394 Split=X
286+
DockNode ID=0x0000000A Pos=749,564 Size=685,394 Split=X
287287
DockNode ID=0x0000000B Parent=0x0000000A SizeRef=1042,407 Selected=0x2D59FDA6
288288
DockNode ID=0x0000000C Parent=0x0000000A SizeRef=606,407 Selected=0x4DB1B67D
289-
DockNode ID=0x0000000D Pos=1485,556 Size=433,378 Selected=0x7773E0DE
289+
DockNode ID=0x0000000D Pos=1447,704 Size=433,378 Selected=0x7773E0DE
290290
DockSpace ID=0x633F05CB Window=0xFB32D03B Pos=0,0 Size=1920,1080 Split=Y Selected=0xC52A91C6
291291
DockNode ID=0x00000001 Parent=0x633F05CB SizeRef=1920,31 Selected=0x38DB91B6
292292
DockNode ID=0x00000002 Parent=0x633F05CB SizeRef=1920,1047 CentralNode=1

bin/MulNX/Log/Log_CS2Injector.txt

Lines changed: 101 additions & 100 deletions
Large diffs are not rendered by default.

bin/MulNX/Log/Log_CS2OBTool.txt

Lines changed: 646 additions & 617 deletions
Large diffs are not rendered by default.

source/MulNX/Systems/UISystem/UICoordinator/UICoordinator.cpp

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ void MulNX::UICoordinator::Window() {
7070
bool MulNX::UICoordinator::Init() {
7171
(*this)
7272
.SubscribeAsync("UISystem/ModulePush")
73+
.SubscribeAsync("UISystem/UICallback")
7374
.SubscribeAsync("UINode/Swap"); // 订阅交换消息
7475
// 向 UISystem 注册本模块的根窗口回调
7576
this->SendUIRoot(this->GetName(), [this](auto&&...) {return this->Window();});
@@ -80,18 +81,22 @@ void MulNX::UICoordinator::ProcessMsg(MulNX::Message& msg) {
8081
switch (msg.type) {
8182
case "UISystem/ModulePush"_hash: {
8283
MulNX::UINode* pNode = msg.asp.get<MulNX::UINode>();
83-
if (!pNode) break;
84-
8584
size_t index = UINodes.size();
8685
UINodes.emplace_back(std::move(*pNode));
8786
auto& node = UINodes.back();
8887
nameToIndex[node.name] = index;
89-
node.pCoordinator = this;
90-
88+
9189
this->LogSucc(std::format("接收到UI节点: {} (索引 {})", node.name, index));
9290
break;
9391
}
92+
case "UISystem/UICallback"_hash: {
93+
MulNX::UINode node = std::move(*msg.asp.get<MulNX::UINode>());
94+
auto&& [target, str] = msg.Access<uint64_t, const char*>();
95+
this->UICallbacks[target].push_back(std::move(node));
9496

97+
this->LogSucc(std::format("UI节点: {} 回调于: {}", node.name, str));
98+
break;
99+
}
95100
case "UINode/Swap"_hash: {
96101
auto pNet = msg.asp.get<MulNX::NetExt>();
97102
if (!pNet) break;
@@ -165,9 +170,17 @@ void MulNX::UICoordinator::Render() {
165170
}
166171
}
167172

168-
void MulNX::UICoordinator::CallUINode(std::string&& name) {
169-
auto it = nameToIndex.find(name);
170-
if (it != nameToIndex.end()) {
171-
UINodes[it->second].Render(this, nullptr);
173+
void MulNX::UICoordinator::CallUINode(const std::string& name) {
174+
auto it = this->nameToIndex.find(name);
175+
if (it != this->nameToIndex.end()) {
176+
this->UINodes[it->second].Render(this, nullptr);
177+
}
178+
}
179+
180+
void MulNX::UICoordinator::CallbackCall(uint64_t hash, Message* msg) {
181+
auto it = this->UICallbacks.find(hash);
182+
if (it == this->UICallbacks.end())return;
183+
for (auto& callback : it->second) {
184+
callback.Render(this, msg);
172185
}
173186
}

source/MulNX/Systems/UISystem/UICoordinator/UICoordinator.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#pragma once
22
#include <MulNX/Core/Module/Module.hpp>
3+
#include <map>
34

45
namespace MulNX {
56
class UICoordinator final :public MulNX::Module<UICoordinator> {
67
std::unordered_map<std::string, size_t>nameToIndex{};
78
std::vector<MulNX::UINode>UINodes{};
9+
std::map<uint64_t, std::vector<MulNX::UINode>>UICallbacks{};
810
struct Padding {
911
float top = 0;
1012
float bottom = 0;
@@ -19,6 +21,7 @@ namespace MulNX {
1921
public:
2022
void HandleUpdate();
2123
void Render();
22-
void CallUINode(std::string&& name);
24+
void CallUINode(const std::string& name);
25+
void CallbackCall(uint64_t hash, Message* msg);
2326
};
2427
}

source/MulNX/Systems/UISystem/UIMixin.hpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,14 @@ namespace MulNX {
66

77
template<typename T>
88
class UIMixin {
9-
private:
9+
T* This() { return static_cast<T*>(this); }
1010
auto CreateUINode(std::string&& name, std::function<void(UICoordinator*, Message*)>&& func) {
11-
// 创建UI节点
1211
MulNX::UINode UINode = MulNX::UINode::Create(This());
13-
// 设置UI节点属性
1412
UINode.name = std::move(name);
1513
UINode.Render = std::move(func);
16-
// 创建UI消息
1714
return MulNX::Message::Create<MulNX::UINode>("UISystem/ModulePush"_hash, std::move(UINode));
1815
}
1916
public:
20-
T* This() { return static_cast<T*>(this); }
21-
UIMixin() {
22-
23-
}
24-
2517
void SendUINode(std::string&& name, std::function<void(UICoordinator*, Message*)>&& func) {
2618
auto [msg, rp] = this->CreateUINode(std::move(name), std::move(func));
2719
This()->PublishAsync(std::move(msg));
@@ -34,5 +26,16 @@ namespace MulNX {
3426
This()->PublishAsync(std::move(msg));
3527
This()->LogInfo(I18n("module.send_ui"));
3628
}
29+
void UIRegisterCallback(const char* name, std::function<void(UICoordinator*, Message*)>&& func) {
30+
MulNX::UINode UINode = MulNX::UINode::Create(This());
31+
UINode.name = std::string(name);
32+
UINode.Render = std::move(func);
33+
auto [msg, pNode] = MulNX::Message::Create<MulNX::UINode>("UISystem/UICallback"_hash);
34+
*pNode = std::move(UINode);
35+
auto&& [target, str] = msg.Access<uint64_t, const char*>();
36+
target = MulNX::HashString(name);
37+
str = name;
38+
This()->PublishAsync(std::move(msg));
39+
}
3740
};
3841
}

0 commit comments

Comments
 (0)