From 447ee7352c9874244f1a98e268024412281c05de Mon Sep 17 00:00:00 2001 From: Speedvicio Date: Sun, 7 Apr 2024 22:54:00 +0200 Subject: [PATCH] - Added the option to convert a dat --- MedGui Reborn/Dat.vb | 27 +++++++++++++++++++++++++++ MedGui Reborn/MDM.Designer.vb | 22 ++++++++++++++++++---- MedGui Reborn/MDM.vb | 18 ++++++++++++++++++ MedGui Reborn/Resource.vb | 1 + 4 files changed, 64 insertions(+), 4 deletions(-) diff --git a/MedGui Reborn/Dat.vb b/MedGui Reborn/Dat.vb index 6cdc3e0..a919370 100644 --- a/MedGui Reborn/Dat.vb +++ b/MedGui Reborn/Dat.vb @@ -1,4 +1,6 @@ Imports System.IO +Imports System.Xml +Imports GenericParsing Module Dat @@ -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 \ No newline at end of file diff --git a/MedGui Reborn/MDM.Designer.vb b/MedGui Reborn/MDM.Designer.vb index 801f3d5..21d36ed 100644 --- a/MedGui Reborn/MDM.Designer.vb +++ b/MedGui Reborn/MDM.Designer.vb @@ -40,6 +40,7 @@ Partial Class MDM Me.Label2 = New System.Windows.Forms.Label() Me.Button3 = New System.Windows.Forms.Button() Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components) + Me.Button4 = New System.Windows.Forms.Button() Me.GroupBox1.SuspendLayout() Me.SuspendLayout() ' @@ -55,9 +56,9 @@ Partial Class MDM 'ComboBox1 ' Me.ComboBox1.FormattingEnabled = True - Me.ComboBox1.Location = New System.Drawing.Point(88, 14) + Me.ComboBox1.Location = New System.Drawing.Point(56, 14) Me.ComboBox1.Name = "ComboBox1" - Me.ComboBox1.Size = New System.Drawing.Size(192, 21) + Me.ComboBox1.Size = New System.Drawing.Size(166, 21) Me.ComboBox1.Sorted = True Me.ComboBox1.TabIndex = 1 Me.ToolTip1.SetToolTip(Me.ComboBox1, "Filter rom by console system (empty value = all extensions") @@ -65,7 +66,7 @@ Partial Class MDM 'Button1 ' Me.Button1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch - Me.Button1.Location = New System.Drawing.Point(12, 12) + Me.Button1.Location = New System.Drawing.Point(228, 12) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(23, 23) Me.Button1.TabIndex = 2 @@ -86,7 +87,7 @@ Partial Class MDM 'Label1 ' Me.Label1.AutoSize = True - Me.Label1.Location = New System.Drawing.Point(41, 17) + Me.Label1.Location = New System.Drawing.Point(9, 17) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(41, 13) Me.Label1.TabIndex = 4 @@ -213,11 +214,23 @@ Partial Class MDM Me.ToolTip1.ReshowDelay = 0 Me.ToolTip1.ShowAlways = True ' + 'Button4 + ' + Me.Button4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch + Me.Button4.Enabled = False + Me.Button4.Location = New System.Drawing.Point(257, 12) + Me.Button4.Name = "Button4" + Me.Button4.Size = New System.Drawing.Size(23, 23) + Me.Button4.TabIndex = 6 + Me.ToolTip1.SetToolTip(Me.Button4, "Select a Dat file to convert") + Me.Button4.UseVisualStyleBackColor = True + ' 'MDM ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(538, 276) + Me.Controls.Add(Me.Button4) Me.Controls.Add(Me.Button3) Me.Controls.Add(Me.GroupBox1) Me.Controls.Add(Me.Label1) @@ -252,4 +265,5 @@ Partial Class MDM Friend WithEvents Label5 As System.Windows.Forms.Label Friend WithEvents ToolTip1 As System.Windows.Forms.ToolTip Friend WithEvents CheckBox1 As CheckBox + Friend WithEvents Button4 As Button End Class diff --git a/MedGui Reborn/MDM.vb b/MedGui Reborn/MDM.vb index b4d6980..4d71950 100644 --- a/MedGui Reborn/MDM.vb +++ b/MedGui Reborn/MDM.vb @@ -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() @@ -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 \ No newline at end of file diff --git a/MedGui Reborn/Resource.vb b/MedGui Reborn/Resource.vb index f23ef66..1cb9f2c 100644 --- a/MedGui Reborn/Resource.vb +++ b/MedGui Reborn/Resource.vb @@ -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"))