mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
highdpi support test
This commit is contained in:
parent
ba6a0141ba
commit
e3a867eb77
9 changed files with 16 additions and 14 deletions
|
|
@ -1,5 +1,6 @@
|
|||
-cp src
|
||||
-lib heaps
|
||||
-lib hlsdl
|
||||
-D highDPI
|
||||
-hl native/marblegame.c
|
||||
--main Main
|
||||
|
|
@ -6,5 +6,6 @@
|
|||
--js marblegame.js
|
||||
-D windowSize=1280x720
|
||||
-D js-es=6
|
||||
-D highDPI
|
||||
--dce full
|
||||
--main Main
|
||||
|
|
@ -6,5 +6,6 @@
|
|||
-D windowSize=1280x720
|
||||
-D js-es=6
|
||||
-D keep-inline-positions
|
||||
-D highDPI
|
||||
--main Main
|
||||
-debug
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
-cp src
|
||||
-lib heaps
|
||||
-lib hlsdl
|
||||
-D highDPI
|
||||
-hl native/marblegame.c
|
||||
-D MACOS_BUNDLE
|
||||
--main Main
|
||||
|
|
|
|||
|
|
@ -5,5 +5,6 @@
|
|||
-hl marblegame.hl
|
||||
-D windowSize=1280x720
|
||||
-D keep-inline-positions
|
||||
-D highDPI
|
||||
--main Main
|
||||
-debug
|
||||
|
|
@ -115,7 +115,7 @@ class CameraController extends Object {
|
|||
_ignoreCursor = false;
|
||||
return;
|
||||
}
|
||||
var scaleFactor = 1.0;
|
||||
var scaleFactor = 1.0 / Window.getInstance().windowToPixelRatio;
|
||||
#if js
|
||||
scaleFactor = 1 / js.Browser.window.devicePixelRatio;
|
||||
#end
|
||||
|
|
|
|||
|
|
@ -20,11 +20,11 @@ import src.ResourceLoaderWorker;
|
|||
|
||||
class ResourceLoader {
|
||||
#if (hl && !android)
|
||||
#if MACOS_BUNDLE
|
||||
#if MACOS_BUNDLE
|
||||
public static var fileSystem:FileSystem = new LocalFileSystem(Path.normalize(Path.join([Path.directory(Sys.programPath()), "..", "..", ".."])), null);
|
||||
#else
|
||||
#else
|
||||
public static var fileSystem:FileSystem = new LocalFileSystem(".", null);
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
#if (js || android)
|
||||
public static var fileSystem:FileSystem = null;
|
||||
|
|
@ -271,8 +271,7 @@ class ResourceLoader {
|
|||
texObj.flags.set(MipMapped);
|
||||
}
|
||||
var tex = img.toTexture();
|
||||
tex.mipMap = Linear;
|
||||
tex.filter = Linear;
|
||||
tex.mipMap = Nearest;
|
||||
// tex.filter = Nearest;
|
||||
var textureresource = new Resource(tex, path, textureCache, tex -> tex.dispose());
|
||||
textureCache.set(path, textureresource);
|
||||
|
|
|
|||
|
|
@ -117,13 +117,12 @@ class Settings {
|
|||
public static var isTouch:Option<Bool> = Option.None;
|
||||
|
||||
#if hl
|
||||
#if MACOS_BUNDLE
|
||||
#if MACOS_BUNDLE
|
||||
public static var settingsDir = Path.join([Sys.getEnv("HOME"), "Library", "Application Support", "MBHaxe-MBG"]);
|
||||
#else
|
||||
#else
|
||||
public static var settingsDir = ".";
|
||||
#end
|
||||
#end
|
||||
|
||||
#end
|
||||
public static function applySettings() {
|
||||
#if hl
|
||||
Window.getInstance().resize(optionsSettings.screenWidth, optionsSettings.screenHeight);
|
||||
|
|
@ -208,8 +207,7 @@ class Settings {
|
|||
|
||||
if (settingsExists) {
|
||||
#if hl
|
||||
var json =
|
||||
Json.parse(File.getContent(Path.join([settingsDir, "settings.json"])));
|
||||
var json = Json.parse(File.getContent(Path.join([settingsDir, "settings.json"])));
|
||||
#end
|
||||
#if js
|
||||
var json = Json.parse(localStorage.getItem("MBHaxeSettings"));
|
||||
|
|
@ -247,7 +245,7 @@ class Settings {
|
|||
// @:privateAccess Window.getInstance().window.center();
|
||||
Window.getInstance().addResizeEvent(() -> {
|
||||
var wnd = Window.getInstance();
|
||||
var zoomRatio = 1.0;
|
||||
var zoomRatio = Window.getInstance().windowToPixelRatio;
|
||||
#if js
|
||||
var zoomRatio = Util.isTouchDevice() ? js.Browser.window.screen.height * js.Browser.window.devicePixelRatio / 600 : js.Browser.window.devicePixelRatio; // 768 / js.Browser.window.innerHeight; // js.Browser.window.innerHeight * js.Browser.window.devicePixelRatio / 768;
|
||||
Settings.zoomRatio = zoomRatio;
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ class GuiControl {
|
|||
rect.position = parentRect.position.add(this.position.multiply(uiScaleFactor));
|
||||
}
|
||||
|
||||
var scaleFactor = 1.0;
|
||||
var scaleFactor = 1.0 / Window.getInstance().windowToPixelRatio;
|
||||
#if (js || android)
|
||||
scaleFactor = 1 / Settings.zoomRatio; // 768 / js.Browser.window.innerHeight * js.Browser.window.devicePixelRatio; // 0.5; // 768 / js.Browser.window.innerHeight; // js.Browser.window.innerHeight * js.Browser.window.devicePixelRatio / 768;
|
||||
#end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue