Skip to content

Commit

Permalink
v2019.11.18
Browse files Browse the repository at this point in the history
  • Loading branch information
pypy committed Nov 18, 2019
1 parent 6365582 commit 149a211
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 35 deletions.
36 changes: 34 additions & 2 deletions VRCX.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
// For a copy, see <https://opensource.org/licenses/MIT>.

using CefSharp;
using Microsoft.Win32;
using System;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;

namespace VRCX
Expand Down Expand Up @@ -39,17 +43,45 @@ public bool IsGameRunning()
return WinApi.FindWindow("UnityWndClass", "VRChat") != IntPtr.Zero;
}

public void StartGame(string location)
public void StartGame(string location, bool desktop)
{
try
{
System.Diagnostics.Process.Start("vrchat://launch?id=" + location);
using (var key = Registry.ClassesRoot.OpenSubKey(@"VRChat\shell\open\command"))
{
// "C:\Program Files (x86)\Steam\steamapps\common\VRChat\launch.bat" "C:\Program Files (x86)\Steam\steamapps\common\VRChat" "%1"
var match = Regex.Match(key.GetValue(string.Empty) as string, "^\"(.+\\\\VRChat)\\\\launch.bat\"");
if (match.Success)
{
var path = match.Groups[1].Value;
var args = new StringBuilder();
if (desktop)
{
args.Append("--no-vr ");
}
args.Append("\"vrchat://launch?id=");
args.Append(location);
args.Append('"');
Process.Start(new ProcessStartInfo
{
WorkingDirectory = path,
FileName = path + "\\VRChat.exe",
UseShellExecute = false,
Arguments = args.ToString()
}).Close();
}
}
}
catch
{
}
}

public void OpenRepository()
{
Process.Start("https://github.com/pypy-vrc/VRCX").Close();
}

public void ShowVRForm()
{
try
Expand Down
24 changes: 19 additions & 5 deletions html/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ For a copy, see <https://opensource.org/licenses/MIT>.
padding: 20px;
}

.el-dialog__footer>.el-button+.el-button {
margin-left: 5px;
}

