fabric-imgui-example-mod icon indicating copy to clipboard operation
fabric-imgui-example-mod copied to clipboard

How can i open my imgui menu without any opened minecraft menu?

Open TurboKoT1 opened this issue 1 year ago • 2 comments

How can i open my imgui menu without any opened minecraft menu?

TurboKoT1 avatar May 08 '24 14:05 TurboKoT1

I don't really know whether your goal is to only remove the background appearing when opening screens ingame (which would be done by removing the super.render in the render method or if you want custom viewports so you can drag out the imgui window outside of MC, for that there is a tutorial on imguis github repository.

FlorianMichael avatar May 08 '24 14:05 FlorianMichael

I don't really know whether your goal is to only remove the background appearing when opening screens ingame (which would be done by removing the super.render in the render method or if you want custom viewports so you can drag out the imgui window outside of MC, for that there is a tutorial on imguis github repository.

No, you misunderstood me. I want to open Imgui menu directly in the game on the server. I am newbie, and don't know how can i do it

TurboKoT1 avatar May 08 '24 14:05 TurboKoT1

I am not sure if it's possible to open ImGui without having a minecraft screen as backend, at least not if you want proper mouse interactions.

FlorianMichael avatar Jun 19 '24 23:06 FlorianMichael

I am not sure if this is what you are getting at by minecraft "menu", but you can mixin to the InGameHud class, and draw your ImGui window(s) there.

How can i open my imgui menu without any opened minecraft menu?

MrBreakNFix avatar Jun 19 '24 23:06 MrBreakNFix

@Mixin(InGameHud.class)
public class Window {

    @Inject(method = "render", at = @At("RETURN"))
    private void render(DrawContext context, float tickDelta, CallbackInfo ci) {

        ImGuiImpl.draw(io -> {
            if(ImGui.begin("Hello World", ImGuiWindowFlags.MenuBar)) {

                ImGui.setWindowSize(200, 200);

                if (ImGui.beginMenuBar())
                {
                    if (ImGui.beginMenu("File"))
                    {
                        if (ImGui.menuItem("Open..", "Ctrl+O")) { /* Do stuff */ }
                        if (ImGui.menuItem("Save", "Ctrl+S"))   { /* Do stuff */ }
                        if (ImGui.menuItem("Close", "Ctrl+W"))  {  }
                        ImGui.endMenu();
                    }
                    ImGui.endMenuBar();
                }

                ImString ms = new ImString("wqe");
                float f = 0;
                ImGui.text("Hello, world %d");
                if (ImGui.button("Save")) {
                }

                ImGui.inputText("string", ms);
                ImGui.end();
            }
        });
    }
}

Withors avatar Jul 18 '24 14:07 Withors

This should work, although I don't see why you would want that since you can't interact with it in game.

FlorianMichael avatar Jul 18 '24 19:07 FlorianMichael

you can have it display stuff, like I have the gizmo display a view of the world in my hud, you can interact with it in screens like chat aswell when mixed into the ingame hud

MrBreakNFix avatar Jul 19 '24 00:07 MrBreakNFix

How does the Gizmo of the world looks like? I'm curious

FlorianMichael avatar Jul 19 '24 00:07 FlorianMichael

You can post it into https://github.com/FlorianMichael/fabric-imgui-example-mod/issues/5

FlorianMichael avatar Jul 19 '24 00:07 FlorianMichael