Skip to content
This repository has been archived by the owner on Dec 24, 2023. It is now read-only.

Commit

Permalink
rebrand from qalcyo to w-overflow
Browse files Browse the repository at this point in the history
update updater
rewrite hud gui
  • Loading branch information
Wyvest committed Jan 14, 2022
1 parent feaa0c7 commit 9ef0a2f
Show file tree
Hide file tree
Showing 16 changed files with 257 additions and 420 deletions.
14 changes: 5 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
plugins {
id "java"
id "com.github.johnrengelman.shadow" version "6.1.0"
id "net.minecraftforge.gradle.forge" version "86b2392"
id "net.minecraftforge.gradle.forge" version "ddb1eb0"
id "org.jetbrains.kotlin.jvm" version "1.5.30"
}

version = "3.0.0"
group = "xyz.queffe"
version = "3.1.0"
group = "net.wyvest"
archivesBaseName = "TimerHUD"

sourceCompatibility = targetCompatibility = 1.8
Expand All @@ -31,15 +31,11 @@ repositories {
maven { url 'https://repo.sk1er.club/repository/maven-releases/' }
maven { url 'https://jitpack.io/' }
maven { url 'https://repo.spongepowered.org/repository/maven-public/' }
maven {
url 'http://maven.matthewtgm.xyz/repository/maven-public/'
allowInsecureProtocol = true
}
}

dependencies {
include ('gg.essential:loader-launchwrapper:1.1.0')
provided 'gg.essential:essential-1.8.9-forge:1328'
include ('gg.essential:loader-launchwrapper:1.1.3')
compileOnly 'gg.essential:essential-1.8.9-forge:1788'
}

