Skip to content

Commit

Permalink
fix: small changes for improving the reports and scroll speed
Browse files Browse the repository at this point in the history
  • Loading branch information
Scoppio committed Jan 8, 2025
1 parent 177e6f6 commit b42b7a9
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 12 deletions.
5 changes: 3 additions & 2 deletions megamek/i18n/megamek/client/acs-report-messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
999={0}
1000=<h2>\u25d4 Initiative Phase for Round {0}</h2>
1005=<h2>\u25d4 Initiative Phase for Start of Game Deployment</h2>
1015=\u25ba {0} has {1} initiative bonus.
1015=\u25ba {0} initiative rolls.
1016=\u25ba {0} initiative rolls, they have {1} bonus.
1020=\u25b6 The general turn order is:
1040=<h3>\u25bc The turn order is:</h3>
1045=\u25ba {0}({1}), rolled {2}
Expand All @@ -49,7 +50,7 @@
1231={0} ({1}) {2}
1242=no effect
9999=<h2>\u25cf End of the Game</h2>
2020={0} rolls a {1}.
2020={0} rolls {1}...

2201=<h2>\u25d1 Movement Phase</h2>
2202={0} deployed at sector {1}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@
import java.awt.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.time.temporal.TemporalUnit;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.TreeMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

public class AutoResolveChanceDialog extends AbstractDialog implements PropertyChangeListener {
Expand Down Expand Up @@ -256,7 +258,7 @@ public Integer doInBackground() {
messageKey = "AutoResolveDialog.messageFailedCalc";
logger.warn("No combat scenarios were simulated, possible error!");
} else {
var timePerRun = stopWatch.getDuration().getSeconds() / (numberOfSimulations / Runtime.getRuntime().availableProcessors());
var timePerRun = (stopWatch.getTime(TimeUnit.MILLISECONDS) / (double) numberOfSimulations) / (double) numberOfThreads;
logger.debug("Simulated victories: {} runs, {} victories, {} losses, {} draws, {} failed - processed in {} seconds per CPU core - total of {}",
simulatedVictories.getRuns(),
simulatedVictories.getVictories(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public class AutoResolveProgressDialog extends AbstractDialog implements Propert
private final Board board;

private static final TreeMap<Integer, String> splashImages = new TreeMap<>();

static {
splashImages.put(0, Configuration.miscImagesDir() + "/acar_splash_hd.png");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ protected Container createCenterPane() {
}
}
});
scrollPane.getVerticalScrollBar().setUnitIncrement(100);
scrollPane.getVerticalScrollBar().setUnitIncrement(16);

final File helpFile = new File(getHelpFilePath());

// Get the help content file if possible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ public void reportAttackRoll(Roll roll, Formation attacker) {

@Override
public void reportAttackMiss() {
reportConsumer.accept(new PublicReportEntry(2012).indent(2));
reportConsumer.accept(new PublicReportEntry(2012).indent(1));
}

@Override
public void reportAttackHit() {
reportConsumer.accept(new PublicReportEntry(2013).indent(2));
reportConsumer.accept(new PublicReportEntry(2013).indent(1));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,15 @@ public void writeInitiativeRolls() {
if (team.isObserverTeam()) {
continue;
}
reportConsumer.accept(new PublicReportEntry(1015).add(Player.TEAM_NAMES[team.getId()])
.add(team.getInitiative().toString()));

var teamInitBonus = team.getTotalInitBonus(false);
var reportKey = 1015;
if (teamInitBonus > 0) {
reportKey = 1016;
}

reportConsumer.accept(new PublicReportEntry(reportKey).add(Player.TEAM_NAMES[team.getId()])
.add(teamInitBonus));

// Multiple players. List the team, then break it down.
for (Player player : team.nonObserverPlayers()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void playerFinalReport(Player player) {
.map(Entity.class::cast)
.toList();

reportConsumer.accept(new LinkEntry(301, "remaining-" + player.getId()).indent().indent());
reportConsumer.accept(new LinkEntry(301, "remaining-" + player.getId()).noNL());
reportConsumer.accept(new ReportEntryWithAnchor(5003, "end-player-" + player.getId() + "-remaining").noNL()
.add(new PlayerNameReportEntry(player).reportText())
.add(playerEntities.size()).indent());
Expand All @@ -109,7 +109,7 @@ public void playerFinalReport(Player player) {
.map(Entity.class::cast)
.toList();

reportConsumer.accept(new LinkEntry(301, "destroyed-" + player.getId()).noNL().indent());
reportConsumer.accept(new LinkEntry(301, "destroyed-" + player.getId()).noNL());
reportConsumer.accept(new ReportEntryWithAnchor(5006, "end-player-" + player.getId() + "-destroyed")
.add(new PlayerNameReportEntry(player).reportText())
.add(deadEntities.size())
Expand All @@ -134,7 +134,7 @@ public void playerFinalReport(Player player) {
.filter(e -> e.getOwnerId() == player.getId())
.toList();

reportConsumer.accept(new LinkEntry(301, "retreating-" + player.getId()).indent());
reportConsumer.accept(new LinkEntry(301, "retreating-" + player.getId()).noNL());
reportConsumer.accept(new ReportEntryWithAnchor(5007, "end-player-" + player.getId() + "-retreating")
.add(new PlayerNameReportEntry(player).reportText())
.add(retreatingEntities.size())
Expand Down

0 comments on commit b42b7a9

Please sign in to comment.