예제 #1
0
        public static int Async_GetThumbnail(
            Guid worldId,
            AsyncThumbnail asyncTexture,
            BokuAsyncCallback callback,
            object param)
        {
            try
            {
                AsyncState state = new AsyncState();
                state.callback = callback;
                state.param    = param;

                Trans.GetThumbnail trans = new Boku.Web.Trans.GetThumbnail(
                    worldId,
                    Callback_GetThumbnail,
                    state);
                IRegister(state.transId);
                if (trans.Send())
                {
                    return(state.transId);
                }
                else
                {
                    return(0);
                }
            }
            catch
            {
                return(0);
            }
        }
예제 #2
0
        public static int Async_GetKoduWebUser(
            string userSecret,
            BokuAsyncCallback callback,
            object param)
        {
            try
            {
                AsyncState state = new AsyncState();
                state.callback = callback;
                state.param    = param;

                Trans.GetKoduWebUser trans = new Boku.Web.Trans.GetKoduWebUser(
                    userSecret,
                    Callback_GetKoduWebUser,
                    state);
                IRegister(state.transId);
                if (trans.Send())
                {
                    return(state.transId);
                }
                else
                {
                    return(0);
                }
            }
            catch
            {
                return(0);
            }
        }
예제 #3
0
 public static int Async_PostLikeByWorldId(
     PostLikeByWorldIdPacket packet,
     BokuAsyncCallback callback,
     object param)
 {
     try
     {
         AsyncState state = new AsyncState();
         state.callback = callback;
         state.param    = param;
         Trans.PostLikeByWorldId trans = new Trans.PostLikeByWorldId(
             Callback_PostLikeByWorldId,
             state,
             packet);
         IRegister(state.transId);
         if (trans.Send())
         {
             return(state.transId);
         }
         else
         {
             return(0);
         }
     }
     catch
     {
         return(0);
     }
 }
예제 #4
0
 /// <summary>
 /// Upload a level to the community server.
 /// </summary>
 /// <param name="packet"></param>
 /// <param name="callback"></param>
 /// <param name="param"></param>
 /// <returns></returns>
 public static int Async_PutWorldData(
     WorldPacket packet,
     BokuAsyncCallback callback,
     object param)
 {
     try
     {
         AsyncState state = new AsyncState();
         state.callback = callback;
         state.param    = param;
         Trans.PutWorldData trans = new Trans.PutWorldData(
             packet,
             Callback_PutWorldData,
             state);
         IRegister(state.transId);
         if (trans.Send())
         {
             return(state.transId);
         }
         else
         {
             return(0);
         }
     }
     catch
     {
         return(0);
     }
 }
예제 #5
0
 /// <summary>
 /// Flag a level as offensive. Behavior differs based on the flagger's admin level:
 ///   User  : A notification is sent to the domain admin DL about the flag.
 ///   Admin : Level is banned, its creator gets a mark, and a notification sent to domain admin DL.
 /// </summary>
 /// <param name="worldId"></param>
 /// <param name="callback"></param>
 /// <param name="param"></param>
 /// <returns></returns>
 public static int Async_FlagLevel(
     Guid worldId,
     bool flag,
     BokuAsyncCallback callback,
     object param)
 {
     try
     {
         AsyncState state = new AsyncState();
         state.callback = callback;
         state.param    = param;
         Trans.FlagLevel trans = new Trans.FlagLevel(
             worldId,
             flag,
             Callback_FlagLevel,
             state);
         IRegister(state.transId);
         if (trans.Send())
         {
             return(state.transId);
         }
         else
         {
             return(0);
         }
     }
     catch
     {
         return(0);
     }
 }
예제 #6
0
 public static int Async_DelWorldData2(
     Guid worldId,
     string pin,
     BokuAsyncCallback callback,
     object param)
 {
     try
     {
         AsyncState state = new AsyncState();
         state.callback = callback;
         state.param    = param;
         Trans.DelWorldData2 trans = new Trans.DelWorldData2(
             worldId,
             pin,
             Callback_DelWorldData2,
             state);
         IRegister(state.transId);
         if (trans.Send())
         {
             return(state.transId);
         }
         else
         {
             return(0);
         }
     }
     catch
     {
         return(0);
     }
 }
