Skip to content

Commit 0eb8019

Browse files
committed
make key template json file as import
1 parent aae7411 commit 0eb8019

File tree

5 files changed

+32
-69
lines changed

5 files changed

+32
-69
lines changed

Diff for: src-tauri/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ font-kit = "0.14.2"
2929
incremental = true # Compile your binary in smaller steps.
3030

3131
[profile.release]
32+
codegen-units = 1 # Allows LLVM to perform better optimization.
3233
lto = true # Enables link-time-optimizations.
33-
opt-level = 3 # Prioritizes small binary size. Use `3` if you prefer speed.
34+
opt-level = "s" # Prioritizes small binary size. Use `3` if you prefer speed.
3435
panic = "abort" # Higher performance by disabling panic handlers.
3536
strip = true # Ensures debug symbols are removed.

Diff for: src/components/settings/sections/ColorSettings.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<script setup lang="ts">
22
import { storeToRefs } from "pinia"
33
import ColorInput from "../input-components/ColorInput.vue"
4-
import type { KeyColorOption, KeyTemplate } from "@/types/key-templates"
4+
import type { KeyColorOption, KeyTemplateStyling } from "@/types/key-templates"
55
import { defaultKeyStyling } from "@/constants/key-template"
66
import { useKeyTemplateStore } from "@/stores/useKeyTemplateStore"
77
88
const { keyTemplate } = storeToRefs(useKeyTemplateStore())
99
1010
const colorCategoryName: {
11-
[key in keyof KeyTemplate["styling"]["keyColor"]]: string
11+
[key in keyof KeyTemplateStyling["keyColor"]]: string
1212
} = { idle: "일반 상태", pressed: "눌린 상태" }
1313
1414
const colorTypeName: {

Diff for: src/constants/key-template.ts

+6-48
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,8 @@
1-
import type { KeyTemplate } from "@/types/key-templates"
1+
import { KeyTemplate, KeyTemplateStyling } from "@/types/key-templates"
2+
import defaultKeyTemplateJson from "@/bundle-resources/resources/key-templates/speed.json"
23

3-
export const defaultKeyStyling = {
4-
keySize: 10,
5-
keyGap: 1,
6-
keyBorderRadius: 0.5,
7-
keyBorderWidth: 0,
8-
keyColor: {
9-
idle: {
10-
backgroundColor: "#ffffff",
11-
textColor: "#0c1236",
12-
borderColor: "#0c1236",
13-
},
14-
pressed: {
15-
backgroundColor: "#00d7f8",
16-
textColor: "#0c1236",
17-
borderColor: "#0c1236",
18-
},
19-
},
4+
export const defaultKeyStyling = KeyTemplateStyling.parse(
5+
defaultKeyTemplateJson.styling,
6+
)
207

21-
fontSize: 1.9,
22-
fontWeight: 570,
23-
fontFamily: "Pretendard",
24-
} as const satisfies KeyTemplate["styling"]
25-
26-
export const defaultKeyTemplate = {
27-
templateName: "스피드전",
28-
29-
keybinds: {
30-
a: {
31-
description: "드리프트",
32-
keyCode: "ShiftLeft",
33-
customLabel: "Shift",
34-
},
35-
b: {
36-
description: "부스터",
37-
keyCode: "ControlLeft",
38-
customLabel: "Ctrl",
39-
},
40-
c: {
41-
description: "앞 방향키",
42-
keyCode: "UpArrow",
43-
},
44-
d: { description: "왼쪽 방향키", keyCode: "LeftArrow" },
45-
e: { description: "뒤 방향키", keyCode: "DownArrow" },
46-
f: { description: "오른쪽 방향키", keyCode: "RightArrow" },
47-
},
48-
gridAreas: ["a a . c .", "b b d e f"],
49-
styling: defaultKeyStyling,
50-
} as const satisfies KeyTemplate
8+
export const defaultKeyTemplate = KeyTemplate.parse(defaultKeyTemplateJson)

Diff for: src/types/key-templates.ts

+20-16
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,25 @@ export const keyColorOption = z.object({
1818

1919
export type KeyColorOption = z.infer<typeof keyColorOption>
2020

21+
export const KeyTemplateStyling = z.object({
22+
keySize: z.number(),
23+
keyGap: z.number(),
24+
keyBorderRadius: z.number(),
25+
keyBorderWidth: z.number(),
26+
27+
keyColor: z.object({
28+
idle: keyColorOption,
29+
pressed: keyColorOption,
30+
}),
31+
32+
fontSize: z.number(),
33+
/** Absolute number */
34+
fontWeight: z.number(),
35+
fontFamily: z.string(),
36+
})
37+
38+
export type KeyTemplateStyling = z.infer<typeof KeyTemplateStyling>
39+
2140
export const KeyTemplate = z.object({
2241
templateName: z.string(),
2342

@@ -27,22 +46,7 @@ export const KeyTemplate = z.object({
2746
gridAreas: z.array(z.string()),
2847

2948
/** Relative sizes */
30-
styling: z.object({
31-
keySize: z.number(),
32-
keyGap: z.number(),
33-
keyBorderRadius: z.number(),
34-
keyBorderWidth: z.number(),
35-
36-
keyColor: z.object({
37-
idle: keyColorOption,
38-
pressed: keyColorOption,
39-
}),
40-
41-
fontSize: z.number(),
42-
/** Absolute number */
43-
fontWeight: z.number(),
44-
fontFamily: z.string(),
45-
}),
49+
styling: KeyTemplateStyling,
4650
})
4751

4852
export type KeyTemplate = z.infer<typeof KeyTemplate>

Diff for: src/utils/keyviewer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { KeybindData, KeyTemplate } from "@/types/key-templates"
1+
import type { KeybindData, KeyTemplateStyling } from "@/types/key-templates"
22
import { keybindTypeRegex, type KeybindType } from "@/types/keyviewer/keybind"
33
import type { AbsoluteSizeData } from "@/types/keyviewer/size"
44
import type { PxUnit } from "@/types/unit"
@@ -47,7 +47,7 @@ export const calculateKeyViewerAbsoluteSizes = ({
4747

4848
columnCount: number
4949
rowCount: number
50-
} & KeyTemplate["styling"]): AbsoluteSizeData => {
50+
} & KeyTemplateStyling): AbsoluteSizeData => {
5151
// Set window size
5252
const relativeWidth = keySize * columnCount + keyGap * (columnCount - 1)
5353
const relativeHeight = keySize * rowCount + keyGap * (rowCount - 1)

0 commit comments

Comments
 (0)