Commit d51c3db1 authored by Toussaint Etienne's avatar Toussaint Etienne
Browse files

Merge branch 'master' of gitlab.crans.org:genie_logiciel_2015/the_dungeon_project

* 'master' of gitlab.crans.org:genie_logiciel_2015/the_dungeon_project:
  configurationPanel terminal+abstract done
parents 2b17aa2e b059e7b6
package graphics.graphical_abstraction.panel.menu;
/**
* Created by zobi on 25/11/15.
*/
public interface ConfigurationPanelAbstraction extends MenuPanelAbstraction {
void ChangeMoveUpConfig();
void ChangeMoveDownConfig();
void ChangeMoveRightConfig();
void ChangeMoveLeftConfig();
void ChangeAttackConfig();
void ChangeAbility1Config();
void ChangeAbility2Config();
void ChangeAbility3Config();
void ChangeBackToMainConfig();
void BackToMainMenu();
}
\ No newline at end of file
package graphics.graphical_abstraction.panel.menu;
/**
* Created by zobi on 25/11/15.
*/
......@@ -10,4 +11,15 @@ public class ConfigurationPanelAbstractionController extends MenuPanelAbstractio
this.menuPanel = configurationMenuPanel;
this.configurationMenuPanel = configurationMenuPanel;
}
public void ConfigUpButtonPressed(){this.configurationMenuPanel.ChangeMoveUpConfig();}
public void ConfigDownButtonPressed(){this.configurationMenuPanel.ChangeMoveUpConfig();}
public void ConfigRightButtonPressed(){this.configurationMenuPanel.ChangeMoveUpConfig();}
public void ConfigLeftButtonPressed(){this.configurationMenuPanel.ChangeMoveUpConfig();}
public void ConfigAttackButtonPressed(){this.configurationMenuPanel.ChangeMoveUpConfig();}
public void ConfigAbility1ButtonPressed(){this.configurationMenuPanel.ChangeMoveUpConfig();}
public void ConfigAbility2ButtonPressed(){this.configurationMenuPanel.ChangeMoveUpConfig();}
public void ConfigAbility3ButtonPressed(){this.configurationMenuPanel.ChangeMoveUpConfig();}
public void ConfigBackToMainButtonPressed(){this.configurationMenuPanel.ChangeMoveUpConfig();}
public void BackButtonPressed(){this.configurationMenuPanel.BackToMainMenu();}
}
\ No newline at end of file
......@@ -36,7 +36,7 @@ public class RonflexEntityDisplayer extends EntityDisplayer {
}
// TODO : change in action. Adaptation for multiaction.
@Override
public PositionedSprite getPositionedSprite(GraphicsMap graphicsMap) {
Sprite sprite = SpriteStorage.getInstance().getRonflex();
......
......@@ -12,15 +12,13 @@ import java.util.ArrayList;
public class ConfigurationFrame extends Frame implements ActionListener{
private ArrayList<Button> b= new ArrayList<>();
private ConfigurationPanel conf;
public static void InputConfigurationFrame(String title) {
ConfigurationFrame configFrame = new ConfigurationFrame(title);
configFrame.setSize(600, 600);
configFrame.setVisible(true);
}
public ConfigurationFrame(String title) {
public ConfigurationFrame(String title,ConfigurationPanel conf) {
super(title);
this.setSize(600, 600);
this.setVisible(true);
this.conf=conf;
String simpleKeyboard="abcdefghijklmnopqrstuvwxyz0123456789+-*(_)=,;:!^$/";
Button button;
......@@ -138,7 +136,7 @@ public class ConfigurationFrame extends Frame implements ActionListener{
Object source=e.getSource();
for(int i=0;i<b.size();i++){
if(source==b.get(i)){
InputConfiguration.ChangeInput(ConfigurationPanel.GetInputBeingChanged(),b.get(i).getLabel());
InputConfiguration.ChangeInput(conf.GetInputBeingChanged(),b.get(i).getLabel());
dispose();
}
}
......
package graphics.guiSkeleton.guiPanel.menuPanel.configuration;
import graphics.graphical_abstraction.panel.menu.ConfigurationPanelAbstraction;
import graphics.graphical_abstraction.panel.menu.ConfigurationPanelAbstractionController;
import graphics.guiSkeleton.GUIColorsAndFonts;
import graphics.guiSkeleton.GraphicsMaster;
import graphics.guiSkeleton.guiPanel.menuPanel.facilities.ButtonMaker;
......@@ -14,12 +16,13 @@ import java.awt.event.ActionListener;
/**
* Created by zobi on 25/11/15.
*/
public class ConfigurationPanel extends MenuPanel {
public class ConfigurationPanel extends MenuPanel implements ConfigurationPanelAbstraction{
private static final long serialVersionUID = 1L;
private static Input InputBeingChanged = Input.NONE;
private ConfigurationPanelAbstractionController controller = new ConfigurationPanelAbstractionController(this);
public static Input GetInputBeingChanged(){return InputBeingChanged;}
public Input GetInputBeingChanged(){return InputBeingChanged;}
/** create a key Labels */
private JLabel makeKeyLabel(Input input){
......@@ -32,17 +35,17 @@ public class ConfigurationPanel extends MenuPanel {
public ConfigurationPanel(GraphicsMaster graphicsMaster) {
super(graphicsMaster);
setTitlePanel("Configuration");
addToCentralColumn(ButtonMaker.makeButton("move up: ", configUpListener),1,1);
addToCentralColumn(ButtonMaker.makeButton("move down: ", configDownListener),1,1);
addToCentralColumn(ButtonMaker.makeButton("move right: ", configLeftListener),1,1);
addToCentralColumn(ButtonMaker.makeButton("move left: ", configRightListener),1,1);
addToCentralColumn(ButtonMaker.makeButton("attack: ", configAttackListener),1,1);
addToCentralColumn(ButtonMaker.makeButton("ability 1: ", configAbility1Listener),1,1);
addToCentralColumn(ButtonMaker.makeButton("ability 2: ", configAbility2Listener),1,1);
addToCentralColumn(ButtonMaker.makeButton("ability 3: ", configAbility3Listener),1,1);
addToCentralColumn(ButtonMaker.makeButton("back: ", backButtonListener),1,1);
addToCentralColumn(ButtonMaker.makeButton("move up: "+MoveUpConfig(), configUpListener),1,1);
addToCentralColumn(ButtonMaker.makeButton("move down: "+MoveDownConfig(), configDownListener),1,1);
addToCentralColumn(ButtonMaker.makeButton("move right: "+MoveRightConfig(), configLeftListener),1,1);
addToCentralColumn(ButtonMaker.makeButton("move left: "+MoveLeftConfig(), configRightListener),1,1);
addToCentralColumn(ButtonMaker.makeButton("attack: "+AttackConfig(), configAttackListener),1,1);
addToCentralColumn(ButtonMaker.makeButton("ability 1: "+Ability1Config(), configAbility1Listener),1,1);
addToCentralColumn(ButtonMaker.makeButton("ability 2: "+Ability2Config(), configAbility2Listener),1,1);
addToCentralColumn(ButtonMaker.makeButton("ability 3: "+Ability3Config(), configAbility3Listener),1,1);
addToCentralColumn(ButtonMaker.makeButton("back to main: "+Ability3Config(), configBackToMainListener),1,1);
addToCentralColumn(ButtonMaker.makeButton("back", backButtonListener),1,1);
}
/**###################################**/
......@@ -52,66 +55,117 @@ public class ConfigurationPanel extends MenuPanel {
private ActionListener configUpListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
InputBeingChanged=Input.UP_ARROW;
ConfigurationFrame.InputConfigurationFrame("Move Up: current control: " + (InputConfiguration.GetFormalInputString(Input.UP_ARROW)));
}
controller.ConfigUpButtonPressed();
}
};
private ActionListener configDownListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
InputBeingChanged=Input.DOWN_ARROW;
ConfigurationFrame.InputConfigurationFrame("Move Down: current control: " + (InputConfiguration.GetFormalInputString(Input.DOWN_ARROW)));
controller.ConfigDownButtonPressed();
}
};
private ActionListener configLeftListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
InputBeingChanged=Input.LEFT_ARROW;
ConfigurationFrame.InputConfigurationFrame("Move Left: current control: " + (InputConfiguration.GetFormalInputString(Input.LEFT_ARROW)));
}
controller.ConfigLeftButtonPressed();
}
};
private ActionListener configRightListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
InputBeingChanged=Input.RIGHT_ARROW;
ConfigurationFrame.InputConfigurationFrame("Move Right: current control: " + (InputConfiguration.GetFormalInputString(Input.RIGHT_ARROW)));
controller.ConfigRightButtonPressed();
}
};
private ActionListener configAttackListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
InputBeingChanged=Input.ATTACK;
ConfigurationFrame.InputConfigurationFrame("Attack: current control: " + (InputConfiguration.GetFormalInputString(Input.ATTACK)));
}
controller.ConfigAttackButtonPressed();
}
};
private ActionListener configAbility1Listener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
InputBeingChanged=Input.ABILITY_1;
ConfigurationFrame.InputConfigurationFrame("First Ability: current control: " + (InputConfiguration.GetFormalInputString(Input.ABILITY_1)));
}
controller.ConfigAbility1ButtonPressed();
}
};
private ActionListener configAbility2Listener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
InputBeingChanged=Input.ABILITY_2;
ConfigurationFrame.InputConfigurationFrame("Second Ability: current control: " + (InputConfiguration.GetFormalInputString(Input.ABILITY_2)));}
controller.ConfigAbility2ButtonPressed();
}
};
private ActionListener configAbility3Listener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
InputBeingChanged=Input.ABILITY_3;
ConfigurationFrame.InputConfigurationFrame("Third Ability: current control: " + (InputConfiguration.GetFormalInputString(Input.ABILITY_3)));
}
controller.ConfigAbility3ButtonPressed();
}
};
private ActionListener configBackToMainListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
controller.ConfigBackToMainButtonPressed();
}
};
private ActionListener backButtonListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
getGraphicsMaster().changeGUIStateTo(GraphicsMaster.GUIStates.MAIN_MENU);
controller.BackButtonPressed();
}
};
private String MoveUpConfig(){return InputConfiguration.GetFormalInputString(Input.UP_ARROW);}
private String MoveDownConfig(){return InputConfiguration.GetFormalInputString(Input.DOWN_ARROW);}
private String MoveRightConfig(){return InputConfiguration.GetFormalInputString(Input.RIGHT_ARROW);}
private String MoveLeftConfig(){return InputConfiguration.GetFormalInputString(Input.LEFT_ARROW);}
private String AttackConfig(){return InputConfiguration.GetFormalInputString(Input.ATTACK);}
private String Ability1Config(){return InputConfiguration.GetFormalInputString(Input.ABILITY_1);}
private String Ability2Config(){return InputConfiguration.GetFormalInputString(Input.ABILITY_2);}
private String Ability3Config(){return InputConfiguration.GetFormalInputString(Input.ABILITY_3);}
private String BackToMainConfig(){return InputConfiguration.GetFormalInputString(Input.ESCAPE);}
/**#######################################################**/
/** necessary as implements ConfigurationPanelAbstraction **/
/**#######################################################**/
public void ChangeMoveUpConfig(){
InputBeingChanged=Input.UP_ARROW;
new ConfigurationFrame("Move Up: current control: " + MoveUpConfig(),ConfigurationPanel.this);
}
public void ChangeMoveDownConfig(){
InputBeingChanged=Input.DOWN_ARROW;
new ConfigurationFrame("Move Down: current control: " + MoveDownConfig(),ConfigurationPanel.this);
}
public void ChangeMoveRightConfig(){
InputBeingChanged=Input.RIGHT_ARROW;
new ConfigurationFrame("Move Right: current control: " + MoveRightConfig(),ConfigurationPanel.this);}
public void ChangeMoveLeftConfig(){
InputBeingChanged=Input.LEFT_ARROW;
new ConfigurationFrame("Move Left: current control: " + MoveLeftConfig(),ConfigurationPanel.this);
}
public void ChangeAttackConfig(){
InputBeingChanged=Input.ATTACK;
new ConfigurationFrame("Attack: current control: " + AttackConfig(),ConfigurationPanel.this);
}
public void ChangeAbility1Config(){
InputBeingChanged=Input.ABILITY_1;
new ConfigurationFrame("First Ability: current control: " + Ability1Config(),ConfigurationPanel.this);
}
public void ChangeAbility2Config(){
InputBeingChanged=Input.ABILITY_2;
new ConfigurationFrame("Second Ability: current control: " + Ability2Config(),ConfigurationPanel.this);
}
public void ChangeAbility3Config(){
InputBeingChanged=Input.ABILITY_3;
new ConfigurationFrame("Third Ability: current control: " + Ability3Config(),ConfigurationPanel.this);
}
public void ChangeBackToMainConfig(){
InputBeingChanged=Input.ESCAPE;
new ConfigurationFrame("Back to main: current control: " + BackToMainConfig(),ConfigurationPanel.this);
}
public void BackToMainMenu(){getGraphicsMaster().changeGUIStateTo(GraphicsMaster.GUIStates.MAIN_MENU);}
/**###################################**/
/** necessary as extension of guiPanel **/
/**###################################**/
......
......@@ -27,15 +27,15 @@ public class InputConfiguration {
private static int left = KeyEvent.VK_LEFT;
//keys special for terminal version
private static char left_arrow = 'q';
private static char right_arrow = 'd';
private static char up_arrow = 'z';
private static char down_arrow = 's';
private static char escape_terminal = 'v';
private static char attack_terminal = 'o';
private static char ability1_terminal = 'k';
private static char ability2_terminal = 'l';
private static char ability3_terminal = 'm';
private static int left_terminal = 'q';
private static int right_terminal = 'd';
private static int up_terminal = 'z';
private static int down_terminal = 's';
private static int escape_terminal = 'v';
private static int attack_terminal = 'o';
private static int ability1_terminal = 'k';
private static int ability2_terminal = 'l';
private static int ability3_terminal = 'm';
/**
......@@ -577,7 +577,7 @@ public class InputConfiguration {
* @return the string of the character linked to input
*/
//Will only be used for the terminal version
public static char GetFormalInputChar(Input input) {
public static int GetFormalInputIntTerminal(Input input) {
switch (input) {
case ATTACK:
return attack_terminal;
......@@ -590,15 +590,15 @@ public class InputConfiguration {
case ESCAPE:
return escape_terminal;
case LEFT_ARROW:
return left_arrow;
return left_terminal;
case RIGHT_ARROW:
return right_arrow;
return right_terminal;
case UP_ARROW:
return up_arrow;
return up_terminal;
case DOWN_ARROW:
return down_arrow;
return down_terminal;
case NONE:
return ' ';
return 0;
default:
throw new IllegalStateException("Unknown input : " + input);
}
......@@ -645,4 +645,40 @@ public class InputConfiguration {
throw new IllegalStateException("Unknown input: " + input);
}
}
public static void ChangeInputTerminal(Input input, int j) {
switch (input) {
case ATTACK:
attack_terminal = j;
break;
case ABILITY_1:
ability1_terminal = j;
break;
case ABILITY_2:
ability2_terminal = j;
break;
case ABILITY_3:
ability3_terminal = j;
break;
case ESCAPE:
escape_terminal = j;
break;
case UP_ARROW:
up_terminal = j;
break;
case DOWN_ARROW:
down_terminal = j;
break;
case RIGHT_ARROW:
right_terminal = j;
break;
case LEFT_ARROW:
left_terminal = j;
break;
case NONE:
return;
default:
throw new IllegalStateException("Unknown input: " + input);
}
}
}
\ No newline at end of file
......@@ -89,39 +89,39 @@ public class TermFrameKeyListener implements FrameKeyListenerAbstraction{
while (in.ready()) {
line = in.read();
if (line == InputConfiguration.GetFormalInputChar(Input.ESCAPE)) {
if (line == InputConfiguration.GetFormalInputIntTerminal(Input.ESCAPE)) {
//graphicsMaster.keyPressedHandler(Input.ESCAPE);
inputs_current.add(Input.ESCAPE);
}
if (line == InputConfiguration.GetFormalInputChar(Input.LEFT_ARROW)) {
if (line == InputConfiguration.GetFormalInputIntTerminal(Input.LEFT_ARROW)) {
//graphicsMaster.keyPressedHandler(Input.LEFT_ARROW);
inputs_current.add(Input.LEFT_ARROW);
}
if (line == InputConfiguration.GetFormalInputChar(Input.UP_ARROW)) {
if (line == InputConfiguration.GetFormalInputIntTerminal(Input.UP_ARROW)) {
//graphicsMaster.keyPressedHandler(Input.UP_ARROW);
inputs_current.add(Input.UP_ARROW);
}
if (line == InputConfiguration.GetFormalInputChar(Input.RIGHT_ARROW)) {
if (line == InputConfiguration.GetFormalInputIntTerminal(Input.RIGHT_ARROW)) {
//graphicsMaster.keyPressedHandler(Input.RIGHT_ARROW);
inputs_current.add(Input.RIGHT_ARROW);
}
if (line == InputConfiguration.GetFormalInputChar(Input.DOWN_ARROW)) {
if (line == InputConfiguration.GetFormalInputIntTerminal(Input.DOWN_ARROW)) {
//graphicsMaster.keyPressedHandler(Input.DOWN_ARROW);
inputs_current.add(Input.DOWN_ARROW);
}
if (line == InputConfiguration.GetFormalInputChar(Input.ATTACK)) {
if (line == InputConfiguration.GetFormalInputIntTerminal(Input.ATTACK)) {
//graphicsMaster.keyPressedHandler(Input.DOWN_ARROW);
inputs_current.add(Input.ATTACK);
}
if (line == InputConfiguration.GetFormalInputChar(Input.ABILITY_1)) {
if (line == InputConfiguration.GetFormalInputIntTerminal(Input.ABILITY_1)) {
//graphicsMaster.keyPressedHandler(Input.DOWN_ARROW);
inputs_current.add(Input.ABILITY_1);
}
if (line == InputConfiguration.GetFormalInputChar(Input.ABILITY_2)) {
if (line == InputConfiguration.GetFormalInputIntTerminal(Input.ABILITY_2)) {
//graphicsMaster.keyPressedHandler(Input.DOWN_ARROW);
inputs_current.add(Input.ABILITY_2);
}
if (line == InputConfiguration.GetFormalInputChar(Input.ABILITY_3)) {
if (line == InputConfiguration.GetFormalInputIntTerminal(Input.ABILITY_3)) {
//graphicsMaster.keyPressedHandler(Input.DOWN_ARROW);
inputs_current.add(Input.ABILITY_3);
}
......
......@@ -13,10 +13,10 @@ public abstract class PanelTerminal implements PanelAbstraction{
/*Configuration*/
protected int number_line = 40;
protected int number_colunm = 140;
protected int number_column = 140;
public int getHeight(){return number_line;}
public int getWidth(){return number_colunm;}
public int getWidth(){return number_column;}
//The following line is commented because KeyListener does not seem to work in a JPanel
//Private KeyListenerForGUIPanel associatedKeyHandler;
......@@ -29,7 +29,7 @@ public abstract class PanelTerminal implements PanelAbstraction{
public PanelTerminal(GraphicsMasterTerm graphicsMaster) {
String s = new String();
for(int i = 0; i<number_colunm ; i++){
for(int i = 0; i< number_column; i++){
s+= "\0";
}
this.graphicsMaster = graphicsMaster;
......
package graphics.termSkeleton.panel.menu;
import graphics.graphical_abstraction.GraphicsMasterAbstraction;
import graphics.graphical_abstraction.panel.menu.ConfigurationPanelAbstraction;
import graphics.graphical_abstraction.panel.menu.ConfigurationPanelAbstractionController;
import graphics.ingame_input_listener.Input;
import graphics.ingame_input_listener.InputConfiguration;
import graphics.termSkeleton.GraphicsMasterTerm;
import graphics.termSkeleton.panel.PanelTerminal;
import java.io.IOException;
import java.util.ArrayList;
/**
* Created by zobi on 25/11/15.
*/
public class ConfigurationPanelTerminal extends PanelTerminal implements ConfigurationPanelAbstraction {
public class ConfigurationPanelTerminal extends MenuPanelTerminal implements ConfigurationPanelAbstraction {
ConfigurationPanelAbstractionController controller = new ConfigurationPanelAbstractionController(this);
public ConfigurationPanelTerminal(GraphicsMasterTerm graphicsMaster) {
super(graphicsMaster);
}
setTitlePanel("Configuration");
@Override
public void setTitlePanel(String title) {
buttonDefList = new ArrayList<>();
buttonDefList.add(new buttonPanelButtonDefinition("move up: ", ()->controller.ConfigUpButtonPressed()));
buttonDefList.add(new buttonPanelButtonDefinition("move down: ", ()->controller.ConfigDownButtonPressed()));
buttonDefList.add(new buttonPanelButtonDefinition("move left: ", ()->controller.ConfigLeftButtonPressed()));
buttonDefList.add(new buttonPanelButtonDefinition("move right: ", ()->controller.ConfigRightButtonPressed()));
buttonDefList.add(new buttonPanelButtonDefinition("attack: ", ()->controller.ConfigAttackButtonPressed()));
buttonDefList.add(new buttonPanelButtonDefinition("ability 1: ", ()->controller.ConfigAbility1ButtonPressed()));
buttonDefList.add(new buttonPanelButtonDefinition("ability 2: ", ()->controller.ConfigAbility2ButtonPressed()));
buttonDefList.add(new buttonPanelButtonDefinition("ability 3: ", ()->controller.ConfigAbility3ButtonPressed()));
buttonDefList.add(new buttonPanelButtonDefinition("back to main: ", ()->controller.ConfigBackToMainButtonPressed()));
buttonDefList.add(new buttonPanelButtonDefinition("back", ()->controller.BackButtonPressed()));
setButtonPanel(buttonDefList);
}
private void ChangeInput(Input input){
System.out.println("Enter a Character please:");
try {
InputConfiguration.ChangeInputTerminal(input, System.in.read());
}
catch (IOException e){
System.out.println("Error reading from user while trying to change a command");
}
}
@Override
public void keyPressedHandler(Input e) {
public void ChangeMoveUpConfig() {
ChangeInput(Input.UP_ARROW);
}
@Override
public void ChangeMoveDownConfig() {
ChangeInput(Input.DOWN_ARROW);
}
@Override
public void keyReleasedHandler(Input e) {
public void ChangeMoveRightConfig() {
ChangeInput(Input.RIGHT_ARROW);
}
@Override
public void ChangeMoveLeftConfig() {
ChangeInput(Input.LEFT_ARROW);
}
@Override
public void keyTypedHandler(Input e) {
public void ChangeAttackConfig() {
ChangeInput(Input.ATTACK);
}
@Override
public void ChangeAbility1Config() {
ChangeInput(Input.ABILITY_1);
}
@Override
public void initialise() {
public void ChangeAbility2Config() {
ChangeInput(Input.ABILITY_2);
}
@Override
public void ChangeAbility3Config() {
ChangeInput(Input.ABILITY_3);
}
@Override
public void finalise() {
public void ChangeBackToMainConfig() {
ChangeInput(Input.ESCAPE);
}
@Override
public void BackToMainMenu() {
getGraphicsMaster().changeGUIStateTo(GraphicsMasterAbstraction.GUIStates.MAIN_MENU);
}
}
\ No newline at end of file
......@@ -5,20 +5,20 @@ import java.io.Serializable;
/**
* Represents a single tile of the map
*
*
*/
public class Tile implements Serializable{ // No need for abstract implementation
/**
*
*
*/
private static final long serialVersionUID = -857708415876341217L;
public TilePropertyVector tpv;
// public static enum TileDirection{NORTH, SOUTH, EAST, WEST, NE, NW, SE, SW};