Skip to content

Commit

Permalink
Add "done" button to cape menus (Fixes #56)
Browse files Browse the repository at this point in the history
  • Loading branch information
CaelTheColher committed Jun 13, 2022
1 parent 29e9fd9 commit 941bbf6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
11 changes: 6 additions & 5 deletions src/main/kotlin/me/cael/capes/menu/OtherMenu.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package me.cael.capes.menu

import me.cael.capes.CapeType
import me.cael.capes.Capes
import net.fabricmc.loader.api.FabricLoader
import net.minecraft.client.gui.screen.ConfirmChatLinkScreen
import net.minecraft.client.gui.screen.Screen
import net.minecraft.screen.ScreenTexts
import net.minecraft.client.gui.widget.ButtonWidget
import net.minecraft.client.option.GameOptions
import net.minecraft.screen.ScreenTexts
import net.minecraft.text.Text
import net.minecraft.util.Util
import java.math.BigInteger
Expand All @@ -20,7 +17,7 @@ class OtherMenu(parent: Screen, gameOptions: GameOptions) : MainMenu(parent, gam

val buttonW = 200

addDrawableChild(ButtonWidget((width/2) - (buttonW / 2), 60, buttonW, 20, Text.translatable("options.capes.optifineeditor")) { buttonWidget: ButtonWidget ->
addDrawableChild(ButtonWidget((width/2) - (buttonW / 2), height / 7 + 24, buttonW, 20, Text.translatable("options.capes.optifineeditor")) { buttonWidget: ButtonWidget ->
try {
val random1Bi = BigInteger(128, Random())
val random2Bi = BigInteger(128, Random(System.identityHashCode(Object()).toLong()))
Expand All @@ -37,6 +34,10 @@ class OtherMenu(parent: Screen, gameOptions: GameOptions) : MainMenu(parent, gam
exception.printStackTrace()
}
})

addDrawableChild(ButtonWidget((width/2) - (buttonW / 2), height / 7 + 2 * 24, buttonW, 20, ScreenTexts.DONE) { buttonWidget: ButtonWidget ->
client!!.setScreen(parent)
})
}

}
6 changes: 4 additions & 2 deletions src/main/kotlin/me/cael/capes/menu/SelectorMenu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ package me.cael.capes.menu

import com.mojang.blaze3d.systems.RenderSystem
import me.cael.capes.Capes
import me.cael.capes.handler.PlayerHandler
import me.cael.capes.mixins.AccessorPlayerEntityModel
import me.cael.capes.mixins.AccessorPlayerListEntry
import me.cael.capes.utils.FakePlayer
import net.fabricmc.loader.api.FabricLoader
import net.minecraft.client.MinecraftClient
import net.minecraft.client.gui.screen.Screen
import net.minecraft.client.gui.widget.ButtonWidget
Expand Down Expand Up @@ -43,6 +41,10 @@ class SelectorMenu(parent: Screen, gameOptions: GameOptions) : MainMenu(parent,
}
})

addDrawableChild(ButtonWidget((width/2) - (buttonW / 2), 220, buttonW, 20, ScreenTexts.DONE) { buttonWidget: ButtonWidget ->
client!!.setScreen(parent)
})

buttonW = 100

addDrawableChild(ButtonWidget((width/4) - (buttonW / 2), 120, buttonW, 20, Text.translatable("options.capes.selector.elytra")) { buttonWidget: ButtonWidget ->
Expand Down
18 changes: 11 additions & 7 deletions src/main/kotlin/me/cael/capes/menu/ToggleMenu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,48 +16,52 @@ class ToggleMenu(parent: Screen, gameOptions: GameOptions) : MainMenu(parent, ga

val config = Capes.CONFIG

addDrawableChild(ButtonWidget(width / 2 - 155, height / 6 + 24, 150, 20, CapeType.OPTIFINE.getToggleText(config.enableOptifine)) { buttonWidget: ButtonWidget ->
addDrawableChild(ButtonWidget(width / 2 - 155, height / 7 + 24, 150, 20, CapeType.OPTIFINE.getToggleText(config.enableOptifine)) { buttonWidget: ButtonWidget ->
config.enableOptifine = !config.enableOptifine
config.save()
buttonWidget.message = CapeType.OPTIFINE.getToggleText(config.enableOptifine)
})

addDrawableChild(ButtonWidget(width / 2 - 155 + 160, height / 6 + 24, 150, 20, CapeType.LABYMOD.getToggleText(config.enableLabyMod)) { buttonWidget: ButtonWidget ->
addDrawableChild(ButtonWidget(width / 2 - 155 + 160, height / 7 + 24, 150, 20, CapeType.LABYMOD.getToggleText(config.enableLabyMod)) { buttonWidget: ButtonWidget ->
config.enableLabyMod = !config.enableLabyMod
config.save()
buttonWidget.message = CapeType.LABYMOD.getToggleText(config.enableLabyMod)
})

addDrawableChild(ButtonWidget(width / 2 - 155, height / 6 + 2 * 24, 150, 20, CapeType.MINECRAFTCAPES.getToggleText(config.enableMinecraftCapesMod)) { buttonWidget: ButtonWidget ->
addDrawableChild(ButtonWidget(width / 2 - 155, height / 7 + 2 * 24, 150, 20, CapeType.MINECRAFTCAPES.getToggleText(config.enableMinecraftCapesMod)) { buttonWidget: ButtonWidget ->
config.enableMinecraftCapesMod = !config.enableMinecraftCapesMod
config.save()
buttonWidget.message = CapeType.MINECRAFTCAPES.getToggleText(config.enableMinecraftCapesMod)
})

addDrawableChild(ButtonWidget(width / 2 - 155 + 160, height / 6 + 2 * 24, 150, 20, CapeType.WYNNTILS.getToggleText(config.enableWynntils)) { buttonWidget: ButtonWidget ->
addDrawableChild(ButtonWidget(width / 2 - 155 + 160, height / 7 + 2 * 24, 150, 20, CapeType.WYNNTILS.getToggleText(config.enableWynntils)) { buttonWidget: ButtonWidget ->
config.enableWynntils = !config.enableWynntils
config.save()
buttonWidget.message = CapeType.WYNNTILS.getToggleText(config.enableWynntils)
})

addDrawableChild(ButtonWidget(width / 2 - 155, height / 6 + 3 * 24, 150, 20, CapeType.COSMETICA.getToggleText(config.enableCosmetica)) { buttonWidget: ButtonWidget ->
addDrawableChild(ButtonWidget(width / 2 - 155, height / 7 + 3 * 24, 150, 20, CapeType.COSMETICA.getToggleText(config.enableCosmetica)) { buttonWidget: ButtonWidget ->
config.enableCosmetica = !config.enableCosmetica
config.save()
buttonWidget.message = CapeType.COSMETICA.getToggleText(config.enableCosmetica)
})

addDrawableChild(ButtonWidget(width / 2 - 155 + 160, height / 6 + 3 * 24, 150, 20, CapeType.CLOAKSPLUS.getToggleText(config.enableCloaksPlus)) { buttonWidget: ButtonWidget ->
addDrawableChild(ButtonWidget(width / 2 - 155 + 160, height / 7 + 3 * 24, 150, 20, CapeType.CLOAKSPLUS.getToggleText(config.enableCloaksPlus)) { buttonWidget: ButtonWidget ->
config.enableCloaksPlus = !config.enableCloaksPlus
config.save()
buttonWidget.message = CapeType.CLOAKSPLUS.getToggleText(config.enableCloaksPlus)
})

addDrawableChild(ButtonWidget((width/2) - (200 / 2), height / 6 + 4 * 24, 200, 20, elytraMessage(config.enableElytraTexture)) { buttonWidget: ButtonWidget ->
addDrawableChild(ButtonWidget((width/2) - (200 / 2), height / 7 + 4 * 24, 200, 20, elytraMessage(config.enableElytraTexture)) { buttonWidget: ButtonWidget ->
config.enableElytraTexture = !config.enableElytraTexture
config.save()
buttonWidget.message = elytraMessage(config.enableElytraTexture)
}).active = !FabricLoader.getInstance().getModContainer("capetweaks").isPresent

addDrawableChild(ButtonWidget((width/2) - (200 / 2), height / 7 + 5 * 24, 200, 20, ScreenTexts.DONE) { buttonWidget: ButtonWidget ->
client!!.setScreen(parent)
})

}

private fun elytraMessage(enabled: Boolean) = ScreenTexts.composeToggleText(Text.translatable("options.capes.elytra"), enabled)
Expand Down

0 comments on commit 941bbf6

Please sign in to comment.