From 8b968640b0cea1e68bf5bf89b000154bbe660dd8 Mon Sep 17 00:00:00 2001 From: GillianMC <70141395+SandeMC@users.noreply.github.com> Date: Sun, 16 Jun 2024 16:56:46 +0300 Subject: [PATCH] testing --- index.html | 1 + test/copyHexOffsets.js | 60 ++++++++++++++++++++ test/index.html | 55 ++++++++++++++++++ test/style.css | 124 +++++++++++++++++++++++++++++++++++++++++ test/updateLabel.js | 46 +++++++++++++++ updateLabel.js | 2 +- 6 files changed, 287 insertions(+), 1 deletion(-) create mode 100644 test/copyHexOffsets.js create mode 100644 test/index.html create mode 100644 test/style.css create mode 100644 test/updateLabel.js diff --git a/index.html b/index.html index 1562efc..908ac5c 100644 --- a/index.html +++ b/index.html @@ -31,6 +31,7 @@

Usage Instructions

  • If some error appears, make sure to read the error properly. Also make sure your file is not renamed in any way and shows up as the game creates them.
  • Note: Do not create the "empty" files manually in the explorer.

    +

    Note 2: If the savefile returns an error in-game, reach a save point and create a save slot on the empty savefile before conversion and try again.

    diff --git a/test/copyHexOffsets.js b/test/copyHexOffsets.js new file mode 100644 index 0000000..70d6103 --- /dev/null +++ b/test/copyHexOffsets.js @@ -0,0 +1,60 @@ +function areBaseNamesSame(name1, name2) { + const baseName1 = name1.split('.')[0].split('_')[0]; + const baseName2 = name2.split('.')[0].split('_')[0]; + return baseName1 === baseName2; +} + +function copyHexOffsets() { + const fileInput1 = document.getElementById('file1').files[0]; + const fileInput2 = document.getElementById('file2').files[0]; + + if (!fileInput1 || !fileInput2) { + alert("Please select two files."); + return; + } + else if (!areBaseNamesSame(fileInput1.name, fileInput2.name)) { + alert("Savefiles are not of the same game."); + return; + } + + const reader1 = new FileReader(); + const reader2 = new FileReader(); + + reader1.onload = function (e1) { + const arrayBuffer1 = e1.target.result; + const uint8Array1 = new Uint8Array(arrayBuffer1); + + reader2.onload = function (e2) { + const arrayBuffer2 = e2.target.result; + const uint8Array2 = new Uint8Array(arrayBuffer2); + + // Copy bytes at offsets from 00000000 to 00000160 + for (let i = 0; i <= 0x160; i++) { + uint8Array1[i] = uint8Array2[i]; + } + + // Copy bytes at offset 006AB060 + const offset = 0x6AB060; + for (let i = 0; i < 4; i++) { + uint8Array1[offset + i] = uint8Array2[offset + i]; + } + + // Create new file + const blob1 = new Blob([uint8Array1], { type: 'application/octet-stream' }); + const downloadUrl = URL.createObjectURL(blob1); + + // Trigger download + const a = document.createElement('a'); + a.href = downloadUrl; + a.download = fileInput2.name; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + URL.revokeObjectURL(downloadUrl); + }; + + reader2.readAsArrayBuffer(fileInput2); + }; + + reader1.readAsArrayBuffer(fileInput1); +} \ No newline at end of file diff --git a/test/index.html b/test/index.html new file mode 100644 index 0000000..908ac5c --- /dev/null +++ b/test/index.html @@ -0,0 +1,55 @@ + + + + + + Kingdom Hearts 1.5+2.5 Savefile Converter + + + +
    +
    +

    Kingdom Hearts 1.5+2.5 Savefile Converter

    +

    Convert from (put your original savefile here):

    +
    + + +
    +

    Convert to (put your empty savefile here):

    +
    + + +
    + +
    +
    +

    Usage Instructions

    +
      +
    • For this example, let's assume you want to convert an existing EGS KH2 savefile to Steam. Start a new game on Steam and make sure an empty KHIIFM_WW.png appears in the save location.
    • +
    • After you have located both your EGS savefile and your Steam savefile, put the EGS savefile on top and the Steam one on the bottom.
    • +
    • Press Convert. Your Steam savefile with EGS saveslots should now have been downloaded! Put it where you originally found the Steam savefile and you should be good to go.
    • +
    • If some error appears, make sure to read the error properly. Also make sure your file is not renamed in any way and shows up as the game creates them.
    • +
    +

    Note: Do not create the "empty" files manually in the explorer.

    +

    Note 2: If the savefile returns an error in-game, reach a save point and create a save slot on the empty savefile before conversion and try again.

    +
    +
    +
    +

    Save File Locations

    +

    Savefiles can be found in:

    + +
    +
    +

    This can also be used to convert somebody else's savefile to yours.

    +

    If you only want to convert an individual save slot rather than the whole file, you can use Kingdom Save Editor instead.

    +

    If you wish to also carry over your achievements, you can do it manually using Steam Achievement Manager.

    +

    This tool doesn't do a lot btw it just copies over hex offsets

    +
    + + + + diff --git a/test/style.css b/test/style.css new file mode 100644 index 0000000..42c1a75 --- /dev/null +++ b/test/style.css @@ -0,0 +1,124 @@ +body { + background: url('https://shared.cloudflare.steamstatic.com/store_item_assets/steam/apps/2552430/page_bg_raw.jpg') no-repeat center center fixed; + background-size: cover; + font-family: 'Trebuchet MS', sans-serif; + color: #ffffff; + margin: 0; + padding: 0; + display: flex; + flex-direction: column; + align-items: center; + height: 100vh; +} + +.main-container { + display: flex; + justify-content: center; + align-items: flex-start; + margin-top: 20px; +} + +.converter-window, .example-window { + background: rgba(0, 0, 0, 0.7); + padding: 20px; + border-radius: 15px; + box-shadow: 0 0 20px rgba(0, 0, 0, 0.5); + margin: 10px; +} + +.converter-window { + text-align: center; + width: 350px; + order: 1; +} + +.example-window { + width: 400px; + order: 2; +} + +.save-locations { + background: rgba(0, 0, 0, 0.7); + padding: 20px; + border-radius: 15px; + box-shadow: 0 0 20px rgba(0, 0, 0, 0.5); + margin-top: 20px; + width: 80%; + max-width: 600px; + text-align: center; +} + +h1, h2 { + font-size: 1.5em; + margin-bottom: 20px; +} + +h3 { + font-size: 1.2em; + margin: 10px 0; +} + +p, ul { + margin: 10px 0; + text-align: left; +} + +.file-input-wrapper { + position: relative; + width: 100%; + text-align: center; + margin: 10px auto; +} + +.file-input-wrapper input[type="file"] { + display: none; +} + +.file-input-wrapper label { + display: inline-block; + padding: 10px 20px; + background-color: #003366; + color: #ffffff; + border-radius: 10px; + cursor: pointer; + font-size: 1em; +} + +.file-input-wrapper label:hover { + background-color: #005599; +} + +button { + background-color: #003366; + color: #ffffff; + border: none; + padding: 10px 20px; + font-size: 1em; + border-radius: 10px; + cursor: pointer; + margin-top: 20px; +} + +button:hover { + background-color: #005599; +} + +a { + color: #66ccff; + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + +.additional-info { + background: rgba(0, 0, 0, 0.7); + padding: 20px; + border-radius: 15px; + box-shadow: 0 0 20px rgba(0, 0, 0, 0.5); + margin-top: 20px; + width: 80%; + max-width: 600px; + text-align: center; +} diff --git a/test/updateLabel.js b/test/updateLabel.js new file mode 100644 index 0000000..5c91981 --- /dev/null +++ b/test/updateLabel.js @@ -0,0 +1,46 @@ +function updateLabel(input) { + const label = input.nextElementSibling; + const fileName = input.files[0].name; + + let gameName = ''; + + if (fileName.includes('KHIII')) { + alert("Kingdom Hearts III savefiles are not supported."); + resetInput(input, label); + return; + } else if (fileName.includes('KH0.2')) { + alert("Kingdom Hearts 0.2 savefiles are not supported."); + resetInput(input, label); + return; + } else if (fileName.includes('KH3DHD')) { + alert("Kingdom Hearts DDD savefiles are not supported."); + resetInput(input, label); + return; + } + + if (fileName.includes('KHFM')) { + gameName = 'KH1 (EGS)'; + } else if (fileName.includes('KHIIFM')) { + gameName = 'KH2 (EGS)'; + } else if (fileName.includes('KHReCoM')) { + gameName = 'KH: Re:COM (EGS)'; + } else if (fileName.includes('KHBbSFM')) { + gameName = 'KH: BBS (EGS)'; + } else { + gameName = null; + alert("Selected file is not a valid Kingdom Hearts savefile."); + resetInput(input, label); + return; + } + + if (fileName.includes('_WW') || fileName.includes('_JP')) { + gameName = gameName.replace('EGS', 'Steam'); + } + + label.textContent = gameName ? `Selected: ${gameName}` : 'Select File'; +} + +function resetInput(input, label) { + input.value = ""; // Clear the file input + label.textContent = 'Select File'; // Reset the label +} diff --git a/updateLabel.js b/updateLabel.js index bf763ca..5c91981 100644 --- a/updateLabel.js +++ b/updateLabel.js @@ -33,7 +33,7 @@ function updateLabel(input) { return; } - if (fileName.includes('_WW')) { + if (fileName.includes('_WW') || fileName.includes('_JP')) { gameName = gameName.replace('EGS', 'Steam'); }