Пример #1
0
    public void MenuUser(MenuStack menuStack)
    {
        bool isSignedInPSN = User.IsSignedInPSN;

        menuUser.Update();
        if (menuUser.AddItem("Get My Profile", !User.IsUserProfileBusy) && User.RequestUserProfile() != 0)
        {
            ResultCode result = default(ResultCode);
            User.GetLastUserProfileError(out result);
            OnScreenLog.Add(result.className + ": " + result.lastError + ", sce error 0x" + result.lastErrorSCE.ToString("X8"));
        }
        if (menuUser.AddItem("Get Remote Profile (onlineID)", isSignedInPSN && !User.IsUserProfileBusy) && User.RequestRemoteUserProfileForOnlineID(remoteOnlineID) != 0)
        {
            ResultCode result2 = default(ResultCode);
            User.GetLastUserProfileError(out result2);
            OnScreenLog.Add(result2.className + ": " + result2.lastError + ", sce error 0x" + result2.lastErrorSCE.ToString("X8"));
        }
        if (menuUser.AddItem("Get Remote NpID", isSignedInPSN && !User.IsUserProfileBusy) && User.RequestRemoteUserNpID(remoteOnlineID) != 0)
        {
            ResultCode result3 = default(ResultCode);
            User.GetLastUserProfileError(out result3);
            OnScreenLog.Add(result3.className + ": " + result3.lastError + ", sce error 0x" + result3.lastErrorSCE.ToString("X8"));
        }
        if (menuUser.AddItem("Get Remote Profile (npID)", remoteNpID != null && isSignedInPSN && !User.IsUserProfileBusy) && User.RequestRemoteUserProfileForNpID(remoteNpID) != 0)
        {
            ResultCode result4 = default(ResultCode);
            User.GetLastUserProfileError(out result4);
            OnScreenLog.Add(result4.className + ": " + result4.lastError + ", sce error 0x" + result4.lastErrorSCE.ToString("X8"));
        }
        if (menuUser.AddBackIndex("Back"))
        {
            menuStack.PopMenu();
        }
    }
    public void Process(MenuStack stack)
    {
        bool enabled = User.IsSignedInPSN && sessionCreated && !Commerce.IsBusy();

        menu.Update();
        if (menu.AddItem("Category Info", enabled))
        {
            SonyNpCommerce.ErrorHandler(Commerce.RequestCategoryInfo(string.Empty));
        }
        if (menu.AddItem("Product List", enabled))
        {
            SonyNpCommerce.ErrorHandler(Commerce.RequestProductList(testCategoryID));
        }
        if (menu.AddItem("Product Info", enabled))
        {
            SonyNpCommerce.ErrorHandler(Commerce.RequestDetailedProductInfo(testProductID));
        }
        if (menu.AddItem("Browse Product", enabled))
        {
            SonyNpCommerce.ErrorHandler(Commerce.BrowseProduct(testProductID));
        }
        if (menu.AddItem("Checkout", enabled))
        {
            Commerce.GetProductList();
            SonyNpCommerce.ErrorHandler(Commerce.Checkout(testProductSkuIDs));
        }
        if (menu.AddItem("Redeem Voucher", enabled))
        {
            SonyNpCommerce.ErrorHandler(Commerce.VoucherInput());
        }
        if (menu.AddBackIndex("Back"))
        {
            stack.PopMenu();
        }
    }
Пример #3
0
    public void Process(MenuStack stack)
    {
        bool enabled = User.IsSignedInPSN && !Commerce.IsBusy();

        menu.Update();
        if (menu.AddItem("Store", enabled))
        {
            stack.PushMenu(store.GetMenu());
        }
        if (menu.AddItem("In Game Store"))
        {
            stack.PushMenu(inGameStore.GetMenu());
        }
        if (menu.AddItem("Downloads"))
        {
            Commerce.DisplayDownloadList();
        }
        if (menu.AddItem("Entitlements"))
        {
            stack.PushMenu(entitlements.GetMenu());
        }
        if (menu.AddItem("Find Installed Content"))
        {
            EnumerateDRMContent();
        }
        if (menu.AddBackIndex("Back"))
        {
            stack.PopMenu();
        }
    }
Пример #4
0
    public void Process(MenuStack stack)
    {
        menuTicketing.Update();
        bool enabled = User.IsSignedInPSN && !Ticketing.IsBusy();

        if (menuTicketing.AddItem("Request Ticket", enabled))
        {
            ErrorHandler(Ticketing.RequestTicket());
        }
        if (menuTicketing.AddItem("Request Cached Ticket", enabled))
        {
            ErrorHandler(Ticketing.RequestCachedTicket());
        }
        if (menuTicketing.AddItem("Get Ticket Entitlements", gotTicket))
        {
            Ticketing.TicketEntitlement[] ticketEntitlements = Ticketing.GetTicketEntitlements(ticket);
            OnScreenLog.Add("Ticket contains " + ticketEntitlements.Length + " entitlements");
            for (int i = 0; i < ticketEntitlements.Length; i++)
            {
                OnScreenLog.Add("Entitlement " + i);
                OnScreenLog.Add(" " + ticketEntitlements[i].id + " rc: " + ticketEntitlements[i].remainingCount + " cc: " + ticketEntitlements[i].consumedCount + " type: " + ticketEntitlements[i].type);
            }
        }
        if (menuTicketing.AddBackIndex("Back"))
        {
            stack.PopMenu();
        }
    }
Пример #5
0
 public void Process(MenuStack stack)
 {
     menu.Update();
     if (menu.AddBackIndex("Back"))
     {
         stack.PopMenu();
     }
 }
