Search in sources :

Example 1 with GuiOpenEvent

use of cc.hyperium.event.gui.GuiOpenEvent in project Hyperium by HyperiumClient.

the class HyperiumMinecraft method displayGuiScreen.

public void displayGuiScreen(GuiScreen guiScreenIn, GuiScreen currentScreen, WorldClient theWorld, EntityPlayerSP thePlayer, GameSettings gameSettings, GuiIngame ingameGUI) {
    if (currentScreen != null) {
        currentScreen.onGuiClosed();
    }
    if (guiScreenIn == null && theWorld == null) {
        guiScreenIn = new GuiHyperiumScreenMainMenu();
    } else if (guiScreenIn == null && thePlayer.getHealth() <= 0.0F) {
        guiScreenIn = new GuiGameOver();
    }
    GuiOpenEvent event = new GuiOpenEvent(guiScreenIn);
    EventBus.INSTANCE.post(event);
    if (event.isCancelled())
        return;
    guiScreenIn = event.getGui();
    if (currentScreen != null && guiScreenIn != currentScreen)
        currentScreen.onGuiClosed();
    if (currentScreen != null)
        EventBus.INSTANCE.unregister(currentScreen);
    if (guiScreenIn instanceof GuiHyperiumScreenMainMenu) {
        gameSettings.showDebugInfo = false;
        if (!Settings.PERSISTENT_CHAT) {
            ingameGUI.getChatGUI().clearChatMessages();
        }
    }
    parent.currentScreen = guiScreenIn;
    if (guiScreenIn != null) {
        parent.setIngameNotInFocus();
        ScaledResolution scaledresolution = new ScaledResolution(parent);
        int scaledWidth = scaledresolution.getScaledWidth();
        int scaledHeight = scaledresolution.getScaledHeight();
        guiScreenIn.setWorldAndResolution(parent, scaledWidth, scaledHeight);
        parent.skipRenderWorld = false;
    } else {
        parent.getSoundHandler().resumeSounds();
        parent.setIngameFocus();
    }
    if (Hyperium.INSTANCE.getHandlers() != null) {
        Hyperium.INSTANCE.getHandlers().getKeybindHandler().releaseAllKeybinds();
    }
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) GuiGameOver(net.minecraft.client.gui.GuiGameOver) GuiHyperiumScreenMainMenu(cc.hyperium.gui.GuiHyperiumScreenMainMenu) GuiOpenEvent(cc.hyperium.event.gui.GuiOpenEvent)

Aggregations

GuiOpenEvent (cc.hyperium.event.gui.GuiOpenEvent)1 GuiHyperiumScreenMainMenu (cc.hyperium.gui.GuiHyperiumScreenMainMenu)1 GuiGameOver (net.minecraft.client.gui.GuiGameOver)1 ScaledResolution (net.minecraft.client.gui.ScaledResolution)1