diff --git a/RefereeClient/Comms.pde b/RefereeClient/Comms.pde index 5f552d6..d3f07d2 100644 --- a/RefereeClient/Comms.pde +++ b/RefereeClient/Comms.pde @@ -65,6 +65,7 @@ public static final String COMM_THROWIN = "THROWIN"; public static final String COMM_CORNER = "CORNER"; public static final String COMM_PENALTY = "PENALTY"; public static final String COMM_DROP_BALL = "DROP_BALL"; +public static final String COMM_ISALIVE = "IS_ALIVE"; // repair Commands public static final String COMM_REPAIR = "REPAIR"; @@ -93,6 +94,7 @@ void comms_initDescriptionDictionary() { Description.set(COMM_SECOND_HALF_OVERTIME, "Overtime 2nd half"); Description.set(COMM_PARK, "Park"); Description.set(COMM_SUBSTITUTION, "Substitution"); + Description.set(COMM_ISALIVE, "Is Alive"); Description.set(COMM_KICKOFF, "Kickoff"); Description.set(COMM_FREEKICK, "Freekick"); diff --git a/RefereeClient/RefereeClient.pde b/RefereeClient/RefereeClient.pde index e0b1750..777bf28 100644 --- a/RefereeClient/RefereeClient.pde +++ b/RefereeClient/RefereeClient.pde @@ -60,6 +60,30 @@ public static PVector offsetLeft= new PVector(250, 160); public static PVector offsetRight= new PVector(610, 160); public static PFont buttonFont, clockFont, panelFont, scoreFont, debugFont, teamFont, watermark; public static PImage backgroundImage; +public static PImage stop; +public static PImage playOn; +public static PImage preGame; +public static PImage halfTime; +public static PImage gameOver; +public static PImage endGame; +public static PImage substitutionLeft; +public static PImage substitutionRight; +public static PImage kickOffLeft; +public static PImage goalKickLeft; +public static PImage throwInLeft; +public static PImage freeKickLeft; +public static PImage cornerKickLeft; +public static PImage penaltyKickLeft; +public static PImage kickOffRight; +public static PImage throwInRight; +public static PImage goalKickRight; +public static PImage freeKickRight; +public static PImage cornerKickRight; +public static PImage penaltyKickRight; +public static PImage dropBall; +public static PImage isAliveLeft; +public static PImage isAliveRight; + public static PApplet mainApplet = null; @@ -77,8 +101,31 @@ void setup() { size(1000, 680); backgroundImage = loadImage("img/bg_normal.png"); - - frame.setTitle(MSG_WINDOWTITLE); + stop = loadImage("img/stop.png"); + playOn = loadImage("img/PlayOn.png"); + preGame = loadImage("img/PreGame.png"); + halfTime = loadImage("img/HalfTime.png"); + gameOver = loadImage("img/GameOver.png"); + endGame = loadImage("img/EndGame.png"); + substitutionLeft = loadImage("img/SubstitutionLeft.png"); + substitutionRight = loadImage("img/SubstitutionRight.png"); + kickOffLeft = loadImage("img/KickOffLeft.png"); + goalKickLeft = loadImage("img/GoalKickLeft.png"); + throwInLeft = loadImage("img/ThrowInLeft.png"); + freeKickLeft = loadImage("img/FreeKickLeft.png"); + cornerKickLeft = loadImage("img/CornerKickLeft.png"); + penaltyKickLeft = loadImage("img/PenaltyLeft.png"); + kickOffRight = loadImage("img/KickOffRight.png"); + throwInRight = loadImage("img/ThrowInRight.png"); + goalKickRight = loadImage("img/GoalKickRight.png"); + freeKickRight = loadImage("img/FreeKickRight.png"); + cornerKickRight = loadImage("img/CornerKickRight.png"); + penaltyKickRight = loadImage("img/PenaltyRight.png"); + dropBall = loadImage("img/DropBall.png"); + isAliveLeft = loadImage("img/IsAliveLeft.png"); + isAliveRight = loadImage("img/IsAliveRight.png"); + + surface.setTitle(MSG_WINDOWTITLE); clockFont = createFont("fonts/LCDM.TTF", 64, false); scoreFont = createFont("fonts/LED.ttf", 40, false); buttonFont=loadFont("fonts/Futura-CondensedExtraBold-24.vlw"); @@ -90,6 +137,7 @@ void setup() { //============================================== //=== Modules Initialization Config.Load(this, "config.json"); // Load config file + Log.init(this); // Init Log module comms_initDescriptionDictionary(); // Initializes the dictionary for communications with the basestations @@ -152,12 +200,112 @@ void draw() { //refresh command show PImage img = null; String imageName = ""; - if(lastCommandCode.equals(COMM_STOP)) imageName = "stop"; - if(imageName.length() > 0 && new File(dataPath("img/"+imageName+".png")).exists() && (img = loadImage("img/"+imageName+".png")) != null) - { - imageMode(CENTER); - image(img, width/2, height/2 + 45, 230, 230); - }else{ + imageMode(CENTER); + textFont(teamFont, 30); + textAlign(CENTER, CENTER-5); + if(lastCommandCode.equals(COMM_STOP)){ + image(stop, width/2, height/2 + 45, 230, 230); + } + else if (lastCommandCode.equals(COMM_START)) { + image(playOn, width/2, height/2 + 45, 230, 230); + } + else if (lastCommandCode.equals(COMM_DROP_BALL)) { + image(dropBall, width/2, height/2 + 45, 230, 230); + } + else if (lastCommandCode.equals(COMM_HALF_TIME)) { + image(halfTime, width/2, height/2 + 45, 230, 230); + } + else if (lastCommandCode.equals(COMM_END_GAME)) { + image(endGame, width/2, height/2 + 45, 230, 230); + } + else if (lastCommandCode.equals(COMM_GAMEOVER)) { + image(gameOver, width/2, height/2 + 45, 230, 230); + } + else if (lastCommandCode.equals(COMM_RESET)) { + image(preGame, width/2, height/2 + 45, 230, 230); + } + else if (lastCommandCode.equals(COMM_KICKOFF)) { + if (teamA.longName.equals(lastCommandTeam)){ //<>// + image(kickOffLeft, width/2, height/2 + 25, 230, 230); //<>// + } + else { + image(kickOffRight, width/2, height/2 + 25, 230, 230); + } + text(lastCommandTeam, width/2, height/2 + 175); + } + else if (lastCommandCode.equals(COMM_FREEKICK)) { + if (teamA.longName.equals(lastCommandTeam)){ //<>// + image(freeKickLeft, width/2, height/2 + 25, 230, 230); //<>// + } + else { + image(freeKickRight, width/2, height/2 + 25, 230, 230); + } + text(lastCommandTeam, width/2, height/2 + 175); + } + else if (lastCommandCode.equals(COMM_GOALKICK)) { + if (teamA.longName.equals(lastCommandTeam)){ //<>// + image(goalKickLeft, width/2, height/2 + 25, 230, 230); //<>// + } + else { + image(goalKickRight, width/2, height/2 + 25, 230, 230); + } + text(lastCommandTeam, width/2, height/2 + 175); + } + else if (lastCommandCode.equals(COMM_THROWIN)) { + if (teamA.longName.equals(lastCommandTeam)){ //<>// + image(throwInLeft, width/2, height/2 + 25, 230, 230); //<>// + } + else { + image(throwInRight, width/2, height/2 + 25, 230, 230); + } + text(lastCommandTeam, width/2, height/2 + 175); + } + else if (lastCommandCode.equals(COMM_CORNER)) { + if (teamA.longName.equals(lastCommandTeam)){ //<>// + image(cornerKickLeft, width/2, height/2 + 25, 230, 230); //<>// + } + else { + image(cornerKickRight, width/2, height/2 + 25, 230, 230); + } + text(lastCommandTeam, width/2, height/2 + 175); + } + else if (lastCommandCode.equals(COMM_PENALTY)) { + if (teamA.longName.equals(lastCommandTeam)){ //<>// + image(penaltyKickLeft, width/2, height/2 + 25, 230, 230); //<>// + } + else { + image(penaltyKickRight, width/2, height/2 + 25, 230, 230); + } + text(lastCommandTeam, width/2, height/2 + 175); + } + else if (lastCommandCode.equals(COMM_SUBSTITUTION)) { + if (teamA.longName.equals(lastCommandTeam)){ //<>// + image(substitutionLeft, width/2, height/2 + 25, 230, 230); //<>// + } + else { + image(substitutionRight, width/2, height/2 + 25, 230, 230); + } + text("ID: "+ lastRobotID, width/2, height/2 + 175); + } + else if (lastCommandCode.equals(COMM_ISALIVE)) { + if (teamA.longName.equals(lastCommandTeam)){ //<>// + image(isAliveLeft, width/2, height/2 + 25, 230, 230); + } + else { + image(isAliveRight, width/2, height/2 + 25, 230, 230); + } + text("ID: "+ lastRobotID, width/2, height/2 + 175); + + } +/* + Description.set(COMM_WELCOME, "Welcome"); + Description.set(COMM_FIRST_HALF, "1st half"); + Description.set(COMM_SECOND_HALF, "2nd half"); + Description.set(COMM_FIRST_HALF_OVERTIME, "Overtime 1st half"); + Description.set(COMM_SECOND_HALF_OVERTIME, "Overtime 2nd half"); + Description.set(COMM_PARK, "Park"); +*/ + else{ fill(#E0F000); String description = lastCommandDescription; if(description.contains("START")) @@ -171,14 +319,15 @@ void draw() { textAlign(CENTER, CENTER); text(description, width/2, height/2 + 10); //team dest command - textFont(teamFont, 35); + + textFont(teamFont, 30); textAlign(CENTER, CENTER-5); text(lastCommandTeam, width/2, height/2 + 100); if(lastRobotID != -1) { text("ID: "+ lastRobotID, width/2, height/2 + 150); } - } + } } //receive message and get from json important information for referee Client diff --git a/RefereeClient/data/config.json b/RefereeClient/data/config.json index 6dcb1a3..247ea13 100644 --- a/RefereeClient/data/config.json +++ b/RefereeClient/data/config.json @@ -13,10 +13,10 @@ "robotDoubleYellowCardColor": "#707000", "robotRedCardColor": "#E01010", "defaultCyanTeamShortName": "***", - "defaultCyanTeamLongName": "Disconnected", + "defaultCyanTeamLongName": "TeamA Disconnected", "defaultCyanTeamColor": "#007BA7", "defaultMagentaTeamShortName": "***", - "defaultMagentaTeamLongName": "Disconnected", + "defaultMagentaTeamLongName": "TeamB Disconnected", "defaultMagentaTeamColor": "#DA70D6" } } diff --git a/RefereeClient/data/img/CornerKickLeft.png b/RefereeClient/data/img/CornerKickLeft.png new file mode 100644 index 0000000..a3b0f2b Binary files /dev/null and b/RefereeClient/data/img/CornerKickLeft.png differ diff --git a/RefereeClient/data/img/CornerKickRight.png b/RefereeClient/data/img/CornerKickRight.png new file mode 100644 index 0000000..0a0a69b Binary files /dev/null and b/RefereeClient/data/img/CornerKickRight.png differ diff --git a/RefereeClient/data/img/DropBall.png b/RefereeClient/data/img/DropBall.png new file mode 100644 index 0000000..6cd2cde Binary files /dev/null and b/RefereeClient/data/img/DropBall.png differ diff --git a/RefereeClient/data/img/EndGame.png b/RefereeClient/data/img/EndGame.png new file mode 100644 index 0000000..b37ffb0 Binary files /dev/null and b/RefereeClient/data/img/EndGame.png differ diff --git a/RefereeClient/data/img/FreeKickLeft.png b/RefereeClient/data/img/FreeKickLeft.png new file mode 100644 index 0000000..ce48dfc Binary files /dev/null and b/RefereeClient/data/img/FreeKickLeft.png differ diff --git a/RefereeClient/data/img/FreeKickRight.png b/RefereeClient/data/img/FreeKickRight.png new file mode 100644 index 0000000..59ddb2f Binary files /dev/null and b/RefereeClient/data/img/FreeKickRight.png differ diff --git a/RefereeClient/data/img/GameOver.png b/RefereeClient/data/img/GameOver.png new file mode 100644 index 0000000..788c6fa Binary files /dev/null and b/RefereeClient/data/img/GameOver.png differ diff --git a/RefereeClient/data/img/GoalKickLeft.png b/RefereeClient/data/img/GoalKickLeft.png new file mode 100644 index 0000000..59838b9 Binary files /dev/null and b/RefereeClient/data/img/GoalKickLeft.png differ diff --git a/RefereeClient/data/img/GoalKickRight.png b/RefereeClient/data/img/GoalKickRight.png new file mode 100644 index 0000000..7663f1b Binary files /dev/null and b/RefereeClient/data/img/GoalKickRight.png differ diff --git a/RefereeClient/data/img/HalfTime.png b/RefereeClient/data/img/HalfTime.png new file mode 100644 index 0000000..985f360 Binary files /dev/null and b/RefereeClient/data/img/HalfTime.png differ diff --git a/RefereeClient/data/img/IsAliveLeft.png b/RefereeClient/data/img/IsAliveLeft.png new file mode 100644 index 0000000..92ef3bc Binary files /dev/null and b/RefereeClient/data/img/IsAliveLeft.png differ diff --git a/RefereeClient/data/img/IsAliveRight.png b/RefereeClient/data/img/IsAliveRight.png new file mode 100644 index 0000000..92b5561 Binary files /dev/null and b/RefereeClient/data/img/IsAliveRight.png differ diff --git a/RefereeClient/data/img/KickOffLeft.png b/RefereeClient/data/img/KickOffLeft.png new file mode 100644 index 0000000..5171e42 Binary files /dev/null and b/RefereeClient/data/img/KickOffLeft.png differ diff --git a/RefereeClient/data/img/KickOffRight.png b/RefereeClient/data/img/KickOffRight.png new file mode 100644 index 0000000..0a1286f Binary files /dev/null and b/RefereeClient/data/img/KickOffRight.png differ diff --git a/RefereeClient/data/img/PenaltyLeft.png b/RefereeClient/data/img/PenaltyLeft.png new file mode 100644 index 0000000..4135959 Binary files /dev/null and b/RefereeClient/data/img/PenaltyLeft.png differ diff --git a/RefereeClient/data/img/PenaltyRight.png b/RefereeClient/data/img/PenaltyRight.png new file mode 100644 index 0000000..e063d66 Binary files /dev/null and b/RefereeClient/data/img/PenaltyRight.png differ diff --git a/RefereeClient/data/img/PlayOn.png b/RefereeClient/data/img/PlayOn.png new file mode 100644 index 0000000..f923d9b Binary files /dev/null and b/RefereeClient/data/img/PlayOn.png differ diff --git a/RefereeClient/data/img/PreGame.png b/RefereeClient/data/img/PreGame.png new file mode 100644 index 0000000..2c48be7 Binary files /dev/null and b/RefereeClient/data/img/PreGame.png differ diff --git a/RefereeClient/data/img/SubstitutionLeft.png b/RefereeClient/data/img/SubstitutionLeft.png new file mode 100644 index 0000000..2b16877 Binary files /dev/null and b/RefereeClient/data/img/SubstitutionLeft.png differ diff --git a/RefereeClient/data/img/SubstitutionRight.png b/RefereeClient/data/img/SubstitutionRight.png new file mode 100644 index 0000000..400fa7a Binary files /dev/null and b/RefereeClient/data/img/SubstitutionRight.png differ diff --git a/RefereeClient/data/img/ThrowInLeft.png b/RefereeClient/data/img/ThrowInLeft.png new file mode 100644 index 0000000..301f333 Binary files /dev/null and b/RefereeClient/data/img/ThrowInLeft.png differ diff --git a/RefereeClient/data/img/ThrowInRight.png b/RefereeClient/data/img/ThrowInRight.png new file mode 100644 index 0000000..f1e4f1b Binary files /dev/null and b/RefereeClient/data/img/ThrowInRight.png differ diff --git a/mslrb2015/Button.pde b/mslrb2015/Button.pde index ff9c783..0be04a6 100644 --- a/mslrb2015/Button.pde +++ b/mslrb2015/Button.pde @@ -303,7 +303,7 @@ void buttonEvent(char group, int pos) { // Special cases, that send only event message on game change (flags) if( clickedButton.isYellow() || clickedButton.isRed() || clickedButton.isRepair() || clickedButton.isConfig() || - clickedButton.isEndPart() || clickedButton.isReset() || clickedButton.isAlive()) + clickedButton.isEndPart() || clickedButton.isReset() || clickedButton.isAlive() || clickedButton.isSubs()) { // Do literally nothing... }else{ diff --git a/mslrb2015/RefreshButon.pde b/mslrb2015/RefreshButon.pde index f3ffe43..f1953a7 100644 --- a/mslrb2015/RefreshButon.pde +++ b/mslrb2015/RefreshButon.pde @@ -3,149 +3,150 @@ void RefreshButonStatus1() { switch(StateMachine.GetCurrentGameState()) { - // PRE-GAME - case GS_PREGAME: - if (Popup.isEnabled() && (Popup.getType() == PopupTypeEnum.POPUP_WAIT)) Popup.close(); - - buttonAdisableAll(0); //team A commands - buttonBdisableAll(0); //team B commands - buttonCdisable(); //common commands - - if(StateMachine.setpiece) - { - if(StateMachine.setpiece_left){ - buttonFromEnum(ButtonsEnum.BTN_L_KICKOFF).activate(); - buttonFromEnum(ButtonsEnum.BTN_R_KICKOFF).disable(); + // PRE-GAME + case GS_PREGAME: + if (Popup.isEnabled() && (Popup.getType() == PopupTypeEnum.POPUP_WAIT)) Popup.close(); + + buttonAdisableAll(0); //team A commands + buttonBdisableAll(0); //team B commands + buttonCdisable(); //common commands + + if(StateMachine.setpiece) + { + if(StateMachine.setpiece_left){ + buttonFromEnum(ButtonsEnum.BTN_L_KICKOFF).activate(); + buttonFromEnum(ButtonsEnum.BTN_R_KICKOFF).disable(); + + }else{ + buttonFromEnum(ButtonsEnum.BTN_L_KICKOFF).disable(); + buttonFromEnum(ButtonsEnum.BTN_R_KICKOFF).activate(); + } + + buttonFromEnum(ButtonsEnum.BTN_RESET).disable(); + buttonFromEnum(ButtonsEnum.BTN_START).enable(); + buttonFromEnum(ButtonsEnum.BTN_STOP).activate(); + buttonFromEnum(ButtonsEnum.BTN_CONFIG).disable(); }else{ - buttonFromEnum(ButtonsEnum.BTN_L_KICKOFF).disable(); - buttonFromEnum(ButtonsEnum.BTN_R_KICKOFF).activate(); - } - - buttonFromEnum(ButtonsEnum.BTN_RESET).disable(); - buttonFromEnum(ButtonsEnum.BTN_START).enable(); - buttonFromEnum(ButtonsEnum.BTN_STOP).activate(); - buttonFromEnum(ButtonsEnum.BTN_CONFIG).disable(); - }else{ + buttonFromEnum(ButtonsEnum.BTN_L_KICKOFF).enable(); + buttonFromEnum(ButtonsEnum.BTN_R_KICKOFF).enable(); - buttonFromEnum(ButtonsEnum.BTN_L_KICKOFF).enable(); - buttonFromEnum(ButtonsEnum.BTN_R_KICKOFF).enable(); + buttonFromEnum(ButtonsEnum.BTN_START).disable(); + buttonFromEnum(ButtonsEnum.BTN_STOP).activate(); + buttonFromEnum(ButtonsEnum.BTN_RESET).activate(); + buttonFromEnum(ButtonsEnum.BTN_CONFIG).activate(); + } + - buttonFromEnum(ButtonsEnum.BTN_START).disable(); - buttonFromEnum(ButtonsEnum.BTN_STOP).activate(); - buttonFromEnum(ButtonsEnum.BTN_RESET).activate(); - buttonFromEnum(ButtonsEnum.BTN_CONFIG).activate(); - } - + break; + + case GS_GAMEON_H1: + case GS_GAMEON_H2: + case GS_GAMEON_H3: + case GS_GAMEON_H4: + refreshbutton_game_on(); + break; + + case GS_GAMESTOP_H1: + case GS_GAMESTOP_H2: + case GS_GAMESTOP_H3: + case GS_GAMESTOP_H4: + refreshbutton_game_stopped(); + if(StateMachine.setpiece){ + buttonAdisable(); //team A commands + buttonBdisable(); //team B commands + buttonCdisable(); //common commands + buttonFromEnum(StateMachine.setpiece_button).activate(); + buttonFromEnum(ButtonsEnum.BTN_START).enable(); + buttonFromEnum(ButtonsEnum.BTN_PARK).disable(); + }else{ + buttonFromEnum(ButtonsEnum.BTN_START).disable(); + } + break; + + case GS_HALFTIME: + case GS_OVERTIME: + case GS_HALFTIME_OVERTIME: + buttonAdisableAll(0); //team A commands + buttonBdisableAll(0); //team B commands + buttonCdisable(); //common commands + bTeamAcmds[CMDID_TEAM_GOAL].disable(); // Disable goal button if part ended with a goal + bTeamBcmds[CMDID_TEAM_GOAL].disable(); // Disable goal button if part ended with a goal + + if (StateMachine.GetCurrentGameState() == GameStateEnum.GS_OVERTIME){ + buttonFromEnum(ButtonsEnum.BTN_ENDPART).enable(); + } + + // Alternate Kick-Offs + boolean enableLeft = StateMachine.firstKickoffLeft; + if(StateMachine.GetCurrentGameState() == GameStateEnum.GS_HALFTIME || StateMachine.GetCurrentGameState() == GameStateEnum.GS_HALFTIME_OVERTIME) + enableLeft = !enableLeft; - break; - - case GS_GAMEON_H1: - case GS_GAMEON_H2: - case GS_GAMEON_H3: - case GS_GAMEON_H4: - refreshbutton_game_on(); - break; - - case GS_GAMESTOP_H1: - case GS_GAMESTOP_H2: - case GS_GAMESTOP_H3: - case GS_GAMESTOP_H4: - refreshbutton_game_stopped(); - if(StateMachine.setpiece){ + if(StateMachine.setpiece) + { + buttonFromEnum(StateMachine.setpiece_button).activate(); + buttonFromEnum(ButtonsEnum.BTN_START).enable(); + buttonFromEnum(ButtonsEnum.BTN_STOP).activate(); + buttonFromEnum(ButtonsEnum.BTN_PARK).disable(); + buttonFromEnum(ButtonsEnum.BTN_RESET).disable(); + }else{ + if(enableLeft) + { + buttonFromEnum(ButtonsEnum.BTN_L_KICKOFF).enable(); + buttonFromEnum(ButtonsEnum.BTN_R_KICKOFF).disable(); + }else{ + buttonFromEnum(ButtonsEnum.BTN_L_KICKOFF).disable(); + buttonFromEnum(ButtonsEnum.BTN_R_KICKOFF).enable(); + } + buttonFromEnum(ButtonsEnum.BTN_START).disable(); + buttonFromEnum(ButtonsEnum.BTN_STOP).activate(); + buttonFromEnum(ButtonsEnum.BTN_PARK).activate(); + if(StateMachine.GetCurrentGameState() == GameStateEnum.GS_OVERTIME) + buttonFromEnum(ButtonsEnum.BTN_RESET).activate(); + } + break; + + case GS_PENALTIES: + refreshbutton_game_stopped(); buttonAdisable(); //team A commands buttonBdisable(); //team B commands buttonCdisable(); //common commands - buttonFromEnum(StateMachine.setpiece_button).activate(); - buttonFromEnum(ButtonsEnum.BTN_START).enable(); - buttonFromEnum(ButtonsEnum.BTN_PARK).disable(); - }else{ - buttonFromEnum(ButtonsEnum.BTN_START).disable(); - } - break; - - case GS_HALFTIME: - case GS_OVERTIME: - case GS_HALFTIME_OVERTIME: - buttonAdisableAll(0); //team A commands - buttonBdisableAll(0); //team B commands - buttonCdisable(); //common commands - bTeamAcmds[CMDID_TEAM_GOAL].disable(); // Disable goal button if part ended with a goal - bTeamBcmds[CMDID_TEAM_GOAL].disable(); // Disable goal button if part ended with a goal - - // Alternate Kick-Offs - boolean enableLeft = StateMachine.firstKickoffLeft; - if(StateMachine.GetCurrentGameState() == GameStateEnum.GS_HALFTIME || StateMachine.GetCurrentGameState() == GameStateEnum.GS_HALFTIME_OVERTIME) - enableLeft = !enableLeft; - - if(StateMachine.setpiece) - { + + bTeamAcmds[CMDID_TEAM_PENALTY].enable(); + bTeamBcmds[CMDID_TEAM_PENALTY].enable(); + + if(StateMachine.setpiece) buttonFromEnum(StateMachine.setpiece_button).activate(); buttonFromEnum(ButtonsEnum.BTN_START).enable(); buttonFromEnum(ButtonsEnum.BTN_STOP).activate(); buttonFromEnum(ButtonsEnum.BTN_PARK).disable(); buttonFromEnum(ButtonsEnum.BTN_RESET).disable(); - }else{ - if(enableLeft) - { - buttonFromEnum(ButtonsEnum.BTN_L_KICKOFF).enable(); - buttonFromEnum(ButtonsEnum.BTN_R_KICKOFF).disable(); - }else{ - buttonFromEnum(ButtonsEnum.BTN_L_KICKOFF).disable(); - buttonFromEnum(ButtonsEnum.BTN_R_KICKOFF).enable(); - } - buttonFromEnum(ButtonsEnum.BTN_START).disable(); - buttonFromEnum(ButtonsEnum.BTN_STOP).activate(); - buttonFromEnum(ButtonsEnum.BTN_PARK).activate(); - if(StateMachine.GetCurrentGameState() == GameStateEnum.GS_OVERTIME) - buttonFromEnum(ButtonsEnum.BTN_RESET).activate(); - } - break; - - case GS_PENALTIES: - refreshbutton_game_stopped(); - buttonAdisable(); //team A commands - buttonBdisable(); //team B commands - buttonCdisable(); //common commands - - bTeamAcmds[CMDID_TEAM_PENALTY].enable(); - bTeamBcmds[CMDID_TEAM_PENALTY].enable(); - - if(StateMachine.setpiece) - buttonFromEnum(StateMachine.setpiece_button).activate(); - buttonFromEnum(ButtonsEnum.BTN_START).enable(); - buttonFromEnum(ButtonsEnum.BTN_STOP).activate(); - buttonFromEnum(ButtonsEnum.BTN_PARK).disable(); - buttonFromEnum(ButtonsEnum.BTN_RESET).disable(); - bCommoncmds[CMDID_COMMON_DROP_BALL].disable(); - bCommoncmds[CMDID_COMMON_HALFTIME].enable(); - break; - - case GS_PENALTIES_ON: - refreshbutton_game_on(); - break; - - case GS_ENDGAME: - buttonAdisable(); //team A commands - buttonBdisable(); //team B commands - buttonCenable(); //common commands - - bCommoncmds[CMDID_COMMON_DROP_BALL].disable(); - bCommoncmds[CMDID_COMMON_HALFTIME].disable(); - bCommoncmds[CMDID_COMMON_RESET].activate(); - bCommoncmds[CMDID_COMMON_PARKING].activate(); - buttonCSTARTdisable(); - buttonCSTOPactivate(); - break; - - default: - buttonAenable(); //team A commands - buttonBenable(); //team B commands - buttonCenable(); //common commands - buttonCSTOPactivate(); - break; + bCommoncmds[CMDID_COMMON_DROP_BALL].disable(); + bCommoncmds[CMDID_COMMON_HALFTIME].enable(); + break; + + case GS_PENALTIES_ON: + refreshbutton_game_on(); + break; + + case GS_ENDGAME: + buttonAdisableAll(-1); //disabke team A commands + buttonBdisableAll(-1); //disable team B commands + buttonCdisable(); //disable common commands + bCommoncmds[CMDID_COMMON_RESET].activate(); + bCommoncmds[CMDID_COMMON_PARKING].activate(); + buttonCSTARTdisable(); + buttonCSTOPactivate(); + break; + + default: + buttonAenable(); //team A commands + buttonBenable(); //team B commands + buttonCenable(); //common commands + buttonCSTOPactivate(); + break; } @@ -162,6 +163,7 @@ void RefreshButonStatus1() { } // Update End Part / End Game button + String endPartOrEndGame = "End Part"; switch(StateMachine.GetCurrentGameState()) { @@ -171,7 +173,13 @@ void RefreshButonStatus1() { case GS_GAMESTOP_H2: case GS_GAMESTOP_H4: endPartOrEndGame = "End Game"; + break; + case GS_PENALTIES: + case GS_OVERTIME: + endPartOrEndGame = "Game Over"; + break; } + bCommoncmds[CMDID_COMMON_HALFTIME].Label = endPartOrEndGame; } diff --git a/mslrb2015/RefreshButon5408860871915498609.autosave b/mslrb2015/RefreshButon5408860871915498609.autosave new file mode 100644 index 0000000..42527ba --- /dev/null +++ b/mslrb2015/RefreshButon5408860871915498609.autosave @@ -0,0 +1,379 @@ +//********************************************************************* +void RefreshButonStatus1() { + + switch(StateMachine.GetCurrentGameState()) + { + // PRE-GAME + case GS_PREGAME: + if (Popup.isEnabled() && (Popup.getType() == PopupTypeEnum.POPUP_WAIT)) Popup.close(); + + buttonAdisableAll(0); //team A commands + buttonBdisableAll(0); //team B commands + buttonCdisable(); //common commands + + if(StateMachine.setpiece) + { + if(StateMachine.setpiece_left){ + buttonFromEnum(ButtonsEnum.BTN_L_KICKOFF).activate(); + buttonFromEnum(ButtonsEnum.BTN_R_KICKOFF).disable(); + + }else{ + buttonFromEnum(ButtonsEnum.BTN_L_KICKOFF).disable(); + buttonFromEnum(ButtonsEnum.BTN_R_KICKOFF).activate(); + } + + buttonFromEnum(ButtonsEnum.BTN_RESET).disable(); + buttonFromEnum(ButtonsEnum.BTN_START).enable(); + buttonFromEnum(ButtonsEnum.BTN_STOP).activate(); + buttonFromEnum(ButtonsEnum.BTN_CONFIG).disable(); + + }else{ + + buttonFromEnum(ButtonsEnum.BTN_L_KICKOFF).enable(); + buttonFromEnum(ButtonsEnum.BTN_R_KICKOFF).enable(); + + buttonFromEnum(ButtonsEnum.BTN_START).disable(); + buttonFromEnum(ButtonsEnum.BTN_STOP).activate(); + buttonFromEnum(ButtonsEnum.BTN_RESET).activate(); + buttonFromEnum(ButtonsEnum.BTN_CONFIG).activate(); + } + + + break; + + case GS_GAMEON_H1: + case GS_GAMEON_H2: + case GS_GAMEON_H3: + case GS_GAMEON_H4: + refreshbutton_game_on(); + break; + + case GS_GAMESTOP_H1: + case GS_GAMESTOP_H2: + case GS_GAMESTOP_H3: + case GS_GAMESTOP_H4: + refreshbutton_game_stopped(); + if(StateMachine.setpiece){ + buttonAdisable(); //team A commands + buttonBdisable(); //team B commands + buttonCdisable(); //common commands + buttonFromEnum(StateMachine.setpiece_button).activate(); + buttonFromEnum(ButtonsEnum.BTN_START).enable(); + buttonFromEnum(ButtonsEnum.BTN_PARK).disable(); + }else{ + buttonFromEnum(ButtonsEnum.BTN_START).disable(); + } + break; + + case GS_HALFTIME: + case GS_OVERTIME: + case GS_HALFTIME_OVERTIME: + buttonAdisableAll(0); //team A commands + buttonBdisableAll(0); //team B commands + buttonCdisable(); //common commands + bTeamAcmds[CMDID_TEAM_GOAL].disable(); // Disable goal button if part ended with a goal + bTeamBcmds[CMDID_TEAM_GOAL].disable(); // Disable goal button if part ended with a goal + + if (StateMachine.GetCurrentGameState() == GameStateEnum.GS_OVERTIME){ + buttonFromEnum(ButtonsEnum.BTN_ENDPART).enable(); + } + + // Alternate Kick-Offs + boolean enableLeft = StateMachine.firstKickoffLeft; + if(StateMachine.GetCurrentGameState() == GameStateEnum.GS_HALFTIME || StateMachine.GetCurrentGameState() == GameStateEnum.GS_HALFTIME_OVERTIME) + enableLeft = !enableLeft; + + if(StateMachine.setpiece) + { + buttonFromEnum(StateMachine.setpiece_button).activate(); + buttonFromEnum(ButtonsEnum.BTN_START).enable(); + buttonFromEnum(ButtonsEnum.BTN_STOP).activate(); + buttonFromEnum(ButtonsEnum.BTN_PARK).disable(); + buttonFromEnum(ButtonsEnum.BTN_RESET).disable(); + }else{ + if(enableLeft) + { + buttonFromEnum(ButtonsEnum.BTN_L_KICKOFF).enable(); + buttonFromEnum(ButtonsEnum.BTN_R_KICKOFF).disable(); + }else{ + buttonFromEnum(ButtonsEnum.BTN_L_KICKOFF).disable(); + buttonFromEnum(ButtonsEnum.BTN_R_KICKOFF).enable(); + } + buttonFromEnum(ButtonsEnum.BTN_START).disable(); + buttonFromEnum(ButtonsEnum.BTN_STOP).activate(); + buttonFromEnum(ButtonsEnum.BTN_PARK).activate(); + if(StateMachine.GetCurrentGameState() == GameStateEnum.GS_OVERTIME) + buttonFromEnum(ButtonsEnum.BTN_RESET).activate(); + } + break; + + case GS_PENALTIES: + refreshbutton_game_stopped(); + buttonAdisable(); //team A commands + buttonBdisable(); //team B commands + buttonCdisable(); //common commands + + bTeamAcmds[CMDID_TEAM_PENALTY].enable(); + bTeamBcmds[CMDID_TEAM_PENALTY].enable(); + + if(StateMachine.setpiece) + buttonFromEnum(StateMachine.setpiece_button).activate(); + buttonFromEnum(ButtonsEnum.BTN_START).enable(); + buttonFromEnum(ButtonsEnum.BTN_STOP).activate(); + buttonFromEnum(ButtonsEnum.BTN_PARK).disable(); + buttonFromEnum(ButtonsEnum.BTN_RESET).disable(); + + bCommoncmds[CMDID_COMMON_DROP_BALL].disable(); + bCommoncmds[CMDID_COMMON_HALFTIME].enable(); + break; + + case GS_PENALTIES_ON: + refreshbutton_game_on(); + break; + + case GS_ENDGAME: + buttonAdisableAll(0); //team A commands + buttonBdisableAll(0); //team B commands + buttonCdisable(); //common commands + +// bCommoncmds[CMDID_COMMON_DROP_BALL].disable(); +// bCommoncmds[CMDID_COMMON_SUBS].disable(); +// bCommoncmds[CMDID_COMMON_HALFTIME].disable(); +// bCommoncmds[CMDID_COMMON_CONFIG].disable(); + + bCommoncmds[CMDID_COMMON_RESET].activate(); + bCommoncmds[CMDID_COMMON_PARKING].activate(); + buttonCSTARTdisable(); + buttonCSTOPactivate(); + break; + + default: + buttonAenable(); //team A commands + buttonBenable(); //team B commands + buttonCenable(); //common commands + buttonCSTOPactivate(); + break; + + } + + // The switches are enabled only on pre-game + if(StateMachine.GetCurrentGameState() != GameStateEnum.GS_PREGAME) + { + for(int i = 0; i < bSlider.length; i++) { + //bSlider[i].disable(); + } + }else{ + for(int i = 0; i < bSlider.length; i++) { + //bSlider[i].enable(); + } + } + + // Update End Part / End Game button + + String endPartOrEndGame = "End Part"; + switch(StateMachine.GetCurrentGameState()) + { + case GS_HALFTIME: + case GS_GAMEON_H2: + case GS_GAMEON_H4: + case GS_GAMESTOP_H2: + case GS_GAMESTOP_H4: + endPartOrEndGame = "End Game"; + break; + case GS_PENALTIES: + case GS_OVERTIME: + endPartOrEndGame = "Game Over"; + break; + } + + bCommoncmds[CMDID_COMMON_HALFTIME].Label = endPartOrEndGame; +} + +//********************************************************************* +// Start button has been pressed and game is now ON +void refreshbutton_game_on() +{ + buttondisableAll(); + buttonCSTARTdisable(); + buttonCSTOPactivate(); +} + +//********************************************************************* +// +void refreshbutton_game_stopped() +{ + if(bTeamAcmds[CMDID_TEAM_GOAL].isActive()) { + buttonAdisable(); + buttonBdisable(); + buttonCdisable(); + bTeamBcmds[CMDID_TEAM_KICKOFF].enable(); + bTeamBcmds[CMDID_TEAM_GOAL].disable(); + bCommoncmds[CMDID_COMMON_HALFTIME].enable(); + } + else if(bTeamBcmds[CMDID_TEAM_GOAL].isActive()) { + buttonAdisable(); + buttonBdisable(); + buttonCdisable(); + bTeamAcmds[CMDID_TEAM_KICKOFF].enable(); + bTeamAcmds[CMDID_TEAM_GOAL].disable(); + bCommoncmds[CMDID_COMMON_HALFTIME].enable(); + } + else { + if(!StateMachine.setpiece) { + buttonA_setpieces_en(); //team A commands + buttonB_setpieces_en(); //team B commands + + bCommoncmds[CMDID_COMMON_DROP_BALL].enable(); + bCommoncmds[CMDID_COMMON_HALFTIME].enable(); + bCommoncmds[CMDID_COMMON_PARKING].disable(); + bCommoncmds[CMDID_COMMON_RESET].disable(); + bTeamAcmds[CMDID_TEAM_GOAL].enable(); + bTeamBcmds[CMDID_TEAM_GOAL].enable(); + bCommoncmds[CMDID_COMMON_SUBS].enable(); + buttonCSTARTdisable(); // Turn OFF START button + } + else + { + bTeamAcmds[CMDID_TEAM_GOAL].disable(); + bTeamBcmds[CMDID_TEAM_GOAL].disable(); + } + + for(int i = CMDID_TEAM_REPAIR_OUT; i <= CMDID_TEAM_YELLOWCARD; i++) + { + if(!bTeamAcmds[i].isActive()) + bTeamAcmds[i].enable(); + + if(!bTeamBcmds[i].isActive()) + bTeamBcmds[i].enable(); + } + } + buttonCSTOPactivate(); // Turn ON STOP button + + if (teamA.numberOfPlayingRobots() < 3) bTeamAcmds[CMDID_TEAM_REPAIR_OUT].disable(); + if (teamB.numberOfPlayingRobots() < 3) bTeamBcmds[CMDID_TEAM_REPAIR_OUT].disable(); +} + +// ============================ + +//********************************************************************* +void buttonA_setpieces_en() +{ + for (int i=CMDID_TEAM_FREEKICK; i <= CMDID_TEAM_ISALIVE; i++) + bTeamAcmds[i].enable(); + if (forceKickoff == true) + bTeamAcmds[CMDID_TEAM_KICKOFF].enable(); + else + bTeamAcmds[CMDID_TEAM_KICKOFF].disable(); +} + +//********************************************************************* +void buttonB_setpieces_en() +{ + for (int i=CMDID_TEAM_FREEKICK; i <= CMDID_TEAM_ISALIVE; i++) + bTeamBcmds[i].enable(); + if (forceKickoff == true) + bTeamBcmds[CMDID_TEAM_KICKOFF].enable(); + else + bTeamBcmds[CMDID_TEAM_KICKOFF].disable(); +} + +//********************************************************************* +void buttonAenable() { + for (int i=0; i6 && bTeamAcmds[i].isActive()) ; //maintains goals+repair+cards + else bTeamAcmds[i].enable(); + } +} +//********************************************************************* +void buttonBenable() { + for (int i=0; i6 && bTeamBcmds[i].isActive()) ; //maintains repair+cards + else bTeamBcmds[i].enable(); + } +} + +//********************************************************************* +void buttonCenable() { + for (int i=2; i// //<>// + ResetSetpiece(); //<>// //<>// if(btnCurrent.isStop()){ SetPieceDelay.resetStopWatch(); SetPieceDelay.stopTimer(); @@ -466,7 +484,7 @@ static class StateMachine case GS_PENALTIES: return GameStateEnum.GS_ENDGAME; } - return null; + return gsCurrent; } //************************************************************************ @@ -493,9 +511,10 @@ static class StateMachine case GS_HALFTIME_OVERTIME: case GS_GAMESTOP_H4: return GameStateEnum.GS_GAMEON_H4; - - case GS_PENALTIES: return GameStateEnum.GS_PENALTIES_ON; - case GS_PENALTIES_ON: return GameStateEnum.GS_PENALTIES; + case GS_PENALTIES: + return GameStateEnum.GS_PENALTIES_ON; + case GS_PENALTIES_ON: + return GameStateEnum.GS_PENALTIES; } return null; diff --git a/mslrb2015/data/config.json b/mslrb2015/data/config.json index 789bacf..904ef77 100644 --- a/mslrb2015/data/config.json +++ b/mslrb2015/data/config.json @@ -29,11 +29,11 @@ "robotRedCardColor": "#FF0000", "defaultLeftTeamShortName": "TeamA", "defaultLeftTeamLongName": "TeamA Disconnected", - "defaultLeftTeam": "TeamA N.C.", + "defaultLeftTeam": "TeamA Disconnected", "defaultLeftTeamColor": "#007BA7", "defaultRightTeamShortName": "TeamB", "defaultRightTeamLongName": "TeamB Disconnected", - "defaultRightTeam": "TeamB N.C.", + "defaultRightTeam": "TeamB Disconnected", "defaultRightTeamColor": "#C240BC" }, "sounds": diff --git a/mslrb2015/enums.java b/mslrb2015/enums.java index 57504e1..e8b70e7 100644 --- a/mslrb2015/enums.java +++ b/mslrb2015/enums.java @@ -172,13 +172,13 @@ enum GameStateEnum GS_GAMESTOP_H3(7), // Game stopped during first half of overtime GS_GAMEON_H3(8), // Game on during first half of overtime - GS_HALFTIME_OVERTIME(9), // First half time of oertime + GS_HALFTIME_OVERTIME(9), // First half time of overtime GS_GAMESTOP_H4(10), // Game stopped during second half of overtime GS_GAMEON_H4(11), // Game on during second half of overtime - GS_PENALTIES(12), // Penalties period on mbc???? - GS_PENALTIES_ON(13), // Penalties period on mbc???? + GS_PENALTIES(12), // Penalties shoot out period on - setpiece OFF + GS_PENALTIES_ON(13), // Penalties shoot out period on - setpiece ON GS_ENDGAME(14), // Game over GS_FORCE_ENDGAME(15), // Game over GS_RESET(16), // Reset Game diff --git a/mslrb2015/gui.pde b/mslrb2015/gui.pde new file mode 100644 index 0000000..e77b741 --- /dev/null +++ b/mslrb2015/gui.pde @@ -0,0 +1,4 @@ +// gui.pde + + +