Re: [VB.Net]2d Map Creator
Hi Dave,
Nice work as usual. I found a couple of bugs, though:
The very first time you run the code, My.Settings.tile_location is set to String.Empty, so the code bugs out on the highlighted line. (tile_location will also be String.Empty). Of course, as this sub is called from the Form1 Load event handler, on a 64 bit OS the error will be swallowed while in Debug mode and the form will still show, but without any images.
Code:
Private tile_location As String = My.Settings.tile_location
Private tile_list As New List(Of Map_Tile)
Private Sub load_images()
If tile_location = String.Empty Then
MessageBox.Show("Please navigate to the folder that stores your tiles.", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning)
Dim fbd As New FolderBrowserDialog
fbd.RootFolder = Environment.SpecialFolder.MyComputer
If fbd.ShowDialog = Windows.Forms.DialogResult.OK Then
My.Settings.tile_location = fbd.SelectedPath
My.Settings.Save()
Dim FileDirectory As New IO.DirectoryInfo(tile_location)
Dim FileJpg As IO.FileInfo() = FileDirectory.GetFiles("*.jpg")
Dim FileGif As IO.FileInfo() = FileDirectory.GetFiles("*.gif")
Dim FileBmp As IO.FileInfo() = FileDirectory.GetFiles("*.bmp")
Dim FilePng As IO.FileInfo() = FileDirectory.GetFiles("*.png")
In the Board_MouseClick and board_MouseMove Subs, when you are filling blocks of multiple tiles the tiles may not go right up to the edges of the board. For example, select RadioButton3 or RadioButton5 (3x3 or 5x5) and click in the tile at location 1,1 (remembering 0,0 is the top left tile). I think this is being caused by your conditionals such as:
Code:
If xind - 1 > 0 AndAlso yind + 2 < board_size.Height - 1 Then
where they should be:
Code:
If xind - 1 >= 0 AndAlso yind + 2 <= board_size.Height - 1 Then
When I first ran the code, the Save Button did not appear since the splitter panel had resized so as to hide it (confused me for a while :)). Perhaps you could set the panel it is on to be SplitContainer3's FixedPanel, and/or allow scroll bars for the panels on the left hand side of the Form.
Finally, as there are 2500 tiles on the map, it's taking a fair bit of time to add all the tiles to Panel2. I think you might be able to speed up the loading of the Form by using SuspendLayout for Panel2 while you are creating its tiles; something like:
Code:
'Load board
SplitContainer1.Panel2.SuspendLayout()
Call load_board()
SplitContainer1.Panel2.ResumeLayout()
I always enjoy your projects. Keep 'em coming! :)
Re: [VB.Net]2d Map Creator
Quote:
Of course, as this sub is called from the Form1 Load event handler, on a 64 bit OS the error will be swallowed while in Debug mode and the form will still show, but without any images.
Ah that's something I didn't think about. I was always running it with a location all ready picked out, so that's something I must've overlooked!
Quote:
For example, select RadioButton3 or RadioButton5 (3x3 or 5x5) and click in the tile at location 1,1 (remembering 0,0 is the top left tile). I think this is being caused by your conditionals such as
Rookie mistake :p
Quote:
When I first ran the code, the Save Button did not appear since the splitter panel had resized so as to hide it (confused me for a while ). Perhaps you could set the panel it is on to be SplitContainer3's FixedPanel, and/or allow scroll bars for the panels on the left hand side of the Form.
Could you post a screen shot of that for me, I wasn't able to reproduce it.
Quote:
I think you might be able to speed up the loading of the Form by using SuspendLayout for Panel2 while you are creating its tiles; something like:
Cool, I had no idea about Suspend/Resume Layout! That would definitely help out.