add attempt counter display and a setting to turn it on/off
This commit is contained in:
parent
d5d82a9a5e
commit
6db7171704
|
@ -57,6 +57,7 @@ public enum Language {
|
||||||
// Settings > Header
|
// Settings > Header
|
||||||
setting_header_goal,
|
setting_header_goal,
|
||||||
setting_header_title,
|
setting_header_title,
|
||||||
|
setting_header_showAttempts,
|
||||||
|
|
||||||
// Settings > History
|
// Settings > History
|
||||||
setting_history_rowCount,
|
setting_history_rowCount,
|
||||||
|
|
|
@ -99,6 +99,10 @@ public class Run implements TableModel, Serializable {
|
||||||
|
|
||||||
public static final String COUNTER_EDIT_PROPERTY = "run.counters.edit";
|
public static final String COUNTER_EDIT_PROPERTY = "run.counters.edit";
|
||||||
|
|
||||||
|
public static final String ATTEMPT_COUNTER_PROPERTY = "run.attemptCounter";
|
||||||
|
|
||||||
|
public static final String COMPLETED_ATTEMPT_COUNTER_PROPERTY = "run.completedAttemptCounter";
|
||||||
|
|
||||||
// ------------------------------------------------------------- ATTRIBUTES
|
// ------------------------------------------------------------- ATTRIBUTES
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -700,6 +704,7 @@ public class Run implements TableModel, Serializable {
|
||||||
|
|
||||||
numberOfAttempts += 1;
|
numberOfAttempts += 1;
|
||||||
|
|
||||||
|
pcSupport.firePropertyChange(ATTEMPT_COUNTER_PROPERTY, numberOfAttempts - 1, numberOfAttempts);
|
||||||
pcSupport.firePropertyChange(STATE_PROPERTY, State.READY, state);
|
pcSupport.firePropertyChange(STATE_PROPERTY, State.READY, state);
|
||||||
pcSupport.firePropertyChange(CURRENT_SEGMENT_PROPERTY, -1, 0);
|
pcSupport.firePropertyChange(CURRENT_SEGMENT_PROPERTY, -1, 0);
|
||||||
}
|
}
|
||||||
|
@ -725,6 +730,7 @@ public class Run implements TableModel, Serializable {
|
||||||
if (current == getRowCount()) {
|
if (current == getRowCount()) {
|
||||||
// run is finished
|
// run is finished
|
||||||
numberOfCompletedAttempts += 1;
|
numberOfCompletedAttempts += 1;
|
||||||
|
pcSupport.firePropertyChange(COMPLETED_ATTEMPT_COUNTER_PROPERTY, numberOfCompletedAttempts - 1, numberOfCompletedAttempts);
|
||||||
stop();
|
stop();
|
||||||
} else {
|
} else {
|
||||||
segments.get(current).setStartTime(stopTime);
|
segments.get(current).setStartTime(stopTime);
|
||||||
|
|
|
@ -66,6 +66,7 @@ public class Settings {
|
||||||
|
|
||||||
public static final Property<Boolean> headerShowGoal = new Property<>( "header.goal" );
|
public static final Property<Boolean> headerShowGoal = new Property<>( "header.goal" );
|
||||||
public static final Property<Boolean> headerShowTitle = new Property<>( "header.title" );
|
public static final Property<Boolean> headerShowTitle = new Property<>( "header.title" );
|
||||||
|
public static final Property<Boolean> headerShowAttempts = new Property<>( "header.showAttempts" );
|
||||||
|
|
||||||
/* HISTORY properties */
|
/* HISTORY properties */
|
||||||
|
|
||||||
|
@ -225,6 +226,7 @@ public class Settings {
|
||||||
|
|
||||||
global.put( headerShowGoal.key, true );
|
global.put( headerShowGoal.key, true );
|
||||||
global.put( headerShowTitle.key, true );
|
global.put( headerShowTitle.key, true );
|
||||||
|
global.put( headerShowAttempts.key, true );
|
||||||
|
|
||||||
global.put( historyRowCount.key, 8 );
|
global.put( historyRowCount.key, 8 );
|
||||||
global.put( historyTabular.key, true );
|
global.put( historyTabular.key, true );
|
||||||
|
|
|
@ -39,6 +39,7 @@ public class TabComponents extends SettingsTab
|
||||||
SCB_SETTINGS.add(Settings.coreShowSegmentTimer);
|
SCB_SETTINGS.add(Settings.coreShowSegmentTimer);
|
||||||
SCB_SETTINGS.add(Settings.coreShowIcons);
|
SCB_SETTINGS.add(Settings.coreShowIcons);
|
||||||
SCB_SETTINGS.add(Settings.headerShowGoal);
|
SCB_SETTINGS.add(Settings.headerShowGoal);
|
||||||
|
SCB_SETTINGS.add(Settings.headerShowAttempts);
|
||||||
}
|
}
|
||||||
|
|
||||||
private JComboBox iconSizes;
|
private JComboBox iconSizes;
|
||||||
|
@ -219,6 +220,7 @@ public class TabComponents extends SettingsTab
|
||||||
miscPanel.add(checkBoxes.get(Settings.headerShowGoal.getKey()), GBC.grid(0, 0).anchor(GBC.LS));
|
miscPanel.add(checkBoxes.get(Settings.headerShowGoal.getKey()), GBC.grid(0, 0).anchor(GBC.LS));
|
||||||
miscPanel.add(checkBoxes.get(Settings.headerShowTitle.getKey()), GBC.grid(0, 1).anchor(GBC.LS));
|
miscPanel.add(checkBoxes.get(Settings.headerShowTitle.getKey()), GBC.grid(0, 1).anchor(GBC.LS));
|
||||||
miscPanel.add(checkBoxes.get(Settings.graphDisplay.getKey()), GBC.grid(0, 2).anchor(GBC.LS));
|
miscPanel.add(checkBoxes.get(Settings.graphDisplay.getKey()), GBC.grid(0, 2).anchor(GBC.LS));
|
||||||
|
miscPanel.add(checkBoxes.get(Settings.headerShowAttempts.getKey()), GBC.grid(0, 3).anchor(GBC.LS));
|
||||||
miscPanel.setBorder(
|
miscPanel.setBorder(
|
||||||
BorderFactory.createTitledBorder("" + Language.MISC)
|
BorderFactory.createTitledBorder("" + Language.MISC)
|
||||||
);
|
);
|
||||||
|
|
|
@ -77,6 +77,11 @@ public class RunPane extends JPanel {
|
||||||
*/
|
*/
|
||||||
private static final int FOOTER = 0x40;
|
private static final int FOOTER = 0x40;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update identifier for the attempt counter component.
|
||||||
|
*/
|
||||||
|
private static final int ATTEMPTS = 0x80;
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------- ATTRIBUTES
|
// ------------------------------------------------------------- ATTRIBUTES
|
||||||
|
|
||||||
|
@ -106,6 +111,11 @@ public class RunPane extends JPanel {
|
||||||
*/
|
*/
|
||||||
private JPanel goalPane;
|
private JPanel goalPane;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Label displaying the number of attempts the user has made of this run.
|
||||||
|
*/
|
||||||
|
private JLabel attemptCounter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list containing empty labels serving as separators.
|
* A list containing empty labels serving as separators.
|
||||||
*/
|
*/
|
||||||
|
@ -149,6 +159,7 @@ public class RunPane extends JPanel {
|
||||||
title = new JLabel();
|
title = new JLabel();
|
||||||
goal = new JLabel();
|
goal = new JLabel();
|
||||||
goalText = new JLabel();
|
goalText = new JLabel();
|
||||||
|
attemptCounter = new JLabel();
|
||||||
core = new Core(run);
|
core = new Core(run);
|
||||||
graph = new Graph(run);
|
graph = new Graph(run);
|
||||||
history = new History(run);
|
history = new History(run);
|
||||||
|
@ -245,9 +256,15 @@ public class RunPane extends JPanel {
|
||||||
} else if (Settings.headerShowGoal.equals(property)) {
|
} else if (Settings.headerShowGoal.equals(property)) {
|
||||||
updateVisibility(TITLE | GOAL);
|
updateVisibility(TITLE | GOAL);
|
||||||
updateValues(SEPARATOR);
|
updateValues(SEPARATOR);
|
||||||
|
} else if (Settings.headerShowAttempts.equals(property)) {
|
||||||
|
updateVisibility(ATTEMPTS);
|
||||||
|
updateValues(SEPARATOR);
|
||||||
} else if (Settings.accuracy.equals(property)
|
} else if (Settings.accuracy.equals(property)
|
||||||
|| Run.GOAL_PROPERTY.equals(property)) {
|
|| Run.GOAL_PROPERTY.equals(property)) {
|
||||||
updateValues(GOAL);
|
updateValues(GOAL);
|
||||||
|
} else if (Run.ATTEMPT_COUNTER_PROPERTY.equals(property) ||
|
||||||
|
Run.COMPLETED_ATTEMPT_COUNTER_PROPERTY.equals(property)) {
|
||||||
|
updateValues(ATTEMPTS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,10 +309,11 @@ public class RunPane extends JPanel {
|
||||||
goalPane.add(goal, GBC.grid(1, 1).insets(0, 3, 0, 0));
|
goalPane.add(goal, GBC.grid(1, 1).insets(0, 3, 0, 0));
|
||||||
goalPane.setOpaque(false);
|
goalPane.setOpaque(false);
|
||||||
}
|
}
|
||||||
add(createSeparator(), GBC.grid(0, 2).insets(3, 0).fill(GBC.H));
|
add(attemptCounter, GBC.grid(0, 2).insets(1, 0, 1, 3).anchor(GBC.LE));
|
||||||
add(history, GBC.grid(0, 3).fill(GBC.H).insets(0, 5));
|
add(createSeparator(), GBC.grid(0, 3).insets(3, 0).fill(GBC.H));
|
||||||
add(createSeparator(), GBC.grid(0, 4).insets(3, 0).fill(GBC.H));
|
add(history, GBC.grid(0, 4).fill(GBC.H).insets(0, 5));
|
||||||
add(createSeparator(), GBC.grid(0, 6).insets(3, 0, 0, 0).fill(GBC.H));
|
add(createSeparator(), GBC.grid(0, 5).insets(3, 0).fill(GBC.H));
|
||||||
|
add(createSeparator(), GBC.grid(0, 7).insets(3, 0, 0, 0).fill(GBC.H));
|
||||||
|
|
||||||
updateVisibility(ALL);
|
updateVisibility(ALL);
|
||||||
}
|
}
|
||||||
|
@ -321,12 +339,23 @@ public class RunPane extends JPanel {
|
||||||
if ((identifier & TITLE) == TITLE) {
|
if ((identifier & TITLE) == TITLE) {
|
||||||
title.setText("" + run.getName());
|
title.setText("" + run.getName());
|
||||||
}
|
}
|
||||||
|
if ((identifier & ATTEMPTS) == ATTEMPTS) {
|
||||||
|
int attempts = run.getNumberOfAttempts();
|
||||||
|
int completedAttempts = run.getNumberOfCompletedAttempts();
|
||||||
|
if (attempts == 0)
|
||||||
|
attemptCounter.setText("0");
|
||||||
|
else if (completedAttempts == 0)
|
||||||
|
attemptCounter.setText(String.format("%d", attempts));
|
||||||
|
else
|
||||||
|
attemptCounter.setText(String.format("%d / %d", completedAttempts, attempts));
|
||||||
|
}
|
||||||
if ((identifier & SEPARATOR) == SEPARATOR) {
|
if ((identifier & SEPARATOR) == SEPARATOR) {
|
||||||
boolean hdTitle = Settings.headerShowGoal.get();
|
boolean hdTitle = Settings.headerShowGoal.get();
|
||||||
boolean hdGoal = Settings.headerShowTitle.get();
|
boolean hdGoal = Settings.headerShowTitle.get();
|
||||||
|
boolean hdAttempts = Settings.headerShowAttempts.get();
|
||||||
boolean hsRows = history.getRowCount() > 0;
|
boolean hsRows = history.getRowCount() > 0;
|
||||||
|
|
||||||
separators.get(0).setVisible(hdTitle || hdGoal);
|
separators.get(0).setVisible(hdTitle || hdGoal || hdAttempts);
|
||||||
separators.get(1).setVisible(hsRows);
|
separators.get(1).setVisible(hsRows);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -357,6 +386,8 @@ public class RunPane extends JPanel {
|
||||||
BorderFactory.createMatteBorder(1, 0, 0, 0, color));
|
BorderFactory.createMatteBorder(1, 0, 0, 0, color));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
attemptCounter.setForeground(Color.WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -369,19 +400,19 @@ public class RunPane extends JPanel {
|
||||||
if ((identifier & GRAPH) == GRAPH) {
|
if ((identifier & GRAPH) == GRAPH) {
|
||||||
if (Settings.graphDisplay.get()) {
|
if (Settings.graphDisplay.get()) {
|
||||||
remove(core);
|
remove(core);
|
||||||
add(core, GBC.grid(0, 5).insets(0, 5).fill(GBC.H));
|
add(core, GBC.grid(0, 6).insets(0, 5).fill(GBC.H));
|
||||||
add(graph, GBC.grid(0, 7).fill(GBC.B).insets(0, 0, 3, 0)
|
add(graph, GBC.grid(0, 8).fill(GBC.B).insets(0, 0, 3, 0)
|
||||||
.weight(1.0, 1.0));
|
.weight(1.0, 1.0));
|
||||||
} else {
|
} else {
|
||||||
remove(graph);
|
remove(graph);
|
||||||
remove(core);
|
remove(core);
|
||||||
add(core, GBC.grid(0, 5).insets(0, 5).fill(GBC.H)
|
add(core, GBC.grid(0, 6).insets(0, 5).fill(GBC.H)
|
||||||
.weight(1.0, 1.0));
|
.weight(1.0, 1.0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((identifier & FOOTER) == FOOTER) {
|
if ((identifier & FOOTER) == FOOTER) {
|
||||||
if (Settings.footerDisplay.get()) {
|
if (Settings.footerDisplay.get()) {
|
||||||
add(footer, GBC.grid(0, 8).insets(0, 3).fill(GBC.H));
|
add(footer, GBC.grid(0, 9).insets(0, 3).fill(GBC.H));
|
||||||
} else {
|
} else {
|
||||||
remove(footer);
|
remove(footer);
|
||||||
}
|
}
|
||||||
|
@ -400,6 +431,9 @@ public class RunPane extends JPanel {
|
||||||
if ((identifier & TITLE) == TITLE) {
|
if ((identifier & TITLE) == TITLE) {
|
||||||
title.setVisible(Settings.headerShowTitle.get());
|
title.setVisible(Settings.headerShowTitle.get());
|
||||||
}
|
}
|
||||||
|
if ((identifier & ATTEMPTS) == ATTEMPTS) {
|
||||||
|
attemptCounter.setVisible(Settings.headerShowAttempts.get());
|
||||||
|
}
|
||||||
revalidate();
|
revalidate();
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ GLOBAL_HOTKEYS_HOOK_ERROR = Key event hook registration failed. You will need to
|
||||||
# Settings > Header
|
# Settings > Header
|
||||||
setting_header_goal = Display Goal
|
setting_header_goal = Display Goal
|
||||||
setting_header_title = Display Run Title
|
setting_header_title = Display Run Title
|
||||||
|
setting_header_showAttempts = Display Attempt Counter
|
||||||
|
|
||||||
# Settings > History
|
# Settings > History
|
||||||
setting_history_rowCount = Number of Rows
|
setting_history_rowCount = Number of Rows
|
||||||
|
|
Reference in a new issue