Ejemplo n.º 1
0
    IEnumerator GenerateWorkshopThumbnails(List <WorkshopItem> items)
    {
        foreach (WorkshopItem item in items)
        {
            string[] tags = item.SteamNative.m_details.m_rgchTags.Split(',');
            if (tags.Contains(SteamUtil.GameBuilderTags.Asset.ToString()))
            {
                continue;
            }
            GameThumbnail gameThumbnail = Instantiate(gameThumbnailPrefab).GetComponent <GameThumbnail>();
            if (item.PreviewImageURL != null && item.PreviewImageURL.Length > 0)
            {
                gameThumbnail.SetThumbnailUrl(item.PreviewImageURL);
            }
            else
            {
                gameThumbnail.SetThumbnail(placeholderThumbnailTexture);
            }

            gameThumbnail.SetGameSource(GameDetail.GameSource.Workshop);
            gameThumbnail.SetName(item.Name);
            gameThumbnail.OnClick        = () => OpenWorkshopEntry(gameThumbnail, item);
            gameThumbnail.GetWriteTime   = () => GetWorkshopWriteTime(item);
            gameThumbnail.GetDescription = () => { return(item.Description); };
            AddThumbnail(gameThumbnail, WORKSHOP);
            yield return(null);
        }
    }
Ejemplo n.º 2
0
    void OpenLibraryEntry(GameThumbnail gameThumbnail, GameBundleLibrary.Entry entry)
    {
#if UNITY_EDITOR
        // Dev only for deleting
        if (Input.GetKey(KeyCode.LeftControl) && Input.GetKey(KeyCode.LeftShift) && Input.GetKey(KeyCode.LeftAlt))
        {
            UnityEngine.Windows.Directory.Delete(gameBundleLibrary.GetBundleDirectory(entry.id));
            return;
        }
#endif

        if (Input.GetKey(KeyCode.LeftControl))
        {
            Application.OpenURL($"file://{gameBundleLibrary.GetBundleDirectory(entry.id)}");
            return;
        }

        SelectThumbnail(gameThumbnail, (rect) =>
        {
            gameDetail.FitTo(rect);
            gameDetail.OpenLocal(entry);
        });

        ScrollToThumbnail(gameThumbnail);
    }
Ejemplo n.º 3
0
        /// <summary>
        /// called by a child GUI component to launch a game
        /// </summary>
        /// <param name="g">game to launch</param>
        public void ActionLaunchGame(GardenItem g, GameThumbnail thumb)
        {
            if (g.IsInstalled)
            {
                if (g.IsPlayable)
                {
                    // if installed, then launch it if possible
                    if ((launcher == null || launcher.IsFinished() == true) &&
                        (launchGameThread == null || launchGameThread.IsFinished()))
                    {
                        loadingDisplay.SetLoadingGame(g, thumb);
                        // set state of game to 'game playing state'
                        TreeRoot.SetNextState(new StatePlayingGame());

                        launcher         = new GameLauncherTask(g);
                        launchGameThread = new ThreadedTask(launcher);
                        launchGameThread.TaskSuccessEvent += new TaskEventHandler(taskThread_TaskFinishedEvent);
                        launchGameThread.TaskFailEvent    += new TaskEventHandler(taskThread_TaskFinishedEvent);
                        launchGameThread.Start();
                    }
                }
                if (g.IsMusic)
                {
                    music.Play(g.ExeFilepath, 0.5f, 0f);   // TODO vary audio volume per track.
                }
            }
        }
Ejemplo n.º 4
0
    IEnumerator CreateMyLibraryThumbnails()
    {
        foreach (GameBundleLibrary.Entry entry in gameBundleLibrary.Enumerate())
        {
            GameThumbnail       gameThumbnail = Instantiate(gameThumbnailPrefab).GetComponent <GameThumbnail>();
            GameBundle.Metadata metadata      = entry.bundle.GetMetadata();

            Texture2D texture = entry.bundle.GetThumbnail();
            if (texture != null)
            {
                gameThumbnail.SetThumbnail(texture);
            }
            else
            {
                gameThumbnail.SetThumbnail(placeholderThumbnailTexture);
            }

            if (AutoSaveController.IsAutosave(entry))
            {
                gameThumbnail.SetGameSource(GameDetail.GameSource.Autosave);
            }
            else
            {
                gameThumbnail.SetGameSource(GameDetail.GameSource.Local);
            }
            gameThumbnail.SetName(metadata.name);
            gameThumbnail.OnClick        = () => OpenLibraryEntry(gameThumbnail, entry);
            gameThumbnail.GetWriteTime   = () => GetBundleWriteTime(entry.id);
            gameThumbnail.GetDescription = () => { return(metadata.description); };
            AddThumbnail(gameThumbnail, AutoSaveController.IsAutosave(entry) ? AUTOSAVES : SAVED);
            yield return(null);
        }
    }
