Skip to content
This repository was archived by the owner on Jan 27, 2022. It is now read-only.

Commit 4d3b4a9

Browse files
committed
cli usage (commit description for more info)
-sbox "path/to/sbox/folder" -vmap "path/to/vmap/file" -assets "path/to/asset/addon" optional: -pause "true"/"false" (display ui if true) -pack "true"/"false" (same as checkbox in ui. false for NO packing)
1 parent cb9c85e commit 4d3b4a9

File tree

2 files changed

+116
-26
lines changed

2 files changed

+116
-26
lines changed

MapPacker/AssetPacker.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,17 @@ public AssetPacker(string assetDir, string sboxDir, string vmapFile) {
2424
outputDirectory = Path.GetDirectoryName(vmapFile) + "\\" + Path.GetFileNameWithoutExtension(vmapFile);
2525
}
2626

27+
private bool noNotf = false;
28+
2729
public void GetAssets() {
30+
GetAssets(false);
31+
}
32+
33+
public void GetAssets(bool noNotf = false) {
34+
35+
if(noNotf)
36+
this.noNotf = noNotf;
37+
2838
if(parentForm.Pack) {
2939
Directory.CreateDirectory(outputDirectory);
3040
}
@@ -44,7 +54,8 @@ public void GetAssets() {
4454
} else {
4555
parentForm.PrintToConsole("No assets found!");
4656
parentForm.SetProgress(0);
47-
MessageBox.Show("No assets could be found!", "Alert", MessageBoxButton.OK, MessageBoxImage.Warning);
57+
if(!this.noNotf)
58+
MessageBox.Show("No assets could be found!", "Alert", MessageBoxButton.OK, MessageBoxImage.Warning);
4859
return;
4960
}
5061
foreach(string asset in assets) {
@@ -136,7 +147,8 @@ public void CopyFiles() {
136147
//player.Play();
137148

138149
parentForm.PrintToConsole("\nAsset move completed.");
139-
MessageBox.Show("Content successfully moved!", "Complete", MessageBoxButton.OK, MessageBoxImage.Information);
150+
if(!this.noNotf)
151+
MessageBox.Show("Content successfully moved!", "Complete", MessageBoxButton.OK, MessageBoxImage.Information);
140152
parentForm.SetCheckBoxEnabled(true);
141153
}
142154
}
@@ -160,7 +172,8 @@ public void PackVPK() {
160172
//SoundPlayer player = new SoundPlayer(Properties.Resources.steam_message);
161173
//player.Play();
162174
parentForm.PrintToConsole("\nAsset pack completed.\n");
163-
MessageBox.Show("Map Successfully packed!", "Complete", MessageBoxButton.OK, MessageBoxImage.Information);
175+
if(!this.noNotf)
176+
MessageBox.Show("Map Successfully packed!", "Complete", MessageBoxButton.OK, MessageBoxImage.Information);
164177
parentForm.SetCheckBoxEnabled(true);
165178
}
166179

MapPacker/MainWindow.xaml.cs

Lines changed: 100 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,33 +47,110 @@ public MainWindow() {
4747

4848
string[] args = System.Environment.GetCommandLineArgs();
4949

50-
dictionary = new();
50+
if(args.Length >= 3) { // cli args come in groups of two. first arg is always the source executing the program
51+
dictionary = new();
5152

52-
for(int index = 1; index < args.Length; index += 2) {
53-
dictionary.Add(args[index], args[index + 1]);
54-
}
53+
for(int index = 1; index < args.Length; index += 2) {
54+
dictionary.Add(args[index], args[index + 1]);
55+
}
56+
57+
//PrintToConsole($"args");
58+
bool sbox = false;
59+
bool vmap = false;
60+
bool assets = false;
61+
62+
bool pack = true;
63+
bool pause = false;
64+
65+
string sboxPath = "";
66+
string vmapPath = "";
67+
string assetsPath = "";
68+
69+
PrintToConsole("MapPacker CLI usage");
70+
71+
string value;
72+
if(dictionary.TryGetValue("-sbox", out value)) {
73+
PrintToConsole($"\n-sbox: {value}");
74+
if(!Directory.Exists(value)) {
75+
PrintToConsole("INVALID PATH");
76+
} else {
77+
PrintToConsole("VALID");
78+
var box = (RichTextBox)this.FindName("sboxLocation");
79+
box.Document.Blocks.Clear();
80+
box.Document.Blocks.Add(new Paragraph(new Run(value)));
81+
sboxPath = value;
82+
sbox = true;
83+
}
84+
}
85+
if(dictionary.TryGetValue("-vmap", out value)) {
86+
PrintToConsole($"\n-vmap: {value}");
87+
if(!File.Exists(value)) {
88+
PrintToConsole("INVALID PATH");
89+
} else {
90+
PrintToConsole("VALID");
91+
var box = (RichTextBox)this.FindName("vmapLocation");
92+
box.Document.Blocks.Clear();
93+
box.Document.Blocks.Add(new Paragraph(new Run(value)));
94+
vmapPath = value;
95+
vmap = true;
96+
}
97+
}
98+
if(dictionary.TryGetValue("-assets", out value)) {
99+
PrintToConsole($"\n-assets: {value}");
100+
if(!Directory.Exists(value)) {
101+
PrintToConsole("INVALID PATH");
102+
} else {
103+
PrintToConsole("VALID");
104+
var box = (RichTextBox)this.FindName("assetLocation");
105+
box.Document.Blocks.Clear();
106+
box.Document.Blocks.Add(new Paragraph(new Run(value)));
107+
assetsPath = value;
108+
assets = true;
109+
}
110+
}
111+
if(dictionary.TryGetValue("-pause", out value)) {
112+
if(bool.Parse(value))
113+
pause = true;
114+
}
115+
if(dictionary.TryGetValue("-pack", out value)) {
116+
if(!bool.Parse(value)) {
117+
PackCheckBox.IsEnabled = true;
118+
pack = false;
119+
}
120+
}
55121

56-
//PrintToConsole($"args");
122+
if(sbox && vmap && assets) { // all main params valid
123+
PrintToConsole("\nAll parameters valid, continuing...\n");
124+
_PackCheck = pack;
125+
AssetPacker AssetPacker = new AssetPacker(assetsPath, sboxPath, vmapPath);
126+
AssetPacker.parentForm = this;
127+
if(pause)
128+
new Thread(AssetPacker.GetAssets).Start();
129+
else
130+
AssetPacker.GetAssets(true);
131+
132+
if(!pause) {
133+
Close();
134+
return;
135+
}
136+
} else {
137+
PrintToConsole("\nNot enough valid parameters to continue!");
138+
if(!pause) {
139+
Close();
140+
return;
141+
}
142+
}
57143

58-
string value;
59-
if(dictionary.TryGetValue("-sbox", out value)) {
60-
PrintToConsole($"sbox {value}");
144+
} else {
145+
PrintToConsole("Welcome to the Eagle One Asset Packer!");
146+
PrintToConsole("\n\tHow to Use:");
147+
PrintToConsole("\n\t[+] Compile your map.");
148+
PrintToConsole("\t[+] Make sure your vmap and compiled vpk are in the same directory.");
149+
PrintToConsole("\t[+] Select your vmap, asset directory and sbox directory in the boxes above.");
150+
PrintToConsole("\t[+] Click pack. The found and packed assets will be listed below.");
151+
PrintToConsole("\n\t[+] In case you don't want to have your content packed, just check the box and it will instead appear in a folder called 'yourMap_content'.");
152+
PrintToConsole("\nFor any additional help, contact 'DoctorGurke#0007' or 'Josh Wilson#9332' on discord or make an issue on the Github.");
61153
}
62-
if(dictionary.TryGetValue("-vmap", out value)) {
63-
PrintToConsole($"sbox {value}");
64-
}
65-
if(dictionary.TryGetValue("-assets", out value)) {
66-
PrintToConsole($"sbox {value}");
67-
}
68-
69-
PrintToConsole("Welcome to the Eagle One Asset Packer!");
70-
PrintToConsole("\n\tHow to Use:");
71-
PrintToConsole("\n\t[+] Compile your map.");
72-
PrintToConsole("\t[+] Make sure your vmap and compiled vpk are in the same directory.");
73-
PrintToConsole("\t[+] Select your vmap, asset directory and sbox directory in the boxes above.");
74-
PrintToConsole("\t[+] Click pack. The found and packed assets will be listed below.");
75-
PrintToConsole("\n\t[+] In case you don't want to have your content packed, just check the box and it will instead appear in a folder called 'yourMap_content'.");
76-
PrintToConsole("\nFor any additional help, contact 'DoctorGurke#0007' or 'Josh Wilson#9332' on discord or make an issue on the Github.");
77154
}
78155

79156
private void Window_MouseDown(object sender, MouseButtonEventArgs e) {

0 commit comments

Comments
 (0)