theTimeLabel.setText(theSimulator.getCurrentDisplaySimTime());
int satValue = theSimulator.getScenario().computePassengerSatisfaction(theSimulator.getCurrentSimTime(), theSimulator.getDifficultyLevel());
if ( satValue < theSimulator.getScenario().getMinimumSatisfaction() ) {
theInterface.pauseSimulation();
JOptionPane.showMessageDialog(ControlScreen.this, theSimulator.getScenario().getScenarioName() + " have relunctanly decided to relieve you of your duties as managing director as passenger satisfaction is now " + satValue + "%.", "Sorry You Have Been Sacked!", JOptionPane.ERROR_MESSAGE);
new WelcomeScreen(new UserInterface());
dispose();
}
thePassengerSatisfactionBar.setValue(satValue);
thePassengerSatisfactionBar.setString("Passenger Satisfaction Rating - " + thePassengerSatisfactionBar.getValue() + "%");
thePassengerSatisfactionBar.setFont(new Font("Arial", Font.ITALIC, 20));
//Update graphics panel.
//theDialogPanel.remove(theGraphicsPanel);
//theDialogPanel.add(theGraphicsPanel);
//Repaint the whole interface immediately.
theDialogPanel.paintImmediately(theDialogPanel.getBounds());
return;
//logger.debug("I need to do allocations!");
//AllocationScreen as = new AllocationScreen(theInterface, true, true, theSimulator);
//dispose();
}
//Set doneAllocations to false.
doneAllocations = false;
//Now get the component and replace it if appropriate.
if ( !isRedraw ) {
logger.debug("I've set graphics panel to something...");
theGraphicsPanel = generateNewVehiclePanel();
}
if ( isRedraw ) {
theDialogPanel.remove(theDialogPanel.getComponent(1));
theGraphicsPanel = generateNewVehiclePanel();
theTabbedPane.removeAll();
theTabbedPane.addTab("Live Situation", theGraphicsPanel);
drawMessages();
theTabbedPane.addTab("Messages", theMessagesPanel);
//Create manage tab.
theTabbedPane.addTab("Management", theManagementPanel.getDisplayPanel());
if ( theInterface.getMessageScreen() ) {
theTabbedPane.setSelectedIndex(1);
} else if ( theInterface.getManagementScreen() ) {
theTabbedPane.setSelectedIndex(2);
}
theTabbedPane.addMouseListener(new MouseListener() {
public void mouseExited ( MouseEvent e ) { }
public void mouseEntered ( MouseEvent e ) { }
public void mouseReleased ( MouseEvent e ) { }
public void mousePressed ( MouseEvent e ) { }
public void mouseClicked ( MouseEvent e ) {
logger.debug("You just selected the " + theTabbedPane.getSelectedIndex() + " component");
if ( theTabbedPane.getSelectedIndex() == 1) {
theTopPanel.getComponent(1).setVisible(false);
theInterface.setMessageScreen(true);
theInterface.setManagementScreen(false);
theInterface.pauseSimulation(); //Pause simulation for message screen.
} else if ( theTabbedPane.getSelectedIndex() == 2 ) {
theTopPanel.getComponent(1).setVisible(false);
theInterface.setManagementScreen(true);
theInterface.setMessageScreen(false);
theInterface.pauseSimulation(); //Pause simulation for management screen.
} else {
theTopPanel.getComponent(1).setVisible(true);
theInterface.setMessageScreen(false);
theInterface.setManagementScreen(false);
theInterface.resumeSimulation(); //Resume simulation for live screen.
}
}
});
//Now disable live situation if no routes.
if ( theSimulator.getScenario().getNumberRoutes() == 0 ) {
theTabbedPane.setEnabledAt(0, false);
}
theDialogPanel.add(theTabbedPane, 1);
/*for ( int i = 0; i < theDialogPanel.getComponentCount(); i++ ) {
logger.debug("Going through component " + i + theDialogPanel.getComponent(i));
logger.debug("Graphics Panel component " + theGraphicsPanel);
if ( theDialogPanel.getComponent(i) == theGraphicsPanel ) {
theDialogPanel.remove(theDialogPanel.getComponent(i));
logger.debug("I've generated vehicle panel!");
theGraphicsPanel = generateNewVehiclePanel();
theDialogPanel.add(theGraphicsPanel, i);
}
}*/
theTimeLabel.setText(theSimulator.getCurrentDisplaySimTime());
//Now here we need to update satisfaction bar.
int satValue = theSimulator.getScenario().computePassengerSatisfaction(theSimulator.getCurrentSimTime(), theSimulator.getDifficultyLevel());
if ( satValue < theSimulator.getScenario().getMinimumSatisfaction() ) {
theInterface.pauseSimulation();
JOptionPane.showMessageDialog(ControlScreen.this, theSimulator.getScenario().getScenarioName() + " have relunctanly decided to relieve you of your duties as managing director as passenger satisfaction is now " + satValue + "%.", "Sorry You Have Been Sacked!", JOptionPane.ERROR_MESSAGE);
new WelcomeScreen(new UserInterface());
dispose();
}
thePassengerSatisfactionBar.setValue(satValue);
thePassengerSatisfactionBar.setString("Passenger Satisfaction Rating - " + thePassengerSatisfactionBar.getValue() + "%");
thePassengerSatisfactionBar.setFont(new Font("Arial", Font.ITALIC, 20));