Skip to content

Commit aa87c01

Browse files
committed
Fixes #2
1 parent 029fe09 commit aa87c01

10 files changed

+301
-24
lines changed

Soartex Texture Zipper/Soartex Texture Zipper/Form1.Designer.vb

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Soartex Texture Zipper/Soartex Texture Zipper/Form1.resx

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
<resheader name="writer">
118118
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120-
<metadata name="FolderBrowserDialog_toZip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
120+
<metadata name="FolderBrowserDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
121121
<value>17, 17</value>
122122
</metadata>
123123
</root>

Soartex Texture Zipper/Soartex Texture Zipper/Form1.vb

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
Public Class Form1
1+
Public Class form_main
22

33
Private Sub btn_selectFolderToCompress_Click(sender As Object, e As EventArgs) Handles btn_selectFolderSource.Click
4-
FolderBrowserDialog_toZip.ShowDialog()
5-
If FolderBrowserDialog_toZip.SelectedPath <> "" Then
6-
tb_folderSource.Text = FolderBrowserDialog_toZip.SelectedPath
4+
FolderBrowserDialog.ShowDialog()
5+
If FolderBrowserDialog.SelectedPath <> "" Then
6+
tb_folderSource.Text = FolderBrowserDialog.SelectedPath
77
End If
88
End Sub
99

1010
Private Sub btn_selectFolderTarget_Click(sender As Object, e As EventArgs) Handles btn_selectFolderTarget.Click
11-
FolderBrowserDialog_toZip.ShowDialog()
12-
If FolderBrowserDialog_toZip.SelectedPath <> "" Then
13-
tb_folderTarget.Text = FolderBrowserDialog_toZip.SelectedPath
11+
FolderBrowserDialog.ShowDialog()
12+
If FolderBrowserDialog.SelectedPath <> "" Then
13+
tb_folderTarget.Text = FolderBrowserDialog.SelectedPath
1414
End If
1515
End Sub
1616

Soartex Texture Zipper/Soartex Texture Zipper/My Project/Application.Designer.vb

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-16"?>
22
<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
33
<MySubMain>true</MySubMain>
4-
<MainForm>Form1</MainForm>
4+
<MainForm>form_main</MainForm>
55
<SingleInstance>false</SingleInstance>
66
<ShutdownMode>0</ShutdownMode>
77
<EnableVisualStyles>true</EnableVisualStyles>
88
<AuthenticationMode>0</AuthenticationMode>
9-
<ApplicationType>0</ApplicationType>
109
<SaveMySettingsOnExit>true</SaveMySettingsOnExit>
11-
</MyApplicationData>
10+
</MyApplicationData>

Soartex Texture Zipper/Soartex Texture Zipper/Soartex Texture Zipper.vbproj

+9
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@
7979
<DependentUpon>Form1.vb</DependentUpon>
8080
<SubType>Form</SubType>
8181
</Compile>
82+
<Compile Include="form_selectTarget.Designer.vb">
83+
<DependentUpon>form_selectTarget.vb</DependentUpon>
84+
</Compile>
85+
<Compile Include="form_selectTarget.vb">
86+
<SubType>Form</SubType>
87+
</Compile>
8288
<Compile Include="My Project\AssemblyInfo.vb" />
8389
<Compile Include="My Project\Application.Designer.vb">
8490
<AutoGen>True</AutoGen>
@@ -99,6 +105,9 @@
99105
<EmbeddedResource Include="Form1.resx">
100106
<DependentUpon>Form1.vb</DependentUpon>
101107
</EmbeddedResource>
108+
<EmbeddedResource Include="form_selectTarget.resx">
109+
<DependentUpon>form_selectTarget.vb</DependentUpon>
110+
</EmbeddedResource>
102111
<EmbeddedResource Include="My Project\Resources.resx">
103112
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
104113
<LastGenOutput>Resources.Designer.vb</LastGenOutput>

Soartex Texture Zipper/Soartex Texture Zipper/compress.vb

