From: ShadowFlare Date: Mon, 24 Aug 2009 14:17:17 +0000 (-0600) Subject: Add bzip2 compression option and Ctrl+A select all. X-Git-Url: https://sfsrealm.hopto.org/projects/?a=commitdiff_plain;h=ba4954d5a6b02339751eaac89a9f0d56f7600059;p=WinMPQ.git Add bzip2 compression option and Ctrl+A select all. --- diff --git a/MpqStuff.bas b/MpqStuff.bas index 971d029..f4a74dc 100644 --- a/MpqStuff.bas +++ b/MpqStuff.bas @@ -99,9 +99,18 @@ ElseIf LCase(fExt) = ".mp3" Then ElseIf LCase(fExt) = ".mpq" Then cType = CInt(GetReg(AppKey + "Compression\.mpq", "-2")) dwFlags = dwFlags And (-1& Xor MAFA_ENCRYPT) +ElseIf LCase(fExt) = ".scm" Then + cType = CInt(GetReg(AppKey + "Compression\.scm", "-2")) + dwFlags = dwFlags And (-1& Xor MAFA_ENCRYPT) +ElseIf LCase(fExt) = ".scx" Then + cType = CInt(GetReg(AppKey + "Compression\.scx", "-2")) + dwFlags = dwFlags And (-1& Xor MAFA_ENCRYPT) ElseIf LCase(fExt) = ".w3m" Then cType = CInt(GetReg(AppKey + "Compression\.w3m", "-2")) dwFlags = dwFlags And (-1& Xor MAFA_ENCRYPT) +ElseIf LCase(fExt) = ".w3x" Then + cType = CInt(GetReg(AppKey + "Compression\.w3x", "-2")) + dwFlags = dwFlags And (-1& Xor MAFA_ENCRYPT) ElseIf LCase(fExt) = ".wav" Then cType = CInt(GetReg(AppKey + "Compression\.wav", "0")) Else @@ -318,10 +327,16 @@ Case -1 MpqAddFileToArchiveEx hMPQ, File, MpqPath, dwFlags Or MAFA_COMPRESS, MAFA_COMPRESS_STANDARD, 0 Case -3 MpqAddFileToArchiveEx hMPQ, File, MpqPath, dwFlags Or MAFA_COMPRESS, MAFA_COMPRESS_DEFLATE, DefaultCompressLevel +Case -4 +MpqAddFileToArchiveEx hMPQ, File, MpqPath, dwFlags Or MAFA_COMPRESS, MAFA_COMPRESS_BZIP2, 0 Case 0, 1, 2 MpqAddWaveToArchive hMPQ, File, MpqPath, dwFlags Or MAFA_COMPRESS, cType Case Else -MpqAddFileToArchiveEx hMPQ, File, MpqPath, dwFlags Or MAFA_COMPRESS, DefaultCompress, DefaultCompressLevel +If DefaultCompress = MAFA_COMPRESS_DEFLATE Then + MpqAddFileToArchiveEx hMPQ, File, MpqPath, dwFlags Or MAFA_COMPRESS, DefaultCompress, DefaultCompressLevel +Else + MpqAddFileToArchiveEx hMPQ, File, MpqPath, dwFlags Or MAFA_COMPRESS, DefaultCompress, 0 +End If End Select End Sub Sub mAddAutoFromBuffer(hMPQ As Long, ByRef buffer As Byte, BufSize As Long, MpqPath As String) @@ -336,10 +351,16 @@ Case -1 MpqAddFileFromBufferEx hMPQ, buffer, BufSize, MpqPath, dwFlags Or MAFA_COMPRESS, MAFA_COMPRESS_STANDARD, 0 Case -3 MpqAddFileFromBufferEx hMPQ, buffer, BufSize, MpqPath, dwFlags Or MAFA_COMPRESS, MAFA_COMPRESS_DEFLATE, DefaultCompressLevel +Case -4 +MpqAddFileFromBufferEx hMPQ, buffer, BufSize, MpqPath, dwFlags Or MAFA_COMPRESS, MAFA_COMPRESS_BZIP2, 0 Case 0, 1, 2 MpqAddWaveFromBuffer hMPQ, buffer, BufSize, MpqPath, dwFlags Or MAFA_COMPRESS, cType Case Else -MpqAddFileFromBufferEx hMPQ, buffer, BufSize, MpqPath, dwFlags Or MAFA_COMPRESS, DefaultCompress, DefaultCompressLevel +If DefaultCompress = MAFA_COMPRESS_DEFLATE Then + MpqAddFileFromBufferEx hMPQ, buffer, BufSize, MpqPath, dwFlags Or MAFA_COMPRESS, DefaultCompress, DefaultCompressLevel +Else + MpqAddFileFromBufferEx hMPQ, buffer, BufSize, MpqPath, dwFlags Or MAFA_COMPRESS, DefaultCompress, 0 +End If End Select End Sub @@ -788,7 +809,11 @@ For bNum = 1 To Len(Script) ElseIf cType = -1 Then mAddAutoFile hMPQ, FullPath(CurPath, fLine), Param(3) + fLine ElseIf cType = 1 Then - MpqAddFileToArchiveEx hMPQ, FullPath(CurPath, fLine), Param(3) + fLine, dwFlags, DefaultCompress, DefaultCompressLevel + If DefaultCompress = MAFA_COMPRESS_DEFLATE Then + MpqAddFileToArchiveEx hMPQ, FullPath(CurPath, fLine), Param(3) + fLine, dwFlags, DefaultCompress, DefaultCompressLevel + Else + MpqAddFileToArchiveEx hMPQ, FullPath(CurPath, fLine), Param(3) + fLine, dwFlags, DefaultCompress, 0 + End If Else MpqAddFileToArchiveEx hMPQ, FullPath(CurPath, fLine), Param(3) + fLine, dwFlags, 0, 0 End If @@ -798,7 +823,11 @@ For bNum = 1 To Len(Script) ElseIf cType = -1 Then mAddAutoFile hMPQ, FullPath(CurPath, fLine), Param(3) ElseIf cType = 1 Then - MpqAddFileToArchiveEx hMPQ, FullPath(CurPath, fLine), Param(3), dwFlags, DefaultCompress, DefaultCompressLevel + If DefaultCompress = MAFA_COMPRESS_DEFLATE Then + MpqAddFileToArchiveEx hMPQ, FullPath(CurPath, fLine), Param(3), dwFlags, DefaultCompress, DefaultCompressLevel + Else + MpqAddFileToArchiveEx hMPQ, FullPath(CurPath, fLine), Param(3), dwFlags, DefaultCompress, 0 + End If Else MpqAddFileToArchiveEx hMPQ, FullPath(CurPath, fLine), Param(3), dwFlags, 0, 0 End If diff --git a/Options.frm b/Options.frm index 9dccb7c..83453ca 100644 --- a/Options.frm +++ b/Options.frm @@ -3,20 +3,20 @@ Begin VB.Form Options BorderStyle = 3 'Fixed Dialog Caption = "Options" ClientHeight = 4695 - ClientLeft = 1575 - ClientTop = 1815 + ClientLeft = 1665 + ClientTop = 2085 ClientWidth = 5415 Height = 5100 Icon = "Options.frx":0000 KeyPreview = -1 'True - Left = 1515 + Left = 1605 LinkTopic = "Form1" MaxButton = 0 'False MinButton = 0 'False ScaleHeight = 4695 ScaleWidth = 5415 ShowInTaskbar = 0 'False - Top = 1470 + Top = 1740 Width = 5535 Begin VB.CommandButton Command2 Caption = "&Cancel" @@ -421,7 +421,7 @@ Begin VB.Form Options Height = 315 ItemData = "Options.frx":0245 Left = 1200 - List = "Options.frx":024F + List = "Options.frx":0252 Style = 2 'Dropdown List TabIndex = 33 Top = 3120 @@ -429,9 +429,9 @@ Begin VB.Form Options End Begin VB.ListBox List1 Height = 1815 - ItemData = "Options.frx":0266 + ItemData = "Options.frx":0270 Left = 0 - List = "Options.frx":0268 + List = "Options.frx":0272 Sorted = -1 'True TabIndex = 27 Top = 720 @@ -463,9 +463,9 @@ Begin VB.Form Options Begin VB.ComboBox Combo1 Enabled = 0 'False Height = 315 - ItemData = "Options.frx":026A + ItemData = "Options.frx":0274 Left = 1800 - List = "Options.frx":027A + List = "Options.frx":0287 Style = 2 'Dropdown List TabIndex = 29 Top = 720 @@ -668,7 +668,11 @@ Else If Combo1.ListIndex < 2 Then NewExtComp(xNum) = Combo1.ListIndex - 2 Else - NewExtComp(xNum) = -3 + If Combo1.ListIndex = 2 Then + NewExtComp(xNum) = -3 + Else + NewExtComp(xNum) = -4 + End If End If End If End Sub @@ -801,6 +805,9 @@ DefaultCompress = MAFA_COMPRESS_STANDARD Case 1 DefaultCompressID = -3 DefaultCompress = MAFA_COMPRESS_DEFLATE +Case 2 +DefaultCompressID = -4 +DefaultCompress = MAFA_COMPRESS_BZIP2 End Select DefaultCompressLevel = Combo3.ListIndex - 1 SetReg AppKey + "DefaultCompress", DefaultCompressID, REG_DWORD @@ -927,11 +934,13 @@ DCompType = GetReg(AppKey + "DefaultCompress", -1) Select Case DCompType Case -3 Combo2.ListIndex = 1 +Case -4 +Combo2.ListIndex = 2 Case Else Combo2.ListIndex = 0 End Select Combo3.ListIndex = GetReg(AppKey + "DefaultZlibLevel", Z_DEFAULT_COMPRESSION) + 1 -ExtList = GetReg(AppKey + "Compression\List", ".bik.smk.mp3.mpq.w3m.wav") +ExtList = GetReg(AppKey + "Compression\List", ".bik.smk.mp3.mpq.scm.scx.w3m.w3x.wav") If InStr(1, ExtList, ".") > 0 And Len(ExtList) > 1 Then Do ReDim Preserve NewExtNames(UBound(NewExtNames) + 1) As String @@ -951,8 +960,14 @@ Do NewExtComp(UBound(NewExtComp)) = CInt(GetReg(AppKey + "Compression\.mp3", "-2")) ElseIf LCase(NewExtNames(UBound(NewExtNames))) = ".mpq" Then NewExtComp(UBound(NewExtComp)) = CInt(GetReg(AppKey + "Compression\.mpq", "-2")) + ElseIf LCase(NewExtNames(UBound(NewExtNames))) = ".scm" Then + NewExtComp(UBound(NewExtComp)) = CInt(GetReg(AppKey + "Compression\.scm", "-2")) + ElseIf LCase(NewExtNames(UBound(NewExtNames))) = ".scx" Then + NewExtComp(UBound(NewExtComp)) = CInt(GetReg(AppKey + "Compression\.scx", "-2")) ElseIf LCase(NewExtNames(UBound(NewExtNames))) = ".w3m" Then NewExtComp(UBound(NewExtComp)) = CInt(GetReg(AppKey + "Compression\.w3m", "-2")) + ElseIf LCase(NewExtNames(UBound(NewExtNames))) = ".w3x" Then + NewExtComp(UBound(NewExtComp)) = CInt(GetReg(AppKey + "Compression\.w3x", "-2")) ElseIf LCase(NewExtNames(UBound(NewExtNames))) = ".wav" Then NewExtComp(UBound(NewExtComp)) = CInt(GetReg(AppKey + "Compression\.wav", "0")) Else @@ -1007,6 +1022,9 @@ If List1.ListIndex > -1 Then Case -3 AudioC(0).Value = True Combo1.ListIndex = 2 + Case -4 + AudioC(0).Value = True + Combo1.ListIndex = 4 Case 0, 1, 2 OldExtComp = NewExtComp(xNum) Combo1.ListIndex = 3 diff --git a/Options.frx b/Options.frx index ea0726e..590d8eb 100644 Binary files a/Options.frx and b/Options.frx differ diff --git a/listing.frm b/listing.frm index a36ad42..f5705c1 100644 --- a/listing.frm +++ b/listing.frm @@ -56,7 +56,7 @@ Begin VB.Form MpqEx Width = 6690 _ExtentX = 11800 _ExtentY = 609 - ButtonWidth = 1535 + ButtonWidth = 1561 ButtonHeight = 556 Wrappable = 0 'False Appearance = 1 @@ -308,7 +308,7 @@ Begin VB.Form MpqEx End Begin VB.Menu mnuMAdd Caption = "&Add..." - Shortcut = ^A + Shortcut = ^{INSERT} End Begin VB.Menu mnuMAddFolder Caption = "Add &Folder..." @@ -336,6 +336,10 @@ Begin VB.Form MpqEx Caption = "&Deflate" Shortcut = {F9} End + Begin VB.Menu mnuMCBzip2 + Caption = "&Bzip2" + Shortcut = ^{F11} + End Begin VB.Menu mnuMCAudio Caption = "&Audio" Begin VB.Menu mnuMCALowest @@ -734,6 +738,8 @@ Sub ConvertCwad() MpqAddFileFromBufferEx hMPQ, buffer(0), fLen, Files(nFile), dwFlags Or MAFA_COMPRESS, MAFA_COMPRESS_STANDARD, 0 ElseIf mnuMCDeflate.Checked Then MpqAddFileFromBufferEx hMPQ, buffer(0), fLen, Files(nFile), dwFlags Or MAFA_COMPRESS, MAFA_COMPRESS_DEFLATE, DefaultCompressLevel + ElseIf mnuMCBzip2.Checked Then + MpqAddFileFromBufferEx hMPQ, buffer(0), fLen, Files(nFile), dwFlags Or MAFA_COMPRESS, MAFA_COMPRESS_BZIP2, 0 ElseIf mnuMCAMedium.Checked Then MpqAddWaveFromBuffer hMPQ, buffer(0), fLen, Files(nFile), dwFlags Or MAFA_COMPRESS, 0 ElseIf mnuMCAHighest.Checked Then @@ -1211,7 +1217,11 @@ If sLine <> "" Then ElseIf cType = -1 Then mAddAutoFile hMPQ, FullPath(CurPath, fLine), Param(3) + fLine ElseIf cType = 1 Then - MpqAddFileToArchiveEx hMPQ, FullPath(CurPath, fLine), Param(3) + fLine, dwFlags, DefaultCompress, DefaultCompressLevel + If DefaultCompress = MAFA_COMPRESS_DEFLATE Then + MpqAddFileToArchiveEx hMPQ, FullPath(CurPath, fLine), Param(3) + fLine, dwFlags, DefaultCompress, DefaultCompressLevel + Else + MpqAddFileToArchiveEx hMPQ, FullPath(CurPath, fLine), Param(3) + fLine, dwFlags, DefaultCompress, 0 + End If Else MpqAddFileToArchiveEx hMPQ, FullPath(CurPath, fLine), Param(3) + fLine, dwFlags, 0, 0 End If @@ -1233,7 +1243,11 @@ If sLine <> "" Then ElseIf cType = -1 Then mAddAutoFile hMPQ, FullPath(CurPath, fLine), Param(3) ElseIf cType = 1 Then - MpqAddFileToArchiveEx hMPQ, FullPath(CurPath, fLine), Param(3), dwFlags, DefaultCompress, DefaultCompressLevel + If DefaultCompress = MAFA_COMPRESS_DEFLATE Then + MpqAddFileToArchiveEx hMPQ, FullPath(CurPath, fLine), Param(3), dwFlags, DefaultCompress, DefaultCompressLevel + Else + MpqAddFileToArchiveEx hMPQ, FullPath(CurPath, fLine), Param(3), dwFlags, DefaultCompress, 0 + End If Else MpqAddFileToArchiveEx hMPQ, FullPath(CurPath, fLine), Param(3), dwFlags, 0, 0 End If @@ -2243,8 +2257,15 @@ Private Sub List_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then List_DblClick End Sub Private Sub List_KeyUp(KeyCode As Integer, Shift As Integer) +Dim fNum As Long, fSelect As Long If KeyCode = vbKeyDelete Then mnuMDelete_Click +ElseIf (Shift And vbCtrlMask) And KeyCode = vbKeyA Then + fSelect = List.SelectedItem.Index + For fNum = 1 To List.ListItems.Count + List.ListItems.Item(fNum).Selected = True + Next fNum + List.ListItems.Item(fSelect).Selected = True ElseIf KeyCode = 93 Or ((Shift And vbShiftMask) And KeyCode = vbKeyF10) Then On Error GoTo NotSelected List.SelectedItem.Tag = List.SelectedItem.Tag @@ -2373,6 +2394,8 @@ For bNum = 1 To UBound(Files) MpqAddFileToArchiveEx hMPQ, Files(bNum), ShortFiles(bNum), dwFlags Or MAFA_COMPRESS, MAFA_COMPRESS_STANDARD, 0 ElseIf mnuMCDeflate.Checked Then MpqAddFileToArchiveEx hMPQ, Files(bNum), ShortFiles(bNum), dwFlags Or MAFA_COMPRESS, MAFA_COMPRESS_DEFLATE, DefaultCompressLevel + ElseIf mnuMCBzip2.Checked Then + MpqAddFileToArchiveEx hMPQ, Files(bNum), ShortFiles(bNum), dwFlags Or MAFA_COMPRESS, MAFA_COMPRESS_BZIP2, 0 ElseIf mnuMCAMedium.Checked Then MpqAddWaveToArchive hMPQ, Files(bNum), ShortFiles(bNum), dwFlags Or MAFA_COMPRESS, 0 ElseIf mnuMCAHighest.Checked Then @@ -2608,6 +2631,8 @@ For bNum = 1 To UBound(Files) MpqAddFileToArchiveEx hMPQ, Files(bNum), ShortFiles(bNum), dwFlags Or MAFA_COMPRESS, MAFA_COMPRESS_STANDARD, 0 ElseIf mnuMCDeflate.Checked Then MpqAddFileToArchiveEx hMPQ, Files(bNum), ShortFiles(bNum), dwFlags Or MAFA_COMPRESS, MAFA_COMPRESS_DEFLATE, DefaultCompressLevel + ElseIf mnuMCBzip2.Checked Then + MpqAddFileToArchiveEx hMPQ, Files(bNum), ShortFiles(bNum), dwFlags Or MAFA_COMPRESS, MAFA_COMPRESS_BZIP2, 0 ElseIf mnuMCAMedium.Checked Then MpqAddWaveToArchive hMPQ, Files(bNum), ShortFiles(bNum), dwFlags Or MAFA_COMPRESS, 0 ElseIf mnuMCAHighest.Checked Then @@ -2719,6 +2744,8 @@ For bNum = 1 To UBound(Files) MpqAddFileToArchiveEx hMPQ, Files(bNum), ShortFiles(bNum), dwFlags Or MAFA_COMPRESS, MAFA_COMPRESS_STANDARD, 0 ElseIf mnuMCDeflate.Checked Then MpqAddFileToArchiveEx hMPQ, Files(bNum), ShortFiles(bNum), dwFlags Or MAFA_COMPRESS, MAFA_COMPRESS_DEFLATE, DefaultCompressLevel + ElseIf mnuMCBzip2.Checked Then + MpqAddFileToArchiveEx hMPQ, Files(bNum), ShortFiles(bNum), dwFlags Or MAFA_COMPRESS, MAFA_COMPRESS_BZIP2, 0 ElseIf mnuMCAMedium.Checked Then MpqAddWaveToArchive hMPQ, Files(bNum), ShortFiles(bNum), dwFlags Or MAFA_COMPRESS, 0 ElseIf mnuMCAHighest.Checked Then @@ -2771,6 +2798,7 @@ Private Sub mnuMCAHighest_Click() mnuMCNone.Checked = False mnuMCStandard.Checked = False mnuMCDeflate.Checked = False +mnuMCBzip2.Checked = False mnuMCALowest.Checked = False mnuMCAMedium.Checked = False mnuMCAHighest.Checked = True @@ -2780,6 +2808,7 @@ Private Sub mnuMCALowest_Click() mnuMCNone.Checked = False mnuMCStandard.Checked = False mnuMCDeflate.Checked = False +mnuMCBzip2.Checked = False mnuMCALowest.Checked = True mnuMCAMedium.Checked = False mnuMCAHighest.Checked = False @@ -2791,6 +2820,7 @@ Private Sub mnuMCAMedium_Click() mnuMCNone.Checked = False mnuMCStandard.Checked = False mnuMCDeflate.Checked = False +mnuMCBzip2.Checked = False mnuMCALowest.Checked = False mnuMCAMedium.Checked = True mnuMCAHighest.Checked = False @@ -2800,16 +2830,29 @@ Private Sub mnuMCAuto_Click() mnuMCNone.Checked = False mnuMCStandard.Checked = False mnuMCDeflate.Checked = False +mnuMCBzip2.Checked = False mnuMCALowest.Checked = False mnuMCAMedium.Checked = False mnuMCAHighest.Checked = False mnuMCAuto.Checked = True End Sub +Private Sub mnuMCBzip2_Click() +mnuMCNone.Checked = False +mnuMCStandard.Checked = False +mnuMCDeflate.Checked = False +mnuMCBzip2.Checked = True +mnuMCALowest.Checked = False +mnuMCAMedium.Checked = False +mnuMCAHighest.Checked = False +mnuMCAuto.Checked = False +End Sub + Private Sub mnuMCDeflate_Click() mnuMCNone.Checked = False mnuMCStandard.Checked = False mnuMCDeflate.Checked = True +mnuMCBzip2.Checked = False mnuMCALowest.Checked = False mnuMCAMedium.Checked = False mnuMCAHighest.Checked = False @@ -2838,6 +2881,7 @@ Private Sub mnuMCNone_Click() mnuMCNone.Checked = True mnuMCStandard.Checked = False mnuMCDeflate.Checked = False +mnuMCBzip2.Checked = False mnuMCALowest.Checked = False mnuMCAMedium.Checked = False mnuMCAHighest.Checked = False @@ -2870,6 +2914,7 @@ Private Sub mnuMCStandard_Click() mnuMCNone.Checked = False mnuMCStandard.Checked = True mnuMCDeflate.Checked = False +mnuMCBzip2.Checked = False mnuMCALowest.Checked = False mnuMCAMedium.Checked = False mnuMCAHighest.Checked = False @@ -3224,6 +3269,8 @@ For fNum = 1 To UBound(OpenFiles) MpqAddFileToArchiveEx hMPQ, FullPath(Path, OpenFiles(fNum)), OpenFiles(fNum), dwFlags Or MAFA_COMPRESS, MAFA_COMPRESS_STANDARD, 0 ElseIf mnuMCDeflate.Checked Then MpqAddFileToArchiveEx hMPQ, FullPath(Path, OpenFiles(fNum)), OpenFiles(fNum), dwFlags Or MAFA_COMPRESS, MAFA_COMPRESS_DEFLATE, DefaultCompressLevel + ElseIf mnuMCBzip2.Checked Then + MpqAddFileToArchiveEx hMPQ, FullPath(Path, OpenFiles(fNum)), OpenFiles(fNum), dwFlags Or MAFA_COMPRESS, MAFA_COMPRESS_BZIP2, 0 ElseIf mnuMCAMedium.Checked Then MpqAddWaveToArchive hMPQ, FullPath(Path, OpenFiles(fNum)), OpenFiles(fNum), dwFlags Or MAFA_COMPRESS, 0 ElseIf mnuMCAHighest.Checked Then