GUI, preferences: reworked size settings:

- added size settings for player's panel size (closes #12455, closes #12451, closes #5605);
- size settings can be edit by slider or by text edit;
- size settings for fonts has preview button with real text sample;
- improved some tabs and hints for better UX;
- improved GUI rendering performance;
This commit is contained in:
Oleg Agafonov 2024-07-21 23:35:44 +04:00
parent 921e656e3c
commit 1f3fad6594
15 changed files with 3224 additions and 5913 deletions

View file

@ -64,35 +64,49 @@ public class PlayerPanelExt extends javax.swing.JPanel {
private static final int PANEL_HEIGHT_SMALL = 218; // small mode (with avatar button) // TODO: no need in small mode after GUI scale added
private static final int PANEL_HEIGHT_EXTRA_FOR_ME = 25; // hints button
private final Border GREEN_BORDER;
private final Border RED_BORDER;
private final Border YELLOW_BORDER;
private final Border EMPTY_BORDER;
private Border GREEN_BORDER;
private Border RED_BORDER;
private Border YELLOW_BORDER;
private Border EMPTY_BORDER;
float guiScaleMod = 1.0f;
private final Color activeValueColor = new Color(244, 9, 47);
private final Font fontValuesZero;
private final Font fontValuesNonZero;
private Color activeValueColor = new Color(244, 9, 47);
private Font fontValuesZero;
private Font fontValuesNonZero;
private int avatarId = -1;
private String flagName;
private String basicTooltipText;
private static final Map<UUID, Integer> playerLives = new HashMap<>();
private Font defaultFont = null;
private PriorityTimer timer;
/**
* Creates new form PlayerPanel
*/
public PlayerPanelExt() {
this(1.0f);
}
public PlayerPanelExt(float guiScaleMod) {
// gui scale
// save default font cause panel can be recreated manually
this.defaultFont = this.getFont();
createAllComponents(guiScaleMod);
}
/**
* Refresh full panel's components due actual GUI settings
*/
public void fullRefresh(float guiScaleMod) {
this.cleanUp();
this.removeAll();
this.createAllComponents(guiScaleMod);
}
public void createAllComponents(float guiScaleMod) {
this.guiScaleMod = guiScaleMod;
this.setFont(this.getFont().deriveFont(sizeMod(this.getFont().getSize2D())));
this.setFont(this.defaultFont.deriveFont(sizeMod(this.defaultFont.getSize2D())));
this.fontValuesZero = this.getFont().deriveFont(Font.PLAIN);
this.fontValuesNonZero = this.getFont().deriveFont(Font.BOLD);
this.GREEN_BORDER = new LineBorder(Color.green, sizeMod(3));
@ -123,7 +137,8 @@ public class PlayerPanelExt extends javax.swing.JPanel {
toolHintsHelper.setVisible(this.isMe);
toolHintsHelper.setFocusable(false);
flagName = null;
if (priorityTime > 0) {
avatarId = -1;
if (priorityTime > 0 && priorityTime != Integer.MAX_VALUE) {
long delay = 1000L;
timer = new PriorityTimer(priorityTime, delay, () -> {
@ -360,9 +375,9 @@ public class PlayerPanelExt extends javax.swing.JPanel {
}
}
if (this.timer != null) {
if (player.getPriorityTimeLeft() != Integer.MAX_VALUE) {
if (player.getPriorityTimeLeftSecs() != Integer.MAX_VALUE) {
String priorityTimeValue = getPriorityTimeLeftString(player);
this.timer.setCount(player.getPriorityTimeLeft());
this.timer.setCount(player.getPriorityTimeLeftSecs());
this.timer.setBufferCount(player.getBufferTimeLeft());
this.avatar.setTopText(priorityTimeValue);
this.timerLabel.setText(priorityTimeValue);
@ -372,7 +387,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
if (player.getBufferTimeLeft() > 0) {
textColor = Color.GREEN;
foregroundColor = Color.GREEN.darker().darker();
} else if (player.getPriorityTimeLeft() < 300) { // visual indication for under 5 minutes
} else if (player.getPriorityTimeLeftSecs() < 300) { // visual indication for under 5 minutes
textColor = Color.RED;
foregroundColor = Color.RED.darker().darker();
} else {
@ -476,7 +491,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
}
private String getPriorityTimeLeftString(PlayerView player) {
int priorityTimeLeft = player.getPriorityTimeLeft() + player.getBufferTimeLeft();
int priorityTimeLeft = player.getPriorityTimeLeftSecs() + player.getBufferTimeLeft();
return getPriorityTimeLeftString(priorityTimeLeft);
}
@ -975,7 +990,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
}// </editor-fold>//GEN-END:initComponents
protected void sizePlayerPanel(boolean smallMode) {
public void sizePlayerPanel(boolean smallMode) {
int extraForMe = this.isMe ? PANEL_HEIGHT_EXTRA_FOR_ME : 0;
if (smallMode) {
avatar.setVisible(false);