Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

button tool tip for hot keys #4125

Merged
merged 9 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion megamek/i18n/megamek/client/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ Cancel=Cancel
Close=Close
Next=Next
Previous=Previous
Left=Left
Right=Right
to=to
Error=Error
FROM=from
Expand Down Expand Up @@ -1558,8 +1560,10 @@ FiringDisplay.its_your_turn=It's your turn to fire.
FiringDisplay.fireMode=Mode
FiringDisplay.fireMore=More...
FiringDisplay.fireNextTarg=Next Target
FiringDisplay.fireNextTarg.tooltip=<html>Selects the next target (regardless of to hit.) <br>Holding shift when clicking will show next valid target that can be hit. <br>Holding control when clicking will cause allies to be ignored.</html>
FiringDisplay.fireNextTarg.tooltip=Selects the next target (regardless of to hit.) <br>Holding shift when clicking will show next valid target that can be hit. <br>Holding control when clicking will cause allies to be ignored.
FiringDisplay.fireNext=\ Next Unit
FiringDisplay.FireNextTarget.tooltip.Valid=Valid
FiringDisplay.FireNextTarget.tooltip.NoAllies=No Allies
FiringDisplay.fireStrafe=Strafe
FiringDisplay.OverheatNag.title=Allow overheating?
FiringDisplay.OverheatNag.message=Do you really wish to overheat? This will require a control roll.
Expand Down Expand Up @@ -2335,6 +2339,8 @@ MovementDisplay.UpToSpeed=Selected unit is up to speed so it can run/flank
MovementDisplay.UnjamRAC.title=Unjam?
MovementDisplay.UnjamRAC.message=Do you really wish to unjam? This will end your movement.
MovementDisplay.Mode=Mode
MovementDisplay.tooltip.ToggleMode=Toggle Mode
MovementDisplay.tooltip.ToggleMoveJump=Toggle Move / Jump

#Movement Mode display text
MovementType.None=None
Expand Down Expand Up @@ -3171,6 +3177,8 @@ TargetingPhaseDisplay.fireCancel=Cancel
TargetingPhaseDisplay.fireMode=Mode
TargetingPhaseDisplay.fireNextTarg=Next Target
TargetingPhaseDisplay.fireNextTarg.tooltip=Selects the next target (regardless of to hit.) \nHolding Control when clicking will show next valid target that can be hit.
TargetingPhaseDisplay.FireNextTarget.tooltip.Valid=Valid
TargetingPhaseDisplay.FireNextTarget.tooltip.NoAllies=No Allies
TargetingPhaseDisplay.fireNext=Next Unit
TargetingPhaseDisplay.fireSkip=Skip
TargetingPhaseDisplay.fireTwist=Twist
Expand Down
82 changes: 41 additions & 41 deletions megamek/mmconf/defaultKeyBinds.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@
</KeyBind>

<KeyBind>
<command>nextWeapon</command> <!-- E -->
<keyCode>69</keyCode>
<command>nextWeapon</command> <!-- Down -->
<keyCode>40</keyCode>
<modifier>0</modifier>
<isRepeatable>false</isRepeatable>
</KeyBind>

<KeyBind>
<command>prevWeapon</command> <!-- Q -->
<keyCode>81</keyCode>
<command>prevWeapon</command> <!-- Up -->
<keyCode>38</keyCode>
<modifier>0</modifier>
<isRepeatable>false</isRepeatable>
</KeyBind>
Expand All @@ -106,58 +106,58 @@
</KeyBind>

<KeyBind>
<command>nextTarget</command> <!-- Dead Acute -->
<keyCode>129</keyCode>
<command>nextTarget</command> <!-- Right -->
<keyCode>39</keyCode>
<modifier>0</modifier>
<isRepeatable>false</isRepeatable>
</KeyBind>

<KeyBind>
<command>prevTarget</command> <!-- Dead Acute -->
<keyCode>129</keyCode>
<command>prevTarget</command> <!-- Left -->
<keyCode>37</keyCode>
<modifier>0</modifier>
<isRepeatable>false</isRepeatable>
</KeyBind>

<KeyBind>
<command>nextTargetValid</command> <!-- Dead Acute -->
<keyCode>129</keyCode>
<modifier>0</modifier>
<command>nextTargetValid</command> <!-- Shift-Right -->
<keyCode>39</keyCode>
<modifier>64</modifier>
<isRepeatable>false</isRepeatable>
</KeyBind>

