home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / dump_s1r / wadprop.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-12-15  |  14.6 KB  |  436 lines

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