Skip to content

Commit

Permalink
Small changes and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Natsumi-sama committed Mar 15, 2024
1 parent f33e301 commit 0b64416
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 27 deletions.
7 changes: 4 additions & 3 deletions Dotnet/AppApi/AppApiVr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class AppApiVr
{
public static readonly AppApiVr Instance;

private readonly PerformanceCounter _uptime = new PerformanceCounter("System", "System Up Time");

static AppApiVr()
{
Instance = new AppApiVr();
Expand Down Expand Up @@ -45,9 +47,8 @@ public string[][] GetVRDevices()
/// <returns>The number of milliseconds that the system has been running.</returns>
public double GetUptime()
{
using var uptime = new PerformanceCounter("System", "System Up Time");
uptime.NextValue();
return TimeSpan.FromSeconds(uptime.NextValue()).TotalMilliseconds;
_uptime.NextValue();
return TimeSpan.FromSeconds(_uptime.NextValue()).TotalMilliseconds;
}

/// <summary>
Expand Down
23 changes: 23 additions & 0 deletions Dotnet/AppApi/Folders.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using Newtonsoft.Json;
Expand Down Expand Up @@ -170,6 +171,7 @@ public void OpenFolderAndSelectItem(string path, bool isFolder = false)
var result = WinApi.SHParseDisplayName(folderPath, IntPtr.Zero, out pidlFolder, 0, out psfgaoOut);
if (result != 0)
{
OpenFolderAndSelectItemFallback(path);
return;
}

Expand All @@ -178,6 +180,7 @@ public void OpenFolderAndSelectItem(string path, bool isFolder = false)
{
// Free the PIDL we allocated earlier if we failed to parse the display name of the file.
Marshal.FreeCoTaskMem(pidlFolder);
OpenFolderAndSelectItemFallback(path);
return;
}

Expand All @@ -189,12 +192,32 @@ public void OpenFolderAndSelectItem(string path, bool isFolder = false)
// It can select multiple items, but we only need to select one.
WinApi.SHOpenFolderAndSelectItems(pidlFolder, (uint)files.Length, files, 0);
}
catch
{
OpenFolderAndSelectItemFallback(path);
}
finally
{
// Free the PIDLs we allocated earlier
Marshal.FreeCoTaskMem(pidlFolder);
Marshal.FreeCoTaskMem(pidlFile);
}
}

