|
|
@ -5,7 +5,6 @@ import java.io.DataInputStream; |
|
|
|
import java.io.DataOutputStream; |
|
|
|
import java.io.DataOutputStream; |
|
|
|
import java.io.File; |
|
|
|
import java.io.File; |
|
|
|
import java.io.FileInputStream; |
|
|
|
import java.io.FileInputStream; |
|
|
|
import java.io.FileNotFoundException; |
|
|
|
|
|
|
|
import java.io.FileOutputStream; |
|
|
|
import java.io.FileOutputStream; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
@ -13,7 +12,6 @@ import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
import net.java.games.input.Component; |
|
|
|
import net.java.games.input.Component; |
|
|
|
import net.java.games.input.Controller; |
|
|
|
import net.java.games.input.Controller; |
|
|
|
import net.java.games.input.ControllerEnvironment; |
|
|
|
|
|
|
|
import net.java.games.input.Event; |
|
|
|
import net.java.games.input.Event; |
|
|
|
import net.java.games.input.Component.Identifier; |
|
|
|
import net.java.games.input.Component.Identifier; |
|
|
|
import net.java.games.input.Component.POV; |
|
|
|
import net.java.games.input.Component.POV; |
|
|
@ -46,7 +44,7 @@ public class ConfigureControls extends Object{ |
|
|
|
super(panel); |
|
|
|
super(panel); |
|
|
|
RabiClone.BACKGROUND_COLOR = PaletteColor.WHITE; |
|
|
|
RabiClone.BACKGROUND_COLOR = PaletteColor.WHITE; |
|
|
|
if (GAME_CONTROLS_FILE.exists()) { |
|
|
|
if (GAME_CONTROLS_FILE.exists()) { |
|
|
|
LoadControls(); |
|
|
|
RabiClone.reloadControllerList = true; |
|
|
|
} |
|
|
|
} |
|
|
|
updateHighlightSections(); |
|
|
|
updateHighlightSections(); |
|
|
|
} |
|
|
|
} |
|
|
@ -54,7 +52,6 @@ public class ConfigureControls extends Object{ |
|
|
|
public static void LoadControls() { |
|
|
|
public static void LoadControls() { |
|
|
|
try { |
|
|
|
try { |
|
|
|
DataInputStream stream = new DataInputStream(new FileInputStream(GAME_CONTROLS_FILE)); |
|
|
|
DataInputStream stream = new DataInputStream(new FileInputStream(GAME_CONTROLS_FILE)); |
|
|
|
Controller[] CONTROLLERS = ControllerEnvironment.getDefaultEnvironment().rescanControllers(); |
|
|
|
|
|
|
|
KeyBind.KEYBINDS.clear(); |
|
|
|
KeyBind.KEYBINDS.clear(); |
|
|
|
while (stream.available()>0) { |
|
|
|
while (stream.available()>0) { |
|
|
|
Action a = Action.valueOf(readString(stream)); |
|
|
|
Action a = Action.valueOf(readString(stream)); |
|
|
@ -67,13 +64,13 @@ public class ConfigureControls extends Object{ |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
java.lang.String controllerName = readString(stream); |
|
|
|
java.lang.String controllerName = readString(stream); |
|
|
|
Controller controller=null; |
|
|
|
Controller controller=null; |
|
|
|
for (int i = 0; i < CONTROLLERS.length; i++) { |
|
|
|
for (int i = 0; i < RabiClone.CONTROLLERS.length; i++) { |
|
|
|
if (CONTROLLERS[i].getType() == Controller.Type.KEYBOARD |
|
|
|
if (RabiClone.CONTROLLERS[i].getType() == Controller.Type.KEYBOARD |
|
|
|
|| CONTROLLERS[i].getType() == Controller.Type.MOUSE) { |
|
|
|
|| RabiClone.CONTROLLERS[i].getType() == Controller.Type.MOUSE) { |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} else |
|
|
|
} else |
|
|
|
if (CONTROLLERS[i].getName().equals(controllerName)) { |
|
|
|
if (RabiClone.CONTROLLERS[i].getName().equals(controllerName)) { |
|
|
|
controller=CONTROLLERS[i]; |
|
|
|
controller=RabiClone.CONTROLLERS[i]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (controller==null) { |
|
|
|
if (controller==null) { |
|
|
@ -205,6 +202,7 @@ public class ConfigureControls extends Object{ |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void draw(byte[] p) { |
|
|
|
public void draw(byte[] p) { |
|
|
|
|
|
|
|
if (!RabiClone.reloadControllerList) { |
|
|
|
int y = 4; |
|
|
|
int y = 4; |
|
|
|
if (!assigningKey) { |
|
|
|
if (!assigningKey) { |
|
|
|
selectedAction=null; |
|
|
|
selectedAction=null; |
|
|
@ -237,6 +235,9 @@ public class ConfigureControls extends Object{ |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
Draw_Text_Ext(4, 4, new String("Press a key to assign to ").append(selectedAction), Font.PROFONT_12, Alpha.ALPHA0, PaletteColor.MIDNIGHT_BLUE); |
|
|
|
Draw_Text_Ext(4, 4, new String("Press a key to assign to ").append(selectedAction), Font.PROFONT_12, Alpha.ALPHA0, PaletteColor.MIDNIGHT_BLUE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Draw_Text_Ext(4, 4, new String("Preparing controller list..."), Font.PROFONT_12, Alpha.ALPHA0, PaletteColor.MIDNIGHT_BLUE); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|