Skip to content

Commit

Permalink
Parity Generator draft
Browse files Browse the repository at this point in the history
  • Loading branch information
tillvit committed Dec 28, 2023
1 parent 776de4d commit 288bc5a
Show file tree
Hide file tree
Showing 5 changed files with 1,050 additions and 91 deletions.
2 changes: 2 additions & 0 deletions app/src/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { EventHandler } from "./util/EventHandler"
import { Flags, loadFlags } from "./util/Flags"
import { Keybinds } from "./util/Keybinds"
import { Options } from "./util/Options"
import { ParityGenerator } from "./util/ParityGenerator"
import { extname } from "./util/Path"
import { fpsUpdate } from "./util/Performance"
import { isIFrame } from "./util/Util"
Expand All @@ -35,6 +36,7 @@ import { FileHandler } from "./util/file-handler/FileHandler"
declare global {
interface Window {
app: App
Parity?: ParityGenerator
}
interface File {
path?: string
Expand Down
10 changes: 10 additions & 0 deletions app/src/chart/ChartManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { Flags } from "../util/Flags"
import { Keybinds } from "../util/Keybinds"
import { clamp } from "../util/Math"
import { Options } from "../util/Options"
import { ParityGenerator } from "../util/ParityGenerator"
import { basename, dirname, extname } from "../util/Path"
import { tpsUpdate } from "../util/Performance"
import { RecentFileHandler } from "../util/RecentFileHandler"
Expand Down Expand Up @@ -784,6 +785,15 @@ export class ChartManager {
EventHandler.emit("audioLoaded")
EventHandler.emit("chartModified")

if (this.loadedChart.gameType.id == "dance-single") {
window.Parity = new ParityGenerator(
this.app,
this.loadedChart.gameType.id
)
} else {
window.Parity = undefined
}

if (Flags.autoPlay) {
this.playPause()
}
Expand Down
24 changes: 21 additions & 3 deletions app/src/chart/component/notefield/NoteContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@ import { Notefield } from "./Notefield"

interface HighlightedNoteObject extends Container {
selection: Sprite
parity: Sprite
object: NoteObject
}

const parityColors: Record<string, number> = {
L: 0x0390fc,
l: 0xabd6f7,
R: 0xfcad03,
r: 0xfae5b9,
}

export class NoteContainer extends Container {
private readonly notefield: Notefield
private arrowMap: Map<NotedataEntry, HighlightedNoteObject> = new Map()
Expand Down Expand Up @@ -68,19 +76,26 @@ export class NoteContainer extends Container {
selection.width = objectBounds.width
selection.height = objectBounds.height
selection.alpha = 0

const parity = new Sprite(Texture.WHITE)
parity.x = objectBounds.x
parity.y = objectBounds.y
parity.width = objectBounds.width
parity.height = objectBounds.height
parity.alpha = 0
this.notefield.renderer.registerDragNote(container, note)
container.object = object
container.selection = selection
container.parity = parity
this.arrowMap.set(note, container)
container.addChild(object, selection)
container.addChild(object, selection, parity)
this.addChild(container)
}
}

for (const [note, container] of this.arrowMap.entries()) {
if (!this.shouldDisplayNote(note, fromBeat, toBeat)) {
container.object.destroy()
container.selection.destroy()
container.destroy()
this.arrowMap.delete(note)
continue
}
Expand Down Expand Up @@ -146,6 +161,9 @@ export class NoteContainer extends Container {
this.notefield.renderer.chartManager.removeNoteFromDragSelection(note)
}
}
container.parity.alpha = note.parity ? 0.4 : 0
container.parity.tint =
note.parity !== undefined ? parityColors[note.parity] : 0xffffff
}
}

Expand Down
1 change: 1 addition & 0 deletions app/src/chart/sm/NoteTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ interface ExtraNotedata {
hideNote: boolean
hasHit: boolean
}
parity?: string
}

export type TapNotedataEntry = PartialTapNotedataEntry & ExtraNotedata
Expand Down
Loading

0 comments on commit 288bc5a

Please sign in to comment.