Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,9 @@ joysticks-*.txt
/jme3-screenshot-tests/jme3-screenshot-tests-desktop/build/
/jme3-screenshot-tests/jme3-screenshot-tests-android/build/
/jme3-screenshot-tests/jme3-screenshot-tests-shared/build/

/jme3-screenshot-tests/jme3-screenshot-tests-proto-report/build/
/jme3-screenshot-tests/jme3-screenshot-tests-desktop/bin/
/jme3-screenshot-tests/jme3-screenshot-tests-android/bin/
/jme3-screenshot-tests/jme3-screenshot-tests-shared/bin/
/jme3-screenshot-tests/jme3-screenshot-tests-proto-report/bin/
hs_err_pid*.log
110 changes: 106 additions & 4 deletions jme3-awt-dialogs/src/main/java/com/jme3/awt/AWTSettingsDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.jme3.asset.AssetNotFoundException;
import com.jme3.system.AppSettings;
import com.jme3.system.JmeSystem;
import com.jme3.system.Platform;

import java.awt.*;
import java.awt.event.*;
Expand All @@ -42,7 +43,6 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.LinkedHashSet;
Expand Down Expand Up @@ -125,11 +125,13 @@ public interface SelectionListener {
private JCheckBox vsyncBox = null;
private JCheckBox gammaBox = null;
private JCheckBox fullscreenBox = null;
private JCheckBox x11PlatformPreferredBox = null;
private JComboBox<String> displayResCombo = null;
private JComboBox<String> colorDepthCombo = null;
private JComboBox<String> displayFreqCombo = null;
private JComboBox<String> antialiasCombo = null;
private JComboBox<String> rendererCombo = null;
private JComboBox<DisplayScaleModeOption> displayScaleModeCombo = null;
private JLabel icon = null;
private int selection = 0;
private SelectionListener selectionListener = null;
Expand Down Expand Up @@ -466,6 +468,8 @@ public void keyPressed(KeyEvent e) {
antialiasCombo.addKeyListener(aListener);
rendererCombo = setUpRendererChooser();
rendererCombo.addKeyListener(aListener);
displayScaleModeCombo = setUpDisplayScaleModeChooser();
displayScaleModeCombo.addKeyListener(aListener);
fullscreenBox = new JCheckBox(resourceBundle.getString("checkbox.fullscreen"));
fullscreenBox.setSelected(source.isFullscreen());
fullscreenBox.addActionListener(new ActionListener() {
Expand All @@ -481,6 +485,10 @@ public void actionPerformed(ActionEvent e) {
gammaBox = new JCheckBox(resourceBundle.getString("checkbox.gamma"));
gammaBox.setSelected(source.isGammaCorrection());

x11PlatformPreferredBox = new JCheckBox(resourceBundle.getString("checkbox.x11PlatformPreferred"));
x11PlatformPreferredBox.setSelected(source.isX11PlatformPreferred());
boolean linux = JmeSystem.getPlatform().getOs() == Platform.Os.Linux;

GridBagConstraints gbc = new GridBagConstraints();
gbc.weightx = 0.5;
gbc.gridx = 0;
Expand Down Expand Up @@ -562,10 +570,34 @@ public void actionPerformed(ActionEvent e) {
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 4;
gbc.gridwidth = 3;
gbc.gridwidth = linux ? 1 : 3;
gbc.anchor = GridBagConstraints.WEST;
mainPanel.add(rendererCombo, gbc);

if (linux) {
gbc = new GridBagConstraints();
gbc.insets = new Insets(4, 16, 4, 4);
gbc.gridx = 2;
gbc.gridy = 4;
gbc.gridwidth = 2;
gbc.anchor = GridBagConstraints.WEST;
mainPanel.add(x11PlatformPreferredBox, gbc);
}

gbc = new GridBagConstraints();
gbc.insets = new Insets(4, 4, 4, 4);
gbc.gridx = 0;
gbc.gridy = 5;
gbc.anchor = GridBagConstraints.EAST;
gbc.weightx = 0.5;
mainPanel.add(new JLabel(resourceBundle.getString("label.displayScaleMode")), gbc);
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 5;
gbc.gridwidth = 3;
gbc.anchor = GridBagConstraints.WEST;
mainPanel.add(displayScaleModeCombo, gbc);

// Set the button action listeners. Cancel disposes without saving, OK
// saves.
ok.addActionListener(new ActionListener() {
Expand Down Expand Up @@ -600,14 +632,14 @@ public void actionPerformed(ActionEvent e) {
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridwidth = 2;
gbc.gridy = 5;
gbc.gridy = 6;
gbc.anchor = GridBagConstraints.EAST;
mainPanel.add(ok, gbc);
gbc = new GridBagConstraints();
gbc.insets = new Insets(4, 16, 4, 4);
gbc.gridx = 2;
gbc.gridwidth = 2;
gbc.gridy = 5;
gbc.gridy = 6;
gbc.anchor = GridBagConstraints.WEST;
mainPanel.add(cancel, gbc);

Expand Down Expand Up @@ -739,6 +771,12 @@ private boolean verifyAndSaveCurrentSelection() {
source.setFullscreen(fullscreen);
source.setVSync(vsync);
source.setGammaCorrection(gamma);
source.setX11PlatformPreferred(x11PlatformPreferredBox.isSelected());
DisplayScaleModeOption displayScaleMode
= (DisplayScaleModeOption) displayScaleModeCombo.getSelectedItem();
if (displayScaleMode != null) {
source.setDisplayScaleMode(displayScaleMode.value);
}
source.setRenderer(renderer);
source.setSamples(multisample);

Expand Down Expand Up @@ -804,6 +842,55 @@ private JComboBox<String> setUpRendererChooser() {
return rendererBox;
}

private JComboBox<DisplayScaleModeOption> setUpDisplayScaleModeChooser() {
JComboBox<DisplayScaleModeOption> scaleModeBox = new JComboBox<>();
float currentMode = source.getDisplayScaleMode();
float[] standardModes = {
AppSettings.DISPLAY_SCALE_DISABLED,
AppSettings.DISPLAY_SCALE_NATIVE_PIXELS,
AppSettings.DISPLAY_SCALE_DPI_AWARE,
2f,
3f,
4f,
5f,
6f,
7f,
8f
};

boolean currentModeAdded = false;
for (float mode : standardModes) {
DisplayScaleModeOption option = createDisplayScaleModeOption(mode);
scaleModeBox.addItem(option);
if (Float.compare(mode, currentMode) == 0) {
scaleModeBox.setSelectedItem(option);
currentModeAdded = true;
}
}

if (!currentModeAdded) {
DisplayScaleModeOption option = createDisplayScaleModeOption(currentMode);
scaleModeBox.addItem(option);
scaleModeBox.setSelectedItem(option);
}

return scaleModeBox;
}

private DisplayScaleModeOption createDisplayScaleModeOption(float mode) {
String label;
if (mode == AppSettings.DISPLAY_SCALE_DISABLED) {
label = resourceBundle.getString("displayScaleMode.disabled");
} else if (mode == AppSettings.DISPLAY_SCALE_NATIVE_PIXELS) {
label = resourceBundle.getString("displayScaleMode.nativePixels");
} else if (mode == AppSettings.DISPLAY_SCALE_DPI_AWARE) {
label = resourceBundle.getString("displayScaleMode.dpiAware");
} else {
label = MessageFormat.format(resourceBundle.getString("displayScaleMode.supersampling"), mode);
}
return new DisplayScaleModeOption(label, mode);
}

/**
* <code>updateDisplayChoices</code> updates the available color depth and
* display frequency options to match the currently selected resolution.
Expand Down Expand Up @@ -1069,4 +1156,19 @@ public int compare(DisplayMode a, DisplayMode b) {
return 0;
}
}

private static final class DisplayScaleModeOption {
private final String label;
private final float value;

private DisplayScaleModeOption(String label, float value) {
this.label = label;
this.value = value;
}

@Override
public String toString() {
return label;
}
}
}
Loading
Loading