package agaricus.mods.highlighttips;

import cpw.mods.fml.client.registry.KeyBindingRegistry;
import cpw.mods.fml.common.TickType;
import net.minecraft.client.settings.KeyBinding;

import java.util.EnumSet;

public class ToggleKeyHandler extends KeyBindingRegistry.KeyHandler {

    enum DetailLevel {
        HIDDEN,
        MINIMAL,
        DETAILED,
    };

    private DetailLevel detailLevel = DetailLevel.MINIMAL;

    public ToggleKeyHandler(int keyCode) {
        super(new KeyBinding[] { new KeyBinding("Highlight Tips", keyCode) }, new boolean[] { false });
    }

    public boolean isVisible() {
        return detailLevel != DetailLevel.HIDDEN;
    }

    public boolean isDetailed() {
        return detailLevel == DetailLevel.DETAILED;
    }

    @Override
    public String getLabel() {
        return "HighlightTips Toggle Key";
    }

    @Override
    public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat) {
        if (!tickEnd) return;

        switch (detailLevel) {
            case HIDDEN:
                detailLevel = DetailLevel.MINIMAL;
                break;
            default:
            case MINIMAL:
                detailLevel = DetailLevel.DETAILED;
                break;
            case DETAILED:
                detailLevel = DetailLevel.HIDDEN;
                break;
        }
    }

    @Override
    public void keyUp(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd) {

    }

    @Override
    public EnumSet<TickType> ticks() {
        return EnumSet.of(TickType.CLIENT);
    }
}

@@ -172,16 +172,49 @@
 Binding;
+%0Aimport org.lwjgl.input.Keyboard;
 %0A%0Aimport
@@ -313,86 +313,40 @@
     
-enum DetailLevel %7B%0A        HIDDEN,%0A        MINIMAL,%0A        DETAILED,%0A    %7D
+private boolean visible = true
 ;%0A
-%0A
     
@@ -357,53 +357,32 @@
 ate 
-DetailLevel detailLevel = DetailLevel.MINIMAL
+boolean detailed = false
 ;%0A%0A 
@@ -586,41 +586,15 @@
 urn 
-detailLevel != DetailLevel.HIDDEN
+visible
 ;%0A  
@@ -657,37 +657,10 @@
 tail
-Level == DetailLevel.DETAILED
+ed
 ;%0A  
@@ -917,60 +917,130 @@
     
-switch (detailLevel) %7B%0A            case HIDDEN:%0A    
+// shift: toggle detail%0A        if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) %7C%7C Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) %7B%0A
     
@@ -1057,35 +1057,22 @@
 tail
-Level = D
+ed = !d
 etail
-Level.MINIMAL
+ed
 ;%0A  
@@ -1085,147 +1085,330 @@
     
-    break;%0A            default:%0A            case MINIMAL:%0A                detailLevel = DetailLevel.DETAILED;%0A                break
+return;%0A        %7D%0A%0A        // ctrl or menu: toggle visibility%0A        if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) %7C%7C Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) %7C%7C%0A                Keyboard.isKeyDown(Keyboard.KEY_LMENU) %7C%7C Keyboard.isKeyDown(Keyboard.KEY_RMENU)) %7B%0A            visible = !visible;%0A            return
 ;%0A      
     
@@ -1407,100 +1407,257 @@
     
+  %7D%0A%0A
       
-case DETAILED:%0A                detailLevel = DetailLevel.HIDDEN;%0A                break
+  // normal: cycle through hidden/minimal/detailed%0A        if (!visible) %7B%0A            visible = true;%0A            detailed = false;%0A        %7D else if (!detailed) %7B%0A            detailed = true;%0A        %7D else %7B%0A            visible = false
 ;%0A  

Add visibility and detail toggle shortcuts