Commit 54ef1f2f authored by Huot Mathieu's avatar Huot Mathieu

input config bug fixed

parent 826cac06
################### THIS FILE IS USED TO HAVE PERSISTENT COMMANDS IN THE GAME ###################
#################################################################################################
###################
MOVE UP:
Left arrow
###################
MOVE DOWN:
Down arrow
###################
MOVE RIGHT:
Right arrow
###################
MOVE LEFT:
Left arrow
###################
ATTACK:
a
###################
ABILITY 1:
z
###################
ABILITY 2:
e
###################
ABILITY 3:
r
###################
BACK TO MAIN:
Escape
###################
###################
###################
###################
###################
###################
###################
###################
################### THIS FILE IS USED TO HAVE PERSISTENT COMMANDS IN THE GAME ###################
#################################################################################################
###################
MOVE UP:
Left arrow
###################
MOVE DOWN:
Down arrow
###################
MOVE RIGHT:
Right arrow
###################
MOVE LEFT:
Left arrow
###################
ATTACK:
a
###################
ABILITY 1:
z
###################
ABILITY 2:
e
###################
ABILITY 3:
r
###################
BACK TO MAIN:
Escape
###################
...@@ -19,14 +19,14 @@ public class ConfigurationPanelAbstractionController extends MenuPanelAbstractio ...@@ -19,14 +19,14 @@ public class ConfigurationPanelAbstractionController extends MenuPanelAbstractio
//To handle the ask from the user to change the configuration of an input //To handle the ask from the user to change the configuration of an input
public void ConfigUpButtonPressed(){this.configurationMenuPanel.ChangeMoveUpConfig();} public void ConfigUpButtonPressed(){this.configurationMenuPanel.ChangeMoveUpConfig();}
public void ConfigDownButtonPressed(){this.configurationMenuPanel.ChangeMoveUpConfig();} public void ConfigDownButtonPressed(){this.configurationMenuPanel.ChangeMoveDownConfig();}
public void ConfigRightButtonPressed(){this.configurationMenuPanel.ChangeMoveUpConfig();} public void ConfigRightButtonPressed(){this.configurationMenuPanel.ChangeMoveRightConfig();}
public void ConfigLeftButtonPressed(){this.configurationMenuPanel.ChangeMoveUpConfig();} public void ConfigLeftButtonPressed(){this.configurationMenuPanel.ChangeMoveLeftConfig();}
public void ConfigAttackButtonPressed(){this.configurationMenuPanel.ChangeMoveUpConfig();} public void ConfigAttackButtonPressed(){this.configurationMenuPanel.ChangeAttackConfig();}
public void ConfigAbility1ButtonPressed(){this.configurationMenuPanel.ChangeMoveUpConfig();} public void ConfigAbility1ButtonPressed(){this.configurationMenuPanel.ChangeAbility1Config();}
public void ConfigAbility2ButtonPressed(){this.configurationMenuPanel.ChangeMoveUpConfig();} public void ConfigAbility2ButtonPressed(){this.configurationMenuPanel.ChangeAbility2Config();}
public void ConfigAbility3ButtonPressed(){this.configurationMenuPanel.ChangeMoveUpConfig();} public void ConfigAbility3ButtonPressed(){this.configurationMenuPanel.ChangeAbility3Config();}
public void ConfigBackToMainButtonPressed(){this.configurationMenuPanel.ChangeMoveUpConfig();} public void ConfigBackToMainButtonPressed(){this.configurationMenuPanel.ChangeBackToMainConfig();}
//To handle the ask from the user to get back to the main menu //To handle the ask from the user to get back to the main menu
public void BackButtonPressed(){this.configurationMenuPanel.BackToMainMenu();} public void BackButtonPressed(){this.configurationMenuPanel.BackToMainMenu();}
} }
\ No newline at end of file
...@@ -23,6 +23,7 @@ public class ConfigurationFrame extends Frame implements ActionListener{ ...@@ -23,6 +23,7 @@ public class ConfigurationFrame extends Frame implements ActionListener{
this.setSize(600, 600); this.setSize(600, 600);
this.setVisible(true); this.setVisible(true);
this.conf=conf; this.conf=conf;
// monoalphabetic keys // monoalphabetic keys
String simpleKeyboard="abcdefghijklmnopqrstuvwxyz0123456789+-*(_)=,;:!^$/"; String simpleKeyboard="abcdefghijklmnopqrstuvwxyz0123456789+-*(_)=,;:!^$/";
Button button; Button button;
...@@ -148,6 +149,7 @@ public class ConfigurationFrame extends Frame implements ActionListener{ ...@@ -148,6 +149,7 @@ public class ConfigurationFrame extends Frame implements ActionListener{
for(int i=0;i<b.size();i++){ for(int i=0;i<b.size();i++){
if(source==b.get(i)){ if(source==b.get(i)){
InputConfiguration.ChangeInput(conf.GetInputBeingChanged(),b.get(i).getLabel()); InputConfiguration.ChangeInput(conf.GetInputBeingChanged(),b.get(i).getLabel());
conf.ResetInputBeingChanged();
dispose(); dispose();
} }
} }
......
...@@ -2,14 +2,12 @@ package graphics.guiSkeleton.guiPanel.menuPanel.configuration; ...@@ -2,14 +2,12 @@ package graphics.guiSkeleton.guiPanel.menuPanel.configuration;
import graphics.graphical_abstraction.panel.menu.ConfigurationPanelAbstraction; import graphics.graphical_abstraction.panel.menu.ConfigurationPanelAbstraction;
import graphics.graphical_abstraction.panel.menu.ConfigurationPanelAbstractionController; import graphics.graphical_abstraction.panel.menu.ConfigurationPanelAbstractionController;
import graphics.guiSkeleton.GUIColorsAndFonts;
import graphics.guiSkeleton.GraphicsMaster; import graphics.guiSkeleton.GraphicsMaster;
import graphics.guiSkeleton.guiPanel.menuPanel.facilities.ButtonMaker; import graphics.guiSkeleton.guiPanel.menuPanel.facilities.ButtonMaker;
import graphics.guiSkeleton.guiPanel.menuPanel.facilities.MenuPanel; import graphics.guiSkeleton.guiPanel.menuPanel.facilities.MenuPanel;
import graphics.ingame_input_listener.Input; import graphics.ingame_input_listener.Input;
import graphics.ingame_input_listener.InputConfiguration; import graphics.ingame_input_listener.InputConfiguration;
import javax.swing.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
...@@ -31,13 +29,15 @@ public class ConfigurationPanel extends MenuPanel implements ConfigurationPanelA ...@@ -31,13 +29,15 @@ public class ConfigurationPanel extends MenuPanel implements ConfigurationPanelA
*/ */
public Input GetInputBeingChanged(){return InputBeingChanged;} public Input GetInputBeingChanged(){return InputBeingChanged;}
public void ResetInputBeingChanged(){InputBeingChanged=Input.NONE;}
public ConfigurationPanel(GraphicsMaster graphicsMaster) { public ConfigurationPanel(GraphicsMaster graphicsMaster) {
super(graphicsMaster); super(graphicsMaster);
setTitlePanel("Configuration"); setTitlePanel("Configuration");
addToCentralColumn(ButtonMaker.makeButton("move up: "+MoveUpConfig(), configUpListener),1,1); addToCentralColumn(ButtonMaker.makeButton("move up: "+MoveUpConfig(), configUpListener),1,1);
addToCentralColumn(ButtonMaker.makeButton("move down: "+MoveDownConfig(), configDownListener),1,1); addToCentralColumn(ButtonMaker.makeButton("move down: "+MoveDownConfig(), configDownListener),1,1);
addToCentralColumn(ButtonMaker.makeButton("move right: "+MoveRightConfig(), configLeftListener),1,1); addToCentralColumn(ButtonMaker.makeButton("move right: "+MoveRightConfig(), configRightListener),1,1);
addToCentralColumn(ButtonMaker.makeButton("move left: "+MoveLeftConfig(), configRightListener),1,1); addToCentralColumn(ButtonMaker.makeButton("move left: "+MoveLeftConfig(), configLeftListener),1,1);
addToCentralColumn(ButtonMaker.makeButton("attack: "+AttackConfig(), configAttackListener),1,1); addToCentralColumn(ButtonMaker.makeButton("attack: "+AttackConfig(), configAttackListener),1,1);
addToCentralColumn(ButtonMaker.makeButton("ability 1: "+Ability1Config(), configAbility1Listener),1,1); addToCentralColumn(ButtonMaker.makeButton("ability 1: "+Ability1Config(), configAbility1Listener),1,1);
addToCentralColumn(ButtonMaker.makeButton("ability 2: "+Ability2Config(), configAbility2Listener),1,1); addToCentralColumn(ButtonMaker.makeButton("ability 2: "+Ability2Config(), configAbility2Listener),1,1);
...@@ -136,57 +136,57 @@ public class ConfigurationPanel extends MenuPanel implements ConfigurationPanelA ...@@ -136,57 +136,57 @@ public class ConfigurationPanel extends MenuPanel implements ConfigurationPanelA
if (InputBeingChanged==Input.NONE){ if (InputBeingChanged==Input.NONE){
InputBeingChanged=Input.UP_ARROW; InputBeingChanged=Input.UP_ARROW;
new ConfigurationFrame("Move Up: current control: " + MoveUpConfig(),ConfigurationPanel.this); new ConfigurationFrame("Move Up: current control: " + MoveUpConfig(),ConfigurationPanel.this);
InputBeingChanged=Input.NONE;} }
} }
public void ChangeMoveDownConfig(){ public void ChangeMoveDownConfig(){
if (InputBeingChanged==Input.NONE){ if (InputBeingChanged==Input.NONE){
InputBeingChanged=Input.DOWN_ARROW; InputBeingChanged=Input.DOWN_ARROW;
new ConfigurationFrame("Move Down: current control: " + MoveUpConfig(),ConfigurationPanel.this); new ConfigurationFrame("Move Down: current control: " + MoveDownConfig(),ConfigurationPanel.this);
InputBeingChanged=Input.NONE;} }
} }
public void ChangeMoveRightConfig(){ public void ChangeMoveRightConfig(){
if (InputBeingChanged==Input.NONE){ if (InputBeingChanged==Input.NONE){
InputBeingChanged=Input.RIGHT_ARROW; InputBeingChanged=Input.RIGHT_ARROW;
new ConfigurationFrame("Move Right: current control: " + MoveUpConfig(),ConfigurationPanel.this); new ConfigurationFrame("Move Right: current control: " + MoveRightConfig(),ConfigurationPanel.this);
InputBeingChanged=Input.NONE;} }
} }
public void ChangeMoveLeftConfig(){ public void ChangeMoveLeftConfig(){
if (InputBeingChanged==Input.NONE){ if (InputBeingChanged==Input.NONE){
InputBeingChanged=Input.LEFT_ARROW; InputBeingChanged=Input.LEFT_ARROW;
new ConfigurationFrame("Move Left: current control: " + MoveUpConfig(),ConfigurationPanel.this); new ConfigurationFrame("Move Left: current control: " + MoveLeftConfig(),ConfigurationPanel.this);
InputBeingChanged=Input.NONE;} }
} }
public void ChangeAttackConfig(){ public void ChangeAttackConfig(){
if (InputBeingChanged==Input.NONE){ if (InputBeingChanged==Input.NONE){
InputBeingChanged=Input.ATTACK; InputBeingChanged=Input.ATTACK;
new ConfigurationFrame("Move Attack: current control: " + MoveUpConfig(),ConfigurationPanel.this); new ConfigurationFrame("Move Attack: current control: " + AttackConfig(),ConfigurationPanel.this);
InputBeingChanged=Input.NONE;} }
} }
public void ChangeAbility1Config(){ public void ChangeAbility1Config(){
if (InputBeingChanged==Input.NONE){ if (InputBeingChanged==Input.NONE){
InputBeingChanged=Input.ABILITY_1; InputBeingChanged=Input.ABILITY_1;
new ConfigurationFrame("Ability 1: current control: " + MoveUpConfig(),ConfigurationPanel.this); new ConfigurationFrame("Ability 1: current control: " + Ability1Config(),ConfigurationPanel.this);
InputBeingChanged=Input.NONE;} }
} }
public void ChangeAbility2Config(){ public void ChangeAbility2Config(){
if (InputBeingChanged==Input.NONE){ if (InputBeingChanged==Input.NONE){
InputBeingChanged=Input.ABILITY_2; InputBeingChanged=Input.ABILITY_2;
new ConfigurationFrame("Ability 2: current control: " + MoveUpConfig(),ConfigurationPanel.this); new ConfigurationFrame("Ability 2: current control: " + Ability2Config(),ConfigurationPanel.this);
InputBeingChanged=Input.NONE;} }
} }
public void ChangeAbility3Config(){ public void ChangeAbility3Config(){
if (InputBeingChanged==Input.NONE){ if (InputBeingChanged==Input.NONE){
InputBeingChanged=Input.ABILITY_3; InputBeingChanged=Input.ABILITY_3;
new ConfigurationFrame("Ability 3: current control: " + MoveUpConfig(),ConfigurationPanel.this); new ConfigurationFrame("Ability 3: current control: " + Ability3Config(),ConfigurationPanel.this);
InputBeingChanged=Input.NONE;} }
} }
public void ChangeBackToMainConfig(){ public void ChangeBackToMainConfig(){
if (InputBeingChanged==Input.NONE){ if (InputBeingChanged==Input.NONE){
InputBeingChanged=Input.ESCAPE; InputBeingChanged=Input.ESCAPE;
new ConfigurationFrame("Escape: current control: " + MoveUpConfig(),ConfigurationPanel.this); new ConfigurationFrame("Escape: current control: " + BackToMainConfig(),ConfigurationPanel.this);}
InputBeingChanged=Input.NONE;} }
public void BackToMainMenu(){getGraphicsMaster().changeGUIStateTo(GraphicsMaster.GUIStates.MAIN_MENU);
} }
public void BackToMainMenu(){getGraphicsMaster().changeGUIStateTo(GraphicsMaster.GUIStates.MAIN_MENU);}
/**###################################**/ /**###################################**/
/** necessary as extension of guiPanel **/ /** necessary as extension of guiPanel **/
......
...@@ -6,6 +6,31 @@ import java.awt.event.KeyEvent; ...@@ -6,6 +6,31 @@ import java.awt.event.KeyEvent;
* Created by etouss on 09/11/2015. * Created by etouss on 09/11/2015.
*/ */
public class InputConfiguration { public class InputConfiguration {
// static public int lineError=0;
// static{
// URL url= UsedForLoadingSprites.getInstance().getClass().getResource("./assets/configuration/configuration.txt");
// if(url==null)
// throw new IllegalStateException("Configuration file assets/configuration/configuration.txt not found");
// try(BufferedReader br= new BufferedReader(new InputStreamReader(url.openStream()))){
// System.out.println(br.readLine());
// }catch(IOException e){
// errorMessage(e.getMessage());
// throw new IllegalStateException("Should not access this line");
// }
// }
//
// /**
// * Beware, throw an exception with the given message !
// * @param message
// */
// private static void errorMessage(String message) {
// throw new IllegalStateException("Error parsing configuration: " + System.lineSeparator()+
// "Line"+lineError + message);
// }
/** /**
* Each action that can be performed in the game * Each action that can be performed in the game
* is firstly linked with some input which is * is firstly linked with some input which is
...@@ -264,6 +289,12 @@ public class InputConfiguration { ...@@ -264,6 +289,12 @@ public class InputConfiguration {
if (string.equals("g")) { if (string.equals("g")) {
return KeyEvent.VK_G; return KeyEvent.VK_G;
} }
if (string.equals("h")) {
return KeyEvent.VK_H;
}
if (string.equals("i")) {
return KeyEvent.VK_I;
}
if (string.equals("j")) { if (string.equals("j")) {
return KeyEvent.VK_J; return KeyEvent.VK_J;
} }
...@@ -279,12 +310,6 @@ public class InputConfiguration { ...@@ -279,12 +310,6 @@ public class InputConfiguration {
if (string.equals("n")) { if (string.equals("n")) {
return KeyEvent.VK_N; return KeyEvent.VK_N;
} }
if (string.equals("m")) {
return KeyEvent.VK_M;
}
if (string.equals("n")) {
return KeyEvent.VK_N;
}
if (string.equals("o")) { if (string.equals("o")) {
return KeyEvent.VK_O; return KeyEvent.VK_O;
} }
...@@ -540,7 +565,9 @@ public class InputConfiguration { ...@@ -540,7 +565,9 @@ public class InputConfiguration {
* the key pressed linked to "input" is changed to "j" * the key pressed linked to "input" is changed to "j"
*/ */
public static void ChangeInput(Input input, String string) { public static void ChangeInput(Input input, String string) {
System.out.println("Got here");
int j = GetIntFromString(string); int j = GetIntFromString(string);
System.out.println(j);
switch (input) { switch (input) {
case ATTACK: case ATTACK:
attack = j; attack = j;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment