fxrjson 8.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +24 -0
- package/README.md +60 -0
- package/fxr.ico +0 -0
- package/fxrjson.js +126 -0
- package/package.json +27 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
4
|
+
distribute this software, either in source code form or as a compiled
|
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
|
6
|
+
means.
|
|
7
|
+
|
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
|
9
|
+
of this software dedicate any and all copyright interest in the
|
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
|
11
|
+
of the public at large and to the detriment of our heirs and
|
|
12
|
+
successors. We intend this dedication to be an overt act of
|
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
|
14
|
+
software under copyright law.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
|
|
24
|
+
For more information, please refer to <https://unlicense.org>
|
package/README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# FXR ⇄ JSON
|
|
2
|
+
This is a small command line tool for converting FXR files from Dark Souls 3, Sekiro, Elden Ring, and Armored Core 6 to and from JSON using the [@cccode/fxr](https://www.npmjs.com/package/@cccode/fxr) library.
|
|
3
|
+
|
|
4
|
+
It also includes an option to add a context menu command for .fxr and .json files when you right click them, and converting an effect to JSON and back can be used as a simple way to convert the effect to any of the four games as it allows you to choose what game to convert it back to.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
The tool is easier to use when it is globally installed, but also works when installed locally in a folder.
|
|
8
|
+
|
|
9
|
+
### Global installation
|
|
10
|
+
To install it globally, use this command:
|
|
11
|
+
```
|
|
12
|
+
npm i -g fxrjson
|
|
13
|
+
```
|
|
14
|
+
This allows you to use the tool directly from anywhere, like this:
|
|
15
|
+
```
|
|
16
|
+
fxrjson example.fxr
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Local installation
|
|
20
|
+
To install it locally, use this command in the folder you want to install it to:
|
|
21
|
+
```
|
|
22
|
+
npm i fxrjson
|
|
23
|
+
```
|
|
24
|
+
Note that to run the local one you need to use the `npx` command in the folder it was installed to:
|
|
25
|
+
```
|
|
26
|
+
npx fxrjson example.fxr
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
There are two ways to use the tool: through commands, and through the right-click context menu in the file explorer.
|
|
31
|
+
|
|
32
|
+
### Command line
|
|
33
|
+
The command line tool takes a file name and optionally a game:
|
|
34
|
+
```
|
|
35
|
+
fxrjson <input file> [game]
|
|
36
|
+
```
|
|
37
|
+
The input file can be any .fxr file from any of the four supported games, or a .json file produced by this tool. The game can be one of: `ds3`, `DarkSouls3`, `sdt`, `Sekiro`, `er`, `EldenRing`, `ac6`, `ArmoredCore6`. The game is case-insensitive, which means that `DS3` and `ds3` works the same way.
|
|
38
|
+
|
|
39
|
+
If a game is not specified, the tool will prompt you to pick one from a list.
|
|
40
|
+
|
|
41
|
+
Some examples:
|
|
42
|
+
```
|
|
43
|
+
fxrjson f000000300.fxr
|
|
44
|
+
fxrjson f000000300.fxr ds3
|
|
45
|
+
fxrjson f000000300.fxr.json sekiro
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Context menu
|
|
49
|
+
Registering the context menu command requires administrator privileges!
|
|
50
|
+
|
|
51
|
+
To add the context menu command, open the Windows Terminal as admin and run this command:
|
|
52
|
+
```
|
|
53
|
+
fxrjson add-context-menu
|
|
54
|
+
```
|
|
55
|
+
After doing this, there should be a new "FXR ⇄ JSON" button in the context menu when right-clicking .fxr and .json files.
|
|
56
|
+
|
|
57
|
+
If you want to remove the context menu command again, you can do so by running this command as admin:
|
|
58
|
+
```
|
|
59
|
+
fxrjson remove-context-menu
|
|
60
|
+
```
|
package/fxr.ico
ADDED
|
Binary file
|
package/fxrjson.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from 'node:fs/promises'
|
|
4
|
+
import path from 'node:path'
|
|
5
|
+
import { FXR, Game } from '@cccode/fxr'
|
|
6
|
+
import beautify from 'json-beautify'
|
|
7
|
+
import { fileURLToPath } from 'node:url'
|
|
8
|
+
|
|
9
|
+
const CTX_MENU_NAME = 'FXR ⇄ JSON'
|
|
10
|
+
|
|
11
|
+
const games = {
|
|
12
|
+
ds3: Game.DarkSouls3,
|
|
13
|
+
darksouls3: Game.DarkSouls3,
|
|
14
|
+
sdt: Game.Sekiro,
|
|
15
|
+
sekiro: Game.Sekiro,
|
|
16
|
+
er: Game.EldenRing,
|
|
17
|
+
eldenring: Game.EldenRing,
|
|
18
|
+
ac6: Game.ArmoredCore6,
|
|
19
|
+
armoredcore6: Game.ArmoredCore6,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function addCommand(reg, ext) {
|
|
23
|
+
const icon = path.join(fileURLToPath(import.meta.url), '..', 'fxr.ico')
|
|
24
|
+
const toolCmd = process.argv.slice(0, 2).map(e => `"${e}"`).join(' ')
|
|
25
|
+
await reg.set(`\\${ext}\\shell\\${CTX_MENU_NAME}`, 'Icon', icon)
|
|
26
|
+
await reg.set(`\\${ext}\\shell\\${CTX_MENU_NAME}\\command`, '', `${toolCmd} "%1"`)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function removeCommand(reg, ext) {
|
|
30
|
+
await reg.delete(`\\${ext}\\shell\\${CTX_MENU_NAME}`)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
await (async () => {
|
|
34
|
+
try {
|
|
35
|
+
if (process.argv[2] === 'add-context-menu') {
|
|
36
|
+
const { Registry } = await import('rage-edit')
|
|
37
|
+
const reg = new Registry('HKEY_CLASSES_ROOT\\SystemFileAssociations')
|
|
38
|
+
await addCommand(reg, '.fxr')
|
|
39
|
+
await addCommand(reg, '.json')
|
|
40
|
+
return
|
|
41
|
+
}
|
|
42
|
+
if (process.argv[2] === 'remove-context-menu') {
|
|
43
|
+
const { Registry } = await import('rage-edit')
|
|
44
|
+
const reg = new Registry('HKEY_CLASSES_ROOT\\SystemFileAssociations')
|
|
45
|
+
await removeCommand(reg, '.fxr')
|
|
46
|
+
await removeCommand(reg, '.json')
|
|
47
|
+
return
|
|
48
|
+
}
|
|
49
|
+
} catch {
|
|
50
|
+
console.error('Something went wrong while editing the context menu command. Make sure that the command is run as an administrator.')
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (process.argv.length < 3) {
|
|
55
|
+
console.error('Please provide a file to convert.')
|
|
56
|
+
console.error('Syntax:')
|
|
57
|
+
console.error('> fxrjson <input file> [game]')
|
|
58
|
+
console.error('Examples:')
|
|
59
|
+
console.error('> fxrjson f000000300.fxr')
|
|
60
|
+
console.error('> fxrjson f000000300.fxr DS3')
|
|
61
|
+
console.error('> fxrjson f000000300.fxr.json ER')
|
|
62
|
+
console.error('')
|
|
63
|
+
console.error('To manage the context menu command, use one of these commands as admin:')
|
|
64
|
+
console.error('fxrjson add-context-menu')
|
|
65
|
+
console.error('fxrjson remove-context-menu')
|
|
66
|
+
process.exitCode = 1
|
|
67
|
+
return
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const packagePath = path.join(fileURLToPath(import.meta.url), '..', 'node_modules', '@cccode', 'fxr', 'package.json')
|
|
71
|
+
const { name, version } = JSON.parse(await fs.readFile(packagePath))
|
|
72
|
+
|
|
73
|
+
let game = null
|
|
74
|
+
|
|
75
|
+
if (process.argv.length === 4) {
|
|
76
|
+
game = games[process.argv[3].toLowerCase()] ?? null
|
|
77
|
+
if (game === null) {
|
|
78
|
+
console.warn(`'${process.argv[3]}' is not a valid game.`)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (game === null) try {
|
|
83
|
+
const cliSelect = (await import('cli-select')).default
|
|
84
|
+
console.log('What game is this for?')
|
|
85
|
+
const result = await cliSelect({
|
|
86
|
+
values: [
|
|
87
|
+
'Dark Souls III',
|
|
88
|
+
'Sekiro: Shadows Die Twice',
|
|
89
|
+
'Elden Ring',
|
|
90
|
+
'Armored Core VI Fires of Rubicon',
|
|
91
|
+
],
|
|
92
|
+
defaultValue: 2,
|
|
93
|
+
indentation: 2,
|
|
94
|
+
unselected: '[ ]',
|
|
95
|
+
selected: '[✓]',
|
|
96
|
+
})
|
|
97
|
+
game = games[Game[result.id].toLowerCase()]
|
|
98
|
+
console.log(`Selected: ${result.value}`)
|
|
99
|
+
} catch {
|
|
100
|
+
console.log('Canceled.')
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const filePath = process.argv[2]
|
|
105
|
+
const content = await fs.readFile(filePath)
|
|
106
|
+
|
|
107
|
+
if (content.subarray(0, 4).equals(Buffer.from('FXR\0'))) {
|
|
108
|
+
const fxr = FXR.read(content, game)
|
|
109
|
+
await fs.writeFile(filePath + '.json', beautify({
|
|
110
|
+
version: `${name}@${version}`,
|
|
111
|
+
fxr
|
|
112
|
+
}, null, 2, 80))
|
|
113
|
+
} else {
|
|
114
|
+
const json = JSON.parse(await fs.readFile(filePath, 'utf-8'))
|
|
115
|
+
if (json.version !== `${name}@${version}`) {
|
|
116
|
+
console.warn(
|
|
117
|
+
`${path.basename(filePath)} was deserialized by a different version of ${name}, ` +
|
|
118
|
+
`which means that this version might fail to serialize it. To ensure that it works ` +
|
|
119
|
+
`correctly, please serialize it with ${json.version} instead.`
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
const fxr = FXR.fromJSON(json.fxr)
|
|
123
|
+
await fxr.saveAs(filePath.replace(/(?:(?:\.fxr)?\.json)?$/, '.fxr'), game)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
})()
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "fxrjson",
|
|
3
|
+
"version": "8.1.0",
|
|
4
|
+
"description": "Convert FXR files from Dark Souls 3, Sekiro, Elden Ring, and Armored Core 6 to and from JSON.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": "fxrjson.js",
|
|
7
|
+
"author": "CCCode",
|
|
8
|
+
"license": "Unlicense",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"json",
|
|
11
|
+
"souls",
|
|
12
|
+
"modding"
|
|
13
|
+
],
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/EvenTorset/fxrjson.git"
|
|
17
|
+
},
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/EvenTorset/fxrjson/issues"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@cccode/fxr": "^8.1.0",
|
|
23
|
+
"cli-select": "^1.1.2",
|
|
24
|
+
"json-beautify": "^1.1.1",
|
|
25
|
+
"rage-edit": "^1.2.0"
|
|
26
|
+
}
|
|
27
|
+
}
|