if anyone wants to help me put this togeather please contact me by pming me or at my hotmail which i am usually never on.
fudgy - [email protected]
i will give credit and you can probably help me learn more.
but basically i just want to make a halo2 program like dot halo. and such. please help.
my code for the open, save bottons/file menu tab.
Code: Select all
Private Sub OpenMapToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenMapToolStripMenuItem.Click
Dim data As String = ""
Dim Open As New OpenFileDialog()
Dim myStreamReader As System.IO.StreamReader
Open.Filter = "Halo Map (*.map)|*.map"
Open.CheckFileExists = True
Open.Title = "Open Halo Map"
Open.ShowDialog(Me)
Try
Open.OpenFile()
myStreamReader = System.IO.File.OpenText(Open.FileName)
data = myStreamReader.ReadToEnd()
Catch ex As Exception
MsgBox("An error has occured.")
End Try
End Sub
Private Sub SaveMapToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveMapToolStripMenuItem.Click
Dim data As String = ""
Dim Save As New SaveFileDialog()
Dim myStreamWriter As System.IO.StreamWriter
Save.Filter = "Halo Map (*.map)|*.map"
Save.CheckPathExists = True
Save.Title = "Save Map"
Save.ShowDialog(Me)
Try
myStreamWriter = System.IO.File.AppendText(Save.FileName)
myStreamWriter.Write(data)
myStreamWriter.Flush()
Catch ex As Exception
MsgBox("An error has occured.")
End Try
End Sub
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim TempInteger As Integer = HaloMap.FindTagIndexByPath(ListBox1.Text)
If TempInteger = 0 Then Exit Sub
'This is the TagMeta offset that we will be editing
Dim TagMetaOffset As Long = HaloMap.H2Tag(TempInteger).MetaOffset
'This is the offset thats on the XML plugin or the offset in the meta you want to edit
Dim PluginValue As Long = Hex("504")
'Open up a BinaryWriter so we can write our value
Dim BW As New BinaryWriter(New FileStream(HaloMap.MapLocation, FileMode.Open, FileAccess.Write, FileShare.Write))
'Move to the Offset of the value we want to edit
BW.BaseStream.Position = TagMetaOffset + PluginValue
'Write the value
'Note: Not all values are Singles some can be other data types
Dim TempSingle As Single = TextBox1.Text
BW.Write(TempSingle)
'Close the map
BW.Close()
End Sub
End Class
Code: Select all
Private Sub ListBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox2.SelectedIndexChanged
Dim TempInteger As Integer = HaloMap.FindTagIndexByPath(ListBox1.Text)
If TempInteger = 0 Then Exit Sub
'This is the TagMeta offset that we will be editing
Dim TagMetaOffset As Long = HaloMap.H2Tag(TempInteger).MetaOffset
'This is the offset thats on the XML plugin or the offset in the meta you want to edit
Dim PluginValue As Long = ("504")
'Open up a BinaryReader so we can read our value
Dim BR As New BinaryReader(New FileStream(HaloMap.MapLocation, FileMode.Open, FileAccess.Read, FileShare.Read))
'Move to the Offset of the value we want to edit
BR.BaseStream.Position = TagMetaOffset + PluginValue
'Read the value
'Note: Not all values are Singles some can be other data types
TextBox1.Text = BR.ReadSingle
'Close the map
BR.Close()
End Sub
Public Sub LoadH2Map()
Dim BR As New BinaryReader(New FileStream(MapLocation, FileMode.Open, FileAccess.Read, FileShare.Read))
BR.BaseStream.Position = 16
indexOffset = BR.ReadInt32()
indexSize = BR.ReadInt32()
metaSize = BR.ReadInt32()
BR.BaseStream.Position = 708
fileTableOffset = BR.ReadInt32()
BR.BaseStream.Position = 408
Dim tempcharforname As Char = " "
Do While tempcharforname <> Chr(0)
tempcharforname = BR.ReadChar
If tempcharforname <> Chr(0) Then mapName &= tempcharforname
Loop
BR.BaseStream.Position = indexOffset - primaryMagicConstantMagic = BR.ReadInt32()
BR.BaseStream.Position += 4
objectIndexOffset = BR.ReadInt32()
BR.BaseStream.Position += 12
objectCount = BR.ReadInt32()
Dim TagStart As Long = indexOffset + 32 + (objectIndexOffset - primaryMagicConstantMagic)
ReDim H2Tag(0 To objectCount + 1)
BR.BaseStream.Position = TagStart
For i As Integer = 1 To objectCount Step 1
H2Tag(i).TagClass = StrReverse(BR.ReadChars(4))
H2Tag(i).TagID = BR.ReadInt32()
H2Tag(i).MetaOffset = BR.ReadInt32()
H2Tag(i).MetaSize = BR.ReadInt32()
Next
mapMagic = H2Tag(1).MetaOffset - (indexOffset + indexSize)
mapSecondaryMagic = primaryMagicConstantMagic - indexOffset - 32
For i As Integer = 1 To objectCount Step 1
H2Tag(i).MetaOffset = H2Tag(i).MetaOffset - mapMagic
Next
BR.BaseStream.Position = fileTableOffset
For i As Integer = 1 To objectCount Step 1
Dim tempchar As Char = " "
Do While tempchar <> Chr(0)
tempchar = BR.ReadChar()
H2Tag(i).TagPath &= tempchar
Loop
Next
BR.Close()
MapLoaded = True
End Sub
Public Sub LoadIntoTreeView(ByVal TreeView1 As TreeView, ByVal ProgressBar1 As ProgressBar)
TreeView1.Nodes.Add("Map(" & mapName & ")")
TreeView1.Sorted = True
ProgressBar1.Maximum = objectCount + 1
ProgressBar1.Minimum = 0
ProgressBar1.Value = 0
Dim templistbox As New ListBox
For x As Integer = 1 To objectCount Step 1
'If the templistbox dosent have the class in it then add it to it and also add it to the treeview
If templistbox.Items.Contains(H2Tag(x).TagClass) = False Then
templistbox.Items.Add(H2Tag(x).TagClass)
TreeView1.Nodes(0).Nodes.Add(BuildClassNode(H2Tag(x).TagClass))
Application.DoEvents()
End If
'Increase the Progressbar
ProgressBar1.Value += 1
Next
'Dispose the templistbox
templistbox.Dispose()
'Expand the TreeView
TreeView1.Nodes(0).Expand()
'Reset the Progressbar to 0
ProgressBar1.Value = 0
End Sub
Private Function BuildClassNode(ByVal tagClass As String)
'create a temp TreeNode
Dim ClassNode As New TreeNode
'Set the text to the tagclass
ClassNode.Text = "[" & tagClass & "]"
'Loop through all the tags and if its of the class we want then add to the node
For i As Integer = 1 To objectCount Step 1
If H2Tag(i).TagClass = tagClass Then
ClassNode.Nodes.Add(H2Tag(i).TagPath)
End If
Next
'return the node we put together
Return ClassNode
End Function
Public Sub LoadIntoListBox(ByVal Listbox1 As ListBox, ByVal ProgressBar1 As ProgressBar, Optional ByVal TagClass As String = "")
'Set up the ProgressBars
ProgressBar1.Maximum = objectCount + 1
ProgressBar1.Minimum = 0
ProgressBar1.Value = 0
'If they dont specify A tagClass then do all then if they do then do just that class
If TagClass = "" Then
'This will let you use a Listbox
For i As Integer = 1 To objectCount Step 1
Listbox1.Items.Add(H2Tag(i).TagPath)
ProgressBar1.Value += 1
Next
Else
'This will let you use a Listbox with only 1 tag class
For i As Integer = 1 To objectCount Step 1
If H2Tag(i).TagClass = TagClass Then
Listbox1.Items.Add(H2Tag(i).TagPath)
End If
ProgressBar1.Value += 1
Next
End If
ProgressBar1.Value = 0
End Sub
Public Function FindTagIndexByPath(ByVal TagPath As String) As Integer
Dim index As Integer = 0
'Loop through all the tags and if we find a matching path then we return then index of it
For i As Integer = 1 To objectCount Step 1
If H2Tag(i).TagPath = TagPath Then
index = i
Exit For
End If
Next
Return index
End Function
End Class