Skip to content

Commit

Permalink
ignore system scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
jjppof committed Feb 28, 2023
1 parent a46b8b4 commit 8dffe0b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
1 change: 1 addition & 0 deletions assets/init.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"collision_layer": 1,
"coins": 10000,
"skip_start_menu": false,
"ignore_system_scaling": true,
"artifacts_global_list": [
{
"key_name":"apollos_axe",
Expand Down
31 changes: 26 additions & 5 deletions base/GoldenSun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class GoldenSun {
public loading_what: string = "";
public fps_reduction_active: boolean = false;
public showing_fps_banner: boolean = false;
public ignore_system_scaling: boolean = false;

public electron_app: boolean;
private ipcRenderer: any;
Expand Down Expand Up @@ -242,7 +243,21 @@ export class GoldenSun {
this.initialize_utils_controls();

this.scale_factor = this.dbs.init_db.initial_scale_factor;
this.game.scale.setupScale(this.scale_factor * numbers.GAME_WIDTH, this.scale_factor * numbers.GAME_HEIGHT);
let width = this.scale_factor * numbers.GAME_WIDTH;
let height = this.scale_factor * numbers.GAME_HEIGHT;
this.game.scale.setupScale(width, height);
this.ignore_system_scaling = this.dbs.init_db.ignore_system_scaling;
if (this.ignore_system_scaling) {
window.onresize = () =>
((this.game.canvas.style as any).transform = this.fullscreen
? "scale(1.0)"
: `scale(${1 / window.devicePixelRatio})`);
}
if (this.ipcRenderer) {
width = this.ignore_system_scaling ? (width * 1) / window.devicePixelRatio : width;
height = this.ignore_system_scaling ? (height * 1) / window.devicePixelRatio : height;
this.ipcRenderer.send("resize-window", width, height);
}
window.dispatchEvent(new Event("resize"));

this.game.stage.disableVisibilityChange = false;
Expand Down Expand Up @@ -390,10 +405,14 @@ export class GoldenSun {
this.fullscreen = !this.fullscreen;
}
this.scale_factor = 1;
this.game.scale.setupScale(numbers.GAME_WIDTH, numbers.GAME_HEIGHT);
let width = numbers.GAME_WIDTH;
let height = numbers.GAME_HEIGHT;
this.game.scale.setupScale(width, height);
window.dispatchEvent(new Event("resize"));
if (this.ipcRenderer) {
this.ipcRenderer.send("resize-window", numbers.GAME_WIDTH, numbers.GAME_HEIGHT);
width = this.ignore_system_scaling ? (width * 1) / window.devicePixelRatio : width;
height = this.ignore_system_scaling ? (height * 1) / window.devicePixelRatio : height;
this.ipcRenderer.send("resize-window", width, height);
}
}

Expand All @@ -414,11 +433,13 @@ export class GoldenSun {
const setup_scale = (scaleFactor: number) => {
if (this.fullscreen) return;
this.scale_factor = scaleFactor;
const width = this.scale_factor * numbers.GAME_WIDTH;
const height = this.scale_factor * numbers.GAME_HEIGHT;
let width = this.scale_factor * numbers.GAME_WIDTH;
let height = this.scale_factor * numbers.GAME_HEIGHT;
this.game.scale.setupScale(width, height);
window.dispatchEvent(new Event("resize"));
if (this.ipcRenderer) {
width = this.ignore_system_scaling ? (width * 1) / window.devicePixelRatio : width;
height = this.ignore_system_scaling ? (height * 1) / window.devicePixelRatio : height;
this.ipcRenderer.send("resize-window", width, height);
}
};
Expand Down
4 changes: 2 additions & 2 deletions electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const {
function createWindow() {
const is_dev_env = process.argv[2] !== undefined && process.argv[2] == "dev";
const win = new BrowserWindow({
width: 480,
height: 320,
width: 240,
height: 160,
resizable: is_dev_env ? true : false,
center: true,
useContentSize: true,
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<small>The engine is not working properly on Firefox. Don't use it.</small>

• Use the same controls of VBA: arrows, Z, X, A, S, Backspace and Enter.
• Press 1,2 and 3 for zoom. Double click on screen to fullscreen.
• Press 1,2, 3, or 4 for zoom. Double click on screen to fullscreen.
• Press M to unmute. Press SHIFT + PGUP/PGDN to control the volume.
• D for debug colision. F for fps. G for grid. K for keys debug. T for battle stats. L for sliders.
• Use Q to cast Move. Use W to cast Whirlwind. Use E to cast Growth (swap djinn first). Use R to cast Reveal.
Expand Down
1 change: 1 addition & 0 deletions static/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ canvas {
image-rendering: -webkit-crisp-edges;
image-rendering: pixelated;
image-rendering: crisp-edges;
transform-origin: top left;
}
#key_debug {
display: none;
Expand Down

0 comments on commit 8dffe0b

Please sign in to comment.