This repository has been archived by the owner on Feb 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Failing downloads no longer suspend the updater + added a summary screen
- Loading branch information
1 parent
079b605
commit 28b0c48
Showing
3 changed files
with
91 additions
and
20 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
31 changes: 31 additions & 0 deletions
31
src/main/kotlin/mynameisjeff/skyblockclientupdater/gui/UpdateSummaryScreen.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,31 @@ | ||
package mynameisjeff.skyblockclientupdater.gui | ||
|
||
import net.minecraft.client.gui.GuiButton | ||
import net.minecraft.client.gui.GuiScreen | ||
import java.awt.Color | ||
import java.io.File | ||
|
||
class UpdateSummaryScreen(val downloadedMods: ArrayList<File>, val failedDownloadingMods: ArrayList<File>) : GuiScreen() { | ||
|
||
override fun initGui() { | ||
buttonList.add(GuiButton(0, width / 2 - 100, height - 75, 200, 20, "Quit Game")) | ||
} | ||
|
||
override fun drawScreen(mouseX: Int, mouseY: Int, partialTicks: Float) { | ||
drawDefaultBackground() | ||
|
||
drawCenteredString(fontRendererObj, "${downloadedMods.size + failedDownloadingMods.size} updates requested", width / 2, 20, 0xFFFFFF) | ||
drawCenteredString(fontRendererObj, "${downloadedMods.size} updates successful", width / 4, 30, Color.GREEN.rgb) | ||
drawCenteredString(fontRendererObj, "${failedDownloadingMods.size} updates failed", 3 * (width / 4), 30, Color.RED.rgb) | ||
|
||
for (i in 0 until downloadedMods.size) drawCenteredString(fontRendererObj, | ||
downloadedMods[i].name, width / 4, 30 + i.inc() * fontRendererObj.FONT_HEIGHT, Color.GREEN.rgb) | ||
for (i in 0 until failedDownloadingMods.size) drawCenteredString(fontRendererObj, | ||
failedDownloadingMods[i].name, 3 * (width / 4), 30 + i.inc() * fontRendererObj.FONT_HEIGHT, Color.RED.rgb) | ||
super.drawScreen(mouseX, mouseY, partialTicks) | ||
} | ||
|
||
override fun actionPerformed(button: GuiButton) { | ||
mc.shutdown() | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/kotlin/mynameisjeff/skyblockclientupdater/utils/TickTask.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,40 @@ | ||
/* | ||
* Skytils - Hypixel Skyblock Quality of Life Mod | ||
* Copyright (C) 2021 Skytils | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program 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 Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package mynameisjeff.skyblockclientupdater.utils | ||
|
||
import net.minecraftforge.common.MinecraftForge | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent | ||
import net.minecraftforge.fml.common.gameevent.TickEvent | ||
|
||
class TickTask(private var ticks: Int = 0, private val task: () -> Unit) { | ||
|
||
@SubscribeEvent | ||
fun onTick(event: TickEvent.ClientTickEvent) { | ||
if (event.phase != TickEvent.Phase.START) return | ||
if (ticks <= 0) { | ||
task() | ||
MinecraftForge.EVENT_BUS.unregister(this) | ||
} | ||
ticks-- | ||
} | ||
|
||
init { | ||
MinecraftForge.EVENT_BUS.register(this) | ||
} | ||
} |