Skip to content

Commit

Permalink
Merge pull request #99 from tillvit/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
tillvit authored Jan 31, 2024
2 parents b7998c7 + 5a2088d commit 94c4be8
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 32 deletions.
12 changes: 9 additions & 3 deletions app/src/chart/ChartManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1256,12 +1256,17 @@ export class ChartManager {
hold.endBeat = Math.max(hold.startBeat, Math.round(beat * 48) / 48)
hold.roll ||= roll
if (!hold.originalNote) {
this.loadedChart.addNote({
const note: PartialNotedataEntry = {
beat: hold.startBeat,
col: col,
type: hold.roll ? "Roll" : "Hold",
hold: hold.endBeat - hold.startBeat,
})
}
if (hold.endBeat - hold.startBeat == 0) {
note.type = "Tap"
Object.assign(note, { hold: undefined })
}
this.loadedChart.addNote(note)
} else {
const props: Partial<PartialNotedataEntry> = {
beat: hold.startBeat,
Expand Down Expand Up @@ -1770,14 +1775,15 @@ export class ChartManager {
note =>
note.beat >= this.startRegion! && note.beat <= this.endRegion!
)
.filter(note => !this.selection.notes.includes(note))
)
} else {
this.setEventSelection(
TIMING_EVENT_NAMES.flatMap(
event =>
this.loadedChart!.timingData.getColumn(event)
.events as Cached<TimingEvent>[]
).filter(
note => note.beat >= this.startRegion! && note.beat <= this.endRegion!
)
)
}
Expand Down
35 changes: 25 additions & 10 deletions app/src/chart/ChartRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,21 +625,28 @@ export class ChartRenderer extends Container<ChartRendererComponent> {
a => a.beat
)

if (
this.getVisualBeat() - Options.chart.maxDrawBeatsBack <
scrolls[0]?.beat
) {
scrollIndex = -1
}

while (
scrolls[scrollIndex]?.beat <
this.getVisualBeat() + Options.chart.maxDrawBeats
scrolls[scrollIndex]?.beat ??
0 < this.getVisualBeat() + Options.chart.maxDrawBeats
) {
const scroll = scrolls[scrollIndex]

const scrollStartYPos = this.getYPosFromBeat(scroll.beat)
const scrollStartYPos = this.getYPosFromBeat(scroll?.beat ?? 0)

const scrollEndBeat =
scrolls[scrollIndex + 1]?.beat ??
this.getVisualBeat() + Options.chart.maxDrawBeats
const scrollEndYPos = this.getYPosFromBeat(scrollEndBeat)

if (
scroll.value * sign > 0 &&
(scroll?.value ?? 1) * sign > 0 &&
scrollEndYPos > upperBound &&
(scrollStartYPos < upperBound ||
!scrolls[scrollIndex - 1] ||
Expand All @@ -649,7 +656,7 @@ export class ChartRenderer extends Container<ChartRendererComponent> {
)
break
if (
scroll.value * sign < 0 &&
(scroll?.value ?? 1) * sign < 0 &&
scrollEndYPos < lowerBound &&
(scrollStartYPos > lowerBound ||
!scrolls[scrollIndex - 1] ||
Expand All @@ -669,6 +676,7 @@ export class ChartRenderer extends Container<ChartRendererComponent> {
(pixelsToEffectiveBeats / Math.abs(scrollValue)) * Options.chart.zoom
const start = Options.chart.reverse ? upperBound : lowerBound
const end = Options.chart.reverse ? lowerBound : upperBound

if (scrollValue * sign > 0) {
if (
scrolls[scrollIndex - 1]?.value == 0 &&
Expand Down Expand Up @@ -731,21 +739,28 @@ export class ChartRenderer extends Container<ChartRendererComponent> {
a => a.beat
)

if (
this.getVisualBeat() - Options.chart.maxDrawBeatsBack <
scrolls[0]?.beat
) {
scrollIndex = -1
}

while (
scrolls[scrollIndex]?.beat >
this.getVisualBeat() - Options.chart.maxDrawBeatsBack
scrolls[scrollIndex]?.beat ??
0 > this.getVisualBeat() - Options.chart.maxDrawBeatsBack
) {
const scroll = scrolls[scrollIndex]

const scrollStartYPos = this.getYPosFromBeat(scroll.beat)
const scrollStartYPos = this.getYPosFromBeat(scroll?.beat ?? 0)

const scrollEndBeat =
scrolls[scrollIndex + 1]?.beat ??
this.getVisualBeat() + Options.chart.maxDrawBeats
const scrollEndYPos = this.getYPosFromBeat(scrollEndBeat)

if (
scroll.value * sign > 0 &&
(scroll?.value ?? 1) * sign > 0 &&
scrollStartYPos < lowerBound &&
(scrollEndYPos > lowerBound ||
!scrolls[scrollIndex + 1] ||
Expand All @@ -755,7 +770,7 @@ export class ChartRenderer extends Container<ChartRendererComponent> {
)
break
if (
scroll.value * sign < 0 &&
(scroll?.value ?? 1) * sign < 0 &&
scrollStartYPos > upperBound &&
(scrollEndYPos < upperBound ||
!scrolls[scrollIndex + 1] ||
Expand Down
34 changes: 16 additions & 18 deletions app/src/chart/gameTypes/dance/default/DanceDefaultNoteTexture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
Sprite,
Texture,
} from "pixi.js"
import { App } from "../../../../App"
import { Options } from "../../../../util/Options"
import { NotedataEntry } from "../../../sm/NoteTypes"

Expand All @@ -30,6 +29,7 @@ import arrowFrameGeomText from "../../../../../assets/noteskin/dance/default/tap

import liftBodyGeomText from "../../../../../assets/noteskin/dance/default/lift/body.txt?raw"
import mineBodyGeomText from "../../../../../assets/noteskin/dance/default/mine/body.txt?raw"
import { App } from "../../../../App"

const mine_frame_texture = Texture.from(mineFrameUrl)

Expand Down Expand Up @@ -60,7 +60,7 @@ export class DanceDefaultNoteTexture {

private static loaded = false

static async initArrowTex(app: App) {
static async initArrowTex() {
if (this.loaded) return

// Initialize rendertextures in here so we can read options
Expand Down Expand Up @@ -162,21 +162,6 @@ export class DanceDefaultNoteTexture {
DanceDefaultNoteTexture.mineConainer.addChild(mine_frame)
}

app.ticker.add(() => {
app.renderer.render(DanceDefaultNoteTexture.arrowFrame, {
renderTexture: DanceDefaultNoteTexture.arrowFrameTex,
})
app.renderer.render(DanceDefaultNoteTexture.arrowContainer, {
renderTexture: DanceDefaultNoteTexture.arrowTex,
})
app.renderer.render(DanceDefaultNoteTexture.mineConainer, {
renderTexture: DanceDefaultNoteTexture.mineTex,
})
app.renderer.render(DanceDefaultNoteTexture.liftContainer, {
renderTexture: DanceDefaultNoteTexture.liftTex,
})
})

this.loaded = true
}

Expand Down Expand Up @@ -221,7 +206,7 @@ export class DanceDefaultNoteTexture {
.addIndex(vIndex)
}

static setArrowTexTime(beat: number, second: number) {
static setArrowTexTime(app: App, beat: number, second: number) {
if (!this.loaded) return
for (let i = 0; i < 10; i++) {
const tapShader: Mesh<Shader> =
Expand All @@ -235,6 +220,19 @@ export class DanceDefaultNoteTexture {
DanceDefaultNoteTexture.mineConainer.children[0]
)).shader.uniforms.time = second
DanceDefaultNoteTexture.mineConainer.rotation = (second % 1) * Math.PI * 2

app.renderer.render(DanceDefaultNoteTexture.arrowFrame, {
renderTexture: DanceDefaultNoteTexture.arrowFrameTex,
})
app.renderer.render(DanceDefaultNoteTexture.arrowContainer, {
renderTexture: DanceDefaultNoteTexture.arrowTex,
})
app.renderer.render(DanceDefaultNoteTexture.mineConainer, {
renderTexture: DanceDefaultNoteTexture.mineTex,
})
app.renderer.render(DanceDefaultNoteTexture.liftContainer, {
renderTexture: DanceDefaultNoteTexture.liftTex,
})
}

static setNoteTex(arrow: Sprite, note: NotedataEntry) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class DanceDefaultNoteskinObject extends NoteSkin {
constructor(renderer: ChartRenderer) {
super(renderer)

DanceDefaultNoteTexture.initArrowTex(renderer.chartManager.app)
DanceDefaultNoteTexture.initArrowTex()
}

createReceptor(_: number) {
Expand All @@ -31,6 +31,7 @@ class DanceDefaultNoteskinObject extends NoteSkin {

update(): void {
DanceDefaultNoteTexture.setArrowTexTime(
this.renderer.chartManager.app,
this.renderer.getVisualBeat(),
this.renderer.getVisualTime()
)
Expand Down

0 comments on commit 94c4be8

Please sign in to comment.