Search in sources :

Example 1 with GeneralCategory

use of com.almuradev.almura.core.client.config.category.GeneralCategory in project Almura by AlmuraDev.

the class MainMenuManager method onGuiOpen.

@SubscribeEvent
public void onGuiOpen(final GuiOpenEvent event) {
    final GuiScreen screen = event.getGui();
    final GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen;
    final GameSettings settings = Minecraft.getMinecraft().gameSettings;
    boolean refreshResources = false;
    if (screen != null) {
        if (currentScreen != null && debug) {
            System.out.println("MainMenuManager: current: " + currentScreen.getClass().getSimpleName() + " requested: " + screen.getClass().getSimpleName());
        }
        if (screen.getClass().equals(GuiMainMenu.class)) {
            event.setCanceled(true);
            final GeneralCategory general = configAdapter.get().general;
            if (general.firstLaunch) {
                AlmuraSettings.checkFirstLaunched();
            } else {
                new PanoramicMainMenu(null).display();
            }
        } else if (screen.getClass().equals(GuiIngameMenu.class)) {
            event.setCanceled(true);
            new SimpleIngameMenu().display();
        } else if (screen.getClass().equals(GuiGameOver.class)) {
            event.setCanceled(true);
        // Cancel this, packet sent to client opens the DeathGUI
        } else if (screen.getClass().equals(GuiDisconnected.class)) {
            event.setCanceled(true);
            String message = "";
            if (Almura.networkManager != null && Almura.networkManager.getExitMessage() != null) {
                message = Almura.networkManager.getExitMessage().getFormattedText();
            }
            new DisconnectedGui(message).display();
        }
    }
}
Also used : SimpleIngameMenu(com.almuradev.almura.feature.menu.game.SimpleIngameMenu) GeneralCategory(com.almuradev.almura.core.client.config.category.GeneralCategory) GuiIngameMenu(net.minecraft.client.gui.GuiIngameMenu) GuiScreen(net.minecraft.client.gui.GuiScreen) GameSettings(net.minecraft.client.settings.GameSettings) GuiDisconnected(net.minecraft.client.gui.GuiDisconnected) DisconnectedGui(com.almuradev.almura.feature.menu.main.DisconnectedGui) PanoramicMainMenu(com.almuradev.almura.feature.menu.main.PanoramicMainMenu) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with GeneralCategory

use of com.almuradev.almura.core.client.config.category.GeneralCategory in project Almura by AlmuraDev.

the class SimpleOptionsMenu method construct.