예제 #7
0
 /// <summary>
 /// Register the user's vote for a level. Multiple votes from the
 /// same user will not accumulate on a level. A user may change
 /// their vote at any time and it will be reflected.
 /// </summary>
 /// <param name="id"></param>
 /// <param name="vote"></param>
 /// <param name="callback"></param>
 /// <param name="param"></param>
 /// <returns></returns>
 public static int Async_VoteOnLevel(
     Guid id,
     Vote vote,
     BokuAsyncCallback callback,
     object param)
 {
     try
     {
         AsyncState state = new AsyncState();
         state.callback = callback;
         state.param    = param;
         Trans.VoteOnLevel trans = new Trans.VoteOnLevel(
             id,
             vote,
             Callback_VoteOnLevel,
             state);
         IRegister(state.transId);
         if (trans.Send())
         {
             return(state.transId);
         }
         else
         {
             return(0);
         }
     }
     catch
     {
         return(0);
     }
 }
예제 #8
0
 /// <summary>
 /// Queries for the user's admin level.
 /// </summary>
 /// <param name="callback"></param>
 /// <param name="param"></param>
 /// <returns></returns>
 public static int Async_UserLogin(
     BokuAsyncCallback callback,
     object param)
 {
     try
     {
         AsyncState state = new AsyncState();
         state.callback = callback;
         state.param    = param;
         Trans.UserLogin trans = new Trans.UserLogin(Callback_UserLogin, state);
         IRegister(state.transId);
         if (trans.Send())
         {
             return(state.transId);
         }
         else
         {
             return(0);
         }
     }
     catch
     {
         return(0);
     }
 }
예제 #9
0
 /// <summary>
 /// Start getting a page of level metadata from the local system.
 /// </summary>
 /// <param name="genreFilter"></param>
 /// <param name="sortBy"></param>
 /// <param name="sortDir"></param>
 /// <param name="first"></param>
 /// <param name="count"></param>
 /// <param name="callback"></param>
 /// <param name="param"></param>
 /// <returns></returns>
 public bool Async_GetPageOfLevels(
     Genres genreFilter,
     SortBy sortBy,
     SortDirection sortDir,
     int first,
     int count,
     BokuAsyncCallback callback,
     object param)
 {
     return(false);
 }
예제 #10
0
 public static bool Async_Ping(
     BokuAsyncCallback callback,
     object param)
 {
     try
     {
         AsyncState state = new AsyncState();
         state.callback = callback;
         state.param    = param;
         Trans.Ping trans = new Trans.Ping(Callback_Ping, state);
         IRegister(state.transId);
         return(trans.Send());
     }
     catch
     {
         return(false);
     }
 }
        /// <summary>
        /// Start deleting a level from the community server.  You must have adequate permissions or the server will deny your request.
        /// </summary>
        /// <param name="worldId"></param>
        /// <param name="callback"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        public bool StartDeletingLevel(
            Guid worldId,
            Genres bucket,
            BokuAsyncCallback callback,
            object param)
        {
            int index = IndexOf(worldId);

            if (index >= 0)
            {
                LevelMetadata level = allLevels[index];
                allLevels.RemoveAt(index);
                LevelRemoved(level);
            }

            return(0 != Web.Community.Async_DelWorldData2(
                       worldId,
                       Auth.Pin,
                       callback,
                       param));
        }
