Skip to content

Commit

Permalink
Merge pull request #127 from tillvit/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
tillvit authored Sep 2, 2024
2 parents ec0e3fa + 2edb34a commit 1caa989
Show file tree
Hide file tree
Showing 16 changed files with 111 additions and 66 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "18.x"
node-version: "20.x"

- name: Build
run: |
npm install
npm run build
- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/devbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "18.x"
node-version: "20.x"

- name: Build
run: |
Expand Down
22 changes: 11 additions & 11 deletions app/src/chart/ChartRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,11 @@ export class ChartRenderer extends Container<ChartRendererComponent> {
...this.chart.timingData.getTimingData("SCROLLS"),
]
if (scrolls[0]?.beat != 0)
scrolls.splice(0, 0, { beat: 0, value: 1, type: "SCROLLS" })
scrolls.splice(0, 0, {
beat: 0,
value: scrolls[0]?.value ?? 1,
type: "SCROLLS",
})

let scrollIndex = bsearch(
scrolls,
Expand All @@ -633,8 +637,6 @@ export class ChartRenderer extends Container<ChartRendererComponent> {
const scroll = scrolls[scrollIndex]
scrollIndex++

if (scroll.value == 0) continue

const scrollStartY =
scroll === undefined
? -Infinity * this.getScrollDirection(scrolls[0]?.value ?? 1)
Expand All @@ -656,7 +658,11 @@ export class ChartRenderer extends Container<ChartRendererComponent> {
...this.chart.timingData.getTimingData("SCROLLS"),
]
if (scrolls[0]?.beat != 0)
scrolls.splice(0, 0, { beat: 0, value: 1, type: "SCROLLS" })
scrolls.splice(0, 0, {
beat: 0,
value: scrolls[0]?.value ?? 1,
type: "SCROLLS",
})
let scrollIndex = bsearch(
scrolls,
this.getVisualBeat() + Options.chart.maxDrawBeats,
Expand All @@ -673,8 +679,6 @@ export class ChartRenderer extends Container<ChartRendererComponent> {
const scroll = scrolls[scrollIndex]
scrollIndex--

if (scroll.value == 0) continue

const scrollStartY =
scroll === undefined
? -Infinity * this.getScrollDirection(scrolls[0]?.value ?? 1)
Expand All @@ -699,12 +703,8 @@ export class ChartRenderer extends Container<ChartRendererComponent> {
) {
const scroll = this.findFirstOnScreenScroll()

const speedMult = this.getCurrentSpeedMult()
const pixelsToEffectiveBeats =
100 /
Options.chart.speed /
Math.abs(speedMult) /
64 /
(1 / Math.abs(this.getEffectiveBeatsToPixelsRatio())) *
Options.chart.zoom

const scrollStartY = this.getYPosFromBeat(scroll.beat)
Expand Down
16 changes: 9 additions & 7 deletions app/src/chart/component/edit/Waveform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,11 @@ export class Waveform extends Sprite implements ChartRendererComponent {
...this.renderer.chart.timingData.getTimingData("SCROLLS"),
]
if (scrolls[0]?.beat != 0)
scrolls.unshift({ type: "SCROLLS", beat: 0, value: 1 })
scrolls.unshift({
type: "SCROLLS",
beat: 0,
value: scrolls[0]?.value ?? 1,
})

const startScrollIndex = scrolls.findIndex(
a => a.beat == startScroll.beat
Expand All @@ -258,7 +262,7 @@ export class Waveform extends Sprite implements ChartRendererComponent {
)) {
if (scroll.value == 0) continue
const pixelsToBeats = pixelsToEffectiveBeats / Math.abs(scroll.value)
if (scroll != startScroll) {
if (scroll.beat != startScroll.beat) {
currentBeat = scroll.beat
} else {
// fix flickering by rounding the current beat to land on a pixel
Expand All @@ -279,7 +283,7 @@ export class Waveform extends Sprite implements ChartRendererComponent {
// Stop if the scroll is off the screen
if (currentYPos < 0) {
// Skip the scroll if we step off the top of the screen
if (scroll.value * scrollDirection < 0) {
if (scrollDirection < 0) {
currentBeat = scrollEndBeat
break
}
Expand All @@ -290,7 +294,7 @@ export class Waveform extends Sprite implements ChartRendererComponent {

if (currentYPos > screenHeight) {
// Skip the scroll if we step off the bottom of the screen
if (scroll.value * scrollDirection > 0) {
if (scrollDirection > 0) {
currentBeat = scrollEndBeat
break
}
Expand All @@ -302,9 +306,7 @@ export class Waveform extends Sprite implements ChartRendererComponent {

// Step by 1 or -1 pixels and get the current beat
currentBeat += pixelsToBeats * Options.chart.waveform.lineHeight
currentYPos +=
(scroll.value * scrollDirection > 0 ? 1 : -1) *
Options.chart.waveform.lineHeight
currentYPos += scrollDirection * Options.chart.waveform.lineHeight

curSec = this.calculateSecond(
currentBeat,
Expand Down
2 changes: 1 addition & 1 deletion app/src/chart/component/timing/TimingTrackContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ export class TimingTrackContainer
TIMING_EVENT_COLORS[event.type] ?? 0x000000,
Math.sin(Date.now() / 320) * 0.4 + 1.5
)
: TIMING_EVENT_COLORS[event.type] ?? 0x000000
: (TIMING_EVENT_COLORS[event.type] ?? 0x000000)
box.selection.alpha = inSelection ? 1 : 0
box.visible =
!inSelection || !this.renderer.chartManager.eventSelection.shift
Expand Down
8 changes: 4 additions & 4 deletions app/src/chart/gameTypes/GameTypeRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ GameTypeRegistry.register({
parser: new BasicNotedataParser(),
editNoteTypes: ["Tap", "Mine", "Fake", "Lift"],
flipColumns: {
horizontal: [4, 3, 2, 1, 0, 9, 8, 7, 6, 5],
horizontal: [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],
vertical: [1, 0, 2, 4, 3, 6, 5, 7, 9, 8],
},
})
Expand All @@ -217,7 +217,7 @@ GameTypeRegistry.register({
parser: new BasicNotedataParser(),
editNoteTypes: ["Tap", "Mine", "Fake", "Lift"],
flipColumns: {
horizontal: [4, 3, 2, 1, 0, 9, 8, 7, 6, 5],
horizontal: [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],
vertical: [1, 0, 2, 4, 3, 6, 5, 7, 9, 8],
},
})
Expand All @@ -242,7 +242,7 @@ GameTypeRegistry.register({
parser: new BasicNotedataParser(),
editNoteTypes: ["Tap", "Mine", "Fake", "Lift"],
flipColumns: {
horizontal: [4, 3, 2, 1, 0, 9, 8, 7, 6, 5],
horizontal: [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],
vertical: [1, 0, 2, 4, 3, 6, 5, 7, 9, 8],
},
})
Expand All @@ -263,7 +263,7 @@ GameTypeRegistry.register({
parser: new BasicNotedataParser(),
editNoteTypes: ["Tap", "Mine", "Fake", "Lift"],
flipColumns: {
horizontal: [5, 1, 2, 3, 4, 0],
horizontal: [5, 4, 3, 2, 1, 0],
vertical: [0, 2, 1, 4, 3, 5],
},
})
4 changes: 2 additions & 2 deletions app/src/chart/sm/TimingData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export abstract class TimingData {
cache.unshift({
type: "SCROLLS",
beat: 0,
value: 1,
value: cache[0].value ?? 1,
})
effBeat = cache[0].beat
for (let i = 0; i < cache.length - 1; i++) {
Expand Down Expand Up @@ -478,14 +478,14 @@ export abstract class TimingData {
switch (event.type) {
case "BPMS":
case "SPEEDS":
case "SCROLLS":
case "TICKCOUNTS":
case "TIMESIGNATURES":
case "COMBOS":
return false
case "STOPS":
case "WARPS":
case "DELAYS":
case "SCROLLS":
case "FAKES":
return event.value == 0
case "LABELS":
Expand Down
34 changes: 34 additions & 0 deletions app/src/data/KeybindData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1423,4 +1423,38 @@ export const KEYBIND_DATA: { [key: string]: Keybind } = {
disabled: app => !app.chartManager.chartView,
callback: app => app.windowManager.openWindow(new NoteskinWindow(app)),
},
previousChart: {
label: "Previous chart",
combos: [{ key: "F5", mods: [] }],
disabled: app => !app.chartManager.chartView,
callback: app => {
if (!app.chartManager.loadedSM?.charts || !app.chartManager.loadedChart)
return
const charts =
app.chartManager.loadedSM?.charts[
app.chartManager.loadedChart.gameType.id
]
const curIndex = charts.indexOf(app.chartManager.loadedChart)
if (charts[curIndex - 1]) {
app.chartManager.loadChart(charts[curIndex - 1])
}
},
},
nextChart: {
label: "Next chart",
combos: [{ key: "F6", mods: [] }],
disabled: app => !app.chartManager.chartView,
callback: app => {
if (!app.chartManager.loadedSM?.charts || !app.chartManager.loadedChart)
return
const charts =
app.chartManager.loadedSM?.charts[
app.chartManager.loadedChart.gameType.id
]
const curIndex = charts.indexOf(app.chartManager.loadedChart)
if (charts[curIndex + 1]) {
app.chartManager.loadChart(charts[curIndex + 1])
}
},
},
}
11 changes: 11 additions & 0 deletions app/src/data/MenubarData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,17 @@ export const MENUBAR_DATA: { [key: string]: MenuMain } = {
{
type: "separator",
},
{
type: "selection",
id: "previousChart",
},
{
type: "selection",
id: "nextChart",
},
{
type: "separator",
},
{
type: "selection",
id: "songProperties",
Expand Down
46 changes: 22 additions & 24 deletions app/src/gui/window/ChartListWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,34 +236,32 @@ export class ChartListWindow extends Window {
if (!chart) return

const sortDifficulties = () =>
this.app.chartManager.loadedSM!.charts[chart!.gameType.id]!.sort(
(a, b) => {
if (
CHART_DIFFICULTIES.indexOf(a.difficulty) ==
CHART_DIFFICULTIES.indexOf(b.difficulty)
)
return a.meter - b.meter
return (
CHART_DIFFICULTIES.indexOf(a.difficulty) -
CHART_DIFFICULTIES.indexOf(b.difficulty)
)
}
)
this.app.chartManager.loadedSM!.charts[chart.gameType.id].sort((a, b) => {
if (
CHART_DIFFICULTIES.indexOf(a.difficulty) ==
CHART_DIFFICULTIES.indexOf(b.difficulty)
)
return a.meter - b.meter
return (
CHART_DIFFICULTIES.indexOf(a.difficulty) -
CHART_DIFFICULTIES.indexOf(b.difficulty)
)
})

const main = document.createElement("div")
main.classList.add("chart-info-main")
const difficulty = Dropdown.create(CHART_DIFFICULTIES, chart.difficulty)
difficulty.view.classList.add("no-border", "white")
difficulty.onChange(value => {
const lastVal = chart!.difficulty
const lastVal = chart.difficulty
ActionHistory.instance.run({
action: () => {
chart!.difficulty = value
chart.difficulty = value
sortDifficulties()
this.loadCharts()
},
undo: () => {
chart!.difficulty = lastVal
chart.difficulty = lastVal
sortDifficulties()
this.loadCharts()
},
Expand All @@ -285,17 +283,17 @@ export class ChartListWindow extends Window {
return
}
value = Math.round(clamp(1, value, 2 ** 31 - 1))
const lastVal = chart!.meter
const lastVal = chart.meter
ActionHistory.instance.run({
action: () => {
chart!.meter = value!
chart!.meterF = value!
chart.meter = value!
chart.meterF = value!
sortDifficulties()
this.loadCharts()
},
undo: () => {
chart!.meter = lastVal
chart!.meterF = lastVal!
chart.meter = lastVal
chart.meterF = lastVal!
sortDifficulties()
this.loadCharts()
},
Expand All @@ -315,7 +313,7 @@ export class ChartListWindow extends Window {
label.classList.add("label")
label.innerText = entry.title

const item = entry.element(chart!, this.app)
const item = entry.element(chart, this.app)

if (entry.title == "Artist") {
item.addEventListener("blur", () => this.loadCharts())
Expand Down Expand Up @@ -366,7 +364,7 @@ export class ChartListWindow extends Window {
chart
)
newChart.setNotedata(
chart!.getNotedata().map(note => chart!.computeNote(note)) ?? []
chart.getNotedata().map(note => chart.computeNote(note)) ?? []
)
this.app.chartManager.loadedSM!.addChart(newChart)
this.app.chartManager.loadChart(newChart)
Expand Down Expand Up @@ -403,7 +401,7 @@ export class ChartListWindow extends Window {
type: "delete",
label: "Delete",
callback: () => {
if (this.app.chartManager.loadedSM!.removeChart(chart!)) {
if (this.app.chartManager.loadedSM!.removeChart(chart)) {
this.app.chartManager.loadChart()
this.gameType =
this.app.chartManager.loadedChart?.gameType ?? this.gameType
Expand Down
4 changes: 2 additions & 2 deletions app/src/gui/window/DirectoryWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ export class DirectoryWindow extends Window {
if (!next && item.parentElement!.classList.contains("children"))
next = (<HTMLElement>(
item.parentElement!.parentElement!.nextSibling
))!.querySelector(".info") as HTMLElement
)).querySelector(".info") as HTMLElement
if (next) {
this.selectElement(next)
scrollIntoView(next, {
Expand Down Expand Up @@ -736,7 +736,7 @@ export class DirectoryWindow extends Window {

private handleMouseEvent(event: MouseEvent) {
const scroll = this.viewElement.querySelector(".dir-selector")!
let items = Array.from(scroll.querySelectorAll("div.item.folder"))!
let items = Array.from(scroll.querySelectorAll("div.item.folder"))
const prevOwner = this.viewElement.querySelector(".outlined")
items = items.filter(x => !x.parentElement!.closest(".collapsed"))
items.reverse()
Expand Down
2 changes: 1 addition & 1 deletion app/src/gui/window/KeybindWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export class KeybindWindow extends Window {
KEYBIND_INSERTS[id].forEach(insert => {
const insertIndex = !insert.after
? 0
: GROUPS[id].findIndex(id => insert.after == id) + 1 ?? 0
: (GROUPS[id].findIndex(id => insert.after == id) + 1 ?? 0)
GROUPS[id].splice(insertIndex, 0, ...insert.ids)
insert.ids.forEach(option => {
const idx = missingKeybindTest.indexOf(option)
Expand Down
Loading

0 comments on commit 1caa989

Please sign in to comment.