this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

make editors HiDPI-aware

+71 -35
-10
src/main/java/common/BaseEditor.java
··· 636 636 return deltaTime; 637 637 } 638 638 639 - public final int glCanvasWidth() 640 - { 641 - return glCanvas.getWidth(); 642 - } 643 - 644 - public final int glCanvasHeight() 645 - { 646 - return glCanvas.getHeight(); 647 - } 648 - 649 639 protected final void revalidateFrame() 650 640 { 651 641 frame.revalidate();
+45
src/main/java/common/GLEditor.java
··· 1 1 package common; 2 2 3 + import java.awt.GraphicsConfiguration; 3 4 import java.awt.Window; 4 5 5 6 import util.Logger; ··· 22 23 protected void runInContext(Runnable runnable) 23 24 { 24 25 glCanvas.runInContext(runnable); 26 + } 27 + 28 + /** 29 + * Returns the logical width of the canvas. 30 + */ 31 + public final int glCanvasWidth() 32 + { 33 + return glCanvas.getWidth(); 34 + } 35 + 36 + /** 37 + * Returns the logical height of the canvas. 38 + */ 39 + public final int glCanvasHeight() 40 + { 41 + return glCanvas.getHeight(); 42 + } 43 + 44 + /** 45 + * Returns the physical pixel width of the canvas (for glViewport). 46 + */ 47 + public final int glCanvasPixelWidth() 48 + { 49 + return (int) (glCanvas.getWidth() * getCanvasScaleFactor()); 50 + } 51 + 52 + /** 53 + * Returns the physical pixel height of the canvas (for glViewport). 54 + */ 55 + public final int glCanvasPixelHeight() 56 + { 57 + return (int) (glCanvas.getHeight() * getCanvasScaleFactor()); 58 + } 59 + 60 + /** 61 + * Returns the HiDPI scale factor for the canvas. 62 + */ 63 + public double getCanvasScaleFactor() 64 + { 65 + GraphicsConfiguration gc = glCanvas.getGraphicsConfiguration(); 66 + if (gc != null) { 67 + return gc.getDefaultTransform().getScaleX(); 68 + } 69 + return 1.0; 25 70 } 26 71 27 72 public static void setFullScreenEnabled(Window frame, boolean b)
+14 -14
src/main/java/game/map/editor/MapEditor.java
··· 1300 1300 } 1301 1301 1302 1302 // compute the current pick ray 1303 - currentRay = activeView.camera.getPickRay(mouse.getPosX(), mouse.getPosY()); 1303 + currentRay = activeView.camera.getPickRay((int)(mouse.getPosX() * getCanvasScaleFactor()), (int)(mouse.getPosY() * getCanvasScaleFactor())); 1304 1304 1305 1305 if (editorMode == EditorMode.VertexPaint) { 1306 1306 PaintManager.update(this, deltaTime); ··· 1779 1779 { 1780 1780 // switch active viewport 1781 1781 boolean holding = mouse.isHoldingLMB() || mouse.isHoldingRMB() || mouse.isHoldingMMB(); 1782 - int mouseX = mouse.getPosX(); 1783 - int mouseY = mouse.getPosY(); 1782 + int mouseX = (int)(mouse.getPosX() * getCanvasScaleFactor()); 1783 + int mouseY = (int)(mouse.getPosY() * getCanvasScaleFactor()); 1784 1784 1785 1785 if (!holding) { 1786 1786 switch (viewMode) { ··· 1816 1816 // resize the viewports 1817 1817 if (viewMode != ViewMode.ONE && resizingViews) { 1818 1818 if (enableXDivider) { 1819 - int width = glCanvas.getWidth(); 1819 + int width = glCanvasPixelWidth(); 1820 1820 int hDiv = (int) (hDivRatio * width); 1821 1821 hDiv += mouse.getFrameDX(); 1822 1822 hDivRatio = (float) hDiv / width; ··· 1828 1828 } 1829 1829 1830 1830 if (enableYDivider) { 1831 - int height = glCanvas.getHeight(); 1831 + int height = glCanvasPixelHeight(); 1832 1832 int vDiv = (int) (vDivRatio * height); 1833 1833 vDiv += mouse.getFrameDY(); 1834 1834 vDivRatio = (float) vDiv / height; ··· 1942 1942 // allow viewport resizing 1943 1943 resizingViews = false; 1944 1944 if (enableXDivider) { 1945 - int xDiv = (int) (hDivRatio * glCanvas.getWidth()); 1945 + int xDiv = (int) (hDivRatio * glCanvasPixelWidth()); 1946 1946 int mouseX = mouse.getPosX(); 1947 1947 if (mouseX > xDiv - BORDER_HALF_SIZE && mouseX < xDiv + BORDER_HALF_SIZE) 1948 1948 resizingViews = true; 1949 1949 } 1950 1950 if (enableYDivider) { 1951 - int yDiv = (int) (vDivRatio * glCanvas.getHeight()); 1951 + int yDiv = (int) (vDivRatio * glCanvasPixelHeight()); 1952 1952 int mouseY = mouse.getPosY(); 1953 1953 if (mouseY > yDiv - BORDER_HALF_SIZE && mouseY < yDiv + BORDER_HALF_SIZE) 1954 1954 resizingViews = true; ··· 3427 3427 public RenderingOptions getRenderingOptions() 3428 3428 { 3429 3429 RenderingOptions opts = new RenderingOptions(); 3430 - opts.canvasSizeX = prevCanvasSize.width; 3431 - opts.canvasSizeY = prevCanvasSize.height; 3430 + opts.canvasSizeX = glCanvasPixelWidth(); 3431 + opts.canvasSizeY = glCanvasPixelHeight(); 3432 3432 opts.editorMode = getEditorMode(); 3433 3433 opts.selectionMode = selectionManager.getSelectionMode(); 3434 3434 opts.worldFogEnabled = map.scripts.worldFogSettings.enabled.get(); ··· 3514 3514 3515 3515 // render UI 3516 3516 if (viewMode != ViewMode.ONE) { 3517 - int sizeX = glCanvas.getWidth(); 3518 - int sizeY = glCanvas.getHeight(); 3519 - RenderState.setViewport(0, 0, sizeX, sizeY); 3517 + int sizeX = glCanvasWidth(); 3518 + int sizeY = glCanvasHeight(); 3519 + RenderState.setViewport(0, 0, glCanvasPixelWidth(), glCanvasPixelHeight()); 3520 3520 3521 3521 TransformMatrix projMtx = TransformMatrix.identity(); 3522 3522 projMtx.ortho(0, sizeX, 0, sizeY, -1, 1); ··· 3656 3656 3657 3657 private void resizeViews() 3658 3658 { 3659 - int width = glCanvas.getWidth(); 3660 - int height = glCanvas.getHeight(); 3659 + int width = glCanvasPixelWidth(); 3660 + int height = glCanvasPixelHeight(); 3661 3661 int hDiv = (int) (hDivRatio * width); 3662 3662 int vDiv = (int) (vDivRatio * height); 3663 3663
+1 -1
src/main/java/game/message/editor/MessageEditor.java
··· 282 282 public void glDraw() 283 283 { 284 284 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 285 - RenderState.setViewport(0, 0, glCanvasWidth(), glCanvasHeight()); 285 + RenderState.setViewport(0, 0, glCanvasPixelWidth(), glCanvasPixelHeight()); 286 286 287 287 renderer.render(mouse, printer, cameraX, cameraY, cameraZoom, cameraYaw); 288 288 }
+4 -3
src/main/java/game/message/editor/MessageRenderer.java
··· 214 214 215 215 float hfov = 105; 216 216 float right = (hfov + 360) / 360; 217 - float scaleX = RenderState.getViewportSizeX() / 600.0f; 217 + float scaleX = editor.glCanvasWidth() / 600.0f; 218 218 219 219 BasicTexturedShader shader = ShaderManager.use(BasicTexturedShader.class); 220 220 shader.texture.bind(glTexID); ··· 340 340 341 341 public Vector3f getMousePosition(MouseInput mouse, boolean useDepth) 342 342 { 343 - int mouseX = mouse.getPosX(); 344 - int mouseY = mouse.getPosY(); 343 + double scale = editor.getCanvasScaleFactor(); 344 + int mouseX = (int) (mouse.getPosX() * scale); 345 + int mouseY = (int) (mouse.getPosY() * scale); 345 346 346 347 int width = editor.glCanvasWidth(); 347 348 int height = editor.glCanvasHeight();
+5 -5
src/main/java/game/sprite/editor/SpriteEditor.java
··· 733 733 { 734 734 assert (sprite != null); 735 735 //TODO separate these? 736 - sprite.centerImgAtlas(rasterCamera, glCanvasWidth(), glCanvasHeight()); 737 - sprite.centerRasterAtlas(paletteCamera, glCanvasWidth(), glCanvasHeight()); 736 + sprite.centerImgAtlas(rasterCamera, glCanvasPixelWidth(), glCanvasPixelHeight()); 737 + sprite.centerRasterAtlas(paletteCamera, glCanvasPixelWidth(), glCanvasPixelHeight()); 738 738 } 739 739 740 740 public void setSprite(SpriteMetadata newMetadata, boolean forceReload) ··· 1039 1039 1040 1040 private void renderImgAtlas() 1041 1041 { 1042 - rasterCamera.glSetViewport(0, 0, glCanvasWidth(), glCanvasHeight()); 1042 + rasterCamera.glSetViewport(0, 0, glCanvasPixelWidth(), glCanvasPixelHeight()); 1043 1043 1044 1044 if (showBackground) 1045 1045 rasterCamera.drawBackground(); ··· 1059 1059 1060 1060 private void renderRasterAtlas() 1061 1061 { 1062 - paletteCamera.glSetViewport(0, 0, glCanvasWidth(), glCanvasHeight()); 1062 + paletteCamera.glSetViewport(0, 0, glCanvasPixelWidth(), glCanvasPixelHeight()); 1063 1063 1064 1064 if (showBackground) 1065 1065 paletteCamera.drawBackground(); ··· 1080 1080 1081 1081 private void renderAnim() 1082 1082 { 1083 - animCamera.glSetViewport(0, 0, glCanvasWidth(), glCanvasHeight()); 1083 + animCamera.glSetViewport(0, 0, glCanvasPixelWidth(), glCanvasPixelHeight()); 1084 1084 1085 1085 if (showBackground) 1086 1086 animCamera.drawBackground();
+1 -1
src/main/java/game/texture/editor/ImageEditor.java
··· 695 695 colorLerpAlpha = 0.5f * (float) Math.sin(omega * time); 696 696 colorLerpAlpha = 0.5f + colorLerpAlpha * colorLerpAlpha; // more pleasing 697 697 698 - cam.glSetViewport(0, 0, glCanvasWidth(), glCanvasHeight()); 698 + cam.glSetViewport(0, 0, glCanvasPixelWidth(), glCanvasPixelHeight()); 699 699 700 700 if (image != null && bDrawBackground) 701 701 glClearColor(0.6f, 0.6f, 0.6f, 1.0f);
+1 -1
src/main/java/game/worldmap/WorldMapEditor.java
··· 512 512 glTexDirty = false; 513 513 } 514 514 515 - cam.glSetViewport(0, 0, glCanvasWidth(), glCanvasHeight()); 515 + cam.glSetViewport(0, 0, glCanvasPixelWidth(), glCanvasPixelHeight()); 516 516 517 517 glClearColor(0.1f, 0.1f, 0.1f, 1.0f); 518 518