コード例 #1
0
    protected void saveInstanceToShortcutGUI(Instance i, bool httpLink = false)
    {
        var sfd = new SaveFileDialog();

        var filename         = i.WorldId;
        var idWithoutWorldId = i.IdWithoutWorldId;

        if (httpLink)
        {
            filename = "web-" + filename;
        }

        if (idWithoutWorldId != "")
        {
            filename += "-";
            filename += idWithoutWorldId;
        }

        filename += ".lnk";

        sfd.FileName = filename;

        sfd.Filter = "Link (*.lnk)|*.lnk|All files (*.*)|*.*";
        sfd.Title  = "Save Instance";

        if (sfd.ShowDialog() != DialogResult.OK)
        {
            return;
        }

        VRChat.SaveInstanceToShortcut(i, sfd.FileName, httpLink);
    }
コード例 #2
0
 protected void showUserDetail(Instance i)
 {
     Process.Start(new ProcessStartInfo()
     {
         FileName        = VRChat.GetUserIdLink(i),
         UseShellExecute = true,
     });
 }
コード例 #3
0
 void inviteMeButtonClick(object sender, EventArgs e)
 {
     if (VRChat.InviteMe(instance, vrcInviteMePath) == 0)
     {
         this.Close();
     }
     else
     {
         MessageBox.Show("Check your vrc-invite-me.exe setting");
     }
 }
コード例 #4
0
    public static void SaveInstanceToShortcut(Instance i, string filepath, bool httpLink = false)
    {
        var     t        = Type.GetTypeFromCLSID(new Guid("72C24DD5-D70A-438B-8A42-98424B88AFB8"));
        dynamic shell    = Activator.CreateInstance(t);
        var     shortcut = shell.CreateShortcut(filepath);

        shortcut.IconLocation = Application.ExecutablePath + ",0";

        if (!httpLink)
        {
            shortcut.TargetPath = VRChat.GetLaunchInstanceLink(i);
        }
        else
        {
            shortcut.TargetPath = VRChat.GetInstanceLink(i);
        }

        shortcut.Save();
        Marshal.FinalReleaseComObject(shortcut);
        Marshal.FinalReleaseComObject(shell);
    }
コード例 #5
0
 void launchVrcButtonClick(object sender, EventArgs e)
 {
     VRChat.Launch(instance, this.killVRC);
 }
コード例 #6
0
ファイル: MainForm.cs プロジェクト: VRCMG/VRChatRejoinTool
    void launchVrcButtonClick(object sender, EventArgs e)
    {
        VRChat.Launch(sortedHistory[index].Instance, killVRC);

        this.Close();
    }
コード例 #7
0
 protected void copyInstanceLinkToClipboard(Instance i)
 {
     Clipboard.SetText(VRChat.GetInstanceLink(i));
 }
