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

@ -9,13 +9,14 @@ import java.util.ArrayList;
import java.util.List;
/**
* Game GUI: choose number
* Game GUI: choose number dialog
*
* @author BetaSteward_at_googlemail.com, JayDi85
*/
public class PickNumberDialog extends MageDialog {
private boolean cancel;
private PickNumberCallback callback = null;
public PickNumberDialog() {
initComponents();
@ -24,10 +25,15 @@ public class PickNumberDialog extends MageDialog {
this.setModal(true);
}
public void showDialog(int min, int max, String message) {
public interface PickNumberCallback {
void onChoiceDone();
}
public void showDialog(int min, int max, String message, PickNumberCallback callback) {
this.editAmount.setModel(new SpinnerNumberModel(min, min, max, 1));
this.textMessage.setContentType("text/html");
this.textMessage.setText(message);
this.callback = callback;
List<String> limits = new ArrayList<>();
if (min != Integer.MIN_VALUE) {
@ -42,11 +48,7 @@ public class PickNumberDialog 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);
this.getRootPane().setDefaultButton(this.buttonOk); // restore default button after root panel change (no need actually)
@ -73,7 +75,7 @@ public class PickNumberDialog extends MageDialog {
this.makeWindowCentered();
// TODO: need to fix focus restore on second popup (it's not focues, test on Manamorphose)
// TODO: need to fix focus restore on second popup (it's not get focus, test on Manamorphose)
this.setVisible(true);
}
@ -85,6 +87,13 @@ public class PickNumberDialog extends MageDialog {
return cancel;
}
private void doClose() {
this.hideDialog();
if (this.callback != null) {
this.callback.onChoiceDone();
}
}
/**
* This method is called from within the constructor to
* initialize the form.
@ -188,12 +197,12 @@ public class PickNumberDialog extends MageDialog {
private void buttonOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonOkActionPerformed
this.cancel = false;
this.hideDialog();
doClose();
}//GEN-LAST:event_buttonOkActionPerformed
private void buttonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCancelActionPerformed
this.cancel = true;
this.hideDialog();
doClose();
}//GEN-LAST:event_buttonCancelActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables