mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-14 22:37:06 -04:00
基于实际屏幕分辨率添加游戏窗口分辨率选项 (#4275)
This commit is contained in:
parent
9d17834227
commit
6cf933741f
@ -26,12 +26,14 @@ import javafx.beans.value.ChangeListener;
|
||||
import javafx.geometry.HPos;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.geometry.Rectangle2D;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.control.Toggle;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.stage.FileChooser;
|
||||
import javafx.stage.Screen;
|
||||
import org.jackhuang.hmcl.game.*;
|
||||
import org.jackhuang.hmcl.java.JavaManager;
|
||||
import org.jackhuang.hmcl.setting.*;
|
||||
@ -394,14 +396,7 @@ public final class VersionSettingsPage extends StackPane implements DecoratorPag
|
||||
cboWindowsSize.setEditable(true);
|
||||
cboWindowsSize.setStyle("-fx-padding: 4 4 4 16");
|
||||
cboWindowsSize.setPromptText("854x480");
|
||||
cboWindowsSize.getItems().addAll(
|
||||
"854x480",
|
||||
"1280x720",
|
||||
"1600x900",
|
||||
"1920x1080",
|
||||
"2560x1440",
|
||||
"3840x2160"
|
||||
);
|
||||
cboWindowsSize.getItems().setAll(getSupportedResolutions());
|
||||
|
||||
chkFullscreen = new JFXCheckBox();
|
||||
right.setRight(chkFullscreen);
|
||||
@ -784,6 +779,28 @@ public final class VersionSettingsPage extends StackPane implements DecoratorPag
|
||||
FXUtils.limitSize(iconPickerItem.getImageView(), 32, 32);
|
||||
}
|
||||
|
||||
private static List<String> getSupportedResolutions() {
|
||||
int maxScreenWidth = 0;
|
||||
int maxScreenHeight = 0;
|
||||
|
||||
for (Screen screen : Screen.getScreens()) {
|
||||
Rectangle2D bounds = screen.getBounds();
|
||||
int screenWidth = (int) (bounds.getWidth() * screen.getOutputScaleX());
|
||||
int screenHeight = (int) (bounds.getHeight() * screen.getOutputScaleY());
|
||||
|
||||
maxScreenWidth = Math.max(maxScreenWidth, screenWidth);
|
||||
maxScreenHeight = Math.max(maxScreenHeight, screenHeight);
|
||||
}
|
||||
|
||||
List<String> resolutions = new ArrayList<>(List.of("854x480", "1280x720", "1600x900"));
|
||||
|
||||
if (maxScreenWidth >= 1920 && maxScreenHeight >= 1080) resolutions.add("1920x1080");
|
||||
if (maxScreenWidth >= 2560 && maxScreenHeight >= 1440) resolutions.add("2560x1440");
|
||||
if (maxScreenWidth >= 3840 && maxScreenHeight >= 2160) resolutions.add("3840x2160");
|
||||
|
||||
return resolutions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReadOnlyObjectProperty<State> stateProperty() {
|
||||
return state.getReadOnlyProperty();
|
||||
|
Loading…
x
Reference in New Issue
Block a user