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

Commit 99c4081

Browse files
committed
MapPacker rename
1 parent 47b030c commit 99c4081

31 files changed

+456
-399
lines changed

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
MapScrubber/bin/
2-
MapScrubber/obj/
3-
MapScrubber/.vs/
1+
MapPacker/bin/
2+
MapPacker/obj/
3+
MapPacker/.vs/
44
.vs/

MapPacker/AppForm.Designer.cs

Lines changed: 388 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111
using Microsoft.WindowsAPICodePack;
1212
using Microsoft.WindowsAPICodePack.Dialogs;
1313
using System.Media;
14-
namespace MapScrubber {
15-
16-
1714

15+
namespace MapPacker {
1816

1917
public partial class AppForm : Form {
2018
public AppForm() {
@@ -41,6 +39,16 @@ public ProgressBar bar {
4139
}
4240
}
4341

42+
public CheckBox packCheck {
43+
get {
44+
return checkBox1;
45+
}
46+
47+
set {
48+
checkBox1 = value;
49+
}
50+
}
51+
4452
private void browse_asset_Click(object sender, EventArgs e) {
4553
using(var openFileDialog = new CommonOpenFileDialog() { IsFolderPicker = true }) {
4654
openFileDialog.RestoreDirectory = true;
@@ -127,6 +135,14 @@ private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs
127135
private void linkLabel4_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
128136
System.Diagnostics.Process.Start("https://twitter.com/EagleOneDevs");
129137
}
138+
139+
private void checkBox1_CheckedChanged(object sender, EventArgs e) {
140+
if(this.checkBox1.Checked) {
141+
packAssets.Text = "Move Assets";
142+
} else {
143+
packAssets.Text = "Pack Assets";
144+
}
145+
}
130146
}
131147

132148
public class StringRedir : StringWriter {
Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
using System.Threading;
99
using System.Media;
1010

11-
namespace MapScrubber {
11+
namespace MapPacker {
1212
public class AssetCleaner {
1313

1414
public static HashSet<string> assets = new HashSet<string>();
@@ -46,7 +46,10 @@ public void GetAssets() {
4646
} else if(item.EndsWith("vpcf")) {
4747
GetAssetsFromParticle(item);
4848
} else if (item.EndsWith("vmap")) {
49-
GetSkyboxAssets(item);
49+
var mapName = pathToMap.Substring(pathToMap.LastIndexOf("\\") + 1, pathToMap.Length - pathToMap.LastIndexOf("\\") - 1);
50+
if(!(item == "mapName")) {
51+
GetSkyboxAssets(item);
52+
}
5053
}
5154
}
5255

@@ -87,7 +90,7 @@ public void PackVPK() {
8790
SoundPlayer player = new SoundPlayer(Properties.Resources.steam_message);
8891
player.Play();
8992
Console.WriteLine("\nAsset pack completed.");
90-
MessageBox.Show("VPK Successfully Completed", "Complete", MessageBoxButtons.OK, MessageBoxIcon.None);
93+
MessageBox.Show("Map Successfully packed!", "Complete", MessageBoxButtons.OK, MessageBoxIcon.None);
9194
}
9295

9396
public void ExecuteCommandAsync(string command) {
@@ -127,7 +130,13 @@ public void ExecuteCommandSync(object command) {
127130
}
128131

129132
public void CopyFiles() {
130-
Console.WriteLine("\nAssets packed: ");
133+
134+
if(parentForm.packCheck.Checked) {
135+
outputDirectory += "_content";
136+
Console.WriteLine("\nAssets moved: ");
137+
} else {
138+
Console.WriteLine("\nAssets packed: ");
139+
}
131140

132141
int index = 0;
133142
foreach(string asset in assets) {
@@ -136,12 +145,11 @@ public void CopyFiles() {
136145
parentForm.bar.Value = 40 + 30 * (int)Math.Round(index / (float)assets.Count);
137146

138147
string fileName = asset;
139-
140-
string source = Path.Combine(assetPath, fileName);
141-
string destination = Path.Combine(outputDirectory, fileName);
142-
string directory = destination.Substring(0, destination.LastIndexOf("\\"));
143-
144148
try {
149+
string source = Path.Combine(assetPath, fileName);
150+
string destination = Path.Combine(outputDirectory, fileName);
151+
string directory = destination.Substring(0, destination.LastIndexOf("\\"));
152+
145153
if(File.Exists(source)) {
146154
Directory.CreateDirectory(directory);
147155
File.Copy(source, destination, true);
@@ -151,11 +159,17 @@ public void CopyFiles() {
151159
// asset is in core files, ignore
152160
}
153161

154-
} catch(DirectoryNotFoundException) {
155-
Console.WriteLine($"{asset} could not be found or is missing");
162+
} catch {
163+
//Console.WriteLine($"{asset} could not be found or is missing");
164+
// asset not found, broken or otherwise defunct, ignore
156165
}
157166
}
158-
PackVPK();
167+
if(!parentForm.packCheck.Checked) {
168+
PackVPK();
169+
} else {
170+
Console.WriteLine("\nAsset move completed.");
171+
MessageBox.Show("Content successfully moved!", "Complete", MessageBoxButtons.OK, MessageBoxIcon.None);
172+
}
159173
}
160174

161175
public void GetSkyboxAssets(string map) {
@@ -188,6 +202,11 @@ public void GetAssetsFromModel(string item) {
188202
if(matItem.EndsWith("vmat")) {
189203
AddAsset(matItem); // add vmat_c referenced by the vmdl_c
190204
GetAssetsFromMaterial(matItem); // add vtex_c referenced by the vmat_c
205+
} else if (matItem.EndsWith("vmesh")) { // LEGACY IMPORT SUPPORT
206+
AddAsset(matItem); // add vmesh_c referenced by the vmdl_c
207+
GetAssetsFromModel(matItem); // add vmat_c referenced by the vmesh_c
208+
} else if (matItem.EndsWith("vphys")) {
209+
AddAsset(matItem); // add vphys_c referenced by a vmesh_c
191210
}
192211
}
193212
} catch {
@@ -256,6 +275,10 @@ public static string CleanAssetPath(string item) {
256275
asset = asset.Replace(".vpcf", ".vpcf_c");
257276
} else if(asset.EndsWith("vsnd")) {
258277
asset = asset.Replace(".vsnd", ".vsnd_c");
278+
} else if(asset.EndsWith("vphys")) {
279+
asset = asset.Replace(".vphys", ".vphys_c");
280+
} else if(asset.EndsWith("vmesh")) {
281+
asset = asset.Replace(".vmesh", ".vmesh_c");
259282
}
260283
return asset;
261284
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
77
<ProjectGuid>{07817566-E70C-4F15-8A18-A601288E0458}</ProjectGuid>
88
<OutputType>WinExe</OutputType>
9-
<RootNamespace>MapScrubber</RootNamespace>
10-
<AssemblyName>VPK Asset Packer</AssemblyName>
9+
<RootNamespace>MapPacker</RootNamespace>
10+
<AssemblyName>Map Asset Packer</AssemblyName>
1111
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
1212
<FileAlignment>512</FileAlignment>
1313
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 16
44
VisualStudioVersion = 16.0.31025.194
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MapScrubber", "MapScrubber.csproj", "{07817566-E70C-4F15-8A18-A601288E0458}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MapPacker", "MapPacker.csproj", "{07817566-E70C-4F15-8A18-A601288E0458}"
77
EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{86038B8E-EC26-41F3-ADCF-3F16F260A266}"
99
ProjectSection(SolutionItems) = preProject
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System.Threading.Tasks;
66
using System.Windows.Forms;
77

8-
namespace MapScrubber
8+
namespace MapPacker
99
{
1010

1111
class Program

0 commit comments

Comments
 (0)