/*
* Copyright (C) 2023 NotEnoughUpdates contributors
*
* This file is part of NotEnoughUpdates.
*
* NotEnoughUpdates is free software: you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* NotEnoughUpdates is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with NotEnoughUpdates. If not, see .
*/
package io.github.moulberry.notenoughupdates.miscgui.pricegraph
import io.github.moulberry.notenoughupdates.NotEnoughUpdates
import io.github.moulberry.notenoughupdates.core.util.StringUtils
import io.github.moulberry.notenoughupdates.util.SpecialColour
import io.github.moulberry.notenoughupdates.util.Utils
import io.github.moulberry.notenoughupdates.util.roundToDecimals
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.GuiScreen
import net.minecraft.client.renderer.GlStateManager
import net.minecraft.item.ItemStack
import net.minecraft.util.EnumChatFormatting
import net.minecraft.util.ResourceLocation
import org.lwjgl.opengl.GL11
import java.text.DecimalFormat
import java.text.SimpleDateFormat
import java.time.Duration
import java.time.Instant
import java.util.*
import java.util.concurrent.CompletableFuture
import kotlin.math.abs
private const val X_SIZE = 364
private const val Y_SIZE = 215
private val dateFormat = SimpleDateFormat("'§b'd MMMMM yyyy '§eat§b' HH:mm")
private val config = NotEnoughUpdates.INSTANCE.config
class GuiPriceGraph(itemId: String) : GuiScreen() {
private val TEXTURE: ResourceLocation = when (config.ahGraph.graphStyle) {
1 -> ResourceLocation("notenoughupdates:price_graph_gui/price_information_gui_dark.png")
2 -> ResourceLocation("notenoughupdates:price_graph_gui/price_information_gui_phqdark.png")
3 -> ResourceLocation("notenoughupdates:price_graph_gui/price_information_gui_fsr.png")
else -> ResourceLocation("notenoughupdates:price_graph_gui/price_information_gui.png")
}
private val dataProvider: GraphDataProvider = when (config.ahGraph.dataSource) {
0 -> ServerGraphDataProvider
else -> LocalGraphDataProvider
}
private val rawData: CompletableFuture