This repository has been archived by the owner on Dec 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update updater rewrite hud gui
- Loading branch information
Showing
16 changed files
with
257 additions
and
420 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...n/kotlin/xyz/qalcyo/timerhud/TimerTask.kt → ...n/kotlin/net/wyvest/timerhud/TimerTask.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} |
10 changes: 5 additions & 5 deletions
10
...ain/kotlin/xyz/qalcyo/timerhud/hud/HUD.kt → ...ain/kotlin/net/wyvest/timerhud/hud/HUD.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 7 additions & 7 deletions
14
.../xyz/qalcyo/timerhud/listener/Listener.kt → .../net/wyvest/timerhud/listener/Listener.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/main/kotlin/net/wyvest/timerhud/updater/DownloadGui.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
Oops, something went wrong.