diff --git a/.vs/GBAPokemonGameEditor/v15/.suo b/.vs/GBAPokemonGameEditor/v15/.suo index f67f918..cf22111 100644 Binary files a/.vs/GBAPokemonGameEditor/v15/.suo and b/.vs/GBAPokemonGameEditor/v15/.suo differ diff --git a/.vs/GBAPokemonGameEditor/v15/Server/sqlite3/storage.ide-shm b/.vs/GBAPokemonGameEditor/v15/Server/sqlite3/storage.ide-shm index 651c97d..1c8de21 100644 Binary files a/.vs/GBAPokemonGameEditor/v15/Server/sqlite3/storage.ide-shm and b/.vs/GBAPokemonGameEditor/v15/Server/sqlite3/storage.ide-shm differ diff --git a/GBAPokemonGameEditor/ImportDataFunctions.vb b/GBAPokemonGameEditor/ImportDataFunctions.vb index e75f647..a9736b4 100644 --- a/GBAPokemonGameEditor/ImportDataFunctions.vb +++ b/GBAPokemonGameEditor/ImportDataFunctions.vb @@ -764,4 +764,66 @@ Module ImportDataFunctions End Sub + Public Sub ImportPokemonIconNewOffset(filename As String, PokemonIndex As Integer) + + Dim iconpals(2)() As Color + + Dim importimg As New Bitmap(filename) + + + If importimg.Height <> &H40 Or importimg.Width <> &H20 Then + + MsgBox("Image dimensions must be 32 by 64! Aborting...") + Exit Sub + End If + + Dim palval As Integer + + Dim sOffset As Integer = Int32.Parse(GetString(GetINIFileLocation(), header, "IconPointerTable", ""), System.Globalization.NumberStyles.HexNumber) + (PokemonIndex * 4) + + Dim pOffset As Integer = Int32.Parse(GetString(GetINIFileLocation(), header, "IconPals", ""), System.Globalization.NumberStyles.HexNumber) + + Dim hexstring As String = "" + Dim ImgNewOffset + Dim ImgBytes As Byte() + Dim ImgString As String + + + Using fs As New FileStream(LoadedROM, FileMode.Open, FileAccess.Read) + Using r As New BinaryReader(fs) + + fs.Position = sOffset + sOffset = r.ReadInt32 - &H8000000 + + fs.Position = pOffset + + Dim indexvar As Integer = 0 + + Do + iconpals(indexvar) = LoadPaletteFromROM(fs) + indexvar += 1 + Loop While (indexvar <= 2) + + fs.Close() + r.Close() + + End Using + End Using + + palval = GetClosestPalette(importimg, iconpals) + + ConvertBitmapToPalette(importimg, iconpals(palval), True) + ImgBytes = ConvertStringToByteArray(CompressLz77String(ConvertByteArrayToString(SaveBitmapToArray(importimg, iconpals(palval))))) + ImgString = ByteArrayToHexString(ImgBytes) + hexstring = ByteArrayToHexString(SaveBitmapToArray(importimg, iconpals(palval))) + ImgNewOffset = SearchFreeSpaceFourAligned(LoadedROM, &HFF, ((Len(hexstring) / 2)), "&H" & GetString(GetINIFileLocation(), header, "B00000", "B00000")) + WriteHEX(LoadedROM, ImgNewOffset, hexstring) + + + sOffset = Int32.Parse(GetString(GetINIFileLocation(), header, "IconPointerTable", ""), System.Globalization.NumberStyles.HexNumber) + (PokemonIndex * 4) + + WriteHEX(LoadedROM, Int32.Parse((GetString(GetINIFileLocation(), header, "IconPalTable", "")), System.Globalization.NumberStyles.HexNumber) + PokemonIndex, Hex(palval)) + WriteHEX(LoadedROM, sOffset, ReverseHEX(Hex((ImgNewOffset) + &H8000000))) + End Sub + End Module diff --git a/GBAPokemonGameEditor/Pokemonedit.Designer.vb b/GBAPokemonGameEditor/Pokemonedit.Designer.vb index 1d21d18..1a0343e 100644 --- a/GBAPokemonGameEditor/Pokemonedit.Designer.vb +++ b/GBAPokemonGameEditor/Pokemonedit.Designer.vb @@ -226,6 +226,7 @@ Partial Class Pokemonedit Me.GroupBox2 = New System.Windows.Forms.GroupBox() Me.Clr1 = New System.Windows.Forms.ComboBox() Me.TabPage6 = New System.Windows.Forms.TabPage() + Me.Button43 = New System.Windows.Forms.Button() Me.GroupBox35 = New System.Windows.Forms.GroupBox() Me.Button35 = New System.Windows.Forms.Button() Me.Button36 = New System.Windows.Forms.Button() @@ -283,7 +284,8 @@ Partial Class Pokemonedit Me.Button30 = New System.Windows.Forms.Button() Me.Button38 = New System.Windows.Forms.Button() Me.Button39 = New System.Windows.Forms.Button() - Me.Button43 = New System.Windows.Forms.Button() + Me.Button40 = New System.Windows.Forms.Button() + Me.Button41 = New System.Windows.Forms.Button() Me.TabControl1.SuspendLayout() Me.TabPage1.SuspendLayout() Me.GroupBox26.SuspendLayout() @@ -409,7 +411,7 @@ Partial Class Pokemonedit ' 'Button20 ' - Me.Button20.Location = New System.Drawing.Point(9, 54) + Me.Button20.Location = New System.Drawing.Point(9, 50) Me.Button20.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) Me.Button20.Name = "Button20" Me.Button20.Size = New System.Drawing.Size(267, 35) @@ -581,13 +583,14 @@ Partial Class Pokemonedit ' 'GroupBox16 ' + Me.GroupBox16.Controls.Add(Me.Button40) Me.GroupBox16.Controls.Add(Me.Button22) Me.GroupBox16.Controls.Add(Me.Button21) Me.GroupBox16.Controls.Add(Me.IconPicBox) Me.GroupBox16.Controls.Add(Me.IconPal) Me.GroupBox16.Controls.Add(Me.Button4) Me.GroupBox16.Controls.Add(Me.IconPointer) - Me.GroupBox16.Location = New System.Drawing.Point(9, 92) + Me.GroupBox16.Location = New System.Drawing.Point(9, 95) Me.GroupBox16.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) Me.GroupBox16.Name = "GroupBox16" Me.GroupBox16.Padding = New System.Windows.Forms.Padding(4, 5, 4, 5) @@ -608,10 +611,10 @@ Partial Class Pokemonedit ' 'Button21 ' - Me.Button21.Location = New System.Drawing.Point(22, 194) + Me.Button21.Location = New System.Drawing.Point(22, 195) Me.Button21.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) Me.Button21.Name = "Button21" - Me.Button21.Size = New System.Drawing.Size(183, 39) + Me.Button21.Size = New System.Drawing.Size(87, 39) Me.Button21.TabIndex = 13 Me.Button21.Text = "Import" Me.Button21.UseVisualStyleBackColor = True @@ -2557,6 +2560,16 @@ Partial Class Pokemonedit Me.TabPage6.Text = "Cry Data" Me.TabPage6.UseVisualStyleBackColor = True ' + 'Button43 + ' + Me.Button43.Location = New System.Drawing.Point(19, 682) + Me.Button43.Margin = New System.Windows.Forms.Padding(3, 4, 3, 4) + Me.Button43.Name = "Button43" + Me.Button43.Size = New System.Drawing.Size(237, 41) + Me.Button43.TabIndex = 29 + Me.Button43.Text = "Import And Repoint All" + Me.Button43.UseVisualStyleBackColor = True + ' 'GroupBox35 ' Me.GroupBox35.Controls.Add(Me.Button35) @@ -3083,7 +3096,7 @@ Partial Class Pokemonedit Me.Button28.Location = New System.Drawing.Point(12, 592) Me.Button28.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) Me.Button28.Name = "Button28" - Me.Button28.Size = New System.Drawing.Size(195, 29) + Me.Button28.Size = New System.Drawing.Size(140, 29) Me.Button28.TabIndex = 16 Me.Button28.Text = "Import All Icons" Me.Button28.UseVisualStyleBackColor = True @@ -3129,21 +3142,32 @@ Partial Class Pokemonedit Me.Button39.Text = "Import All Cries" Me.Button39.UseVisualStyleBackColor = True ' - 'Button43 + 'Button40 ' - Me.Button43.Location = New System.Drawing.Point(19, 682) - Me.Button43.Margin = New System.Windows.Forms.Padding(3, 4, 3, 4) - Me.Button43.Name = "Button43" - Me.Button43.Size = New System.Drawing.Size(237, 41) - Me.Button43.TabIndex = 29 - Me.Button43.Text = "Import And Repoint All" - Me.Button43.UseVisualStyleBackColor = True + Me.Button40.Location = New System.Drawing.Point(118, 195) + Me.Button40.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) + Me.Button40.Name = "Button40" + Me.Button40.Size = New System.Drawing.Size(87, 39) + Me.Button40.TabIndex = 15 + Me.Button40.Text = "Imp/Rep" + Me.Button40.UseVisualStyleBackColor = True + ' + 'Button41 + ' + Me.Button41.Location = New System.Drawing.Point(154, 592) + Me.Button41.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) + Me.Button41.Name = "Button41" + Me.Button41.Size = New System.Drawing.Size(53, 29) + Me.Button41.TabIndex = 22 + Me.Button41.Text = "Rep." + Me.Button41.UseVisualStyleBackColor = True ' 'Pokemonedit ' Me.AutoScaleDimensions = New System.Drawing.SizeF(9.0!, 20.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(1173, 862) + Me.Controls.Add(Me.Button41) Me.Controls.Add(Me.Button38) Me.Controls.Add(Me.Button39) Me.Controls.Add(Me.Button29) @@ -3525,4 +3549,6 @@ Partial Class Pokemonedit Friend WithEvents TextBox8 As System.Windows.Forms.TextBox Friend WithEvents Label58 As System.Windows.Forms.Label Friend WithEvents Button43 As Button + Friend WithEvents Button40 As Button + Friend WithEvents Button41 As Button End Class diff --git a/GBAPokemonGameEditor/Pokemonedit.vb b/GBAPokemonGameEditor/Pokemonedit.vb index b5c3506..68aaa2d 100644 --- a/GBAPokemonGameEditor/Pokemonedit.vb +++ b/GBAPokemonGameEditor/Pokemonedit.vb @@ -4138,6 +4138,8 @@ Public Class Pokemonedit Private Sub Button43_Click(sender As Object, e As EventArgs) Handles Button43.Click FolderBrowserDialog.Description = "Select folder to import cries from:" + + If FolderBrowserDialog.ShowDialog = Windows.Forms.DialogResult.OK Then Me.Text = "Please wait..." Me.UseWaitCursor = True @@ -4233,4 +4235,119 @@ Public Class Pokemonedit Me.BringToFront() End If End Sub + + Private Sub Button40_Click(sender As Object, e As EventArgs) Handles Button40.Click + fileOpenDialog.FileName = "" + fileOpenDialog.CheckFileExists = True + + ' Check to ensure that the selected path exists. Dialog box displays + ' a warning otherwise. + fileOpenDialog.CheckPathExists = True + + ' Get or set default extension. Doesn't include the leading ".". + fileOpenDialog.DefaultExt = "png" + + ' Return the file referenced by a link? If False, simply returns the selected link + ' file. If True, returns the file linked to the LNK file. + fileOpenDialog.DereferenceLinks = True + + ' Just as in VB6, use a set of pairs of filters, separated with "|". Each + ' pair consists of a description|file spec. Use a "|" between pairs. No need to put a + ' trailing "|". You can set the FilterIndex property as well, to select the default + ' filter. The first filter is numbered 1 (not 0). The default is 1. + fileOpenDialog.Filter = + "(*.png)|*.png*" + + fileOpenDialog.Multiselect = False + + ' Restore the original directory when done selecting + ' a file? If False, the current directory changes + ' to the directory in which you selected the file. + ' Set this to True to put the current folder back + ' where it was when you started. + ' The default is False. + '.RestoreDirectory = False + + ' Show the Help button and Read-Only checkbox? + fileOpenDialog.ShowHelp = False + fileOpenDialog.ShowReadOnly = False + + ' Start out with the read-only check box checked? + ' This only make sense if ShowReadOnly is True. + fileOpenDialog.ReadOnlyChecked = False + + fileOpenDialog.Title = "Select Icon to import" + + ' Only accept valid Win32 file names? + fileOpenDialog.ValidateNames = True + + + If fileOpenDialog.ShowDialog = Windows.Forms.DialogResult.OK Then + + Me.Text = "Please wait..." + Me.Enabled = False + + ImportPokemonIconNewOffset(fileOpenDialog.FileName, PKMNames.SelectedIndex + 1) + + i = PKMNames.SelectedIndex + + IconPointers = Int32.Parse((GetString(GetINIFileLocation(), header, "IconPointerTable", "")), System.Globalization.NumberStyles.HexNumber) + IconPalTable = Int32.Parse((GetString(GetINIFileLocation(), header, "IconPalTable", "")), System.Globalization.NumberStyles.HexNumber) + + IconPointer.Text = Hex(Int32.Parse((ReverseHEX(ReadHEX(LoadedROM, (IconPointers) + (4) + (i * 4), 4))), System.Globalization.NumberStyles.HexNumber) - &H8000000) + IconPal.SelectedIndex = Int32.Parse(((ReadHEX(LoadedROM, (IconPalTable) + (1) + (i), 1))), System.Globalization.NumberStyles.HexNumber) + + GetAndDrawPokemonIconPic(IconPicBox, i + 1, IconPal.SelectedIndex) + + Me.Text = "Pokemon Editor" + Me.Enabled = True + End If + End Sub + + Private Sub Button41_Click(sender As Object, e As EventArgs) Handles Button41.Click + FolderBrowserDialog.Description = "Select folder to import Icons from:" + + If FolderBrowserDialog.ShowDialog = Windows.Forms.DialogResult.OK Then + Me.Text = "Please wait..." + Me.UseWaitCursor = True + ProgressBar.Value = 0 + ProgressBar.Visible = True + + Dim LoopVar As Integer + + LoopVar = 0 + + Me.Enabled = False + + While LoopVar < (GetString(GetINIFileLocation(), header, "NumberOfPokemon", "")) - 1 = True + 'PKMNames.SelectedIndex = LoopVar + + LoopVar = LoopVar + 1 + + + + If System.IO.File.Exists(FolderBrowserDialog.SelectedPath & "\" & LoopVar & ".png") Then + ImportPokemonIconNewOffset(FolderBrowserDialog.SelectedPath & "\" & LoopVar & ".png", LoopVar) + ElseIf System.IO.File.Exists(FolderBrowserDialog.SelectedPath & "\" & VB.Right("000" & LoopVar, 3) & ".png") And LoopVar < 1000 Then + ImportPokemonIconNewOffset(FolderBrowserDialog.SelectedPath & "\" & VB.Right("000" & LoopVar, 3) & ".png", LoopVar) + ElseIf System.IO.File.Exists(FolderBrowserDialog.SelectedPath & "\" & VB.Right("0000" & LoopVar, 4) & ".png") And LoopVar >= 1000 Then + ImportPokemonIconNewOffset(FolderBrowserDialog.SelectedPath & "\" & VB.Right("0000" & LoopVar, 4) & ".png", LoopVar) + End If + + ProgressBar.Value = (LoopVar / (GetString(GetINIFileLocation(), header, "NumberOfPokemon", ""))) * 100 + ProgressBar.Invalidate() + ProgressBar.Update() + + End While + + PKMNames.SelectedIndex = 1 + PKMNames.SelectedIndex = 0 + + Me.Text = "Pokemon Editor" + Me.UseWaitCursor = False + Me.Enabled = True + ProgressBar.Visible = False + Me.BringToFront() + End If + End Sub End Class \ No newline at end of file diff --git a/GBAPokemonGameEditor/bin/Debug/PokemonGameEditor.application b/GBAPokemonGameEditor/bin/Debug/PokemonGameEditor.application index 909c35e..fd337b5 100644 --- a/GBAPokemonGameEditor/bin/Debug/PokemonGameEditor.application +++ b/GBAPokemonGameEditor/bin/Debug/PokemonGameEditor.application @@ -16,7 +16,7 @@ - kytGOmG4B4tanQZichw/k6jjdxy0xuvBb1PbEOxDu40= + IJqIfSj+q2GUE9RHzIIJXL8gGMj3fvFMRuhAIcubK70= diff --git a/GBAPokemonGameEditor/bin/Debug/PokemonGameEditor.exe b/GBAPokemonGameEditor/bin/Debug/PokemonGameEditor.exe index 6b0ab8d..65c8753 100644 Binary files a/GBAPokemonGameEditor/bin/Debug/PokemonGameEditor.exe and b/GBAPokemonGameEditor/bin/Debug/PokemonGameEditor.exe differ diff --git a/GBAPokemonGameEditor/bin/Debug/PokemonGameEditor.exe.manifest b/GBAPokemonGameEditor/bin/Debug/PokemonGameEditor.exe.manifest index bda903a..0ce71f7 100644 --- a/GBAPokemonGameEditor/bin/Debug/PokemonGameEditor.exe.manifest +++ b/GBAPokemonGameEditor/bin/Debug/PokemonGameEditor.exe.manifest @@ -43,14 +43,14 @@ - + - Sv3R1F88R/tTFukRAccZ5vRShV9n2epo2X+P85970rs= + dyCtcOu7k0Fu/5vfcAW1cfLkzpItbrnKPzpDivRuhK8= diff --git a/GBAPokemonGameEditor/bin/Debug/PokemonGameEditor.pdb b/GBAPokemonGameEditor/bin/Debug/PokemonGameEditor.pdb index 74b131d..fb93381 100644 Binary files a/GBAPokemonGameEditor/bin/Debug/PokemonGameEditor.pdb and b/GBAPokemonGameEditor/bin/Debug/PokemonGameEditor.pdb differ diff --git a/GBAPokemonGameEditor/bin/Debug/app.publish/PokemonGameEditor.exe b/GBAPokemonGameEditor/bin/Debug/app.publish/PokemonGameEditor.exe index 6b0ab8d..65c8753 100644 Binary files a/GBAPokemonGameEditor/bin/Debug/app.publish/PokemonGameEditor.exe and b/GBAPokemonGameEditor/bin/Debug/app.publish/PokemonGameEditor.exe differ diff --git a/GBAPokemonGameEditor/obj/x86/Debug/GBAPokemonGameEditor.vbproj.GenerateResource.Cache b/GBAPokemonGameEditor/obj/x86/Debug/GBAPokemonGameEditor.vbproj.GenerateResource.Cache index 6c034f4..a233659 100644 Binary files a/GBAPokemonGameEditor/obj/x86/Debug/GBAPokemonGameEditor.vbproj.GenerateResource.Cache and b/GBAPokemonGameEditor/obj/x86/Debug/GBAPokemonGameEditor.vbproj.GenerateResource.Cache differ diff --git a/GBAPokemonGameEditor/obj/x86/Debug/PokemonGameEditor.application b/GBAPokemonGameEditor/obj/x86/Debug/PokemonGameEditor.application index 909c35e..fd337b5 100644 --- a/GBAPokemonGameEditor/obj/x86/Debug/PokemonGameEditor.application +++ b/GBAPokemonGameEditor/obj/x86/Debug/PokemonGameEditor.application @@ -16,7 +16,7 @@ - kytGOmG4B4tanQZichw/k6jjdxy0xuvBb1PbEOxDu40= + IJqIfSj+q2GUE9RHzIIJXL8gGMj3fvFMRuhAIcubK70= diff --git a/GBAPokemonGameEditor/obj/x86/Debug/PokemonGameEditor.exe b/GBAPokemonGameEditor/obj/x86/Debug/PokemonGameEditor.exe index 6b0ab8d..65c8753 100644 Binary files a/GBAPokemonGameEditor/obj/x86/Debug/PokemonGameEditor.exe and b/GBAPokemonGameEditor/obj/x86/Debug/PokemonGameEditor.exe differ diff --git a/GBAPokemonGameEditor/obj/x86/Debug/PokemonGameEditor.exe.manifest b/GBAPokemonGameEditor/obj/x86/Debug/PokemonGameEditor.exe.manifest index bda903a..0ce71f7 100644 --- a/GBAPokemonGameEditor/obj/x86/Debug/PokemonGameEditor.exe.manifest +++ b/GBAPokemonGameEditor/obj/x86/Debug/PokemonGameEditor.exe.manifest @@ -43,14 +43,14 @@ - + - Sv3R1F88R/tTFukRAccZ5vRShV9n2epo2X+P85970rs= + dyCtcOu7k0Fu/5vfcAW1cfLkzpItbrnKPzpDivRuhK8= diff --git a/GBAPokemonGameEditor/obj/x86/Debug/PokemonGameEditor.pdb b/GBAPokemonGameEditor/obj/x86/Debug/PokemonGameEditor.pdb index 74b131d..fb93381 100644 Binary files a/GBAPokemonGameEditor/obj/x86/Debug/PokemonGameEditor.pdb and b/GBAPokemonGameEditor/obj/x86/Debug/PokemonGameEditor.pdb differ