-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuidownmanager.cpp
More file actions
290 lines (274 loc) · 8.52 KB
/
uidownmanager.cpp
File metadata and controls
290 lines (274 loc) · 8.52 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
#include "stdafx.h"
namespace local {
UIDownManager::UIDownManager(const UIType& uitype, const bool& init_show) : UIBase(uitype, init_show) {
Init();
}
UIDownManager::~UIDownManager() {
UnInit();
}
void UIDownManager::Init() {
}
void UIDownManager::UnInit() {
}
void UIDownManager::OnFinalMessage(HWND hWnd) {
/*delete this;*////Release can cause a crash
}
const HWND& UIDownManager::Hwnd() const {
return UIBase::m_hWnd;
}
bool UIDownManager::IsOpen() const {
return m_IsOpen.load();
}
void UIDownManager::Create() {
do {
if (m_IsOpen.load())
break;
CPaintManagerUI::SetInstance(__gpHinstance);
#if 0
#ifdef _DEBUG
/*auto sss = CPaintManagerUI::GetInstancePath();*/
CPaintManagerUI::SetResourcePath(LR"(D:\__SVN__\Memade\projects\pcdown\res\skin\)");
#else
//std::string res = shared::Win::File::Read(R"(D:\__SVN__\Memade\projects\pcdown\res\skin.zip)");
////*Global::SetupGet() << shared::Win::File::Read(R"(E:\__SVN__\Memade\projects\downtool\res\setup.xml)");
//if (res.empty())
// break;
std::string res = std::string((char*)&skin_zip_res[0], sizeof(skin_zip_res));
res = shared::Encryption::WemadeDecode(res);
if (!shared::Zip::IsZipCompress(res))
break;
CPaintManagerUI::SetResourceZip(res.data(), static_cast<unsigned int>(res.size()));
#endif
#else
#ifdef _DEBUG
CPaintManagerUI::SetResourcePath(LR"(D:\__SVN__\Memade\projects\pcdown\res\skin\)");
#else
CPaintManagerUI::SetResourcePath(Global::PCHackerGet()->UISkinDirectory().c_str());
#endif
#endif
DWORD dwCreateStyle = UI_WNDSTYLE_FRAME;
do {
if (m_Show.load())
break;
if (!(dwCreateStyle & WS_VISIBLE))
break;
dwCreateStyle &= ~WS_VISIBLE;
} while (0);
UIBase::m_hWnd = UIFrame::Create(NULL, _TEXT("PCDown Manager®"), dwCreateStyle, 0L);
if (!UIBase::m_hWnd)
break;
m_IsOpen.store(true);
CenterWindow();
CPaintManagerUI::MessageLoop();
} while (0);
}
void UIDownManager::Destory() {
do {
if (!m_IsOpen.load())
break;
for (auto& it : m_Threads)
it.join();
m_Threads.clear();
UIFrame::Close(IDOK);
m_IsOpen.store(false);
} while (0);
}
void UIDownManager::InitWindow() {
m_pUITabLayoutMain = GetCtrl<CTabLayoutUI>(LR"(F8CB64B38563)");
m_pUITabLayoutDowning = GetCtrl<CTabLayoutUI>(LR"(D6B8863320C6)");
m_pUITabLayoutDownsuc = GetCtrl<CTabLayoutUI>(LR"(516D679BA67B)");
m_pUIListLocalResource = GetCtrl<CListUI>(LR"(CB0884D16B20)");
m_pUIListDownTask = GetCtrl<CListUI>(LR"(0B36A7206C94)");
m_pUIOptionDowning = GetCtrl<COptionUI>(LR"(BC7F1E5583F8)");
m_pUIOptionDownsuc = GetCtrl<COptionUI>(LR"(7F3985EFCB8E)");
m_pUIButtonSystemClose = GetCtrl<CButtonUI>(LR"(7A98852B5AD7)");
if (m_pUIOptionDowning)
m_pUIOptionDowning->Selected(true);
}
LRESULT UIDownManager::OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
bHandled = FALSE;
return 0;
}
LRESULT UIDownManager::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
LONG styleValue = ::GetWindowLongW(*this, GWL_STYLE);
styleValue &= ~WS_CAPTION;
::SetWindowLongW(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
LONG ExStyleValue = ::GetWindowLongW(*this, GWL_EXSTYLE);
if (!(ExStyleValue & WS_EX_TOOLWINDOW)) {
ExStyleValue |= WS_EX_TOOLWINDOW;
::SetWindowLongW(*this, GWL_EXSTYLE, ExStyleValue);
}
m_pm.Init(GetHWND());
CDialogBuilder builder;
CControlUI* pRoot = builder.Create(std::wstring(GetWindowClassName()).append(_TEXT(".xml")).c_str(), (LPCTSTR)0, NULL, &m_pm);
ASSERT(pRoot && "Failed to parse 'ui.xml'");
m_pm.AttachDialog(pRoot);
m_pm.AddNotifier(this);
bHandled = TRUE;
return 0;
}
LRESULT UIDownManager::OnGetMinMaxInfo(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
bHandled = FALSE;
return 0;
}
LRESULT UIDownManager::OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
bHandled = FALSE;
return 0;
}
LRESULT UIDownManager::HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
bHandled = FALSE;
return 0;
}
LRESULT UIDownManager::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
::PostQuitMessage(0L);
bHandled = TRUE;
return 0;
}
LRESULT UIDownManager::OnChar(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
bHandled = FALSE;
return 0;
}
CControlUI* UIDownManager::CreateControl(LPCTSTR pstrClassName) {
return nullptr;
}
void UIDownManager::Notify(TNotifyUI& msg) {
if (msg.sType == DUI_MSGTYPE_HEADERCLICK) {
}///DUI_MSGTYPE_HEADERCLICK
#if 0
else if (msg.sType == DUI_MSGTYPE_LINK) {
CTextUI* pText = (CTextUI*)msg.pSender;
CDuiString* strUrl = pText->GetLinkContent(0);
::ShellExecute(NULL, _T("open"), strUrl->GetData(), NULL, NULL, SW_SHOWNORMAL);
}
#endif
else if (msg.sType == DUI_MSGTYPE_CHECKCLICK) {
}
else if (msg.sType == DUI_MSGTYPE_CLICK) {
if (msg.pSender == m_pUIButtonSystemClose || \
/*浏览游戏*/
msg.pSender->GetName() == L"A66590EB6D37" ||
msg.pSender->GetName() == L"6DBE42A6ACC5"
) {
ShowWindow(false);
}
else if (msg.pSender->GetName() == L"469E58562CD1") {//!@ 下载任务节点移除
auto parent = shared::ui::FindControlParent(msg.pSender, L"89AF1FBB3D8B");
do {
if (!parent)
break;
Global::PCHackerGet()->TaskAction(parent->GetTagUINT64(),EnActionType::DownRemove);
} while (0);
}
else if (msg.pSender->GetName() == L"06A057E7350B") {//!@ 下载任务节点暂停/停止 | 开始/启动
auto running = ((COptionUI*)msg.pSender)->IsSelected();
auto parent = shared::ui::FindControlParent(msg.pSender, L"89AF1FBB3D8B");
do {
if (!parent)
break;
Global::PCHackerGet()->TaskAction(parent->GetTagUINT64(), running ? EnActionType::DownPause : EnActionType::DownPreparation);
} while (0);
}
else if (msg.pSender->GetName() == L"D90336733AF1") {//!@ 下载任务节点重置
auto parent = shared::ui::FindControlParent(msg.pSender, L"89AF1FBB3D8B");
do {
if (!parent)
break;
Global::PCHackerGet()->TaskAction(parent->GetTagUINT64(), EnActionType::DownReset);
} while (0);
}
else if (msg.pSender == m_pUIOptionDowning) {
do {
if (!m_pUITabLayoutMain)
break;
m_pUITabLayoutMain->SelectItem(static_cast<int>(EnMainPageType::Downing));
} while (0);
}
else if (msg.pSender == m_pUIOptionDownsuc) {
do {
if (!m_pUITabLayoutMain)
break;
m_pUITabLayoutMain->SelectItem(static_cast<int>(EnMainPageType::Success));
} while (0);
}
}
else {
}
}
bool UIDownManager::SwitchPage(const EnChildPageType& type) {
bool result = false;
std::lock_guard<std::mutex> lock{ *m_Mutex };
do {
if (!m_pUITabLayoutDowning)
break;
if (m_pUITabLayoutDowning->GetCount() < static_cast<int>(type))
break;
if (m_pUITabLayoutDowning->GetCurSel() == static_cast<int>(type)) {
result = true;
break;
}
if (!m_pUITabLayoutDowning->SelectItem(static_cast<int>(type)))
break;
result = true;
} while (0);
return result;
}
void UIDownManager::ShowWindow(bool bShow /*= true*/, bool bTakeFocus /*= true*/) {
std::lock_guard<std::mutex> lock{ *m_Mutex };
m_Show.store(bShow);
__super::ShowWindow(bShow, bTakeFocus);
}
unsigned int UIDownManager::UIListDownTaskCount() const {
std::lock_guard<std::mutex> lock{ *m_Mutex };
return m_pUIListDownTask->GetCount();
}
bool UIDownManager::RemoveDownTaskNode(TaskNode* pTaskNode) {
bool result = false;
std::lock_guard<std::mutex> lock{ *m_Mutex };
do {
if (!pTaskNode)
break;
if (!pTaskNode->Verify())
break;
if (!m_pUIListDownTask)
break;
int lines = m_pUIListDownTask->GetCount();
if (lines <= 0)
break;
auto found_id = pTaskNode->ID();
for (int i = 0; i < lines; ++i) {
auto the = m_pUIListDownTask->GetItemAt(i);
if (!the)
continue;
if (found_id != the->GetTagUINT64())
continue;
result = m_pUIListDownTask->RemoveAt(i);
break;
}
} while (0);
return result;
}
bool UIDownManager::AppendDownTaskNode(TaskNode* pTaskNode) {
bool result = false;
std::lock_guard<std::mutex> lock{ *m_Mutex };
#if 0
do {
if (!pTaskNode)
break;
if (!pTaskNode->Verify())
break;
if (!m_pUIListDownTask)
break;
auto theTaskNode = pTaskNode->UIDownTaskElementGet();
if (!theTaskNode)
theTaskNode = pTaskNode->UIDownTaskElementCreate();
if (!theTaskNode)
break;
theTaskNode->SetTagUINT64(pTaskNode->ID());
if (!m_pUIListDownTask->Add(theTaskNode))
break;
result = true;
} while (0);
#endif
return result;
}
}///namespace local