-
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.
🚚 deleted
screens
package, renamed impl object
- Loading branch information
Showing
3 changed files
with
128 additions
and
149 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
8 changes: 4 additions & 4 deletions
8
...astels/client/screens/imgui/ImGuiPanel.kt → ...i/innerpastels/client/imgui/ImGuiPanel.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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package gay.asoji.innerpastels.client.screens.imgui | ||
|
||
interface ImGuiPanel { | ||
fun render(open_: BooleanArray) | ||
package gay.asoji.innerpastels.client.imgui | ||
|
||
interface ImGuiPanel { | ||
fun render(open_: BooleanArray) | ||
} |
238 changes: 109 additions & 129 deletions
238
...stels/client/screens/imgui/ImGuiScreen.kt → ...els/client/imgui/InnerPastelsImGuiImpl.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 |
---|---|---|
@@ -1,130 +1,110 @@ | ||
package gay.asoji.innerpastels.client.screens.imgui | ||
|
||
import gay.asoji.innerpastels.client.InnerPastelsClient | ||
import gln.cap.Caps | ||
import imgui.ImGui | ||
import imgui.MINECRAFT_BEHAVIORS | ||
import imgui.MouseButton | ||
import imgui.classes.Context | ||
import imgui.impl.gl.ImplGL3 | ||
import imgui.impl.glfw.ImplGlfw | ||
import imgui.impl.glfw.ImplGlfw.Companion.imguiKey | ||
import imgui.internal.DrawData | ||
import net.fabricmc.api.EnvType | ||
import net.fabricmc.api.Environment | ||
import net.minecraft.client.Minecraft | ||
import net.minecraft.client.gui.GuiGraphics | ||
import net.minecraft.client.gui.screens.Screen | ||
import net.minecraft.network.chat.Component | ||
import org.lwjgl.glfw.GLFW | ||
import uno.gl.GlWindow | ||
import uno.glfw.GlfwWindow | ||
import java.util.* | ||
|
||
|
||
@Environment(EnvType.CLIENT) | ||
object ImGuiScreen { | ||
val imgui = ImGui | ||
|
||
var implGl3: ImplGL3 | ||
var implGlfw: ImplGlfw | ||
|
||
// Initialization for imgui. | ||
init { | ||
MINECRAFT_BEHAVIORS = true | ||
|
||
val glfwWindow = GlfwWindow(Minecraft.getInstance().window.window) | ||
val window = GlWindow(glfwWindow, Caps.Profile.CORE, true) | ||
|
||
window.makeCurrent(true) | ||
Context().setCurrent() | ||
|
||
implGlfw = ImplGlfw(window, false, null) | ||
implGl3 = ImplGL3() | ||
} | ||
|
||
fun mouseReleased(mouseX: Double, mouseY: Double, button: Int): Boolean { | ||
if (imgui.io.wantCaptureMouse) { | ||
imgui.io.addMouseButtonEvent(MouseButton.of(button), false) | ||
} | ||
|
||
return imgui.io.wantCaptureMouse | ||
} | ||
|
||
fun mouseScrolled(mouseX: Double, mouseY: Double, scrollX: Double, scrollY: Double): Boolean { | ||
if (imgui.io.wantCaptureMouse) { | ||
imgui.io.mouseWheelH = scrollX.toFloat() | ||
imgui.io.mouseWheel = scrollY.toFloat() | ||
} | ||
|
||
return imgui.io.wantCaptureMouse | ||
} | ||
|
||
fun mouseClicked(mouseX: Double, mouseY: Double, button: Int): Boolean { | ||
if (imgui.io.wantCaptureMouse) { | ||
imgui.io.addMouseButtonEvent(MouseButton.of(button), true) | ||
} | ||
|
||
return imgui.io.wantCaptureMouse | ||
} | ||
|
||
fun keyPressed(keyCode: Int, scanCode: Int, modifiers: Int): Boolean { | ||
if (imgui.io.wantCaptureKeyboard) { | ||
val key = uno.glfw.Key.of(keyCode).imguiKey | ||
|
||
imgui.io.keyCtrl = modifiers and GLFW.GLFW_MOD_CONTROL != 0 | ||
imgui.io.keyShift = modifiers and GLFW.GLFW_MOD_SHIFT != 0 | ||
imgui.io.keyAlt = modifiers and GLFW.GLFW_MOD_ALT != 0 | ||
imgui.io.keySuper = modifiers and GLFW.GLFW_MOD_SUPER != 0 | ||
|
||
imgui.io.addKeyEvent(key, true) | ||
imgui.io.keysData[key.index].down = true | ||
imgui.io.setKeyEventNativeData(key, key.i, scanCode) | ||
} | ||
|
||
return imgui.io.wantCaptureKeyboard | ||
} | ||
|
||
fun keyReleased(keyCode: Int, scanCode: Int, modifiers: Int): Boolean { | ||
if (imgui.io.wantCaptureKeyboard) { | ||
val key = uno.glfw.Key.of(keyCode).imguiKey | ||
|
||
imgui.io.keyCtrl = modifiers and GLFW.GLFW_MOD_CONTROL != 0 | ||
imgui.io.keyShift = modifiers and GLFW.GLFW_MOD_SHIFT != 0 | ||
imgui.io.keyAlt = modifiers and GLFW.GLFW_MOD_ALT != 0 | ||
imgui.io.keySuper = modifiers and GLFW.GLFW_MOD_SUPER != 0 | ||
|
||
imgui.io.addKeyEvent(key, false) | ||
imgui.io.keysData[key.index].down = false | ||
imgui.io.setKeyEventNativeData(key, key.i, scanCode) | ||
} | ||
|
||
return imgui.io.wantCaptureKeyboard | ||
} | ||
|
||
fun charTyped(codePoint: Char, modifiers: Int): Boolean { | ||
if (imgui.io.wantCaptureKeyboard) { | ||
imgui.io.keyCtrl = modifiers and GLFW.GLFW_MOD_CONTROL != 0 | ||
imgui.io.keyShift = modifiers and GLFW.GLFW_MOD_SHIFT != 0 | ||
imgui.io.keyAlt = modifiers and GLFW.GLFW_MOD_ALT != 0 | ||
imgui.io.keySuper = modifiers and GLFW.GLFW_MOD_SUPER != 0 | ||
|
||
imgui.io.addInputCharacter(codePoint) | ||
} | ||
|
||
return imgui.io.wantCaptureKeyboard | ||
} | ||
|
||
fun render(guiGraphics: GuiGraphics, x: Int, y: Int, partialTicks: Float) { | ||
// implGl3.newFrame() | ||
// implGlfw.newFrame() | ||
// imgui.newFrame() | ||
// | ||
// InnerPastelsClient.panels.forEach { | ||
// it.render(booleanArrayOf(true)) | ||
// } | ||
// | ||
// imgui.render() | ||
// implGl3.renderDrawData(Objects.requireNonNull<DrawData>(ImGui.drawData)) | ||
} | ||
package gay.asoji.innerpastels.client.imgui | ||
|
||
import gln.cap.Caps | ||
import imgui.ImGui | ||
import imgui.MINECRAFT_BEHAVIORS | ||
import imgui.MouseButton | ||
import imgui.classes.Context | ||
import imgui.impl.gl.ImplGL3 | ||
import imgui.impl.glfw.ImplGlfw | ||
import imgui.impl.glfw.ImplGlfw.Companion.imguiKey | ||
import net.fabricmc.api.EnvType | ||
import net.fabricmc.api.Environment | ||
import net.minecraft.client.Minecraft | ||
import org.lwjgl.glfw.GLFW | ||
import uno.gl.GlWindow | ||
import uno.glfw.GlfwWindow | ||
|
||
|
||
@Environment(EnvType.CLIENT) | ||
object InnerPastelsImGuiImpl { | ||
val imgui = ImGui | ||
var implGl3: ImplGL3 | ||
var implGlfw: ImplGlfw | ||
|
||
// Initialization for imgui. | ||
init { | ||
MINECRAFT_BEHAVIORS = true | ||
|
||
val glfwWindow = GlfwWindow(Minecraft.getInstance().window.window) | ||
val window = GlWindow(glfwWindow, Caps.Profile.CORE, true) | ||
|
||
window.makeCurrent(true) | ||
Context().setCurrent() | ||
|
||
implGlfw = ImplGlfw(window, false, null) | ||
implGl3 = ImplGL3() | ||
} | ||
|
||
fun mouseReleased(mouseX: Double, mouseY: Double, button: Int): Boolean { | ||
if (imgui.io.wantCaptureMouse) { | ||
imgui.io.addMouseButtonEvent(MouseButton.of(button), false) | ||
} | ||
|
||
return imgui.io.wantCaptureMouse | ||
} | ||
|
||
fun mouseScrolled(mouseX: Double, mouseY: Double, scrollX: Double, scrollY: Double): Boolean { | ||
if (imgui.io.wantCaptureMouse) { | ||
imgui.io.mouseWheelH = scrollX.toFloat() | ||
imgui.io.mouseWheel = scrollY.toFloat() | ||
} | ||
|
||
return imgui.io.wantCaptureMouse | ||
} | ||
|
||
fun mouseClicked(mouseX: Double, mouseY: Double, button: Int): Boolean { | ||
if (imgui.io.wantCaptureMouse) { | ||
imgui.io.addMouseButtonEvent(MouseButton.of(button), true) | ||
} | ||
|
||
return imgui.io.wantCaptureMouse | ||
} | ||
|
||
fun keyPressed(keyCode: Int, scanCode: Int, modifiers: Int): Boolean { | ||
if (imgui.io.wantCaptureKeyboard) { | ||
val key = uno.glfw.Key.of(keyCode).imguiKey | ||
|
||
imgui.io.keyCtrl = modifiers and GLFW.GLFW_MOD_CONTROL != 0 | ||
imgui.io.keyShift = modifiers and GLFW.GLFW_MOD_SHIFT != 0 | ||
imgui.io.keyAlt = modifiers and GLFW.GLFW_MOD_ALT != 0 | ||
imgui.io.keySuper = modifiers and GLFW.GLFW_MOD_SUPER != 0 | ||
|
||
imgui.io.addKeyEvent(key, true) | ||
imgui.io.keysData[key.index].down = true | ||
imgui.io.setKeyEventNativeData(key, key.i, scanCode) | ||
} | ||
|
||
return imgui.io.wantCaptureKeyboard | ||
} | ||
|
||
fun keyReleased(keyCode: Int, scanCode: Int, modifiers: Int): Boolean { | ||
if (imgui.io.wantCaptureKeyboard) { | ||
val key = uno.glfw.Key.of(keyCode).imguiKey | ||
|
||
imgui.io.keyCtrl = modifiers and GLFW.GLFW_MOD_CONTROL != 0 | ||
imgui.io.keyShift = modifiers and GLFW.GLFW_MOD_SHIFT != 0 | ||
imgui.io.keyAlt = modifiers and GLFW.GLFW_MOD_ALT != 0 | ||
imgui.io.keySuper = modifiers and GLFW.GLFW_MOD_SUPER != 0 | ||
|
||
imgui.io.addKeyEvent(key, false) | ||
imgui.io.keysData[key.index].down = false | ||
imgui.io.setKeyEventNativeData(key, key.i, scanCode) | ||
} | ||
|
||
return imgui.io.wantCaptureKeyboard | ||
} | ||
|
||
fun charTyped(codePoint: Char, modifiers: Int): Boolean { | ||
if (imgui.io.wantCaptureKeyboard) { | ||
imgui.io.keyCtrl = modifiers and GLFW.GLFW_MOD_CONTROL != 0 | ||
imgui.io.keyShift = modifiers and GLFW.GLFW_MOD_SHIFT != 0 | ||
imgui.io.keyAlt = modifiers and GLFW.GLFW_MOD_ALT != 0 | ||
imgui.io.keySuper = modifiers and GLFW.GLFW_MOD_SUPER != 0 | ||
|
||
imgui.io.addInputCharacter(codePoint) | ||
} | ||
|
||
return imgui.io.wantCaptureKeyboard | ||
} | ||
} |