Skip to content

Commit

Permalink
- Added the option to convert a dat
Browse files Browse the repository at this point in the history
  • Loading branch information
Speedvicio committed Apr 7, 2024
1 parent 7e4c64d commit 447ee73
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 4 deletions.
27 changes: 27 additions & 0 deletions MedGui Reborn/Dat.vb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Imports System.IO
Imports System.Xml
Imports GenericParsing

Module Dat

Expand Down Expand Up @@ -31,4 +33,29 @@ Module Dat
End Using
End Sub

Public Sub ConvDat(dat As String)

Dim xmldoc As New XmlDocument()
xmldoc.Load(dat)
Dim nodes As XmlNodeList = xmldoc.DocumentElement.SelectNodes("game")
MDM.Enabled = False
Using sw As StreamWriter = File.AppendText(MedExtra & "\DATs\MDM\" & MDM.ComboBox1.Text & ".dat")
For Each node As XmlNode In nodes
sw.WriteLine(vbCrLf & "game (")
sw.WriteLine(vbTab & "name " & Chr(34) & node.Attributes("name").InnerText & Chr(34))
sw.WriteLine(vbTab & "description " & Chr(34) & node.FirstChild.InnerText & Chr(34))
Dim Xname = (node.LastChild.Attributes("name").InnerText)
Dim Xcrc = (node.LastChild.Attributes("crc").InnerText)
Dim Xmd5 = (node.LastChild.Attributes("md5").InnerText)
Dim Xsha1 = (node.LastChild.Attributes("sha1").InnerText)
sw.WriteLine(vbTab & "rom ( name " & Chr(34) & Xname & Chr(34) & " crc " & Xcrc & " md5 " & Xmd5 & " sha1 " & Xsha1 & " )")
sw.WriteLine(")")
Next
sw.Dispose()
sw.Close()
End Using
MsgBox("Dat Created!", vbOKOnly + MsgBoxStyle.Information)
MDM.Enabled = True
End Sub

End Module
22 changes: 18 additions & 4 deletions MedGui Reborn/MDM.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions MedGui Reborn/MDM.vb
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,19 @@ Public Class MDM
MedGuiR.list_DATs()
End Sub

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim fd As OpenFileDialog = New OpenFileDialog()

fd.Title = "Select a Dat to convert"
fd.Filter = "Dat files (*.dat)|*.dat"
fd.FilterIndex = 2
fd.RestoreDirectory = True

If fd.ShowDialog() = DialogResult.OK Then
ConvDat(fd.FileName)
End If
End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Icon = gIcon
cleaning()
Expand Down Expand Up @@ -161,6 +174,11 @@ Public Class MDM
MDMoperations = "populate"
scans()
End If
If ComboBox1.Text <> "" Then
Button4.Enabled = True
Else
Button4.Enabled = False
End If
End Sub

End Class
1 change: 1 addition & 0 deletions MedGui Reborn/Resource.vb
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@
MedGuiR.PreviousToolStripMenuItem.Image = flip

MDM.Button1.BackgroundImage = (New Bitmap(MedExtra & "Resource\Gui\folder.png"))
MDM.Button4.BackgroundImage = (New Bitmap(MedExtra & "Resource\Gui\dat.png"))

CPM.Button5.BackgroundImage = (New Bitmap(MedExtra & "Resource\Gui\save.png"))
CPM.Button6.BackgroundImage = (New Bitmap(MedExtra & "Resource\Gui\delete.png"))
Expand Down

0 comments on commit 447ee73

Please sign in to comment.