mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Updating threading in draft start game process.
This commit is contained in:
@@ -8,6 +8,7 @@ import java.util.Random;
|
|||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
import javax.swing.SwingWorker;
|
||||||
|
|
||||||
import forge.Command;
|
import forge.Command;
|
||||||
import forge.Constant;
|
import forge.Constant;
|
||||||
@@ -182,21 +183,37 @@ public enum CSubmenuDraft implements ICSubmenu {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
OverlayUtils.startGameOverlay();
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
OverlayUtils.showOverlay();
|
@Override
|
||||||
|
public void run() {
|
||||||
|
OverlayUtils.startGameOverlay();
|
||||||
|
OverlayUtils.showOverlay();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
DeckGroup opponentDecks = Singletons.getModel().getDecks().getDraft().get(human.getName());
|
final SwingWorker<Object, Void> worker = new SwingWorker<Object, Void>() {
|
||||||
|
@Override
|
||||||
|
public Object doInBackground() {
|
||||||
|
DeckGroup opponentDecks = Singletons.getModel().getDecks().getDraft().get(human.getName());
|
||||||
|
|
||||||
Constant.Runtime.HUMAN_DECK[0] = human;
|
Constant.Runtime.HUMAN_DECK[0] = human;
|
||||||
Constant.Runtime.COMPUTER_DECK[0] = opponentDecks.getAiDecks().get(aiIndex); //zero is human deck, so it must be +1
|
Constant.Runtime.COMPUTER_DECK[0] = opponentDecks.getAiDecks().get(aiIndex); //zero is human deck, so it must be +1
|
||||||
|
|
||||||
if (Constant.Runtime.COMPUTER_DECK[0] == null) {
|
if (Constant.Runtime.COMPUTER_DECK[0] == null) {
|
||||||
throw new IllegalStateException("Draft: Computer deck is null!");
|
throw new IllegalStateException("Draft: Computer deck is null!");
|
||||||
}
|
}
|
||||||
|
|
||||||
Constant.Runtime.setGameType(GameType.Draft);
|
Constant.Runtime.setGameType(GameType.Draft);
|
||||||
GameNew.newGame(Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0]);
|
GameNew.newGame(Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0]);
|
||||||
OverlayUtils.hideOverlay();
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void done() {
|
||||||
|
OverlayUtils.hideOverlay();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
worker.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
|
|||||||
Reference in New Issue
Block a user