Ejemplo n.º 5
0
        public void ActionLaunchWebsite(GardenItem g, GameThumbnail thumb)
        {
            ITask t = new ThreadedTask(new SiteLauncherTask(g));

            t.Start();
            loadingDisplay.SetLoadingGame(g, thumb);
            TreeRoot.SetNextState(new StatePlayingGame(2f, false));
        }
Ejemplo n.º 6
0
 void OpenWorkshopEntry(GameThumbnail gameThumbnail, WorkshopItem item)
 {
     SelectThumbnail(gameThumbnail, (rect) =>
     {
         gameDetail.FitTo(rect);
         gameDetail.OpenWorkshop(gameThumbnail.GetTexture(), item);
     });
 }
Ejemplo n.º 7
0
    private void ScrollToThumbnail(GameThumbnail gameThumbnail)
    {
        Vector2 thumbnailCoordinates = Util.FindRectTransformScreenPoint(gameThumbnail.GetComponent <RectTransform>());

        RectTransformUtility.ScreenPointToLocalPointInRectangle(libraryViewport, thumbnailCoordinates, null, out Vector2 viewportPoint);

        if (viewportPoint.y < libraryViewport.offsetMax.y || viewportPoint.y > libraryViewport.offsetMin.y)
        {
            RectTransformUtility.ScreenPointToLocalPointInRectangle(libraryContainer, thumbnailCoordinates, null, out Vector2 localPoint);
            libraryScrollRect.verticalNormalizedPosition = Mathf.Clamp01(1 - Mathf.Abs(localPoint.y / libraryContainer.rect.height));
        }
    }
Ejemplo n.º 8
0
 void AddTutorialThumbnail()
 {
     tutorialThumbnail = Instantiate(gameThumbnailPrefab).GetComponent <GameThumbnail>();
     tutorialThumbnail.SetThumbnail(tutorialGameTexture);
     tutorialThumbnail.SetGameSource(GameDetail.GameSource.Local);
     tutorialThumbnail.SetName("Tutorial");
     tutorialThumbnail.OnClick        = OpenTutorial;
     tutorialThumbnail.GetWriteTime   = () => { return(System.DateTime.Today); };
     tutorialThumbnail.GetDescription = () => { return(""); };
     tutorialThumbnail.SetSortPriorityHint(50);
     AddThumbnail(tutorialThumbnail);
 }
Ejemplo n.º 9
0
 void AddNewThumbnail()
 {
     newThumbnail = Instantiate(gameThumbnailPrefab).GetComponent <GameThumbnail>();
     newThumbnail.SetThumbnail(newGameTexture);
     newThumbnail.SetGameSource(GameDetail.GameSource.Local);
     newThumbnail.SetName("New Game");
     newThumbnail.OnClick        = OpenNew;
     newThumbnail.GetWriteTime   = () => { return(System.DateTime.Today); };
     newThumbnail.GetDescription = () => { return(""); };
     newThumbnail.SetSortPriorityHint(100);
     AddThumbnail(newThumbnail);
 }
Ejemplo n.º 10
0
    private void MakeSampleGameThumbnail(LocalSampleGames.GameInfo gameInfo, int sortPriorityHint)
    {
        GameThumbnail thumb = Instantiate(gameThumbnailPrefab).GetComponent <GameThumbnail>();

        thumb.SetThumbnailUrl("file://" + gameInfo.GetThumbnailFilePath());
        thumb.SetGameSource(GameDetail.GameSource.Local);
        thumb.SetName(gameInfo.title);
        thumb.OnClick        = () => OpenSampleGame(thumb, gameInfo);
        thumb.GetWriteTime   = () => { return(System.DateTime.Today); };
        thumb.GetDescription = () => { return(gameInfo.description); };
        thumb.SetSortPriorityHint(sortPriorityHint);
        AddThumbnail(thumb);
    }
Ejemplo n.º 11
0
    void AddNewGameThumbnail()
    {
        string gameName = "New game";

        GameThumbnail thumbnail = Instantiate(gameThumbnailPrefab).GetComponent <GameThumbnail>();

        thumbnail.SetThumbnail(newGameTexture);
        thumbnail.SetGameSource(GameDetail.GameSource.Local);
        thumbnail.SetName(gameName);
        thumbnail.OnClick        = OpenNew;
        thumbnail.GetWriteTime   = () => { return(System.DateTime.Today); }; // Not relevant
        thumbnail.GetDescription = () => { return("Start a new multiplayer game"); };
        thumbnail.GetPlayerCount = () => { return(0); };
        AddThumbnail(thumbnail);
    }
Ejemplo n.º 12
0
 void OpenSampleGame(GameThumbnail thumb, LocalSampleGames.GameInfo gameInfo)
 {
     SelectThumbnail(thumb, (rect) =>
     {
         gameDetail.FitTo(rect);
         string desc = "<b>Example game: " + gameInfo.title + "</b>\n" + gameInfo.description;
         gameDetail.OpenSpecial(desc, thumb.GetTexture(), playOpts =>
         {
             loadingScreen.ShowAndDo(() =>
             {
                 var gameOpts = new GameBuilderApplication.GameOptions {
                     playOptions = playOpts
                 };
                 loadingScreen.ShowAndDo(() => sceneController.RestartAndLoad(gameInfo.GetVoosFilePath(), gameOpts));
             });
         }, true);
     });
 }