@SuppressWarnings({ "unchecked" })
@Override
public void construct() {
    this.saveAndLoad();
    final GeneralCategory general = configAdapter.get().general;
    final UILabel titleLabel = new UILabel(this, I18n.format("almura.menu_button.options"));
    titleLabel.setFontOptions(FontColors.WHITE_FO);
    titleLabel.setPosition(0, 20, Anchor.TOP | Anchor.CENTER);
    this.addToScreen(titleLabel);
    final UIBackgroundContainer optionsContainer = new UIBackgroundContainer(this, 335, 200);
    optionsContainer.setBackgroundAlpha(0);
    optionsContainer.setPosition(0, getPaddedY(titleLabel, CONTROL_PADDING), Anchor.TOP | Anchor.CENTER);
    /*
         * LEFT COLUMN
         */
    this.buttonOptimized = new UIButtonBuilder(this).text("Load Optimized Defaults").size(CONTROL_WIDTH, CONTROL_HEIGHT).listener(this).build("button.optimized");
    this.updatePosition(this.buttonOptimized, Anchor.LEFT);
    this.buttonHudType = new UIButtonBuilder(this).text("HUD: " + general.hud.substring(0, 1).toUpperCase() + general.hud.substring(1)).size(CONTROL_WIDTH, CONTROL_HEIGHT).listener(this).build("button.hudType");
    this.updatePosition(this.buttonHudType, Anchor.LEFT);
    // TODO: Add builder for checkbox component
    final boolean displayWorldCompassWidget = general.displayWorldCompassWidget;
    final UICheckBox checkboxWorldCompassWidget = new UICheckBox(this);
    checkboxWorldCompassWidget.setText(TextFormatting.WHITE + "Display World Compass Widget");
    checkboxWorldCompassWidget.setChecked(displayWorldCompassWidget);
    checkboxWorldCompassWidget.setName("checkbox.world_compass_widget");
    checkboxWorldCompassWidget.register(this);
    this.updatePosition(checkboxWorldCompassWidget, Anchor.LEFT);
    final boolean displayLocationWidget = general.displayLocationWidget;
    final UICheckBox checkboxLocationWidget = new UICheckBox(this);
    checkboxLocationWidget.setText(TextFormatting.WHITE + "Display Location Widget");
    checkboxLocationWidget.setChecked(displayLocationWidget);
    checkboxLocationWidget.setName("checkbox.location_widget");
    checkboxLocationWidget.register(this);
    this.updatePosition(checkboxLocationWidget, Anchor.LEFT);
    final boolean displayNumericHUDValues = general.displayNumericHUDValues;
    final UICheckBox checkboxNumericHUDValues = new UICheckBox(this);
    checkboxNumericHUDValues.setText(TextFormatting.WHITE + "Display Numeric HUD Values");
    checkboxNumericHUDValues.setChecked(displayNumericHUDValues);
    checkboxNumericHUDValues.setName("checkbox.numeric_hud_values");
    checkboxNumericHUDValues.register(this);
    this.updatePosition(checkboxNumericHUDValues, Anchor.LEFT);
    final boolean displayNames = general.displayNames;
    final UICheckBox checkboxDisplayNames = new UICheckBox(this);
    checkboxDisplayNames.setText(TextFormatting.WHITE + "Display Entity Names");
    checkboxDisplayNames.setChecked(displayNames);
    checkboxDisplayNames.setName("checkbox.display_names");
    checkboxDisplayNames.register(this);
    this.updatePosition(checkboxDisplayNames, Anchor.LEFT);
    final boolean displayHealthbars = general.displayHealthbars;
    final UICheckBox checkboxDisplayHealthbars = new UICheckBox(this);
    checkboxDisplayHealthbars.setText(TextFormatting.WHITE + "Display Entity Healthbars");
    checkboxDisplayHealthbars.setChecked(displayHealthbars);
    checkboxDisplayHealthbars.setName("checkbox.display_healthbars");
    checkboxDisplayHealthbars.register(this);
    this.updatePosition(checkboxDisplayHealthbars, Anchor.LEFT);
    final boolean disableOffhandTorchPlacement = general.disableOffhandTorchPlacement;
    final UICheckBox checkboxDisableOffhandTorchPlacement = new UICheckBox(this);
    checkboxDisableOffhandTorchPlacement.setText(TextFormatting.WHITE + "Disable Offhand Torch Placement");
    checkboxDisableOffhandTorchPlacement.setChecked(disableOffhandTorchPlacement);
    checkboxDisableOffhandTorchPlacement.setName("checkbox.disable_offhand_torch_placement");
    checkboxDisableOffhandTorchPlacement.register(this);
    this.updatePosition(checkboxDisableOffhandTorchPlacement, Anchor.LEFT);
    final boolean displayGuideOnLogin = general.displayGuideOnLogin;
    final UICheckBox checkboxDisplayGuideOnLogin = new UICheckBox(this);
    checkboxDisplayGuideOnLogin.setText(TextFormatting.WHITE + "Display Guide upon Login");
    checkboxDisplayGuideOnLogin.setChecked(displayGuideOnLogin);
    checkboxDisplayGuideOnLogin.setName("checkbox.display_guide_on_login");
    checkboxDisplayGuideOnLogin.register(this);
    this.updatePosition(checkboxDisplayGuideOnLogin, Anchor.LEFT);
    // Reset for new column
    this.lastComponent = null;
    /*
         * RIGHT COLUMN
         */
    final boolean isOrigin = general.hud.equalsIgnoreCase(HUDType.ORIGIN);
    this.sliderOriginHudOpacity = new UISliderBuilder(this, Converter.<Float, Integer>from(f -> (int) (f * 255), i -> (float) i / 255)).text("HUD Opacity: %d").value(general.originHudOpacity).size(CONTROL_WIDTH, CONTROL_HEIGHT).listener(this).enabled(isOrigin).build("slider.originHudOpacity");
    this.sliderOriginHudOpacity.setAlpha(isOrigin ? 255 : 128);
    this.updatePosition(this.sliderOriginHudOpacity, Anchor.RIGHT);
    final UISlider<OptionsConverter.Options> sliderChestDistance = new UISliderBuilder(this, OPTIONS_CONVERTER).text("Chest Distance: %s").value(Arrays.stream(OptionsConverter.Options.values()).filter(o -> o.value == general.chestRenderDistance).findFirst().orElse(OptionsConverter.Options.DEFAULT)).size(CONTROL_WIDTH, CONTROL_HEIGHT).listener(this).build("slider.chestRenderDistance");
    this.updatePosition(sliderChestDistance, Anchor.RIGHT);
    final UISlider<OptionsConverter.Options> sliderSignTextDistance = new UISliderBuilder(this, OPTIONS_CONVERTER).text("Sign Text Distance: %s").value(Arrays.stream(OptionsConverter.Options.values()).filter(o -> o.value == general.signTextRenderDistance).findFirst().orElse(OptionsConverter.Options.DEFAULT)).size(CONTROL_WIDTH, CONTROL_HEIGHT).listener(this).build("slider.signTextRenderDistance");
    this.updatePosition(sliderSignTextDistance, Anchor.RIGHT);
    final UISlider<OptionsConverter.Options> sliderItemFrameDistance = new UISliderBuilder(this, OPTIONS_CONVERTER).text("Item Frame Distance: %s").value(Arrays.stream(OptionsConverter.Options.values()).filter(o -> o.value == general.itemFrameRenderDistance).findFirst().orElse(OptionsConverter.Options.DEFAULT)).size(CONTROL_WIDTH, CONTROL_HEIGHT).listener(this).build("slider.itemFrameRenderDistance");
    this.updatePosition(sliderItemFrameDistance, Anchor.RIGHT);
    final UISlider<OptionsConverter.Options> sliderPlayerNameRenderDistance = new UISliderBuilder(this, OPTIONS_CONVERTER).text("Player Name Distance: %s").value(Arrays.stream(OptionsConverter.Options.values()).filter(o -> o.value == general.playerNameRenderDistance).findFirst().orElse(OptionsConverter.Options.DEFAULT)).size(CONTROL_WIDTH, CONTROL_HEIGHT).listener(this).build("slider.playerNameRenderDistance");
    this.updatePosition(sliderPlayerNameRenderDistance, Anchor.RIGHT);
    final UISlider<OptionsConverter.Options> sliderEnemyNameRenderDistance = new UISliderBuilder(this, OPTIONS_CONVERTER).text("Enemy Name Distance: %s").value(Arrays.stream(OptionsConverter.Options.values()).filter(o -> o.value == general.enemyNameRenderDistance).findFirst().orElse(OptionsConverter.Options.DEFAULT)).size(CONTROL_WIDTH, CONTROL_HEIGHT).listener(this).build("slider.enemyNameRenderDistance");
    this.updatePosition(sliderEnemyNameRenderDistance, Anchor.RIGHT);
    final UISlider<OptionsConverter.Options> sliderAnimalNameRenderDistance = new UISliderBuilder(this, OPTIONS_CONVERTER).text("Animal Name Distance: %s").value(Arrays.stream(OptionsConverter.Options.values()).filter(o -> o.value == general.animalNameRenderDistance).findFirst().orElse(OptionsConverter.Options.DEFAULT)).size(CONTROL_WIDTH, CONTROL_HEIGHT).listener(this).build("slider.animalNameRenderDistance");
    this.updatePosition(sliderAnimalNameRenderDistance, Anchor.RIGHT);
    final UIButton buttonDone = new UIButtonBuilder(this).text(I18n.format("gui.done")).size(200, CONTROL_HEIGHT).position(0, this.lastComponent == null ? 10 : getPaddedY(this.lastComponent, 10)).anchor(Anchor.TOP | Anchor.CENTER).listener(this).build("button.done");
    optionsContainer.add(this.buttonOptimized, this.buttonHudType, this.sliderOriginHudOpacity, checkboxWorldCompassWidget, checkboxLocationWidget, checkboxNumericHUDValues, checkboxDisplayNames, checkboxDisplayHealthbars, checkboxDisableOffhandTorchPlacement, checkboxDisplayGuideOnLogin, sliderChestDistance, sliderSignTextDistance, sliderItemFrameDistance, sliderPlayerNameRenderDistance, sliderEnemyNameRenderDistance, sliderAnimalNameRenderDistance, buttonDone);
    addToScreen(optionsContainer);
}
Also used : UILabel(net.malisis.core.client.gui.component.decoration.UILabel) GuiOptions(net.minecraft.client.gui.GuiOptions) GeneralCategory(com.almuradev.almura.core.client.config.category.GeneralCategory) UISliderBuilder(net.malisis.core.client.gui.component.interaction.slider.builder.UISliderBuilder) UIButtonBuilder(net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder) UIButton(net.malisis.core.client.gui.component.interaction.UIButton) UICheckBox(net.malisis.core.client.gui.component.interaction.UICheckBox) UIBackgroundContainer(net.malisis.core.client.gui.component.container.UIBackgroundContainer)

