* UI: added F12 hotkey to go in or out from game chat (can be changed in preferences);

This commit is contained in:
Oleg Agafonov 2019-04-06 04:01:06 +04:00
parent c3da15493a
commit 11b254e5f7
4 changed files with 112 additions and 51 deletions

View file

@ -6033,27 +6033,25 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="labelCancel" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="labelNextTurn" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="labelEndStep" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="labelMainStep" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="labelYourTurn" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="lebelSkip" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="labelPriorEnd" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="labelSkipStep" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="labelConfirm" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="labelToggleRecordMacro" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="bttnResetControls" min="-2" max="-2" attributes="0"/>
<Component id="labelSwitchChat" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="bttnResetControls" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="labelCancel" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="labelNextTurn" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="labelEndStep" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="labelMainStep" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="labelYourTurn" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="lebelSkip" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="labelPriorEnd" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="labelSkipStep" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="labelConfirm" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="labelToggleRecordMacro" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="keyConfirm" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="keyCancelSkip" alignment="0" min="-2" max="-2" attributes="0"/>
@ -6066,8 +6064,12 @@
<Component id="keyEndStep" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="keyToggleRecordMacro" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="controlsDescriptionLabel" pref="468" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="321" max="-2" attributes="0"/>
<Component id="controlsDescriptionLabel" pref="151" max="32767" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="keySwitchChat" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
@ -6132,6 +6134,11 @@
</Group>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="keySwitchChat" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="labelSwitchChat" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="bttnResetControls" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
@ -6284,6 +6291,19 @@
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new KeyBindButton(this, KEY_CONTROL_TOGGLE_MACRO)"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="labelSwitchChat">
<Properties>
<Property name="text" type="java.lang.String" value="Go in/out to chat"/>
</Properties>
</Component>
<Component class="mage.client.components.KeyBindButton" name="keySwitchChat">
<Properties>
<Property name="text" type="java.lang.String" value="keyBindButton1"/>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new KeyBindButton(this, KEY_CONTROL_SWITCH_CHAT)"/>
</AuxValues>
</Component>
</SubComponents>
</Container>
</SubComponents>

View file

