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

Enhanced Formatting in StratCon Scenario Information #5297

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
35 changes: 17 additions & 18 deletions MekHQ/src/mekhq/campaign/stratcon/StratconScenario.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,65 +167,64 @@

@Override
public String getInfo() {
return getInfo(null, true);
return getInfo(null);
}

public String getInfo(@Nullable Campaign campaign, boolean html) {
public String getInfo(@Nullable Campaign campaign) {
StringBuilder stateBuilder = new StringBuilder();

if (isStrategicObjective()) {
stateBuilder.append("<span color='").append(MekHQ.getMHQOptions().getFontColorNegativeHexColor()).append("'>Contract objective located</span>")
.append(html ? "<br/>" : "");
stateBuilder.append("<span color='").append(MekHQ.getMHQOptions().getFontColorNegativeHexColor())
.append("'>Contract objective located</span><br/>");
}

stateBuilder.append("Scenario: ")
stateBuilder.append("<b>Scenario:</b> ")
.append(backingScenario.getName())
.append(html ? "<br/>" : "");
.append("<br/>");

if (backingScenario.getTemplate() != null) {
stateBuilder.append(backingScenario.getTemplate().shortBriefing)
.append(html ? "<br/>" : "");
stateBuilder.append("<i>").append(backingScenario.getTemplate().shortBriefing).append("</i>")
.append("<br/>");
}

if (isRequiredScenario()) {
stateBuilder.append("<span color='").append(MekHQ.getMHQOptions().getFontColorNegativeHexColor()).append("'>Deployment required by contract</span>")
.append(html ? "<br/>" : "").append("<span color='").append(MekHQ.getMHQOptions().getFontColorNegativeHexColor()).append("'>-1 VP if lost/ignored; +1 VP if won</span>")
.append(html ? "<br/>" : "");
stateBuilder.append("<span color='").append(MekHQ.getMHQOptions().getFontColorNegativeHexColor())
.append("'>-1 VP if lost/ignored; +1 VP if won</span><br/>");
}

stateBuilder.append("Status: ")
stateBuilder.append("<b>Status:</b> ")
.append(currentState.getScenarioStateName())
.append("<br/>");

stateBuilder.append("Terrain: ")
stateBuilder.append("<b>Terrain:</b> ")
.append(backingScenario.getMap())
.append("<br/>");

if (deploymentDate != null) {
stateBuilder.append("Deployment Date: ")
stateBuilder.append("<b>Deployment Date:</b> ")
.append(deploymentDate)
.append("<br/>");
}

if (actionDate != null) {
stateBuilder.append("Battle Date: ")
stateBuilder.append("<b>Battle Date:</b> ")
.append(actionDate)
.append("<br/>");
}

if (returnDate != null) {
stateBuilder.append("Return Date: ")
stateBuilder.append("<b>Return Date:</b> ")
.append(returnDate)
.append("<br/>");
}

if (campaign != null) {
AtBDynamicScenario backingScenario = getBackingScenario();

Check notice

Code scanning / CodeQL

Possible confusion of local and field Note

Confusing name: method
getInfo
also refers to field
backingScenario
(without qualifying it with 'this').
if (backingScenario != null) {
stateBuilder.append(String.format("Hostile BV: %d<br>",
stateBuilder.append(String.format("<b>Hostile BV:</b> %d<br>",
backingScenario.getTeamTotalBattleValue(campaign, false)));
stateBuilder.append(String.format("Allied BV: %d",
stateBuilder.append(String.format("<b>Allied BV:</b> %d",
backingScenario.getTeamTotalBattleValue(campaign, true)));
}
}
Expand Down
16 changes: 8 additions & 8 deletions MekHQ/src/mekhq/gui/StratconPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -855,18 +855,18 @@ private String buildSelectedHexInfo(Campaign campaign) {
StringBuilder infoBuilder = new StringBuilder();
infoBuilder.append("<html><br/>");

infoBuilder.append("Average Temperature: ");
infoBuilder.append("<b>Average Temperature:</b> ");
infoBuilder.append(currentTrack.getTemperature());
infoBuilder.append("&deg;C<br/>");
infoBuilder.append("Terrain Type: ");
infoBuilder.append("<b>Terrain Type:</b> ");
infoBuilder.append(currentTrack.getTerrainTile(boardState.getSelectedCoords()));
infoBuilder.append("<br/>");

boolean coordsRevealed = currentTrack.hasActiveTrackReveal()
|| currentTrack.getRevealedCoords().contains(boardState.getSelectedCoords());
if (coordsRevealed) {
infoBuilder.append("<span color='").append(MekHQ.getMHQOptions().getFontColorPositiveHexColor())
.append("'>Recon Complete</span><br/>");
.append("'><i>Recon Complete</i></span><br/>");
}

if (currentTrack.getAssignedCoordForces().containsKey(boardState.getSelectedCoords())) {
Expand All @@ -875,13 +875,13 @@ private String buildSelectedHexInfo(Campaign campaign) {
infoBuilder.append(force.getName()).append(" assigned");

if (currentTrack.getStickyForces().contains(forceID)) {
infoBuilder.append(" - remain deployed");
infoBuilder.append("<i> - remain deployed</i>");
}

infoBuilder.append("<br/>")
.append("Returns on ")
.append("<i>Returns on ")
.append(currentTrack.getAssignedForceReturnDates().get(forceID))
.append("<br/>");
.append("</i><br/>");
}
}

Expand Down Expand Up @@ -913,14 +913,14 @@ private String buildSelectedHexInfo(Campaign campaign) {

} else {
infoBuilder.append("<span color='").append(MekHQ.getMHQOptions().getFontColorNegative())
.append("'>Recon Incomplete</span>");
.append("'><i>Recon Incomplete</i></span>");
}
infoBuilder.append("<br/>");

StratconScenario selectedScenario = getSelectedScenario();
if ((selectedScenario != null) &&
((selectedScenario.getDeploymentDate() != null) || currentTrack.isGmRevealed())) {
infoBuilder.append(selectedScenario.getInfo(campaign, true));
infoBuilder.append(selectedScenario.getInfo(campaign));
}

infoBuilder.append("</html>");
Expand Down
2 changes: 1 addition & 1 deletion MekHQ/src/mekhq/gui/stratcon/StratconScenarioWizard.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private void setInstructions(GridBagConstraints gbc) {
if (currentTrackState.isGmRevealed()
|| currentTrackState.getRevealedCoords().contains(currentScenario.getCoords()) ||
(currentScenario.getDeploymentDate() != null)) {
labelBuilder.append(currentScenario.getInfo(campaign, true));
labelBuilder.append(currentScenario.getInfo(campaign));
}

if (Objects.requireNonNull(currentScenario.getCurrentState()) == ScenarioState.UNRESOLVED) {
Expand Down
Loading