diff --git a/.github/workflows/run-bot-update-maps.yml b/.github/workflows/run-bot-update-maps.yml index 9afe3f0c4e1..8a4ea95d5a9 100644 --- a/.github/workflows/run-bot-update-maps.yml +++ b/.github/workflows/run-bot-update-maps.yml @@ -7,7 +7,7 @@ jobs: runs-on: Ubuntu-20.04 steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Run Ansible to Deploy run: | pip install ansible==2.9.13 diff --git a/.github/workflows/run-deploy-production.yml b/.github/workflows/run-deploy-production.yml index 67e4bd7a893..027a6ffee32 100644 --- a/.github/workflows/run-deploy-production.yml +++ b/.github/workflows/run-deploy-production.yml @@ -7,7 +7,7 @@ jobs: runs-on: Ubuntu-20.04 steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Load SSH private key into ssh-agent uses: webfactory/ssh-agent@v0.8.0 with: diff --git a/.github/workflows/upload-game-installers.yml b/.github/workflows/upload-game-installers.yml index ec634a90dfb..da397eab85f 100644 --- a/.github/workflows/upload-game-installers.yml +++ b/.github/workflows/upload-game-installers.yml @@ -15,7 +15,7 @@ jobs: runs-on: Ubuntu-20.04 steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: # Fetch depth of 0 is needed so we checkout the full revision history # The current revision count will be used as our build-number diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 81b0b940f73..64c516b0c64 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -23,7 +23,7 @@ jobs: --health-timeout 5s --health-retries 5 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up JDK 11 uses: actions/setup-java@v3 with: diff --git a/build.gradle b/build.gradle index e2d07f94e9b..d64c9514501 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id 'java' - id 'com.github.ben-manes.versions' version '0.47.0' + id 'com.github.ben-manes.versions' version '0.48.0' id 'io.franzbecker.gradle-lombok' version '5.0.0' apply false id 'com.diffplug.spotless' version '6.21.0' apply false } @@ -55,7 +55,7 @@ subprojects { commonsIoVersion = '2.13.0' commonsMathVersion = '3.6.1' commonsTextVersion = '1.10.0' - databaseRiderVersion = '1.40.0' + databaseRiderVersion = '1.41.0' dropwizardVersion = '2.1.0' dropwizardWebsocketsVersion = '1.3.14' equalsVerifierVersion = '3.15.1' @@ -74,7 +74,7 @@ subprojects { jaxbApiVersion = '2.3.1' jaxbCoreVersion = '4.0.3' jaxbImplVersion = '4.0.3' - jdbiVersion = '3.41.0' + jdbiVersion = '3.41.1' jetbrainsAnnotationsVersion = '24.0.1' jlayerVersion = '1.0.1.4' junitJupiterVersion = '5.10.0' diff --git a/game-app/game-core/src/main/java/games/strategy/engine/data/changefactory/units/UnitDamageReceivedChange.java b/game-app/game-core/src/main/java/games/strategy/engine/data/changefactory/units/UnitDamageReceivedChange.java index 0ebf9376beb..91ae9050620 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/data/changefactory/units/UnitDamageReceivedChange.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/data/changefactory/units/UnitDamageReceivedChange.java @@ -50,7 +50,9 @@ protected void perform(final GameState data) { newTotalDamage.forEach( (unitId, damage) -> { final Unit unit = data.getUnits().get(UUID.fromString(unitId)); - unit.setHits(damage); + if (unit != null) { + unit.setHits(damage); + } }); // invoke territory change listeners for (final String territory : territoriesToNotify) { diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/ProNonCombatMoveAi.java b/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/ProNonCombatMoveAi.java index 9314e26d34a..4fb8c962507 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/ProNonCombatMoveAi.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/ProNonCombatMoveAi.java @@ -235,7 +235,6 @@ private void findUnitsThatCantMove( Map moveMap = territoryManager.getDefendOptions().getTerritoryMap(); Map> unitMoveMap = territoryManager.getDefendOptions().getUnitMoveMap(); - List transportMapList = territoryManager.getDefendOptions().getTransportList(); // Add all units that can't move (to be consumed, allied units, 0 move units, etc) for (final Territory t : moveMap.keySet()) { @@ -252,26 +251,13 @@ private void findUnitsThatCantMove( // Add all units that only have 1 move option and can't be transported for (final Iterator it = unitMoveMap.keySet().iterator(); it.hasNext(); ) { final Unit u = it.next(); - if (unitMoveMap.get(u).size() == 1) { - final Territory onlyTerritory = CollectionUtils.getAny(unitMoveMap.get(u)); - if (onlyTerritory.equals(unitTerritoryMap.get(u))) { - boolean canBeTransported = false; - for (final ProTransport pad : transportMapList) { - for (final Territory t : pad.getTransportMap().keySet()) { - if (pad.getTransportMap().get(t).contains(onlyTerritory)) { - canBeTransported = true; - } - } - for (final Territory t : pad.getSeaTransportMap().keySet()) { - if (pad.getSeaTransportMap().get(t).contains(onlyTerritory)) { - canBeTransported = true; - } - } - } - if (!canBeTransported) { - moveMap.get(onlyTerritory).addCantMoveUnit(u); - it.remove(); - } + final Set territories = unitMoveMap.get(u); + if (territories.size() == 1) { + final Territory onlyTerritory = CollectionUtils.getAny(territories); + if (onlyTerritory.equals(unitTerritoryMap.get(u)) + && !canPotentiallyBeTransported(onlyTerritory)) { + moveMap.get(onlyTerritory).addCantMoveUnit(u); + it.remove(); } } } @@ -325,6 +311,24 @@ private Map> findInfraUnitsThatCanMove() { return infraUnitMoveMap; } + private boolean canPotentiallyBeTransported(Territory unitTerritory) { + final List transportMapList = + territoryManager.getDefendOptions().getTransportList(); + for (final ProTransport pad : transportMapList) { + for (final Territory t : pad.getTransportMap().keySet()) { + if (pad.getTransportMap().get(t).contains(unitTerritory)) { + return true; + } + } + for (final Territory t : pad.getSeaTransportMap().keySet()) { + if (pad.getSeaTransportMap().get(t).contains(unitTerritory)) { + return true; + } + } + } + return false; + } + private List moveOneDefenderToLandTerritoriesBorderingEnemy() { ProLogger.info("Determine which territories to defend with one land unit"); diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/data/ProTerritory.java b/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/data/ProTerritory.java index 321bc35deef..d962db97862 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/data/ProTerritory.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/data/ProTerritory.java @@ -52,7 +52,7 @@ public class ProTerritory { private ProBattleResult battleResult; // Non-combat move variables - private final List cantMoveUnits; + private final Set cantMoveUnits; private List maxEnemyUnits; private Set maxEnemyBombardUnits; private ProBattleResult minBattleResult; @@ -89,7 +89,7 @@ public ProTerritory(final Territory territory, final ProData proData) { currentlyWins = false; battleResult = null; - cantMoveUnits = new ArrayList<>(); + cantMoveUnits = new HashSet<>(); maxEnemyUnits = new ArrayList<>(); maxEnemyBombardUnits = new HashSet<>(); minBattleResult = new ProBattleResult(); @@ -126,7 +126,7 @@ public ProTerritory(final Territory territory, final ProData proData) { currentlyWins = patd.isCurrentlyWins(); battleResult = patd.getBattleResult(); - cantMoveUnits = new ArrayList<>(patd.getCantMoveUnits()); + cantMoveUnits = new HashSet<>(patd.getCantMoveUnits()); maxEnemyUnits = new ArrayList<>(patd.getMaxEnemyUnits()); maxEnemyBombardUnits = new HashSet<>(patd.getMaxEnemyBombardUnits()); minBattleResult = patd.getMinBattleResult(); @@ -332,8 +332,8 @@ public String getResultString() { return sb.toString(); } - public List getCantMoveUnits() { - return Collections.unmodifiableList(cantMoveUnits); + public Collection getCantMoveUnits() { + return Collections.unmodifiableCollection(cantMoveUnits); } public void addCantMoveUnit(final Unit unit) { diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/attachments/TriggerAttachment.java b/game-app/game-core/src/main/java/games/strategy/triplea/attachments/TriggerAttachment.java index 919b9c52295..f9da6454ec6 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/attachments/TriggerAttachment.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/attachments/TriggerAttachment.java @@ -24,8 +24,8 @@ import games.strategy.engine.data.UnitType; import games.strategy.engine.data.changefactory.ChangeFactory; import games.strategy.engine.data.gameparser.GameParseException; -import games.strategy.engine.delegate.IDelegate; import games.strategy.engine.delegate.IDelegateBridge; +import games.strategy.engine.history.IDelegateHistoryWriter; import games.strategy.triplea.Constants; import games.strategy.triplea.Properties; import games.strategy.triplea.delegate.AbstractMoveDelegate; @@ -58,6 +58,7 @@ import org.triplea.java.PredicateBuilder; import org.triplea.java.collections.CollectionUtils; import org.triplea.java.collections.IntegerMap; +import org.triplea.sound.ISound; import org.triplea.sound.SoundPath; import org.triplea.util.Tuple; @@ -1762,7 +1763,6 @@ public static void triggerTerritoryEffectPropertyChange( getClearFirstNewValue(property.getSecond()); for (final TerritoryEffect territoryEffect : t.getTerritoryEffects()) { - // covers TerritoryEffectAttachment if (t.getTerritoryEffectAttachmentName().getFirst().equals("TerritoryEffectAttachment")) { final TerritoryEffectAttachment attachment = @@ -1909,6 +1909,7 @@ public static void triggerAvailableTechChange( final FireTriggerParams fireTriggerParams) { final Collection trigs = filterSatisfiedTriggers(satisfiedTriggers, techAvailableMatch(), fireTriggerParams); + IDelegateHistoryWriter historyWriter = bridge.getHistoryWriter(); for (final TriggerAttachment t : trigs) { if (fireTriggerParams.testChance && !t.testChance(bridge)) { continue; @@ -1926,25 +1927,21 @@ public static void triggerAvailableTechChange( } for (final TechAdvance ta : t.getAvailableTech().get(cat).keySet()) { if (t.getAvailableTech().get(cat).get(ta)) { - bridge - .getHistoryWriter() - .startEvent( - MyFormatter.attachmentNameToText(t.getName()) - + ": " - + player.getName() - + " gains access to " - + ta); + historyWriter.startEvent( + MyFormatter.attachmentNameToText(t.getName()) + + ": " + + player.getName() + + " gains access to " + + ta); final Change change = ChangeFactory.addAvailableTech(tf, ta, player); bridge.addChange(change); } else { - bridge - .getHistoryWriter() - .startEvent( - MyFormatter.attachmentNameToText(t.getName()) - + ": " - + player.getName() - + " loses access to " - + ta); + historyWriter.startEvent( + MyFormatter.attachmentNameToText(t.getName()) + + ": " + + player.getName() + + " loses access to " + + ta); final Change change = ChangeFactory.removeAvailableTech(tf, ta, player); bridge.addChange(change); } @@ -1961,6 +1958,7 @@ public static void triggerTechChange( final FireTriggerParams fireTriggerParams) { final Collection trigs = filterSatisfiedTriggers(satisfiedTriggers, techMatch(), fireTriggerParams); + IDelegateHistoryWriter historyWriter = bridge.getHistoryWriter(); for (final TriggerAttachment t : trigs) { if (fireTriggerParams.testChance && !t.testChance(bridge)) { continue; @@ -1973,14 +1971,12 @@ public static void triggerTechChange( if (ta.hasTech(player.getTechAttachment())) { continue; } - bridge - .getHistoryWriter() - .startEvent( - MyFormatter.attachmentNameToText(t.getName()) - + ": " - + player.getName() - + " activates " - + ta); + historyWriter.startEvent( + MyFormatter.attachmentNameToText(t.getName()) + + ": " + + player.getName() + + " activates " + + ta); TechTracker.addAdvance(player, bridge, ta); } } @@ -2002,16 +1998,15 @@ public static void triggerProductionChange( if (fireTriggerParams.useUses) { t.use(bridge); } + IDelegateHistoryWriter historyWriter = bridge.getHistoryWriter(); for (final GamePlayer player : t.getPlayers()) { change.add(ChangeFactory.changeProductionFrontier(player, t.getFrontier())); - bridge - .getHistoryWriter() - .startEvent( - MyFormatter.attachmentNameToText(t.getName()) - + ": " - + player.getName() - + " has their production frontier changed to: " - + t.getFrontier().getName()); + historyWriter.startEvent( + MyFormatter.attachmentNameToText(t.getName()) + + ": " + + player.getName() + + " has their production frontier changed to: " + + t.getFrontier().getName()); } } if (!change.isEmpty()) { @@ -2046,29 +2041,26 @@ public static void triggerProductionFrontierEditChange( final ProductionRule productionRule = data.getProductionRuleList().getProductionRule(ruleName); final boolean ruleAdded = !rule.startsWith("-"); + final IDelegateHistoryWriter historyWriter = bridge.getHistoryWriter(); if (ruleAdded) { if (!front.getRules().contains(productionRule)) { change.add(ChangeFactory.addProductionRule(productionRule, front)); - bridge - .getHistoryWriter() - .startEvent( - MyFormatter.attachmentNameToText(triggerAttachment.getName()) - + ": " - + productionRule.getName() - + " added to " - + front.getName()); + historyWriter.startEvent( + MyFormatter.attachmentNameToText(triggerAttachment.getName()) + + ": " + + productionRule.getName() + + " added to " + + front.getName()); } } else { if (front.getRules().contains(productionRule)) { change.add(ChangeFactory.removeProductionRule(productionRule, front)); - bridge - .getHistoryWriter() - .startEvent( - MyFormatter.attachmentNameToText(triggerAttachment.getName()) - + ": " - + productionRule.getName() - + " removed from " - + front.getName()); + historyWriter.startEvent( + MyFormatter.attachmentNameToText(triggerAttachment.getName()) + + ": " + + productionRule.getName() + + " removed from " + + front.getName()); } } }); @@ -2160,6 +2152,7 @@ public static void triggerChangeOwnership( final GamePlayer oldOwner = data.getPlayerList().getPlayerId(s[1]); final GamePlayer newOwner = data.getPlayerList().getPlayerId(s[2]); final boolean captured = getBool(s[3]); + final IDelegateHistoryWriter historyWriter = bridge.getHistoryWriter(); for (final Territory terr : territories) { final GamePlayer currentOwner = terr.getOwner(); if (TerritoryAttachment.get(terr) == null) { @@ -2169,14 +2162,12 @@ public static void triggerChangeOwnership( if (oldOwner != null && !oldOwner.equals(currentOwner)) { continue; } - bridge - .getHistoryWriter() - .startEvent( - MyFormatter.attachmentNameToText(t.getName()) - + ": " - + newOwner.getName() - + (captured ? " captures territory " : " takes ownership of territory ") - + terr.getName()); + historyWriter.startEvent( + MyFormatter.attachmentNameToText(t.getName()) + + ": " + + newOwner.getName() + + (captured ? " captures territory " : " takes ownership of territory ") + + terr.getName()); if (!captured) { bridge.addChange(ChangeFactory.changeOwner(terr, newOwner)); } else { @@ -2406,13 +2397,12 @@ public static void triggerActivateTriggerOther( testUsesToFire, testChanceToFire, false); + IDelegateHistoryWriter historyWriter = bridge.getHistoryWriter(); for (int i = 0; i < numberOfTimesToFire * eachMultiple; ++i) { - bridge - .getHistoryWriter() - .startEvent( - MyFormatter.attachmentNameToText(t.getName()) - + " activates a trigger called: " - + MyFormatter.attachmentNameToText(toFire.getName())); + historyWriter.startEvent( + MyFormatter.attachmentNameToText(t.getName()) + + " activates a trigger called: " + + MyFormatter.attachmentNameToText(toFire.getName())); fireTriggers(toFireSet, testedConditionsSoFar, bridge, toFireTriggerParams); } } @@ -2461,20 +2451,14 @@ static void triggerVictory( final String sounds = notificationMessages.getSoundsKey(t.getVictory().trim()); if (victoryMessage != null) { if (sounds != null) { // only play the sound if we are also notifying everyone - bridge - .getSoundChannelBroadcaster() - .playSoundToPlayers( - SoundPath.CLIP_TRIGGERED_VICTORY_SOUND + sounds.trim(), - t.getPlayers(), - null, - true); - bridge - .getSoundChannelBroadcaster() - .playSoundToPlayers( - SoundPath.CLIP_TRIGGERED_DEFEAT_SOUND + sounds.trim(), - data.getPlayerList().getPlayers(), - t.getPlayers(), - false); + ISound sound = bridge.getSoundChannelBroadcaster(); + sound.playSoundToPlayers( + SoundPath.CLIP_TRIGGERED_VICTORY_SOUND + sounds.trim(), t.getPlayers(), null, true); + sound.playSoundToPlayers( + SoundPath.CLIP_TRIGGERED_DEFEAT_SOUND + sounds.trim(), + data.getPlayerList().getPlayers(), + t.getPlayers(), + false); } String messageForRecord = victoryMessage.trim(); if (messageForRecord.length() > 150) { @@ -2485,16 +2469,14 @@ static void triggerVictory( } } try { - bridge - .getHistoryWriter() - .startEvent( - "Players: " - + MyFormatter.defaultNamedToTextList(t.getPlayers()) - + " have just won the game, with this victory: " - + messageForRecord); - final IDelegate delegateEndRound = data.getDelegate("endRound"); - ((EndRoundDelegate) delegateEndRound) - .signalGameOver(victoryMessage.trim(), t.getPlayers(), bridge); + IDelegateHistoryWriter historyWriter = bridge.getHistoryWriter(); + historyWriter.startEvent( + "Players: " + + MyFormatter.defaultNamedToTextList(t.getPlayers()) + + " have just won the game, with this victory: " + + messageForRecord); + final EndRoundDelegate delegateEndRound = (EndRoundDelegate) data.getDelegate("endRound"); + delegateEndRound.signalGameOver(victoryMessage.trim(), t.getPlayers(), bridge); } catch (final Exception e) { log.error("Failed to signal game over", e); } diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/odds/calculator/OrderOfLossesInputPanel.java b/game-app/game-core/src/main/java/games/strategy/triplea/odds/calculator/OrderOfLossesInputPanel.java index ad8218e911d..b24c0e1c55a 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/odds/calculator/OrderOfLossesInputPanel.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/odds/calculator/OrderOfLossesInputPanel.java @@ -10,7 +10,6 @@ import games.strategy.engine.data.UnitTypeList; import games.strategy.triplea.delegate.Matches; import games.strategy.triplea.image.UnitImageFactory.ImageKey; -import games.strategy.triplea.ui.TooltipProperties; import games.strategy.triplea.ui.UiContext; import games.strategy.triplea.util.UnitCategory; import java.awt.Color; @@ -271,7 +270,8 @@ private JPanel getUnitButtonPanel( "" + category.getType().getName() + ": " - + new TooltipProperties(uiContext) + + uiContext + .getTooltipProperties() .getTooltip(category.getType(), category.getOwner()) + ""; final ImageIcon img = uiContext.getUnitImageFactory().getIcon(ImageKey.of(category)); diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/odds/calculator/UnitPanel.java b/game-app/game-core/src/main/java/games/strategy/triplea/odds/calculator/UnitPanel.java index 1367e821b0d..37fb9d60e33 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/odds/calculator/UnitPanel.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/odds/calculator/UnitPanel.java @@ -5,7 +5,6 @@ import games.strategy.engine.data.Unit; import games.strategy.engine.data.UnitType; import games.strategy.triplea.delegate.Matches; -import games.strategy.triplea.ui.TooltipProperties; import games.strategy.triplea.ui.UiContext; import games.strategy.triplea.util.UnitCategory; import games.strategy.ui.ScrollableTextField; @@ -38,7 +37,7 @@ public class UnitPanel extends JPanel { + ": " + costs.getInt(category.getType()) + " cost,
     " - + new TooltipProperties(uiContext).getTooltip(category.getType(), category.getOwner()) + + uiContext.getTooltipProperties().getTooltip(category.getType(), category.getOwner()) + ""; setCount(category.getUnits().size()); setLayout(new GridBagLayout()); diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ui/MapUnitTooltipManager.java b/game-app/game-core/src/main/java/games/strategy/triplea/ui/MapUnitTooltipManager.java index cd6ea1656c5..b38c1789d82 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ui/MapUnitTooltipManager.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ui/MapUnitTooltipManager.java @@ -129,7 +129,7 @@ public static String getTooltipTextForUnit( count == 1 ? "" : (count + " "), StringUtils.capitalize(unitType.getName()), player.getName()); - return firstLine + new TooltipProperties(uiContext).getTooltip(unitType, player); + return firstLine + uiContext.getTooltipProperties().getTooltip(unitType, player); } /** diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ui/ProductionPanel.java b/game-app/game-core/src/main/java/games/strategy/triplea/ui/ProductionPanel.java index 018d1c0d19f..05937076451 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ui/ProductionPanel.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ui/ProductionPanel.java @@ -337,7 +337,7 @@ protected JPanel getPanelComponent() { tooltip .append(type.getName()) .append(": ") - .append(new TooltipProperties(uiContext).getTooltip(type, player)); + .append(uiContext.getTooltipProperties().getTooltip(type, player)); name.setText(type.getName()); if (attach.getConsumesUnits().totalValues() == 1) { name.setForeground(Color.CYAN); diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ui/UiContext.java b/game-app/game-core/src/main/java/games/strategy/triplea/ui/UiContext.java index 0e1a10cdd80..094fdacc961 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ui/UiContext.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ui/UiContext.java @@ -70,6 +70,7 @@ public class UiContext { @Getter private final TileImageFactory tileImageFactory = new TileImageFactory(); @Getter private UnitImageFactory unitImageFactory; @Getter private final ResourceImageFactory resourceImageFactory = new ResourceImageFactory(); + @Getter private final TooltipProperties tooltipProperties; @Getter private final TerritoryEffectImageFactory territoryEffectImageFactory = @@ -152,6 +153,7 @@ public class UiContext { log.error("Failed to create cursor from: " + cursorUrl, e); } } + tooltipProperties = new TooltipProperties(this); } public JLabel newUnitImageLabel(final ImageKey imageKey) { diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ui/menubar/help/GameNotesMenu.java b/game-app/game-core/src/main/java/games/strategy/triplea/ui/menubar/help/GameNotesMenu.java index 211acc4261a..e28ce0977d4 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ui/menubar/help/GameNotesMenu.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ui/menubar/help/GameNotesMenu.java @@ -1,6 +1,7 @@ package games.strategy.triplea.ui.menubar.help; import games.strategy.engine.framework.ui.GameNotesView; +import java.awt.Dimension; import java.nio.file.Path; import javax.swing.Action; import javax.swing.JComponent; @@ -24,18 +25,12 @@ Action buildMenu(final String gameNotes, final Path mapLocation) { final JDialog dialog = InformationDialog.createDialog( notesPanel(gameNotes, mapLocation), gameNotesTitle); - if (dialog.getWidth() < 400) { - dialog.setSize(400, dialog.getHeight()); - } - if (dialog.getHeight() < 300) { - dialog.setSize(dialog.getWidth(), 300); - } - if (dialog.getWidth() > 800) { - dialog.setSize(800, dialog.getHeight()); - } - if (dialog.getHeight() > 600) { - dialog.setSize(dialog.getWidth(), 600); - } + Dimension size = dialog.getSize(); + size.width = Math.min(size.width, 400); + size.height = Math.min(size.height, 300); + size.width = Math.max(size.width, 800); + size.height = Math.max(size.height, 600); + dialog.setSize(size); dialog.setVisible(true); })); } diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ui/menubar/help/UnitHelpMenu.java b/game-app/game-core/src/main/java/games/strategy/triplea/ui/menubar/help/UnitHelpMenu.java index 10663a2620f..23ba4de9127 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ui/menubar/help/UnitHelpMenu.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ui/menubar/help/UnitHelpMenu.java @@ -5,6 +5,7 @@ import games.strategy.triplea.ui.UiContext; import javax.swing.Action; import javax.swing.BorderFactory; +import javax.swing.JDialog; import javax.swing.JEditorPane; import javax.swing.JScrollPane; import lombok.experimental.UtilityClass; @@ -20,19 +21,21 @@ Action buildMenu(final GameData gameData, final UiContext uiContext) { return SwingAction.of( unitHelpTitle, e -> { - final Result result = + final Result result = Interruptibles.awaitResult( () -> BackgroundTaskRunner.runInBackgroundAndReturn( "Calculating Data", - () -> UnitStatsTable.getUnitStatsTable(gameData, uiContext))); - final JEditorPane editorPane = - new JEditorPane("text/html", result.result.orElse("Failed to calculate Data")); - editorPane.setEditable(false); - editorPane.setCaretPosition(0); - final JScrollPane scroll = new JScrollPane(editorPane); - scroll.setBorder(BorderFactory.createEmptyBorder()); - InformationDialog.createDialog(scroll, unitHelpTitle).setVisible(true); + () -> { + String text = UnitStatsTable.getUnitStatsTable(gameData, uiContext); + JEditorPane editorPane = new JEditorPane("text/html", text); + editorPane.setEditable(false); + editorPane.setCaretPosition(0); + JScrollPane scroll = new JScrollPane(editorPane); + scroll.setBorder(BorderFactory.createEmptyBorder()); + return InformationDialog.createDialog(scroll, unitHelpTitle); + })); + result.result.orElseThrow().setVisible(true); }); } } diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ui/menubar/help/UnitStatsTable.java b/game-app/game-core/src/main/java/games/strategy/triplea/ui/menubar/help/UnitStatsTable.java index 5d93bbf183d..62fa409392e 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ui/menubar/help/UnitStatsTable.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ui/menubar/help/UnitStatsTable.java @@ -11,7 +11,6 @@ import games.strategy.engine.data.UnitType; import games.strategy.triplea.image.UnitImageFactory; import games.strategy.triplea.image.UnitImageFactory.ImageKey; -import games.strategy.triplea.ui.TooltipProperties; import games.strategy.triplea.ui.UiContext; import games.strategy.triplea.util.TuvUtils; import java.util.ArrayList; @@ -72,7 +71,7 @@ public static String getUnitStatsTable(final GameData gameData, final UiContext .append(costs.get(player).get(ut).toStringForHtml()) .append("") .append("") - .append(new TooltipProperties(uiContext).getTooltip(ut, player)) + .append(uiContext.getTooltipProperties().getTooltip(ut, player)) .append(""); } } diff --git a/game-app/game-headed/.eclipse/HeadedGameRunner.launch b/game-app/game-headed/.eclipse/HeadedGameRunner.launch index b9fb61b6ea0..6154592bf9d 100644 --- a/game-app/game-headed/.eclipse/HeadedGameRunner.launch +++ b/game-app/game-headed/.eclipse/HeadedGameRunner.launch @@ -1,18 +1,17 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/game-app/game-headed/src/main/java/games/strategy/triplea/ui/TerritoryDetailPanel.java b/game-app/game-headed/src/main/java/games/strategy/triplea/ui/TerritoryDetailPanel.java index 95cd3a0540a..b9f9a38b3e4 100644 --- a/game-app/game-headed/src/main/java/games/strategy/triplea/ui/TerritoryDetailPanel.java +++ b/game-app/game-headed/src/main/java/games/strategy/triplea/ui/TerritoryDetailPanel.java @@ -199,7 +199,7 @@ private static JPanel unitsInTerritoryPanel( "" + item.getType().getName() + ": " - + new TooltipProperties(uiContext).getTooltip(item.getType(), currentPlayer) + + uiContext.getTooltipProperties().getTooltip(item.getType(), currentPlayer) + ""; label.setToolTipText(toolTipText); panel.add(label); diff --git a/game-app/game-headless/.eclipse/HeadlessGameRunner.launch b/game-app/game-headless/.eclipse/HeadlessGameRunner.launch index d8e4dd65ac5..e8385b7839c 100644 --- a/game-app/game-headless/.eclipse/HeadlessGameRunner.launch +++ b/game-app/game-headless/.eclipse/HeadlessGameRunner.launch @@ -1,15 +1,14 @@ - - - - - - - - - - - - + + + + + + + + + + + diff --git a/node-bb/install/package.json b/node-bb/install/package.json index c2cc0ae5370..2b1b0df0124 100644 --- a/node-bb/install/package.json +++ b/node-bb/install/package.json @@ -113,11 +113,11 @@ "passport-local": "1.0.0", "pg": "^8.0.2", "pg-cursor": "^2.1.9", - "postcss": "7.0.27", + "postcss": "7.0.36", "postcss-clean": "1.1.0", "promise-polyfill": "^8.1.3", "prompt": "^1.0.0", - "redis": "3.0.2", + "redis": "3.1.1", "request": "2.88.2", "request-promise-native": "^1.0.8", "rimraf": "3.0.2", @@ -125,9 +125,9 @@ "sanitize-html": "^1.23.0", "semver": "^7.2.1", "serve-favicon": "^2.5.0", - "sharp": "0.25.2", + "sharp": "0.30.5", "sitemap": "^6.1.0", - "socket.io": "2.3.0", + "socket.io": "2.4.0", "socket.io-adapter-cluster": "^1.0.1", "socket.io-adapter-mongo": "^2.0.5", "socket.io-adapter-postgres": "^1.2.1", @@ -142,7 +142,7 @@ "uglify-es": "^3.3.9", "uglify-js": "^3.3.4", "util.promisify": "1.0.0", - "validator": "13.0.0", + "validator": "13.7.0", "winston": "3.2.1", "xml": "^1.0.1", "xregexp": "^4.3.0", @@ -156,10 +156,10 @@ "eslint": "6.8.0", "eslint-config-airbnb-base": "14.1.0", "eslint-plugin-import": "2.20.2", - "grunt": "1.1.0", + "grunt": "1.5.3", "grunt-contrib-watch": "1.1.0", "husky": "4.2.5", - "jsdom": "16.2.2", + "jsdom": "16.5.0", "lint-staged": "10.2.0", "mocha": "7.1.2", "mocha-lcov-reporter": "1.3.0",