Пример #6
0
    private void MenuMain()
    {
        menuMain.Update();
        bool isSignedInPSN = User.IsSignedInPSN;

        if (!npReady)
        {
            return;
        }
        if (!isSignedInPSN && menuMain.AddItem("Sign In To PSN", npReady))
        {
            OnScreenLog.Add("Begin sign in");
            User.SignIn();
        }
        if (menuMain.AddItem("Trophies"))
        {
            menuStack.PushMenu(trophies.GetMenu());
        }
        if (menuMain.AddItem("User"))
        {
            menuStack.PushMenu(user.GetMenu());
        }
        if (menuMain.AddItem("Utilities, Dialogs & Auth"))
        {
            menuStack.PushMenu(utilities.GetMenu());
        }
        if (isSignedInPSN)
        {
            if (menuMain.AddItem("Friends & SNS", isSignedInPSN))
            {
                menuStack.PushMenu(friends.GetMenu());
            }
            if (menuMain.AddItem("Ranking", isSignedInPSN))
            {
                menuStack.PushMenu(ranking.GetMenu());
            }
            if (menuMain.AddItem("Matching", isSignedInPSN))
            {
                menuStack.PushMenu(sessions.GetMenu());
            }
            if (menuMain.AddItem("Messaging", isSignedInPSN))
            {
                menuStack.PushMenu(messaging.GetMenu());
            }
            if (menuMain.AddItem("Cloud Storage (TUS/TSS)", isSignedInPSN))
            {
                menuStack.PushMenu(cloudStorage.GetMenu());
            }
            if (menuMain.AddItem("Commerce", isSignedInPSN))
            {
                menuStack.PushMenu(commerce.GetMenu());
            }
        }
    }
Пример #7
0
    public void Process(MenuStack stack)
    {
        bool enabled = User.IsSignedInPSN && !Commerce.IsBusy();

        menu.Update();
        if (menu.AddItem("Browse Category", enabled))
        {
            SonyNpCommerce.ErrorHandler(Commerce.BrowseCategory(string.Empty));
        }
        if (menu.AddBackIndex("Back"))
        {
            stack.PopMenu();
        }
    }
Пример #8
0
 public void MenuCloud(MenuStack stack)
 {
     menuCloud.Update();
     if (menuCloud.AddItem("Title User Storage"))
     {
         stack.PushMenu(tus.GetMenu());
     }
     if (menuCloud.AddItem("Title Small Storage"))
     {
         stack.PushMenu(tss.GetMenu());
     }
     if (menuCloud.AddBackIndex("Back"))
     {
         stack.PopMenu();
     }
 }
Пример #9
0
 public void MenuFriends(MenuStack menuStack)
 {
     menuFriends.Update();
     if (menuFriends.AddItem("Friends", User.IsSignedInPSN && !Friends.FriendsListIsBusy()))
     {
         ErrorHandlerFriends(Friends.RequestFriendsList());
     }
     if (menuFriends.AddItem("Set Presence", User.IsSignedInPSN && !User.OnlinePresenceIsBusy()))
     {
         ErrorHandlerPresence(User.SetOnlinePresence("Testing UnityNpToolkit"));
     }
     if (menuFriends.AddItem("Clear Presence", User.IsSignedInPSN && !User.OnlinePresenceIsBusy()))
     {
         ErrorHandlerPresence(User.SetOnlinePresence(string.Empty));
     }
     if (menuFriends.AddItem("Post On Facebook", User.IsSignedInPSN && !Facebook.IsBusy()))
     {
         Facebook.PostFacebook message = default(Facebook.PostFacebook);
         message.appID            = 701792156521339L;
         message.userText         = "I'm testing Unity's facebook integration !";
         message.photoURL         = "http://uk.playstation.com/media/RZXT_744/159/PlayStationNetworkFeaturedImage.jpg";
         message.photoTitle       = "Title";
         message.photoCaption     = "This is the caption";
         message.photoDescription = "This is the description";
         message.actionLinkName   = "Go To Unity3d.com";
         message.actionLinkURL    = "http://unity3d.com/";
         ErrorHandlerFacebook(Facebook.PostMessage(message));
     }
     if (menuFriends.AddItem("Post On Twitter", User.IsSignedInPSN && !Twitter.IsBusy()))
     {
         Twitter.PostTwitter message2 = default(Twitter.PostTwitter);
         message2.userText             = "I'm testing Unity's Twitter integration !";
         message2.imagePath            = Application.streamingAssetsPath + "/TweetUnity.png";
         message2.forbidAttachPhoto    = false;
         message2.disableEditTweetMsg  = true;
         message2.forbidOnlyImageTweet = false;
         message2.forbidNoImageTweet   = false;
         message2.disableChangeImage   = false;
         message2.limitToScreenShot    = true;
         ErrorHandlerTwitter(Twitter.PostMessage(message2));
     }
     if (menuFriends.AddBackIndex("Back"))
     {
         menuStack.PopMenu();
     }
 }
Пример #10
0
 public void MenuUtilities(MenuStack menuStack)
 {
     menu.Update();
     if (menu.AddItem("Get Network Time", Sony.NP.System.IsConnected))
     {
         DateTime dateTime = new DateTime(Sony.NP.System.GetNetworkTime(), DateTimeKind.Utc);
         OnScreenLog.Add("networkTime: " + dateTime.ToLongDateString() + " - " + dateTime.ToLongTimeString());
     }
     if (menu.AddItem("Bandwidth", Sony.NP.System.IsConnected && !Sony.NP.System.RequestBandwidthInfoIsBusy()))
     {
         ErrorHandlerSystem(Sony.NP.System.RequestBandwidthInfo());
     }
     if (menu.AddItem("Net Info", !Sony.NP.System.RequestBandwidthInfoIsBusy()))
     {
         ErrorHandlerSystem(Sony.NP.System.RequestNetInfo());
     }
     if (menu.AddItem("Net Device Type"))
     {
         Sony.NP.System.NetDeviceType networkDeviceType = Sony.NP.System.GetNetworkDeviceType();
         OnScreenLog.Add("Network device: " + networkDeviceType);
     }
     if (User.IsSignedInPSN)
     {
         if (menu.AddItem("Dialogs"))
         {
             menuStack.PushMenu(dialogs.GetMenu());
         }
         if (menu.AddItem("Auth Ticketing"))
         {
             menuStack.PushMenu(ticketing.GetMenu());
         }
         if (menu.AddItem("Censor Bad Comment", Sony.NP.System.IsConnected && !WordFilter.IsBusy()))
         {
             WordFilter.CensorComment("Censor a shit comment");
         }
         if (menu.AddItem("Sanitize Bad Comment", Sony.NP.System.IsConnected && !WordFilter.IsBusy()))
         {
             WordFilter.SanitizeComment("Sanitize a shit comment");
         }
     }
     if (menu.AddBackIndex("Back"))
     {
         menuStack.PopMenu();
     }
 }
Пример #11
0
    public void MenuTss(MenuStack menuStack)
    {
        menuTss.Update();
        bool enabled = User.IsSignedInPSN && !TusTss.IsTssBusy();

        if (menuTss.AddItem("TSS Request Data", enabled))
        {
            ErrorHandler(TusTss.RequestTssData());
        }
        if (menuTss.AddItem("TSS Request Data from slot", enabled))
        {
            int slot = 1;
            ErrorHandler(TusTss.RequestTssDataFromSlot(slot));
        }
        if (menuTss.AddBackIndex("Back"))
        {
            menuStack.PopMenu();
        }
    }
Пример #12
0
    public void MenuTrophies(MenuStack menuStack)
    {
        menuTrophies.Update();
        bool trophiesAreAvailable = Trophies.TrophiesAreAvailable;

        if (menuTrophies.AddItem("Game Info", trophiesAreAvailable))
        {
            DumpGameInfo();
        }
        if (menuTrophies.AddItem("Group Info", trophiesAreAvailable && !Trophies.RequestGroupInfoIsBusy()))
        {
            ErrorHandler(Trophies.RequestGroupInfo());
        }
        if (menuTrophies.AddItem("Trophy Info", trophiesAreAvailable && !Trophies.RequestTrophyInfoIsBusy()))
        {
            ErrorHandler(Trophies.RequestTrophyInfo());
        }
        if (menuTrophies.AddItem("Trophy Progress", trophiesAreAvailable && !Trophies.RequestTrophyProgressIsBusy()))
        {
            ErrorHandler(Trophies.RequestTrophyProgress());
        }
        if (menuTrophies.AddItem("Award Trophy", trophiesAreAvailable) && ErrorHandler(Trophies.AwardTrophy(nextTrophyIndex)) == ErrorCode.NP_OK)
        {
            nextTrophyIndex++;
            if (nextTrophyIndex == gameInfo.numTrophies)
            {
                nextTrophyIndex = 1;
            }
        }
        if (menuTrophies.AddItem("Award All Trophies", trophiesAreAvailable))
        {
            for (int i = 1; i < gameInfo.numTrophies; i++)
            {
                ErrorHandler(Trophies.AwardTrophy(i));
            }
        }
        if (menuTrophies.AddBackIndex("Back"))
        {
            menuStack.PopMenu();
        }
    }
Пример #13
0
    public void MenuRanking(MenuStack menuStack)
    {
        bool isSignedInPSN = User.IsSignedInPSN;

        rankingMenu.Update();
        if (rankingMenu.AddItem("Register Score", isSignedInPSN && !Ranking.RegisterScoreIsBusy()))
        {
            OnScreenLog.Add("Registering score: " + currentScore);
            ErrorHandler(Ranking.RegisterScore(rankBoardID, currentScore, "Insert comment here"));
            currentScore++;
        }
        if (rankingMenu.AddItem("Register score & data", isSignedInPSN && !Ranking.RegisterScoreIsBusy()))
        {
            OnScreenLog.Add("Registering score: " + currentScore);
            byte[] array = new byte[64];
            for (byte b = 0; b < 64; b = (byte)(b + 1))
            {
                array[b] = b;
            }
            ErrorHandler(Ranking.RegisterScoreWithData(rankBoardID, currentScore, "Insert comment here", array));
            currentScore++;
        }
        if (rankingMenu.AddItem("Own Rank", isSignedInPSN && !Ranking.RefreshOwnRankIsBusy()))
        {
            ErrorHandler(Ranking.RefreshOwnRank(rankBoardID));
        }
        if (rankingMenu.AddItem("Friend Rank", isSignedInPSN && !Ranking.RefreshFriendRankIsBusy()))
        {
            ErrorHandler(Ranking.RefreshFriendRank(rankBoardID));
        }
        if (rankingMenu.AddItem("Rank List", isSignedInPSN && !Ranking.RefreshRankListIsBusy()))
        {
            int num   = LastRankDisplayed + 1;
            int count = Math.Min(10, LastRankingMaxCount - num + 1);
            ErrorHandler(Ranking.RefreshRankList(rankBoardID, num, count));
        }
        if (rankingMenu.AddBackIndex("Back"))
        {
            menuStack.PopMenu();
        }
    }
Пример #14
0
    public void Process(MenuStack stack)
    {
        menu.Update();
        bool enabled = User.IsSignedInPSN && !Dialogs.IsDialogOpen;

        if (menu.AddItem("Friends Dialog", enabled))
        {
            ErrorHandler(Dialogs.FriendsList());
        }
        if (menu.AddItem("Shared History Dialog", enabled))
        {
            ErrorHandler(Dialogs.SharedPlayHistory());
        }
        if (menu.AddItem("Profile Dialog", enabled))
        {
            ErrorHandler(Dialogs.Profile(User.GetCachedUserProfile().npID));
        }
        if (menu.AddBackIndex("Back"))
        {
            stack.PopMenu();
        }
    }