예제 #12
0
 /// <summary>
 /// Query for a page of level metadata. This function is used by
 /// CommunityLevelBrowser class, but you may call it directly if
 /// you prefer.
 /// </summary>
 /// <param name="genreFilter"></param>
 /// <param name="sortBy"></param>
 /// <param name="sortDir"></param>
 /// <param name="first"></param>
 /// <param name="count"></param>
 /// <param name="callback"></param>
 /// <param name="param"></param>
 /// <returns></returns>
 public static int Async_GetSearchPageOfLevels(
     Genres genreFilter,
     string searchString,
     SortBy sortBy,
     SortDirection sortDir,
     int first,
     int count,
     BokuAsyncCallback callback,
     object param)
 {
     try
     {
         AsyncState state = new AsyncState();
         state.callback = callback;
         state.param    = param;
         Trans.GetSearchWorldPage trans = new Trans.GetSearchWorldPage(
             genreFilter,
             searchString,
             sortBy,
             sortDir,
             first,
             count,
             Callback_GetSearchPageOfLevels,
             state);
         IRegister(state.transId);
         if (trans.Send())
         {
             return(state.transId);
         }
         else
         {
             return(0);
         }
     }
     catch
     {
         return(0);
     }
 }
        /// <summary>
        /// Delete a level from the local system.  Returns false if not yet initialized.
        /// </summary>
        /// <param name="worldId"></param>
        /// <param name="callback"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        public bool StartDeletingLevel(
            Guid worldId,
            Genres bucket,
            BokuAsyncCallback callback,
            object param)
        {
            bool deleted = false;

            bucket &= Genres.SharableBins;

            // Verify exactly one bucket is specified
            Debug.Assert(bucket != 0);
            Debug.Assert((int)bucket == int.MinValue || MyMath.IsPowerOfTwo((int)bucket));

            string worldFilename = null;
            string stuffFilename = null;
            string thumbFilename = null;

            LevelMetadata record = null;

            string stuffPath = String.Empty;
            string worldPath = String.Empty;

            if (0 != (bucket & Genres.MyWorlds))
            {
                stuffPath = BokuGame.MyWorldsStuffPath;
                worldPath = BokuGame.MyWorldsPath;
            }
            else if (0 != (bucket & Genres.Downloads))
            {
                stuffPath = BokuGame.DownloadsStuffPath;
                worldPath = BokuGame.DownloadsPath;
            }


            lock (Synch)
            {
                for (int i = 0; i < allLevels.Count; ++i)
                {
                    record = allLevels[i];

                    if (record.WorldId == worldId && (record.Genres & bucket) == bucket)
                    {
                        worldFilename = Path.Combine(BokuGame.Settings.MediaPath, worldPath + worldId.ToString() + @".Xml");
                        stuffFilename = Path.Combine(BokuGame.Settings.MediaPath, stuffPath + worldId.ToString() + @".Xml");
                        thumbFilename = Path.Combine(BokuGame.Settings.MediaPath, worldPath + worldId.ToString());

                        // Need to get the terrain file before we delete the main file.  BUT the terrain should be
                        // deleted after, otherwise the usage test will find the main file and always thing that
                        // the terrain file is in use.
                        string terrainFilename = null;
                        try
                        {
                            // Only delete terrain file if no longer referenced.
                            XmlWorldData xmlWorldData = XmlWorldData.Load(worldFilename, XnaStorageHelper.Instance);
                            terrainFilename = xmlWorldData.xmlTerrainData2.virtualMapFile;
                        }
                        catch { }

                        // Note : Delete() handles non-existent files just fine.
                        Storage4.Delete(worldFilename);
                        Storage4.Delete(stuffFilename);
                        Storage4.Delete(thumbFilename + @".dds");
                        Storage4.Delete(thumbFilename + @".jpg");
                        Storage4.Delete(thumbFilename + @".png");

                        // Only deletes terrain file if no other world is using it.  (including autosaves)
                        DeleteTerrainFile(terrainFilename);

                        LevelMetadata level = allLevels[i];
                        allLevels.RemoveAt(i);

                        LevelRemoved_Synched(level);

                        deleted = true;

                        break;
                    }
                }
            }

            AsyncResult result = new AsyncResult();

            result.Success = deleted;
            result.Param   = param;
            result.Seconds = 0;

            if (callback != null)
            {
                callback(result);
            }

            return(deleted);
        }