From 9dad1d2912452359fdaabaf274f35de53e950f20 Mon Sep 17 00:00:00 2001 From: Senk Ju <18741573+SenkJu@users.noreply.github.com> Date: Fri, 15 Nov 2024 19:00:41 +0100 Subject: [PATCH] add ability to dissable clickgui animations --- src-theme/src/routes/clickgui/ClickGui.svelte | 4 +- src-theme/src/routes/clickgui/Panel.svelte | 7 +- .../src/routes/clickgui/clickgui_store.ts | 4 +- .../clickgui/setting/ChoiceSetting.svelte | 9 ++- .../setting/ConfigurableSetting.svelte | 8 ++- .../clickgui/setting/TogglableSetting.svelte | 64 ++++++++++--------- .../setting/common/GenericSetting.svelte | 5 +- src-theme/src/routes/clickgui/util.ts | 13 ++++ .../module/modules/render/ModuleClickGui.kt | 3 + 9 files changed, 76 insertions(+), 41 deletions(-) create mode 100644 src-theme/src/routes/clickgui/util.ts diff --git a/src-theme/src/routes/clickgui/ClickGui.svelte b/src-theme/src/routes/clickgui/ClickGui.svelte index 70864cf8160..9705aa48f88 100644 --- a/src-theme/src/routes/clickgui/ClickGui.svelte +++ b/src-theme/src/routes/clickgui/ClickGui.svelte @@ -9,12 +9,13 @@ import {fade} from "svelte/transition"; import {listen} from "../../integration/ws"; import type {ClickGuiScaleChangeEvent, ScaleFactorChangeEvent} from "../../integration/events"; - import {scaleFactor} from "./clickgui_store"; + import {animationsEnabled, scaleFactor} from "./clickgui_store"; let categories: GroupedModules = {}; let modules: Module[] = []; let minecraftScaleFactor = 2; let clickGuiScaleFactor = 1; + $: { scaleFactor.set(minecraftScaleFactor * clickGuiScaleFactor); } @@ -28,6 +29,7 @@ const clickGuiSettings = await getModuleSettings("ClickGUI"); clickGuiScaleFactor = clickGuiSettings.value.find(v => v.name === "Scale")?.value as number ?? 1 + $animationsEnabled = clickGuiSettings.value.find(v => v.name === "Animations")?.value as boolean ?? true; }); listen("scaleFactorChange", (e: ScaleFactorChangeEvent) => { diff --git a/src-theme/src/routes/clickgui/Panel.svelte b/src-theme/src/routes/clickgui/Panel.svelte index 7f6213d10a6..04c1d44cd53 100644 --- a/src-theme/src/routes/clickgui/Panel.svelte +++ b/src-theme/src/routes/clickgui/Panel.svelte @@ -6,9 +6,10 @@ import type {ToggleModuleEvent} from "../../integration/events"; import {fly} from "svelte/transition"; import {quintOut} from "svelte/easing"; - import {highlightModuleName, maxPanelZIndex} from "./clickgui_store"; + import {animationsEnabled, highlightModuleName, maxPanelZIndex} from "./clickgui_store"; import {setItem} from "../../integration/persistent_storage"; import {scaleFactor} from "./clickgui_store"; + import {maybe} from "./util"; export let category: string; export let modules: TModule[]; @@ -170,8 +171,8 @@ class="panel" style="left: {panelConfig.left}px; top: {panelConfig.top}px; z-index: {panelConfig.zIndex};" bind:this={panelElement} - in:fly|global={{y: -30, duration: 200, easing: quintOut}} - out:fly|global={{y: -30, duration: 200, easing: quintOut}} + in:maybe|global={{y: -30, duration: 200, easing: quintOut, fn: fly, animate: $animationsEnabled}} + out:maybe|global={{y: -30, duration: 200, easing: quintOut, fn: fly, animate: $animationsEnabled}} >
= writable(0); export const highlightModuleName: Writable = writable(null); -export const scaleFactor: Writable = writable(2); \ No newline at end of file +export const scaleFactor: Writable = writable(2); + +export const animationsEnabled: Writable = writable(true); \ No newline at end of file diff --git a/src-theme/src/routes/clickgui/setting/ChoiceSetting.svelte b/src-theme/src/routes/clickgui/setting/ChoiceSetting.svelte index 217aa63d0ca..ab5cf222d47 100644 --- a/src-theme/src/routes/clickgui/setting/ChoiceSetting.svelte +++ b/src-theme/src/routes/clickgui/setting/ChoiceSetting.svelte @@ -6,6 +6,7 @@ import GenericSetting from "./common/GenericSetting.svelte"; import { setItem } from "../../../integration/persistent_storage"; import {convertToSpacedString, spaceSeperatedNames} from "../../../theme/theme_config"; + import {animationsEnabled} from "../clickgui_store"; export let setting: ModuleSetting; export let path: string; @@ -40,7 +41,7 @@
{#if nestedSettings.length > 0} -
+
skipAnimationDelay = true} />
{:else} -
+
-
+
{$spaceSeperatedNames ? convertToSpacedString(cSetting.name) : cSetting.name}
skipAnimationDelay = true} />
@@ -65,7 +66,10 @@ .head { display: flex; justify-content: space-between; - transition: ease margin-bottom .2s; + + &.animate { + transition: ease margin-bottom .2s; + } &.expanded { margin-bottom: 10px; diff --git a/src-theme/src/routes/clickgui/setting/TogglableSetting.svelte b/src-theme/src/routes/clickgui/setting/TogglableSetting.svelte index cef4fb63ebe..edfde10d27c 100644 --- a/src-theme/src/routes/clickgui/setting/TogglableSetting.svelte +++ b/src-theme/src/routes/clickgui/setting/TogglableSetting.svelte @@ -1,5 +1,5 @@ {#if ready} -
+
{#if setting.valueType === "BOOLEAN"} {:else if setting.valueType === "CHOICE"} diff --git a/src-theme/src/routes/clickgui/util.ts b/src-theme/src/routes/clickgui/util.ts new file mode 100644 index 00000000000..448ab312eea --- /dev/null +++ b/src-theme/src/routes/clickgui/util.ts @@ -0,0 +1,13 @@ +import type {TransitionConfig} from "svelte/transition"; + +interface ExtendedTransitionConfig extends Partial { + fn: Function; + animate: boolean; + [x: string]: unknown; +} + +export function maybe(node: HTMLElement, options: ExtendedTransitionConfig) { + if (options.animate) { + return options.fn(node, options); + } +} \ No newline at end of file diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleClickGui.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleClickGui.kt index 31f3b15c639..9fa82c8520d 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleClickGui.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleClickGui.kt @@ -43,6 +43,9 @@ object ModuleClickGui : @Suppress("UnusedPrivateProperty") private val searchBarAutoFocus by boolean("SearchBarAutoFocus", true) + @Suppress("UnusedPrivateProperty") + private val animations by boolean("Animations", true) + override fun enable() { // Pretty sure we are not in a game, so we can't open the clickgui if (mc.player == null || mc.world == null) {