package sig.objects; import java.awt.event.MouseEvent; import java.util.List; import net.java.games.input.Component; import net.java.games.input.Controller; import net.java.games.input.Event; import net.java.games.input.Component.Identifier; import net.java.games.input.Component.POV; import sig.RabiClone; import sig.engine.Action; import sig.engine.Alpha; import sig.engine.Font; import sig.engine.KeyBind; import sig.engine.Object; import sig.engine.PaletteColor; import sig.engine.Panel; public class ConfigureControls extends Object{ Action selectedAction = Action.MOVE_RIGHT; boolean assigningKey = false; public ConfigureControls(Panel panel) { super(panel); RabiClone.BACKGROUND_COLOR = PaletteColor.WHITE; } @Override public void update(double updateMult) { Event e = new Event(); for (int i=0;i clist = KeyBind.KEYBINDS.get(selectedAction); Identifier id = e.getComponent().getIdentifier(); if (id==Identifier.Axis.POV) { if (e.getValue()!=POV.DOWN&& e.getValue()!=POV.RIGHT&& e.getValue()!=POV.LEFT&& e.getValue()!=POV.UP) { continue; //Can't add ordinal directions, only cardinal. } } clist.add(new KeyBind((byte)i,id,e.getValue())); KeyBind.KEYBINDS.put(selectedAction,clist); assigningKey=false; } //System.out.println(e.getComponent().getName()+" value: "+e.getValue()); } } } @Override public void draw(byte[] p) { int y = 4; if (!assigningKey) { for (Action a : Action.values()) { if (RabiClone.MOUSE_POS.getY()>=getY()+y&&RabiClone.MOUSE_POS.getY() clist = KeyBind.KEYBINDS.get(selectedAction); clist.add(new KeyBind(keyCode)); KeyBind.KEYBINDS.put(selectedAction,clist); assigningKey=false; } } }