public void OpenFolderAndSelectItemFallback(string path)
{
if (!File.Exists(path) && !Directory.Exists(path))
return;

if (Directory.Exists(path))
{
Process.Start("explorer.exe", path);
}
else
{
// open folder with file highlighted
Process.Start("explorer.exe", $"/select,\"{path}\"");
}
}
}
}
2 changes: 1 addition & 1 deletion Dotnet/LogWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ private bool ParseOscFailedToStart(FileInfo fileInfo, LogContext logContext, str
{
// 2023.09.26 04:12:57 Warning - Could not Start OSC: Address already in use

if (string.Compare(line, offset, "Could not Start OSC: ", 0, 21, StringComparison.Ordinal) != 0)
if (string.Compare(line, offset, "VRChat could not start OSC server: ", 0, 21, StringComparison.Ordinal) != 0)
return false;

AppendLog(new[]
Expand Down
82 changes: 61 additions & 21 deletions html/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8135,7 +8135,7 @@ speechSynthesis.getVoices();
);
this.isFriendsGroup2 = await configRepository.getBool(
'VRCX_isFriendsGroupActive',
true
false
);
this.isFriendsGroup3 = await configRepository.getBool(
'VRCX_isFriendsGroupOffline',
Expand Down Expand Up @@ -26836,7 +26836,51 @@ speechSynthesis.getVoices();
$app.getLocalWorldFavorites();
});

// pending offline timer
$app.data.worldFavoriteSearch = '';
$app.data.worldFavoriteSearchResults = [];

$app.methods.searchWorldFavorites = function () {
var search = this.worldFavoriteSearch.toLowerCase();
if (search.length < 3) {
this.worldFavoriteSearchResults = [];
return;
}

var results = [];
for (var i = 0; i < this.localWorldFavoriteGroups.length; ++i) {
var group = this.localWorldFavoriteGroups[i];
if (!this.localWorldFavorites[group]) {
continue;
}
for (var j = 0; j < this.localWorldFavorites[group].length; ++j) {
var ref = this.localWorldFavorites[group][j];
if (
ref.name.toLowerCase().includes(search) ||
ref.authorName.toLowerCase().includes(search)
) {
results.push(ref);
}
}
}

for (var i = 0; i < this.favoriteWorlds.length; ++i) {
var ref = this.favoriteWorlds[i].ref;
if (!ref) {
continue;
}
if (
ref.name.toLowerCase().includes(search) ||
ref.authorName.toLowerCase().includes(search)
) {
results.push(ref);
}
}

this.worldFavoriteSearchResults = results;
};

// #endregion
// #region | App: pending offline timer

$app.methods.promptSetPendingOffline = function () {
this.$prompt(
Expand Down Expand Up @@ -28135,26 +28179,22 @@ speechSynthesis.getVoices();
D.memberRoles.push(role);
}
}
if (D.inGroup) {
API.getAllGroupPosts({
groupId
}).then((args2) => {
if (groupId === args2.params.groupId) {
for (var post of args2.posts) {
post.title = this.replaceBioSymbols(
post.title
);
post.text = this.replaceBioSymbols(
post.text
);
}
if (args2.posts.length > 0) {
D.announcement = args2.posts[0];
}
D.posts = args2.posts;
this.updateGroupPostSearch();
API.getAllGroupPosts({
groupId
}).then((args2) => {
if (groupId === args2.params.groupId) {
for (var post of args2.posts) {
post.title = this.replaceBioSymbols(post.title);
post.text = this.replaceBioSymbols(post.text);
}
});
if (args2.posts.length > 0) {
D.announcement = args2.posts[0];
}
D.posts = args2.posts;
this.updateGroupPostSearch();
}
});
if (D.inGroup) {
API.getGroupInstances({
groupId
}).then((args3) => {
Expand Down
4 changes: 2 additions & 2 deletions html/src/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ html
timer(:epoch="user.$travelingToTime")
span.extra(v-else)
timer(:epoch="user.$location_at")
.x-friend-item(v-if="groupDialog.ref.membershipStatus === 'member'" style="width:100%;cursor:default")
.x-friend-item(style="width:100%;cursor:default")
.detail
span.name {{ $t('dialog.group.info.announcement') }}
span(style="display:block" v-text="groupDialog.announcement.title")
Expand Down Expand Up @@ -2361,7 +2361,7 @@ html
el-button(type="default" @click="deleteVRCPlusIcon(image.id)" size="mini" icon="el-icon-delete" circle style="margin-left:5px")
el-tab-pane(v-if="galleryDialogVisible" v-loading="galleryDialogIconsLoading")
span(slot="label") {{ $t('dialog.gallery_icons.emojis') }}
span(style="color:#909399;font-size:12px;margin-left:5px") {{ emojiTable.length }}/5
span(style="color:#909399;font-size:12px;margin-left:5px") {{ emojiTable.length }}/9
input(type="file" accept="image/*" @change="onFileChangeEmoji" id="EmojiUploadButton" style="display:none")
el-button-group(style="margin-right:10px")
el-button(type="default" size="small" @click="refreshEmojiTable" icon="el-icon-refresh") {{ $t('dialog.gallery_icons.refresh') }}
Expand Down
1 change: 1 addition & 0 deletions html/src/localization/en/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
},
"worlds": {
"header": "Worlds",
"search": "Search",
"vrchat_favorites": "VRChat Favorites",
"local_favorites": "Local Favorites",
"new_group": "New Group"
Expand Down
17 changes: 17 additions & 0 deletions html/src/mixins/tabs/favorites.pug
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,23 @@ mixin favoritesTab()
div(style="display:inline-block;float:right;font-size:13px;margin-right:10px")
span.name(style="margin-right:5px") {{ $t('view.favorite.sort_by') }}
el-switch(v-model="sortFavorites" :inactive-text="$t('view.settings.appearance.appearance.sort_favorite_by_name')" :active-text="$t('view.settings.appearance.appearance.sort_favorite_by_date')" @change="saveSortFavoritesOption")
span(style="display:block;margin-top:20px") {{ $t('view.favorite.worlds.search') }}
el-input(v-model="worldFavoriteSearch" @input="searchWorldFavorites" clearable size="mini" :placeholder="$t('view.favorite.worlds.search')" style="width:300px;margin-top:10px")
.x-friend-list(style="margin-top:10px")
div(style="display:inline-block;width:300px;margin-right:15px" v-for="favorite in worldFavoriteSearchResults" :key="favorite.id" @click="showWorldDialog(favorite.id)")
.x-friend-item
template(v-if="favorite.name")
.avatar
img(v-lazy="favorite.thumbnailImageUrl")
.detail
span.name(v-text="favorite.name")
span.extra(v-if="favorite.occupants") {{ favorite.authorName }} ({{ favorite.occupants }})
span.extra(v-else v-text="favorite.authorName")
template(v-else)
.avatar
.detail
span(v-text="favorite.id")

span(style="display:block;margin-top:20px") {{ $t('view.favorite.worlds.vrchat_favorites') }}
el-collapse-item(v-for="group in API.favoriteWorldGroups" :key="group.name")
template(slot="title")
Expand Down

0 comments on commit 0b64416

Please sign in to comment.