use of com.almuradev.almura.core.client.config.ClientCategory in project Almura by AlmuraDev.
the class SimpleOptionsMenu method construct.
@SuppressWarnings({ "unchecked" })
@Override
public void construct() {
final ClientCategory config = StaticAccess.config.get().client;
this.saveAndLoad();
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.buttonHudType = new UIButtonBuilder(this).text("HUD: " + config.hud.substring(0, 1).toUpperCase() + config.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 = config.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 = config.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 = config.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 = config.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 = config.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 = config.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);
// Reset for new column
this.lastComponent = null;
/*
* RIGHT COLUMN
*/
final boolean isOrigin = config.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(config.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 == config.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 == config.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 == config.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 == config.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 == config.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 == config.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.buttonHudType, this.sliderOriginHudOpacity, checkboxWorldCompassWidget, checkboxLocationWidget, checkboxNumericHUDValues, checkboxDisplayNames, checkboxDisplayHealthbars, checkboxDisableOffhandTorchPlacement, sliderChestDistance, sliderSignTextDistance, sliderItemFrameDistance, sliderPlayerNameRenderDistance, sliderEnemyNameRenderDistance, sliderAnimalNameRenderDistance, buttonDone);
addToScreen(optionsContainer);
}
use of com.almuradev.almura.core.client.config.ClientCategory in project Almura by AlmuraDev.
the class FirstLaunchOptimization method configLoad.
@SubscribeEvent
public void configLoad(final ConfigLoadEvent<ClientConfiguration> event) {
final ClientCategory category = event.config().client;
if (category.firstLaunch) {
category.firstLaunch = false;
this.optimizeGame();
event.adapter().save();
}
}
use of com.almuradev.almura.core.client.config.ClientCategory in project Almura by AlmuraDev.
the class OriginHUD method drawScreen.
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
final ClientCategory category = this.config.get().client;
this.userPanel.setAlpha(category.originHudOpacity);
this.detailsPanel.setVisible(this.config.get().client.displayLocationWidget);
this.detailsPanel.setAlpha(category.originHudOpacity);
this.worldPanel.setVisible(this.config.get().client.displayWorldCompassWidget);
if (manager.getCurrent() == null) {
this.notificationPanel.setAlpha(Math.max(this.notificationPanel.getAlpha() - 2, 0));
this.worldPanel.setAlpha(Math.min(this.worldPanel.getAlpha() + 2, category.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 = SimpleScreen.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, SimpleScreen.getPaddedY(this.userPanel, PADDING));
this.debugBlockPanel.setAlpha(category.originHudOpacity);
// Debug details panel
this.debugDetailsPanel.setPosition(0, yOffset);
this.debugDetailsPanel.setAlpha(category.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(category.originHudOpacity);
}
// Show player list if necessary
this.playerListPanel.setVisible(this.client.gameSettings.keyBindPlayerList.isKeyDown());
super.drawScreen(mouseX, mouseY, partialTicks);
}
Aggregations