diff --git a/README.md b/README.md index 18f7174..fb93380 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/public/index.html b/public/index.html index b9d5af5..e2e8358 100644 --- a/public/index.html +++ b/public/index.html @@ -148,6 +148,13 @@

+ +
+ +

diff --git a/src/css/UI.scss b/src/css/UI.scss index 95c04b5..e2475fc 100644 --- a/src/css/UI.scss +++ b/src/css/UI.scss @@ -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 { diff --git a/src/js/xiv/ButtonActions.js b/src/js/xiv/ButtonActions.js index 285e573..dcdfdb3 100644 --- a/src/js/xiv/ButtonActions.js +++ b/src/js/xiv/ButtonActions.js @@ -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 => { diff --git a/src/js/xiv/Characters.js b/src/js/xiv/Characters.js index 96e9355..670aa84 100644 --- a/src/js/xiv/Characters.js +++ b/src/js/xiv/Characters.js @@ -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; @@ -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"], @@ -205,7 +209,7 @@ class Characters let otp = ''; if (character.otp) { - otp = `
` + otp = `
` } $view.html(` @@ -226,6 +230,11 @@ class Characters `); $view.addClass('open'); + + // auto focus + if (character.otp) { + $('.otp2').focus(); + } } /** @@ -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! @@ -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); }); diff --git a/src/js/xiv/GameLauncherWindow.js b/src/js/xiv/GameLauncherWindow.js index 1a170db..1d3b537 100644 --- a/src/js/xiv/GameLauncherWindow.js +++ b/src/js/xiv/GameLauncherWindow.js @@ -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", () => { @@ -29,8 +28,7 @@ class GameLauncherWindow }); document.getElementById("Launcher.Window.Close").addEventListener("click", () => { - let window = remote.BrowserWindow.getFocusedWindow(); - window.close(); + remote.BrowserWindow.getFocusedWindow().close(); }); /** @@ -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'); } } diff --git a/src/js/xiv/Settings.js b/src/js/xiv/Settings.js index 08d7687..4749981 100644 --- a/src/js/xiv/Settings.js +++ b/src/js/xiv/Settings.js @@ -18,6 +18,7 @@ module.exports = { }, // Characters checkCharacterExpiryDelay: 60000, + closeAppOnGameStart: false, }, // Square-Enix specific options se: { diff --git a/src/js/xiv/SettingsManager.js b/src/js/xiv/SettingsManager.js index c0fec7d..ac2f39f 100644 --- a/src/js/xiv/SettingsManager.js +++ b/src/js/xiv/SettingsManager.js @@ -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) {