Пример #15
0
 public void MenuMessaging(MenuStack menuStack)
 {
     menuMessaging.Update();
     if (menuMessaging.AddItem("Show Messages & Invites", User.IsSignedInPSN && !Messaging.IsBusy()))
     {
         Messaging.ShowRecievedDataMessageDialog();
     }
     if (menuMessaging.AddItem("Send Session Invite", User.IsSignedInPSN && Matching.InSession))
     {
         string text      = "Join my session";
         int    npIDCount = 8;
         Matching.InviteToSession(text, npIDCount);
     }
     if (menuMessaging.AddItem("Send Game Invite", User.IsSignedInPSN && !Messaging.IsBusy()))
     {
         GameInviteData gameInviteData = new GameInviteData();
         gameInviteData.taunt = "I got an awesome score, can you do better?";
         gameInviteData.level = 1;
         gameInviteData.score = 123456789;
         byte[] data = gameInviteData.WriteToBuffer();
         Messaging.MsgRequest msgRequest = new Messaging.MsgRequest();
         msgRequest.body          = "Game invite";
         msgRequest.expireMinutes = 30;
         msgRequest.data          = data;
         msgRequest.npIDCount     = 8;
         string dataDescription = "Some data to test invite messages";
         string dataName        = "Test data";
         msgRequest.dataDescription = dataDescription;
         msgRequest.dataName        = dataName;
         msgRequest.iconPath        = Application.streamingAssetsPath + "/PSP2SessionImage.jpg";
         Messaging.SendMessage(msgRequest);
     }
     if (menuMessaging.AddItem("Send Data Message", User.IsSignedInPSN && !Messaging.IsBusy()))
     {
         GameData gameData = default(GameData);
         gameData.text  = "Here's some data";
         gameData.item1 = 2;
         gameData.item2 = 987654321;
         byte[] data2 = gameData.WriteToBuffer();
         Messaging.MsgRequest msgRequest2 = new Messaging.MsgRequest();
         msgRequest2.body          = "Data message";
         msgRequest2.expireMinutes = 0;
         msgRequest2.data          = data2;
         msgRequest2.npIDCount     = 8;
         string dataDescription2 = "Some data to test messages";
         string dataName2        = "Test data";
         msgRequest2.dataDescription = dataDescription2;
         msgRequest2.dataName        = dataName2;
         msgRequest2.iconPath        = Application.streamingAssetsPath + "/PSP2SessionImage.jpg";
         Messaging.SendMessage(msgRequest2);
     }
     if (menuMessaging.AddItem("Send In Game Data (Session)", Matching.InSession && !Messaging.IsBusy()))
     {
         Matching.Session             session = Matching.GetSession();
         Matching.SessionMemberInfo[] members = session.members;
         if (members == null)
         {
             return;
         }
         int num = -1;
         for (int i = 0; i < members.Length; i++)
         {
             if ((members[i].memberFlag & Matching.FlagMemberType.MEMBER_MYSELF) == 0)
             {
                 num = i;
                 break;
             }
         }
         if (num >= 0)
         {
             OnScreenLog.Add("Sending in game data message to " + members[num].npOnlineID);
             GameData gameData2 = default(GameData);
             gameData2.text  = "Here's some data";
             gameData2.item1 = 2;
             gameData2.item2 = 987654321;
             byte[] data3 = gameData2.WriteToBuffer();
             Messaging.SendInGameDataMessage(members[num].npID, data3);
         }
         else
         {
             OnScreenLog.Add("No session member to send to.");
         }
     }
     if (menuMessaging.AddItem("Send In Game Message (Friend)", User.IsSignedInPSN && !Messaging.IsBusy()))
     {
         Friends.Friend[] cachedFriendsList = Friends.GetCachedFriendsList();
         if (cachedFriendsList.Length > 0)
         {
             int num2 = 0;
             if (num2 >= 0)
             {
                 OnScreenLog.Add("Sending in game data message to " + cachedFriendsList[num2].npOnlineID);
                 GameData gameData3 = default(GameData);
                 gameData3.text  = "Here's some data";
                 gameData3.item1 = 2;
                 gameData3.item2 = 987654321;
                 byte[] data4 = gameData3.WriteToBuffer();
                 Messaging.SendInGameDataMessage(cachedFriendsList[num2].npID, data4);
             }
             else
             {
                 OnScreenLog.Add("No friends in this context.");
             }
         }
         else
         {
             OnScreenLog.Add("No friends cached.");
             OnScreenLog.Add("refresh the friends list then try again.");
         }
     }
     if (menuMessaging.AddBackIndex("Back"))
     {
         menuStack.PopMenu();
     }
 }
