home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / dump_s1r / docwadpr.dob < prev    next >
Encoding:
Text File  |  1998-12-27  |  14.4 KB  |  471 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "COMDLG32.OCX"
  3. Begin VB.UserDocument  docWadProp
  4.    AutoRedraw      =   -1  'True
  5.    ClientHeight    =   4908
  6.    ClientLeft      =   48
  7.    ClientTop       =   48
  8.    ClientWidth     =   7812
  9.    LockControls    =   -1  'True
  10.    Palette         =   "WadProp.frx":000C
  11.    PaletteMode     =   2  'Custom
  12.    ScaleHeight     =   4908
  13.    ScaleWidth      =   7812
  14.    Begin VB.CommandButton cmdLoadExternaL 
  15.       Caption         =   "Load ExternaL"
  16.       Height          =   345
  17.       Left            =   3720
  18.       TabIndex        =   22
  19.       Top             =   270
  20.       Width           =   1275
  21.    End
  22.  
  23.    Begin VB.CommandButton cmdNew 
  24.       Caption         =   "New..."
  25.       Height          =   345
  26.       Left            =   2400
  27.       TabIndex        =   17
  28.       Top             =   270
  29.       Width           =   1275
  30.    End
  31.  
  32.    Begin MSComDlg.CommonDialog c 
  33.       Left            =   2580
  34.       Top             =   2220
  35.       _ExtentX        =   847
  36.       _ExtentY        =   847
  37.       _Version        =   327681
  38.       CancelError     =   -1  'True
  39.       Filter          =   "LMP Files(*.lmp)|*.lmp"
  40.    End
  41.  
  42.    Begin VB.ComboBox cboWads 
  43.       Height          =   315
  44.       Left            =   60
  45.       Style           =   2  'Dropdown List
  46.       TabIndex        =   8
  47.       Top             =   270
  48.       Width           =   2310
  49.    End
  50.  
  51.    Begin VB.Frame fmWadProp 
  52.       Caption         =   "Selected Wads Properties"
  53.       Height          =   3795
  54.       Left            =   0
  55.       TabIndex        =   1
  56.       Top             =   660
  57.       Width           =   7755
  58.  
  59.       Begin VB.CommandButton Command1 
  60.          Caption         =   "Export +"
  61.          Height          =   315
  62.          Left            =   6720
  63.          TabIndex        =   19
  64.          Top             =   420
  65.          Width           =   945
  66.       End
  67.  
  68.       Begin VB.CommandButton cmdSaveAs 
  69.          Caption         =   "Save &As"
  70.          Height          =   315
  71.          Left            =   5730
  72.          TabIndex        =   16
  73.          Top             =   420
  74.          Width           =   945
  75.       End
  76.  
  77.       Begin VB.CommandButton cmdUpdate 
  78.          Caption         =   "&Save"
  79.          Default         =   -1  'True
  80.          Height          =   315
  81.          Left            =   4740
  82.          TabIndex        =   15
  83.          Top             =   420
  84.          Width           =   945
  85.       End
  86.  
  87.       Begin VB.CommandButton cmdExport 
  88.          Caption         =   "Export"
  89.          Height          =   315
  90.          Left            =   3750
  91.          TabIndex        =   14
  92.          Top             =   420
  93.          Width           =   945
  94.       End
  95.  
  96.       Begin VB.CommandButton cmdAddEnt 
  97.          Caption         =   "Add Entry"
  98.          Height          =   315
  99.          Left            =   2760
  100.          TabIndex        =   11
  101.          Top             =   420
  102.          Width           =   945
  103.       End
  104.  
  105.       Begin VB.CommandButton cmdDelEnt 
  106.          Caption         =   "Delete"
  107.          Height          =   315
  108.          Left            =   1770
  109.          TabIndex        =   10
  110.          Top             =   420
  111.          Width           =   945
  112.       End
  113.  
  114.       Begin VB.Frame fmEntProp 
  115.          Caption         =   "Entry Properties"
  116.          Height          =   2955
  117.          Left            =   60
  118.          TabIndex        =   4
  119.          Top             =   780
  120.          Width           =   7605
  121.  
  122.          Begin VB.CommandButton Command2 
  123.             Caption         =   "Re-Calc"
  124.             Height          =   315
  125.             Left            =   5250
  126.             TabIndex        =   23
  127.             Top             =   450
  128.             Width           =   945
  129.          End
  130.  
  131.          Begin VB.TextBox Text1 
  132.             Height          =   315
  133.             Left            =   3540
  134.             MaxLength       =   4
  135.             TabIndex        =   21
  136.             Text            =   "PWAD"
  137.             Top             =   450
  138.             Width           =   1635
  139.          End
  140.  
  141.          Begin VB.ComboBox cboEntryType 
  142.             Height          =   315
  143.             ItemData        =   "WadProp.frx":0052
  144.             Left            =   1740
  145.             List            =   "WadProp.frx":0089
  146.             Locked          =   -1  'True
  147.             Style           =   2  'Dropdown List
  148.             TabIndex        =   13
  149.             Top             =   450
  150.             Width           =   1755
  151.          End
  152.  
  153.          Begin VB.TextBox txtEByts 
  154.             Appearance      =   0  'Flat
  155.             BeginProperty Font 
  156.                Name            =   "Fixedsys"
  157.                Size            =   10.8
  158.                Charset         =   0
  159.                Weight          =   400
  160.                Underline       =   0   'False
  161.                Italic          =   0   'False
  162.                Strikethrough   =   0   'False
  163.             EndProperty
  164.             Height          =   1365
  165.             Left            =   60
  166.             MultiLine       =   -1  'True
  167.             ScrollBars      =   3  'Both
  168.             TabIndex        =   9
  169.             Text            =   "WadProp.frx":0174
  170.             Top             =   1560
  171.             Width           =   7455
  172.          End
  173.  
  174.          Begin VB.TextBox txtEName 
  175.             Height          =   315
  176.             Left            =   60
  177.             TabIndex        =   5
  178.             Text            =   "Name"
  179.             Top             =   450
  180.             Width           =   1635
  181.          End
  182.  
  183.          Begin VB.Label Label4 
  184.             AutoSize        =   -1  'True
  185.             Caption         =   "Header Text:"
  186.             Height          =   195
  187.             Left            =   3570
  188.             TabIndex        =   20
  189.             Top             =   240
  190.             Width           =   930
  191.          End
  192.  
  193.          Begin VB.Label Label3 
  194.             AutoSize        =   -1  'True
  195.             Caption         =   "Position: 0"
  196.             Height          =   195
  197.             Left            =   60
  198.             TabIndex        =   18
  199.             Top             =   1020
  200.             Width           =   735
  201.          End
  202.  
  203.          Begin VB.Label lblSize 
  204.             AutoSize        =   -1  'True
  205.             Caption         =   "Size: "
  206.             Height          =   195
  207.             Left            =   60
  208.             TabIndex        =   12
  209.             Top             =   780
  210.             Width           =   390
  211.          End
  212.  
  213.          Begin VB.Label lblEName 
  214.             AutoSize        =   -1  'True
  215.             Caption         =   "Entry Name:"
  216.             Height          =   195
  217.             Left            =   60
  218.             TabIndex        =   6
  219.             Top             =   210
  220.             Width           =   870
  221.          End
  222.  
  223.       End
  224.       Begin VB.ComboBox cboResource 
  225.          Height          =   315
  226.          Left            =   60
  227.          Style           =   2  'Dropdown List
  228.          TabIndex        =   3
  229.          Top             =   420
  230.          Width           =   1665
  231.       End
  232.  
  233.       Begin VB.Label Label1 
  234.          AutoSize        =   -1  'True
  235.          Caption         =   "Entries:"
  236.          Height          =   195
  237.          Left            =   60
  238.          TabIndex        =   2
  239.          Top             =   210
  240.          Width           =   525
  241.       End
  242.  
  243.    End
  244.    Begin VB.CommandButton cmdClose 
  245.       Cancel          =   -1  'True
  246.       Caption         =   "&Close"
  247.       Height          =   405
  248.       Left            =   3390
  249.       TabIndex        =   0
  250.       Top             =   4470
  251.       Width           =   1035
  252.    End
  253.  
  254.    Begin VB.Label Label2 
  255.       AutoSize        =   -1  'True
  256.       Caption         =   "Wad List:"
  257.       Height          =   195
  258.       Left            =   90
  259.       TabIndex        =   7
  260.       Top             =   30
  261.       Width           =   675
  262.    End
  263.  
  264. End
  265. Attribute VB_Name = "docWadProp"
  266. Attribute VB_GlobalNameSpace = False
  267. Attribute VB_Creatable = True
  268. Attribute VB_PredeclaredId = False
  269. Attribute VB_Exposed = True
  270. Option Explicit
  271. Const const_strWadFltr = "Wad Files(*.Wad)|*.Wad"
  272. Private cWad As New clsWad
  273. Private FFiles As New Files
  274. Private Sub cboResource_Click()
  275.     If cboResource.ListIndex = -1 Then Exit Sub
  276.     lblSize.Caption = "Size: " & cWad.ReturnLump(cboResource.ListIndex + 1).LumpSize
  277.     txtEName = cWad.ReturnLump(cboResource.ListIndex + 1).LumpName
  278.     cboEntryType.ListIndex = cWad.ReturnLump(cboResource.ListIndex + 1).LumpType
  279.     Dim bBytes() As Byte
  280.     cWad.ReturnLump(cboResource.ListIndex + 1).LumpBytes bBytes
  281.     If lblSize = "Size: 0" Then _
  282.         txtEByts = "": _
  283.         Label3.Caption = "Position: 0" _
  284.         : Exit Sub
  285.     If UBound(bBytes) >= 3000 Then
  286.         ReDim Preserve bBytes(1 To 3000)
  287.     End If
  288.     Label3.Caption = "Position: " & cWad.ReturnLump(cboResource.ListIndex + 1).LumpPosition
  289.     txtEByts = BytesToText(bBytes)
  290. End Sub
  291.  
  292. Private Sub cboWads_Click()
  293.     cboResource.Clear
  294.     If cboWads.ListIndex = -1 Then
  295.         Text1.Enabled = False
  296.         Exit Sub
  297.     End If
  298.     Set cWad = New clsWad
  299.     cWad.Load FFiles(cboWads.ListIndex + 1).FileName
  300.     Text1.Enabled = True
  301.     Text1.Text = cWad.WadType
  302.     Update2
  303. End Sub
  304.  
  305. Private Sub cmdAddEnt_Click()
  306.     Dim m_strEntryName As String, m_msgRet As VbMsgBoxResult, bts() As Byte
  307.     m_strEntryName = InputBox("Enter the Name of the New Entry...", "Define Lump Name", "NewLumpX")
  308.     If m_strEntryName = "" Then _
  309.         Exit Sub
  310.     m_msgRet = MsgBox("Is the Entry in a file?", vbYesNo + vbQuestion, "Query")
  311.     If m_msgRet = vbYes Then
  312.         On Error Resume Next
  313.         c.Filter = "Mus Files (*.mus)|*.mus|ppm [Image] Files (*.ppm)|*.ppm|All Files (*.*)|*.*"
  314.         c.ShowOpen
  315.         If Err <> 0 Then Exit Sub
  316.         If Not FileLen(c.FileName) = 0 Then
  317.             ReDim bts(1 To FileLen(c.FileName))
  318.             Open c.FileName For Binary As #1
  319.             Get #1, 1, bts
  320.             Close #1
  321.                 If cWad.Count = 0 Then
  322.                     cWad.AddLump bts, m_strEntryName, 12, UBound(bts)
  323.                     cWad.LumpDirectory.AddEntry m_strEntryName, UBound(bts), 12
  324.                 Else
  325.                     cWad.AddLump bts, m_strEntryName, cWad.ReturnLump(cWad.Count).LumpPosition + cWad.ReturnLump(cWad.Count).LumpSize, UBound(bts)
  326.                     cWad.LumpDirectory.AddEntry m_strEntryName, UBound(bts), cWad.ReturnLump(cWad.Count).LumpPosition + cWad.ReturnLump(cWad.Count).LumpSize
  327.                 End If
  328.             cWad.ReCalc
  329.             cWad.LumpDirectory.ReCalc
  330.             Update2
  331.             Exit Sub
  332.         End If
  333.     End If
  334.     ReDim bts(0)
  335.     cWad.AddLump bts, m_strEntryName, 0, 0
  336.     cWad.LumpDirectory.AddEntry m_strEntryName, 0, 0
  337.     cWad.ReCalc
  338.     cWad.LumpDirectory.ReCalc
  339.     Update2
  340. End Sub
  341.  
  342. Private Sub cmdClose_Click()
  343.     Unload Me
  344. End Sub
  345.  
  346. Public Sub SetUp(Files As Files)
  347.     Set FFiles = Files
  348.     Update1
  349.     Show
  350. End Sub
  351.  
  352. Public Sub Update1()
  353.     Dim m_lngLoop As Long
  354.     cboWads.Clear
  355.     For m_lngLoop = 1 To FFiles.Count
  356.     cboWads.AddItem FFiles(m_lngLoop).IDName
  357.     Next
  358.     Update2
  359. End Sub
  360.  
  361. Public Sub Update2()
  362.     Dim m_lngLoop As Long
  363.     If cboWads.ListIndex = -1 Then Exit Sub
  364.     cboResource.Clear
  365.     For m_lngLoop = 1 To cWad.Count
  366.         If InStr(1, cWad.ReturnLump(m_lngLoop).LumpName, Chr(0)) = 0 Then
  367.             cboResource.AddItem cWad.ReturnLump(m_lngLoop).LumpName
  368.         Else
  369.             cboResource.AddItem Mid(cWad.ReturnLump(m_lngLoop).LumpName, 1, InStr(1, cWad.ReturnLump(m_lngLoop).LumpName, Chr(0))) 'cWad.ReturnLump(m_lngLoop).LumpName
  370.         End If
  371.     Next
  372. End Sub
  373.  
  374. Public Function BytesToText(Text() As Byte) As String
  375.     Dim Buffer As String, id As Integer, m_lngLoop As Long
  376.     For m_lngLoop = 1 To UBound(Text)
  377.         Buffer = Buffer & (Text(m_lngLoop)) & "-"
  378.     If id = 30 Then Buffer = Buffer & vbCrLf: id = 0
  379.         id = id + 1
  380.     Next
  381.     BytesToText = Mid(Buffer, 1, Len(Buffer) - 1)
  382. End Function
  383.  
  384. Private Sub cmdDelEnt_Click()
  385.     If cboResource.ListIndex = -1 Then Exit Sub
  386.     Dim m_msgRes As VbMsgBoxResult
  387.     m_msgRes = MsgBox("Are you sure you wish to delete this entry?", vbQuestion + vbYesNo, "Query")
  388.     If m_msgRes = vbYes Then
  389.         cWad.DeleteLump cboResource.ListIndex + 1
  390.         Update2
  391.     End If
  392. End Sub
  393.  
  394. Private Sub cmdExport_Click()
  395.     On Error Resume Next
  396.     Dim Bytes() As Byte
  397.     c.Filter = "LMP Files(*.lmp)|*.lmp"
  398.     c.Flags = cdlOFNCreatePrompt + 4
  399.     c.ShowSave
  400.     If Err = cdlCancel Then Exit Sub
  401.     cWad.ReturnLump(cboResource.ListIndex + 1).LumpBytes Bytes
  402.     Open c.FileName For Binary As #1
  403.         Put #1, 1, Bytes
  404.     Close #1
  405. End Sub
  406.  
  407. Private Sub cmdLoadExternaL_Click()
  408.     c.Filter = const_strWadFltr
  409.     On Error Resume Next
  410.     c.ShowOpen
  411.     If Err = cdlCancel Then Exit Sub
  412.     FFiles.Add c.FileName, ReturnExtention(c.FileName, False, "\")
  413.     Update1
  414. End Sub
  415.  
  416. Private Sub cmdNew_Click()
  417.     c.Filter = const_strWadFltr
  418.     Dim m_msgRes As VbMsgBoxResult
  419.     m_msgRes = MsgBox("Do you wish to create a new BLANK Wad file?", vbYesNo + vbQuestion, "Query")
  420.     If Not m_msgRes = vbYes Then
  421.         Exit Sub
  422.     End If
  423.     On Error Resume Next
  424.     c.ShowSave
  425.     If Err <> 0 Then Exit Sub
  426.     On Error GoTo 0
  427.     Set cWad = New clsWad
  428.     cWad.WadDirStart = 12
  429.     cWad.WadType = "PWAD"
  430.     cWad.WadLumpCount = 0
  431.     cWad.Save c.FileName
  432.     FFiles.Add c.FileName, ReturnExtention(c.FileName, False, "\")
  433.     Update1
  434. End Sub
  435.  
  436. Private Sub cmdSaveAs_Click()
  437.     On Error Resume Next
  438.     Dim Bytes() As Byte
  439.     c.Filter = const_strWadFltr
  440.     c.Flags = cdlOFNCreatePrompt + 4
  441.     c.ShowSave
  442.     If Err = cdlCancel Then Exit Sub
  443.     cWad.Save c.FileName
  444. End Sub
  445.  
  446. Private Sub cmdUpdate_Click()
  447.     If cboWads.ListIndex = -1 Then Exit Sub
  448.     cWad.Save FFiles(cboWads.ListIndex + 1).FileName
  449.     Update2
  450. End Sub
  451.  
  452. Private Sub Command2_Click()
  453.     cWad.ReCalc
  454. End Sub
  455.  
  456.  
  457. Private Sub Text1_Change()
  458.     Text1 = UCase(Text1)
  459.     If Not (Text1 = "PWAD" Or Text1 = "IWAD") Then
  460.         Text1 = "PWAD"
  461.     End If
  462.     cWad.WadType = Text1
  463. End Sub
  464.  
  465. Private Sub txtEName_Change()
  466.     If cboResource.ListIndex = -1 Or cboWads.ListIndex = -1 Then Exit Sub
  467.     cWad.ReturnLump(cboResource.ListIndex + 1).LumpName = txtEName
  468.     cWad.LumpDirectory(cboResource.ListIndex + 1).LumpName = txtEName
  469.     cboResource.List(cboResource.ListIndex) = txtEName
  470. End Sub
  471.