From fda166053d056062839b860041e7eadcd34aa273 Mon Sep 17 00:00:00 2001 From: Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> Date: Wed, 29 Jun 2022 16:39:16 +0800 Subject: + Make custom mana bar animate between values --- features/betterGuis/index.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'features/betterGuis/index.js') diff --git a/features/betterGuis/index.js b/features/betterGuis/index.js index f509674..3c9f264 100644 --- a/features/betterGuis/index.js +++ b/features/betterGuis/index.js @@ -8,6 +8,7 @@ import MuseumGui from "./museumGui.js"; import DungeonReadyGui from "./dungeonReadyGui"; import { SoopyGui } from "../../../guimanager"; import TextBox from "../../../guimanager/GuiElement/TextBox"; +import SoopyNumber from "../../../guimanager/Classes/SoopyNumber"; class BetterGuis extends Feature { constructor() { @@ -138,9 +139,9 @@ class BetterGuis extends Feature { this.invSearchTextBox = new TextBox().setPlaceholder("Click to search").setLocation(0.4, 0.05, 0.2, 0.05) this.invSearchSoopyGui.element.addChild(this.invSearchTextBox) - this.mana = 0 - this.overflowMana = 0 - this.maxMana = 0 + this.mana = new SoopyNumber(0) + this.overflowMana = new SoopyNumber(0) + this.maxMana = new SoopyNumber(0) this.lastOverFlow = Date.now() this.slotMatches = new Map() @@ -165,13 +166,13 @@ class BetterGuis extends Feature { if (curr.includes("Mana")) { curr = curr.split("&b").pop() } - this.mana = parseInt(curr) - this.maxMana = parseInt(max) - if (Date.now() - this.lastOverFlow > 1000) this.overflowMana = 0 + this.mana.set(parseInt(curr), 500) + this.maxMana.set(parseInt(max), 500) + if (Date.now() - this.lastOverFlow > 1000) this.overflowMana.set(0, 500) } actionbarOverflowMana(curr) { - this.overflowMana = parseInt(curr) + this.overflowMana.set(parseInt(curr), 500) this.lastOverFlow = Date.now() } @@ -184,10 +185,10 @@ class BetterGuis extends Feature { Renderer.retainTransforms(true) Renderer.translate(left, top) - let totalAmt = Math.max(this.maxMana, this.mana + this.overflowMana) + let totalAmt = Math.max(this.maxMana.get(), this.mana.get() + this.overflowMana.get()) - let manaPercent = this.mana / totalAmt - let ofPercent = this.overflowMana / totalAmt + let manaPercent = this.mana.get() / totalAmt + let ofPercent = this.overflowMana.get() / totalAmt Renderer.drawRect(Renderer.color(0, 0, 0), 0, 0, 80, 10) Renderer.drawRect(Renderer.color(50, 50, 50), 2, 2, 76, 6) -- cgit