::-webkit-scrollbar {
width: 8px;
height: 8px;
Expand Down Expand Up @@ -135,14 +139,24 @@ body, input, textarea, select, button {
border: 0;
}

.el-menu-item.is-active::before {
position: absolute;
content: '';
left: 1px;
top: 4px;
width: 2px;
height: 48px;
background: #DCDFE6;
}

.el-menu-item.notify::after {
position: absolute;
content: '';
right: 5px;
top: 5px;
width: 5px;
height: 5px;
background: #909399;
right: 4px;
top: 4px;
width: 6px;
height: 6px;
background: #EBEEF5;
border-radius: 50%
}

Expand Down
84 changes: 60 additions & 24 deletions html/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,12 @@ if (window.CefSharp) {
setInterval(() => VRCXStorage.Flush(), 5 * 60 * 1000);

Noty.overrideDefaults({
/*
animation: {
open: 'animated bounceInLeft',
close: 'animated bounceOutLeft'
},
*/
layout: 'bottomLeft',
theme: 'mint',
timeout: 6000
Expand Down Expand Up @@ -825,6 +827,8 @@ if (window.CefSharp) {
id: ref.id,
username: '',
displayName: '',
bio: '',
bioLinks: [],
pastDisplayNames: [],
friends: [],
currentAvatarImageUrl: '',
Expand Down Expand Up @@ -938,6 +942,8 @@ if (window.CefSharp) {
id: ref.id,
username: '',
displayName: '',
bio: '',
bioLinks: [],
currentAvatarImageUrl: '',
currentAvatarThumbnailImageUrl: '',
status: '',
Expand Down Expand Up @@ -3471,7 +3477,7 @@ if (window.CefSharp) {
VRCX,
nextRefresh: 0,
isGameRunning: false,
appVersion: '2019.10.31.1',
appVersion: 'VRCX 2019.11.18',
latestAppVersion: '',
ossDialog: false
},
Expand Down Expand Up @@ -3509,6 +3515,17 @@ if (window.CefSharp) {
if (json.name &&
json.published_at) {
this.latestAppVersion = `${json.name} (${formatDate(json.published_at, 'YYYY-MM-DD HH24:MI:SS')})`;
if (json.name > this.appVersion) {
new Noty({
type: 'info',
text: `Update available!!<br>${this.latestAppVersion}`,
timeout: false,
callbacks: {
onClick: () => VRCX.OpenRepository()
}
}).show();
this.notifyMenu('more');
}
} else {
this.latestAppVersion = 'Error occured';
}
Expand Down Expand Up @@ -3653,28 +3670,6 @@ if (window.CefSharp) {
}
};

$app.methods.showLaunchDialog = function (tag) {
var L = API.parseLocation(tag);
if (L.worldId) {
this.$msgbox({
title: 'Launch World',
message: `<span style="word-break:break-all;font-size:12px">${escapeTag(`https://vrchat.net/launch?worldId=${encodeURIComponent(L.worldId)}&instanceId=${encodeURIComponent(L.instanceId)}`)}</span>`,
dangerouslyUseHTMLString: true,
distinguishCancelAndClose: true,
showCancelButton: true,
cancelButtonText: 'Invite',
confirmButtonText: 'Launch',
callback: (action) => {
if (action === 'confirm') {
VRCX.StartGame(tag);
} else if (action === 'cancel') {
$app.showInviteDialog(tag);
}
}
});
}
};

$app.methods.promptTOTP = function () {
this.$prompt('Enter a numeric code from your authenticator app', 'Two-factor Authentication', {
distinguishCancelAndClose: true,
Expand Down Expand Up @@ -6834,7 +6829,7 @@ if (window.CefSharp) {
$app.watch['newInstanceDialog.instanceId'] = updateLocationURL;

$app.methods.showNewInstanceDialog = function (tag) {
this.$nextTick(() => adjustDialogZ(this.$refs.inviteDialog.$el));
this.$nextTick(() => adjustDialogZ(this.$refs.newInstanceDialog.$el));
var L = API.parseLocation(tag);
if (!(L.isOffline || L.isPrivate) &&
L.worldId) {
Expand Down Expand Up @@ -6867,6 +6862,47 @@ if (window.CefSharp) {
});
};

// App: Launch Dialog

$app.data.launchDialog = {
visible: false,
loading: false,
desktop: VRCXStorage.GetBool('launchAsDesktop'),
location: '',
url: ''
};

$app.watch['launchDialog.desktop'] = function () {
VRCXStorage.SetBool('launchAsDesktop', this.launchDialog.desktop);
};

API.$on('LOGOUT', () => {
$app.launchDialog.visible = false;
});

$app.methods.showLaunchDialog = function (tag) {
this.$nextTick(() => adjustDialogZ(this.$refs.launchDialog.$el));
var L = API.parseLocation(tag);
if (!(L.isOffline || L.isPrivate) &&
L.worldId) {
var D = this.launchDialog;
if (L.instanceId) {
D.location = `${L.worldId}:${L.instanceId}`;
D.url = `https://vrchat.net/launch?worldId=${encodeURIComponent(L.worldId)}&instanceId=${encodeURIComponent(L.instanceId)}`;
} else {
D.location = L.worldId;
D.url = `https://vrchat.net/launch?worldId=${encodeURIComponent(L.worldId)}`;
}
D.visible = true;
}
};

$app.methods.launchGame = function () {
var D = this.launchDialog;
VRCX.StartGame(D.location, D.desktop);
D.visible = false;
};

$app = new Vue($app);
window.$app = $app;
});
Expand Down
18 changes: 14 additions & 4 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@
<span v-if="scope.row.type === 'DisplayName'">{{ scope.row.previousDisplayName }}&nbsp;<i class="el-icon-right"></i>&nbsp;</span>
<span v-text="scope.row.displayName || scope.row.userId" @click="showUserDialog(scope.row.userId)" class="x-link"></span>
<template v-if="scope.row.type === 'TrustLevel'">
<br/><span>({{ scope.row.previousTrustLevel }}&nbsp;<i class="el-icon-right"></i>&nbsp;{{ scope.row.trustLevel }})</span>
<br><span>({{ scope.row.previousTrustLevel }}&nbsp;<i class="el-icon-right"></i>&nbsp;{{ scope.row.trustLevel }})</span>
</template>
</template>
</el-table-column>
Expand Down Expand Up @@ -549,7 +549,7 @@
<span v-else class="extra">Click to refresh</span>
</div>
</div>
<div class="x-friend-item">
<div class="x-friend-item" @click="VRCX.OpenRepository()">
<div class="detail">
<span class="name">Repository URL</span>
<span class="extra">https://github.com/pypy-vrc/VRCX</span>
Expand Down Expand Up @@ -669,7 +669,7 @@
<div class="x-friend-item">
<div class="detail" @click="API.getVisits()">
<span class="name">Online Users</span>
<span v-if="visits" class="extra">{{visits}} Users online.</span>
<span v-if="visits" class="extra">{{visits}} users online.</span>
<span v-else class="extra">Click to refresh</span>
</div>
</div>
Expand Down Expand Up @@ -1417,7 +1417,17 @@
<template #footer>
<el-button size="small" @click="makeHome(newInstanceDialog.location)">Make Home</el-button>
<el-button size="small" @click="showInviteDialog(newInstanceDialog.location)">Invite</el-button>
<el-button type="primary" size="small" @click="VRCX.StartGame(newInstanceDialog.location)">Launch</el-button>
<el-button type="primary" size="small" @click="showLaunchDialog(newInstanceDialog.location)">Launch</el-button>
</template>
</el-dialog>

<!-- dialog: launch -->
<el-dialog ref="launchDialog" :visible.sync="launchDialog.visible" title="Launch" width="400px" class="x-dialog">
<div><span v-text="launchDialog.url" style="word-break:break-all;font-size:12px"></span></div>
<template #footer>
<el-checkbox v-model="launchDialog.desktop" style="float:left;margin-top:5px">Start as Desktop (No VR)</el-checkbox>
<el-button size="small" @click="showInviteDialog(launchDialog.location)">Invite</el-button>
<el-button type="primary" size="small" @click="launchGame()">Launch</el-button>
</template>
</el-dialog>

Expand Down

0 comments on commit 149a211

Please sign in to comment.