Player count and instance time on wrist overlay

This commit is contained in:
Natsumi
2021-03-03 14:23:55 +13:00
parent e73ee80ef5
commit a9d8003408
4 changed files with 80 additions and 22 deletions

View File

@@ -1158,7 +1158,7 @@ speechSynthesis.getVoices();
json.last_login = API.currentUser.last_login; json.last_login = API.currentUser.last_login;
if ($app.lastLocation.location) { if ($app.lastLocation.location) {
json.location = $app.lastLocation.location; json.location = $app.lastLocation.location;
json.$location_at = Date.parse($app.lastLocation.date); json.$location_at = $app.lastLocation.date;
} }
json.$online_for = API.currentUser.$online_for; json.$online_for = API.currentUser.$online_for;
json.$offline_for = API.currentUser.$offline_for; json.$offline_for = API.currentUser.$offline_for;
@@ -3770,7 +3770,10 @@ speechSynthesis.getVoices();
var wristFilter = this.sharedFeedFilters.wrist; var wristFilter = this.sharedFeedFilters.wrist;
var notyFilter = this.sharedFeedFilters.noty; var notyFilter = this.sharedFeedFilters.noty;
var locationChange = false; var locationChange = false;
while ((w < 20) || (n < 5) || ((!locationChange) && (this.hideOnPlayerJoined))) { var playerCountDone = false;
var playerCount = 0;
var friendCount = 0;
while ((w < 20) || (n < 5) || ((!locationChange) && (this.hideOnPlayerJoined)) || !playerCountDone) {
var ctx = data[--i]; var ctx = data[--i];
if ((i <= -1) || (ctx.created_at < bias)) { if ((i <= -1) || (ctx.created_at < bias)) {
break; break;
@@ -3814,6 +3817,26 @@ speechSynthesis.getVoices();
break; break;
} }
} }
// instance player count
if (ctx.type === 'Location') {
playerCountDone = true;
}
if ((!playerCountDone) && (ctx.type === 'OnPlayerJoined')) {
playerCount++;
if (isFriend) {
friendCount++;
}
}
if ((!playerCountDone) && (ctx.type === 'OnPlayerLeft')) {
playerCount--;
if (isFriend) {
friendCount--;
}
}
if (((ctx.type === 'OnPlayerJoined') || (ctx.type === 'OnPlayerLeft')) &&
(ctx.data === API.currentUser.displayName)) {
continue;
}
if ((w < 20) && (wristFilter[ctx.type]) && if ((w < 20) && (wristFilter[ctx.type]) &&
((wristFilter[ctx.type] === 'On') || ((wristFilter[ctx.type] === 'On') ||
(wristFilter[ctx.type] === 'Everyone') || (wristFilter[ctx.type] === 'Everyone') ||
@@ -3839,6 +3862,9 @@ speechSynthesis.getVoices();
++n; ++n;
} }
} }
this.lastLocation.playerCount = playerCount;
this.lastLocation.friendCount = friendCount;
sharedRepository.setObject('last_location', this.lastLocation);
this.sharedFeed.gameLog.wrist = wristArr; this.sharedFeed.gameLog.wrist = wristArr;
this.sharedFeed.gameLog.noty = notyArr; this.sharedFeed.gameLog.noty = notyArr;
this.sharedFeed.pendingUpdate = true; this.sharedFeed.pendingUpdate = true;
@@ -5388,9 +5414,11 @@ speechSynthesis.getVoices();
// App: gameLog // App: gameLog
$app.data.lastLocation = { $app.data.lastLocation = {
date: '', date: 0,
location: '', location: '',
name: '' name: '',
playerCount: 0,
friendCount: 0
}; };
$app.data.lastLocation$ = {}; $app.data.lastLocation$ = {};
$app.data.discordActive = configRepository.getBool('discordActive'); $app.data.discordActive = configRepository.getBool('discordActive');
@@ -5414,6 +5442,11 @@ speechSynthesis.getVoices();
{ {
prop: 'data', prop: 'data',
value: '' value: ''
},
{
prop: 'data',
value: true,
filterFn: (row, filter) => row.data !== API.currentUser.displayName
} }
], ],
tableProps: { tableProps: {
@@ -5441,9 +5474,11 @@ speechSynthesis.getVoices();
await gameLogService.reset(); await gameLogService.reset();
this.gameLogTable.data = []; this.gameLogTable.data = [];
this.lastLocation = { this.lastLocation = {
date: '', date: 0,
location: '', location: '',
name: '' name: '',
playerCount: 0,
friendCount: 0
}; };
}; };
@@ -5468,8 +5503,6 @@ speechSynthesis.getVoices();
}; };
$app.methods.updateGameLog = async function () { $app.methods.updateGameLog = async function () {
var currentUserDisplayName = API.currentUser.displayName;
for (var gameLog of await gameLogService.poll()) { for (var gameLog of await gameLogService.poll()) {
var tableData = null; var tableData = null;
@@ -5477,7 +5510,7 @@ speechSynthesis.getVoices();
case 'location': case 'location':
if (this.isGameRunning) { if (this.isGameRunning) {
this.lastLocation = { this.lastLocation = {
date: gameLog.dt, date: Date.parse(gameLog.dt),
location: gameLog.location, location: gameLog.location,
name: gameLog.worldName name: gameLog.worldName
}; };
@@ -5490,9 +5523,6 @@ speechSynthesis.getVoices();
break; break;
case 'player-joined': case 'player-joined':
if (currentUserDisplayName === gameLog.userDisplayName) {
continue;
}
tableData = { tableData = {
created_at: gameLog.dt, created_at: gameLog.dt,
type: 'OnPlayerJoined', type: 'OnPlayerJoined',
@@ -5501,9 +5531,6 @@ speechSynthesis.getVoices();
break; break;
case 'player-left': case 'player-left':
if (currentUserDisplayName === gameLog.userDisplayName) {
continue;
}
tableData = { tableData = {
created_at: gameLog.dt, created_at: gameLog.dt,
type: 'OnPlayerLeft', type: 'OnPlayerLeft',
@@ -6836,10 +6863,12 @@ speechSynthesis.getVoices();
sharedRepository.setBool('is_game_running', false); sharedRepository.setBool('is_game_running', false);
var isGameRunningStateChange = function () { var isGameRunningStateChange = function () {
sharedRepository.setBool('is_game_running', this.isGameRunning); sharedRepository.setBool('is_game_running', this.isGameRunning);
$app.lastLocation = { this.lastLocation = {
date: '', date: 0,
location: '', location: '',
name: '' name: '',
playerCount: 0,
friendCount: 0
}; };
if (this.isGameRunning) { if (this.isGameRunning) {
API.currentUser.$online_for = Date.now(); API.currentUser.$online_for = Date.now();

View File

@@ -694,7 +694,14 @@ speechSynthesis.getVoices();
config: {}, config: {},
isGameRunning: false, isGameRunning: false,
isGameNoVR: false, isGameNoVR: false,
lastLocation: {}, lastLocation: {
date: 0,
location: '',
name: '',
playerCount: 0,
friendCount: 0
},
lastLocationTimer: '',
wristFeedLastEntry: '', wristFeedLastEntry: '',
notyFeedLastEntry: '', notyFeedLastEntry: '',
wristFeed: [], wristFeed: [],
@@ -738,6 +745,11 @@ speechSynthesis.getVoices();
this.isGameRunning = sharedRepository.getBool('is_game_running'); this.isGameRunning = sharedRepository.getBool('is_game_running');
this.isGameNoVR = sharedRepository.getBool('is_Game_No_VR'); this.isGameNoVR = sharedRepository.getBool('is_Game_No_VR');
this.lastLocation = sharedRepository.getObject('last_location'); this.lastLocation = sharedRepository.getObject('last_location');
if (this.lastLocation.date !== 0) {
this.lastLocationTimer = timeToText(Date.now() - this.lastLocation.date);
} else {
this.lastLocationTimer = '';
}
var newConfig = sharedRepository.getObject('VRConfigVars'); var newConfig = sharedRepository.getObject('VRConfigVars');
if (newConfig) { if (newConfig) {
if (JSON.stringify(newConfig) !== JSON.stringify(this.config)) { if (JSON.stringify(newConfig) !== JSON.stringify(this.config)) {
@@ -810,7 +822,7 @@ speechSynthesis.getVoices();
$app.methods.updateCpuUsageLoop = async function () { $app.methods.updateCpuUsageLoop = async function () {
try { try {
var cpuUsage = await AppApi.CpuUsage(); var cpuUsage = await AppApi.CpuUsage();
this.cpuUsage = cpuUsage.toFixed(2); this.cpuUsage = cpuUsage.toFixed(0);
} catch (err) { } catch (err) {
console.error(err); console.error(err);
} }

View File

@@ -240,7 +240,7 @@ html
span.extra span.extra
span.time {{ feed.created_at | formatDate('HH:MI') }} span.time {{ feed.created_at | formatDate('HH:MI') }}
| #[span.name(v-text="feed.sourceDisplayName")] has unmuted you | #[span.name(v-text="feed.sourceDisplayName")] has unmuted you
.x-container .x-containerbottom
div(style="display:flex;flex-direction:row") div(style="display:flex;flex-direction:row")
template(v-if="devices.length") template(v-if="devices.length")
div(v-for="device in devices" style="flex:none;text-align:center;width:64px") div(v-for="device in devices" style="flex:none;text-align:center;width:64px")
@@ -280,7 +280,11 @@ html
img(v-else src="images/other_status_ready.png" style="width:32px;height:32px") img(v-else src="images/other_status_ready.png" style="width:32px;height:32px")
br br
span {{ device[2] }}% span {{ device[2] }}%
.x-container .x-containerbottom
span(style="float:right") Timer: {{ lastLocationTimer }}
span(style="display:inline-block") Players: {{ lastLocation.playerCount }}
span(style="display:inline-block;font-weight:bold") {{ lastLocation.friendCount !== 0 ? ` (${lastLocation.friendCount})` : ''}}
br
span(style="float:right") {{ currentTime | formatDate('YYYY-MM-DD HH:MI:SS AMPM') }} span(style="float:right") {{ currentTime | formatDate('YYYY-MM-DD HH:MI:SS AMPM') }}
span CPU {{ cpuUsage }}% span CPU {{ cpuUsage }}%
script(src="vr.js") script(src="vr.js")

View File

@@ -187,6 +187,19 @@ button {
overflow: hidden auto; overflow: hidden auto;
} }
.x-containerbottom {
padding: 0px 10px;
overflow: hidden;
font-size: 20px;
white-space: nowrap;
}
.x-containerbottom span {
padding: 0px;
display: block;
overflow: hidden;
}
.x-friend-item { .x-friend-item {
box-sizing: border-box; box-sizing: border-box;
display: flex; display: flex;