-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
90 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,75 @@ | ||
export const GameSaveSerializer = { | ||
serialize(save) { | ||
const json = JSON.stringify(save, this.jsonConverter); | ||
return this.encodeText(json, "savefile"); | ||
}, | ||
jsonConverter(key, value) { | ||
if (value === Infinity) { | ||
return "Infinity"; | ||
} | ||
if (value instanceof Set) { | ||
return Array.from(value.keys()); | ||
} | ||
return value; | ||
}, | ||
deserialize(data) { | ||
if (typeof data !== "string") return undefined; | ||
try { | ||
const json = this.decodeText(data, "savefile"); | ||
return JSON.parse(json, (k, v) => ((v === Infinity) ? "Infinity" : v)); | ||
} catch (e) { | ||
return undefined; | ||
} | ||
}, | ||
encoder: new TextEncoder(), | ||
decoder: new TextDecoder(), | ||
startingString: { | ||
savefile: "AntimatterDimensionsSavefileFormat", | ||
"automator script": "AntimatterDimensionsAutomatorScriptFormat", | ||
"automator data": "AntimatterDimensionsAutomatorDataFormat", | ||
"glyph filter": "AntimatterDimensionsGlyphFilterFormat", | ||
}, | ||
endingString: { | ||
savefile: "EndOfSavefile", | ||
"automator script": "EndOfAutomatorScript", | ||
"automator data": "EndOfAutomatorData", | ||
"glyph filter": "EndOfGlyphFilter", | ||
}, | ||
version: "AAB", | ||
steps: [ | ||
{ encode: x => GameSaveSerializer.encoder.encode(x), decode: x => GameSaveSerializer.decoder.decode(x) }, | ||
{ encode: x => pako.deflate(x), decode: x => pako.inflate(x) }, | ||
{ | ||
encode: x => Array.from(x).map(i => String.fromCharCode(i)).join(""), | ||
decode: x => Uint8Array.from(Array.from(x).map(i => i.charCodeAt(0))) | ||
serialize(save) { | ||
const json = JSON.stringify(save, this.jsonConverter); | ||
return this.encodeText(json, "savefile"); | ||
}, | ||
{ encode: x => btoa(x), decode: x => atob(x) }, | ||
{ | ||
encode: x => x.replace(/=+$/gu, "").replace(/0/gu, "0a").replace(/\+/gu, "0b").replace(/\//gu, "0c"), | ||
decode: x => x.replace(/0b/gu, "+").replace(/0c/gu, "/").replace(/0a/gu, "0") | ||
jsonConverter(key, value) { | ||
if (value === Infinity) { | ||
return "Infinity"; | ||
} | ||
if (value instanceof Set) { | ||
return Array.from(value.keys()); | ||
} | ||
return value; | ||
}, | ||
{ | ||
encode: (x, type) => x + GameSaveSerializer.endingString[type], | ||
decode: (x, type) => x.slice(0, x.length - GameSaveSerializer.endingString[type].length), | ||
condition: version => version >= "AAB" | ||
} | ||
], | ||
getSteps(type, version) { | ||
return this.steps.filter(i => (!i.condition) || i.condition(version)).concat({ | ||
encode: x => `${GameSaveSerializer.startingString[type] + GameSaveSerializer.version}${x}`, | ||
decode: x => x.slice(GameSaveSerializer.startingString[type].length + 3) | ||
}); | ||
}, | ||
encodeText(text, type) { | ||
return this.getSteps(type, this.version).reduce((x, step) => step.encode(x, type), text); | ||
}, | ||
decodeText(text, type) { | ||
if (text.startsWith(this.startingString[type])) { | ||
const len = this.startingString[type].length; | ||
const version = text.slice(len, len + 3); | ||
return this.getSteps(type, version).reduceRight((x, step) => step.decode(x, type), text); | ||
deserialize(data) { | ||
if (typeof data !== "string") return undefined; | ||
try { | ||
const json = this.decodeText(data, "savefile"); | ||
return JSON.parse(json, (k, v) => ((v === Infinity) ? "Infinity" : v)); | ||
} catch (e) { | ||
return undefined; | ||
} | ||
}, | ||
encoder: new TextEncoder(), | ||
decoder: new TextDecoder(), | ||
startingString: { | ||
savefile: "AntimatterDimensionsSavefileFormat", | ||
"automator script": "AntimatterDimensionsAutomatorScriptFormat", | ||
"automator data": "AntimatterDimensionsAutomatorDataFormat", | ||
"glyph filter": "AntimatterDimensionsGlyphFilterFormat", | ||
}, | ||
endingString: { | ||
savefile: "EndOfSavefile", | ||
"automator script": "EndOfAutomatorScript", | ||
"automator data": "EndOfAutomatorData", | ||
"glyph filter": "EndOfGlyphFilter", | ||
}, | ||
version: "AAB", | ||
steps: [ | ||
{ encode: x => GameSaveSerializer.encoder.encode(x), decode: x => GameSaveSerializer.decoder.decode(x) }, | ||
{ encode: x => pako.deflate(x), decode: x => pako.inflate(x) }, | ||
{ | ||
encode: x => Array.from(x).map(i => String.fromCharCode(i)).join(""), | ||
decode: x => Uint8Array.from(Array.from(x).map(i => i.charCodeAt(0))) | ||
}, | ||
{ encode: x => btoa(x), decode: x => atob(x) }, | ||
{ | ||
encode: x => x.replace(/=+$/gu, "").replace(/0/gu, "0a").replace(/\+/gu, "0b").replace(/\//gu, "0c"), | ||
decode: x => x.replace(/0b/gu, "+").replace(/0c/gu, "/").replace(/0a/gu, "0") | ||
}, | ||
{ | ||
encode: (x, type) => x + GameSaveSerializer.endingString[type], | ||
decode: (x, type) => x.slice(0, x.length - GameSaveSerializer.endingString[type].length), | ||
condition: version => version >= "AAB" | ||
} | ||
], | ||
getSteps(type, version) { | ||
return this.steps.filter(i => (!i.condition) || i.condition(version)).concat({ | ||
encode: x => `${GameSaveSerializer.startingString[type] + GameSaveSerializer.version}${x}`, | ||
decode: x => x.slice(GameSaveSerializer.startingString[type].length + 3) | ||
}); | ||
}, | ||
encodeText(text, type) { | ||
return this.getSteps(type, this.version).reduce((x, step) => step.encode(x, type), text); | ||
}, | ||
decodeText(text, type) { | ||
if (text.startsWith(this.startingString[type])) { | ||
const len = this.startingString[type].length; | ||
const version = text.slice(len, len + 3); | ||
return this.getSteps(type, version).reduceRight((x, step) => step.decode(x, type), text); | ||
} | ||
return atob(text); | ||
} | ||
return atob(text); | ||
} | ||
}; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,17 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta name="description" content="Antimatter Dimensions Save Editor - A tool for modifying your game saves."> | ||
<meta name="keywords" content="Antimatter Dimensions, Save Editor, Game, Tool"> | ||
<meta name="author" content="Sato-Isolated"> | ||
<title>Antimatter Dimensions Save Editor</title> | ||
<title>Antimatter Dimension Save Editor</title> | ||
<link rel="stylesheet" href="styles.css"> | ||
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/jsoneditor.min.css" rel="stylesheet" type="text/css"> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"> | ||
</head> | ||
|
||
<body class="dark-mode"> | ||
<div class="github-link"> | ||
<a href="https://github.com/Sato-Isolated/Antimatter-Dimensions-Save-Editor" target="_blank"> | ||
<i class="fab fa-github"></i> Contribute on GitHub | ||
</a> | ||
</div> | ||
|
||
<div class="github-stats"> | ||
<h3><i class="fab fa-github"></i> GitHub Stats</h3> | ||
<div class="github-badges"> | ||
<div class="github-badge"> | ||
<span id="githubStars">0</span> <i class="fas fa-star"></i> | ||
</div> | ||
<div class="github-badge"> | ||
<span id="githubForks">0</span> <i class="fas fa-code-branch"></i> | ||
</div> | ||
<div class="github-badge"> | ||
<span id="githubIssues">0</span> <i class="fas fa-exclamation-circle"></i> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="container"> | ||
<div class="editor-section"> | ||
<h1>Antimatter Dimensions Save Editor</h1> | ||
<h1>Antimatter Dimension Save Editor</h1> | ||
<div> | ||
<textarea id="input" placeholder="Paste your encrypted game save here"></textarea> | ||
<button id="pasteButton"><i class="fas fa-paste"></i> Paste</button> | ||
|
@@ -48,24 +22,22 @@ <h1>Antimatter Dimensions Save Editor</h1> | |
<button id="encryptButton"><i class="fas fa-lock"></i> Encrypt</button> | ||
<button id="copyButton"><i class="fas fa-copy"></i> Copy</button> | ||
<textarea id="output" placeholder="Your encrypted game save will appear here"></textarea> | ||
</div> | ||
|
||
</div> | ||
<button id="toggleTheme"><i class="fas fa-sun"></i></button> | ||
</div> | ||
<div class="changelog-section"> | ||
<h2>Changelog</h2> | ||
<ul id="changelogList"> | ||
<li><strong>v1.0.4</strong> — Added GitHub integration and updated meta tags for better SEO.</li> | ||
<li><strong>v1.0.3</strong> — Added paste and copy buttons for convenience.</li> | ||
<li><strong>v1.0.2</strong> — Added dark theme.</li> | ||
<li><strong>v1.0.1</strong> — Implemented save editor functionality.</li> | ||
<li><strong>v1.0.0</strong> — Initial release of the save editor.</li> | ||
</ul> | ||
</div> | ||
</div> | ||
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pako/2.1.0/pako.min.js"></script> | ||
<script src="./pako.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jsoneditor.min.js"></script> | ||
<script type="module" src="script.js"></script> | ||
</body> | ||
|
||
</html> | ||
</html> |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters