scripts & contacts export support

This commit is contained in:
sShemet
2025-12-29 19:03:54 +05:00
parent 3475406781
commit cbad01271c
43 changed files with 102510 additions and 1534 deletions

View File

@@ -1,4 +1,6 @@
Public Class CityEditor
Imports System.Windows.Forms.VisualStyles.VisualStyleElement.TextBox
Public Class CityEditor
Public files1 As List(Of fileInfo)
Public files2 As List(Of fileInfo)
@@ -20,6 +22,10 @@
LoadDistrict()
End Sub
Private Sub SecondVariant_CheckedChanged(sender As Object, e As EventArgs) Handles SecondVariant.CheckedChanged
LoadDistrict()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If ID.Text = 713 Then
ID.Text = 719
@@ -27,7 +33,6 @@
ID.Text -= 1
End If
LoadDistrict()
End Sub
@@ -38,7 +43,6 @@
ID.Text += 1
End If
LoadDistrict()
End Sub
@@ -48,60 +52,44 @@
Dim cd = New ISOTools
Dim rle = New rleTools
Form1.DeconstructFile(cd.getCDfile(Form1.UserPath.Text, files1(ID.Text).Sector, files1(ID.Text).Sizw).ToArray) 'here is separated binfile
CurFile = Form1.binFile(Form1.binFile.Count - 2) 'Get Before Last File
CurFileUnrle = CurFile.Bytes.ToArray
CurFile = Form1.binFile(Form1.binFile.Count - 3 + Convert.ToInt32(SecondVariant.Checked)) 'Get Before Last File
CurFileUnrle = rle.UnrleNocompr(CurFile.Bytes).ToArray
Form1.DeconstructFile(cd.getCDfile(Form1.EngISOPath.Text, files2(ID.Text).Sector, files2(ID.Text).Sizw).ToArray) 'here is separated binfile
EngFile = Form1.binFile(Form1.binFile.Count - 2) 'Get Before Last File
EngFileUnrle = EngFile.Bytes.ToArray
EngFile = Form1.binFile(Form1.binFile.Count - 3 + Convert.ToInt32(SecondVariant.Checked)) 'Get Before Last File
EngFileUnrle = rle.UnrleNocompr(EngFile.Bytes).ToArray
'Dim curfile As rleFile = binFile(8)
Dim JapBlock1Len = CurFileUnrle(0)
Dim JapBlock2Len = CurFileUnrle(1)
Dim JapBlockLines = CurFileUnrle(2)
Dim EnBlock1Len = EngFileUnrle(0)
Dim EnBlock2Len = EngFileUnrle(1)
Dim EnBlockLines = EngFileUnrle(2)
Dim JapBlock1Len = CurFileUnrle(8)
Dim JapBlock2Len = CurFileUnrle(9)
Dim JapBlockLines = CurFileUnrle(10)
Dim EnBlock1Len = EngFileUnrle(8)
Dim EnBlock2Len = EngFileUnrle(9)
Dim EnBlockLines = EngFileUnrle(10)
Dim JapTextStart = JapBlock1Len * 16 + JapBlock2Len * 8 + 4 'header 8 + head 4 block
Dim EngTextStart = EnBlock1Len * 16 + EnBlock2Len * 8 + 4
Dim JapTextStart = JapBlock1Len * 16 + JapBlock2Len * 8 + 8 + 4 'header 8 + head 4 block
Dim EngTextStart = EnBlock1Len * 16 + EnBlock2Len * 8 + 8 + 4
Try
EngTitle.Text = readEngText(EngTextStart + 4) 'after coords...
UserTitle.Text = readRusText(JapTextStart + 4) 'after coords...
DataGridView1.Rows.Clear()
For a = 1 To JapBlockLines - 1
JapTextStart += 40
EngTextStart += 40 'Move to Next Block...
Dim jap_X As String = BitConverter.ToInt16(CurFileUnrle, JapTextStart)
Dim jap_Y As Integer = BitConverter.ToInt16(CurFileUnrle, JapTextStart + 2)
Dim japLoc = readRusText(JapTextStart + 4 + 14) ' aftercoords
EngTitle.Text = readEngText(EngTextStart + 4) 'after coords...
UserTitle.Text = readRusText(JapTextStart + 4) 'after coords...
DataGridView1.Rows.Clear()
For a = 1 To JapBlockLines - 1
JapTextStart += 40
EngTextStart += 40 'Move to Next Block...
Dim jap_coords As String = BitConverter.ToInt16(CurFileUnrle, JapTextStart) & " x " & BitConverter.ToInt16(CurFileUnrle, JapTextStart + 2)
Dim japLoc = readRusText(JapTextStart + 4 + 14) ' aftercoords
Dim en_coords As String = BitConverter.ToInt16(CurFileUnrle, EngTextStart) & " x " & BitConverter.ToInt16(CurFileUnrle, EngTextStart + 2)
Dim enLoc = readEngText(JapTextStart + 4 + 14) ' aftercoords
DataGridView1.Rows.Add(jap_coords, japLoc, enLoc, en_coords)
Next
'Do
' If pointer >= endByte Then Exit Do
' Dim status = BitConverter.ToInt16(CurFileUnrle, pointer)
' Dim statusE = EngFileUnrle(pointer)
' pointer += 2
' Dim engString = readEngText(pointer - 1)
' Dim rustext = readRusText(pointer)
' DataGridView1.Rows.Add(status, rustext, engString, statusE)
' pointer += 30
'Loop
Dim en_coords As String = BitConverter.ToInt16(CurFileUnrle, EngTextStart) & " x " & BitConverter.ToInt16(CurFileUnrle, EngTextStart + 2)
Dim enLoc = readEngText(JapTextStart + 4 + 14) ' aftercoords
DataGridView1.Rows.Add(jap_X, jap_Y, japLoc, enLoc, en_coords)
Next
Catch ex As Exception
MsgBox("Error reading this district. Try another variant.")
End Try
End Sub
@@ -166,86 +154,68 @@
Dim cd = New ISOTools
Dim rle = New rleTools
'Making title bytes
MakeSaveRussianString(UserTitle.Text, 24, 0)
'Dim curfile As rleFile = binFile(8)
Dim off As Int32 = BitConverter.ToInt32(CurFileUnrle, 104)
'Dim pointer As Int32 = BitConverter.ToInt32(CurFileUnrle, 104)
Dim endByte As Int32 = BitConverter.ToInt32(CurFileUnrle, 60)
Dim JapBlock1Len = CurFileUnrle(0)
Dim JapBlock2Len = CurFileUnrle(1)
Dim JapBlockLines = CurFileUnrle(2)
Dim JapTextStart = JapBlock1Len * 16 + JapBlock2Len * 8 + 4 'header 8 + head 4 block
MakeSaveRussianString(UserTitle.Text, 14, JapTextStart + 4)
CurFileUnrle(18) = 0
CurFileUnrle(19) = 10
For Each row In DataGridView1.Rows
CurFileUnrle(off) = row.Cells(0).Value
CurFileUnrle(off + 1) = 0
MakeSaveRussianString(Trim(row.Cells(1).Value), 30, off + 2)
off += 32
JapTextStart += 40
Dim xxx = Convert.ToInt16(row.Cells(0).Value)
Dim yyy = Convert.ToInt16(row.Cells(1).Value)
CurFileUnrle(JapTextStart) = BitConverter.GetBytes(xxx)(0)
CurFileUnrle(JapTextStart + 1) = BitConverter.GetBytes(xxx)(1)
CurFileUnrle(JapTextStart + 2) = BitConverter.GetBytes(yyy)(0)
CurFileUnrle(JapTextStart + 3) = BitConverter.GetBytes(yyy)(1)
Dim japLoc = readRusText(JapTextStart + 4 + 14)
MakeSaveRussianString(Trim(row.Cells(2).Value), 22, JapTextStart + 4 + 14)
Next
Form1.DeconstructFile(cd.getCDfile(Form1.UserPath.Text, files1(ID.Text).Sector, files1(ID.Text).Sizw).ToArray) 'here is separated binfile
Dim curfile = Form1.binFile(0)
Dim before = curfile.Bytes.Count
Form1.binFile(0).Bytes = rle.decodeRLEnew(CurFileUnrle, curfile).ToArray
Form1.binFile(0).BytesAfter = 0
Dim after = Form1.binFile(0).Bytes.Count
Form1.DeconstructFile(cd.getCDfile(Form1.UserPath.Text, files1(ID.Text).Sector, files1(ID.Text).Sizw).ToArray) 'Deconstruct again!
Form1.binFile(Form1.binFile.Count - 3 + Convert.ToInt32(SecondVariant.Checked)).Bytes = rle.attachNoCompressionHeader(CurFile, CurFileUnrle).ToArray
'Packing
Dim finalPack = New List(Of Byte)
For Each bin In Form1.binFile
finalPack.AddRange(bin.Bytes)
'AddingBytesAfter
For g = 0 To bin.BytesAfter - 1
'Adding SectorGaps (ONLY FOR CITY DISTRICTS!!!!!!!)
Dim gap = 2048 - (finalPack.Count Mod 2048)
For g = 0 To gap - 1
finalPack.Add(0)
Next
Next
If finalPack.Count Mod 2048 > 0 Then
For g = 1 To (2048 - (finalPack.Count Mod 2048))
finalPack.Add(0)
Next g
End If
Dim beforePackSize As Integer = cd.getCDfile(Form1.UserPath.Text, files1(ID.Text).Sector, files1(ID.Text).Sizw).Count
Dim beforeSize As Integer = files1(ID.Text).Sizw
If finalPack.Count <= files1(ID.Text).Sizw Then
If finalPack.Count = beforePackSize Then
'If sizw matched
cd.saveCDfile(Form1.UserPath.Text, files1(ID.Text).Sector, finalPack.Count, finalPack.ToArray)
MsgBox("Succesfully Saved!" & vbCrLf & "Bofore: " & before & vbCrLf & "Afta: " & after & vbCrLf & after - before & "b.")
Exit Sub
End If
If MsgBox("finalPack is Bigger than source :(" &
vbCrLf & "Bofore: " & before & vbCrLf & "Afta: " & after & vbCrLf & after - before & "b." &
vbCrLf & "Do you wanna save it to file?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
If Form1.SaveFileDialog1.ShowDialog <> DialogResult.OK Then Exit Sub
ElseIf MsgBox($"finalPack is not match source :( {vbCrLf} Source size {beforePackSize}{vbCrLf} Final Pack Size {finalPack.Count} {vbCrLf} Wanna save it to a file for inspect?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
My.Computer.FileSystem.WriteAllBytes(Form1.SaveFileDialog1.FileName, finalPack.ToArray, False)
End If
'My.Computer.FileSystem.WriteAllBytes("D:\Games\PSX\Persona.2.Innocent.Sin\Export\UnRLE\0097\EDITOR_TEST", CurFileUnrle, False)
End Sub
Public Sub MakeSaveRussianString(ByVal str As String, ByVal maxBytes As Integer, ByVal offs As String)
Dim a = New List(Of Byte)
If str = "0010" Then
For x = 0 To maxBytes - 1 Step 2
CurFileUnrle(offs + x) = 0
CurFileUnrle(offs + x + 1) = &H10
For zzz = 0 To maxBytes - 1 Step 2
CurFileUnrle(offs + zzz) = 0
CurFileUnrle(offs + zzz + 1) = &H10
Next
Exit Sub
@@ -254,15 +224,19 @@
a.Add(str.Length)
a.Add(&H20)
For x = 0 To str.Length - 1
a.Add(Asc(str(x)))
For zzz = 0 To str.Length - 1
a.Add(Asc(str(zzz)))
Next
For x = 0 To maxBytes - str.Length - 3
' a.Add(0)
' a.Add(&H10)
For zzz = 0 To maxBytes - str.Length - 3
a.Add(0)
Next
For x = 0 To maxBytes - 1
CurFileUnrle(x + offs) = a(x)
For zzz = 0 To maxBytes - 1
CurFileUnrle(zzz + offs) = a(zzz)
Next
End Sub
End Class