Ejemplo n.º 13
0
    void OnWorkshopListLoaded(WorkshopItemListEventArgs args, ItemListData data)
    {
        gettingItemList = false;

        if (args.IsError)
        {
            Debug.Log($"Sorry, encountered an error: {args.ErrorMessage}");
            return;
        }

        if (!itemListData.Equals(data))
        {
            Invoke("CreateSteamThumbnails", .1f);
            return;
        }

        pageCount = args.ItemList.PagesItems;

        workingFeedback.SetActive(false);

        if (args.ItemList.Items.Count == 0)
        {
            noResultsFeedback.SetActive(true);
        }

        foreach (WorkshopItem item in args.ItemList.Items)
        {
            GameThumbnail gameThumbnail = Instantiate(gameThumbnailPrefab).GetComponent <GameThumbnail>();
            if (item.PreviewImageURL != null && item.PreviewImageURL.Length > 0)
            {
                gameThumbnail.SetThumbnailUrl(item.PreviewImageURL);
            }
            else
            {
                gameThumbnail.SetThumbnail(placeholderThumbnailTexture);
            }

            gameThumbnail.SetGameSource(GameDetail.GameSource.Workshop);
            gameThumbnail.SetName(item.Name);
            gameThumbnail.OnClick        = () => OpenWorkshopEntry(gameThumbnail, item);
            gameThumbnail.GetDescription = () => { return(item.Description); };
            AddThumbnail(gameThumbnail);
        }
    }
Ejemplo n.º 14
0
 public void SetGameThumbnail(string gameName, byte[] thumbnailBytes)
 {
     using (var gameRepository = repositoryFactory.GetRepository <Game>())
         using (var gameThumbnailRepository = repositoryFactory.GetRepository <GameThumbnail>())
         {
             var game = gameRepository.Get(new Game {
                 Name = gameName
             });
             if (game == null)
             {
                 throw new ArgumentException($"Unrecognised game name: {gameName}", nameof(gameName));
             }
             var gameThumbnail = new GameThumbnail {
                 GameName = gameName
             };
             gameThumbnail.SetThumbnailBytes(thumbnailBytes);
             gameThumbnailRepository.Put(gameThumbnail);
         }
 }
Ejemplo n.º 15
0
    void ShowRoomDetails(GameThumbnail newThumbnail, string roomCode)
    {
        string detailCopy = $"<b>{newThumbnail.GetName()}</b> - {newThumbnail.GetPlayerCount()} player(s)";

        SelectThumbnail(newThumbnail, (rect) =>
        {
            gameDetail.FitTo(rect);
            gameDetail.OpenSpecial(detailCopy, newThumbnail.GetTexture(), playOpts =>
            {
                // TODO loading screen here?
                scenes.LoadMainSceneAsync(new GameBuilderApplication.GameOptions
                {
                    playOptions = new GameBuilderApplication.PlayOptions {
                        isMultiplayer = true
                    },
                    joinCode = roomCode
                });
            }, true);
        });
    }
Ejemplo n.º 16
0
    void AddRoomThumbnail(RoomInfo room)
    {
#if USE_PUN
        string    gameName  = "<no name>";
        Texture2D tnTexture = spoofGameTexture;

        if (room.CustomProperties.ContainsKey(NetworkingController.GameDisplayNameRoomProperty))
        {
            gameName = (string)room.CustomProperties[NetworkingController.GameDisplayNameRoomProperty];
        }

        if (room.CustomProperties.ContainsKey(NetworkingController.ThumbnailZippedJpegRoomProperty))
        {
            try
            {
                byte[] tnBytes = (byte[])room.CustomProperties[NetworkingController.ThumbnailZippedJpegRoomProperty];
                if (tnBytes != null)
                {
                    tnTexture = Util.ZippedJpegToTexture2D(tnBytes);
                }
            }
            catch (System.Exception)
            {
                // Wah wah.
            }
        }

        GameThumbnail thumbnail = Instantiate(gameThumbnailPrefab).GetComponent <GameThumbnail>();
        thumbnail.SetThumbnail(tnTexture);
        thumbnail.SetGameSource(GameDetail.GameSource.Multiplayer);
        thumbnail.SetName(gameName);
        thumbnail.OnClick        = () => ShowRoomDetails(thumbnail, room.Name);
        thumbnail.GetWriteTime   = () => { return(System.DateTime.Today); }; // Not relevant
        thumbnail.GetDescription = () => { return("no description"); };
        thumbnail.GetPlayerCount = () => { return(room.PlayerCount); };
        AddThumbnail(thumbnail);
#endif
    }