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
|
-cp src
|
||||||
-lib heaps
|
-lib heaps
|
||||||
-lib hlsdl
|
-lib hlsdl
|
||||||
|
-D highDPI
|
||||||
-hl native/marblegame.c
|
-hl native/marblegame.c
|
||||||
--main Main
|
--main Main
|
||||||
|
|
@ -6,5 +6,6 @@
|
||||||
--js marblegame.js
|
--js marblegame.js
|
||||||
-D windowSize=1280x720
|
-D windowSize=1280x720
|
||||||
-D js-es=6
|
-D js-es=6
|
||||||
|
-D highDPI
|
||||||
--dce full
|
--dce full
|
||||||
--main Main
|
--main Main
|
||||||
|
|
@ -6,5 +6,6 @@
|
||||||
-D windowSize=1280x720
|
-D windowSize=1280x720
|
||||||
-D js-es=6
|
-D js-es=6
|
||||||
-D keep-inline-positions
|
-D keep-inline-positions
|
||||||
|
-D highDPI
|
||||||
--main Main
|
--main Main
|
||||||
-debug
|
-debug
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
-cp src
|
-cp src
|
||||||
-lib heaps
|
-lib heaps
|
||||||
-lib hlsdl
|
-lib hlsdl
|
||||||
|
-D highDPI
|
||||||
-hl native/marblegame.c
|
-hl native/marblegame.c
|
||||||
-D MACOS_BUNDLE
|
-D MACOS_BUNDLE
|
||||||
--main Main
|
--main Main
|
||||||
|
|
|
||||||
|
|
@ -5,5 +5,6 @@
|
||||||
-hl marblegame.hl
|
-hl marblegame.hl
|
||||||
-D windowSize=1280x720
|
-D windowSize=1280x720
|
||||||
-D keep-inline-positions
|
-D keep-inline-positions
|
||||||
|
-D highDPI
|
||||||
--main Main
|
--main Main
|
||||||
-debug
|
-debug
|
||||||
|
|
@ -115,7 +115,7 @@ class CameraController extends Object {
|
||||||
_ignoreCursor = false;
|
_ignoreCursor = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var scaleFactor = 1.0;
|
var scaleFactor = 1.0 / Window.getInstance().windowToPixelRatio;
|
||||||
#if js
|
#if js
|
||||||
scaleFactor = 1 / js.Browser.window.devicePixelRatio;
|
scaleFactor = 1 / js.Browser.window.devicePixelRatio;
|
||||||
#end
|
#end
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,11 @@ import src.ResourceLoaderWorker;
|
||||||
|
|
||||||
class ResourceLoader {
|
class ResourceLoader {
|
||||||
#if (hl && !android)
|
#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);
|
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);
|
public static var fileSystem:FileSystem = new LocalFileSystem(".", null);
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
#if (js || android)
|
#if (js || android)
|
||||||
public static var fileSystem:FileSystem = null;
|
public static var fileSystem:FileSystem = null;
|
||||||
|
|
@ -271,8 +271,7 @@ class ResourceLoader {
|
||||||
texObj.flags.set(MipMapped);
|
texObj.flags.set(MipMapped);
|
||||||
}
|
}
|
||||||
var tex = img.toTexture();
|
var tex = img.toTexture();
|
||||||
tex.mipMap = Linear;
|
tex.mipMap = Nearest;
|
||||||
tex.filter = Linear;
|
|
||||||
// tex.filter = Nearest;
|
// tex.filter = Nearest;
|
||||||
var textureresource = new Resource(tex, path, textureCache, tex -> tex.dispose());
|
var textureresource = new Resource(tex, path, textureCache, tex -> tex.dispose());
|
||||||
textureCache.set(path, textureresource);
|
textureCache.set(path, textureresource);
|
||||||
|
|
|
||||||
|
|
@ -117,13 +117,12 @@ class Settings {
|
||||||
public static var isTouch:Option<Bool> = Option.None;
|
public static var isTouch:Option<Bool> = Option.None;
|
||||||
|
|
||||||
#if hl
|
#if hl
|
||||||
#if MACOS_BUNDLE
|
#if MACOS_BUNDLE
|
||||||
public static var settingsDir = Path.join([Sys.getEnv("HOME"), "Library", "Application Support", "MBHaxe-MBG"]);
|
public static var settingsDir = Path.join([Sys.getEnv("HOME"), "Library", "Application Support", "MBHaxe-MBG"]);
|
||||||
#else
|
#else
|
||||||
public static var settingsDir = ".";
|
public static var settingsDir = ".";
|
||||||
#end
|
|
||||||
#end
|
#end
|
||||||
|
#end
|
||||||
public static function applySettings() {
|
public static function applySettings() {
|
||||||
#if hl
|
#if hl
|
||||||
Window.getInstance().resize(optionsSettings.screenWidth, optionsSettings.screenHeight);
|
Window.getInstance().resize(optionsSettings.screenWidth, optionsSettings.screenHeight);
|
||||||
|
|
@ -208,8 +207,7 @@ class Settings {
|
||||||
|
|
||||||
if (settingsExists) {
|
if (settingsExists) {
|
||||||
#if hl
|
#if hl
|
||||||
var json =
|
var json = Json.parse(File.getContent(Path.join([settingsDir, "settings.json"])));
|
||||||
Json.parse(File.getContent(Path.join([settingsDir, "settings.json"])));
|
|
||||||
#end
|
#end
|
||||||
#if js
|
#if js
|
||||||
var json = Json.parse(localStorage.getItem("MBHaxeSettings"));
|
var json = Json.parse(localStorage.getItem("MBHaxeSettings"));
|
||||||
|
|
@ -247,7 +245,7 @@ class Settings {
|
||||||
// @:privateAccess Window.getInstance().window.center();
|
// @:privateAccess Window.getInstance().window.center();
|
||||||
Window.getInstance().addResizeEvent(() -> {
|
Window.getInstance().addResizeEvent(() -> {
|
||||||
var wnd = Window.getInstance();
|
var wnd = Window.getInstance();
|
||||||
var zoomRatio = 1.0;
|
var zoomRatio = Window.getInstance().windowToPixelRatio;
|
||||||
#if js
|
#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;
|
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;
|
Settings.zoomRatio = zoomRatio;
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ class GuiControl {
|
||||||
rect.position = parentRect.position.add(this.position.multiply(uiScaleFactor));
|
rect.position = parentRect.position.add(this.position.multiply(uiScaleFactor));
|
||||||
}
|
}
|
||||||
|
|
||||||
var scaleFactor = 1.0;
|
var scaleFactor = 1.0 / Window.getInstance().windowToPixelRatio;
|
||||||
#if (js || android)
|
#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;
|
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
|
#end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue