mirror of
https://github.com/dscalzi/HeliosLauncher.git
synced 2024-10-31 19:36:39 -07:00
b5386c0257
The darwin frame is the same as the original, however the button behavior is corrected. The win32 frame uses the traditional buttons found on windows. Also added a small logo image to the windows frame. Each frame is dynamically loaded on startup via ejs. Also disabled the server selection test UI.
92 lines
3.1 KiB
JavaScript
92 lines
3.1 KiB
JavaScript
/**
|
|
* Core UI functions are initialized in this file. This prevents
|
|
* unexpected errors from breaking the core features. Specifically,
|
|
* actions in this file should not require the usage of any internal
|
|
* modules, excluding dependencies.
|
|
*/
|
|
const $ = require('jquery');
|
|
const {remote, shell, webFrame} = require('electron')
|
|
|
|
// Disable zoom, needed for darwin.
|
|
webFrame.setZoomLevel(0)
|
|
webFrame.setVisualZoomLevelLimits(1, 1)
|
|
webFrame.setLayoutZoomLevelLimits(0, 0)
|
|
|
|
/* jQuery Example
|
|
$(function(){
|
|
console.log('UICore Initialized');
|
|
})*/
|
|
|
|
document.addEventListener('readystatechange', function () {
|
|
if (document.readyState === 'interactive'){
|
|
console.log('UICore Initializing..');
|
|
|
|
// Bind close button.
|
|
Array.from(document.getElementsByClassName('fCb')).map((val) => {
|
|
val.addEventListener('click', e => {
|
|
const window = remote.getCurrentWindow()
|
|
window.close()
|
|
})
|
|
})
|
|
|
|
// Bind restore down button.
|
|
Array.from(document.getElementsByClassName('fRb')).map((val) => {
|
|
val.addEventListener('click', e => {
|
|
const window = remote.getCurrentWindow()
|
|
if(window.isMaximized()){
|
|
window.unmaximize()
|
|
} else {
|
|
window.maximize()
|
|
}
|
|
document.activeElement.blur()
|
|
})
|
|
})
|
|
|
|
// Bind minimize button.
|
|
Array.from(document.getElementsByClassName('fMb')).map((val) => {
|
|
val.addEventListener('click', e => {
|
|
const window = remote.getCurrentWindow()
|
|
window.minimize()
|
|
document.activeElement.blur()
|
|
})
|
|
})
|
|
|
|
} else if(document.readyState === 'complete'){
|
|
|
|
//266.01
|
|
//170.8
|
|
//53.21
|
|
// Bind progress bar length to length of bot wrapper
|
|
//const targetWidth = document.getElementById("launch_content").getBoundingClientRect().width
|
|
//const targetWidth2 = document.getElementById("server_selection").getBoundingClientRect().width
|
|
//const targetWidth3 = document.getElementById("launch_button").getBoundingClientRect().width
|
|
|
|
document.getElementById("launch_details").style.maxWidth = 266.01
|
|
document.getElementById("launch_progress").style.width = 170.8
|
|
document.getElementById("launch_details_right").style.maxWidth = 170.8
|
|
document.getElementById("launch_progress_label").style.width = 53.21
|
|
|
|
}
|
|
|
|
}, false)
|
|
|
|
/**
|
|
* Open web links in the user's default browser.
|
|
*/
|
|
$(document).on('click', 'a[href^="http"]', function(event) {
|
|
event.preventDefault();
|
|
//console.log(os.homedir())
|
|
shell.openExternal(this.href)
|
|
})
|
|
|
|
/**
|
|
* Opens DevTools window if you hold (ctrl + shift + i).
|
|
* This will crash the program if you are using multiple
|
|
* DevTools, for example the chrome debugger in VS Code.
|
|
*/
|
|
document.addEventListener('keydown', function (e) {
|
|
if(e.keyCode == 73 && e.ctrlKey && e.shiftKey){
|
|
let window = remote.getCurrentWindow()
|
|
window.toggleDevTools()
|
|
}
|
|
}) |