Skip to content

Commit

Permalink
re-add missing game events, misc panels
Browse files Browse the repository at this point in the history
  • Loading branch information
SJuliez committed Mar 27, 2024
1 parent 05f2216 commit 9d8f3ee
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 12 deletions.
2 changes: 1 addition & 1 deletion megamek/i18n/megamek/client/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ ClientGUI.StartingScenario=Starting scenario...
ClientGUI.Show=Show
ClientGUI.targetMenuItem=Target
ClientGUI.title=MegaMek Client
ClientGUI.TransmittingData=Transmitting game data...
ClientGUI.TransmittingData=Receiving game data...
ClientGUI.viewMenuItem=View
ClientGUI.viewReadoutMenuItem=View Readout
ClientGUI.doneMenuItem=Done
Expand Down
2 changes: 2 additions & 0 deletions megamek/src/megamek/client/AbstractClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import megamek.Version;
import megamek.client.commands.ClientCommand;
import megamek.common.*;
import megamek.common.event.GamePlayerChangeEvent;
import megamek.common.event.GamePlayerChatEvent;
import megamek.common.event.GamePlayerDisconnectedEvent;
import megamek.common.force.Force;
Expand Down Expand Up @@ -427,6 +428,7 @@ protected boolean handleGameIndependentPacket(Packet packet) {
Player player = getPlayer(packet.getIntValue(0));
if (player != null) {
player.setDone(packet.getBooleanValue(1));
getIGame().fireGameEvent(new GamePlayerChangeEvent(player, player));
}
break;
case PLAYER_REMOVE:
Expand Down
3 changes: 2 additions & 1 deletion megamek/src/megamek/client/ui/swing/ClientGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,8 @@ private JComponent initializePanel(GamePhase phase) {
break;
case EXCHANGE:
chatlounge.killPreviewBV();
component = new JLabel(Messages.getString("ClientGUI.TransmittingData"));
component = new ReceivingGameDataPanel();
// component = new JLabel(Messages.getString("ClientGUI.TransmittingData"));
UIUtil.scaleComp(component, UIUtil.FONT_SCALE1);
main = CG_EXCHANGE;
component.setName(main);
Expand Down
51 changes: 51 additions & 0 deletions megamek/src/megamek/client/ui/swing/ReceivingGameDataPanel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2024 - The MegaMek Team. All Rights Reserved.
*
* This file is part of MegaMek.
*
* MegaMek is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MegaMek is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MegaMek. If not, see <http://www.gnu.org/licenses/>.
*/
package megamek.client.ui.swing;

import megamek.client.ui.Messages;
import megamek.client.ui.swing.util.UIUtil;

import javax.swing.*;
import java.awt.*;

public class ReceivingGameDataPanel extends JPanel {

private static final String text = "<HTML><FONT FACE=Anta SIZE=+3>"
+ Messages.getString("ClientGUI.TransmittingData");
private static final String sign = "<HTML><FONT FACE=Anta SIZE=+5>\u279F";

/**
* Returns a panel that shows the centered notice saying "Under Construction" with a warning sign above.
*/
public ReceivingGameDataPanel() {
JPanel textPanel = new UIUtil.FixedYPanel(new FlowLayout(FlowLayout.CENTER));
textPanel.add(new JLabel(text));

JPanel symbolPanel = new UIUtil.FixedYPanel(new FlowLayout(FlowLayout.CENTER));
JLabel symbolLabel = new JLabel(sign);
symbolLabel.setForeground(UIUtil.uiGreen());
symbolPanel.add(symbolLabel);

setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
add(Box.createVerticalGlue());
add(symbolPanel);
add(textPanel);
add(Box.createVerticalGlue());
}
}
10 changes: 5 additions & 5 deletions megamek/src/megamek/client/ui/swing/UnderConstructionPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ public UnderConstructionPanel() {
JPanel textPanel = new UIUtil.FixedYPanel(new FlowLayout(FlowLayout.CENTER));
textPanel.add(new JLabel(text));

JPanel warningSignPanel = new UIUtil.FixedYPanel(new FlowLayout(FlowLayout.CENTER));
JLabel warningSignLabel = new JLabel(sign);
warningSignLabel.setForeground(GUIPreferences.getInstance().getCautionColor());
warningSignPanel.add(warningSignLabel);
JPanel symbolPanel = new UIUtil.FixedYPanel(new FlowLayout(FlowLayout.CENTER));
JLabel symbolLabel = new JLabel(sign);
symbolLabel.setForeground(GUIPreferences.getInstance().getCautionColor());
symbolPanel.add(symbolLabel);

setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
add(Box.createVerticalGlue());
add(warningSignPanel);
add(symbolPanel);
add(textPanel);
add(Box.createVerticalGlue());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ public WaitingForServerPanel() {
JPanel textPanel = new UIUtil.FixedYPanel(new FlowLayout(FlowLayout.CENTER));
textPanel.add(new JLabel(text));

JPanel warningSignPanel = new UIUtil.FixedYPanel(new FlowLayout(FlowLayout.CENTER));
JLabel warningSignLabel = new JLabel(sign);
warningSignPanel.add(warningSignLabel);
JPanel symbolPanel = new UIUtil.FixedYPanel(new FlowLayout(FlowLayout.CENTER));
JLabel symbolLabel = new JLabel(sign);
symbolPanel.add(symbolLabel);

setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
add(Box.createVerticalGlue());
add(warningSignPanel);
add(symbolPanel);
add(textPanel);
add(Box.createVerticalGlue());
}
Expand Down
2 changes: 1 addition & 1 deletion megamek/src/megamek/common/AbstractGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ public void processGameEvent(GameEvent event) {
if (gameListeners == null) {
gameListeners = new Vector<>();
}
// This iteration must allow concurrent modification of the list!
for (Enumeration<GameListener> e = gameListeners.elements(); e.hasMoreElements(); ) {
event.fireEvent(e.nextElement());
}
// gameListeners.forEach(event::fireEvent);
}
}

0 comments on commit 9d8f3ee

Please sign in to comment.