diff options
Diffstat (limited to 'features/statHistoryGui')
-rw-r--r-- | features/statHistoryGui/index.js | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/features/statHistoryGui/index.js b/features/statHistoryGui/index.js index 5fe8356..4c02b2c 100644 --- a/features/statHistoryGui/index.js +++ b/features/statHistoryGui/index.js @@ -15,6 +15,8 @@ import { fetch } from "../../utils/networkUtils"; import SoopyImageElement from "../../../guimanager/GuiElement/SoopyImageElement"; import renderLibs from "../../../guimanager/renderLibs"; import SoopyBoxElement from "../../../guimanager/GuiElement/SoopyBoxElement"; +import Dropdown from "../../../guimanager/GuiElement/Dropdown"; +import SoopyContentChangeEvent from "../../../guimanager/EventListener/SoopyContentChangeEvent"; class StatHistoryGUI extends Feature { constructor() { @@ -79,7 +81,7 @@ class StatGraphPage extends GuiPage { this.finaliseLoading() } - updateData(player) { + updateData(player, profIn) { this.closeSidebarPage() this.playerLoad = player @@ -102,15 +104,13 @@ class StatGraphPage extends GuiPage { return } this.statArea.clearChildren() - let nameElm = new SoopyTextElement().setText(playerData.data.stats.nameWithPrefix.replace(/§f/g, "§7")).setMaxTextScale(2).setLocation(0.1, 0.05, 0.8, 0.1) + let nameElm = new SoopyTextElement().setText(playerData.data.stats.nameWithPrefix.replace(/§f/g, "§7")).setMaxTextScale(2).setLocation(0.1, 0.05, 0.5, 0.1) this.statArea.addChild(nameElm) this.statArea.addChild(this.loadingElm) fetch("http://soopymc.my.to/api/v2/player_skyblock/" + playerData.data.uuid).json(skyblockData => { - if (player !== this.playerLoad) return - if (!skyblockData.success) { this.statArea.clearChildren() this.statArea.addChild(this.errorElm) @@ -119,8 +119,18 @@ class StatGraphPage extends GuiPage { return } + let selectedProf = profIn || skyblockData.data.stats.bestProfileId + let profOptions = {} + Object.keys(skyblockData.data.profiles).forEach(p => { + profOptions[p] = skyblockData.data.profiles[p].stats.cute_name + }) + + let profileSelect = new Dropdown().setOptions(profOptions).setSelectedOption(selectedProf).setLocation(0.6, 0.05, 0.3, 0.1).addEvent(new SoopyContentChangeEvent().setHandler(newval => { + this.updateData(player, newval) + })) + this.statArea.addChild(profileSelect) - fetch("http://soopymc.my.to/statgraphgenerations/" + playerData.data.uuid + "/" + skyblockData.data.stats.bestProfileId).json(graphData => { + fetch("http://soopymc.my.to/statgraphgenerations/" + playerData.data.uuid + "/" + selectedProf).json(graphData => { if (player !== this.playerLoad) return new Thread(() => { |