GUI: reworked GUI to support non-blocking UI:

- GUI: added non-blocking UI to almost all app and game dialogs;
- GUI: it allows to switch between UI dialogs and use any UI elements at any moment;
- GUI: it allows to use chat, card popup, battlefield, concede and other features while choosing (related to #12670);
- GUI: it allows to download images while playing (related to #4160, not fully tested);
- GUI: enabled by default, can be disabled by java option: -Dxmage.guiModalMode=true
- connection: auto-connect will be visible in main menu on startup;
- connection: removed some unused features (auto-connect by command line);
- connection: added <ESC> button to close connection dialog;
- download: added background images download (see non-blocking UI);
- download: improved cancel stability and fixes that it can't stop preparing/downloading process in some use cases;
- app: fixed freezes on macOS systems in some use cases (related to #12431, #11292, #9300, #4920);
This commit is contained in:
Oleg Agafonov 2024-09-08 00:40:13 +04:00
parent 2fc4e94b3a
commit 6625db1be1
40 changed files with 614 additions and 532 deletions

View file

@ -40,6 +40,7 @@ public class PickChoiceDialog extends MageDialog {
java.util.List<KeyValueItem> allItems = new ArrayList<>();
KeyValueItem biggestItem = null; // for render optimization
PickChoiceCallback callback = null;
final private static String HTML_HEADERS_TEMPLATE = "<html><div style='text-align: center;'>%s</div></html>";
@ -58,14 +59,19 @@ public class PickChoiceDialog extends MageDialog {
this.setModal(true);
}
public void showDialog(Choice choice, String startSelectionValue) {
showDialog(choice, startSelectionValue, null, null, null);
public interface PickChoiceCallback {
void onChoiceDone();
}
public void showDialog(Choice choice, String startSelectionValue, UUID objectId, MageDialogState mageDialogState, BigCard bigCard) {
public void showDialog(Choice choice, String startSelectionValue, PickChoiceCallback callback) {
showDialog(choice, startSelectionValue, null, null, null, callback);
}
public void showDialog(Choice choice, String startSelectionValue, UUID objectId, MageDialogState mageDialogState, BigCard bigCard, PickChoiceCallback callback) {
this.choice = choice;
this.bigCard = bigCard;
this.gameId = objectId;
this.callback = callback;
changeGUISize();
@ -244,11 +250,7 @@ public class PickChoiceDialog extends MageDialog {
// window settings
MageFrame.getDesktop().remove(this);
if (this.isModal()) {
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
} else {
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
}
MageFrame.getDesktop().add(this, this.isModal() ? JLayeredPane.MODAL_LAYER : JLayeredPane.PALETTE_LAYER);
if (mageDialogState != null) {
mageDialogState.setStateToDialog(this);
} else {
@ -421,14 +423,21 @@ public class PickChoiceDialog extends MageDialog {
private void doChoose() {
if (setChoice()) {
this.hideDialog();
doClose();
}
}
private void doCancel() {
this.listChoices.clearSelection();
this.choice.clearChoice();
hideDialog();
doClose();
}
private void doClose() {
this.hideDialog();
if (this.callback != null) {
this.callback.onChoiceDone();
}
}
public boolean setChoice() {