From b3bc82001278ee985c0c3ab433b30b57a2581190 Mon Sep 17 00:00:00 2001 From: Rian8337 <52914632+Rian8337@users.noreply.github.com> Date: Fri, 8 Sep 2023 10:33:24 +0700 Subject: [PATCH] Remove useless "use new layout" context --- src/components/groups/Group.css | 1 + src/components/groups/main/LoadJsonGroup.tsx | 7 - src/components/groups/main/ResetJsonGroup.tsx | 7 - src/components/groups/main/SaveJsonGroup.tsx | 7 - .../groups/skin/Layout/LayoutGroup.tsx | 122 ++++++++---------- src/hooks/ContextProviders.tsx | 4 - .../BackButton/BackButtonHeightContext.tsx | 8 +- .../BackButton/BackButtonScaleContext.tsx | 8 +- .../BackButtonScaleWhenHoldContext.tsx | 8 +- .../BackButton/BackButtonWidthContext.tsx | 8 +- .../Layout/BackButton/BackButtonXContext.tsx | 8 +- .../Layout/BackButton/BackButtonYContext.tsx | 8 +- .../ModsButton/ModsButtonHeightContext.tsx | 8 +- .../ModsButton/ModsButtonScaleContext.tsx | 8 +- .../ModsButton/ModsButtonWidthContext.tsx | 8 +- .../Layout/ModsButton/ModsButtonXContext.tsx | 8 +- .../Layout/ModsButton/ModsButtonYContext.tsx | 8 +- .../OptionsButtonHeightContext.tsx | 8 +- .../OptionsButtonScaleContext.tsx | 19 ++- .../OptionsButtonWidthContext.tsx | 8 +- .../OptionsButton/OptionsButtonXContext.tsx | 8 +- .../OptionsButton/OptionsButtonYContext.tsx | 8 +- .../RandomButtonHeightContext.tsx | 8 +- .../RandomButton/RandomButtonScaleContext.tsx | 8 +- .../RandomButton/RandomButtonWidthContext.tsx | 8 +- .../RandomButton/RandomButtonXContext.tsx | 8 +- .../RandomButton/RandomButtonYContext.tsx | 8 +- src/hooks/Layout/UseNewLayoutContext.tsx | 38 ------ 28 files changed, 141 insertions(+), 224 deletions(-) delete mode 100644 src/hooks/Layout/UseNewLayoutContext.tsx diff --git a/src/components/groups/Group.css b/src/components/groups/Group.css index 45af973..13f1a87 100644 --- a/src/components/groups/Group.css +++ b/src/components/groups/Group.css @@ -17,4 +17,5 @@ .group-item .group-description { font-size: 0.9em; + margin-top: 1em; } diff --git a/src/components/groups/main/LoadJsonGroup.tsx b/src/components/groups/main/LoadJsonGroup.tsx index d66a501..e6f9347 100644 --- a/src/components/groups/main/LoadJsonGroup.tsx +++ b/src/components/groups/main/LoadJsonGroup.tsx @@ -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"; @@ -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); @@ -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); diff --git a/src/components/groups/main/ResetJsonGroup.tsx b/src/components/groups/main/ResetJsonGroup.tsx index f9051f3..3e2652e 100644 --- a/src/components/groups/main/ResetJsonGroup.tsx +++ b/src/components/groups/main/ResetJsonGroup.tsx @@ -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"; @@ -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); @@ -160,9 +156,6 @@ export default function ResetJsonGroup() { menuItemSelectedTextColor.reset(); // Layout - // Layout switch - useNewLayout.reset(); - // Back button backButtonWidth.reset(); backButtonHeight.reset(); diff --git a/src/components/groups/main/SaveJsonGroup.tsx b/src/components/groups/main/SaveJsonGroup.tsx index e143638..1ff5579 100644 --- a/src/components/groups/main/SaveJsonGroup.tsx +++ b/src/components/groups/main/SaveJsonGroup.tsx @@ -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"; @@ -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); @@ -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); diff --git a/src/components/groups/skin/Layout/LayoutGroup.tsx b/src/components/groups/skin/Layout/LayoutGroup.tsx index 22dc26a..873d9ef 100644 --- a/src/components/groups/skin/Layout/LayoutGroup.tsx +++ b/src/components/groups/skin/Layout/LayoutGroup.tsx @@ -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 ( -
- - - - {useNewLayout.value ? ( - <> -
-
- There are the same options for each button, namely: -
    -
  • - Width -
    - Specifies the width of the button, in pixels. - Use -1 to use the width of the button's - texture. -
  • -
    -
  • - Height -
    - Specifies the height of the button, in pixels. - Use -1 to use the height of the button's - texture. -
  • -
    -
  • - Scale -
    - Increasing this number increases the size of the - button, and vice versa. -
  • -
    -
  • - Horizontal Offset -
    - The horizontal offset of the button from the - left of the screen, in pixels. -
  • -
    -
  • - Vertical Offset -
    - The vertical offset of the button from the - bottom of the screen, in pixels. -
  • -
-
+
+ There are the same options for each button, namely: +
    +
  • + Width +
    + Specifies the width of the button, in pixels. Use -1 to + use the width of the button's texture. +
  • +
    +
  • + Height +
    + Specifies the height of the button, in pixels. Use -1 to + use the height of the button's texture. +
  • +
    +
  • + Scale +
    + Increasing this number increases the size of the button, + and vice versa. +
  • +
    +
  • + Horizontal Offset +
    + The horizontal offset of the button from the left of the + screen, in pixels. +
  • +
    +
  • + Vertical Offset +
    + The vertical offset of the button from the bottom of the + screen, in pixels. +
  • +
+
- - - + + + - - - + + + - - - + + + - - - - - ) : null} + + +
); } diff --git a/src/hooks/ContextProviders.tsx b/src/hooks/ContextProviders.tsx index 842ded4..4bc89d1 100644 --- a/src/hooks/ContextProviders.tsx +++ b/src/hooks/ContextProviders.tsx @@ -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>[]) => @@ -77,9 +76,6 @@ export const Providers = compose( HitCirclePrefixContextProvider, ScorePrefixContextProvider, - // Layout Switch - UseNewLayoutContextProvider, - // Layout (BackButton) BackButtonHeightContextProvider, BackButtonScaleContextProvider, diff --git a/src/hooks/Layout/BackButton/BackButtonHeightContext.tsx b/src/hooks/Layout/BackButton/BackButtonHeightContext.tsx index 48d100e..ae4b17d 100644 --- a/src/hooks/Layout/BackButton/BackButtonHeightContext.tsx +++ b/src/hooks/Layout/BackButton/BackButtonHeightContext.tsx @@ -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; @@ -10,7 +9,6 @@ export const BackButtonHeightContext = createContext( ); export function BackButtonHeightContextProvider(props: PropsWithChildren) { - const useNewLayout = useContext(UseNewLayoutContext); const [value, setValue] = useState(defaultValue); return ( @@ -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; } diff --git a/src/hooks/Layout/BackButton/BackButtonScaleContext.tsx b/src/hooks/Layout/BackButton/BackButtonScaleContext.tsx index e6064b1..4986fd6 100644 --- a/src/hooks/Layout/BackButton/BackButtonScaleContext.tsx +++ b/src/hooks/Layout/BackButton/BackButtonScaleContext.tsx @@ -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; @@ -10,7 +9,6 @@ export const BackButtonScaleContext = createContext( ); export function BackButtonScaleContextProvider(props: PropsWithChildren) { - const useNewLayout = useContext(UseNewLayoutContext); const [value, setValue] = useState(defaultValue); return ( @@ -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; } diff --git a/src/hooks/Layout/BackButton/BackButtonScaleWhenHoldContext.tsx b/src/hooks/Layout/BackButton/BackButtonScaleWhenHoldContext.tsx index 7b23bc1..4c5b4d3 100644 --- a/src/hooks/Layout/BackButton/BackButtonScaleWhenHoldContext.tsx +++ b/src/hooks/Layout/BackButton/BackButtonScaleWhenHoldContext.tsx @@ -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; @@ -11,7 +10,6 @@ export const BackButtonScaleWhenHoldContext = createContext( export function BackButtonScaleWhenHoldContextProvider( props: PropsWithChildren ) { - const useNewLayout = useContext(UseNewLayoutContext); const [value, setValue] = useState(defaultValue); return ( @@ -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; } diff --git a/src/hooks/Layout/BackButton/BackButtonWidthContext.tsx b/src/hooks/Layout/BackButton/BackButtonWidthContext.tsx index 8fa61ea..7cc346a 100644 --- a/src/hooks/Layout/BackButton/BackButtonWidthContext.tsx +++ b/src/hooks/Layout/BackButton/BackButtonWidthContext.tsx @@ -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; @@ -10,7 +9,6 @@ export const BackButtonWidthContext = createContext( ); export function BackButtonWidthContextProvider(props: PropsWithChildren) { - const useNewLayout = useContext(UseNewLayoutContext); const [value, setValue] = useState(defaultValue); return ( @@ -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; } diff --git a/src/hooks/Layout/BackButton/BackButtonXContext.tsx b/src/hooks/Layout/BackButton/BackButtonXContext.tsx index e1d4a9e..d66535f 100644 --- a/src/hooks/Layout/BackButton/BackButtonXContext.tsx +++ b/src/hooks/Layout/BackButton/BackButtonXContext.tsx @@ -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; @@ -10,7 +9,6 @@ export const BackButtonXContext = createContext( ); export function BackButtonXContextProvider(props: PropsWithChildren) { - const useNewLayout = useContext(UseNewLayoutContext); const [value, setValue] = useState(defaultValue); return ( @@ -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; } diff --git a/src/hooks/Layout/BackButton/BackButtonYContext.tsx b/src/hooks/Layout/BackButton/BackButtonYContext.tsx index d9231ec..a4d8a1b 100644 --- a/src/hooks/Layout/BackButton/BackButtonYContext.tsx +++ b/src/hooks/Layout/BackButton/BackButtonYContext.tsx @@ -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; @@ -10,7 +9,6 @@ export const BackButtonYContext = createContext( ); export function BackButtonYContextProvider(props: PropsWithChildren) { - const useNewLayout = useContext(UseNewLayoutContext); const [value, setValue] = useState(defaultValue); return ( @@ -29,8 +27,10 @@ export function BackButtonYContextProvider(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.y = value; } diff --git a/src/hooks/Layout/ModsButton/ModsButtonHeightContext.tsx b/src/hooks/Layout/ModsButton/ModsButtonHeightContext.tsx index 6d600a5..838da7f 100644 --- a/src/hooks/Layout/ModsButton/ModsButtonHeightContext.tsx +++ b/src/hooks/Layout/ModsButton/ModsButtonHeightContext.tsx @@ -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; @@ -10,7 +9,6 @@ export const ModsButtonHeightContext = createContext( ); export function ModsButtonHeightContextProvider(props: PropsWithChildren) { - const useNewLayout = useContext(UseNewLayoutContext); const [value, setValue] = useState(defaultValue); return ( @@ -34,8 +32,10 @@ export function ModsButtonHeightContextProvider(props: PropsWithChildren) { setValue(value); }, saveToJSON(json) { - if (useNewLayout.value && !this.isDefault) { + if (!this.isDefault) { json.Layout ??= {}; + json.Layout.useNewLayout = true; + json.Layout.ModsButton ??= {}; json.Layout.ModsButton.h = value; } diff --git a/src/hooks/Layout/ModsButton/ModsButtonScaleContext.tsx b/src/hooks/Layout/ModsButton/ModsButtonScaleContext.tsx index 77e2308..a40d3a1 100644 --- a/src/hooks/Layout/ModsButton/ModsButtonScaleContext.tsx +++ b/src/hooks/Layout/ModsButton/ModsButtonScaleContext.tsx @@ -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; @@ -10,7 +9,6 @@ export const ModsButtonScaleContext = createContext( ); export function ModsButtonScaleContextProvider(props: PropsWithChildren) { - const useNewLayout = useContext(UseNewLayoutContext); const [value, setValue] = useState(defaultValue); return ( @@ -34,8 +32,10 @@ export function ModsButtonScaleContextProvider(props: PropsWithChildren) { setValue(value); }, saveToJSON(json) { - if (useNewLayout.value && !this.isDefault) { + if (!this.isDefault) { json.Layout ??= {}; + json.Layout.useNewLayout = true; + json.Layout.ModsButton ??= {}; json.Layout.ModsButton.scale = value; } diff --git a/src/hooks/Layout/ModsButton/ModsButtonWidthContext.tsx b/src/hooks/Layout/ModsButton/ModsButtonWidthContext.tsx index a6d58ae..36e222e 100644 --- a/src/hooks/Layout/ModsButton/ModsButtonWidthContext.tsx +++ b/src/hooks/Layout/ModsButton/ModsButtonWidthContext.tsx @@ -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; @@ -10,7 +9,6 @@ export const ModsButtonWidthContext = createContext( ); export function ModsButtonWidthContextProvider(props: PropsWithChildren) { - const useNewLayout = useContext(UseNewLayoutContext); const [value, setValue] = useState(defaultValue); return ( @@ -34,8 +32,10 @@ export function ModsButtonWidthContextProvider(props: PropsWithChildren) { setValue(value); }, saveToJSON(json) { - if (useNewLayout.value && !this.isDefault) { + if (!this.isDefault) { json.Layout ??= {}; + json.Layout.useNewLayout = true; + json.Layout.ModsButton ??= {}; json.Layout.ModsButton.w = value; } diff --git a/src/hooks/Layout/ModsButton/ModsButtonXContext.tsx b/src/hooks/Layout/ModsButton/ModsButtonXContext.tsx index cc16751..c37a2cb 100644 --- a/src/hooks/Layout/ModsButton/ModsButtonXContext.tsx +++ b/src/hooks/Layout/ModsButton/ModsButtonXContext.tsx @@ -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; @@ -10,7 +9,6 @@ export const ModsButtonXContext = createContext( ); export function ModsButtonXContextProvider(props: PropsWithChildren) { - const useNewLayout = useContext(UseNewLayoutContext); const [value, setValue] = useState(defaultValue); return ( @@ -29,8 +27,10 @@ export function ModsButtonXContextProvider(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.ModsButton ??= {}; json.Layout.ModsButton.x = value; } diff --git a/src/hooks/Layout/ModsButton/ModsButtonYContext.tsx b/src/hooks/Layout/ModsButton/ModsButtonYContext.tsx index 9ff4821..d1eb062 100644 --- a/src/hooks/Layout/ModsButton/ModsButtonYContext.tsx +++ b/src/hooks/Layout/ModsButton/ModsButtonYContext.tsx @@ -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; @@ -10,7 +9,6 @@ export const ModsButtonYContext = createContext( ); export function ModsButtonYContextProvider(props: PropsWithChildren) { - const useNewLayout = useContext(UseNewLayoutContext); const [value, setValue] = useState(defaultValue); return ( @@ -29,8 +27,10 @@ export function ModsButtonYContextProvider(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.ModsButton ??= {}; json.Layout.ModsButton.y = value; } diff --git a/src/hooks/Layout/OptionsButton/OptionsButtonHeightContext.tsx b/src/hooks/Layout/OptionsButton/OptionsButtonHeightContext.tsx index 6ba41d4..50594fb 100644 --- a/src/hooks/Layout/OptionsButton/OptionsButtonHeightContext.tsx +++ b/src/hooks/Layout/OptionsButton/OptionsButtonHeightContext.tsx @@ -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; @@ -10,7 +9,6 @@ export const OptionsButtonHeightContext = createContext( ); export function OptionsButtonHeightContextProvider(props: PropsWithChildren) { - const useNewLayout = useContext(UseNewLayoutContext); const [value, setValue] = useState(defaultValue); return ( @@ -34,8 +32,10 @@ export function OptionsButtonHeightContextProvider(props: PropsWithChildren) { setValue(value); }, saveToJSON(json) { - if (useNewLayout.value && !this.isDefault) { + if (!this.isDefault) { json.Layout ??= {}; + json.Layout.useNewLayout = true; + json.Layout.OptionsButton ??= {}; json.Layout.OptionsButton.h = value; } diff --git a/src/hooks/Layout/OptionsButton/OptionsButtonScaleContext.tsx b/src/hooks/Layout/OptionsButton/OptionsButtonScaleContext.tsx index afd2250..003d35b 100644 --- a/src/hooks/Layout/OptionsButton/OptionsButtonScaleContext.tsx +++ b/src/hooks/Layout/OptionsButton/OptionsButtonScaleContext.tsx @@ -1,18 +1,14 @@ -import { PropsWithChildren, createContext, useContext, useState } from "react"; -import { createResettable } from "../../../utils/ResettableFactory"; -import { NumberResettable } from "../../../structures/resettable/NumberResettable"; -import { UseNewLayoutContext } from "../UseNewLayoutContext"; +import { PropsWithChildren, createContext, useState } from "react"; +import { createNumberResettable } from "../../../utils/ResettableFactory"; const defaultValue = -1; const minValue = -1; -export const OptionsButtonScaleContext = createContext({ - ...createResettable(defaultValue), - minValue, -}); +export const OptionsButtonScaleContext = createContext( + createNumberResettable(defaultValue, minValue) +); export function OptionsButtonScaleContextProvider(props: PropsWithChildren) { - const useNewLayout = useContext(UseNewLayoutContext); const [value, setValue] = useState(defaultValue); return ( @@ -20,6 +16,7 @@ export function OptionsButtonScaleContextProvider(props: PropsWithChildren) { value={{ defaultValue, value, + minValue, get isDefault() { return value === defaultValue; }, @@ -35,8 +32,10 @@ export function OptionsButtonScaleContextProvider(props: PropsWithChildren) { setValue(value); }, saveToJSON(json) { - if (useNewLayout.value && !this.isDefault) { + if (!this.isDefault) { json.Layout ??= {}; + json.Layout.useNewLayout = true; + json.Layout.OptionsButton ??= {}; json.Layout.OptionsButton.scale = value; } diff --git a/src/hooks/Layout/OptionsButton/OptionsButtonWidthContext.tsx b/src/hooks/Layout/OptionsButton/OptionsButtonWidthContext.tsx index d5e4951..b83c045 100644 --- a/src/hooks/Layout/OptionsButton/OptionsButtonWidthContext.tsx +++ b/src/hooks/Layout/OptionsButton/OptionsButtonWidthContext.tsx @@ -1,6 +1,5 @@ -import { PropsWithChildren, createContext, useContext, useState } from "react"; +import { PropsWithChildren, createContext, useState } from "react"; import { createNumberResettable } from "../../../utils/ResettableFactory"; -import { UseNewLayoutContext } from "../UseNewLayoutContext"; const defaultValue = -1; const minValue = -1; @@ -10,7 +9,6 @@ export const OptionsButtonWidthContext = createContext( ); export function OptionsButtonWidthContextProvider(props: PropsWithChildren) { - const useNewLayout = useContext(UseNewLayoutContext); const [value, setValue] = useState(defaultValue); return ( @@ -34,8 +32,10 @@ export function OptionsButtonWidthContextProvider(props: PropsWithChildren) { setValue(value); }, saveToJSON(json) { - if (useNewLayout.value && !this.isDefault) { + if (!this.isDefault) { json.Layout ??= {}; + json.Layout.useNewLayout = true; + json.Layout.OptionsButton ??= {}; json.Layout.OptionsButton.w = value; } diff --git a/src/hooks/Layout/OptionsButton/OptionsButtonXContext.tsx b/src/hooks/Layout/OptionsButton/OptionsButtonXContext.tsx index 1f3d247..0010661 100644 --- a/src/hooks/Layout/OptionsButton/OptionsButtonXContext.tsx +++ b/src/hooks/Layout/OptionsButton/OptionsButtonXContext.tsx @@ -1,6 +1,5 @@ -import { PropsWithChildren, createContext, useContext, useState } from "react"; +import { PropsWithChildren, createContext, useState } from "react"; import { createNumberResettable } from "../../../utils/ResettableFactory"; -import { UseNewLayoutContext } from "../UseNewLayoutContext"; const defaultValue = 0; const minValue = 0; @@ -10,7 +9,6 @@ export const OptionsButtonXContext = createContext( ); export function OptionsButtonXContextProvider(props: PropsWithChildren) { - const useNewLayout = useContext(UseNewLayoutContext); const [value, setValue] = useState(defaultValue); return ( @@ -29,8 +27,10 @@ export function OptionsButtonXContextProvider(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.OptionsButton ??= {}; json.Layout.OptionsButton.x = value; } diff --git a/src/hooks/Layout/OptionsButton/OptionsButtonYContext.tsx b/src/hooks/Layout/OptionsButton/OptionsButtonYContext.tsx index 96d371b..d27a98d 100644 --- a/src/hooks/Layout/OptionsButton/OptionsButtonYContext.tsx +++ b/src/hooks/Layout/OptionsButton/OptionsButtonYContext.tsx @@ -1,6 +1,5 @@ -import { PropsWithChildren, createContext, useContext, useState } from "react"; +import { PropsWithChildren, createContext, useState } from "react"; import { createNumberResettable } from "../../../utils/ResettableFactory"; -import { UseNewLayoutContext } from "../UseNewLayoutContext"; const defaultValue = 0; const minValue = 0; @@ -10,7 +9,6 @@ export const OptionsButtonYContext = createContext( ); export function OptionsButtonYContextProvider(props: PropsWithChildren) { - const useNewLayout = useContext(UseNewLayoutContext); const [value, setValue] = useState(defaultValue); return ( @@ -29,8 +27,10 @@ export function OptionsButtonYContextProvider(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.OptionsButton ??= {}; json.Layout.OptionsButton.h = value; } diff --git a/src/hooks/Layout/RandomButton/RandomButtonHeightContext.tsx b/src/hooks/Layout/RandomButton/RandomButtonHeightContext.tsx index d7628bb..fc76437 100644 --- a/src/hooks/Layout/RandomButton/RandomButtonHeightContext.tsx +++ b/src/hooks/Layout/RandomButton/RandomButtonHeightContext.tsx @@ -1,6 +1,5 @@ -import { PropsWithChildren, createContext, useContext, useState } from "react"; +import { PropsWithChildren, createContext, useState } from "react"; import { createNumberResettable } from "../../../utils/ResettableFactory"; -import { UseNewLayoutContext } from "../UseNewLayoutContext"; const defaultValue = -1; const minValue = -1; @@ -10,7 +9,6 @@ export const RandomButtonHeightContext = createContext( ); export function RandomButtonHeightContextProvider(props: PropsWithChildren) { - const useNewLayout = useContext(UseNewLayoutContext); const [value, setValue] = useState(defaultValue); return ( @@ -34,8 +32,10 @@ export function RandomButtonHeightContextProvider(props: PropsWithChildren) { setValue(value); }, saveToJSON(json) { - if (useNewLayout.value && !this.isDefault) { + if (!this.isDefault) { json.Layout ??= {}; + json.Layout.useNewLayout = true; + json.Layout.RandomButton ??= {}; json.Layout.RandomButton.h = value; } diff --git a/src/hooks/Layout/RandomButton/RandomButtonScaleContext.tsx b/src/hooks/Layout/RandomButton/RandomButtonScaleContext.tsx index 3c5fd3e..e3e827e 100644 --- a/src/hooks/Layout/RandomButton/RandomButtonScaleContext.tsx +++ b/src/hooks/Layout/RandomButton/RandomButtonScaleContext.tsx @@ -1,6 +1,5 @@ -import { PropsWithChildren, createContext, useContext, useState } from "react"; +import { PropsWithChildren, createContext, useState } from "react"; import { createNumberResettable } from "../../../utils/ResettableFactory"; -import { UseNewLayoutContext } from "../UseNewLayoutContext"; const defaultValue = -1; const minValue = -1; @@ -10,7 +9,6 @@ export const RandomButtonScaleContext = createContext( ); export function RandomButtonScaleContextProvider(props: PropsWithChildren) { - const useNewLayout = useContext(UseNewLayoutContext); const [value, setValue] = useState(defaultValue); return ( @@ -34,8 +32,10 @@ export function RandomButtonScaleContextProvider(props: PropsWithChildren) { setValue(value); }, saveToJSON(json) { - if (useNewLayout.value && !this.isDefault) { + if (!this.isDefault) { json.Layout ??= {}; + json.Layout.useNewLayout = true; + json.Layout.RandomButton ??= {}; json.Layout.RandomButton.scale = value; } diff --git a/src/hooks/Layout/RandomButton/RandomButtonWidthContext.tsx b/src/hooks/Layout/RandomButton/RandomButtonWidthContext.tsx index d81f44b..c9edda3 100644 --- a/src/hooks/Layout/RandomButton/RandomButtonWidthContext.tsx +++ b/src/hooks/Layout/RandomButton/RandomButtonWidthContext.tsx @@ -1,6 +1,5 @@ -import { PropsWithChildren, createContext, useContext, useState } from "react"; +import { PropsWithChildren, createContext, useState } from "react"; import { createNumberResettable } from "../../../utils/ResettableFactory"; -import { UseNewLayoutContext } from "../UseNewLayoutContext"; const defaultValue = -1; const minValue = -1; @@ -10,7 +9,6 @@ export const RandomButtonWidthContext = createContext( ); export function RandomButtonWidthContextProvider(props: PropsWithChildren) { - const useNewLayout = useContext(UseNewLayoutContext); const [value, setValue] = useState(defaultValue); return ( @@ -34,8 +32,10 @@ export function RandomButtonWidthContextProvider(props: PropsWithChildren) { setValue(value); }, saveToJSON(json) { - if (useNewLayout.value && !this.isDefault) { + if (!this.isDefault) { json.Layout ??= {}; + json.Layout.useNewLayout = true; + json.Layout.RandomButton ??= {}; json.Layout.RandomButton.w = value; } diff --git a/src/hooks/Layout/RandomButton/RandomButtonXContext.tsx b/src/hooks/Layout/RandomButton/RandomButtonXContext.tsx index 50bb3e3..098e2c5 100644 --- a/src/hooks/Layout/RandomButton/RandomButtonXContext.tsx +++ b/src/hooks/Layout/RandomButton/RandomButtonXContext.tsx @@ -1,6 +1,5 @@ -import { PropsWithChildren, createContext, useContext, useState } from "react"; +import { PropsWithChildren, createContext, useState } from "react"; import { createNumberResettable } from "../../../utils/ResettableFactory"; -import { UseNewLayoutContext } from "../UseNewLayoutContext"; const defaultValue = 0; const minValue = 0; @@ -10,7 +9,6 @@ export const RandomButtonXContext = createContext( ); export function RandomButtonXContextProvider(props: PropsWithChildren) { - const useNewLayout = useContext(UseNewLayoutContext); const [value, setValue] = useState(defaultValue); return ( @@ -29,8 +27,10 @@ export function RandomButtonXContextProvider(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.RandomButton ??= {}; json.Layout.RandomButton.x = value; } diff --git a/src/hooks/Layout/RandomButton/RandomButtonYContext.tsx b/src/hooks/Layout/RandomButton/RandomButtonYContext.tsx index ee4cd42..fccce9c 100644 --- a/src/hooks/Layout/RandomButton/RandomButtonYContext.tsx +++ b/src/hooks/Layout/RandomButton/RandomButtonYContext.tsx @@ -1,6 +1,5 @@ -import { PropsWithChildren, createContext, useContext, useState } from "react"; +import { PropsWithChildren, createContext, useState } from "react"; import { createNumberResettable } from "../../../utils/ResettableFactory"; -import { UseNewLayoutContext } from "../UseNewLayoutContext"; const defaultValue = 0; const minValue = 0; @@ -10,7 +9,6 @@ export const RandomButtonYContext = createContext( ); export function RandomButtonYContextProvider(props: PropsWithChildren) { - const useNewLayout = useContext(UseNewLayoutContext); const [value, setValue] = useState(defaultValue); return ( @@ -29,8 +27,10 @@ export function RandomButtonYContextProvider(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.RandomButton ??= {}; json.Layout.RandomButton.y = value; } diff --git a/src/hooks/Layout/UseNewLayoutContext.tsx b/src/hooks/Layout/UseNewLayoutContext.tsx deleted file mode 100644 index b30f6f6..0000000 --- a/src/hooks/Layout/UseNewLayoutContext.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import { PropsWithChildren, createContext, useState } from "react"; -import { createResettable } from "../../utils/ResettableFactory"; - -const defaultValue = false; - -export const UseNewLayoutContext = createContext( - createResettable(defaultValue) -); - -export function UseNewLayoutContextProvider(props: PropsWithChildren) { - const [value, setValue] = useState(defaultValue); - - return ( - { - setValue(defaultValue); - }, - setValue: (value = defaultValue) => { - setValue(value); - }, - saveToJSON(json) { - if (!this.isDefault) { - json.Layout ??= {}; - json.Layout.useNewLayout = value; - } - }, - }} - > - {props.children} - - ); -}