Added indication for when there is new news.
This commit is contained in:
parent
05fe516249
commit
08eb04775e
@ -2136,6 +2136,17 @@ input:checked + .toggleSwitchSlider:before {
|
|||||||
stroke: rgba(255, 255, 255, 0.75);
|
stroke: rgba(255, 255, 255, 0.75);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Icon which indicates there is new news. */
|
||||||
|
#newsButtonAlert {
|
||||||
|
width: 5px;
|
||||||
|
height: 5px;
|
||||||
|
position: absolute;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: red;
|
||||||
|
right: -1px;
|
||||||
|
top: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
/* Arrow image which floats above the news button. */
|
/* Arrow image which floats above the news button. */
|
||||||
#newsButtonSVG {
|
#newsButtonSVG {
|
||||||
height: 11px;
|
height: 11px;
|
||||||
|
@ -22,19 +22,19 @@
|
|||||||
* @module assetguard
|
* @module assetguard
|
||||||
*/
|
*/
|
||||||
// Requirements
|
// Requirements
|
||||||
const AdmZip = require('adm-zip')
|
const AdmZip = require('adm-zip')
|
||||||
const async = require('async')
|
const async = require('async')
|
||||||
const child_process = require('child_process')
|
const child_process = require('child_process')
|
||||||
const crypto = require('crypto')
|
const crypto = require('crypto')
|
||||||
const EventEmitter = require('events')
|
const EventEmitter = require('events')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const isDev = require('electron-is-dev')
|
const isDev = require('electron-is-dev')
|
||||||
const mkpath = require('mkdirp');
|
const mkpath = require('mkdirp');
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const Registry = require('winreg')
|
const Registry = require('winreg')
|
||||||
const request = require('request')
|
const request = require('request')
|
||||||
const tar = require('tar-fs')
|
const tar = require('tar-fs')
|
||||||
const zlib = require('zlib')
|
const zlib = require('zlib')
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
const PLATFORM_MAP = {
|
const PLATFORM_MAP = {
|
||||||
|
@ -44,6 +44,11 @@ const DEFAULT_CONFIG = {
|
|||||||
allowPrerelease: false
|
allowPrerelease: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
newsCache: {
|
||||||
|
date: null,
|
||||||
|
content: null,
|
||||||
|
dismissed: false
|
||||||
|
},
|
||||||
commonDirectory: path.join(dataPath, 'common'),
|
commonDirectory: path.join(dataPath, 'common'),
|
||||||
instanceDirectory: path.join(dataPath, 'instances'),
|
instanceDirectory: path.join(dataPath, 'instances'),
|
||||||
clientToken: uuidV4().replace(/-/g, ''),
|
clientToken: uuidV4().replace(/-/g, ''),
|
||||||
@ -143,9 +148,39 @@ exports.getTempNativeFolder = function(){
|
|||||||
|
|
||||||
// System Settings (Unconfigurable on UI)
|
// System Settings (Unconfigurable on UI)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the news cache to determine
|
||||||
|
* whether or not there is newer news.
|
||||||
|
*
|
||||||
|
* @returns {Object} The news cache object.
|
||||||
|
*/
|
||||||
|
exports.getNewsCache = function(){
|
||||||
|
return config.newsCache
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the new news cache object.
|
||||||
|
*
|
||||||
|
* @param {Object} newsCache The new news cache object.
|
||||||
|
*/
|
||||||
|
exports.setNewsCache = function(newsCache){
|
||||||
|
config.newsCache = newsCache
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether or not the news has been dismissed (checked)
|
||||||
|
*
|
||||||
|
* @param {boolean} dismissed Whether or not the news has been dismissed (checked).
|
||||||
|
*/
|
||||||
|
exports.setNewsCacheDismissed = function(dismissed){
|
||||||
|
config.newsCache.dismissed = dismissed
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the common directory for shared
|
* Retrieve the common directory for shared
|
||||||
* game files (assets, libraries, etc).
|
* game files (assets, libraries, etc).
|
||||||
|
*
|
||||||
|
* @returns {string} The launcher's common directory.
|
||||||
*/
|
*/
|
||||||
exports.getCommonDirectory = function(){
|
exports.getCommonDirectory = function(){
|
||||||
return config.commonDirectory
|
return config.commonDirectory
|
||||||
@ -154,6 +189,8 @@ exports.getCommonDirectory = function(){
|
|||||||
/**
|
/**
|
||||||
* Retrieve the instance directory for the per
|
* Retrieve the instance directory for the per
|
||||||
* server game directories.
|
* server game directories.
|
||||||
|
*
|
||||||
|
* @returns {string} The launcher's instance directory.
|
||||||
*/
|
*/
|
||||||
exports.getInstanceDirectory = function(){
|
exports.getInstanceDirectory = function(){
|
||||||
return config.instanceDirectory
|
return config.instanceDirectory
|
||||||
@ -419,7 +456,8 @@ exports.setGameWidth = function(resWidth){
|
|||||||
/**
|
/**
|
||||||
* Validate a potential new width value.
|
* Validate a potential new width value.
|
||||||
*
|
*
|
||||||
* @param {*} resWidth The width value to validate.
|
* @param {number} resWidth The width value to validate.
|
||||||
|
* @returns {boolean} Whether or not the value is valid.
|
||||||
*/
|
*/
|
||||||
exports.validateGameWidth = function(resWidth){
|
exports.validateGameWidth = function(resWidth){
|
||||||
const nVal = Number.parseInt(resWidth)
|
const nVal = Number.parseInt(resWidth)
|
||||||
@ -448,7 +486,8 @@ exports.setGameHeight = function(resHeight){
|
|||||||
/**
|
/**
|
||||||
* Validate a potential new height value.
|
* Validate a potential new height value.
|
||||||
*
|
*
|
||||||
* @param {*} resHeight The height value to validate.
|
* @param {number} resHeight The height value to validate.
|
||||||
|
* @returns {boolean} Whether or not the value is valid.
|
||||||
*/
|
*/
|
||||||
exports.validateGameHeight = function(resHeight){
|
exports.validateGameHeight = function(resHeight){
|
||||||
const nVal = Number.parseInt(resHeight)
|
const nVal = Number.parseInt(resHeight)
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
// Requirements
|
// Requirements
|
||||||
const cp = require('child_process')
|
const cp = require('child_process')
|
||||||
|
const crypto = require('crypto')
|
||||||
const {URL} = require('url')
|
const {URL} = require('url')
|
||||||
|
|
||||||
// Internal Requirements
|
// Internal Requirements
|
||||||
@ -774,11 +775,17 @@ function slide_(up){
|
|||||||
document.getElementById('newsButton').onclick = () => {
|
document.getElementById('newsButton').onclick = () => {
|
||||||
// Toggle tabbing.
|
// Toggle tabbing.
|
||||||
if(newsActive){
|
if(newsActive){
|
||||||
$("#landingContainer *").removeAttr('tabindex')
|
$('#landingContainer *').removeAttr('tabindex')
|
||||||
$("#newsContainer *").attr('tabindex', '-1')
|
$('#newsContainer *').attr('tabindex', '-1')
|
||||||
} else {
|
} else {
|
||||||
$("#landingContainer *").attr('tabindex', '-1')
|
$('#landingContainer *').attr('tabindex', '-1')
|
||||||
$("#newsContainer, #newsContainer *, #lower, #lower #center *").removeAttr('tabindex')
|
$('#newsContainer, #newsContainer *, #lower, #lower #center *').removeAttr('tabindex')
|
||||||
|
if(newsAlertShown){
|
||||||
|
$('#newsButtonAlert').fadeOut(2000)
|
||||||
|
newsAlertShown = false
|
||||||
|
ConfigManager.setNewsCacheDismissed(true)
|
||||||
|
ConfigManager.save()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
slide_(!newsActive)
|
slide_(!newsActive)
|
||||||
newsActive = !newsActive
|
newsActive = !newsActive
|
||||||
@ -841,6 +848,16 @@ function reloadNews(){
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let newsAlertShown = false
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the news alert indicating there is new news.
|
||||||
|
*/
|
||||||
|
function showNewsAlert(){
|
||||||
|
newsAlertShown = true
|
||||||
|
$(newsButtonAlert).fadeIn(250)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize News UI. This will load the news and prepare
|
* Initialize News UI. This will load the news and prepare
|
||||||
* the UI accordingly.
|
* the UI accordingly.
|
||||||
@ -871,6 +888,13 @@ function initNews(){
|
|||||||
// No News Articles
|
// No News Articles
|
||||||
setNewsLoading(false)
|
setNewsLoading(false)
|
||||||
|
|
||||||
|
ConfigManager.setNewsCache({
|
||||||
|
date: null,
|
||||||
|
content: null,
|
||||||
|
dismissed: false
|
||||||
|
})
|
||||||
|
ConfigManager.save()
|
||||||
|
|
||||||
$('#newsErrorLoading').fadeOut(250, () => {
|
$('#newsErrorLoading').fadeOut(250, () => {
|
||||||
$('#newsErrorNone').fadeIn(250, () => {
|
$('#newsErrorNone').fadeIn(250, () => {
|
||||||
resolve()
|
resolve()
|
||||||
@ -880,6 +904,46 @@ function initNews(){
|
|||||||
// Success
|
// Success
|
||||||
setNewsLoading(false)
|
setNewsLoading(false)
|
||||||
|
|
||||||
|
const lN = newsArr[0]
|
||||||
|
const cached = ConfigManager.getNewsCache()
|
||||||
|
let newHash = crypto.createHash('sha1').update(lN.content).digest('hex')
|
||||||
|
let newDate = new Date(lN.date)
|
||||||
|
let isNew = false
|
||||||
|
|
||||||
|
if(cached.date != null && cached.content != null){
|
||||||
|
|
||||||
|
if(new Date(cached.date) >= newDate){
|
||||||
|
|
||||||
|
// Compare Content
|
||||||
|
if(cached.content !== newHash){
|
||||||
|
isNew = true
|
||||||
|
showNewsAlert()
|
||||||
|
} else {
|
||||||
|
if(!cached.dismissed){
|
||||||
|
isNew = true
|
||||||
|
showNewsAlert()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
isNew = true
|
||||||
|
showNewsAlert()
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
isNew = true
|
||||||
|
showNewsAlert()
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isNew){
|
||||||
|
ConfigManager.setNewsCache({
|
||||||
|
date: newDate.getTime(),
|
||||||
|
content: newHash,
|
||||||
|
dismissed: false
|
||||||
|
})
|
||||||
|
ConfigManager.save()
|
||||||
|
}
|
||||||
|
|
||||||
const switchHandler = (forward) => {
|
const switchHandler = (forward) => {
|
||||||
let cArt = parseInt(newsContent.getAttribute('article'))
|
let cArt = parseInt(newsContent.getAttribute('article'))
|
||||||
let nxtArt = forward ? (cArt >= newsArr.length-1 ? 0 : cArt + 1) : (cArt <= 0 ? newsArr.length-1 : cArt - 1)
|
let nxtArt = forward ? (cArt >= newsArr.length-1 ? 0 : cArt + 1) : (cArt <= 0 ? newsArr.length-1 : cArt - 1)
|
||||||
|
@ -126,6 +126,7 @@
|
|||||||
<div id="content">
|
<div id="content">
|
||||||
<button id="newsButton">
|
<button id="newsButton">
|
||||||
<!--<img src="assets/images/icons/arrow.svg" id="newsButtonSVG"/>-->
|
<!--<img src="assets/images/icons/arrow.svg" id="newsButtonSVG"/>-->
|
||||||
|
<div id="newsButtonAlert" style="display: none;"></div>
|
||||||
<svg id="newsButtonSVG" viewBox="0 0 24.87 13.97">
|
<svg id="newsButtonSVG" viewBox="0 0 24.87 13.97">
|
||||||
<defs>
|
<defs>
|
||||||
<style>.arrowLine{fill:none;stroke:#FFF;stroke-width:2px;}</style>
|
<style>.arrowLine{fill:none;stroke:#FFF;stroke-width:2px;}</style>
|
||||||
|
Loading…
Reference in New Issue
Block a user