mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
Add (for now nonfunctional) ready buttons to network lobby.
This commit is contained in:
@@ -38,6 +38,7 @@ import forge.screens.deckeditor.CDeckEditorUI;
|
||||
import forge.screens.deckeditor.controllers.CEditorCommander;
|
||||
import forge.screens.deckeditor.controllers.CEditorVariant;
|
||||
import forge.screens.home.sanctioned.AvatarSelector;
|
||||
import forge.toolbox.FCheckBox;
|
||||
import forge.toolbox.FComboBox;
|
||||
import forge.toolbox.FComboBoxWrapper;
|
||||
import forge.toolbox.FLabel;
|
||||
@@ -71,6 +72,7 @@ public class PlayerPanel extends FPanel {
|
||||
private FRadioButton radioAi;
|
||||
private JCheckBoxMenuItem radioAiUseSimulation;
|
||||
private FRadioButton radioOpen;
|
||||
private FCheckBox chkReady;
|
||||
|
||||
private FComboBoxWrapper<Object> teamComboBox = new FComboBoxWrapper<Object>();
|
||||
private FComboBoxWrapper<Object> aeTeamComboBox = new FComboBoxWrapper<Object>();
|
||||
@@ -143,8 +145,10 @@ public class PlayerPanel extends FPanel {
|
||||
teamComboBox.addTo(this, variantBtnConstraints + ", pushx, growx, gaptop 5px");
|
||||
aeTeamComboBox.addTo(this, variantBtnConstraints + ", pushx, growx, gaptop 5px");
|
||||
|
||||
createReadyButtion();
|
||||
if (allowNetworking) {
|
||||
this.add(radioOpen, "cell 4 1, ax left, sx 2, wrap");
|
||||
this.add(radioOpen, "cell 4 1, ax left, sx 2");
|
||||
this.add(chkReady, "cell 5 1, ax left, sx 2, wrap");
|
||||
}
|
||||
|
||||
this.add(deckLabel, variantBtnConstraints + ", cell 0 2, sx 2, ax right");
|
||||
@@ -192,6 +196,7 @@ public class PlayerPanel extends FPanel {
|
||||
nameRandomiser.setEnabled(mayEdit);
|
||||
deckLabel.setVisible(mayEdit);
|
||||
deckBtn.setVisible(mayEdit);
|
||||
chkReady.setEnabled(mayEdit);
|
||||
|
||||
closeBtn.setVisible(mayRemove);
|
||||
|
||||
@@ -558,6 +563,15 @@ public class PlayerPanel extends FPanel {
|
||||
tempBtnGroup.add(radioOpen);
|
||||
}
|
||||
|
||||
private void createReadyButtion() {
|
||||
chkReady = new FCheckBox("Ready");
|
||||
chkReady.addActionListener(new ActionListener() {
|
||||
@Override public final void actionPerformed(final ActionEvent e) {
|
||||
lobby.setReady(index, chkReady.isSelected());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param index
|
||||
*/
|
||||
@@ -713,6 +727,13 @@ public class PlayerPanel extends FPanel {
|
||||
aeTeamComboBox.unsuppressActionListeners();
|
||||
}
|
||||
|
||||
public boolean isReady() {
|
||||
return chkReady.isSelected();
|
||||
}
|
||||
public void setIsReady(final boolean isReady) {
|
||||
chkReady.setSelected(isReady);
|
||||
}
|
||||
|
||||
public void setMayEdit(final boolean mayEdit) {
|
||||
this.mayEdit = mayEdit;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,9 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.AIOption;
|
||||
import forge.GuiBase;
|
||||
import forge.UiCommand;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.deck.CardPool;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.DeckProxy;
|
||||
@@ -238,6 +240,7 @@ public class VLobby implements IUpdateable {
|
||||
panel.setPlayerName(slot.getName());
|
||||
panel.setAvatar(slot.getAvatarIndex());
|
||||
panel.setTeam(slot.getTeam());
|
||||
panel.setIsReady(slot.isReady());
|
||||
panel.setIsArchenemy(slot.isArchenemy());
|
||||
panel.setUseAiSimulation(slot.getAiOptions().contains(AIOption.USE_SIMULATION));
|
||||
panel.setMayEdit(lobby.mayEdit(i));
|
||||
@@ -262,6 +265,16 @@ public class VLobby implements IUpdateable {
|
||||
this.playerChangeListener = listener;
|
||||
}
|
||||
|
||||
void setReady(final int index, final boolean ready) {
|
||||
if (ready && decks[index] == null) {
|
||||
GuiBase.getInterface().showOptionDialog("Select a deck before readying!", "Error", FSkinProp.ICO_WARNING, new String[] { "Ok" }, 0);
|
||||
update();
|
||||
return;
|
||||
}
|
||||
|
||||
firePlayerChangeListener(index);
|
||||
changePlayerFocus(index);
|
||||
}
|
||||
void firePlayerChangeListener(final int index) {
|
||||
if (playerChangeListener != null) {
|
||||
playerChangeListener.update(index, getSlot(index));
|
||||
@@ -289,7 +302,7 @@ public class VLobby implements IUpdateable {
|
||||
|
||||
private UpdateLobbyPlayerEvent getSlot(final int index) {
|
||||
final PlayerPanel panel = playerPanels.get(index);
|
||||
return UpdateLobbyPlayerEvent.create(panel.getType(), panel.getPlayerName(), panel.getAvatarIndex(), panel.getTeam(), panel.isArchenemy(), panel.getAiOptions());
|
||||
return UpdateLobbyPlayerEvent.create(panel.getType(), panel.getPlayerName(), panel.getAvatarIndex(), panel.getTeam(), panel.isArchenemy(), panel.isReady(), panel.getAiOptions());
|
||||
}
|
||||
|
||||
/** Builds the actual deck panel layouts for each player.
|
||||
|
||||
Reference in New Issue
Block a user