+42-6
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,48 @@ Module compress
88
Dim subDirsMain As String() = Nothing 'asset folder level
99

1010
Public Sub makeResourcePack(dirSource As String, dirTarget As String)
11-
Dim rpFileName As String
12-
rpFileName = extractName(dirSource)
11+
Dim rpDirName As String
12+
rpDirName = extractName(dirSource)
1313

1414
'create the pack.mcmeta file (temporary)
15-
createDescriptionFile(dirTarget, replaceUnderscore(rpFileName))
15+
createDescriptionFile(dirTarget, replaceUnderscore(rpDirName))
1616

1717
'get last modified version of the directory
1818
Dim ver As String = getVersion(dirSource)
1919

20+
Dim rpFileNamePathTemp As String = My.Computer.FileSystem.SpecialDirectories.Temp & "\" & rpDirName & "-" & ver & ".zip"
21+
Dim rpFileNamePath As String = dirTarget & "\" & rpDirName & "-" & ver & ".zip"
22+
2023
'create the resource pack
21-
ZipFile.CreateFromDirectory(dirSource, My.Computer.FileSystem.SpecialDirectories.Temp & "\" & rpFileName & "-" & ver & ".zip")
22-
My.Computer.FileSystem.MoveFile(My.Computer.FileSystem.SpecialDirectories.Temp & "\" & rpFileName & "-" & ver & ".zip", dirSource & "\" & rpFileName & "-" & ver & ".zip")
24+
'check if the zip already exists in the temp folder. If so, delete it
25+
If My.Computer.FileSystem.FileExists(rpFileNamePathTemp) = True Then
26+
My.Computer.FileSystem.DeleteFile(rpFileNamePathTemp)
27+
End If
28+
29+
'check if the zip already exists in the target folder. If so, ask what to do
30+
If My.Computer.FileSystem.FileExists(rpFileNamePath) = True Then
31+
Dim str As String = "Resourcepack already exists in the target directory." & vbNewLine & vbNewLine & "Click ""Yes"" to replace the file." _
32+
& vbNewLine & "Click ""No"" to select a new target directory."
33+
Dim result As MsgBoxResult
34+
result = MsgBox(str, MsgBoxStyle.YesNoCancel, "File already exists")
35+
36+
If result = vbYes Then
37+
My.Computer.FileSystem.DeleteFile(rpFileNamePath)
38+
ElseIf result = vbCancel Then
39+
Exit Sub
40+
ElseIf result = vbNo Then
41+
form_main.Enabled = False
42+
form_selectTarget.ShowDialog()
43+
dirTarget = form_selectTarget.tb_folderTarget.Text
44+
form_selectTarget.Close()
45+
form_main.Enabled = True
46+
47+
rpFileNamePath = dirTarget & "\" & rpDirName & "-" & ver & ".zip"
48+
End If
49+
End If
50+
51+
ZipFile.CreateFromDirectory(dirSource, rpFileNamePathTemp)
52+
My.Computer.FileSystem.MoveFile(rpFileNamePathTemp, rpFileNamePath)
2353

2454
'delete the temporary pack.mcmeta file
2555
My.Computer.FileSystem.DeleteFile(dirSource & "\pack.mcmeta")
@@ -45,7 +75,13 @@ Module compress
4575
End Function
4676

4777
Private Sub createDescriptionFile(dirTarget As String, rpName As String) 'creates the pack.mcmeta
48-
Dim fs As FileStream = File.Create(dirTarget & "\pack.mcmeta")
78+
Dim fileNamePath As String = dirTarget & "\pack.mcmeta"
79+
80+
If My.Computer.FileSystem.FileExists(fileNamePath) = True Then
81+
My.Computer.FileSystem.DeleteFile(fileNamePath)
82+
End If
83+
84+
Dim fs As FileStream = File.Create(fileNamePath)
4985

5086
Dim str As String
5187
Dim tab As String = " "

Soartex Texture Zipper/Soartex Texture Zipper/form_selectTarget.Designer.vb

+92
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)