Example 3 with GeneralCategory

use of com.almuradev.almura.core.client.config.category.GeneralCategory in project Almura by AlmuraDev.

the class OriginHUD method drawScreen.

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    final GeneralCategory general = this.configAdapter.get().general;
    this.userPanel.setAlpha(general.originHudOpacity);
    this.detailsPanel.setVisible(general.displayLocationWidget);
    this.detailsPanel.setAlpha(general.originHudOpacity);
    this.worldPanel.setVisible(general.displayWorldCompassWidget);
    if (manager.getCurrent() == null) {
        this.notificationPanel.setAlpha(Math.max(this.notificationPanel.getAlpha() - 2, 0));
        this.worldPanel.setAlpha(Math.min(this.worldPanel.getAlpha() + 2, general.originHudOpacity));
    } else {
        this.notificationPanel.setAlpha(Math.min(this.notificationPanel.getAlpha() + 5, 255));
        this.worldPanel.setAlpha(Math.max(this.worldPanel.getAlpha() - 20, 0));
        if ((this.notificationPanel.notificationTitle.getWidth()) < (this.notificationPanel.notificationLabel.getWidth())) {
            this.notificationPanel.setSize(this.notificationPanel.notificationLabel.getContentWidth() + 10, this.notificationPanel.getHeight());
        } else {
            this.notificationPanel.setSize(this.notificationPanel.notificationTitle.getContentWidth() + 10, this.notificationPanel.getHeight());
        }
    }
    // Show debug panels if necessary
    final boolean isDebugEnabled = this.client.gameSettings.showDebugInfo;
    this.debugDetailsPanel.setVisible(isDebugEnabled);
    if (isDebugEnabled) {
        // Get proper position based on what potion effects are being shown
        int yOffset = BasicScreen.getPaddedY(this.detailsPanel, PADDING);
        if (this.client.player.getActivePotionEffects().stream().anyMatch(potion -> potion.getPotion().isBeneficial())) {
            // 24 for potion icon, 1 for padding
            yOffset += 25;
        }
        if (this.client.player.getActivePotionEffects().stream().anyMatch(potion -> !potion.getPotion().isBeneficial())) {
            // 24 for potion icon, 1 for padding
            yOffset += 25;
        }
        // Debug block panel
        this.debugBlockPanel.setPosition(0, BasicScreen.getPaddedY(this.userPanel, PADDING));
        this.debugBlockPanel.setAlpha(general.originHudOpacity);
        // Debug details panel
        this.debugDetailsPanel.setPosition(0, yOffset);
        this.debugDetailsPanel.setAlpha(general.originHudOpacity);
    }
    // Show boss panel if necessary
    final GuiIngame guiIngame = this.client.ingameGUI;
    if (guiIngame != null) {
        this.bossBarPanel.setVisible(!((IMixinGuiBossOverlay) guiIngame.getBossOverlay()).getBossInfo().isEmpty());
        this.bossBarPanel.setAlpha(general.originHudOpacity);
    }
    // Show player list if necessary
    this.playerListPanel.setVisible(this.client.gameSettings.keyBindPlayerList.isKeyDown());
    super.drawScreen(mouseX, mouseY, partialTicks);
}
Also used : GuiIngame(net.minecraft.client.gui.GuiIngame) GeneralCategory(com.almuradev.almura.core.client.config.category.GeneralCategory)

