-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.js
More file actions
61 lines (50 loc) · 1.71 KB
/
code.js
File metadata and controls
61 lines (50 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { RPM } from "../path.js"
/**
* This plugin allows to set the window resolution and full screen mode.
*/
// Plugin name
const pluginName = "Change Game Resolution";
// Require the file system module
const fs = require('fs');
const systemJSONFilePath = RPM.Common.Paths.FILE_SYSTEM;
/**
* Set the window size to the specified width, height and full screen mode.
* @param {number} width - The width of the window.
* @param {number} height - The height of the window.
* @param {boolean} fullscreen - Indicates if the window is in full screen mode.
*/
function setWindowSize(width, height, fullscreen) {
// Read the JSON file
const jsonData = fs.readFileSync(systemJSONFilePath, 'utf8');
const data = JSON.parse(jsonData);
// Modify the values
data.sh = height;
data.sw = width;
data.isw = !fullscreen;
// Write the updated object back to the file
fs.writeFileSync(systemJSONFilePath, JSON.stringify(data, null, 2));
// Update the window size
RPM.Datas.Systems.updateWindowSize(width, height, fullscreen);
RPM.Datas.Systems.updateWindowSize(width, height, fullscreen);
}
/**
* Set the desired screen resolution.
* @param {number} Width - The width of the screen.
* @param {number} Height - The height of the screen.
*/
RPM.Manager.Plugins.registerCommand(pluginName, "Set Resolution", (Width, Height) => {
setWindowSize(Width, Height, false);
});
/**
* Set the game to full screen mode.
*/
RPM.Manager.Plugins.registerCommand(pluginName, "Set Full Screen", () => {
setWindowSize(0, 0, true);
});
/**
* Confirm the resolution change.
*/
RPM.Manager.Plugins.registerCommand(pluginName, "Reload Game", () => {
// Reload the window/game
window.location.reload();
});