Skip to content

Commit

Permalink
Fix this and that
Browse files Browse the repository at this point in the history
  • Loading branch information
trixon committed Dec 3, 2024
1 parent 2b93c8a commit 86822b6
Show file tree
Hide file tree
Showing 19 changed files with 55 additions and 30 deletions.
2 changes: 0 additions & 2 deletions main/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-util</artifactId>
<version>${netbeans.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
Expand All @@ -63,7 +62,6 @@
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-awt</artifactId>
<version>${netbeans.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
Expand Down
8 changes: 4 additions & 4 deletions main/src/main/java/se/trixon/yaya/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public class Options extends OptionsBase {
public static final String DEFAULT_PLAYERS_ALL = "Ask;Embla";
public static final boolean DEFAULT_PLAY_SOUND = true;
public static final String DEFAULT_RULE_ID = "se.trixon.yaya.rules.yaya_scandinavian";
public static final boolean DEFAULT_SHOW_INDICATORS = true;
public static final boolean DEFAULT_SHOW_LIM_COLUMN = false;
public static final boolean DEFAULT_SHOW_MAX_COLUMN = false;
public static final String KEY_FONT_SIZE = "font.size";
public static final String KEY_GAME_START_COUNTER = "game.start_counter";
public static final String KEY_NUM_OF_PLAYERS = "numOfPlayers";
Expand All @@ -44,13 +47,10 @@ public class Options extends OptionsBase {
public static final String KEY_SHOW_LIM_COLUMN = "showLimColumn";
public static final String KEY_SHOW_MAX_COLUMN = "showMaxColumn";
public static final String KEY_THEME = "theme";
private static final int DEFAULT_FONT_SIZE = 12;
private static final int DEFAULT_FONT_SIZE = 24;
private static final String DEFAULT_GAME_VARIANT = "standard";
private static final int DEFAULT_NUM_OF_PLAYERS = 2;
private static final boolean DEFAULT_REVERSE_DIRECTION = false;
private static final boolean DEFAULT_SHOW_INDICATORS = true;
private static final boolean DEFAULT_SHOW_LIM_COLUMN = false;
private static final boolean DEFAULT_SHOW_MAX_COLUMN = false;
private static final String DEFAULT_THEME = "default";
private Player[] mPlayers;

Expand Down
11 changes: 8 additions & 3 deletions main/src/main/java/se/trixon/yaya/OptionsPanel.form
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,10 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="soundCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="reverseScrollCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="reverseScrollCheckBox" alignment="0" max="32767" attributes="0"/>
<Component id="removeButton" alignment="0" max="32767" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
Expand All @@ -204,7 +205,9 @@
<Component id="soundCheckBox" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="reverseScrollCheckBox" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="removeButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
Expand All @@ -230,6 +233,8 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="reverseScrollCheckBoxActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="removeButton">
</Component>
</SubComponents>
</Container>
</SubComponents>
Expand Down
16 changes: 13 additions & 3 deletions main/src/main/java/se/trixon/yaya/OptionsPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
*/
package se.trixon.yaya;

import javax.swing.Action;
import javax.swing.DefaultComboBoxModel;
import org.openide.awt.Actions;
import se.trixon.almond.util.Dict;
import se.trixon.almond.util.swing.DelayedResetRunner;
import se.trixon.yaya.themes.Theme;
Expand All @@ -41,6 +43,9 @@ public OptionsPanel() {
initComponents();
initListeners();
loadOptions();
var a = Actions.forID("Game", "se.trixon.yaya.actions.RemovePlayerAction");
Actions.connect(removeButton, a);
removeButton.setText((String) a.getValue(Action.NAME));
}

private void initListeners() {
Expand Down Expand Up @@ -81,6 +86,7 @@ private void initComponents() {
systemPanel = new javax.swing.JPanel();
soundCheckBox = new javax.swing.JCheckBox();
reverseScrollCheckBox = new javax.swing.JCheckBox();
removeButton = new javax.swing.JButton();

scorecardPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(OptionsPanel.class, "OptionsPanel.scorecardPanel.border.title"))); // NOI18N

Expand Down Expand Up @@ -190,9 +196,10 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
systemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(systemPanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(systemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(systemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(soundCheckBox)
.addComponent(reverseScrollCheckBox))
.addComponent(reverseScrollCheckBox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(removeButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
systemPanelLayout.setVerticalGroup(
Expand All @@ -202,7 +209,9 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addComponent(soundCheckBox)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(reverseScrollCheckBox)
.addContainerGap())
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(removeButton)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
Expand Down Expand Up @@ -259,6 +268,7 @@ private void soundCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN
private javax.swing.JCheckBox indicatorCheckBox;
private javax.swing.JCheckBox limCheckBox;
private javax.swing.JCheckBox maxCheckBox;
private javax.swing.JButton removeButton;
private javax.swing.JCheckBox reverseScrollCheckBox;
private javax.swing.JPanel scorecardPanel;
private javax.swing.JLabel sizeLabel;
Expand Down
5 changes: 1 addition & 4 deletions main/src/main/java/se/trixon/yaya/PopupManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,21 @@ private void initMenu() {
var newMenuItem = new JMenuItem();
var fullscreenMenuItem = new JMenuItem();
var optionsMenuItem = new JMenuItem();
var removePlayerMenuItem = new JMenuItem();
var helpMenuItem = new JMenuItem();
var aboutMenuItem = new JMenuItem();
var quitMenuItem = new JMenuItem();

Actions.connect(newMenuItem, Actions.forID("Game", "se.trixon.yaya.actions.NewRoundAction"), false);
Actions.connect(removePlayerMenuItem, Actions.forID("Game", "se.trixon.yaya.actions.RemovePlayerAction"), false);
Actions.connect(optionsMenuItem, Actions.forID("Game", "se.trixon.yaya.actions.OptionsAction"), false);
Actions.connect(fullscreenMenuItem, Actions.forID("Help", "se.trixon.yaya.actions.FullScreenAction"), false);
Actions.connect(helpMenuItem, Actions.forID("Help", "se.trixon.yaya.actions.HelpAction"), false);
Actions.connect(aboutMenuItem, Actions.forID("Help", "se.trixon.yaya.actions.AboutAction"), false);
Actions.connect(quitMenuItem, Actions.forID("File", "se.trixon.almond.nbp.actions.QuitAction"), false);

mPopupMenu.add(newMenuItem);
mPopupMenu.add(fullscreenMenuItem);
mPopupMenu.add(new JPopupMenu.Separator());
mPopupMenu.add(optionsMenuItem);
mPopupMenu.add(removePlayerMenuItem);
mPopupMenu.add(fullscreenMenuItem);
mPopupMenu.add(new JPopupMenu.Separator());
mPopupMenu.add(helpMenuItem);
mPopupMenu.add(aboutMenuItem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
@ActionRegistration(
displayName = "#CTL_NewRoundAction"
)
@ActionReference(path = "Shortcuts", name = "N")
@ActionReference(path = "Shortcuts", name = "F2")
@Messages("CTL_NewRoundAction=New round")
public final class RootNewRoundAction extends BaseAction {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
@ActionRegistration(
displayName = "#CTL_OptionsAction"
)
@ActionReference(path = "Shortcuts", name = "O")
@ActionReference(path = "Shortcuts", name = "F3")
@NbBundle.Messages("CTL_OptionsAction=Options")
public final class RootOptionsAction extends BaseAction {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ public class ScorecardIndicatorAction extends BaseAction {

@Override
public void actionPerformed(ActionEvent e) {
mOptions.invert(Options.KEY_SHOW_INDICATORS);
mOptions.invert(Options.KEY_SHOW_INDICATORS, Options.DEFAULT_SHOW_INDICATORS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ public class ScorecardLimAction extends BaseAction {

@Override
public void actionPerformed(ActionEvent e) {
mOptions.invert(Options.KEY_SHOW_LIM_COLUMN);
mOptions.invert(Options.KEY_SHOW_LIM_COLUMN, Options.DEFAULT_SHOW_LIM_COLUMN);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ public class ScorecardMaxAction extends BaseAction {

@Override
public void actionPerformed(ActionEvent e) {
mOptions.invert(Options.KEY_SHOW_MAX_COLUMN);
mOptions.invert(Options.KEY_SHOW_MAX_COLUMN, Options.DEFAULT_SHOW_MAX_COLUMN);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
id = "se.trixon.yaya.actions.FullScreenAction"
)
@ActionRegistration(displayName = "#CTL_FullScreenAction")
@ActionReference(path = "Shortcuts", name = "F")
@ActionReference(path = "Shortcuts", name = "F11")
@NbBundle.Messages("CTL_FullScreenAction=Full screen")
public class SystemFullScreenAction extends BaseAction {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,27 @@
package se.trixon.yaya.actions;

import java.awt.event.ActionEvent;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionRegistration;
import org.openide.util.NbBundle;
import se.trixon.yaya.Options;

/**
*
* @author Patrik Karlström
*/
@ActionID(
category = "Game",
id = "se.trixon.yaya.actions.PlaySoundAction"
)
@ActionRegistration(displayName = "#CTL_PlaySoundAction")
@ActionReference(path = "Shortcuts", name = "F4")
@NbBundle.Messages("CTL_PlaySoundAction=Play sound")
public class SystemPlaySoundAction extends BaseAction {

@Override
public void actionPerformed(ActionEvent e) {
mOptions.invert(Options.KEY_PLAY_SOUND);
mOptions.invert(Options.KEY_PLAY_SOUND, Options.DEFAULT_PLAY_SOUND);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionRegistration;
import org.openide.util.NbBundle;
import se.trixon.yaya.Options;
Expand All @@ -37,7 +36,6 @@
id = "se.trixon.yaya.actions.RemovePlayerAction"
)
@ActionRegistration(displayName = "#CTL_RemovePlayerAction")
@ActionReference(path = "Shortcuts", name = "DELETE")
@NbBundle.Messages("CTL_RemovePlayerAction=Remove player")
public final class SystemRemovePlayerAction extends BaseAction {

Expand Down
1 change: 0 additions & 1 deletion main/src/main/java/se/trixon/yaya/boot/DoOnStart.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,4 @@ public void run() {
contentPane.add(Yaya.getInstance().getPanel());
});
}

}
2 changes: 2 additions & 0 deletions main/src/main/java/se/trixon/yaya/scorecard/ScoreCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ public void setEnabledUndo(boolean enabled) {
public void setVisibleIndicators(boolean visible) {
mShowIndicators = visible;
getActivePlayerColumn().setVisibleIndicators(visible);
mScoreCardPanel.repaint();
mScoreCardPanel.revalidate();
}

public void undo() {
Expand Down
4 changes: 2 additions & 2 deletions main/src/main/resources/se/trixon/yaya/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ confirmQuitMessage=Cancel this round and quit Yaya...
confirmQuitTitle=Quit Yaya?
OptionsPanel.scorecardPanel.border.title=Scorecard
OptionsPanel.limCheckBox.text=Lim
OptionsPanel.indicatorCheckBox.text=Indicator
OptionsPanel.indicatorCheckBox.text=Indicators
OptionsPanel.maxCheckBox.text=Max
OptionsPanel.reverseScrollCheckBox.text=Reversed scroll direction
OptionsPanel.soundCheckBox.text=Sound
OptionsPanel.soundCheckBox.text=Play sound
OptionsPanel.limCheckBox.toolTipText=F5
OptionsPanel.maxCheckBox.toolTipText=F6
OptionsPanel.indicatorCheckBox.toolTipText=F7
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ confirmQuitTitle=Avsluta Yaya?
confirmQuitMessage=Avbryt denna omg\u00e5ng och avsluta Yaya...
diceRreversedDirection=Omv\u00e4nd rullningsriktning
scorecardIndicators=Indikatorer
OptionsPanel.scorecardPanel.border.title=Protokoll
OptionsPanel.indicatorCheckBox.text=Indikatorer
OptionsPanel.reverseScrollCheckBox.text=Omv\u00e4nd rullningsrikting
OptionsPanel.soundCheckBox.text=Spela ljud
2 changes: 1 addition & 1 deletion main/src/main/resources/se/trixon/yaya/about.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ app.name=Yaya
app.description=Yet Another Yahtzee-esque Application
authors=Patrik Karlstr\u00f6m <[email protected]>
thanksTo=Magnus Myhrberg;Kulturelle Anton Fagerlund;Freddie Juza
libraries=Apache Commons (IO, Lang3, Text);Google Gson;Apache NetBeans Platform;j2html
libraries=Apache Commons (Lang3);Google Gson;Apache NetBeans Platform;j2html
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ max=Max
lim=Lim
colors=F\u00e4rger
scorecard=Protokoll
fullscreen=Helsk\u00e4rm
CTL_FullScreenAction=Helsk\u00e4rm
reverseDiceDirection=Omv\u00e4nd rullningsriktning
dice=T\u00e4rningar
indicator=Indikatorer
removePlayerInfo=V\u00e4lj spelare att ta bort
confirmQuitTitle=Avsluta Yaya?
confirmQuitMessage=Avbryt denna omg\u00e5ng och avsluta Yaya...
CTL_OptionsAction=Alternativ

0 comments on commit 86822b6

Please sign in to comment.