forked from gildor2/UEViewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PackageScanDialog.cpp
95 lines (78 loc) · 2.03 KB
/
PackageScanDialog.cpp
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
#if HAS_UI
#include "BaseDialog.h"
#include "ProgressDialog.h"
class UIPackageScanDialog : public UIBaseDialog
{
public:
void Show()
{
SetResizeable();
UIProgressDialog progress;
progress.Show("Scanning packages");
progress.SetDescription("Scanning package");
bool done = ScanPackageVersions(PkgInfo, &progress);
progress.CloseDialog();
if (done)
ShowModal("Package version report", 475, 370);
}
virtual void InitUI()
{
UIMulticolumnListbox* listbox;
// Create controls
(*this)
[
NewControl(UIMulticolumnListbox, 4)
.SetHeight(-1)
.Expose(listbox)
.AddColumn("Ver", 60)
.AddColumn("Lic", 60)
.AddColumn("Count", 60)
.AddColumn("Path")
+ NewControl(UIGroup, GROUP_HORIZONTAL_LAYOUT|GROUP_NO_BORDER)
[
NewControl(UISpacer, -1)
+ NewControl(UIButton, "Copy")
.SetWidth(80)
.SetCallback(BIND_MEMBER(&UIPackageScanDialog::CopyToClipboard, this))
+ NewControl(UIButton, "Close")
.SetWidth(80)
.SetOK()
+ NewControl(UISpacer, -1)
]
];
// Fill package information
for (const FileInfo& Info : PkgInfo)
{
char buf[128];
appSprintf(ARRAY_ARG(buf), "%d (%X)", Info.Ver, Info.Ver);
int index = listbox->AddItem(buf);
appSprintf(ARRAY_ARG(buf), "%d (%X)", Info.LicVer, Info.LicVer);
listbox->AddSubItem(index, 1, buf);
appSprintf(ARRAY_ARG(buf), "%d", Info.Count);
listbox->AddSubItem(index, 2, buf);
appSprintf(ARRAY_ARG(buf), "%s%s", Info.FileName, (Info.Count > 1) ? "..." : "");
listbox->AddSubItem(index, 3, buf);
}
}
protected:
void CopyToClipboard()
{
FStaticString<1024> Report;
for (const FileInfo& Info : PkgInfo)
{
char buf[256];
appSprintf(ARRAY_ARG(buf), "%3d (%3X) %3d (%3X) %4d %s%s\n",
Info.Ver, Info.Ver, Info.LicVer, Info.LicVer, Info.Count, Info.FileName,
Info.Count > 1 && Info.FileName[0] ? "..." : "");
Report += buf;
}
appCopyTextToClipboard(*Report);
}
TArray<FileInfo> PkgInfo;
};
void ShowPackageScanDialog()
{
UIPackageScanDialog dialog;
dialog.Show();
}
#endif // HAS_UI