<KeyBind>
<command>prevTargetValid</command> <!-- Dead Acute -->
<keyCode>129</keyCode>
<modifier>0</modifier>
<command>prevTargetValid</command> <!-- Shift-Left -->
<keyCode>37</keyCode>
<modifier>64</modifier>
<isRepeatable>false</isRepeatable>
</KeyBind>

<KeyBind>
<command>nextTargetNoAllies</command> <!-- Dead Acute -->
<keyCode>129</keyCode>
<modifier>0</modifier>
<command>nextTargetNoAllies</command> <!-- Ctrl-Right -->
<keyCode>39</keyCode>
<modifier>128</modifier>
<isRepeatable>false</isRepeatable>
</KeyBind>

<KeyBind>
<command>prevTargetNoAllies</command> <!-- Dead Acute -->
<keyCode>129</keyCode>
<modifier>0</modifier>
<command>prevTargetNoAllies</command> <!-- Ctrl-Left -->
<keyCode>37</keyCode>
<modifier>128</modifier>
<isRepeatable>false</isRepeatable>
</KeyBind>

<KeyBind>
<command>nextTargetValidNoAllies</command> <!-- C -->
<keyCode>67</keyCode>
<modifier>0</modifier>
<command>nextTargetValidNoAllies</command> <!-- Ctrl+Shift-Right -->
<keyCode>39</keyCode>
<modifier>192</modifier>
<isRepeatable>false</isRepeatable>
</KeyBind>

<KeyBind>
<command>prevTargetValidNoAllies</command> <!-- Z -->
<keyCode>90</keyCode>
<modifier>0</modifier>
<command>prevTargetValidNoAllies</command> <!-- Ctrl+Shift-Left -->
<keyCode>37</keyCode>
<modifier>192</modifier>
<isRepeatable>false</isRepeatable>
</KeyBind>

Expand Down Expand Up @@ -197,8 +197,8 @@
</KeyBind>

<KeyBind>
<command>autoArtyDeployZone</command> <!-- Shift-Space -->
<keyCode>32</keyCode>
<command>autoArtyDeployZone</command> <!-- Shift-Z -->
<keyCode>90</keyCode>
<modifier>64</modifier>
<isRepeatable>false</isRepeatable>
</KeyBind>
Expand Down Expand Up @@ -274,15 +274,15 @@
</KeyBind>

<KeyBind>
<command>prevMode</command> <!-- Tab -->
<keyCode>9</keyCode>
<command>prevMode</command> <!-- Down -->
<keyCode>225</keyCode>
<modifier>0</modifier>
<isRepeatable>false</isRepeatable>
</KeyBind>

<KeyBind>
<command>nextMode</command> <!-- Tab -->
<keyCode>9</keyCode>
<command>nextMode</command> <!-- Up -->
<keyCode>224</keyCode>
<modifier>0</modifier>
<isRepeatable>false</isRepeatable>
</KeyBind>
Expand All @@ -302,9 +302,9 @@
</KeyBind>

<KeyBind>
<command>fieldOfFire</command> <!-- Ctrl-F -->
<keyCode>70</keyCode>
<modifier>128</modifier>
<command>fieldOfFire</command> <!-- R -->
<keyCode>82</keyCode>
<modifier>0</modifier>
<isRepeatable>false</isRepeatable>
</KeyBind>

Expand All @@ -330,9 +330,9 @@
</KeyBind>

<KeyBind>
<command>viewLosSetting</command> <!-- Ctrl+Alt-L -->
<command>viewLosSetting</command> <!-- Ctrl+Shift-L -->
<keyCode>76</keyCode>
<modifier>640</modifier>
<modifier>192</modifier>
<isRepeatable>false</isRepeatable>
</KeyBind>

Expand Down Expand Up @@ -407,16 +407,16 @@
</KeyBind>

<KeyBind>
<command>quickLoad</command> <!-- Ctrl+Shift-L -->
<command>quickLoad</command> <!-- Shift-L -->
<keyCode>76</keyCode>
<modifier>192</modifier>
<modifier>64</modifier>
<isRepeatable>false</isRepeatable>
</KeyBind>

