Skip to content
This repository has been archived by the owner on Dec 18, 2020. It is now read-only.

Commit

Permalink
Auto focus OTP, Add option for Auto Close, Add random background.
Browse files Browse the repository at this point in the history
  • Loading branch information
vekien committed Jun 8, 2019
1 parent 3c0384a commit d1e1b11
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A custom built launcher for FFXIV written in Javascript on Nodejs via Electron.

> This is a Javascript implementation of: https://github.com/goaaats/FFXIVQuickLauncher

> Note: DO NOT run npm commands in this project, it will install different versions of packages and break stuff.
## Source files

Expand Down
7 changes: 7 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ <h1>
<option value="jp">Japanese</option>
</select>
</div>
<label for="closeAppOnGameStart">Close Launcher on Game Start</label>
<div>
<select id="closeAppOnGameStart">
<option value="false">No</option>
<option value="true">Yes</option>
</select>
</div>
<br>
<button type="button" id="SaveSettings">Save Settings</button>
</form>
Expand Down
2 changes: 1 addition & 1 deletion src/css/UI.scss
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ html, body {

main {
position: relative;
background: url('https://xivapi.com/launcher/bg.jpg');
background-color: #000;
background-size: cover;
}
body, main {
Expand Down
8 changes: 5 additions & 3 deletions src/js/xiv/ButtonActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,19 @@ class ButtonActions
const expansion = document.getElementById('expansion').value.trim();
const language = document.getElementById('language').value.trim();
const region = document.getElementById('region').value.trim();
const raelyslanguage = document.getElementById('raelysLanguage').value.trim();
const raelysLanguage = document.getElementById('raelysLanguage').value.trim();
const closeAppOnGameStart = document.getElementById('closeAppOnGameStart').value.trim();

SettingsManager.saveSettings({
gamePath: gamePath,
expansion: expansion,
language: language,
region: region,
raelysLanguage: raelyslanguage
raelysLanguage: raelysLanguage,
closeAppOnGameStart: (closeAppOnGameStart === "true")
});

document.getElementById('settings-form').classList.remove('open');
$('.settings-form').removeClass('open');
});

$html.on('click', '#OpenLauncherSettingsWindow', event => {
Expand Down
20 changes: 19 additions & 1 deletion src/js/xiv/Characters.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import Settings from './Settings';
import SettingsManager from './SettingsManager';
import GameLauncher from "./GameLauncher";
import Notice from './Notice';
import XIVAPI from "./XIVAPI";
import Login from "./Login";

const fs = require("fs");
const app = require('electron').remote.app;

Expand All @@ -16,6 +19,7 @@ class Characters
this.directory = app.getPath('userData') + '/data/';
this.filename = 'characters.json';

// https://xivapi.com/servers/dc
this.servers = {
"Aether": ["Adamantoise", "Cactuar", "Faerie", "Gilgamesh", "Jenova", "Midgardsormr", "Sargatanas", "Siren"],
"Chaos": ["Cerberus", "Louisoix", "Moogle", "Omega", "Ragnarok"],
Expand Down Expand Up @@ -205,7 +209,7 @@ class Characters

let otp = '';
if (character.otp) {
otp = `<div><input type="text" class="otp2" id="otp2" placeholder="OTP"></div>`
otp = `<div><input type="text" class="otp2" id="otp2" placeholder="OTP" autofocus></div>`
}

$view.html(`
Expand All @@ -226,6 +230,11 @@ class Characters
`);

$view.addClass('open');

// auto focus
if (character.otp) {
$('.otp2').focus();
}
}

/**
Expand Down Expand Up @@ -256,6 +265,9 @@ class Characters
// get otp if its needed
const otp = $('#otp2').val();

// load custom settings
SettingsManager.loadSettings();

// login to character
Login.login(character.username, character.password, otp, response => {
// launch game!
Expand All @@ -264,6 +276,12 @@ class Characters

// hide notice after 5 seconds
setTimeout(() => {
// if close app on game start is set
if (Settings.closeAppOnGameStart) {
require('electron').remote.getCurrentWindow().close();
return;
}

Notice.hide();
}, 3000);
});
Expand Down
13 changes: 9 additions & 4 deletions src/js/xiv/GameLauncherWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ class GameLauncherWindow
init()
{
document.getElementById("Launcher.Window.Min").addEventListener("click", () => {
let window = remote.BrowserWindow.getFocusedWindow();
window.minimize();
remote.BrowserWindow.getFocusedWindow().minimize();
});

document.getElementById("Launcher.Window.Max").addEventListener("click", () => {
Expand All @@ -29,8 +28,7 @@ class GameLauncherWindow
});

document.getElementById("Launcher.Window.Close").addEventListener("click", () => {
let window = remote.BrowserWindow.getFocusedWindow();
window.close();
remote.BrowserWindow.getFocusedWindow().close();
});

/**
Expand All @@ -40,6 +38,13 @@ class GameLauncherWindow
event.preventDefault();
shell.openExternal(event.target.href);
});

/**
* Set a random background
*/
const bgNumber = Math.floor(Math.random() * (8 - 1 + 1)) + 1;
$('main').css('background', `url('https://xivapi.com/launcher/background${bgNumber}.jpg')`);
$('main').css('background-size', 'cover');
}
}

Expand Down
1 change: 1 addition & 0 deletions src/js/xiv/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = {
},
// Characters
checkCharacterExpiryDelay: 60000,
closeAppOnGameStart: false,
},
// Square-Enix specific options
se: {
Expand Down
1 change: 1 addition & 0 deletions src/js/xiv/SettingsManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class SettingsManager
Settings.region = this.custom.region; //Game Language
Settings.RaelysAPILanguage = this.custom.raelysLanguage;
Settings.expansion = this.custom.expansion;
Settings.closeAppOnGameStart = this.custom.closeAppOnGameStart;

// populate forms
for (let option in this.custom) {
Expand Down

0 comments on commit d1e1b11

Please sign in to comment.