Skip to content

Commit a2010f7

Browse files
committed
add fullScreen mode
1 parent d97adf0 commit a2010f7

File tree

4 files changed

+49
-6
lines changed

4 files changed

+49
-6
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,17 @@ name: Changelog
33
index: 4
44
---
55

6-
## 4.8.4
6+
## 4.9.0
7+
8+
- 🚀 Feat: Add fullscreen mode. You can now define in the constructor of your window, if you want to operate in fullscreen mode.
9+
10+
```java
11+
new Window(true); // fullscreen
12+
new Window(true, assets) // fullscreen with assets loading
13+
```
714

815
- 🐛 Fix: keyCodes for some keys were off.
16+
- 🐛 Fix: File extension not working on Windows.
917

1018
## 4.8.3
1119

src/org/openpatch/scratch/Stage.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,19 @@ public Stage(int width, final int height) {
8282
this(width, height, null);
8383
}
8484

85-
public Stage(int width, final int height, String assets) {
85+
public Stage(int width, int height, String assets) {
86+
this(width, height, false, assets);
87+
}
88+
89+
public Stage(boolean fullScreen) {
90+
this(480, 360, fullScreen, null);
91+
}
92+
93+
public Stage(boolean fullScreen, String assets) {
94+
this(480, 360, fullScreen, assets);
95+
}
96+
97+
public Stage(int width, final int height, boolean fullScreen, String assets) {
8698
this.cursor = null;
8799
this.camera = new Camera();
88100
this.texts = new CopyOnWriteArrayList<>();
@@ -93,7 +105,11 @@ public Stage(int width, final int height, String assets) {
93105
this.uiStamps = new ConcurrentLinkedQueue<>();
94106
this.timer = new ConcurrentHashMap<>();
95107
if (Window.getInstance() == null) {
96-
new Window(width, height, assets);
108+
if (fullScreen) {
109+
new Window(fullScreen, assets);
110+
} else {
111+
new Window(width, height, assets);
112+
}
97113
Applet a = Applet.getInstance();
98114
a.setStage(this);
99115
}

src/org/openpatch/scratch/Window.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,20 @@ public Window(int width, int height, String assets) {
2626
}
2727

2828
Window.instance = this;
29-
new Applet(width, height, assets);
29+
new Applet(width, height, false, assets);
30+
}
31+
32+
public Window(boolean fullScreen) {
33+
this(fullScreen, null);
34+
}
35+
36+
public Window(boolean fullScreen, String assets) {
37+
if (Window.instance != null) {
38+
throw new Error("You can only have one Window.");
39+
}
40+
41+
Window.instance = this;
42+
new Applet(480, 360, fullScreen, assets);
3043
}
3144

3245
public static Window getInstance() {

src/org/openpatch/scratch/internal/Applet.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
public class Applet extends PApplet {
2222
private final int INITIAL_HEIGHT;
2323
private final int INITIAL_WIDTH;
24+
private final boolean FULLSCREEN;
2425

2526
private boolean debug;
2627
private static Applet instance;
@@ -36,9 +37,10 @@ public class Applet extends PApplet {
3637
private boolean hasLoaded = false;
3738
private String loadingText = "";
3839

39-
public Applet(int width, final int height, final String assets) {
40+
public Applet(int width, final int height, final boolean fullscreen, final String assets) {
4041
this.INITIAL_HEIGHT = height;
4142
this.INITIAL_WIDTH = width;
43+
this.FULLSCREEN = fullscreen;
4244
this.assets = assets;
4345

4446
this.stages = new ConcurrentHashMap<>();
@@ -124,7 +126,11 @@ public void setStage(Stage stage) {
124126
* @see PApplet#smooth()
125127
*/
126128
public void settings() {
127-
this.size(this.INITIAL_WIDTH, this.INITIAL_HEIGHT, P2D);
129+
if (this.FULLSCREEN) {
130+
this.fullScreen(P2D);
131+
} else {
132+
this.size(this.INITIAL_WIDTH, this.INITIAL_HEIGHT, P2D);
133+
}
128134
}
129135

130136
public double getDeltaTime() {

0 commit comments

Comments
 (0)