Skip to content

Commit

Permalink
after-merge changes and CodeQL
Browse files Browse the repository at this point in the history
  • Loading branch information
SJuliez committed May 17, 2024
1 parent c522a36 commit 55e2bae
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public abstract class AbstractPhaseDisplay extends SkinnedJPanel implements

protected DistractableAdapter distracted = new DistractableAdapter();
protected MegamekButton butDone;
protected IClientGUI clientgui;
private final IClientGUI clientgui;

protected AbstractPhaseDisplay(IClientGUI cg) {
this(cg, SkinSpecification.UIComponents.PhaseDisplay.getComp(),
Expand Down
6 changes: 3 additions & 3 deletions megamek/src/megamek/client/ui/swing/ActionPhaseDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected ActionPhaseDisplay(ClientGUI cg) {
protected UIUtil.FixedXPanel setupDonePanel() {
var donePanel = super.setupDonePanel();
butSkipTurn = new MegamekButton("SKIP", SkinSpecification.UIComponents.PhaseDisplayDoneButton.getComp());
butSkipTurn.setPreferredSize(new Dimension(UIUtil.scaleForGUI(DONE_BUTTON_WIDTH), MIN_BUTTON_SIZE.height * 1));
butSkipTurn.setPreferredSize(new Dimension(UIUtil.scaleForGUI(DONE_BUTTON_WIDTH), MIN_BUTTON_SIZE.height));
String f = guiScaledFontHTML(UIUtil.uiLightViolet()) + KeyCommandBind.getDesc(KeyCommandBind.DONE_NO_ACTION)+ "</FONT>";
butSkipTurn.setToolTipText("<html><body>" + f + "</body></html>");
addToDonePanel(donePanel, butSkipTurn);
Expand Down Expand Up @@ -108,7 +108,7 @@ protected void initDonePanelForNewTurn() {
}

/** called to reset, show, hide and relabel the Done panel buttons. Override to change button labels and states,
* being sure to call {@link #updateDonePanelButtons(String,String,boolean) UpdateDonePanelButtons}
* being sure to call {@link #updateDonePanelButtons(String, String, boolean, List)}
* to set the button labels and states
*/
abstract protected void updateDonePanel();
Expand Down Expand Up @@ -349,6 +349,6 @@ protected void updateDonePanelButtons(final String doneButtonLabel, final String
}

private void adaptToGUIScale() {
butSkipTurn.setPreferredSize(new Dimension(UIUtil.scaleForGUI(DONE_BUTTON_WIDTH), MIN_BUTTON_SIZE.height * 1));
butSkipTurn.setPreferredSize(new Dimension(UIUtil.scaleForGUI(DONE_BUTTON_WIDTH), MIN_BUTTON_SIZE.height));
}
}
10 changes: 4 additions & 6 deletions megamek/src/megamek/client/ui/swing/ClientGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -350,17 +350,15 @@ public class ClientGUI extends AbstractClientGUI implements BoardViewListener,
* clean up after itself as much as possible, but will not call
* System.exit().
*/
public ClientGUI(IClient client, MegaMekController c) {
if (!(client instanceof Client)) {
throw new IllegalArgumentException("TW ClientGUI must use TW Client!");
}
this.client = (Client) client;
public ClientGUI(Client client, MegaMekController c) {
super(client);
this.client = client;
controller = c;
panMain.setLayout(cardsMain);
panSecondary.setLayout(cardsSecondary);

clientGuiPanel.setLayout(new BorderLayout());
clientGuiPanel.addComponentListener(this);
clientGuiPanel.addComponentListener(resizeListener);
clientGuiPanel.add(panMain, BorderLayout.CENTER);
clientGuiPanel.add(panSecondary, BorderLayout.SOUTH);

Expand Down
1 change: 0 additions & 1 deletion megamek/src/megamek/client/ui/swing/MovementDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@ public static MoveCommand[] values(int f, GameOptions opts, boolean forwardIni)
public MovementDisplay(final ClientGUI clientgui) {
super(clientgui);

this.clientgui = clientgui;
if (clientgui != null) {
clientgui.getClient().getGame().addGameListener(this);
clientgui.getBoardView().addBoardViewListener(this);
Expand Down
3 changes: 3 additions & 0 deletions megamek/src/megamek/client/ui/swing/ReportDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,15 @@ public String getHotKeyDesc() {
private static final String RD_REPORTDISPLAY = "ReportDisplay.";
private static final String RD_TOOLTIP = ".tooltip";

private final ClientGUI clientgui;

/**
* Creates and lays out a new movement phase display for the specified
* clientgui.getClient().
*/
public ReportDisplay(ClientGUI clientgui) {
super(clientgui);
this.clientgui = clientgui;

if (clientgui == null) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public abstract class StatusBarPhaseDisplay extends AbstractPhaseDisplay
protected static final GUIPreferences GUIP = GUIPreferences.getInstance();
private static final int BUTTON_ROWS = 2;
private static final String SBPD_KEY_CLEARBUTTON = "clearButton";
protected ClientGUI clientgui;
protected final ClientGUI clientgui;

/**
* timer that ends turn if time limit set in options is over
Expand Down
2 changes: 1 addition & 1 deletion megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public class ChatLounge extends AbstractPhaseDisplay implements

private static final GUIPreferences GUIP = GUIPreferences.getInstance();

protected ClientGUI clientgui;
private ClientGUI clientgui;

/** Creates a new chat lounge for the clientgui.getClient(). */
public ChatLounge(ClientGUI clientgui) {
Expand Down
34 changes: 0 additions & 34 deletions megamek/src/megamek/common/strategicBattleSystems/SBFGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,15 @@
import megamek.common.alphaStrike.AlphaStrikeElement;
import megamek.common.annotations.Nullable;
import megamek.common.enums.GamePhase;
import megamek.common.event.GameListener;
import megamek.common.event.GamePhaseChangeEvent;
import megamek.common.options.GameOptions;
import megamek.common.options.OptionsConstants;
import megamek.common.planetaryconditions.PlanetaryConditions;
import org.apache.logging.log4j.LogManager;

import java.util.*;
import java.util.Map;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
* This is an SBF game's game object that holds all game information. As of 2024, this is under construction.
Expand Down Expand Up @@ -212,35 +209,4 @@ public void replaceAllReports(Map<Integer, List<Report>> newReports) {
public void setLastPhase(GamePhase lastPhase) {
this.lastPhase = lastPhase;
}

public void setLastPhase(GamePhase lastPhase) {
this.lastPhase = lastPhase;
}

/**
* Adds the given reports this game's reports.
*
* @param reports the new reports to add
*/
public void addReports(List<Report> reports) {
gameReport.add(getCurrentRound(), reports);
}

@Override
public ReportEntry getNewReport(int messageId) {
return new Report(messageId);
}

public SBFFullGameReport getGameReport() {
return gameReport;
}

/**
* Replaces this game's entire reports with the given reports.
*
* @param newReports The new reports to keep as this game's reports
*/
public void replaceAllReports(Map<Integer, List<Report>> newReports) {
gameReport.replaceAllReports(newReports);
}
}

0 comments on commit 55e2bae

Please sign in to comment.