Skip to content

Commit

Permalink
Add snap/quant keybinds, change note colors
Browse files Browse the repository at this point in the history
  • Loading branch information
tillvit committed Sep 21, 2023
1 parent fc12733 commit 2a9d4f4
Show file tree
Hide file tree
Showing 19 changed files with 280 additions and 100 deletions.
72 changes: 36 additions & 36 deletions public/assets/noteskin/dance/lift/body.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
79
-9.000000 1.000000 0.500000 0.472100
-6.000000 25.000000 0.546875 0.855300
-9.000000 28.000000 0.500000 0.903200
6.000000 25.000000 0.546875 0.855300
9.000000 28.000000 0.500000 0.903200
-9.000000 1.000000 0.375000 0.472100
-6.000000 25.000000 0.421875 0.855300
-9.000000 28.000000 0.375000 0.903200
6.000000 25.000000 0.421875 0.855300
9.000000 28.000000 0.375000 0.903200
-19.000000 14.000000 0.033500 0.417300
-19.000000 11.000000 0.033500 0.434600
-11.000000 6.000000 0.045700 0.466200
Expand All @@ -13,25 +13,25 @@
19.000000 7.000000 0.094600 0.567900
19.000000 6.000000 0.094600 0.552000
25.000000 1.000000 0.094600 0.472100
0.000000 -24.000000 0.562500 0.072900
0.000000 -25.000000 0.546875 0.057000
26.000000 1.000000 0.546875 0.472100
-6.000000 -5.000000 0.546875 0.376300
-19.000000 7.000000 0.562500 0.567900
-5.500000 -6.500000 0.546875 0.368300
9.000000 1.000000 0.500000 0.472100
19.000000 8.000000 0.546875 0.583900
19.000000 11.000000 0.500000 0.631800
0.000000 -28.000000 0.500000 0.009100
29.000000 1.000000 0.500000 0.472100
-26.000000 1.000000 0.546875 0.472100
5.500000 -6.500000 0.094600 0.392300
0.000000 -24.000000 0.437500 0.072900
0.000000 -25.000000 0.421875 0.057000
26.000000 1.000000 0.421875 0.472100
-6.000000 -5.000000 0.421875 0.376300
-19.000000 7.000000 0.437500 0.567900
-5.375000 -6.375000 0.421875 0.368300
9.000000 1.000000 0.375000 0.472100
19.000000 8.000000 0.421875 0.583900
19.000000 11.000000 0.375000 0.631800
0.000000 -28.000000 0.375000 0.009100
29.000000 1.000000 0.375000 0.472100
-26.000000 1.000000 0.421875 0.472100
5.375000 -6.375000 0.094600 0.392300
5.000000 24.000000 0.094600 0.839400
5.000000 -8.000000 0.094600 0.408300
5.500000 24.500000 0.562500 0.847300
-19.000000 8.000000 0.546875 0.583900
-19.000000 11.000000 0.500000 0.631800
-29.000000 1.000000 0.500000 0.472100
5.375000 24.375000 0.437500 0.847300
-19.000000 8.000000 0.421875 0.583900
-19.000000 11.000000 0.375000 0.631800
-29.000000 1.000000 0.375000 0.472100
11.000000 30.000000 0.079300 0.320000
-11.000000 30.000000 0.045700 0.320000
-11.000000 30.000000 0.045700 0.320000
Expand All @@ -48,36 +48,36 @@
19.000000 14.000000 0.091500 0.417300
-32.000000 1.000000 0.013500 0.497200
32.000000 1.000000 0.111500 0.497200
-5.500000 -6.500000 0.094600 0.352400
-5.375000 -6.375000 0.094600 0.352400
-19.000000 6.000000 0.094600 0.552000
-5.000000 -8.000000 0.094600 0.336400
19.000000 11.000000 0.091500 0.434600
-5.000000 24.000000 0.094600 0.839400
-5.500000 -6.500000 0.094600 0.392300
-5.375000 -6.375000 0.094600 0.392300
-5.000000 -8.000000 0.094600 0.408300
-6.000000 -5.000000 0.546875 0.392300
-6.000000 -5.000000 0.421875 0.392300
-29.000000 1.000000 0.017800 0.497200
-9.000000 1.000000 0.048800 0.495700
-19.000000 7.000000 0.094600 0.567900
0.000000 -24.000000 0.094600 0.072900
24.000000 1.000000 0.094600 0.472100
5.500000 -6.500000 0.094600 0.352400
5.375000 -6.375000 0.094600 0.352400
5.000000 -8.000000 0.094600 0.336400
6.000000 -5.000000 0.546875 0.392300
19.000000 7.000000 0.562500 0.567900
5.500000 -6.500000 0.562500 0.352400
-25.000000 1.000000 0.562500 0.472100
25.000000 1.000000 0.562500 0.472100
6.000000 -5.000000 0.546875 0.376300
5.500000 24.500000 0.094600 0.847300
-5.500000 24.500000 0.562500 0.847300
-5.500000 -6.500000 0.562500 0.400300
6.000000 -5.000000 0.421875 0.392300
19.000000 7.000000 0.437500 0.567900
5.375000 -6.375000 0.437500 0.352400
-25.000000 1.000000 0.437500 0.472100
25.000000 1.000000 0.437500 0.472100
6.000000 -5.000000 0.421875 0.376300
5.375000 24.375000 0.094600 0.847300
-5.375000 24.375000 0.437500 0.847300
-5.375000 -6.375000 0.437500 0.400300
-9.000000 28.000000 0.048800 0.332200
0.000000 -28.000000 0.062500 0.675800
9.000000 28.000000 0.076200 0.332200
29.000000 1.000000 0.107200 0.497200
9.000000 1.000000 0.076200 0.495700
-5.500000 24.500000 0.094600 0.847300
-5.375000 24.375000 0.094600 0.847300
90
0 1 2
2 3 4
Expand Down
Binary file modified public/assets/noteskin/dance/lift/parts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/assets/noteskin/dance/lift/parts_old.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/assets/noteskin/dance/shader/lift_gradient.frag
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void main() {
sampler0,
vec2(vUvs.x + 0.0625 * quant, mod(1.2 - vUvs.y - time, 2.0) / 2.0)
);
if (vUvs.x < 0.5) {
if (vUvs.x < 0.375) {
col = texture2D(sampler0, vUvs);
}
gl_FragColor = col;
Expand Down
24 changes: 12 additions & 12 deletions public/assets/noteskin/dance/tap/body.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
12
5.000000 24.000000 0.536171 0.301126
0.000000 24.000000 0.534100 0.367417
0.000000 -23.000000 0.551018 0.908796
5.000000 -7.000000 0.546875 0.643631
24.000000 1.000000 0.551018 0.356369
19.000000 6.000000 0.546875 0.356369
-5.000000 -7.000000 0.546875 0.643631
-19.000000 6.000000 0.546875 0.356369
-24.000000 1.000000 0.542731 0.356369
0.000000 -23.000000 0.542731 0.908796
0.000000 24.000000 0.559649 0.367417
-5.000000 24.000000 0.557578 0.301126
5.000000 24.000000 0.421875 0.301126
0.000000 24.000000 0.421875 0.367417
0.000000 -23.000000 0.421875 0.908796
5.000000 -7.000000 0.421875 0.643631
24.000000 1.000000 0.421875 0.356369
19.000000 6.000000 0.421875 0.356369
-5.000000 -7.000000 0.421875 0.643631
-19.000000 6.000000 0.421875 0.356369
-24.000000 1.000000 0.421875 0.356369
0.000000 -23.000000 0.421875 0.908796
0.000000 24.000000 0.421875 0.367417
-5.000000 24.000000 0.421875 0.301126
8
0 1 2
3 0 2
Expand Down
Binary file modified public/assets/noteskin/dance/tap/parts.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/assets/noteskin/dance/tap/parts_old.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 22 additions & 11 deletions src/chart/ChartManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { TIMING_WINDOW_AUTOPLAY } from "./play/StandardTimingWindow"
import { Chart } from "./sm/Chart"
import {
HoldNotedataEntry,
NoteType,
Notedata,
NotedataEntry,
PartialHoldNotedataEntry,
Expand Down Expand Up @@ -132,7 +133,6 @@ export class ChartManager {
private holdEditing: (PartialHold | undefined)[] = []
private editNoteTypeIndex = 0

private snapIndex = 0
private partialScroll = 0
private noteIndex = 0
private lastMetronomeDivision = -1
Expand Down Expand Up @@ -896,19 +896,30 @@ export class ChartManager {
}

previousSnap() {
this.snapIndex = (this.snapIndex - 1 + SNAPS.length) % SNAPS.length
Options.chart.snap =
SNAPS[this.snapIndex] == -1 ? 0 : 1 / SNAPS[this.snapIndex]
let curIndex = this.getSnapIndex() - 1
curIndex = (curIndex + SNAPS.length) % SNAPS.length
Options.chart.snap = SNAPS[curIndex] == -1 ? 0 : 1 / SNAPS[curIndex]
EventHandler.emit("snapChanged")
}

nextSnap() {
this.snapIndex = (this.snapIndex + 1 + SNAPS.length) % SNAPS.length
Options.chart.snap =
SNAPS[this.snapIndex] == -1 ? 0 : 1 / SNAPS[this.snapIndex]
let curIndex = this.getSnapIndex()
if (
curIndex == SNAPS.length - 1 ||
Math.abs(1 / Options.chart.snap - SNAPS[curIndex]) <= 0.0005
) {
curIndex++
}
curIndex = (curIndex + SNAPS.length) % SNAPS.length
Options.chart.snap = SNAPS[curIndex] == -1 ? 0 : 1 / SNAPS[curIndex]
EventHandler.emit("snapChanged")
}

private getSnapIndex() {
if (Options.chart.snap == 0) return SNAPS.length - 1
return SNAPS.findIndex(s => 1 / s <= Options.chart.snap)
}

private removeDuplicateBeats(arr: number[]): number[] {
if (arr.length === 0) return arr
const ret = [arr[0]]
Expand Down Expand Up @@ -1086,7 +1097,7 @@ export class ChartManager {
holdEdit.originalNote = {
beat: beat,
col: col,
type: this.getEditingNoteType(),
type: this.getEditingNoteType()!,
}
}
this.getAssistTickIndex()
Expand Down Expand Up @@ -1214,13 +1225,13 @@ export class ChartManager {
(this.editNoteTypeIndex + 1 + numNoteTypes) % numNoteTypes
}

getEditingNoteType(): string {
getEditingNoteType(): NoteType | null {
return (
this.loadedChart?.gameType.editNoteTypes[this.editNoteTypeIndex] ?? ""
this.loadedChart?.gameType.editNoteTypes[this.editNoteTypeIndex] ?? null
)
}

setEditingNoteType(type: string) {
setEditingNoteType(type: NoteType) {
if (!this.loadedChart) return
const types = this.loadedChart?.gameType.editNoteTypes
const index = types.indexOf(type)
Expand Down
6 changes: 3 additions & 3 deletions src/chart/ChartRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { Waveform } from "./component/Waveform"
import { Notefield } from "./gameTypes/base/Notefield"
import { TimingWindow } from "./play/TimingWindow"
import { Chart } from "./sm/Chart"
import { NotedataEntry } from "./sm/NoteTypes"
import { NoteType, NotedataEntry } from "./sm/NoteTypes"

interface SelectionBounds {
start: Point
Expand All @@ -46,7 +46,7 @@ export class ChartRenderer extends Container<
private lastMousePos?: Point
private lastMouseBeat = -1
private lastMouseCol = -1
private lastNoteType = ""
private lastNoteType: NoteType | null = null
private editingCol = -1

private waveform: Waveform
Expand Down Expand Up @@ -313,7 +313,7 @@ export class ChartRenderer extends Container<
this.notefield.setGhostNote({
beat: snapBeat,
col: this.lastMouseCol,
type: this.chartManager.getEditingNoteType(),
type: this.chartManager.getEditingNoteType()!,
})
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/chart/component/SnapContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ const snapNumbers = {
fill: ["#ffffff"],
}

const SNAP_COLORS: { [key: number]: number } = {
export const QUANT_COLORS: { [key: number]: number } = {
4: 0xe74827,
8: 0x3d89f7,
12: 0xaa2df4,
16: 0x82e247,
24: 0xaa2df4,
24: 0xd82eab,
32: 0xeaa138,
48: 0xaa2df4,
48: 0xef8ceb,
64: 0x6be88e,
96: 0x6be88e,
192: 0x6be88e,
96: 0x828282,
192: 0x828282,
}

export class SnapContainer extends Container implements ChartRendererComponent {
Expand Down Expand Up @@ -66,7 +66,7 @@ export class SnapContainer extends Container implements ChartRendererComponent {
for (let i = 0; i < 2; i++) {
const container = this.children[i]
const square = container.children[0] as Graphics
square.tint = SNAP_COLORS[4 / Options.chart.snap] ?? 0x707070
square.tint = QUANT_COLORS[4 / Options.chart.snap] ?? 0x707070
const text = container.children[1] as BitmapText
text.text =
"" +
Expand Down
3 changes: 2 additions & 1 deletion src/chart/gameTypes/GameTypeRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ChartRenderer } from "../ChartRenderer"
import { NoteType } from "../sm/NoteTypes"
import { GameLogic } from "./base/GameLogic"
import { NotedataParser } from "./base/NotedataParser"
import { Notefield } from "./base/Notefield"
Expand All @@ -13,7 +14,7 @@ export interface GameType {
gameLogic: GameLogic
parser: NotedataParser
notefield: new (renderer: ChartRenderer) => Notefield
editNoteTypes: string[]
editNoteTypes: NoteType[]
flipColumns: {
horizontal: number[]
vertical: number[]
Expand Down
5 changes: 3 additions & 2 deletions src/chart/gameTypes/common/BasicNotedataParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
isHoldNote,
Notedata,
NotedataStats,
NoteType,
PartialHoldNotedataEntry,
PartialNotedata,
PartialNotedataEntry,
Expand All @@ -12,7 +13,7 @@ import { TimingData } from "../../sm/TimingData"
import { NotedataParser } from "../base/NotedataParser"
import { GameType } from "../GameTypeRegistry"

const NOTE_TYPE_LOOKUP: Record<string, string> = {
const NOTE_TYPE_LOOKUP: Record<string, NoteType> = {
"1": "Tap",
"2": "Hold",
"4": "Roll",
Expand All @@ -21,7 +22,7 @@ const NOTE_TYPE_LOOKUP: Record<string, string> = {
L: "Lift",
}

const NOTE_TYPE_LOOKUP_REV: Record<string, string> = {
const NOTE_TYPE_LOOKUP_REV: Record<NoteType, string> = {
Tap: "1",
Hold: "2",
Roll: "4",
Expand Down
15 changes: 6 additions & 9 deletions src/chart/gameTypes/dance/DanceNoteTexture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ export class DanceNoteTexture {
})
DanceNoteTexture.arrow_tex = RenderTexture.create({
width: 256,
height: 256,
height: 320,
resolution: Options.performance.resolution,
})
DanceNoteTexture.lift_tex = RenderTexture.create({
width: 256,
height: 256,
height: 320,
resolution: Options.performance.resolution,
})
DanceNoteTexture.mine_tex = RenderTexture.create({
Expand Down Expand Up @@ -124,7 +124,7 @@ export class DanceNoteTexture {
this.arrow_frame = arrow_frame
}
{
for (let i = 0; i < 8; i++) {
for (let i = 0; i < 10; i++) {
const shader_body = Shader.from(
this.noop_vert,
this.arrow_gradient_frag,
Expand All @@ -146,7 +146,7 @@ export class DanceNoteTexture {
}
}
{
for (let i = 0; i < 8; i++) {
for (let i = 0; i < 10; i++) {
const shader_body = Shader.from(
this.noop_vert,
this.lift_gradient_frag,
Expand Down Expand Up @@ -244,7 +244,7 @@ export class DanceNoteTexture {

static setArrowTexTime(beat: number, second: number) {
if (!this.loaded) return
for (let i = 0; i < 8; i++) {
for (let i = 0; i < 10; i++) {
const tapShader: Mesh<Shader> =
DanceNoteTexture.arrow_container.getChildByName("body" + i)!
tapShader.shader.uniforms.time = beat
Expand All @@ -265,10 +265,7 @@ export class DanceNoteTexture {
if (note.type == "Mine") {
arrow.texture = DanceNoteTexture.mine_tex
} else {
const i = Math.min(
getQuantIndex(timingData.getBeatOfMeasure(note.beat)),
7
)
const i = getQuantIndex(timingData.getBeatOfMeasure(note.beat))
arrow.texture = new Texture(
note.type == "Lift"
? DanceNoteTexture.lift_tex.baseTexture
Expand Down
Loading

0 comments on commit 2a9d4f4

Please sign in to comment.