Пример #16
0
    public void MenuTus(MenuStack menuStack)
    {
        menuTus.Update();
        bool enabled = User.IsSignedInPSN && !TusTss.IsTusBusy();

        if (menuTus.AddItem("TUS Set Data", enabled))
        {
            byte[] array = new byte[4];
            for (int i = 0; i < 4; i++)
            {
                array[i] = (byte)(3 - i);
            }
            OnScreenLog.Add(" Data size: " + array.Length);
            string text = string.Empty;
            for (int j = 0; j < 16 && j < array.Length; j++)
            {
                text = text + array[j].ToString() + ", ";
            }
            OnScreenLog.Add(" Data: " + text);
            m_TUSDataRequestType = TUSDataRequestType.SaveRawData;
            ErrorHandler(TusTss.SetTusData(1, array));
        }
        if (menuTus.AddItem("TUS Request Data", enabled))
        {
            m_TUSDataRequestType = TUSDataRequestType.LoadRawData;
            ErrorHandler(TusTss.RequestTusData(1));
        }
        if (menuTus.AddItem("TUS Save PlayerPrefs", enabled))
        {
            PlayerPrefs.DeleteAll();
            PlayerPrefs.SetInt("keyA", 1);
            PlayerPrefs.SetString("keyB", "Hello");
            PlayerPrefs.SetInt("keyC", 3);
            PlayerPrefs.SetInt("keyD", 4);
            byte[] data = PSVitaPlayerPrefs.SaveToByteArray();
            m_TUSDataRequestType = TUSDataRequestType.SavePlayerPrefs;
            ErrorHandler(TusTss.SetTusData(3, data));
        }
        if (menuTus.AddItem("TUS Load PlayerPrefs", enabled))
        {
            m_TUSDataRequestType = TUSDataRequestType.LoadPlayerPrefs;
            ErrorHandler(TusTss.RequestTusData(3));
        }
        if (menuTus.AddItem("TUS Set Variables", enabled))
        {
            ErrorHandler(TusTss.SetTusVariables(new TusTss.TusVariable[4]
            {
                new TusTss.TusVariable(1, 110L),
                new TusTss.TusVariable(2, 220L),
                new TusTss.TusVariable(3, 330L),
                new TusTss.TusVariable(4, 440L)
            }));
        }
        if (menuTus.AddItem("TUS Request Variables", enabled))
        {
            int[] slotIDs = new int[4]
            {
                1,
                2,
                3,
                4
            };
            ErrorHandler(TusTss.RequestTusVariables(slotIDs));
        }
        if (menuTus.AddItem("TUS Set Variables VU", enabled))
        {
            ErrorHandler(TusTss.SetTusVariablesForVirtualUser(variables: new TusTss.TusVariable[1]
            {
                new TusTss.TusVariable(5, 12345L)
            }, onlineID: virtualUserOnlineID));
        }
        if (menuTus.AddItem("TUS Request Variables VU", enabled))
        {
            int[] slotIDs2 = new int[1]
            {
                5
            };
            ErrorHandler(TusTss.RequestTusVariablesForVirtualUser(virtualUserOnlineID, slotIDs2));
        }
        if (menuTus.AddItem("TUS Modify Variables VU", enabled))
        {
            ErrorHandler(TusTss.ModifyTusVariablesForVirtualUser(variables: new TusTss.TusVariable[1]
            {
                new TusTss.TusVariable(5, 1L)
            }, onlineID: virtualUserOnlineID));
        }
        if (menuTus.AddBackIndex("Back"))
        {
            menuStack.PopMenu();
        }
    }
Пример #17
0
    public void MenuInSession(MenuStack menuStack)
    {
        bool       isSignedInPSN = User.IsSignedInPSN;
        bool       inSession     = Matching.InSession;
        bool       sessionIsBusy = Matching.SessionIsBusy;
        bool       isHost        = Matching.IsHost;
        MenuLayout menuLayout    = (!isHost) ? menuInSessionClient : menuInSessionHosting;

        menuLayout.Update();
        if (isHost && menuLayout.AddItem("Modify Session", isSignedInPSN && inSession && !sessionIsBusy))
        {
            OnScreenLog.Add("Modifying session...");
            Matching.ClearModifySessionAttributes();
            gameDetails += 100;
            Matching.ModifySessionAttribute modifySessionAttribute = new Matching.ModifySessionAttribute();
            modifySessionAttribute.name     = "GAME_DETAILS";
            modifySessionAttribute.intValue = gameDetails;
            Matching.AddModifySessionAttribute(modifySessionAttribute);
            ErrorHandler(Matching.ModifySession(Matching.EnumAttributeType.SESSION_INTERNAL_ATTRIBUTE));
        }
        if (menuLayout.AddItem("Modify Member Attribute", isSignedInPSN && inSession && !sessionIsBusy))
        {
            OnScreenLog.Add("Modifying Member Attribute...");
            Matching.ClearModifySessionAttributes();
            Matching.ModifySessionAttribute modifySessionAttribute2 = new Matching.ModifySessionAttribute();
            modifySessionAttribute2.name = "CAR_TYPE";
            cartype++;
            if (cartype > 3)
            {
                cartype = 0;
            }
            switch (cartype)
            {
            case 0:
                modifySessionAttribute2.binValue = "CATMOB";
                break;

            case 1:
                modifySessionAttribute2.binValue = "CARTYPE1";
                break;

            case 2:
                modifySessionAttribute2.binValue = "CARTYPE2";
                break;

            case 3:
                modifySessionAttribute2.binValue = "CARTYPE3";
                break;
            }
            modifySessionAttribute2.intValue = gameDetails;
            Matching.AddModifySessionAttribute(modifySessionAttribute2);
            ErrorHandler(Matching.ModifySession(Matching.EnumAttributeType.SESSION_MEMBER_ATTRIBUTE));
        }
        if (!sendingData)
        {
            if (menuLayout.AddItem("Start Sending Data", isSignedInPSN && inSession && !sessionIsBusy))
            {
                sendingData = true;
            }
        }
        else if (menuLayout.AddItem("Stop Sending Data", isSignedInPSN && inSession && !sessionIsBusy))
        {
            sendingData = false;
        }
        if (menuLayout.AddItem("Leave Session", isSignedInPSN && inSession && !sessionIsBusy))
        {
            OnScreenLog.Add("Leaving session...");
            ErrorHandler(Matching.LeaveSession());
        }
        if (menuLayout.AddItem("List session members", isSignedInPSN && inSession && !sessionIsBusy))
        {
            Matching.Session             session = Matching.GetSession();
            Matching.SessionMemberInfo[] members = session.members;
            for (int i = 0; i < members.Length; i++)
            {
                Matching.SessionMemberInfo sessionMemberInfo = members[i];
                string msg = i + "/memberId:" + sessionMemberInfo.memberId + "/memberFlag:" + sessionMemberInfo.memberFlag + "/addr:" + sessionMemberInfo.addr + "/natType:" + sessionMemberInfo.natType + "/port:" + sessionMemberInfo.port;
                OnScreenLog.Add(msg);
            }
        }
        if (menuLayout.AddItem("Invite Friend", isSignedInPSN && inSession && !sessionIsBusy))
        {
            OnScreenLog.Add("Invite Friend...");
            ErrorHandler(Matching.InviteToSession("Invite Test", 8));
        }
        if (menuLayout.AddBackIndex("Back"))
        {
            menuStack.PopMenu();
        }
        if (Matching.IsHost)
        {
            NetworkPlayer[] connections = Network.connections;
            GUI.Label(new Rect(Screen.width - 200, Screen.height - 200, 200f, 64f), connections.Length.ToString());
        }
    }
