Esempio n. 1
0
        public override DeepLinker CreateDeepLinker()
        {
            DeepLinker       linker   = base.CreateDeepLinker();
            DeepLinkReceiver receiver = new GameObject(nameof(DeepLinkReceiver)).AddComponent <DeepLinkReceiver>();

            receiver.Linker = linker;
            return(linker);
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes all required modules for the game.
        /// </summary>
        protected virtual void InitializeModules()
        {
            UnityThread.Initialize();

            Dependencies.CacheAs <IGame>(this);

            Dependencies.CacheAs <IPlatformHost>(platformHost = PlatformHost.CreateHost());
            Dependencies.CacheAs <DeepLinker>(deepLinker      = platformHost.CreateDeepLinker());

            Dependencies.CacheAs <IEnvConfiguration>(envConfiguration = new EnvConfiguration(EnvType.Production));

            Dependencies.CacheAs <IModeManager>(modeManager = new ModeManager());

            Dependencies.CacheAs <INotificationBox>(notificationBox = new NotificationBox());

            Dependencies.CacheAs <IGameConfiguration>(gameConfiguration     = new GameConfiguration());
            Dependencies.CacheAs <IMapConfiguration>(mapConfiguration       = new MapConfiguration());
            Dependencies.CacheAs <IMapsetConfiguration>(mapsetConfiguration = new MapsetConfiguration());

            Dependencies.CacheAs <IFontManager>(fontManager       = new FontManager());
            Dependencies.CacheAs <IAtlas <Sprite> >(spriteAtlas   = new ResourceSpriteAtlas());
            Dependencies.CacheAs <IAtlas <AudioClip> >(audioAtlas = new ResourceAudioAtlas());

            Dependencies.CacheAs <IMusicCacher>(musicCacher           = new MusicCacher());
            Dependencies.CacheAs <IBackgroundCacher>(backgroundCacher = new BackgroundCacher());
            Dependencies.CacheAs <IWebImageCacher>(webImageCacher     = new WebImageCacher());
            Dependencies.CacheAs <IWebMusicCacher>(webMusicCacher     = new WebMusicCacher());

            Dependencies.CacheAs <IMusicController>(musicController = MusicController.Create());

            Dependencies.CacheAs <ISoundTable>(soundTable = new DefaultSoundTable(audioAtlas));
            Dependencies.CacheAs <ISoundPool>(soundPool   = new SoundPool(soundTable));

            Dependencies.CacheAs <IMapsetStore>(mapsetStore   = new MapsetStore(modeManager));
            Dependencies.CacheAs <IMapSelection>(mapSelection = new MapSelection(musicCacher, backgroundCacher, gameConfiguration, mapsetConfiguration, mapConfiguration));
            Dependencies.CacheAs <IMapManager>(mapManager     = new MapManager(mapsetStore, notificationBox, mapSelection));
            Dependencies.CacheAs <IMetronome>(metronome       = new Metronome()
            {
                AudioController = musicController
            });
            Dependencies.CacheAs <IMusicPlaylist>(musicPlaylist = new MusicPlaylist());

            Dependencies.CacheAs <IDownloadStore>(downloadStore = new DownloadStore());
            Dependencies.CacheAs <IApi>(api = new Api(envConfiguration, notificationBox, deepLinker));

            Dependencies.CacheAs <IUserManager>(userManager = new UserManager(api, Dependencies));
            Dependencies.CacheAs <IRecordStore>(recordStore = new RecordStore());

            Dependencies.CacheAs <IRootMain>(rootMain                 = RootMain.Create(Dependencies));
            Dependencies.CacheAs <IRoot3D>(root3D                     = Root3D.Create(Dependencies));
            Dependencies.CacheAs <IColorPreset>(colorPreset           = new ColorPreset());
            Dependencies.CacheAs <IAnimePreset>(animePreset           = new AnimePreset());
            Dependencies.CacheAs <IScreenNavigator>(screenNavigator   = new ScreenNavigator(rootMain));
            Dependencies.CacheAs <IOverlayNavigator>(overlayNavigator = new OverlayNavigator(rootMain));
            Dependencies.CacheAs <IDropdownProvider>(dropdownProvider = new DropdownProvider(rootMain));

            Dependencies.CacheAs <ITemporaryStore>(temporaryStore = new TemporaryStore());
        }
Esempio n. 3
0
        public void TestRemoveLink()
        {
            DeepLinker linker = new DeepLinker();

            linker.LinkPath("api", (link) => { });
            Assert.IsTrue(linker.IsLinked("api"));

            linker.RemoveLink("/api///");
            Assert.IsFalse(linker.IsLinked("api"));
        }
Esempio n. 4
0
        public void TestEmit()
        {
            int calledCount = 0;

            DeepLinker linker = new DeepLinker();

            linker.LinkPath("api", (link) =>
            {
                calledCount++;
                Assert.AreEqual("api", link.Path);
                Assert.AreEqual(0, link.Parameters.Count);
            });
            linker.Emit("api");
            Assert.AreEqual(1, calledCount);
            linker.Emit("api/a");
            linker.Emit("api/s");
            linker.Emit("a/api");
            linker.Emit("nb/api");
            Assert.AreEqual(1, calledCount);

            linker = new DeepLinker();
            linker.LinkPath("api/lolz/", (link) =>
            {
                calledCount++;
                Assert.AreEqual("api/lolz", link.Path);
                Assert.AreEqual(0, link.Parameters.Count);
            });
            linker.Emit("api/lolz");
            Assert.AreEqual(2, calledCount);

            linker = new DeepLinker();
            linker.LinkPath("api", (link) =>
            {
                calledCount++;
                Assert.AreEqual("api", link.Path);
                Assert.AreEqual(1, link.Parameters.Count);
                Assert.IsTrue(link.Parameters.ContainsKey("asdf"));
                Assert.AreEqual("fdsa", link.Parameters["asdf"]);
            });
            linker.Emit("api?asdf=fdsa");
            Assert.AreEqual(3, calledCount);

            linker = new DeepLinker();
            linker.LinkPath("api", (link) =>
            {
                calledCount++;
                Assert.AreEqual("api", link.Path);
                Assert.AreEqual(1, link.Parameters.Count);
                Assert.IsTrue(link.Parameters.ContainsKey("asd[f]"));
                Assert.AreEqual("fdsa", link.Parameters["asd[f]"]);
            });
            linker.Emit("api?asd%5Bf%5D=fdsa");
            Assert.AreEqual(4, calledCount);
        }
Esempio n. 5
0
        public Api(IEnvConfiguration envConfig, NotificationBox notificationBox, DeepLinker deepLinker)
        {
            if (envConfig == null)
            {
                throw new ArgumentNullException(nameof(envConfig));
            }

            this.envConfig       = envConfig;
            this.notificationBox = notificationBox;

            this.providers = new Dictionary <ApiProviderType, IApiProvider>()
            {
                { ApiProviderType.Osu, new OsuApiProvider(this) },
                { ApiProviderType.Bloodcat, new BloodcatApiProvider(this) },
            };

            if (deepLinker != null)
            {
                deepLinker.LinkPath("api", OnDeepLinkApi);
            }
        }
Esempio n. 6
0
        public void TestLink()
        {
            DeepLinker.HookHandler handler = new DeepLinker.HookHandler((link) => {});

            DeepLinker linker = new DeepLinker();

            linker.LinkPath("api/", handler);
            Assert.IsTrue(linker.IsLinked("api"));
            Assert.IsTrue(linker.IsLinked("api/"));
            Assert.IsTrue(linker.IsLinked("/api"));

            linker = new DeepLinker();
            linker.LinkPath("/api", handler);
            Assert.IsTrue(linker.IsLinked("api"));
            Assert.IsTrue(linker.IsLinked("api/"));
            Assert.IsTrue(linker.IsLinked("/api"));

            linker = new DeepLinker();
            linker.LinkPath(null, handler);
            Assert.IsFalse(linker.IsLinked("api"));

            linker = new DeepLinker();
            linker.LinkPath("api", null);
            Assert.IsFalse(linker.IsLinked("api"));

            linker = new DeepLinker();
            linker.LinkPath("api?ab=ba", handler);
            Assert.IsTrue(linker.IsLinked("api"));

            linker = new DeepLinker();
            linker.LinkPath("api/?ab=ba", handler);
            Assert.IsTrue(linker.IsLinked("api"));

            linker = new DeepLinker();
            linker.LinkPath("pbtest://api", handler);
            Assert.IsTrue(linker.IsLinked("api"));
        }