Skip to content

Commit 94e4235

Browse files
Add preview options (#55)
1 parent a357de2 commit 94e4235

File tree

5 files changed

+57
-1
lines changed

5 files changed

+57
-1
lines changed

preview/src/engine/previewData/archetypes/BpmChange.mts

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { EngineArchetypeDataName } from '@sonolus/core'
2+
import { options } from '../../configuration/options.mjs'
23
import { print } from '../print.mjs'
34
import { line, skin } from '../skin.mjs'
45

@@ -9,6 +10,8 @@ export class BpmChange extends Archetype {
910
})
1011

1112
render() {
13+
if (!options.previewBpm) return
14+
1215
line(skin.sprites.bpmChangeLine, this.import.beat, 0.5)
1316

1417
print(

preview/src/engine/previewData/archetypes/Stage.mts

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { options } from '../../configuration/options.mjs'
12
import { chart } from '../chart.mjs'
23
import { panel } from '../panel.mjs'
34
import { print } from '../print.mjs'
@@ -65,18 +66,24 @@ export class Stage extends Archetype {
6566
}
6667

6768
renderBeats() {
69+
if (!options.previewBeat) return
70+
6871
for (let i = 0; i <= Math.floor(chart.beats); i++) {
6972
line(skin.sprites.beatLine, i, i % 4 === 0 ? 0.25 : 0.125)
7073
}
7174
}
7275

7376
printTimes() {
77+
if (!options.previewTime) return
78+
7479
for (let i = 1; i <= Math.floor(chart.duration); i++) {
7580
print(i, i, PrintFormat.Time, 0, PrintColor.Neutral, 'left')
7681
}
7782
}
7883

7984
printMeasures() {
85+
if (!options.previewMeasure) return
86+
8087
for (let i = 4; i <= Math.floor(chart.beats); i += 4) {
8188
print(
8289
i / 4 + 1,

preview/src/engine/previewData/archetypes/TimeScaleChange.mts

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { EngineArchetypeDataName } from '@sonolus/core'
2+
import { options } from '../../configuration/options.mjs'
23
import { print } from '../print.mjs'
34
import { line, skin } from '../skin.mjs'
45

@@ -9,6 +10,8 @@ export class TimeScaleChange extends Archetype {
910
})
1011

1112
render() {
13+
if (!options.previewTimeScale) return
14+
1215
line(skin.sprites.timeScaleChangeLine, this.import.beat, 0.5)
1316

1417
print(

preview/src/engine/previewData/panel.mts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
import { options } from '../configuration/options.mjs'
12
import { chart } from './chart.mjs'
23

34
export const panel = {
45
w: 20,
5-
h: 2,
6+
get h() {
7+
return 2 / options.previewVerticalScale
8+
},
69

710
get count() {
811
return Math.ceil(chart.duration / this.h)

shared/src/engine/configuration/options.mts

+40
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,44 @@ export const optionsDefinition = {
132132
type: 'toggle',
133133
def: 1,
134134
},
135+
previewVerticalScale: {
136+
name: Text.PreviewScaleVertical,
137+
scope: 'Sekai',
138+
type: 'slider',
139+
def: 1,
140+
min: 0.5,
141+
max: 2,
142+
step: 0.05,
143+
unit: Text.PercentageUnit,
144+
},
145+
previewMeasure: {
146+
name: Text.PreviewMeasure,
147+
scope: 'Sekai',
148+
type: 'toggle',
149+
def: 1,
150+
},
151+
previewBeat: {
152+
name: Text.PreviewBeat,
153+
scope: 'Sekai',
154+
type: 'toggle',
155+
def: 1,
156+
},
157+
previewTime: {
158+
name: Text.PreviewTime,
159+
scope: 'Sekai',
160+
type: 'toggle',
161+
def: 1,
162+
},
163+
previewBpm: {
164+
name: Text.PreviewBpm,
165+
scope: 'Sekai',
166+
type: 'toggle',
167+
def: 1,
168+
},
169+
previewTimeScale: {
170+
name: Text.PreviewTimescale,
171+
scope: 'Sekai',
172+
type: 'toggle',
173+
def: 1,
174+
},
135175
} satisfies Record<string, EngineConfigurationOption>

0 commit comments

Comments
 (0)