@ -279,6 +279,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
// controls
public static final String KEY_CONTROL_TOGGLE_MACRO = "controlToggleMacro";
public static final String KEY_CONTROL_SWITCH_CHAT = "controlSwitchChat";
public static final String KEY_CONTROL_CONFIRM = "controlConfirm";
public static final String KEY_CONTROL_CANCEL_SKIP = "controlCancelSkip";
public static final String KEY_CONTROL_NEXT_TURN = "controlNextTurn";
@ -568,6 +569,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
bttnResetControls = new javax.swing.JButton();
labelToggleRecordMacro = new javax.swing.JLabel();
keyToggleRecordMacro = new KeyBindButton(this, KEY_CONTROL_TOGGLE_MACRO);
labelSwitchChat = new javax.swing.JLabel();
keySwitchChat = new KeyBindButton(this, KEY_CONTROL_SWITCH_CHAT);
saveButton = new javax.swing.JButton();
exitButton = new javax.swing.JButton();
@ -2622,29 +2625,32 @@ public class PreferencesDialog extends javax.swing.JDialog {
keyToggleRecordMacro.setText("keyBindButton1");
labelSwitchChat.setText("Go in/out to chat");
keySwitchChat.setText("keyBindButton1");
org.jdesktop.layout.GroupLayout tabControlsLayout = new org.jdesktop.layout.GroupLayout(tabControls);
tabControls.setLayout(tabControlsLayout);
tabControlsLayout.setHorizontalGroup(
tabControlsLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(tabControlsLayout.createSequentialGroup()
.addContainerGap()
.add(tabControlsLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(labelCancel)
.add(labelNextTurn)
.add(labelEndStep)
.add(labelMainStep)
.add(labelYourTurn)
.add(lebelSkip)
.add(labelPriorEnd)
.add(labelSkipStep)
.add(labelConfirm)
.add(labelToggleRecordMacro)
.add(bttnResetControls)
.add(labelSwitchChat))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
.add(tabControlsLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(tabControlsLayout.createSequentialGroup()
.add(bttnResetControls)
.add(0, 0, Short.MAX_VALUE))
.add(tabControlsLayout.createSequentialGroup()
.add(tabControlsLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(labelCancel)
.add(labelNextTurn)
.add(labelEndStep)
.add(labelMainStep)
.add(labelYourTurn)
.add(lebelSkip)
.add(labelPriorEnd)
.add(labelSkipStep)
.add(labelConfirm)
.add(labelToggleRecordMacro))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
.add(tabControlsLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(keyConfirm, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(keyCancelSkip, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
@ -2656,8 +2662,11 @@ public class PreferencesDialog extends javax.swing.JDialog {
.add(keySkipStep, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(keyEndStep, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(keyToggleRecordMacro, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(controlsDescriptionLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 468, Short.MAX_VALUE)))
.add(321, 321, 321)
.add(controlsDescriptionLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE))
.add(tabControlsLayout.createSequentialGroup()
.add(keySwitchChat, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
tabControlsLayout.setVerticalGroup(
@ -2706,6 +2715,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
.add(tabControlsLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(labelToggleRecordMacro)
.add(keyToggleRecordMacro, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(tabControlsLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(keySwitchChat, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(labelSwitchChat))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
.add(bttnResetControls)
.addContainerGap())
@ -2927,6 +2940,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
save(prefs, dialog.keySkipStack);
save(prefs, dialog.keyPriorEnd);
save(prefs, dialog.keyToggleRecordMacro);
save(prefs, dialog.keySwitchChat);
// Avatar
if (selectedAvatarId < MIN_AVATAR_ID || selectedAvatarId > MAX_AVATAR_ID) {
@ -3520,6 +3534,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
load(prefs, dialog.keySkipStack);
load(prefs, dialog.keyPriorEnd);
load(prefs, dialog.keyToggleRecordMacro);
load(prefs, dialog.keySwitchChat);
}
private static void loadSelectedAvatar(Preferences prefs) {
@ -3728,6 +3743,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
}
}
public static int getCurrentKeyControlKey(String key) {
return getCachedValue(key, getDefaultControlKey(key));
}
private static int getDefaultControlKey(String key) {
switch (key) {
case KEY_CONTROL_CONFIRM:
@ -3742,14 +3761,16 @@ public class PreferencesDialog extends javax.swing.JDialog {
return KeyEvent.VK_F6;
case KEY_CONTROL_MAIN_STEP:
return KeyEvent.VK_F7;
case KEY_CONTROL_TOGGLE_MACRO:
return KeyEvent.VK_F8;
case KEY_CONTROL_YOUR_TURN:
return KeyEvent.VK_F9;
case KEY_CONTROL_SKIP_STACK:
return KeyEvent.VK_F10;
case KEY_CONTROL_PRIOR_END:
return KeyEvent.VK_F11;
case KEY_CONTROL_TOGGLE_MACRO:
return KeyEvent.VK_F8;
case KEY_CONTROL_SWITCH_CHAT:
return KeyEvent.VK_F12;
default:
return 0;
}
@ -3897,7 +3918,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
keySkipStack,
keySkipStep,
keyYourTurn,
keyToggleRecordMacro
keyToggleRecordMacro,
keySwitchChat
);
}
@ -4013,6 +4035,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
private mage.client.components.KeyBindButton keyPriorEnd;
private mage.client.components.KeyBindButton keySkipStack;
private mage.client.components.KeyBindButton keySkipStep;
private mage.client.components.KeyBindButton keySwitchChat;
private mage.client.components.KeyBindButton keyToggleRecordMacro;
private mage.client.components.KeyBindButton keyYourTurn;
private javax.swing.JLabel labelCancel;
@ -4034,6 +4057,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
private javax.swing.JLabel labelPriorEnd;
private javax.swing.JLabel labelSkipStep;
private javax.swing.JLabel labelStackWidth;
private javax.swing.JLabel labelSwitchChat;
private javax.swing.JLabel labelToggleRecordMacro;
private javax.swing.JLabel labelTooltipSize;
private javax.swing.JLabel labelYourTurn;

View file

@ -1783,6 +1783,21 @@ public final class GamePanel extends javax.swing.JPanel {
}
});
KeyStroke ks12 = getCachedKeystroke(KEY_CONTROL_SWITCH_CHAT);
this.getInputMap(c).put(ks12, "F12_PRESS");
this.getActionMap().put("F12_PRESS", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
// switch in/out to chat, must triggers in chat input too
//if (isUserImputActive()) return;
if (isChatInputActive()) {
KeyboardFocusManager.getCurrentKeyboardFocusManager().clearFocusOwner();
} else if (!isUserImputActive()) {
userChatPanel.getTxtMessageInputComponent().requestFocusInWindow();
}
}
});
KeyStroke ksAltE = KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.ALT_MASK);
this.getInputMap(c).put(ksAltE, "ENLARGE");
this.getActionMap().put("ENLARGE", new AbstractAction() {

View file

@ -1,4 +1,3 @@
package mage.client.remote;
import mage.cards.decks.Deck;
@ -158,7 +157,7 @@ public class CallbackClientImpl implements CallbackClient {
case GAME_INIT: {
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
appendJsonEvent("GAME_INIT", callback.getObjectId(), (GameView) callback.getData());
appendJsonEvent("GAME_INIT", callback.getObjectId(), callback.getData());
panel.init((GameView) callback.getData());
}
break;
@ -405,31 +404,34 @@ public class CallbackClientImpl implements CallbackClient {
.append("<br/>Turn mousewheel up (ALT-e) - enlarge image of card the mousepointer hovers over")
.append("<br/>Turn mousewheel down (ALT-s) - enlarge original/alternate image of card the mousepointer hovers over")
.append("<br/><b>")
.append(KeyEvent.getKeyText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CONTROL_CONFIRM, 113)))
.append(KeyEvent.getKeyText(PreferencesDialog.getCurrentKeyControlKey(PreferencesDialog.KEY_CONTROL_CONFIRM)))
.append("</b> - Confirm \"Ok\", \"Yes\" or \"Done\" button")
.append("<br/><b>")
.append(KeyEvent.getKeyText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CONTROL_NEXT_TURN, 115)))
.append(KeyEvent.getKeyText(PreferencesDialog.getCurrentKeyControlKey(PreferencesDialog.KEY_CONTROL_NEXT_TURN)))
.append("</b> - Skip current turn but stop on declare attackers/blockers and something on the stack")
.append("<br/><b>")
.append(KeyEvent.getKeyText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CONTROL_END_STEP, 116)))
.append(KeyEvent.getKeyText(PreferencesDialog.getCurrentKeyControlKey(PreferencesDialog.KEY_CONTROL_END_STEP)))
.append("</b> - Skip to next end step but stop on declare attackers/blockers and something on the stack")
.append("<br/><b>")
.append(KeyEvent.getKeyText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CONTROL_SKIP_STEP, 117)))
.append(KeyEvent.getKeyText(PreferencesDialog.getCurrentKeyControlKey(PreferencesDialog.KEY_CONTROL_SKIP_STEP)))
.append("</b> - Skip current turn but stop on declare attackers/blockers")
.append("<br/><b>")
.append(KeyEvent.getKeyText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CONTROL_MAIN_STEP, 118)))
.append(KeyEvent.getKeyText(PreferencesDialog.getCurrentKeyControlKey(PreferencesDialog.KEY_CONTROL_MAIN_STEP)))
.append("</b> - Skip to next main phase but stop on declare attackers/blockers and something on the stack")
.append("<br/><b>")
.append(KeyEvent.getKeyText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CONTROL_YOUR_TURN, 120)))
.append(KeyEvent.getKeyText(PreferencesDialog.getCurrentKeyControlKey(PreferencesDialog.KEY_CONTROL_YOUR_TURN)))
.append("</b> - Skip everything until your next turn")
.append("<br/><b>")
.append(KeyEvent.getKeyText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CONTROL_PRIOR_END, 122)))
.append(KeyEvent.getKeyText(PreferencesDialog.getCurrentKeyControlKey(PreferencesDialog.KEY_CONTROL_PRIOR_END)))
.append("</b> - Skip everything until the end step just prior to your turn")
.append("<br/><b>")
.append(KeyEvent.getKeyText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CONTROL_CANCEL_SKIP, 114)))
.append(KeyEvent.getKeyText(PreferencesDialog.getCurrentKeyControlKey(PreferencesDialog.KEY_CONTROL_CANCEL_SKIP)))
.append("</b> - Undo F4/F5/F7/F9/F11")
.append("<br/><b>")
.append(KeyEvent.getKeyText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CONTROL_TOGGLE_MACRO, 119)))
.append(KeyEvent.getKeyText(PreferencesDialog.getCurrentKeyControlKey(PreferencesDialog.KEY_CONTROL_SWITCH_CHAT)))
.append("</b> - Switth in/out to chat text field")
.append("<br/><b>")
.append(KeyEvent.getKeyText(PreferencesDialog.getCurrentKeyControlKey(PreferencesDialog.KEY_CONTROL_TOGGLE_MACRO)))
.append("</b> - Toggle recording a sequence of actions to repeat. Will not pause if interrupted and can fail if a selected card changes such as when scrying top card to bottom.")
.append("<br/><b>").append(System.getProperty("os.name").contains("Mac OS X") ? "Cmd" : "Ctrl").append(" + click</b> - Hold priority while casting a spell or activating an ability")
.append("<br/>").append("Type <b>/FIX</b> message in chat to fix freezed game")