<KeyBind>
<command>quickSave</command> <!-- Ctrl+Shift-S -->
<command>quickSave</command> <!-- Shift-S -->
<keyCode>83</keyCode>
<modifier>192</modifier>
<modifier>64</modifier>
<isRepeatable>false</isRepeatable>
</KeyBind>

Expand Down
5 changes: 3 additions & 2 deletions megamek/src/megamek/client/ui/swing/AbstractPhaseDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ public void actionPerformed(ActionEvent e) {

@Override
public boolean shouldPerformAction() {
if ((!clientgui.getClient().isMyTurn() && (clientgui
.getClient().getGame().getTurn() != null))
if (((!clientgui.getClient().isMyTurn()
&& (clientgui.getClient().getGame().getTurn() != null)
&& (!clientgui.getClient().getGame().getPhase().isReport())))
|| clientgui.getBoardView().getChatterBoxActive()
|| display.isIgnoringEvents()
|| !display.isVisible()
Expand Down
57 changes: 51 additions & 6 deletions megamek/src/megamek/client/ui/swing/DeployMinefieldDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import megamek.client.event.BoardViewEvent;
import megamek.client.ui.Messages;
import megamek.client.ui.swing.util.KeyCommandBind;
import megamek.client.ui.swing.widget.MegamekButton;
import megamek.client.ui.swing.widget.SkinSpecification;
import megamek.common.*;
Expand All @@ -25,6 +26,9 @@
import java.awt.event.MouseEvent;
import java.util.*;

import static megamek.client.ui.swing.util.UIUtil.guiScaledFontHTML;
import static megamek.client.ui.swing.util.UIUtil.uiLightViolet;

public class DeployMinefieldDisplay extends StatusBarPhaseDisplay {
private static final long serialVersionUID = -1243277953037374936L;

Expand Down Expand Up @@ -56,6 +60,17 @@ public String getCmd() {
public String toString() {
return cmd;
}

public String getHotKeyDesc() {
kuronekochomusuke marked this conversation as resolved.
Show resolved Hide resolved
kuronekochomusuke marked this conversation as resolved.
Show resolved Hide resolved
String result = "";

switch (this) {
default:
break;
}

return result;
}
}

// buttons
Expand Down Expand Up @@ -84,6 +99,19 @@ public DeployMinefieldDisplay(ClientGUI clientgui) {

p = clientgui.getClient().getLocalPlayer();

setButtons();
setButtonsTooltips();

butDone.setText(Messages.getString("DeployMinefieldDisplay.Done"));
String f = guiScaledFontHTML(uiLightViolet()) + KeyCommandBind.getDesc(KeyCommandBind.DONE)+ "</FONT>";
butDone.setToolTipText("<html><body>" + f + "</body></html>");
butDone.setEnabled(false);

setupButtonPanel();
}

@Override
protected void setButtons() {
buttons = new HashMap<>((int) (Command.values().length * 1.25 + 0.5));
for (Command cmd : Command.values()) {
String title = Messages.getString("DeployMinefieldDisplay."
Expand All @@ -98,13 +126,30 @@ public DeployMinefieldDisplay(ClientGUI clientgui) {
newButton.setActionCommand(cmd.getCmd());
newButton.setEnabled(false);
buttons.put(cmd, newButton);
}
}
numButtonGroups = (int) Math.ceil((buttons.size()+0.0) / buttonsPerGroup);

butDone.setText(Messages.getString("DeployMinefieldDisplay.Done"));
butDone.setEnabled(false);

setupButtonPanel();
}

@Override
protected void setButtonsTooltips() {
for (Command cmd : Command.values()) {
String ttKey = "DeployMinefieldDisplay." + cmd.getCmd() + ".tooltip";
String tt = cmd.getHotKeyDesc();
if (!tt.isEmpty()) {
String title = Messages.getString("DeployMinefieldDisplay." + cmd.getCmd());
tt = guiScaledFontHTML(uiLightViolet()) + title + ": " + tt + "</FONT>";
tt += "<BR>";
}
if (Messages.keyExists(ttKey)) {
String msg_key = Messages.getString(ttKey);
tt += guiScaledFontHTML() + msg_key + "</FONT>";
}
String b = "<BODY>" + tt + "</BODY>";
String h = "<HTML>" + b + "</HTML>";
if (!tt.isEmpty()) {
buttons.get(cmd).setToolTipText(h);
}
}
}

@Override
Expand Down
Loading