diff --git a/Crowbar/Core/- Application/AppSettings.vb b/Crowbar/Core/- Application/AppSettings.vb
index 2a38084..245d0bf 100644
--- a/Crowbar/Core/- Application/AppSettings.vb
+++ b/Crowbar/Core/- Application/AppSettings.vb
@@ -296,6 +296,18 @@ Public Class AppSettings
End Set
End Property
+ Public Property DownloadConvertToExpectedFileOrFolderCheckBoxIsChecked() As Boolean
+ Get
+ Return Me.theDownloadConvertToExpectedFileOrFolderCheckBoxIsChecked
+ End Get
+ Set(ByVal value As Boolean)
+ If Me.theDownloadConvertToExpectedFileOrFolderCheckBoxIsChecked <> value Then
+ Me.theDownloadConvertToExpectedFileOrFolderCheckBoxIsChecked = value
+ NotifyPropertyChanged("DownloadConvertToExpectedFileOrFolderCheckBoxIsChecked")
+ End If
+ End Set
+ End Property
+
Public Property UnpackPackagePathFolderOrFileName() As String
Get
Return Me.theUnpackPackagePathFolderOrFileName
@@ -1193,10 +1205,10 @@ Public Class AppSettings
Public Property OptionsAutoOpenVpkFileOption() As ActionType
Get
- Return Me.theOptionsAutoOpenvpkFileOption
+ Return Me.theOptionsAutoOpenVpkFileOption
End Get
Set(ByVal value As ActionType)
- Me.theOptionsAutoOpenvpkFileOption = value
+ Me.theOptionsAutoOpenVpkFileOption = value
NotifyPropertyChanged("OptionsAutoOpenVpkFileOption")
End Set
End Property
@@ -1503,6 +1515,7 @@ Public Class AppSettings
Me.DownloadPrependItemTitleIsChecked = True
Me.DownloadAppendItemUpdateDateTimeIsChecked = True
Me.DownloadReplaceSpacesWithUnderscoresIsChecked = True
+ Me.DownloadConvertToExpectedFileOrFolderCheckBoxIsChecked = True
End Sub
Public Sub SetDefaultUnpackOutputSubfolderName()
@@ -1672,6 +1685,7 @@ Public Class AppSettings
Private theDownloadPrependItemTitleIsChecked As Boolean
Private theDownloadAppendItemUpdateDateTimeIsChecked As Boolean
Private theDownloadReplaceSpacesWithUnderscoresIsChecked As Boolean
+ Private theDownloadConvertToExpectedFileOrFolderCheckBoxIsChecked As Boolean
' Unpack tab
@@ -1804,7 +1818,7 @@ Public Class AppSettings
' Publish tab
Private thePublishGameSelectedIndex As Integer
- Private thePublishSteamAppUserInfos As BindingListExAutoSort(Of SteamAppUserInfo)
+ Private thePublishSteamAppUserInfos As BindingListExAutoSort(Of SteamAppUserInfo)
Private thePublishSearchField As PublishSearchFieldOptions
Private thePublishSearchText As String
'Private thePublishDragDroppedContentPath As String
diff --git a/Crowbar/Core/SteamAppInfos/GarrysModSteamAppInfo.vb b/Crowbar/Core/SteamAppInfos/GarrysModSteamAppInfo.vb
index c5abc7f..d83f2bc 100644
--- a/Crowbar/Core/SteamAppInfos/GarrysModSteamAppInfo.vb
+++ b/Crowbar/Core/SteamAppInfos/GarrysModSteamAppInfo.vb
@@ -17,6 +17,47 @@ Public Class GarrysModSteamAppInfo
Me.TagsControlType = GetType(GarrysModTagsUserControl)
End Sub
+ Public Overrides Function ProcessFileAfterDownload(ByVal givenPathFileName As String, ByVal bw As BackgroundWorkerEx) As String
+ Dim processedPathFileName As String = Path.ChangeExtension(givenPathFileName, ".gma")
+
+ bw.ReportProgress(0, "Decompressing downloaded Garry's Mod workshop file into a GMA file." + vbCrLf)
+ Dim lzmaExeProcess As New Process()
+ Try
+ lzmaExeProcess.StartInfo.UseShellExecute = False
+ 'NOTE: From Microsoft website:
+ ' On Windows Vista and earlier versions of the Windows operating system,
+ ' the length of the arguments added to the length of the full path to the process must be less than 2080.
+ ' On Windows 7 and later versions, the length must be less than 32699.
+ 'FROM BAT file: lzma.exe d %1 "%~n1.gma"
+ lzmaExeProcess.StartInfo.FileName = TheApp.LzmaExePathFileName
+ lzmaExeProcess.StartInfo.Arguments = "d """ + givenPathFileName + """ """ + processedPathFileName + """"
+#If DEBUG Then
+ lzmaExeProcess.StartInfo.CreateNoWindow = False
+#Else
+ lzmaExeProcess.StartInfo.CreateNoWindow = True
+#End If
+ lzmaExeProcess.Start()
+ lzmaExeProcess.WaitForExit()
+ lzmaExeProcess.Close()
+ Catch ex As Exception
+ Throw New System.Exception("Crowbar tried to decompress the file """ + givenPathFileName + """ to """ + processedPathFileName + """ but Windows gave this message: " + ex.Message)
+ Finally
+ lzmaExeProcess.Close()
+ bw.ReportProgress(0, "Decompress done." + vbCrLf)
+ End Try
+
+ Try
+ If File.Exists(givenPathFileName) Then
+ File.Delete(givenPathFileName)
+ bw.ReportProgress(0, "Deleted: """ + givenPathFileName + """" + vbCrLf)
+ End If
+ Catch ex As Exception
+ bw.ReportProgress(0, "Crowbar tried to delete the file """ + givenPathFileName + """ but Windows gave this message: " + ex.Message)
+ End Try
+
+ Return processedPathFileName
+ End Function
+
Public Overrides Function ProcessFileBeforeUpload(ByVal item As WorkshopItem, ByVal bw As BackgroundWorkerEx) As String
Dim processedPathFileName As String = item.ContentPathFolderOrFileName
Me.theBackgroundWorker = bw
diff --git a/Crowbar/Core/SteamAppInfos/SteamAppInfoBase.vb b/Crowbar/Core/SteamAppInfos/SteamAppInfoBase.vb
index d414b38..84a4ea9 100644
--- a/Crowbar/Core/SteamAppInfos/SteamAppInfoBase.vb
+++ b/Crowbar/Core/SteamAppInfos/SteamAppInfoBase.vb
@@ -73,7 +73,7 @@ Public Class SteamAppInfoBase
Me.ContentFileExtensionsAndDescriptions = New SortedList(Of String, String)()
End Sub
- Public Overridable Function ProcessFileAfterDownload(ByVal givenPathFileName As String) As String
+ Public Overridable Function ProcessFileAfterDownload(ByVal givenPathFileName As String, ByVal bw As BackgroundWorkerEx) As String
Dim processedPathFileName As String = givenPathFileName
Return processedPathFileName
End Function
diff --git a/Crowbar/Widgets/Main Tabs/DownloadUserControl.Designer.vb b/Crowbar/Widgets/Main Tabs/DownloadUserControl.Designer.vb
index 7716ce4..256b694 100644
--- a/Crowbar/Widgets/Main Tabs/DownloadUserControl.Designer.vb
+++ b/Crowbar/Widgets/Main Tabs/DownloadUserControl.Designer.vb
@@ -21,6 +21,7 @@ Partial Class DownloadUserControl
Me.GotoOutputPathButton = New System.Windows.Forms.Button()
Me.BrowseForOutputPathButton = New System.Windows.Forms.Button()
Me.OptionsGroupBox = New Crowbar.GroupBoxEx()
+ Me.ConvertToExpectedFileOrFolderCheckBox = New Crowbar.CheckBoxEx()
Me.OptionsUseDefaultsButton = New System.Windows.Forms.Button()
Me.ReplaceSpacesWithUnderscoresCheckBox = New Crowbar.CheckBoxEx()
Me.AppendDateTimeCheckBox = New Crowbar.CheckBoxEx()
@@ -35,6 +36,7 @@ Partial Class DownloadUserControl
Me.DownloadedItemTextBox = New Crowbar.TextBoxEx()
Me.Label1 = New System.Windows.Forms.Label()
Me.DownloadedItemButton = New System.Windows.Forms.Button()
+ Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
Me.OptionsGroupBox.SuspendLayout()
Me.SuspendLayout()
'
@@ -132,6 +134,7 @@ Partial Class DownloadUserControl
'
Me.OptionsGroupBox.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
+ Me.OptionsGroupBox.Controls.Add(Me.ConvertToExpectedFileOrFolderCheckBox)
Me.OptionsGroupBox.Controls.Add(Me.OptionsUseDefaultsButton)
Me.OptionsGroupBox.Controls.Add(Me.ReplaceSpacesWithUnderscoresCheckBox)
Me.OptionsGroupBox.Controls.Add(Me.AppendDateTimeCheckBox)
@@ -148,6 +151,18 @@ Partial Class DownloadUserControl
Me.OptionsGroupBox.TabStop = False
Me.OptionsGroupBox.Text = "Output File Name Options"
'
+ 'ConvertToExpectedFileOrFolderCheckBox
+ '
+ Me.ConvertToExpectedFileOrFolderCheckBox.AutoSize = True
+ Me.ConvertToExpectedFileOrFolderCheckBox.IsReadOnly = False
+ Me.ConvertToExpectedFileOrFolderCheckBox.Location = New System.Drawing.Point(230, 20)
+ Me.ConvertToExpectedFileOrFolderCheckBox.Name = "ConvertToExpectedFileOrFolderCheckBox"
+ Me.ConvertToExpectedFileOrFolderCheckBox.Size = New System.Drawing.Size(187, 17)
+ Me.ConvertToExpectedFileOrFolderCheckBox.TabIndex = 7
+ Me.ConvertToExpectedFileOrFolderCheckBox.Text = "Convert to expected file or folder"
+ Me.ToolTip1.SetToolTip(Me.ConvertToExpectedFileOrFolderCheckBox, "Example: Garry's Mod uses compressed GMA (LZMA) instead of GMA.")
+ Me.ConvertToExpectedFileOrFolderCheckBox.UseVisualStyleBackColor = True
+ '
'OptionsUseDefaultsButton
'
Me.OptionsUseDefaultsButton.Location = New System.Drawing.Point(6, 112)
@@ -348,4 +363,6 @@ Partial Class DownloadUserControl
Friend WithEvents Label1 As Label
Friend WithEvents DownloadedItemButton As Button
Friend WithEvents ExampleOutputFileNameTextBox As TextBoxEx
+ Friend WithEvents ConvertToExpectedFileOrFolderCheckBox As CheckBoxEx
+ Friend WithEvents ToolTip1 As ToolTip
End Class
diff --git a/Crowbar/Widgets/Main Tabs/DownloadUserControl.resx b/Crowbar/Widgets/Main Tabs/DownloadUserControl.resx
index 1af7de1..beae4c1 100644
--- a/Crowbar/Widgets/Main Tabs/DownloadUserControl.resx
+++ b/Crowbar/Widgets/Main Tabs/DownloadUserControl.resx
@@ -117,4 +117,7 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ 17, 17
+
\ No newline at end of file
diff --git a/Crowbar/Widgets/Main Tabs/DownloadUserControl.vb b/Crowbar/Widgets/Main Tabs/DownloadUserControl.vb
index ee785a6..0c72cf5 100644
--- a/Crowbar/Widgets/Main Tabs/DownloadUserControl.vb
+++ b/Crowbar/Widgets/Main Tabs/DownloadUserControl.vb
@@ -66,15 +66,15 @@ Public Class DownloadUserControl
Me.theBackgroundSteamPipe.Kill()
End If
- 'RemoveHandler Me.OutputPathTextBox.DataBindings("Text").Parse, AddressOf FileManager.ParsePathFileName
+ RemoveHandler Me.OutputPathTextBox.DataBindings("Text").Parse, AddressOf FileManager.ParsePathFileName
RemoveHandler TheApp.Settings.PropertyChanged, AddressOf AppSettings_PropertyChanged
- 'Me.FreeDownloadOptions()
+ Me.FreeDownloadOptions()
- 'Me.FreeOutputPathComboBox()
+ Me.FreeOutputPathComboBox()
- 'Me.ItemIdTextBox.DataBindings.Clear()
+ Me.ItemIdTextBox.DataBindings.Clear()
End Sub
Private Sub InitOutputPathComboBox()
@@ -100,6 +100,7 @@ Public Class DownloadUserControl
Me.PrependTitleCheckBox.DataBindings.Add("Checked", TheApp.Settings, "DownloadPrependItemTitleIsChecked", False, DataSourceUpdateMode.OnPropertyChanged)
Me.AppendDateTimeCheckBox.DataBindings.Add("Checked", TheApp.Settings, "DownloadAppendItemUpdateDateTimeIsChecked", False, DataSourceUpdateMode.OnPropertyChanged)
Me.ReplaceSpacesWithUnderscoresCheckBox.DataBindings.Add("Checked", TheApp.Settings, "DownloadReplaceSpacesWithUnderscoresIsChecked", False, DataSourceUpdateMode.OnPropertyChanged)
+ Me.ConvertToExpectedFileOrFolderCheckBox.DataBindings.Add("Checked", TheApp.Settings, "DownloadConvertToExpectedFileOrFolderCheckBoxIsChecked", False, DataSourceUpdateMode.OnPropertyChanged)
End Sub
Private Sub FreeDownloadOptions()
@@ -107,6 +108,7 @@ Public Class DownloadUserControl
Me.PrependTitleCheckBox.DataBindings.Clear()
Me.AppendDateTimeCheckBox.DataBindings.Clear()
Me.ReplaceSpacesWithUnderscoresCheckBox.DataBindings.Clear()
+ Me.ConvertToExpectedFileOrFolderCheckBox.DataBindings.Clear()
End Sub
#End Region
@@ -180,12 +182,13 @@ Public Class DownloadUserControl
End Sub
Private Sub WebClient_DownloadFileCompleted(ByVal sender As Object, ByVal e As AsyncCompletedEventArgs)
+ Dim pathFileName As String = CType(e.UserState, String)
+
If e.Cancelled Then
Me.LogTextBox.AppendText("Download cancelled." + vbCrLf)
Me.DownloadProgressBar.Text = ""
Me.DownloadProgressBar.Value = 0
- Dim pathFileName As String = CType(e.UserState, String)
If File.Exists(pathFileName) Then
Try
File.Delete(pathFileName)
@@ -194,15 +197,9 @@ Public Class DownloadUserControl
End Try
End If
Else
- Dim pathFileName As String = CType(e.UserState, String)
If File.Exists(pathFileName) Then
- Me.ProcessFileAfterDownload(pathFileName)
- If File.Exists(pathFileName) Then
- Me.LogTextBox.AppendText("Download complete." + vbCrLf + "Downloaded file: """ + pathFileName + """" + vbCrLf)
- Me.DownloadedItemTextBox.Text = pathFileName
- Else
- Me.LogTextBox.AppendText("Download failed." + vbCrLf)
- End If
+ Me.LogTextBox.AppendText("Download complete." + vbCrLf + "Downloaded file: """ + pathFileName + """" + vbCrLf)
+ Me.DownloadedItemTextBox.Text = pathFileName
Else
Me.LogTextBox.AppendText("Download failed." + vbCrLf)
End If
@@ -214,6 +211,10 @@ Public Class DownloadUserControl
Me.DownloadButton.Enabled = True
Me.CancelDownloadButton.Enabled = False
+
+ If Not e.Cancelled AndAlso File.Exists(pathFileName) Then
+ Me.ProcessFileAfterDownload(pathFileName)
+ End If
End Sub
Private Sub DownloadItem_ProgressChanged(ByVal sender As System.Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs)
@@ -260,9 +261,9 @@ Public Class DownloadUserControl
File.WriteAllBytes(outputPathFileName, outputInfo.ContentFile)
If File.Exists(outputPathFileName) Then
- Me.ProcessFileAfterDownload(outputPathFileName)
Me.LogTextBox.AppendText("Download complete." + vbCrLf + "Downloaded file: """ + outputPathFileName + """" + vbCrLf)
Me.DownloadedItemTextBox.Text = outputPathFileName
+ Me.ProcessFileAfterDownload(outputPathFileName)
Else
Me.LogTextBox.AppendText("Download failed." + vbCrLf)
End If
@@ -525,36 +526,32 @@ Public Class DownloadUserControl
Dim jss As JavaScriptSerializer = New JavaScriptSerializer()
Dim root As SteamRemoteStorage_PublishedFileDetails_Json = jss.Deserialize(Of SteamRemoteStorage_PublishedFileDetails_Json)(responseFromServer)
Dim file_url As String = root.response.publishedfiledetails(0).file_url
- If file_url Is Nothing OrElse file_url = "" Then
- appID = CUInt(root.response.publishedfiledetails(0).consumer_app_id)
- Else
+ If file_url IsNot Nothing AndAlso file_url <> "" Then
itemLink = file_url
- appID = CUInt(root.response.publishedfiledetails(0).consumer_app_id)
- Me.theAppIdText = appID.ToString()
- Me.theSteamAppInfo = Nothing
- Try
- If TheApp.Settings.PublishSteamAppUserInfos.Count > 0 Then
- 'NOTE: Use this temp var because appID as a ByRef var can not be used in a lambda expression used in next line.
- Dim steamAppID As New Steamworks.AppId_t(appID)
- Me.theSteamAppInfo = TheApp.SteamAppInfos.First(Function(info) info.ID = steamAppID)
- End If
- Catch ex As Exception
- Dim debug As Integer = 4242
- End Try
- If Me.theSteamAppInfo Is Nothing Then
- 'NOTE: Value was not found, so unable to download.
- appID = 0
- End If
-
Me.theItemTitle = root.response.publishedfiledetails(0).title
Dim fileName As String = root.response.publishedfiledetails(0).filename
Me.theItemContentPathFileName = fileName
Me.theItemIdText = root.response.publishedfiledetails(0).publishedfileid
Me.theItemTimeUpdatedText = root.response.publishedfiledetails(0).time_updated.ToString()
End If
- Catch ex As Exception
- Dim debug As Integer = 4242
+
+ appID = CUInt(root.response.publishedfiledetails(0).consumer_app_id)
+ Me.theAppIdText = appID.ToString()
+ Me.theSteamAppInfo = Nothing
+ Try
+ If TheApp.Settings.PublishSteamAppUserInfos.Count > 0 Then
+ 'NOTE: Use this temp var because appID as a ByRef var can not be used in a lambda expression used in next line.
+ Dim steamAppID As New Steamworks.AppId_t(appID)
+ Me.theSteamAppInfo = TheApp.SteamAppInfos.First(Function(info) info.ID = steamAppID)
+ End If
+ Catch ex As Exception
+ Dim debug As Integer = 4242
+ End Try
+ If Me.theSteamAppInfo Is Nothing Then
+ 'NOTE: Value was not found, so unable to download.
+ appID = 0
+ End If
Finally
If reader IsNot Nothing Then
reader.Close()
@@ -703,20 +700,60 @@ Public Class DownloadUserControl
End Sub
Private Sub ProcessFileAfterDownload(ByRef pathFileName As String)
- If Me.theSteamAppInfo IsNot Nothing Then
+ If Me.theSteamAppInfo IsNot Nothing AndAlso TheApp.Settings.DownloadConvertToExpectedFileOrFolderCheckBoxIsChecked Then
Try
- pathFileName = Me.theSteamAppInfo.ProcessFileAfterDownload(pathFileName)
+ Me.DownloadButton.Enabled = False
+ Me.CancelDownloadButton.Enabled = True
+
+ Me.theProcessAfterDownloadWorker = New BackgroundWorkerEx()
+ Me.theProcessAfterDownloadWorker.WorkerSupportsCancellation = True
+ Me.theProcessAfterDownloadWorker.WorkerReportsProgress = True
+ AddHandler Me.theProcessAfterDownloadWorker.DoWork, AddressOf ProcessAfterDownloadWorker_DoWork
+ AddHandler Me.theProcessAfterDownloadWorker.ProgressChanged, AddressOf ProcessAfterDownloadWorker_ProgressChanged
+ AddHandler Me.theProcessAfterDownloadWorker.RunWorkerCompleted, AddressOf ProcessAfterDownloadWorker_RunWorkerCompleted
+ Me.theProcessAfterDownloadWorker.RunWorkerAsync(pathFileName)
Catch ex As Exception
Me.LogTextBox.AppendText("ERROR: " + ex.Message + vbCrLf)
End Try
End If
End Sub
+ 'NOTE: This is run in a background thread.
+ Private Sub ProcessAfterDownloadWorker_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs)
+ e.Result = Me.theSteamAppInfo.ProcessFileAfterDownload(CType(e.Argument, String), Me.theProcessAfterDownloadWorker)
+ End Sub
+
+ Private Sub ProcessAfterDownloadWorker_ProgressChanged(ByVal sender As System.Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs)
+ If e.ProgressPercentage = 0 Then
+ Me.LogTextBox.AppendText(CStr(e.UserState))
+ 'ElseIf e.ProgressPercentage = 1 Then
+ ' Me.LogTextBox.AppendText(vbTab + CStr(e.UserState))
+ End If
+ End Sub
+
+ Private Sub ProcessAfterDownloadWorker_RunWorkerCompleted(ByVal sender As System.Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs)
+ If e.Cancelled Then
+ Else
+ Dim pathFileName As String = CType(e.Result, String)
+ Me.LogTextBox.AppendText("Final file: """ + pathFileName + """" + vbCrLf)
+ Me.DownloadedItemTextBox.Text = pathFileName
+ End If
+
+ RemoveHandler Me.theProcessAfterDownloadWorker.DoWork, AddressOf ProcessAfterDownloadWorker_DoWork
+ RemoveHandler Me.theProcessAfterDownloadWorker.ProgressChanged, AddressOf ProcessAfterDownloadWorker_ProgressChanged
+ RemoveHandler Me.theProcessAfterDownloadWorker.RunWorkerCompleted, AddressOf ProcessAfterDownloadWorker_RunWorkerCompleted
+ Me.theProcessAfterDownloadWorker = Nothing
+
+ Me.DownloadButton.Enabled = True
+ Me.CancelDownloadButton.Enabled = False
+ End Sub
+
#End Region
#Region "Data"
Private theWebClient As WebClient
+ Private theProcessAfterDownloadWorker As BackgroundWorkerEx
Private theAppIdText As String
Private theSteamAppInfo As SteamAppInfoBase