Skip to content

Commit

Permalink
Added RAM, FPS, and Zoom options to settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
dpwhittaker committed Aug 16, 2017
1 parent 6b35026 commit 152d2de
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 14 deletions.
44 changes: 38 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,21 @@
width: 155px;
right: -7px;
left: initial;
border: none;
}
.right.input {
border: 3px solid #7b1b1d;
border-radius: 8px;
background-color: #627d9f;
box-sizing: border-box;
color: black;
}
button.right {
background-color: #7b1b1d;
cursor: pointer;
border-radius: 8px;
border: 3px solid #7b1b1d;
color: #cc9966
}
button.right:disabled {
background-color: #2f2f2f;
Expand Down Expand Up @@ -133,14 +144,35 @@
</div>
<div id="rightsettings" class="rightbox" style="display:none">
<div class="right" style="top: 12px;">RoC Folder</div>
<input id="folder" type="text" class="right shadow" style="top: 48px;color: black; border: 3px solid #7b1b1d; border-radius: 8px; box-sizing: border-box; background-color: #627d9f"/>
<button id="browse" class="right shadow" style="top: 96px; border-radius: 8px; border: 3px solid #7b1b1d; color: #cc9966">Browse</button>
<button id="install" class="right shadow" style="top: 144px; width:38%; border-radius: 8px; border: 3px solid #7b1b1d; color: #cc9966">Install From SWG</button>
<button id="fullscan" class="right shadow" style="top: 144px; left:40%; width:38%; border-radius: 8px; border: 3px solid #7b1b1d; color: #cc9966">Full Scan</button>
<button id="cancel" class="right shadow" style="top: 144px; left:80%; width:20%; border-radius: 8px; border: 3px solid #7b1b1d; color: #cc9966">Cancel</button>
<input id="folder" type="text" class="right shadow input" style="top: 48px;"/>
<button id="browse" class="right shadow" style="top: 96px;">Browse</button>
<button id="install" class="right shadow" style="top: 144px; width:38%;">Install From SWG</button>
<button id="fullscan" class="right shadow" style="top: 144px; left:40%; width:38%;">Full Scan</button>
<button id="cancel" class="right shadow" style="top: 144px; left:80%; width:20%;">Cancel</button>
<div class="right" style="top: 208px;">Mods</div>
<ul id="modlist" class="right shadow" style="top:240px;"></ul>
<button id="gamesettings" class="right shadow" style="bottom:70px; border-radius: 8px; border: 3px solid #7b1b1d; color: #cc9966">Game Settings</button>
<div class="right" style="bottom:118px;left: 0px;width:15%">RAM</div>
<select id="ram" class="right shadow input" style="bottom:118px;left:15%;width:15%;">
<option value="750">750 MB (default)</option>
<option value="1024">1 GB</option>
<option value="1536">1.5 GB</option>
<option value="2048">2 GB</option>
</select>
<div class="right" style="bottom:118px; left:35%;width:15%">FPS</div>
<select id="fps" class="right shadow input" style="bottom:118px;left:50%;width:15%;">
<option value="30">30 (default)</option>
<option value="45">45</option>
<option value="60">60</option>
</select>
<div class="right" style="bottom:118px; left:70%;width:15%">Zoom</div>
<select id="zoom" class="right shadow input" style="bottom:118px;left:85%;width:15%;">
<option value="1">1 (default)</option>
<option value="3">3</option>
<option value="5">5 (medium)</option>
<option value="7">7</option>
<option value="10">10 (far)</option>
</select>
<button id="gamesettings" class="right shadow" style="bottom:70px;">Game Settings</button>
<button id="home" class="right button" style="bottom:12px"></button>
</div>

Expand Down
32 changes: 29 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "roc-launcher",
"version": "0.0.16",
"version": "0.0.17",
"description": "Relics of Corbantis Official SWGEMU Launcher",
"main": "main.js",
"scripts": {
Expand Down Expand Up @@ -33,6 +33,7 @@
"electron-log": "^2.2.7",
"electron-updater": "^2.4.5",
"follow-redirects": "^1.2.4",
"random-access-file": "^1.8.1",
"request": "^2.81.0"
},
"build": {
Expand Down
62 changes: 58 additions & 4 deletions renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ const updates = document.getElementById('updates');
const minBtn = document.getElementById('minimize');
const maxBtn = document.getElementById('maximize');
const closeBtn = document.getElementById('close');
const ramSel = document.getElementById('ram');
const fpsSel = document.getElementById('fps');
const zoomSel = document.getElementById('zoom');
const gamesettingsBtn = document.getElementById('gamesettings');
const versionDiv = document.getElementById('version');
versionDiv.innerHTML = package.version;
Expand All @@ -38,10 +41,27 @@ var config = {folder: 'C:\\SWGRelics'};
if (fs.existsSync(configFile))
config = JSON.parse(fs.readFileSync(configFile));
folderBox.value = config.folder;
var needSave = false;
if (!config.mods) {
config.mods = [];
saveConfig();
needSave = true;
}
if (!config.fps) {
config.fps = 30;
needSave = true;
}
fpsSel.value = config.fps;
if (!config.ram) {
config.ram = 750;
needSave = true;
}
ramSel.value = config.ram;
if (!config.zoom) {
config.zoom = 1;
needSave = true;
}
zoomSel.value = config.zoom;
if (needSave) saveConfig();

minBtn.addEventListener('click', event => remote.getCurrentWindow().minimize());
maxBtn.addEventListener('click', event => {
Expand All @@ -53,14 +73,35 @@ closeBtn.addEventListener('click', event => remote.getCurrentWindow().close());

playBtn.addEventListener('click', event => {
if (playBtn.disabled) return;
fs.writeFileSync(path.join(config.folder, "swgemu_login.cfg"), `[ClientGame]\r\nloginServerAddress0=${server.address}\r\nloginServerPort0=${server.port}`);
var fd = fs.openSync(path.join(config.folder, "SWGEmu.exe"), "r");
var buf = new Buffer(7);
var bytes = fs.readSync(fd, buf, 0, 7, 0x1153);
fs.closeSync(fd);
fd = null;
if (bytes == 7 && buf.readUInt8(0) == 0xc7 && buf.readUInt8(1) == 0x45 && buf.readUInt8(2) == 0x94 && buf.readFloatLE(3) != config.fps) {
var file = require('random-access-file')(path.join(config.folder, "SWGEmu.exe"));
buf = new Buffer(4);
buf.writeFloatLE(config.fps);
file.write(0x1156, buf, err => {
if (err) alert("Could not modify FPS. Close all instances of the game to update FPS.\n" + ex.toString());
file.close(play);
})
} else {
play();
}
});

function play() {
fs.writeFileSync(path.join(config.folder, "swgemu_login.cfg"), `[ClientGame]\r\nloginServerAddress0=${server.address}\r\nloginServerPort0=${server.port}\r\nfreeChaseCameraMaximumZoom=${config.zoom}`);
var args = ["--",
"-s", "ClientGame", "loginServerAddress0=" + server.address, "loginServerPort0=" + server.port,
"-s", "Station", "gameFeatures=34929",
"-s", "SwgClient", "allowMultipleInstances=true"];
const child = process.spawn("SWGEmu.exe", args, {cwd: config.folder, detached: true, stdio: 'ignore'});
var env = Object.create(require('process').env);
env.SWGCLIENT_MEMORY_SIZE_MB = config.ram;
const child = process.spawn("SWGEmu.exe", args, {cwd: config.folder, env: env, detached: true, stdio: 'ignore'});
child.unref();
});
}

gamesettingsBtn.addEventListener('click', event => {
const child = process.spawn("cmd", ["/c", path.join(config.folder, "SWGEmu_Setup.exe")], {cwd: config.folder, detached: true, stdio: 'ignore'});
Expand Down Expand Up @@ -103,6 +144,19 @@ ipc.on('selected-directory', function (event, path) {
saveConfig();
});

fpsSel.addEventListener('change', event => {
config.fps = event.target.value;
saveConfig();
});
ramSel.addEventListener('change', event => {
config.ram = event.target.value;
saveConfig();
});
zoomSel.addEventListener('change', event => {
config.zoom = event.target.value;
saveConfig();
});

installBtn.addEventListener('click', function(event) {
if (installBtn.disabled = false) return;
installBtn.disabled = true;
Expand Down

0 comments on commit 152d2de

Please sign in to comment.