Пример #18
0
    public void MenuSetupSession(MenuStack menuStack)
    {
        bool isSignedInPSN = User.IsSignedInPSN;
        bool inSession     = Matching.InSession;
        bool sessionIsBusy = Matching.SessionIsBusy;

        menuSession.Update();
        if (menuSession.AddItem("Create & Join Session", isSignedInPSN && !inSession && !sessionIsBusy))
        {
            OnScreenLog.Add("Creating session...");
            Matching.ClearSessionAttributes();
            Matching.SessionAttribute sessionAttribute = new Matching.SessionAttribute();
            sessionAttribute.name     = "APP_VERSION";
            sessionAttribute.intValue = appVersion;
            Matching.AddSessionAttribute(sessionAttribute);
            sessionAttribute          = new Matching.SessionAttribute();
            sessionAttribute.name     = "PASSWORD";
            sessionAttribute.binValue = "NO";
            Matching.AddSessionAttribute(sessionAttribute);
            sessionAttribute          = new Matching.SessionAttribute();
            sessionAttribute.name     = "CAR_TYPE";
            sessionAttribute.binValue = "CATMOB";
            Matching.AddSessionAttribute(sessionAttribute);
            sessionAttribute          = new Matching.SessionAttribute();
            sessionAttribute.name     = "LEVEL";
            sessionAttribute.intValue = 1;
            Matching.AddSessionAttribute(sessionAttribute);
            sessionAttribute          = new Matching.SessionAttribute();
            sessionAttribute.name     = "RACE_TRACK";
            sessionAttribute.binValue = "TURKEY";
            Matching.AddSessionAttribute(sessionAttribute);
            sessionAttribute          = new Matching.SessionAttribute();
            sessionAttribute.name     = "GAME_DETAILS";
            sessionAttribute.intValue = gameDetails;
            Matching.AddSessionAttribute(sessionAttribute);
            sessionAttribute          = new Matching.SessionAttribute();
            sessionAttribute.name     = "TEST_BIN_SEARCH";
            sessionAttribute.binValue = "BIN_VALUE";
            Matching.AddSessionAttribute(sessionAttribute);
            string name             = "Test Session";
            int    serverID         = 0;
            int    worldID          = 0;
            int    numSlots         = 8;
            string empty            = string.Empty;
            string ps4SessionStatus = "Toolkit Sample Session";
            ErrorHandler(Matching.CreateSession(name, serverID, worldID, numSlots, empty, SignallingType, Matching.EnumSessionType.SESSION_TYPE_PUBLIC, ps4SessionStatus));
        }
        if (menuSession.AddItem("Create & Join Private Session", isSignedInPSN && !inSession && !sessionIsBusy))
        {
            OnScreenLog.Add("Creating private session... password is required");
            Matching.ClearSessionAttributes();
            Matching.SessionAttribute sessionAttribute2 = new Matching.SessionAttribute();
            sessionAttribute2.name     = "APP_VERSION";
            sessionAttribute2.intValue = appVersion;
            Matching.AddSessionAttribute(sessionAttribute2);
            sessionAttribute2          = new Matching.SessionAttribute();
            sessionAttribute2.name     = "PASSWORD";
            sessionAttribute2.binValue = "YES";
            Matching.AddSessionAttribute(sessionAttribute2);
            sessionAttribute2          = new Matching.SessionAttribute();
            sessionAttribute2.name     = "CAR_TYPE";
            sessionAttribute2.binValue = "CATMOB";
            Matching.AddSessionAttribute(sessionAttribute2);
            sessionAttribute2          = new Matching.SessionAttribute();
            sessionAttribute2.name     = "LEVEL";
            sessionAttribute2.intValue = 1;
            Matching.AddSessionAttribute(sessionAttribute2);
            sessionAttribute2          = new Matching.SessionAttribute();
            sessionAttribute2.name     = "RACE_TRACK";
            sessionAttribute2.binValue = "TURKEY";
            Matching.AddSessionAttribute(sessionAttribute2);
            sessionAttribute2          = new Matching.SessionAttribute();
            sessionAttribute2.name     = "GAME_DETAILS";
            sessionAttribute2.intValue = gameDetails;
            Matching.AddSessionAttribute(sessionAttribute2);
            sessionAttribute2          = new Matching.SessionAttribute();
            sessionAttribute2.name     = "TEST_BIN_SEARCH";
            sessionAttribute2.binValue = "BIN_VALUE";
            Matching.AddSessionAttribute(sessionAttribute2);
            string name2             = "Test Session";
            int    serverID2         = 0;
            int    worldID2          = 0;
            int    numSlots2         = 8;
            string password          = sessionPassword;
            string ps4SessionStatus2 = "Toolkit Sample Session";
            ErrorHandler(Matching.CreateSession(name2, serverID2, worldID2, numSlots2, password, SignallingType | Matching.FlagSessionCreate.CREATE_PASSWORD_SESSION, Matching.EnumSessionType.SESSION_TYPE_PRIVATE, ps4SessionStatus2));
        }
        if (menuSession.AddItem("Create & Join Friend Session", isSignedInPSN && !inSession && !sessionIsBusy))
        {
            OnScreenLog.Add("Creating Friend session...");
            Matching.ClearSessionAttributes();
            Matching.SessionAttribute sessionAttribute3 = new Matching.SessionAttribute();
            sessionAttribute3.name     = "APP_VERSION";
            sessionAttribute3.intValue = appVersion;
            Matching.AddSessionAttribute(sessionAttribute3);
            sessionAttribute3          = new Matching.SessionAttribute();
            sessionAttribute3.name     = "PASSWORD";
            sessionAttribute3.binValue = "YES";
            Matching.AddSessionAttribute(sessionAttribute3);
            sessionAttribute3          = new Matching.SessionAttribute();
            sessionAttribute3.name     = "CAR_TYPE";
            sessionAttribute3.binValue = "CATMOB";
            Matching.AddSessionAttribute(sessionAttribute3);
            sessionAttribute3          = new Matching.SessionAttribute();
            sessionAttribute3.name     = "LEVEL";
            sessionAttribute3.intValue = 1;
            Matching.AddSessionAttribute(sessionAttribute3);
            sessionAttribute3          = new Matching.SessionAttribute();
            sessionAttribute3.name     = "RACE_TRACK";
            sessionAttribute3.binValue = "TURKEY";
            Matching.AddSessionAttribute(sessionAttribute3);
            sessionAttribute3          = new Matching.SessionAttribute();
            sessionAttribute3.name     = "GAME_DETAILS";
            sessionAttribute3.intValue = gameDetails;
            Matching.AddSessionAttribute(sessionAttribute3);
            sessionAttribute3          = new Matching.SessionAttribute();
            sessionAttribute3.name     = "TEST_BIN_SEARCH";
            sessionAttribute3.binValue = "BIN_VALUE";
            Matching.AddSessionAttribute(sessionAttribute3);
            string name3             = "Test Session";
            int    serverID3         = 0;
            int    worldID3          = 0;
            int    numSlots3         = 8;
            int    friendSlots       = 8;
            string password2         = sessionPassword;
            string ps4SessionStatus3 = "Toolkit Sample Session";
            ErrorHandler(Matching.CreateFriendsSession(name3, serverID3, worldID3, numSlots3, friendSlots, password2, SignallingType | Matching.FlagSessionCreate.CREATE_PASSWORD_SESSION, ps4SessionStatus3));
        }
        if (menuSession.AddItem("Find Sessions", isSignedInPSN && !inSession && !sessionIsBusy))
        {
            OnScreenLog.Add("Finding sessions...");
            Matching.ClearSessionAttributes();
            Matching.SessionAttribute sessionAttribute4 = new Matching.SessionAttribute();
            sessionAttribute4.name           = "APP_VERSION";
            sessionAttribute4.intValue       = appVersion;
            sessionAttribute4.searchOperator = Matching.EnumSearchOperators.MATCHING_OPERATOR_EQ;
            Matching.AddSessionAttribute(sessionAttribute4);
            int serverID4 = 0;
            int worldID4  = 0;
            ErrorHandler(Matching.FindSession(serverID4, worldID4));
        }
        if (menuSession.AddItem("Find Sessions (bin search)", isSignedInPSN && !inSession && !sessionIsBusy))
        {
            OnScreenLog.Add("Finding sessions...");
            Matching.ClearSessionAttributes();
            Matching.SessionAttribute sessionAttribute5 = new Matching.SessionAttribute();
            sessionAttribute5.name           = "TEST_BIN_SEARCH";
            sessionAttribute5.binValue       = "BIN_VALUE";
            sessionAttribute5.searchOperator = Matching.EnumSearchOperators.MATCHING_OPERATOR_EQ;
            Matching.AddSessionAttribute(sessionAttribute5);
            int serverID5 = 0;
            int worldID5  = 0;
            ErrorHandler(Matching.FindSession(serverID5, worldID5, Matching.FlagSessionSearch.SEARCH_REGIONAL_SESSIONS));
        }
        if (menuSession.AddItem("Find Friend Sessions", isSignedInPSN && !inSession && !sessionIsBusy))
        {
            OnScreenLog.Add("Finding friend sessions...");
            Matching.ClearSessionAttributes();
            Matching.SessionAttribute sessionAttribute6 = new Matching.SessionAttribute();
            sessionAttribute6.name           = "APP_VERSION";
            sessionAttribute6.intValue       = appVersion;
            sessionAttribute6.searchOperator = Matching.EnumSearchOperators.MATCHING_OPERATOR_EQ;
            Matching.AddSessionAttribute(sessionAttribute6);
            int serverID6 = 0;
            int worldID6  = 0;
            ErrorHandler(Matching.FindSession(serverID6, worldID6, Matching.FlagSessionSearch.SEARCH_FRIENDS_SESSIONS));
        }
        if (menuSession.AddItem("Find Regional Sessions", isSignedInPSN && !inSession && !sessionIsBusy))
        {
            OnScreenLog.Add("Finding friend sessions...");
            Matching.ClearSessionAttributes();
            Matching.SessionAttribute sessionAttribute7 = new Matching.SessionAttribute();
            sessionAttribute7.name           = "APP_VERSION";
            sessionAttribute7.intValue       = appVersion;
            sessionAttribute7.searchOperator = Matching.EnumSearchOperators.MATCHING_OPERATOR_EQ;
            Matching.AddSessionAttribute(sessionAttribute7);
            int serverID7 = 0;
            int worldID7  = 0;
            ErrorHandler(Matching.FindSession(serverID7, worldID7, Matching.FlagSessionSearch.SEARCH_REGIONAL_SESSIONS));
        }
        if (menuSession.AddItem("Find Random Sessions", isSignedInPSN && !inSession && !sessionIsBusy))
        {
            OnScreenLog.Add("Finding sessions in a random order...");
            Matching.ClearSessionAttributes();
            Matching.SessionAttribute sessionAttribute8 = new Matching.SessionAttribute();
            sessionAttribute8.name           = "APP_VERSION";
            sessionAttribute8.intValue       = appVersion;
            sessionAttribute8.searchOperator = Matching.EnumSearchOperators.MATCHING_OPERATOR_EQ;
            Matching.AddSessionAttribute(sessionAttribute8);
            int serverID8 = 0;
            int worldID8  = 0;
            ErrorHandler(Matching.FindSession(serverID8, worldID8, Matching.FlagSessionSearch.SEARCH_RANDOM_SESSIONS));
        }
        bool flag = availableSessions != null && availableSessions.Length > 0;

        if (menuSession.AddItem("Join 1st Found Session", isSignedInPSN && flag && !inSession && !sessionIsBusy))
        {
            OnScreenLog.Add("Joining PSN session: " + availableSessions[0].sessionInfo.sessionName);
            Matching.ClearSessionAttributes();
            Matching.SessionAttribute sessionAttribute9 = new Matching.SessionAttribute();
            sessionAttribute9.name     = "CAR_TYPE";
            sessionAttribute9.binValue = "CATMOB";
            Matching.AddSessionAttribute(sessionAttribute9);
            ErrorHandler(Matching.JoinSession(availableSessions[0].sessionInfo.sessionID, sessionPassword));
        }
        if (menuSession.AddBackIndex("Back"))
        {
            menuStack.PopMenu();
        }
    }
    public void MenuInSession(MenuStack menuStack)
    {
        bool       isSignedInPSN = User.get_IsSignedInPSN();
        bool       inSession     = Matching.get_InSession();
        bool       sessionIsBusy = Matching.get_SessionIsBusy();
        bool       isHost        = Matching.get_IsHost();
        MenuLayout menuLayout    = (!isHost) ? this.menuInSessionClient : this.menuInSessionHosting;

        menuLayout.Update();
        if (isHost && menuLayout.AddItem("Modify Session", isSignedInPSN && inSession && !sessionIsBusy))
        {
            OnScreenLog.Add("Modifying session...");
            Matching.ClearModifySessionAttributes();
            this.gameDetails += 100;
            Matching.ModifySessionAttribute modifySessionAttribute = new Matching.ModifySessionAttribute();
            modifySessionAttribute.set_name("GAME_DETAILS");
            modifySessionAttribute.intValue = this.gameDetails;
            Matching.AddModifySessionAttribute(modifySessionAttribute);
            this.ErrorHandler(Matching.ModifySession(8));
        }
        if (menuLayout.AddItem("Modify Member Attribute", isSignedInPSN && inSession && !sessionIsBusy))
        {
            OnScreenLog.Add("Modifying Member Attribute...");
            Matching.ClearModifySessionAttributes();
            Matching.ModifySessionAttribute modifySessionAttribute2 = new Matching.ModifySessionAttribute();
            modifySessionAttribute2.set_name("CAR_TYPE");
            this.cartype++;
            if (this.cartype > 3)
            {
                this.cartype = 0;
            }
            switch (this.cartype)
            {
            case 0:
                modifySessionAttribute2.set_binValue("CATMOB");
                break;

            case 1:
                modifySessionAttribute2.set_binValue("CARTYPE1");
                break;

            case 2:
                modifySessionAttribute2.set_binValue("CARTYPE2");
                break;

            case 3:
                modifySessionAttribute2.set_binValue("CARTYPE3");
                break;
            }
            modifySessionAttribute2.intValue = this.gameDetails;
            Matching.AddModifySessionAttribute(modifySessionAttribute2);
            this.ErrorHandler(Matching.ModifySession(16));
        }
        if (!this.sendingData)
        {
            if (menuLayout.AddItem("Start Sending Data", isSignedInPSN && inSession && !sessionIsBusy))
            {
                this.sendingData = true;
            }
        }
        else if (menuLayout.AddItem("Stop Sending Data", isSignedInPSN && inSession && !sessionIsBusy))
        {
            this.sendingData = false;
        }
        if (menuLayout.AddItem("Leave Session", isSignedInPSN && inSession && !sessionIsBusy))
        {
            OnScreenLog.Add("Leaving session...");
            this.ErrorHandler(Matching.LeaveSession());
        }
        if (menuLayout.AddItem("List session members", isSignedInPSN && inSession && !sessionIsBusy))
        {
            Matching.SessionMemberInfo[] members = Matching.GetSession().members;
            for (int i = 0; i < members.Length; i++)
            {
                Matching.SessionMemberInfo sessionMemberInfo = members[i];
                string msg = string.Concat(new object[]
                {
                    i,
                    "/memberId:",
                    sessionMemberInfo.memberId,
                    "/memberFlag:",
                    sessionMemberInfo.memberFlag,
                    "/addr:",
                    sessionMemberInfo.addr,
                    "/natType:",
                    sessionMemberInfo.natType,
                    "/port:",
                    sessionMemberInfo.port
                });
                OnScreenLog.Add(msg);
            }
        }
        if (menuLayout.AddItem("Invite Friend", isSignedInPSN && inSession && !sessionIsBusy))
        {
            OnScreenLog.Add("Invite Friend...");
            this.ErrorHandler(Matching.InviteToSession("Invite Test", 8));
        }
        if (menuLayout.AddBackIndex("Back", true))
        {
            menuStack.PopMenu();
        }
        if (Matching.get_IsHost())
        {
            NetworkPlayer[] connections = Network.get_connections();
            GUI.Label(new Rect((float)(Screen.get_width() - 200), (float)(Screen.get_height() - 200), 200f, 64f), connections.Length.ToString());
        }
    }