mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2026-01-21 17:32:41 +00:00
refactor: use standard prettier formatting
This commit is contained in:
@@ -1,25 +1,28 @@
|
||||
import type {CharaLayoutFile} from "$lib/share/chara-file"
|
||||
import type { CharaLayoutFile } from "$lib/share/chara-file";
|
||||
|
||||
/**
|
||||
* Converts a legacy CSV-based layout to the modern JSON-based format
|
||||
*/
|
||||
export function csvLayoutToJson(csv: string, device: CharaLayoutFile["device"] = "one"): CharaLayoutFile {
|
||||
export function csvLayoutToJson(
|
||||
csv: string,
|
||||
device: CharaLayoutFile["device"] = "one",
|
||||
): CharaLayoutFile {
|
||||
const layout: CharaLayoutFile = {
|
||||
charaVersion: 1,
|
||||
type: "layout",
|
||||
device,
|
||||
layout: [[], [], []],
|
||||
}
|
||||
};
|
||||
|
||||
for (const layer of csv.trim().split("\n")) {
|
||||
const [layerId, key, action] = layer.substring(1).split(",").map(Number)
|
||||
const [layerId, key, action] = layer.substring(1).split(",").map(Number);
|
||||
|
||||
layout.layout[Number(layerId) - 1][Number(key)] = Number(action)
|
||||
layout.layout[Number(layerId) - 1][Number(key)] = Number(action);
|
||||
}
|
||||
|
||||
return layout
|
||||
return layout;
|
||||
}
|
||||
|
||||
export function isCsvLayout(csv: string): boolean {
|
||||
return /^(A[123],\d+,\d+\n?)+$/.test(csv)
|
||||
return /^(A[123],\d+,\d+\n?)+$/.test(csv);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user