public static Promise <DeployedScene[]> FetchScenes(ICatalyst catalyst, string[] parcels, float cacheMaxAgeSeconds = DEFAULT_SCENES_CACHE_TIME)
    {
        Promise <DeployedScene[]> promise = new Promise <DeployedScene[]>();

        catalyst.GetDeployedScenes(parcels, cacheMaxAgeSeconds)
        .Then(result =>
        {
            promise.Resolve(result.Select(deployment => new DeployedScene(deployment, catalyst.contentUrl)).ToArray());
        })
        .Catch(err => promise.Reject(err));
        return(promise);
    }
    public static Promise <LandWithAccess[]> FetchLandsFromOwner(ICatalyst catalyst, ITheGraph theGraph, string ethAddress, string tld,
                                                                 float cacheMaxAgeSecondsLand = DEFAULT_LAND_CACHE_TIME, float cacheMaxAgeSecondsScenes = DEFAULT_SCENES_CACHE_TIME)
    {
        Promise <LandWithAccess[]> resultPromise = new Promise <LandWithAccess[]>();

        List <Land> lands = new List <Land>();

        Promise <string[]>        getOwnedParcelsPromise   = new Promise <string[]>();
        Promise <DeployedScene[]> getDeployedScenesPromise = new Promise <DeployedScene[]>();

        theGraph.QueryLands(tld, ethAddress, cacheMaxAgeSecondsLand)
        .Then(landsReceived =>
        {
            lands = landsReceived;

            List <string> parcels = new List <string>();
            for (int i = 0; i < landsReceived.Count; i++)
            {
                if (landsReceived[i].parcels == null)
                {
                    continue;
                }

                parcels.AddRange(landsReceived[i].parcels.Select(parcel => $"{parcel.x},{parcel.y}"));
            }

            getOwnedParcelsPromise.Resolve(parcels.ToArray());
        })
        .Catch(err => getOwnedParcelsPromise.Reject(err));

        getOwnedParcelsPromise.Then(parcels =>
        {
            if (parcels.Length > 0)
            {
                FetchScenes(catalyst, parcels, cacheMaxAgeSecondsScenes)
                .Then(scenes => getDeployedScenesPromise.Resolve(scenes))
                .Catch(err => getDeployedScenesPromise.Reject(err));
            }
            else
            {
                getDeployedScenesPromise.Resolve(new DeployedScene[] { });
            }
        })
        .Catch(err => getDeployedScenesPromise.Reject(err));

        getDeployedScenesPromise.Then(scenes =>
        {
            resultPromise.Resolve(GetLands(lands, scenes));
        })
        .Catch(err => resultPromise.Reject(err));

        return(resultPromise);
    }
Beispiel #3
0
        private static IServiceProviders GetServiceProvidersMock()
        {
            IServiceProviders serviceProviders = Substitute.For <IServiceProviders>();

            ITheGraph theGraph = Substitute.For <ITheGraph>();

            serviceProviders.theGraph.Returns(theGraph);

            ICatalyst catalyst = Substitute.For <ICatalyst>();

            serviceProviders.catalyst.Returns(catalyst);

            return(serviceProviders);
        }
Beispiel #4
0
    internal void Initialize(ISectionsController sectionsController,
                             IScenesViewController scenesViewController, ILandController landController, ITheGraph theGraph, ICatalyst catalyst)
    {
        if (isInitialized)
        {
            return;
        }

        isInitialized = true;

        this.sectionsController   = sectionsController;
        this.scenesViewController = scenesViewController;
        this.landsController      = landController;

        this.theGraph = theGraph;
        this.catalyst = catalyst;

        this.unpublishPopupController = new UnpublishPopupController(view.GetUnpublishPopup());

        // set listeners for sections, setup searchbar for section, handle request for opening a new section
        sectionsHandler = new SectionsHandler(sectionsController, scenesViewController, landsController, view.GetSearchBar());
        // handle if main panel or settings panel should be shown in current section
        leftMenuHandler = new LeftMenuHandler(view, sectionsController);
        // handle project scene info on the left menu panel
        leftMenuSettingsViewHandler = new LeftMenuSettingsViewHandler(view.GetSettingsViewReferences(), scenesViewController);
        // handle scene's context menu options
        sceneContextMenuHandler = new SceneContextMenuHandler(view.GetSceneCardViewContextMenu(), sectionsController, scenesViewController, unpublishPopupController);

        SetView();

        sectionsController.OnRequestOpenUrl           += OpenUrl;
        sectionsController.OnRequestGoToCoords        += GoToCoords;
        sectionsController.OnRequestEditSceneAtCoords += OnGoToEditScene;
        scenesViewController.OnJumpInPressed          += GoToCoords;
        scenesViewController.OnRequestOpenUrl         += OpenUrl;
        scenesViewController.OnEditorPressed          += OnGoToEditScene;

        DataStore.i.HUDs.builderProjectsPanelVisible.OnChange             += OnVisibilityChanged;
        DataStore.i.dataStoreBuilderInWorld.unpublishSceneResult.OnChange += OnSceneUnpublished;
    }
Beispiel #5
0
        public void SetUp()
        {
            controller = new BuilderProjectsPanelController();

            sectionsController   = Substitute.For <ISectionsController>();
            scenesViewController = Substitute.For <IScenesViewController>();
            landsController      = Substitute.For <ILandController>();

            ITheGraph theGraph = Substitute.For <ITheGraph>();

            theGraph.Query(Arg.Any <string>(), Arg.Any <string>()).Returns(new Promise <string>());
            theGraph.Query(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <QueryVariablesBase>()).Returns(new Promise <string>());
            theGraph.QueryLands(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <float>()).Returns(new Promise <List <Land> >());

            ICatalyst catalyst = Substitute.For <ICatalyst>();

            catalyst.contentUrl.Returns(string.Empty);
            catalyst.Get(Arg.Any <string>()).Returns(new Promise <string>());
            catalyst.GetEntities(Arg.Any <string>(), Arg.Any <string[]>()).Returns(new Promise <string>());
            catalyst.GetDeployedScenes(Arg.Any <string[]>()).Returns(new Promise <CatalystSceneEntityPayload[]>());

            controller.Initialize(sectionsController, scenesViewController,
                                  landsController, theGraph, catalyst);
        }