Add config options to show/hide spell HUD and charge meter

This commit is contained in:
Electroblob77
2020-07-02 17:28:02 +01:00
parent 02ab4a9014
commit b6ccee010b
4 changed files with 39 additions and 0 deletions
@@ -338,6 +338,10 @@ public final class Settings {
public boolean blinkEffect = true;
/** <b>[Client-only]</b> Whether to use spellcasting animations for players. */
public boolean spellcastingAnimations = true;
/** <b>[Client-only]</b> Whether to show the spell HUD when holding a wand. */
public boolean showSpellHUD = true;
/** <b>[Client-only]</b> Whether to show the charge meter when charging up a spell. */
public boolean showChargeMeter = true;
/** <b>[Client-only]</b> The position of the spell HUD. */
public GuiPosition spellHUDPosition = GuiPosition.BOTTOM_LEFT;
@@ -966,6 +970,20 @@ public final class Settings {
reverseScrollDirection = property.getBoolean();
propOrder.add(property.getName());
property = config.get(CLIENT_CATEGORY, "showSpellHUD", false, "Whether to show the spell HUD in the corner of the screen when holding a wand.");
property.setLanguageKey("config." + Wizardry.MODID + ".show_spell_hud");
property.setRequiresWorldRestart(false);
Wizardry.proxy.setToNamedBooleanEntry(property);
showSpellHUD = property.getBoolean();
propOrder.add(property.getName());
property = config.get(CLIENT_CATEGORY, "showChargeMeter", false, "Whether to show the spell charge-up meter around the crosshairs when charging up a spell.");
property.setLanguageKey("config." + Wizardry.MODID + ".show_charge_meter");
property.setRequiresWorldRestart(false);
Wizardry.proxy.setToNamedBooleanEntry(property);
showChargeMeter = property.getBoolean();
propOrder.add(property.getName());
property = config.get(CLIENT_CATEGORY, "spellHUDPosition", GuiPosition.BOTTOM_LEFT.name, "The position of the spell HUD.", GuiPosition.names);
property.setLanguageKey("config." + Wizardry.MODID + ".spell_hud_position");
spellHUDPosition = GuiPosition.fromName(property.getString());
@@ -106,6 +106,8 @@ public class GuiSpellDisplay {
@SubscribeEvent
public static void draw(RenderGameOverlayEvent.Post event){
if(!Wizardry.settings.showSpellHUD && !Wizardry.settings.showChargeMeter) return; // Optimisation
EntityPlayer player = Minecraft.getMinecraft().player;
if(player.isSpectator()) return; // Spectators shouldn't have the spell HUD!
@@ -150,6 +152,7 @@ public class GuiSpellDisplay {
*/
private static void renderChargeMeter(EntityPlayer player, ItemStack wand, int width, int height, float partialTicks){
if(!Wizardry.settings.showChargeMeter) return;
if(Minecraft.getMinecraft().gameSettings.showDebugInfo) return; // Don't show charge meter in the debug screen
if(Minecraft.getMinecraft().gameSettings.thirdPersonView != 0) return; // Don't show in third person
@@ -194,6 +197,8 @@ public class GuiSpellDisplay {
*/
private static void renderSpellHUD(EntityPlayer player, ItemStack wand, boolean mainHand, int width, int height, float partialTicks, boolean textLayer){
if(!Wizardry.settings.showSpellHUD) return;
boolean flipX = Wizardry.settings.spellHUDPosition.flipX;
boolean flipY = Wizardry.settings.spellHUDPosition.flipY;