magefree / mage

Magic Another Game Engine
http://xmage.today
MIT License
1.91k stars 777 forks source link

Scale interface on Hi-DPI #969

Open mattiasb opened 9 years ago

mattiasb commented 9 years ago

XMage is really tiny on my shiny Hi-DPI screen on Linux (Fedora 22). It would be great if XMage scaled its interface on Hi-DPI screens (like the rest of my apps do).

skeet70 commented 9 years ago

+1, this problem occurs on my Yoga 2 Pro running Windows 8 as well. It'd be awesome to be able to play on that thing instead of just my Windows desktop (since it's currently unplayable on my Linux desktop as well).

ghost commented 9 years ago

AFAIK XMage's client is made with the Swing framework, which does not support Hi-DPI (see here, here for examples). The whole client would have to be remade in JavaFX to allow this.

skeet70 commented 9 years ago

That blows. Can't find anything about upcoming support for swing and scaling either. For those who are in my particular situation, setting the resolution to half the maximum and the scaling to 100% makes Xmage usable.

Juicebox360 commented 9 years ago

Looks like Linux behaviour with Swing is just really awful. I'm on ElementaryOS and the client window originally opens cut off on the right side. I have to scoot it up and over to the left, then resize to achieve the desired size.

mattiasb commented 8 years ago

This is supposed to be supported in JDK9 according to JEP-263.

I tested switching out the Nimbus look-and-feel for the GTK+ one and can confirm that the scaling looks semi-reasonable but there were a bunch of bugs (the game panel wouldn't work for example).

magreenblatt commented 7 years ago

Display scaling can be enabled for Windows 10 as follows:

  1. Install xmage in the usual way. I'm using a "C:\temp\xmage" directory in this example.

  2. Create a "javaw.exe.manifest" file and place it next to javaw.exe in the bundled JRE install (for example, at "C:\temp\xmage\java\jre1.8.0_131\bin") with the following contents:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<description>javaw</description>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
  <security>
    <requestedPrivileges>
      <requestedExecutionLevel xmlns:ms_asmv3="urn:schemas-microsoft-com:asm.v3"
        level="asInvoker"
        ms_asmv3:uiAccess="false">
      </requestedExecutionLevel>
    </requestedPrivileges>
  </security>
</trustInfo>
<asmv3:application>
  <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
    <ms_windowsSettings:dpiAware xmlns:ms_windowsSettings="http://schemas.microsoft.com/SMI/2005/WindowsSettings">false</ms_windowsSettings:dpiAware>
  </asmv3:windowsSettings>
</asmv3:application>
</assembly>
  1. Run regedit.exe and create a DWORD Value named "PreferExternalManifest" under "Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide". Set the value to 1.
  2. Create a modified version of startClient.bat with the following contents (for example, at "C:\temp\xmage\xmage\mage-client"):
@ECHO OFF
set JAVA_HOME=C:\temp\xmage\java\jre1.8.0_131\bin
set CLASSPATH=%JAVA_HOME%/bin;%CLASSPATH%
set PATH=%JAVA_HOME%/bin;%PATH%
start %JAVA_HOME%\javaw.exe -Xms256m -Xmx512m -XX:MaxPermSize=384m -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -jar .\lib\mage-client-1.4.26.jar
  1. Run this version of startClient.bat to launch the client.

(These instructions are based on https://github.com/magarena/magarena/issues/795)

derlhurgoyf commented 5 years ago

I've been searching for a solution for a while now and can only add to the above that no combination of the following options works on linux:

GDK_SCALE=2
GDK_DPI_SCALE=2
-Dsun.java2d.uiScale=2
-Dsun.java2d.dpiaware=false

Apparently the only real solution in this case is to switch to jdk9 or use run_scaled, albeit it looks a bit pixelated.

fearphage commented 4 years ago

Apparently the only real solution in this case is to switch to jdk9 or use run_scaled, albeit it looks a bit pixelated.

Is this a future fix or is there a functional solution here? If it's the latter, could you provide some additional details?

sweber83 commented 4 years ago

@fearphage Instead of running xmage with a version 8 jdk, use version 9 or newer. I just tried with jdk 11, works fine. To enable scaling, add this parameter to the command line: -Dsun.java2d.uiScale=2

derlhurgoyf commented 4 years ago

@sweber83 can you give some details how you did that? What is your start command? Does everything just work?

sweber83 commented 4 years ago

@derlhurgoyf Here is the command I use to start xmage:

java -Xms1G -Xmx2G -Dsun.java2d.xrender=true -Dsun.java2d.uiScale=2 -jar mage-client/lib/mage-client-1.4.44.jar

I left out the exact paths to java & the .jar file, because those will probably differ on your system. The exact version of the jdk I use is openjdk version "11.0.7" So far I did not experience any problems.

JayDi85 commented 4 years ago

@sweber83 can you make example screenshots with and without that command? If it's really good then it must be added to launcher/client settings.

sweber83 commented 4 years ago

@JayDi85 I made two screenshots, which show the difference. xmage_lodpi xmage_hidpi

I see an issues with changing the launcher settings. As far as I know, the launcher installs its own jdk, which is a version 8 jdk, iirc. So that would first have to be changed to use a version 9 or newer jdk, otherwise the -Dsun.java2d.uiScale=2 command line switch does nothing. I don't use the launcher myself, because I prefer to use the package manager of my OS, which is NixOS.

johtso commented 2 years ago

Would be great if we could respect the pixel density. I opened a pull request for Cockatrice and it didn't take much to scale all images at 2x the size on high dpi displays. Is it similarly straightforward with the framework that xmage uses? https://github.com/Cockatrice/Cockatrice/commit/5652b56b459e559862ea00bc1ee2cccb4351986a

That would be a good start.

JayDi85 commented 7 months ago

Another possible solution, compatible with java 8:

P.S. If not helps then set same settings for java.exe file too.

tiera3 commented 7 months ago

Question - I run xmage on different monitors (two different TVs with vastly different scaling and sometimes just the laptop monitor). (I am reluctant to try these solutions in case it makes xmage unplayable on my laptop screen (when I don't have external TV available for a monitor.)

Is there a solution that will enable different scaling on the different monitors? Or perhaps I could create different shortcuts and thus run the one appropriate for the monitor I was using that day?

JayDi85 commented 7 months ago

For windows you can make multiple links to javaw.exe or java.exe files and setup each link with different params and compatibility settings:

As additional you can load some registry settings by command line, see here for paths and tools (but you can run only one client that way):

JayDi85 commented 3 months ago

Some usefull info from 664ac24dfd3629c1f929908d6f9d37b3626822fc

Possible use cases with DPI problems:

Current xmage problems with enabled HiDPI settings by OS -- pixelated images for mana icons, cards, texts, etc. It can be "fixed" manually by windows compatibility settings (see option 3 above) or by improved rendering code with smooth hints. The last one must be used as priority (see example code from ce439d7fcf943c07e4b5a6cab5013f6f56ce79b1).

P.S. Modes example. Maybe x2-x4 scale can be potentially good for HiDPI monitors. Need more research. shot_240814_203629

JayDi85 commented 2 months ago

Related topic about low quality render on resize: #12276