Aggregations

GeneralCategory (com.almuradev.almura.core.client.config.category.GeneralCategory)3 SimpleIngameMenu (com.almuradev.almura.feature.menu.game.SimpleIngameMenu)1 DisconnectedGui (com.almuradev.almura.feature.menu.main.DisconnectedGui)1 PanoramicMainMenu (com.almuradev.almura.feature.menu.main.PanoramicMainMenu)1 UIBackgroundContainer (net.malisis.core.client.gui.component.container.UIBackgroundContainer)1 UILabel (net.malisis.core.client.gui.component.decoration.UILabel)1 UIButton (net.malisis.core.client.gui.component.interaction.UIButton)1 UICheckBox (net.malisis.core.client.gui.component.interaction.UICheckBox)1 UIButtonBuilder (net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder)1 UISliderBuilder (net.malisis.core.client.gui.component.interaction.slider.builder.UISliderBuilder)1 GuiDisconnected (net.minecraft.client.gui.GuiDisconnected)1 GuiIngame (net.minecraft.client.gui.GuiIngame)1 GuiIngameMenu (net.minecraft.client.gui.GuiIngameMenu)1 GuiOptions (net.minecraft.client.gui.GuiOptions)1 GuiScreen (net.minecraft.client.gui.GuiScreen)1 GameSettings (net.minecraft.client.settings.GameSettings)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1