K. Here's a tutorial for a BLIC editor. I'm just going to explain the display part. This is actually a pretty easy tutorial.
First make the form as follows with 4 list boxes, a button and a combobox: (obviously you can use comboboxes for each player but this is quicker for displaying)
Label as follows:
Again import system.io, inherit system.windows.forms.forms and declare our global variables:
The open sub is very simular to the c2k5 one. Just change the filter and extension. Feel free to just copy and paste this part (I do the whole time!):
Code:
System.Windows.Forms.Application.EnableVisualStyles()
Dim strFileName As String
With OpenFileDialog1
.Filter = "BLIC 2005 roster file|*.bag"
.ShowDialog()
strFileName = .FileName
End With
If strFileName = vbNullString Then Exit Sub
If Not IsNothing(FS) Then
BR.Close()
BW.Close()
FS.Close()
FS = Nothing
End If
FS = New FileStream(strFileName, FileMode.Open, FileAccess.ReadWrite)
BR = New BinaryReader(FS)
BW = New BinaryWriter(FS)
cboteams.Items.Clear()
Then we need to load up our teams combobox: (first clear it as you see above)
The longest team name is 20 charactors so we'll declare chrteam(20), also x as integer. I like using x for my loops; no idea why...
For x = 0 To 79
There are 80 teams to load so we set out loop as follows
FS.Seek((6144 + x * 3328), SeekOrigin.Begin)
6144 is the offset the first team is found at
3328 is how many bytes per team
Therefore we're adding 6144 to the team number times 3328. So first the loop will load team 0 at 6144 + 0*3328 then team 1 at 6144 + 1*3328 etc
FS.Seek(0, SeekOrigin.Current)
The team name is the first thing we find. We use seek origin current to show that it is relative to where we are at the moment and not absolute to the file.
chrTeam = BR.ReadChars(20)
Reads the next 20 bytes as ASCII charactors
cboteams.Items.Add(Convert.ToString(chrTeam))
Adds the 20 bytes converted to a string to the list box
next
Goes back to For until x = 79
cboteams.SelectedIndex = 0
Sets our teams combobox to index 0. You'll see why this is important in a minute.
Now the combobox selected index changed sub. In other words whatever will happen when we change the team.
Declare some variables and clear all 4 list boxes. This is important as, if you don't clear the list boxes, they will keep adding onto the end when you load a new team.
We're also going to define i as follows:
Code:
i = 6144 + cboteams.SelectedIndex * 3328
i therefore will equal the start byte of the selected team.
Next we'll code the test lineup listbox:
Lineups in the roster are listed by player position so if M.Vaughan is the first player in the England roster he will show as 0. There will be 11 bytes consecutively where the numbers will be anything from 0 to 15.
For x = 3238 To 3248
The test lineup is found between bytes 3238 and 3248 of the team info.
FS.Seek(i + x, SeekOrigin.Begin)
The start of the team added to the first player, then second player, then third player.
a = BR.ReadByte
Will be between 0 and 15 (16 players in a team)
FS.Seek(i + 40 + a * 168 + 2, SeekOrigin.Begin)
This calculates the player name. Byte 40 is where the first player name is in the team bytes. A player has 168 bytes so we multiply that by the player number. We then add 2 as the first two bytes of a player are the ID.
playername = BR.ReadChars(20)
This gives us the player name
lsttest.Items.Add(Convert.ToString(playername))
Add it to lsttest exactly the same way as we added items to the combobox.
Exactly the same for the ODI listbox. Just add to that rather than test and use different bytes.
The bowler bytes are relative not to the position in the roster but to the position in the lineup. So they will range from 0 to 9. For blank it will show 255 instead.
Code:
For x = 3260 To 3269
FS.Seek(i + x, SeekOrigin.Begin)
a = BR.ReadByte
Pretty obvious by now hopefully...
Code:
If a <> 255 Then
lsttest.SelectedIndex = a
playername = lsttest.Text
Else
playername = ""
End If
Then we put an if statement in. If the byte we've read isn't 255 then we set the index of the test list box to it. We then read off what the text selected is and that is saved to variable 'playername'.
If it does equal 255 then 'playername' will show as blank: ""
lsttestbowl.Items.Add(Convert.ToString(playername))
Add the player name to the listbox and then go back and do it all again.
Exactly the same for ODI lineup.
Finally deselect the current item in the test list by putting:
Good luck.