jar {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
package xyz.qalcyo.timerhud
package net.wyvest.timerhud

import gg.essential.universal.ChatColor
import net.minecraft.client.Minecraft
import net.minecraft.client.settings.KeyBinding
import net.minecraft.util.ChatComponentText
import net.minecraft.util.EnumChatFormatting
import net.minecraftforge.common.MinecraftForge.EVENT_BUS
import net.minecraftforge.fml.client.registry.ClientRegistry
import net.minecraftforge.fml.common.Mod
import net.minecraftforge.fml.common.event.FMLInitializationEvent
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent
import xyz.qalcyo.timerhud.commands.TimerHUDCommand
import xyz.qalcyo.timerhud.config.TimerConfig
import xyz.qalcyo.timerhud.listener.Listener
import xyz.qalcyo.timerhud.utils.Updater
import net.wyvest.timerhud.commands.TimerHUDCommand
import net.wyvest.timerhud.config.TimerConfig
import net.wyvest.timerhud.listener.Listener
import net.wyvest.timerhud.updater.Updater
import org.lwjgl.input.Keyboard
import java.io.File

Expand All @@ -25,21 +22,13 @@ import java.io.File
)
object TimerHUD {
const val NAME = "TimerHUD"
const val VERSION = "3.0.0"
const val VERSION = "3.1.0"
const val ID = "timerhud"
val mc: Minecraft
get() = Minecraft.getMinecraft()

fun sendMessage(message: String) {
if (mc.thePlayer == null)
return
val text =
ChatComponentText(EnumChatFormatting.DARK_PURPLE.toString() + "[$NAME] " + ChatColor.RESET.toString() + " " + message)
Minecraft.getMinecraft().thePlayer.addChatMessage(text)
}

lateinit var jarFile: File
val modDir = File(File(File(mc.mcDataDir, "config"), "Qalcyo"), NAME)
val modDir = File(File(mc.mcDataDir, "W-OVERFLOW"), NAME)
var timerKeybind: KeyBinding = KeyBinding("Toggle Timer", Keyboard.KEY_NONE, "TimerHUD")

@Mod.EventHandler
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package xyz.qalcyo.timerhud
package net.wyvest.timerhud

import gg.essential.api.utils.Multithreading
import xyz.qalcyo.timerhud.TimerHUD.mc
import net.wyvest.timerhud.TimerHUD.mc
import java.awt.event.ActionListener
import javax.swing.Timer

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package xyz.qalcyo.timerhud.commands
package net.wyvest.timerhud.commands

import gg.essential.api.EssentialAPI
import gg.essential.api.commands.Command
import gg.essential.api.commands.DefaultHandler
import gg.essential.api.commands.SubCommand
import xyz.qalcyo.timerhud.TimerHUD
import xyz.qalcyo.timerhud.config.TimerConfig
import xyz.qalcyo.timerhud.gui.HUDGui
import net.wyvest.timerhud.TimerHUD
import net.wyvest.timerhud.config.TimerConfig
import net.wyvest.timerhud.gui.HUDGui

@Suppress("unused")
object TimerHUDCommand : Command(TimerHUD.ID, true) {
Expand All @@ -23,11 +23,11 @@ object TimerHUDCommand : Command(TimerHUD.ID, true) {

@SubCommand("gui", description = "Open the HUD editor for TimerHUD")
fun gui() {
EssentialAPI.getGuiUtil().openScreen(HUDGui(null))
EssentialAPI.getGuiUtil().openScreen(HUDGui())
}

@SubCommand("hud", description = "Open the HUD editor for TimerHUD")
fun hud() {
EssentialAPI.getGuiUtil().openScreen(HUDGui(null))
EssentialAPI.getGuiUtil().openScreen(HUDGui())
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package xyz.qalcyo.timerhud.config
package net.wyvest.timerhud.config

import gg.essential.api.EssentialAPI
import gg.essential.vigilance.Vigilant
import gg.essential.vigilance.data.Category
import gg.essential.vigilance.data.Property
import gg.essential.vigilance.data.PropertyType
import gg.essential.vigilance.data.SortingBehavior
import xyz.qalcyo.timerhud.TimerHUD
import xyz.qalcyo.timerhud.TimerHUD.NAME
import xyz.qalcyo.timerhud.TimerHUD.mc
import xyz.qalcyo.timerhud.gui.DownloadConfirmGui
import xyz.qalcyo.timerhud.gui.HUDGui
import xyz.qalcyo.timerhud.utils.Updater
import net.wyvest.timerhud.TimerHUD
import net.wyvest.timerhud.TimerHUD.NAME
import net.wyvest.timerhud.gui.HUDGui
import net.wyvest.timerhud.updater.DownloadGui
import net.wyvest.timerhud.updater.Updater
import java.awt.Color
import java.io.File

Expand Down Expand Up @@ -40,7 +39,7 @@ object TimerConfig : Vigilant(File(TimerHUD.modDir, "${TimerHUD.ID}.toml"), NAME
category = "Render"
)
fun openHUD() {
EssentialAPI.getGuiUtil().openScreen(HUDGui(gui()))
EssentialAPI.getGuiUtil().openScreen(HUDGui())
}

@Property(
Expand Down Expand Up @@ -153,7 +152,7 @@ object TimerConfig : Vigilant(File(TimerHUD.modDir, "${TimerHUD.ID}.toml"), NAME
)
fun update() {
if (Updater.shouldUpdate) EssentialAPI.getGuiUtil()
.openScreen(DownloadConfirmGui(mc.currentScreen)) else EssentialAPI.getNotifications()
.openScreen(DownloadGui()) else EssentialAPI.getNotifications()
.push(NAME, "No update had been detected at startup, and thus the update GUI has not been shown.")
}

Expand Down
58 changes: 58 additions & 0 deletions src/main/kotlin/net/wyvest/timerhud/gui/HUDGui.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package net.wyvest.timerhud.gui

import gg.essential.elementa.ElementaVersion
import gg.essential.elementa.WindowScreen
import gg.essential.universal.UMatrixStack
import net.minecraft.client.gui.GuiButton
import net.minecraft.client.renderer.GlStateManager
import org.lwjgl.input.Keyboard
import org.lwjgl.opengl.GL11
import net.wyvest.timerhud.config.TimerConfig
import net.wyvest.timerhud.hud.HUD

class HUDGui : WindowScreen(version = ElementaVersion.V1, restoreCurrentGuiOnClose = true, enableRepeatKeys = true, drawDefaultBackground = false) {

override fun initScreen(width: Int, height: Int) {
super.initScreen(width, height)
buttonList.add(GuiButton(0, width / 2 - 50, height - 20, 100, 20, "Close"))
window.onMouseDrag { mouseX, mouseY, mouseButton ->
if (mouseButton == 0) {
TimerConfig.x = mouseX.toInt()
TimerConfig.y = mouseY.toInt()
}
}.onKeyType { _, keyCode ->
when (keyCode) {
Keyboard.KEY_UP -> TimerConfig.y -= 5
Keyboard.KEY_DOWN -> TimerConfig.y += 5
Keyboard.KEY_LEFT -> TimerConfig.x -= 5
Keyboard.KEY_RIGHT -> TimerConfig.x += 5
}
}
}

override fun actionPerformed(button: GuiButton) {
when (button.id) {
0 -> restorePreviousScreen()
}
}

override fun onDrawScreen(matrixStack: UMatrixStack, mouseX: Int, mouseY: Int, partialTicks: Float) {
super.onDrawScreen(matrixStack, mouseX, mouseY, partialTicks)
GlStateManager.pushMatrix()
GlStateManager.enableBlend()
GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0)
HUD.render()
GlStateManager.disableBlend()
GlStateManager.popMatrix()
}

override fun doesGuiPauseGame(): Boolean {
return false
}

override fun onScreenClose() {
super.onScreenClose()
TimerConfig.markDirty()
TimerConfig.writeData()
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package xyz.qalcyo.timerhud.hud
package net.wyvest.timerhud.hud

import net.minecraft.client.gui.Gui
import xyz.qalcyo.timerhud.TimerHUD.mc
import xyz.qalcyo.timerhud.TimerTask
import xyz.qalcyo.timerhud.config.TimerConfig
import xyz.qalcyo.timerhud.utils.drawString
import net.wyvest.timerhud.TimerHUD.mc
import net.wyvest.timerhud.TimerTask
import net.wyvest.timerhud.config.TimerConfig
import net.wyvest.timerhud.utils.drawString
import kotlin.math.max

object HUD {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package xyz.qalcyo.timerhud.listener
package net.wyvest.timerhud.listener

import net.minecraft.client.gui.GuiChat
import net.minecraftforge.client.event.RenderGameOverlayEvent
import net.minecraftforge.event.world.WorldEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.InputEvent
import xyz.qalcyo.timerhud.TimerHUD.mc
import xyz.qalcyo.timerhud.TimerHUD.timerKeybind
import xyz.qalcyo.timerhud.TimerTask
import xyz.qalcyo.timerhud.config.TimerConfig
import xyz.qalcyo.timerhud.gui.HUDGui
import xyz.qalcyo.timerhud.hud.HUD
import net.wyvest.timerhud.TimerHUD.mc
import net.wyvest.timerhud.TimerHUD.timerKeybind
import net.wyvest.timerhud.TimerTask
import net.wyvest.timerhud.config.TimerConfig
import net.wyvest.timerhud.gui.HUDGui
import net.wyvest.timerhud.hud.HUD
import org.lwjgl.input.Keyboard
import org.lwjgl.input.Mouse

Expand Down
54 changes: 54 additions & 0 deletions src/main/kotlin/net/wyvest/timerhud/updater/DownloadGui.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package net.wyvest.timerhud.updater

import gg.essential.api.EssentialAPI
import gg.essential.api.gui.buildConfirmationModal
import gg.essential.api.utils.Multithreading
import gg.essential.elementa.ElementaVersion
import gg.essential.elementa.WindowScreen
import gg.essential.elementa.dsl.childOf
import net.wyvest.timerhud.TimerHUD
import java.io.File

class DownloadGui : WindowScreen(version = ElementaVersion.V1, true, true, true, -1) {
override fun initScreen(width: Int, height: Int) {
super.initScreen(width, height)
EssentialAPI.getEssentialComponentFactory().buildConfirmationModal {
this.text = "Are you sure you want to update?"
this.secondaryText =
"(This will update from v${TimerHUD.VERSION} to ${Updater.latestTag})"
this.onConfirm = {
restorePreviousScreen()
Multithreading.runAsync {
if (Updater.download(
Updater.updateUrl,
File(
"mods/${TimerHUD.NAME}-${
Updater.latestTag!!.substringAfter("v")
}.jar"
)
) && Updater.download(
"https://github.com/Wyvest/Deleter/releases/download/v1.2/Deleter-1.2.jar",
File(TimerHUD.modDir.parentFile, "Deleter-1.2.jar")
)
) {
EssentialAPI.getNotifications()
.push(
TimerHUD.NAME,
"The ingame updater has successfully installed the newest version."
)
Updater.addShutdownHook()
Updater.shouldUpdate = false
} else {
EssentialAPI.getNotifications().push(
TimerHUD.NAME,
"The ingame updater has NOT installed the newest version as something went wrong."
)
}
}
}
this.onDeny = {
restorePreviousScreen()
}
} childOf this.window
}
}
Loading

0 comments on commit 9ef0a2f

Please sign in to comment.