Skip to content

Commit a91f848

Browse files
committed
Add OS based resolution scaling support
1 parent 020258c commit a91f848

2 files changed

Lines changed: 16 additions & 8 deletions

File tree

editor/src/main/java/com/jvn/editor/ui/NewProjectWizard.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@
4040
import javafx.scene.layout.Priority;
4141
import javafx.scene.layout.Region;
4242
import javafx.scene.layout.VBox;
43-
import javafx.stage.DirectoryChooser;
44-
import javafx.stage.Modality;
45-
import javafx.stage.Stage;
46-
import javafx.stage.StageStyle;
43+
import javafx.stage.*;
4744

4845
/**
4946
* Project creation wizard for VN projects.
@@ -1089,7 +1086,7 @@ private void updatePresetPreview() {
10891086
if (lblPreview == null || cmbTheme == null || cmbResolution == null) return;
10901087
String name = txtProjectName == null ? "" : txtProjectName.getText().trim();
10911088
if (name.isBlank()) name = "Untitled";
1092-
int[] resolution = parseResolution();
1089+
int[] resolution = getScaledResolution();
10931090
String res = resolution[0] + "x" + resolution[1];
10941091
String ratio = formatAspectRatio(resolution[0], resolution[1]);
10951092
String theme = cmbTheme.getValue() == null ? "Dark Elegant" : cmbTheme.getValue();
@@ -1544,7 +1541,7 @@ private void createProjectStructure(File dir, String displayName) throws Excepti
15441541
}
15451542
}
15461543

1547-
int[] resolution = parseResolution();
1544+
int[] resolution = getScaledResolution();
15481545
createManifest(
15491546
dir,
15501547
displayName,
@@ -1768,6 +1765,16 @@ private int[] parseResolution() {
17681765
return new int[] {width, height};
17691766
}
17701767

1768+
private int[] getScaledResolution() {
1769+
int[] resolution = parseResolution();
1770+
double scaling = Screen.getPrimary().getOutputScaleX();
1771+
1772+
int width = (int) (resolution[0] / scaling);
1773+
int height = (int) (resolution[1] / scaling);
1774+
1775+
return new int[] {width, height};
1776+
}
1777+
17711778
private int parseDimension(String raw, int fallback, String axis) {
17721779
if (raw == null || raw.isBlank()) return fallback;
17731780
try {
@@ -2229,7 +2236,7 @@ private void createSettings(File dir) throws Exception {
22292236
}
22302237

22312238
private void createDialogueLayout(File dir) throws Exception {
2232-
int[] res = parseResolution();
2239+
int[] res = getScaledResolution();
22332240
double scale = res[1] / 1080.0;
22342241
String template = LayoutDslTemplates.defaultDialogueLayoutTemplate();
22352242
if (Math.abs(scale - 1.0) > 0.01) {
@@ -2664,7 +2671,7 @@ private void createReadme(File dir,
26642671
fw.write("- Initial commit: " + (gitInitialCommit ? "yes" : "no") + "\n\n");
26652672

26662673
fw.write("## Runtime Profile\n\n");
2667-
int[] resolution = parseResolution();
2674+
int[] resolution = getScaledResolution();
26682675
fw.write("- Resolution: " + resolution[0] + "x" + resolution[1] + " (" + formatAspectRatio(resolution[0], resolution[1]) + ")\n");
26692676
fw.write("- Theme preset: " + (cmbTheme.getValue() == null ? "Dark Elegant" : cmbTheme.getValue()) + "\n");
26702677
fw.write("- UI backend: " + (cmbRuntimeUi.getValue() == null ? "fx" : cmbRuntimeUi.getValue()) + "\n");

runtime/src/main/java/com/jvn/runtime/RuntimeVnInterop.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ public VnInteropResult handle(VnExternalCommand command, VnScene scene) {
367367
}
368368

369369
private VnInteropResult handleJes(String payload, VnScene scene) {
370+
370371
String[] toks = split(payload);
371372
if (toks.length == 0) return VnInteropResult.advance();
372373
String cmd = toks[0].toLowerCase();

0 commit comments

Comments
 (0)