Skip to content

Commit

Permalink
Remove useless "use new layout" context
Browse files Browse the repository at this point in the history
  • Loading branch information
Rian8337 committed Sep 8, 2023
1 parent 58db641 commit b3bc820
Show file tree
Hide file tree
Showing 28 changed files with 141 additions and 224 deletions.
1 change: 1 addition & 0 deletions src/components/groups/Group.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@

.group-item .group-description {
font-size: 0.9em;
margin-top: 1em;
}
7 changes: 0 additions & 7 deletions src/components/groups/main/LoadJsonGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { MenuItemVersionsDefaultColorContext } from "../../../hooks/Color/MenuIt
import { MenuItemVersionsSelectedColorContext } from "../../../hooks/Color/MenuItemVersionsSelectedColorContext";
import { MenuItemDefaultTextColorContext } from "../../../hooks/Color/MenuItemDefaultTextColorContext";
import { MenuItemSelectedTextColorContext } from "../../../hooks/Color/MenuItemSelectedTextColorContext";
import { UseNewLayoutContext } from "../../../hooks/Layout/UseNewLayoutContext";
import { BackButtonWidthContext } from "../../../hooks/Layout/BackButton/BackButtonWidthContext";
import { BackButtonHeightContext } from "../../../hooks/Layout/BackButton/BackButtonHeightContext";
import { BackButtonScaleContext } from "../../../hooks/Layout/BackButton/BackButtonScaleContext";
Expand Down Expand Up @@ -89,9 +88,6 @@ export default function LoadJsonGroup() {
);

// Layout
// Layout Switch
const useNewLayout = useContext(UseNewLayoutContext);

// Back Button
const backButtonWidth = useContext(BackButtonWidthContext);
const backButtonHeight = useContext(BackButtonHeightContext);
Expand Down Expand Up @@ -189,9 +185,6 @@ export default function LoadJsonGroup() {
);

// Layout
// Layout Switch
useNewLayout.setValue(Layout?.useNewLayout);

// Back Button
backButtonWidth.setValue(Layout?.BackButton?.w);
backButtonHeight.setValue(Layout?.BackButton?.h);
Expand Down
7 changes: 0 additions & 7 deletions src/components/groups/main/ResetJsonGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import { RandomButtonScaleContext } from "../../../hooks/Layout/RandomButton/Ran
import { RandomButtonWidthContext } from "../../../hooks/Layout/RandomButton/RandomButtonWidthContext";
import { RandomButtonXContext } from "../../../hooks/Layout/RandomButton/RandomButtonXContext";
import { RandomButtonYContext } from "../../../hooks/Layout/RandomButton/RandomButtonYContext";
import { UseNewLayoutContext } from "../../../hooks/Layout/UseNewLayoutContext";
import { SliderBodyBaseAlphaContext } from "../../../hooks/Slider/SliderBodyBaseAlphaContext";
import { SliderBodyColorContext } from "../../../hooks/Slider/SliderBodyColorContext";
import { SliderBodyWidthContext } from "../../../hooks/Slider/SliderBodyWidthContext";
Expand Down Expand Up @@ -88,9 +87,6 @@ export default function ResetJsonGroup() {
);

// Layout
// Layout Switch
const useNewLayout = useContext(UseNewLayoutContext);

