Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development #137

Merged
merged 4 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -2553,6 +2553,10 @@ input[type="color"] {
border-bottom: 0px solid var(--secondary-border);
}

#playback-options .playback-options-label {
white-space: nowrap;
}

.playback-options-title {
justify-content: center;
text-align: center;
Expand Down
3 changes: 2 additions & 1 deletion app/src/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ export class App {
return
}
let foundSM = ""
for (const file of args) {
for (let file of args) {
if (file.startsWith("file://")) file = file.substring(7)
if (extname(file) == ".ssc") {
foundSM = file
break
Expand Down
20 changes: 19 additions & 1 deletion app/src/chart/ChartManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ interface PartialHold {
oldNote: PartialHoldNotedataEntry
newNote: PartialNotedataEntry
}[]
direction: "up" | "down" | null
}

interface Selection {
Expand Down Expand Up @@ -1259,6 +1260,7 @@ export class ChartManager {
type,
removedNotes: conflictingNotes,
truncatedHolds: truncatedHolds,
direction: null,
}
this.holdEditing[col] = holdEdit

Expand Down Expand Up @@ -1313,7 +1315,23 @@ export class ChartManager {
if (hold == undefined) return
if (beat == hold.startBeat && beat == hold.endBeat) return

hold.endBeat = Math.max(hold.startBeat, Math.round(beat * 48) / 48)
if (hold.direction === null) {
if (beat < hold.startBeat) {
hold.direction = "up"
} else {
hold.direction = "down"
}
}
if (Options.chart.defaultHoldPlacement) {
if (hold.direction == "up") {
hold.startBeat = Math.min(hold.endBeat, Math.round(beat * 48) / 48)
} else {
hold.endBeat = Math.max(hold.startBeat, Math.round(beat * 48) / 48)
}
} else {
hold.startBeat = Math.min(hold.startBeat, Math.round(beat * 48) / 48)
hold.endBeat = Math.max(hold.endBeat, Math.round(beat * 48) / 48)
}
hold.roll ||= roll
if (!hold.originalNote) {
const note: PartialNotedataEntry = {
Expand Down
4 changes: 2 additions & 2 deletions app/src/chart/component/edit/BarlineContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ export class BarlineContainer
private barlinePool = new DisplayObjectPool({
create: () => {
const line = new Sprite(Texture.WHITE)
assignTint(line, "--text-color")
assignTint(line, "text-color")
return line
},
})
private barlineLabelPool = new DisplayObjectPool({
create: () => {
const text = new BitmapText("", measureNumbers)
assignTint(text, "--text-color")
assignTint(text, "text-color")
return text
},
})
Expand Down
2 changes: 1 addition & 1 deletion app/src/chart/component/edit/PreviewAreaContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class PreviewAreaContainer
})
this.previewText.x = -this.previewArea.width / 2 + 5
this.previewArea.anchor.x = 0.5
assignTint(this.previewText, "--text-color")
assignTint(this.previewText, "text-color")
this.addChild(this.previewArea, this.previewText)
}

Expand Down
6 changes: 3 additions & 3 deletions app/src/chart/component/play/ErrorBarContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ export class ErrorBarContainer
this.barline.anchor.set(0.5)
this.barline.height = 1
this.barline.alpha = 0.5
assignTint(this.barline, "--text-color")
assignTint(this.barline, "text-color")
const target = new Sprite(Texture.WHITE)
target.width = 2
target.height = BAR_HEIGHT
target.anchor.set(0.5)
assignTint(target, "--text-color")
assignTint(target, "text-color")
this.currentMedian = new Graphics()
this.currentMedian.beginFill(0xffffff)
this.currentMedian.moveTo(0, -10)
this.currentMedian.lineTo(5, -15)
this.currentMedian.lineTo(-5, -15)
this.currentMedian.lineTo(0, -10)
assignTint(this.currentMedian, "--text-color")
assignTint(this.currentMedian, "text-color")
this.errorText.y = -25
this.errorText.anchor.set(0.5)
this.addChild(
Expand Down
10 changes: 10 additions & 0 deletions app/src/data/UserOptionsWindowData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,16 @@ export const USER_OPTIONS_WINDOW_DATA: UserOption[] = [
type: "checkbox",
},
},
{
type: "item",
label: "Directional hold placement behavior",
id: "chart.defaultHoldPlacement",
input: {
type: "checkbox",
},
tooltip:
"Changes the hold placement behavior. By default, holds can only be extended in one direction when placed. Turn this off to mimic the behavior of AV/Stepmania.",
},
],
},
{
Expand Down
2 changes: 1 addition & 1 deletion app/src/gui/widget/BaseTimelineWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class BaseTimelineWidget extends Widget {
this.addChild(this.container)
this.visible = false

assignTint(this.backing, "--widget-bg")
assignTint(this.backing, "widget-bg")

this.overlay.anchor.x = 0.5
this.overlay.anchor.y = 0
Expand Down
6 changes: 3 additions & 3 deletions app/src/gui/widget/DebugWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ export class DebugWidget extends Widget {

this.fpsText.x = 5
this.fpsBg.y = -5
assignTint(this.fpsBg, "--widget-bg")
assignTint(this.fpsText, "--text-color")
assignTint(this.fpsBg, "widget-bg")
assignTint(this.fpsText, "text-color")

this.graphs.addChild(
this.frameTimeGraph,
Expand Down Expand Up @@ -220,7 +220,7 @@ class DebugGraph extends Container {
bg.width = this.graphWidth
bg.height = this.graphHeight

assignTint(bg, "--text-color")
assignTint(bg, "text-color")

this.labelText = new BitmapText(label, {
fontName: "Main",
Expand Down
2 changes: 1 addition & 1 deletion app/src/gui/widget/NPSGraphWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class NPSGraphWidget extends BaseTimelineWidget {
this.npsText.visible = false
this.npsText.anchor.x = 1
this.npsText.anchor.y = 0.5
assignTint(this.npsText, "--text-color")
assignTint(this.npsText, "text-color")
this.addChild(this.npsText)

EventHandler.on("userOptionUpdated", optionId => {
Expand Down
26 changes: 13 additions & 13 deletions app/src/gui/widget/PlayInfoWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class PlayInfoWidget extends Widget {
this.visible = false

this.background.addChild(this.backgroundRect)
assignTint(this.backgroundRect, "--widget-bg")
assignTint(this.backgroundRect, "widget-bg")
this.addChild(this.background)
this.addChild(this.backgroundLines)
this.eventMode = "static"
Expand Down Expand Up @@ -140,7 +140,7 @@ export class PlayInfoWidget extends Widget {
early.y = -HISTOGRAM_HEIGHT - 40
early.alpha = 0.3
this.background.addChild(early)
assignTint(early, "--text-color")
assignTint(early, "text-color")

const late = new BitmapText("Late", {
fontName: "Main",
Expand All @@ -151,7 +151,7 @@ export class PlayInfoWidget extends Widget {
late.y = -HISTOGRAM_HEIGHT - 40
late.alpha = 0.3
this.background.addChild(late)
assignTint(late, "--text-color")
assignTint(late, "text-color")

this.meanText = new BitmapText("-", {
fontName: "Main",
Expand Down Expand Up @@ -226,7 +226,7 @@ export class PlayInfoWidget extends Widget {
this.statText.addChild(stddevLabel)

this.statText.children.forEach(child => {
assignTint(child as BitmapText, "--text-color")
assignTint(child as BitmapText, "text-color")
})

const alignSongContainer = new Container()
Expand Down Expand Up @@ -261,7 +261,7 @@ export class PlayInfoWidget extends Widget {
alignSongBg.alpha = 0.3
})
this.statText.addChild(alignSongContainer)
assignTint(alignSongText, "--text-color")
assignTint(alignSongText, "text-color")

const alignGlobalContainer = new Container()

Expand Down Expand Up @@ -290,7 +290,7 @@ export class PlayInfoWidget extends Widget {
alignGlobalText.x = WIDGET_WIDTH / 4
alignGlobalText.y = -25
alignGlobalContainer.addChild(alignGlobalBg, alignGlobalText)
assignTint(alignGlobalText, "--text-color")
assignTint(alignGlobalText, "text-color")

alignGlobalContainer.eventMode = "static"
alignGlobalContainer.addEventListener("mouseenter", () => {
Expand Down Expand Up @@ -463,8 +463,8 @@ export class PlayInfoWidget extends Widget {
fontName: "Main",
fontSize: 15,
})
assignTint(label, "--text-color")
assignTint(count, "--text-color")
assignTint(label, "text-color")
assignTint(count, "text-color")
if (name != "Mine")
count.text =
"0 / " +
Expand All @@ -489,12 +489,12 @@ export class PlayInfoWidget extends Widget {
fontName: "Main",
fontSize: 15,
})
assignTint(label, "--text-color")
assignTint(label, "text-color")
const count = new BitmapText("0", {
fontName: "Main",
fontSize: 15,
})
assignTint(count, "--text-color")
assignTint(count, "text-color")
label.alpha = 0.8
count.alpha = 0.8
count.name = "Combo"
Expand All @@ -512,7 +512,7 @@ export class PlayInfoWidget extends Widget {
fontName: "Main",
fontSize: 20,
})
assignTint(score, "--text-color")
assignTint(score, "text-color")
score.alpha = 0.8
score.x = -WIDGET_WIDTH / 2 + 225
score.y = -HISTOGRAM_HEIGHT - 112
Expand All @@ -524,7 +524,7 @@ export class PlayInfoWidget extends Widget {
fontName: "Main",
fontSize: 13,
})
assignTint(scoreLabel, "--text-color")
assignTint(scoreLabel, "text-color")
scoreLabel.alpha = 0.5
scoreLabel.x = -WIDGET_WIDTH / 2 + 225
scoreLabel.y = -HISTOGRAM_HEIGHT - 135
Expand All @@ -537,7 +537,7 @@ export class PlayInfoWidget extends Widget {
})
windowLabel.y = -HISTOGRAM_HEIGHT - 245
windowLabel.anchor.set(0.5)
assignTint(windowLabel, "--text-color")
assignTint(windowLabel, "text-color")
this.texts.addChild(windowLabel)

gameStats.onJudge((error, judge) => {
Expand Down
9 changes: 5 additions & 4 deletions app/src/gui/widget/StatusWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import {
TapNoteType,
} from "../../chart/sm/NoteTypes"
import { BetterRoundedRect } from "../../util/BetterRoundedRect"
import { assignTint, blendPixiColors, getCSSColor } from "../../util/Color"
import { assignTint, blendPixiColors } from "../../util/Color"
import { EventHandler } from "../../util/EventHandler"
import { Flags } from "../../util/Flags"
import { Keybinds } from "../../util/Keybinds"
import { roundDigit } from "../../util/Math"
import { Options } from "../../util/Options"
import { Themes } from "../../util/Theme"
import { Icons } from "../Icons"
import { Dropdown } from "../element/Dropdown"
import { TimingTrackOrderPopup } from "../popup/TimingTrackOrderPopup"
Expand Down Expand Up @@ -494,7 +495,7 @@ export class StatusWidget extends Widget {
})
sprite.scale.set(0.5)
const bg = new Sprite(Texture.WHITE)
assignTint(bg, "--widget-bg")
assignTint(bg, "widget-bg")
bg.width = 48
bg.height = 48
bg.anchor.set(0.5)
Expand Down Expand Up @@ -804,8 +805,8 @@ export class StatusWidget extends Widget {
}

const noteType = this.manager.chartManager.getEditingNoteType()
const hoverColor = getCSSColor("--editable-overlay-hover")
const activeColor = getCSSColor("--editable-overlay-active")
const hoverColor = Themes.getColor("editable-overlay-hover")
const activeColor = Themes.getColor("editable-overlay-active")
const emptyColor = new Color(hoverColor).setAlpha(0)
this.noteArrows.forEach(arrow => {
let color =
Expand Down
10 changes: 6 additions & 4 deletions app/src/util/Color.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Color, ColorSource } from "pixi.js"
import { ThemeProperty } from "../data/ThemeData"
import { EventHandler } from "./EventHandler"
import { clamp, lerp } from "./Math"
import { Themes } from "./Theme"

export function rgbtoHex(r: number, g: number, b: number): number {
return (r << 16) + (g << 8) + b
Expand Down Expand Up @@ -57,11 +59,11 @@ export function getCSSColor(id: string) {

type TintableObject = { tint: ColorSource; alpha: number; destroyed: boolean }

const themeObjectMap = new Map<string, TintableObject[]>()
const themeObjectMap = new Map<ThemeProperty, TintableObject[]>()

EventHandler.on("themeChanged", () => {
for (const [id, objects] of themeObjectMap.entries()) {
const color = getCSSColor(id)
const color = Themes.getColor(id)
objects.forEach(o => {
if (o.destroyed) return
o.tint = color.toNumber()
Expand All @@ -74,12 +76,12 @@ EventHandler.on("themeChanged", () => {
}
})

export function assignTint(element: TintableObject, id: string) {
export function assignTint(element: TintableObject, id: ThemeProperty) {
if (!themeObjectMap.has(id)) {
themeObjectMap.set(id, [])
}
themeObjectMap.get(id)!.push(element)
const color = getCSSColor(id)
const color = Themes.getColor(id)
element.tint = color.toNumber()
element.alpha = color.alpha
}
Expand Down
1 change: 1 addition & 0 deletions app/src/util/Options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class DefaultOptions {
CMod: false,
reverse: false,
mousePlacement: false,
defaultHoldPlacement: true,
zoom: 1,
speed: 250,
snap: 1,
Expand Down
5 changes: 5 additions & 0 deletions app/src/util/Theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
DEFAULT_THEMES,
Theme,
THEME_VAR_WHITELIST,
ThemeProperty,
ThemeString,
} from "../data/ThemeData"
import { WaterfallManager } from "../gui/element/WaterfallManager"
Expand Down Expand Up @@ -186,4 +187,8 @@ export class Themes {
}
return this.validateTheme(theme)
}

static getColor(id: ThemeProperty) {
return this.currentTheme?.[id] ?? DEFAULT_THEMES["default"][id]
}
}
Loading