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

View File

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

View File

@@ -240,7 +240,7 @@ html
span.extra
span.time {{ feed.created_at | formatDate('HH:MI') }}
| #[span.name(v-text="feed.sourceDisplayName")] has unmuted you
.x-container
.x-containerbottom
div(style="display:flex;flex-direction:row")
template(v-if="devices.length")
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")
br
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 CPU {{ cpuUsage }}%
script(src="vr.js")

View File

@@ -187,6 +187,19 @@ button {
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 {
box-sizing: border-box;
display: flex;