Skip to content

Commit

Permalink
Add setting for banana path shade visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
solstice23 committed Nov 3, 2024
1 parent 2e0d3cb commit 0b5d6e6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/contexts/SettingsContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export const SettingsProvider = ({children}) => {
const [easy, easyRef, setEasy] = useSetting("easy", false);

const [gameSpeed, gameSpeedRef, setGameSpeed] = useSetting("gameSpeed", 1, false);

const [showBananaPathShade, showBananaPathShadeRef, setShowBananaPathShade] = useSetting("showBananaPathShade", true, true);

const [showFPS, showFPSRef, setShowFPS] = useSetting("showFPS", false, true);

Expand All @@ -32,6 +34,7 @@ export const SettingsProvider = ({children}) => {
hardRock, setHardRock, hardRockRef,
easy, setEasy, easyRef,
gameSpeed, setGameSpeed, gameSpeedRef,
showBananaPathShade, setShowBananaPathShade, showBananaPathShadeRef,
showFPS, setShowFPS, showFPSRef,
backgroundDim, setBackgroundDim, backgroundDimRef,
volume, setVolume, volumeRef,
Expand Down
27 changes: 18 additions & 9 deletions src/modules/Main/Playfield/ObjectsCanvas.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export function ObjectsCanvas({


const { verticalScale,
derandomize, derandomizeRef,
hardRock, hardRockRef,
easy, easyRef,
derandomize,
hardRock, easy,
showBananaPathShade
} = useContext(SettingsContext);

const {playing, playerRef, getPreciseTime} = useContext(PlayStateContext);
Expand Down Expand Up @@ -57,6 +57,10 @@ export function ObjectsCanvas({
managerRef.current.setBananaSegmentPaths(bananaSegmentPaths);
}, [bananaSegmentPaths]);

useEffect(() => {
managerRef.current.setShowBananaPathShade(showBananaPathShade);
}, [showBananaPathShade]);

useEffect(() => {
managerRef.current.setHardRock(hardRock);
managerRef.current.setEasy(easy);
Expand Down Expand Up @@ -186,6 +190,9 @@ class PixiManager {
getCatchWidth() {
return CalculateCatchWidthByCircleSize(this.getModdedCircleSize());
}
getShowBananaPathShade() {
return this.showBananaPathShade;
}
setSkinAssets(skin) {
this.skinAssets = skin;
this.applyToAllFruits(fruit => fruit.updateTexture());
Expand All @@ -212,6 +219,10 @@ class PixiManager {
this.bananaSegmentPaths = bananaSegmentPaths;
if (this.rendering) this.initBananaPathPolylines();
}
setShowBananaPathShade(showBananaPathShade) {
this.showBananaPathShade = showBananaPathShade;
this.applyToAllPolyLines(polyline => polyline.setVisiblity(showBananaPathShade));
}
setRendering(rendering) {
this.rendering = rendering;
}
Expand Down Expand Up @@ -242,7 +253,6 @@ class PixiManager {
const bananaPathPolyline = new BananaPathPolyline(this, path);
this.bananaPathPolylines.push(bananaPathPolyline);
}
this.applyToAllPolyLines(polyline => polyline.updatePosition());
}

applyToAllPolyLines(func) {
Expand Down Expand Up @@ -480,6 +490,7 @@ class BananaPathPolyline {
this.shade.fill(0xffff00);
}
const drawCatcherOutline = (fromX, fromTime, toX, toTime) => {
// outline
this.outline.lineTo(transformX(fromX), transformY(fromTime));
this.outline.lineTo(transformX(toX), transformY(toTime));
}
Expand All @@ -504,11 +515,9 @@ class BananaPathPolyline {
manager.app.stage.addChild(this.outline);


//this.setVisiblity(false);
this.setVisiblity(manager.getShowBananaPathShade());

//this.updateSize();
//this.updateComboColour();
//this.updateVisualStyle();
this.updatePosition();

manager.app.stage.addChild(this.shade);
}
Expand All @@ -527,7 +536,7 @@ class BananaPathPolyline {
}

setVisiblity(visible) {
this.shade.visible = visible;
this.shade.visible = this.outline.visible = visible;
}

destory() {
Expand Down
11 changes: 10 additions & 1 deletion src/modules/Navbar/SettingsPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export function SettingsPanel () {
hardRock, setHardRock,
easy, setEasy,
gameSpeed, setGameSpeed,
showBananaPathShade, setShowBananaPathShade,
showFPS, setShowFPS,
backgroundDim, setBackgroundDim,
useLegacyDOMRenderer, setUseLegacyDOMRenderer,
Expand All @@ -36,7 +37,7 @@ export function SettingsPanel () {
}}
>
<MdSettings />
<div className="settings-panel-menu" onClick={(e) => e.stopPropagation()}>
<div className="settings-panel-menu" onClick={(e) => e.stopPropagation()} onWheel={(e) => e.stopPropagation()}>
<Checkbox
label="Show Grid"
description="Show grid lines on the playfield"
Expand Down Expand Up @@ -126,6 +127,14 @@ export function SettingsPanel () {
defaultValue={0.2}
onChange={(value) => setMaxSpinLeniency(value)}
/>
<Checkbox
label="Show Banana Path Shade"
description="Visualize the catcher path for bananas"
value={showBananaPathShade}
onChange={(value) => {
setShowBananaPathShade(value);
}}
/>
<Checkbox
label="Show FPS"
description="Show performance monitor"
Expand Down

0 comments on commit 0b5d6e6

Please sign in to comment.