Added icon import with repoint

When using PokeExpansion for emerald, all new pokemon icons point to bulbasaur's. So instead of repointing them I figured this would be useful. There is an import all button, and import single button.
This commit is contained in:
Dreuu
2018-08-03 22:06:26 -04:00
parent 7b3067ad0f
commit 3aebedf721
15 changed files with 225 additions and 20 deletions

Binary file not shown.

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -16,7 +16,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>kytGOmG4B4tanQZichw/k6jjdxy0xuvBb1PbEOxDu40=</dsig:DigestValue>
<dsig:DigestValue>IJqIfSj+q2GUE9RHzIIJXL8gGMj3fvFMRuhAIcubK70=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>

View File

@@ -43,14 +43,14 @@
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="PokemonGameEditor.exe" size="2092032">
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="PokemonGameEditor.exe" size="2094592">
<assemblyIdentity name="PokemonGameEditor" version="3.8.1.0" language="neutral" processorArchitecture="msil" />
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>Sv3R1F88R/tTFukRAccZ5vRShV9n2epo2X+P85970rs=</dsig:DigestValue>
<dsig:DigestValue>dyCtcOu7k0Fu/5vfcAW1cfLkzpItbrnKPzpDivRuhK8=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>

View File

@@ -16,7 +16,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>kytGOmG4B4tanQZichw/k6jjdxy0xuvBb1PbEOxDu40=</dsig:DigestValue>
<dsig:DigestValue>IJqIfSj+q2GUE9RHzIIJXL8gGMj3fvFMRuhAIcubK70=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>

View File

@@ -43,14 +43,14 @@
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="PokemonGameEditor.exe" size="2092032">
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="PokemonGameEditor.exe" size="2094592">
<assemblyIdentity name="PokemonGameEditor" version="3.8.1.0" language="neutral" processorArchitecture="msil" />
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>Sv3R1F88R/tTFukRAccZ5vRShV9n2epo2X+P85970rs=</dsig:DigestValue>
<dsig:DigestValue>dyCtcOu7k0Fu/5vfcAW1cfLkzpItbrnKPzpDivRuhK8=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>