// Back Button
const backButtonWidth = useContext(BackButtonWidthContext);
const backButtonHeight = useContext(BackButtonHeightContext);
Expand Down Expand Up @@ -160,9 +156,6 @@ export default function ResetJsonGroup() {
menuItemSelectedTextColor.reset();

// Layout
// Layout switch
useNewLayout.reset();

// Back button
backButtonWidth.reset();
backButtonHeight.reset();
Expand Down
7 changes: 0 additions & 7 deletions src/components/groups/main/SaveJsonGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import { RandomButtonScaleContext } from "../../../hooks/Layout/RandomButton/Ran
import { RandomButtonWidthContext } from "../../../hooks/Layout/RandomButton/RandomButtonWidthContext";
import { RandomButtonXContext } from "../../../hooks/Layout/RandomButton/RandomButtonXContext";
import { RandomButtonYContext } from "../../../hooks/Layout/RandomButton/RandomButtonYContext";
import { UseNewLayoutContext } from "../../../hooks/Layout/UseNewLayoutContext";
import { SliderBodyBaseAlphaContext } from "../../../hooks/Slider/SliderBodyBaseAlphaContext";
import { SliderBodyColorContext } from "../../../hooks/Slider/SliderBodyColorContext";
import { SliderBodyWidthContext } from "../../../hooks/Slider/SliderBodyWidthContext";
Expand Down Expand Up @@ -89,9 +88,6 @@ export default function SaveJsonGroup() {
);

// Layout
// Layout switch
const useNewLayout = useContext(UseNewLayoutContext);

// Back button
const backButtonWidth = useContext(BackButtonWidthContext);
const backButtonHeight = useContext(BackButtonHeightContext);
Expand Down Expand Up @@ -156,9 +152,6 @@ export default function SaveJsonGroup() {
menuItemSelectedTextColor.saveToJSON(json);

// Layout
// Layout switch
useNewLayout.saveToJSON(json);

// Back button
backButtonWidth.saveToJSON(json);
backButtonHeight.saveToJSON(json);
Expand Down
122 changes: 51 additions & 71 deletions src/components/groups/skin/Layout/LayoutGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,88 +1,68 @@
import { useContext } from "react";
import Group from "../../Group";
import SubGroup from "../../SubGroup";
import LayoutBackButton from "./LayoutBackButton";
import LayoutModsButton from "./LayoutModsButton";
import LayoutOptionsButton from "./LayoutOptionsButton";
import LayoutRandomButton from "./LayoutRandomButton";
import { UseNewLayoutContext } from "../../../../hooks/Layout/UseNewLayoutContext";
import CheckBoxEditor from "../../../editors/CheckBoxEditor";

export default function LayoutGroup() {
const useNewLayout = useContext(UseNewLayoutContext);

return (
<Group title="Song Selection Menu Buttons">
<hr />

<CheckBoxEditor
title="Enable Customization"
description="Allows the customization of the back, mods, options, and random buttons in the song selection menu."
resettable={useNewLayout}
/>

{useNewLayout.value ? (
<>
<hr />
<div className="group-description">
There are the same options for each button, namely:
<ul>
<li>
<b>Width</b>
<br />
Specifies the width of the button, in pixels.
Use -1 to use the width of the button&apos;s
texture.
</li>
<br />
<li>
<b>Height</b>
<br />
Specifies the height of the button, in pixels.
Use -1 to use the height of the button&apos;s
texture.
</li>
<br />
<li>
<b>Scale</b>
<br />
Increasing this number increases the size of the
button, and vice versa.
</li>
<br />
<li>
<b>Horizontal Offset</b>
<br />
The horizontal offset of the button from the
left of the screen, in pixels.
</li>
<br />
<li>
<b>Vertical Offset</b>
<br />
The vertical offset of the button from the
bottom of the screen, in pixels.
</li>
</ul>
</div>
<div className="group-description">
There are the same options for each button, namely:
<ul>
<li>
<b>Width</b>
<br />
Specifies the width of the button, in pixels. Use -1 to
use the width of the button&apos;s texture.
</li>
<br />
<li>
<b>Height</b>
<br />
Specifies the height of the button, in pixels. Use -1 to
use the height of the button&apos;s texture.
</li>
<br />
<li>
<b>Scale</b>
<br />
Increasing this number increases the size of the button,
and vice versa.
</li>
<br />
<li>
<b>Horizontal Offset</b>
<br />
The horizontal offset of the button from the left of the
screen, in pixels.
</li>
<br />
<li>
<b>Vertical Offset</b>
<br />
The vertical offset of the button from the bottom of the
screen, in pixels.
</li>
</ul>
</div>

<SubGroup title="Back Button">
<LayoutBackButton />
</SubGroup>
<SubGroup title="Back Button">
<LayoutBackButton />
</SubGroup>

<SubGroup title="Mods Button">
<LayoutModsButton />
</SubGroup>
<SubGroup title="Mods Button">
<LayoutModsButton />
</SubGroup>

<SubGroup title="Options Button">
<LayoutOptionsButton />
</SubGroup>
<SubGroup title="Options Button">
<LayoutOptionsButton />
</SubGroup>

<SubGroup title="Random Button">
<LayoutRandomButton />
</SubGroup>
</>
) : null}
<SubGroup title="Random Button">
<LayoutRandomButton />
</SubGroup>
</Group>
);
}
4 changes: 0 additions & 4 deletions src/hooks/ContextProviders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ import { OptionsButtonXContextProvider } from "./Layout/OptionsButton/OptionsBut
import { OptionsButtonYContextProvider } from "./Layout/OptionsButton/OptionsButtonYContext";
import { RandomButtonXContextProvider } from "./Layout/RandomButton/RandomButtonXContext";
import { RandomButtonYContextProvider } from "./Layout/RandomButton/RandomButtonYContext";
import { UseNewLayoutContextProvider } from "./Layout/UseNewLayoutContext";

const compose =
(...components: FC<Record<string, unknown>>[]) =>
Expand Down Expand Up @@ -77,9 +76,6 @@ export const Providers = compose(
HitCirclePrefixContextProvider,
ScorePrefixContextProvider,

// Layout Switch
UseNewLayoutContextProvider,

// Layout (BackButton)
BackButtonHeightContextProvider,
BackButtonScaleContextProvider,
Expand Down
8 changes: 4 additions & 4 deletions src/hooks/Layout/BackButton/BackButtonHeightContext.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { PropsWithChildren, createContext, useContext, useState } from "react";
import { UseNewLayoutContext } from "../UseNewLayoutContext";
import { PropsWithChildren, createContext, useState } from "react";
import { createNumberResettable } from "../../../utils/ResettableFactory";

const defaultValue = -1;
Expand All @@ -10,7 +9,6 @@ export const BackButtonHeightContext = createContext(
);

export function BackButtonHeightContextProvider(props: PropsWithChildren) {
const useNewLayout = useContext(UseNewLayoutContext);
const [value, setValue] = useState(defaultValue);

return (
Expand All @@ -34,8 +32,10 @@ export function BackButtonHeightContextProvider(props: PropsWithChildren) {
setValue(value);
},
saveToJSON(json) {
if (useNewLayout.value && !this.isDefault) {
if (!this.isDefault) {
json.Layout ??= {};
json.Layout.useNewLayout = true;

json.Layout.BackButton ??= {};
json.Layout.BackButton.h = value;
}
Expand Down
8 changes: 4 additions & 4 deletions src/hooks/Layout/BackButton/BackButtonScaleContext.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { PropsWithChildren, createContext, useContext, useState } from "react";
import { UseNewLayoutContext } from "../UseNewLayoutContext";
import { PropsWithChildren, createContext, useState } from "react";
import { createNumberResettable } from "../../../utils/ResettableFactory";

const defaultValue = -1;
Expand All @@ -10,7 +9,6 @@ export const BackButtonScaleContext = createContext(
);

export function BackButtonScaleContextProvider(props: PropsWithChildren) {
const useNewLayout = useContext(UseNewLayoutContext);
const [value, setValue] = useState(defaultValue);

return (
Expand All @@ -34,8 +32,10 @@ export function BackButtonScaleContextProvider(props: PropsWithChildren) {
setValue(value);
},
saveToJSON(json) {
if (useNewLayout.value && !this.isDefault) {
if (!this.isDefault) {
json.Layout ??= {};
json.Layout.useNewLayout = true;

json.Layout.BackButton ??= {};
json.Layout.BackButton.scale = value;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { PropsWithChildren, createContext, useContext, useState } from "react";
import { UseNewLayoutContext } from "../UseNewLayoutContext";
import { PropsWithChildren, createContext, useState } from "react";
import { createResettable } from "../../../utils/ResettableFactory";

const defaultValue = true;
Expand All @@ -11,7 +10,6 @@ export const BackButtonScaleWhenHoldContext = createContext(
export function BackButtonScaleWhenHoldContextProvider(
props: PropsWithChildren
) {
const useNewLayout = useContext(UseNewLayoutContext);
const [value, setValue] = useState(defaultValue);

return (
Expand All @@ -29,8 +27,10 @@ export function BackButtonScaleWhenHoldContextProvider(
setValue(value);
},
saveToJSON(json) {
if (useNewLayout.value && !this.isDefault) {
if (!this.isDefault) {
json.Layout ??= {};
json.Layout.useNewLayout = true;

json.Layout.BackButton ??= {};
json.Layout.BackButton.scaleWhenHold = value;
}
Expand Down
8 changes: 4 additions & 4 deletions src/hooks/Layout/BackButton/BackButtonWidthContext.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { PropsWithChildren, createContext, useContext, useState } from "react";
import { UseNewLayoutContext } from "../UseNewLayoutContext";
import { PropsWithChildren, createContext, useState } from "react";
import { createNumberResettable } from "../../../utils/ResettableFactory";

const defaultValue = -1;
Expand All @@ -10,7 +9,6 @@ export const BackButtonWidthContext = createContext(
);

export function BackButtonWidthContextProvider(props: PropsWithChildren) {
const useNewLayout = useContext(UseNewLayoutContext);
const [value, setValue] = useState(defaultValue);

return (
Expand All @@ -34,8 +32,10 @@ export function BackButtonWidthContextProvider(props: PropsWithChildren) {
setValue(value);
},
saveToJSON(json) {
if (useNewLayout.value && !this.isDefault) {
if (!this.isDefault) {
json.Layout ??= {};
json.Layout.useNewLayout = true;

json.Layout.BackButton ??= {};
json.Layout.BackButton.w = value;
}
Expand Down
8 changes: 4 additions & 4 deletions src/hooks/Layout/BackButton/BackButtonXContext.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { PropsWithChildren, createContext, useContext, useState } from "react";
import { UseNewLayoutContext } from "../UseNewLayoutContext";
import { PropsWithChildren, createContext, useState } from "react";
import { createNumberResettable } from "../../../utils/ResettableFactory";

const defaultValue = 0;
Expand All @@ -10,7 +9,6 @@ export const BackButtonXContext = createContext(
);

export function BackButtonXContextProvider(props: PropsWithChildren) {
const useNewLayout = useContext(UseNewLayoutContext);
const [value, setValue] = useState(defaultValue);

return (
Expand All @@ -29,8 +27,10 @@ export function BackButtonXContextProvider(props: PropsWithChildren) {
setValue(Math.max(value, minValue));
},
saveToJSON(json) {
if (useNewLayout.value && !this.isDefault) {
if (!this.isDefault) {
json.Layout ??= {};
json.Layout.useNewLayout = true;

json.Layout.BackButton ??= {};
json.Layout.BackButton.x = value;
}
Expand Down
Loading

0 comments on commit b3bc820

Please sign in to comment.