70 lines
2.1 KiB
Kotlin
70 lines
2.1 KiB
Kotlin
package codes.som.hibiscus.features.overlay
|
|
|
|
import codes.som.hibiscus.HibiscusMod
|
|
import codes.som.hibiscus.api.feature.Feature
|
|
import codes.som.hibiscus.api.feature.FeatureCategory
|
|
import codes.som.hibiscus.events.PostRenderAllEvent
|
|
import imgui.ImGui
|
|
import imgui.flag.ImGuiCol
|
|
import imgui.flag.ImGuiStyleVar
|
|
import imgui.flag.ImGuiWindowFlags
|
|
|
|
class Overlay : Feature("Overlay", FeatureCategory.OVERLAY) {
|
|
init {
|
|
val enabledFeatures by values.bool("Enabled Features", true)
|
|
|
|
on { _: PostRenderAllEvent ->
|
|
val viewport = ImGui.getMainViewport()
|
|
ImGui.setNextWindowPos(viewport.posX, viewport.posY)
|
|
ImGui.setNextWindowSize(viewport.sizeX, viewport.sizeY)
|
|
|
|
ImGui.pushStyleColor(ImGuiCol.WindowBg, 0, 0, 0, 0)
|
|
ImGui.begin(
|
|
"Overlay##Overlay",
|
|
ImGuiWindowFlags.NoMove + ImGuiWindowFlags.NoInputs + ImGuiWindowFlags.NoDecoration
|
|
)
|
|
|
|
if (enabledFeatures)
|
|
drawEnabledFeatures()
|
|
|
|
ImGui.end()
|
|
ImGui.popStyleColor()
|
|
}
|
|
|
|
enabled = true
|
|
}
|
|
|
|
private fun drawEnabledFeatures() {
|
|
val enabledFeatures =
|
|
HibiscusMod.features.getAllFeatures()
|
|
.filter { it.category != FeatureCategory.OVERLAY }
|
|
.filter { it.enabled }.toList()
|
|
|
|
if (enabledFeatures.isEmpty())
|
|
return
|
|
|
|
val padX = 8f
|
|
val padY = 8f
|
|
|
|
val pos = ImGui.getCursorScreenPos()
|
|
ImGui.setCursorScreenPos(pos.x + padX, pos.y + padY)
|
|
|
|
ImGui.beginGroup()
|
|
|
|
ImGui.pushStyleColor(ImGuiCol.Text, 244, 161, 255, 255)
|
|
for (feature in enabledFeatures)
|
|
ImGui.text(feature.name)
|
|
ImGui.popStyleColor()
|
|
|
|
ImGui.endGroup()
|
|
val min = ImGui.getItemRectMin()
|
|
val max = ImGui.getItemRectMax()
|
|
ImGui.getBackgroundDrawList().addRectFilled(
|
|
min.x - padX, min.y - padY, max.x + padX,
|
|
max.y + padY,
|
|
0xAA0A0A0AL.toInt(),
|
|
0F
|
|
)
|
|
}
|
|
}
|