Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2858: StratCon Tab NPE #2861

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions MekHQ/src/mekhq/gui/StratconTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class StratconTab extends CampaignGuiTab {
private static final String OBJECTIVE_FAILED = "x";
private static final String OBJECTIVE_COMPLETED = "✓";
private static final String OBJECTIVE_IN_PROGRESS = "o";

private StratconPanel stratconPanel;
private JPanel infoPanel;
private JComboBox<TrackDropdownItem> cboCurrentTrack;
Expand All @@ -66,7 +66,7 @@ public class StratconTab extends CampaignGuiTab {
private boolean objectivesCollapsed = true;

CampaignManagementDialog cmd;

/**
* Creates an instance of the StratconTab.
*/
Expand All @@ -88,7 +88,7 @@ public void initTab() {
campaignStatusText = new JLabel();
campaignStatusText.setHorizontalAlignment(SwingConstants.LEFT);
campaignStatusText.setVerticalAlignment(SwingConstants.TOP);

objectiveStatusText = new JLabel();
objectiveStatusText.setHorizontalAlignment(SwingConstants.LEFT);
objectiveStatusText.setVerticalAlignment(SwingConstants.TOP);
Expand Down Expand Up @@ -129,7 +129,7 @@ private void initializeInfoPanel() {

infoPanel.add(new JLabel("Current Campaign Status:"));
infoPanel.add(campaignStatusText);

JButton btnManageCampaignState = new JButton("Manage SP/VP");
btnManageCampaignState.setHorizontalAlignment(SwingConstants.LEFT);
btnManageCampaignState.setVerticalAlignment(SwingConstants.TOP);
Expand Down Expand Up @@ -325,17 +325,17 @@ private String buildStrategicObjectiveText(StratconCampaignState campaignState)
boolean objectiveFailed = objective.isObjectiveFailed(track);

// special case: allied facilities can get lost at any point in time
if ((objective.getObjectiveType() == StrategicObjectiveType.AlliedFacilityControl) &&
if ((objective.getObjectiveType() == StrategicObjectiveType.AlliedFacilityControl) &&
!campaignState.allowEarlyVictory()) {
sb.append("<span color='orange'>").append(OBJECTIVE_IN_PROGRESS);
} else if (objectiveCompleted) {
sb.append("<span color='green'>").append(OBJECTIVE_COMPLETED);
sb.append("<span color='green'>").append(OBJECTIVE_COMPLETED);
} else if (objectiveFailed) {
sb.append("<span color='red'>").append(OBJECTIVE_FAILED);
} else {
sb.append("<span color='orange'>").append(OBJECTIVE_IN_PROGRESS);
}

sb.append(" ");

if (!coordsRevealed && displayCoordinateData) {
Expand All @@ -354,7 +354,7 @@ private String buildStrategicObjectiveText(StratconCampaignState campaignState)
case AlliedFacilityControl:
sb.append(coordsRevealed ? "M" : "m")
.append("aintain control of designated facility");

if (!campaignState.allowEarlyVictory()) {
sb.append(" until " + campaignState.getContract().getEndingDate());
}
Expand All @@ -380,7 +380,7 @@ private String buildStrategicObjectiveText(StratconCampaignState campaignState)
// special case text reminding player to complete required scenarios
if (!campaignState.getContract().getCommandRights().isIndependent()) {
boolean contractIsActive = campaignState.getContract().isActiveOn(getCampaignGui().getCampaign().getLocalDate());

if (contractIsActive) {
sb.append("<span color='orange'>").append(OBJECTIVE_IN_PROGRESS);
} else if (campaignState.getVictoryPoints() > 0) {
Expand Down Expand Up @@ -431,9 +431,12 @@ private void repopulateTrackList() {
stratconPanel.setVisible(false);
}
}

private void showCampaignStateManagement(ActionEvent e) {
TrackDropdownItem selectedTrack = (TrackDropdownItem) cboCurrentTrack.getSelectedItem();
if (selectedTrack == null) {
return;
}
cmd.display(selectedTrack.contract.getStratconCampaignState(), selectedTrack.track, getCampaign().isGM());
cmd.setModalityType(ModalityType.APPLICATION_MODAL);
cmd.setVisible(true);
Expand Down