mirror of
https://github.com/lexi-lambda/shattered-plans.git
synced 2024-11-22 02:52:23 +03:00
Add a property for altering the game’s aspect ratio
This commit is contained in:
parent
8ec4eb6b6a
commit
c7fc2fe4c8
@ -1,6 +1,6 @@
|
||||
## 0.0.6 (not yet released)
|
||||
|
||||
* Added experimental support for custom UI scaling via the `funorb.shatteredplans.client.uiScale` JVM property. See the README for more details.
|
||||
* Added experimental support for custom UI scaling via the `funorb.shatteredplans.client.uiScale` and `funorb.shatteredplans.client.aspectRatio` JVM properties. See the README for more details.
|
||||
* Fixed game chat messages being sent as lobby chat messages.
|
||||
|
||||
## 0.0.5 (2022-10-01)
|
||||
|
12
README.md
12
README.md
@ -22,13 +22,19 @@ replacing `<HOST>` with your IP address. By default, the server runs on port 435
|
||||
|
||||
### Experimental: Adjusting the user interface scale
|
||||
|
||||
Limited support for adjusting the UI scale is available by setting the `funorb.shatteredplans.client.uiScale` JVM property to a numeric value. The default is `1.0`. Larger values increase the internal resolution of the game’s renderer, which effectively makes individual user interface elements smaller. For example, the following command will force the game to render at 1.5× standard resolution:
|
||||
Limited support for adjusting the UI scale is available by setting one or both of the following JVM properties:
|
||||
|
||||
* `funorb.shatteredplans.client.uiScale` — Accepts any real value, but reasonable values are in the range `1.0`–`3.0`. The default is `1.0`. Larger values increase the internal resolution of the game’s renderer, which effectively makes individual user interface elements smaller.
|
||||
|
||||
* `funorb.shatteredplans.client.aspectRatio` — Accepts a ratio of two integers in the format `N:M`. The default is `4:3`, and the most reasonable alternative value is `16:9`.
|
||||
|
||||
For example, the following command will force the game to render at 1.5× standard height using a widescreen aspect ratio:
|
||||
|
||||
```sh
|
||||
java -Dfunorb.shatteredplans.client.uiScale=1.5 -jar shattered-plans-0.0.5.jar
|
||||
java -Dfunorb.shatteredplans.client.uiScale=1.5 -Dfunorb.shatteredplans.client.aspectRatio=16:9 -jar shattered-plans-0.0.5.jar
|
||||
```
|
||||
|
||||
This is particularly useful on large screens, as it makes the in-game user interface less cramped. However, the game was originally designed to run at a fixed resolution of 640×480, so altering the UI scale can cause layout glitches and other visual issues. The in-game user interface has been patched to automatically adapt to larger UI scales, but some visual issues remain.
|
||||
This is particularly useful on large screens, as it makes the in-game user interface less cramped. However, the game was originally designed to run at a fixed resolution of 640×480, so altering the UI scale may cause rendering glitches, and particularly large resolutions may cause performance problems on slower machines. All the critical UIs in the game have been patched to automatically adapt to larger UI scales, but some minor visual issues remain.
|
||||
|
||||
## What works, what doesn’t, and other limitations
|
||||
|
||||
|
@ -86,6 +86,7 @@ public final class ShatteredPlansClient extends JagexApplet {
|
||||
public static final int ORIGINAL_SCREEN_HEIGHT = 480;
|
||||
|
||||
public static final double UI_SCALE;
|
||||
public static final double ASPECT_RATIO;
|
||||
public static final int SCREEN_WIDTH;
|
||||
public static final int SCREEN_HEIGHT;
|
||||
static {
|
||||
@ -95,11 +96,34 @@ public final class ShatteredPlansClient extends JagexApplet {
|
||||
} catch (final NumberFormatException e) {
|
||||
throw new RuntimeException("non-numeric value for property ‘funorb.shatteredplans.client.uiScale’: " + uiScaleStr, e);
|
||||
}
|
||||
SCREEN_WIDTH = (int) (ORIGINAL_SCREEN_WIDTH * UI_SCALE);
|
||||
|
||||
final String aspectRatioStr = System.getProperty("funorb.shatteredplans.client.aspectRatio", "4:3");
|
||||
final String[] aspectRatioStrs = aspectRatioStr.split(":");
|
||||
if (aspectRatioStrs.length != 2) {
|
||||
throw new RuntimeException("value for property ‘funorb.shatteredplans.client.aspectRatio’ is not in the form ‘N:M’: " + aspectRatioStr);
|
||||
}
|
||||
try {
|
||||
ASPECT_RATIO = (double) Integer.parseInt(aspectRatioStrs[0]) / Integer.parseInt(aspectRatioStrs[1]);
|
||||
} catch (final NumberFormatException e) {
|
||||
throw new RuntimeException("value for property ‘funorb.shatteredplans.client.aspectRatio’ is not in the form ‘N:M’: " + aspectRatioStr, e);
|
||||
}
|
||||
|
||||
SCREEN_HEIGHT = (int) (ORIGINAL_SCREEN_HEIGHT * UI_SCALE);
|
||||
SCREEN_WIDTH = (int) (ORIGINAL_SCREEN_HEIGHT * UI_SCALE * ASPECT_RATIO);
|
||||
}
|
||||
|
||||
public static final AffineTransform ORIGINAL_TO_SCALED_TRANSFORM = AffineTransform.getScaleInstance(UI_SCALE, UI_SCALE);
|
||||
public static final AffineTransform STAR_FIELD_TRANSFORM = new AffineTransform();
|
||||
static {
|
||||
final double originalAspectRatio = 4.0 / 3.0;
|
||||
if (ASPECT_RATIO > originalAspectRatio) {
|
||||
final double scale = UI_SCALE * ASPECT_RATIO;
|
||||
STAR_FIELD_TRANSFORM.scale(scale, scale);
|
||||
STAR_FIELD_TRANSFORM.translate(0.0, ORIGINAL_SCREEN_HEIGHT * (1.0/originalAspectRatio - 1.0/ASPECT_RATIO) * -0.5);
|
||||
} else {
|
||||
STAR_FIELD_TRANSFORM.scale(UI_SCALE, UI_SCALE);
|
||||
STAR_FIELD_TRANSFORM.translate(ORIGINAL_SCREEN_WIDTH * (ASPECT_RATIO - originalAspectRatio) * -0.5, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
public static final int[] NUM_PLAYERS_OPTION_VALUES = {2, 3, 4, 5, 6};
|
||||
public static final int[] GAMEOPT_CHOICES_COUNTS = {5, 7, 4, 5, 2};
|
||||
@ -2464,7 +2488,7 @@ public final class ShatteredPlansClient extends JagexApplet {
|
||||
if (renderQuality.antialiasStarfieldBackground || SCREEN_WIDTH != 640 || SCREEN_HEIGHT != 480) {
|
||||
final AffineTransform transform = new AffineTransform();
|
||||
transform.translate(x, y);
|
||||
transform.concatenate(ORIGINAL_TO_SCALED_TRANSFORM);
|
||||
transform.concatenate(STAR_FIELD_TRANSFORM);
|
||||
STAR_FIELD.drawAntialiased(transform);
|
||||
} else {
|
||||
STAR_FIELD.c093((int) x, (int) y);
|
||||
|
Loading…
Reference in New Issue
Block a user