From a560f8c5cd44c9c1eeb12702f4b74a486711f701 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Fri, 24 Nov 2023 11:27:51 -0500 Subject: [PATCH 01/24] add team and player0 deployemnt options --- .../common/options/messages.properties | 4 ++++ megamek/src/megamek/common/Entity.java | 24 ++++++++++++++++--- .../megamek/common/options/GameOptions.java | 4 +++- .../common/options/OptionsConstants.java | 2 ++ megamek/src/megamek/server/Server.java | 16 +++++++++---- 5 files changed, 42 insertions(+), 8 deletions(-) diff --git a/megamek/i18n/megamek/common/options/messages.properties b/megamek/i18n/megamek/common/options/messages.properties index 34c9c5d8874..052524dcbc7 100644 --- a/megamek/i18n/megamek/common/options/messages.properties +++ b/megamek/i18n/megamek/common/options/messages.properties @@ -33,6 +33,10 @@ GameOptionsInfo.option.dumping_from_round.displayableName=first round for ammo d GameOptionsInfo.option.dumping_from_round.description=Number of the round that has to be at least reached before allowing ammo dumps. GameOptionsInfo.option.set_arty_player_homeedge.displayableName=Automatically set artillery home edge GameOptionsInfo.option.set_arty_player_homeedge.description=If checked, all of the players' artillery units will have their home edge set to the deployment edge of the player, NW and NE are North, SW and SE are South. \nUnchecked by default. +GameOptionsInfo.option.set_default_team_1.displayableName=Default non-bot players to team 1 +GameOptionsInfo.option.set_default_team_1.description=Unchecked each player is assigned new team +GameOptionsInfo.option.set_player_deployment_to_player0.displayableName=Non-bot players entities with \"Use Owners*\" deployment set, use Player 0\'s settings, instead of current player\'s settings +GameOptionsInfo.option.set_player_deployment_to_player0.description=Unchecked use current player deployments settings GameOptionsInfo.option.restrict_game_commands.displayableName=Restrict sensitive commands to non-Observers GameOptionsInfo.option.restrict_game_commands.description=If checked, commands such as /reset and /kick cannot be used by Observers while others are playing. \nUnchecked by default. GameOptionsInfo.option.disable_local_save.displayableName=Disable local saves when using double blind diff --git a/megamek/src/megamek/common/Entity.java b/megamek/src/megamek/common/Entity.java index 7adba24108f..cfaffa1822e 100644 --- a/megamek/src/megamek/common/Entity.java +++ b/megamek/src/megamek/common/Entity.java @@ -12890,7 +12890,13 @@ public int getStartingPos() { public int getStartingPos(boolean inheritFromOwner) { if (inheritFromOwner && startingPos == Board.START_NONE) { - return getOwner().getStartingPos(); + final GameOptions gOpts = getGame().getOptions(); + if (!getOwner().isBot() && gOpts.booleanOption(OptionsConstants.BASE_SET_PLAYER_DEPLOYMENT_TO_PLAYER0)) { + return game.getPlayer(0).getStartingPos(); + } + else { + return getOwner().getStartingPos(); + } } return startingPos; } @@ -15288,7 +15294,13 @@ public int getStartingOffset(boolean inheritFromOwner) { // if we are given permission to use the owner's settings // and have specified entity-specific settings, use the owner's settings if (inheritFromOwner && (startingPos == Board.START_NONE)) { - return getOwner().getStartOffset(); + final GameOptions gOpts = getGame().getOptions(); + if (!getOwner().isBot() && gOpts.booleanOption(OptionsConstants.BASE_SET_PLAYER_DEPLOYMENT_TO_PLAYER0)) { + return game.getPlayer(0).getStartOffset(); + } + else { + return getOwner().getStartOffset(); + } } return startingOffset; @@ -15306,7 +15318,13 @@ public int getStartingWidth(boolean inheritFromOwner) { // if we are given permission to use the owner's settings // and have specified entity-specific settings, use the owner's settings if (inheritFromOwner && (startingPos == Board.START_NONE)) { - return getOwner().getStartWidth(); + final GameOptions gOpts = getGame().getOptions(); + if (!getOwner().isBot() && gOpts.booleanOption(OptionsConstants.BASE_SET_PLAYER_DEPLOYMENT_TO_PLAYER0)) { + return game.getPlayer(0).getStartWidth(); + } + else { + return getOwner().getStartWidth(); + } } return startingWidth; diff --git a/megamek/src/megamek/common/options/GameOptions.java b/megamek/src/megamek/common/options/GameOptions.java index 7c9d5e9d97b..63936a5a375 100755 --- a/megamek/src/megamek/common/options/GameOptions.java +++ b/megamek/src/megamek/common/options/GameOptions.java @@ -61,7 +61,9 @@ public synchronized void initialize() { addOption(base, OptionsConstants.BASE_REAL_BLIND_DROP, false); addOption(base, OptionsConstants.BASE_LOBBY_AMMO_DUMP, false); addOption(base, OptionsConstants.BASE_DUMPING_FROM_ROUND, 1); - addOption(base, OptionsConstants.BASE_SET_ARTY_PLAYER_HOMEEDGE, false); + addOption(base, OptionsConstants.BASE_SET_ARTY_PLAYER_HOMEEDGE, false); + addOption(base, OptionsConstants.BASE_SET_DEFAULT_TEAM_1, false); + addOption(base, OptionsConstants.BASE_SET_PLAYER_DEPLOYMENT_TO_PLAYER0, false); addOption(base, OptionsConstants.BASE_RESTRICT_GAME_COMMANDS, false); addOption(base, OptionsConstants.BASE_DISABLE_LOCAL_SAVE, false); addOption(base, OptionsConstants.BASE_BRIDGECF, 0); diff --git a/megamek/src/megamek/common/options/OptionsConstants.java b/megamek/src/megamek/common/options/OptionsConstants.java index 02d11bd3fce..127433e1a93 100644 --- a/megamek/src/megamek/common/options/OptionsConstants.java +++ b/megamek/src/megamek/common/options/OptionsConstants.java @@ -281,6 +281,8 @@ public class OptionsConstants { public static final String BASE_LOBBY_AMMO_DUMP = "lobby_ammo_dump"; public static final String BASE_DUMPING_FROM_ROUND = "dumping_from_round"; public static final String BASE_SET_ARTY_PLAYER_HOMEEDGE = "set_arty_player_homeedge"; + public static final String BASE_SET_DEFAULT_TEAM_1 = "set_default_team_1"; + public static final String BASE_SET_PLAYER_DEPLOYMENT_TO_PLAYER0 = "set_player_deployment_to_player0"; public static final String BASE_RESTRICT_GAME_COMMANDS = "restrict_game_commands"; public static final String BASE_DISABLE_LOCAL_SAVE = "disable_local_save"; public static final String BASE_BRIDGECF = "bridgeCF"; diff --git a/megamek/src/megamek/server/Server.java b/megamek/src/megamek/server/Server.java index 0fd46b61af3..71f1ef98af5 100644 --- a/megamek/src/megamek/server/Server.java +++ b/megamek/src/megamek/server/Server.java @@ -32,6 +32,8 @@ import megamek.common.net.factories.ConnectionFactory; import megamek.common.net.listeners.ConnectionListener; import megamek.common.net.packets.Packet; +import megamek.common.options.GameOptions; +import megamek.common.options.OptionsConstants; import megamek.common.preference.PreferenceManager; import megamek.common.util.EmailService; import megamek.common.util.SerializationHelper; @@ -751,12 +753,18 @@ private Player addNewPlayer(int connId, String name, boolean isBot) { int team = Player.TEAM_UNASSIGNED; if (getGame().getPhase().isLounge()) { team = Player.TEAM_NONE; - for (Player p : getGame().getPlayersVector()) { - if (p.getTeam() > team) { - team = p.getTeam(); + final GameOptions gOpts = getGame().getOptions(); + if (isBot || !gOpts.booleanOption(OptionsConstants.BASE_SET_DEFAULT_TEAM_1)) { + for (Player p : getGame().getPlayersVector()) { + if (p.getTeam() > team) { + team = p.getTeam(); + } } + team++; + } else { + team = 1; } - team++; + } Player newPlayer = new Player(connId, name); newPlayer.setBot(isBot); From 9640b1163b542435c7d0bb9389e428850c0563ea Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Fri, 24 Nov 2023 11:37:02 -0500 Subject: [PATCH 02/24] typo --- megamek/i18n/megamek/common/options/messages.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/megamek/i18n/megamek/common/options/messages.properties b/megamek/i18n/megamek/common/options/messages.properties index 052524dcbc7..b49eeb04922 100644 --- a/megamek/i18n/megamek/common/options/messages.properties +++ b/megamek/i18n/megamek/common/options/messages.properties @@ -35,7 +35,7 @@ GameOptionsInfo.option.set_arty_player_homeedge.displayableName=Automatically se GameOptionsInfo.option.set_arty_player_homeedge.description=If checked, all of the players' artillery units will have their home edge set to the deployment edge of the player, NW and NE are North, SW and SE are South. \nUnchecked by default. GameOptionsInfo.option.set_default_team_1.displayableName=Default non-bot players to team 1 GameOptionsInfo.option.set_default_team_1.description=Unchecked each player is assigned new team -GameOptionsInfo.option.set_player_deployment_to_player0.displayableName=Non-bot players entities with \"Use Owners*\" deployment set, use Player 0\'s settings, instead of current player\'s settings +GameOptionsInfo.option.set_player_deployment_to_player0.displayableName=Non-bot player entities with \"Use Owners*\" deployment set, use Player 0\'s settings, instead of current player\'s settings GameOptionsInfo.option.set_player_deployment_to_player0.description=Unchecked use current player deployments settings GameOptionsInfo.option.restrict_game_commands.displayableName=Restrict sensitive commands to non-Observers GameOptionsInfo.option.restrict_game_commands.description=If checked, commands such as /reset and /kick cannot be used by Observers while others are playing. \nUnchecked by default. From 2d419e1a7d16aaf877af3634ebff76adea99ef2a Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Fri, 24 Nov 2023 11:48:13 -0500 Subject: [PATCH 03/24] code cleanup --- megamek/src/megamek/server/Server.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/megamek/src/megamek/server/Server.java b/megamek/src/megamek/server/Server.java index 71f1ef98af5..8e06f2e7eb9 100644 --- a/megamek/src/megamek/server/Server.java +++ b/megamek/src/megamek/server/Server.java @@ -755,7 +755,7 @@ private Player addNewPlayer(int connId, String name, boolean isBot) { team = Player.TEAM_NONE; final GameOptions gOpts = getGame().getOptions(); if (isBot || !gOpts.booleanOption(OptionsConstants.BASE_SET_DEFAULT_TEAM_1)) { - for (Player p : getGame().getPlayersVector()) { + for (Player p : getGame().getPlayersList()) { if (p.getTeam() > team) { team = p.getTeam(); } From c4cd96c7ece7f5aa53a81ff76c6e29a8f7bd083d Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Fri, 24 Nov 2023 13:29:53 -0500 Subject: [PATCH 04/24] handle overlapping start positions and player display --- megamek/i18n/megamek/client/messages.properties | 1 + .../client/ui/swing/lobby/LobbyUtility.java | 15 +++++++++++++-- .../client/ui/swing/lobby/PlayerTable.java | 7 ++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/megamek/i18n/megamek/client/messages.properties b/megamek/i18n/megamek/client/messages.properties index 9a906e0d485..be658f4a361 100644 --- a/megamek/i18n/megamek/client/messages.properties +++ b/megamek/i18n/megamek/client/messages.properties @@ -772,6 +772,7 @@ ChatLounge.notDone=Not Done ChatLounge.PartialRepairs=Partial Repairs ChatLounge.Player=Player ChatLounge.Players=Players +ChatLounge.Player0=Player0 ChatLounge.quickView=Unit Quick View ChatLounge.OverlapDeploy.title=Must choose exclusive deployment zone ChatLounge.OverlapDeploy.msg=When using double blind, each player needs to have an exclusive deployment zone. diff --git a/megamek/src/megamek/client/ui/swing/lobby/LobbyUtility.java b/megamek/src/megamek/client/ui/swing/lobby/LobbyUtility.java index e56f521369a..a41c8223ff2 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/LobbyUtility.java +++ b/megamek/src/megamek/client/ui/swing/lobby/LobbyUtility.java @@ -73,11 +73,22 @@ static boolean isValidStartPos(Game game, Player player, int pos) { if (!isExclusiveDeployment(game)) { return true; } else { + final GameOptions gOpts = game.getOptions(); + List players = game.getPlayersList(); + + if (gOpts.booleanOption(OptionsConstants.BASE_SET_PLAYER_DEPLOYMENT_TO_PLAYER0) && !player.isBot() && player.getId() != 0) { + return true; + } + + if (gOpts.booleanOption(OptionsConstants.BASE_SET_PLAYER_DEPLOYMENT_TO_PLAYER0)) { + players = players.stream().filter(p -> p.isBot() || p.getId() == 0).collect(Collectors.toList()); + } + if (isTeamsShareVision(game)) { - return game.getPlayersVector().stream().filter(p -> p.isEnemyOf(player)) + return players.stream().filter(p -> p.isEnemyOf(player)) .noneMatch(p -> startPosOverlap(pos, p.getStartingPos())); } else { - return game.getPlayersVector().stream().filter(p -> !p.equals(player)) + return players.stream().filter(p -> !p.equals(player)) .noneMatch(p -> startPosOverlap(pos, p.getStartingPos())); } } diff --git a/megamek/src/megamek/client/ui/swing/lobby/PlayerTable.java b/megamek/src/megamek/client/ui/swing/lobby/PlayerTable.java index 0b320781159..d8e771c3ec3 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/PlayerTable.java +++ b/megamek/src/megamek/client/ui/swing/lobby/PlayerTable.java @@ -25,6 +25,7 @@ import megamek.client.ui.swing.util.UIUtil; import megamek.common.IStartingPositions; import megamek.common.Player; +import megamek.common.options.GameOptions; import megamek.common.options.OptionsConstants; import javax.swing.*; @@ -195,7 +196,11 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole result.append(guiScaledFontHTML()); String msg_start = Messages.getString("ChatLounge.Start"); - if ((player.getStartingPos() >= 0) && (player.getStartingPos() <= IStartingPositions.START_LOCATION_NAMES.length)) { + + final GameOptions gOpts = lobby.game().getOptions(); + if (gOpts.booleanOption(OptionsConstants.BASE_SET_PLAYER_DEPLOYMENT_TO_PLAYER0) && !player.isBot() && player.getId() != 0) { + result.append(msg_start + ": " + Messages.getString("ChatLounge.Player0")); + } else if ((player.getStartingPos() >= 0) && (player.getStartingPos() <= IStartingPositions.START_LOCATION_NAMES.length)) { result.append(msg_start + ": " + IStartingPositions.START_LOCATION_NAMES[player.getStartingPos()]); int so = player.getStartOffset(); int sw = player.getStartWidth(); From cf4f166f2aaeb460140d4ac8c2eada9e0386543a Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Fri, 24 Nov 2023 17:05:47 -0500 Subject: [PATCH 05/24] allow limiting Any deployment to a smaller square area --- .../client/ui/swing/CustomMechDialog.java | 49 +++++++++ .../client/ui/swing/MapDimensionsDialog.java | 16 +++ .../client/ui/swing/lobby/ChatLounge.java | 4 + .../ui/swing/lobby/LobbyMekCellFormatter.java | 9 ++ .../ui/swing/lobby/PlayerSettingsDialog.java | 54 ++++++++- .../client/ui/swing/lobby/PlayerTable.java | 9 ++ megamek/src/megamek/common/Board.java | 11 +- megamek/src/megamek/common/Entity.java | 103 ++++++++++++++++++ megamek/src/megamek/common/Player.java | 41 +++++++ megamek/src/megamek/server/Server.java | 4 + 10 files changed, 294 insertions(+), 6 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/CustomMechDialog.java b/megamek/src/megamek/client/ui/swing/CustomMechDialog.java index 030b086fbfc..070a1a26daf 100644 --- a/megamek/src/megamek/client/ui/swing/CustomMechDialog.java +++ b/megamek/src/megamek/client/ui/swing/CustomMechDialog.java @@ -85,6 +85,11 @@ public class CustomMechDialog extends AbstractButtonDialog implements ActionList private final JFormattedTextField txtDeploymentOffset = new JFormattedTextField(formatterFactory); private final JFormattedTextField txtDeploymentWidth = new JFormattedTextField(formatterFactory); + private JSpinner spinStartingAnyNWx; + private JSpinner spinStartingAnyNWy; + private JSpinner spinStartingAnySEx; + private JSpinner spinStartingAnySEy; + private final JLabel labDeployShutdown = new JLabel( Messages.getString("CustomMechDialog.labDeployShutdown"), SwingConstants.RIGHT); private final JCheckBox chDeployShutdown = new JCheckBox(); @@ -473,6 +478,17 @@ private void refreshDeployment() { txtDeploymentOffset.setText(Integer.toString(entity.getStartingOffset(false))); txtDeploymentWidth.setText(Integer.toString(entity.getStartingWidth(false))); + int bh = clientgui.getClient().getMapSettings().getBoardHeight(); + int bw = clientgui.getClient().getMapSettings().getBoardWidth(); + int x = entity.getStartingAnyNWx() + 1 >= bw ? bw : entity.getStartingAnyNWx() + 1; + spinStartingAnyNWx.setValue(x); + int y = entity.getStartingAnyNWy() + 1 >= bh ? bh : entity.getStartingAnyNWy() + 1; + spinStartingAnyNWy.setValue(y); + x = entity.getStartingAnySEx() + 1 >= bw ? bw : entity.getStartingAnySEx() + 1; + spinStartingAnySEy.setValue(x); + y = entity.getStartingAnySEy() + 1 >= bh ? bh : entity.getStartingAnySEy() + 1; + spinStartingAnySEy.setValue(y); + boolean enableDeploymentZoneControls = choDeploymentZone.isEnabled() && (choDeploymentZone.getSelectedIndex() > 0); txtDeploymentOffset.setEnabled(enableDeploymentZoneControls); txtDeploymentWidth.setEnabled(enableDeploymentZoneControls); @@ -881,6 +897,13 @@ protected void okAction() { entity.setStartingOffset(Integer.parseInt(txtDeploymentOffset.getText())); entity.setStartingWidth(Integer.parseInt(txtDeploymentWidth.getText())); + int x = (Integer) spinStartingAnyNWx.getValue() > (Integer) spinStartingAnySEx.getValue() ? (Integer) spinStartingAnySEx.getValue() : (Integer) spinStartingAnyNWx.getValue(); + int y = (Integer) spinStartingAnyNWy.getValue() > (Integer) spinStartingAnySEy.getValue() ? (Integer) spinStartingAnySEy.getValue() : (Integer) spinStartingAnyNWy.getValue(); + entity.setStartingAnyNWx(x - 1); + entity.setStartingAnyNWy(y - 1); + entity.setStartingAnySEx((Integer) spinStartingAnySEx.getValue() - 1); + entity.setStartingAnySEy((Integer) spinStartingAnySEy.getValue() - 1); + // Should the entity begin the game shutdown? if (chDeployShutdown.isSelected() && gameOptions().booleanOption(OptionsConstants.RPG_BEGIN_SHUTDOWN)) { entity.performManualShutdown(); @@ -1200,6 +1223,32 @@ protected Container createCenterPane() { panDeploy.add(labDeploymentWidth, GBC.std()); panDeploy.add(txtDeploymentWidth, GBC.eol()); + int bh = clientgui.getClient().getMapSettings().getBoardHeight(); + int bw = clientgui.getClient().getMapSettings().getBoardWidth(); + + panDeploy.add(new JLabel("Deployment Any NW corner:"), GBC.std()); + int x = entity.getStartingAnyNWx() + 1 >= bw ? bw : entity.getStartingAnyNWx() + 1; + SpinnerNumberModel mStartingAnyNWx = new SpinnerNumberModel(x, 0,bw, 1); + spinStartingAnyNWx = new JSpinner(mStartingAnyNWx); + spinStartingAnyNWx.setValue(x); + panDeploy.add(spinStartingAnyNWx, GBC.std()); + int y = entity.getStartingAnyNWy() + 1 >= bh ? bh : entity.getStartingAnyNWy() + 1; + SpinnerNumberModel mStartingAnyNWy = new SpinnerNumberModel(y, 0, bh, 1); + spinStartingAnyNWy = new JSpinner(mStartingAnyNWy); + spinStartingAnyNWy.setValue(y); + panDeploy.add(spinStartingAnyNWy, GBC.eol()); + panDeploy.add(new JLabel("Deployment Any SE corner:"), GBC.std()); + x = entity.getStartingAnySEx() + 1 >= bw ? bw : entity.getStartingAnySEx() + 1; + SpinnerNumberModel mStartingAnySEx = new SpinnerNumberModel(x, 0, bw, 1); + spinStartingAnySEx = new JSpinner(mStartingAnySEx); + spinStartingAnySEx.setValue(x); + panDeploy.add(spinStartingAnySEx, GBC.std()); + y = entity.getStartingAnySEy() + 1 >= bh ? bh : entity.getStartingAnySEy() + 1; + SpinnerNumberModel mStartingAnySEy = new SpinnerNumberModel(y, -0, bh, 1); + spinStartingAnySEy = new JSpinner(mStartingAnySEy); + spinStartingAnySEy.setValue(y); + panDeploy.add(spinStartingAnySEy, GBC.eol()); + numFormatter.setMinimum(0); numFormatter.setCommitsOnValidEdit(true); diff --git a/megamek/src/megamek/client/ui/swing/MapDimensionsDialog.java b/megamek/src/megamek/client/ui/swing/MapDimensionsDialog.java index 173f8349024..18056bc50c9 100644 --- a/megamek/src/megamek/client/ui/swing/MapDimensionsDialog.java +++ b/megamek/src/megamek/client/ui/swing/MapDimensionsDialog.java @@ -15,6 +15,7 @@ import megamek.client.ui.Messages; import megamek.client.ui.swing.util.UIUtil; +import megamek.common.Entity; import megamek.common.MapSettings; import javax.swing.*; @@ -281,6 +282,21 @@ private void apply() { mapSettings.setBoardSize(boardWidth, boardHeight); mapSettings.setMapSize(mapWidth, mapHeight); clientGUI.getClient().sendMapDimensions(mapSettings); + + for (Entity entity : clientGUI.getClient().getGame().getEntitiesVector()) { + if (entity.getStartingAnyNWx() >= boardWidth) { + entity.setStartingAnyNWx(boardWidth - 1); + } + if (entity.getStartingAnyNWy() >= boardHeight) { + entity.setStartingAnyNWy(boardHeight - 1); + } + if (entity.getStartingAnySEx() >= boardWidth) { + entity.setStartingAnySEx(boardWidth - 1); + } + if (entity.getStartingAnySEy() >= boardHeight) { + entity.setStartingAnySEy(boardHeight - 1); + } + } } diff --git a/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java b/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java index a988bd06549..bf2abf5cf3b 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java +++ b/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java @@ -1546,6 +1546,10 @@ public void configPlayer() { player.setStartingPos(startPos); player.setStartOffset(psd.getStartOffset()); player.setStartWidth(psd.getStartWidth()); + player.setStartingAnyNWx(psd.getStartingAnyNWx()); + player.setStartingAnyNWy(psd.getStartingAnyNWy()); + player.setStartingAnySEx(psd.getStartingAnySEx()); + player.setStartingAnySEy(psd.getStartingAnySEy()); c.sendPlayerInfo(); // If the gameoption set_arty_player_homeedge is set, adjust the player's offboard diff --git a/megamek/src/megamek/client/ui/swing/lobby/LobbyMekCellFormatter.java b/megamek/src/megamek/client/ui/swing/lobby/LobbyMekCellFormatter.java index 13d901b7a08..5092237ca9d 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/LobbyMekCellFormatter.java +++ b/megamek/src/megamek/client/ui/swing/lobby/LobbyMekCellFormatter.java @@ -262,6 +262,15 @@ static String formatUnitFull(Entity entity, ChatLounge lobby, boolean forceView) } String msg_start = Messages.getString("ChatLounge.Start"); result.append(" " + msg_start + ":" + IStartingPositions.START_LOCATION_NAMES[sp]); + if (sp == 0) { + int NWx = entity.getStartingAnyNWx() + 1; + int NWy = entity.getStartingAnyNWy() + 1; + int SEx = entity.getStartingAnySEx() + 1; + int SEy = entity.getStartingAnySEy() + 1; + if ((NWx + NWy + SEx + SEy) > 0) { + result.append("(" + NWx + ", " + NWy + ")-(" + SEx + ", " + SEy + ")"); + } + } int so = entity.getStartingOffset(true); int sw = entity.getStartingWidth(true); if ((so != 0) || (sw != 3)) { diff --git a/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java b/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java index f7374d79502..c1a5df37828 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java +++ b/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java @@ -120,6 +120,22 @@ public int getStartPos() { return currentPlayerStartPos; } + public int getStartingAnyNWx() { + return (Integer) spinStartingAnyNWx.getValue() - 1; + } + + public int getStartingAnyNWy() { + return (Integer) spinStartingAnyNWy.getValue() - 1; + } + + public int getStartingAnySEx() { + return (Integer) spinStartingAnySEx.getValue() - 1; + } + + public int getStartingAnySEy() { + return (Integer) spinStartingAnySEy.getValue() - 1; + } + /** * @return the current {@link SkillGenerationOptionsPanel} */ @@ -167,6 +183,10 @@ public String getEmail() { private final DefaultFormatterFactory formatterFactory = new DefaultFormatterFactory(numFormatter); private final JFormattedTextField txtOffset = new JFormattedTextField(formatterFactory, 0); private final JFormattedTextField txtWidth = new JFormattedTextField(formatterFactory, 3); + private JSpinner spinStartingAnyNWx; + private JSpinner spinStartingAnyNWy; + private JSpinner spinStartingAnySEx; + private JSpinner spinStartingAnySEy; // Bot Settings Section private final JButton butBotSettings = new JButton(Messages.getString("PlayerSettingsDialog.botSettings")); @@ -248,7 +268,17 @@ private JPanel deploymentParametersPanel() { result.add(txtOffset, GBC.eol()); result.add(lblWidth, GBC.std()); result.add(txtWidth, GBC.eol()); - + + int bh = clientgui.getClient().getMapSettings().getBoardHeight(); + int bw = clientgui.getClient().getMapSettings().getBoardWidth(); + + result.add(new JLabel("Deployment Any NW corner:"), GBC.std()); + result.add(spinStartingAnyNWx, GBC.std()); + result.add(spinStartingAnyNWy, GBC.eol()); + result.add(new JLabel("Deployment Any SE corner:"), GBC.std()); + result.add(spinStartingAnySEx, GBC.std()); + result.add(spinStartingAnySEy, GBC.eol()); + return result; } @@ -309,7 +339,27 @@ private void setupValues() { fldEmail.setText(player.getEmail()); txtWidth.setText(Integer.toString(player.getStartWidth())); txtOffset.setText(Integer.toString(player.getStartOffset())); - + + int bh = clientgui.getClient().getMapSettings().getBoardHeight(); + int bw = clientgui.getClient().getMapSettings().getBoardWidth(); + + SpinnerNumberModel mStartingAnyNWx = new SpinnerNumberModel(0, 0,bw, 1); + spinStartingAnyNWx = new JSpinner(mStartingAnyNWx); + SpinnerNumberModel mStartingAnyNWy = new SpinnerNumberModel(0, 0, bh, 1); + spinStartingAnyNWy = new JSpinner(mStartingAnyNWy); + SpinnerNumberModel mStartingAnySEx = new SpinnerNumberModel(0, 0, bw, 1); + spinStartingAnySEx = new JSpinner(mStartingAnySEx); + SpinnerNumberModel mStartingAnySEy = new SpinnerNumberModel(0, -0, bh, 1); + spinStartingAnySEy = new JSpinner(mStartingAnySEy); + + int x = player.getStartingAnyNWx() + 1 >= bw ? bw : player.getStartingAnyNWx() + 1; + spinStartingAnyNWx.setValue(x); + int y = player.getStartingAnyNWy() + 1 >= bh ? bh : player.getStartingAnyNWy() + 1; + spinStartingAnyNWy.setValue(y); + x = player.getStartingAnySEx() + 1 >= bw ? bw : player.getStartingAnySEx() + 1; + spinStartingAnySEx.setValue(x); + y = player.getStartingAnySEy() + 1 >= bh ? bh : player.getStartingAnySEy() + 1; + spinStartingAnySEy.setValue(y); } private void setupStartGrid() { diff --git a/megamek/src/megamek/client/ui/swing/lobby/PlayerTable.java b/megamek/src/megamek/client/ui/swing/lobby/PlayerTable.java index d8e771c3ec3..c4d360d1687 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/PlayerTable.java +++ b/megamek/src/megamek/client/ui/swing/lobby/PlayerTable.java @@ -202,6 +202,15 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole result.append(msg_start + ": " + Messages.getString("ChatLounge.Player0")); } else if ((player.getStartingPos() >= 0) && (player.getStartingPos() <= IStartingPositions.START_LOCATION_NAMES.length)) { result.append(msg_start + ": " + IStartingPositions.START_LOCATION_NAMES[player.getStartingPos()]); + if (player.getStartingPos() == 0) { + int NWx = player.getStartingAnyNWx() + 1; + int NWy = player.getStartingAnyNWy() + 1; + int SEx = player.getStartingAnySEx() + 1; + int SEy = player.getStartingAnySEy() + 1; + if ((NWx + NWy + SEx + SEy) > 0) { + result.append("(" + NWx + ", " + NWy + ")-(" + SEx + ", " + SEy + ")"); + } + } int so = player.getStartOffset(); int sw = player.getStartWidth(); if ((so != 0) || (sw != 3)) { diff --git a/megamek/src/megamek/common/Board.java b/megamek/src/megamek/common/Board.java index ecd7e834b65..b8a838422ec 100644 --- a/megamek/src/megamek/common/Board.java +++ b/megamek/src/megamek/common/Board.java @@ -846,7 +846,7 @@ public static boolean isValid(String board) { * Can the given player deploy at these coordinates? */ public boolean isLegalDeployment(Coords c, Player p) { - return isLegalDeployment(c, p.getStartingPos(), p.getStartWidth(), p.getStartOffset()); + return isLegalDeployment(c, p.getStartingPos(), p.getStartWidth(), p.getStartOffset(), p.getStartingAnyNWx(), p.getStartingAnyNWy(), p.getStartingAnySEx(), p.getStartingAnySEy()); } /** @@ -857,13 +857,13 @@ public boolean isLegalDeployment(Coords c, Entity e) { return false; } - return isLegalDeployment(c, e.getStartingPos(), e.getStartingWidth(), e.getStartingOffset()); + return isLegalDeployment(c, e.getStartingPos(), e.getStartingWidth(), e.getStartingOffset(), e.getStartingAnyNWx(), e.getStartingAnyNWy(), e.getStartingAnySEx(), e.getStartingAnySEy()); } /** * Can an object be deployed at these coordinates, given a starting zone, width of starting zone and offset from edge of board? */ - public boolean isLegalDeployment(Coords c, int zoneType, int startingWidth, int startingOffset) { + public boolean isLegalDeployment(Coords c, int zoneType, int startingWidth, int startingOffset, int startingAnyNWx, int startingAnyNWy, int startingAnySEx, int startingAnySEy) { if ((c == null) || !contains(c)) { return false; } @@ -876,7 +876,10 @@ public boolean isLegalDeployment(Coords c, int zoneType, int startingWidth, int switch (zoneType) { case START_ANY: - return true; + return (((startingAnyNWx == -1) || (c.getX() >= startingAnyNWx)) + && ((startingAnySEx == -1) || (c.getX() <= startingAnySEx)) + && ((startingAnyNWy == -1) || (c.getY() >= startingAnyNWy)) + && ((startingAnySEy == -1) || (c.getY() <= startingAnySEy))); case START_NW: return ((c.getX() < (minx + nLimit)) && (c.getX() >= minx) && (c.getY() >= miny) && (c.getY() < (height / 2))) || ((c.getY() < (miny + nLimit)) && (c.getY() >= miny) && (c.getX() >= minx) && (c.getX() < (width / 2))); diff --git a/megamek/src/megamek/common/Entity.java b/megamek/src/megamek/common/Entity.java index cfaffa1822e..86a9289ab26 100644 --- a/megamek/src/megamek/common/Entity.java +++ b/megamek/src/megamek/common/Entity.java @@ -210,6 +210,11 @@ public abstract class Entity extends TurnOrdered implements Transporter, Targeta private int startingOffset = 0; private int startingWidth = 3; + private int startingAnyNWx = -1; + private int startingAnyNWy = -1; + private int startingAnySEx = -1; + private int startingAnySEy = -1; + /** * The pilot of the entity. Even infantry has a 'pilot'. */ @@ -15334,10 +15339,108 @@ public void setStartingWidth(int startingWidth) { this.startingWidth = startingWidth; } + public int getStartingAnyNWx() { + return getStartingAnyNWx(true); + } + + public int getStartingAnyNWx(boolean inheritFromOwner) { + // if we are given permission to use the owner's settings + // and have specified entity-specific settings, use the owner's settings + if (inheritFromOwner && (startingPos == Board.START_NONE)) { + final GameOptions gOpts = getGame().getOptions(); + if (!getOwner().isBot() && gOpts.booleanOption(OptionsConstants.BASE_SET_PLAYER_DEPLOYMENT_TO_PLAYER0)) { + return game.getPlayer(0).getStartingAnyNWx(); + } + else { + return getOwner().getStartingAnyNWx(); + } + } + + return startingAnyNWx; + } + + public void setStartingAnyNWx(int i) { + this.startingAnyNWx = i; + } + + public int getStartingAnyNWy() { + return getStartingAnyNWy(true); + } + + public int getStartingAnyNWy(boolean inheritFromOwner) { + // if we are given permission to use the owner's settings + // and have specified entity-specific settings, use the owner's settings + if (inheritFromOwner && (startingPos == Board.START_NONE)) { + final GameOptions gOpts = getGame().getOptions(); + if (!getOwner().isBot() && gOpts.booleanOption(OptionsConstants.BASE_SET_PLAYER_DEPLOYMENT_TO_PLAYER0)) { + return game.getPlayer(0).getStartingAnyNWy(); + } + else { + return getOwner().getStartingAnyNWy(); + } + } + + return startingAnyNWy; + } + + public void setStartingAnyNWy(int i) { + this.startingAnyNWy = i; + } + + public int getStartingAnySEx() { + return getStartingAnySEx(true); + } + + public int getStartingAnySEx(boolean inheritFromOwner) { + // if we are given permission to use the owner's settings + // and have specified entity-specific settings, use the owner's settings + if (inheritFromOwner && (startingPos == Board.START_NONE)) { + final GameOptions gOpts = getGame().getOptions(); + if (!getOwner().isBot() && gOpts.booleanOption(OptionsConstants.BASE_SET_PLAYER_DEPLOYMENT_TO_PLAYER0)) { + return game.getPlayer(0).getStartingAnySEx(); + } + else { + return getOwner().getStartingAnySEx(); + } + } + + return startingAnySEx; + } + + public void setStartingAnySEx(int i) { + this.startingAnySEx = i; + } + + public int getStartingAnySEy() { + return getStartingAnySEy(true); + } + + public int getStartingAnySEy(boolean inheritFromOwner) { + // if we are given permission to use the owner's settings + // and have specified entity-specific settings, use the owner's settings + if (inheritFromOwner && (startingPos == Board.START_NONE)) { + final GameOptions gOpts = getGame().getOptions(); + if (!getOwner().isBot() && gOpts.booleanOption(OptionsConstants.BASE_SET_PLAYER_DEPLOYMENT_TO_PLAYER0)) { + return game.getPlayer(0).getStartingAnySEy(); + } + else { + return getOwner().getStartingAnySEy(); + } + } + + return startingAnySEy; + } + + public void setStartingAnySEy(int i) { + this.startingAnySEy = i; + } + public int getBloodStalkerTarget() { return bloodStalkerTarget; } + + /** * Whether this entity can activate the "blood stalker" ability */ diff --git a/megamek/src/megamek/common/Player.java b/megamek/src/megamek/common/Player.java index f88228a2c98..0d65990e5ea 100644 --- a/megamek/src/megamek/common/Player.java +++ b/megamek/src/megamek/common/Player.java @@ -56,6 +56,10 @@ public final class Player extends TurnOrdered { private int startingPos = Board.START_ANY; private int startOffset = 0; private int startWidth = 3; + private int startingAnyNWx = -1; + private int startingAnyNWy = -1; + private int startingAnySEx = -1; + private int startingAnySEy = -1; // number of minefields private int numMfConv = 0; @@ -384,6 +388,38 @@ public void setStartWidth(int startWidth) { this.startWidth = startWidth; } + public int getStartingAnyNWx() { + return startingAnyNWx; + } + + public void setStartingAnyNWx(int i) { + this.startingAnyNWx = i; + } + + public int getStartingAnyNWy() { + return startingAnyNWy; + } + + public void setStartingAnyNWy(int i) { + this.startingAnyNWy = i; + } + + public int getStartingAnySEx() { + return startingAnySEx; + } + + public void setStartingAnySEx(int i) { + this.startingAnySEx = i; + } + + public int getStartingAnySEy() { + return startingAnySEy; + } + + public void setStartingAnySEy(int i) { + this.startingAnySEy = i; + } + /** * Set deployment zone to edge of board for reinforcements */ @@ -748,6 +784,11 @@ public Player copy() { copy.startOffset = startOffset; copy.startWidth = startWidth; + copy.startingAnyNWx = startingAnyNWx; + copy.startingAnyNWy = startingAnyNWy; + copy.startingAnySEx = startingAnySEx; + copy.startingAnySEy = startingAnySEy; + copy.numMfConv = numMfConv; copy.numMfCmd = numMfCmd; copy.numMfVibra = numMfVibra; diff --git a/megamek/src/megamek/server/Server.java b/megamek/src/megamek/server/Server.java index 8e06f2e7eb9..23d452d2ff0 100644 --- a/megamek/src/megamek/server/Server.java +++ b/megamek/src/megamek/server/Server.java @@ -544,6 +544,10 @@ private void receivePlayerInfo(Packet packet, int connId) { gamePlayer.setStartingPos(player.getStartingPos()); gamePlayer.setStartWidth(player.getStartWidth()); gamePlayer.setStartOffset(player.getStartOffset()); + gamePlayer.setStartingAnyNWx(player.getStartingAnyNWx()); + gamePlayer.setStartingAnyNWy(player.getStartingAnyNWy()); + gamePlayer.setStartingAnySEx(player.getStartingAnySEx()); + gamePlayer.setStartingAnySEy(player.getStartingAnySEy()); gamePlayer.setTeam(player.getTeam()); gamePlayer.setCamouflage(player.getCamouflage().clone()); gamePlayer.setNbrMFConventional(player.getNbrMFConventional()); From 688dc507e4814b26819d2b4731fc3e22bdc7756f Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Fri, 24 Nov 2023 18:31:20 -0500 Subject: [PATCH 06/24] code cleanup --- megamek/i18n/megamek/client/messages.properties | 2 ++ .../client/ui/swing/CustomMechDialog.java | 4 ++-- .../client/ui/swing/MapDimensionsDialog.java | 16 ---------------- .../ui/swing/lobby/LobbyMekCellFormatter.java | 3 ++- .../ui/swing/lobby/PlayerSettingsDialog.java | 7 ++----- .../client/ui/swing/lobby/PlayerTable.java | 2 +- megamek/src/megamek/common/Entity.java | 2 -- 7 files changed, 9 insertions(+), 27 deletions(-) diff --git a/megamek/i18n/megamek/client/messages.properties b/megamek/i18n/megamek/client/messages.properties index be658f4a361..764d8ee4851 100644 --- a/megamek/i18n/megamek/client/messages.properties +++ b/megamek/i18n/megamek/client/messages.properties @@ -1431,6 +1431,8 @@ CustomMechDialog.labDeploymentOffset=Deployment Zone Offset: CustomMechDialog.labDeploymentOffsetTip=Deployment Zone Offset, in hexes from corresponding map edge CustomMechDialog.labDeploymentWidth=Deployment Zone Width: CustomMechDialog.labDeploymentWidthTip=Deployment Zone width, in hexes +CustomMechDialog.labDeploymentAnyNW=Deployment Any NW corner: +CustomMechDialog.labDeploymentAnySE=Deployment Any SE corner: CustomMechDialog.labDeployShutdown=Shutdown CustomMechDialog.labDeployProne=Prone CustomMechDialog.labDeployHullDown=Hull Down diff --git a/megamek/src/megamek/client/ui/swing/CustomMechDialog.java b/megamek/src/megamek/client/ui/swing/CustomMechDialog.java index 070a1a26daf..07f980158ec 100644 --- a/megamek/src/megamek/client/ui/swing/CustomMechDialog.java +++ b/megamek/src/megamek/client/ui/swing/CustomMechDialog.java @@ -1226,7 +1226,7 @@ protected Container createCenterPane() { int bh = clientgui.getClient().getMapSettings().getBoardHeight(); int bw = clientgui.getClient().getMapSettings().getBoardWidth(); - panDeploy.add(new JLabel("Deployment Any NW corner:"), GBC.std()); + panDeploy.add(new JLabel(Messages.getString("CustomMechDialog.labDeploymentAnyNW")), GBC.std()); int x = entity.getStartingAnyNWx() + 1 >= bw ? bw : entity.getStartingAnyNWx() + 1; SpinnerNumberModel mStartingAnyNWx = new SpinnerNumberModel(x, 0,bw, 1); spinStartingAnyNWx = new JSpinner(mStartingAnyNWx); @@ -1237,7 +1237,7 @@ protected Container createCenterPane() { spinStartingAnyNWy = new JSpinner(mStartingAnyNWy); spinStartingAnyNWy.setValue(y); panDeploy.add(spinStartingAnyNWy, GBC.eol()); - panDeploy.add(new JLabel("Deployment Any SE corner:"), GBC.std()); + panDeploy.add(new JLabel(Messages.getString("CustomMechDialog.labDeploymentAnySE")), GBC.std()); x = entity.getStartingAnySEx() + 1 >= bw ? bw : entity.getStartingAnySEx() + 1; SpinnerNumberModel mStartingAnySEx = new SpinnerNumberModel(x, 0, bw, 1); spinStartingAnySEx = new JSpinner(mStartingAnySEx); diff --git a/megamek/src/megamek/client/ui/swing/MapDimensionsDialog.java b/megamek/src/megamek/client/ui/swing/MapDimensionsDialog.java index 18056bc50c9..173f8349024 100644 --- a/megamek/src/megamek/client/ui/swing/MapDimensionsDialog.java +++ b/megamek/src/megamek/client/ui/swing/MapDimensionsDialog.java @@ -15,7 +15,6 @@ import megamek.client.ui.Messages; import megamek.client.ui.swing.util.UIUtil; -import megamek.common.Entity; import megamek.common.MapSettings; import javax.swing.*; @@ -282,21 +281,6 @@ private void apply() { mapSettings.setBoardSize(boardWidth, boardHeight); mapSettings.setMapSize(mapWidth, mapHeight); clientGUI.getClient().sendMapDimensions(mapSettings); - - for (Entity entity : clientGUI.getClient().getGame().getEntitiesVector()) { - if (entity.getStartingAnyNWx() >= boardWidth) { - entity.setStartingAnyNWx(boardWidth - 1); - } - if (entity.getStartingAnyNWy() >= boardHeight) { - entity.setStartingAnyNWy(boardHeight - 1); - } - if (entity.getStartingAnySEx() >= boardWidth) { - entity.setStartingAnySEx(boardWidth - 1); - } - if (entity.getStartingAnySEy() >= boardHeight) { - entity.setStartingAnySEy(boardHeight - 1); - } - } } diff --git a/megamek/src/megamek/client/ui/swing/lobby/LobbyMekCellFormatter.java b/megamek/src/megamek/client/ui/swing/lobby/LobbyMekCellFormatter.java index 5092237ca9d..9002a0a4ca8 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/LobbyMekCellFormatter.java +++ b/megamek/src/megamek/client/ui/swing/lobby/LobbyMekCellFormatter.java @@ -267,8 +267,9 @@ static String formatUnitFull(Entity entity, ChatLounge lobby, boolean forceView) int NWy = entity.getStartingAnyNWy() + 1; int SEx = entity.getStartingAnySEx() + 1; int SEy = entity.getStartingAnySEy() + 1; + int hexes = (1 + SEx - NWx) * (1 + SEy - NWy); if ((NWx + NWy + SEx + SEy) > 0) { - result.append("(" + NWx + ", " + NWy + ")-(" + SEx + ", " + SEy + ")"); + result.append(" (" + NWx + ", " + NWy + ")-(" + SEx + ", " + SEy + ") (" + hexes + ")"); } } int so = entity.getStartingOffset(true); diff --git a/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java b/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java index c1a5df37828..bbe93c35e9f 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java +++ b/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java @@ -269,13 +269,10 @@ private JPanel deploymentParametersPanel() { result.add(lblWidth, GBC.std()); result.add(txtWidth, GBC.eol()); - int bh = clientgui.getClient().getMapSettings().getBoardHeight(); - int bw = clientgui.getClient().getMapSettings().getBoardWidth(); - - result.add(new JLabel("Deployment Any NW corner:"), GBC.std()); + result.add(new JLabel(Messages.getString("CustomMechDialog.labDeploymentAnyNW")), GBC.std()); result.add(spinStartingAnyNWx, GBC.std()); result.add(spinStartingAnyNWy, GBC.eol()); - result.add(new JLabel("Deployment Any SE corner:"), GBC.std()); + result.add(new JLabel(Messages.getString("CustomMechDialog.labDeploymentAnySE")), GBC.std()); result.add(spinStartingAnySEx, GBC.std()); result.add(spinStartingAnySEy, GBC.eol()); diff --git a/megamek/src/megamek/client/ui/swing/lobby/PlayerTable.java b/megamek/src/megamek/client/ui/swing/lobby/PlayerTable.java index c4d360d1687..0dd61a484d0 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/PlayerTable.java +++ b/megamek/src/megamek/client/ui/swing/lobby/PlayerTable.java @@ -208,7 +208,7 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole int SEx = player.getStartingAnySEx() + 1; int SEy = player.getStartingAnySEy() + 1; if ((NWx + NWy + SEx + SEy) > 0) { - result.append("(" + NWx + ", " + NWy + ")-(" + SEx + ", " + SEy + ")"); + result.append(" (" + NWx + ", " + NWy + ")-(" + SEx + ", " + SEy + ")"); } } int so = player.getStartOffset(); diff --git a/megamek/src/megamek/common/Entity.java b/megamek/src/megamek/common/Entity.java index 86a9289ab26..014de3df56c 100644 --- a/megamek/src/megamek/common/Entity.java +++ b/megamek/src/megamek/common/Entity.java @@ -15439,8 +15439,6 @@ public int getBloodStalkerTarget() { return bloodStalkerTarget; } - - /** * Whether this entity can activate the "blood stalker" ability */ From 11a8d305d2e2cea60adf4f65a7829bff3f2995f2 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 25 Nov 2023 08:21:51 -0500 Subject: [PATCH 07/24] show player deployments on map preview --- .../i18n/megamek/client/messages.properties | 1 + .../client/ui/swing/CustomMechDialog.java | 16 ++++++++-------- .../client/ui/swing/boardview/BoardView.java | 19 ++++++++++++------- .../client/ui/swing/lobby/ChatLounge.java | 19 ++++++++++++++++++- 4 files changed, 39 insertions(+), 16 deletions(-) diff --git a/megamek/i18n/megamek/client/messages.properties b/megamek/i18n/megamek/client/messages.properties index 764d8ee4851..983453a07b1 100644 --- a/megamek/i18n/megamek/client/messages.properties +++ b/megamek/i18n/megamek/client/messages.properties @@ -285,6 +285,7 @@ BoardSelectionDialog.UpdateSize=Update Size BoardSelectionDialog.Updating=Updating... BoardSelectionDialog.ViewGameBoard=Preview Game Map... * BoardSelectionDialog.ViewGameBoardTooltip=Shows a preview of the game's map.
* Note: For generated maps and surprise maps the preview is only a sample
and will not be the same as the actual map used. +BoardSelectionDialog.ViewGameBoardButton=refresh preview #Game board tooltips BoardView1.ACTIVATING=ACTIVATING diff --git a/megamek/src/megamek/client/ui/swing/CustomMechDialog.java b/megamek/src/megamek/client/ui/swing/CustomMechDialog.java index 07f980158ec..8767123293f 100644 --- a/megamek/src/megamek/client/ui/swing/CustomMechDialog.java +++ b/megamek/src/megamek/client/ui/swing/CustomMechDialog.java @@ -480,13 +480,13 @@ private void refreshDeployment() { int bh = clientgui.getClient().getMapSettings().getBoardHeight(); int bw = clientgui.getClient().getMapSettings().getBoardWidth(); - int x = entity.getStartingAnyNWx() + 1 >= bw ? bw : entity.getStartingAnyNWx() + 1; + int x = Math.min(entity.getStartingAnyNWx(false) + 1, bw); spinStartingAnyNWx.setValue(x); - int y = entity.getStartingAnyNWy() + 1 >= bh ? bh : entity.getStartingAnyNWy() + 1; + int y = Math.min(entity.getStartingAnyNWy(false) + 1, bh); spinStartingAnyNWy.setValue(y); - x = entity.getStartingAnySEx() + 1 >= bw ? bw : entity.getStartingAnySEx() + 1; + x = Math.min(entity.getStartingAnySEx(false) + 1, bw); spinStartingAnySEy.setValue(x); - y = entity.getStartingAnySEy() + 1 >= bh ? bh : entity.getStartingAnySEy() + 1; + y = Math.min(entity.getStartingAnySEy(false) + 1, bh); spinStartingAnySEy.setValue(y); boolean enableDeploymentZoneControls = choDeploymentZone.isEnabled() && (choDeploymentZone.getSelectedIndex() > 0); @@ -1227,23 +1227,23 @@ protected Container createCenterPane() { int bw = clientgui.getClient().getMapSettings().getBoardWidth(); panDeploy.add(new JLabel(Messages.getString("CustomMechDialog.labDeploymentAnyNW")), GBC.std()); - int x = entity.getStartingAnyNWx() + 1 >= bw ? bw : entity.getStartingAnyNWx() + 1; + int x = Math.min(entity.getStartingAnyNWx(false) + 1, bw); SpinnerNumberModel mStartingAnyNWx = new SpinnerNumberModel(x, 0,bw, 1); spinStartingAnyNWx = new JSpinner(mStartingAnyNWx); spinStartingAnyNWx.setValue(x); panDeploy.add(spinStartingAnyNWx, GBC.std()); - int y = entity.getStartingAnyNWy() + 1 >= bh ? bh : entity.getStartingAnyNWy() + 1; + int y = Math.min(entity.getStartingAnyNWy(false) + 1, bh); SpinnerNumberModel mStartingAnyNWy = new SpinnerNumberModel(y, 0, bh, 1); spinStartingAnyNWy = new JSpinner(mStartingAnyNWy); spinStartingAnyNWy.setValue(y); panDeploy.add(spinStartingAnyNWy, GBC.eol()); panDeploy.add(new JLabel(Messages.getString("CustomMechDialog.labDeploymentAnySE")), GBC.std()); - x = entity.getStartingAnySEx() + 1 >= bw ? bw : entity.getStartingAnySEx() + 1; + x = Math.min(entity.getStartingAnySEx(false) + 1, bw); SpinnerNumberModel mStartingAnySEx = new SpinnerNumberModel(x, 0, bw, 1); spinStartingAnySEx = new JSpinner(mStartingAnySEx); spinStartingAnySEx.setValue(x); panDeploy.add(spinStartingAnySEx, GBC.std()); - y = entity.getStartingAnySEy() + 1 >= bh ? bh : entity.getStartingAnySEy() + 1; + y = Math.min(entity.getStartingAnySEy(false) + 1, bh); SpinnerNumberModel mStartingAnySEy = new SpinnerNumberModel(y, -0, bh, 1); spinStartingAnySEy = new JSpinner(mStartingAnySEy); spinStartingAnySEy.setValue(y); diff --git a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java index cb803585f47..c9e52643c15 100644 --- a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java +++ b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java @@ -1138,7 +1138,8 @@ public synchronized void paintComponent(Graphics g) { drawDeployment(g); } - if (game.getPhase().isSetArtilleryAutohitHexes() && showAllDeployment) { + if ((game.getPhase().isSetArtilleryAutohitHexes() && showAllDeployment) + || (game.getPhase().isLounge())) { drawAllDeployment(g); } @@ -1850,20 +1851,24 @@ private void drawAllDeployment(Graphics g) { int drawWidth = (view.width / (int) (HEX_WC * scale)) + 3; int drawHeight = (view.height / (int) (HEX_H * scale)) + 3; + List players = game.getPlayersList(); + final GameOptions gOpts = game.getOptions(); + + if (gOpts.booleanOption(OptionsConstants.BASE_SET_PLAYER_DEPLOYMENT_TO_PLAYER0)) { + players = players.stream().filter(p -> p.isBot() || p.getId() == 0).collect(Collectors.toList()); + } + Board board = game.getBoard(); // loop through the hexes for (int i = 0; i < drawHeight; i++) { for (int j = 0; j < drawWidth; j++) { Coords c = new Coords(j + drawX, i + drawY); - Enumeration allP = game.getPlayers(); - Player cp; int pCount = 0; int bThickness = 1 + 10 / game.getNoOfPlayers(); // loop through all players - while (allP.hasMoreElements()) { - cp = allP.nextElement(); - if (board.isLegalDeployment(c, cp)) { - Color bC = cp.getColour().getColour(); + for (Player player : players) { + if (board.isLegalDeployment(c, player)) { + Color bC = player.getColour().getColour(); drawHexBorder(g, getHexLocation(c), bC, (bThickness + 2) * pCount, bThickness); pCount++; } diff --git a/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java b/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java index bf2abf5cf3b..34637287758 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java +++ b/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java @@ -44,6 +44,7 @@ import megamek.client.ui.swing.widget.SkinSpecification; import megamek.common.*; import megamek.common.annotations.Nullable; +import megamek.common.enums.GamePhase; import megamek.common.event.*; import megamek.common.force.Force; import megamek.common.force.Forces; @@ -753,10 +754,17 @@ public void componentShown(ComponentEvent e) { boardPreviewW.setLocationRelativeTo(clientgui.frame); try { + boardPreviewGame.setPhase(GamePhase.LOUNGE); previewBV = new BoardView(boardPreviewGame, null, null); previewBV.setDisplayInvalidHexInfo(false); previewBV.setUseLOSTool(false); - boardPreviewW.add(previewBV.getComponent(true)); + JButton bpButton = new JButton(Messages.getString("BoardSelectionDialog.ViewGameBoardButton")); + bpButton.addActionListener(e -> previewGameBoard()); + JPanel bpPanel = new JPanel(); + bpPanel.setLayout(new BoxLayout(bpPanel, BoxLayout.PAGE_AXIS)); + bpPanel.add(bpButton); + bpPanel.add(previewBV.getComponent(true)); + boardPreviewW.add(bpPanel); boardPreviewW.setSize(clientgui.frame.getWidth() / 2, clientgui.frame.getHeight() / 2); // Most boards will be far too large on the standard zoom previewBV.zoomOut(); @@ -1138,6 +1146,15 @@ private void markServerSideBoard(BufferedImage image) { public void previewGameBoard() { Board newBoard = getPossibleGameBoard(false); boardPreviewGame.setBoard(newBoard); + final GameOptions gOpts = game().getOptions(); + boardPreviewGame.setOptions(gOpts); + + for (Player player : game().getPlayersList()) { + boardPreviewGame.removePlayer(player.getId()); + } + for (Player player : game().getPlayersList()) { + boardPreviewGame.setPlayer(player.getId(), player); + } boardPreviewW.setVisible(true); } From ec892040a8133a6f7dc55e1f5c474067ca9d3ae1 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 25 Nov 2023 11:23:31 -0500 Subject: [PATCH 08/24] if blind drop hid player deployment zones from non gm player --- megamek/i18n/megamek/client/messages.properties | 1 + .../src/megamek/client/ui/swing/boardview/BoardView.java | 6 ++++++ .../src/megamek/client/ui/swing/lobby/ChatLounge.java | 1 + .../client/ui/swing/lobby/PlayerSettingsDialog.java | 8 ++++---- .../src/megamek/client/ui/swing/lobby/PlayerTable.java | 9 ++++++++- 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/megamek/i18n/megamek/client/messages.properties b/megamek/i18n/megamek/client/messages.properties index 983453a07b1..d04f0123509 100644 --- a/megamek/i18n/megamek/client/messages.properties +++ b/megamek/i18n/megamek/client/messages.properties @@ -774,6 +774,7 @@ ChatLounge.PartialRepairs=Partial Repairs ChatLounge.Player=Player ChatLounge.Players=Players ChatLounge.Player0=Player0 +ChatLounge.Blind=Blind ChatLounge.quickView=Unit Quick View ChatLounge.OverlapDeploy.title=Must choose exclusive deployment zone ChatLounge.OverlapDeploy.msg=When using double blind, each player needs to have an exclusive deployment zone. diff --git a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java index c9e52643c15..ee4b2f6f4e1 100644 --- a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java +++ b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java @@ -1858,6 +1858,12 @@ private void drawAllDeployment(Graphics g) { players = players.stream().filter(p -> p.isBot() || p.getId() == 0).collect(Collectors.toList()); } + if (game.getPhase().isLounge() && !localPlayer.isGameMaster() + && (gOpts.booleanOption(OptionsConstants.BASE_BLIND_DROP) + || gOpts.booleanOption(OptionsConstants.BASE_REAL_BLIND_DROP)) ) { + players = players.stream().filter(p -> !p.isEnemyOf(localPlayer)).collect(Collectors.toList()); + } + Board board = game.getBoard(); // loop through the hexes for (int i = 0; i < drawHeight; i++) { diff --git a/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java b/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java index 34637287758..27e2ac345bb 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java +++ b/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java @@ -1146,6 +1146,7 @@ private void markServerSideBoard(BufferedImage image) { public void previewGameBoard() { Board newBoard = getPossibleGameBoard(false); boardPreviewGame.setBoard(newBoard); + previewBV.setLocalPlayer(client().getLocalPlayer()); final GameOptions gOpts = game().getOptions(); boardPreviewGame.setOptions(gOpts); diff --git a/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java b/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java index bbe93c35e9f..95617602a7c 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java +++ b/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java @@ -349,13 +349,13 @@ private void setupValues() { SpinnerNumberModel mStartingAnySEy = new SpinnerNumberModel(0, -0, bh, 1); spinStartingAnySEy = new JSpinner(mStartingAnySEy); - int x = player.getStartingAnyNWx() + 1 >= bw ? bw : player.getStartingAnyNWx() + 1; + int x = Math.min(player.getStartingAnyNWx() + 1, bw); spinStartingAnyNWx.setValue(x); - int y = player.getStartingAnyNWy() + 1 >= bh ? bh : player.getStartingAnyNWy() + 1; + int y = Math.min(player.getStartingAnyNWy() + 1, bh); spinStartingAnyNWy.setValue(y); - x = player.getStartingAnySEx() + 1 >= bw ? bw : player.getStartingAnySEx() + 1; + x = Math.min(player.getStartingAnySEx() + 1, bw); spinStartingAnySEx.setValue(x); - y = player.getStartingAnySEy() + 1 >= bh ? bh : player.getStartingAnySEy() + 1; + y = Math.min(player.getStartingAnySEy() + 1, bh); spinStartingAnySEy.setValue(y); } diff --git a/megamek/src/megamek/client/ui/swing/lobby/PlayerTable.java b/megamek/src/megamek/client/ui/swing/lobby/PlayerTable.java index 0dd61a484d0..78ad59fddac 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/PlayerTable.java +++ b/megamek/src/megamek/client/ui/swing/lobby/PlayerTable.java @@ -200,8 +200,15 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole final GameOptions gOpts = lobby.game().getOptions(); if (gOpts.booleanOption(OptionsConstants.BASE_SET_PLAYER_DEPLOYMENT_TO_PLAYER0) && !player.isBot() && player.getId() != 0) { result.append(msg_start + ": " + Messages.getString("ChatLounge.Player0")); - } else if ((player.getStartingPos() >= 0) && (player.getStartingPos() <= IStartingPositions.START_LOCATION_NAMES.length)) { + } else if ((!lobby.client().getLocalPlayer().isGameMaster() + && (isEnemy) + && (gOpts.booleanOption(OptionsConstants.BASE_BLIND_DROP) + || gOpts.booleanOption(OptionsConstants.BASE_REAL_BLIND_DROP)))) { + result.append(msg_start + ": " + Messages.getString("ChatLounge.Blind")); + } else if ((player.getStartingPos() >= 0) + && (player.getStartingPos() <= IStartingPositions.START_LOCATION_NAMES.length)) { result.append(msg_start + ": " + IStartingPositions.START_LOCATION_NAMES[player.getStartingPos()]); + if (player.getStartingPos() == 0) { int NWx = player.getStartingAnyNWx() + 1; int NWy = player.getStartingAnyNWy() + 1; From 262b7307950079f67199174c3cfcb8c3da8ecda8 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 25 Nov 2023 11:37:11 -0500 Subject: [PATCH 09/24] code cleanup --- megamek/src/megamek/client/ui/swing/CustomMechDialog.java | 4 ++-- .../megamek/client/ui/swing/lobby/PlayerSettingsDialog.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/CustomMechDialog.java b/megamek/src/megamek/client/ui/swing/CustomMechDialog.java index 8767123293f..ec06ce966fa 100644 --- a/megamek/src/megamek/client/ui/swing/CustomMechDialog.java +++ b/megamek/src/megamek/client/ui/swing/CustomMechDialog.java @@ -897,8 +897,8 @@ protected void okAction() { entity.setStartingOffset(Integer.parseInt(txtDeploymentOffset.getText())); entity.setStartingWidth(Integer.parseInt(txtDeploymentWidth.getText())); - int x = (Integer) spinStartingAnyNWx.getValue() > (Integer) spinStartingAnySEx.getValue() ? (Integer) spinStartingAnySEx.getValue() : (Integer) spinStartingAnyNWx.getValue(); - int y = (Integer) spinStartingAnyNWy.getValue() > (Integer) spinStartingAnySEy.getValue() ? (Integer) spinStartingAnySEy.getValue() : (Integer) spinStartingAnyNWy.getValue(); + int x = Math.min((Integer) spinStartingAnyNWx.getValue(), (Integer) spinStartingAnySEx.getValue()); + int y = Math.min((Integer) spinStartingAnyNWy.getValue(), (Integer) spinStartingAnySEy.getValue()); entity.setStartingAnyNWx(x - 1); entity.setStartingAnyNWy(y - 1); entity.setStartingAnySEx((Integer) spinStartingAnySEx.getValue() - 1); diff --git a/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java b/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java index 95617602a7c..619da27e234 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java +++ b/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java @@ -121,11 +121,11 @@ public int getStartPos() { } public int getStartingAnyNWx() { - return (Integer) spinStartingAnyNWx.getValue() - 1; + return Math.min((Integer) spinStartingAnyNWx.getValue(), (Integer) spinStartingAnySEx.getValue()) - 1; } public int getStartingAnyNWy() { - return (Integer) spinStartingAnyNWy.getValue() - 1; + return Math.min((Integer) spinStartingAnyNWy.getValue(), (Integer) spinStartingAnySEy.getValue()) - 1; } public int getStartingAnySEx() { From b3150d6ff0059c23bb8546c102363d86526b8f3e Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 25 Nov 2023 13:00:20 -0500 Subject: [PATCH 10/24] allow gm to see and edit all units on any team hidden or not in lobby --- .../src/megamek/client/ui/swing/lobby/ChatLounge.java | 8 +++++--- .../megamek/client/ui/swing/lobby/LobbyActions.java | 7 +++++-- .../client/ui/swing/lobby/LobbyMekCellFormatter.java | 6 ++++-- .../megamek/client/ui/swing/lobby/MekTableModel.java | 10 +++++++--- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java b/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java index 27e2ac345bb..43ffa2e25c6 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java +++ b/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java @@ -1269,7 +1269,8 @@ private void refreshMekTable() { boolean localUnit = entity.getOwner().equals(localPlayer()); boolean teamUnit = !entity.getOwner().isEnemyOf(localPlayer()); boolean realBlindDrop = opts.booleanOption(OptionsConstants.BASE_REAL_BLIND_DROP); - if (localUnit || teamUnit || !realBlindDrop) { + boolean localGM = localPlayer().isGameMaster(); + if (localUnit || teamUnit || !realBlindDrop || localGM) { mekModel.addUnit(entity); } } @@ -1504,8 +1505,9 @@ void disembarkAll(Collection entities) { * own units (and bots) though. */ boolean isEditable(Entity entity) { - return clientgui.getLocalBots().containsKey(entity.getOwner().getName()) - || (entity.getOwnerId() == localPlayer().getId()); + boolean localGM = clientgui.getClient().getLocalPlayer().isGameMaster(); + return !localGM && (clientgui.getLocalBots().containsKey(entity.getOwner().getName()) + || (entity.getOwnerId() == localPlayer().getId())); } /** diff --git a/megamek/src/megamek/client/ui/swing/lobby/LobbyActions.java b/megamek/src/megamek/client/ui/swing/lobby/LobbyActions.java index d1771161181..33faa6b18b3 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/LobbyActions.java +++ b/megamek/src/megamek/client/ui/swing/lobby/LobbyActions.java @@ -1192,7 +1192,9 @@ private Client correctSender(Force force) { * player is allowed to change everything. */ boolean isEditable(Entity entity) { - return client().localBots.containsKey(entity.getOwner().getName()) + boolean localGM = client().getLocalPlayer().isGameMaster(); + return localGM + || client().localBots.containsKey(entity.getOwner().getName()) || (entity.getOwnerId() == localPlayer().getId()) || (entity.partOfForce() && isSelfOrLocalBot(game().getForces().getOwner(entity.getForceId()))) || (entity.partOfForce() && isEditable(game().getForces().getForce(entity))); @@ -1222,7 +1224,8 @@ boolean isEditable(Collection entities) { * of the entities are not on his team. */ boolean canSeeAll(Collection entities) { - if (!isBlindDrop(game()) && !isRealBlindDrop(game())) { + boolean localGM = client().getLocalPlayer().isGameMaster(); + if (localGM || (!isBlindDrop(game()) && !isRealBlindDrop(game()))) { return true; } return entities.stream().noneMatch(this::isLocalEnemy); diff --git a/megamek/src/megamek/client/ui/swing/lobby/LobbyMekCellFormatter.java b/megamek/src/megamek/client/ui/swing/lobby/LobbyMekCellFormatter.java index 9002a0a4ca8..ccb1729196c 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/LobbyMekCellFormatter.java +++ b/megamek/src/megamek/client/ui/swing/lobby/LobbyMekCellFormatter.java @@ -85,7 +85,8 @@ static String formatUnitFull(Entity entity, ChatLounge lobby, boolean forceView) GameOptions options = game.getOptions(); Player localPlayer = client.getLocalPlayer(); Player owner = entity.getOwner(); - boolean hideEntity = owner.isEnemyOf(localPlayer) + boolean localGM = localPlayer.isGameMaster(); + boolean hideEntity = !localGM && owner.isEnemyOf(localPlayer) && options.booleanOption(OptionsConstants.BASE_BLIND_DROP); if (hideEntity) { result.append(DOT_SPACER); @@ -493,7 +494,8 @@ static String formatUnitCompact(Entity entity, ChatLounge lobby, boolean forceVi GameOptions options = game.getOptions(); Player localPlayer = client.getLocalPlayer(); Player owner = entity.getOwner(); - boolean hideEntity = owner.isEnemyOf(localPlayer) + boolean localGM = localPlayer.isGameMaster(); + boolean hideEntity = !localGM && owner.isEnemyOf(localPlayer) && options.booleanOption(OptionsConstants.BASE_BLIND_DROP); if (hideEntity) { String value = "  "; diff --git a/megamek/src/megamek/client/ui/swing/lobby/MekTableModel.java b/megamek/src/megamek/client/ui/swing/lobby/MekTableModel.java index c0a1cc2f9a8..46e0a251a16 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/MekTableModel.java +++ b/megamek/src/megamek/client/ui/swing/lobby/MekTableModel.java @@ -104,7 +104,8 @@ public Object getValueAt(int row, int col) { if (col == COLS.BV.ordinal()) { boolean isEnemy = clientGui.getClient().getLocalPlayer().isEnemyOf(ownerOf(entity)); boolean isBlindDrop = clientGui.getClient().getGame().getOptions().booleanOption(OptionsConstants.BASE_BLIND_DROP); - boolean hideEntity = isEnemy && isBlindDrop; + boolean localGM = clientGui.getClient().getLocalPlayer().isGameMaster(); + boolean hideEntity = !localGM && isEnemy && isBlindDrop; float size = chatLounge.isCompact() ? 0 : 0.2f; return hideEntity ? "" : guiScaledFontHTML(size) + NumberFormat.getIntegerInstance().format(bv.get(row)); @@ -176,8 +177,10 @@ private void addCellData(InGameObject entity) { // Note that units of a player's bots are obscured because they could be added from // a MekHQ AtB campaign. Thus, the player can still configure them and so can identify // the obscured units but has to actively decide to do it. - boolean hideEntity = clientGui.getClient().getLocalPlayer().isEnemyOf(owner) + boolean localGM = clientGui.getClient().getLocalPlayer().isGameMaster(); + boolean hideEntity = !localGM && clientGui.getClient().getLocalPlayer().isEnemyOf(owner) && clientGui.getClient().getGame().getOptions().booleanOption(OptionsConstants.BASE_BLIND_DROP); + if (hideEntity) { unitTooltips.add(null); pilotTooltips.add(null); @@ -295,7 +298,8 @@ public Component getTableCellRendererComponent(final JTable table, } Player owner = ownerOf(entity); - boolean showAsUnknown = clientGui.getClient().getLocalPlayer().isEnemyOf(owner) + boolean localGM = clientGui.getClient().getLocalPlayer().isGameMaster(); + boolean showAsUnknown = !localGM && clientGui.getClient().getLocalPlayer().isEnemyOf(owner) && clientGui.getClient().getGame().getOptions().booleanOption(OptionsConstants.BASE_BLIND_DROP); int size = UIUtil.scaleForGUI(MEKTABLE_IMGHEIGHT); From 1cfebffa746cb3e9cc9aa38c69b975372a7ebd16 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 25 Nov 2023 13:26:51 -0500 Subject: [PATCH 11/24] correct issue --- megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java b/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java index 43ffa2e25c6..1baf788ff8d 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java +++ b/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java @@ -1506,7 +1506,7 @@ void disembarkAll(Collection entities) { */ boolean isEditable(Entity entity) { boolean localGM = clientgui.getClient().getLocalPlayer().isGameMaster(); - return !localGM && (clientgui.getLocalBots().containsKey(entity.getOwner().getName()) + return localGM || (clientgui.getLocalBots().containsKey(entity.getOwner().getName()) || (entity.getOwnerId() == localPlayer().getId())); } From 86a483f680254ef14b9c1109b139a65a713546df Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sun, 26 Nov 2023 10:34:29 -0500 Subject: [PATCH 12/24] save and load from mul --- megamek/src/megamek/common/Board.java | 8 ++--- megamek/src/megamek/common/Entity.java | 9 ++--- .../src/megamek/common/EntityListFile.java | 8 +++++ megamek/src/megamek/common/MULParser.java | 33 +++++++++++++++++++ megamek/src/megamek/common/Player.java | 8 ++--- 5 files changed, 54 insertions(+), 12 deletions(-) diff --git a/megamek/src/megamek/common/Board.java b/megamek/src/megamek/common/Board.java index b8a838422ec..c5a7b194769 100644 --- a/megamek/src/megamek/common/Board.java +++ b/megamek/src/megamek/common/Board.java @@ -876,10 +876,10 @@ public boolean isLegalDeployment(Coords c, int zoneType, int startingWidth, int switch (zoneType) { case START_ANY: - return (((startingAnyNWx == -1) || (c.getX() >= startingAnyNWx)) - && ((startingAnySEx == -1) || (c.getX() <= startingAnySEx)) - && ((startingAnyNWy == -1) || (c.getY() >= startingAnyNWy)) - && ((startingAnySEy == -1) || (c.getY() <= startingAnySEy))); + return (((startingAnyNWx == Entity.STARTING_ANY_NONE) || (c.getX() >= startingAnyNWx)) + && ((startingAnySEx == Entity.STARTING_ANY_NONE) || (c.getX() <= startingAnySEx)) + && ((startingAnyNWy == Entity.STARTING_ANY_NONE) || (c.getY() >= startingAnyNWy)) + && ((startingAnySEy == Entity.STARTING_ANY_NONE) || (c.getY() <= startingAnySEy))); case START_NW: return ((c.getX() < (minx + nLimit)) && (c.getX() >= minx) && (c.getY() >= miny) && (c.getY() < (height / 2))) || ((c.getY() < (miny + nLimit)) && (c.getY() >= miny) && (c.getX() >= minx) && (c.getX() < (width / 2))); diff --git a/megamek/src/megamek/common/Entity.java b/megamek/src/megamek/common/Entity.java index 014de3df56c..480af760fb6 100644 --- a/megamek/src/megamek/common/Entity.java +++ b/megamek/src/megamek/common/Entity.java @@ -210,10 +210,11 @@ public abstract class Entity extends TurnOrdered implements Transporter, Targeta private int startingOffset = 0; private int startingWidth = 3; - private int startingAnyNWx = -1; - private int startingAnyNWy = -1; - private int startingAnySEx = -1; - private int startingAnySEy = -1; + public static final int STARTING_ANY_NONE = -1; + private int startingAnyNWx = STARTING_ANY_NONE; + private int startingAnyNWy = STARTING_ANY_NONE; + private int startingAnySEx = STARTING_ANY_NONE; + private int startingAnySEy = STARTING_ANY_NONE; /** * The pilot of the entity. Even infantry has a 'pilot'. diff --git a/megamek/src/megamek/common/EntityListFile.java b/megamek/src/megamek/common/EntityListFile.java index 84f5c11649e..331c27ea563 100644 --- a/megamek/src/megamek/common/EntityListFile.java +++ b/megamek/src/megamek/common/EntityListFile.java @@ -719,6 +719,14 @@ private static void writeEntityList(Writer output, ArrayList list) throw output.write(String.valueOf(entity.getStartingWidth(false))); output.write("\" deploymentZoneOffset=\""); output.write(String.valueOf(entity.getStartingOffset(false))); + output.write("\" " + MULParser.DEPLOYMENT_ZONE_ANY_NWX + "=\""); + output.write(String.valueOf(entity.getStartingAnyNWx(false))); + output.write("\" " + MULParser.DEPLOYMENT_ZONE_ANY_NWY + "=\""); + output.write(String.valueOf(entity.getStartingAnyNWy(false))); + output.write("\" " + MULParser.DEPLOYMENT_ZONE_ANY_SEX + "=\""); + output.write(String.valueOf(entity.getStartingAnySEx(false))); + output.write("\" " + MULParser.DEPLOYMENT_ZONE_ANY_SEY + "=\""); + output.write(String.valueOf(entity.getStartingAnySEy(false))); output.write("\" neverDeployed=\""); output.write(String.valueOf(entity.wasNeverDeployed())); if (entity.isAero()) { diff --git a/megamek/src/megamek/common/MULParser.java b/megamek/src/megamek/common/MULParser.java index a18781f04b0..37d5595d371 100644 --- a/megamek/src/megamek/common/MULParser.java +++ b/megamek/src/megamek/common/MULParser.java @@ -144,6 +144,10 @@ public class MULParser { private static final String DEPLOYMENT_ZONE = "deploymentZone"; private static final String DEPLOYMENT_ZONE_WIDTH = "deploymentZoneWidth"; private static final String DEPLOYMENT_ZONE_OFFSET = "deploymentZoneOffset"; + public static final String DEPLOYMENT_ZONE_ANY_NWX = "deploymentZoneAnyNWx"; + public static final String DEPLOYMENT_ZONE_ANY_NWY = "deploymentZoneAnyNWy"; + public static final String DEPLOYMENT_ZONE_ANY_SEX = "deploymentZoneAnySEx"; + public static final String DEPLOYMENT_ZONE_ANY_SEY = "deploymentZoneAnySEy"; private static final String NEVER_DEPLOYED = "neverDeployed"; private static final String VELOCITY = "velocity"; public static final String ALTITUDE = "altitude"; @@ -710,6 +714,35 @@ private void parseEntityAttributes(Entity entity, Element entityTag) { entity.setStartingOffset(0); } + // deployment zone Any + try { + int deployZoneAnyNWx = Integer.parseInt(entityTag.getAttribute(DEPLOYMENT_ZONE_ANY_NWX)); + entity.setStartingAnyNWx(deployZoneAnyNWx); + } catch (Exception e) { + entity.setStartingAnyNWx(Entity.STARTING_ANY_NONE); + } + + try { + int deployZoneAnyNWy = Integer.parseInt(entityTag.getAttribute(DEPLOYMENT_ZONE_ANY_NWY)); + entity.setStartingAnyNWy(deployZoneAnyNWy); + } catch (Exception e) { + entity.setStartingAnyNWy(Entity.STARTING_ANY_NONE); + } + + try { + int deployZoneAnySEx = Integer.parseInt(entityTag.getAttribute(DEPLOYMENT_ZONE_ANY_SEX)); + entity.setStartingAnySEx(deployZoneAnySEx); + } catch (Exception e) { + entity.setStartingAnySEx(Entity.STARTING_ANY_NONE); + } + + try { + int deployZoneAnySEy = Integer.parseInt(entityTag.getAttribute(DEPLOYMENT_ZONE_ANY_SEY)); + entity.setStartingAnySEy(deployZoneAnySEy); + } catch (Exception e) { + entity.setStartingAnySEy(Entity.STARTING_ANY_NONE); + } + // Was never deployed try { String ndeploy = entityTag.getAttribute(NEVER_DEPLOYED); diff --git a/megamek/src/megamek/common/Player.java b/megamek/src/megamek/common/Player.java index 0d65990e5ea..7a6a30f646e 100644 --- a/megamek/src/megamek/common/Player.java +++ b/megamek/src/megamek/common/Player.java @@ -56,10 +56,10 @@ public final class Player extends TurnOrdered { private int startingPos = Board.START_ANY; private int startOffset = 0; private int startWidth = 3; - private int startingAnyNWx = -1; - private int startingAnyNWy = -1; - private int startingAnySEx = -1; - private int startingAnySEy = -1; + private int startingAnyNWx = Entity.STARTING_ANY_NONE; + private int startingAnyNWy = Entity.STARTING_ANY_NONE; + private int startingAnySEx = Entity.STARTING_ANY_NONE; + private int startingAnySEy = Entity.STARTING_ANY_NONE; // number of minefields private int numMfConv = 0; From 9195c913cb205c932b7290bb67e6f3932841f1c5 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sun, 26 Nov 2023 11:21:10 -0500 Subject: [PATCH 13/24] add ruler to map preview --- .../megamek/client/ui/swing/ClientGUI.java | 2 +- .../src/megamek/client/ui/swing/Ruler.java | 28 ++++++++++--------- .../client/ui/swing/lobby/ChatLounge.java | 8 ++++++ 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index 6b3615e82b1..7f81b09af2a 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -585,7 +585,7 @@ public void windowClosing(WindowEvent e) { Ruler.color1 = GUIP.getRulerColor1(); Ruler.color2 = GUIP.getRulerColor2(); - ruler = new Ruler(frame, client, bv); + ruler = new Ruler(frame, client, bv, client.getGame()); ruler.setLocation(GUIP.getRulerPosX(), GUIP.getRulerPosY()); ruler.setSize(GUIP.getRulerSizeHeight(), GUIP.getRulerSizeWidth()); UIUtil.updateWindowBounds(ruler); diff --git a/megamek/src/megamek/client/ui/swing/Ruler.java b/megamek/src/megamek/client/ui/swing/Ruler.java index b9a81e7b02f..39b1eeb5ab0 100644 --- a/megamek/src/megamek/client/ui/swing/Ruler.java +++ b/megamek/src/megamek/client/ui/swing/Ruler.java @@ -43,6 +43,7 @@ public class Ruler extends JDialog implements BoardViewListener, IPreferenceChan private int distance; private Client client; private BoardView bv; + private Game game; private boolean flip; private JPanel buttonPanel; @@ -69,7 +70,7 @@ public class Ruler extends JDialog implements BoardViewListener, IPreferenceChan private JCheckBox cboIsMech2 = new JCheckBox(Messages.getString("Ruler.isMech")); - public Ruler(JFrame f, Client c, BoardView b) { + public Ruler(JFrame f, Client c, BoardView b, Game g) { super(f, Messages.getString("Ruler.title"), false); enableEvents(AWTEvent.WINDOW_EVENT_MASK); @@ -81,6 +82,7 @@ public Ruler(JFrame f, Client c, BoardView b) { bv = b; client = c; + game = g; b.addBoardViewListener(this); try { @@ -273,7 +275,7 @@ private void addPoint(Coords c) { int absHeight = Integer.MIN_VALUE; boolean isMech = false; boolean entFound = false; - for (Entity ent : client.getGame().getEntitiesVector(c)) { + for (Entity ent : game.getEntitiesVector(c)) { int trAbsheight = ent.relHeight(); if (trAbsheight > absHeight) { absHeight = trAbsheight; @@ -316,20 +318,20 @@ private void setText() { // leave at default value } - if (!client.getGame().getBoard().contains(start) || !client.getGame().getBoard().contains(end)) { + if (!game.getBoard().contains(start) || !game.getBoard().contains(end)) { return; } String toHit1 = "", toHit2 = ""; ToHitData thd; if (flip) { - thd = LosEffects.calculateLos(client.getGame(), + thd = LosEffects.calculateLos(game, buildAttackInfo(start, end, h1, h2, cboIsMech1.isSelected(), - cboIsMech2.isSelected())).losModifiers(client.getGame()); + cboIsMech2.isSelected())).losModifiers(game); } else { - thd = LosEffects.calculateLos(client.getGame(), + thd = LosEffects.calculateLos(game, buildAttackInfo(end, start, h2, h1, cboIsMech2.isSelected(), - cboIsMech1.isSelected())).losModifiers(client.getGame()); + cboIsMech1.isSelected())).losModifiers(game); } if (thd.getValue() != TargetRoll.IMPOSSIBLE) { toHit1 = thd.getValue() + " = "; @@ -337,13 +339,13 @@ private void setText() { toHit1 += thd.getDesc(); if (flip) { - thd = LosEffects.calculateLos(client.getGame(), + thd = LosEffects.calculateLos(game, buildAttackInfo(end, start, h2, h1, cboIsMech2.isSelected(), - cboIsMech1.isSelected())).losModifiers(client.getGame()); + cboIsMech1.isSelected())).losModifiers(game); } else { - thd = LosEffects.calculateLos(client.getGame(), + thd = LosEffects.calculateLos(game, buildAttackInfo(start, end, h1, h2, cboIsMech1.isSelected(), - cboIsMech2.isSelected())).losModifiers(client.getGame()); + cboIsMech2.isSelected())).losModifiers(game); } if (thd.getValue() != TargetRoll.IMPOSSIBLE) { toHit2 = thd.getValue() + " = "; @@ -377,8 +379,8 @@ private LosEffects.AttackInfo buildAttackInfo(Coords c1, Coords c2, int h1, ai.targetHeight = h2; ai.attackerIsMech = attackerIsMech; ai.targetIsMech = targetIsMech; - ai.attackAbsHeight = client.getGame().getBoard().getHex(c1).floor() + h1; - ai.targetAbsHeight = client.getGame().getBoard().getHex(c2).floor() + h2; + ai.attackAbsHeight =game.getBoard().getHex(c1).floor() + h1; + ai.targetAbsHeight = game.getBoard().getHex(c2).floor() + h2; return ai; } diff --git a/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java b/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java index 1baf788ff8d..622386528b7 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java +++ b/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java @@ -766,6 +766,14 @@ public void componentShown(ComponentEvent e) { bpPanel.add(previewBV.getComponent(true)); boardPreviewW.add(bpPanel); boardPreviewW.setSize(clientgui.frame.getWidth() / 2, clientgui.frame.getHeight() / 2); + + Ruler.color1 = GUIP.getRulerColor1(); + Ruler.color2 = GUIP.getRulerColor2(); + Ruler ruler = new Ruler(clientgui.frame, client(), previewBV, boardPreviewGame); + ruler.setLocation(GUIP.getRulerPosX(), GUIP.getRulerPosY()); + ruler.setSize(GUIP.getRulerSizeHeight(), GUIP.getRulerSizeWidth()); + UIUtil.updateWindowBounds(ruler); + // Most boards will be far too large on the standard zoom previewBV.zoomOut(); previewBV.zoomOut(); From a106899fb232d78dfa25ae744f859bbc49aad74d Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sun, 26 Nov 2023 11:53:19 -0500 Subject: [PATCH 14/24] insure ruler is always on top of the map preview --- megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java | 1 + 1 file changed, 1 insertion(+) diff --git a/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java b/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java index 622386528b7..97c3c1354f3 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java +++ b/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java @@ -772,6 +772,7 @@ public void componentShown(ComponentEvent e) { Ruler ruler = new Ruler(clientgui.frame, client(), previewBV, boardPreviewGame); ruler.setLocation(GUIP.getRulerPosX(), GUIP.getRulerPosY()); ruler.setSize(GUIP.getRulerSizeHeight(), GUIP.getRulerSizeWidth()); + ruler.setAlwaysOnTop(true); UIUtil.updateWindowBounds(ruler); // Most boards will be far too large on the standard zoom From ab56dc63ccbbd43836fa4173e72d49a49fe10826 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sun, 26 Nov 2023 17:46:37 -0500 Subject: [PATCH 15/24] apply ruler coords for deployment Any corners --- .../i18n/megamek/client/messages.properties | 1 + .../megamek/client/ui/swing/ClientGUI.java | 2 +- .../client/ui/swing/CustomMechDialog.java | 6 ++-- .../client/ui/swing/boardview/BoardView.java | 8 +++++ .../client/ui/swing/lobby/ChatLounge.java | 4 ++- .../ui/swing/lobby/PlayerSettingsDialog.java | 35 ++++++++++++++++--- 6 files changed, 48 insertions(+), 8 deletions(-) diff --git a/megamek/i18n/megamek/client/messages.properties b/megamek/i18n/megamek/client/messages.properties index d04f0123509..f1a78836da0 100644 --- a/megamek/i18n/megamek/client/messages.properties +++ b/megamek/i18n/megamek/client/messages.properties @@ -1435,6 +1435,7 @@ CustomMechDialog.labDeploymentWidth=Deployment Zone Width: CustomMechDialog.labDeploymentWidthTip=Deployment Zone width, in hexes CustomMechDialog.labDeploymentAnyNW=Deployment Any NW corner: CustomMechDialog.labDeploymentAnySE=Deployment Any SE corner: +CustomMechDialog.BtnDeploymentAnyApplyRulerCoords=Apply ruler coords for Deployment Any corners CustomMechDialog.labDeployShutdown=Shutdown CustomMechDialog.labDeployProne=Prone CustomMechDialog.labDeployHullDown=Hull Down diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index 7f81b09af2a..f51744f904c 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -680,7 +680,7 @@ private void showOptions() { } public void customizePlayer() { - PlayerSettingsDialog psd = new PlayerSettingsDialog(this, client); + PlayerSettingsDialog psd = new PlayerSettingsDialog(this, client, bv); psd.setVisible(true); } diff --git a/megamek/src/megamek/client/ui/swing/CustomMechDialog.java b/megamek/src/megamek/client/ui/swing/CustomMechDialog.java index ec06ce966fa..0cb6df18afd 100644 --- a/megamek/src/megamek/client/ui/swing/CustomMechDialog.java +++ b/megamek/src/megamek/client/ui/swing/CustomMechDialog.java @@ -901,8 +901,10 @@ protected void okAction() { int y = Math.min((Integer) spinStartingAnyNWy.getValue(), (Integer) spinStartingAnySEy.getValue()); entity.setStartingAnyNWx(x - 1); entity.setStartingAnyNWy(y - 1); - entity.setStartingAnySEx((Integer) spinStartingAnySEx.getValue() - 1); - entity.setStartingAnySEy((Integer) spinStartingAnySEy.getValue() - 1); + x = Math.max((Integer) spinStartingAnyNWx.getValue(), (Integer) spinStartingAnySEx.getValue()); + y = Math.max((Integer) spinStartingAnyNWy.getValue(), (Integer) spinStartingAnySEy.getValue()); + entity.setStartingAnySEx(x - 1); + entity.setStartingAnySEy(y - 1); // Should the entity begin the game shutdown? if (chDeployShutdown.isSelected() && gameOptions().booleanOption(OptionsConstants.RPG_BEGIN_SHUTDOWN)) { diff --git a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java index ee4b2f6f4e1..bebb1bed4aa 100644 --- a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java +++ b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java @@ -3158,6 +3158,14 @@ public void drawRuler(Coords s, Coords e, Color sc, Color ec) { repaint(); } + public Coords getRulerStart() { + return rulerStart; + } + + public Coords getRulerEnd() { + return rulerEnd; + } + /** * @return the coords at the specified point */ diff --git a/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java b/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java index 97c3c1354f3..e8bb89ce148 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java +++ b/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java @@ -1557,7 +1557,9 @@ public void configPlayer() { return; } - PlayerSettingsDialog psd = new PlayerSettingsDialog(clientgui, c); + PlayerSettingsDialog psd = new PlayerSettingsDialog(clientgui, c, previewBV); + psd.setModal(false); + psd.setAlwaysOnTop(true); if (psd.showDialog().isConfirmed()) { Player player = c.getLocalPlayer(); player.setConstantInitBonus(psd.getInit()); diff --git a/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java b/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java index 619da27e234..a38ff0982e1 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java +++ b/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java @@ -31,6 +31,7 @@ import megamek.client.ui.panels.SkillGenerationOptionsPanel; import megamek.client.ui.swing.ClientGUI; import megamek.client.ui.swing.GUIPreferences; +import megamek.client.ui.swing.boardview.BoardView; import megamek.client.ui.swing.util.UIUtil; import megamek.common.IStartingPositions; import megamek.common.Player; @@ -59,10 +60,11 @@ */ public class PlayerSettingsDialog extends AbstractButtonDialog { - public PlayerSettingsDialog(ClientGUI cg, Client cl) { + public PlayerSettingsDialog(ClientGUI cg, Client cl, BoardView bv) { super(cg.frame, "PlayerSettingsDialog", "PlayerSettingsDialog.title"); client = cl; clientgui = cg; + this.bv = bv; currentPlayerStartPos = cl.getLocalPlayer().getStartingPos(); if (currentPlayerStartPos > 10) { currentPlayerStartPos -= 10; @@ -129,11 +131,11 @@ public int getStartingAnyNWy() { } public int getStartingAnySEx() { - return (Integer) spinStartingAnySEx.getValue() - 1; + return Math.max((Integer) spinStartingAnyNWx.getValue(), (Integer) spinStartingAnySEx.getValue()) - 1; } public int getStartingAnySEy() { - return (Integer) spinStartingAnySEy.getValue() - 1; + return Math.max((Integer) spinStartingAnyNWy.getValue(), (Integer) spinStartingAnySEy.getValue()) - 1; } /** @@ -152,6 +154,7 @@ public String getEmail() { private final Client client; private final ClientGUI clientgui; + private final BoardView bv; // Initiative Section private final JLabel labInit = new TipLabel(Messages.getString("PlayerSettingsDialog.initMod"), SwingConstants.RIGHT); @@ -276,9 +279,33 @@ private JPanel deploymentParametersPanel() { result.add(spinStartingAnySEx, GBC.std()); result.add(spinStartingAnySEy, GBC.eol()); + JButton btnApplyRuler = new JButton(Messages.getString("CustomMechDialog.BtnDeploymentAnyApplyRulerCoords")); + btnApplyRuler.addActionListener(e -> previewGameApplyRuler()); + result.add(btnApplyRuler, GBC.eol()); + return result; } - + + private void previewGameApplyRuler() { + Player player = client.getLocalPlayer(); + + if (bv.getRulerStart() != null && bv.getRulerEnd() != null) { + int x = Math.min(bv.getRulerStart().getX(), bv.getRulerEnd().getX()); + player.setStartingAnyNWx(x); + spinStartingAnyNWx.setValue(x + 1); + int y = Math.min(bv.getRulerStart().getY(), bv.getRulerEnd().getY()); + player.setStartingAnyNWy(y); + spinStartingAnyNWy.setValue(y + 1); + x = Math.max(bv.getRulerStart().getX(), bv.getRulerEnd().getX()); + player.setStartingAnySEx(x); + spinStartingAnySEx.setValue(x + 1); + y = Math.max(bv.getRulerStart().getY(), bv.getRulerEnd().getY()); + player.setStartingAnySEy(y); + spinStartingAnySEy.setValue(y + 1); + client.sendPlayerInfo(); + } + } + private JPanel initiativeSection() { JPanel result = new OptionPanel("PlayerSettingsDialog.header.initMod"); Content panContent = new Content(new GridLayout(1, 2, 10, 5)); From 966f32d552893bc637f7d809c828ba19abd72177 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sun, 26 Nov 2023 18:52:59 -0500 Subject: [PATCH 16/24] update button to apply any deployment changes --- megamek/i18n/megamek/client/messages.properties | 2 +- .../megamek/client/ui/swing/lobby/PlayerSettingsDialog.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/megamek/i18n/megamek/client/messages.properties b/megamek/i18n/megamek/client/messages.properties index f1a78836da0..f809a0eee2e 100644 --- a/megamek/i18n/megamek/client/messages.properties +++ b/megamek/i18n/megamek/client/messages.properties @@ -1435,7 +1435,7 @@ CustomMechDialog.labDeploymentWidth=Deployment Zone Width: CustomMechDialog.labDeploymentWidthTip=Deployment Zone width, in hexes CustomMechDialog.labDeploymentAnyNW=Deployment Any NW corner: CustomMechDialog.labDeploymentAnySE=Deployment Any SE corner: -CustomMechDialog.BtnDeploymentAnyApplyRulerCoords=Apply ruler coords for Deployment Any corners +CustomMechDialog.BtnDeploymentApply=Apply Deployment CustomMechDialog.labDeployShutdown=Shutdown CustomMechDialog.labDeployProne=Prone CustomMechDialog.labDeployHullDown=Hull Down diff --git a/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java b/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java index a38ff0982e1..d84cc456342 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java +++ b/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java @@ -279,7 +279,7 @@ private JPanel deploymentParametersPanel() { result.add(spinStartingAnySEx, GBC.std()); result.add(spinStartingAnySEy, GBC.eol()); - JButton btnApplyRuler = new JButton(Messages.getString("CustomMechDialog.BtnDeploymentAnyApplyRulerCoords")); + JButton btnApplyRuler = new JButton(Messages.getString("CustomMechDialog.BtnDeploymentApply")); btnApplyRuler.addActionListener(e -> previewGameApplyRuler()); result.add(btnApplyRuler, GBC.eol()); @@ -304,6 +304,10 @@ private void previewGameApplyRuler() { spinStartingAnySEy.setValue(y + 1); client.sendPlayerInfo(); } + + player.setStartingPos(currentPlayerStartPos); + player.setStartOffset(getStartOffset()); + player.setStartWidth(getStartWidth()); } private JPanel initiativeSection() { From 5163750f957d0d503ae3ae20ac83316998ae0337 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sun, 26 Nov 2023 19:18:44 -0500 Subject: [PATCH 17/24] correct issue --- .../i18n/megamek/client/messages.properties | 2 +- .../client/ui/swing/lobby/ChatLounge.java | 36 +-------------- .../ui/swing/lobby/PlayerSettingsDialog.java | 46 +++++++++++++++---- 3 files changed, 40 insertions(+), 44 deletions(-) diff --git a/megamek/i18n/megamek/client/messages.properties b/megamek/i18n/megamek/client/messages.properties index f809a0eee2e..94a89db48ce 100644 --- a/megamek/i18n/megamek/client/messages.properties +++ b/megamek/i18n/megamek/client/messages.properties @@ -1435,7 +1435,7 @@ CustomMechDialog.labDeploymentWidth=Deployment Zone Width: CustomMechDialog.labDeploymentWidthTip=Deployment Zone width, in hexes CustomMechDialog.labDeploymentAnyNW=Deployment Any NW corner: CustomMechDialog.labDeploymentAnySE=Deployment Any SE corner: -CustomMechDialog.BtnDeploymentApply=Apply Deployment +CustomMechDialog.BtnDeploymentApply=Apply ruler coords and Deployment CustomMechDialog.labDeployShutdown=Shutdown CustomMechDialog.labDeployProne=Prone CustomMechDialog.labDeployHullDown=Hull Down diff --git a/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java b/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java index e8bb89ce148..44e60009d43 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java +++ b/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java @@ -1560,41 +1560,7 @@ public void configPlayer() { PlayerSettingsDialog psd = new PlayerSettingsDialog(clientgui, c, previewBV); psd.setModal(false); psd.setAlwaysOnTop(true); - if (psd.showDialog().isConfirmed()) { - Player player = c.getLocalPlayer(); - player.setConstantInitBonus(psd.getInit()); - player.setNbrMFConventional(psd.getCnvMines()); - player.setNbrMFVibra(psd.getVibMines()); - player.setNbrMFActive(psd.getActMines()); - player.setNbrMFInferno(psd.getInfMines()); - psd.getSkillGenerationOptionsPanel().updateClient(); - player.setEmail(psd.getEmail()); - - // The deployment position - int startPos = psd.getStartPos(); - final GameOptions gOpts = clientgui.getClient().getGame().getOptions(); - - player.setStartingPos(startPos); - player.setStartOffset(psd.getStartOffset()); - player.setStartWidth(psd.getStartWidth()); - player.setStartingAnyNWx(psd.getStartingAnyNWx()); - player.setStartingAnyNWy(psd.getStartingAnyNWy()); - player.setStartingAnySEx(psd.getStartingAnySEx()); - player.setStartingAnySEy(psd.getStartingAnySEy()); - c.sendPlayerInfo(); - - // If the gameoption set_arty_player_homeedge is set, adjust the player's offboard - // arty units to be behind the newly selected home edge. - OffBoardDirection direction = OffBoardDirection.translateStartPosition(startPos); - if (direction != OffBoardDirection.NONE && - gOpts.booleanOption(OptionsConstants.BASE_SET_ARTY_PLAYER_HOMEEDGE)) { - for (Entity entity: c.getGame().getPlayerEntities(c.getLocalPlayer(), false)) { - if (entity.getOffBoardDirection() != OffBoardDirection.NONE) { - entity.setOffBoard(entity.getOffBoardDistance(), direction); - } - } - } - } + psd.showDialog(); } /** diff --git a/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java b/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java index d84cc456342..59de04c96fa 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java +++ b/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java @@ -33,8 +33,11 @@ import megamek.client.ui.swing.GUIPreferences; import megamek.client.ui.swing.boardview.BoardView; import megamek.client.ui.swing.util.UIUtil; +import megamek.common.Entity; import megamek.common.IStartingPositions; +import megamek.common.OffBoardDirection; import megamek.common.Player; +import megamek.common.options.GameOptions; import megamek.common.options.OptionsConstants; import javax.swing.*; @@ -81,6 +84,10 @@ protected void finalizeInitialization() throws Exception { adaptToGUIScale(); super.finalizeInitialization(); } + @Override + protected void okAction() { + apply(); + } /** Returns the chosen initiative modifier. */ public int getInit() { @@ -280,34 +287,57 @@ private JPanel deploymentParametersPanel() { result.add(spinStartingAnySEy, GBC.eol()); JButton btnApplyRuler = new JButton(Messages.getString("CustomMechDialog.BtnDeploymentApply")); - btnApplyRuler.addActionListener(e -> previewGameApplyRuler()); + btnApplyRuler.addActionListener(e -> apply()); result.add(btnApplyRuler, GBC.eol()); return result; } - private void previewGameApplyRuler() { + private void apply() { Player player = client.getLocalPlayer(); + player.setConstantInitBonus(getInit()); + player.setNbrMFConventional(getCnvMines()); + player.setNbrMFVibra(getVibMines()); + player.setNbrMFActive(getActMines()); + player.setNbrMFInferno(getInfMines()); + getSkillGenerationOptionsPanel().updateClient(); + player.setEmail(getEmail()); + + final GameOptions gOpts = clientgui.getClient().getGame().getOptions(); + + // If the gameoption set_arty_player_homeedge is set, adjust the player's offboard + // arty units to be behind the newly selected home edge. + OffBoardDirection direction = OffBoardDirection.translateStartPosition(getStartPos()); + if (direction != OffBoardDirection.NONE && + gOpts.booleanOption(OptionsConstants.BASE_SET_ARTY_PLAYER_HOMEEDGE)) { + for (Entity entity: client.getGame().getPlayerEntities(client.getLocalPlayer(), false)) { + if (entity.getOffBoardDirection() != OffBoardDirection.NONE) { + entity.setOffBoard(entity.getOffBoardDistance(), direction); + } + } + } + if (bv.getRulerStart() != null && bv.getRulerEnd() != null) { int x = Math.min(bv.getRulerStart().getX(), bv.getRulerEnd().getX()); - player.setStartingAnyNWx(x); spinStartingAnyNWx.setValue(x + 1); int y = Math.min(bv.getRulerStart().getY(), bv.getRulerEnd().getY()); - player.setStartingAnyNWy(y); spinStartingAnyNWy.setValue(y + 1); x = Math.max(bv.getRulerStart().getX(), bv.getRulerEnd().getX()); - player.setStartingAnySEx(x); spinStartingAnySEx.setValue(x + 1); y = Math.max(bv.getRulerStart().getY(), bv.getRulerEnd().getY()); - player.setStartingAnySEy(y); spinStartingAnySEy.setValue(y + 1); - client.sendPlayerInfo(); } - player.setStartingPos(currentPlayerStartPos); + // The deployment position + player.setStartingPos(getStartPos()); player.setStartOffset(getStartOffset()); player.setStartWidth(getStartWidth()); + player.setStartingAnyNWx(getStartingAnyNWx()); + player.setStartingAnyNWy(getStartingAnyNWy()); + player.setStartingAnySEx(getStartingAnySEx()); + player.setStartingAnySEy(getStartingAnySEy()); + client.sendPlayerInfo(); } private JPanel initiativeSection() { From 65cf65d4b18ad03f47811d0f388eccd0b87754b2 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sun, 26 Nov 2023 19:22:24 -0500 Subject: [PATCH 18/24] update message --- megamek/i18n/megamek/client/messages.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/megamek/i18n/megamek/client/messages.properties b/megamek/i18n/megamek/client/messages.properties index 94a89db48ce..fa0a7e5d1f1 100644 --- a/megamek/i18n/megamek/client/messages.properties +++ b/megamek/i18n/megamek/client/messages.properties @@ -1435,7 +1435,7 @@ CustomMechDialog.labDeploymentWidth=Deployment Zone Width: CustomMechDialog.labDeploymentWidthTip=Deployment Zone width, in hexes CustomMechDialog.labDeploymentAnyNW=Deployment Any NW corner: CustomMechDialog.labDeploymentAnySE=Deployment Any SE corner: -CustomMechDialog.BtnDeploymentApply=Apply ruler coords and Deployment +CustomMechDialog.BtnDeploymentApply=Apply ruler coords and any player setting changes CustomMechDialog.labDeployShutdown=Shutdown CustomMechDialog.labDeployProne=Prone CustomMechDialog.labDeployHullDown=Hull Down From c2fe464584bccc316bfd04c257c0d93245245f87 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Mon, 27 Nov 2023 17:22:20 -0500 Subject: [PATCH 19/24] use 2 buttons --- .../i18n/megamek/client/messages.properties | 5 ++- .../ui/swing/lobby/PlayerSettingsDialog.java | 36 +++++++++++-------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/megamek/i18n/megamek/client/messages.properties b/megamek/i18n/megamek/client/messages.properties index fa0a7e5d1f1..9a56eae8aab 100644 --- a/megamek/i18n/megamek/client/messages.properties +++ b/megamek/i18n/megamek/client/messages.properties @@ -1435,7 +1435,10 @@ CustomMechDialog.labDeploymentWidth=Deployment Zone Width: CustomMechDialog.labDeploymentWidthTip=Deployment Zone width, in hexes CustomMechDialog.labDeploymentAnyNW=Deployment Any NW corner: CustomMechDialog.labDeploymentAnySE=Deployment Any SE corner: -CustomMechDialog.BtnDeploymentApply=Apply ruler coords and any player setting changes +CustomMechDialog.BtnDeploymentUseRuler=Use ruler coords +CustomMechDialog.BtnDeploymentUseRulerTip=set the Any NW and SE corners based on the corners of the NW and SE corners the square defined by the map preview ruler +CustomMechDialog.BtnDeploymentApply=Apply +CustomMechDialog.BtnDeploymentApplyTip=Apply player setting CustomMechDialog.labDeployShutdown=Shutdown CustomMechDialog.labDeployProne=Prone CustomMechDialog.labDeployHullDown=Hull Down diff --git a/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java b/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java index 59de04c96fa..e319ed62c03 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java +++ b/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java @@ -286,13 +286,32 @@ private JPanel deploymentParametersPanel() { result.add(spinStartingAnySEx, GBC.std()); result.add(spinStartingAnySEy, GBC.eol()); - JButton btnApplyRuler = new JButton(Messages.getString("CustomMechDialog.BtnDeploymentApply")); - btnApplyRuler.addActionListener(e -> apply()); - result.add(btnApplyRuler, GBC.eol()); + JButton btnUseRuler = new JButton(Messages.getString("CustomMechDialog.BtnDeploymentUseRuler")); + btnUseRuler.setToolTipText(Messages.getString("CustomMechDialog.BtnDeploymentUseRulerTip")); + btnUseRuler.addActionListener(e -> useRuler()); + result.add(btnUseRuler, GBC.std()); + JButton btnApply = new JButton(Messages.getString("CustomMechDialog.BtnDeploymentApply")); + btnApply.setToolTipText(Messages.getString("CustomMechDialog.BtnDeploymentApplyTip")); + btnApply.addActionListener(e -> apply()); + result.add(btnApply, GBC.eol()); return result; } + + private void useRuler() { + if (bv.getRulerStart() != null && bv.getRulerEnd() != null) { + int x = Math.min(bv.getRulerStart().getX(), bv.getRulerEnd().getX()); + spinStartingAnyNWx.setValue(x + 1); + int y = Math.min(bv.getRulerStart().getY(), bv.getRulerEnd().getY()); + spinStartingAnyNWy.setValue(y + 1); + x = Math.max(bv.getRulerStart().getX(), bv.getRulerEnd().getX()); + spinStartingAnySEx.setValue(x + 1); + y = Math.max(bv.getRulerStart().getY(), bv.getRulerEnd().getY()); + spinStartingAnySEy.setValue(y + 1); + } + } + private void apply() { Player player = client.getLocalPlayer(); @@ -318,17 +337,6 @@ private void apply() { } } - if (bv.getRulerStart() != null && bv.getRulerEnd() != null) { - int x = Math.min(bv.getRulerStart().getX(), bv.getRulerEnd().getX()); - spinStartingAnyNWx.setValue(x + 1); - int y = Math.min(bv.getRulerStart().getY(), bv.getRulerEnd().getY()); - spinStartingAnyNWy.setValue(y + 1); - x = Math.max(bv.getRulerStart().getX(), bv.getRulerEnd().getX()); - spinStartingAnySEx.setValue(x + 1); - y = Math.max(bv.getRulerStart().getY(), bv.getRulerEnd().getY()); - spinStartingAnySEy.setValue(y + 1); - } - // The deployment position player.setStartingPos(getStartPos()); player.setStartOffset(getStartOffset()); From 3c6518de0b310403e0004181c894673b6586d09f Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Mon, 27 Nov 2023 18:32:26 -0500 Subject: [PATCH 20/24] correct gm edit issue --- megamek/src/megamek/client/ui/swing/lobby/LobbyActions.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/megamek/src/megamek/client/ui/swing/lobby/LobbyActions.java b/megamek/src/megamek/client/ui/swing/lobby/LobbyActions.java index 33faa6b18b3..f8b8b69ddf3 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/LobbyActions.java +++ b/megamek/src/megamek/client/ui/swing/lobby/LobbyActions.java @@ -354,9 +354,11 @@ public void customizeMech(Entity entity) { if (editable) { c = client().localBots.get(entity.getOwner().getName()); } else { - editable |= entity.getOwnerId() == localPlayer().getId(); + boolean localGM = localPlayer().isGameMaster(); + editable |= localGM || entity.getOwnerId() == localPlayer().getId(); c = client(); } + // When we customize a single entity's C3 network setting, // **ALL** members of the network may get changed. Entity c3master = entity.getC3Master(); From 1fad826b69930855b92126b0485b6364fed5b64b Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Mon, 27 Nov 2023 18:50:49 -0500 Subject: [PATCH 21/24] while in lobby and there is a gm, if player disconnects transfer the disconnected players unit to gm --- megamek/src/megamek/server/GameManager.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/megamek/src/megamek/server/GameManager.java b/megamek/src/megamek/server/GameManager.java index 1a566c6e304..71b75615444 100644 --- a/megamek/src/megamek/server/GameManager.java +++ b/megamek/src/megamek/server/GameManager.java @@ -482,7 +482,19 @@ public void saveGame(String sFile) { public void disconnect(Player player) { // in the lounge, just remove all entities for that player if (getGame().getPhase().isLounge()) { - removeAllEntitiesOwnedBy(player); + List gms = game.getPlayersList().stream().filter(p -> p.isGameMaster()).collect(Collectors.toList()); + + if (gms.size() > 0) { + for (Entity entity : game.getEntitiesVector().stream().filter(e -> e.getOwner().equals(player)).collect(Collectors.toList())) { + entity.setOwner(gms.get(0)); + } + game.getForces().correct(); + ServerLobbyHelper.correctLoading(game); + ServerLobbyHelper.correctC3Connections(game); + send(createFullEntitiesPacket()); + } else { + removeAllEntitiesOwnedBy(player); + } } // if a player has active entities, he becomes a ghost From c913302f695dcc83fdb0cffe3ef925f843239e93 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Tue, 28 Nov 2023 17:51:12 -0500 Subject: [PATCH 22/24] code cleanup --- megamek/src/megamek/server/GameManager.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/megamek/src/megamek/server/GameManager.java b/megamek/src/megamek/server/GameManager.java index 71b75615444..d5d8910c1ea 100644 --- a/megamek/src/megamek/server/GameManager.java +++ b/megamek/src/megamek/server/GameManager.java @@ -485,13 +485,7 @@ public void disconnect(Player player) { List gms = game.getPlayersList().stream().filter(p -> p.isGameMaster()).collect(Collectors.toList()); if (gms.size() > 0) { - for (Entity entity : game.getEntitiesVector().stream().filter(e -> e.getOwner().equals(player)).collect(Collectors.toList())) { - entity.setOwner(gms.get(0)); - } - game.getForces().correct(); - ServerLobbyHelper.correctLoading(game); - ServerLobbyHelper.correctC3Connections(game); - send(createFullEntitiesPacket()); + transferAllEnititiesOwnedBy(player, gms.get(0)); } else { removeAllEntitiesOwnedBy(player); } @@ -552,6 +546,16 @@ public void checkForObservers() { } } + private void transferAllEnititiesOwnedBy(Player pFrom, Player pTo) { + for (Entity entity : game.getEntitiesVector().stream().filter(e -> e.getOwner().equals(pFrom)).collect(Collectors.toList())) { + entity.setOwner(pTo); + } + game.getForces().correct(); + ServerLobbyHelper.correctLoading(game); + ServerLobbyHelper.correctC3Connections(game); + send(createFullEntitiesPacket()); + } + @Override public void removeAllEntitiesOwnedBy(Player player) { int pid = player.getId(); From 6df8b2fb61b7b42b701aa401797ffa470de3dad4 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Mon, 4 Dec 2023 18:11:04 -0500 Subject: [PATCH 23/24] code cleanup --- .../src/megamek/client/ui/swing/Ruler.java | 2 +- .../ui/swing/lobby/PlayerSettingsDialog.java | 1 + megamek/src/megamek/common/Entity.java | 21 +++++++------------ 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/Ruler.java b/megamek/src/megamek/client/ui/swing/Ruler.java index 39b1eeb5ab0..2fa7d3983ff 100644 --- a/megamek/src/megamek/client/ui/swing/Ruler.java +++ b/megamek/src/megamek/client/ui/swing/Ruler.java @@ -379,7 +379,7 @@ private LosEffects.AttackInfo buildAttackInfo(Coords c1, Coords c2, int h1, ai.targetHeight = h2; ai.attackerIsMech = attackerIsMech; ai.targetIsMech = targetIsMech; - ai.attackAbsHeight =game.getBoard().getHex(c1).floor() + h1; + ai.attackAbsHeight = game.getBoard().getHex(c1).floor() + h1; ai.targetAbsHeight = game.getBoard().getHex(c2).floor() + h2; return ai; } diff --git a/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java b/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java index e319ed62c03..cf13f5ba4f8 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java +++ b/megamek/src/megamek/client/ui/swing/lobby/PlayerSettingsDialog.java @@ -84,6 +84,7 @@ protected void finalizeInitialization() throws Exception { adaptToGUIScale(); super.finalizeInitialization(); } + @Override protected void okAction() { apply(); diff --git a/megamek/src/megamek/common/Entity.java b/megamek/src/megamek/common/Entity.java index 480af760fb6..a3d5a2334d7 100644 --- a/megamek/src/megamek/common/Entity.java +++ b/megamek/src/megamek/common/Entity.java @@ -12899,8 +12899,7 @@ public int getStartingPos(boolean inheritFromOwner) { final GameOptions gOpts = getGame().getOptions(); if (!getOwner().isBot() && gOpts.booleanOption(OptionsConstants.BASE_SET_PLAYER_DEPLOYMENT_TO_PLAYER0)) { return game.getPlayer(0).getStartingPos(); - } - else { + } else { return getOwner().getStartingPos(); } } @@ -15303,8 +15302,7 @@ public int getStartingOffset(boolean inheritFromOwner) { final GameOptions gOpts = getGame().getOptions(); if (!getOwner().isBot() && gOpts.booleanOption(OptionsConstants.BASE_SET_PLAYER_DEPLOYMENT_TO_PLAYER0)) { return game.getPlayer(0).getStartOffset(); - } - else { + } else { return getOwner().getStartOffset(); } } @@ -15327,8 +15325,7 @@ public int getStartingWidth(boolean inheritFromOwner) { final GameOptions gOpts = getGame().getOptions(); if (!getOwner().isBot() && gOpts.booleanOption(OptionsConstants.BASE_SET_PLAYER_DEPLOYMENT_TO_PLAYER0)) { return game.getPlayer(0).getStartWidth(); - } - else { + } else { return getOwner().getStartWidth(); } } @@ -15351,8 +15348,7 @@ public int getStartingAnyNWx(boolean inheritFromOwner) { final GameOptions gOpts = getGame().getOptions(); if (!getOwner().isBot() && gOpts.booleanOption(OptionsConstants.BASE_SET_PLAYER_DEPLOYMENT_TO_PLAYER0)) { return game.getPlayer(0).getStartingAnyNWx(); - } - else { + } else { return getOwner().getStartingAnyNWx(); } } @@ -15375,8 +15371,7 @@ public int getStartingAnyNWy(boolean inheritFromOwner) { final GameOptions gOpts = getGame().getOptions(); if (!getOwner().isBot() && gOpts.booleanOption(OptionsConstants.BASE_SET_PLAYER_DEPLOYMENT_TO_PLAYER0)) { return game.getPlayer(0).getStartingAnyNWy(); - } - else { + } else { return getOwner().getStartingAnyNWy(); } } @@ -15399,8 +15394,7 @@ public int getStartingAnySEx(boolean inheritFromOwner) { final GameOptions gOpts = getGame().getOptions(); if (!getOwner().isBot() && gOpts.booleanOption(OptionsConstants.BASE_SET_PLAYER_DEPLOYMENT_TO_PLAYER0)) { return game.getPlayer(0).getStartingAnySEx(); - } - else { + } else { return getOwner().getStartingAnySEx(); } } @@ -15423,8 +15417,7 @@ public int getStartingAnySEy(boolean inheritFromOwner) { final GameOptions gOpts = getGame().getOptions(); if (!getOwner().isBot() && gOpts.booleanOption(OptionsConstants.BASE_SET_PLAYER_DEPLOYMENT_TO_PLAYER0)) { return game.getPlayer(0).getStartingAnySEy(); - } - else { + } else { return getOwner().getStartingAnySEy(); } } From a1efa21f064eb696678d2f96507ff7b9b12c6ee9 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Tue, 19 Dec 2023 17:57:30 -0500 Subject: [PATCH 24/24] text cleanup --- megamek/i18n/megamek/client/messages.properties | 4 ++-- megamek/i18n/megamek/common/options/messages.properties | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/megamek/i18n/megamek/client/messages.properties b/megamek/i18n/megamek/client/messages.properties index 9a56eae8aab..1295c966fbb 100644 --- a/megamek/i18n/megamek/client/messages.properties +++ b/megamek/i18n/megamek/client/messages.properties @@ -285,7 +285,7 @@ BoardSelectionDialog.UpdateSize=Update Size BoardSelectionDialog.Updating=Updating... BoardSelectionDialog.ViewGameBoard=Preview Game Map... * BoardSelectionDialog.ViewGameBoardTooltip=Shows a preview of the game's map.
* Note: For generated maps and surprise maps the preview is only a sample
and will not be the same as the actual map used. -BoardSelectionDialog.ViewGameBoardButton=refresh preview +BoardSelectionDialog.ViewGameBoardButton=Refresh Preview #Game board tooltips BoardView1.ACTIVATING=ACTIVATING @@ -1436,7 +1436,7 @@ CustomMechDialog.labDeploymentWidthTip=Deployment Zone width, in hexes CustomMechDialog.labDeploymentAnyNW=Deployment Any NW corner: CustomMechDialog.labDeploymentAnySE=Deployment Any SE corner: CustomMechDialog.BtnDeploymentUseRuler=Use ruler coords -CustomMechDialog.BtnDeploymentUseRulerTip=set the Any NW and SE corners based on the corners of the NW and SE corners the square defined by the map preview ruler +CustomMechDialog.BtnDeploymentUseRulerTip=Set the Any NW and SE corners based on the corners of the NW and SE corners the square defined by the map preview ruler CustomMechDialog.BtnDeploymentApply=Apply CustomMechDialog.BtnDeploymentApplyTip=Apply player setting CustomMechDialog.labDeployShutdown=Shutdown diff --git a/megamek/i18n/megamek/common/options/messages.properties b/megamek/i18n/megamek/common/options/messages.properties index b49eeb04922..894be944f70 100644 --- a/megamek/i18n/megamek/common/options/messages.properties +++ b/megamek/i18n/megamek/common/options/messages.properties @@ -33,10 +33,10 @@ GameOptionsInfo.option.dumping_from_round.displayableName=first round for ammo d GameOptionsInfo.option.dumping_from_round.description=Number of the round that has to be at least reached before allowing ammo dumps. GameOptionsInfo.option.set_arty_player_homeedge.displayableName=Automatically set artillery home edge GameOptionsInfo.option.set_arty_player_homeedge.description=If checked, all of the players' artillery units will have their home edge set to the deployment edge of the player, NW and NE are North, SW and SE are South. \nUnchecked by default. -GameOptionsInfo.option.set_default_team_1.displayableName=Default non-bot players to team 1 -GameOptionsInfo.option.set_default_team_1.description=Unchecked each player is assigned new team +GameOptionsInfo.option.set_default_team_1.displayableName=Default non-bot players to team 1, useful in coop games +GameOptionsInfo.option.set_default_team_1.description=When this option is unchecked each player is assigned new team GameOptionsInfo.option.set_player_deployment_to_player0.displayableName=Non-bot player entities with \"Use Owners*\" deployment set, use Player 0\'s settings, instead of current player\'s settings -GameOptionsInfo.option.set_player_deployment_to_player0.description=Unchecked use current player deployments settings +GameOptionsInfo.option.set_player_deployment_to_player0.description=When this option is unchecked use the standard player deployments settings GameOptionsInfo.option.restrict_game_commands.displayableName=Restrict sensitive commands to non-Observers GameOptionsInfo.option.restrict_game_commands.description=If checked, commands such as /reset and /kick cannot be used by Observers while others are playing. \nUnchecked by default. GameOptionsInfo.option.disable_local_save.displayableName=Disable local saves when using double blind