-
-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backend: No longer use neu gui elements in config (#2725)
- Loading branch information
Showing
4 changed files
with
70 additions
and
8 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
src/main/java/at/hannibal2/skyhanni/config/core/elements/GuiElement.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,19 @@ | ||
package at.hannibal2.skyhanni.config.core.elements | ||
|
||
import net.minecraft.client.gui.Gui | ||
|
||
abstract class GuiElement : Gui() { | ||
abstract fun render(x: Int, y: Int) | ||
|
||
abstract val width: Int | ||
|
||
abstract val height: Int | ||
|
||
open fun mouseClicked(mouseX: Int, mouseY: Int, mouseButton: Int) {} | ||
|
||
fun mouseClickMove(mouseX: Int, mouseY: Int, clickedMouseButton: Int, timeSinceLastClick: Long) {} | ||
|
||
fun otherComponentClick() {} | ||
|
||
fun keyTyped(typedChar: Char, keyCode: Int) {} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/at/hannibal2/skyhanni/config/core/elements/GuiElementButton.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,22 @@ | ||
package at.hannibal2.skyhanni.config.core.elements | ||
|
||
import java.awt.Color | ||
|
||
class GuiElementButton(text: String, colour: Int, private val callback: Runnable) : GuiElementText(text, colour) { | ||
|
||
override val height: Int | ||
get() = super.height + 5 | ||
|
||
override val width: Int | ||
get() = super.width + 10 | ||
|
||
override fun mouseClicked(mouseX: Int, mouseY: Int, mouseButton: Int) { | ||
callback.run() | ||
} | ||
|
||
override fun render(x: Int, y: Int) { | ||
drawRect(x, y, x + width, y + super.height, Color.WHITE.rgb) | ||
drawRect(x + 1, y + 1, x + width - 1, y + super.height - 1, Color.BLACK.rgb) | ||
super.render(x + 5, y - 1) | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/at/hannibal2/skyhanni/config/core/elements/GuiElementText.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,21 @@ | ||
package at.hannibal2.skyhanni.config.core.elements | ||
|
||
import net.minecraft.client.Minecraft | ||
|
||
open class GuiElementText(var text: String, private val colour: Int) : GuiElement() { | ||
|
||
override val height: Int | ||
get() = 18 | ||
|
||
override val width: Int | ||
get() { | ||
val fr = Minecraft.getMinecraft().fontRendererObj | ||
return fr.getStringWidth(text) | ||
} | ||
|
||
override fun render(x: Int, y: Int) { | ||
val fr = Minecraft.getMinecraft().fontRendererObj | ||
|
||
fr.drawString(text, x, y + 6, colour) | ||
} | ||
} |
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