summaryrefslogtreecommitdiff
path: root/NET/worlds/console/RenderCanvasOverlay.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 22:33:32 -0800
committerFuwn <[email protected]>2026-02-12 22:33:32 -0800
commitc7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch)
treedf9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/console/RenderCanvasOverlay.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/console/RenderCanvasOverlay.java')
-rw-r--r--NET/worlds/console/RenderCanvasOverlay.java129
1 files changed, 129 insertions, 0 deletions
diff --git a/NET/worlds/console/RenderCanvasOverlay.java b/NET/worlds/console/RenderCanvasOverlay.java
new file mode 100644
index 0000000..dfc33e7
--- /dev/null
+++ b/NET/worlds/console/RenderCanvasOverlay.java
@@ -0,0 +1,129 @@
+package NET.worlds.console;
+
+public abstract class RenderCanvasOverlay {
+ private RenderCanvas canvas;
+ private int xPercent;
+ private int yPercent;
+ private int xFixed;
+ private int yFixed;
+ private boolean isFixed;
+ private boolean fullscreen;
+ private int hwnd;
+ private boolean allowFocus;
+
+ public RenderCanvasOverlay(RenderCanvas pCanvas, int pX, int pY, boolean pIsFixed, boolean pAllowFocus) throws NoWebControlException {
+ assert pX > 0 || pY > 0;
+
+ if (pCanvas != null && pCanvas.getWindow() != null) {
+ this.canvas = pCanvas;
+ this.isFixed = pIsFixed;
+ this.allowFocus = pAllowFocus;
+ if (this.isFixed) {
+ this.xFixed = pX;
+ this.yFixed = pY;
+ this.xPercent = this.yPercent = 1;
+ } else {
+ this.xPercent = pX;
+ this.yPercent = pY;
+ }
+
+ this.fullscreen = false;
+ } else {
+ throw new NoWebControlException("RenderCanvas does not exist");
+ }
+ }
+
+ public RenderCanvasOverlay(RenderCanvas pCanvas) {
+ assert pCanvas != null;
+
+ this.canvas = pCanvas;
+ this.xPercent = this.yPercent = 100;
+ this.isFixed = false;
+ this.allowFocus = true;
+ this.fullscreen = true;
+ this.hwnd = this.canvas.getWindow().getHwnd();
+ }
+
+ public void activate() {
+ this.canvas.addOverlay(this);
+ }
+
+ int getNativeWindowHandle() {
+ assert this.canvas.getWindow() != null;
+
+ if (this.hwnd == 0) {
+ if (this.fullscreen) {
+ this.hwnd = this.canvas.getWindow().getHwnd();
+ } else {
+ this.hwnd = this.nativeMakeChild(this.canvas.getWindow().getHwnd(), this.xPercent, this.yPercent, this.allowFocus);
+ }
+ }
+
+ return this.hwnd;
+ }
+
+ int getXPercent() {
+ return this.xPercent;
+ }
+
+ int getYPercent() {
+ return this.yPercent;
+ }
+
+ int getFixedWidth() {
+ return this.xFixed;
+ }
+
+ int getFixedHeight() {
+ return this.yFixed;
+ }
+
+ boolean getIsFixedSize() {
+ return this.isFixed;
+ }
+
+ void canvasResized(int parentX, int parentY) {
+ int w;
+ int h;
+ if (this.isFixed) {
+ w = this.xFixed;
+ h = this.yFixed;
+ if (w > parentX) {
+ w = parentX;
+ }
+
+ if (h > parentY) {
+ h = parentY;
+ }
+
+ this.xPercent = (int)Math.ceil((double)w / parentX * 100.0);
+ this.yPercent = (int)Math.ceil((double)h / parentY * 100.0);
+ } else {
+ w = (int)(parentX * this.xPercent * 0.01);
+ h = (int)(parentY * this.yPercent * 0.01);
+ }
+
+ if (this.hwnd != 0) {
+ this.nativeResizeChild(this.hwnd, w, h);
+ }
+ }
+
+ boolean isFullscreen() {
+ return this.fullscreen || !this.isFixed && this.xPercent == 100 && this.yPercent == 100;
+ }
+
+ protected abstract void handleCommand(int var1);
+
+ void detach() {
+ this.canvas.removeOverlay(this);
+ if (!this.fullscreen && this.hwnd != 0) {
+ this.nativeKillChild(this.hwnd);
+ }
+ }
+
+ private native int nativeMakeChild(long var1, int var3, int var4, boolean var5);
+
+ private native void nativeKillChild(long var1);
+
+ private native void nativeResizeChild(int var1, int var2, int var3);
+}