diff --git a/mslrb2015/Button.pde b/mslrb2015/Button.pde index fe08f05..2a45f6a 100644 --- a/mslrb2015/Button.pde +++ b/mslrb2015/Button.pde @@ -152,7 +152,7 @@ public static Button buttonFromEnum(ButtonsEnum btn) return null; } -void bevent(char group, int pos) { +void buttonEvent(char group, int pos) { ButtonsEnum clickedButton = null; Button clickBtn = null; @@ -192,7 +192,7 @@ void bevent(char group, int pos) { StateMachine.Update(clickedButton, btnOn); if(soundMaxTime != null && clickedButton.isStart()) - lastPlayMillis = millis(); + lastPlayMillis = mainApplet.millis(); else lastPlayMillis = 0; @@ -214,4 +214,4 @@ void bevent(char group, int pos) { } } } -} +} \ No newline at end of file diff --git a/mslrb2015/Comms.pde b/mslrb2015/Comms.pde index 08d761f..2d40306 100644 --- a/mslrb2015/Comms.pde +++ b/mslrb2015/Comms.pde @@ -2,13 +2,13 @@ public static void serverEvent(MyServer whichServer, Client whichClient) { try { if (whichServer.equals(BaseStationServer)) { - Log.logMessage("New BaseStationClient @ "+whichClient.ip()); + Log.logMessage("New BaseStation @ "+whichClient.ip()); } else if (whichServer.equals(scoreClients.scoreServer)) { Log.logMessage("New ScoreClient @ " + whichClient.ip()); } else if (mslRemote != null && mslRemote.server != null && whichServer != null && whichServer.equals(mslRemote.server)) { - Log.logMessage("New RemoteControl @ " + whichClient.ip()); + Log.logMessage("New Remote @ " + whichClient.ip()); } }catch(Exception e){} } @@ -382,11 +382,6 @@ public static final char COMM_DROPPED_BALL = 'N'; // repair Commands public static final char COMM_REPAIR_OUT_MAGENTA = 'o'; //exits field public static final char COMM_REPAIR_OUT_CYAN = 'O'; -//public static final char COMM_REPAIR_IN_MAGENTA = 'i'; -//public static final char COMM_REPAIR_IN_CYAN = 'I'; - -// public static final char COMM_CANCEL = 'x'; //not used -// public static final String COMM_RECONNECT_STRING = "Reconnect"; //not used //free: fFHlmMnqQvVxX //------------------------------------------------------ @@ -399,16 +394,15 @@ void comms_initDescriptionDictionary() { Description.set("N", "Drop Ball"); Description.set("h", "Halftime"); Description.set("e", "End Game"); - Description.set("z", "Game Over"); //NEW 2015CAMBADA - Description.set("Z", "Reset Game"); //NEW 2015CAMBADA - Description.set("W", "Welcome"); //NEW 2015CAMBADA - Description.set("w", "Request World State"); //NEW 2015CAMBADA - Description.set("U", "Test Mode on"); //NEW 2015CAMBADA ? - Description.set("u", "Test Mode off"); //NEW 2015CAMBADA ? + Description.set("z", "Game Over"); + Description.set("Z", "Reset Game"); + Description.set("W", "Welcome"); + Description.set("U", "Test Mode on"); + Description.set("u", "Test Mode off"); Description.set("1", "1st half"); Description.set("2", "2nd half"); - Description.set("3", "Overtime 1st half"); //NEW 2015CAMBADA - Description.set("4", "Overtime 2nd half"); //NEW 2015CAMBADA + Description.set("3", "Overtime 1st half"); + Description.set("4", "Overtime 2nd half"); Description.set("L", "Park"); Description.set("K", "CYAN Kickoff"); @@ -418,13 +412,11 @@ void comms_initDescriptionDictionary() { Description.set("C", "CYAN Corner"); Description.set("P", "CYAN Penalty Kick"); Description.set("A", "CYAN Goal+"); - Description.set("D", "CYAN Goal-"); + Description.set("D", "CYAN Goal-"); Description.set("O", "CYAN Repair Out"); -// Description.set("I", "CYAN Repair In"); - Description.set("R", "CYAN Red Card"); //NEW 2015CAMBADA - Description.set("Y", "CYAN Yellow Card"); //NEW 2015CAMBADA -// Description.set("J", "CYAN Double Yellow in"); //NEW 2015CAMBADA - Description.set("B","CYAN Double Yellow"); //NEW 2015CAMBADA + Description.set("R", "CYAN Red Card"); + Description.set("Y", "CYAN Yellow Card"); + Description.set("B", "CYAN Double Yellow"); Description.set("k", "MAGENTA Kickoff"); Description.set("f", "MAGENTA Freekick"); @@ -435,9 +427,7 @@ void comms_initDescriptionDictionary() { Description.set("a", "MAGENTA Goal+"); Description.set("d", "MAGENTA Goal-"); Description.set("o", "MAGENTA Repair Out"); -// Description.set("i", "MAGENTA Repair In"); - Description.set("r", "MAGENTA Red Card"); //NEW 2015CAMBADA - Description.set("y", "MAGENTA Yellow Card"); //NEW 2015CAMBADA -// Description.set("j", "MAGENTA Double Yellow in"); //NEW 2015CAMBADA - Description.set("b","MAGENTA Double Yellow"); //NEW 2015CAMBADA -} + Description.set("r", "MAGENTA Red Card"); + Description.set("y", "MAGENTA Yellow Card"); + Description.set("b", "MAGENTA Double Yellow"); +} \ No newline at end of file diff --git a/mslrb2015/MSLRemote.pde b/mslrb2015/MSLRemote.pde index f9bf1d3..cdde6f7 100644 --- a/mslrb2015/MSLRemote.pde +++ b/mslrb2015/MSLRemote.pde @@ -253,7 +253,7 @@ class MSLRemote char group = 'C'; - bevent(group, pos); + buttonEvent(group, pos); } } @@ -262,4 +262,4 @@ class MSLRemote println("Invalid JSON received from MSL Remote."); } } -} +} \ No newline at end of file diff --git a/mslrb2015/StateMachine.pde b/mslrb2015/StateMachine.pde index 69f8771..a8bd261 100644 --- a/mslrb2015/StateMachine.pde +++ b/mslrb2015/StateMachine.pde @@ -324,6 +324,9 @@ static class StateMachine public static void reset() { + try { + send_to_basestation("" + COMM_RESET); + needUpdate = false; btnCurrent = ButtonsEnum.BTN_ILLEGAL; btnPrev = ButtonsEnum.BTN_ILLEGAL; @@ -341,10 +344,9 @@ static class StateMachine Log.createLog(); - send_to_basestation("" + COMM_RESET); - BaseStationServer.stop(); BaseStationServer = new MyServer(mainApplet, Config.basestationServerPort); + } catch(Exception e) {} } public static boolean isHalf() @@ -385,55 +387,4 @@ static class StateMachine void StateMachineCheck() { StateMachine.StateMachineRefresh(); -} - -//============== -void checkpopup() { - /*if (bCommoncmds[5].isActive()) checkresetpopup(); //"RESET" - else if (bCommoncmds[4].isActive()) checkendhalfpopup(); //"ENDHALF" - else if (StateMachine.GetCurrentGameState() == GameStateEnum.GS_PREGAME) checkteampopup();*/ -} - -void checkresetpopup() { //RESET - //if (bPopup[0].isActive()) resetgame(); //popup yes - if (bPopup[0].isActive() || bPopup[1].isActive()) { - bCommoncmds[5].enable(); //reset - Popup.close(); - } - //else println("outside click..."); -} - -void checkteampopup(){ - if (bPopup[0].isActive()) { - println("cyan - " + teamselect.getString("shortname8")); - teamA.shortName=teamselect.getString("shortname8"); - teamA.longName=teamselect.getString("longame24"); - teamA.unicastIP = teamselect.getString("UnicastAddr"); - teamA.multicastIP = teamselect.getString("MulticastAddr"); - Popup.close(); - } - else if (bPopup[1].isActive()) { - println("magenta - " + teamselect.getString("shortname8")); - teamB.shortName=teamselect.getString("shortname8"); - teamB.longName=teamselect.getString("longame24"); - teamB.unicastIP = teamselect.getString("UnicastAddr"); - teamB.multicastIP = teamselect.getString("MulticastAddr"); - Popup.close(); - } - //else println("outside click..."); -} - -void checkflags() { - teamA.checkflags(); - teamB.checkflags(); -} - -void doubleyellowtimercheck() { - if (teamA.DoubleYellowCardCount>0) teamA.setDoubleYellowOutRemain(); - if (teamB.DoubleYellowCardCount>0) teamB.setDoubleYellowOutRemain(); -} - -void doubleyellowtimercheckresume() { - if (teamA.DoubleYellowCardCount>0) teamA.resumeDoubleYellowOutRemain(); - if (teamB.DoubleYellowCardCount>0) teamB.resumeDoubleYellowOutRemain(); -} +} \ No newline at end of file diff --git a/mslrb2015/SystemEvents.pde b/mslrb2015/SystemEvents.pde index 1298c80..8d52366 100644 --- a/mslrb2015/SystemEvents.pde +++ b/mslrb2015/SystemEvents.pde @@ -23,7 +23,7 @@ void mousePressed() { if (bCommoncmds[i].isEnabled()) { bCommoncmds[i].checkhover(); if (bCommoncmds[i].HOVER==true) { - bevent('C', i); + buttonEvent('C', i); break; } } @@ -34,14 +34,14 @@ void mousePressed() { if (bTeamAcmds[i].isEnabled()) { bTeamAcmds[i].checkhover(); if (bTeamAcmds[i].HOVER==true) { - bevent('A', i); + buttonEvent('A', i); break; } } if (bTeamBcmds[i].isEnabled()) { bTeamBcmds[i].checkhover(); if (bTeamBcmds[i].HOVER==true) { - bevent('B', i); + buttonEvent('B', i); break; } } @@ -84,5 +84,4 @@ void keyPressed() { Popup.close(); } -} - +} \ No newline at end of file diff --git a/mslrb2015/Team.pde b/mslrb2015/Team.pde index 9264ab1..3e614b4 100644 --- a/mslrb2015/Team.pde +++ b/mslrb2015/Team.pde @@ -96,7 +96,11 @@ class Team { this.newPenaltyKick=false; for (int i=0; i<5; i++) r[i].reset(); + + if(this.connectedClient != null && this.connectedClient.active()) + this.connectedClient.stop(); this.connectedClient = null; + this.firstWorldState = true; } diff --git a/mslrb2015/mslrb2015.pde b/mslrb2015/mslrb2015.pde index d3f69f7..a963c8c 100644 --- a/mslrb2015/mslrb2015.pde +++ b/mslrb2015/mslrb2015.pde @@ -56,7 +56,7 @@ public static Table teamstable; public static TableRow teamselect; public static long updateScoreClientslasttime=0; public static long tstartTime=0, tsplitTime=0, tprevsplitTime=0; -public static boolean TESTMODE=false, stopsplittimer=true, BACKGROUNDon=true, VOICECOACH=false, REMOTECONTROLENABLE=false; +public static boolean TESTMODE=false, stopsplittimer=true, VOICECOACH=false, REMOTECONTROLENABLE=false; public static char LastKickOff='.'; public static String[] Last5cmds= { ".", ".", ".", ".", "." }; public static String LogFileName; @@ -73,11 +73,10 @@ public PImage backgroundImage; public PImage rcfLogo; // Sounds -AudioChannel soundMaxTime; +public static AudioChannel soundMaxTime; public static long lastPlayMillis = 0; public static PApplet mainApplet = null; -//static long ctr = 0; /************************************************************************************************************************** * This the Processing setup() function @@ -109,10 +108,6 @@ void setup() { Config.Load(this, "config.json"); // Load config file Log.init(this); // Init Log module comms_initDescriptionDictionary(); // Initializes the dictionary for communications with the basestations - - - //setbackground(); // Load background - //backgroundImage=get(); scoreClients = new ScoreClients(this, Config.scoreServerPort); // Load score clients server BaseStationServer = new MyServer(this, Config.basestationServerPort); // Load basestations server @@ -134,6 +129,8 @@ void setup() { Ess.start(this); // start up Ess if(Config.sounds_maxTime.length() > 0) { soundMaxTime = new AudioChannel(dataPath("sounds/" + Config.sounds_maxTime)); + }else{ + soundMaxTime = null; } } @@ -153,9 +150,8 @@ void setup() { **************************************************************************************************************************/ void draw() { - if (BACKGROUNDon) background(backgroundImage); - else background(48); - + background(backgroundImage); + long t1=getGameTime(); long t2=getSplitTime(); gametime=nf(int((t1/1000)/60), 2)+":"+nf(int((t1/1000)%60), 2); @@ -176,19 +172,14 @@ void draw() { bTeamBcmds[i].update(); } -// ctr ++; -// println ("Update : ", ctr); teamA.updateUI(); teamB.updateUI(); for (int i = 0; i < bSlider.length; i++) bSlider[i].update(); - // Check scheduled state change - StateMachineCheck(); - - // Refresh buttons - RefreshButonStatus1(); + StateMachineCheck(); // Check scheduled state change + RefreshButonStatus1(); // Refresh buttons fill(255); textAlign(CENTER, CENTER);