コード例 #8
0
ファイル: Program.cs プロジェクト: sksat/VRChatRejoinTool
    public static void Main(string[] Args)
    {
        List <Visit> visitHistory = new List <Visit>();

        // Arguments
        List <string> userSelectedLogFiles = new List <string>();
        List <string> ignoreWorldIds       = new List <string>();

        string vrcInviteMePath = FindInPath("vrc-invite-me.exe");

        bool
            ignorePublic  = false,
            noDialog      = false,
            killVRC       = false,
            noGUI         = false,
            quickSave     = false,
            quickSaveHTTP = false,
            inviteMe      = false;

        int
            ignoreByTimeMins = 0,
            index            = 0;

        Match match;
        Regex ignoreWorldsArgRegex = new Regex(@"\A--ignore-worlds=wrld_.+(,wrld_.+)?\z");
        Regex ignoreByTimeRegex    = new Regex(@"\A--ignore-by-time=\d+\z");
        Regex indexRegex           = new Regex(@"\A--index=\d+\z");

        /*\
        |*| Parse arguments
        \*/
        foreach (string arg in Args)
        {
            if (arg == "--quick-save")
            {
                quickSave = true;
                continue;
            }

            if (arg == "--quick-save-http")
            {
                quickSaveHTTP = true;
                continue;
            }

            if (arg == "--no-gui")
            {
                noGUI = true;
                continue;
            }

            if (arg == "--kill-vrc")
            {
                killVRC = true;
                continue;
            }

            if (arg == "--ignore-public")
            {
                ignorePublic = true;
                continue;
            }

            if (arg == "--no-dialog")
            {
                noDialog = true;
                continue;
            }

            if (arg == "--invite-me")
            {
                inviteMe = true;
                continue;
            }

            match = indexRegex.Match(arg);
            if (match.Success)
            {
                index = int.Parse(arg.Split('=')[1]);
                continue;
            }

            match = ignoreWorldsArgRegex.Match(arg);
            if (match.Success)
            {
                foreach (string world in arg.Split('=')[1].Split(','))
                {
                    ignoreWorldIds.Add(world);
                }

                continue;
            }

            match = ignoreByTimeRegex.Match(arg);
            if (match.Success)
            {
                ignoreByTimeMins = int.Parse(arg.Split('=')[1]);
                continue;
            }

            if (!File.Exists(arg))
            {
                showMessage(
                    "Unknown option or invalid file.: " + arg,
                    noGUI && noDialog
                    );

                return;
            }

            userSelectedLogFiles.Add(arg);
        }

        if (inviteMe && vrcInviteMePath == null)
        {
            showMessage("Failed to find vrc-invite-me.exe", noGUI && noDialog);
            return;
        }

        if (quickSave && quickSaveHTTP)
        {
            showMessage(
                "The combination of --quick-save and --quick-save-http cannot be used.",
                noGUI && noDialog
                );

            return;
        }


        /*\
        |*| Read logfiles
        |*|  (Find logfiles by AppData if userSelectedLogFiles is empty)
        \*/
        if (userSelectedLogFiles.Any())
        {
            foreach (string filepath in userSelectedLogFiles)
            {
                using (
                    FileStream stream = new FileStream(
                        filepath,
                        FileMode.Open,
                        FileAccess.Read,
                        FileShare.ReadWrite
                        )
                    ) {
                    readLogfile(stream, visitHistory);
                }
            }
        }
        else
        {
            IEnumerable <FileInfo> logfiles = getLogFiles();

            if (logfiles == null)
            {
                showMessage("Failed to lookup VRChat log directory.", noGUI && noDialog);
                return;
            }

            if (!logfiles.Any())
            {
                showMessage("Could not find VRChat log.", noGUI && noDialog);
                return;
            }

            foreach (FileInfo logfile in logfiles)
            {
                using (
                    FileStream stream = logfile.Open(
                        FileMode.Open,
                        FileAccess.Read,
                        FileShare.ReadWrite
                        )
                    ) {
                    readLogfile(stream, visitHistory);
                }
            }
        }

        /*\
        |*| Filter and Sort
        \*/
        DateTime     compDate           = DateTime.Now.AddMinutes(ignoreByTimeMins * -1);
        List <Visit> sortedVisitHistory = visitHistory.Where(
            v => (
                !ignorePublic
                ||
                (
                    v.Instance.Permission != Permission.Public
                    &&
                    v.Instance.Permission != Permission.PublicWithIdentifier
                    &&
                    v.Instance.Permission != Permission.Unknown
                )
                )
            &&
            (
                ignoreByTimeMins == 0
                ||
                compDate < v.DateTime
            )
            &&
            !ignoreWorldIds.Contains(v.Instance.WorldId)
            ).OrderByDescending(
            v => v.DateTime
            ).ToList();

        if (!sortedVisitHistory.Any())
        {
            showMessage("Could not find visits from VRChat log.", noGUI && noDialog);
            return;
        }

        /*\
        |*| Action
        \*/
        if (noGUI)
        {
            if (index >= sortedVisitHistory.Count)
            {
                showMessage("Out of bounds index: " + index.ToString(), noDialog);
                return;
            }

            var v = sortedVisitHistory[index];
            var i = v.Instance;

            if (quickSave || quickSaveHTTP)
            {
                string saveDir = Path.GetDirectoryName(
                    Assembly.GetExecutingAssembly().Location
                    ) + @"\saves";

                try {
                    if (!Directory.Exists(saveDir))
                    {
                        Directory.CreateDirectory(saveDir);
                    }
                } catch (Exception e) {
                    showMessage(
                        "[QuickSave] Make Directory:\n" + e.Message,
                        noDialog
                        );

                    throw e;
                }

                string instanceString   = i.WorldId;
                string idWithoutWorldId = i.IdWithoutWorldId;

                if (idWithoutWorldId != "")
                {
                    instanceString += "-";
                    instanceString += idWithoutWorldId;
                }

                var existsLinks = new DirectoryInfo(saveDir).EnumerateFiles(
                    quickSaveHTTP ? "web-*.lnk" : "*.lnk"
                    );

                foreach (FileInfo link in existsLinks)
                {
                    if (quickSave && link.Name.StartsWith("web-"))
                    {
                        continue;
                    }

                    if (link.Name.EndsWith(instanceString + ".lnk"))
                    {
                        File.SetLastWriteTime(link.FullName, DateTime.Now);
                        return;
                    }
                }

                string filepath = string.Format(
                    @"{0}\{3}{1}{2}.lnk",
                    saveDir,
                    v.DateTime.ToString("yyyyMMdd-hhmmss-"),
                    instanceString,
                    quickSaveHTTP ? "web-" : string.Empty
                    );

                try {
                    VRChat.SaveInstanceToShortcut(i, filepath, quickSaveHTTP);
                } catch (Exception e) {
                    showMessage(
                        "[QuickSave] Create Shortcut:\n" + e.Message,
                        noDialog
                        );

                    throw e;
                }
            }
            else if (inviteMe)
            {
                if (VRChat.InviteMe(i, vrcInviteMePath) != 0)
                {
                    showMessage(
                        "Check your vrc-invite-me.exe settings",
                        noDialog
                        );
                }
            }
            else
            {
                VRChat.Launch(i, killVRC);
            }
        }
        else
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(
                new MainForm(sortedVisitHistory, killVRC, vrcInviteMePath)
                );
        }
    }